mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-22 00:48:09 +01:00
Also add is_zero_approx() to Vector4.
This commit is contained in:
parent
3f2ed008d1
commit
ed224298e5
@ -72,6 +72,10 @@ bool Vector4::is_equal_approx(const Vector4 &p_vec4) const {
|
||||
return Math::is_equal_approx(x, p_vec4.x) && Math::is_equal_approx(y, p_vec4.y) && Math::is_equal_approx(z, p_vec4.z) && Math::is_equal_approx(w, p_vec4.w);
|
||||
}
|
||||
|
||||
bool Vector4::is_zero_approx() const {
|
||||
return Math::is_zero_approx(x) && Math::is_zero_approx(y) && Math::is_zero_approx(z) && Math::is_zero_approx(w);
|
||||
}
|
||||
|
||||
real_t Vector4::length() const {
|
||||
return Math::sqrt(length_squared());
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ struct _NO_DISCARD_CLASS_ Vector4 {
|
||||
|
||||
_FORCE_INLINE_ real_t length_squared() const;
|
||||
bool is_equal_approx(const Vector4 &p_vec4) const;
|
||||
bool is_zero_approx() const;
|
||||
real_t length() const;
|
||||
void normalize();
|
||||
Vector4 normalized() const;
|
||||
|
@ -706,6 +706,7 @@ struct _VariantCall {
|
||||
VCALL_LOCALMEM0R(Vector4, max_axis);
|
||||
VCALL_LOCALMEM0R(Vector4, length_squared);
|
||||
VCALL_LOCALMEM1R(Vector4, is_equal_approx);
|
||||
VCALL_LOCALMEM0R(Vector4, is_zero_approx);
|
||||
VCALL_LOCALMEM0R(Vector4, length);
|
||||
VCALL_LOCALMEM0(Vector4, normalize);
|
||||
VCALL_LOCALMEM0R(Vector4, normalized);
|
||||
@ -2807,6 +2808,7 @@ void register_variant_methods() {
|
||||
ADDFUNC0R(VECTOR4, INT, Vector4, max_axis, varray());
|
||||
ADDFUNC0R(VECTOR4, REAL, Vector4, length_squared, varray());
|
||||
ADDFUNC1R(VECTOR4, BOOL, Vector4, is_equal_approx, VECTOR4, "v", varray());
|
||||
ADDFUNC0R(VECTOR4, BOOL, Vector4, is_zero_approx, varray());
|
||||
ADDFUNC0R(VECTOR4, REAL, Vector4, length, varray());
|
||||
ADDFUNC0(VECTOR4, NIL, Vector4, normalize, varray());
|
||||
ADDFUNC0R(VECTOR4, VECTOR4, Vector4, normalized, varray());
|
||||
|
@ -94,6 +94,13 @@
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_zero_approx">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if this vector's values are approximately zero, by running [method @GDScript.is_zero_approx] on each component.
|
||||
This method is faster than using [method is_equal_approx] with one value as a zero vector.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_normalized">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
|
Loading…
Reference in New Issue
Block a user