diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-05-11 13:22:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-11 13:22:50 +0200 |
commit | 5f3395100973ba86d0c8ba3470e0f7b97baa16db (patch) | |
tree | 01464dd744234324ca66e6ef753877c9810708ce /core/math/vector2.h | |
parent | 063ccaa8688438297b3c6b433175ad2ac47488be (diff) | |
parent | 3877ed73d01bbbf764d0a2756fe6b310ba9dc6f4 (diff) |
Merge pull request #48629 from nekomatata/dynamic-bvh-broadphase-4.0
Dynamic BVH broadphase in 2D & 3D Godot Physics
Diffstat (limited to 'core/math/vector2.h')
-rw-r--r-- | core/math/vector2.h | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/core/math/vector2.h b/core/math/vector2.h index edc6e3a3ef..6abe0f5ea9 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -37,18 +37,26 @@ struct Vector2i; struct Vector2 { + static const int AXIS_COUNT = 2; + enum Axis { AXIS_X, AXIS_Y, }; union { - real_t x = 0; - real_t width; - }; - union { - real_t y = 0; - real_t height; + struct { + union { + real_t x; + real_t width; + }; + union { + real_t y; + real_t height; + }; + }; + + real_t coord[2] = { 0 }; }; _FORCE_INLINE_ real_t &operator[](int p_idx) { @@ -58,6 +66,18 @@ struct Vector2 { return p_idx ? y : x; } + _FORCE_INLINE_ void set_all(real_t p_value) { + x = y = p_value; + } + + _FORCE_INLINE_ int min_axis() const { + return x < y ? 0 : 1; + } + + _FORCE_INLINE_ int max_axis() const { + return x < y ? 1 : 0; + } + void normalize(); Vector2 normalized() const; bool is_normalized() const; |