summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorElijah Thomas <42302100+elijah-thomas774@users.noreply.github.com>2025-11-23 02:29:49 -0500
committerGitHub <noreply@github.com>2025-11-23 02:29:49 -0500
commit57557d11285aeff9ffd86c6e57fdc09b62b391d1 (patch)
tree9381837b90d062335cf1fd9a87c86822c568abd8 /include
parent3492eac0b23272356b07268ff547494941158e89 (diff)
parent167ee588e064a771e9b581f2c20090ebe8c3c27a (diff)
Merge pull request #272 from elijah-thomas774/mAng
change mAng to template operators
Diffstat (limited to 'include')
-rw-r--r--include/d/a/obj/d_a_obj_decoB.h2
-rw-r--r--include/d/a/obj/d_a_obj_windmill.h1
-rw-r--r--include/m/m_angle.h150
-rw-r--r--include/m/m_pad.h2
4 files changed, 73 insertions, 82 deletions
diff --git a/include/d/a/obj/d_a_obj_decoB.h b/include/d/a/obj/d_a_obj_decoB.h
index d6bbf259..16572b2d 100644
--- a/include/d/a/obj/d_a_obj_decoB.h
+++ b/include/d/a/obj/d_a_obj_decoB.h
@@ -6,7 +6,6 @@
#include "m/m_angle.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
-#include "s/s_StateMgr.hpp"
class dAcODecoB_c : public dAcObjBase_c {
public:
@@ -28,7 +27,6 @@ private:
/* 0x38C */ u16 padding_0x38C;
/* 0x38E */ mAng field_0x38E;
- static f32 lbl_611_data_34;
static const f32 lbl_611_rodata_30;
};
diff --git a/include/d/a/obj/d_a_obj_windmill.h b/include/d/a/obj/d_a_obj_windmill.h
index dca36070..24b3e72c 100644
--- a/include/d/a/obj/d_a_obj_windmill.h
+++ b/include/d/a/obj/d_a_obj_windmill.h
@@ -12,7 +12,6 @@
#include "m/m_vec.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "s/s_State.hpp"
-#include "s/s_StateMgr.hpp"
#include "toBeSorted/stage_render_stuff.h"
class dAcOwindmill_c : public dAcObjBase_c {
diff --git a/include/m/m_angle.h b/include/m/m_angle.h
index 3fb0ca39..05842818 100644
--- a/include/m/m_angle.h
+++ b/include/m/m_angle.h
@@ -8,141 +8,145 @@
#include "nw4r/math/math_triangular.h"
#include "s/s_Math.h"
-struct mAng {
+class mAng {
+public:
mAng() {}
mAng(s16 s) : mVal(s) {}
mAng(const mAng &other) : mVal(other.mVal) {}
- mAng &operator=(const s32 &val) {
+public:
+ void set(s16 val) {
mVal = val;
- return *this;
- }
-
- void setF(const f32 &f) {
- mVal = f;
}
- static mAng atan2s(f32 a, f32 b) {
- return mAng(cM::atan2s(a, b));
- }
- static mAng fromVec(const mVec3_c &other) {
- return mAng(cM::atan2s(other.x, other.z));
+public:
+ s16 *ref() {
+ return &mVal;
}
operator s16() const {
return mVal;
}
- void set(s16 val) {
- mVal = val;
- }
-
- s16 *ref() {
- return &mVal;
- }
-
mAng operator-() {
return mAng(-mVal);
}
- mAng &operator+=(const mAng &other) {
- mVal += other.mVal;
+ template <typename T>
+ mAng &operator+=(const T &other) {
+ mVal += s16(other);
return *this;
}
- mAng &operator-=(const mAng &other) {
- mVal -= other.mVal;
+ template <typename T>
+ mAng &operator-=(const T &other) {
+ mVal -= s16(other);
return *this;
}
- mAng &operator*=(const s32 &other) {
+ template <typename T>
+ mAng &operator*=(const T &other) {
mVal *= other;
return *this;
}
- mAng &operator*=(const f32 &other) {
- mVal *= other;
+ template <typename T>
+ mAng &operator=(const T &other) {
+ mVal = other;
return *this;
}
- s32 absDiff(const mAng &other) const {
- return sLib::absDiff(mVal, other.mVal);
- }
-
+public:
static s32 abs(const mAng b) {
return labs(b);
}
-
- s32 step(s16 target, s32 steps, s16 max, s16 min);
-
+ s32 abs() const {
+ return abs(*this);
+ }
+ s32 absDiff(const mAng &other) const {
+ return sLib::absDiff(mVal, other.mVal);
+ }
f32 sin() const {
return nw4r::math::SinIdx(*this);
}
-
f32 cos() const {
return nw4r::math::CosIdx(*this);
}
-
- f32 degree() const {
- return (360.0f / 65536.0f) * mVal;
+ static mAng atan2s(f32 a, f32 b) {
+ return mAng(cM::atan2s(a, b));
}
+public:
+ s32 step(s16 target, s32 steps, s16 max, s16 min);
+
+public:
+ static mAng fromVec(const mVec3_c &other) {
+ return mAng(cM::atan2s(other.x, other.z));
+ }
static s16 fromDeg(f32 deg) {
return deg * sDegToAng;
}
- f32 degree2() const {
- return mVal * sAngToDeg;
+ static mAng fromRad(f32 rad) {
+ return rad * sRadToAng;
}
+ f32 degree() const {
+ return (360.0f / 65536.0f) * mVal;
+ }
f32 radian() const {
return ((2.f * M_PI) / 65536.0f) * mVal;
}
- f32 radian2() const {
+ f32 degree_c() const {
+ return mVal * sAngToDeg;
+ }
+ f32 radian_c() const {
return mVal * sAngToRad;
}
- static mAng fromRad(f32 rad) {
- return rad * sRadToAng;
+public:
+ static s16 d2s(f32 deg) {
+ return deg * (65536.0f / 360.0f);
}
-
- static f32 ang2deg_c(f32 ang) {
+ static f32 s2d(s16 angle) {
+ return (360.0f / 65536.0f) * angle;
+ }
+ static f32 s2d_c(f32 ang) {
return ang * sAngToDeg;
}
-
- static f32 rad2deg_c(f32 rad) {
- return rad * sRadToDeg;
+ static f32 d2s_c(f32 ang) {
+ return ang * sDegToAng;
}
- static f32 rad2deg(f32 rad) {
- return rad * (360.f / (2.f * M_PI));
+ static f32 s2r(s16 angle) {
+ return ((2.f * M_PI) / 65536.0f) * angle;
}
- static f32 deg2rad(f32 deg) {
- return deg * ((2.f * M_PI) / 360.f);
+ static s16 r2s(f32 rad) {
+ return rad * (65536.0f / (2.f * M_PI));
}
- static s16 deg2short(f32 deg) {
- return deg * (65536.0f / 360.0f);
+ static f32 s2r_c(f32 ang) {
+ return ang * sAngToRad;
}
- static f32 short2deg(s16 angle) {
- return (360.0f / 65536.0f) * angle;
+ static f32 r2s_c(f32 ang) {
+ return ang * sRadToAng;
}
- static f32 short2rad(s16 angle) {
- return ((2.f * M_PI) / 65536.0f) * angle;
+
+ static f32 d2r(f32 deg) {
+ return deg * ((2.f * M_PI) / 360.f);
}
- static f32 short2norm(s16 angle) {
- return 3.0517578E-5f * angle;
+ static f32 r2d(f32 rad) {
+ return rad * (360.f / (2.f * M_PI));
}
- static s16 rad2short(f32 rad) {
- return rad * (65536.0f / (2.f * M_PI));
+ static f32 d2r_c(f32 deg) {
+ return deg * sDegToRad;
+ }
+ static f32 r2d_c(f32 rad) {
+ return rad * sRadToDeg;
}
- static f32 deg2rad_c(f32 deg) {
- return deg * sDegToRad;
+ static f32 s2n(s16 angle) {
+ return 3.0517578E-5f * angle;
}
s16 mVal;
- static const mAng Zero() {
- return 0;
- }
-
private:
static const f32 sHalfCircleDeg;
static const f32 sAngToDeg;
@@ -197,16 +201,6 @@ public:
set(0, 0, 0);
}
- // TODO - This is the only way I could get the regswap to be fixed..
- // Found with the pattern mAng3_c.y += cM::rndFX()
- void addY(f32 val) {
- y.mVal += (s16)val;
- }
-
- void addX(const s32 &fx) {
- x += fx;
- }
-
mAng x, y, z;
static mAng3_c Zero;
diff --git a/include/m/m_pad.h b/include/m/m_pad.h
index 3942e191..14b100c3 100644
--- a/include/m/m_pad.h
+++ b/include/m/m_pad.h
@@ -44,7 +44,7 @@ inline int getCurrentCoreID() {
}
inline bool isMpls(const int i) {
- return g_padMg->getDevType(i) == EGG::cDEV_MPLS;
+ return g_padMg->getDevType(i) == EGG::cDEV_MPLS ? true : false;
}
inline bool isMplsPtFS(const int i) {
return g_padMg->getDevType(i) == EGG::cDEV_MPLS_PT_FS;