diff --git a/include/JSystem/JParticle/JPAEmitter.h b/include/JSystem/JParticle/JPAEmitter.h index c47cd538d6..1531bd183d 100644 --- a/include/JSystem/JParticle/JPAEmitter.h +++ b/include/JSystem/JParticle/JPAEmitter.h @@ -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& i_trans) { mLocalTrs.set(i_trans); } - void setLocalRotation(const JGeometry::TVec3& i_rot) { mLocalRot.set(i_rot.x * 0.005493248f, i_rot.y * 0.005493248f, i_rot.z * 0.005493248f); } + void setLocalRotation(const JGeometry::TVec3& 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) { diff --git a/include/JSystem/JStudio/JStudio/jstudio-math.h b/include/JSystem/JStudio/JStudio/jstudio-math.h index d902c218fa..f5a41031f5 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-math.h +++ b/include/JSystem/JStudio/JStudio/jstudio-math.h @@ -4,6 +4,8 @@ #include "dolphin/mtx.h" #include +#define m_PI_D 3.141592653589793 + namespace JStudio { namespace math { void getRotation_xyz(MtxP, f32, f32, f32); diff --git a/include/SSystem/SComponent/c_angle.h b/include/SSystem/SComponent/c_angle.h index 4afd36e504..29a43cd7df 100644 --- a/include/SSystem/SComponent/c_angle.h +++ b/include/SSystem/SComponent/c_angle.h @@ -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); } diff --git a/include/d/actor/d_a_npc_cd.h b/include/d/actor/d_a_npc_cd.h index 918a29e88a..2e86c867c6 100644 --- a/include/d/actor/d_a_npc_cd.h +++ b/include/d/actor/d_a_npc_cd.h @@ -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) { diff --git a/include/d/d_demo.h b/include/d/d_demo.h index 3d763d0f56..a65f8c60b2 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -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; } diff --git a/include/m_Do/m_Do_controller_pad.h b/include/m_Do/m_Do_controller_pad.h index c4291c1af9..48d5256ea2 100644 --- a/include/m_Do/m_Do_controller_pad.h +++ b/include/m_Do/m_Do_controller_pad.h @@ -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; } diff --git a/src/JSystem/J3DU/J3DUClipper.cpp b/src/JSystem/J3DU/J3DUClipper.cpp index 59367bee3a..350d67e36a 100644 --- a/src/JSystem/J3DU/J3DUClipper.cpp +++ b/src/JSystem/J3DU/J3DUClipper.cpp @@ -10,7 +10,7 @@ void J3DUClipper::init() { void J3DUClipper::calcViewFrustum() { static const f32 unused[3] = {0.0f}; - f32 f0 = tan(0.5f * mFovY * 0.01745329238474369f); + f32 f0 = tan(0.5f * mFovY * (M_PI / 180.0f)); f32 f4 = mNear * f0; f32 f5 = mAspect * f4; Vec tmp1 = {-f5, -f4, -mNear}; diff --git a/src/JSystem/JStudio/JStudio/jstudio-math.cpp b/src/JSystem/JStudio/JStudio/jstudio-math.cpp index 0203a9e894..d6e31f7a9c 100644 --- a/src/JSystem/JStudio/JStudio/jstudio-math.cpp +++ b/src/JSystem/JStudio/JStudio/jstudio-math.cpp @@ -62,7 +62,7 @@ void JStudio::math::getFromTransformation_SRxyzT(Vec* param_1, Vec* param_2, Vec param_4[1][0] * dVar9, param_4[1][1] * dVar8, param_4[1][2] * dVar7, param_4[2][0] * dVar9, param_4[2][1] * dVar8, param_4[2][2] * dVar7); aTStack_88.getEulerXYZ(&local_a0); - local_a0 *= 57.29577951308232; + local_a0 *= 180.0 / m_PI_D; param_2->x = local_a0.x; param_2->y = local_a0.y; param_2->z = local_a0.z; diff --git a/src/Z2AudioLib/Z2Audience.cpp b/src/Z2AudioLib/Z2Audience.cpp index 26f79ebbe4..46b7107473 100644 --- a/src/Z2AudioLib/Z2Audience.cpp +++ b/src/Z2AudioLib/Z2Audience.cpp @@ -309,7 +309,7 @@ void Z2AudioCamera::setCameraState(f32 (*param_0)[4], Vec& pos, Vec& param_2, f3 } else { Vec aTStack_cc = {param_0[0][0], param_0[0][1], param_0[0][2]}; Mtx rotMtx; - MTXRotAxisRad(rotMtx, &aTStack_cc, 0.017453292f * (-1.0f * dVar10)); + MTXRotAxisRad(rotMtx, &aTStack_cc, (M_PI / 180.0f) * (-1.0f * dVar10)); JGeometry::TVec3 aTStack_d8; MTXMultVec(rotMtx, aTStack_c0, aTStack_d8); aTStack_d8.scale(aTStack_c0.y / aTStack_d8.y); diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index f940a04974..650409f04c 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -2855,7 +2855,7 @@ s16 daAlink_c::getNeckAimAngle(cXyz* param_0, s16* param_1, s16* param_2, s16* p s16 sp18; s16 sp16 = field_0x2fe6 + mBodyAngle.y; if ((mProcID == PROC_GOAT_CATCH && mProcVar1.field_0x300a == 0) || (mProcID == PROC_HAND_PAT && mProcVar2.field_0x300c == 0)) { - ADD_ANGLE(sp16, 0x8000); + ADD_ANGLE_2(sp16, 0x8000); } cXyz sp28 = eyePos - field_0x34e0; diff --git a/src/d/actor/d_a_cstatue.cpp b/src/d/actor/d_a_cstatue.cpp index 727d2fb833..e055ec0c37 100644 --- a/src/d/actor/d_a_cstatue.cpp +++ b/src/d/actor/d_a_cstatue.cpp @@ -1043,7 +1043,7 @@ void daCstatue_c::initStartBrkBtk() { for (int iParticle = 0; iParticle < 2; iParticle++) { dComIfGp_particle_set(0x88bb, &mBallPos, &angle, NULL); dComIfGp_particle_set(0x88bc, &mBallPos, &angle, NULL); - ADD_ANGLE(angle.y, 0x8000); + ADD_ANGLE_2(angle.y, 0x8000); } } diff --git a/src/d/actor/d_a_demo00.cpp b/src/d/actor/d_a_demo00.cpp index e3e56e9d66..a5a071d17c 100644 --- a/src/d/actor/d_a_demo00.cpp +++ b/src/d/actor/d_a_demo00.cpp @@ -1174,14 +1174,15 @@ inline int daDemo00_c::execute() { if (field_0x6ae != 0) { f32 cutoff = 90.0f; - cutoff = shape_angle.z / 182.04445f; + // converting from short to degrees + cutoff = shape_angle.z / DEG2S_CONSTANT; GXColor color; color.r = scale.x; color.g = scale.y; color.b = scale.z; color.a = 0xFF; - f32 f30 = shape_angle.x / 182.04445f; - f32 f29 = shape_angle.y / 182.04445f; + f32 f30 = shape_angle.x / DEG2S_CONSTANT; + f32 f29 = shape_angle.y / DEG2S_CONSTANT; dKy_BossSpotLight_set(¤t.pos, f30, f29 - 90.0f, cutoff, &color, gravity, field_0x6b0, field_0x6af); } diff --git a/src/d/actor/d_a_e_hzelda.cpp b/src/d/actor/d_a_e_hzelda.cpp index 6402b7f5ef..1630397e1a 100644 --- a/src/d/actor/d_a_e_hzelda.cpp +++ b/src/d/actor/d_a_e_hzelda.cpp @@ -1232,7 +1232,7 @@ static int daE_HZELDA_Execute(e_hzelda_class* i_this) { sp108.z = player->current.pos.z - i_this->mTrianglePos.z; cMtx_YrotS(*calc_mtx, -i_this->mTriangleRotY); MtxPosition(&sp108, &sp114); - + // 57.295 is close to 180 / PI, but not quite, probably a hand written constant f32 var_f31 = fabsf(57.295f * cM_atan2f(sp114.x, sp114.z)); if (var_f31 >= 60.0f && var_f31 <= 120.0f) { var_f31 = 120.0f - var_f31; diff --git a/src/d/actor/d_a_e_rdy.cpp b/src/d/actor/d_a_e_rdy.cpp index 0c7b4967e8..46624ca064 100644 --- a/src/d/actor/d_a_e_rdy.cpp +++ b/src/d/actor/d_a_e_rdy.cpp @@ -683,7 +683,7 @@ static BOOL way_check(e_rdy_class* i_this) { dBgS_LinChk lin_chk; lin_chk.Set(&start, &end, _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - ADD_ANGLE(angle, 0x1000); + ADD_ANGLE_2(angle, 0x1000); } else { i_this->mTargetAngleY = angle; return TRUE; @@ -1165,7 +1165,7 @@ static void e_rdy_bow_run(e_rdy_class* i_this) { case 1: target_speed = run_speed; - ADD_ANGLE(target_angle, 0x8000); + ADD_ANGLE_2(target_angle, 0x8000); if (i_this->mPlayerDist > l_HIO.field_0x28 || i_this->mTimer[0] == 0 || i_this->mAcch.ChkWallHit()) { @@ -1933,7 +1933,7 @@ static void e_rdy_bomb_action(e_rdy_class* i_this) { break; } } - ADD_ANGLE(target_angle, 0x8000); + ADD_ANGLE_2(target_angle, 0x8000); target_speed = l_HIO.mRunSpeed; if (JMAFastSqrt(vec1.x * vec1.x + vec1.z * vec1.z) > 600.0f) { i_this->mMode = 3; @@ -2171,7 +2171,7 @@ static void e_rdy_damage(e_rdy_class* i_this) { i_this->mMode = 10; a_this->speed.y = 0.0f; i_this->field_0xabc *= 0.2f; - ADD_ANGLE(i_this->field_0xadc.y, 0x8000); + ADD_ANGLE_2(i_this->field_0xadc.y, 0x8000); i_this->field_0xbc0 = 5 + BREG_S(7); i_this->field_0xaf4 = 100.0f + BREG_F(4); i_this->field_0xafc = 100.0f + BREG_F(5); diff --git a/src/d/actor/d_a_e_s1.cpp b/src/d/actor/d_a_e_s1.cpp index a50615874e..352cdb985f 100644 --- a/src/d/actor/d_a_e_s1.cpp +++ b/src/d/actor/d_a_e_s1.cpp @@ -1487,6 +1487,8 @@ static void action(e_s1_class* i_this) { if (can_bibiri && (daPy_getPlayerActorClass()->checkWolfBark() || daPy_getPlayerActorClass()->checkWolfThreat()) && pl_at_check(i_this, l_HIO.mReactionDist)) { fopAc_ac_c* player = dComIfGp_getPlayer(0); s16 angle_to_player = player->shape_angle.y - (fopAcM_searchPlayerAngleY(a_this) + 0x8000); + // 182.04 is close to the degree -> short constant, but not quite, + // maybe someone calculated it on their own and rounded it off? s16 bibiri_angle = 182.04f * l_HIO.mReactionAngle; if (angle_to_player < bibiri_angle && angle_to_player > (s16)-bibiri_angle) { diff --git a/src/d/actor/d_a_npc_cd2.cpp b/src/d/actor/d_a_npc_cd2.cpp index 227ea5703b..503bff2d3f 100644 --- a/src/d/actor/d_a_npc_cd2.cpp +++ b/src/d/actor/d_a_npc_cd2.cpp @@ -815,7 +815,7 @@ static inline s16 Cd2_HIO_jntRZ(int param_1, int param_2) { } else { rv = l_Cd2_HIO.field_0x20c4[param_1 - 16].field_0x004[param_2].field_0x04.field_0x0C[2]; } - return 182.04444885253906f * rv; + return DEG2S(rv); } static inline s16 Cd2_HIO_jntRY(int param_1, int param_2) { @@ -825,7 +825,7 @@ static inline s16 Cd2_HIO_jntRY(int param_1, int param_2) { } else { rv = l_Cd2_HIO.field_0x20c4[param_1 - 16].field_0x004[param_2].field_0x04.field_0x0C[1]; } - return 182.04444885253906f * rv; + return DEG2S(rv); } static inline s16 Cd2_HIO_jntRX(int param_1, int param_2) { @@ -835,7 +835,7 @@ static inline s16 Cd2_HIO_jntRX(int param_1, int param_2) { } else { rv = l_Cd2_HIO.field_0x20c4[param_1 - 16].field_0x004[param_2].field_0x04.field_0x0C[0]; } - return 182.04444885253906f * rv; + return DEG2S(rv); } int daNpcCd2_c::jntNodeCB(J3DJoint* param_1, J3DModel* param_2) { diff --git a/src/d/actor/d_a_npc_chat.cpp b/src/d/actor/d_a_npc_chat.cpp index f650a01ffe..d4adad99d6 100644 --- a/src/d/actor/d_a_npc_chat.cpp +++ b/src/d/actor/d_a_npc_chat.cpp @@ -2872,15 +2872,15 @@ inline f32 JntTZ(int type, int jnt_no) { } inline s16 JntRX(int type, int jnt_no) { - return (type < 16 ? a_jntTbl_M[type].jntPrm[jnt_no].jntR[0] : a_jntTbl_W[type - 16].jntPrm[jnt_no].jntR[0]) * 182.04445f; + return DEG2S(type < 16 ? a_jntTbl_M[type].jntPrm[jnt_no].jntR[0] : a_jntTbl_W[type - 16].jntPrm[jnt_no].jntR[0]); } inline s16 JntRY(int type, int jnt_no) { - return (type < 16 ? a_jntTbl_M[type].jntPrm[jnt_no].jntR[1] : a_jntTbl_W[type - 16].jntPrm[jnt_no].jntR[1]) * 182.04445f; + return DEG2S(type < 16 ? a_jntTbl_M[type].jntPrm[jnt_no].jntR[1] : a_jntTbl_W[type - 16].jntPrm[jnt_no].jntR[1]); } inline s16 JntRZ(int type, int jnt_no) { - return (type < 16 ? a_jntTbl_M[type].jntPrm[jnt_no].jntR[2] : a_jntTbl_W[type - 16].jntPrm[jnt_no].jntR[2]) * 182.04445f; + return DEG2S(type < 16 ? a_jntTbl_M[type].jntPrm[jnt_no].jntR[2] : a_jntTbl_W[type - 16].jntPrm[jnt_no].jntR[2]); } int daNpcChat_c::ctrlJoint(J3DJoint* i_joint, J3DModel* i_model) { diff --git a/src/d/actor/d_a_obj_lv7PropellerY.cpp b/src/d/actor/d_a_obj_lv7PropellerY.cpp index 1725cd5bec..c1458bb9e0 100644 --- a/src/d/actor/d_a_obj_lv7PropellerY.cpp +++ b/src/d/actor/d_a_obj_lv7PropellerY.cpp @@ -199,7 +199,7 @@ void daPropY_c::init_modeMove2() { void daPropY_c::modeMove2() { cLib_chaseF(&speedF, l_HIO.max_rot_speed, l_HIO.rot_accel); - s16 temp_r30 = cLib_addCalcAngleS(&shape_angle.y, field_0x5b6, 1, (182.04445f * fopAcM_GetSpeedF(this)), 1); + s16 temp_r30 = cLib_addCalcAngleS(&shape_angle.y, field_0x5b6, 1, DEG2S(fopAcM_GetSpeedF(this)), 1); field_0x5c4 = 127.0f * (speedF / l_HIO.max_rot_speed); mDoAud_seStartLevel(Z2SE_OBJ_AMI_ROLL, ¤t.pos, field_0x5c4, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); @@ -240,7 +240,7 @@ void daPropY_c::modeStop() { if (mTurnType == 0) { var_r30 = cLib_addCalcAngleS(&shape_angle.y, field_0x5b6, 16, fopAcM_GetSpeedF(this), cM_deg2s(0.1f)); } else { - var_r30 = cLib_addCalcAngleS(&shape_angle.y, field_0x5b6, 1, (182.04445f * fopAcM_GetSpeedF(this)), 1); + var_r30 = cLib_addCalcAngleS(&shape_angle.y, field_0x5b6, 1, DEG2S(fopAcM_GetSpeedF(this)), 1); } // probably not a real version difference - GCN has fsub for some reason instead of fsubs diff --git a/src/d/actor/d_a_obj_magLiftRot.cpp b/src/d/actor/d_a_obj_magLiftRot.cpp index ca5970915a..ce64f16e90 100644 --- a/src/d/actor/d_a_obj_magLiftRot.cpp +++ b/src/d/actor/d_a_obj_magLiftRot.cpp @@ -242,8 +242,7 @@ void daMagLiftRot_c::init_modeMove() { void daMagLiftRot_c::modeMove() { cLib_chaseF(&speedF, l_HIO.mMaxSpeed, l_HIO.mAcceleration); - if (cLib_addCalcAngleS(¤t.angle.z, field_0x5e2, 1, fopAcM_GetSpeedF(this) * 182.04445f, - 1) == 0) + if (cLib_addCalcAngleS(¤t.angle.z, field_0x5e2, 1, DEG2S(fopAcM_GetSpeedF(this)), 1) == 0) { field_0x5e2 += 0x8000; field_0x5e4 = 0; diff --git a/src/d/actor/d_a_obj_mirror_chain.cpp b/src/d/actor/d_a_obj_mirror_chain.cpp index 65cd8c533a..75bb7fd32f 100644 --- a/src/d/actor/d_a_obj_mirror_chain.cpp +++ b/src/d/actor/d_a_obj_mirror_chain.cpp @@ -98,7 +98,7 @@ void dScissorBegin_packet_c::draw() { f32 sp2C = view_p->fovy; f32 sp28 = view_p->aspect; - f32 sp24 = std::tan(0.017453292f * (0.5f * sp2C)); + f32 sp24 = std::tan((M_PI / 180.0f) * (0.5f * sp2C)); f32 sp20, sp1C, sp18, sp14; view_port_class* viewport_p = dComIfGd_getViewport(); diff --git a/src/d/actor/d_a_obj_taFence.cpp b/src/d/actor/d_a_obj_taFence.cpp index 2a58db6e0d..ff6823ff43 100644 --- a/src/d/actor/d_a_obj_taFence.cpp +++ b/src/d/actor/d_a_obj_taFence.cpp @@ -353,7 +353,7 @@ void daTaFence_c::init_modeMove() { void daTaFence_c::modeMove() { cLib_chaseF(&speedF, mFallSpeed, mFallSpeed / 30.0f); - if (cLib_addCalcAngleS(&shape_angle.x, field_0x1384, 1, (182.04445f * fopAcM_GetSpeedF(this)), 1) == 0) { + if (cLib_addCalcAngleS(&shape_angle.x, field_0x1384, 1, DEG2S(fopAcM_GetSpeedF(this)), 1) == 0) { init_modeMoveEnd(); } } diff --git a/src/d/actor/d_a_obj_wood_pendulum.cpp b/src/d/actor/d_a_obj_wood_pendulum.cpp index 8cf29afb59..b762f6d1ce 100644 --- a/src/d/actor/d_a_obj_wood_pendulum.cpp +++ b/src/d/actor/d_a_obj_wood_pendulum.cpp @@ -64,7 +64,7 @@ int daObjWPndlm_c::Create() { if (arg0 == 0 || arg0 == 255) { arg0 = 0; } - field_0x958 = arg0 * 182.04445f; + field_0x958 = DEG2S(arg0); return 1; } diff --git a/src/d/d_camera.cpp b/src/d/d_camera.cpp index 00acd50d42..6ccde84b20 100644 --- a/src/d/d_camera.cpp +++ b/src/d/d_camera.cpp @@ -8498,7 +8498,7 @@ bool dCamera_c::observeCamera(s32 param_0) { } else if (mPadInfo.mMainStick.mLastPosX <= -0.75f) { sp50 = -1.0f; } else { - sp50 = dCamMath::rationalBezierRatio(mPadInfo.mMainStick.mLastPosX * 1.3333334f, dVar8); + sp50 = dCamMath::rationalBezierRatio(mPadInfo.mMainStick.mLastPosX * (4.0f / 3.0f), dVar8); } if (mPadInfo.mMainStick.mLastPosY >= 0.75f) { @@ -8506,7 +8506,7 @@ bool dCamera_c::observeCamera(s32 param_0) { } else if (mPadInfo.mMainStick.mLastPosY <= -0.75f) { sp54 = -1.0f; } else { - sp54 = dCamMath::rationalBezierRatio(mPadInfo.mMainStick.mLastPosY * 1.3333334f, dVar8); + sp54 = dCamMath::rationalBezierRatio(mPadInfo.mMainStick.mLastPosY * (4.0f / 3.0f), dVar8); } if (dComIfGs_getOptCameraControl() != 0) { diff --git a/src/d/d_demo.cpp b/src/d/d_demo.cpp index d3332240bf..b4433c5e02 100644 --- a/src/d/d_demo.cpp +++ b/src/d/d_demo.cpp @@ -397,9 +397,9 @@ void dDemo_actor_c::JSGSetScaling(Vec const& i_scale) { } void dDemo_actor_c::JSGSetRotation(Vec const& i_rotate) { - mRotate.x = i_rotate.x * 182.04444885253906f; - mRotate.y = i_rotate.y * 182.04444885253906f; - mRotate.z = i_rotate.z * 182.04444885253906f; + mRotate.x = DEG2S(i_rotate.x); + mRotate.y = DEG2S(i_rotate.y); + mRotate.z = DEG2S(i_rotate.z); onEnable(ENABLE_ROTATE_e); } @@ -560,8 +560,8 @@ f32 dDemo_camera_c::JSGGetViewRoll() const { if (view == NULL) { return 0.0f; } - - return view->bank * 0.0054931640625f; + + return S2DEG(view->bank); } void dDemo_camera_c::JSGSetViewRoll(f32 i_roll) { diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index 6d90b08181..ddea5f1128 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -1544,7 +1544,7 @@ int dDlst_shadowControl_c::setReal(u32 param_1, s8 param_2, J3DModel* param_3, c }; f32 fVar1; - f32 dVar16 = (param_2 == 0) ? 1.0f : (1.0f - 0.003000000026077032f * param_6); + f32 dVar16 = (param_2 == 0) ? 1.0f : (1.0f - 0.003f * param_6); if (dVar16 <= 0.0f) { return 0; } @@ -1558,8 +1558,7 @@ int dDlst_shadowControl_c::setReal(u32 param_1, s8 param_2, J3DModel* param_3, c } f32 dVar17 = acStack_94.z + param_5; if (dVar17 < -1000.0f) { - f32 fVar1 = 0.0010000000474974513f * - (-1000.0f - dVar17); + f32 fVar1 = 0.001f * (-1000.0f - dVar17); if (fVar1 >= 1.0f) { return 0; } diff --git a/src/d/d_ev_camera.cpp b/src/d/d_ev_camera.cpp index ac2d2ca32f..bfa0be490a 100644 --- a/src/d/d_ev_camera.cpp +++ b/src/d/d_ev_camera.cpp @@ -3348,8 +3348,8 @@ bool dCamera_c::possessedEvCamera() { cXyz sp60; mDoLib_project(&mEyePos, &sp60); SetBlurePosition(sp60.x / scissor->width, sp60.y / scissor->height, 0.0f); - SetBlureAlpha((fVar1 * 0.699999988079071f) + 0.5f); - SetBlureScale((fVar1 * 0.09000000357627869f) + 1.1f, 0.98f - (fVar1 * 0.18000000715255737f), 0.0f); + SetBlureAlpha((fVar1 * 0.7f) + 0.5f); + SetBlureScale((fVar1 * 0.09f) + 1.1f, 0.98f - (fVar1 * 0.18f), 0.0f); } } diff --git a/src/d/d_file_select.cpp b/src/d/d_file_select.cpp index 153811b6fe..efd4dff429 100644 --- a/src/d/d_file_select.cpp +++ b/src/d/d_file_select.cpp @@ -5439,7 +5439,7 @@ void dFile_select3D_c::toItem3Dpos(f32 param_0, f32 param_1, f32 param_2, cXyz* param_1 = (2.0f * ((param_1 - -100.0f) / 448.0f) - 1.0f); calcViewMtx(adStack_98); cMtx_inverse(adStack_98, auStack_c8); - f32 tangent = std::tan(0.39269909262657166); + f32 tangent = std::tan(M_PI / 8.0f); f32 dVar12 = -param_2; cXyz cStack_d4((param_0 * param_2) * (mDoGph_gInf_c::getAspect() * tangent), (tangent * (param_1 * dVar12)), dVar12); diff --git a/src/d/d_kankyo_rain.cpp b/src/d/d_kankyo_rain.cpp index ae2cfd0210..3769ab6f10 100644 --- a/src/d/d_kankyo_rain.cpp +++ b/src/d/d_kankyo_rain.cpp @@ -117,7 +117,7 @@ void dKyr_lenzflare_move() { dKyr_get_vectle_calc(¢er, &proj, &vect); lenz_packet->field_0x94 = cM_atan2s(vect.x, vect.y); - lenz_packet->field_0x94 *= 0.0054931640625f; // Maybe 45 / 8192 + lenz_packet->field_0x94 *= S2DEG_CONSTANT; // convert from short angle to degrees lenz_packet->field_0x94 += 180.0f; dKyr_get_vectle_calc(&camera->lookat.eye, &camera->lookat.center, &camFwd); diff --git a/src/d/d_map.cpp b/src/d/d_map.cpp index 922a0aea39..a26715f9d7 100644 --- a/src/d/d_map.cpp +++ b/src/d/d_map.cpp @@ -775,7 +775,7 @@ void dMap_c::changeTextureSize(int param_1, int param_2, int param_3) { mTexSizeH = param_2 >> param_3; u32 imageSize = GXGetTexBufferSize(mTexSizeW, mTexSizeH, 9, 0, 0); - OS_REPORT("imageSize<%d> <%d kbyte>mTexSizeW<%d>mTexSizeH<%d>\n", imageSize, imageSize * 0.0009765625f, mTexSizeW, mTexSizeH); + OS_REPORT("imageSize<%d> <%d kbyte>mTexSizeW<%d>mTexSizeH<%d>\n", imageSize, imageSize * (1.0f / 1024.f), mTexSizeW, mTexSizeH); JUT_ASSERT(2682, mImage_p != NULL); diff --git a/src/m_Do/m_Do_lib.cpp b/src/m_Do/m_Do_lib.cpp index fb592da49f..9b68a1a1c3 100644 --- a/src/m_Do/m_Do_lib.cpp +++ b/src/m_Do/m_Do_lib.cpp @@ -46,7 +46,7 @@ void mDoLib_clipper::setup(f32 fovy, f32 aspect, f32 near, f32 far) { mSystemFar = far; mClipper.calcViewFrustum(); - s16 tmp = fovy * 182.04444885253906f; + s16 tmp = DEG2S(fovy); mFovyRate = cM_scos(tmp) / cM_ssin(tmp); }