summaryrefslogtreecommitdiffstats
path: root/core/math/vector2i.h
diff options
context:
space:
mode:
authorBartłomiej T. Listwon <blistwon@gmail.com>2022-02-09 09:17:17 +0100
committerBartłomiej T. Listwon <blistwon@gmail.com>2022-02-09 09:17:17 +0100
commit51cac0709e9c053b0785fc11cd26cb9cc83c01ae (patch)
tree91474421d12857861a13cdaf794e7524c224044d /core/math/vector2i.h
parentd435c51cda529cc85a945fb909217dd6b0dc531b (diff)
downloadredot-engine-51cac0709e9c053b0785fc11cd26cb9cc83c01ae.tar.gz
Fix Vector2 and Vector2i coord access via operator[]
Diffstat (limited to 'core/math/vector2i.h')
-rw-r--r--core/math/vector2i.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/core/math/vector2i.h b/core/math/vector2i.h
index 707c8c9490..3f5f12d4dd 100644
--- a/core/math/vector2i.h
+++ b/core/math/vector2i.h
@@ -43,19 +43,25 @@ struct _NO_DISCARD_ Vector2i {
};
union {
- int32_t x = 0;
- int32_t width;
- };
- union {
- int32_t y = 0;
- int32_t height;
+ struct {
+ union {
+ int32_t x;
+ int32_t width;
+ };
+ union {
+ int32_t y;
+ int32_t height;
+ };
+ };
+
+ int32_t coord[2] = { 0 };
};
_FORCE_INLINE_ int32_t &operator[](int p_idx) {
- return p_idx ? y : x;
+ return coord[p_idx];
}
_FORCE_INLINE_ const int32_t &operator[](int p_idx) const {
- return p_idx ? y : x;
+ return coord[p_idx];
}
_FORCE_INLINE_ Vector2i::Axis min_axis_index() const {