summaryrefslogtreecommitdiff
path: root/3dmath.c
diff options
context:
space:
mode:
authorMorten Hustveit <morten.hustveit@gmail.com>2014-12-02 15:10:58 -0500
committerMorten Hustveit <morten.hustveit@gmail.com>2014-12-02 15:10:58 -0500
commit59eb492aac9d1d5a005858f9e32b34ac79cb02a6 (patch)
tree579f236d0773e655c792e12687849f230e6b79e7 /3dmath.c
parentef3f2085ff238469207d099562d61635e1f9e138 (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.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/3dmath.c b/3dmath.c
index 2693c32..866af09 100644
--- a/3dmath.c
+++ b/3dmath.c
@@ -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];