Skip to content

Commit 57557d1

Browse files
Merge pull request #272 from elijah-thomas774/mAng
change mAng to template operators
2 parents 3492eac + 167ee58 commit 57557d1

22 files changed

+178
-191
lines changed

configure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def MatchingFor(*versions):
539539
Object(Matching, "d/lyt/d_lyt_common_icon_item.cpp"),
540540
Object(NonMatching, "d/lyt/d_lyt_target_bird.cpp"),
541541
Object(NonMatching, "d/lyt/msg_window/d_lyt_msg_window.cpp"),
542-
Object(NonMatching, "d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp"),
542+
Object(Matching, "d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp"),
543543
Object(Matching, "d/lyt/msg_window/d_lyt_msg_window_common.cpp"),
544544
Object(Matching, "d/lyt/msg_window/d_lyt_msg_window_talk.cpp"),
545545
Object(Matching, "d/lyt/msg_window/d_lyt_msg_window_link.cpp"),
@@ -2437,7 +2437,7 @@ def MatchingFor(*versions):
24372437
Rel(NonMatching, "d_a_obj_D3_dummy", "REL/d/a/obj/d_a_obj_D3_dummy.cpp"),
24382438
Rel(NonMatching, "d_a_obj_daynight", "REL/d/a/obj/d_a_obj_daynight.cpp"),
24392439
Rel(NonMatching, "d_a_obj_decoA", "REL/d/a/obj/d_a_obj_decoA.cpp"),
2440-
Rel(NonMatching, "d_a_obj_decoB", "REL/d/a/obj/d_a_obj_decoB.cpp"),
2440+
Rel(Matching, "d_a_obj_decoB", "REL/d/a/obj/d_a_obj_decoB.cpp"),
24412441
Rel(NonMatching, "d_a_obj_desert", "REL/d/a/obj/d_a_obj_desert.cpp"),
24422442
Rel(NonMatching, "d_a_obj_desert_ago", "REL/d/a/obj/d_a_obj_desert_ago.cpp"),
24432443
Rel(Matching, "d_a_obj_desert_debris", "REL/d/a/obj/d_a_obj_desert_debris.cpp"),

include/d/a/obj/d_a_obj_decoB.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "m/m_angle.h"
77
#include "nw4r/g3d/res/g3d_resfile.h"
88
#include "s/s_State.hpp"
9-
#include "s/s_StateMgr.hpp"
109

