moved Node::evaluateChildren() to nodes.cc, added EvaluatePropagateNode support

git-svn-id: svn://anubis/fart/branches/scene-file-scripting@340 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2010-10-06 17:54:54 +00:00
parent 18886ef767
commit 4d488b9e55
2 changed files with 30 additions and 15 deletions

View File

@ -9,6 +9,35 @@
using namespace std; using namespace std;
void Node::evaluateChildren(refptr<Node> parent)
{
/* recursively evaluate all children nodes */
for (std::vector< refptr<Node> >::iterator it = m_children.begin();
it != m_children.end();
it++)
{
refptr<Node> evaluated = (*it)->evaluate();
if ( ! evaluated.isNull() )
{
if (typeid(*evaluated) == typeid(EvaluatePropagateNode))
{
for (vector<NodeRef>::iterator it2
= evaluated->getChildren().begin();
it2 != evaluated->getChildren().end();
it2++)
{
parent->addChild(*it2);
}
}
else
{
(*it)->evaluateChildren(evaluated);
parent->addChild(evaluated);
}
}
}
}
void Node::addChildren(NodeRef other) void Node::addChildren(NodeRef other)
{ {
if (other.isNull()) if (other.isNull())

View File

@ -44,21 +44,7 @@ class Node
std::cerr << "Warning: Node::evaluate() called!" << std::endl; std::cerr << "Warning: Node::evaluate() called!" << std::endl;
return NULL; return NULL;
} }
virtual void evaluateChildren(refptr<Node> parent) virtual void evaluateChildren(refptr<Node> parent);
{
/* recursively evaluate all children nodes */
for (std::vector< refptr<Node> >::iterator it = m_children.begin();
it != m_children.end();
it++)
{
refptr<Node> evaluated = (*it)->evaluate();
if ( ! evaluated.isNull() )
{
(*it)->evaluateChildren(evaluated);
parent->addChild(evaluated);
}
}
}
virtual bool isShape() { return false; } virtual bool isShape() { return false; }
virtual bool isMaterial() { return false; } virtual bool isMaterial() { return false; }