Scott Lawrence avatar Scott Lawrence committed 18498af Merge

merge changes for DRTVWR-236

Comments (0)

Files changed (4)

 28e100d0379a2b0710c57647a28fc5239d3d7b99 3.3.4-release
 005dfe5c4c377207d065fb27858d2eb0b53b143a DRTVWR-167
 888768f162d2c0a8de1dcc5fb9a08bd8bd120a6b DRTVWR-175
-4ad8a3afe40e0200309e3ada68932c4295ac2795 DRTVWR-179
 a8b3eca451a9eaab59987efb0ab1c4217e3f2dcc DRTVWR-182
 1f27cdfdc54246484f8afbbe42ce48e954175cbd 3.4.0-beta1
 9ee9387789701d597130f879d9011a4958753862 DRTVWR-189
 dd23d4da3bcb2ffda58569e759feb7c119982973 DRTVWR-224
 0bd3744ff060452aa13ff4992eafb381df7b1012 3.4.1-beta5
 29075f8c1abed53dcf195a59f61744e27a91108f DRTVWR-226
+fba99f381b8d4ad1b7b42fa4993b29998d95be18 DRTVWR-179
 49ed253c80bed7410e238eeab35a9f14cb034364 3.4.1-beta6
 468ca3268229011a59df99229b24315844b33d34 DRTVWR-227
 524da902713e8b60322640b9825101add4a7c497 3.4.1-beta7
 637fe8bbee5e24940448198c221d5ee0fa3247b4 3.4.1-beta9
 4e0d84e92132e9e95a1d52a1e49bad69c278ea05 3.4.1-beta10
 f7cbd60a3f57ff1101157eeb79ea21e8898bedae DRTVWR-235
+baf97f06ae17223614c5e31aa42e71d87cff07fe DRTVWR-236

indra/llmath/lloctree.h

 
 	typedef LLOctreeTraveler<T>									oct_traveler;
 	typedef LLTreeTraveler<T>									tree_traveler;
-	typedef LLPointer<T>*										element_list;
+	typedef std::vector<LLPointer<T> >							element_list;
 	typedef LLPointer<T>*										element_iter;
 	typedef const LLPointer<T>*									const_element_iter;
 	typedef typename std::vector<LLTreeListener<T>*>::iterator	tree_listener_iter;
 	:	mParent((oct_node*)parent), 
 		mOctant(octant) 
 	{ 
-		mData = NULL;
-		mDataEnd = NULL;
+		//always keep a NULL terminated list to avoid out of bounds exceptions in debug builds
+		mData.push_back(NULL);
+		mDataEnd = &mData[0];
 
 		mCenter = center;
 		mSize = size;
 			mData[i] = NULL;
 		}
 
