apparently calling FindOrInsertWorldspawn during tree traversing is bad, so let's not do that

This commit is contained in:
Rudolf Polzer 2010-11-01 07:43:42 +01:00
parent 4adf8ad52b
commit 288318d040
3 changed files with 12 additions and 8 deletions

View File

@ -184,11 +184,11 @@ public:
class EntityGroupSelected : public scene::Graph::Walker class EntityGroupSelected : public scene::Graph::Walker
{ {
NodeSmartReference group; NodeSmartReference group, worldspawn;
//typedef std::pair<NodeSmartReference, NodeSmartReference> DeletionPair; //typedef std::pair<NodeSmartReference, NodeSmartReference> DeletionPair;
//Stack<DeletionPair> deleteme; //Stack<DeletionPair> deleteme;
public: public:
EntityGroupSelected(const scene::Path &p): group(p.top().get()) EntityGroupSelected(const scene::Path &p): group(p.top().get()), worldspawn(Map_FindOrInsertWorldspawn(g_map))
{ {
} }
bool pre(const scene::Path& path, scene::Instance& instance) const bool pre(const scene::Path& path, scene::Instance& instance) const
@ -206,7 +206,7 @@ class EntityGroupSelected : public scene::Graph::Walker
NodeSmartReference child(path.top().get()); NodeSmartReference child(path.top().get());
NodeSmartReference parent(path.parent().get()); NodeSmartReference parent(path.parent().get());
if(path.size() >= 3 && parent != Map_FindOrInsertWorldspawn(g_map)) if(path.size() >= 3 && parent != worldspawn)
{ {
NodeSmartReference parentparent(path[path.size() - 3].get()); NodeSmartReference parentparent(path[path.size() - 3].get());

View File

@ -1189,8 +1189,11 @@ void SelectFaceMode()
class CloneSelected : public scene::Graph::Walker class CloneSelected : public scene::Graph::Walker
{ {
bool doMakeUnique; bool doMakeUnique;
NodeSmartReference worldspawn;
public: public:
CloneSelected(bool d): doMakeUnique(d) { } CloneSelected(bool d): doMakeUnique(d), worldspawn(Map_FindOrInsertWorldspawn(g_map))
{
}
bool pre(const scene::Path& path, scene::Instance& instance) const bool pre(const scene::Path& path, scene::Instance& instance) const
{ {
if(path.size() == 1) if(path.size() == 1)
@ -1198,7 +1201,7 @@ public:
// ignore worldspawn, but keep checking children // ignore worldspawn, but keep checking children
NodeSmartReference me(path.top().get()); NodeSmartReference me(path.top().get());
if(me == Map_FindOrInsertWorldspawn(g_map)) if(me == worldspawn)
return true; return true;
if(!path.top().get().isRoot()) if(!path.top().get().isRoot())
@ -1220,7 +1223,7 @@ public:
// ignore worldspawn, but keep checking children // ignore worldspawn, but keep checking children
NodeSmartReference me(path.top().get()); NodeSmartReference me(path.top().get());
if(me == Map_FindOrInsertWorldspawn(g_map)) if(me == worldspawn)
return; return;
if(!path.top().get().isRoot()) if(!path.top().get().isRoot())

View File

@ -340,8 +340,9 @@ void Select_Invert()
class ExpandSelectionToEntitiesWalker : public scene::Graph::Walker class ExpandSelectionToEntitiesWalker : public scene::Graph::Walker
{ {
mutable std::size_t m_depth; mutable std::size_t m_depth;
NodeSmartReference worldspawn;
public: public:
ExpandSelectionToEntitiesWalker() : m_depth(0) ExpandSelectionToEntitiesWalker() : m_depth(0), worldspawn(Map_FindOrInsertWorldspawn(g_map))
{ {
} }
bool pre(const scene::Path& path, scene::Instance& instance) const bool pre(const scene::Path& path, scene::Instance& instance) const
@ -350,7 +351,7 @@ public:
// ignore worldspawn // ignore worldspawn
NodeSmartReference me(path.top().get()); NodeSmartReference me(path.top().get());
if(me == Map_FindOrInsertWorldspawn(g_map)) if(me == worldspawn)
return false; return false;
if(m_depth == 2) // entity depth if(m_depth == 2) // entity depth