From 4f93c2526b82132ee695949779775b5e7abc7d4d Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Thu, 13 Aug 2015 08:43:15 +0200 Subject: [PATCH 1/1] fix normal in intersection ray/box intersection was transformed by M which apparently was wrong :) --- src/model/geometry.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/model/geometry.cpp b/src/model/geometry.cpp index c2816b4..e0b5582 100644 --- a/src/model/geometry.cpp +++ b/src/model/geometry.cpp @@ -47,20 +47,17 @@ bool Intersection( *dist = t_min; } if (normal) { - glm::vec4 norm(0.0f); if (min_all.x > min_all.y) { if (min_all.x > min_all.z) { - norm.x = t2.x < t1.x ? 1 : -1; + normal->x = t2.x < t1.x ? 1 : -1; } else { - norm.z = t2.z < t1.z ? 1 : -1; + normal->z = t2.z < t1.z ? 1 : -1; } } else if (min_all.y > min_all.z) { - norm.y = t2.y < t1.y ? 1 : -1; + normal->y = t2.y < t1.y ? 1 : -1; } else { - norm.z = t2.z < t1.z ? 1 : -1; + normal->z = t2.z < t1.z ? 1 : -1; } - norm = M * norm; - *normal = glm::vec3(norm); } return true; } -- 2.39.2