X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FPlane.hh;h=11cd63ec23f2bf7f6517a8b2d5e937eb6f3832f3;hp=5ec59eab28e1c6115f4923b92892de9fd5e9d572;hb=7e84479de612a4ce287c6f63deb014b447a993ec;hpb=a723e23ca2d32e8eed32f9c53323afbbedba575b diff --git a/src/Moof/Plane.hh b/src/Moof/Plane.hh index 5ec59ea..11cd63e 100644 --- a/src/Moof/Plane.hh +++ b/src/Moof/Plane.hh @@ -79,7 +79,8 @@ struct Plane : public Shape<3> { // the ray lies on the plane intersection.point = ray.point; - intersection.normal = normal; + intersection.normal.set(0.0, 0.0, 0.0); + //intersection.normal = normal; return SCALAR(0.0); } @@ -87,11 +88,14 @@ struct Plane : public Shape<3> return SCALAR(-1.0); } - Scalar t = (cml::dot(ray.point, normal) + d) / denominator; + Scalar distance = cml::dot(ray.point, normal) + d; + Scalar t = -distance / denominator; if (t > SCALAR(0.0)) { ray.solve(intersection.point, t); - intersection.normal = normal; + + if (distance >= 0.0) intersection.normal = normal; + else intersection.normal = -normal; } return t;