diff --git a/shapes/Union.cc b/shapes/Union.cc index 4f1eca4..a3257f9 100644 --- a/shapes/Union.cc +++ b/shapes/Union.cc @@ -33,7 +33,7 @@ Shape::IntersectionList Union::intersect(refptr _this, const Ray & ray) in1 = true; else in2 = true; - if (!in_bool && in1 && in2) + if (!in_bool && (in1 || in2)) { /* we found an intersection point with the boolean object */ in_bool = true; @@ -42,16 +42,16 @@ Shape::IntersectionList Union::intersect(refptr _this, const Ray & ray) } else { - if (in_bool && in1 && in2) - { - /* we found an intersection point with the boolean object */ - res.add( merged[i].intersection ); - } if (left) in1 = false; else in2 = false; - in_bool = false; + if (in_bool && !(in1 || in2)) + { + /* we found an intersection point with the boolean object */ + res.add( merged[i].intersection ); + in_bool = false; + } } }