From 506f199a2d750edecc6807d4189de3fb86cef81d Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 14 Jul 2024 13:47:55 -0700 Subject: [PATCH] JPAMath work --- src/JSystem/JParticle/JPAMath.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/JSystem/JParticle/JPAMath.cpp b/src/JSystem/JParticle/JPAMath.cpp index 61e779e58..a371e7681 100644 --- a/src/JSystem/JParticle/JPAMath.cpp +++ b/src/JSystem/JParticle/JPAMath.cpp @@ -8,7 +8,9 @@ #include "JSystem/JMath/JMATrigonometric.h" #include "dolphin/types.h" -static const f32 dummy[1] = { 1.0f }; +static void dummy() { + fabsf(1.0f); +} /* 8025991C-802599A0 .text JPAGetYZRotateMtx__FssPA4_f */ void JPAGetYZRotateMtx(s16 y, s16 z, Mtx dst) { @@ -62,11 +64,19 @@ void JPAGetDirMtx(const JGeometry::TVec3& dir, Mtx dst) { JGeometry::TVec3 perp; perp.x = dir.y; perp.y = -dir.x; + f32 z = dir.z; perp.z = 0.0f; - f32 mag = perp.normalize(); + f32 mag = perp.squared(); + mag *= JGeometry::TUtil::inv_sqrt(mag); + if (mag <= JGeometry::TUtil::epsilon()) { + perp.x = perp.y = 0.0f; + } else { + perp.x *= (1.0f / mag); + perp.y *= (1.0f / mag); + } - f32 x = perp.x, y = perp.y, z = dir.z; + f32 x = perp.x, y = perp.y; dst[0][0] = x*x + z * (1.0f - x*x); dst[0][1] = (1.0f - z) * (x * y); dst[0][2] = -y * mag;