Use array list for scene nodes
This commit is contained in:
parent
98763a10eb
commit
fddc19225c
@ -24,8 +24,6 @@ namespace scene
|
||||
{
|
||||
class ISceneManager;
|
||||
|
||||
//! Typedef for list of scene nodes
|
||||
typedef core::list<ISceneNode*> ISceneNodeList;
|
||||
//! Typedef for list of scene node animators
|
||||
typedef core::list<ISceneNodeAnimator*> ISceneNodeAnimatorList;
|
||||
|
||||
@ -92,9 +90,8 @@ namespace scene
|
||||
{
|
||||
if (IsVisible)
|
||||
{
|
||||
ISceneNodeList::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
(*it)->OnRegisterSceneNode();
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
Children[i]->OnRegisterSceneNode();
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,9 +124,8 @@ namespace scene
|
||||
|
||||
// perform the post render process on all children
|
||||
|
||||
ISceneNodeList::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
(*it)->OnAnimate(timeMs);
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
Children[i]->OnAnimate(timeMs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,9 +138,8 @@ namespace scene
|
||||
|
||||
// perform the post render process on all children
|
||||
|
||||
ISceneNodeList::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
(*it)->recursiveUpdateAbsolutePosition();
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
Children[i]->recursiveUpdateAbsolutePosition();
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,16 +309,16 @@ namespace scene
|
||||
e.g. because it couldn't be found in the children list. */
|
||||
virtual bool removeChild(ISceneNode* child)
|
||||
{
|
||||
ISceneNodeList::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
if ((*it) == child)
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
{
|
||||
if (Children[i] == child)
|
||||
{
|
||||
(*it)->Parent = 0;
|
||||
(*it)->drop();
|
||||
Children.erase(it);
|
||||
child->Parent = 0;
|
||||
child->drop();
|
||||
Children.erase(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return false;
|
||||
}
|
||||
@ -335,13 +330,11 @@ namespace scene
|
||||
*/
|
||||
virtual void removeAll()
|
||||
{
|
||||
ISceneNodeList::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
{
|
||||
(*it)->Parent = 0;
|
||||
(*it)->drop();
|
||||
Children[i]->Parent = 0;
|
||||
Children[i]->drop();
|
||||
}
|
||||
|
||||
Children.clear();
|
||||
}
|
||||
|
||||
@ -598,14 +591,14 @@ namespace scene
|
||||
|
||||
//! Returns a const reference to the list of all children.
|
||||
/** \return The list of all children of this node. */
|
||||
const core::list<ISceneNode*>& getChildren() const
|
||||
const core::array<ISceneNode*>& getChildren() const
|
||||
{
|
||||
return Children;
|
||||
}
|
||||
|
||||
//! Returns a list of all children (non-const version).
|
||||
/** \return The list of all children of this node. */
|
||||
core::list<ISceneNode*>& getChildren()
|
||||
core::array<ISceneNode*>& getChildren()
|
||||
{
|
||||
return Children;
|
||||
}
|
||||
@ -794,10 +787,8 @@ namespace scene
|
||||
|
||||
// clone children
|
||||
|
||||
ISceneNodeList::Iterator it = toCopyFrom->Children.begin();
|
||||
for (; it != toCopyFrom->Children.end(); ++it)
|
||||
(*it)->clone(this, newManager);
|
||||
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
Children[i]->clone(this, newManager);
|
||||
// clone animators
|
||||
|
||||
ISceneNodeAnimatorList::Iterator ait = toCopyFrom->Animators.begin();
|
||||
@ -818,9 +809,9 @@ namespace scene
|
||||
{
|
||||
SceneManager = newManager;
|
||||
|
||||
ISceneNodeList::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
(*it)->setSceneManager(newManager);
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
Children[i]->setSceneManager(newManager);
|
||||
|
||||
}
|
||||
|
||||
//! Name of the scene node.
|
||||
@ -842,7 +833,7 @@ namespace scene
|
||||
ISceneNode* Parent;
|
||||
|
||||
//! List of all children of this node
|
||||
core::list<ISceneNode*> Children;
|
||||
core::array<ISceneNode*> Children;
|
||||
|
||||
//! List of all animator nodes
|
||||
core::list<ISceneNodeAnimator*> Animators;
|
||||
|
@ -77,9 +77,8 @@ void CBoneSceneNode::OnAnimate(u32 timeMs)
|
||||
//updateAbsolutePosition();
|
||||
|
||||
// perform the post render process on all children
|
||||
ISceneNodeList::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
(*it)->OnAnimate(timeMs);
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
Children[i]->OnAnimate(timeMs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,10 +87,9 @@ void CBoneSceneNode::helper_updateAbsolutePositionOfAllChildren(ISceneNode *Node
|
||||
{
|
||||
Node->updateAbsolutePosition();
|
||||
|
||||
ISceneNodeList::ConstIterator it = Node->getChildren().begin();
|
||||
for (; it != Node->getChildren().end(); ++it)
|
||||
for (unsigned i = 0; i < Node->getChildren().size(); ++i)
|
||||
{
|
||||
helper_updateAbsolutePositionOfAllChildren( (*it) );
|
||||
helper_updateAbsolutePositionOfAllChildren( Node->getChildren()[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,13 +74,11 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
|
||||
core::line3df& ray, s32 bits, bool noDebugObjects,
|
||||
f32& outbestdistance, ISceneNode*& outbestnode)
|
||||
{
|
||||
const ISceneNodeList& children = root->getChildren();
|
||||
const core::vector3df rayVector = ray.getVector().normalize();
|
||||
|
||||
ISceneNodeList::ConstIterator it = children.begin();
|
||||
for (; it != children.end(); ++it)
|
||||
for (unsigned i = 0; i != root->getChildren().size(); ++i)
|
||||
{
|
||||
ISceneNode* current = *it;
|
||||
ISceneNode* current = root->getChildren()[i];
|
||||
|
||||
if (current->isVisible())
|
||||
{
|
||||
@ -275,12 +273,9 @@ void CSceneCollisionManager::getPickedNodeFromBBAndSelector(
|
||||
core::vector3df & outBestCollisionPoint,
|
||||
core::triangle3df & outBestTriangle)
|
||||
{
|
||||
const ISceneNodeList& children = root->getChildren();
|
||||
|
||||
ISceneNodeList::ConstIterator it = children.begin();
|
||||
for (; it != children.end(); ++it)
|
||||
for (unsigned i = 0; i != root->getChildren().size(); ++i)
|
||||
{
|
||||
ISceneNode* current = *it;
|
||||
ISceneNode* current = root->getChildren()[i];
|
||||
ITriangleSelector * selector = current->getTriangleSelector();
|
||||
|
||||
if (selector && current->isVisible() &&
|
||||
|
@ -1668,11 +1668,9 @@ ISceneNode* CSceneManager::getSceneNodeFromName(const char* name, ISceneNode* st
|
||||
|
||||
ISceneNode* node = 0;
|
||||
|
||||
const ISceneNodeList& list = start->getChildren();
|
||||
ISceneNodeList::ConstIterator it = list.begin();
|
||||
for (; it!=list.end(); ++it)
|
||||
for (unsigned i = 0; i < start->getChildren().size(); ++i)
|
||||
{
|
||||
node = getSceneNodeFromName(name, *it);
|
||||
node = getSceneNodeFromName(name, start->getChildren()[i]);
|
||||
if (node)
|
||||
return node;
|
||||
}
|
||||
@ -1692,11 +1690,9 @@ ISceneNode* CSceneManager::getSceneNodeFromId(s32 id, ISceneNode* start)
|
||||
|
||||
ISceneNode* node = 0;
|
||||
|
||||
const ISceneNodeList& list = start->getChildren();
|
||||
ISceneNodeList::ConstIterator it = list.begin();
|
||||
for (; it!=list.end(); ++it)
|
||||
for (unsigned i = 0; i < start->getChildren().size(); ++i)
|
||||
{
|
||||
node = getSceneNodeFromId(id, *it);
|
||||
node = getSceneNodeFromId(id, start->getChildren()[i]);
|
||||
if (node)
|
||||
return node;
|
||||
}
|
||||
@ -1716,11 +1712,9 @@ ISceneNode* CSceneManager::getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, IS
|
||||
|
||||
ISceneNode* node = 0;
|
||||
|
||||
const ISceneNodeList& list = start->getChildren();
|
||||
ISceneNodeList::ConstIterator it = list.begin();
|
||||
for (; it!=list.end(); ++it)
|
||||
for (unsigned i = 0; i < start->getChildren().size(); ++i)
|
||||
{
|
||||
node = getSceneNodeFromType(type, *it);
|
||||
node = getSceneNodeFromType(type, start->getChildren()[i]);
|
||||
if (node)
|
||||
return node;
|
||||
}
|
||||
@ -1738,12 +1732,9 @@ void CSceneManager::getSceneNodesFromType(ESCENE_NODE_TYPE type, core::array<sce
|
||||
if (start->getType() == type || ESNT_ANY == type)
|
||||
outNodes.push_back(start);
|
||||
|
||||
const ISceneNodeList& list = start->getChildren();
|
||||
ISceneNodeList::ConstIterator it = list.begin();
|
||||
|
||||
for (; it!=list.end(); ++it)
|
||||
for (unsigned i = 0; i < start->getChildren().size(); ++i)
|
||||
{
|
||||
getSceneNodesFromType(type, outNodes, *it);
|
||||
getSceneNodesFromType(type, outNodes, start->getChildren()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2101,9 +2092,8 @@ void CSceneManager::writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISc
|
||||
}
|
||||
else
|
||||
{
|
||||
ISceneNodeList::ConstIterator it = node->getChildren().begin();
|
||||
for (; it != node->getChildren().end(); ++it)
|
||||
writeSceneNode(writer, (*it), userDataSerializer, currentPath);
|
||||
for (unsigned i = 0; i < node->getChildren().size(); ++i)
|
||||
writeSceneNode(writer, node->getChildren()[i], userDataSerializer, currentPath);
|
||||
}
|
||||
|
||||
attr->drop();
|
||||
|
@ -136,49 +136,48 @@ void DrawCalls::renderBoundingBoxes()
|
||||
} // renderBoundingBoxes
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void DrawCalls::parseSceneManager(core::list<scene::ISceneNode*> &List,
|
||||
void DrawCalls::parseSceneManager(core::array<scene::ISceneNode*> &List,
|
||||
const scene::ICameraSceneNode *cam)
|
||||
{
|
||||
core::list<scene::ISceneNode*>::Iterator I = List.begin(), E = List.end();
|
||||
for (; I != E; ++I)
|
||||
for (unsigned i = 0; i < List.size(); ++i)
|
||||
{
|
||||
if (LODNode *node = dynamic_cast<LODNode *>(*I))
|
||||
if (LODNode *node = dynamic_cast<LODNode *>(List[i]))
|
||||
{
|
||||
node->updateVisibility();
|
||||
}
|
||||
(*I)->updateAbsolutePosition();
|
||||
if (!(*I)->isVisible())
|
||||
List[i]->updateAbsolutePosition();
|
||||
if (!List[i]->isVisible())
|
||||
continue;
|
||||
|
||||
if (STKParticle *node = dynamic_cast<STKParticle*>(*I))
|
||||
if (STKParticle *node = dynamic_cast<STKParticle*>(List[i]))
|
||||
{
|
||||
if (!isCulledPrecise(cam, *I, irr_driver->getBoundingBoxesViz()))
|
||||
if (!isCulledPrecise(cam, List[i], irr_driver->getBoundingBoxesViz()))
|
||||
CPUParticleManager::getInstance()->addParticleNode(node);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (scene::IBillboardSceneNode *node =
|
||||
dynamic_cast<scene::IBillboardSceneNode*>(*I))
|
||||
dynamic_cast<scene::IBillboardSceneNode*>(List[i]))
|
||||
{
|
||||
if (!isCulledPrecise(cam, *I))
|
||||
if (!isCulledPrecise(cam, List[i]))
|
||||
CPUParticleManager::getInstance()->addBillboardNode(node);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (STKTextBillboard *tb =
|
||||
dynamic_cast<STKTextBillboard*>(*I))
|
||||
dynamic_cast<STKTextBillboard*>(List[i]))
|
||||
{
|
||||
if (!isCulledPrecise(cam, *I, irr_driver->getBoundingBoxesViz()))
|
||||
if (!isCulledPrecise(cam, List[i], irr_driver->getBoundingBoxesViz()))
|
||||
TextBillboardDrawer::addTextBillboard(tb);
|
||||
continue;
|
||||
}
|
||||
|
||||
SP::SPMeshNode* node = dynamic_cast<SP::SPMeshNode*>(*I);
|
||||
SP::SPMeshNode* node = dynamic_cast<SP::SPMeshNode*>(List[i]);
|
||||
if (node)
|
||||
{
|
||||
SP::addObject(node);
|
||||
}
|
||||
parseSceneManager((*I)->getChildren(), cam);
|
||||
parseSceneManager(List[i]->getChildren(), cam);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
GLsync m_sync;
|
||||
std::vector<float> m_bounding_boxes;
|
||||
|
||||
void parseSceneManager(core::list<scene::ISceneNode*> &List,
|
||||
void parseSceneManager(core::array<scene::ISceneNode*> &List,
|
||||
const scene::ICameraSceneNode *cam);
|
||||
|
||||
bool isCulledPrecise(const scene::ICameraSceneNode *cam,
|
||||
|
@ -129,15 +129,14 @@ void LODNode::OnAnimate(u32 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++)
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
{
|
||||
if (m_nodes_set.find(*it) == m_nodes_set.end())
|
||||
if (m_nodes_set.find(Children[i]) == m_nodes_set.end())
|
||||
{
|
||||
assert(*it != NULL);
|
||||
if ((*it)->isVisible())
|
||||
assert(Children[i] != NULL);
|
||||
if (Children[i]->isVisible())
|
||||
{
|
||||
(*it)->OnAnimate(timeMs);
|
||||
Children[i]->OnAnimate(timeMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,11 +177,8 @@ void LODNode::OnRegisterSceneNode()
|
||||
#ifndef SERVER_ONLY
|
||||
if (!CVS->isGLSL())
|
||||
{
|
||||
for (core::list<ISceneNode*>::Iterator it = Children.begin();
|
||||
it != Children.end(); it++)
|
||||
{
|
||||
(*it)->updateAbsolutePosition();
|
||||
}
|
||||
for (unsigned i = 0; i < Children.size(); ++i)
|
||||
Children[i]->updateAbsolutePosition();
|
||||
}
|
||||
#endif
|
||||
scene::ISceneNode::OnRegisterSceneNode();
|
||||
|
@ -453,14 +453,13 @@ void STKTextBillboard::reload()
|
||||
} // reload
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
static void updateTextBillboard(core::list<scene::ISceneNode*>& List)
|
||||
static void updateTextBillboard(core::array<scene::ISceneNode*>& List)
|
||||
{
|
||||
core::list<scene::ISceneNode*>::Iterator I = List.begin(), E = List.end();
|
||||
for (; I != E; ++I)
|
||||
for (unsigned i = 0; i < List.size(); i++)
|
||||
{
|
||||
if (STKTextBillboard* tb = dynamic_cast<STKTextBillboard*>(*I))
|
||||
if (STKTextBillboard* tb = dynamic_cast<STKTextBillboard*>(List[i]))
|
||||
tb->reload();
|
||||
updateTextBillboard((*I)->getChildren());
|
||||
updateTextBillboard(List[i]->getChildren());
|
||||
}
|
||||
} // updateTextBillboard
|
||||
|
||||
|
@ -124,11 +124,9 @@ void ThreeStrikesBattle::reset(bool restart)
|
||||
|
||||
scene::ISceneNode* kart_node = m_karts[n]->getNode();
|
||||
|
||||
core::list<scene::ISceneNode*>& children = kart_node->getChildren();
|
||||
for (core::list<scene::ISceneNode*>::Iterator it = children.begin();
|
||||
it != children.end(); it++)
|
||||
for (unsigned i = 0; i < kart_node->getChildren().size(); i++)
|
||||
{
|
||||
scene::ISceneNode* curr = *it;
|
||||
scene::ISceneNode* curr = kart_node->getChildren()[i];
|
||||
|
||||
if (core::stringc(curr->getName()) == "tire1")
|
||||
{
|
||||
@ -302,11 +300,9 @@ bool ThreeStrikesBattle::kartHit(int kart_id, int hitter)
|
||||
}
|
||||
|
||||
scene::ISceneNode* kart_node = m_karts[kart_id]->getNode();
|
||||
core::list<scene::ISceneNode*>& children = kart_node->getChildren();
|
||||
for (core::list<scene::ISceneNode*>::Iterator it = children.begin();
|
||||
it != children.end(); it++)
|
||||
for (unsigned i = 0; i < kart_node->getChildren().size(); i++)
|
||||
{
|
||||
scene::ISceneNode* curr = *it;
|
||||
scene::ISceneNode* curr = kart_node->getChildren()[i];
|
||||
|
||||
if (core::stringc(curr->getName()) == "tire1")
|
||||
{
|
||||
@ -590,11 +586,9 @@ void ThreeStrikesBattle::addKartLife(unsigned int id)
|
||||
updateKartRanks();
|
||||
|
||||
scene::ISceneNode* kart_node = m_karts[id]->getNode();
|
||||
core::list<scene::ISceneNode*>& children = kart_node->getChildren();
|
||||
for (core::list<scene::ISceneNode*>::Iterator it = children.begin();
|
||||
it != children.end(); it++)
|
||||
for (unsigned i = 0; i < kart_node->getChildren().size(); i++)
|
||||
{
|
||||
scene::ISceneNode* curr = *it;
|
||||
scene::ISceneNode* curr = kart_node->getChildren()[i];
|
||||
if (core::stringc(curr->getName()) == "tire1")
|
||||
{
|
||||
curr->setVisible(m_kart_info[id].m_lives >= 3);
|
||||
|
@ -1747,11 +1747,8 @@ static void recursiveUpdatePosition(scene::ISceneNode *node)
|
||||
{
|
||||
node->updateAbsolutePosition();
|
||||
|
||||
scene::ISceneNodeList::ConstIterator it = node->getChildren().begin();
|
||||
for (; it != node->getChildren().end(); ++it)
|
||||
{
|
||||
recursiveUpdatePosition(*it);
|
||||
}
|
||||
for (unsigned i = 0; i < node->getChildren().size(); i++)
|
||||
recursiveUpdatePosition(node->getChildren()[i]);
|
||||
} // recursiveUpdatePosition
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user