summaryrefslogtreecommitdiff
path: root/src/math/vec3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/vec3.c')
-rw-r--r--src/math/vec3.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/math/vec3.c b/src/math/vec3.c
index 5d273d8..df56f3f 100644
--- a/src/math/vec3.c
+++ b/src/math/vec3.c
@@ -110,7 +110,11 @@ void vec3_multiply(Vec3* v1, Vec3* v2, Quat* out) {
void vec3_normalize(Vec3* v, Vec3* out) {
ssr_assert(v && out);
//float mag = rsqrt(v->x * v->x + v->y * v->y + v->z * v->z);
- float mag = 1.f / vec3_magnitude(v);
+ float mag = vec3_magnitude(v);
+ if (compare(mag, 0)) {
+ return;
+ }
+ mag = 1.f / mag;
out->x = v->x * mag;
out->y = v->y * mag;
out->z = v->z * mag;