Fixed boolean objects to determine if rays start inside or outside the boolean; changed constructors to accept a list of shapes instead of just two shapes; changed parser to accept any number of top-level shapes inside of a boolean shape block; changed scenes/die.fart to reflect this change (a drastic simplification)

git-svn-id: svn://anubis/fart/trunk@215 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop committed 2009-03-15 19:51:21 +00:00
1 parent f103b71ed6
commit 5590c533ce
12 files changed
+203 -173

No files matched your search

+10 -26
View File
@@ -465,9 +465,8 @@ refptr<Shape> Scene::processSphere(refptr<Node> node)
refptr<Shape> Scene::processBool(refptr<Node> node)
{
refptr<Shape> shape1, shape2;
vector< refptr<Shape> > shapes;
refptr<Material> material;
int shapes_seen = 0;
bool restore_transform = processTransforms(node);
@@ -477,14 +476,9 @@ refptr<Shape> Scene::processBool(refptr<Node> node)
{
if ( (*it)->isShape() )
{
switch (shapes_seen)
{
case 0: shape1 = processShape(*it);
break;
case 1: shape2 = processShape(*it);
break;
}
shapes_seen++;
refptr<Shape> shape = processShape(*it);
if ( ! shape.isNull() )
shapes.push_back(shape);
}
else if ( (*it)->isMaterial() )
{
@@ -492,30 +486,20 @@ refptr<Shape> Scene::processBool(refptr<Node> node)
}
}
if (shapes_seen < 2 || shape1.isNull() || shape2.isNull())
if (shapes.size() < 2)
{
if (shapes_seen < 2)
cerr << __FILE__ << ": " << __LINE__
<< ": error: only saw "
<< shapes_seen
<< " child shapes!"
<< endl;
if (shape1.isNull())
cerr << __FILE__ << ": " << __LINE__
<< ": error: shape1 is null!" << endl;
if (shape2.isNull())
cerr << __FILE__ << ": " << __LINE__
<< ": error: shape2 is null!" << endl;
cerr << "Error: boolean objects must have 2 or more sub-objects!"
<< endl;
exit(3);
}
refptr<Shape> shape;
if ( typeid(*node) == typeid(IntersectNode) )
shape = new Intersect(shape1, shape2);
shape = new Intersect(shapes);
else if ( typeid(*node) == typeid(UnionNode) )
shape = new Union(shape1, shape2);
shape = new Union(shapes);
else if ( typeid(*node) == typeid(SubtractNode) )
shape = new Subtract(shape1, shape2);
shape = new Subtract(shapes);
else
{
cerr << __FILE__ << ": " << __LINE__