Modify LOD node to use cleaner technique
This commit is contained in:
parent
5c1b24b4e4
commit
fd1f2537d4
@ -137,19 +137,24 @@ void LODNode::OnAnimate(u32 timeMs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LODNode::OnRegisterSceneNode()
|
void LODNode::updateVisibility(bool* shown)
|
||||||
{
|
{
|
||||||
if (!isVisible()) return;
|
if (!isVisible()) return;
|
||||||
if (m_nodes.size() == 0) return;
|
if (m_nodes.size() == 0) return;
|
||||||
|
|
||||||
bool shown = false;
|
|
||||||
int level = getLevel();
|
int level = getLevel();
|
||||||
if (level>=0)
|
for (int i = 0; i < m_nodes.size(); i++)
|
||||||
{
|
{
|
||||||
m_nodes[level]->updateAbsolutePosition();
|
m_nodes[i]->setVisible(i == level);
|
||||||
m_nodes[level]->OnRegisterSceneNode();
|
if (i == level && shown != NULL)
|
||||||
shown = true;
|
*shown = level;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LODNode::OnRegisterSceneNode()
|
||||||
|
{
|
||||||
|
bool shown;
|
||||||
|
updateVisibility(&shown);
|
||||||
|
|
||||||
const u32 now = irr_driver->getDevice()->getTimer()->getTime();
|
const u32 now = irr_driver->getDevice()->getTimer()->getTime();
|
||||||
|
|
||||||
@ -158,6 +163,7 @@ void LODNode::OnRegisterSceneNode()
|
|||||||
m_nodes[0]->getType() == scene::ESNT_ANIMATED_MESH) &&
|
m_nodes[0]->getType() == scene::ESNT_ANIMATED_MESH) &&
|
||||||
now > m_last_tick)
|
now > m_last_tick)
|
||||||
{
|
{
|
||||||
|
int level = getLevel();
|
||||||
if (m_previous_visibility == WAS_HIDDEN && shown)
|
if (m_previous_visibility == WAS_HIDDEN && shown)
|
||||||
{
|
{
|
||||||
scene::IMesh* mesh;
|
scene::IMesh* mesh;
|
||||||
@ -254,20 +260,7 @@ void LODNode::OnRegisterSceneNode()
|
|||||||
m_previous_visibility = (shown ? WAS_SHOWN : WAS_HIDDEN);
|
m_previous_visibility = (shown ? WAS_SHOWN : WAS_HIDDEN);
|
||||||
m_last_tick = now;
|
m_last_tick = now;
|
||||||
|
|
||||||
// If this node has children other than the LOD nodes, draw them
|
scene::ISceneNode::OnRegisterSceneNode();
|
||||||
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)->OnRegisterSceneNode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LODNode::add(int level, scene::ISceneNode* node, bool reparent)
|
void LODNode::add(int level, scene::ISceneNode* node, bool reparent)
|
||||||
|
@ -83,6 +83,8 @@ public:
|
|||||||
|
|
||||||
int getLevel();
|
int getLevel();
|
||||||
|
|
||||||
|
void updateVisibility(bool* shown = NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//! Returns a reference to the current relative transformation matrix.
|
//! Returns a reference to the current relative transformation matrix.
|
||||||
//! This is the matrix, this scene node uses instead of scale, translation
|
//! This is the matrix, this scene node uses instead of scale, translation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user