From 6cee50ceb0d153622b89fb813060419f5985857d Mon Sep 17 00:00:00 2001 From: Morten Hustveit Date: Tue, 2 Dec 2014 21:32:20 -0500 Subject: Subtract the central sphere, and update the animation to match --- 3dmath.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to '3dmath.c') diff --git a/3dmath.c b/3dmath.c index 9e7f7a1..5bc1861 100644 --- a/3dmath.c +++ b/3dmath.c @@ -2,8 +2,6 @@ #include -#define POW2(x) ((x) * (x)) - float dot(const float x[3], const float y[3]) { return x[0] * y[0] + x[1] * y[1] + x[2] * y[2]; @@ -21,7 +19,7 @@ normalize(float x[3]) { float sphere_intersect(float* restrict y, float* restrict r, const float* restrict s, const float* restrict d, - const float* restrict c, float R) { + const float* restrict c, float R, int invert) { int i; float D, n[3], t, v[3]; @@ -33,7 +31,10 @@ sphere_intersect(float* restrict y, float* restrict r, if(D < 0) return -1; - t = -dot(v, d) - D; + if (invert) + t = -dot(v, d) + D; + else + t = -dot(v, d) - D; if (t <= 0) return -1; -- cgit v1.2.3