diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-04-18 01:04:51 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-04-18 11:57:55 +0300 |
commit | f029903cd953d24eba57f88e2c8a58a3b9647105 (patch) | |
tree | 1a40012daff9af40ecefb720f50b47634a5a3f04 | |
parent | c0ecfce26d77420f0a26bfb93a82eb9b61513677 (diff) |
Fix '1:angle_between' test failure
-rw-r--r-- | indra/llmath/v3dmath.h | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h index e72c150cdc..fcce2c30eb 100644 --- a/indra/llmath/v3dmath.h +++ b/indra/llmath/v3dmath.h @@ -278,21 +278,22 @@ inline const LLVector3d& LLVector3d::setVec(const F64* vec) inline F64 LLVector3d::normVec() { - F64 mag = sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); + F64 mag = (F32)sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); // This explicit cast to F32 limits the precision for numerical stability. + // Without it, Unit test "v3dmath_h" fails at "1:angle_between" on macos. F64 oomag; if (mag > FP_MAG_THRESHOLD) { - oomag = 1.f/mag; + oomag = 1.0/mag; mdV[VX] *= oomag; mdV[VY] *= oomag; mdV[VZ] *= oomag; } else { - mdV[VX] = 0.f; - mdV[VY] = 0.f; - mdV[VZ] = 0.f; + mdV[VX] = 0.0; + mdV[VY] = 0.0; + mdV[VZ] = 0.0; mag = 0; } return (mag); @@ -300,21 +301,21 @@ inline F64 LLVector3d::normVec() inline F64 LLVector3d::normalize() { - F64 mag = sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); + F64 mag = (F32)sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); // Same as in normVec() above. F64 oomag; if (mag > FP_MAG_THRESHOLD) { - oomag = 1.f/mag; + oomag = 1.0/mag; mdV[VX] *= oomag; mdV[VY] *= oomag; mdV[VZ] *= oomag; } else { - mdV[VX] = 0.f; - mdV[VY] = 0.f; - mdV[VZ] = 0.f; + mdV[VX] = 0.0; + mdV[VY] = 0.0; + mdV[VZ] = 0.0; mag = 0; } return (mag); |