]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Plane.hh
ray-scene intersection
[chaz/yoink] / src / Moof / Plane.hh
index 5ec59eab28e1c6115f4923b92892de9fd5e9d572..11cd63ec23f2bf7f6517a8b2d5e937eb6f3832f3 100644 (file)
@@ -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;
This page took 0.01689 seconds and 4 git commands to generate.