optimized intersect() test for Subtract and Intersect boolean objects to not attempt intersecting with object B when object A had no intersections.... had about a 26% speed improvement for DW test scene

git-svn-id: svn://anubis/fart/trunk@304 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2010-09-28 14:22:25 +00:00
parent f337831df6
commit 138c90c2c3
2 changed files with 4 additions and 0 deletions

View File

@ -33,6 +33,8 @@ Shape::IntersectionList Intersect::intersect(refptr<Shape> _this, const Ray & ra
{ {
Ray ray_inv = m_inverse.transform_ray(ray); Ray ray_inv = m_inverse.transform_ray(ray);
IntersectionList res1 = m_shape1->intersect(m_shape1, ray_inv); 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); IntersectionList res2 = m_shape2->intersect(m_shape2, ray_inv);
BoolIntersectionList merged(res1, res2, ray_inv.getOrigin()); BoolIntersectionList merged(res1, res2, ray_inv.getOrigin());

View File

@ -33,6 +33,8 @@ Shape::IntersectionList Subtract::intersect(refptr<Shape> _this, const Ray & ray
{ {
Ray ray_inv = m_inverse.transform_ray(ray); Ray ray_inv = m_inverse.transform_ray(ray);
IntersectionList res1 = m_shape1->intersect(m_shape1, ray_inv); 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); IntersectionList res2 = m_shape2->intersect(m_shape2, ray_inv);
BoolIntersectionList merged(res1, res2, ray_inv.getOrigin()); BoolIntersectionList merged(res1, res2, ray_inv.getOrigin());