|
@@ -25,26 +25,32 @@ CSG::CSG(OperationType operation, Shape *left, Shape *right) : Shape(SHAPE_CSG),
|
|
|
}
|
|
|
|
|
|
Intersect CSG::localIntersect(Ray r)
|
|
|
+{
|
|
|
+ return this->intersect(r);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+Intersect CSG::intersect(Ray r)
|
|
|
{
|
|
|
int i;
|
|
|
- Intersect leftxs = this->left->intersect(r);
|
|
|
- Intersect rightxs = this->right->intersect(r);
|
|
|
+ Intersect ret = Intersect();
|
|
|
|
|
|
- for(i = 0; i < rightxs.count(); i++)
|
|
|
+ if (this->bounds.intesectMe(r))
|
|
|
{
|
|
|
- leftxs.add(rightxs[i]);
|
|
|
- }
|
|
|
+ Intersect leftxs = this->left->intersect(r);
|
|
|
+ Intersect rightxs = this->right->intersect(r);
|
|
|
+
|
|
|
+ for (i = 0 ; i < rightxs.count() ; i++)
|
|
|
+ {
|
|
|
+ leftxs.add(rightxs[i]);
|
|
|
+ }
|
|
|
|
|
|
- Intersect ret = this->filterIntersections(leftxs);
|
|
|
+ this->filterIntersections(leftxs, ret);
|
|
|
+ }
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-Intersect CSG::intersect(Ray r)
|
|
|
-{
|
|
|
- return localIntersect(r);
|
|
|
-}
|
|
|
-
|
|
|
Tuple CSG::localNormalAt(Tuple point, Intersection *hit)
|
|
|
{
|
|
|
return Vector(1, 0, 0);
|