Add is_zero_approx methods to Vector{2,3}
This commit is contained in:
@ -199,6 +199,10 @@ bool Vector2::is_equal_approx(const Vector2 &p_v) const {
|
||||
return Math::is_equal_approx(x, p_v.x) && Math::is_equal_approx(y, p_v.y);
|
||||
}
|
||||
|
||||
bool Vector2::is_zero_approx() const {
|
||||
return Math::is_zero_approx(x) && Math::is_zero_approx(y);
|
||||
}
|
||||
|
||||
/* Vector2i */
|
||||
|
||||
Vector2i Vector2i::operator+(const Vector2i &p_v) const {
|
||||
|
||||
@ -115,6 +115,7 @@ struct _NO_DISCARD_CLASS_ Vector2 {
|
||||
Vector2 reflect(const Vector2 &p_normal) const;
|
||||
|
||||
bool is_equal_approx(const Vector2 &p_v) const;
|
||||
bool is_zero_approx() const;
|
||||
|
||||
Vector2 operator+(const Vector2 &p_v) const;
|
||||
void operator+=(const Vector2 &p_v);
|
||||
|
||||
@ -151,6 +151,10 @@ bool Vector3::is_equal_approx(const Vector3 &p_v) const {
|
||||
return Math::is_equal_approx(x, p_v.x) && Math::is_equal_approx(y, p_v.y) && Math::is_equal_approx(z, p_v.z);
|
||||
}
|
||||
|
||||
bool Vector3::is_zero_approx() const {
|
||||
return Math::is_zero_approx(x) && Math::is_zero_approx(y) && Math::is_zero_approx(z);
|
||||
}
|
||||
|
||||
Vector3::operator String() const {
|
||||
return (rtos(x) + ", " + rtos(y) + ", " + rtos(z));
|
||||
}
|
||||
|
||||
@ -133,6 +133,7 @@ struct _NO_DISCARD_CLASS_ Vector3 {
|
||||
|
||||
bool is_equal_approx(const Vector3 &p_v) const;
|
||||
inline bool is_equal_approx(const Vector3 &p_v, real_t p_tolerance) const;
|
||||
bool is_zero_approx() const;
|
||||
|
||||
/* Operators */
|
||||
|
||||
|
||||
@ -385,6 +385,7 @@ struct _VariantCall {
|
||||
VCALL_LOCALMEM0R(Vector2, normalized);
|
||||
VCALL_LOCALMEM0R(Vector2, is_normalized);
|
||||
VCALL_LOCALMEM1R(Vector2, is_equal_approx);
|
||||
VCALL_LOCALMEM0R(Vector2, is_zero_approx);
|
||||
VCALL_LOCALMEM1R(Vector2, posmod);
|
||||
VCALL_LOCALMEM1R(Vector2, posmodv);
|
||||
VCALL_LOCALMEM1R(Vector2, project);
|
||||
@ -437,6 +438,7 @@ struct _VariantCall {
|
||||
VCALL_LOCALMEM0R(Vector3, normalized);
|
||||
VCALL_LOCALMEM0R(Vector3, is_normalized);
|
||||
VCALL_LOCALMEM1R(Vector3, is_equal_approx);
|
||||
VCALL_LOCALMEM0R(Vector3, is_zero_approx);
|
||||
VCALL_LOCALMEM0R(Vector3, inverse);
|
||||
VCALL_LOCALMEM1R(Vector3, snapped);
|
||||
VCALL_LOCALMEM2R(Vector3, rotated);
|
||||
@ -1800,6 +1802,7 @@ void register_variant_methods() {
|
||||
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, normalized, varray());
|
||||
ADDFUNC0R(VECTOR2, BOOL, Vector2, is_normalized, varray());
|
||||
ADDFUNC1R(VECTOR2, BOOL, Vector2, is_equal_approx, VECTOR2, "v", varray());
|
||||
ADDFUNC0R(VECTOR2, BOOL, Vector2, is_zero_approx, varray());
|
||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, REAL, "mod", varray());
|
||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray());
|
||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray());
|
||||
@ -1851,6 +1854,7 @@ void register_variant_methods() {
|
||||
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, normalized, varray());
|
||||
ADDFUNC0R(VECTOR3, BOOL, Vector3, is_normalized, varray());
|
||||
ADDFUNC1R(VECTOR3, BOOL, Vector3, is_equal_approx, VECTOR3, "v", varray());
|
||||
ADDFUNC0R(VECTOR3, BOOL, Vector3, is_zero_approx, varray());
|
||||
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray());
|
||||
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray());
|
||||
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "angle", varray());
|
||||
|
||||
Reference in New Issue
Block a user