Browse Source

Convert plPageTree::fNodes to std::vector

Adam Johnson 11 years ago
parent
commit
88ce09698e
  1. 41
      Sources/Plasma/PubUtilLib/plScene/plPageTreeMgr.cpp
  2. 7
      Sources/Plasma/PubUtilLib/plScene/plPageTreeMgr.h

41
Sources/Plasma/PubUtilLib/plScene/plPageTreeMgr.cpp

@ -85,21 +85,21 @@ void plPageTreeMgr::AddNode(plSceneNode* node)
node->Init();
fNodes.Append(node);
fNodes.push_back(node);
}
void plPageTreeMgr::RemoveNode(plSceneNode* node)
{
ITrashSpaceTree();
int idx = fNodes.Find(node);
if( idx != fNodes.kMissingIndex )
fNodes.Remove(idx);
auto it = std::find(fNodes.begin(), fNodes.end(), node);
if (it != fNodes.end())
fNodes.erase(it);
}
void plPageTreeMgr::Reset()
{
fNodes.Reset();
fNodes.clear();
ITrashSpaceTree();
}
@ -474,16 +474,13 @@ bool plPageTreeMgr::IRenderSortingSpans(plPipeline* pipe, hsTArray<plDrawVisList
bool plPageTreeMgr::IBuildSpaceTree()
{
if( !fNodes.GetCount() )
if (fNodes.empty())
return false;
plSpaceTreeMaker maker;
maker.Reset();
int i;
for( i = 0; i < fNodes.GetCount(); i++ )
{
maker.AddLeaf(fNodes[i]->GetSpaceTree()->GetWorldBounds(), fNodes[i]->GetSpaceTree()->IsEmpty());
}
for (plSceneNode* node : fNodes)
maker.AddLeaf(node->GetSpaceTree()->GetWorldBounds(), node->GetSpaceTree()->IsEmpty());
fSpaceTree = maker.MakeTree();
return true;
@ -491,18 +488,17 @@ bool plPageTreeMgr::IBuildSpaceTree()
bool plPageTreeMgr::IRefreshTree(plPipeline* pipe)
{
int i;
for( i = 0; i < fNodes.GetCount(); i++ )
for (size_t i = 0; i < fNodes.size(); ++i)
{
if( fNodes[i]->GetSpaceTree()->IsDirty() )
plSceneNode* node = fNodes[i];
if (node->GetSpaceTree()->IsDirty())
{
fNodes[i]->GetSpaceTree()->Refresh();
GetSpaceTree()->MoveLeaf(i, fNodes[i]->GetSpaceTree()->GetWorldBounds());
node->GetSpaceTree()->Refresh();
if( !fNodes[i]->GetSpaceTree()->IsEmpty() && fSpaceTree->HasLeafFlag(i, plSpaceTreeNode::kDisabled) )
GetSpaceTree()->MoveLeaf(i, node->GetSpaceTree()->GetWorldBounds());
if (!node->GetSpaceTree()->IsEmpty() && fSpaceTree->HasLeafFlag(i, plSpaceTreeNode::kDisabled) )
fSpaceTree->SetLeafFlag(i, plSpaceTreeNode::kDisabled, false);
}
}
@ -679,11 +675,8 @@ bool plPageTreeMgr::IGetOcclusion(plPipeline* pipe, hsTArray<int16_t>& list)
fCullPolys.SetCount(0);
fOccluders.SetCount(0);
int i;
for( i = 0; i < fNodes.GetCount(); i++ )
{
fNodes[i]->SubmitOccluders(this);
}
for (plSceneNode* node : fNodes)
node->SubmitOccluders(this);
if( !IGetCullPolys(pipe) )
{

7
Sources/Plasma/PubUtilLib/plScene/plPageTreeMgr.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plPageTreeMgr_inc
#include "hsTemplates.h"
#include <vector>
class plSceneNode;
class plSpaceTree;
@ -79,7 +80,7 @@ public:
class plPageTreeMgr
{
protected:
hsTArray<plSceneNode*> fNodes;
std::vector<plSceneNode*> fNodes;
plSpaceTree* fSpaceTree;
plVisMgr* fVisMgr;
@ -108,12 +109,12 @@ public:
plPageTreeMgr();
virtual ~plPageTreeMgr();
const hsTArray<plSceneNode*>& GetNodes() const { return fNodes; }
const std::vector<plSceneNode*>& GetNodes() const { return fNodes; }
void AddNode(plSceneNode* node);
void RemoveNode(plSceneNode* node);
virtual void Reset(); // remove all nodes, nuke the space tree
virtual bool Empty() const { return !fNodes.GetCount(); }
virtual bool Empty() const { return fNodes.empty(); }
virtual int Render(plPipeline* pipe);

Loading…
Cancel
Save