-		free(mData);
-		mData = NULL;
-		mDataEnd = NULL;
+		mData.clear();
+		mData.push_back(NULL);
+		mDataEnd = &mData[0];
 
 		for (U32 i = 0; i < getChildCount(); i++)
 		{
 	bool isEmpty() const							{ return mElementCount == 0; }
 	element_list& getData()							{ return mData; }
 	const element_list& getData() const				{ return mData; }
-	element_iter getDataBegin()						{ return mData; }
+	element_iter getDataBegin()						{ return &mData[0]; }
 	element_iter getDataEnd()						{ return mDataEnd; }
-	const_element_iter getDataBegin() const			{ return mData; }
+	const_element_iter getDataBegin() const			{ return &mData[0]; }
 	const_element_iter getDataEnd() const			{ return mDataEnd; }
 		
 	U32 getChildCount()	const						{ return mChildCount; }
 			if ((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius()) ||
 				(data->getBinRadius() > getSize()[0] &&	parent && parent->getElementCount() >= gOctreeMaxCapacity))) 
 			{ //it belongs here
+				mData.push_back(NULL);
+				mData[mElementCount] = data;
 				mElementCount++;
-				mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
-
-				//avoid unref on uninitialized memory
-				memset(mData+mElementCount-1, 0, sizeof(LLPointer<T>));
-
-				mData[mElementCount-1] = data;
-				mDataEnd = mData + mElementCount;
+				mDataEnd = &mData[mElementCount];
 				data->setBinIndex(mElementCount-1);
 				BaseType::insert(data);
 				return true;
 
 				if( lt == 0x7 )
 				{
+					mData.push_back(NULL);
+					mData[mElementCount] = data;
 					mElementCount++;
-					mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
-
-					//avoid unref on uninitialized memory
-					memset(mData+mElementCount-1, 0, sizeof(LLPointer<T>));
-
-					mData[mElementCount-1] = data;
-					mDataEnd = mData + mElementCount;
+					mDataEnd = &mData[mElementCount];
 					data->setBinIndex(mElementCount-1);
 					BaseType::insert(data);
 					return true;
 				mData[i]->setBinIndex(i);
 			}
 
-			mData[mElementCount] = NULL; //needed for unref
-			mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
-			mDataEnd = mData+mElementCount;
+			mData[mElementCount] = NULL;
+			mData.pop_back();
+			mDataEnd = &mData[mElementCount];
 		}
 		else
 		{
-			mData[0] = NULL; //needed for unref
-			free(mData);
-			mData = NULL;
-			mDataEnd = NULL;
+			mData.clear();
+			mData.push_back(NULL);
+			mDataEnd = &mData[0];
 		}
 
 		notifyRemoval(data);
 		}
 
 		//node is now root
-		llwarns << "!!! OCTREE REMOVING FACE BY ADDRESS, SEVERE PERFORMANCE PENALTY |||" << llendl;
+		llwarns << "!!! OCTREE REMOVING ELEMENT BY ADDRESS, SEVERE PERFORMANCE PENALTY |||" << llendl;
 		node->removeByAddress(data);
 		llassert(data->getBinIndex() == -1);
 		return true;

indra/newview/llspatialpartition.cpp

 	mVisibleListAllocated = 0;
 	mVisibleBridgeAllocated = 0;
 
-	mVisibleGroups = NULL;
-	mVisibleGroupsEnd = NULL;
-	mAlphaGroups = NULL;
-	mAlphaGroupsEnd = NULL;
-	mOcclusionGroups = NULL;
-	mOcclusionGroupsEnd = NULL;
-	mDrawableGroups = NULL;
-	mDrawableGroupsEnd = NULL;
-	mVisibleList = NULL;
-	mVisibleListEnd = NULL;
-	mVisibleBridge = NULL;
-	mVisibleBridgeEnd = NULL;
+	mVisibleGroups.clear();
+	mVisibleGroups.push_back(NULL);
+	mVisibleGroupsEnd = &mVisibleGroups[0];
+	mAlphaGroups.clear();
+	mAlphaGroups.push_back(NULL);
+	mAlphaGroupsEnd = &mAlphaGroups[0];
+	mOcclusionGroups.clear();
+	mOcclusionGroups.push_back(NULL);
+	mOcclusionGroupsEnd = &mOcclusionGroups[0];
+	mDrawableGroups.clear();
+	mDrawableGroups.push_back(NULL);
+	mDrawableGroupsEnd = &mDrawableGroups[0];
+	mVisibleList.clear();
+	mVisibleList.push_back(NULL);
+	mVisibleListEnd = &mVisibleList[0];
+	mVisibleBridge.clear();
+	mVisibleBridge.push_back(NULL);
+	mVisibleBridgeEnd = &mVisibleBridge[0];
 
 	for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
 	{
-		mRenderMap[i] = NULL;
-		mRenderMapEnd[i] = NULL;
+		mRenderMap[i].clear();
+		mRenderMap[i].push_back(NULL);
+		mRenderMapEnd[i] = &mRenderMap[i][0];
 		mRenderMapAllocated[i] = 0;
 	}
 
 	clear();
 }
 
