From f1f3ec15fd3fcbee634a77297a9908962cfab9aa Mon Sep 17 00:00:00 2001 From: Narr the Reg <5944268+german77@users.noreply.github.com> Date: Wed, 10 Jun 2026 18:14:37 -0600 Subject: [PATCH] math: Implement MathCalcCommon::isNan and vectorx::isNan --- include/math/seadMathCalcCommon.hpp | 6 ++++++ include/math/seadVector.h | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/math/seadMathCalcCommon.hpp b/include/math/seadMathCalcCommon.hpp index c638d672..daaa1436 100644 --- a/include/math/seadMathCalcCommon.hpp +++ b/include/math/seadMathCalcCommon.hpp @@ -528,6 +528,12 @@ inline T MathCalcCommon::clamp(T value, T low, T high) return value; } +template +inline bool MathCalcCommon::isNan(T value) +{ + return std::isnan(value); +} + template inline bool MathCalcCommon::chase(T* value, T target, T step) { diff --git a/include/math/seadVector.h b/include/math/seadVector.h index 0d2e97be..8de5ca32 100644 --- a/include/math/seadVector.h +++ b/include/math/seadVector.h @@ -69,6 +69,7 @@ struct Vector2 : public Policies::Vec2Base T normalize(); bool isZero() const { return *this == zero; } + bool isNan() const { return sead::Mathf::isNan(this->x) || sead::Mathf::isNan(this->y); } static const Vector2 zero; static const Vector2 ex; @@ -190,6 +191,12 @@ struct Vector3 : public Policies::Vec3Base void setRotated(const Quat& q, const Vector3& a); void setSub(const Vector3& a, const Vector3& b); + bool isNan() const + { + return sead::Mathf::isNan(this->x) || sead::Mathf::isNan(this->y) || + sead::Mathf::isNan(this->z); + } + static const Vector3 zero; static const Vector3 ex; static const Vector3 ey; @@ -244,6 +251,12 @@ struct Vector4 : public Policies::Vec4Base void set(const Vector4& v); void set(T x_, T y_, T z_, T w_); + bool isNan() const + { + return sead::Mathf::isNan(this->x) || sead::Mathf::isNan(this->y) || + sead::Mathf::isNan(this->z) || sead::Mathf::isNan(this->w); + } + static const Vector4 zero; static const Vector4 ex; static const Vector4 ey;