catch a few error conditions for extrudes and polygons

git-svn-id: svn://anubis/fart/trunk@271 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2010-07-01 21:24:39 +00:00
parent 4c5444f053
commit b51d11d043

View File

@ -569,6 +569,11 @@ refptr<Shape> Scene::processExtrude(refptr<Node> node)
else if ( typeid(**it) == typeid(OffsetNode) ) else if ( typeid(**it) == typeid(OffsetNode) )
{ {
double distance = (*it)->getNumber(); double distance = (*it)->getNumber();
if (distance <= 0.0)
{
cerr << "Error: extrude distance must be positive" << endl;
exit(3);
}
Vector scale(1, 1, 1); Vector scale(1, 1, 1);
Vector position(0, 0, 0); Vector position(0, 0, 0);
for (Node_Iterator it2 = (*it)->getChildren().begin(); for (Node_Iterator it2 = (*it)->getChildren().begin();
@ -584,6 +589,11 @@ refptr<Shape> Scene::processExtrude(refptr<Node> node)
position = * (*it2)->getVector(); position = * (*it2)->getVector();
} }
} }
if (scale[0] < 0.0 || scale[1] < 0.0)
{
cerr << "Error: extrude scale cannot be negative" << endl;
exit(3);
}
extrude->addOffset(distance, scale, position); extrude->addOffset(distance, scale, position);
} }
else if ( (*it)->isMaterial() ) else if ( (*it)->isMaterial() )
@ -619,6 +629,11 @@ refptr<Polygon> Scene::processPolygon(refptr<Node> node)
exit(3); exit(3);
} }
} }
if (p->size() < 3)
{
cerr << "Error: Polygon with fewer than three points!" << endl;
exit(3);
}
return p; return p;
} }