diff options
author | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 14:58:22 -0500 |
---|---|---|
committer | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 14:58:22 -0500 |
commit | 8fdc2a63b118f37fa0bad11be0104296556aa5b0 (patch) | |
tree | a7de209070f12d8247faf7edf3bfe89196676afa /3dmath.c | |
parent | 04ee2de37c1f80d098172fc7bc4d42ea1797f128 (diff) |
3dmath.c: In normalize, calculate reciprocal only once, and use sqrtf
This saves about 12ms per frame on yelena.
Diffstat (limited to '3dmath.c')
-rw-r--r-- | 3dmath.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -11,13 +11,11 @@ dot(const float x[3], const float y[3]) { void normalize(float x[3]) { - float len; - int i; - - len = sqrt(dot(x, x)); + float len = 1.0f / sqrtf(dot(x, x)); - for(i = 0; i < 3; ++i) - x[i] /= len; + x[0] *= len; + x[1] *= len; + x[2] *= len; } float |