summaryrefslogtreecommitdiff
path: root/3dmath.c
diff options
context:
space:
mode:
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];