summaryrefslogtreecommitdiff
path: root/src/math/vec3.c
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-02-24 10:28:41 +0800
committerchai <chaifix@163.com>2020-02-24 10:28:41 +0800
commit538cb1cd010a3323ad61239a12a4134ef4dceca6 (patch)
tree0a2c492ce5d27c77da039aa5189b67aa3070aa20 /src/math/vec3.c
parentb656c9415a8e7e3b5b7d8bf1f3c8a5444f830c79 (diff)
*camera
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;