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(); node->Init();
fNodes.Append(node); fNodes.push_back(node);
} }
void plPageTreeMgr::RemoveNode(plSceneNode* node) void plPageTreeMgr::RemoveNode(plSceneNode* node)
{ {
ITrashSpaceTree(); ITrashSpaceTree();
int idx = fNodes.Find(node); auto it = std::find(fNodes.begin(), fNodes.end(), node);
if( idx != fNodes.kMissingIndex ) if (it != fNodes.end())
fNodes.Remove(idx); fNodes.erase(it);
} }
void plPageTreeMgr::Reset() void plPageTreeMgr::Reset()
{ {
fNodes.Reset(); fNodes.clear();
ITrashSpaceTree(); ITrashSpaceTree();
} }
@ -474,16 +474,13 @@ bool plPageTreeMgr::IRenderSortingSpans(plPipeline* pipe, hsTArray<plDrawVisList
bool plPageTreeMgr::IBuildSpaceTree() bool plPageTreeMgr::IBuildSpaceTree()
{ {
if( !fNodes.GetCount() ) if (fNodes.empty())
return false; return false;
plSpaceTreeMaker maker; plSpaceTreeMaker maker;
maker.Reset(); maker.Reset();
int i; for (plSceneNode* node : fNodes)
for( i = 0; i < fNodes.GetCount(); i++ ) maker.AddLeaf(node->GetSpaceTree()->GetWorldBounds(), node->GetSpaceTree()->IsEmpty());
{
maker.AddLeaf(fNodes[i]->GetSpaceTree()->GetWorldBounds(), fNodes[i]->GetSpaceTree()->IsEmpty());
}
fSpaceTree = maker.MakeTree(); fSpaceTree = maker.MakeTree();
return true; return true;
@ -491,18 +488,17 @@ bool plPageTreeMgr::IBuildSpaceTree()
bool plPageTreeMgr::IRefreshTree(plPipeline* pipe) bool plPageTreeMgr::IRefreshTree(plPipeline* pipe)
{ {
int i; for (size_t i = 0; i < fNodes.size(); ++i)
for( i = 0; i < fNodes.GetCount(); i++ )
{ {
if( fNodes[i]->GetSpaceTree()->IsDirty() ) plSceneNode* node = fNodes[i];
if (node->GetSpaceTree()->IsDirty())
{ {
fNodes[i]->GetSpaceTree()->Refresh(); node->GetSpaceTree()->Refresh();
GetSpaceTree()->MoveLeaf(i, fNodes[i]->GetSpaceTree()->GetWorldBounds());
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); fSpaceTree->SetLeafFlag(i, plSpaceTreeNode::kDisabled, false);
} }
} }
@ -679,11 +675,8 @@ bool plPageTreeMgr::IGetOcclusion(plPipeline* pipe, hsTArray<int16_t>& list)
fCullPolys.SetCount(0); fCullPolys.SetCount(0);
fOccluders.SetCount(0); fOccluders.SetCount(0);
int i; for (plSceneNode* node : fNodes)
for( i = 0; i < fNodes.GetCount(); i++ ) node->SubmitOccluders(this);
{
fNodes[i]->SubmitOccluders(this);
}
if( !IGetCullPolys(pipe) ) 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 #define plPageTreeMgr_inc
#include "hsTemplates.h" #include "hsTemplates.h"
#include <vector>
class plSceneNode; class plSceneNode;
class plSpaceTree; class plSpaceTree;
@ -79,7 +80,7 @@ public:
class plPageTreeMgr class plPageTreeMgr
{ {
protected: protected:
hsTArray<plSceneNode*> fNodes; std::vector<plSceneNode*> fNodes;
plSpaceTree* fSpaceTree; plSpaceTree* fSpaceTree;
plVisMgr* fVisMgr; plVisMgr* fVisMgr;
@ -108,12 +109,12 @@ public:
plPageTreeMgr(); plPageTreeMgr();
virtual ~plPageTreeMgr(); virtual ~plPageTreeMgr();
const hsTArray<plSceneNode*>& GetNodes() const { return fNodes; } const std::vector<plSceneNode*>& GetNodes() const { return fNodes; }
void AddNode(plSceneNode* node); void AddNode(plSceneNode* node);
void RemoveNode(plSceneNode* node); void RemoveNode(plSceneNode* node);
virtual void Reset(); // remove all nodes, nuke the space tree 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); virtual int Render(plPipeline* pipe);

Loading…
Cancel
Save