diff options
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/aabb.h | 8 | ||||
-rw-r--r-- | core/math/expression.cpp | 2 | ||||
-rw-r--r-- | core/math/quat.h | 18 | ||||
-rw-r--r-- | core/math/rect2.h | 17 |
4 files changed, 42 insertions, 3 deletions
diff --git a/core/math/aabb.h b/core/math/aabb.h index 8c08754e1c..45dcbc7f7f 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -107,6 +107,14 @@ public: Variant intersects_segment_bind(const Vector3 &p_from, const Vector3 &p_to) const; Variant intersects_ray_bind(const Vector3 &p_from, const Vector3 &p_dir) const; + _FORCE_INLINE_ void set_end(const Vector3 &p_end) { + size = p_end - position; + } + + _FORCE_INLINE_ Vector3 get_end() const { + return position + size; + } + operator String() const; _FORCE_INLINE_ AABB() {} diff --git a/core/math/expression.cpp b/core/math/expression.cpp index de7d2d2e2c..0e72b153e4 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -1980,7 +1980,7 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression: } bool valid; - r_ret = base.get_named(index->name, &valid); + r_ret = base.get_named(index->name, valid); if (!valid) { r_error_str = vformat(RTR("Invalid named index '%s' for base type %s"), String(index->name), Variant::get_type_name(base.get_type())); return true; diff --git a/core/math/quat.h b/core/math/quat.h index 617bffd908..1ab64a2655 100644 --- a/core/math/quat.h +++ b/core/math/quat.h @@ -40,8 +40,22 @@ class Quat { public: - real_t x = 0, y = 0, z = 0, w = 1; - + union { + struct { + real_t x; + real_t y; + real_t z; + real_t w; + }; + real_t components[4] = { 0, 0, 0, 1.0 }; + }; + + _FORCE_INLINE_ real_t &operator[](int idx) { + return components[idx]; + } + _FORCE_INLINE_ const real_t &operator[](int idx) const { + return components[idx]; + } _FORCE_INLINE_ real_t length_squared() const; bool is_equal_approx(const Quat &p_quat) const; real_t length() const; diff --git a/core/math/rect2.h b/core/math/rect2.h index 5a746aa732..b1fe865ba5 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -306,6 +306,15 @@ struct Rect2 { return false; } } + + _FORCE_INLINE_ void set_end(const Vector2 &p_end) { + size = p_end - position; + } + + _FORCE_INLINE_ Vector2 get_end() const { + return position + size; + } + operator String() const { return String(position) + ", " + String(size); } Rect2() {} @@ -475,6 +484,14 @@ struct Rect2i { return Rect2i(Point2i(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0)), size.abs()); } + _FORCE_INLINE_ void set_end(const Vector2i &p_end) { + size = p_end - position; + } + + _FORCE_INLINE_ Vector2i get_end() const { + return position + size; + } + operator String() const { return String(position) + ", " + String(size); } operator Rect2() const { return Rect2(position, size); } |