From 59eb492aac9d1d5a005858f9e32b34ac79cb02a6 Mon Sep 17 00:00:00 2001 From: Morten Hustveit Date: Tue, 2 Dec 2014 15:10:58 -0500 Subject: 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. --- 3dmath.c | 3 +++ 1 file changed, 3 insertions(+) (limited to '3dmath.c') 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]; -- cgit v1.2.3