diff --git a/shapes/Intersect.cc b/shapes/Intersect.cc index a4c421e..2546c1c 100644 --- a/shapes/Intersect.cc +++ b/shapes/Intersect.cc @@ -33,6 +33,8 @@ Shape::IntersectionList Intersect::intersect(refptr _this, const Ray & ra { Ray ray_inv = m_inverse.transform_ray(ray); IntersectionList res1 = m_shape1->intersect(m_shape1, ray_inv); + if (res1.size() == 0) /* optimization */ + return res1; IntersectionList res2 = m_shape2->intersect(m_shape2, ray_inv); BoolIntersectionList merged(res1, res2, ray_inv.getOrigin()); diff --git a/shapes/Subtract.cc b/shapes/Subtract.cc index a2f2d94..dd7a646 100644 --- a/shapes/Subtract.cc +++ b/shapes/Subtract.cc @@ -33,6 +33,8 @@ Shape::IntersectionList Subtract::intersect(refptr _this, const Ray & ray { Ray ray_inv = m_inverse.transform_ray(ray); IntersectionList res1 = m_shape1->intersect(m_shape1, ray_inv); + if (res1.size() == 0) /* optimization */ + return res1; IntersectionList res2 = m_shape2->intersect(m_shape2, ray_inv); BoolIntersectionList merged(res1, res2, ray_inv.getOrigin());