From 61b864a89ce9a98c1280c13ae818fd848432cf6c Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sun, 13 Mar 2022 19:46:46 +0100 Subject: [PATCH] Angle cleanup - `RADF_TO_BINANG` (#1155) * Run formatter * Touch up angle macros (parentheses and hex constants) * Use `RADF_TO_BINANG` more --- include/z64math.h | 16 +++++------ src/code/sys_matrix.c | 20 +++++++------- src/code/z_actor.c | 4 +-- src/code/z_camera.c | 2 +- src/code/z_path.c | 2 +- src/code/z_player_lib.c | 4 +-- .../actors/ovl_Boss_Dodongo/z_boss_dodongo.c | 6 ++--- src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c | 4 +-- .../ovl_Boss_Ganondrof/z_boss_ganondrof.c | 2 +- src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c | 8 +++--- src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c | 27 +++++++++---------- .../actors/ovl_Demo_Effect/z_demo_effect.c | 6 ++--- src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c | 4 +-- src/overlays/actors/ovl_En_Bw/z_en_bw.c | 4 +-- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 4 +-- src/overlays/actors/ovl_En_Cs/z_en_cs.c | 4 +-- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 6 ++--- .../z_en_daiku_kakariko.c | 2 +- .../actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c | 2 +- .../actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c | 16 +++++------ src/overlays/actors/ovl_En_Fd/z_en_fd.c | 4 +-- .../actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c | 19 +++++++------ src/overlays/actors/ovl_En_Fr/z_en_fr.c | 4 +-- src/overlays/actors/ovl_En_Fw/z_en_fw.c | 2 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 2 +- src/overlays/actors/ovl_En_Goma/z_en_goma.c | 4 +-- .../actors/ovl_En_Heishi1/z_en_heishi1.c | 2 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 11 ++++---- .../ovl_En_Horse_Ganon/z_en_horse_ganon.c | 2 +- .../ovl_En_Horse_Normal/z_en_horse_normal.c | 4 +-- .../ovl_En_Horse_Zelda/z_en_horse_zelda.c | 2 +- .../actors/ovl_En_Kanban/z_en_kanban.c | 2 +- src/overlays/actors/ovl_En_Kz/z_en_kz.c | 2 +- src/overlays/actors/ovl_En_Nb/z_en_nb.c | 4 +-- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 9 +++---- .../actors/ovl_En_Niw_Girl/z_en_niw_girl.c | 2 +- src/overlays/actors/ovl_En_Ru1/z_en_ru1.c | 2 +- .../actors/ovl_En_Siofuki/z_en_siofuki.c | 2 +- .../actors/ovl_En_Stream/z_en_stream.c | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- .../ovl_En_Syateki_Niw/z_en_syateki_niw.c | 8 +++--- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 2 +- .../actors/ovl_En_Vb_Ball/z_en_vb_ball.c | 2 +- src/overlays/actors/ovl_En_Zl2/z_en_zl2.c | 2 +- src/overlays/actors/ovl_En_Zl3/z_en_zl3.c | 8 +++--- 45 files changed, 120 insertions(+), 128 deletions(-) diff --git a/include/z64math.h b/include/z64math.h index 4ceea2bb63..cdb40ba014 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -94,15 +94,15 @@ typedef struct { #define IS_ZERO(f) (fabsf(f) < 0.008f) // Trig macros -#define DEGF_TO_BINANG(degreesf) (s16)(degreesf * 182.04167f + .5f) -#define RADF_TO_BINANG(radf) (s16)(radf * (32768.0f / M_PI)) -#define RADF_TO_DEGF(radf) (radf * (180.0f / M_PI)) -#define DEGF_TO_RADF(degf) (degf * (M_PI / 180.0f)) -#define BINANG_ROT180(angle) ((s16)(angle - 0x7FFF)) -#define BINANG_SUB(a, b) ((s16)(a - b)) +#define DEGF_TO_BINANG(degreesf) (s16)((degreesf) * 182.04167f + .5f) +#define RADF_TO_BINANG(radf) (s16)((radf) * (0x8000 / M_PI)) +#define RADF_TO_DEGF(radf) ((radf) * (180.0f / M_PI)) +#define DEGF_TO_RADF(degf) ((degf) * (M_PI / 180.0f)) +#define BINANG_ROT180(angle) ((s16)((angle) - 0x7FFF)) +#define BINANG_SUB(a, b) ((s16)((a) - (b))) #define DEG_TO_RAD(degrees) ((degrees) * (M_PI / 180.0f)) -#define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) -#define BINANG_TO_RAD(binang) (((f32)binang / 32768.0f) * M_PI) +#define BINANG_TO_DEGF(binang) ((f32)(binang) * (360.0001525f / 65535.0f)) +#define BINANG_TO_RAD(binang) (((f32)(binang) / (f32)0x8000) * M_PI) // Vector macros #define SQXZ(vec) ((vec.x) * (vec.x) + (vec.z) * (vec.z)) diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 9f44a99318..42ca0b2a01 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -769,17 +769,17 @@ void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag) { temp = mf->xz; temp *= temp; temp += SQ(mf->zz); - rotDest->x = Math_FAtan2F(-mf->yz, sqrtf(temp)) * (0x8000 / M_PI); + rotDest->x = RADF_TO_BINANG(Math_FAtan2F(-mf->yz, sqrtf(temp))); if ((rotDest->x == 0x4000) || (rotDest->x == -0x4000)) { rotDest->z = 0; - rotDest->y = Math_FAtan2F(-mf->zx, mf->xx) * (0x8000 / M_PI); + rotDest->y = RADF_TO_BINANG(Math_FAtan2F(-mf->zx, mf->xx)); } else { - rotDest->y = Math_FAtan2F(mf->xz, mf->zz) * (0x8000 / M_PI); + rotDest->y = RADF_TO_BINANG(Math_FAtan2F(mf->xz, mf->zz)); if (!flag) { - rotDest->z = Math_FAtan2F(mf->yx, mf->yy) * (0x8000 / M_PI); + rotDest->z = RADF_TO_BINANG(Math_FAtan2F(mf->yx, mf->yy)); } else { temp = mf->xx; temp2 = mf->zx; @@ -804,7 +804,7 @@ void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag) { /* for a rotation matrix, temp == yx and temp2 == yy * which is the same as in the !flag branch */ - rotDest->z = Math_FAtan2F(temp, temp2) * (0x8000 / M_PI); + rotDest->z = RADF_TO_BINANG(Math_FAtan2F(temp, temp2)); } } } @@ -822,16 +822,16 @@ void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag) { temp = mf->xx; temp *= temp; temp += SQ(mf->yx); - rotDest->y = Math_FAtan2F(-mf->zx, sqrtf(temp)) * (0x8000 / M_PI); + rotDest->y = RADF_TO_BINANG(Math_FAtan2F(-mf->zx, sqrtf(temp))); if ((rotDest->y == 0x4000) || (rotDest->y == -0x4000)) { rotDest->x = 0; - rotDest->z = Math_FAtan2F(-mf->xy, mf->yy) * (0x8000 / M_PI); + rotDest->z = RADF_TO_BINANG(Math_FAtan2F(-mf->xy, mf->yy)); } else { - rotDest->z = Math_FAtan2F(mf->yx, mf->xx) * (0x8000 / M_PI); + rotDest->z = RADF_TO_BINANG(Math_FAtan2F(mf->yx, mf->xx)); if (!flag) { - rotDest->x = Math_FAtan2F(mf->zy, mf->zz) * (0x8000 / M_PI); + rotDest->x = RADF_TO_BINANG(Math_FAtan2F(mf->zy, mf->zz)); } else { // see Matrix_MtxFToYXZRotS temp = mf->xy; @@ -853,7 +853,7 @@ void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag) { temp2 = sqrtf(temp2); temp2 = temp3 / temp2; - rotDest->x = Math_FAtan2F(temp, temp2) * (0x8000 / M_PI); + rotDest->x = RADF_TO_BINANG(Math_FAtan2F(temp, temp2)); } } } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 2301446ab0..816d98d633 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4179,12 +4179,12 @@ void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2) { sp38 = Math_SinS(arg1); sp34 = Math_CosS(arg1); sp28 = (-(floorPolyNormalX * sp38) - (floorPolyNormalZ * sp34)); - arg2->x = -(s16)(Math_FAtan2F(sp28 * floorPolyNormalY, 1.0f) * (32768 / M_PI)); + arg2->x = -RADF_TO_BINANG(Math_FAtan2F(sp28 * floorPolyNormalY, 1.0f)); sp2C = Math_SinS(arg1 - 16375); sp30 = Math_CosS(arg1 - 16375); sp24 = (-(floorPolyNormalX * sp2C) - (floorPolyNormalZ * sp30)); - arg2->z = -(s16)(Math_FAtan2F(sp24 * floorPolyNormalY, 1.0f) * (32768 / M_PI)); + arg2->z = -RADF_TO_BINANG(Math_FAtan2F(sp24 * floorPolyNormalY, 1.0f)); } } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 7e731b42e7..a3eaefeb0c 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -951,7 +951,7 @@ s32 func_800458D4(Camera* camera, VecSph* eyeAtDir, f32 arg2, f32* arg3, s16 arg if (eyeAtAngle > DEGF_TO_RADF(OREG(32))) { if (1) {} - phi_f2 = 1.0f - sinf(DEGF_TO_RADF(eyeAtAngle - OREG(32))); + phi_f2 = 1.0f - sinf(eyeAtAngle - DEGF_TO_RADF(OREG(32))); } else if (eyeAtAngle < DEGF_TO_RADF(OREG(33))) { phi_f2 = 1.0f - sinf(DEGF_TO_RADF(OREG(33)) - eyeAtAngle); } else { diff --git a/src/code/z_path.c b/src/code/z_path.c index 8ff42c07aa..bfffb26745 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.c @@ -27,7 +27,7 @@ f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw) { dx = pointPos->x - actor->world.pos.x; dz = pointPos->z - actor->world.pos.z; - *yaw = Math_FAtan2F(dx, dz) * (32768 / M_PI); + *yaw = RADF_TO_BINANG(Math_FAtan2F(dx, dz)); return SQ(dx) + SQ(dz); } diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 7181830690..e3f95b7e95 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -852,14 +852,14 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, sp50 = Math_FAtan2F(sp58, sp60); - temp1 = (M_PI - (Math_FAtan2F(sp5C, sp58) + ((M_PI / 2) - sp50))) * (0x8000 / M_PI); + temp1 = RADF_TO_BINANG(M_PI - (Math_FAtan2F(sp5C, sp58) + ((M_PI / 2) - sp50))); temp1 = temp1 - skelAnime->jointTable[shinLimbIndex].z; if ((s16)(ABS(skelAnime->jointTable[shinLimbIndex].x) + ABS(skelAnime->jointTable[shinLimbIndex].y)) < 0) { temp1 += 0x8000; } - temp2 = (sp50 - sp54) * (0x8000 / M_PI); + temp2 = RADF_TO_BINANG(sp50 - sp54); rot->z -= temp2; skelAnime->jointTable[thighLimbIndex].z = skelAnime->jointTable[thighLimbIndex].z - temp2; diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index fc1db706fa..a3121a2aa7 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -694,7 +694,7 @@ void BossDodongo_Walk(BossDodongo* this, GlobalContext* globalCtx) { sp48 = sp4C->x - this->actor.world.pos.x; sp44 = sp4C->z - this->actor.world.pos.z; Math_SmoothStepToF(&this->unk_1E8, 2000.0f, 1.0f, this->unk_1EC * 80.0f, 0.0f); - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(sp48, sp44) * (0x8000 / M_PI), 5, + Math_SmoothStepToS(&this->actor.world.rot.y, RADF_TO_BINANG(Math_FAtan2F(sp48, sp44)), 5, (this->unk_1EC * this->unk_1E8), 5); Math_SmoothStepToS(&this->unk_1C4, 0, 2, 2000, 0); @@ -771,7 +771,7 @@ void BossDodongo_Roll(BossDodongo* this, GlobalContext* globalCtx) { sp4C = sp5C->x - this->actor.world.pos.x; sp48 = sp5C->z - this->actor.world.pos.z; Math_SmoothStepToF(&this->unk_1E8, 2000.0f, 1.0f, this->unk_1EC * 100.0f, 0.0f); - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(sp4C, sp48) * (0x8000 / M_PI), 5, + Math_SmoothStepToS(&this->actor.world.rot.y, RADF_TO_BINANG(Math_FAtan2F(sp4C, sp48)), 5, this->unk_1EC * this->unk_1E8, 0); if (fabsf(sp4C) <= 15.0f && fabsf(sp48) <= 15.0f) { @@ -1403,7 +1403,7 @@ void BossDodongo_DeathCutscene(BossDodongo* this, GlobalContext* globalCtx) { tempSin = cornerPos->x - this->actor.world.pos.x; tempCos = cornerPos->z - this->actor.world.pos.z; Math_SmoothStepToF(&this->unk_1E8, 1500.0f, 1.0f, this->unk_1EC * 100.0f, 0.0f); - Math_SmoothStepToS(&this->actor.world.rot.y, (Math_FAtan2F(tempSin, tempCos) * (0x8000 / M_PI)), 5, + Math_SmoothStepToS(&this->actor.world.rot.y, RADF_TO_BINANG(Math_FAtan2F(tempSin, tempCos)), 5, (this->unk_1EC * this->unk_1E8), 0); if ((fabsf(tempSin) <= 15.0f) && (fabsf(tempCos) <= 15.0f)) { diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index 89721137bc..31cbf1f2d8 100644 --- a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -289,8 +289,8 @@ void BossFd_Fly(BossFd* this, GlobalContext* globalCtx) { this->fwork[BFD_FLY_WOBBLE_AMP]; dz += Math_SinS((1796.0f + this->fwork[BFD_FLY_WOBBLE_RATE]) * this->work[BFD_MOVE_TIMER]) * this->fwork[BFD_FLY_WOBBLE_AMP]; - angleToTarget = (s16)(Math_FAtan2F(dx, dz) * (0x8000 / M_PI)); - pitchToTarget = (s16)(Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz))) * (0x8000 / M_PI)); + angleToTarget = RADF_TO_BINANG(Math_FAtan2F(dx, dz)); + pitchToTarget = RADF_TO_BINANG(Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz)))); osSyncPrintf("MODE %d\n", this->work[BFD_ACTION_STATE]); diff --git a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c index f7d746dde6..29e4b6040c 100644 --- a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c +++ b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c @@ -844,7 +844,7 @@ void BossGanondrof_Charge(BossGanondrof* this, GlobalContext* globalCtx) { vecToLink.z = playerx->world.pos.z - thisx->world.pos.z; thisx->world.rot.y = thisx->shape.rot.y; thisx->world.rot.x = - Math_FAtan2F(vecToLink.y, sqrtf(SQ(vecToLink.x) + SQ(vecToLink.z))) * (0x8000 / M_PI); + RADF_TO_BINANG(Math_FAtan2F(vecToLink.y, sqrtf(SQ(vecToLink.x) + SQ(vecToLink.z)))); } func_8002D908(thisx); diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index 039381ab79..7119b38900 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -1277,8 +1277,8 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { dz = this->targetPos.z - this->cameraEye.z; tempY = Math_FAtan2F(dx, dz); tempX = Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz))); - Math_ApproachS(&this->actor.world.rot.y, tempY * (0x8000 / M_PI), 5, this->cameraYawRate); - Math_ApproachS(&this->actor.world.rot.x, tempX * (0x8000 / M_PI), 5, this->cameraYawRate); + Math_ApproachS(&this->actor.world.rot.y, RADF_TO_BINANG(tempY), 5, this->cameraYawRate); + Math_ApproachS(&this->actor.world.rot.x, RADF_TO_BINANG(tempX), 5, this->cameraYawRate); if (this->work[MO_TENT_MOVE_TIMER] == 150) { this->cameraAtVel.x = fabsf(this->cameraAt.x - player->actor.world.pos.x); this->cameraAtVel.y = fabsf(this->cameraAt.y - player->actor.world.pos.y); @@ -2130,8 +2130,8 @@ void BossMo_Core(BossMo* this, GlobalContext* globalCtx) { spDC = this->targetPos.x - this->actor.world.pos.x; spD8 = this->targetPos.y - this->actor.world.pos.y; spD4 = this->targetPos.z - this->actor.world.pos.z; - spCC = (s16)(Math_FAtan2F(spDC, spD4) * (0x8000 / M_PI)); - spD0 = (s16)(Math_FAtan2F(spD8, sqrtf(SQ(spDC) + SQ(spD4))) * (0x8000 / M_PI)); + spCC = RADF_TO_BINANG(Math_FAtan2F(spDC, spD4)); + spD0 = RADF_TO_BINANG(Math_FAtan2F(spD8, sqrtf(SQ(spDC) + SQ(spD4)))); Math_ApproachS(&this->actor.world.rot.y, spCC, this->tentMaxAngle, this->tentSpeed); Math_ApproachS(&this->actor.world.rot.x, spD0, this->tentMaxAngle, this->tentSpeed); func_8002D908(&this->actor); diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 6cee44811e..562f7f7346 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -687,9 +687,9 @@ void BossTw_FlyTo(BossTw* this, GlobalContext* globalCtx) { yDiff = this->targetPos.y - this->actor.world.pos.y; zDiff = this->targetPos.z - this->actor.world.pos.z; - yawTarget = (s16)(Math_FAtan2F(xDiff, zDiff) * (32768.0f / M_PI)); + yawTarget = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - pitchTarget = (s16)(Math_FAtan2F(yDiff, xzDist) * (32768.0f / M_PI)); + pitchTarget = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); Math_ApproachS(&this->actor.world.rot.x, pitchTarget, 0xA, this->rotateSpeed); Math_ApproachS(&this->actor.world.rot.y, yawTarget, 0xA, this->rotateSpeed); @@ -2360,8 +2360,8 @@ void BossTw_DeathBall(BossTw* this, GlobalContext* globalCtx) { yDiff = this->targetPos.y - this->actor.world.pos.y; zDiff = this->targetPos.z - this->actor.world.pos.z; - yaw = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); - Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff))) * (32768 / M_PI), 5, + yaw = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); + Math_ApproachS(&this->actor.world.rot.x, RADF_TO_BINANG(Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff)))), 5, this->rotateSpeed); Math_ApproachS(&this->actor.world.rot.y, yaw, 5, this->rotateSpeed); func_8002D908(&this->actor); @@ -3924,10 +3924,10 @@ void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx) { yDiff = (player->actor.world.pos.y + 30.0f) - this->actor.world.pos.y; zDiff = player->actor.world.pos.z - this->actor.world.pos.z; // yaw - this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); // pitch distXZ = sqrtf(SQ(xDiff) + SQ(zDiff)); - this->actor.world.rot.x = Math_FAtan2F(yDiff, distXZ) * (32768 / M_PI); + this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(yDiff, distXZ)); this->actor.speedXZ = 20.0f; for (i = 0; i < 50; i++) { @@ -4114,9 +4114,9 @@ void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx) { xDiff = player->actor.world.pos.x - this->actor.world.pos.x; yDiff = (player->actor.world.pos.y + 30.0f) - this->actor.world.pos.y; zDiff = player->actor.world.pos.z - this->actor.world.pos.z; - this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - this->actor.world.rot.x = Math_FAtan2F(yDiff, xzDist) * (32768 / M_PI); + this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); this->actor.speedXZ = 20.0f; for (i = 0; i < 50; i++) { this->blastTailPos[i] = this->actor.world.pos; @@ -5383,9 +5383,9 @@ void BossTw_TwinrovaSetupFly(BossTw* this, GlobalContext* globalCtx) { this->actionFunc = BossTw_TwinrovaFly; this->rotateSpeed = 0.0f; this->actor.speedXZ = 0.0f; - this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - this->actor.world.rot.x = Math_FAtan2F(yDiff, xzDist) * (32768 / M_PI); + this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)); Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_032BF8, -10.0f); } @@ -5402,12 +5402,9 @@ void BossTw_TwinrovaFly(BossTw* this, GlobalContext* globalCtx) { xDiff = this->targetPos.x - this->actor.world.pos.x; yDiff = this->targetPos.y - this->actor.world.pos.y; zDiff = this->targetPos.z - this->actor.world.pos.z; - // Convert from radians to degrees, then degrees to binary angle - yaw = (s16)(Math_FAtan2F(xDiff, zDiff) * ((180.0f / M_PI) * (65536.0f / 360.0f))); + yaw = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); - Math_ApproachS(&this->actor.world.rot.x, - (f32)(s16)(Math_FAtan2F(yDiff, xzDist) * ((180.0f / M_PI) * (65536.0f / 360.0f))), 0xA, - this->rotateSpeed); + Math_ApproachS(&this->actor.world.rot.x, (f32)RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)), 0xA, this->rotateSpeed); Math_ApproachS(&this->actor.world.rot.y, yaw, 0xA, this->rotateSpeed); Math_ApproachS(&this->actor.shape.rot.y, yaw, 0xA, this->rotateSpeed); Math_ApproachF(&this->rotateSpeed, 2000.0f, 1.0f, 100.0f); diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index e54285d8cc..279f921b03 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -1471,7 +1471,7 @@ void DemoEffect_MoveJewelActivateDoorOfTime(DemoEffect* this, GlobalContext* glo } if (startPos.x != endPos.x || startPos.y != endPos.y || startPos.z != endPos.z) { - this->jewelCsRotation.x = Math_Atan2F(endPos.z - startPos.z, -(endPos.x - startPos.x)) * (0x8000 / M_PI); + this->jewelCsRotation.x = RADF_TO_BINANG(Math_Atan2F(endPos.z - startPos.z, -(endPos.x - startPos.x))); this->jewelCsRotation.y = Math_Vec3f_Yaw(&startPos, &endPos); } @@ -2093,8 +2093,8 @@ void DemoEffect_FaceToCsEndpoint(DemoEffect* this, Vec3f startPos, Vec3f endPos) f32 z = endPos.z - startPos.z; f32 xzDistance = sqrtf(SQ(x) + SQ(z)); - this->actor.shape.rot.y = Math_FAtan2F(x, z) * (32768.0f / M_PI); - this->actor.shape.rot.x = Math_FAtan2F(-(endPos.y - startPos.y), xzDistance) * (32768.0f / M_PI); + this->actor.shape.rot.y = RADF_TO_BINANG(Math_FAtan2F(x, z)); + this->actor.shape.rot.x = RADF_TO_BINANG(Math_FAtan2F(-(endPos.y - startPos.y), xzDistance)); } /** diff --git a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c index 1132f71d97..8b132280b4 100644 --- a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c +++ b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c @@ -550,10 +550,10 @@ void DemoGj_SetupMovement(DemoGj* this, GlobalContext* globalCtx) { zDistance = player->actor.world.pos.z - pos->z; if (xDistance != 0.0f || zDistance != 0.0f) { - actor->world.rot.y = (Math_FAtan2F(xDistance, zDistance) * (0x8000 / M_PI)); + actor->world.rot.y = RADF_TO_BINANG(Math_FAtan2F(xDistance, zDistance)); } } else { - actor->world.rot.y = (Math_FAtan2F(xDistance, zDistance) * (0x8000 / M_PI)); + actor->world.rot.y = RADF_TO_BINANG(Math_FAtan2F(xDistance, zDistance)); } } } diff --git a/src/overlays/actors/ovl_En_Bw/z_en_bw.c b/src/overlays/actors/ovl_En_Bw/z_en_bw.c index f27117ce75..5c2d082d4d 100644 --- a/src/overlays/actors/ovl_En_Bw/z_en_bw.c +++ b/src/overlays/actors/ovl_En_Bw/z_en_bw.c @@ -227,7 +227,7 @@ void func_809CEA24(EnBw* this, GlobalContext* globalCtx) { (this->unk_222 == 0)) { if (sp74 != NULL) { sp74 = SEGMENTED_TO_VIRTUAL(sp74); - sp62 = Math_FAtan2F(sp74->normal.x, sp74->normal.z) * ((f32)0x8000 / M_PI); + sp62 = RADF_TO_BINANG(Math_FAtan2F(sp74->normal.x, sp74->normal.z)); } else { sp62 = this->actor.world.rot.y + 0x8000; } @@ -305,7 +305,7 @@ void func_809CEA24(EnBw* this, GlobalContext* globalCtx) { &sp74, 1, 0, 0, 1); if (sp64 != 0) { sp74 = SEGMENTED_TO_VIRTUAL(sp74); - sp60 = Math_FAtan2F(sp74->normal.x, sp74->normal.z) * ((f32)0x8000 / M_PI); + sp60 = RADF_TO_BINANG(Math_FAtan2F(sp74->normal.x, sp74->normal.z)); if (this->unk_236 != sp60) { if ((s16)(this->actor.yawTowardsPlayer - sp60) >= 0) { this->unk_238 = 0x4000; diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index ebc4169b5c..e00ceb232b 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -445,9 +445,9 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx2) { // Calculate the direction for the Arwing to fly and the rotation for the Arwing // based on the Arwing's direction, and current rotation. - worldRotationTargetY = Math_FAtan2F(vectorToTargetX, vectorToTargetZ) * (0x8000 / M_PI); + worldRotationTargetY = RADF_TO_BINANG(Math_FAtan2F(vectorToTargetX, vectorToTargetZ)); worldRotationTargetX = - Math_FAtan2F(vectorToTargetY, sqrtf(SQ(vectorToTargetX) + SQ(vectorToTargetZ))) * (0x8000 / M_PI); + RADF_TO_BINANG(Math_FAtan2F(vectorToTargetY, sqrtf(SQ(vectorToTargetX) + SQ(vectorToTargetZ)))); if ((worldRotationTargetX < 0) && (this->actor.world.pos.y < this->actor.floorHeight + 20.0f)) { worldRotationTargetX = 0; } diff --git a/src/overlays/actors/ovl_En_Cs/z_en_cs.c b/src/overlays/actors/ovl_En_Cs/z_en_cs.c index da0eabc621..a23df708f2 100644 --- a/src/overlays/actors/ovl_En_Cs/z_en_cs.c +++ b/src/overlays/actors/ovl_En_Cs/z_en_cs.c @@ -290,7 +290,7 @@ s32 EnCs_HandleWalking(EnCs* this, GlobalContext* globalCtx) { EnCs_GetPathPoint(globalCtx->setupPathList, &pathPos, this->path, this->waypoint); xDiff = pathPos.x - this->actor.world.pos.x; zDiff = pathPos.z - this->actor.world.pos.z; - walkAngle1 = Math_FAtan2F(xDiff, zDiff) * (32768.0f / M_PI); + walkAngle1 = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); this->walkAngle = walkAngle1; this->walkDist = sqrtf((xDiff * xDiff) + (zDiff * zDiff)); @@ -305,7 +305,7 @@ s32 EnCs_HandleWalking(EnCs* this, GlobalContext* globalCtx) { EnCs_GetPathPoint(globalCtx->setupPathList, &pathPos, this->path, this->waypoint); xDiff = pathPos.x - this->actor.world.pos.x; zDiff = pathPos.z - this->actor.world.pos.z; - walkAngle2 = Math_FAtan2F(xDiff, zDiff) * (32768.0f / M_PI); + walkAngle2 = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); this->walkAngle = walkAngle2; this->walkDist = sqrtf((xDiff * xDiff) + (zDiff * zDiff)); } diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 4825ceed4c..9e6bba7258 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -411,7 +411,7 @@ void EnDaiku_InitEscape(EnDaiku* this, GlobalContext* globalCtx) { pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint; dx = pointPos->x - this->actor.world.pos.x; dz = pointPos->z - this->actor.world.pos.z; - this->rotYtowardsPath = Math_FAtan2F(dx, dz) * (0x8000 / M_PI); + this->rotYtowardsPath = RADF_TO_BINANG(Math_FAtan2F(dx, dz)); dxz = sqrtf(SQ(dx) + SQ(dz)); if (dxz > 10.0f) { exitLoop = true; @@ -499,7 +499,7 @@ void EnDaiku_EscapeSuccess(EnDaiku* this, GlobalContext* globalCtx) { Matrix_MultVec3f(&D_809E4148, &vec); gerudoGuard = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_GE3, this->initPos.x + vec.x, this->initPos.y + vec.y, - this->initPos.z + vec.z, 0, Math_FAtan2F(-vec.x, -vec.z) * (0x8000 / M_PI), 0, 2); + this->initPos.z + vec.z, 0, RADF_TO_BINANG(Math_FAtan2F(-vec.x, -vec.z)), 0, 2); if (gerudoGuard == NULL) { Actor_Kill(&this->actor); @@ -526,7 +526,7 @@ void EnDaiku_EscapeRun(EnDaiku* this, GlobalContext* globalCtx) { pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint; dx = pointPos->x - this->actor.world.pos.x; dz = pointPos->z - this->actor.world.pos.z; - ry = Math_FAtan2F(dx, dz) * (0x8000 / M_PI); + ry = RADF_TO_BINANG(Math_FAtan2F(dx, dz)); dxz = sqrtf(SQ(dx) + SQ(dz)); if (dxz <= 20.88f) { this->waypoint++; diff --git a/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.c b/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.c index b63180c9d1..0f46f53a7f 100644 --- a/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.c +++ b/src/overlays/actors/ovl_En_Daiku_Kakariko/z_en_daiku_kakariko.c @@ -364,7 +364,7 @@ void EnDaikuKakariko_Run(EnDaikuKakariko* this, GlobalContext* globalCtx) { pathPos = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->waypoint]; xDist = pathPos->x - this->actor.world.pos.x; zDist = pathPos->z - this->actor.world.pos.z; - runAngle = Math_FAtan2F(xDist, zDist) * (32768.0f / M_PI); + runAngle = RADF_TO_BINANG(Math_FAtan2F(xDist, zDist)); runDist = sqrtf((xDist * xDist) + (zDist * zDist)); run = false; diff --git a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c index fdee038582..2c1836ebe4 100644 --- a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c +++ b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c @@ -342,7 +342,7 @@ void EnDntJiji_Return(EnDntJiji* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); dx = this->flowerPos.x - this->actor.world.pos.x; dz = this->flowerPos.z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(dx, dz)), 1, 0xBB8, 0); this->actor.world.rot.y = this->actor.shape.rot.y; if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.velocity.y = 9.0f; diff --git a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c index 6afc570ddb..4cd11c07d5 100644 --- a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c +++ b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c @@ -303,7 +303,7 @@ void EnDntNomal_TargetWalk(EnDntNomal* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); dx = 1340.0f + 3.0f - this->actor.world.pos.x; dz = 0.0f - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 0x32, 0xBB8, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(dx, dz)), 0x32, 0xBB8, 0); this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); @@ -382,8 +382,8 @@ void EnDntNomal_TargetReturn(EnDntNomal* this, GlobalContext* globalCtx) { dx = this->flowerPos.x - this->actor.world.pos.x; dz = -180.0f - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 3, 0x1388, 0); - if (fabsf(this->actor.shape.rot.y - (s16)(Math_FAtan2F(dx, dz) * (0x8000 / M_PI))) < 20.0f) { + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(dx, dz)), 3, 0x1388, 0); + if (fabsf(this->actor.shape.rot.y - RADF_TO_BINANG(Math_FAtan2F(dx, dz))) < 20.0f) { this->actor.speedXZ = 1.0f; } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { @@ -453,7 +453,7 @@ void EnDntNomal_StageUp(EnDntNomal* this, GlobalContext* globalCtx) { f32 dx = this->targetPos.x - this->actor.world.pos.x; f32 dz = this->targetPos.z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(dx, dz)), 1, 0xBB8, 0); turnMod = 90.0f; } if ((Rand_ZeroFloat(10.0f + turnMod) < 1.0f) && (this->action != DNT_ACTION_ATTACK)) { @@ -525,7 +525,7 @@ void EnDntNomal_StageCelebrate(EnDntNomal* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; return; } - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 1, 0xBB8, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(dx, dz)), 1, 0xBB8, 0); this->actor.world.rot.y = this->actor.shape.rot.y; } else { if (this->timer1 == 1) { @@ -668,8 +668,8 @@ void EnDntNomal_StageAttack(EnDntNomal* this, GlobalContext* globalCtx) { dx = player->actor.world.pos.x - this->mouthPos.x; dy = player->actor.world.pos.y + 30.0f - this->mouthPos.y; dz = player->actor.world.pos.z - this->mouthPos.z; - Math_SmoothStepToS(&this->actor.shape.rot.x, -(s16)(Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz))) * (0x8000 / M_PI)), 3, - 0x1388, 0); + Math_SmoothStepToS(&this->actor.shape.rot.x, -RADF_TO_BINANG(Math_FAtan2F(dy, sqrtf(SQ(dx) + SQ(dz)))), 3, 0x1388, + 0); if ((frame >= this->endFrame) && (this->timer2 == 0)) { this->timer2 = (s16)Rand_ZeroFloat(10.0f) + 10; } @@ -721,7 +721,7 @@ void EnDntNomal_StageReturn(EnDntNomal* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); sp2C = this->flowerPos.x - this->actor.world.pos.x; sp28 = this->flowerPos.z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(sp2C, sp28) * (0x8000 / M_PI), 1, 0xBB8, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(sp2C, sp28)), 1, 0xBB8, 0); if (this->timer5 == 0) { this->timer5 = 10; } else if (!(this->timer5 & 1)) { diff --git a/src/overlays/actors/ovl_En_Fd/z_en_fd.c b/src/overlays/actors/ovl_En_Fd/z_en_fd.c index ab0ab20539..481b628051 100644 --- a/src/overlays/actors/ovl_En_Fd/z_en_fd.c +++ b/src/overlays/actors/ovl_En_Fd/z_en_fd.c @@ -518,7 +518,7 @@ void EnFd_Land(EnFd* this, GlobalContext* globalCtx) { this->spinTimer = Rand_S16Offset(60, 90); this->runRadius = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.home.pos); EnFd_GetPosAdjAroundCircle(&adjPos, this, this->runRadius, this->runDir); - this->actor.world.rot.y = Math_FAtan2F(adjPos.x, adjPos.z) * (0x8000 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(adjPos.x, adjPos.z)); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENFD_ANIM_4); this->actionFunc = EnFd_SpinAndSpawnFire; } @@ -619,7 +619,7 @@ void EnFd_Run(EnFd* this, GlobalContext* globalCtx) { } Math_SmoothStepToF(&this->runRadius, runRadiusTarget, 0.3f, 100.0f, 0.0f); EnFd_GetPosAdjAroundCircle(&adjPos, this, this->runRadius, this->runDir); - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(adjPos.x, adjPos.z) * (0x8000 / M_PI), 4, 0xFA0, 1); + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(adjPos.x, adjPos.z)), 4, 0xFA0, 1); this->actor.world.rot = this->actor.shape.rot; func_8002F974(&this->actor, NA_SE_EN_FLAME_RUN - SFX_FLAG); if (this->skelAnime.curFrame == 6.0f || this->skelAnime.curFrame == 13.0f || this->skelAnime.curFrame == 28.0f) { diff --git a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c index 6edec2e295..22b5de7445 100644 --- a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c +++ b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c @@ -150,9 +150,9 @@ void EnFhgFire_Init(Actor* thisx, GlobalContext* globalCtx) { dxL = player->actor.world.pos.x - this->actor.world.pos.x; dyL = player->actor.world.pos.y + 30.0f - this->actor.world.pos.y; dzL = player->actor.world.pos.z - this->actor.world.pos.z; - this->actor.world.rot.y = Math_FAtan2F(dxL, dzL) * (0x8000 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(dxL, dzL)); dxzL = sqrtf(SQ(dxL) + SQ(dzL)); - this->actor.world.rot.x = Math_FAtan2F(dyL, dxzL) * (0x8000 / M_PI); + this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(dyL, dxzL)); this->collider.dim.radius = 40; this->collider.dim.height = 50; this->collider.dim.yShift = -25; @@ -516,10 +516,9 @@ void EnFhgFire_EnergyBall(EnFhgFire* this, GlobalContext* globalCtx) { this->actor.speedXZ += 1.0f; } } - this->actor.world.rot.y = (s16)(Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI)) + angleModY; + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(dxPG, dzPG)) + angleModY; this->actor.world.rot.x = - (s16)(Math_FAtan2F(dyPG, sqrtf((dxPG * dxPG) + (dzPG * dzPG))) * (0x8000 / M_PI)) + - angleModX; + RADF_TO_BINANG(Math_FAtan2F(dyPG, sqrtf((dxPG * dxPG) + (dzPG * dzPG)))) + angleModX; this->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_BLUE; this->work[FHGFIRE_FX_TIMER] = 2; Audio_PlaySoundGeneral(NA_SE_IT_SWORD_REFLECT_MG, &player->actor.projectedPos, 4, &D_801333E0, @@ -537,7 +536,7 @@ void EnFhgFire_EnergyBall(EnFhgFire* this, GlobalContext* globalCtx) { break; case FHGFIRE_LIGHT_BLUE: if ((bossGnd->flyMode == GND_FLY_RETURN) && (this->work[FHGFIRE_RETURN_COUNT] < 100)) { - this->actor.world.rot.y = Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(dxPG, dzPG)); if ((sqrtf(SQ(dxPG) + SQ(dzPG)) < (150.0f + (this->actor.speedXZ * 8.0f)))) { this->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_REFLECT; bossGnd->returnSuccess = true; @@ -548,8 +547,8 @@ void EnFhgFire_EnergyBall(EnFhgFire* this, GlobalContext* globalCtx) { if ((sqrtf(SQ(dxPG) + SQ(dyPG) + SQ(dzPG)) < 100.0f)) { bossGnd->returnSuccess = true; } - this->actor.world.rot.y = Math_FAtan2F(dxPG, dzPG) * (0x8000 / M_PI); - this->actor.world.rot.x = Math_FAtan2F(dyPG, sqrtf(SQ(dxPG) + SQ(dzPG))) * (0x8000 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(dxPG, dzPG)); + this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(dyPG, sqrtf(SQ(dxPG) + SQ(dzPG)))); } if ((fabsf(dxPG) < 30.0f) && (fabsf(dzPG) < 30.0f) && (fabsf(dyPG) < 45.0f)) { killMode = BALL_IMPACT; @@ -574,9 +573,9 @@ void EnFhgFire_EnergyBall(EnFhgFire* this, GlobalContext* globalCtx) { EffectSsFhgFlash_SpawnLightBall(globalCtx, &this->actor.world.pos, &sp88, &sp7C, (s16)(Rand_ZeroOne() * 40.0f) + 80, FHGFLASH_LIGHTBALL_GREEN); } - this->actor.world.rot.y = Math_FAtan2F(dxL, dzL) * (0x8000 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(dxL, dzL)); dxzL = sqrtf(SQ(dxL) + SQ(dzL)); - this->actor.world.rot.x = Math_FAtan2F(dyL, dxzL) * (0x8000 / M_PI); + this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(dyL, dxzL)); this->work[FHGFIRE_FIRE_MODE] = FHGFIRE_LIGHT_GREEN; Audio_PlayActorSound2(&this->actor, NA_SE_IT_SWORD_REFLECT_MG); this->actor.speedXZ += 2.0f; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index 60da9551a8..76b08717d3 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -210,7 +210,7 @@ void EnFr_OrientUnderwater(EnFr* this) { this->actor.world.pos.z = this->posLogSpot.z + vec2.z; this->actor.world.pos.y = sLogSpotToFromWater[this->actor.params].yDist + this->posLogSpot.y; this->actor.world.rot.y = this->actor.shape.rot.y = - (s16)(sLogSpotToFromWater[this->actor.params].yaw * ((f32)0x8000 / M_PI)) + 0x8000; + RADF_TO_BINANG(sLogSpotToFromWater[this->actor.params].yaw) + 0x8000; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; @@ -445,7 +445,7 @@ void EnFr_OrientOnLogSpot(EnFr* this, GlobalContext* globalCtx) { void EnFr_ChooseJumpFromLogSpot(EnFr* this, GlobalContext* globalCtx) { if (sEnFrPointers.flags == 12) { - this->actor.world.rot.y = ((f32)0x8000 / M_PI) * sLogSpotToFromWater[this->actor.params].yaw; + this->actor.world.rot.y = RADF_TO_BINANG(sLogSpotToFromWater[this->actor.params].yaw); Animation_Change(&this->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, Animation_GetLastFrame(&object_fr_Anim_0007BC), ANIMMODE_ONCE, 0.0f); this->actionFunc = EnFr_JumpingBackIntoWater; diff --git a/src/overlays/actors/ovl_En_Fw/z_en_fw.c b/src/overlays/actors/ovl_En_Fw/z_en_fw.c index 4eba7888ee..35826f10d5 100644 --- a/src/overlays/actors/ovl_En_Fw/z_en_fw.c +++ b/src/overlays/actors/ovl_En_Fw/z_en_fw.c @@ -296,7 +296,7 @@ void EnFw_Run(EnFw* this, GlobalContext* globalCtx) { } else { Vec3f sp48; EnFw_GetPosAdjAroundCircle(&sp48, this, this->runRadius, this->runDirection); - Math_SmoothStepToS(&this->actor.shape.rot.y, (Math_FAtan2F(sp48.x, sp48.z) * (0x8000 / M_PI)), 4, 0xFA0, 1); + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(sp48.x, sp48.z)), 4, 0xFA0, 1); } this->actor.world.rot = this->actor.shape.rot; diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 6ffc88622e..182a21e485 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -476,7 +476,7 @@ s32 EnGo_FollowPath(EnGo* this, GlobalContext* globalCtx) { pointPos += this->unk_218; xDist = pointPos->x - this->actor.world.pos.x; zDist = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, (s16)(Math_FAtan2F(xDist, zDist) * ((f32)0x8000 / M_PI)), 10, 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, RADF_TO_BINANG(Math_FAtan2F(xDist, zDist)), 10, 1000, 1); if ((SQ(xDist) + SQ(zDist)) < 600.0f) { this->unk_218++; diff --git a/src/overlays/actors/ovl_En_Goma/z_en_goma.c b/src/overlays/actors/ovl_En_Goma/z_en_goma.c index 41ecc223d9..d64dad410f 100644 --- a/src/overlays/actors/ovl_En_Goma/z_en_goma.c +++ b/src/overlays/actors/ovl_En_Goma/z_en_goma.c @@ -690,8 +690,8 @@ void EnGoma_SetFloorRot(EnGoma* this) { nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - Math_ApproachS(&this->slopePitch, -Math_FAtan2F(-nz * ny, 1.0f) * (0x8000 / M_PI), 1, 1000); - Math_ApproachS(&this->slopeRoll, Math_FAtan2F(-nx * ny, 1.0f) * (0x8000 / M_PI), 1, 1000); + Math_ApproachS(&this->slopePitch, RADF_TO_BINANG(-Math_FAtan2F(-nz * ny, 1.0f)), 1, 1000); + Math_ApproachS(&this->slopeRoll, RADF_TO_BINANG(Math_FAtan2F(-nx * ny, 1.0f)), 1, 1000); } } diff --git a/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c b/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c index 3418e15d15..325b4c9409 100644 --- a/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c +++ b/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c @@ -165,7 +165,7 @@ void EnHeishi1_Walk(EnHeishi1* this, GlobalContext* globalCtx) { pathDiffX = pointPos->x - this->actor.world.pos.x; pathDiffZ = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, (Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI)), 3, + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(pathDiffX, pathDiffZ)), 3, this->bodyTurnSpeed, 0); Math_ApproachF(&this->bodyTurnSpeed, this->bodyTurnSpeedTarget, 1.0f, this->bodyTurnSpeedMax); diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 5b78936d99..7ab3fd1173 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -2936,7 +2936,7 @@ void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { return; } - floorSlope = Math_FAtan2F(this->yBack - this->yFront, 60.0f) * (0x8000 / M_PI); + floorSlope = RADF_TO_BINANG(Math_FAtan2F(this->yBack - this->yFront, 60.0f)); if (this->actor.floorPoly != 0) { nx = this->actor.floorPoly->normal.x * COLPOLY_NORMAL_FRAC; ny = this->actor.floorPoly->normal.y * COLPOLY_NORMAL_FRAC; @@ -3035,7 +3035,7 @@ void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { *stickMag = *stickMag; } - *angle = Math_FAtan2F(-curStick->x, curStick->y) * (32768.0f / M_PI); + *angle = RADF_TO_BINANG(Math_FAtan2F(-curStick->x, curStick->y)); } void EnHorse_UpdateStick(EnHorse* this, GlobalContext* globalCtx) { @@ -3054,9 +3054,8 @@ void EnHorse_ResolveCollision(EnHorse* this, GlobalContext* globalCtx, Collision nx = COLPOLY_GET_NORMAL(colPoly->normal.x); ny = COLPOLY_GET_NORMAL(colPoly->normal.y); nz = COLPOLY_GET_NORMAL(colPoly->normal.z); - if (!(Math_CosS(this->actor.world.rot.y - - (s16)(Math_FAtan2F(colPoly->normal.x, colPoly->normal.z) * (0x8000 / M_PI)) - 0x7FFF) < - 0.7071f)) { // cos(45 degrees) + if (!(Math_CosS(this->actor.world.rot.y - RADF_TO_BINANG(Math_FAtan2F(colPoly->normal.x, colPoly->normal.z)) - + 0x7FFF) < 0.7071f)) { // cos(45 degrees) dist = Math3D_DistPlaneToPos(nx, ny, nz, colPoly->dist, &this->actor.world.pos); offset = (1.0f / sqrtf(SQ(nx) + SQ(nz))); offset = (30.0f - dist) * offset; @@ -3175,7 +3174,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { if (intersectDist < 30.0f) { EnHorse_ResolveCollision(this, globalCtx, wall); } - if ((Math_CosS(this->actor.world.rot.y - (s16)(Math_FAtan2F(wall->normal.x, wall->normal.z) * (0x8000 / M_PI)) - + if ((Math_CosS(this->actor.world.rot.y - RADF_TO_BINANG(Math_FAtan2F(wall->normal.x, wall->normal.z)) - 0x7FFF) < 0.5f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, wall, bgId) != 0) { return; diff --git a/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.c b/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.c index b3ec08c2c1..ab0e586e67 100644 --- a/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.c +++ b/src/overlays/actors/ovl_En_Horse_Ganon/z_en_horse_ganon.c @@ -280,7 +280,7 @@ void func_80A68E14(EnHorseGanon* this, GlobalContext* globalCtx) { temp_ret = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &col, &temp1, &v); this->unk_1F4 = temp_ret; - this->actor.shape.rot.x = (0x8000 / M_PI) * Math_FAtan2F(this->actor.world.pos.y - temp_ret, 30.0f); + this->actor.shape.rot.x = RADF_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - temp_ret, 30.0f)); } void EnHorseGanon_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.c b/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.c index f39ac68a62..6548fb8f87 100644 --- a/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.c +++ b/src/overlays/actors/ovl_En_Horse_Normal/z_en_horse_normal.c @@ -295,7 +295,7 @@ void EnHorseNormal_FollowPath(EnHorseNormal* this, GlobalContext* globalCtx) { pointPos += this->waypoint; dx = pointPos->x - this->actor.world.pos.x; dz = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 0xA, 0x7D0, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, RADF_TO_BINANG(Math_FAtan2F(dx, dz)), 0xA, 0x7D0, 1); this->actor.shape.rot.y = this->actor.world.rot.y; if (SQ(dx) + SQ(dz) < 600.0f) { this->waypoint++; @@ -556,7 +556,7 @@ void func_80A6C8E0(EnHorseNormal* this, GlobalContext* globalCtx) { sp28.y = this->actor.world.pos.y + 60.0f; sp28.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z; this->unk_220 = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp38, &sp24, &sp28); - this->actor.shape.rot.x = Math_FAtan2F(this->actor.world.pos.y - this->unk_220, 30.0f) * (0x8000 / M_PI); + this->actor.shape.rot.x = RADF_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->unk_220, 30.0f)); } static EnHorseNormalActionFunc sActionFuncs[] = { diff --git a/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.c b/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.c index a885581b0b..eb82958201 100644 --- a/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.c +++ b/src/overlays/actors/ovl_En_Horse_Zelda/z_en_horse_zelda.c @@ -223,7 +223,7 @@ void func_80A6DE38(EnHorseZelda* this, GlobalContext* globalCtx) { pos.y = this->actor.world.pos.y + 60.0f; pos.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z; this->unk_1F4 = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &pos); - this->actor.shape.rot.x = Math_FAtan2F(this->actor.world.pos.y - this->unk_1F4, 30.0f) * (0x8000 / M_PI); + this->actor.shape.rot.x = RADF_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->unk_1F4, 30.0f)); } void EnHorseZelda_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index d85135bd34..0ac8cceb2e 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -694,7 +694,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actionState = ENKANBAN_AIR; this->actor.gravity = -1.0f; - this->actor.world.rot.y = Math_FAtan2F(dx, dz) * (0x8000 / M_PI); + this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(dx, dz)); if (this->partCount >= 4) { this->bounceX = (s16)Rand_ZeroFloat(10.0f) + 6; this->bounceZ = (s16)Rand_ZeroFloat(10.0f) + 6; diff --git a/src/overlays/actors/ovl_En_Kz/z_en_kz.c b/src/overlays/actors/ovl_En_Kz/z_en_kz.c index a63d6c52b5..0e95543885 100644 --- a/src/overlays/actors/ovl_En_Kz/z_en_kz.c +++ b/src/overlays/actors/ovl_En_Kz/z_en_kz.c @@ -284,7 +284,7 @@ s32 EnKz_FollowPath(EnKz* this, GlobalContext* globalCtx) { pathDiffX = pointPos->x - this->actor.world.pos.x; pathDiffZ = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, (Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI)), 0xA, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, RADF_TO_BINANG(Math_FAtan2F(pathDiffX, pathDiffZ)), 0xA, 0x3E8, 1); if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 10.0f) { this->waypoint++; diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index 0bacf8dfd8..93868496ad 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -117,8 +117,8 @@ void EnNb_UpdatePath(EnNb* this, GlobalContext* globalCtx) { this->finalPos.x = pointPos[1].x; this->finalPos.y = pointPos[1].y; this->finalPos.z = pointPos[1].z; - this->pathYaw = (Math_FAtan2F(this->finalPos.x - this->initialPos.x, this->finalPos.z - this->initialPos.z) * - (0x8000 / M_PI)); + this->pathYaw = + RADF_TO_BINANG(Math_FAtan2F(this->finalPos.x - this->initialPos.x, this->finalPos.z - this->initialPos.z)); // "En_Nb_Get_path_info Rail Data Get! = %d!!!!!!!!!!!!!!" osSyncPrintf("En_Nb_Get_path_info レールデータをゲットだぜ = %d!!!!!!!!!!!!!!\n", path); } else { diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index 827d4bfc2e..224138181c 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -577,7 +577,7 @@ void func_80AB6570(EnNiw* this, GlobalContext* globalCtx) { this->unk_29E = 7; } - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(posY, posZ) * (0x8000 / M_PI), 3, this->unk_300, 0); + Math_SmoothStepToS(&this->actor.world.rot.y, RADF_TO_BINANG(Math_FAtan2F(posY, posZ)), 3, this->unk_300, 0); Math_ApproachF(&this->unk_300, 10000.0f, 1.0f, 1000.0f); } @@ -605,7 +605,7 @@ void func_80AB6A38(EnNiw* this, GlobalContext* globalCtx) { pointPos += this->waypoint; pathDiffX = pointPos->x - this->actor.world.pos.x; pathDiffZ = pointPos->z - this->actor.world.pos.z; - this->unk_2E4 = Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI); + this->unk_2E4 = RADF_TO_BINANG(Math_FAtan2F(pathDiffX, pathDiffZ)); func_80AB6100(this, globalCtx, 2); if (fabsf(pathDiffX) < 30.0f && fabsf(pathDiffZ) < 30.0f) { @@ -839,9 +839,8 @@ void func_80AB7328(EnNiw* this, GlobalContext* globalCtx) { } this->actionFunc = EnNiw_ResetAction; } else { - this->unk_2E4 = Math_FAtan2F(this->actor.world.pos.x - player->actor.world.pos.x, - this->actor.world.pos.z - player->actor.world.pos.z) * - (0x8000 / M_PI); + this->unk_2E4 = RADF_TO_BINANG(Math_FAtan2F(this->actor.world.pos.x - player->actor.world.pos.x, + this->actor.world.pos.z - player->actor.world.pos.z)); func_80AB6100(this, globalCtx, 0); func_80AB5BF8(this, globalCtx, 2); } diff --git a/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c b/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c index a8af6ca78c..ccac186d81 100644 --- a/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c +++ b/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c @@ -123,7 +123,7 @@ void func_80AB9210(EnNiwGirl* this, GlobalContext* globalCtx) { } // Change her angle so that she is always facing the cuckoo - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(xDistBetween, zDistBetween) * (0x8000 / M_PI), 3, + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(xDistBetween, zDistBetween)), 3, this->unk_27C, 0); Math_ApproachF(&this->unk_27C, 5000.0f, 30.0f, 150.0f); this->actor.world.rot.y = this->actor.shape.rot.y; diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index 76c3994990..cad05faf9e 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -1058,7 +1058,7 @@ s32 func_80AECF6C(EnRu1* this, GlobalContext* globalCtx) { shapeRotY = &player->actor.shape.rot.y; temp1 = this->actor.world.pos.x - player->actor.world.pos.x; temp2 = this->actor.world.pos.z - player->actor.world.pos.z; - temp_f16 = Math_FAtan2F(temp1, temp2) * (0x8000 / M_PI); + temp_f16 = RADF_TO_BINANG(Math_FAtan2F(temp1, temp2)); if (*shapeRotY != temp_f16) { Math_SmoothStepToS(shapeRotY, temp_f16, 0x14, 0x1838, 0x64); player->actor.world.rot.y = *shapeRotY; diff --git a/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c b/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c index 81a9519dc3..59c1821706 100644 --- a/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c +++ b/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c @@ -142,7 +142,7 @@ void func_80AFBE8C(EnSiofuki* this, GlobalContext* globalCtx) { dist2d = sqrtf(SQ(dX) + SQ(dZ)); this->applySpeed = true; this->splashTimer = 0; - angle = Math_FAtan2F(dX, dZ) * (0x8000 / M_PI); + angle = RADF_TO_BINANG(Math_FAtan2F(dX, dZ)); dAngle = (player->actor.world.rot.y ^ 0x8000) - angle; player->actor.gravity = 0.0f; player->actor.velocity.y = 0.0f; diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 7315e0c38d..fdf25705cd 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -91,7 +91,7 @@ void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) { if (func_80B0B81C(&this->actor.world.pos, &player->actor.world.pos, &posDifference, this->actor.scale.y) != 0) { xzDist = sqrtf(SQ(posDifference.x) + SQ(posDifference.z)); yDistWithOffset = player->actor.world.pos.y - (this->actor.world.pos.y - 90.0f); - player->windDirection = Math_FAtan2F(-posDifference.x, -posDifference.z) * (0x8000 / M_PI); + player->windDirection = RADF_TO_BINANG(Math_FAtan2F(-posDifference.x, -posDifference.z)); if (xzDist > 3.0f) { Math_SmoothStepToF(&player->windSpeed, 3.0f, 0.5f, xzDist, 0.0f); } else { diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index e308662fc2..a1cbe8f1ad 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -739,7 +739,7 @@ s32 func_80B0DFFC(EnSw* this, GlobalContext* globalCtx) { if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_484, &sp50, &this->unk_430, true, false, false, true, &sp5C)) { - this->actor.wallYaw = Math_FAtan2F(this->unk_430->normal.x, this->unk_430->normal.z) * (0x8000 / M_PI); + this->actor.wallYaw = RADF_TO_BINANG(Math_FAtan2F(this->unk_430->normal.x, this->unk_430->normal.z)); this->actor.world.pos = sp50; this->actor.world.pos.x += 6.0f * Math_SinS(this->actor.world.rot.y); this->actor.world.pos.z += 6.0f * Math_CosS(this->actor.world.rot.y); diff --git a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c index 690cd2fd7d..8a5fc27479 100644 --- a/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c +++ b/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c @@ -328,8 +328,7 @@ void func_80B11E78(EnSyatekiNiw* this, GlobalContext* globalCtx) { this->unk_294 = 7; } - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(tmpf1, tmpf2) * (0x8000 / M_PI), 3, this->unk_2C8.z, - 0); + Math_SmoothStepToS(&this->actor.world.rot.y, RADF_TO_BINANG(Math_FAtan2F(tmpf1, tmpf2)), 3, this->unk_2C8.z, 0); Math_ApproachF(&this->unk_2C8.z, 10000.0f, 1.0f, 1000.0f); } @@ -475,9 +474,8 @@ void func_80B12460(EnSyatekiNiw* this, GlobalContext* globalCtx) { } Math_SmoothStepToS(&this->actor.world.rot.y, - (s16)(Math_FAtan2F(player->actor.world.pos.x - this->actor.world.pos.x, - player->actor.world.pos.z - this->actor.world.pos.z) * - (0x8000 / M_PI)) + + RADF_TO_BINANG(Math_FAtan2F(player->actor.world.pos.x - this->actor.world.pos.x, + player->actor.world.pos.z - this->actor.world.pos.z)) + phi_f16, 5, this->unk_2C8.y, 0); Math_ApproachF(&this->unk_2C8.y, 3000.0f, 1.0f, 500.0f); diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 7b08cf071d..b967bd3d05 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -315,7 +315,7 @@ s32 EnTk_Orient(EnTk* this, GlobalContext* globalCtx) { dx = point->x - this->actor.world.pos.x; dz = point->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 10, 1000, 1); + Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(dx, dz)), 10, 1000, 1); this->actor.world.rot = this->actor.shape.rot; if (SQ(dx) + SQ(dz) < 10.0f) { diff --git a/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c b/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c index 586da43d63..f02aead5c6 100644 --- a/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c +++ b/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c @@ -228,7 +228,7 @@ void EnVbBall_Update(Actor* thisx, GlobalContext* globalCtx2) { newActor->yRotVel = 0.0f; xRotVel = sqrtf(SQ(spawnOffset.x) + SQ(spawnOffset.z)); newActor->xRotVel = 0x1000 / 10.0f * xRotVel; - newActor->actor.shape.rot.y = Math_FAtan2F(spawnOffset.x, spawnOffset.z) * ((f32)0x8000 / M_PI); + newActor->actor.shape.rot.y = RADF_TO_BINANG(Math_FAtan2F(spawnOffset.x, spawnOffset.z)); newActor->shadowOpacity = 200.0f; } } diff --git a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c index 97257ceee2..d753dfcc27 100644 --- a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c +++ b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c @@ -754,7 +754,7 @@ void func_80B50304(EnZl2* this, GlobalContext* globalCtx) { this->drawConfig = 1; this->unk_23C = 0.0f; shape->shadowAlpha = 255; - this->actor.world.rot.y = shape->rot.y = Math_FAtan2F(actionXDelta, actionZDelta) * (0x8000 / M_PI); + this->actor.world.rot.y = shape->rot.y = RADF_TO_BINANG(Math_FAtan2F(actionXDelta, actionZDelta)); } void func_80B503DC(EnZl2* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 7aaa6c1bf3..58a7ee540c 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -1614,7 +1614,7 @@ s32 func_80B57034(EnZl3* this, s32 arg1, s32 arg2) { f32 xDiff = vec2->x - vec1->x; f32 zDiff = vec2->z - vec1->z; - return ((xDiff == 0.0f) && (zDiff == 0.0f)) ? 0 : (s16)(Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI)); + return ((xDiff == 0.0f) && (zDiff == 0.0f)) ? 0 : RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); } return 0; } @@ -1627,7 +1627,7 @@ s16 func_80B57104(EnZl3* this, s32 arg1) { f32 zDiff = point->z - this->actor.world.pos.z; if ((xDiff != 0.0f) || (zDiff != 0.0f)) { - return Math_FAtan2F(xDiff, zDiff) * (0x8000 / M_PI); + return RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff)); } } return 0; @@ -1741,7 +1741,7 @@ s32 func_80B57458(EnZl3* this, GlobalContext* globalCtx) { return 1; } - temp_v0 = (s16)(temp_v1 - (s16)(Math_FAtan2F(temp_f12, temp_f13) * (0x8000 / M_PI))); + temp_v0 = (s16)(temp_v1 - RADF_TO_BINANG(Math_FAtan2F(temp_f12, temp_f13))); if (temp_v0 < 0x1555) { return 1; @@ -1828,7 +1828,7 @@ void func_80B577BC(GlobalContext* globalCtx, Vec3f* vec) { f32 posZ = vec->z; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TEST, posX, posY, posZ, 0, - (Math_FAtan2F(playerPos->x - posX, playerPos->z - posZ) * (0x8000 / M_PI)), 0, 5); + RADF_TO_BINANG(Math_FAtan2F(playerPos->x - posX, playerPos->z - posZ)), 0, 5); } void func_80B57858(GlobalContext* globalCtx) {