-void LLCullResult::pushBack(void**& head, U32& count, void* val)
+template <class T, class V> 
+void LLCullResult::pushBack(T& head, U32& count, V* val)
 {
+	head[count] = val;
+	head.push_back(NULL);
 	count++;
-	head = (void**) realloc((void*) head, sizeof(void*) * count);
-	head[count-1] = val;
 }
 
 void LLCullResult::clear()
 {
 	mVisibleGroupsSize = 0;
-	mVisibleGroupsEnd = mVisibleGroups;
+	mVisibleGroupsEnd = &mVisibleGroups[0];
 
 	mAlphaGroupsSize = 0;
-	mAlphaGroupsEnd = mAlphaGroups;
+	mAlphaGroupsEnd = &mAlphaGroups[0];
 
 	mOcclusionGroupsSize = 0;
-	mOcclusionGroupsEnd = mOcclusionGroups;
+	mOcclusionGroupsEnd = &mOcclusionGroups[0];
 
 	mDrawableGroupsSize = 0;
-	mDrawableGroupsEnd = mDrawableGroups;
+	mDrawableGroupsEnd = &mDrawableGroups[0];
 
 	mVisibleListSize = 0;
-	mVisibleListEnd = mVisibleList;
+	mVisibleListEnd = &mVisibleList[0];
 
 	mVisibleBridgeSize = 0;
-	mVisibleBridgeEnd = mVisibleBridge;
+	mVisibleBridgeEnd = &mVisibleBridge[0];
 
 
 	for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
 			mRenderMap[i][j] = 0;
 		}
 		mRenderMapSize[i] = 0;
-		mRenderMapEnd[i] = mRenderMap[i];
+		mRenderMapEnd[i] = &(mRenderMap[i][0]);
 	}
 }
 
 LLCullResult::sg_iterator LLCullResult::beginVisibleGroups()
 {
-	return mVisibleGroups;
+	return &mVisibleGroups[0];
 }
 
 LLCullResult::sg_iterator LLCullResult::endVisibleGroups()
 
 LLCullResult::sg_iterator LLCullResult::beginAlphaGroups()
 {
-	return mAlphaGroups;
+	return &mAlphaGroups[0];
 }
 
 LLCullResult::sg_iterator LLCullResult::endAlphaGroups()
 
 LLCullResult::sg_iterator LLCullResult::beginOcclusionGroups()
 {
-	return mOcclusionGroups;
+	return &mOcclusionGroups[0];
 }
 
 LLCullResult::sg_iterator LLCullResult::endOcclusionGroups()
 
 LLCullResult::sg_iterator LLCullResult::beginDrawableGroups()
 {
-	return mDrawableGroups;
+	return &mDrawableGroups[0];
 }
 
 LLCullResult::sg_iterator LLCullResult::endDrawableGroups()
 
 LLCullResult::drawable_iterator LLCullResult::beginVisibleList()
 {
-	return mVisibleList;
+	return &mVisibleList[0];
 }
 
 LLCullResult::drawable_iterator LLCullResult::endVisibleList()
 
 LLCullResult::bridge_iterator LLCullResult::beginVisibleBridge()
 {
-	return mVisibleBridge;
+	return &mVisibleBridge[0];
 }
 
 LLCullResult::bridge_iterator LLCullResult::endVisibleBridge()
 
 LLCullResult::drawinfo_iterator LLCullResult::beginRenderMap(U32 type)
 {
-	return mRenderMap[type];
+	return &mRenderMap[type][0];
 }
 
 LLCullResult::drawinfo_iterator LLCullResult::endRenderMap(U32 type)
 	}
 	else
 	{
-		pushBack((void**&) mVisibleGroups, mVisibleGroupsAllocated, (void*) group);
+		pushBack(mVisibleGroups, mVisibleGroupsAllocated, group);
 	}
 	++mVisibleGroupsSize;
-	mVisibleGroupsEnd = mVisibleGroups+mVisibleGroupsSize;
+	mVisibleGroupsEnd = &mVisibleGroups[mVisibleGroupsSize];
 }
 
 void LLCullResult::pushAlphaGroup(LLSpatialGroup* group)
 	}
 	else
 	{
-		pushBack((void**&) mAlphaGroups, mAlphaGroupsAllocated, (void*) group);
+		pushBack(mAlphaGroups, mAlphaGroupsAllocated, group);
 	}
 	++mAlphaGroupsSize;
