Fix Vector2 and Vector2i coord access via operator[]
This commit is contained in:
parent
a47a71b87e
commit
134aac5725
1 changed files with 16 additions and 10 deletions
|
@ -60,10 +60,10 @@ struct _NO_DISCARD_CLASS_ Vector2 {
|
||||||
};
|
};
|
||||||
|
|
||||||
_FORCE_INLINE_ real_t &operator[](int p_idx) {
|
_FORCE_INLINE_ real_t &operator[](int p_idx) {
|
||||||
return p_idx ? y : x;
|
return coord[p_idx];
|
||||||
}
|
}
|
||||||
_FORCE_INLINE_ const real_t &operator[](int p_idx) const {
|
_FORCE_INLINE_ const real_t &operator[](int p_idx) const {
|
||||||
return p_idx ? y : x;
|
return coord[p_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
_FORCE_INLINE_ void set_all(real_t p_value) {
|
_FORCE_INLINE_ void set_all(real_t p_value) {
|
||||||
|
@ -276,19 +276,25 @@ struct _NO_DISCARD_CLASS_ Vector2i {
|
||||||
};
|
};
|
||||||
|
|
||||||
union {
|
union {
|
||||||
int x;
|
struct {
|
||||||
int width;
|
union {
|
||||||
};
|
int x;
|
||||||
union {
|
int width;
|
||||||
int y;
|
};
|
||||||
int height;
|
union {
|
||||||
|
int y;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
int coord[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
_FORCE_INLINE_ int &operator[](int p_idx) {
|
_FORCE_INLINE_ int &operator[](int p_idx) {
|
||||||
return p_idx ? y : x;
|
return coord[p_idx];
|
||||||
}
|
}
|
||||||
_FORCE_INLINE_ const int &operator[](int p_idx) const {
|
_FORCE_INLINE_ const int &operator[](int p_idx) const {
|
||||||
return p_idx ? y : x;
|
return coord[p_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i operator+(const Vector2i &p_v) const;
|
Vector2i operator+(const Vector2i &p_v) const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue