mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-27 07:15:37 +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
|
|
@ -205,8 +205,19 @@ namespace
|
|||
|
||||
inline f32x4 v_normalize3(f32x4 v)
|
||||
{
|
||||
f32x4 inv = v_rsqrt_nr(v_dot3(v,v));
|
||||
return vmulq_f32(v, inv);
|
||||
const float32x4_t zero = vdupq_n_f32(0.0f);
|
||||
const float32x4_t fallback = {0.0f, 0.0f, 1.0f, 0.0f};
|
||||
|
||||
f32x4 dot = v_dot3(v, v);
|
||||
|
||||
// dot == 0?
|
||||
uint32x4_t isZero = vceqq_f32(dot, zero);
|
||||
|
||||
f32x4 inv = v_rsqrt_nr(dot);
|
||||
f32x4 norm = vmulq_f32(v, inv);
|
||||
|
||||
// Select fallback when zero
|
||||
return vbslq_f32(isZero, fallback, norm);
|
||||
}
|
||||
|
||||
inline f32x4 v_hadd4(f32x4 a)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue