Tweak division by 0 QoL fix

This commit is contained in:
Colton Rushton 2021-02-20 20:19:40 -04:00
parent fdaec405bc
commit 899490a8fd
1 changed files with 1 additions and 3 deletions

View File

@ -172,11 +172,9 @@ void *vec3f_normalize(Vec3f dest) {
//! Possible division by zero
f32 invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]);
#else
f32 invsqrt = 0.0f;
f32 invsqrt = 1.0f;
if (sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]) != 0) {
invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]);
} else {
invsqrt = 1.0f * 0.0f;
}
#endif