Fix a division by 0 when normalizing a vector.

This commit is contained in:
David Reid
2021-04-02 09:48:00 +10:00
parent 88687fdc43
commit ca5023415f
+6 -1
View File
@@ -8784,8 +8784,13 @@ MA_API float ma_vec3f_dist(ma_vec3f a, ma_vec3f b)
MA_API ma_vec3f ma_vec3f_normalize(ma_vec3f v)
{
float f = 1 / ma_vec3f_len(v);
float f;
float l = ma_vec3f_len(v);
if (l == 0) {
return ma_vec3f_init_3f(0, 0, 0);
}
f = 1 / l;
v.x *= f;
v.y *= f;
v.z *= f;