summaryrefslogtreecommitdiff
path: root/src/d/d_npc.cpp
diff options
context:
space:
mode:
authorLagoLunatic <LagoLunatic@users.noreply.github.com>2025-08-08 21:51:30 -0400
committerLagoLunatic <LagoLunatic@users.noreply.github.com>2025-08-08 21:51:30 -0400
commit5802571a5680c65e2fcdd39bceac26d42f490d64 (patch)
tree371d72242beb595fd0887c025846062cf7a75efa /src/d/d_npc.cpp
parentb24d8574cdef4f7e4521b2b0c72e0a8775706d9c (diff)
Add SQUARE macro to improve readibility for distances
Diffstat (limited to 'src/d/d_npc.cpp')
-rw-r--r--src/d/d_npc.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/d/d_npc.cpp b/src/d/d_npc.cpp
index 3c73c812..7f0436b5 100644
--- a/src/d/d_npc.cpp
+++ b/src/d/d_npc.cpp
@@ -104,7 +104,7 @@ void dNpc_JntCtrl_c::lookAtTarget(s16* outY, cXyz* pDstPos, cXyz srcPos, s16 def
delta.x = pDstPos->x - srcPos.x;
delta.y = pDstPos->y - srcPos.y;
delta.z = pDstPos->z - srcPos.z;
- f32 distXZ = std::sqrtf(delta.x * delta.x + delta.z * delta.z);
+ f32 distXZ = std::sqrtf(SQUARE(delta.x) + SQUARE(delta.z));
targetY = cM_atan2s(delta.x, delta.z);
r23 = cM_atan2s(delta.y, distXZ);
} else {
@@ -422,7 +422,7 @@ bool dNpc_PathRun_c::setNearPathIndx(cXyz* param_1, f32 param_2) {
cXyz diff = (*param_1 - point);
f32 xz_mag = diff.abs2XZ();
- f32 y_mag = param_2 * (diff.y * diff.y);
+ f32 y_mag = param_2 * SQUARE(diff.y);
f32 dist = std::sqrtf(y_mag + xz_mag);
if(max_dist > dist) {
@@ -629,7 +629,7 @@ void dNpc_calc_DisXZ_AngY(cXyz param_1, cXyz param_2, float* param_3, s16* param
diff.z = param_2.z - param_1.z;
if(param_3 != 0) {
- f32 dist = std::sqrtf(diff.x * diff.x + diff.z * diff.z);
+ f32 dist = std::sqrtf(SQUARE(diff.x) + SQUARE(diff.z));
*param_3 = dist;
}