diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2022-09-19 17:57:52 -0500 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2022-10-01 21:09:05 -0500 |
commit | d479208a8fe9c3c1b0f2b0acbc94635c8005d9b8 (patch) | |
tree | 664e8c8821e95f96d0bc5d66949239b1955fadfc /include/godot_cpp/variant/vector2.hpp | |
parent | fa4d18f21cfae319b8f16a1604742cfec6022079 (diff) | |
download | redot-cpp-d479208a8fe9c3c1b0f2b0acbc94635c8005d9b8.tar.gz |
Update Vector2/2i/3/3i to match the engine
Diffstat (limited to 'include/godot_cpp/variant/vector2.hpp')
-rw-r--r-- | include/godot_cpp/variant/vector2.hpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/include/godot_cpp/variant/vector2.hpp b/include/godot_cpp/variant/vector2.hpp index d965ced..b210c7d 100644 --- a/include/godot_cpp/variant/vector2.hpp +++ b/include/godot_cpp/variant/vector2.hpp @@ -45,6 +45,8 @@ class Vector2 { friend class Variant; public: + static const int AXIS_COUNT = 2; + enum Axis { AXIS_X, AXIS_Y, @@ -74,10 +76,6 @@ public: return coord[p_idx]; } - _FORCE_INLINE_ void set_all(const real_t p_value) { - x = y = p_value; - } - _FORCE_INLINE_ Vector2::Axis min_axis_index() const { return x < y ? Vector2::AXIS_X : Vector2::AXIS_Y; } @@ -119,6 +117,7 @@ public: _FORCE_INLINE_ Vector2 lerp(const Vector2 &p_to, const real_t p_weight) const; _FORCE_INLINE_ Vector2 slerp(const Vector2 &p_to, const real_t p_weight) const; _FORCE_INLINE_ Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, const real_t p_weight) const; + _FORCE_INLINE_ Vector2 cubic_interpolate_in_time(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, const real_t p_weight, const real_t &p_b_t, const real_t &p_pre_a_t, const real_t &p_post_b_t) const; _FORCE_INLINE_ Vector2 bezier_interpolate(const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, const real_t p_t) const; Vector2 move_toward(const Vector2 &p_to, const real_t p_delta) const; @@ -128,6 +127,7 @@ public: Vector2 reflect(const Vector2 &p_normal) const; bool is_equal_approx(const Vector2 &p_v) const; + bool is_zero_approx() const; Vector2 operator+(const Vector2 &p_v) const; void operator+=(const Vector2 &p_v); @@ -275,6 +275,13 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c return res; } +Vector2 Vector2::cubic_interpolate_in_time(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, const real_t p_weight, const real_t &p_b_t, const real_t &p_pre_a_t, const real_t &p_post_b_t) const { + Vector2 res = *this; + res.x = Math::cubic_interpolate_in_time(res.x, p_b.x, p_pre_a.x, p_post_b.x, p_weight, p_b_t, p_pre_a_t, p_post_b_t); + res.y = Math::cubic_interpolate_in_time(res.y, p_b.y, p_pre_a.y, p_post_b.y, p_weight, p_b_t, p_pre_a_t, p_post_b_t); + return res; +} + Vector2 Vector2::bezier_interpolate(const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, const real_t p_t) const { Vector2 res = *this; |