2017-03-03 01:30:56 +00:00
|
|
|
#ifndef VECTOR3_H
|
|
|
|
#define VECTOR3_H
|
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
# ifdef _GD_CPP_CORE_API_IMPL
|
|
|
|
# define GD_CPP_CORE_API __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define GD_CPP_CORE_API __declspec(dllimport)
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define GD_CPP_CORE_API
|
|
|
|
#endif
|
|
|
|
|
2017-03-06 07:49:24 +00:00
|
|
|
#include "Defs.hpp"
|
2017-03-03 01:30:56 +00:00
|
|
|
|
2017-03-06 07:49:24 +00:00
|
|
|
#include "String.hpp"
|
2017-03-03 01:30:56 +00:00
|
|
|
|
|
|
|
namespace godot {
|
|
|
|
|
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
struct GD_CPP_CORE_API Vector3 {
|
2017-03-03 01:30:56 +00:00
|
|
|
|
|
|
|
enum Axis {
|
|
|
|
AXIS_X,
|
|
|
|
AXIS_Y,
|
|
|
|
AXIS_Z,
|
|
|
|
};
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
real_t x;
|
|
|
|
real_t y;
|
|
|
|
real_t z;
|
|
|
|
};
|
|
|
|
|
|
|
|
real_t coord[3];
|
|
|
|
};
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
Vector3(real_t x, real_t y, real_t z);
|
|
|
|
|
|
|
|
Vector3();
|
|
|
|
|
|
|
|
Vector3(const Vector3& b);
|
|
|
|
|
|
|
|
const real_t& operator[](int p_axis) const;
|
|
|
|
|
|
|
|
real_t& operator[](int p_axis);
|
|
|
|
|
|
|
|
Vector3& operator+=(const Vector3& p_v);
|
|
|
|
|
|
|
|
Vector3 operator+(const Vector3& p_v) const;
|
|
|
|
|
|
|
|
Vector3& operator-=(const Vector3& p_v);
|
|
|
|
|
|
|
|
Vector3 operator-(const Vector3& p_v) const;
|
|
|
|
|
|
|
|
Vector3& operator*=(const Vector3& p_v);
|
|
|
|
|
|
|
|
Vector3 operator*(const Vector3& p_v) const;
|
|
|
|
|
|
|
|
Vector3& operator/=(const Vector3& p_v);
|
|
|
|
|
|
|
|
Vector3 operator/(const Vector3& p_v) const;
|
|
|
|
|
|
|
|
|
|
|
|
Vector3& operator*=(real_t p_scalar);
|
|
|
|
|
|
|
|
Vector3 operator*(real_t p_scalar) const;
|
|
|
|
|
|
|
|
Vector3& operator/=(real_t p_scalar);
|
|
|
|
|
|
|
|
Vector3 operator/(real_t p_scalar) const;
|
|
|
|
|
|
|
|
Vector3 operator-() const;
|
|
|
|
|
|
|
|
bool operator==(const Vector3& p_v) const;
|
|
|
|
|
|
|
|
bool operator!=(const Vector3& p_v) const;
|
|
|
|
|
|
|
|
bool operator<(const Vector3& p_v) const;
|
|
|
|
|
|
|
|
bool operator<=(const Vector3& p_v) const;
|
|
|
|
|
|
|
|
Vector3 abs() const;
|
|
|
|
|
|
|
|
Vector3 ceil() const;
|
|
|
|
|
|
|
|
Vector3 cross(const Vector3& b) const;
|
|
|
|
|
|
|
|
Vector3 linear_interpolate(const Vector3& p_b,real_t p_t) const;
|
|
|
|
|
|
|
|
Vector3 cubic_interpolate(const Vector3& b, const Vector3& pre_a, const Vector3& post_b, const real_t t) const;
|
|
|
|
|
|
|
|
real_t length() const;
|
|
|
|
|
|
|
|
real_t length_squared() const;
|
|
|
|
|
|
|
|
real_t distance_squared_to(const Vector3& b) const;
|
|
|
|
|
|
|
|
real_t distance_to(const Vector3& b) const;
|
|
|
|
|
|
|
|
real_t dot(const Vector3& b) const;
|
|
|
|
|
|
|
|
Vector3 floor() const;
|
|
|
|
|
|
|
|
Vector3 inverse() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int max_axis() const;
|
|
|
|
|
|
|
|
int min_axis() const;
|
|
|
|
|
|
|
|
void normalize();
|
|
|
|
|
|
|
|
Vector3 normalized() const;
|
|
|
|
|
|
|
|
Vector3 reflect(const Vector3& by) const;
|
|
|
|
|
|
|
|
Vector3 rotated(const Vector3& axis, const real_t phi) const;
|
|
|
|
|
|
|
|
void rotate(const Vector3& p_axis,real_t p_phi);
|
|
|
|
|
|
|
|
Vector3 slide(const Vector3& by) const;
|
|
|
|
|
|
|
|
void snap(real_t p_val);
|
|
|
|
|
|
|
|
Vector3 snapped(const float by);
|
|
|
|
|
|
|
|
operator String() const;
|
2017-03-03 01:30:56 +00:00
|
|
|
};
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
inline Vector3 operator*(real_t p_scalar, const Vector3& p_vec)
|
2017-03-03 01:30:56 +00:00
|
|
|
{
|
|
|
|
return p_vec * p_scalar;
|
|
|
|
}
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
inline Vector3 vec3_cross(const Vector3& p_a, const Vector3& p_b) {
|
2017-03-03 20:04:23 +00:00
|
|
|
|
|
|
|
return p_a.cross(p_b);
|
|
|
|
}
|
|
|
|
|
2017-03-03 01:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // VECTOR3_H
|