mirror of
https://github.com/zeldaret/mm.git
synced 2026-05-25 07:22:49 -04:00
Fix last two functions in sys_math_atan (#1066)
* Fix extra Atan2 funcs * format * make Math_GetAtan2Tbl private * rename Depr to XY * ./format.sh i loathe thee * namefixer.py changes
This commit is contained in:
@@ -130,10 +130,12 @@ f32 Math_Atan2F(f32 y, f32 x) {
|
||||
return Math_Atan2S(y, x) * (M_PI / 0x8000);
|
||||
}
|
||||
|
||||
s16 Math_FAtan2F(f32 adjacent, f32 opposite) {
|
||||
return Math_Atan2S(opposite, adjacent);
|
||||
// Match the OoT implementation of Math_Atan2S
|
||||
s16 Math_Atan2S_XY(f32 x, f32 y) {
|
||||
return Math_Atan2S(y, x);
|
||||
}
|
||||
|
||||
f32 Math_Acot2F(f32 adjacent, f32 opposite) {
|
||||
return Math_Atan2F(opposite, adjacent);
|
||||
// Match the OoT implementation of Math_Atan2F
|
||||
f32 Math_Atan2F_XY(f32 x, f32 y) {
|
||||
return Math_Atan2F(y, x);
|
||||
}
|
||||
|
||||
+5
-6
@@ -151,7 +151,7 @@ void ActorShadow_DrawFoot(PlayState* play, Light* light, MtxF* arg2, s32 lightNu
|
||||
|
||||
dir0 = light->l.dir[0];
|
||||
dir2 = light->l.dir[2];
|
||||
sp58 = Math_FAtan2F(dir2, dir0);
|
||||
sp58 = Math_Atan2S_XY(dir2, dir0);
|
||||
shadowScaleZ *= (4.5f - (light->l.dir[1] * 0.035f));
|
||||
shadowScaleZ = CLAMP_MIN(shadowScaleZ, 1.0f);
|
||||
Matrix_Put(arg2);
|
||||
@@ -1493,8 +1493,7 @@ void Actor_GetSlopeDirection(CollisionPoly* floorPoly, Vec3f* slopeNormal, s16*
|
||||
slopeNormal->x = COLPOLY_GET_NORMAL(floorPoly->normal.x);
|
||||
slopeNormal->y = COLPOLY_GET_NORMAL(floorPoly->normal.y);
|
||||
slopeNormal->z = COLPOLY_GET_NORMAL(floorPoly->normal.z);
|
||||
|
||||
*downwardSlopeYaw = Math_FAtan2F(slopeNormal->z, slopeNormal->x);
|
||||
*downwardSlopeYaw = Math_Atan2S_XY(slopeNormal->z, slopeNormal->x);
|
||||
}
|
||||
|
||||
s32 func_800B761C(Actor* actor, f32 arg1, s32 arg2) {
|
||||
@@ -1591,7 +1590,7 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight,
|
||||
Math_Vec3f_Copy(&actor->world.pos, &pos);
|
||||
}
|
||||
|
||||
actor->wallYaw = Math_FAtan2F(sp7C->normal.z, sp7C->normal.x);
|
||||
actor->wallYaw = Math_Atan2S_XY(sp7C->normal.z, sp7C->normal.x);
|
||||
actor->wallBgId = bgId;
|
||||
} else {
|
||||
actor->bgCheckFlags &= ~8;
|
||||
@@ -4380,8 +4379,8 @@ void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) {
|
||||
f32 zDiff = arg1->z - arg0->z;
|
||||
f32 yDiff = arg3 ? (arg1->y - arg0->y) : (arg0->y - arg1->y);
|
||||
|
||||
arg2->y = Math_FAtan2F(zDiff, xDiff);
|
||||
arg2->x = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff);
|
||||
arg2->y = Math_Atan2S_XY(zDiff, xDiff);
|
||||
arg2->x = Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff);
|
||||
}
|
||||
|
||||
void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2) {
|
||||
|
||||
+3
-3
@@ -251,7 +251,7 @@ void func_800FF3A0(f32* distOut, s16* angleOut, Input* input) {
|
||||
if (dist > 0.0f) {
|
||||
x = input->cur.stick_x;
|
||||
y = input->cur.stick_y;
|
||||
*angleOut = Math_FAtan2F(y, -x);
|
||||
*angleOut = Math_Atan2S_XY(y, -x);
|
||||
} else {
|
||||
*angleOut = 0;
|
||||
}
|
||||
@@ -420,11 +420,11 @@ f32 Math_Vec3f_DiffY(Vec3f* a, Vec3f* b) {
|
||||
s16 Math_Vec3f_Yaw(Vec3f* a, Vec3f* b) {
|
||||
f32 f14 = b->x - a->x;
|
||||
f32 f12 = b->z - a->z;
|
||||
return Math_FAtan2F(f12, f14);
|
||||
return Math_Atan2S_XY(f12, f14);
|
||||
}
|
||||
|
||||
s16 Math_Vec3f_Pitch(Vec3f* a, Vec3f* b) {
|
||||
return Math_FAtan2F(Math_Vec3f_DistXZ(a, b), a->y - b->y);
|
||||
return Math_Atan2S_XY(Math_Vec3f_DistXZ(a, b), a->y - b->y);
|
||||
}
|
||||
|
||||
void IChain_Apply_u8(u8* ptr, InitChainEntry* ichain);
|
||||
|
||||
@@ -1725,7 +1725,7 @@ void func_80124FF0(f32 arg0, s16 arg1, Vec3f* arg2, s16 arg3, Vec3f* arg4, Vec3f
|
||||
Math_Vec3f_Diff(arg5, arg4, &sp44);
|
||||
sp40 = sqrtf(SQXZ(sp44));
|
||||
|
||||
sp3C = (sp40 <= 1.0f) ? arg3 : Math_FAtan2F(sp44.z, sp44.x);
|
||||
sp3C = (sp40 <= 1.0f) ? arg3 : Math_Atan2S_XY(sp44.z, sp44.x);
|
||||
sp40 = (Math_CosS(sp3C - arg3) * sp40) + arg8;
|
||||
|
||||
if (ABS_ALT(BINANG_SUB(sp3C, arg3)) > 0x4000) {
|
||||
@@ -1733,7 +1733,7 @@ void func_80124FF0(f32 arg0, s16 arg1, Vec3f* arg2, s16 arg3, Vec3f* arg4, Vec3f
|
||||
}
|
||||
sp3C -= arg3;
|
||||
|
||||
temp_v0 = Math_FAtan2F(sp44.y, sp40);
|
||||
temp_v0 = Math_Atan2S_XY(sp44.y, sp40);
|
||||
temp_v0 = CLAMP(temp_v0, (s16)-arg9, arg9);
|
||||
//! FAKE:
|
||||
if (sp3C) {}
|
||||
|
||||
+4
-4
@@ -1072,8 +1072,8 @@ s32 SubS_TrackPoint(Vec3f* target, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* trac
|
||||
s16 targetX;
|
||||
f32 diffZ = target->z - focusPos->z;
|
||||
|
||||
yaw = Math_FAtan2F(diffZ, diffX);
|
||||
pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), target->y - focusPos->y);
|
||||
yaw = Math_Atan2S_XY(diffZ, diffX);
|
||||
pitch = Math_Atan2S_XY(sqrtf(SQ(diffX) + SQ(diffZ)), target->y - focusPos->y);
|
||||
Math_SmoothStepToS(&trackTarget->x, pitch, 4, 0x2710, 0);
|
||||
Math_SmoothStepToS(&trackTarget->y, yaw, 4, 0x2710, 0);
|
||||
|
||||
@@ -1306,8 +1306,8 @@ void SubS_ActorPathing_ComputePointInfo(PlayState* play, ActorPathing* actorPath
|
||||
diff.z = actorPath->curPoint.z - actorPath->worldPos->z;
|
||||
actorPath->distSqToCurPointXZ = Math3D_XZLengthSquared(diff.x, diff.z);
|
||||
actorPath->distSqToCurPoint = Math3D_LengthSquared(&diff);
|
||||
actorPath->rotToCurPoint.y = Math_FAtan2F(diff.z, diff.x);
|
||||
actorPath->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPath->distSqToCurPointXZ), -diff.y);
|
||||
actorPath->rotToCurPoint.y = Math_Atan2S_XY(diff.z, diff.x);
|
||||
actorPath->rotToCurPoint.x = Math_Atan2S_XY(sqrtf(actorPath->distSqToCurPointXZ), -diff.y);
|
||||
actorPath->rotToCurPoint.z = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user