File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -278,43 +278,44 @@ inline const LLVector3d& LLVector3d::setVec(const F64* vec)
278
278
279
279
inline F64 LLVector3d::normVec ()
280
280
{
281
- F64 mag = sqrt (mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]);
281
+ 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.
282
+ // Without it, Unit test "v3dmath_h" fails at "1:angle_between" on macos.
282
283
F64 oomag;
283
284
284
285
if (mag > FP_MAG_THRESHOLD)
285
286
{
286
- oomag = 1 .f /mag;
287
+ oomag = 1.0 /mag;
287
288
mdV[VX] *= oomag;
288
289
mdV[VY] *= oomag;
289
290
mdV[VZ] *= oomag;
290
291
}
291
292
else
292
293
{
293
- mdV[VX] = 0 .f ;
294
- mdV[VY] = 0 .f ;
295
- mdV[VZ] = 0 .f ;
294
+ mdV[VX] = 0.0 ;
295
+ mdV[VY] = 0.0 ;
296
+ mdV[VZ] = 0.0 ;
296
297
mag = 0 ;
297
298
}
298
299
return (mag);
299
300
}
300
301
301
302
inline F64 LLVector3d::normalize ()
302
303
{
303
- F64 mag = sqrt (mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]);
304
+ F64 mag = (F32) sqrt (mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); // Same as in normVec() above.
304
305
F64 oomag;
305
306
306
307
if (mag > FP_MAG_THRESHOLD)
307
308
{
308
- oomag = 1 .f /mag;
309
+ oomag = 1.0 /mag;
309
310
mdV[VX] *= oomag;
310
311
mdV[VY] *= oomag;
311
312
mdV[VZ] *= oomag;
312
313
}
313
314
else
314
315
{
315
- mdV[VX] = 0 .f ;
316
- mdV[VY] = 0 .f ;
317
- mdV[VZ] = 0 .f ;
316
+ mdV[VX] = 0.0 ;
317
+ mdV[VY] = 0.0 ;
318
+ mdV[VZ] = 0.0 ;
318
319
mag = 0 ;
319
320
}
320
321
return (mag);
You can’t perform that action at this time.
0 commit comments