1110
class dAcODecoB_c : public dAcObjBase_c {
1211
public:
@@ -28,7 +27,6 @@ class dAcODecoB_c : public dAcObjBase_c {
2827
/* 0x38C */ u16 padding_0x38C;
2928
/* 0x38E */ mAng field_0x38E;
3029

31-
static f32 lbl_611_data_34;
3230
static const f32 lbl_611_rodata_30;
3331
};
3432

include/d/a/obj/d_a_obj_windmill.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "m/m_vec.h"
1313
#include "nw4r/g3d/res/g3d_resfile.h"
1414
#include "s/s_State.hpp"
15-
#include "s/s_StateMgr.hpp"
1615
#include "toBeSorted/stage_render_stuff.h"
1716

1817
class dAcOwindmill_c : public dAcObjBase_c {

include/m/m_angle.h

Lines changed: 72 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,141 +8,145 @@
88
#include "nw4r/math/math_triangular.h"
99
#include "s/s_Math.h"
1010

11-
struct mAng {
11+
class mAng {
12+
public:
1213
mAng() {}
1314
mAng(s16 s) : mVal(s) {}
1415
mAng(const mAng &other) : mVal(other.mVal) {}
1516

16-
mAng &operator=(const s32 &val) {
17+
public:
18+
void set(s16 val) {
1719
mVal = val;
18-
return *this;
19-
}
20-
21-
void setF(const f32 &f) {
22-
mVal = f;
2320
}
2421

25-
static mAng atan2s(f32 a, f32 b) {
26-
return mAng(cM::atan2s(a, b));
27-
}
28-
static mAng fromVec(const mVec3_c &other) {
29-
return mAng(cM::atan2s(other.x, other.z));
22+
public:
23+
s16 *ref() {
24+
return &mVal;
3025
}
3126

3227
operator s16() const {
3328
return mVal;
3429
}
3530

36-
void set(s16 val) {
37-
mVal = val;
38-
}
39-
40-
s16 *ref() {
41-
return &mVal;
42-
}
43-
4431
mAng operator-() {
4532
return mAng(-mVal);
4633
}
4734

48-
mAng &operator+=(const mAng &other) {
49-
mVal += other.mVal;
35+
template <typename T>
36+
mAng &operator+=(const T &other) {
37+
mVal += s16(other);
5038
return *this;
5139
}
52-
mAng &operator-=(const mAng &other) {
53-
mVal -= other.mVal;
40+
template <typename T>
41+
mAng &operator-=(const T &other) {
42+
mVal -= s16(other);
5443
return *this;
5544
}
56-
mAng &operator*=(const s32 &other) {
45+
template <typename T>
46+
mAng &operator*=(const T &other) {
5747
mVal *= other;
5848
return *this;
5949
}
60-
mAng &operator*=(const f32 &other) {
61-
mVal *= other;
50+
template <typename T>
51+
mAng &operator=(const T &other) {
52+
mVal = other;
6253
return *this;
6354
}
6455

65-
s32 absDiff(const mAng &other) const {
66-
return sLib::absDiff(mVal, other.mVal);
67-
}
68-
56+
public:
6957
static s32 abs(const mAng b) {
7058
return labs(b);
7159
}
72-
73-
s32 step(s16 target, s32 steps, s16 max, s16 min);
74-
60+
s32 abs() const {
61+
return abs(*this);
62+
}
63+
s32 absDiff(const mAng &other) const {
64+
return sLib::absDiff(mVal, other.mVal);
65+
}
7566
f32 sin() const {
7667
return nw4r::math::SinIdx(*this);
7768
}
78-
7969
f32 cos() const {
8070
return nw4r::math::CosIdx(*this);
8171
}
82-
83-
f32 degree() const {
84-
return (360.0f / 65536.0f) * mVal;
72+
static mAng atan2s(f32 a, f32 b) {
73+
return mAng(cM::atan2s(a, b));
8574
}
8675

76+
public:
77+
s32 step(s16 target, s32 steps, s16 max, s16 min);
78+
79+
public:
80+
static mAng fromVec(const mVec3_c &other) {
81+
return mAng(cM::atan2s(other.x, other.z));
82+
}
8783
static s16 fromDeg(f32 deg) {
8884
return deg * sDegToAng;
8985
}
90-
f32 degree2() const {
91-
return mVal * sAngToDeg;
86+
static mAng fromRad(f32 rad) {
87+
return rad * sRadToAng;
9288
}
9389

90+
f32 degree() const {
91+
return (360.0f / 65536.0f) * mVal;
92+
}
9493
f32 radian() const {
9594
return ((2.f * M_PI) / 65536.0f) * mVal;
9695
}
9796

98-
f32 radian2() const {
97+
f32 degree_c() const {
98+
return mVal * sAngToDeg;
99+
}
100+
f32 radian_c() const {
99101
return mVal * sAngToRad;
100102
}
101103

102-
static mAng fromRad(f32 rad) {
103-
return rad * sRadToAng;
104+
public:
105+
static s16 d2s(f32 deg) {
106+
return deg * (65536.0f / 360.0f);
104107
}
105-
106-
static f32 ang2deg_c(f32 ang) {
108+
static f32 s2d(s16 angle) {
109+
return (360.0f / 65536.0f) * angle;
110+
}
111+
static f32 s2d_c(f32 ang) {
107112
return ang * sAngToDeg;
108113
}
109-
110-
static f32 rad2deg_c(f32 rad) {
111-
return rad * sRadToDeg;
114+
static f32 d2s_c(f32 ang) {
115+
return ang * sDegToAng;
112116
}
113117

114-
static f32 rad2deg(f32 rad) {
115-
return rad * (360.f / (2.f * M_PI));
118+
static f32 s2r(s16 angle) {
119+
return ((2.f * M_PI) / 65536.0f) * angle;
116120
}
117-
static f32 deg2rad(f32 deg) {
118-
return deg * ((2.f * M_PI) / 360.f);
121+
static s16 r2s(f32 rad) {
122+
return rad * (65536.0f / (2.f * M_PI));
119123
}
120-
static s16 deg2short(f32 deg) {
121-
return deg * (65536.0f / 360.0f);
124+
static f32 s2r_c(f32 ang) {
125+
return ang * sAngToRad;
122126
}
123-
static f32 short2deg(s16 angle) {
124-
return (360.0f / 65536.0f) * angle;
127+
static f32 r2s_c(f32 ang) {
128+
return ang * sRadToAng;
125129
}
126-
static f32 short2rad(s16 angle) {
127-
return ((2.f * M_PI) / 65536.0f) * angle;
130+
131+
static f32 d2r(f32 deg) {
132+
return deg * ((2.f * M_PI) / 360.f);
128133
}
129-
static f32 short2norm(s16 angle) {
130-
return 3.0517578E-5f * angle;
134+
static f32 r2d(f32 rad) {
135+
return rad * (360.f / (2.f * M_PI));
131136
}
132-
static s16 rad2short(f32 rad) {
133-
return rad * (65536.0f / (2.f * M_PI));
137+
static f32 d2r_c(f32 deg) {
138+
return deg * sDegToRad;
139+
}
140+
static f32 r2d_c(f32 rad) {
141+
return rad * sRadToDeg;
134142
}
135143

136-
static f32 deg2rad_c(f32 deg) {
137-
return deg * sDegToRad;
144+
static f32 s2n(s16 angle) {
145+
return 3.0517578E-5f * angle;
138146
}
139147

140148
s16 mVal;
141149

142-
static const mAng Zero() {
143-
return 0;
144-
}
145-
146150
private:
147151
static const f32 sHalfCircleDeg;
148152
static const f32 sAngToDeg;
@@ -197,16 +201,6 @@ class mAng3_c {
197201
set(0, 0, 0);
198202
}
199203

200-
// TODO - This is the only way I could get the regswap to be fixed..
201-
// Found with the pattern mAng3_c.y += cM::rndFX()
202-
void addY(f32 val) {
203-
y.mVal += (s16)val;
204-
}
205-
206-
void addX(const s32 &fx) {
207-
x += fx;
208-
}
209-
210204
mAng x, y, z;
211205

212206
static mAng3_c Zero;

include/m/m_pad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ inline int getCurrentCoreID() {
4444
}
4545

4646
inline bool isMpls(const int i) {
47-
return g_padMg->getDevType(i) == EGG::cDEV_MPLS;
47+
return g_padMg->getDevType(i) == EGG::cDEV_MPLS ? true : false;
4848
}
4949
inline bool isMplsPtFS(const int i) {
5050
return g_padMg->getDevType(i) == EGG::cDEV_MPLS_PT_FS;

src/REL/d/a/e/d_a_e_sm.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,7 @@ void dAcEsm_c::fn_187_4540(int param0) {
10191019
pChild->mStateMgr.changeState(StateID_BirthJump);
10201020

10211021
if (field_0xB98 == 0) {
1022-
mAng ang = (f + cM::rndFX(4096.f));
1023-
rot.y -= mAng(ang);
1022+
rot.y -= mAng(f + cM::rndFX(4096.f));
10241023
} else {
10251024
rot.y = fn_187_51F0(true);
10261025
const f32 y = sSmDataArr[field_0xB98].field_0x04.y;
@@ -1438,7 +1437,7 @@ void dAcEsm_c::fn_187_6C20(bool param0) {
14381437
if (!param0) {
14391438
dCamera_c *cam = dScGame_c::getCamera(0);
14401439
mAngle.y = cLib::targetAngleY(cam->getPositionMaybe(), cam->getField_0x78());
1441-
mAngle.addY(cM::rndFX(16384.f));
1440+
mAngle.y += cM::rndFX(16384.f);
14421441
}
14431442

14441443
field_0xBCE = 1;

0 commit comments

Comments
 (0)