mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
add normal safety
wrap safety around normal checks, this was done on the scalar math may as well do it here just in case. Ad the impl.inl files to libraries so they can actually be found.
This commit is contained in:
parent
5a6467d54a
commit
8c1acbd1da
7 changed files with 61 additions and 14 deletions
|
|
@ -183,8 +183,15 @@ namespace
|
|||
|
||||
inline f32x4 v_normalize3(f32x4 v)
|
||||
{
|
||||
f32x4 inv = v_rsqrt_nr(v_dot3(v, v));
|
||||
return _mm_mul_ps(v, inv);
|
||||
const f32x4 zero = _mm_setzero_ps();
|
||||
const f32x4 fallback = _mm_set_ps(0.0f, 1.0f, 0.0f, 0.0f); // {0,0,1,0}
|
||||
f32x4 dot = v_dot3(v, v);
|
||||
|
||||
f32x4 inv = v_rsqrt_nr(dot);
|
||||
f32x4 isZero = _mm_cmpeq_ps(dot, zero);
|
||||
f32x4 norm = _mm_mul_ps(v, inv);
|
||||
|
||||
return _mm_blendv_ps(norm, fallback, isZero);
|
||||
}
|
||||
|
||||
// adds all 4 lanes together.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue