Commit 28dbc4be authored by hybrid's avatar hybrid

Defer bbox calculation of skinned mesh as suggested by tprochownik.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1603 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f6beb73a
...@@ -849,30 +849,11 @@ void CSkinnedMesh::finalize() ...@@ -849,30 +849,11 @@ void CSkinnedMesh::finalize()
LastSkinnedFrame=-1; LastSkinnedFrame=-1;
//calculate bounding box //calculate bounding box
for (i=0; i<LocalBuffers.size(); ++i) for (i=0; i<LocalBuffers.size(); ++i)
{ {
LocalBuffers[i]->recalculateBoundingBox(); LocalBuffers[i]->recalculateBoundingBox();
} }
// Get BoundingBox...
if (LocalBuffers.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(LocalBuffers[0]->BoundingBox.MaxEdge);
for (u32 j=0; j<LocalBuffers.size(); ++j)
{
BoundingBox.addInternalBox(LocalBuffers[j]->BoundingBox);
}
}
//add 5% padding to bounding box
core::vector3df Padding=BoundingBox.getExtent()*0.05f;
BoundingBox.MinEdge-=Padding;
BoundingBox.MaxEdge+=Padding;
if (AllJoints.size() || RootJoints.size()) if (AllJoints.size() || RootJoints.size())
{ {
// populate AllJoints or RootJoints, depending on which is empty // populate AllJoints or RootJoints, depending on which is empty
...@@ -1081,6 +1062,23 @@ void CSkinnedMesh::finalize() ...@@ -1081,6 +1062,23 @@ void CSkinnedMesh::finalize()
Buffer->Transformation=AllJoints[i]->GlobalAnimatedMatrix; Buffer->Transformation=AllJoints[i]->GlobalAnimatedMatrix;
} }
} }
//calculate bounding box
if (LocalBuffers.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(LocalBuffers[0]->BoundingBox.MaxEdge);
for (u32 j=0; j<LocalBuffers.size(); ++j)
{
BoundingBox.addInternalBox(LocalBuffers[j]->BoundingBox);
}
}
//add 5% padding to bounding box
const core::vector3df Padding = BoundingBox.getExtent()*0.05f;
BoundingBox.MinEdge -= Padding;
BoundingBox.MaxEdge += Padding;
} }
......
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