Vector4/Vector4i: Add missing methods, tests and fix change of sign operator
This commit is contained in:
@ -62,6 +62,15 @@ struct _NO_DISCARD_ Vector4 {
|
||||
DEV_ASSERT((unsigned int)p_axis < 4);
|
||||
return components[p_axis];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_all(const real_t p_value);
|
||||
|
||||
void set_axis(const int p_axis, const real_t p_value);
|
||||
real_t get_axis(const int p_axis) const;
|
||||
|
||||
Vector4::Axis min_axis_index() const;
|
||||
Vector4::Axis max_axis_index() const;
|
||||
|
||||
_FORCE_INLINE_ real_t length_squared() const;
|
||||
bool is_equal_approx(const Vector4 &p_vec4) const;
|
||||
real_t length() const;
|
||||
@ -69,15 +78,21 @@ struct _NO_DISCARD_ Vector4 {
|
||||
Vector4 normalized() const;
|
||||
bool is_normalized() const;
|
||||
|
||||
real_t distance_to(const Vector4 &p_to) const;
|
||||
Vector4 direction_to(const Vector4 &p_to) 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 cubic_interpolate(const Vector4 &p_b, const Vector4 &p_pre_a, const Vector4 &p_post_b, const real_t p_weight) const;
|
||||
|
||||
Vector4::Axis min_axis_index() const;
|
||||
Vector4::Axis max_axis_index() const;
|
||||
Vector4 posmod(const real_t p_mod) const;
|
||||
Vector4 posmodv(const Vector4 &p_modv) const;
|
||||
void snap(const Vector4 &p_step);
|
||||
Vector4 snapped(const Vector4 &p_step) const;
|
||||
Vector4 clamp(const Vector4 &p_min, const Vector4 &p_max) const;
|
||||
|
||||
Vector4 inverse() const;
|
||||
@ -130,6 +145,10 @@ struct _NO_DISCARD_ Vector4 {
|
||||
}
|
||||
};
|
||||
|
||||
void Vector4::set_all(const real_t p_value) {
|
||||
x = y = z = p_value;
|
||||
}
|
||||
|
||||
real_t Vector4::dot(const Vector4 &p_vec4) const {
|
||||
return x * p_vec4.x + y * p_vec4.y + z * p_vec4.z + w * p_vec4.w;
|
||||
}
|
||||
@ -193,7 +212,7 @@ Vector4 Vector4::operator/(const Vector4 &p_vec4) const {
|
||||
}
|
||||
|
||||
Vector4 Vector4::operator-() const {
|
||||
return Vector4(x, y, z, w);
|
||||
return Vector4(-x, -y, -z, -w);
|
||||
}
|
||||
|
||||
Vector4 Vector4::operator*(const real_t &s) const {
|
||||
|
||||
Reference in New Issue
Block a user