Hello,
I wanna ask a question about the irrlicht source code.
Here is my question :
I am digging codes that handling about animated models.
I try to load "dwarf.x" into the tutorial 1 and trace it.
In ISceneManager :: drawAll(), this function should be the whole scene renderer of irrlicht.
When I traced onto the line
// do animations and other stuff.
OnAnimate(os::Timer::getTime());
This would trigger
CAnimatedMeshSceneNode :: OnAnimate()
void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
{
buildFrameNr(timeMs-LastTimeMs);
if (Mesh)
{
scene::IMesh * mesh = getMeshForCurrentFrame();
if (mesh)
Box = mesh->getBoundingBox();
}
LastTimeMs = timeMs;
IAnimatedMeshSceneNode::OnAnimate ( timeMs );
}
And then as I trace to the line
for (i=0; i<SolidNodeList.size(); ++i)
SolidNodeList[i].Node->render();
This triggers
//! renders the node.
void CAnimatedMeshSceneNode::render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
if (!Mesh || !driver)
return;
bool isTransparentPass =
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
++PassCount;
scene::IMesh* m = getMeshForCurrentFrame();
if(m)
{
Box = m->getBoundingBox();
}
else
{
#ifdef _DEBUG
os::Printer::log("Animated Mesh returned no mesh to render.", Mesh->getDebugName(), ELL_WARNING);
#endif
}
.....
My question is that obviously, getMeshForCurrentFrame(); is called twice at each rendering job.
This would cause animated mesh to re-calculate animated vertex data twice, right?
Is there another way to avoid this situation for the performance issue?
Or just this re-calculation is necessary for another purpose?
Any feedback would be appreciated.