-	mAlphaGroupsEnd = mAlphaGroups+mAlphaGroupsSize;
+	mAlphaGroupsEnd = &mAlphaGroups[mAlphaGroupsSize];
 }
 
 void LLCullResult::pushOcclusionGroup(LLSpatialGroup* group)
 	}
 	else
 	{
-		pushBack((void**&) mOcclusionGroups, mOcclusionGroupsAllocated, (void*) group);
+		pushBack(mOcclusionGroups, mOcclusionGroupsAllocated, group);
 	}
 	++mOcclusionGroupsSize;
-	mOcclusionGroupsEnd = mOcclusionGroups+mOcclusionGroupsSize;
+	mOcclusionGroupsEnd = &mOcclusionGroups[mOcclusionGroupsSize];
 }
 
 void LLCullResult::pushDrawableGroup(LLSpatialGroup* group)
 	}
 	else
 	{
-		pushBack((void**&) mDrawableGroups, mDrawableGroupsAllocated, (void*) group);
+		pushBack(mDrawableGroups, mDrawableGroupsAllocated, group);
 	}
 	++mDrawableGroupsSize;
-	mDrawableGroupsEnd = mDrawableGroups+mDrawableGroupsSize;
+	mDrawableGroupsEnd = &mDrawableGroups[mDrawableGroupsSize];
 }
 
 void LLCullResult::pushDrawable(LLDrawable* drawable)
 	}
 	else
 	{
-		pushBack((void**&) mVisibleList, mVisibleListAllocated, (void*) drawable);
+		pushBack(mVisibleList, mVisibleListAllocated, drawable);
 	}
 	++mVisibleListSize;
-	mVisibleListEnd = mVisibleList+mVisibleListSize;
+	mVisibleListEnd = &mVisibleList[mVisibleListSize];
 }
 
 void LLCullResult::pushBridge(LLSpatialBridge* bridge)
 	}
 	else
 	{
-		pushBack((void**&) mVisibleBridge, mVisibleBridgeAllocated, (void*) bridge);
+		pushBack(mVisibleBridge, mVisibleBridgeAllocated, bridge);
 	}
 	++mVisibleBridgeSize;
-	mVisibleBridgeEnd = mVisibleBridge+mVisibleBridgeSize;
+	mVisibleBridgeEnd = &mVisibleBridge[mVisibleBridgeSize];
 }
 
 void LLCullResult::pushDrawInfo(U32 type, LLDrawInfo* draw_info)
 	}
 	else
 	{
-		pushBack((void**&) mRenderMap[type], mRenderMapAllocated[type], (void*) draw_info);
+		pushBack(mRenderMap[type], mRenderMapAllocated[type], draw_info);
 	}
 	++mRenderMapSize[type];
-	mRenderMapEnd[type] = mRenderMap[type] + mRenderMapSize[type];
+	mRenderMapEnd[type] = &(mRenderMap[type][mRenderMapSize[type]]);
 }
 
 

indra/newview/llspatialpartition.h

 public:
 	LLCullResult();
 
-	typedef LLSpatialGroup** sg_list_t;
-	typedef LLDrawable** drawable_list_t;
-	typedef LLSpatialBridge** bridge_list_t;
-	typedef LLDrawInfo** drawinfo_list_t;
+	typedef std::vector<LLSpatialGroup*> sg_list_t;
+	typedef std::vector<LLDrawable*> drawable_list_t;
+	typedef std::vector<LLSpatialBridge*> bridge_list_t;
+	typedef std::vector<LLDrawInfo*> drawinfo_list_t;
 
 	typedef LLSpatialGroup** sg_iterator;
 	typedef LLSpatialBridge** bridge_iterator;
 
 private:
 
-	void pushBack(void** &head, U32& count, void* val);
+	template <class T, class V> void pushBack(T &head, U32& count, V* val);
 
 	U32					mVisibleGroupsSize;
 	U32					mAlphaGroupsSize;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.