Apply patch by Steel to disable animations when the animated level of detail is not visible. Thanks

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11807 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-10-28 23:37:18 +00:00
parent 9112283551
commit 50a99ee486
3 changed files with 57 additions and 15 deletions

View File

@ -55,11 +55,39 @@ LODNode::~LODNode()
void LODNode::render()
{
if (isVisible())
ISceneNode::OnRegisterSceneNode();
//ISceneNode::render();
}
void LODNode::OnAnimate(u32 timeMs)
{
if (isVisible())
{
// update absolute position
updateAbsolutePosition();
// Assume all the scene node have the same bouding box
// update the less detailed one (it might be the unanimated one)
m_nodes[m_detail.size()-1]->OnAnimate(timeMs);
Box = m_nodes[m_detail.size()-1]->getBoundingBox();
// If this node has children other than the LOD nodes, animate it
core::list<ISceneNode*>::Iterator it;
for (it = Children.begin(); it != Children.end(); it++)
{
if (m_nodes_set.find(*it) == m_nodes_set.end())
{
assert(*it != NULL);
if ((*it)->isVisible())
{
(*it)->OnAnimate(timeMs);
}
}
}
}
}
void LODNode::OnRegisterSceneNode()
{
if (!isVisible()) return;
@ -77,6 +105,7 @@ void LODNode::OnRegisterSceneNode()
{
if (dist < m_detail[n])
{
m_nodes[n]->updateAbsolutePosition();
m_nodes[n]->OnRegisterSceneNode();
shown = true;
break;

View File

@ -102,6 +102,11 @@ public:
std::vector<scene::ISceneNode*>& getAllNodes() { return m_nodes; }
//! OnAnimate() is called just before rendering the whole scene.
/** This method will be called once per frame, independent
of whether the scene node is visible or not. */
virtual void OnAnimate(u32 timeMs);
virtual void OnRegisterSceneNode();
virtual void render();

View File

@ -228,6 +228,9 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models)
node = irr_driver->addAnimatedMesh(m_mesh);
// as animated mesh are not cheap to render use frustum box culling
node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
lod_node->add(50, node, true);
scene::ISceneNode* static_model = attachModel(false);
lod_node->add(500, static_model, true);
@ -242,6 +245,13 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models)
m_animated_node->setLoopMode(false);
m_animated_node->grab();
node = lod_node;
// Become the owner of the wheels
for(unsigned int i=0; i<4; i++)
{
if(!m_wheel_model[i]) continue;
m_wheel_node[i]->setParent(lod_node);
}
}
else
{
@ -259,19 +269,17 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models)
std::string debug_name = m_model_filename+" (kart-model)";
node->setName(debug_name.c_str());
#endif
}
for(unsigned int i=0; i<4; i++)
{
if(!m_wheel_model[i]) continue;
m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i], node);
m_wheel_node[i]->grab();
#ifdef DEBUG
std::string debug_name = m_wheel_filename[i]+" (wheel)";
m_wheel_node[i]->setName(debug_name.c_str());
#endif
m_wheel_node[i]->setPosition(m_wheel_graphics_position[i].toIrrVector());
for(unsigned int i=0; i<4; i++)
{
if(!m_wheel_model[i]) continue;
m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i], node);
m_wheel_node[i]->grab();
#ifdef DEBUG
std::string debug_name = m_wheel_filename[i]+" (wheel)";
m_wheel_node[i]->setName(debug_name.c_str());
#endif
m_wheel_node[i]->setPosition(m_wheel_graphics_position[i].toIrrVector());
}
}
return node;