diff options
| author | engineer124 <47598039+engineer124@users.noreply.github.com> | 2023-06-06 12:16:34 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-05 22:16:34 -0400 |
| commit | 7f5087d0b2014dc1ba2bbfc7ce858f0059a8a7cb (patch) | |
| tree | a56edb9e5d173d9e24bdce4a373e9fe38253cb34 /src/code | |
| parent | f92a61db27ed8ee213072df11169777c6794bc1b (diff) | |
sys_math.c Rename (#1258)
* rename via comments
* missed a comment
* math header
* name boot_80086760.c functions
* PR Review
* rm cam comment
* Elliptic review
* alphabetical
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/sys_math.c | 33 | ||||
| -rw-r--r-- | src/code/z_actor.c | 18 | ||||
| -rw-r--r-- | src/code/z_bgcheck.c | 3 | ||||
| -rw-r--r-- | src/code/z_camera.c | 33 | ||||
| -rw-r--r-- | src/code/z_eff_blure.c | 24 | ||||
| -rw-r--r-- | src/code/z_en_item00.c | 12 | ||||
| -rw-r--r-- | src/code/z_lib.c | 6 | ||||
| -rw-r--r-- | src/code/z_olib.c | 8 | ||||
| -rw-r--r-- | src/code/z_player_lib.c | 12 | ||||
| -rw-r--r-- | src/code/z_sub_s.c | 2 |
10 files changed, 77 insertions, 74 deletions
diff --git a/src/code/sys_math.c b/src/code/sys_math.c index 7fd7e9dea..99d13c332 100644 --- a/src/code/sys_math.c +++ b/src/code/sys_math.c @@ -4,15 +4,17 @@ */ #include "global.h" -static f32 sFactorialTbl[] = { 1.0f, 1.0f, 2.0f, 6.0f, 24.0f, 120.0f, 720.0f, - 5040.0f, 40320.0f, 362880.0f, 3628800.0f, 39916800.0f, 479001600.0f }; +static f32 sFactorialTbl[] = { + 1.0f, 1.0f, 2.0f, 6.0f, 24.0f, 120.0f, 720.0f, 5040.0f, 40320.0f, 362880.0f, 3628800.0f, 39916800.0f, 479001600.0f, +}; -// Rename to Math_FactorialF /** * Takes a float, returns the factorial of it(s trunctation), iteratively * Unused + * + * @remark original name: "ffact" */ -f32 func_80179300(f32 n) { +f32 Math_FactorialF(f32 n) { f32 ret = 1.0f; s32 i; @@ -23,12 +25,13 @@ f32 func_80179300(f32 n) { return ret; } -// Rename to Math_Factorial /** * Takes an int and returns its factorial as a float. Uses the lookup table for n <= 12. * Unused + * + * @remark original name: "ifact" */ -f32 func_80179400(s32 n) { +f32 Math_Factorial(s32 n) { f32 ret; s32 i; @@ -45,12 +48,13 @@ f32 func_80179400(s32 n) { return ret; } -// Rename to Math_PowF /** * Returns base^{exp} if exp is nonnegative and 1.0f otherwise. * Unused + * + * @remark original name: "powi" */ -f32 pow_int(f32 base, s32 exp) { +f32 Math_PowF(f32 base, s32 exp) { f32 ret = 1.0f; while (exp > 0) { @@ -61,19 +65,21 @@ f32 pow_int(f32 base, s32 exp) { return ret; } -// Rename to Math_SinF /** * Takes an angle in radians and returns the sine. + * + * @remark original name: "sinf_table" */ -f32 sin_rad(f32 rad) { +f32 Math_SinF(f32 rad) { return sins(RAD_TO_BINANG(rad)) * SHT_MINV; } -// Rename to Math_CosF /** * Takes an angle in radians and returns the cosine. + * + * @remark original name: "cosf_table" */ -f32 cos_rad(f32 rad) { +f32 Math_CosF(f32 rad) { return coss(RAD_TO_BINANG(rad)) * SHT_MINV; } @@ -84,10 +90,9 @@ f32 Rand_ZeroFloat(f32 scale) { return Rand_ZeroOne() * scale; } -// Rename to Rand_CenteredFloat /** * Returns a pseudo-random floating-point number between (- scale / 2) and (scale / 2). Originally in z_actor in OoT. */ -f32 randPlusMinusPoint5Scaled(f32 scale) { +f32 Rand_CenteredFloat(f32 scale) { return Rand_Centered() * scale; } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 82ff8ddd9..e7bc92a26 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3567,8 +3567,8 @@ void Actor_SpawnFloorDustRing(PlayState* play, Actor* actor, Vec3f* posXZ, f32 r accel.y += (Rand_ZeroOne() - 0.5f) * 0.2f; for (i = countMinusOne; i >= 0; i--) { - pos.x = (sin_rad(angle) * radius) + posXZ->x; - pos.z = (cos_rad(angle) * radius) + posXZ->z; + pos.x = (Math_SinF(angle) * radius) + posXZ->x; + pos.z = (Math_CosF(angle) * radius) + posXZ->z; accel.x = (Rand_ZeroOne() - 0.5f) * randAccelWeight; accel.z = (Rand_ZeroOne() - 0.5f) * randAccelWeight; @@ -4816,7 +4816,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 // Apply and draw a light orb over each limb of frozen actor for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { - Matrix_RotateZF(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); + Matrix_RotateZF(Rand_CenteredFloat(2 * M_PI), MTXMODE_APPLY); currentMatrix->mf[3][0] = limbPos->x; currentMatrix->mf[3][1] = limbPos->y; currentMatrix->mf[3][2] = limbPos->z; @@ -4857,9 +4857,9 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 // first electric spark Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); - currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4869,9 +4869,9 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 // second electric spark Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); - currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index e30dec5d5..a263d4393 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,4 +1,5 @@ #include "global.h" +#include "fixed_point.h" #include "vt.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" @@ -3047,7 +3048,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); } - newPoly->dist = func_80086D24(-DOTXYZ(newNormal, vtxA)); + newPoly->dist = nearbyint(-DOTXYZ(newNormal, vtxA)); if (newNormal.y > 0.5f) { s16 polyId = *polyStartIndex + i; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index bd23308c3..ce09f7c4d 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -875,7 +875,7 @@ void func_800CC938(Camera* camera) { * Calculates the angle between points `from` and `to` */ s16 Camera_CalcXZAngle(Vec3f* to, Vec3f* from) { - return CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(from->x - to->x, from->z - to->z))); + return CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(from->x - to->x, from->z - to->z))); } // BSS @@ -964,8 +964,8 @@ s16 Camera_GetPitchAdjFromFloorHeightDiffs(Camera* camera, s16 viewYaw, s16 shou floorYDiffNear = (sFloorYNear - camera->focalActorFloorHeight) * 0.8f; floorYDiffFar = (sFloorYFar - camera->focalActorFloorHeight) * (20.0f * 0.01f); - pitchNear = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(floorYDiffNear, nearDist))); - pitchFar = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(floorYDiffFar, farDist))); + pitchNear = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(floorYDiffNear, nearDist))); + pitchFar = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(floorYDiffFar, farDist))); return pitchNear + pitchFar; } @@ -1457,9 +1457,8 @@ s32 Camera_CalcAtForParallel(Camera* camera, VecGeo* arg1, f32 yOffset, f32 xzOf deltaY = focalActorPosRot->pos.y - *focalActorPosY; eyeAtDistXZ = OLib_Vec3fDistXZ(at, &camera->eye); - // Math_FTanF // Get the height based on 80% of the fov - fovHeight = func_80086760(DEG_TO_RAD(camera->fov * (0.8f * 0.5f))) * eyeAtDistXZ; + fovHeight = Math_FTanF(DEG_TO_RAD(camera->fov * (0.8f * 0.5f))) * eyeAtDistXZ; if (deltaY > fovHeight) { //! FAKE @@ -1539,8 +1538,8 @@ s32 Camera_CalcAtForFriendlyLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targ deltaY = focalActorPosRot->pos.y - *yPosOffset; sp50 = OLib_Vec3fDistXZ(at, &camera->eye); phi_f16 = sp50; - func_80086B30(deltaY, sp50); - fovHeight = func_80086760(DEG_TO_RAD(camera->fov * 0.4f)) * phi_f16; + Math_FAtan2F(deltaY, sp50); + fovHeight = Math_FTanF(DEG_TO_RAD(camera->fov * 0.4f)) * phi_f16; if (fovHeight < deltaY) { *yPosOffset += deltaY - fovHeight; @@ -1552,12 +1551,12 @@ s32 Camera_CalcAtForFriendlyLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targ focalActorAtOffsetTarget.y -= deltaY; } else { deltaY = focalActorPosRot->pos.y - *yPosOffset; - temp_f0_6 = func_80086B30(deltaY, OLib_Vec3fDistXZ(at, &camera->eye)); + temp_f0_6 = Math_FAtan2F(deltaY, OLib_Vec3fDistXZ(at, &camera->eye)); if (temp_f0_6 > 0.34906584f) { // (M_PI / 9) - phi_f16 = 1.0f - sin_rad(temp_f0_6 - 0.34906584f); + phi_f16 = 1.0f - Math_SinF(temp_f0_6 - 0.34906584f); } else if (temp_f0_6 < -0.17453292f) { // (M_PI / 18) - phi_f16 = 1.0f - sin_rad(-0.17453292f - temp_f0_6); + phi_f16 = 1.0f - Math_SinF(-0.17453292f - temp_f0_6); } else { phi_f16 = 1.0f; } @@ -1625,10 +1624,10 @@ s32 Camera_CalcAtForEnemyLockOn(Camera* camera, f32* arg1, s32 arg2, f32 yOffset new_var2 = *arg1; sp4C = new_var2; deltaY = focalActorPosRot->pos.y - *arg6; - temp_f0_3 = func_80086B30(deltaY, sp4C); + temp_f0_3 = Math_FAtan2F(deltaY, sp4C); if (!(flags & 0x80)) { - fovHeight = func_80086760(DEG_TO_RAD(camera->fov * 0.4f)) * sp4C; + fovHeight = Math_FTanF(DEG_TO_RAD(camera->fov * 0.4f)) * sp4C; if (fovHeight < deltaY) { *arg6 += deltaY - fovHeight; @@ -1641,9 +1640,9 @@ s32 Camera_CalcAtForEnemyLockOn(Camera* camera, f32* arg1, s32 arg2, f32 yOffset focalActorAtOffsetTarget.y -= deltaY; } else { if (temp_f0_3 > 0.34906584f) { // (M_PI / 9) - phi_f14 = 1.0f - sin_rad(temp_f0_3 - 0.34906584f); + phi_f14 = 1.0f - Math_SinF(temp_f0_3 - 0.34906584f); } else if (temp_f0_3 < -0.17453292f) { // (M_PI / 18) - phi_f14 = 1.0f - sin_rad(-0.17453292f - temp_f0_3); + phi_f14 = 1.0f - Math_SinF(-0.17453292f - temp_f0_3); } else { phi_f14 = 1.0f; } @@ -6343,8 +6342,8 @@ s32 Camera_Demo4(Camera* camera) { // Camera fixed on human player as the mask moves from the pocket to the face // Camera rolls left and right if (rwData->timer >= 12) { - rwData->unk_0C = (rwData->timer - 12) * 10.384615f; - sin = sin_rad(DEG_TO_RAD(rwData->unk_0C)); + rwData->unk_0C = (rwData->timer - 12) * (135.0f / 13.0f); + sin = Math_SinF(DEG_TO_RAD(rwData->unk_0C)); rwData->unk_0C = ((rwData->unk_10 < 0.0f) ? -1.0f : 1.0f) * sin; if (rwData->timer == 12) { Distortion_Request(DISTORTION_TYPE_MASK_TRANSFORM_1); @@ -6516,7 +6515,7 @@ s32 Camera_Demo5(Camera* camera) { // Camera zooms out while rolling back and forth rwData->unk_0C = rwData->timer * (180.0f / 23.0f); sp58 = DEG_TO_RAD(rwData->unk_0C); - sin = sin_rad(sp58); + sin = Math_SinF(sp58); rwData->unk_0C = ((rwData->unk_10 < 0.0f) ? -1.0f : 1.0f) * sin; new_var = (46 - rwData->timer) * (5.0f / 46.0f); focalActorFocus.pos.x = (Math_SinS(rwData->unk_24) * new_var * rwData->unk_0C) + focalActorPosRot->pos.x; diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 370ca9481..775db80e1 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -561,16 +561,16 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem vtx[0].v = baseVtx; vtx[1].v = baseVtx; - vtx[0].v.ob[0] = func_80086814(sp158.x); - vtx[0].v.ob[1] = func_80086814(sp158.y); - vtx[0].v.ob[2] = func_80086814(sp158.z); + vtx[0].v.ob[0] = Math_FNearbyIntF(sp158.x); + vtx[0].v.ob[1] = Math_FNearbyIntF(sp158.y); + vtx[0].v.ob[2] = Math_FNearbyIntF(sp158.z); vtx[0].v.cn[0] = sp148.r; vtx[0].v.cn[1] = sp148.g; vtx[0].v.cn[2] = sp148.b; vtx[0].v.cn[3] = sp148.a; - vtx[1].v.ob[0] = func_80086814(sp14C.x); - vtx[1].v.ob[1] = func_80086814(sp14C.y); - vtx[1].v.ob[2] = func_80086814(sp14C.z); + vtx[1].v.ob[0] = Math_FNearbyIntF(sp14C.x); + vtx[1].v.ob[1] = Math_FNearbyIntF(sp14C.y); + vtx[1].v.ob[2] = Math_FNearbyIntF(sp14C.z); vtx[1].v.cn[0] = sp144.r; vtx[1].v.cn[1] = sp144.g; vtx[1].v.cn[2] = sp144.b; @@ -606,17 +606,17 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem vtx[j1].v = baseVtx; vtx[j2].v = baseVtx; - vtx[j1].v.ob[0] = func_80086814(sp158.x); - vtx[j1].v.ob[1] = func_80086814(sp158.y); - vtx[j1].v.ob[2] = func_80086814(sp158.z); + vtx[j1].v.ob[0] = Math_FNearbyIntF(sp158.x); + vtx[j1].v.ob[1] = Math_FNearbyIntF(sp158.y); + vtx[j1].v.ob[2] = Math_FNearbyIntF(sp158.z); vtx[j1].v.cn[0] = func_800B0A24(sp1A4.r, sp19C.r, temp_f28); vtx[j1].v.cn[1] = func_800B0A24(sp1A4.g, sp19C.g, temp_f28); vtx[j1].v.cn[2] = func_800B0A24(sp1A4.b, sp19C.b, temp_f28); vtx[j1].v.cn[3] = func_800B0A24(sp1A4.a, sp19C.a, temp_f28); - vtx[j2].v.ob[0] = func_80086814(sp14C.x); - vtx[j2].v.ob[1] = func_80086814(sp14C.y); - vtx[j2].v.ob[2] = func_80086814(sp14C.z); + vtx[j2].v.ob[0] = Math_FNearbyIntF(sp14C.x); + vtx[j2].v.ob[1] = Math_FNearbyIntF(sp14C.y); + vtx[j2].v.ob[2] = Math_FNearbyIntF(sp14C.z); vtx[j2].v.cn[0] = func_800B0A24(sp1A0.r, sp198.r, temp_f28); vtx[j2].v.cn[1] = func_800B0A24(sp1A0.g, sp198.g, temp_f28); vtx[j2].v.cn[2] = func_800B0A24(sp1A0.b, sp198.b, temp_f28); diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 7b9e2ca34..886c3c942 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -127,7 +127,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { break; case ITEM00_RECOVERY_HEART: - this->actor.home.rot.z = randPlusMinusPoint5Scaled(0xFFFF); + this->actor.home.rot.z = Rand_CenteredFloat(0xFFFF); shadowOffset = 430.0f; Actor_SetScale(&this->actor, 0.02f); this->unk154 = 0.02f; @@ -381,9 +381,9 @@ void func_800A6650(EnItem00* this, PlayState* play) { } if ((play->gameplayFrames & 1) != 0) { - pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(10.0f); - pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(10.0f); - pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(10.0f); + pos.x = this->actor.world.pos.x + Rand_CenteredFloat(10.0f); + pos.y = this->actor.world.pos.y + Rand_CenteredFloat(10.0f); + pos.z = this->actor.world.pos.z + Rand_CenteredFloat(10.0f); EffectSsKirakira_SpawnSmall(play, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } @@ -956,7 +956,7 @@ Actor* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, u32 params) { } spawnedActor->speed = 2.0f; spawnedActor->gravity = -0.9f; - spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(0x10000); + spawnedActor->world.rot.y = Rand_CenteredFloat(0x10000); Actor_SetScale(spawnedActor, 0.0f); ((EnItem00*)spawnedActor)->actionFunc = func_800A6780; ((EnItem00*)spawnedActor)->unk152 = 0xDC; @@ -1011,7 +1011,7 @@ Actor* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s32 params) { } else { spawnedActor->gravity = -0.9f; } - spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(0x10000); + spawnedActor->world.rot.y = Rand_CenteredFloat(0x10000); spawnedActor->flags |= 0x10; } } diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 136918765..f3e67e5f3 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -348,9 +348,9 @@ void Math_Vec3f_SumScaled(Vec3f* a, Vec3f* b, f32 scale, Vec3f* dest) { } void Math_Vec3f_AddRand(Vec3f* orig, f32 scale, Vec3f* dest) { - dest->x = randPlusMinusPoint5Scaled(scale) + orig->x; - dest->y = randPlusMinusPoint5Scaled(scale) + orig->y; - dest->z = randPlusMinusPoint5Scaled(scale) + orig->z; + dest->x = Rand_CenteredFloat(scale) + orig->x; + dest->y = Rand_CenteredFloat(scale) + orig->y; + dest->z = Rand_CenteredFloat(scale) + orig->z; } void Math_Vec3f_DistXYZAndStoreNormDiff(Vec3f* a, Vec3f* b, f32 scale, Vec3f* dest) { diff --git a/src/code/z_olib.c b/src/code/z_olib.c index 754857014..848a48a72 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -123,14 +123,14 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) { if ((distXZ == 0.0f) && (vec->y == 0.0f)) { sph.pitch = 0; } else { - sph.pitch = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(distXZ, vec->y))); + sph.pitch = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(distXZ, vec->y))); } sph.r = sqrtf(SQ(vec->y) + distXZSq); if ((vec->x == 0.0f) && (vec->z == 0.0f)) { sph.yaw = 0; } else { - sph.yaw = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(vec->x, vec->z))); + sph.yaw = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(vec->x, vec->z))); } *dest = sph; @@ -202,8 +202,8 @@ Vec3f* OLib_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo) { Vec3f* OLib_Vec3fDiffRad(Vec3f* dest, Vec3f* a, Vec3f* b) { Vec3f anglesRad; - anglesRad.x = func_80086B30(b->z - a->z, b->y - a->y); - anglesRad.y = func_80086B30(b->x - a->x, b->z - a->z); + anglesRad.x = Math_FAtan2F(b->z - a->z, b->y - a->y); + anglesRad.y = Math_FAtan2F(b->x - a->x, b->z - a->z); anglesRad.z = 0; *dest = anglesRad; diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 2c0a79d21..2e2d2222d 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1540,10 +1540,8 @@ void Player_UpdateBunnyEars(Player* player) { sBunnyEarKinematics.angVel.y += -sBunnyEarKinematics.rot.y >> 2; angle = player->actor.world.rot.y - player->actor.shape.rot.y; - force.x = - (s32)(player->actor.speed * -200.0f * Math_CosS(angle) * (randPlusMinusPoint5Scaled(2.0f) + 10.0f)) & 0xFFFF; - force.y = - (s32)(player->actor.speed * 100.0f * Math_SinS(angle) * (randPlusMinusPoint5Scaled(2.0f) + 10.0f)) & 0xFFFF; + force.x = (s32)(player->actor.speed * -200.0f * Math_CosS(angle) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; + force.y = (s32)(player->actor.speed * 100.0f * Math_SinS(angle) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; sBunnyEarKinematics.angVel.x += force.x >> 2; sBunnyEarKinematics.angVel.y += force.y >> 2; @@ -1801,7 +1799,7 @@ void Player_AdjustSingleLeg(PlayState* play, Player* player, SkelAnime* skelAnim temp_f20 = sp74 - SQ(sp58); temp_f20 = (temp_f20 < 0.0f) ? 0.0f : sqrtf(temp_f20); - sp4C = func_80086B30(temp_f20, sp58); + sp4C = Math_FAtan2F(temp_f20, sp58); distance = sqrtf(SQ(diffX) + SQ(yIntersect - sp90.y) + SQ(diffZ)); sp58 = (SQ(distance) + sp70) / (2.0f * distance); sp54 = distance - sp58; @@ -1809,8 +1807,8 @@ void Player_AdjustSingleLeg(PlayState* play, Player* player, SkelAnime* skelAnim temp_f20 = sp74 - SQ(sp58); temp_f20 = (temp_f20 < 0.0f) ? 0.0f : sqrtf(temp_f20); - sp48 = func_80086B30(temp_f20, sp58); - phi_t1 = (M_PI - (func_80086B30(sp54, temp_f20) + ((M_PI / 2.0f) - sp48))) * (0x8000 / M_PI); + sp48 = Math_FAtan2F(temp_f20, sp58); + phi_t1 = (M_PI - (Math_FAtan2F(sp54, temp_f20) + ((M_PI / 2.0f) - sp48))) * (0x8000 / M_PI); phi_t1 = -skelAnime->jointTable[shinLimbIndex].z + phi_t1; temp_f8 = (sp48 - sp4C) * (0x8000 / M_PI); diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 35886da18..90d09a4b1 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -577,7 +577,7 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { diffZ = points[index + 1].z - points[index - 1].z; } - func_8017B7F8(&point, RAD_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + func_8017B7F8(&point, RAD_TO_BINANG(Math_FAtan2F(diffX, diffZ)), &px, &pz, &d); if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) { reached = true; } |
