diff options
author | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 15:53:29 -0500 |
---|---|---|
committer | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 15:53:29 -0500 |
commit | 4ddcfc0bb65d82d4e3fd2d424912086a4b454fdf (patch) | |
tree | 36df67d3c86055707d14bb037d1b2de342e31b68 /3dmath.c | |
parent | 64a24eff5995c44d21e42d0bc654739030eca76c (diff) |
3dmath.c: Remove sqrt from sphere_intersect
Interestingly, this seems to only save 1ms/frame on yelena. But that's still
16% of a 60fps frame.
Diffstat (limited to '3dmath.c')
-rw-r--r-- | 3dmath.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -43,10 +43,10 @@ sphere_intersect(float* restrict y, float* restrict r, n[i] = y[i] - c[i]; } - normalize(n); + float two_dot_nd_div_sq_n_mag = 2.0f * dot(n, d) / dot(n, n); - for(i = 0; i < 3; ++i) - r[i] = d[i] - 2 * dot(n, d) * n[i]; + for (i = 0; i < 3; ++i) + r[i] = d[i] - two_dot_nd_div_sq_n_mag * n[i]; return t; } |