Move fmodf, atan2f, sinf, and cosf to std:: namespace

This commit is contained in:
LagoLunatic
2024-08-08 14:50:10 -04:00
parent 864847dfd9
commit 707fceca57
8 changed files with 26 additions and 39 deletions
+6 -6
View File
@@ -11,12 +11,12 @@ namespace math {
/* 8026E610-8026E778 .text getRotation_xyz__Q27JStudio4mathFPA4_ffff */
void getRotation_xyz(MtxP param_1, f32 x, f32 y, f32 z) {
f32 cosx = i_cosf(DEG_TO_RAD(x));
f32 sinx = i_sinf(DEG_TO_RAD(x));
f32 cosy = i_cosf(DEG_TO_RAD(y));
f32 siny = i_sinf(DEG_TO_RAD(y));
f32 cosz = i_cosf(DEG_TO_RAD(z));
f32 sinz = i_sinf(DEG_TO_RAD(z));
f32 cosx = std::cosf(DEG_TO_RAD(x));
f32 sinx = std::sinf(DEG_TO_RAD(x));
f32 cosy = std::cosf(DEG_TO_RAD(y));
f32 siny = std::sinf(DEG_TO_RAD(y));
f32 cosz = std::cosf(DEG_TO_RAD(z));
f32 sinz = std::sinf(DEG_TO_RAD(z));
f32 cosxcosz = cosx * cosz;
f32 cosxsinz = cosx * sinz;
f32 sinxcosz = sinx * cosz;
+1 -1
View File
@@ -323,7 +323,7 @@ u32 JUTGamePad::CStick::update(s8 x_val, s8 y_val, EStickMode mode, EWhichStick
mAngle = -0x4000;
}
} else {
mAngle = 10430.379f * atan2f(mPosX, -mPosY);
mAngle = 10430.379f * std::atan2f(mPosX, -mPosY);
}
}
@@ -35,9 +35,6 @@ inline double fabs(double f) {
double floor(double);
double fmod(double, double);
inline float fmodf(float f1, float f2) {
return fmod(f1, f2);
}
double frexp(double, int*);
double ldexp(double, int);
@@ -85,20 +82,6 @@ extern inline double sqrt(double x) {
return HUGE_VALF;
}
inline float atan2f(float y, float x) {
return (float)atan2(y, x);
}
// these are duplicated due to sinf/cosf having a symbol, but
// still being used as inlines elsewhere
inline float i_sinf(float x) {
return sin(x);
}
inline float i_cosf(float x) {
return cos(x);
}
#ifdef __cplusplus
};
@@ -106,6 +89,10 @@ inline float i_cosf(float x) {
namespace std {
inline float fabsf(float f) { return fabs(f); }
inline float abs(float f) { return fabsf(f); }
inline float fmodf(float x, float y) { return fmod(x, y); }
inline float atan2f(float y, float x) { return (float)atan2(y, x); }
inline float sinf(float x) { return sin(x); }
inline float cosf(float x) { return cos(x); }
}; // namespace std
#endif
+1 -1
View File
@@ -178,7 +178,7 @@ float cM_rnd(void) {
r0 = (r0 * 0xAB) % 0x763D;
r1 = (r1 * 0xAC) % 0x7663;
r2 = (r2 * 0xAA) % 0x7673;
return std::fabsf(fmod(r0 / 30269.0f + r1 / 30307.0f + r2 / 30323.0f, 1.0));
return std::fabsf(std::fmodf(r0 / 30269.0f + r1 / 30307.0f + r2 / 30323.0f, 1.0));
}
/* 802463B0-802463E8 .text cM_rndF__Ff */
+2 -2
View File
@@ -1045,8 +1045,8 @@ int dComIfGd_setShadow(u32 id, s8 param_2, J3DModel* pModel, cXyz* pPos, f32 par
int sid = dComIfGd_setRealShadow2(id, param_2, pModel, pPos, param_5, y - param_8, param_10);
if (sid == 0) {
cXyz i_pos(pPos->x, y, pPos->z);
dComIfGd_setSimpleShadow2(&i_pos, param_8, param_6, pFloorPoly, rotY, param_12, pTexObj);
cXyz pos(pPos->x, y, pPos->z);
dComIfGd_setSimpleShadow2(&pos, param_8, param_6, pFloorPoly, rotY, param_12, pTexObj);
}
return sid;
}
+1 -1
View File
@@ -700,7 +700,7 @@ f32 cM_rnd_c::get() {
m0 = (m0 * 171) % 30269;
m4 = (m4 * 172) % 30307;
m8 = (m8 * 170) % 30323;
return std::fabsf(fmod((m0 / 30269.0f) + (m4 / 30307.0f) + (m8 / 30323.0f), 1.0f));
return std::fabsf(std::fmodf((m0 / 30269.0f) + (m4 / 30307.0f) + (m8 / 30323.0f), 1.0f));
}
f32 cM_rnd_c::getF(f32 m) {
+3 -3
View File
@@ -583,9 +583,9 @@ void dScnKy_env_light_c::setSunpos() {
var_f1 = g_env_light.mCurTime + 345.0f;
}
sp8.x = i_sinf(DEG_TO_RAD(var_f1)) * 80000.0f;
sp8.y = i_cosf(DEG_TO_RAD(var_f1)) * 80000.0f;
sp8.z = i_cosf(DEG_TO_RAD(var_f1)) * -48000.0f;
sp8.x = std::sinf(DEG_TO_RAD(var_f1)) * 80000.0f;
sp8.y = std::cosf(DEG_TO_RAD(var_f1)) * 80000.0f;
sp8.z = std::cosf(DEG_TO_RAD(var_f1)) * -48000.0f;
if (!dComIfGp_event_runCheck() || g_env_light.mInitAnimTimer != 0) {
mSunPos.x = camera_p->mLookat.mEye.x + sp8.x;
+8 -8
View File
@@ -1477,12 +1477,12 @@ void dKyr_drawSun(Mtx drawMtx, cXyz* pPos, GXColor& reg0, u8** pImg) {
dKyr_get_vectle_calc(&pCamera->mLookat.mEye, &pCamera->mLookat.mCenter, &camfwd);
f32 cam_distXZ = sqrtf(camfwd.x*camfwd.x + camfwd.z*camfwd.z);
f32 cam_theta = atan2f(camfwd.x, camfwd.z);
f32 cam_phi = atan2f(camfwd.y, cam_distXZ);
f32 cam_theta = std::atan2f(camfwd.x, camfwd.z);
f32 cam_phi = std::atan2f(camfwd.y, cam_distXZ);
f32 moon_distXZ = sqrtf(moonPos.x*moonPos.x + moonPos.z*moonPos.z);
f32 moon_theta = atan2f(moonPos.x, moonPos.z);
f32 moon_phi = atan2f(moonPos.y, moon_distXZ);
f32 moon_theta = std::atan2f(moonPos.x, moonPos.z);
f32 moon_phi = std::atan2f(moonPos.y, moon_distXZ);
f32 angle = 45.0f + (((moon_theta - cam_theta) / -8.0f) * moon_phi) * 360.0f;
MTXRotDeg(rotMtx, 'Z', angle);
@@ -1575,14 +1575,14 @@ void dKyr_drawSun(Mtx drawMtx, cXyz* pPos, GXColor& reg0, u8** pImg) {
snap_sunmoon_proc(&sunPos, 9);
f32 sun_distXZ = sqrtf(sunPos.x*sunPos.x + sunPos.z*sunPos.z);
f32 sun_theta = atan2f(sunPos.x, sunPos.z);
f32 sun_phi = atan2f(sunPos.y, sun_distXZ);
f32 sun_theta = std::atan2f(sunPos.x, sunPos.z);
f32 sun_phi = std::atan2f(sunPos.y, sun_distXZ);
dKyr_get_vectle_calc(&pCamera->mLookat.mEye, &pCamera->mLookat.mCenter, &camfwd);
f32 cam_distXZ = sqrtf(camfwd.x*camfwd.x + camfwd.z*camfwd.z);
f32 cam_theta = atan2f(camfwd.x, camfwd.z);
f32 cam_phi = atan2f(camfwd.y, cam_distXZ);
f32 cam_theta = std::atan2f(camfwd.x, camfwd.z);
f32 cam_phi = std::atan2f(camfwd.y, cam_distXZ);
MTXRotDeg(rotMtx, 'Z', -50.0f + (360.0f * ((sun_theta - cam_theta) / -8.0f)));
MTXConcat(camMtx, rotMtx, camMtx);