]> git.localhorst.tv Git - blank.git/commitdiff
fix normal in intersection ray/box intersection
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 13 Aug 2015 06:43:15 +0000 (08:43 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 13 Aug 2015 18:21:12 +0000 (20:21 +0200)
was transformed by M which apparently was wrong :)

src/model/geometry.cpp

index c2816b44a0f585f67781ef7e6bbe4e811dcd4fe9..e0b55826de35ed58bb05ca441a260a5877f45e86 100644 (file)
@@ -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;
 }