mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Add is_zero_approx methods to Vector{2,3}
This commit is contained in:
parent
1a231787b0
commit
441bb29fd3
@ -172,6 +172,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);
|
||||
}
|
||||
|
||||
Vector2::operator String() const {
|
||||
return "(" + String::num_real(x) + ", " + String::num_real(y) + ")";
|
||||
}
|
||||
|
@ -126,6 +126,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);
|
||||
|
@ -106,6 +106,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 "(" + String::num_real(x) + ", " + String::num_real(y) + ", " + String::num_real(z) + ")";
|
||||
}
|
||||
|
@ -137,6 +137,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;
|
||||
inline bool is_equal_approxt(const Vector3 &p_v, real_t p_tolerance) const;
|
||||
bool is_zero_approx() const;
|
||||
|
||||
/* Operators */
|
||||
|
||||
|
@ -547,6 +547,7 @@ struct _VariantCall {
|
||||
VCALL_LOCALMEM1R(Vector2, bounce);
|
||||
VCALL_LOCALMEM1R(Vector2, reflect);
|
||||
VCALL_LOCALMEM1R(Vector2, is_equal_approx);
|
||||
VCALL_LOCALMEM0R(Vector2, is_zero_approx);
|
||||
VCALL_LOCALMEM0R(Vector2, angle);
|
||||
VCALL_LOCALMEM1(Vector2, set_rotation);
|
||||
VCALL_LOCALMEM0R(Vector2, abs);
|
||||
@ -682,6 +683,7 @@ struct _VariantCall {
|
||||
VCALL_LOCALMEM1R(Vector3, reflect);
|
||||
VCALL_LOCALMEM1R(Vector3, is_equal_approx);
|
||||
VCALL_LOCALMEM2R(Vector3, is_equal_approxt);
|
||||
VCALL_LOCALMEM0R(Vector3, is_zero_approx);
|
||||
|
||||
VCALL_LOCALMEM2(Vector3i, set_axis);
|
||||
VCALL_LOCALMEM1R(Vector3i, get_axis);
|
||||
@ -2657,6 +2659,7 @@ void register_variant_methods() {
|
||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray());
|
||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray());
|
||||
ADDFUNC1R(VECTOR2, BOOL, Vector2, is_equal_approx, VECTOR2, "v", varray());
|
||||
ADDFUNC0R(VECTOR2, BOOL, Vector2, is_zero_approx, varray());
|
||||
ADDFUNC0R(VECTOR2, REAL, Vector2, angle, varray());
|
||||
ADDFUNC1(VECTOR2, NIL, Vector2, set_rotation, REAL, "radians", varray());
|
||||
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, abs, varray());
|
||||
@ -2781,6 +2784,7 @@ void register_variant_methods() {
|
||||
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray());
|
||||
ADDFUNC1R(VECTOR3, BOOL, Vector3, is_equal_approx, VECTOR3, "v", varray());
|
||||
ADDFUNC2R(VECTOR3, BOOL, Vector3, is_equal_approxt, VECTOR3, "v", REAL, "tolerance", varray());
|
||||
ADDFUNC0R(VECTOR3, BOOL, Vector3, is_zero_approx, varray());
|
||||
|
||||
ADDFUNC2(VECTOR3I, NIL, Vector3i, set_axis, INT, "axis", INT, "value", varray());
|
||||
ADDFUNC1R(VECTOR3I, INT, Vector3i, get_axis, INT, "axis", varray());
|
||||
|
@ -159,6 +159,13 @@
|
||||
Returns [code]true[/code] if the vector is normalized, [code]false[/code] otherwise.
|
||||
</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="length">
|
||||
<return type="float" />
|
||||
<description>
|
||||
|
@ -160,6 +160,13 @@
|
||||
Returns [code]true[/code] if the vector is normalized, [code]false[/code] otherwise.
|
||||
</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="length">
|
||||
<return type="float" />
|
||||
<description>
|
||||
|
@ -685,7 +685,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
|
||||
const bool rounded_corners = (corner_radius[0] > 0) || (corner_radius[1] > 0) || (corner_radius[2] > 0) || (corner_radius[3] > 0);
|
||||
// Only enable antialiasing if it is actually needed. This improve performances
|
||||
// and maximizes sharpness for non-skewed StyleBoxes with sharp corners.
|
||||
const bool aa_on = (rounded_corners || !skew.is_equal_approx(Vector2())) && anti_aliased;
|
||||
const bool aa_on = (rounded_corners || !skew.is_zero_approx()) && anti_aliased;
|
||||
|
||||
const bool blend_on = blend_border && draw_border;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user