diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2023-04-18 13:34:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-18 16:34:58 -0400 |
| commit | 823746d49530318331f29af92fa924a15f2482a1 (patch) | |
| tree | 2931bf8e06b9e1d2ef13774e3fb2b25ac3b4d0fa /src/code | |
| parent | a67d086addc1d0e226c28cadf58dda5e637d58ba (diff) | |
Angle Conversions (#1216)
* Angle Conversions
* Format
* namefixer
* Renames in ObjHsStump_Appear
* Format
* once more
* Explicit cast in EnSsh
* Update src/overlays/actors/ovl_En_Fishing/z_en_fishing.c
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
---------
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/sys_math.c | 4 | ||||
| -rw-r--r-- | src/code/sys_math_atan.c | 2 | ||||
| -rw-r--r-- | src/code/sys_matrix.c | 4 | ||||
| -rw-r--r-- | src/code/z_olib.c | 12 | ||||
| -rw-r--r-- | src/code/z_quake.c | 6 | ||||
| -rw-r--r-- | src/code/z_sub_s.c | 8 |
6 files changed, 18 insertions, 18 deletions
diff --git a/src/code/sys_math.c b/src/code/sys_math.c index da4ccc9d2..7fd7e9dea 100644 --- a/src/code/sys_math.c +++ b/src/code/sys_math.c @@ -66,7 +66,7 @@ f32 pow_int(f32 base, s32 exp) { * Takes an angle in radians and returns the sine. */ f32 sin_rad(f32 rad) { - return sins(RADF_TO_BINANG(rad)) * SHT_MINV; + return sins(RAD_TO_BINANG(rad)) * SHT_MINV; } // Rename to Math_CosF @@ -74,7 +74,7 @@ f32 sin_rad(f32 rad) { * Takes an angle in radians and returns the cosine. */ f32 cos_rad(f32 rad) { - return coss(RADF_TO_BINANG(rad)) * SHT_MINV; + return coss(RAD_TO_BINANG(rad)) * SHT_MINV; } /** diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c index 72383b6b9..ef05676f5 100644 --- a/src/code/sys_math_atan.c +++ b/src/code/sys_math_atan.c @@ -127,7 +127,7 @@ s16 Math_Atan2S(f32 y, f32 x) { } f32 Math_Atan2F(f32 y, f32 x) { - return Math_Atan2S(y, x) * (M_PI / 0x8000); + return BINANG_TO_RAD(Math_Atan2S(y, x)); } // Match the OoT implementation of Math_Atan2S diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 63857676e..de8da3def 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -444,8 +444,8 @@ void Matrix_RotateXFApply(f32 x) { if (x != 0.0f) { cmf = sCurrentMatrix; - sin = sins(RADF_TO_BINANG(x)) * SHT_MINV; - cos = coss(RADF_TO_BINANG(x)) * SHT_MINV; + sin = sins(RAD_TO_BINANG(x)) * SHT_MINV; + cos = coss(RAD_TO_BINANG(x)) * SHT_MINV; tempY = cmf->xy; tempZ = cmf->xz; diff --git a/src/code/z_olib.c b/src/code/z_olib.c index 2b6b8d139..ad0c2b35c 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 ((dist == 0.0f) && (vec->y == 0.0f)) { sph.pitch = 0; } else { - sph.pitch = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(dist, vec->y))); + sph.pitch = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(dist, vec->y))); } sph.r = sqrtf(SQ(vec->y) + distSquared); if ((vec->x == 0.0f) && (vec->z == 0.0f)) { sph.yaw = 0; } else { - sph.yaw = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(vec->x, vec->z))); + sph.yaw = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(vec->x, vec->z))); } *dest = sph; @@ -220,8 +220,8 @@ Vec3f* OLib_Vec3fDiffDegF(Vec3f* dest, Vec3f* a, Vec3f* b) { OLib_Vec3fDiffRad(&anglesRad, a, b); - anglesDegrees.x = RADF_TO_DEGF(anglesRad.x); - anglesDegrees.y = RADF_TO_DEGF(anglesRad.y); + anglesDegrees.x = RAD_TO_DEG(anglesRad.x); + anglesDegrees.y = RAD_TO_DEG(anglesRad.y); anglesDegrees.z = 0.0f; *dest = anglesDegrees; @@ -238,8 +238,8 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b) { OLib_Vec3fDiffRad(&anglesRad, a, b); - anglesBinAng.x = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.x)); - anglesBinAng.y = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.y)); + anglesBinAng.x = CAM_DEG_TO_BINANG(RAD_TO_DEG(anglesRad.x)); + anglesBinAng.y = CAM_DEG_TO_BINANG(RAD_TO_DEG(anglesRad.y)); anglesBinAng.z = 0.0f; *dest = anglesBinAng; diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 8a6b9d73a..e1e12bbf1 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -825,9 +825,9 @@ void Distortion_Update(void) { screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); View_SetDistortionOrientation(&sDistortionRequest.play->view, - Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), - Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), - Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); + Math_CosS(depthPhase) * (DEG_TO_RAD(rotX) * xyScaleFactor), + Math_SinS(depthPhase) * (DEG_TO_RAD(rotY) * xyScaleFactor), + Math_SinS(screenPlanePhase) * (DEG_TO_RAD(rotZ) * zScaleFactor)); View_SetDistortionScale(&sDistortionRequest.play->view, (Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f, (Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f, diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 6650f41a7..210d6c36f 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, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + func_8017B7F8(&point, RAD_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) { reached = true; } @@ -1023,13 +1023,13 @@ s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f3 f32 step; f32 prevRotStep; - step = (f32)(target - *rot) * (360.0f / (f32)0x10000); + step = BINANG_TO_DEG(target - *rot); step *= gFramerateDivisorHalf; prevRotStep = step; if (step >= 0.0f) { step /= slowness; step = CLAMP(step, stepMin, stepMax); - *rot += (s16)((step * (f32)0x10000) / 360.0f); + *rot += DEG_TO_BINANG_ALT2(step); if (prevRotStep < stepMin) { *rot = target; } @@ -1039,7 +1039,7 @@ s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f3 } else { step = (step / slowness) * -1.0f; step = CLAMP(step, stepMin, stepMax); - *rot -= (s16)((step * (f32)0x10000) / 360.0f); + *rot -= DEG_TO_BINANG_ALT2(step); if (-stepMin < prevRotStep) { *rot = target; } |
