Add some missing Vector4 methods

This commit is contained in:
kobewi
2022-07-25 22:49:18 +02:00
parent 72b5a4335e
commit 7006f7d693
6 changed files with 75 additions and 6 deletions

View File

@@ -54,11 +54,13 @@ struct _NO_DISCARD_ Vector4 {
real_t components[4] = { 0, 0, 0, 0 };
};
_FORCE_INLINE_ real_t &operator[](int idx) {
return components[idx];
_FORCE_INLINE_ real_t &operator[](const int p_axis) {
DEV_ASSERT((unsigned int)p_axis < 4);
return components[p_axis];
}
_FORCE_INLINE_ const real_t &operator[](int idx) const {
return components[idx];
_FORCE_INLINE_ const real_t &operator[](const int p_axis) const {
DEV_ASSERT((unsigned int)p_axis < 4);
return components[p_axis];
}
_FORCE_INLINE_ real_t length_squared() const;
bool is_equal_approx(const Vector4 &p_vec4) const;
@@ -66,8 +68,13 @@ struct _NO_DISCARD_ Vector4 {
void normalize();
Vector4 normalized() const;
bool is_normalized() const;
Vector4 abs() const;
Vector4 sign() const;
Vector4 floor() const;
Vector4 ceil() const;
Vector4 round() const;
Vector4 lerp(const Vector4 &p_to, const real_t p_weight) const;
Vector4::Axis min_axis_index() const;
Vector4::Axis max_axis_index() const;