From 4ddcfc0bb65d82d4e3fd2d424912086a4b454fdf Mon Sep 17 00:00:00 2001 From: Morten Hustveit Date: Tue, 2 Dec 2014 15:53:29 -0500 Subject: 3dmath.c: Remove sqrt from sphere_intersect Interestingly, this seems to only save 1ms/frame on yelena. But that's still 16% of a 60fps frame. --- 3dmath.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '3dmath.c') diff --git a/3dmath.c b/3dmath.c index 866af09..9e7f7a1 100644 --- a/3dmath.c +++ b/3dmath.c @@ -43,10 +43,10 @@ sphere_intersect(float* restrict y, float* restrict r, n[i] = y[i] - c[i]; } - normalize(n); + float two_dot_nd_div_sq_n_mag = 2.0f * dot(n, d) / dot(n, n); - for(i = 0; i < 3; ++i) - r[i] = d[i] - 2 * dot(n, d) * n[i]; + for (i = 0; i < 3; ++i) + r[i] = d[i] - two_dot_nd_div_sq_n_mag * n[i]; return t; } -- cgit v1.2.3