diff options
author | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 15:10:58 -0500 |
---|---|---|
committer | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 15:10:58 -0500 |
commit | 59eb492aac9d1d5a005858f9e32b34ac79cb02a6 (patch) | |
tree | 579f236d0773e655c792e12687849f230e6b79e7 /3dmath.c | |
parent | ef3f2085ff238469207d099562d61635e1f9e138 (diff) |
3dmath.c: Early out of sphere_intersect on t <= 0
The loop in ray.c discards any data from intersections with t <= 0 anyway, so
we might as well not calculate it.
This saves 15 ms/frame on yelena.
Diffstat (limited to '3dmath.c')
-rw-r--r-- | 3dmath.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -35,6 +35,9 @@ sphere_intersect(float* restrict y, float* restrict r, t = -dot(v, d) - D; + if (t <= 0) + return -1; + for(i = 0; i < 3; ++i) { y[i] = s[i] + t * d[i]; n[i] = y[i] - c[i]; |