From a1ab7c51f0f8f6d33fbdaf7e841f52de2a8b8933 Mon Sep 17 00:00:00 2001 From: KazeEmanuar <46371299+KazeEmanuar@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:04:58 +0200 Subject: [PATCH] Made raycasts not hit backfaces * Update name of lighting engine branch in readme --- src/engine/math_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 722d12466..c410e558b 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -1339,8 +1339,8 @@ s32 ray_surface_intersect(Vec3f orig, Vec3f dir, f32 dir_length, struct Surface vec3f_cross(h, dir, e2); // Determine the cos(angle) difference between ray and surface normals. f32 det = vec3f_dot(e1, h); - // Check if we're perpendicular from the surface. - if ((det > -NEAR_ZERO) && (det < NEAR_ZERO)) return FALSE; + // Check if we're perpendicular or pointing away from the surface. + if (det < NEAR_ZERO) return FALSE; // Check if we're making contact with the surface. // Make f the inverse of the cos(angle) between ray and surface normals. f32 f = 1.0f / det; // invDet