Commit f2277b5d authored by Michele Bosi's avatar Michele Bosi

Added ActorTree findChild()/eraseChild() and non const Transform::worldMatrix()

parent 10be9a90
......@@ -162,6 +162,12 @@ namespace vl
return mWorldMatrix;
}
/** Returns the world matrix used for rendering. Use this only if you keep the matrices up to date on your own. */
mat4& worldMatrix()
{
return mWorldMatrix;
}
/** Sets both the local and the world matrices.
* This function is useful to quickly set those Transforms that do not have a parent, for which
* is equivalent to: \p setLocalMatrix(matrix); \p computeWorldMatrix(NULL); */
......
......@@ -53,6 +53,27 @@ void ActorTree::addChild(ActorTreeAbstract* node)
mChildren.push_back(node);
}
//-----------------------------------------------------------------------------
int ActorTree::findChild(ActorTreeAbstract* node)
{
int pos = -1;
std::vector< ref<ActorTreeAbstract> >::iterator it = std::find( mChildren.begin(), mChildren.end(), node );
if ( it != mChildren.end() ) {
pos = (int)( it - mChildren.begin() );
}
return pos;
}
//-----------------------------------------------------------------------------
bool ActorTree::eraseChild(ActorTreeAbstract* node)
{
int pos = findChild( node );
if ( pos != -1 ) {
eraseChild( pos );
return true;
} else {
return false;
}
}
//-----------------------------------------------------------------------------
void ActorTree::setChild(int i, ActorTreeAbstract* node)
{
if (node->parent())
......
......@@ -74,6 +74,8 @@ namespace vl
virtual const ActorTreeAbstract* child(int i) const { return mChildren[i].get(); }
void addChild(ActorTreeAbstract* node);
int findChild(ActorTreeAbstract* node);
bool eraseChild(ActorTreeAbstract* node);
void setChild(int i, ActorTreeAbstract* node);
void eraseChild(int i, int count=1);
void eraseAllChildren();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment