modify getAABBRecursively

This commit is contained in:
yangxiao 2015-04-08 16:40:04 +08:00
parent 3b01222787
commit a7a39d71f5
2 changed files with 28 additions and 9 deletions

View File

@ -820,6 +820,22 @@ const BlendFunc& Sprite3D::getBlendFunc() const
return _blend;
}
AABB Sprite3D::getAABBRecursively()
{
AABB aabb;
const Vector<Node*>& children = getChildren();
for (const auto& iter : children)
{
Sprite3D* child = dynamic_cast<Sprite3D*>(iter);
if(child)
{
aabb.merge(child->getAABBRecursively());
}
}
aabb.merge(getAABB());
return aabb;
}
const AABB& Sprite3D::getAABB() const
{
Mat4 nodeToWorldTransform(getNodeToWorldTransform());
@ -832,6 +848,8 @@ const AABB& Sprite3D::getAABB() const
else
{
_aabb.reset();
if (_meshes.size())
{
Mat4 transform(nodeToWorldTransform);
for (const auto& it : _meshes) {
if (it->isVisible())
@ -842,6 +860,7 @@ const AABB& Sprite3D::getAABB() const
_nodeToWorldTransform = nodeToWorldTransform;
_aabbDirty = false;
}
}
return _aabb;
}

View File

@ -141,7 +141,7 @@ public:
* the Sprite3D don't contain any meshes, so getAABB()
* will return a wrong value at that time.
*/
const AABB& getAABBRecursively();
AABB getAABBRecursively();
/**
* Executes an action, and returns the action that is executed. For Sprite3D special logic are needed to take care of Fading.