Skip to content

Commit 5f1406d

Browse files
[Math] Add is_finite methods
1 parent b021245 commit 5f1406d

File tree

19 files changed

+53
-0
lines changed

19 files changed

+53
-0
lines changed

include/godot_cpp/core/math.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,14 @@ inline bool is_inf(double p_val) {
613613
return std::isinf(p_val);
614614
}
615615

616+
inline bool is_finite(float p_val) {
617+
return std::isfinite(p_val);
618+
}
619+
620+
inline bool is_finite(double p_val) {
621+
return std::isfinite(p_val);
622+
}
623+
616624
inline bool is_equal_approx(float a, float b) {
617625
// Check for exact equality first, required to handle "infinity" values.
618626
if (a == b) {

include/godot_cpp/variant/aabb.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct _NO_DISCARD_ AABB {
6565
bool operator!=(const AABB &p_rval) const;
6666

6767
bool is_equal_approx(const AABB &p_aabb) const;
68+
bool is_finite() const;
6869
_FORCE_INLINE_ bool intersects(const AABB &p_aabb) const; /// Both AABBs overlap
6970
_FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap
7071
_FORCE_INLINE_ bool encloses(const AABB &p_aabb) const; /// p_aabb is completely inside this

include/godot_cpp/variant/basis.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct _NO_DISCARD_ Basis {
128128
}
129129

130130
bool is_equal_approx(const Basis &p_basis) const;
131+
bool is_finite() const;
131132

132133
bool operator==(const Basis &p_matrix) const;
133134
bool operator!=(const Basis &p_matrix) const;

include/godot_cpp/variant/quaternion.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct _NO_DISCARD_ Quaternion {
5555
}
5656
_FORCE_INLINE_ real_t length_squared() const;
5757
bool is_equal_approx(const Quaternion &p_quaternion) const;
58+
bool is_finite() const;
5859
real_t length() const;
5960
void normalize();
6061
Quaternion normalized() const;

include/godot_cpp/variant/rect2.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ struct _NO_DISCARD_ Rect2 {
209209
}
210210

211211
bool is_equal_approx(const Rect2 &p_rect) const;
212+
bool is_finite() const;
212213

213214
bool operator==(const Rect2 &p_rect) const { return position == p_rect.position && size == p_rect.size; }
214215
bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }

include/godot_cpp/variant/transform2d.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct _NO_DISCARD_ Transform2D {
9999
void orthonormalize();
100100
Transform2D orthonormalized() const;
101101
bool is_equal_approx(const Transform2D &p_transform) const;
102+
bool is_finite() const;
102103

103104
Transform2D looking_at(const Vector2 &p_target) const;
104105

include/godot_cpp/variant/transform3d.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct _NO_DISCARD_ Transform3D {
7878
void orthogonalize();
7979
Transform3D orthogonalized() const;
8080
bool is_equal_approx(const Transform3D &p_transform) const;
81+
bool is_finite() const;
8182

8283
bool operator==(const Transform3D &p_transform) const;
8384
bool operator!=(const Transform3D &p_transform) const;

include/godot_cpp/variant/vector2.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct _NO_DISCARD_ Vector2 {
123123

124124
bool is_equal_approx(const Vector2 &p_v) const;
125125
bool is_zero_approx() const;
126+
bool is_finite() const;
126127

127128
Vector2 operator+(const Vector2 &p_v) const;
128129
void operator+=(const Vector2 &p_v);

include/godot_cpp/variant/vector3.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct _NO_DISCARD_ Vector3 {
146146

147147
bool is_equal_approx(const Vector3 &p_v) const;
148148
bool is_zero_approx() const;
149+
bool is_finite() const;
149150

150151
/* Operators */
151152

include/godot_cpp/variant/vector4.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct _NO_DISCARD_ Vector4 {
8181
_FORCE_INLINE_ real_t length_squared() const;
8282
bool is_equal_approx(const Vector4 &p_vec4) const;
8383
bool is_zero_approx() const;
84+
bool is_finite() const;
8485
real_t length() const;
8586
void normalize();
8687
Vector4 normalized() const;

0 commit comments

Comments
 (0)