diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-04-18 18:11:44 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-04-18 18:11:44 +0300 |
commit | 933f5226fec756016487f0cfdec0986f11d1eb87 (patch) | |
tree | a0a43ea19ddbd0368cb168d85f0fff20ed87dfe0 /indra/llmath/v3dmath.h | |
parent | 01f73fe120244f1849e987f0273e2bbbbb87d342 (diff) | |
parent | 8c5d144f99eacaee619d07c5046c37a2481c2fb5 (diff) |
Merge branch 'develop' into marchcat/05-develop
Diffstat (limited to 'indra/llmath/v3dmath.h')
-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); |