first round of constants cleanup (#3021)

* first round of constants cleanup

* move m_PI_D definition

* remove compatibility comment

* add future version of angle subtracting with/without cast

* whitespace change to run builds again
This commit is contained in:
roeming
2026-01-10 16:38:04 -05:00
committed by GitHub
parent d5e748beaa
commit 37ec227b3f
30 changed files with 81 additions and 59 deletions
+4 -1
View File
@@ -151,7 +151,10 @@ public:
void setAwayFromAxisSpeed(f32 i_speed) { mAwayFromAxisSpeed = i_speed; }
void setSpread(f32 i_spread) { mSpread = i_spread; }
void setLocalTranslation(const JGeometry::TVec3<f32>& i_trans) { mLocalTrs.set(i_trans); }
void setLocalRotation(const JGeometry::TVec3<s16>& i_rot) { mLocalRot.set(i_rot.x * 0.005493248f, i_rot.y * 0.005493248f, i_rot.z * 0.005493248f); }
void setLocalRotation(const JGeometry::TVec3<s16>& i_rot) {
mLocalRot.set(i_rot.x * (360.0f / 0xffff), i_rot.y * (360.0f / 0xffff),
i_rot.z * (360.0f / 0xffff));
}
void setRateStep(u8 i_step) { mRateStep = i_step; }
void setGlobalParticleHeightScale(f32 height) {
@@ -4,6 +4,8 @@
#include "dolphin/mtx.h"
#include <math>
#define m_PI_D 3.141592653589793
namespace JStudio {
namespace math {
void getRotation_xyz(MtxP, f32, f32, f32);
+24 -9
View File
@@ -3,12 +3,27 @@
#include "SSystem/SComponent/c_xyz.h"
#if PLATFORM_SHIELD
#define ADD_ANGLE(x, y) ((x) += (s16)(y))
#define SUB_ANGLE(x, y) ((x) -= (s16)(y))
// There are some angles that weren't sign-extended until the shield version
#if !PLATFORM_SHIELD
#define ADD_ANGLE_2(x, y) ((x) += (y))
#define SUB_ANGLE_2(x, y) ((x) -= (y))
#else
#define ADD_ANGLE(x, y) ((x) += (y))
#define ADD_ANGLE_2(x, y) ADD_ANGLE(x, y)
#define SUB_ANGLE_2(x, y) SUB_ANGLE(x, y)
#endif
#define DEG2S_CONSTANT (0x8000 / 180.0f)
#define S2DEG_CONSTANT (180.0f / 0x8000)
#define S2RAD_CONSTANT (M_PI / 0x8000)
#define RAD2S_CONSTANT (0x8000 / M_PI)
#define DEG2S(x) ((s16)((x) * DEG2S_CONSTANT))
#define S2DEG(x) ((x) * S2DEG_CONSTANT)
#define S2RAD(x) ((x) * S2RAD_CONSTANT)
#define RAD2S(x) ((x) * RAD2S_CONSTANT)
class cSAngle {
private:
@@ -67,13 +82,13 @@ cSAngle operator+(short, const cSAngle&);
cSAngle operator-(short, const cSAngle&);
struct cAngle {
static f32 Radian_to_Degree(f32 rad) { return rad * 57.2957763671875f; }
static f32 Degree_to_Radian(f32 deg) { return deg * 0.017453292f; }
static s16 Degree_to_SAngle(f32 deg) { return deg * 182.04444885253906f; }
static f32 SAngle_to_Degree(s16 angle) { return (360.0f / 65536.0f) * angle; }
static f32 SAngle_to_Radian(s16 angle) { return 9.58738E-5f * angle; }
static f32 SAngle_to_Normal(s16 angle) { return 3.0517578E-5f * angle; }
static s16 Radian_to_SAngle(f32 rad) { return rad * 10430.378f; }
static f32 Radian_to_Degree(f32 rad) { return rad * (180.0f / M_PI); }
static f32 Degree_to_Radian(f32 deg) { return deg * (M_PI / 180.0f); }
static s16 Degree_to_SAngle(f32 deg) { return DEG2S(deg); }
static f32 SAngle_to_Degree(s16 angle) { return S2DEG(angle); }
static f32 SAngle_to_Radian(s16 angle) { return angle * (M_PI / 0x8000); }
static f32 SAngle_to_Normal(s16 angle) { return angle * (1.0f / 0x8000); }
static s16 Radian_to_SAngle(f32 rad) { return rad * (0x8000 / M_PI); }
/* Converts Radian value into Degree value */
static f32 r2d(f32 r) { return Radian_to_Degree(r); }
+3 -3
View File
@@ -119,7 +119,7 @@ inline s16 HIO_jntRX(int param_1, int param_2) {
} else {
rv = l_Cd_HIO.field_0x1648[param_1 - 16].field_0x4[param_2].jntR.x;
}
return 182.04444885253906f * rv;
return DEG2S(rv);
}
inline s16 HIO_jntRY(int param_1, int param_2) {
@@ -129,7 +129,7 @@ inline s16 HIO_jntRY(int param_1, int param_2) {
} else {
rv = l_Cd_HIO.field_0x1648[param_1 - 16].field_0x4[param_2].jntR.y;
}
return 182.04444885253906f * rv;
return DEG2S(rv);
}
inline s16 HIO_jntRZ(int param_1, int param_2) {
@@ -139,7 +139,7 @@ inline s16 HIO_jntRZ(int param_1, int param_2) {
} else {
rv = l_Cd_HIO.field_0x1648[param_1 - 16].field_0x4[param_2].jntR.z;
}
return 182.04444885253906f * rv;
return DEG2S(rv);
}
static inline f32 HIO_jntTX(int param_1, int param_2) {
+4 -3
View File
@@ -10,6 +10,7 @@
#include "SSystem/SComponent/c_xyz.h"
#include "Z2AudioLib/Z2SoundStarter.h"
#include "f_op/f_op_actor_mng.h"
#include "SSystem/SComponent/c_angle.h"
class J3DModel;
class dDemo_actor_c;
@@ -118,9 +119,9 @@ public:
*o_scale = mScale;
}
virtual void JSGGetRotation(Vec* param_0) const {
param_0->x = mRotate.x * 0.005493164f;
param_0->y = mRotate.y * 0.005493164f;
param_0->z = mRotate.z * 0.005493164f;
param_0->x = S2DEG(mRotate.x);
param_0->y = S2DEG(mRotate.y);
param_0->z = S2DEG(mRotate.z);
}
void setModel(J3DModel* p_model) { mModel = p_model; }
+1 -1
View File
@@ -81,7 +81,7 @@ inline void mDoCPd_ANALOG_CONV(u8 analog, f32& param_1) {
}
inline void mDoCPd_TRIGGER_CONV(u8 analog, f32& param_1) {
param_1 = analog * 0.0071428571827709675f;
param_1 = analog * (1.0f / 140.0f);
if (param_1 > 1.0f) {
param_1 = 1.0f;
}