diff options
author | Richard Linden <none@none> | 2012-01-17 12:05:23 -0800 |
---|---|---|
committer | Richard Linden <none@none> | 2012-01-17 12:05:23 -0800 |
commit | 37593f276cacb9db7f1f8ed8ff6c1fe1b56ff883 (patch) | |
tree | 2ec32a4cf984cde8a003f45b324de328f318c675 /indra/llmath/lloctree.h | |
parent | 944814941d16e7853ff365acc17a16b3a20ac9cb (diff) | |
parent | facb0fa42cf7dbc4deb3a4026cc216aa0099111e (diff) |
Automated merge with ssh://hg.lindenlab.com/richard/viewer-experience/
Diffstat (limited to 'indra/llmath/lloctree.h')
-rw-r--r-- | indra/llmath/lloctree.h | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 3c1ae45d68..1b11e83b4a 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -80,8 +80,8 @@ public: typedef LLOctreeTraveler<T> oct_traveler; typedef LLTreeTraveler<T> tree_traveler; typedef typename std::set<LLPointer<T> > element_list; - typedef typename std::set<LLPointer<T> >::iterator element_iter; - typedef typename std::set<LLPointer<T> >::const_iterator const_element_iter; + typedef typename element_list::iterator element_iter; + typedef typename element_list::const_iterator const_element_iter; typedef typename std::vector<LLTreeListener<T>*>::iterator tree_listener_iter; typedef typename std::vector<LLOctreeNode<T>* > child_list; typedef LLTreeNode<T> BaseType; @@ -114,6 +114,8 @@ public: mOctant = ((oct_node*) mParent)->getOctant(mCenter); } + mElementCount = 0; + clearChildren(); } @@ -219,11 +221,11 @@ public: void accept(oct_traveler* visitor) { visitor->visit(this); } virtual bool isLeaf() const { return mChild.empty(); } - U32 getElementCount() const { return mData.size(); } + U32 getElementCount() const { return mElementCount; } element_list& getData() { return mData; } const element_list& getData() const { return mData; } - U32 getChildCount() const { return mChild.size(); } + U32 getChildCount() const { return mChildCount; } oct_node* getChild(U32 index) { return mChild[index]; } const oct_node* getChild(U32 index) const { return mChild[index]; } child_list& getChildren() { return mChild; } @@ -300,17 +302,13 @@ public: if ((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius()) || (data->getBinRadius() > getSize()[0] && parent && parent->getElementCount() >= gOctreeMaxCapacity))) { //it belongs here -#if LL_OCTREE_PARANOIA_CHECK //if this is a redundant insertion, error out (should never happen) - if (mData.find(data) != mData.end()) - { - llwarns << "Redundant octree insertion detected. " << data << llendl; - return false; - } -#endif + llassert(mData.find(data) == mData.end()); mData.insert(data); BaseType::insert(data); + + mElementCount = mData.size(); return true; } else @@ -346,6 +344,8 @@ public: { mData.insert(data); BaseType::insert(data); + + mElementCount = mData.size(); return true; } @@ -399,6 +399,7 @@ public: if (mData.find(data) != mData.end()) { //we have data mData.erase(data); + mElementCount = mData.size(); notifyRemoval(data); checkAlive(); return true; @@ -436,6 +437,7 @@ public: if (mData.find(data) != mData.end()) { mData.erase(data); + mElementCount = mData.size(); notifyRemoval(data); llwarns << "FOUND!" << llendl; checkAlive(); @@ -452,7 +454,7 @@ public: void clearChildren() { mChild.clear(); - + mChildCount = 0; U32* foo = (U32*) mChildMap; foo[0] = foo[1] = 0xFFFFFFFF; } @@ -512,9 +514,10 @@ public: } #endif - mChildMap[child->getOctant()] = (U8) mChild.size(); + mChildMap[child->getOctant()] = mChildCount; mChild.push_back(child); + ++mChildCount; child->setParent(this); if (!silent) @@ -534,21 +537,20 @@ public: oct_listener* listener = getOctListener(i); listener->handleChildRemoval(this, getChild(index)); } - - if (destroy) { mChild[index]->destroy(); delete mChild[index]; } mChild.erase(mChild.begin() + index); + --mChildCount; //rebuild child map U32* foo = (U32*) mChildMap; foo[0] = foo[1] = 0xFFFFFFFF; - for (U32 i = 0; i < mChild.size(); ++i) + for (U32 i = 0; i < mChildCount; ++i) { mChildMap[mChild[i]->getOctant()] = i; } @@ -601,8 +603,10 @@ protected: child_list mChild; U8 mChildMap[8]; + U32 mChildCount; element_list mData; + U32 mElementCount; }; |