From e4db67671729334b5d67d43af7bea3bd98b7447e Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Fri, 28 Sep 2012 12:06:46 -0700
Subject: Re-enabling tcmalloc in the build.

---
 indra/cmake/GooglePerfTools.cmake | 2 +-
 indra/llcommon/llmemory.h         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/cmake/GooglePerfTools.cmake b/indra/cmake/GooglePerfTools.cmake
index 73b3642ae6..09501e0406 100644
--- a/indra/cmake/GooglePerfTools.cmake
+++ b/indra/cmake/GooglePerfTools.cmake
@@ -3,7 +3,7 @@ include(Prebuilt)
 
 # If you want to enable or disable TCMALLOC in viewer builds, this is the place.
 # set ON or OFF as desired.
-set (USE_TCMALLOC OFF)
+set (USE_TCMALLOC ON)
 
 if (STANDALONE)
   include(FindGooglePerfTools)
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index f37e8459ff..9b7fb1b1ca 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -90,7 +90,7 @@ inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // r
 #else // USE_TCMALLOC
 // ll_aligned_foo_16 are not needed with tcmalloc
 #define ll_aligned_malloc_16 malloc
-#define ll_aligned_realloc_16 realloc
+#define ll_aligned_realloc_16(a,b,c) realloc(a,b)
 #define ll_aligned_free_16 free
 #endif // USE_TCMALLOC
 
-- 
cgit v1.2.3


From 866c9d06395bceb383789f3cd224d23cee6a3d6e Mon Sep 17 00:00:00 2001
From: Todd Stinson <stinson@lindenlab.com>
Date: Wed, 22 Aug 2012 15:49:14 -0700
Subject: PATH-864: Altering the minimum linksets floater size to smaller to
 allow fitting to 1024 width screens.

---
 indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml
index 9bc5c7d5a4..4a457fb929 100644
--- a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml
+++ b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml
@@ -6,7 +6,7 @@
     height="395"
     width="1075"
     min_height="395"
-    min_width="1075"
+    min_width="990"
     layout="topleft"
     name="floater_pathfinding_linksets"
     help_topic="floater_pathfinding_linksets"
@@ -524,7 +524,7 @@
         tool_tip="Walkability for characters of type D.  Example character type is other."
         width="45" />
     <button
-        follows="right|bottom"
+        follows="left|bottom"
         height="21"
         label="Apply changes"
         layout="topleft"
-- 
cgit v1.2.3


From fc09a016a0272558a89e21a0228157eec3ed62cd Mon Sep 17 00:00:00 2001
From: Todd Stinson <stinson@lindenlab.com>
Date: Mon, 27 Aug 2012 13:31:07 -0700
Subject: MAINT-1480: Clearing the angular velocity accummulation when the
 updated angular velocity is set to zero.

---
 indra/newview/llviewerobject.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 6c4e70add0..437a078061 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2075,7 +2075,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 	{
 		if (new_angv != old_angv)
 		{
-			if (flagUsePhysics())
+			if (flagUsePhysics() || new_angv.isExactlyZero())
 			{
 				resetRot();
 			}
-- 
cgit v1.2.3


From 839799c2625326c4965443dbf48c0a099b67ecaa Mon Sep 17 00:00:00 2001
From: Todd Stinson <stinson@lindenlab.com>
Date: Mon, 27 Aug 2012 16:35:34 -0700
Subject: PATH-868: Ensuring that walkability values are reset to a previous
 value if the empty string is entered.

---
 indra/newview/llfloaterpathfindinglinksets.cpp | 56 +++++++++++++++++---------
 indra/newview/llfloaterpathfindinglinksets.h   |  7 +++-
 2 files changed, 44 insertions(+), 19 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp
index 0fe0e151fb..1e46d7a402 100644
--- a/indra/newview/llfloaterpathfindinglinksets.cpp
+++ b/indra/newview/llfloaterpathfindinglinksets.cpp
@@ -98,7 +98,11 @@ LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed)
 	mLabelSuggestedUseD(NULL),
 	mEditD(NULL),
 	mApplyEditsButton(NULL),
-	mBeaconColor()
+	mBeaconColor(),
+	mPreviousValueA(LLPathfindingLinkset::MAX_WALKABILITY_VALUE),
+	mPreviousValueB(LLPathfindingLinkset::MAX_WALKABILITY_VALUE),
+	mPreviousValueC(LLPathfindingLinkset::MAX_WALKABILITY_VALUE),
+	mPreviousValueD(LLPathfindingLinkset::MAX_WALKABILITY_VALUE)
 {
 }
 
@@ -168,7 +172,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild()
 	mEditA = findChild<LLLineEditor>("edit_a_value");
 	llassert(mEditA != NULL);
 	mEditA->setPrevalidate(LLTextValidate::validateNonNegativeS32);
-	mEditA->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1));
+	mEditA->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1, mPreviousValueA));
 
 	mLabelEditB = findChild<LLTextBase>("edit_b_label");
 	llassert(mLabelEditB != NULL);
@@ -179,7 +183,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild()
 	mEditB = findChild<LLLineEditor>("edit_b_value");
 	llassert(mEditB != NULL);
 	mEditB->setPrevalidate(LLTextValidate::validateNonNegativeS32);
-	mEditB->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1));
+	mEditB->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1, mPreviousValueB));
 
 	mLabelEditC = findChild<LLTextBase>("edit_c_label");
 	llassert(mLabelEditC != NULL);
@@ -190,7 +194,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild()
 	mEditC = findChild<LLLineEditor>("edit_c_value");
 	llassert(mEditC != NULL);
 	mEditC->setPrevalidate(LLTextValidate::validateNonNegativeS32);
-	mEditC->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1));
+	mEditC->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1, mPreviousValueC));
 
 	mLabelEditD = findChild<LLTextBase>("edit_d_label");
 	llassert(mLabelEditD != NULL);
@@ -201,7 +205,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild()
 	mEditD = findChild<LLLineEditor>("edit_d_value");
 	llassert(mEditD != NULL);
 	mEditD->setPrevalidate(LLTextValidate::validateNonNegativeS32);
-	mEditD->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1));
+	mEditD->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1, mPreviousValueD));
 
 	mApplyEditsButton = findChild<LLButton>("apply_edit_values");
 	llassert(mApplyEditsButton != NULL);
@@ -323,26 +327,38 @@ void LLFloaterPathfindingLinksets::onClearFiltersClicked()
 	rebuildObjectsScrollList();
 }
 
-void LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl)
+void LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl, LLSD &pPreviousValue)
 {
 	LLLineEditor *pLineEditor = static_cast<LLLineEditor *>(pUICtrl);
 	llassert(pLineEditor != NULL);
 
 	const std::string &valueString = pLineEditor->getText();
-	S32 value;
 
-	if (LLStringUtil::convertToS32(valueString, value))
+	S32 intValue;
+	LLSD value;
+	bool doResetValue = false;
+
+	if (valueString.empty())
 	{
-		if ((value < LLPathfindingLinkset::MIN_WALKABILITY_VALUE) || (value > LLPathfindingLinkset::MAX_WALKABILITY_VALUE))
-		{
-			value = llclamp(value, LLPathfindingLinkset::MIN_WALKABILITY_VALUE, LLPathfindingLinkset::MAX_WALKABILITY_VALUE);
-			pLineEditor->setValue(LLSD(value));
-		}
+		value = pPreviousValue;
+		doResetValue = true;
+	}
+	else if (LLStringUtil::convertToS32(valueString, intValue))
+	{
+		doResetValue = ((intValue < LLPathfindingLinkset::MIN_WALKABILITY_VALUE) || (intValue > LLPathfindingLinkset::MAX_WALKABILITY_VALUE));
+		value = LLSD(llclamp(intValue, LLPathfindingLinkset::MIN_WALKABILITY_VALUE, LLPathfindingLinkset::MAX_WALKABILITY_VALUE));
 	}
 	else
 	{
-		pLineEditor->setValue(LLSD(LLPathfindingLinkset::MAX_WALKABILITY_VALUE));
+		value = LLSD(LLPathfindingLinkset::MAX_WALKABILITY_VALUE);
+		doResetValue = true;
+	}
+
+	if (doResetValue)
+	{
+		pLineEditor->setValue(value);
 	}
+	pPreviousValue = value;
 }
 
 void LLFloaterPathfindingLinksets::onApplyChangesClicked()
@@ -376,10 +392,14 @@ void LLFloaterPathfindingLinksets::updateEditFieldValues()
 		const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(firstSelectedObjectPtr.get());
 
 		setEditLinksetUse(linkset->getLinksetUse());
-		mEditA->setValue(LLSD(linkset->getWalkabilityCoefficientA()));
-		mEditB->setValue(LLSD(linkset->getWalkabilityCoefficientB()));
-		mEditC->setValue(LLSD(linkset->getWalkabilityCoefficientC()));
-		mEditD->setValue(LLSD(linkset->getWalkabilityCoefficientD()));
+		mPreviousValueA = LLSD(linkset->getWalkabilityCoefficientA());
+		mPreviousValueB = LLSD(linkset->getWalkabilityCoefficientB());
+		mPreviousValueC = LLSD(linkset->getWalkabilityCoefficientC());
+		mPreviousValueD = LLSD(linkset->getWalkabilityCoefficientD());
+		mEditA->setValue(mPreviousValueA);
+		mEditB->setValue(mPreviousValueB);
+		mEditC->setValue(mPreviousValueC);
+		mEditD->setValue(mPreviousValueD);
 	}
 }
 
diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h
index 6538308122..7149da9215 100644
--- a/indra/newview/llfloaterpathfindinglinksets.h
+++ b/indra/newview/llfloaterpathfindinglinksets.h
@@ -74,7 +74,7 @@ private:
 
 	void onApplyAllFilters();
 	void onClearFiltersClicked();
-	void onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl);
+	void onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl, LLSD &pPreviousValue);
 	void onApplyChangesClicked();
 
 	void clearFilters();
@@ -132,6 +132,11 @@ private:
 	LLButton         *mApplyEditsButton;
 
 	LLColor4         mBeaconColor;
+
+	LLSD             mPreviousValueA;
+	LLSD             mPreviousValueB;
+	LLSD             mPreviousValueC;
+	LLSD             mPreviousValueD;
 };
 
 #endif // LL_LLFLOATERPATHFINDINGLINKSETS_H
-- 
cgit v1.2.3


From 7d54c71aeb6f0829c3c8f8ee68d7b3d542d32b55 Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Mon, 27 Aug 2012 19:26:58 -0700
Subject: MAINT-1480: Ensuring that the new angular velocity is remembered for
 later comparison to the previous angular velocity.

---
 indra/newview/llviewerobject.cpp | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 437a078061..9ad8e14510 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -1434,9 +1434,10 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 #else
 					val = (U16 *) &data[count];
 #endif
-					setAngularVelocity(	U16_to_F32(val[VX], -size, size),
-										U16_to_F32(val[VY], -size, size),
-										U16_to_F32(val[VZ], -size, size));
+					new_angv.set(U16_to_F32(val[VX], -size, size),
+						U16_to_F32(val[VY], -size, size),
+						U16_to_F32(val[VZ], -size, size));
+					setAngularVelocity(new_angv);
 					break;
 
 				case 16:
@@ -1460,9 +1461,10 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 					new_rot.mQ[VZ] = U8_to_F32(data[11], -1.f, 1.f);
 					new_rot.mQ[VW] = U8_to_F32(data[12], -1.f, 1.f);
 
-					setAngularVelocity(	U8_to_F32(data[13], -size, size),
-										U8_to_F32(data[14], -size, size),
-										U8_to_F32(data[15], -size, size) );
+					new_angv.set(U8_to_F32(data[13], -size, size),
+						U8_to_F32(data[14], -size, size),
+						U8_to_F32(data[15], -size, size));
+					setAngularVelocity(new_angv);
 					break;
 				}
 
@@ -1534,9 +1536,10 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 				dp->unpackU16(val[VX], "AccX");
 				dp->unpackU16(val[VY], "AccY");
 				dp->unpackU16(val[VZ], "AccZ");
-				setAngularVelocity(	U16_to_F32(val[VX], -64.f, 64.f),
-									U16_to_F32(val[VY], -64.f, 64.f),
-									U16_to_F32(val[VZ], -64.f, 64.f));
+				new_angv.set(U16_to_F32(val[VX], -64.f, 64.f),
+				             U16_to_F32(val[VY], -64.f, 64.f),
+				             U16_to_F32(val[VZ], -64.f, 64.f));
+				setAngularVelocity(new_angv);
 			}
 			break;
 			case OUT_FULL_COMPRESSED:
@@ -1580,8 +1583,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 
 				if (value & 0x80)
 				{
-					dp->unpackVector3(vec, "Omega");
-					setAngularVelocity(vec);
+					dp->unpackVector3(new_angv, "Omega");
+					setAngularVelocity(new_angv);
 				}
 
 				if (value & 0x20)
-- 
cgit v1.2.3


From a766e26db46c7c054bae1021470dbe365f2a3cb3 Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Mon, 10 Sep 2012 10:37:02 -0700
Subject: Backing out the changes contributing to DRTVWR-167 and DRTVWR-179
 from the repository.

---
 indra/cmake/00-Common.cmake                        |    1 -
 indra/cmake/Copy3rdPartyLibs.cmake                 |    9 +-
 indra/cmake/GooglePerfTools.cmake                  |   40 +-
 indra/cmake/LLAddBuildTest.cmake                   |    9 -
 indra/llcharacter/llcharacter.cpp                  |    6 +-
 indra/llcharacter/llmotioncontroller.cpp           |   17 +-
 indra/llcommon/llallocator.cpp                     |    2 +-
 indra/llcommon/llmemory.cpp                        |   12 -
 indra/llcommon/llmemory.h                          |   45 +-
 indra/llmath/CMakeLists.txt                        |    1 -
 indra/llmath/llcamera.h                            |   12 +-
 indra/llmath/llmatrix3a.h                          |    2 +-
 indra/llmath/llmatrix4a.h                          |    2 +-
 indra/llmath/lloctree.h                            |  147 +--
 indra/llmath/llplane.h                             |    4 +-
 indra/llmath/llsimdmath.h                          |    3 +-
 indra/llmath/llsimdtypes.inl                       |    2 -
 indra/llmath/llvector4a.cpp                        |    8 +-
 indra/llmath/llvector4a.h                          |    6 +-
 indra/llmath/llvector4a.inl                        |    1 -
 indra/llmath/llvector4logical.h                    |    2 -
 indra/llmath/llvolume.cpp                          |   53 +-
 indra/llmath/llvolumeoctree.cpp                    |    6 +-
 indra/llmath/llvolumeoctree.h                      |   35 +-
 indra/llmessage/llurlrequest.cpp                   |    5 +-
 indra/llmessage/tests/llhttpclient_test.cpp        |    1 -
 indra/llplugin/llpluginclassmedia.cpp              |    2 +-
 indra/llprimitive/llmodel.cpp                      |    3 +-
 indra/llrender/llimagegl.cpp                       |    2 -
 indra/llrender/llrendertarget.cpp                  |   36 -
 indra/llrender/llrendertarget.h                    |    8 +-
 indra/llrender/llvertexbuffer.cpp                  |    5 +-
 indra/newview/CMakeLists.txt                       |    8 +-
 indra/newview/llappviewer.cpp                      |    4 -
 indra/newview/llappviewerwin32.cpp                 |    2 -
 indra/newview/lldrawable.cpp                       |   52 +-
 indra/newview/lldrawable.h                         |   23 +-
 indra/newview/lldrawpool.cpp                       |   44 +-
 indra/newview/lldrawpool.h                         |    4 +
 indra/newview/lldrawpoolalpha.cpp                  |   10 +-
 indra/newview/lldrawpoolavatar.cpp                 |   78 +-
 indra/newview/lldrawpoolbump.cpp                   |   12 +-
 indra/newview/lldrawpoolterrain.cpp                |   28 -
 indra/newview/lldrawpoolterrain.h                  |    1 -
 indra/newview/lldrawpooltree.cpp                   |   15 -
 indra/newview/lldriverparam.cpp                    |   26 +-
 indra/newview/lldriverparam.h                      |   10 +-
 indra/newview/lldynamictexture.h                   |   12 +-
 indra/newview/llface.cpp                           |   46 +-
 indra/newview/llface.h                             |   12 -
 indra/newview/llflexibleobject.cpp                 |  130 +--
 indra/newview/llflexibleobject.h                   |    5 +-
 indra/newview/llfloaterbuycontents.cpp             |    4 +-
 indra/newview/llfloaterland.cpp                    |   17 +-
 indra/newview/llfloatermodelpreview.cpp            |    3 +-
 indra/newview/llfolderview.cpp                     |    3 +-
 indra/newview/llpanelmarketplaceinbox.cpp          |    8 +-
 indra/newview/llphysicsmotion.cpp                  |   77 +-
 indra/newview/llpolymesh.cpp                       |  210 ++--
 indra/newview/llpolymesh.h                         |   52 +-
 indra/newview/llpolymorph.cpp                      |  165 ++-
 indra/newview/llpolymorph.h                        |   18 +-
 indra/newview/llsidepaneliteminfo.cpp              |    2 +-
 indra/newview/llspatialpartition.cpp               |  196 ++--
 indra/newview/llspatialpartition.h                 |  109 +-
 indra/newview/llsurface.cpp                        |    8 +-
 indra/newview/llsurfacepatch.cpp                   |   14 +-
 indra/newview/lltexlayerparams.h                   |   20 +-
 indra/newview/llviewercamera.h                     |   13 +-
 indra/newview/llviewerdisplay.cpp                  |   32 +-
 indra/newview/llviewerjointmesh.cpp                |    6 +-
 indra/newview/llviewermenu.cpp                     |   12 +-
 indra/newview/llviewermessage.cpp                  |    2 -
 indra/newview/llviewerobject.cpp                   |   15 +-
 indra/newview/llviewerobject.h                     |    7 +-
 indra/newview/llviewerobjectlist.cpp               |   97 +-
 indra/newview/llviewerobjectlist.h                 |    4 +-
 indra/newview/llviewerregion.cpp                   |    3 +-
 indra/newview/llviewervisualparam.h                |    8 +-
 indra/newview/llviewerwindow.cpp                   |    3 -
 indra/newview/llvoavatar.cpp                       |   23 +-
 indra/newview/llvoavatar.h                         |   16 +-
 indra/newview/llvoavatarself.h                     |   10 -
 indra/newview/llvograss.cpp                        |    2 +-
 indra/newview/llvopartgroup.cpp                    |   12 +-
 indra/newview/llvopartgroup.h                      |    1 -
 indra/newview/llvotree.cpp                         |    6 +-
 indra/newview/llvovolume.cpp                       |   43 +-
 indra/newview/llvovolume.h                         |    3 +-
 indra/newview/llworld.cpp                          |   14 +-
 indra/newview/pipeline.cpp                         |  357 +++----
 indra/newview/pipeline.h                           |    8 +-
 indra/newview/skins/default/xui/de/menu_viewer.xml |    1 +
 .../skins/default/xui/en/floater_texture_ctrl.xml  |   10 -
 .../newview/skins/default/xui/en/notifications.xml |   12 -
 .../skins/default/xui/en/sidepanel_item_info.xml   |    4 -
 .../skins/default/xui/en/sidepanel_task_info.xml   | 1088 ++++++++++----------
 indra/newview/viewer_manifest.py                   |    1 -
 98 files changed, 1463 insertions(+), 2265 deletions(-)

(limited to 'indra')

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 00baf626d2..98eeed09b3 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -69,7 +69,6 @@ if (WINDOWS)
       /Oy-
       /Zc:wchar_t-
       /arch:SSE2
-      /fp:fast
       )
      
   # Are we using the crummy Visual Studio KDU build workaround?
diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 9f05c4cff2..224e0a8b51 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -57,10 +57,10 @@ if(WINDOWS)
         libhunspell.dll
         )
 
-    if(USE_TCMALLOC)
+    if(USE_GOOGLE_PERFTOOLS)
       set(debug_files ${debug_files} libtcmalloc_minimal-debug.dll)
       set(release_files ${release_files} libtcmalloc_minimal.dll)
-    endif(USE_TCMALLOC)
+    endif(USE_GOOGLE_PERFTOOLS)
 
     if (FMOD)
       set(debug_files ${debug_files} fmod.dll)
@@ -272,16 +272,13 @@ elseif(LINUX)
         libopenal.so
         libopenjpeg.so
         libssl.so
+        libtcmalloc_minimal.so
         libuuid.so.16
         libuuid.so.16.0.22
         libssl.so.1.0.0
         libfontconfig.so.1.4.4
        )
 
-    if (USE_TCMALLOC)
-      set(release_files ${release_files} "libtcmalloc_minimal.so")
-    endif (USE_TCMALLOC)
-
     if (FMOD)
       set(release_files ${release_files} "libfmod-3.75.so")
     endif (FMOD)
diff --git a/indra/cmake/GooglePerfTools.cmake b/indra/cmake/GooglePerfTools.cmake
index 09501e0406..d9f91193be 100644
--- a/indra/cmake/GooglePerfTools.cmake
+++ b/indra/cmake/GooglePerfTools.cmake
@@ -1,34 +1,20 @@
 # -*- cmake -*-
 include(Prebuilt)
 
-# If you want to enable or disable TCMALLOC in viewer builds, this is the place.
-# set ON or OFF as desired.
-set (USE_TCMALLOC ON)
-
 if (STANDALONE)
   include(FindGooglePerfTools)
 else (STANDALONE)
   if (WINDOWS)
-    if (USE_TCMALLOC)
-       use_prebuilt_binary(tcmalloc)
-       set(TCMALLOC_LIBRARIES 
-         debug libtcmalloc_minimal-debug
-         optimized libtcmalloc_minimal)
-       set(TCMALLOC_LINK_FLAGS  "/INCLUDE:__tcmalloc")
-    else (USE_TCMALLOC)
-      set(TCMALLOC_LIBRARIES)
-      set(TCMALLOC_LINK_FLAGS)
-    endif (USE_TCMALLOC)
+    use_prebuilt_binary(tcmalloc)
+    set(TCMALLOC_LIBRARIES 
+        debug libtcmalloc_minimal-debug
+        optimized libtcmalloc_minimal)
     set(GOOGLE_PERFTOOLS_FOUND "YES")
   endif (WINDOWS)
   if (LINUX)
-    if (USE_TCMALLOC)
-      use_prebuilt_binary(tcmalloc)
-      set(TCMALLOC_LIBRARIES 
-        tcmalloc)
-    else (USE_TCMALLOC)
-      set(TCMALLOC_LIBRARIES)
-    endif (USE_TCMALLOC)
+    use_prebuilt_binary(tcmalloc)
+    set(TCMALLOC_LIBRARIES 
+    tcmalloc)
     set(PROFILER_LIBRARIES profiler)
     set(GOOGLE_PERFTOOLS_INCLUDE_DIR
         ${LIBS_PREBUILT_DIR}/include)
@@ -43,19 +29,13 @@ if (GOOGLE_PERFTOOLS_FOUND)
 endif (GOOGLE_PERFTOOLS_FOUND)
 
 if (WINDOWS)
-   set(USE_GOOGLE_PERFTOOLS ON)
+    set(USE_GOOGLE_PERFTOOLS ON)
 endif (WINDOWS)
 
 if (USE_GOOGLE_PERFTOOLS)
-  if (USE_TCMALLOC)
-    set(TCMALLOC_FLAG -DLL_USE_TCMALLOC=1)
-  else (USE_TCMALLOC)
-    set(TCMALLOC_FLAG -ULL_USE_TCMALLOC)
-  endif (USE_TCMALLOC)
-endif (USE_GOOGLE_PERFTOOLS)
-
-if (USE_GOOGLE_PERFTOOLS)
+  set(TCMALLOC_FLAG -ULL_USE_TCMALLOC=1)
   include_directories(${GOOGLE_PERFTOOLS_INCLUDE_DIR})
   set(GOOGLE_PERFTOOLS_LIBRARIES ${TCMALLOC_LIBRARIES} ${STACKTRACE_LIBRARIES} ${PROFILER_LIBRARIES})
 else (USE_GOOGLE_PERFTOOLS)
+  set(TCMALLOC_FLAG -ULL_USE_TCMALLOC)
 endif (USE_GOOGLE_PERFTOOLS)
diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake
index 543075db5b..03ce46781c 100755
--- a/indra/cmake/LLAddBuildTest.cmake
+++ b/indra/cmake/LLAddBuildTest.cmake
@@ -214,15 +214,6 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
     SET_TARGET_PROPERTIES(INTEGRATION_TEST_${testname} PROPERTIES COMPILE_FLAGS -I"${TUT_INCLUDE_DIR}")
   endif(STANDALONE)
 
-  if (WINDOWS)
-    SET_TARGET_PROPERTIES(INTEGRATION_TEST_${testname}
-        PROPERTIES
-        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS ${TCMALLOC_LINK_FLAGS}"
-        LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" /INCREMENTAL:NO"
-        LINK_FLAGS_RELEASE ""
-        )
-  endif (WINDOWS)
-
   # Add link deps to the executable
   if(TEST_DEBUG)
     message(STATUS "TARGET_LINK_LIBRARIES(INTEGRATION_TEST_${testname} ${libraries})")
diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index 0a6a8f9fa6..c9fb8534f1 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -189,7 +189,6 @@ void LLCharacter::requestStopMotion( LLMotion* motion)
 //-----------------------------------------------------------------------------
 static LLFastTimer::DeclareTimer FTM_UPDATE_ANIMATION("Update Animation");
 static LLFastTimer::DeclareTimer FTM_UPDATE_HIDDEN_ANIMATION("Update Hidden Anim");
-static LLFastTimer::DeclareTimer FTM_UPDATE_MOTIONS("Update Motions");
 
 void LLCharacter::updateMotions(e_update_t update_type)
 {
@@ -207,10 +206,7 @@ void LLCharacter::updateMotions(e_update_t update_type)
 			mMotionController.unpauseAllMotions();
 		}
 		bool force_update = (update_type == FORCE_UPDATE);
-		{
-			LLFastTimer t(FTM_UPDATE_MOTIONS);
-			mMotionController.updateMotions(force_update);
-		}
+		mMotionController.updateMotions(force_update);
 	}
 }
 
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index 4f6351709e..bb892f4a7f 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -542,8 +542,6 @@ void LLMotionController::updateIdleActiveMotions()
 //-----------------------------------------------------------------------------
 // updateMotionsByType()
 //-----------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_MOTION_ON_UPDATE("Motion onUpdate");
-
 void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_type)
 {
 	BOOL update_result = TRUE;
@@ -701,10 +699,7 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
 			}
 
 			// perform motion update
-			{
-				LLFastTimer t(FTM_MOTION_ON_UPDATE);
-				update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
-			}
+			update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
 		}
 
 		//**********************
@@ -815,7 +810,7 @@ void LLMotionController::updateMotions(bool force_update)
 
 	// Always cap the number of loaded motions
 	purgeExcessMotions();
-		
+	
 	// Update timing info for this time step.
 	if (!mPaused)
 	{
@@ -837,7 +832,6 @@ void LLMotionController::updateMotions(bool force_update)
 				}
 
 				updateLoadingMotions();
-				
 				return;
 			}
 			
@@ -856,7 +850,7 @@ void LLMotionController::updateMotions(bool force_update)
 	}
 
 	updateLoadingMotions();
-	
+
 	resetJointSignatures();
 
 	if (mPaused && !force_update)
@@ -867,12 +861,11 @@ void LLMotionController::updateMotions(bool force_update)
 	{
 		// update additive motions
 		updateAdditiveMotions();
-				
 		resetJointSignatures();
-		
+
 		// update all regular motions
 		updateRegularMotions();
-		
+
 		if (use_quantum)
 		{
 			mPoseBlender.blendAndCache(TRUE);
diff --git a/indra/llcommon/llallocator.cpp b/indra/llcommon/llallocator.cpp
index 87654b5b97..6f6abefc67 100644
--- a/indra/llcommon/llallocator.cpp
+++ b/indra/llcommon/llallocator.cpp
@@ -27,7 +27,7 @@
 #include "linden_common.h"
 #include "llallocator.h"
 
-#if (LL_USE_TCMALLOC && LL_USE_HEAP_PROFILER)
+#if LL_USE_TCMALLOC
 
 #include "google/heap-profiler.h"
 #include "google/commandlineflags_public.h"
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index afaf366668..3b9758f996 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -61,18 +61,6 @@ BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
 LLPrivateMemoryPoolManager::mem_allocation_info_t LLPrivateMemoryPoolManager::sMemAllocationTracker;
 #endif
 
-void ll_assert_aligned_func(uintptr_t ptr,U32 alignment)
-{
-#ifdef SHOW_ASSERT
-	// Redundant, place to set breakpoints.
-	if (ptr%alignment!=0)
-	{
-		llwarns << "alignment check failed" << llendl;
-	}
-	llassert(ptr%alignment==0);
-#endif
-}
-
 //static
 void LLMemory::initClass()
 {
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 9dd776ff57..bbbdaa6497 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -27,6 +27,7 @@
 #define LLMEMORY_H
 
 #include "llmemtype.h"
+#if LL_DEBUG
 inline void* ll_aligned_malloc( size_t size, int align )
 {
 	void* mem = malloc( size + (align - 1) + sizeof(void*) );
@@ -42,11 +43,10 @@ inline void ll_aligned_free( void* ptr )
 	free( ((void**)ptr)[-1] );
 }
 
-#if !LL_USE_TCMALLOC
 inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
 {
 #if defined(LL_WINDOWS)
-	return _aligned_malloc(size, 16);
+	return _mm_malloc(size, 16);
 #elif defined(LL_DARWIN)
 	return malloc(size); // default osx malloc is 16 byte aligned.
 #else
@@ -58,38 +58,21 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi
 #endif
 }
 
-inline void* ll_aligned_realloc_16(void* ptr, size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
-{
-#if defined(LL_WINDOWS)
-	return _aligned_realloc(ptr, size, 16);
-#elif defined(LL_DARWIN)
-	return realloc(ptr,size); // default osx malloc is 16 byte aligned.
-#else
-	return realloc(ptr,size); // FIXME not guaranteed to be aligned.
-#endif
-}
-
 inline void ll_aligned_free_16(void *p)
 {
 #if defined(LL_WINDOWS)
-	_aligned_free(p);
+	_mm_free(p);
 #elif defined(LL_DARWIN)
 	return free(p);
 #else
 	free(p); // posix_memalign() is compatible with heap deallocator
 #endif
 }
-#else // USE_TCMALLOC
-// ll_aligned_foo_16 are not needed with tcmalloc
-#define ll_aligned_malloc_16 malloc
-#define ll_aligned_realloc_16 realloc
-#define ll_aligned_free_16 free
-#endif // USE_TCMALLOC
 
 inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed with ll_aligned_free_32().
 {
 #if defined(LL_WINDOWS)
-	return _aligned_malloc(size, 32);
+	return _mm_malloc(size, 32);
 #elif defined(LL_DARWIN)
 	return ll_aligned_malloc( size, 32 );
 #else
@@ -104,13 +87,22 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi
 inline void ll_aligned_free_32(void *p)
 {
 #if defined(LL_WINDOWS)
-	_aligned_free(p);
+	_mm_free(p);
 #elif defined(LL_DARWIN)
 	ll_aligned_free( p );
 #else
 	free(p); // posix_memalign() is compatible with heap deallocator
 #endif
 }
+#else // LL_DEBUG
+// ll_aligned_foo are noops now that we use tcmalloc everywhere (tcmalloc aligns automatically at appropriate intervals)
+#define ll_aligned_malloc( size, align ) malloc(size)
+#define ll_aligned_free( ptr ) free(ptr)
+#define ll_aligned_malloc_16 malloc
+#define ll_aligned_free_16 free
+#define ll_aligned_malloc_32 malloc
+#define ll_aligned_free_32 free
+#endif // LL_DEBUG
 
 #ifndef __DEBUG_PRIVATE_MEM__
 #define __DEBUG_PRIVATE_MEM__  0
@@ -520,13 +512,4 @@ void  LLPrivateMemoryPoolTester::operator delete[](void* addr)
 
 // LLSingleton moved to llsingleton.h
 
-LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
-
-#ifdef SHOW_ASSERT
-#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast<uintptr_t>(ptr),((U32)alignment))
-#else
-#define ll_assert_aligned(ptr,alignment)
-#endif
-
-
 #endif
diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt
index 5865ae030c..b5e59c1ca3 100644
--- a/indra/llmath/CMakeLists.txt
+++ b/indra/llmath/CMakeLists.txt
@@ -117,7 +117,6 @@ if (LL_TESTS)
   # INTEGRATION TESTS
   set(test_libs llmath llcommon ${LLCOMMON_LIBRARIES} ${WINDOWS_LIBRARIES})
   # TODO: Some of these need refactoring to be proper Unit tests rather than Integration tests.
-  LL_ADD_INTEGRATION_TEST(alignment "" "${test_libs}")
   LL_ADD_INTEGRATION_TEST(llbbox llbbox.cpp "${test_libs}")
   LL_ADD_INTEGRATION_TEST(llquaternion llquaternion.cpp "${test_libs}")
   LL_ADD_INTEGRATION_TEST(mathmisc "" "${test_libs}")
diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
index 0b591be622..ec67b91d05 100644
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -60,7 +60,7 @@ static const F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD;
 // roll(), pitch(), yaw()
 // etc...
 
-LL_ALIGN_PREFIX(16)
+
 class LLCamera
 : 	public LLCoordFrame
 {
@@ -108,7 +108,7 @@ public:
 	};
 
 private:
-	LL_ALIGN_16(LLPlane mAgentPlanes[7]);  //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
+	LLPlane mAgentPlanes[7];  //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
 	U8 mPlaneMask[8];         // 8 for alignment	
 	
 	F32 mView;					// angle between top and bottom frustum planes in radians.
@@ -116,13 +116,13 @@ private:
 	S32 mViewHeightInPixels;	// for ViewHeightInPixels() only
 	F32 mNearPlane;
 	F32 mFarPlane;
-	LL_ALIGN_16(LLPlane mLocalPlanes[4]);
+	LLPlane mLocalPlanes[4];
 	F32 mFixedDistance;			// Always return this distance, unless < 0
 	LLVector3 mFrustCenter;		// center of frustum and radius squared for ultra-quick exclusion test
 	F32 mFrustRadiusSquared;
 	
-	LL_ALIGN_16(LLPlane mWorldPlanes[PLANE_NUM]);
-	LL_ALIGN_16(LLPlane mHorizPlanes[HORIZ_PLANE_NUM]);
+	LLPlane mWorldPlanes[PLANE_NUM];
+	LLPlane mHorizPlanes[HORIZ_PLANE_NUM];
 
 	U32 mPlaneCount;  //defaults to 6, if setUserClipPlane is called, uses user supplied clip plane in
 
@@ -208,7 +208,7 @@ protected:
 	void calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom);
 	void calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2);
 	void calculateWorldFrustumPlanes();
-} LL_ALIGN_POSTFIX(16);
+};
 
 
 #endif
diff --git a/indra/llmath/llmatrix3a.h b/indra/llmath/llmatrix3a.h
index 9916cfd2da..adb7e3389d 100644
--- a/indra/llmath/llmatrix3a.h
+++ b/indra/llmath/llmatrix3a.h
@@ -111,7 +111,7 @@ public:
 
 protected:
 
-	LL_ALIGN_16(LLVector4a mColumns[3]);
+	LLVector4a mColumns[3];
 
 };
 
diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h
index c4cefdb4fa..27cf5b79f6 100644
--- a/indra/llmath/llmatrix4a.h
+++ b/indra/llmath/llmatrix4a.h
@@ -34,7 +34,7 @@
 class LLMatrix4a
 {
 public:
-	LL_ALIGN_16(LLVector4a mMatrix[4]);
+	LLVector4a mMatrix[4];
 
 	inline void clear()
 	{
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index c3f6f7de2a..1b11e83b4a 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -31,6 +31,7 @@
 #include "v3math.h"
 #include "llvector4a.h"
 #include <vector>
+#include <set>
 
 #define OCT_ERRS LL_WARNS("OctreeErrors")
 
@@ -78,18 +79,16 @@ public:
 
 	typedef LLOctreeTraveler<T>									oct_traveler;
 	typedef LLTreeTraveler<T>									tree_traveler;
-	typedef LLPointer<T>*										element_list;
-	typedef LLPointer<T>*										element_iter;
-	typedef const LLPointer<T>*									const_element_iter;
+	typedef typename std::set<LLPointer<T> >					element_list;
+	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 LLOctreeNode<T>**									child_list;
-	typedef LLOctreeNode<T>**									child_iter;
-
+	typedef typename std::vector<LLOctreeNode<T>* >				child_list;
 	typedef LLTreeNode<T>		BaseType;
 	typedef LLOctreeNode<T>		oct_node;
 	typedef LLOctreeListener<T>	oct_listener;
 
-	void* operator new(size_t size)
+	/*void* operator new(size_t size)
 	{
 		return ll_aligned_malloc_16(size);
 	}
@@ -97,7 +96,7 @@ public:
 	void operator delete(void* ptr)
 	{
 		ll_aligned_free_16(ptr);
-	}
+	}*/
 
 	LLOctreeNode(	const LLVector4a& center, 
 					const LLVector4a& size, 
@@ -106,9 +105,6 @@ public:
 	:	mParent((oct_node*)parent), 
 		mOctant(octant) 
 	{ 
-		mData = NULL;
-		mDataEnd = NULL;
-
 		mCenter = center;
 		mSize = size;
 
@@ -127,16 +123,6 @@ public:
 	{ 
 		BaseType::destroyListeners(); 
 		
-		for (U32 i = 0; i < mElementCount; ++i)
-		{
-			mData[i]->setBinIndex(-1);
-			mData[i] = NULL;
-		}
-
-		free(mData);
-		mData = NULL;
-		mDataEnd = NULL;
-
 		for (U32 i = 0; i < getChildCount(); i++)
 		{
 			delete getChild(i);
@@ -233,17 +219,12 @@ public:
 	}
 
 	void accept(oct_traveler* visitor)				{ visitor->visit(this); }
-	virtual bool isLeaf() const						{ return mChildCount == 0; }
+	virtual bool isLeaf() const						{ return mChild.empty(); }
 	
 	U32 getElementCount() const						{ return mElementCount; }
-	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 getDataEnd()						{ return mDataEnd; }
-	const_element_iter getDataBegin() const			{ return mData; }
-	const_element_iter getDataEnd() const			{ return mDataEnd; }
-		
+	
 	U32 getChildCount()	const						{ return mChildCount; }
 	oct_node* getChild(U32 index)					{ return mChild[index]; }
 	const oct_node* getChild(U32 index) const		{ return mChild[index]; }
@@ -308,7 +289,7 @@ public:
 	
 	virtual bool insert(T* data)
 	{
-		if (data == NULL || data->getBinIndex() != -1)
+		if (data == NULL)
 		{
 			OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << llendl;
 			return false;
@@ -321,16 +302,13 @@ public:
 			if ((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius()) ||
 				(data->getBinRadius() > getSize()[0] &&	parent && parent->getElementCount() >= gOctreeMaxCapacity))) 
 			{ //it belongs here
-				mElementCount++;
-				mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
-
-				//avoid unref on uninitialized memory
-				memset(mData+mElementCount-1, 0, sizeof(LLPointer<T>));
+				//if this is a redundant insertion, error out (should never happen)
+				llassert(mData.find(data) == mData.end());
 
-				mData[mElementCount-1] = data;
-				mDataEnd = mData + mElementCount;
-				data->setBinIndex(mElementCount-1);
+				mData.insert(data);
 				BaseType::insert(data);
+
+				mElementCount = mData.size();
 				return true;
 			}
 			else
@@ -364,16 +342,10 @@ public:
 
 				if( lt == 0x7 )
 				{
-					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;
-					data->setBinIndex(mElementCount-1);
+					mData.insert(data);
 					BaseType::insert(data);
+
+					mElementCount = mData.size();
 					return true;
 				}
 
@@ -422,59 +394,23 @@ public:
 		return false;
 	}
 
-	void _remove(T* data, S32 i)
-	{ //precondition -- mElementCount > 0, idx is in range [0, mElementCount)
-
-		mElementCount--;
-		data->setBinIndex(-1); 
-		
-		if (mElementCount > 0)
-		{
-			if (mElementCount != i)
-			{
-				mData[i] = mData[mElementCount]; //might unref data, do not access data after this point
-				mData[i]->setBinIndex(i);
-			}
-
-			mData[mElementCount] = NULL; //needed for unref
-			mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
-			mDataEnd = mData+mElementCount;
-		}
-		else
-		{
-			mData[0] = NULL; //needed for unref
-			free(mData);
-			mData = NULL;
-			mDataEnd = NULL;
-		}
-
-		notifyRemoval(data);
-		checkAlive();
-	}
-
 	bool remove(T* data)
 	{
-		S32 i = data->getBinIndex();
-
-		if (i >= 0 && i < mElementCount)
-		{
-			if (mData[i] == data)
-			{ //found it
-				_remove(data, i);
-				llassert(data->getBinIndex() == -1);
-				return true;
-			}
-		}
-		
-		if (isInside(data))
+		if (mData.find(data) != mData.end())
+		{	//we have data
+			mData.erase(data);
+			mElementCount = mData.size();
+			notifyRemoval(data);
+			checkAlive();
+			return true;
+		}
+		else if (isInside(data))
 		{
 			oct_node* dest = getNodeAt(data);
 
 			if (dest != this)
 			{
-				bool ret = dest->remove(data);
-				llassert(data->getBinIndex() == -1);
-				return ret;
+				return dest->remove(data);
 			}
 		}
 
@@ -493,20 +429,19 @@ public:
 		//node is now root
 		llwarns << "!!! OCTREE REMOVING FACE BY ADDRESS, SEVERE PERFORMANCE PENALTY |||" << llendl;
 		node->removeByAddress(data);
-		llassert(data->getBinIndex() == -1);
 		return true;
 	}
 
 	void removeByAddress(T* data)
 	{
-        for (U32 i = 0; i < mElementCount; ++i)
+        if (mData.find(data) != mData.end())
 		{
-			if (mData[i] == data)
-			{ //we have data
-				_remove(data, i);
-				llwarns << "FOUND!" << llendl;
-				return;
-			}
+			mData.erase(data);
+			mElementCount = mData.size();
+			notifyRemoval(data);
+			llwarns << "FOUND!" << llendl;
+			checkAlive();
+			return;
 		}
 		
 		for (U32 i = 0; i < getChildCount(); i++)
@@ -518,8 +453,8 @@ public:
 
 	void clearChildren()
 	{
+		mChild.clear();
 		mChildCount = 0;
-
 		U32* foo = (U32*) mChildMap;
 		foo[0] = foo[1] = 0xFFFFFFFF;
 	}
@@ -581,7 +516,7 @@ public:
 
 		mChildMap[child->getOctant()] = mChildCount;
 
-		mChild[mChildCount] = child;
+		mChild.push_back(child);
 		++mChildCount;
 		child->setParent(this);
 
@@ -608,12 +543,9 @@ public:
 			mChild[index]->destroy();
 			delete mChild[index];
 		}
-
+		mChild.erase(mChild.begin() + index);
 		--mChildCount;
 
-		mChild[index] = mChild[mChildCount];
-		
-
 		//rebuild child map
 		U32* foo = (U32*) mChildMap;
 		foo[0] = foo[1] = 0xFFFFFFFF;
@@ -669,12 +601,11 @@ protected:
 	oct_node* mParent;
 	U8 mOctant;
 
-	LLOctreeNode<T>* mChild[8];
+	child_list mChild;
 	U8 mChildMap[8];
 	U32 mChildCount;
 
 	element_list mData;
-	element_iter mDataEnd;
 	U32 mElementCount;
 		
 }; 
diff --git a/indra/llmath/llplane.h b/indra/llmath/llplane.h
index 3c32441b11..a611894721 100644
--- a/indra/llmath/llplane.h
+++ b/indra/llmath/llplane.h
@@ -36,8 +36,6 @@
 // The plane normal = [A, B, C]
 // The closest approach = D / sqrt(A*A + B*B + C*C)
 
-
-LL_ALIGN_PREFIX(16)
 class LLPlane
 {
 public:
@@ -96,7 +94,7 @@ public:
 		
 private:
 	LLVector4a mV;
-} LL_ALIGN_POSTFIX(16);
+};
 
 
 
diff --git a/indra/llmath/llsimdmath.h b/indra/llmath/llsimdmath.h
index 01458521ec..c7cdf7b32c 100644
--- a/indra/llmath/llsimdmath.h
+++ b/indra/llmath/llsimdmath.h
@@ -67,10 +67,11 @@ template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address)
 
 #define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16)
 
+
+
 #include <xmmintrin.h>
 #include <emmintrin.h>
 
-#include "llmemory.h"
 #include "llsimdtypes.h"
 #include "llsimdtypes.inl"
 
diff --git a/indra/llmath/llsimdtypes.inl b/indra/llmath/llsimdtypes.inl
index e905c84954..712239e425 100644
--- a/indra/llmath/llsimdtypes.inl
+++ b/indra/llmath/llsimdtypes.inl
@@ -62,7 +62,6 @@ inline LLSimdScalar operator/(const LLSimdScalar& a, const LLSimdScalar& b)
 inline LLSimdScalar operator-(const LLSimdScalar& a)
 {
 	static LL_ALIGN_16(const U32 signMask[4]) = {0x80000000, 0x80000000, 0x80000000, 0x80000000 };
-	ll_assert_aligned(signMask,16);
 	return _mm_xor_ps(*reinterpret_cast<const LLQuad*>(signMask), a);
 }
 
@@ -147,7 +146,6 @@ inline LLSimdScalar& LLSimdScalar::operator/=(const LLSimdScalar& rhs)
 inline LLSimdScalar LLSimdScalar::getAbs() const
 {
 	static const LL_ALIGN_16(U32 F_ABS_MASK_4A[4]) = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF };
-	ll_assert_aligned(F_ABS_MASK_4A,16);
 	return _mm_and_ps( mQ, *reinterpret_cast<const LLQuad*>(F_ABS_MASK_4A));
 }
 
diff --git a/indra/llmath/llvector4a.cpp b/indra/llmath/llvector4a.cpp
index 6edeb0fefe..b66b7a7076 100644
--- a/indra/llmath/llvector4a.cpp
+++ b/indra/llmath/llvector4a.cpp
@@ -24,7 +24,6 @@
  * $/LicenseInfo$
  */
 
-#include "llmemory.h"
 #include "llmath.h"
 #include "llquantize.h"
 
@@ -45,10 +44,7 @@ extern const LLVector4a LL_V4A_EPSILON = reinterpret_cast<const LLVector4a&> ( F
 	assert(dst != NULL);
 	assert(bytes > 0);
 	assert((bytes % sizeof(F32))== 0); 
-	ll_assert_aligned(src,16);
-	ll_assert_aligned(dst,16);
-	assert(bytes%16==0);
-
+	
 	F32* end = dst + (bytes / sizeof(F32) );
 
 	if (bytes > 64)
@@ -193,8 +189,6 @@ void LLVector4a::quantize16( const LLVector4a& low, const LLVector4a& high )
 		LLVector4a oneOverDelta;
 		{
 			static LL_ALIGN_16( const F32 F_TWO_4A[4] ) = { 2.f, 2.f, 2.f, 2.f };
-			ll_assert_aligned(F_TWO_4A,16);
-			
 			LLVector4a two; two.load4a( F_TWO_4A );
 
 			// Here we use _mm_rcp_ps plus one round of newton-raphson
diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h
index 0526793d3a..596082509d 100644
--- a/indra/llmath/llvector4a.h
+++ b/indra/llmath/llvector4a.h
@@ -32,7 +32,6 @@ class LLRotation;
 
 #include <assert.h>
 #include "llpreprocessor.h"
-#include "llmemory.h"
 
 ///////////////////////////////////
 // FIRST TIME USERS PLEASE READ
@@ -47,7 +46,6 @@ class LLRotation;
 // LLVector3/LLVector4. 
 /////////////////////////////////
 
-LL_ALIGN_PREFIX(16)
 class LLVector4a
 {
 public:
@@ -84,7 +82,6 @@ public:
 	}
 
 	// Copy words 16-byte blocks from src to dst. Source and destination must not overlap. 
-	// Source and dest must be 16-byte aligned and size must be multiple of 16.
 	static void memcpyNonAliased16(F32* __restrict dst, const F32* __restrict src, size_t bytes);
 
 	////////////////////////////////////
@@ -93,7 +90,6 @@ public:
 	
 	LLVector4a()
 	{ //DO NOT INITIALIZE -- The overhead is completely unnecessary
-		ll_assert_aligned(this,16);
 	}
 	
 	LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f)
@@ -317,7 +313,7 @@ public:
 
 private:
 	LLQuad mQ;
-} LL_ALIGN_POSTFIX(16);
+};
 
 inline void update_min_max(LLVector4a& min, LLVector4a& max, const LLVector4a& p)
 {
diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl
index 7c52ffef21..7ad22a5631 100644
--- a/indra/llmath/llvector4a.inl
+++ b/indra/llmath/llvector4a.inl
@@ -475,7 +475,6 @@ inline void LLVector4a::setLerp(const LLVector4a& lhs, const LLVector4a& rhs, F3
 inline LLBool32 LLVector4a::isFinite3() const
 {
 	static LL_ALIGN_16(const U32 nanOrInfMask[4]) = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 };
-	ll_assert_aligned(nanOrInfMask,16);
 	const __m128i nanOrInfMaskV = *reinterpret_cast<const __m128i*> (nanOrInfMask);
 	const __m128i maskResult = _mm_and_si128( _mm_castps_si128(mQ), nanOrInfMaskV );
 	const LLVector4Logical equalityCheck = _mm_castsi128_ps(_mm_cmpeq_epi32( maskResult, nanOrInfMaskV ));
diff --git a/indra/llmath/llvector4logical.h b/indra/llmath/llvector4logical.h
index c5698f7cea..dd66b09d43 100644
--- a/indra/llmath/llvector4logical.h
+++ b/indra/llmath/llvector4logical.h
@@ -27,7 +27,6 @@
 #ifndef	LL_VECTOR4LOGICAL_H
 #define	LL_VECTOR4LOGICAL_H
 
-#include "llmemory.h"
 
 ////////////////////////////
 // LLVector4Logical
@@ -78,7 +77,6 @@ public:
 	inline LLVector4Logical& invert()
 	{
 		static const LL_ALIGN_16(U32 allOnes[4]) = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
-		ll_assert_aligned(allOnes,16);
 		mQ = _mm_andnot_ps( mQ, *(LLQuad*)(allOnes) );
 		return *this;
 	}
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 53d56e96da..cc9744756f 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -95,6 +95,17 @@ const S32 SCULPT_MIN_AREA_DETAIL = 1;
 
 extern BOOL gDebugGL;
 
+void assert_aligned(void* ptr, uintptr_t alignment)
+{
+#if 0
+	uintptr_t t = (uintptr_t) ptr;
+	if (t%alignment != 0)
+	{
+		llerrs << "Alignment check failed." << llendl;
+	}
+#endif
+}
+
 BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
 {    
 	LLVector3 test = (pt2-pt1)%(pt3-pt2);
@@ -317,16 +328,16 @@ public:
 		LLVector4a& min = node->mExtents[0];
 		LLVector4a& max = node->mExtents[1];
 
-		if (!branch->isEmpty())
+		if (!branch->getData().empty())
 		{ //node has data, find AABB that binds data set
-			const LLVolumeTriangle* tri = *(branch->getDataBegin());
+			const LLVolumeTriangle* tri = *(branch->getData().begin());
 			
 			//initialize min/max to first available vertex
 			min = *(tri->mV[0]);
 			max = *(tri->mV[0]);
 			
 			for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = 
-				branch->getDataBegin(); iter != branch->getDataEnd(); ++iter)
+				branch->getData().begin(); iter != branch->getData().end(); ++iter)
 			{ //for each triangle in node
 
 				//stretch by triangles in node
@@ -341,7 +352,7 @@ public:
 				max.setMax(max, *tri->mV[2]);
 			}
 		}
-		else if (!branch->isLeaf())
+		else if (!branch->getChildren().empty())
 		{ //no data, but child nodes exist
 			LLVolumeOctreeListener* child = (LLVolumeOctreeListener*) branch->getChild(0)->getListener(0);
 
@@ -6951,14 +6962,14 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
 	if (num_verts)
 	{
 		mPositions = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts);
-		ll_assert_aligned(mPositions, 16);
+		assert_aligned(mPositions, 16);
 		mNormals = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts);
-		ll_assert_aligned(mNormals, 16);
+		assert_aligned(mNormals, 16);
 
 		//pad texture coordinate block end to allow for QWORD reads
 		S32 size = ((num_verts*sizeof(LLVector2)) + 0xF) & ~0xF;
 		mTexCoords = (LLVector2*) ll_aligned_malloc_16(size);
-		ll_assert_aligned(mTexCoords, 16);
+		assert_aligned(mTexCoords, 16);
 	}
 	else
 	{
@@ -6982,17 +6993,14 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 //	S32 old_size = mNumVertices*16;
 
 	//positions
-	mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_size);
-	ll_assert_aligned(mPositions,16);
+	mPositions = (LLVector4a*) realloc(mPositions, new_size);
 	
 	//normals
-	mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_size);
-	ll_assert_aligned(mNormals,16);
-
+	mNormals = (LLVector4a*) realloc(mNormals, new_size);
+	
 	//tex coords
 	new_size = ((new_verts*8)+0xF) & ~0xF;
-	mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, new_size);
-	ll_assert_aligned(mTexCoords,16);
+	mTexCoords = (LLVector2*) realloc(mTexCoords, new_size);
 	
 
 	//just clear binormals
@@ -7045,8 +7053,7 @@ void LLVolumeFace::pushIndex(const U16& idx)
 	S32 old_size = ((mNumIndices*2)+0xF) & ~0xF;
 	if (new_size != old_size)
 	{
-		mIndices = (U16*) ll_aligned_realloc_16(mIndices, new_size);
-		ll_assert_aligned(mIndices,16);
+		mIndices = (U16*) realloc(mIndices, new_size);
 	}
 	
 	mIndices[mNumIndices++] = idx;
@@ -7087,12 +7094,12 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	}
 
 	//allocate new buffer space
-	mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_count*sizeof(LLVector4a));
-	ll_assert_aligned(mPositions, 16);
-	mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_count*sizeof(LLVector4a));
-	ll_assert_aligned(mNormals, 16);
-	mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, (new_count*sizeof(LLVector2)+0xF) & ~0xF);
-	ll_assert_aligned(mTexCoords, 16);
+	mPositions = (LLVector4a*) realloc(mPositions, new_count*sizeof(LLVector4a));
+	assert_aligned(mPositions, 16);
+	mNormals = (LLVector4a*) realloc(mNormals, new_count*sizeof(LLVector4a));
+	assert_aligned(mNormals, 16);
+	mTexCoords = (LLVector2*) realloc(mTexCoords, (new_count*sizeof(LLVector2)+0xF) & ~0xF);
+	assert_aligned(mTexCoords, 16);
 	
 	mNumVertices = new_count;
 
@@ -7138,7 +7145,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	new_count = mNumIndices + face.mNumIndices;
 
 	//allocate new index buffer
-	mIndices = (U16*) ll_aligned_realloc_16(mIndices, (new_count*sizeof(U16)+0xF) & ~0xF);
+	mIndices = (U16*) realloc(mIndices, (new_count*sizeof(U16)+0xF) & ~0xF);
 	
 	//get destination address into new index buffer
 	U16* dst_idx = mIndices+mNumIndices;
diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp
index cc83cb7235..b5a935c2b5 100644
--- a/indra/llmath/llvolumeoctree.cpp
+++ b/indra/llmath/llvolumeoctree.cpp
@@ -131,7 +131,7 @@ void LLOctreeTriangleRayIntersect::traverse(const LLOctreeNode<LLVolumeTriangle>
 void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode<LLVolumeTriangle>* node)
 {
 	for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = 
-			node->getDataBegin(); iter != node->getDataEnd(); ++iter)
+			node->getData().begin(); iter != node->getData().end(); ++iter)
 	{
 		const LLVolumeTriangle* tri = *iter;
 
@@ -236,8 +236,8 @@ void LLVolumeOctreeValidate::visit(const LLOctreeNode<LLVolumeTriangle>* branch)
 	}
 
 	//children fit, check data
-	for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getDataBegin(); 
-			iter != branch->getDataEnd(); ++iter)
+	for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getData().begin(); 
+			iter != branch->getData().end(); ++iter)
 	{
 		const LLVolumeTriangle* tri = *iter;
 
diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h
index 9ae34a0c4e..688d91dc40 100644
--- a/indra/llmath/llvolumeoctree.h
+++ b/indra/llmath/llvolumeoctree.h
@@ -37,19 +37,9 @@
 class LLVolumeTriangle : public LLRefCount
 {
 public:
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 	LLVolumeTriangle()
 	{
-		mBinIndex = -1;	
+		
 	}
 
 	LLVolumeTriangle(const LLVolumeTriangle& rhs)
@@ -68,38 +58,21 @@ public:
 	
 	}
 
-	LL_ALIGN_16(LLVector4a mPositionGroup);
+	LLVector4a mPositionGroup;
 
 	const LLVector4a* mV[3];
 	U16 mIndex[3];
 
 	F32 mRadius;
-	mutable S32 mBinIndex;
-
 
 	virtual const LLVector4a& getPositionGroup() const;
 	virtual const F32& getBinRadius() const;
-	
-	S32 getBinIndex() const { return mBinIndex; }
-	void setBinIndex(S32 idx) const { mBinIndex = idx; }
-
-
 };
 
 class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeTriangle>
 {
 public:
 	
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 	LLVolumeOctreeListener(LLOctreeNode<LLVolumeTriangle>* node);
 	~LLVolumeOctreeListener();
 	
@@ -126,8 +99,8 @@ public:
 	
 
 public:
-	LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects)
-	LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
+	LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LLVector4a mExtents[2]; // extents (min, max) of this node and all its children
 };
 
 class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle>
diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp
index f3f0007205..a16f5c7bf0 100644
--- a/indra/llmessage/llurlrequest.cpp
+++ b/indra/llmessage/llurlrequest.cpp
@@ -289,8 +289,6 @@ LLIOPipe::EStatus LLURLRequest::handleError(
 }
 
 static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST("URL Request");
-static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST_GET_RESULT("Get Result");
-static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform");
 
 // virtual
 LLIOPipe::EStatus LLURLRequest::process_impl(
@@ -360,6 +358,7 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
 	{
 		PUMP_DEBUG;
 		LLIOPipe::EStatus status = STATUS_BREAK;
+		static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform");
 		{
 			LLFastTimer t(FTM_URL_PERFORM);
 			if(!mDetail->mCurlRequest->wait())
@@ -372,6 +371,8 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
 		{
 			CURLcode result;
 
+			static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST_GET_RESULT("Get Result");
+
 			bool newmsg = false;
 			{
 				LLFastTimer t(FTM_PROCESS_URL_REQUEST_GET_RESULT);
diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp
index e338d4ec71..843c3bcc4b 100644
--- a/indra/llmessage/tests/llhttpclient_test.cpp
+++ b/indra/llmessage/tests/llhttpclient_test.cpp
@@ -258,7 +258,6 @@ namespace tut
 	void HTTPClientTestObject::test<1>()
 	{
 		LLHTTPClient::get(local_server, newResult());
-
 		runThePump();
 		ensureStatusOK();
 		ensure("result object wasn't destroyed", mResultDeleted);
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index dbd96673a1..0644d2638c 100644
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -1074,7 +1074,7 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
 			mAuthURL = message.getValue("url");
 			mAuthRealm = message.getValue("realm");
 			mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_AUTH_REQUEST);
-		}		
+		}
 		else if(message_name == "debug_message")
 		{
 			mDebugMessageText = message.getValue("message_text");
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 28ed051c55..cb32a510b8 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -1026,8 +1026,7 @@ void LLModel::setVolumeFaceData(
 
 	if (tc.get())
 	{
-		U32 tex_size = (num_verts*2*sizeof(F32)+0xF)&~0xF;
-		LLVector4a::memcpyNonAliased16((F32*) face.mTexCoords, (F32*) tc.get(), tex_size);
+		LLVector4a::memcpyNonAliased16((F32*) face.mTexCoords, (F32*) tc.get(), num_verts*2*sizeof(F32));
 	}
 	else
 	{
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index a842211764..659d3ca409 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -237,11 +237,9 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat)
 
 //----------------------------------------------------------------------------
 
-static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_STATS("Image Stats");
 // static
 void LLImageGL::updateStats(F32 current_time)
 {
-	LLFastTimer t(FTM_IMAGE_UPDATE_STATS);
 	sLastFrameTime = current_time;
 	sBoundTextureMemoryInBytes = sCurBoundTextureMemory;
 	sCurBoundTextureMemory = 0;
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index cc5c232380..99f0da330c 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -69,42 +69,6 @@ LLRenderTarget::~LLRenderTarget()
 	release();
 }
 
-void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt)
-{ 
-	//for accounting, get the number of pixels added/subtracted
-	S32 pix_diff = (resx*resy)-(mResX*mResY);
-		
-	mResX = resx;
-	mResY = resy;
-
-	for (U32 i = 0; i < mTex.size(); ++i)
-	{ //resize color attachments
-		gGL.getTexUnit(0)->bindManual(mUsage, mTex[i]);
-		LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false);
-		sBytesAllocated += pix_diff*4;
-	}
-
-	if (mDepth)
-	{ //resize depth attachment
-		if (mStencil)
-		{
-			//use render buffers where stencil buffers are in play
-			glBindRenderbuffer(GL_RENDERBUFFER, mDepth);
-			glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, mResX, mResY);
-			glBindRenderbuffer(GL_RENDERBUFFER, 0);
-		}
-		else
-		{
-			gGL.getTexUnit(0)->bindManual(mUsage, mDepth);
-			U32 internal_type = LLTexUnit::getInternalType(mUsage);
-			LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL, false);
-		}
-
-		sBytesAllocated += pix_diff*4;
-	}
-}
-	
-
 bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples)
 {
 	stop_glerror();
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h
index e1a51304f1..8360458840 100644
--- a/indra/llrender/llrendertarget.h
+++ b/indra/llrender/llrendertarget.h
@@ -57,6 +57,8 @@
 
 */
 
+class LLMultisampleBuffer;
+
 class LLRenderTarget
 {
 public:
@@ -72,12 +74,6 @@ public:
 	//multiple calls will release previously allocated resources
 	bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, bool use_fbo = false, S32 samples = 0);
 
-	//resize existing attachments to use new resolution and color format
-	// CAUTION: if the GL runs out of memory attempting to resize, this render target will be undefined
-	// DO NOT use for screen space buffers or for scratch space for an image that might be uploaded
-	// DO use for render targets that resize often and aren't likely to ruin someone's day if they break
-	void resize(U32 resx, U32 resy, U32 color_fmt);
-
 	//add color buffer attachment
 	//limit of 4 color attachments per render target
 	bool addColorAttachment(U32 color_fmt);
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index eadef93c89..80752231d7 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -38,6 +38,10 @@
 #include "llglslshader.h"
 #include "llmemory.h"
 
+#if LL_DARWIN
+#define LL_VBO_POOLING 1
+#else
+#endif
 //Next Highest Power Of Two
 //helper function, returns first number > v that is a power of 2, or v if v is already a power of 2
 U32 nhpo2(U32 v)
@@ -290,7 +294,6 @@ void LLVBOPool::seedPool()
 }
 
 
-
 void LLVBOPool::cleanup()
 {
 	U32 size = LL_VBO_BLOCK_SIZE;
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 3cd03f8641..c0a252637f 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1564,7 +1564,9 @@ set(PACKAGE ON CACHE BOOL
 if (WINDOWS)
     set_target_properties(${VIEWER_BINARY_NAME}
         PROPERTIES
-        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS ${TCMALLOC_LINK_FLAGS}"
+        # *TODO -reenable this once we get server usage sorted out
+        #LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS /INCLUDE:\"__tcmalloc\""
+        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS /INCLUDE:__tcmalloc "
         LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" /INCREMENTAL:NO"
         LINK_FLAGS_RELEASE "/FORCE:MULTIPLE /MAP\"secondlife-bin.MAP\" /OPT:REF"
         )
@@ -1583,7 +1585,7 @@ if (WINDOWS)
     # In the meantime, if you have any ideas on how to easily maintain one list, either here or in viewer_manifest.py
     # and have the build deps get tracked *please* tell me about it.
 
-    if(USE_TCMALLOC)
+    if(USE_GOOGLE_PERFTOOLS)
       # Configure a var for tcmalloc location, if used.
       # Note the need to specify multiple names explicitly.
       set(GOOGLE_PERF_TOOLS_SOURCE
@@ -1591,7 +1593,7 @@ if (WINDOWS)
         ${SHARED_LIB_STAGING_DIR}/RelWithDebInfo/libtcmalloc_minimal.dll
         ${SHARED_LIB_STAGING_DIR}/Debug/libtcmalloc_minimal-debug.dll
         )
-     endif(USE_TCMALLOC)
+     endif(USE_GOOGLE_PERFTOOLS)
 
 
     set(COPY_INPUT_DEPENDENCIES
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index cb69048c60..e8934d9a9e 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -89,7 +89,6 @@
 #include "lllogininstance.h"
 #include "llprogressview.h"
 #include "llvocache.h"
-#include "llvopartgroup.h"
 #include "llweb.h"
 #include "llsecondlifeurls.h"
 #include "llupdaterservice.h"
@@ -680,9 +679,6 @@ bool LLAppViewer::init()
 	// initialize SSE options
 	LLVector4a::initClass();
 
-	//initialize particle index pool
-	LLVOPartGroup::initClass();
-
 	// Need to do this initialization before we do anything else, since anything
 	// that touches files should really go through the lldir API
 	gDirUtilp->initAppDirs("SecondLife");
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 53c77fa22e..bad60a9757 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -130,8 +130,6 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 	// This results in a 2-3x improvement in opening a new Inventory window (which uses a large numebr of allocations)
 	// Note: This won't work when running from the debugger unless the _NO_DEBUG_HEAP environment variable is set to 1
 
-	// Enable to get mem debugging within visual studio.
-	//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
 	_CrtSetDbgFlag(0); // default, just making explicit
 	
 	ULONG ulEnableLFH = 2;
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 89a2e9f407..108ec92f6d 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -57,8 +57,6 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 
 static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
 
-extern bool gShiftFrame;
-
 
 ////////////////////////
 //
@@ -110,8 +108,6 @@ void LLDrawable::init()
 	
 	mGeneration = -1;
 	mBinRadius = 1.f;
-	mBinIndex = -1;
-
 	mSpatialBridge = NULL;
 }
 
@@ -718,11 +714,6 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 		return;
 	}
 
-	if (gShiftFrame)
-	{
-		return;
-	}
-
 	//switch LOD with the spatial group to avoid artifacts
 	//LLSpatialGroup* sg = getSpatialGroup();
 
@@ -820,19 +811,14 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 		mXform.setPosition(mVObjp->getPositionAgent());
 	}
 
+	mXform.setRotation(mVObjp->getRotation());
+	mXform.setScale(1,1,1);
 	mXform.updateMatrix();
 
 	if (isStatic())
 	{
 		LLVOVolume* volume = getVOVolume();
-
-		bool rebuild = (!volume && 
-						getRenderType() != LLPipeline::RENDER_TYPE_TREE &&
-						getRenderType() != LLPipeline::RENDER_TYPE_TERRAIN &&
-						getRenderType() != LLPipeline::RENDER_TYPE_SKY &&
-						getRenderType() != LLPipeline::RENDER_TYPE_GROUND);
-
-		if (rebuild)
+		if (!volume)
 		{
 			gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE);
 		}
@@ -846,7 +832,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 				facep->mExtents[0].add(shift_vector);
 				facep->mExtents[1].add(shift_vector);
 			
-				if (rebuild && facep->hasGeometry())
+				if (!volume && facep->hasGeometry())
 				{
 					facep->clearVertexBuffer();
 				}
@@ -957,12 +943,6 @@ void LLDrawable::updateUVMinMax()
 {
 }
 
-LLSpatialGroup* LLDrawable::getSpatialGroup() const
-{ 
-	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
-	return mSpatialGroupp; 
-}
-
 void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 {
 /*if (mSpatialGroupp && (groupp != mSpatialGroupp))
@@ -985,8 +965,6 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 	}
 
 	mSpatialGroupp = groupp;
-
-	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
 }
 
 LLSpatialPartition* LLDrawable::getSpatialPartition()
@@ -1109,8 +1087,6 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat
 	mDrawable = root;
 	root->setSpatialBridge(this);
 	
-	mBinIndex = -1;
-
 	mRenderType = mDrawable->mRenderType;
 	mDrawableType = mDrawable->mRenderType;
 	
@@ -1414,11 +1390,6 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 		markDead();
 		return;
 	}
-	
-	if (gShiftFrame)
-	{
-		return;
-	}
 
 	if (mDrawable->getVObj())
 	{
@@ -1497,13 +1468,7 @@ void LLSpatialBridge::cleanupReferences()
 	LLDrawable::cleanupReferences();
 	if (mDrawable)
 	{
-		LLSpatialGroup* group = mDrawable->getSpatialGroup();
-		if (group)
-		{
-			group->mOctreeNode->remove(mDrawable);
-			mDrawable->setSpatialGroup(NULL);
-		}
-		
+		mDrawable->setSpatialGroup(NULL);
 		if (mDrawable->getVObj())
 		{
 			LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren();
@@ -1514,12 +1479,7 @@ void LLSpatialBridge::cleanupReferences()
 				LLDrawable* drawable = child->mDrawable;					
 				if (drawable)
 				{
-					LLSpatialGroup* group = drawable->getSpatialGroup();
-					if (group)
-					{
-						group->mOctreeNode->remove(drawable);
-						drawable->setSpatialGroup(NULL);
-					}
+					drawable->setSpatialGroup(NULL);
 				}
 			}
 		}
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 960c64fa9e..e2064b79f8 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -59,7 +59,6 @@ class LLViewerTexture;
 const U32 SILHOUETTE_HIGHLIGHT = 0;
 
 // All data for new renderer goes into this class.
-LL_ALIGN_PREFIX(16)
 class LLDrawable : public LLRefCount
 {
 public:
@@ -76,16 +75,6 @@ public:
 
 	static void initClass();
 
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 	LLDrawable()				{ init(); }
 	MEM_TYPE_NEW(LLMemType::MTYPE_DRAWABLE);
 	
@@ -120,9 +109,6 @@ public:
 	F32			          getIntensity() const			{ return llmin(mXform.getScale().mV[0], 4.f); }
 	S32					  getLOD() const				{ return mVObjp ? mVObjp->getLOD() : 1; }
 	F32					  getBinRadius() const			{ return mBinRadius; }
-	S32					  getBinIndex() const			{ return mBinIndex; }
-	void				  setBinIndex(S32 index) const	{ mBinIndex = index; }
-
 	void  getMinMax(LLVector3& min,LLVector3& max) const { mXform.getMinMax(min,max); }
 	LLXformMatrix*		getXform() { return &mXform; }
 
@@ -208,7 +194,7 @@ public:
 	S32 findReferences(LLDrawable *drawablep); // Not const because of @#$! iterators...
 
 	void setSpatialGroup(LLSpatialGroup *groupp);
-	LLSpatialGroup *getSpatialGroup() const;
+	LLSpatialGroup *getSpatialGroup() const			{ return mSpatialGroupp; }
 	LLSpatialPartition* getSpatialPartition();
 	
 	// Statics
@@ -295,8 +281,8 @@ public:
 	} EDrawableFlags;
 
 private: //aligned members
-	LL_ALIGN_16(LLVector4a		mExtents[2]);
-	LL_ALIGN_16(LLVector4a		mPositionGroup);
+	LLVector4a		mExtents[2];
+	LLVector4a		mPositionGroup;
 	
 public:
 	LLXformMatrix       mXform;
@@ -329,7 +315,6 @@ private:
 	mutable U32		mVisible;
 	F32				mRadius;
 	F32				mBinRadius;
-	mutable S32		mBinIndex;
 	S32				mGeneration;
 	
 	LLVector3		mCurrentScale;
@@ -338,7 +323,7 @@ private:
 
 	static U32 sNumZombieDrawables;
 	static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList;
-} LL_ALIGN_POSTFIX(16);
+};
 
 
 inline LLFace* LLDrawable::getFace(const S32 i) const
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index 013c698445..81f4e3d48f 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -254,6 +254,48 @@ void LLFacePool::dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures
 {
 }
 
+// static
+S32 LLFacePool::drawLoop(face_array_t& face_list)
+{
+	S32 res = 0;
+	if (!face_list.empty())
+	{
+		for (std::vector<LLFace*>::iterator iter = face_list.begin();
+			 iter != face_list.end(); iter++)
+		{
+			LLFace *facep = *iter;
+			res += facep->renderIndexed();
+		}
+	}
+	return res;
+}
+
+// static
+S32 LLFacePool::drawLoopSetTex(face_array_t& face_list, S32 stage)
+{
+	S32 res = 0;
+	if (!face_list.empty())
+	{
+		for (std::vector<LLFace*>::iterator iter = face_list.begin();
+			 iter != face_list.end(); iter++)
+		{
+			LLFace *facep = *iter;
+			gGL.getTexUnit(stage)->bind(facep->getTexture(), TRUE) ;
+			gGL.getTexUnit(0)->activate();
+			res += facep->renderIndexed();
+		}
+	}
+	return res;
+}
+
+void LLFacePool::drawLoop()
+{
+	if (!mDrawFace.empty())
+	{
+		drawLoop(mDrawFace);
+	}
+}
+
 void LLFacePool::enqueue(LLFace* facep)
 {
 	mDrawFace.push_back(facep);
@@ -401,7 +443,7 @@ void LLRenderPass::renderTexture(U32 type, U32 mask)
 
 void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures)
 {
-	for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i)	
+	for (LLCullResult::drawinfo_list_t::iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i)	
 	{
 		LLDrawInfo* pparams = *i;
 		if (pparams) 
diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index ab9bb9e611..977acf7aec 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -190,6 +190,10 @@ public:
 
 	void buildEdges();
 
+	static S32 drawLoop(face_array_t& face_list);
+	static S32 drawLoopSetTex(face_array_t& face_list, S32 stage);
+	void drawLoop();
+
 	void addFaceReference(LLFace *facep);
 	void removeFaceReference(LLFace *facep);
 
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index b4f6bf9383..5f2a982ed3 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -348,7 +348,7 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask)
 {
-	for (LLCullResult::sg_iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
+	for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		if (group->mSpatialPartition->mRenderByGroup &&
@@ -385,7 +385,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 	
 	BOOL use_shaders = gPipeline.canUseVertexShaders();
 		
-	for (LLCullResult::sg_iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
+	for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		llassert(group);
@@ -411,12 +411,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 					continue;
 				}
 
-				if ((params.mVertexBuffer->getTypeMask() & mask) != mask)
-				{ //FIXME!
-					llwarns << "Missing required components, skipping render batch." << llendl;
-					continue;
-				}
-
 				LLRenderPass::applyModelMatrix(params);
 
 				
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 730ad1a364..ace3a20bbb 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1036,13 +1036,9 @@ void LLDrawPoolAvatar::endDeferredSkinned()
 	gGL.getTexUnit(0)->activate();
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_AVATARS("renderAvatars");
-
 
 void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_AVATARS);
-
 	if (pass == -1)
 	{
 		for (S32 i = 1; i < getNumPasses(); i++)
@@ -1199,6 +1195,15 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 
 	if (pass >= 7 && pass < 9)
 	{
+		LLGLEnable blend(GL_BLEND);
+
+		gGL.setColorMask(true, true);
+		gGL.blendFunc(LLRender::BF_SOURCE_ALPHA,
+					  LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
+					  LLRender::BF_ZERO,
+					  LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
+
+		
 		if (pass == 7)
 		{
 			renderRiggedAlpha(avatarp);
@@ -1214,8 +1219,20 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 
 	if (pass == 9)
 	{
+		LLGLEnable blend(GL_BLEND);
+		LLGLDisable test(GL_ALPHA_TEST);
+		gGL.flush();
+
+		LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
+		glPolygonOffset(-1.0f, -1.0f);
+		gGL.setSceneBlendType(LLRender::BT_ADD);
+
+		LLGLDepthTest depth(GL_TRUE, GL_FALSE);
+		gGL.setColorMask(false, true);
+
 		renderRiggedGlow(avatarp);
-		
+		gGL.setColorMask(true, false);
+		gGL.setSceneBlendType(LLRender::BT_ALPHA);
 		return;
 	}
 	
@@ -1413,7 +1430,7 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace*
 
 void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 {
-	if (avatar->isSelf() && !gAgent.needsRenderAvatar())
+	if (avatar->isSelf() && !gAgent.needsRenderAvatar() || !gMeshRepo.meshRezEnabled())
 	{
 		return;
 	}
@@ -1542,12 +1559,8 @@ void LLDrawPoolAvatar::renderDeferredRiggedBump(LLVOAvatar* avatar)
 	renderRigged(avatar, RIGGED_DEFERRED_BUMP);
 }
 
-static LLFastTimer::DeclareTimer FTM_RIGGED_VBO("Rigged VBO");
-
 void LLDrawPoolAvatar::updateRiggedVertexBuffers(LLVOAvatar* avatar)
 {
-	LLFastTimer t(FTM_RIGGED_VBO);
-
 	//update rigged vertex buffers
 	for (U32 type = 0; type < NUM_RIGGED_PASSES; ++type)
 	{
@@ -1619,56 +1632,17 @@ void LLDrawPoolAvatar::renderRiggedFullbrightShiny(LLVOAvatar* avatar)
 
 void LLDrawPoolAvatar::renderRiggedAlpha(LLVOAvatar* avatar)
 {
-	if (!mRiggedFace[RIGGED_ALPHA].empty())
-	{
-		LLGLEnable blend(GL_BLEND);
-
-		gGL.setColorMask(true, true);
-		gGL.blendFunc(LLRender::BF_SOURCE_ALPHA,
-						LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
-						LLRender::BF_ZERO,
-						LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
-
-		renderRigged(avatar, RIGGED_ALPHA);
-	}
+	renderRigged(avatar, RIGGED_ALPHA);
 }
 
 void LLDrawPoolAvatar::renderRiggedFullbrightAlpha(LLVOAvatar* avatar)
 {
-	if (!mRiggedFace[RIGGED_FULLBRIGHT_ALPHA].empty())
-	{
-		LLGLEnable blend(GL_BLEND);
-
-		gGL.setColorMask(true, true);
-		gGL.blendFunc(LLRender::BF_SOURCE_ALPHA,
-						LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
-						LLRender::BF_ZERO,
-						LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
-
-		renderRigged(avatar, RIGGED_FULLBRIGHT_ALPHA);
-	}
+	renderRigged(avatar, RIGGED_FULLBRIGHT_ALPHA);
 }
 
 void LLDrawPoolAvatar::renderRiggedGlow(LLVOAvatar* avatar)
 {
-	if (!mRiggedFace[RIGGED_GLOW].empty())
-	{
-		LLGLEnable blend(GL_BLEND);
-		LLGLDisable test(GL_ALPHA_TEST);
-		gGL.flush();
-
-		LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
-		glPolygonOffset(-1.0f, -1.0f);
-		gGL.setSceneBlendType(LLRender::BT_ADD);
-
-		LLGLDepthTest depth(GL_TRUE, GL_FALSE);
-		gGL.setColorMask(false, true);
-
-		renderRigged(avatar, RIGGED_GLOW, true);
-
-		gGL.setColorMask(true, false);
-		gGL.setSceneBlendType(LLRender::BT_ALPHA);
-	}
+	renderRigged(avatar, RIGGED_GLOW, true);
 }
 
 
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index a264eae302..6f71e6ebc8 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -847,12 +847,12 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
 	LLFastTimer ftm(FTM_RENDER_BUMP);
 
 	U32 type = LLRenderPass::PASS_BUMP;
-	LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type);
-	LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type);
+	LLCullResult::drawinfo_list_t::iterator begin = gPipeline.beginRenderMap(type);
+	LLCullResult::drawinfo_list_t::iterator end = gPipeline.endRenderMap(type);
 
 	U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_BINORMAL | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_COLOR;
 	
-	for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i)	
+	for (LLCullResult::drawinfo_list_t::iterator i = begin; i != end; ++i)	
 	{
 		LLDrawInfo& params = **i;
 
@@ -1448,10 +1448,10 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 
 void LLDrawPoolBump::renderBump(U32 type, U32 mask)
 {	
-	LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type);
-	LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type);
+	LLCullResult::drawinfo_list_t::iterator begin = gPipeline.beginRenderMap(type);
+	LLCullResult::drawinfo_list_t::iterator end = gPipeline.endRenderMap(type);
 
-	for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i)	
+	for (LLCullResult::drawinfo_list_t::iterator i = begin; i != end; ++i)	
 	{
 		LLDrawInfo& params = **i;
 
diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp
index 7fc78fb382..b95d8296fa 100644
--- a/indra/newview/lldrawpoolterrain.cpp
+++ b/indra/newview/lldrawpoolterrain.cpp
@@ -294,34 +294,6 @@ void LLDrawPoolTerrain::renderShadow(S32 pass)
 	//glCullFace(GL_BACK);
 }
 
-
-void LLDrawPoolTerrain::drawLoop()
-{
-	if (!mDrawFace.empty())
-	{
-		for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-			 iter != mDrawFace.end(); iter++)
-		{
-			LLFace *facep = *iter;
-
-			LLMatrix4* model_matrix = &(facep->getDrawable()->getRegion()->mRenderMatrix);
-
-			if (model_matrix != gGLLastMatrix)
-			{
-				gGLLastMatrix = model_matrix;
-				gGL.loadMatrix(gGLModelView);
-				if (model_matrix)
-				{
-					gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
-				}
-				gPipeline.mMatrixOpCount++;
-			}
-
-			facep->renderIndexed();
-		}
-	}
-}
-
 void LLDrawPoolTerrain::renderFullShader()
 {
 	// Hack! Get the region that this draw pool is rendering from!
diff --git a/indra/newview/lldrawpoolterrain.h b/indra/newview/lldrawpoolterrain.h
index 2163d087e1..283ed87f1a 100644
--- a/indra/newview/lldrawpoolterrain.h
+++ b/indra/newview/lldrawpoolterrain.h
@@ -83,7 +83,6 @@ protected:
 	void renderFull2TU();
 	void renderFull4TU();
 	void renderFullShader();
-	void drawLoop();
 };
 
 #endif // LL_LLDRAWPOOLSIMPLE_H
diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp
index 83f04e45a8..3165a3516c 100644
--- a/indra/newview/lldrawpooltree.cpp
+++ b/indra/newview/lldrawpooltree.cpp
@@ -37,7 +37,6 @@
 #include "llviewershadermgr.h"
 #include "llrender.h"
 #include "llviewercontrol.h"
-#include "llviewerregion.h"
 
 S32 LLDrawPoolTree::sDiffTex = 0;
 static LLGLSLShader* shader = NULL;
@@ -105,22 +104,8 @@ void LLDrawPoolTree::render(S32 pass)
 	{
 		LLFace *face = *iter;
 		LLVertexBuffer* buff = face->getVertexBuffer();
-
 		if(buff)
 		{
-			LLMatrix4* model_matrix = &(face->getDrawable()->getRegion()->mRenderMatrix);
-
-			if (model_matrix != gGLLastMatrix)
-			{
-				gGLLastMatrix = model_matrix;
-				gGL.loadMatrix(gGLModelView);
-				if (model_matrix)
-				{
-					gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
-				}
-				gPipeline.mMatrixOpCount++;
-			}
-
 			buff->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
 			buff->drawRange(LLRender::TRIANGLES, 0, buff->getNumVerts()-1, buff->getNumIndices(), 0); 
 			gPipeline.addTrianglesDrawn(buff->getNumIndices());
diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp
index 885cae1737..64eb11fc9b 100644
--- a/indra/newview/lldriverparam.cpp
+++ b/indra/newview/lldriverparam.cpp
@@ -155,7 +155,6 @@ LLDriverParam::LLDriverParam(LLVOAvatar *avatarp) :
 	mAvatarp(avatarp), 
 	mWearablep(NULL)
 {
-	mDefaultVec.clear();
 }
 
 LLDriverParam::LLDriverParam(LLWearable *wearablep) : 
@@ -163,7 +162,6 @@ LLDriverParam::LLDriverParam(LLWearable *wearablep) :
 	mAvatarp(NULL), 
 	mWearablep(wearablep)
 {
-	mDefaultVec.clear();
 }
 
 LLDriverParam::~LLDriverParam()
@@ -343,19 +341,18 @@ F32	LLDriverParam::getTotalDistortion()
 	return sum; 
 }
 
-const LLVector4a	&LLDriverParam::getAvgDistortion()	
+const LLVector3	&LLDriverParam::getAvgDistortion()	
 {
 	// It's not actually correct to take the average of averages, but it good enough here.
-	LLVector4a sum;
-	sum.clear();
+	LLVector3 sum;
 	S32 count = 0;
 	for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
 	{
 		LLDrivenEntry* driven = &(*iter);
-		sum.add(driven->mParam->getAvgDistortion());
+		sum += driven->mParam->getAvgDistortion();
 		count++;
 	}
-	sum.mul( 1.f/(F32)count);
+	sum /= (F32)count;
 
 	mDefaultVec = sum;
 	return mDefaultVec; 
@@ -378,22 +375,21 @@ F32	LLDriverParam::getMaxDistortion()
 }
 
 
-LLVector4a	LLDriverParam::getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)
+LLVector3	LLDriverParam::getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)
 {
-	LLVector4a sum;
-	sum.clear();
+	LLVector3 sum;
 	for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
 	{
 		LLDrivenEntry* driven = &(*iter);
-		sum.add(driven->mParam->getVertexDistortion( index, poly_mesh ));
+		sum += driven->mParam->getVertexDistortion( index, poly_mesh );
 	}
 	return sum;
 }
 
-const LLVector4a*	LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
+const LLVector3*	LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
 {
 	mCurrentDistortionParam = NULL;
-	const LLVector4a* v = NULL;
+	const LLVector3* v = NULL;
 	for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
 	{
 		LLDrivenEntry* driven = &(*iter);
@@ -408,7 +404,7 @@ const LLVector4a*	LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **pol
 	return v;
 };
 
-const LLVector4a*	LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
+const LLVector3*	LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
 {
 	llassert( mCurrentDistortionParam );
 	if( !mCurrentDistortionParam )
@@ -436,7 +432,7 @@ const LLVector4a*	LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly
 	}
 
 	// We're already in the middle of a param's distortions, so get the next one.
-	const LLVector4a* v = driven->mParam->getNextDistortion( index, poly_mesh );
+	const LLVector3* v = driven->mParam->getNextDistortion( index, poly_mesh );
 	if( (!v) && (iter != mDriven.end()) )
 	{
 		// This param is finished, so start the next param.  It might not have any
diff --git a/indra/newview/lldriverparam.h b/indra/newview/lldriverparam.h
index 7a4d711d4e..fb1b44458c 100644
--- a/indra/newview/lldriverparam.h
+++ b/indra/newview/lldriverparam.h
@@ -105,18 +105,18 @@ public:
 	
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion();
-	/*virtual*/ const LLVector4a&	getAvgDistortion();
+	/*virtual*/ const LLVector3&	getAvgDistortion();
 	/*virtual*/ F32					getMaxDistortion();
-	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
-	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
-	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
+	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
+	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
+	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
 
 protected:
 	F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight);
 	void setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake);
 
 
-	LLVector4a	mDefaultVec; // temp holder
+	LLVector3	mDefaultVec; // temp holder
 	typedef std::vector<LLDrivenEntry> entry_list_t;
 	entry_list_t mDriven;
 	LLViewerVisualParam* mCurrentDistortionParam;
diff --git a/indra/newview/lldynamictexture.h b/indra/newview/lldynamictexture.h
index c51e7d1e1a..e18090545d 100644
--- a/indra/newview/lldynamictexture.h
+++ b/indra/newview/lldynamictexture.h
@@ -36,16 +36,6 @@
 class LLViewerDynamicTexture : public LLViewerTexture
 {
 public:
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 	enum
 	{
 		LL_VIEWER_DYNAMIC_TEXTURE = LLViewerTexture::DYNAMIC_TEXTURE,
@@ -95,7 +85,7 @@ protected:
 protected:
 	BOOL mClamp;
 	LLCoordGL mOrigin;
-	LL_ALIGN_16(LLCamera mCamera);
+	LLCamera mCamera;
 	
 	typedef std::set<LLViewerDynamicTexture*> instance_list_t;
 	static instance_list_t sInstances[ LLViewerDynamicTexture::ORDER_COUNT ];
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 8d0664770b..373b1930f5 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -163,10 +163,16 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
 	mGeomCount		= 0;
 	mGeomIndex		= 0;
 	mIndicesCount	= 0;
-
-	//special value to indicate uninitialized position
-	mIndicesIndex	= 0xFFFFFFFF;
-
+	if (drawablep->getRenderType() == LLPipeline::RENDER_TYPE_PARTICLES ||
+		drawablep->getRenderType() == LLPipeline::RENDER_TYPE_HUD_PARTICLES)
+	{ //indicate to LLParticlePartition that this particle is uninitialized
+		mIndicesIndex = 0xFFFFFFFF;
+	}
+	else
+	{
+		mIndicesIndex	= 0;
+	}
+	mIndexInTex = 0;
 	mTexture		= NULL;
 	mTEOffset		= -1;
 	mTextureIndex = 255;
@@ -201,10 +207,13 @@ void LLFace::destroy()
 		mTexture->removeFace(this) ;
 	}
 	
-	if (isState(LLFace::PARTICLE))
+	if (mDrawablep.notNull() &&
+		(mDrawablep->getRenderType() == LLPipeline::RENDER_TYPE_PARTICLES ||
+		mDrawablep->getRenderType() == LLPipeline::RENDER_TYPE_HUD_PARTICLES) &&
+		mIndicesIndex != 0xFFFFFFFF)
 	{
 		LLVOPartGroup::freeVBSlot(getGeomIndex()/4);
-		clearState(LLFace::PARTICLE);
+		mIndicesIndex = 0xFFFFFFFF;
 	}
 
 	if (mDrawPoolp)
@@ -1198,25 +1207,19 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	{
 		if (num_indices + (S32) mIndicesIndex > mVertexBuffer->getNumIndices())
 		{
-			if (gDebugGL)
-			{
-				llwarns	<< "Index buffer overflow!" << llendl;
-				llwarns << "Indices Count: " << mIndicesCount
-						<< " VF Num Indices: " << num_indices
-						<< " Indices Index: " << mIndicesIndex
-						<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
-				llwarns	<< " Face Index: " << f
-						<< " Pool Type: " << mPoolType << llendl;
-			}
+			llwarns	<< "Index buffer overflow!" << llendl;
+			llwarns << "Indices Count: " << mIndicesCount
+					<< " VF Num Indices: " << num_indices
+					<< " Indices Index: " << mIndicesIndex
+					<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
+			llwarns	<< " Face Index: " << f
+					<< " Pool Type: " << mPoolType << llendl;
 			return FALSE;
 		}
 
 		if (num_vertices + mGeomIndex > mVertexBuffer->getNumVerts())
 		{
-			if (gDebugGL)
-			{
-				llwarns << "Vertex buffer overflow!" << llendl;
-			}
+			llwarns << "Vertex buffer overflow!" << llendl;
 			return FALSE;
 		}
 	}
@@ -1648,8 +1651,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 						if (!do_xform)
 						{
 							LLFastTimer t(FTM_FACE_TEX_QUICK_NO_XFORM);
-							S32 tc_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF;
-							LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, tc_size);
+							LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, num_vertices*2*sizeof(F32));
 						}
 						else
 						{
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index efc3424858..76ea5c853a 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -59,17 +59,6 @@ class LLFace
 {
 public:
 
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
-
 	LLFace(const LLFace& rhs)
 	{
 		*this = rhs;
@@ -90,7 +79,6 @@ public:
 		USE_FACE_COLOR	= 0x0010,
 		TEXTURE_ANIM	= 0x0020, 
 		RIGGED			= 0x0040,
-		PARTICLE		= 0x0080,
 	};
 
 	static void initClass();
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 9745bb6d64..3d64ceb71d 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -65,7 +65,7 @@ LLVolumeImplFlexible::LLVolumeImplFlexible(LLViewerObject* vo, LLFlexibleObjectD
 	mFrameNum = 0;
 	mCollisionSphereRadius = 0.f;
 	mRenderRes = 1;
-	
+
 	if(mVO->mDrawable.notNull())
 	{
 		mVO->mDrawable->makeActive() ;
@@ -255,28 +255,50 @@ void LLVolumeImplFlexible::onSetVolume(const LLVolumeParams &volume_params, cons
 {
 }
 
-
-void LLVolumeImplFlexible::updateRenderRes()
+//---------------------------------------------------------------------------------
+// This calculates the physics of the flexible object. Note that it has to be 0
+// updated every time step. In the future, perhaps there could be an 
+// optimization similar to what Havok does for objects that are stationary. 
+//---------------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_FLEXIBLE_UPDATE("Update Flexies");
+BOOL LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
-	LLDrawable* drawablep = mVO->mDrawable;
+	if (mVO->mDrawable.isNull())
+	{
+		// Don't do anything until we have a drawable
+		return FALSE; // (we are not initialized or updated)
+	}
 
-	S32 new_res = mAttributes->getSimulateLOD();
+	BOOL force_update = mSimulateRes == 0 ? TRUE : FALSE;
 
-#if 1 //optimal approximation of previous behavior that doesn't rely on atan2
-	F32 app_angle = mVO->getScale().mV[2]/drawablep->mDistanceWRTCamera;
+	//flexible objects never go static
+	mVO->mDrawable->mQuietCount = 0;
+	if (!mVO->mDrawable->isRoot())
+	{
+		LLViewerObject* parent = (LLViewerObject*) mVO->getParent();
+		parent->mDrawable->mQuietCount = 0;
+	}
+
+	LLFastTimer ftm(FTM_FLEXIBLE_UPDATE);
+		
+	S32 new_res = mAttributes->getSimulateLOD();
 
-	// Rendering sections increases with visible angle on the screen
-	mRenderRes = (S32) (12.f*app_angle);
-#else //legacy behavior
 	//number of segments only cares about z axis
-	F32 app_angle = llround((F32) atan2( mVO->getScale().mV[2]*2.f, drawablep->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f);
+	F32 app_angle = llround((F32) atan2( mVO->getScale().mV[2]*2.f, mVO->mDrawable->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f);
 
- 	// Rendering sections increases with visible angle on the screen
+	// Rendering sections increases with visible angle on the screen
 	mRenderRes = (S32)(FLEXIBLE_OBJECT_MAX_SECTIONS*4*app_angle*DEG_TO_RAD/LLViewerCamera::getInstance()->getView());
-#endif
-		
-	mRenderRes = llclamp(mRenderRes, new_res-1, (S32) FLEXIBLE_OBJECT_MAX_SECTIONS);
-		
+	if (mRenderRes > FLEXIBLE_OBJECT_MAX_SECTIONS)
+	{
+		mRenderRes = FLEXIBLE_OBJECT_MAX_SECTIONS;
+	}
+
+
+	// Bottom cap at 1/4 the original number of sections
+	if (mRenderRes < mAttributes->getSimulateLOD()-1)
+	{
+		mRenderRes = mAttributes->getSimulateLOD()-1;
+	}
 	// Throttle back simulation of segments we're not rendering
 	if (mRenderRes < new_res)
 	{
@@ -289,65 +311,43 @@ void LLVolumeImplFlexible::updateRenderRes()
 		setAttributesOfAllSections();
 		mInitialized = TRUE;
 	}
-}
-//---------------------------------------------------------------------------------
-// This calculates the physics of the flexible object. Note that it has to be 0
-// updated every time step. In the future, perhaps there could be an 
-// optimization similar to what Havok does for objects that are stationary. 
-//---------------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_FLEXIBLE_UPDATE("Update Flexies");
-void LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
-{
-	LLDrawable* drawablep = mVO->mDrawable;
+	if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE))
+	{
+		return FALSE; // (we are not initialized or updated)
+	}
+
+	bool visible = mVO->mDrawable->isVisible();
 
-	if (drawablep)
+	if (force_update && visible)
+	{
+		gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_POSITION, FALSE);
+	}
+	else if	(visible &&
+		!mVO->mDrawable->isState(LLDrawable::IN_REBUILD_Q1) &&
+		mVO->getPixelArea() > 256.f)
 	{
-		//LLFastTimer ftm(FTM_FLEXIBLE_UPDATE);
+		U32 id;
+		F32 pixel_area = mVO->getPixelArea();
 
-		//flexible objects never go static
-		drawablep->mQuietCount = 0;
-		if (!drawablep->isRoot())
+		if (mVO->isRootEdit())
 		{
-			LLViewerObject* parent = (LLViewerObject*) mVO->getParent();
-			parent->mDrawable->mQuietCount = 0;
+			id = mID;
 		}
-
-		if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE))
+		else
 		{
-			bool visible = drawablep->isVisible();
-
-			if ((mSimulateRes == 0) && visible)
-			{
-				updateRenderRes();
-				gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE);
-			}
-			else if	(visible &&
-				!drawablep->isState(LLDrawable::IN_REBUILD_Q1) &&
-				mVO->getPixelArea() > 256.f)
-			{
-				U32 id;
-				F32 pixel_area = mVO->getPixelArea();
-
-				if (mVO->isRootEdit())
-				{
-					id = mID;
-				}
-				else
-				{
-					LLVOVolume* parent = (LLVOVolume*) mVO->getParent();
-					id = parent->getVolumeInterfaceID();
-				}
+			LLVOVolume* parent = (LLVOVolume*) mVO->getParent();
+			id = parent->getVolumeInterfaceID();
+		}
 
-				U32 update_period = (U32) (LLViewerCamera::getInstance()->getScreenPixelArea()*0.01f/(pixel_area*(sUpdateFactor+1.f)))+1;
+		U32 update_period = (U32) (LLViewerCamera::getInstance()->getScreenPixelArea()*0.01f/(pixel_area*(sUpdateFactor+1.f)))+1;
 
-				if ((LLDrawable::getCurrentFrame()+id)%update_period == 0)
-				{
-					updateRenderRes();
-					gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE);
-				}
-			}
+		if ((LLDrawable::getCurrentFrame()+id)%update_period == 0)
+		{
+			gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_POSITION, FALSE);
 		}
 	}
+	
+	return force_update;
 }
 
 inline S32 log2(S32 x)
diff --git a/indra/newview/llflexibleobject.h b/indra/newview/llflexibleobject.h
index 56d579d86f..371d6a0773 100644
--- a/indra/newview/llflexibleobject.h
+++ b/indra/newview/llflexibleobject.h
@@ -78,8 +78,7 @@ class LLVolumeImplFlexible : public LLVolumeInterface
 		LLVector3 getFramePosition() const;
 		LLQuaternion getFrameRotation() const;
 		LLVolumeInterfaceType getInterfaceType() const		{ return INTERFACE_FLEXIBLE; }
-		void updateRenderRes();
-		void doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
+		BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 		BOOL doUpdateGeometry(LLDrawable *drawable);
 		LLVector3 getPivotPosition() const;
 		void onSetVolume(const LLVolumeParams &volume_params, const S32 detail);
@@ -129,7 +128,7 @@ class LLVolumeImplFlexible : public LLVolumeInterface
 		LLVector3					mCollisionSpherePosition;
 		F32							mCollisionSphereRadius;
 		U32							mID;
-		
+
 		//--------------------------------------
 		// private methods
 		//--------------------------------------
diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp
index 809d344d01..bca4b5e447 100644
--- a/indra/newview/llfloaterbuycontents.cpp
+++ b/indra/newview/llfloaterbuycontents.cpp
@@ -211,8 +211,8 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
 
 		BOOL item_is_multi = FALSE;
 		if ((inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_LANDMARK_VISITED
-		     || inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS)
-		     && !(inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_WEARABLES_MASK))
+			|| inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS)
+			&& !(inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_WEARABLES_MASK))
 		{
 			item_is_multi = TRUE;
 		}
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index df8ecb6fd9..61da99fe3a 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -2212,8 +2212,8 @@ void LLPanelLandOptions::onCommitAny(LLUICtrl *ctrl, void *userdata)
 	BOOL allow_damage		= !self->mCheckSafe->get();
 	BOOL allow_fly			= self->mCheckFly->get();
 	BOOL allow_landmark		= TRUE; // cannot restrict landmark creation
+	BOOL allow_group_scripts	= self->mCheckGroupScripts->get() || self->mCheckOtherScripts->get();
 	BOOL allow_other_scripts	= self->mCheckOtherScripts->get();
-	BOOL allow_group_scripts	= self->mCheckGroupScripts->get() || allow_other_scripts;
 	BOOL allow_publish		= FALSE;
 	BOOL mature_publish		= self->mMatureCtrl->get();
 	BOOL push_restriction	= self->mPushRestrictionCtrl->get();
@@ -2226,16 +2226,11 @@ void LLPanelLandOptions::onCommitAny(LLUICtrl *ctrl, void *userdata)
 	LLViewerRegion* region;
 	region = LLViewerParcelMgr::getInstance()->getSelectionRegion();
 
-	if (region && region->getAllowDamage())
-	{	// Damage is allowed on the region - server will always allow scripts
-		if ( (!allow_other_scripts && parcel->getParcelFlag(PF_ALLOW_OTHER_SCRIPTS)) ||
-			 (!allow_group_scripts && parcel->getParcelFlag(PF_ALLOW_GROUP_SCRIPTS)) )
-		{	// Don't allow turning off "Run Scripts" if damage is allowed in the region
-			self->mCheckOtherScripts->set(parcel->getParcelFlag(PF_ALLOW_OTHER_SCRIPTS));	// Restore UI to actual settings
-			self->mCheckGroupScripts->set(parcel->getParcelFlag(PF_ALLOW_GROUP_SCRIPTS));
-			LLNotificationsUtil::add("UnableToDisableOutsideScripts");
-			return;
-		}
+	if (!allow_other_scripts && region && region->getAllowDamage())
+	{
+
+		LLNotificationsUtil::add("UnableToDisableOutsideScripts");
+		return;
 	}
 
 	// Push data into current parcel
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index a071f338ba..3fe535cbe8 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -4774,8 +4774,7 @@ void LLModelPreview::genBuffers(S32 lod, bool include_skin_weights)
 			if (vf.mTexCoords)
 			{
 				vb->getTexCoord0Strider(tc_strider);
-				S32 tex_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF;
-				LLVector4a::memcpyNonAliased16((F32*) tc_strider.get(), (F32*) vf.mTexCoords, tex_size);
+				LLVector4a::memcpyNonAliased16((F32*) tc_strider.get(), (F32*) vf.mTexCoords, num_vertices*2*sizeof(F32));
 			}
 			
 			if (vf.mNormals)
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index d4080ab3f7..8e540a0cc8 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -2234,12 +2234,11 @@ void LLFolderView::doIdle()
 		mDebugFilters = debug_filters;
 		arrangeAll();
 	}
-
 	BOOL filter_modified_and_active = mFilter->isModified() && mFilter->isNotDefault();
 	mNeedsAutoSelect = filter_modified_and_active &&
 						!(gFocusMgr.childHasKeyboardFocus(this) || gFocusMgr.getMouseCapture());
 	mFilter->clearModified();
-			
+
 	// filter to determine visibility before arranging
 	filterFromRoot();
 
diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp
index 66c9c323cb..5d75375847 100644
--- a/indra/newview/llpanelmarketplaceinbox.cpp
+++ b/indra/newview/llpanelmarketplaceinbox.cpp
@@ -115,8 +115,8 @@ void LLPanelMarketplaceInbox::onFocusReceived()
 	if (sidepanel_inventory)
 	{
 		sidepanel_inventory->clearSelections(true, false);
-	}
-
+		}
+	
 	gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected());
 }
 
@@ -168,8 +168,8 @@ U32 LLPanelMarketplaceInbox::getFreshItemCount() const
 				if (inbox_item_view && inbox_item_view->isFresh())
 				{
 					fresh_item_count++;
-				}
-			}
+		}
+	}
 		}
 	}
 
diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index cb6989c9dd..e124916c48 100644
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -67,19 +67,6 @@ inline F64 llsgn(const F64 a)
 class LLPhysicsMotion
 {
 public:
-	typedef enum
-	{
-		SMOOTHING = 0,
-		MASS,
-		GRAVITY,
-		SPRING,
-		GAIN,
-		DAMPING,
-		DRAG,
-		MAX_EFFECT,
-		NUM_PARAMS
-	} eParamName;
-
         /*
           param_driver_name: The param that controls the params that are being affected by the physics.
           joint_name: The joint that the body part is attached to.  The joint is
@@ -111,11 +98,6 @@ public:
                 mPositionLastUpdate_local(0)
         {
                 mJointState = new LLJointState;
-
-				for (U32 i = 0; i < NUM_PARAMS; ++i)
-				{
-					mParamCache[i] = NULL;
-				}
         }
 
         BOOL initialize();
@@ -129,43 +111,16 @@ public:
                 return mJointState;
         }
 protected:
-
-		F32 getParamValue(eParamName param)
-		{
-			static std::string controller_key[] = 
-			{
-				"Smoothing",
-				"Mass",
-				"Gravity",
-				"Spring",
-				"Gain",
-				"Damping",
-				"Drag",
-				"MaxEffect"
-			};
-
-			if (!mParamCache[param])
-			{
-				const controller_map_t::const_iterator& entry = mParamControllers.find(controller_key[param]);
+        F32 getParamValue(const std::string& controller_key)
+        {
+                const controller_map_t::const_iterator& entry = mParamControllers.find(controller_key);
                 if (entry == mParamControllers.end())
                 {
-                        return sDefaultController[controller_key[param]];
+                        return sDefaultController[controller_key];
                 }
                 const std::string& param_name = (*entry).second.c_str();
-                mParamCache[param] = mCharacter->getVisualParam(param_name.c_str());
-			}
-				
-			if (mParamCache[param])
-			{
-				return mParamCache[param]->getWeight();
-			}
-			else
-			{
-				return sDefaultController[controller_key[param]];
-			}
-		}
-
-        
+                return mCharacter->getVisualParamWeight(param_name.c_str());
+        }
         void setParamValue(LLViewerVisualParam *param,
                            const F32 new_value_local,
                                                    F32 behavior_maxeffect);
@@ -195,8 +150,6 @@ private:
 
         F32 mLastTime;
         
-		LLVisualParam* mParamCache[NUM_PARAMS];
-
         static default_controller_map_t sDefaultController;
 };
 
@@ -474,6 +427,7 @@ BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask)
         return TRUE;
 }
 
+
 // Return TRUE if character has to update visual params.
 BOOL LLPhysicsMotion::onUpdate(F32 time)
 {
@@ -517,16 +471,15 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
 
         LLJoint *joint = mJointState->getJoint();
 
-		const F32 behavior_mass = getParamValue(MASS);
-		const F32 behavior_gravity = getParamValue(GRAVITY);
-		const F32 behavior_spring = getParamValue(SPRING);
-		const F32 behavior_gain = getParamValue(GAIN);
-		const F32 behavior_damping = getParamValue(DAMPING);
-		const F32 behavior_drag = getParamValue(DRAG);
-		F32 behavior_maxeffect = getParamValue(MAX_EFFECT);
-		
-		const BOOL physics_test = FALSE; // Enable this to simulate bouncing on all parts.
+        const F32 behavior_mass = getParamValue("Mass");
+        const F32 behavior_gravity = getParamValue("Gravity");
+        const F32 behavior_spring = getParamValue("Spring");
+        const F32 behavior_gain = getParamValue("Gain");
+        const F32 behavior_damping = getParamValue("Damping");
+        const F32 behavior_drag = getParamValue("Drag");
+        const BOOL physics_test = FALSE; // Enable this to simulate bouncing on all parts.
         
+        F32 behavior_maxeffect = getParamValue("MaxEffect");
         if (physics_test)
                 behavior_maxeffect = 1.0f;
 
diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp
index 70f3b5335e..450f9b2be7 100644
--- a/indra/newview/llpolymesh.cpp
+++ b/indra/newview/llpolymesh.cpp
@@ -129,22 +129,22 @@ void LLPolyMeshSharedData::freeMeshData()
         {
                 mNumVertices = 0;
 
-                ll_aligned_free_16(mBaseCoords);
+                delete [] mBaseCoords;
                 mBaseCoords = NULL;
 
-                ll_aligned_free_16(mBaseNormals);
+                delete [] mBaseNormals;
                 mBaseNormals = NULL;
 
-                ll_aligned_free_16(mBaseBinormals);
+                delete [] mBaseBinormals;
                 mBaseBinormals = NULL;
 
-                ll_aligned_free_16(mTexCoords);
+                delete [] mTexCoords;
                 mTexCoords = NULL;
 
-                ll_aligned_free_16(mDetailTexCoords);
+                delete [] mDetailTexCoords;
                 mDetailTexCoords = NULL;
 
-                ll_aligned_free_16(mWeights);
+                delete [] mWeights;
                 mWeights = NULL;
         }
 
@@ -229,19 +229,15 @@ U32 LLPolyMeshSharedData::getNumKB()
 BOOL LLPolyMeshSharedData::allocateVertexData( U32 numVertices )
 {
         U32 i;
-        mBaseCoords = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
-        mBaseNormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
-        mBaseBinormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
-        mTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
-        mDetailTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
-        mWeights = (F32*) ll_aligned_malloc_16(numVertices*sizeof(F32));
+        mBaseCoords = new LLVector3[ numVertices ];
+        mBaseNormals = new LLVector3[ numVertices ];
+        mBaseBinormals = new LLVector3[ numVertices ];
+        mTexCoords = new LLVector2[ numVertices ];
+        mDetailTexCoords = new LLVector2[ numVertices ];
+        mWeights = new F32[ numVertices ];
         for (i = 0; i < numVertices; i++)
         {
-			mBaseCoords[i].clear();
-			mBaseNormals[i].clear();
-			mBaseBinormals[i].clear();
-			mTexCoords[i].clear();
-            mWeights[i] = 0.f;
+                mWeights[i] = 0.f;
         }
         mNumVertices = numVertices;
         return TRUE;
@@ -412,47 +408,39 @@ BOOL LLPolyMeshSharedData::loadMesh( const std::string& fileName )
 
                         allocateVertexData( numVertices );      
 
-						for (U16 i = 0; i < numVertices; ++i)
-						{
-							//----------------------------------------------------------------
-							// Coords
-							//----------------------------------------------------------------
-							numRead = fread(&mBaseCoords[i], sizeof(float), 3, fp);
-							llendianswizzle(&mBaseCoords[i], sizeof(float), 3);
-							if (numRead != 3)
-							{
-									llerrs << "can't read Coordinates from " << fileName << llendl;
-									return FALSE;
-							}
-						}
-
-						for (U16 i = 0; i < numVertices; ++i)
-						{
-							//----------------------------------------------------------------
-							// Normals
-							//----------------------------------------------------------------
-							numRead = fread(&mBaseNormals[i], sizeof(float), 3, fp);
-							llendianswizzle(&mBaseNormals[i], sizeof(float), 3);
-							if (numRead != 3)
-							{
-									llerrs << " can't read Normals from " << fileName << llendl;
-									return FALSE;
-							}
-						}
-
-						for (U16 i = 0; i < numVertices; ++i)
-						{
-							//----------------------------------------------------------------
-							// Binormals
-							//----------------------------------------------------------------
-							numRead = fread(&mBaseBinormals[i], sizeof(float), 3, fp);
-							llendianswizzle(&mBaseBinormals[i], sizeof(float), 3);
-							if (numRead != 3)
-							{
-									llerrs << " can't read Binormals from " << fileName << llendl;
-									return FALSE;
-							}
-						}
+                        //----------------------------------------------------------------
+                        // Coords
+                        //----------------------------------------------------------------
+                        numRead = fread(mBaseCoords, 3*sizeof(float), numVertices, fp);
+                        llendianswizzle(mBaseCoords, sizeof(float), 3*numVertices);
+                        if (numRead != numVertices)
+                        {
+                                llerrs << "can't read Coordinates from " << fileName << llendl;
+                                return FALSE;
+                        }
+
+                        //----------------------------------------------------------------
+                        // Normals
+                        //----------------------------------------------------------------
+                        numRead = fread(mBaseNormals, 3*sizeof(float), numVertices, fp);
+                        llendianswizzle(mBaseNormals, sizeof(float), 3*numVertices);
+                        if (numRead != numVertices)
+                        {
+                                llerrs << " can't read Normals from " << fileName << llendl;
+                                return FALSE;
+                        }
+
+                        //----------------------------------------------------------------
+                        // Binormals
+                        //----------------------------------------------------------------
+                        numRead = fread(mBaseBinormals, 3*sizeof(float), numVertices, fp);
+                        llendianswizzle(mBaseBinormals, sizeof(float), 3*numVertices);
+                        if (numRead != numVertices)
+                        {
+                                llerrs << " can't read Binormals from " << fileName << llendl;
+                                return FALSE;
+                        }
+
 
                         //----------------------------------------------------------------
                         // TexCoords
@@ -779,28 +767,21 @@ LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_
 	{
 		// Allocate memory without initializing every vector
 		// NOTE: This makes asusmptions about the size of LLVector[234]
-		S32 nverts = mSharedData->mNumVertices;
-		//make sure it's an even number of verts for alignment
-		nverts += nverts%2;
-		S32 nfloats = nverts * (
-					4 + //coords
-					4 + //normals
-					4 + //weights
-					2 + //coords
-					4 + //scaled normals
-					4 + //binormals
-					4); //scaled binormals
-
+		int nverts = mSharedData->mNumVertices;
+		int nfloats = nverts * (2*4 + 3*3 + 2 + 4);
 		//use 16 byte aligned vertex data to make LLPolyMesh SSE friendly
 		mVertexData = (F32*) ll_aligned_malloc_16(nfloats*4);
-		S32 offset = 0;
-		mCoords				= 	(LLVector4a*)(mVertexData + offset); offset += 4*nverts;
-		mNormals			=	(LLVector4a*)(mVertexData + offset); offset += 4*nverts;
-		mClothingWeights	= 	(LLVector4a*)(mVertexData + offset); offset += 4*nverts;
-		mTexCoords			= 	(LLVector2*)(mVertexData + offset);  offset += 2*nverts;
-		mScaledNormals		=   (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
-		mBinormals			=   (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
-		mScaledBinormals	=   (LLVector4a*)(mVertexData + offset); offset += 4*nverts; 
+		int offset = 0;
+		mCoords				= 	(LLVector4*)(mVertexData + offset); offset += 4*nverts;
+		mNormals			=	(LLVector4*)(mVertexData + offset); offset += 4*nverts;
+		mClothingWeights	= 	(LLVector4*)(mVertexData + offset); offset += 4*nverts;
+		mTexCoords			= 	(LLVector2*)(mVertexData + offset); offset += 2*nverts;
+
+		// these members don't need to be 16-byte aligned, but the first one might be
+		// read during an aligned memcpy of mTexCoords
+		mScaledNormals =                (LLVector3*)(mVertexData + offset); offset += 3*nverts;
+		mBinormals =                    (LLVector3*)(mVertexData + offset); offset += 3*nverts;
+		mScaledBinormals =              (LLVector3*)(mVertexData + offset); offset += 3*nverts; 
 		initializeForMorph();
 	}
 }
@@ -925,7 +906,7 @@ void LLPolyMesh::dumpDiagInfo()
 //-----------------------------------------------------------------------------
 // getWritableCoords()
 //-----------------------------------------------------------------------------
-LLVector4a *LLPolyMesh::getWritableCoords()
+LLVector4 *LLPolyMesh::getWritableCoords()
 {
         return mCoords;
 }
@@ -933,7 +914,7 @@ LLVector4a *LLPolyMesh::getWritableCoords()
 //-----------------------------------------------------------------------------
 // getWritableNormals()
 //-----------------------------------------------------------------------------
-LLVector4a *LLPolyMesh::getWritableNormals()
+LLVector4 *LLPolyMesh::getWritableNormals()
 {
         return mNormals;
 }
@@ -941,7 +922,7 @@ LLVector4a *LLPolyMesh::getWritableNormals()
 //-----------------------------------------------------------------------------
 // getWritableBinormals()
 //-----------------------------------------------------------------------------
-LLVector4a *LLPolyMesh::getWritableBinormals()
+LLVector3 *LLPolyMesh::getWritableBinormals()
 {
         return mBinormals;
 }
@@ -950,7 +931,7 @@ LLVector4a *LLPolyMesh::getWritableBinormals()
 //-----------------------------------------------------------------------------
 // getWritableClothingWeights()
 //-----------------------------------------------------------------------------
-LLVector4a       *LLPolyMesh::getWritableClothingWeights()
+LLVector4       *LLPolyMesh::getWritableClothingWeights()
 {
         return mClothingWeights;
 }
@@ -966,7 +947,7 @@ LLVector2       *LLPolyMesh::getWritableTexCoords()
 //-----------------------------------------------------------------------------
 // getScaledNormals()
 //-----------------------------------------------------------------------------
-LLVector4a *LLPolyMesh::getScaledNormals()
+LLVector3 *LLPolyMesh::getScaledNormals()
 {
         return mScaledNormals;
 }
@@ -974,7 +955,7 @@ LLVector4a *LLPolyMesh::getScaledNormals()
 //-----------------------------------------------------------------------------
 // getScaledBinormals()
 //-----------------------------------------------------------------------------
-LLVector4a *LLPolyMesh::getScaledBinormals()
+LLVector3 *LLPolyMesh::getScaledBinormals()
 {
         return mScaledBinormals;
 }
@@ -985,17 +966,17 @@ LLVector4a *LLPolyMesh::getScaledBinormals()
 //-----------------------------------------------------------------------------
 void LLPolyMesh::initializeForMorph()
 {
-    LLVector4a::memcpyNonAliased16((F32*) mCoords, (F32*) mSharedData->mBaseCoords, sizeof(LLVector4a) * mSharedData->mNumVertices);
-	LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
-	LLVector4a::memcpyNonAliased16((F32*) mScaledNormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
-	LLVector4a::memcpyNonAliased16((F32*) mBinormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
-	LLVector4a::memcpyNonAliased16((F32*) mScaledBinormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
-	LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) mSharedData->mTexCoords, sizeof(LLVector2) * (mSharedData->mNumVertices + mSharedData->mNumVertices%2));
-
-	for (U32 i = 0; i < mSharedData->mNumVertices; ++i)
+    for (U32 i = 0; i < mSharedData->mNumVertices; ++i)
 	{
-		mClothingWeights[i].clear();
+		mCoords[i] = LLVector4(mSharedData->mBaseCoords[i]);
+		mNormals[i] = LLVector4(mSharedData->mBaseNormals[i]);
 	}
+
+	memcpy(mScaledNormals, mSharedData->mBaseNormals, sizeof(LLVector3) * mSharedData->mNumVertices);	/*Flawfinder: ignore*/
+	memcpy(mBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices);	/*Flawfinder: ignore*/
+	memcpy(mScaledBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices);		/*Flawfinder: ignore*/
+	memcpy(mTexCoords, mSharedData->mTexCoords, sizeof(LLVector2) * mSharedData->mNumVertices);		/*Flawfinder: ignore*/
+	memset(mClothingWeights, 0, sizeof(LLVector4) * mSharedData->mNumVertices);
 }
 
 //-----------------------------------------------------------------------------
@@ -1117,7 +1098,7 @@ BOOL LLPolySkeletalDistortionInfo::parseXml(LLXmlTreeNode* node)
 LLPolySkeletalDistortion::LLPolySkeletalDistortion(LLVOAvatar *avatarp)
 {
         mAvatar = avatarp;
-        mDefaultVec.splat(0.001f);
+        mDefaultVec.setVec(0.001f, 0.001f, 0.001f);
 }
 
 //-----------------------------------------------------------------------------
@@ -1190,12 +1171,8 @@ BOOL LLPolySkeletalDistortion::setInfo(LLPolySkeletalDistortionInfo *info)
 //-----------------------------------------------------------------------------
 // apply()
 //-----------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_POLYSKELETAL_DISTORTION_APPLY("Skeletal Distortion");
-
 void LLPolySkeletalDistortion::apply( ESex avatar_sex )
 {
-	LLFastTimer t(FTM_POLYSKELETAL_DISTORTION_APPLY);
-
         F32 effective_weight = ( getSex() & avatar_sex ) ? mCurWeight : getDefaultWeight();
 
         LLJoint* joint;
@@ -1251,14 +1228,11 @@ LLPolyMorphData *clone_morph_param_direction(const LLPolyMorphData *src_data,
 {
         LLPolyMorphData* cloned_morph_data = new LLPolyMorphData(*src_data);
         cloned_morph_data->mName = name;
-		LLVector4a dir;
-		dir.load3(direction.mV);
-
         for (U32 v=0; v < cloned_morph_data->mNumIndices; v++)
         {
-                cloned_morph_data->mCoords[v] = dir;
-                cloned_morph_data->mNormals[v].clear();
-                cloned_morph_data->mBinormals[v].clear();
+                cloned_morph_data->mCoords[v] = direction;
+                cloned_morph_data->mNormals[v] = LLVector3(0,0,0);
+                cloned_morph_data->mBinormals[v] = LLVector3(0,0,0);
         }
         return cloned_morph_data;
 }
@@ -1269,27 +1243,17 @@ LLPolyMorphData *clone_morph_param_cleavage(const LLPolyMorphData *src_data,
 {
         LLPolyMorphData* cloned_morph_data = new LLPolyMorphData(*src_data);
         cloned_morph_data->mName = name;
-
-		LLVector4a sc;
-		sc.splat(scale);
-
-		LLVector4a nsc;
-		nsc.set(scale, -scale, scale, scale);
-
         for (U32 v=0; v < cloned_morph_data->mNumIndices; v++)
         {
-            if (cloned_morph_data->mCoords[v][1] < 0)
-            {
-                cloned_morph_data->mCoords[v].setMul(src_data->mCoords[v],nsc);
-				cloned_morph_data->mNormals[v].setMul(src_data->mNormals[v],nsc);
-				cloned_morph_data->mBinormals[v].setMul(src_data->mBinormals[v],nsc);
-			}
-			else
-			{
-				cloned_morph_data->mCoords[v].setMul(src_data->mCoords[v],sc);
-				cloned_morph_data->mNormals[v].setMul(src_data->mNormals[v], sc);
-				cloned_morph_data->mBinormals[v].setMul(src_data->mBinormals[v],sc);
-			}
+                cloned_morph_data->mCoords[v] = src_data->mCoords[v]*scale;
+                cloned_morph_data->mNormals[v] = src_data->mNormals[v]*scale;
+                cloned_morph_data->mBinormals[v] = src_data->mBinormals[v]*scale;
+                if (cloned_morph_data->mCoords[v][1] < 0)
+                {
+                        cloned_morph_data->mCoords[v][1] *= -1;
+                        cloned_morph_data->mNormals[v][1] *= -1;
+                        cloned_morph_data->mBinormals[v][1] *= -1;
+                }
         }
         return cloned_morph_data;
 }
diff --git a/indra/newview/llpolymesh.h b/indra/newview/llpolymesh.h
index ffb11a3f7e..ba2bf85570 100644
--- a/indra/newview/llpolymesh.h
+++ b/indra/newview/llpolymesh.h
@@ -73,9 +73,9 @@ private:
 							
 	// vertex data			
 	S32						mNumVertices;
-	LLVector4a				*mBaseCoords;
-	LLVector4a				*mBaseNormals;
-	LLVector4a				*mBaseBinormals;
+	LLVector3				*mBaseCoords;
+	LLVector3				*mBaseNormals;
+	LLVector3				*mBaseBinormals;
 	LLVector2				*mTexCoords;
 	LLVector2				*mDetailTexCoords;
 	F32						*mWeights;
@@ -217,41 +217,41 @@ public:
 	}
 
 	// Get coords
-	const LLVector4a	*getCoords() const{
+	const LLVector4	*getCoords() const{
 		return mCoords;
 	}
 
 	// non const version
-	LLVector4a *getWritableCoords();
+	LLVector4 *getWritableCoords();
 
 	// Get normals
-	const LLVector4a	*getNormals() const{ 
+	const LLVector4	*getNormals() const{ 
 		return mNormals; 
 	}
 
 	// Get normals
-	const LLVector4a	*getBinormals() const{ 
+	const LLVector3	*getBinormals() const{ 
 		return mBinormals; 
 	}
 
 	// Get base mesh normals
-	const LLVector4a *getBaseNormals() const{
+	const LLVector3 *getBaseNormals() const{
 		llassert(mSharedData);
 		return mSharedData->mBaseNormals;
 	}
 
 	// Get base mesh normals
-	const LLVector4a *getBaseBinormals() const{
+	const LLVector3 *getBaseBinormals() const{
 		llassert(mSharedData);
 		return mSharedData->mBaseBinormals;
 	}
 
 	// intermediate morphed normals and output normals
-	LLVector4a *getWritableNormals();
-	LLVector4a *getScaledNormals();
+	LLVector4 *getWritableNormals();
+	LLVector3 *getScaledNormals();
 
-	LLVector4a *getWritableBinormals();
-	LLVector4a *getScaledBinormals();
+	LLVector3 *getWritableBinormals();
+	LLVector3 *getScaledBinormals();
 
 	// Get texCoords
 	const LLVector2	*getTexCoords() const { 
@@ -275,9 +275,9 @@ public:
 
 	F32			*getWritableWeights() const;
 
-	LLVector4a	*getWritableClothingWeights();
+	LLVector4	*getWritableClothingWeights();
 
-	const LLVector4a		*getClothingWeights()
+	const LLVector4		*getClothingWeights()
 	{
 		return mClothingWeights;	
 	}
@@ -341,17 +341,17 @@ protected:
 	// Single array of floats for allocation / deletion
 	F32						*mVertexData;
 	// deformed vertices (resulting from application of morph targets)
-	LLVector4a				*mCoords;
+	LLVector4				*mCoords;
 	// deformed normals (resulting from application of morph targets)
-	LLVector4a				*mScaledNormals;
+	LLVector3				*mScaledNormals;
 	// output normals (after normalization)
-	LLVector4a				*mNormals;
+	LLVector4				*mNormals;
 	// deformed binormals (resulting from application of morph targets)
-	LLVector4a				*mScaledBinormals;
+	LLVector3				*mScaledBinormals;
 	// output binormals (after normalization)
-	LLVector4a				*mBinormals;
+	LLVector3				*mBinormals;
 	// weight values that mark verts as clothing/skin
-	LLVector4a				*mClothingWeights;
+	LLVector4				*mClothingWeights;
 	// output texture coordinates
 	LLVector2				*mTexCoords;
 	
@@ -419,17 +419,17 @@ public:
 	
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion() { return 0.1f; }
-	/*virtual*/ const LLVector4a&	getAvgDistortion()	{ return mDefaultVec; }
+	/*virtual*/ const LLVector3&	getAvgDistortion()	{ return mDefaultVec; }
 	/*virtual*/ F32					getMaxDistortion() { return 0.1f; }
-	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh){return LLVector4a(0.001f, 0.001f, 0.001f);}
-	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh){index = 0; poly_mesh = NULL; return &mDefaultVec;};
-	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh){index = 0; poly_mesh = NULL; return NULL;};
+	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh){return LLVector3(0.001f, 0.001f, 0.001f);}
+	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh){index = 0; poly_mesh = NULL; return &mDefaultVec;};
+	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh){index = 0; poly_mesh = NULL; return NULL;};
 
 protected:
 	typedef std::map<LLJoint*, LLVector3> joint_vec_map_t;
 	joint_vec_map_t mJointScales;
 	joint_vec_map_t mJointOffsets;
-	LLVector4a	mDefaultVec;
+	LLVector3	mDefaultVec;
 	// Backlink only; don't make this an LLPointer.
 	LLVOAvatar *mAvatar;
 };
diff --git a/indra/newview/llpolymorph.cpp b/indra/newview/llpolymorph.cpp
index d25d1420ee..cefd7df3fe 100644
--- a/indra/newview/llpolymorph.cpp
+++ b/indra/newview/llpolymorph.cpp
@@ -48,7 +48,7 @@ LLPolyMorphData::LLPolyMorphData(const std::string& morph_name)
 	mNumIndices = 0;
 	mCurrentIndex = 0;
 	mTotalDistortion = 0.f;
-	mAvgDistortion.clear();
+	mAvgDistortion.zeroVec();
 	mMaxDistortion = 0.f;
 	mVertexIndices = NULL;
 	mCoords = NULL;
@@ -73,9 +73,9 @@ LLPolyMorphData::LLPolyMorphData(const LLPolyMorphData &rhs) :
 {
 	const S32 numVertices = mNumIndices;
 
-	mCoords = new LLVector4a[numVertices];
-	mNormals = new LLVector4a[numVertices];
-	mBinormals = new LLVector4a[numVertices];
+	mCoords = new LLVector3[numVertices];
+	mNormals = new LLVector3[numVertices];
+	mBinormals = new LLVector3[numVertices];
 	mTexCoords = new LLVector2[numVertices];
 	mVertexIndices = new U32[numVertices];
 	
@@ -121,16 +121,16 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
 	//-------------------------------------------------------------------------
 	// allocate vertices
 	//-------------------------------------------------------------------------
-	mCoords = new LLVector4a[numVertices];
-	mNormals = new LLVector4a[numVertices];
-	mBinormals = new LLVector4a[numVertices];
+	mCoords = new LLVector3[numVertices];
+	mNormals = new LLVector3[numVertices];
+	mBinormals = new LLVector3[numVertices];
 	mTexCoords = new LLVector2[numVertices];
 	// Actually, we are allocating more space than we need for the skiplist
 	mVertexIndices = new U32[numVertices];
 	mNumIndices = 0;
 	mTotalDistortion = 0.f;
 	mMaxDistortion = 0.f;
-	mAvgDistortion.clear();
+	mAvgDistortion.zeroVec();
 	mMesh = mesh;
 
 	//-------------------------------------------------------------------------
@@ -152,36 +152,36 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
 		}
 
 
-		numRead = fread(&mCoords[v], sizeof(F32), 3, fp);
-		llendianswizzle(&mCoords[v], sizeof(F32), 3);
+		numRead = fread(&mCoords[v].mV, sizeof(F32), 3, fp);
+		llendianswizzle(&mCoords[v].mV, sizeof(F32), 3);
 		if (numRead != 3)
 		{
 			llwarns << "Can't read morph target vertex coordinates" << llendl;
 			return FALSE;
 		}
 
-		F32 magnitude = mCoords[v].getLength3().getF32();
+		F32 magnitude = mCoords[v].magVec();
 		
 		mTotalDistortion += magnitude;
-		LLVector4a t;
-		t.setAbs(mCoords[v]);
-		mAvgDistortion.add(t);
+		mAvgDistortion.mV[VX] += fabs(mCoords[v].mV[VX]);
+		mAvgDistortion.mV[VY] += fabs(mCoords[v].mV[VY]);
+		mAvgDistortion.mV[VZ] += fabs(mCoords[v].mV[VZ]);
 		
 		if (magnitude > mMaxDistortion)
 		{
 			mMaxDistortion = magnitude;
 		}
 
-		numRead = fread(&mNormals[v], sizeof(F32), 3, fp);
-		llendianswizzle(&mNormals[v], sizeof(F32), 3);
+		numRead = fread(&mNormals[v].mV, sizeof(F32), 3, fp);
+		llendianswizzle(&mNormals[v].mV, sizeof(F32), 3);
 		if (numRead != 3)
 		{
 			llwarns << "Can't read morph target normal" << llendl;
 			return FALSE;
 		}
 
-		numRead = fread(&mBinormals[v], sizeof(F32), 3, fp);
-		llendianswizzle(&mBinormals[v], sizeof(F32), 3);
+		numRead = fread(&mBinormals[v].mV, sizeof(F32), 3, fp);
+		llendianswizzle(&mBinormals[v].mV, sizeof(F32), 3);
 		if (numRead != 3)
 		{
 			llwarns << "Can't read morph target binormal" << llendl;
@@ -200,8 +200,8 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
 		mNumIndices++;
 	}
 
-	mAvgDistortion.mul(1.f/(F32)mNumIndices);
-	mAvgDistortion.normalize3fast();
+	mAvgDistortion = mAvgDistortion * (1.f/(F32)mNumIndices);
+	mAvgDistortion.normVec();
 
 	return TRUE;
 }
@@ -367,9 +367,9 @@ BOOL LLPolyMorphTarget::parseData(LLXmlTreeNode* node)
 //-----------------------------------------------------------------------------
 // getVertexDistortion()
 //-----------------------------------------------------------------------------
-LLVector4a LLPolyMorphTarget::getVertexDistortion(S32 requested_index, LLPolyMesh *mesh)
+LLVector3 LLPolyMorphTarget::getVertexDistortion(S32 requested_index, LLPolyMesh *mesh)
 {
-	if (!mMorphData || mMesh != mesh) return LLVector4a::getZero();
+	if (!mMorphData || mMesh != mesh) return LLVector3::zero;
 
 	for(U32 index = 0; index < mMorphData->mNumIndices; index++)
 	{
@@ -379,17 +379,17 @@ LLVector4a LLPolyMorphTarget::getVertexDistortion(S32 requested_index, LLPolyMes
 		}
 	}
 
-	return LLVector4a::getZero();
+	return LLVector3::zero;
 }
 
 //-----------------------------------------------------------------------------
 // getFirstDistortion()
 //-----------------------------------------------------------------------------
-const LLVector4a *LLPolyMorphTarget::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
+const LLVector3 *LLPolyMorphTarget::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
 {
-	if (!mMorphData) return &LLVector4a::getZero();
+	if (!mMorphData) return &LLVector3::zero;
 
-	LLVector4a* resultVec;
+	LLVector3* resultVec;
 	mMorphData->mCurrentIndex = 0;
 	if (mMorphData->mNumIndices)
 	{
@@ -411,11 +411,11 @@ const LLVector4a *LLPolyMorphTarget::getFirstDistortion(U32 *index, LLPolyMesh *
 //-----------------------------------------------------------------------------
 // getNextDistortion()
 //-----------------------------------------------------------------------------
-const LLVector4a *LLPolyMorphTarget::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
+const LLVector3 *LLPolyMorphTarget::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
 {
-	if (!mMorphData) return &LLVector4a::getZero();
+	if (!mMorphData) return &LLVector3::zero;
 
-	LLVector4a* resultVec;
+	LLVector3* resultVec;
 	mMorphData->mCurrentIndex++;
 	if (mMorphData->mCurrentIndex < mMorphData->mNumIndices)
 	{
@@ -451,7 +451,7 @@ F32	LLPolyMorphTarget::getTotalDistortion()
 //-----------------------------------------------------------------------------
 // getAvgDistortion()
 //-----------------------------------------------------------------------------
-const LLVector4a& LLPolyMorphTarget::getAvgDistortion()	
+const LLVector3& LLPolyMorphTarget::getAvgDistortion()	
 {
 	if (mMorphData) 
 	{
@@ -459,7 +459,7 @@ const LLVector4a& LLPolyMorphTarget::getAvgDistortion()
 	}
 	else 
 	{
-		return LLVector4a::getZero();
+		return LLVector3::zero;
 	}
 }
 
@@ -481,8 +481,6 @@ F32	LLPolyMorphTarget::getMaxDistortion()
 //-----------------------------------------------------------------------------
 // apply()
 //-----------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_APPLY_MORPH_TARGET("Apply Morph");
-
 void LLPolyMorphTarget::apply( ESex avatar_sex )
 {
 	if (!mMorphData || mNumMorphMasksPending > 0)
@@ -490,8 +488,6 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 		return;
 	}
 
-	LLFastTimer t(FTM_APPLY_MORPH_TARGET);
-
 	mLastSex = avatar_sex;
 
 	// Check for NaN condition (NaN is detected if a variable doesn't equal itself.
@@ -512,15 +508,15 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 	if (delta_weight != 0.f)
 	{
 		llassert(!mMesh->isLOD());
-		LLVector4a *coords = mMesh->getWritableCoords();
+		LLVector4 *coords = mMesh->getWritableCoords();
 
-		LLVector4a *scaled_normals = mMesh->getScaledNormals();
-		LLVector4a *normals = mMesh->getWritableNormals();
+		LLVector3 *scaled_normals = mMesh->getScaledNormals();
+		LLVector4 *normals = mMesh->getWritableNormals();
 
-		LLVector4a *scaled_binormals = mMesh->getScaledBinormals();
-		LLVector4a *binormals = mMesh->getWritableBinormals();
+		LLVector3 *scaled_binormals = mMesh->getScaledBinormals();
+		LLVector3 *binormals = mMesh->getWritableBinormals();
 
-		LLVector4a *clothing_weights = mMesh->getWritableClothingWeights();
+		LLVector4 *clothing_weights = mMesh->getWritableClothingWeights();
 		LLVector2 *tex_coords = mMesh->getWritableTexCoords();
 
 		F32 *maskWeightArray = (mVertMask) ? mVertMask->getMorphMaskWeights() : NULL;
@@ -535,38 +531,31 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 				maskWeight = maskWeightArray[vert_index_morph];
 			}
 
-
-			LLVector4a pos = mMorphData->mCoords[vert_index_morph];
-			pos.mul(delta_weight*maskWeight);
-			coords[vert_index_mesh].add(pos);
+			coords[vert_index_mesh] += LLVector4(mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight);
 
 			if (getInfo()->mIsClothingMorph && clothing_weights)
 			{
-				LLVector4a clothing_offset = mMorphData->mCoords[vert_index_morph];
-				clothing_offset.mul(delta_weight * maskWeight);
-				LLVector4a* clothing_weight = &clothing_weights[vert_index_mesh];
-				clothing_weight->add(clothing_offset);
-				clothing_weight->getF32ptr()[VW] = maskWeight;
+				LLVector3 clothing_offset = mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight;
+				LLVector4* clothing_weight = &clothing_weights[vert_index_mesh];
+				clothing_weight->mV[VX] += clothing_offset.mV[VX];
+				clothing_weight->mV[VY] += clothing_offset.mV[VY];
+				clothing_weight->mV[VZ] += clothing_offset.mV[VZ];
+				clothing_weight->mV[VW] = maskWeight;
 			}
 
 			// calculate new normals based on half angles
-			LLVector4a norm = mMorphData->mNormals[vert_index_morph];
-			norm.mul(delta_weight*maskWeight*NORMAL_SOFTEN_FACTOR);
-			scaled_normals[vert_index_mesh].add(norm);
-			norm = scaled_normals[vert_index_mesh];
-			norm.normalize3fast();
-			normals[vert_index_mesh] = norm;
+			scaled_normals[vert_index_mesh] += mMorphData->mNormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR;
+			LLVector3 normalized_normal = scaled_normals[vert_index_mesh];
+			normalized_normal.normVec();
+			normals[vert_index_mesh] = LLVector4(normalized_normal);
 
 			// calculate new binormals
-			LLVector4a binorm = mMorphData->mBinormals[vert_index_morph];
-			binorm.mul(delta_weight*maskWeight*NORMAL_SOFTEN_FACTOR);
-			scaled_binormals[vert_index_mesh].add(binorm);
-			LLVector4a tangent;
-			tangent.setCross3(scaled_binormals[vert_index_mesh], norm);
-			LLVector4a& normalized_binormal = binormals[vert_index_mesh];
-			normalized_binormal.setCross3(norm, tangent); 
-			normalized_binormal.normalize3fast();
-			
+			scaled_binormals[vert_index_mesh] += mMorphData->mBinormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR;
+			LLVector3 tangent = scaled_binormals[vert_index_mesh] % normalized_normal;
+			LLVector3 normalized_binormal = normalized_normal % tangent; 
+			normalized_binormal.normVec();
+			binormals[vert_index_mesh] = normalized_binormal;
+
 			tex_coords[vert_index_mesh] += mMorphData->mTexCoords[vert_index_morph] * delta_weight * maskWeight;
 		}
 
@@ -593,7 +582,7 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 //-----------------------------------------------------------------------------
 void	LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S32 num_components, BOOL invert)
 {
-	LLVector4a *clothing_weights = getInfo()->mIsClothingMorph ? mMesh->getWritableClothingWeights() : NULL;
+	LLVector4 *clothing_weights = getInfo()->mIsClothingMorph ? mMesh->getWritableClothingWeights() : NULL;
 
 	if (!mVertMask)
 	{
@@ -607,47 +596,29 @@ void	LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S3
 
 		if (maskWeights)
 		{
-			LLVector4a *coords = mMesh->getWritableCoords();
-			LLVector4a *scaled_normals = mMesh->getScaledNormals();
-			LLVector4a *scaled_binormals = mMesh->getScaledBinormals();
+			LLVector4 *coords = mMesh->getWritableCoords();
+			LLVector3 *scaled_normals = mMesh->getScaledNormals();
+			LLVector3 *scaled_binormals = mMesh->getScaledBinormals();
 			LLVector2 *tex_coords = mMesh->getWritableTexCoords();
 
-			LLVector4Logical clothing_mask;
-			clothing_mask.clear();
-			clothing_mask.setElement<0>();
-			clothing_mask.setElement<1>();
-			clothing_mask.setElement<2>();
-
-
 			for(U32 vert = 0; vert < mMorphData->mNumIndices; vert++)
 			{
 				F32 lastMaskWeight = mLastWeight * maskWeights[vert];
 				S32 out_vert = mMorphData->mVertexIndices[vert];
 
 				// remove effect of existing masked morph
-				LLVector4a t;
-				t = mMorphData->mCoords[vert];
-				t.mul(lastMaskWeight);
-				coords[out_vert].sub(t);
-
-				t = mMorphData->mNormals[vert];
-				t.mul(lastMaskWeight*NORMAL_SOFTEN_FACTOR);
-				scaled_normals[out_vert].sub(t);
-
-				t = mMorphData->mBinormals[vert];
-				t.mul(lastMaskWeight*NORMAL_SOFTEN_FACTOR);
-				scaled_binormals[out_vert].sub(t);
-
+				coords[out_vert] -= LLVector4(mMorphData->mCoords[vert]) * lastMaskWeight;
+				scaled_normals[out_vert] -= mMorphData->mNormals[vert] * lastMaskWeight * NORMAL_SOFTEN_FACTOR;
+				scaled_binormals[out_vert] -= mMorphData->mBinormals[vert] * lastMaskWeight * NORMAL_SOFTEN_FACTOR;
 				tex_coords[out_vert] -= mMorphData->mTexCoords[vert] * lastMaskWeight;
 
 				if (clothing_weights)
 				{
-					LLVector4a clothing_offset = mMorphData->mCoords[vert];
-					clothing_offset.mul(lastMaskWeight);
-					LLVector4a* clothing_weight = &clothing_weights[out_vert];
-					LLVector4a t;
-					t.setSub(*clothing_weight, clothing_offset);
-					clothing_weight->setSelectWithMask(clothing_mask, t, *clothing_weight);
+					LLVector3 clothing_offset = mMorphData->mCoords[vert] * lastMaskWeight;
+					LLVector4* clothing_weight = &clothing_weights[out_vert];
+					clothing_weight->mV[VX] -= clothing_offset.mV[VX];
+					clothing_weight->mV[VY] -= clothing_offset.mV[VY];
+					clothing_weight->mV[VZ] -= clothing_offset.mV[VZ];
 				}
 			}
 		}
@@ -683,7 +654,7 @@ LLPolyVertexMask::~LLPolyVertexMask()
 //-----------------------------------------------------------------------------
 // generateMask()
 //-----------------------------------------------------------------------------
-void LLPolyVertexMask::generateMask(U8 *maskTextureData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4a *clothing_weights)
+void LLPolyVertexMask::generateMask(U8 *maskTextureData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4 *clothing_weights)
 {
 // RN debug output that uses Image Debugger (http://www.cs.unc.edu/~baxter/projects/imdebug/)
 //	BOOL debugImg = FALSE; 
@@ -727,7 +698,7 @@ void LLPolyVertexMask::generateMask(U8 *maskTextureData, S32 width, S32 height,
 
 		if (clothing_weights)
 		{
-			clothing_weights[vertIndex].getF32ptr()[VW] = mWeights[index];
+			clothing_weights[vertIndex].mV[VW] = mWeights[index];
 		}
 	}
 	mWeightsGenerated = TRUE;
diff --git a/indra/newview/llpolymorph.h b/indra/newview/llpolymorph.h
index 46e23b7792..8a024f2e9e 100644
--- a/indra/newview/llpolymorph.h
+++ b/indra/newview/llpolymorph.h
@@ -58,14 +58,14 @@ public:
 	U32					mNumIndices;
 	U32*				mVertexIndices;
 	U32					mCurrentIndex;
-	LLVector4a*			mCoords;
-	LLVector4a*			mNormals;
-	LLVector4a*			mBinormals;
+	LLVector3*			mCoords;
+	LLVector3*			mNormals;
+	LLVector3*			mBinormals;
 	LLVector2*			mTexCoords;
 
 	F32					mTotalDistortion;	// vertex distortion summed over entire morph
 	F32					mMaxDistortion;		// maximum single vertex distortion in a given morph
-	LLVector4a			mAvgDistortion;		// average vertex distortion, to infer directionality of the morph
+	LLVector3			mAvgDistortion;		// average vertex distortion, to infer directionality of the morph
 	LLPolyMeshSharedData*	mMesh;
 };
 
@@ -78,7 +78,7 @@ public:
 	LLPolyVertexMask(LLPolyMorphData* morph_data);
 	~LLPolyVertexMask();
 
-	void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4a *clothing_weights);
+	void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4 *clothing_weights);
 	F32* getMorphMaskWeights();
 
 
@@ -157,11 +157,11 @@ public:
 	
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion();
-	/*virtual*/ const LLVector4a&	getAvgDistortion();
+	/*virtual*/ const LLVector3&	getAvgDistortion();
 	/*virtual*/ F32					getMaxDistortion();
-	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
-	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
-	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
+	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
+	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
+	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
 
 	void	applyMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert);
 	void	addPendingMorphMask() { mNumMorphMasksPending++; }
diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp
index 92c2863ffd..1ce05da849 100644
--- a/indra/newview/llsidepaneliteminfo.cpp
+++ b/indra/newview/llsidepaneliteminfo.cpp
@@ -352,7 +352,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 		getChildView("BtnCreator")->setEnabled(FALSE);
 		getChildView("LabelCreatorTitle")->setEnabled(FALSE);
 		getChildView("LabelCreatorName")->setEnabled(FALSE);
-		getChild<LLUICtrl>("LabelCreatorName")->setValue(getString("unknown_multiple"));
+		getChild<LLUICtrl>("LabelCreatorName")->setValue(getString("unknown"));
 	}
 
 	////////////////
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 78c905f6ff..325a2d3004 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -68,7 +68,6 @@ const F32 SG_OCCLUSION_FUDGE = 0.25f;
 #define assert_states_valid(x)
 #endif
 
-extern bool gShiftFrame;
 
 static U32 sZombieGroups = 0;
 U32 LLSpatialGroup::sNodeCount = 0;
@@ -530,7 +529,6 @@ void LLSpatialGroup::setVisible()
 
 void LLSpatialGroup::validate()
 {
-	ll_assert_aligned(this,64);
 #if LL_OCTREE_PARANOIA_CHECK
 
 	sg_assert(!isState(DIRTY));
@@ -543,7 +541,7 @@ void LLSpatialGroup::validate()
 
 	validateDrawMap();
 
-	for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
+	for (element_iter i = getData().begin(); i != getData().end(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		sg_assert(drawable->getSpatialGroup() == this);
@@ -760,7 +758,7 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& ma
 {	
 	const OctreeNode* node = mOctreeNode;
 
-	if (node->isEmpty())
+	if (node->getData().empty())
 	{	//don't do anything if there are no objects
 		if (empty && mOctreeNode->getParent())
 		{	//only root is allowed to be empty
@@ -777,14 +775,14 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& ma
 		clearState(OBJECT_DIRTY);
 
 		//initialize bounding box to first element
-		OctreeNode::const_element_iter i = node->getDataBegin();
+		OctreeNode::const_element_iter i = node->getData().begin();
 		LLDrawable* drawablep = *i;
 		const LLVector4a* minMax = drawablep->getSpatialExtents();
 
 		newMin = minMax[0];
 		newMax = minMax[1];
 
-		for (++i; i != node->getDataEnd(); ++i)
+		for (++i; i != node->getData().end(); ++i)
 		{
 			drawablep = *i;
 			minMax = drawablep->getSpatialExtents();
@@ -925,10 +923,7 @@ void LLSpatialGroup::shift(const LLVector4a &offset)
 	mObjectExtents[0].add(offset);
 	mObjectExtents[1].add(offset);
 
-	if (!mSpatialPartition->mRenderByGroup && 
-		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TREE &&
-		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TERRAIN &&
-		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_BRIDGE)
+	//if (!mSpatialPartition->mRenderByGroup)
 	{
 		setState(GEOM_DIRTY);
 		gPipeline.markRebuild(this, TRUE);
@@ -1200,8 +1195,6 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
 	mCurUpdatingSlotp(NULL),
 	mCurUpdatingTexture (NULL)
 {
-	ll_assert_aligned(this,16);
-	
 	sNodeCount++;
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 
@@ -1245,18 +1238,13 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 		return;
 	}
 
-	if (gShiftFrame)
-	{
-		return;
-	}
-
 #if !LL_RELEASE_FOR_DOWNLOAD
 	if (isState(LLSpatialGroup::OBJECT_DIRTY))
 	{
 		llerrs << "Spatial group dirty on distance update." << llendl;
 	}
 #endif
-	if (!isEmpty())
+	if (!getData().empty())
 	{
 		mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].getLength3().getF32() :
 						(F32) mOctreeNode->getSize().getLength3().getF32();
@@ -1407,7 +1395,7 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	setState(DEAD);
 	
-	for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
+	for (element_iter i = getData().begin(); i != getData().end(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		if (drawable->getSpatialGroup() == this)
@@ -1494,7 +1482,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 	}
 
 
-	for (LLSpatialGroup::element_iter i = getDataBegin(); i != getDataEnd(); ++i)
+	for (LLSpatialGroup::element_iter i = getData().begin(); i != getData().end(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		for (S32 j = 0; j < drawable->getNumFaces(); j++)
@@ -1850,14 +1838,12 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
 {
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	
+	drawablep->setSpatialGroup(NULL);
+
 	if (!curp->removeObject(drawablep))
 	{
 		OCT_ERRS << "Failed to remove drawable from octree!" << llendl;
 	}
-	else
-	{
-		drawablep->setSpatialGroup(NULL);
-	}
 
 	assert_octree_valid(mOctree);
 	
@@ -2128,7 +2114,7 @@ public:
 
 	virtual void processGroup(LLSpatialGroup* group)
 	{
-		llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->isEmpty())
+		llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->getData().empty())
 		
 		if (mRes < 2)
 		{
@@ -2195,7 +2181,7 @@ public:
 	{
 		LLSpatialGroup::OctreeNode* branch = group->mOctreeNode;
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
 		{
 			LLDrawable* drawable = *i;
 			
@@ -2319,7 +2305,7 @@ public:
 		LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0);
 		group->destroyGL();
 
-		for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+		for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 		{
 			LLDrawable* drawable = *i;
 			if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup)
@@ -2629,7 +2615,7 @@ void renderOctree(LLSpatialGroup* group)
 			gGL.flush();
 			glLineWidth(1.f);
 			gGL.flush();
-			for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+			for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 			{
 				LLDrawable* drawable = *i;
 				if (!group->mSpatialPartition->isBridge())
@@ -2675,7 +2661,7 @@ void renderOctree(LLSpatialGroup* group)
 	}
 	else
 	{
-		if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->isEmpty() 
+		if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->getData().empty() 
 			&& group->mSpatialPartition->mRenderByGroup)
 		{
 			col.setVec(0.8f, 0.4f, 0.1f, 0.1f);
@@ -2743,7 +2729,7 @@ void renderVisibility(LLSpatialGroup* group, LLCamera* camera)
 	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 
 	BOOL render_objects = (!LLPipeline::sUseOcclusion || !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) && group->isVisible() &&
-							!group->isEmpty();
+							!group->getData().empty();
 
 	if (render_objects)
 	{
@@ -3474,7 +3460,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
 
 void renderPhysicsShapes(LLSpatialGroup* group)
 {
-	for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+	for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		LLVOVolume* volume = drawable->getVOVolume();
@@ -3823,7 +3809,7 @@ public:
 
 		LLVector3 center, size;
 		
-		if (branch->isEmpty())
+		if (branch->getData().empty())
 		{
 			gGL.diffuseColor3f(1.f,0.2f,0.f);
 			center.set(branch->getCenter().getF32ptr());
@@ -3859,8 +3845,8 @@ public:
 			}
 
 			gGL.begin(LLRender::TRIANGLES);
-			for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getDataBegin();
-					iter != branch->getDataEnd();
+			for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getData().begin();
+					iter != branch->getData().end();
 					++iter)
 			{
 				const LLVolumeTriangle* tri = *iter;
@@ -4097,7 +4083,7 @@ public:
 
 		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BBOXES))
 		{
-			if (!group->isEmpty())
+			if (!group->getData().empty())
 			{
 				gGL.diffuseColor3f(0,0,1);
 				drawBoxOutline(group->mObjectBounds[0],
@@ -4105,7 +4091,7 @@ public:
 			}
 		}
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
 		{
 			LLDrawable* drawable = *i;
 					
@@ -4191,7 +4177,7 @@ public:
 						{
 							if (index < 255)
 							{
-								if (facep->mDrawInfo->mTextureList.size()<= index)
+								if (facep->mDrawInfo->mTextureList.size() <= index)
 								{
 									llerrs << "Face texture index out of bounds." << llendl;
 								}
@@ -4294,7 +4280,7 @@ public:
 			return;
 		}
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
 		{
 			LLDrawable* drawable = *i;
 						
@@ -4518,7 +4504,7 @@ public:
 	
 	virtual void visit(const LLSpatialGroup::OctreeNode* branch) 
 	{	
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
 		{
 			check(*i);
 		}
@@ -4704,62 +4690,28 @@ LLVertexBuffer* LLGeometryManager::createVertexBuffer(U32 type_mask, U32 usage)
 
 LLCullResult::LLCullResult() 
 {
-	mVisibleGroupsAllocated = 0;
-	mAlphaGroupsAllocated = 0;
-	mOcclusionGroupsAllocated = 0;
-	mDrawableGroupsAllocated = 0;
-	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;
-
-	for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
-	{
-		mRenderMap[i] = NULL;
-		mRenderMapEnd[i] = NULL;
-		mRenderMapAllocated[i] = 0;
-	}
-
 	clear();
 }
 
-void LLCullResult::pushBack(void**& head, U32& count, void* val)
-{
-	count++;
-	head = (void**) realloc((void*) head, sizeof(void*) * count);
-	head[count-1] = val;
-}
-
 void LLCullResult::clear()
 {
 	mVisibleGroupsSize = 0;
-	mVisibleGroupsEnd = mVisibleGroups;
+	mVisibleGroupsEnd = mVisibleGroups.begin();
 
 	mAlphaGroupsSize = 0;
-	mAlphaGroupsEnd = mAlphaGroups;
+	mAlphaGroupsEnd = mAlphaGroups.begin();
 
 	mOcclusionGroupsSize = 0;
-	mOcclusionGroupsEnd = mOcclusionGroups;
+	mOcclusionGroupsEnd = mOcclusionGroups.begin();
 
 	mDrawableGroupsSize = 0;
-	mDrawableGroupsEnd = mDrawableGroups;
+	mDrawableGroupsEnd = mDrawableGroups.begin();
 
 	mVisibleListSize = 0;
-	mVisibleListEnd = mVisibleList;
+	mVisibleListEnd = mVisibleList.begin();
 
 	mVisibleBridgeSize = 0;
-	mVisibleBridgeEnd = mVisibleBridge;
+	mVisibleBridgeEnd = mVisibleBridge.begin();
 
 
 	for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
@@ -4769,176 +4721,176 @@ void LLCullResult::clear()
 			mRenderMap[i][j] = 0;
 		}
 		mRenderMapSize[i] = 0;
-		mRenderMapEnd[i] = mRenderMap[i];
+		mRenderMapEnd[i] = mRenderMap[i].begin();
 	}
 }
 
-LLCullResult::sg_iterator LLCullResult::beginVisibleGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::beginVisibleGroups()
 {
-	return mVisibleGroups;
+	return mVisibleGroups.begin();
 }
 
-LLCullResult::sg_iterator LLCullResult::endVisibleGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::endVisibleGroups()
 {
 	return mVisibleGroupsEnd;
 }
 
-LLCullResult::sg_iterator LLCullResult::beginAlphaGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::beginAlphaGroups()
 {
-	return mAlphaGroups;
+	return mAlphaGroups.begin();
 }
 
-LLCullResult::sg_iterator LLCullResult::endAlphaGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::endAlphaGroups()
 {
 	return mAlphaGroupsEnd;
 }
 
-LLCullResult::sg_iterator LLCullResult::beginOcclusionGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::beginOcclusionGroups()
 {
-	return mOcclusionGroups;
+	return mOcclusionGroups.begin();
 }
 
-LLCullResult::sg_iterator LLCullResult::endOcclusionGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::endOcclusionGroups()
 {
 	return mOcclusionGroupsEnd;
 }
 
-LLCullResult::sg_iterator LLCullResult::beginDrawableGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::beginDrawableGroups()
 {
-	return mDrawableGroups;
+	return mDrawableGroups.begin();
 }
 
-LLCullResult::sg_iterator LLCullResult::endDrawableGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::endDrawableGroups()
 {
 	return mDrawableGroupsEnd;
 }
 
-LLCullResult::drawable_iterator LLCullResult::beginVisibleList()
+LLCullResult::drawable_list_t::iterator LLCullResult::beginVisibleList()
 {
-	return mVisibleList;
+	return mVisibleList.begin();
 }
 
-LLCullResult::drawable_iterator LLCullResult::endVisibleList()
+LLCullResult::drawable_list_t::iterator LLCullResult::endVisibleList()
 {
 	return mVisibleListEnd;
 }
 
-LLCullResult::bridge_iterator LLCullResult::beginVisibleBridge()
+LLCullResult::bridge_list_t::iterator LLCullResult::beginVisibleBridge()
 {
-	return mVisibleBridge;
+	return mVisibleBridge.begin();
 }
 
-LLCullResult::bridge_iterator LLCullResult::endVisibleBridge()
+LLCullResult::bridge_list_t::iterator LLCullResult::endVisibleBridge()
 {
 	return mVisibleBridgeEnd;
 }
 
-LLCullResult::drawinfo_iterator LLCullResult::beginRenderMap(U32 type)
+LLCullResult::drawinfo_list_t::iterator LLCullResult::beginRenderMap(U32 type)
 {
-	return mRenderMap[type];
+	return mRenderMap[type].begin();
 }
 
-LLCullResult::drawinfo_iterator LLCullResult::endRenderMap(U32 type)
+LLCullResult::drawinfo_list_t::iterator LLCullResult::endRenderMap(U32 type)
 {
 	return mRenderMapEnd[type];
 }
 
 void LLCullResult::pushVisibleGroup(LLSpatialGroup* group)
 {
-	if (mVisibleGroupsSize < mVisibleGroupsAllocated)
+	if (mVisibleGroupsSize < mVisibleGroups.size())
 	{
 		mVisibleGroups[mVisibleGroupsSize] = group;
 	}
 	else
 	{
-		pushBack((void**&) mVisibleGroups, mVisibleGroupsAllocated, (void*) group);
+		mVisibleGroups.push_back(group);
 	}
 	++mVisibleGroupsSize;
-	mVisibleGroupsEnd = mVisibleGroups+mVisibleGroupsSize;
+	mVisibleGroupsEnd = mVisibleGroups.begin()+mVisibleGroupsSize;
 }
 
 void LLCullResult::pushAlphaGroup(LLSpatialGroup* group)
 {
-	if (mAlphaGroupsSize < mAlphaGroupsAllocated)
+	if (mAlphaGroupsSize < mAlphaGroups.size())
 	{
 		mAlphaGroups[mAlphaGroupsSize] = group;
 	}
 	else
 	{
-		pushBack((void**&) mAlphaGroups, mAlphaGroupsAllocated, (void*) group);
+		mAlphaGroups.push_back(group);
 	}
 	++mAlphaGroupsSize;
-	mAlphaGroupsEnd = mAlphaGroups+mAlphaGroupsSize;
+	mAlphaGroupsEnd = mAlphaGroups.begin()+mAlphaGroupsSize;
 }
 
 void LLCullResult::pushOcclusionGroup(LLSpatialGroup* group)
 {
-	if (mOcclusionGroupsSize < mOcclusionGroupsAllocated)
+	if (mOcclusionGroupsSize < mOcclusionGroups.size())
 	{
 		mOcclusionGroups[mOcclusionGroupsSize] = group;
 	}
 	else
 	{
-		pushBack((void**&) mOcclusionGroups, mOcclusionGroupsAllocated, (void*) group);
+		mOcclusionGroups.push_back(group);
 	}
 	++mOcclusionGroupsSize;
-	mOcclusionGroupsEnd = mOcclusionGroups+mOcclusionGroupsSize;
+	mOcclusionGroupsEnd = mOcclusionGroups.begin()+mOcclusionGroupsSize;
 }
 
 void LLCullResult::pushDrawableGroup(LLSpatialGroup* group)
 {
-	if (mDrawableGroupsSize < mDrawableGroupsAllocated)
+	if (mDrawableGroupsSize < mDrawableGroups.size())
 	{
 		mDrawableGroups[mDrawableGroupsSize] = group;
 	}
 	else
 	{
-		pushBack((void**&) mDrawableGroups, mDrawableGroupsAllocated, (void*) group);
+		mDrawableGroups.push_back(group);
 	}
 	++mDrawableGroupsSize;
-	mDrawableGroupsEnd = mDrawableGroups+mDrawableGroupsSize;
+	mDrawableGroupsEnd = mDrawableGroups.begin()+mDrawableGroupsSize;
 }
 
 void LLCullResult::pushDrawable(LLDrawable* drawable)
 {
-	if (mVisibleListSize < mVisibleListAllocated)
+	if (mVisibleListSize < mVisibleList.size())
 	{
 		mVisibleList[mVisibleListSize] = drawable;
 	}
 	else
 	{
-		pushBack((void**&) mVisibleList, mVisibleListAllocated, (void*) drawable);
+		mVisibleList.push_back(drawable);
 	}
 	++mVisibleListSize;
-	mVisibleListEnd = mVisibleList+mVisibleListSize;
+	mVisibleListEnd = mVisibleList.begin()+mVisibleListSize;
 }
 
 void LLCullResult::pushBridge(LLSpatialBridge* bridge)
 {
-	if (mVisibleBridgeSize < mVisibleBridgeAllocated)
+	if (mVisibleBridgeSize < mVisibleBridge.size())
 	{
 		mVisibleBridge[mVisibleBridgeSize] = bridge;
 	}
 	else
 	{
-		pushBack((void**&) mVisibleBridge, mVisibleBridgeAllocated, (void*) bridge);
+		mVisibleBridge.push_back(bridge);
 	}
 	++mVisibleBridgeSize;
-	mVisibleBridgeEnd = mVisibleBridge+mVisibleBridgeSize;
+	mVisibleBridgeEnd = mVisibleBridge.begin()+mVisibleBridgeSize;
 }
 
 void LLCullResult::pushDrawInfo(U32 type, LLDrawInfo* draw_info)
 {
-	if (mRenderMapSize[type] < mRenderMapAllocated[type])
+	if (mRenderMapSize[type] < mRenderMap[type].size())
 	{
 		mRenderMap[type][mRenderMapSize[type]] = draw_info;
 	}
 	else
 	{
-		pushBack((void**&) mRenderMap[type], mRenderMapAllocated[type], (void*) draw_info);
+		mRenderMap[type].push_back(draw_info);
 	}
 	++mRenderMapSize[type];
-	mRenderMapEnd[type] = mRenderMap[type] + mRenderMapSize[type];
+	mRenderMapEnd[type] = mRenderMap[type].begin() + mRenderMapSize[type];
 }
 
 
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index f050df2b39..f0e4f15a83 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -68,16 +68,6 @@ protected:
 	~LLDrawInfo();	
 	
 public:
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 
 	LLDrawInfo(const LLDrawInfo& rhs)
 	{
@@ -116,7 +106,7 @@ public:
 	F32 mPartSize;
 	F32 mVSize;
 	LLSpatialGroup* mGroup;
-	LL_ALIGN_16(LLFace* mFace); //associated face
+	LLFace* mFace; //associated face
 	F32 mDistance;
 	U32 mDrawMode;
 
@@ -191,7 +181,7 @@ public:
 	};
 };
 
-LL_ALIGN_PREFIX(16)
+LL_ALIGN_PREFIX(64)
 class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 {
 	friend class LLSpatialPartition;
@@ -203,16 +193,6 @@ public:
 		*this = rhs;
 	}
 
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 	const LLSpatialGroup& operator=(const LLSpatialGroup& rhs)
 	{
 		llerrs << "Illegal operation!" << llendl;
@@ -345,13 +325,8 @@ public:
 
 	void dirtyGeom() { setState(GEOM_DIRTY); }
 	void dirtyMesh() { setState(MESH_DIRTY); }
-
-	//octree wrappers to make code more readable
 	element_list& getData() { return mOctreeNode->getData(); }
-	element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
-	element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
 	U32 getElementCount() const { return mOctreeNode->getElementCount(); }
-	bool isEmpty() const { return mOctreeNode->isEmpty(); }
 
 	void drawObjectBox(LLColor4 col);
 
@@ -395,12 +370,12 @@ public:
 		V4_COUNT = 10
 	} eV4Index;
 
-	LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects)
-	LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
-	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
-	LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node
-	LL_ALIGN_16(LLVector4a mViewAngle);
-	LL_ALIGN_16(LLVector4a mLastUpdateViewAngle);
+	LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LLVector4a mExtents[2]; // extents (min, max) of this node and all its children
+	LLVector4a mObjectExtents[2]; // extents (min, max) of objects in this node
+	LLVector4a mObjectBounds[2]; // bounding box (center, size) of objects in this node
+	LLVector4a mViewAngle;
+	LLVector4a mLastUpdateViewAngle;
 
 	F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3()
 		
@@ -567,39 +542,34 @@ class LLCullResult
 public:
 	LLCullResult();
 
-	typedef LLSpatialGroup** sg_list_t;
-	typedef LLDrawable** drawable_list_t;
-	typedef LLSpatialBridge** bridge_list_t;
-	typedef LLDrawInfo** drawinfo_list_t;
-
-	typedef LLSpatialGroup** sg_iterator;
-	typedef LLSpatialBridge** bridge_iterator;
-	typedef LLDrawInfo** drawinfo_iterator;
-	typedef LLDrawable** drawable_iterator;
+	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;
 
 	void clear();
 	
-	sg_iterator beginVisibleGroups();
-	sg_iterator endVisibleGroups();
+	sg_list_t::iterator beginVisibleGroups();
+	sg_list_t::iterator endVisibleGroups();
 
-	sg_iterator beginAlphaGroups();
-	sg_iterator endAlphaGroups();
+	sg_list_t::iterator beginAlphaGroups();
+	sg_list_t::iterator endAlphaGroups();
 
 	bool hasOcclusionGroups() { return mOcclusionGroupsSize > 0; }
-	sg_iterator beginOcclusionGroups();
-	sg_iterator endOcclusionGroups();
+	sg_list_t::iterator beginOcclusionGroups();
+	sg_list_t::iterator endOcclusionGroups();
 
-	sg_iterator beginDrawableGroups();
-	sg_iterator endDrawableGroups();
+	sg_list_t::iterator beginDrawableGroups();
+	sg_list_t::iterator endDrawableGroups();
 
-	drawable_iterator beginVisibleList();
-	drawable_iterator endVisibleList();
+	drawable_list_t::iterator beginVisibleList();
+	drawable_list_t::iterator endVisibleList();
 
-	bridge_iterator beginVisibleBridge();
-	bridge_iterator endVisibleBridge();
+	bridge_list_t::iterator beginVisibleBridge();
+	bridge_list_t::iterator endVisibleBridge();
 
-	drawinfo_iterator beginRenderMap(U32 type);
-	drawinfo_iterator endRenderMap(U32 type);
+	drawinfo_list_t::iterator beginRenderMap(U32 type);
+	drawinfo_list_t::iterator endRenderMap(U32 type);
 
 	void pushVisibleGroup(LLSpatialGroup* group);
 	void pushAlphaGroup(LLSpatialGroup* group);
@@ -619,41 +589,28 @@ public:
 	void assertDrawMapsEmpty();
 
 private:
-
-	void pushBack(void** &head, U32& count, void* val);
-
 	U32					mVisibleGroupsSize;
 	U32					mAlphaGroupsSize;
 	U32					mOcclusionGroupsSize;
 	U32					mDrawableGroupsSize;
 	U32					mVisibleListSize;
 	U32					mVisibleBridgeSize;
-
-	U32					mVisibleGroupsAllocated;
-	U32					mAlphaGroupsAllocated;
-	U32					mOcclusionGroupsAllocated;
-	U32					mDrawableGroupsAllocated;
-	U32					mVisibleListAllocated;
-	U32					mVisibleBridgeAllocated;
-
 	U32					mRenderMapSize[LLRenderPass::NUM_RENDER_TYPES];
 
 	sg_list_t			mVisibleGroups;
-	sg_iterator			mVisibleGroupsEnd;
+	sg_list_t::iterator mVisibleGroupsEnd;
 	sg_list_t			mAlphaGroups;
-	sg_iterator			mAlphaGroupsEnd;
+	sg_list_t::iterator mAlphaGroupsEnd;
 	sg_list_t			mOcclusionGroups;
-	sg_iterator			mOcclusionGroupsEnd;
+	sg_list_t::iterator	mOcclusionGroupsEnd;
 	sg_list_t			mDrawableGroups;
-	sg_iterator			mDrawableGroupsEnd;
+	sg_list_t::iterator mDrawableGroupsEnd;
 	drawable_list_t		mVisibleList;
-	drawable_iterator	mVisibleListEnd;
+	drawable_list_t::iterator mVisibleListEnd;
 	bridge_list_t		mVisibleBridge;
-	bridge_iterator		mVisibleBridgeEnd;
+	bridge_list_t::iterator mVisibleBridgeEnd;
 	drawinfo_list_t		mRenderMap[LLRenderPass::NUM_RENDER_TYPES];
-	U32					mRenderMapAllocated[LLRenderPass::NUM_RENDER_TYPES];
-	drawinfo_iterator mRenderMapEnd[LLRenderPass::NUM_RENDER_TYPES];
-
+	drawinfo_list_t::iterator mRenderMapEnd[LLRenderPass::NUM_RENDER_TYPES];
 };
 
 
diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp
index f64a72a616..65393cc168 100644
--- a/indra/newview/llsurface.cpp
+++ b/indra/newview/llsurface.cpp
@@ -56,7 +56,6 @@
 #include "lldrawable.h"
 
 extern LLPipeline gPipeline;
-extern bool gShiftFrame;
 
 LLColor4U MAX_WATER_COLOR(0, 48, 96, 240);
 
@@ -295,7 +294,7 @@ void LLSurface::initTextures()
 		mWaterObjp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, mRegionp);
 		gPipeline.createObject(mWaterObjp);
 		LLVector3d water_pos_global = from_region_handle(mRegionp->getHandle());
-		water_pos_global += LLVector3d(128.0, 128.0, DEFAULT_WATER_HEIGHT);		// region doesn't have a valid water height yet
+		water_pos_global += LLVector3d(128.0, 128.0, DEFAULT_WATER_HEIGHT);
 		mWaterObjp->setPositionGlobal(water_pos_global);
 	}
 }
@@ -622,11 +621,6 @@ void LLSurface::moveZ(const S32 x, const S32 y, const F32 delta)
 
 void LLSurface::updatePatchVisibilities(LLAgent &agent) 
 {
-	if (gShiftFrame)
-	{
-		return;
-	}
-
 	LLVector3 pos_region = mRegionp->getPosRegionFromGlobal(gAgentCamera.getCameraPositionGlobal());
 
 	LLSurfacePatch *patchp;
diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp
index a9ba2bce9c..5077c2c7e1 100644
--- a/indra/newview/llsurfacepatch.cpp
+++ b/indra/newview/llsurfacepatch.cpp
@@ -43,7 +43,6 @@
 #include "lldrawpool.h"
 #include "noise.h"
 
-extern bool gShiftFrame;
 extern U64 gFrameTime;
 extern LLPipeline gPipeline;
 
@@ -219,7 +218,7 @@ void LLSurfacePatch::eval(const U32 x, const U32 y, const U32 stride, LLVector3
 	pos_agent.mV[VX] += x * mSurfacep->getMetersPerGrid();
 	pos_agent.mV[VY] += y * mSurfacep->getMetersPerGrid();
 	pos_agent.mV[VZ]  = *(mDataZ + point_offset);
-	*vertex     = pos_agent-mVObjp->getRegion()->getOriginAgent();
+	*vertex     = pos_agent;
 
 	LLVector3 rel_pos = pos_agent - mSurfacep->getOriginAgent();
 	LLVector3 tex_pos = rel_pos * (1.f/surface_stride);
@@ -367,13 +366,10 @@ void LLSurfacePatch::updateCameraDistanceRegion(const LLVector3 &pos_region)
 {
 	if (LLPipeline::sDynamicLOD)
 	{
-		if (!gShiftFrame)
-		{
-			LLVector3 dv = pos_region;
-			dv -= mCenterRegion;
-			mVisInfo.mDistance = llmax(0.f, (F32)(dv.magVec() - mRadius))/
-				llmax(LLVOSurfacePatch::sLODFactor, 0.1f);
-		}
+		LLVector3 dv = pos_region;
+		dv -= mCenterRegion;
+		mVisInfo.mDistance = llmax(0.f, (F32)(dv.magVec() - mRadius))/
+			llmax(LLVOSurfacePatch::sLODFactor, 0.1f);
 	}
 	else
 	{
diff --git a/indra/newview/lltexlayerparams.h b/indra/newview/lltexlayerparams.h
index 2c0da60b48..74c22b0cdf 100644
--- a/indra/newview/lltexlayerparams.h
+++ b/indra/newview/lltexlayerparams.h
@@ -76,11 +76,11 @@ public:
 
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion()									{ return 1.f; }
-	/*virtual*/ const LLVector4a&	getAvgDistortion()										{ return mAvgDistortionVec; }
+	/*virtual*/ const LLVector3&	getAvgDistortion()										{ return mAvgDistortionVec; }
 	/*virtual*/ F32					getMaxDistortion()										{ return 3.f; }
-	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector4a(1.f, 1.f, 1.f);}
-	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
-	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
+	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector3(1.f, 1.f, 1.f);}
+	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
+	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
 
 	// New functions
 	BOOL					render( S32 x, S32 y, S32 width, S32 height );
@@ -94,7 +94,7 @@ private:
 	LLPointer<LLImageRaw>	mStaticImageRaw;
 	BOOL					mNeedsCreateTexture;
 	BOOL					mStaticImageInvalid;
-	LLVector4a				mAvgDistortionVec;
+	LLVector3				mAvgDistortionVec;
 	F32						mCachedEffectiveWeight;
 
 public:
@@ -155,18 +155,18 @@ public:
 
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion()									{ return 1.f; }
-	/*virtual*/ const LLVector4a&	getAvgDistortion()										{ return mAvgDistortionVec; }
+	/*virtual*/ const LLVector3&	getAvgDistortion()										{ return mAvgDistortionVec; }
 	/*virtual*/ F32					getMaxDistortion()										{ return 3.f; }
-	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector4a(1.f, 1.f, 1.f); }
-	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
-	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
+	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector3(1.f, 1.f, 1.f); }
+	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
+	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
 
 	// New functions
 	LLColor4				getNetColor() const;
 protected:
 	virtual void onGlobalColorChanged(bool upload_bake) {}
 private:
-	LLVector4a				mAvgDistortionVec;
+	LLVector3				mAvgDistortionVec;
 };
 
 class LLTexLayerParamColorInfo : public LLViewerVisualParamInfo
diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h
index b857c7fe89..184033de42 100644
--- a/indra/newview/llviewercamera.h
+++ b/indra/newview/llviewercamera.h
@@ -51,19 +51,9 @@ const BOOL NOT_FOR_SELECTION = FALSE;
 extern template class LLViewerCamera* LLSingleton<class LLViewerCamera>::getInstance();
 #endif
 
-LL_ALIGN_PREFIX(16)
 class LLViewerCamera : public LLCamera, public LLSingleton<LLViewerCamera>
 {
 public:
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
 
 	typedef enum
 	{
@@ -147,7 +137,6 @@ protected:
 	S16					mZoomSubregion;
 
 public:
-} LL_ALIGN_POSTFIX(16);
-
+};
 
 #endif // LL_LLVIEWERCAMERA_H
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index d58ee05fb6..9ef012ece1 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -79,7 +79,6 @@
 #include "llpostprocess.h"
 
 extern LLPointer<LLViewerTexture> gStartTexture;
-extern bool gShiftFrame;
 
 LLPointer<LLViewerTexture> gDisconnectedImagep = NULL;
 
@@ -163,11 +162,8 @@ void display_startup()
 	glClear(GL_DEPTH_BUFFER_BIT);
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_CAMERA("Update Camera");
-
 void display_update_camera()
 {
-	LLFastTimer t(FTM_UPDATE_CAMERA);
 	LLMemType mt_uc(LLMemType::MTYPE_DISPLAY_UPDATE_CAMERA);
 	// TODO: cut draw distance down if customizing avatar?
 	// TODO: cut draw distance on per-parcel basis?
@@ -221,11 +217,6 @@ static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_CLASS("Class");
 static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_BUMP("Bump");
 static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_LIST("List");
 static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_DELETE("Delete");
-static LLFastTimer::DeclareTimer FTM_RESIZE_WINDOW("Resize Window");
-static LLFastTimer::DeclareTimer FTM_HUD_UPDATE("HUD Update");
-static LLFastTimer::DeclareTimer FTM_DISPLAY_UPDATE_GEOM("Update Geom");
-static LLFastTimer::DeclareTimer FTM_TEXTURE_UNBIND("Texture Unbind");
-static LLFastTimer::DeclareTimer FTM_TELEPORT_DISPLAY("Teleport Display");
 
 // Paint the display!
 void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
@@ -235,7 +226,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 	if (gWindowResized)
 	{ //skip render on frames where window has been resized
-		LLFastTimer t(FTM_RESIZE_WINDOW);
 		gGL.flush();
 		glClear(GL_COLOR_BUFFER_BIT);
 		gViewerWindow->getWindow()->swapBuffers();
@@ -372,7 +362,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 	if (gTeleportDisplay)
 	{
-		LLFastTimer t(FTM_TELEPORT_DISPLAY);
 		LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport");
 		const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived.
 
@@ -602,7 +591,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 				
 		// *TODO: merge these two methods
 		{
-			LLFastTimer t(FTM_HUD_UPDATE);
 			LLMemType mt_uh(LLMemType::MTYPE_DISPLAY_UPDATE_HUD);
 			LLHUDManager::getInstance()->updateEffects();
 			LLHUDObject::updateAll();
@@ -610,7 +598,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		}
 
 		{
-			LLFastTimer t(FTM_DISPLAY_UPDATE_GEOM);
 			LLMemType mt_ug(LLMemType::MTYPE_DISPLAY_UPDATE_GEOM);
 			const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time
 			gPipeline.createObjects(max_geom_update_time);
@@ -620,7 +607,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		}
 
 		gPipeline.updateGL();
-		
 		stop_glerror();
 
 		S32 water_clip = 0;
@@ -952,18 +938,14 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			stop_glerror();
 		}
 
-		{
-			LLFastTimer t(FTM_TEXTURE_UNBIND);
-			for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++)
-			{ //dummy cleanup of any currently bound textures
-				if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE)
-				{
-					gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType());
-					gGL.getTexUnit(i)->disable();
-				}
+		for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++)
+		{ //dummy cleanup of any currently bound textures
+			if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE)
+			{
+				gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType());
+				gGL.getTexUnit(i)->disable();
 			}
 		}
-
 		LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush");		
 		
 		if (to_texture)
@@ -1029,8 +1011,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 	display_stats();
 				
 	LLAppViewer::instance()->pingMainloopTimeout("Display:Done");
-
-	gShiftFrame = false;
 }
 
 void render_hud_attachments()
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 5d1aa870a3..f029ae5302 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -729,10 +729,8 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 				F32* vw = (F32*) vertex_weightsp.get();
 				F32* cw = (F32*) clothing_weightsp.get();	
 
-				S32 tc_size = (num_verts*2*sizeof(F32)+0xF) & ~0xF;
-				LLVector4a::memcpyNonAliased16(tc, (F32*) mMesh->getTexCoords(), tc_size);
-				S32 vw_size = (num_verts*sizeof(F32)+0xF) & ~0xF;	
-				LLVector4a::memcpyNonAliased16(vw, (F32*) mMesh->getWeights(), vw_size);	
+				LLVector4a::memcpyNonAliased16(tc, (F32*) mMesh->getTexCoords(), num_verts*2*sizeof(F32));
+				LLVector4a::memcpyNonAliased16(vw, (F32*) mMesh->getWeights(), num_verts*sizeof(F32));	
 				LLVector4a::memcpyNonAliased16(cw, (F32*) mMesh->getClothingWeights(), num_verts*4*sizeof(F32));	
 			}
 
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 01a54509ef..d11e7e32c7 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -5134,12 +5134,6 @@ class LLEditDelete : public view_listener_t
 	}
 };
 
-bool enable_object_return()
-{
-	return (!LLSelectMgr::getInstance()->getSelection()->isEmpty() &&
-		(gAgent.isGodlike() || can_derez(DRD_RETURN_TO_OWNER)));
-}
-
 void handle_spellcheck_replace_with_suggestion(const LLUICtrl* ctrl, const LLSD& param)
 {
 	const LLContextMenu* menu = dynamic_cast<const LLContextMenu*>(ctrl->getParent());
@@ -5212,6 +5206,12 @@ bool enable_spellcheck_add_to_ignore(const LLUICtrl* ctrl)
 	return (spellcheck_handler) && (spellcheck_handler->canAddToIgnore());
 }
 
+bool enable_object_return()
+{
+	return (!LLSelectMgr::getInstance()->getSelection()->isEmpty() &&
+		(gAgent.isGodlike() || can_derez(DRD_RETURN_TO_OWNER)));
+}
+
 bool enable_object_delete()
 {
 	bool new_value = 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 903f4437a7..7d7d1f3047 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -134,7 +134,6 @@ static const U32 LLREQUEST_PERMISSION_THROTTLE_LIMIT	= 5;     // requests
 static const F32 LLREQUEST_PERMISSION_THROTTLE_INTERVAL	= 10.0f; // seconds
 
 extern BOOL gDebugClicks;
-extern bool gShiftFrame;
 
 // function prototypes
 bool check_offer_throttle(const std::string& from_name, bool check_only);
@@ -3931,7 +3930,6 @@ void process_avatar_init_complete(LLMessageSystem* msg, void**)
 
 void process_agent_movement_complete(LLMessageSystem* msg, void**)
 {
-	gShiftFrame = true;
 	gAgentMovementCompleted = true;
 
 	LLUUID agent_id;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 6c4e70add0..572003d2ce 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -199,7 +199,6 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mID(id),
 	mLocalID(0),
 	mTotalCRC(0),
-	mListIndex(-1),
 	mTEImages(NULL),
 	mGLName(0),
 	mbCanSelect(TRUE),
@@ -2180,8 +2179,8 @@ BOOL LLViewerObject::isActive() const
 
 BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
-	//static LLFastTimer::DeclareTimer ftm("Viewer Object");
-	//LLFastTimer t(ftm);
+	static LLFastTimer::DeclareTimer ftm("Viewer Object");
+	LLFastTimer t(ftm);
 
 	if (mDead)
 	{
@@ -4182,7 +4181,7 @@ S32 LLViewerObject::setTETextureCore(const U8 te, const LLUUID& uuid, LLHost hos
 	return retval;
 }
 
-
+//virtual
 void LLViewerObject::changeTEImage(S32 index, LLViewerTexture* new_image) 
 {
 	if(index < 0 || index >= getNumTEs())
@@ -4801,11 +4800,9 @@ void LLViewerObject::deleteParticleSource()
 // virtual
 void LLViewerObject::updateDrawable(BOOL force_damped)
 {
-	if (!isChanged(MOVED))
-	{ //most common case, having an empty if case here makes for better branch prediction
-	}
-	else if (mDrawable.notNull() && 
-		!mDrawable->isState(LLDrawable::ON_MOVE_LIST))
+	if (mDrawable.notNull() && 
+		!mDrawable->isState(LLDrawable::ON_MOVE_LIST) &&
+		isChanged(MOVED))
 	{
 		BOOL damped_motion = 
 			!isChanged(SHIFTED) &&										// not shifted between regions this frame and...
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 05d017dee3..83e34dc6ca 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -232,8 +232,6 @@ public:
 	const LLUUID &getID() const						{ return mID; }
 	U32 getLocalID() const							{ return mLocalID; }
 	U32 getCRC() const								{ return mTotalCRC; }
-	S32 getListIndex() const						{ return mListIndex; }
-	void setListIndex(S32 idx)						{ mListIndex = idx; }
 
 	virtual BOOL isFlexible() const					{ return FALSE; }
 	virtual BOOL isSculpted() const 				{ return FALSE; }
@@ -336,7 +334,7 @@ public:
 	/*virtual*/ S32     setTEGlow(const U8 te, const F32 glow);
 	/*virtual*/	BOOL	setMaterial(const U8 material);
 	virtual		void	setTEImage(const U8 te, LLViewerTexture *imagep); // Not derived from LLPrimitive
-	void                changeTEImage(S32 index, LLViewerTexture* new_image)  ;
+	virtual     void    changeTEImage(S32 index, LLViewerTexture* new_image)  ;
 	LLViewerTexture		*getTEImage(const U8 te) const;
 	
 	void fitFaceTexture(const U8 face);
@@ -608,9 +606,6 @@ public:
 	// Last total CRC received from sim, used for caching
 	U32				mTotalCRC;
 
-	// index into LLViewerObjectList::mActiveObjects or -1 if not in list
-	S32				mListIndex;
-
 	LLPointer<LLViewerTexture> *mTEImages;
 
 	// Selection, picking and rendering variables
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index ea20950b36..28298cedf9 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -914,30 +914,21 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	LLViewerObject *objectp = NULL;	
 	
 	// Make a copy of the list in case something in idleUpdate() messes with it
-	static std::vector<LLViewerObject*> idle_list;
-
-	U32 idle_count = 0;
-		
+	std::vector<LLViewerObject*> idle_list;
+	
 	static LLFastTimer::DeclareTimer idle_copy("Idle Copy");
 
 	{
 		LLFastTimer t(idle_copy);
-		
- 		for (std::vector<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
+		idle_list.reserve( mActiveObjects.size() );
+
+ 		for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
 			active_iter != mActiveObjects.end(); active_iter++)
 		{
 			objectp = *active_iter;
 			if (objectp)
 			{
-				if (idle_count >= idle_list.size())
-				{
-					idle_list.push_back( objectp );
-				}
-				else
-				{
-					idle_list[idle_count] = objectp;
-				}
-				++idle_count;
+				idle_list.push_back( objectp );
 			}
 			else
 			{	// There shouldn't be any NULL pointers in the list, but they have caused
@@ -947,13 +938,10 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 		}
 	}
 
-	std::vector<LLViewerObject*>::iterator idle_end = idle_list.begin()+idle_count;
-
 	if (gSavedSettings.getBOOL("FreezeTime"))
 	{
-		
 		for (std::vector<LLViewerObject*>::iterator iter = idle_list.begin();
-			iter != idle_end; iter++)
+			iter != idle_list.end(); iter++)
 		{
 			objectp = *iter;
 			if (objectp->isAvatar())
@@ -965,17 +953,17 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	else
 	{
 		for (std::vector<LLViewerObject*>::iterator idle_iter = idle_list.begin();
-			idle_iter != idle_end; idle_iter++)
+			idle_iter != idle_list.end(); idle_iter++)
 		{
 			objectp = *idle_iter;
-			if (objectp->idleUpdate(agent, world, frame_time))
+			if (!objectp->idleUpdate(agent, world, frame_time))
 			{
-				num_active_objects++;				
+				//  If Idle Update returns false, kill object!
+				kill_list.push_back(objectp);
 			}
 			else
 			{
-				//  If Idle Update returns false, kill object!
-				kill_list.push_back(objectp);
+				num_active_objects++;
 			}
 		}
 		for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin();
@@ -1213,7 +1201,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 	{
 		//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list in cleanupReferences." << llendl;
 		objectp->setOnActiveList(FALSE);
-		removeFromActiveList(objectp);
+		mActiveObjects.erase(objectp);
 	}
 
 	if (objectp->isOnMap())
@@ -1390,26 +1378,6 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer)
 	mNumDeadObjects = 0;
 }
 
-void LLViewerObjectList::removeFromActiveList(LLViewerObject* objectp)
-{
-	S32 idx = objectp->getListIndex();
-	if (idx != -1)
-	{ //remove by moving last element to this object's position
-		llassert(mActiveObjects[idx] == objectp);
-		
-		objectp->setListIndex(-1);
-
-		S32 last_index = mActiveObjects.size()-1;
-
-		if (idx != last_index)
-		{
-			mActiveObjects[idx] = mActiveObjects[last_index];
-			mActiveObjects[idx]->setListIndex(idx);
-			mActiveObjects.pop_back();
-		}
-	}
-}
-
 void LLViewerObjectList::updateActive(LLViewerObject *objectp)
 {
 	LLMemType mt(LLMemType::MTYPE_OBJECT);
@@ -1424,29 +1392,13 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
 		if (active)
 		{
 			//llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl;
-			S32 idx = objectp->getListIndex();
-			if (idx <= -1)
-			{
-				mActiveObjects.push_back(objectp);
-				objectp->setListIndex(mActiveObjects.size()-1);
-				objectp->setOnActiveList(TRUE);
-			}
-			else
-			{
-				llassert(idx < mActiveObjects.size());
-				llassert(mActiveObjects[idx] == objectp);
-
-				if (idx >= mActiveObjects.size() ||
-					mActiveObjects[idx] != objectp)
-				{
-					llwarns << "Invalid object list index detected!" << llendl;
-				}
-			}
+			mActiveObjects.insert(objectp);
+			objectp->setOnActiveList(TRUE);
 		}
 		else
 		{
 			//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << llendl;
-			removeFromActiveList(objectp);
+			mActiveObjects.erase(objectp);
 			objectp->setOnActiveList(FALSE);
 		}
 	}
@@ -1520,10 +1472,6 @@ void LLViewerObjectList::onPhysicsFlagsFetchFailure(const LLUUID& object_id)
 	mPendingPhysicsFlags.erase(object_id);
 }
 
-static LLFastTimer::DeclareTimer FTM_SHIFT_OBJECTS("Shift Objects");
-static LLFastTimer::DeclareTimer FTM_PIPELINE_SHIFT("Pipeline Shift");
-static LLFastTimer::DeclareTimer FTM_REGION_SHIFT("Region Shift");
-
 void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 {
 	// This is called when we shift our origin when we cross region boundaries...
@@ -1535,8 +1483,6 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 		return;
 	}
 
-	LLFastTimer t(FTM_SHIFT_OBJECTS);
-
 	LLViewerObject *objectp;
 	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 	{
@@ -1553,15 +1499,8 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 		}
 	}
 
-	{
-		LLFastTimer t(FTM_PIPELINE_SHIFT);
-		gPipeline.shiftObjects(offset);
-	}
-
-	{
-		LLFastTimer t(FTM_REGION_SHIFT);
-		LLWorld::getInstance()->shiftRegions(offset);
-	}
+	gPipeline.shiftObjects(offset);
+	LLWorld::getInstance()->shiftRegions(offset);
 }
 
 void LLViewerObjectList::repartitionObjects()
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 9936432a71..64925f46ae 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -118,9 +118,7 @@ public:
 
 	void dirtyAllObjectInventory();
 
-	void removeFromActiveList(LLViewerObject* objectp);
 	void updateActive(LLViewerObject *objectp);
-	
 	void updateAvatarVisibility();
 
 	// Selection related stuff
@@ -199,7 +197,7 @@ protected:
 	typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
 
 	vobj_list_t mObjects;
-	std::vector<LLPointer<LLViewerObject> > mActiveObjects;
+	std::set<LLPointer<LLViewerObject> > mActiveObjects;
 
 	vobj_list_t mMapObjects;
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 05c7ef5381..493195aaa3 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1487,8 +1487,7 @@ void LLViewerRegion::unpackRegionHandshake()
 		// all of our terrain stuff, by
 		if (compp->getParamsReady())
 		{
-			//this line creates frame stalls on region crossing and removing it appears to have no effect
-			//getLand().dirtyAllPatches();
+			getLand().dirtyAllPatches();
 		}
 		else
 		{
diff --git a/indra/newview/llviewervisualparam.h b/indra/newview/llviewervisualparam.h
index 3bc95cbfbf..dd7751acd7 100644
--- a/indra/newview/llviewervisualparam.h
+++ b/indra/newview/llviewervisualparam.h
@@ -83,11 +83,11 @@ public:
 
 	// New Virtual functions
 	virtual F32					getTotalDistortion() = 0;
-	virtual const LLVector4a&	getAvgDistortion() = 0;
+	virtual const LLVector3&	getAvgDistortion() = 0;
 	virtual F32					getMaxDistortion() = 0;
-	virtual LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *mesh) = 0;
-	virtual const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **mesh) = 0;
-	virtual const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **mesh) = 0;
+	virtual LLVector3			getVertexDistortion(S32 index, LLPolyMesh *mesh) = 0;
+	virtual const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **mesh) = 0;
+	virtual const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **mesh) = 0;
 	
 	// interface methods
 	F32					getDisplayOrder() const		{ return getInfo()->mEditGroupDisplayOrder; }
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index af2eec9ba8..30bb787fa7 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -4768,11 +4768,8 @@ void LLViewerWindow::requestResolutionUpdate()
 	mResDirty = true;
 }
 
-static LLFastTimer::DeclareTimer FTM_WINDOW_CHECK_SETTINGS("Window Settings");
-
 void LLViewerWindow::checkSettings()
 {
-	LLFastTimer t(FTM_WINDOW_CHECK_SETTINGS);
 	if (mStatesDirty)
 	{
 		gGL.refreshState();
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 05febdf93b..33dc12c473 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -817,7 +817,6 @@ LLVOAvatar::~LLVOAvatar()
 	lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl;
 
 	mRoot.removeAllChildren();
-	mJointMap.clear();
 
 	deleteAndClearArray(mSkeleton);
 	deleteAndClearArray(mCollisionVolumes);
@@ -1460,6 +1459,8 @@ void LLVOAvatar::onShift(const LLVector4a& shift_vector)
 	const LLVector3& shift = reinterpret_cast<const LLVector3&>(shift_vector);
 	mLastAnimExtents[0] += shift;
 	mLastAnimExtents[1] += shift;
+	mNeedsImpostorUpdate = TRUE;
+	mNeedsAnimUpdate = TRUE;
 }
 
 void LLVOAvatar::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
@@ -1933,7 +1934,6 @@ void LLVOAvatar::buildCharacter()
 	// remove all of mRoot's children
 	//-------------------------------------------------------------------------
 	mRoot.removeAllChildren();
-	mJointMap.clear();
 	mIsBuilt = FALSE;
 
 	//-------------------------------------------------------------------------
@@ -2390,7 +2390,7 @@ S32 LLVOAvatar::setTETexture(const U8 te, const LLUUID& uuid)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_AVATAR_UPDATE("Avatar Update");
+static LLFastTimer::DeclareTimer FTM_AVATAR_UPDATE("Update Avatar");
 static LLFastTimer::DeclareTimer FTM_JOINT_UPDATE("Update Joints");
 
 //------------------------------------------------------------------------
@@ -2692,7 +2692,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 
 	if (isImpostor() && !mNeedsImpostorUpdate)
 	{
-		LL_ALIGN_16(LLVector4a ext[2]);
+		LLVector4a ext[2];
 		F32 distance;
 		LLVector3 angle;
 
@@ -5137,20 +5137,7 @@ const LLUUID& LLVOAvatar::getID() const
 // RN: avatar joints are multi-rooted to include screen-based attachments
 LLJoint *LLVOAvatar::getJoint( const std::string &name )
 {
-	joint_map_t::iterator iter = mJointMap.find(name);
-
-	LLJoint* jointp = NULL;
-
-	if (iter == mJointMap.end() || iter->second == NULL)
-	{ //search for joint and cache found joint in lookup table
-		jointp = mRoot.findJoint(name);
-		mJointMap[name] = jointp;
-	}
-	else
-	{ //return cached pointer
-		jointp = iter->second;
-	}
-
+	LLJoint* jointp = mRoot.findJoint(name);
 	return jointp;
 }
 
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index f5692bb52f..6fb56a4c0b 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -93,16 +93,6 @@ protected:
  **/
 
 public:
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 	LLVOAvatar(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
 	virtual void		markDead();
 	static void			initClass(); // Initialize data that's only init'd once per class.
@@ -225,7 +215,7 @@ public:
 	bool isBuilt() const { return mIsBuilt; }
 
 private: //aligned members
-	LL_ALIGN_16(LLVector4a	mImpostorExtents[2]);
+	LLVector4a	mImpostorExtents[2];
 
 private:
 	BOOL			mSupportsAlphaLayers; // For backwards compatibility, TRUE for 1.23+ clients
@@ -366,10 +356,6 @@ public:
 
 	LLVector3			mHeadOffset; // current head position
 	LLViewerJoint		mRoot;
-
-	typedef std::map<std::string, LLJoint*> joint_map_t;
-	joint_map_t			mJointMap;
-
 protected:
 	static BOOL			parseSkeletonFile(const std::string& filename);
 	void				buildCharacter();
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index 2b273e616c..543891ca63 100644
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -49,16 +49,6 @@ class LLVOAvatarSelf :
  **/
 
 public:
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 	LLVOAvatarSelf(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
 	virtual 				~LLVOAvatarSelf();
 	virtual void			markDead();
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index 5ad9ccc9af..44968342bf 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -622,7 +622,7 @@ void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count
 	mFaceList.clear();
 
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
-	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 	{
 		LLDrawable* drawablep = *i;
 		
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 9cce68fff6..e21358b65a 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -52,7 +52,8 @@ LLPointer<LLVertexBuffer> LLVOPartGroup::sVB = NULL;
 S32 LLVOPartGroup::sVBSlotFree[];
 S32* LLVOPartGroup::sVBSlotCursor = NULL;
 
-void LLVOPartGroup::initClass()
+//static
+void LLVOPartGroup::restoreGL()
 {
 	for (S32 i = 0; i < LL_MAX_PARTICLE_COUNT; ++i)
 	{
@@ -60,11 +61,7 @@ void LLVOPartGroup::initClass()
 	}
 
 	sVBSlotCursor = sVBSlotFree;
-}
 
-//static
-void LLVOPartGroup::restoreGL()
-{
 	sVB = new LLVertexBuffer(VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB);
 	U32 count = LL_MAX_PARTICLE_COUNT;
 	sVB->allocateBuffer(count*4, count*6, true);
@@ -557,7 +554,7 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co
 	mFaceList.clear();
 
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
-	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 	{
 		LLDrawable* drawablep = *i;
 		
@@ -629,7 +626,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
 		LLFace* facep = *i;
 		LLAlphaObject* object = (LLAlphaObject*) facep->getViewerObject();
 
-		if (!facep->isState(LLFace::PARTICLE))
+		if (facep->getIndicesStart() == 0xFFFFFFFF)
 		{ //set the indices of this face
 			S32 idx = LLVOPartGroup::findAvailableVBSlot();
 			if (idx >= 0)
@@ -638,7 +635,6 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
 				facep->setIndicesIndex(idx*6);
 				facep->setVertexBuffer(LLVOPartGroup::sVB);
 				facep->setPoolType(LLDrawPool::POOL_ALPHA);
-				facep->setState(LLFace::PARTICLE);
 			}
 			else
 			{
diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h
index 43b2844f07..6160bceb24 100644
--- a/indra/newview/llvopartgroup.h
+++ b/indra/newview/llvopartgroup.h
@@ -45,7 +45,6 @@ public:
 	static S32 sVBSlotFree[LL_MAX_PARTICLE_COUNT];
 	static S32* sVBSlotCursor;
 
-	static void initClass();
 	static void restoreGL();
 	static void destroyGL();
 	static S32 findAvailableVBSlot();
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 337ddfb24d..3556bde9a8 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -374,7 +374,7 @@ BOOL LLVOTree::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 		// *TODO: I don't know what's so special about trees
 		// that they don't get REBUILD_POSITION automatically
 		// at a higher level.
-		const LLVector3 &this_position = getPositionRegion();
+		const LLVector3 &this_position = getPositionAgent();
 		if (this_position != mLastPosition)
 		{
 			gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION);
@@ -843,10 +843,10 @@ void LLVOTree::updateMesh()
 	LLMatrix4 matrix;
 	
 	// Translate to tree base  HACK - adjustment in Z plants tree underground
-	const LLVector3 &pos_region = getPositionRegion();
+	const LLVector3 &pos_agent = getPositionAgent();
 	//gGL.translatef(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);
 	LLMatrix4 trans_mat;
-	trans_mat.setTranslation(pos_region.mV[VX], pos_region.mV[VY], pos_region.mV[VZ] - 0.1f);
+	trans_mat.setTranslation(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);
 	trans_mat *= matrix;
 	
 	// Rotate to tree position and bend for current trunk/wind
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index a656179c8f..0abe73d55e 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -639,8 +639,8 @@ BOOL LLVOVolume::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
 	LLViewerObject::idleUpdate(agent, world, time);
 
-	//static LLFastTimer::DeclareTimer ftm("Volume Idle");
-	//LLFastTimer t(ftm);
+	static LLFastTimer::DeclareTimer ftm("Volume Idle");
+	LLFastTimer t(ftm);
 
 	if (mDead || mDrawable.isNull())
 	{
@@ -1842,6 +1842,18 @@ void LLVOVolume::setNumTEs(const U8 num_tes)
 	return ;
 }
 
+//virtual     
+void LLVOVolume::changeTEImage(S32 index, LLViewerTexture* imagep)
+{
+	BOOL changed = (mTEImages[index] != imagep);
+	LLViewerObject::changeTEImage(index, imagep);
+	if (changed)
+	{
+		gPipeline.markTextured(mDrawable);
+		mFaceMappingChanged = TRUE;
+	}
+}
+
 void LLVOVolume::setTEImage(const U8 te, LLViewerTexture *imagep)
 {
 	BOOL changed = (mTEImages[te] != imagep);
@@ -4239,7 +4251,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 		LLFastTimer t(FTM_REBUILD_VOLUME_FACE_LIST);
 
 		//get all the faces into a list
-		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
+		for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
 		{
 			LLDrawable* drawablep = *drawable_iter;
 		
@@ -4645,7 +4657,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 	if (!LLPipeline::sDelayVBUpdate)
 	{
 		//drawables have been rebuilt, clear rebuild status
-		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
+		for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
 		{
 			LLDrawable* drawablep = *drawable_iter;
 			drawablep->clearState(LLDrawable::REBUILD_ALL);
@@ -4685,7 +4697,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 		
 		std::set<LLVertexBuffer*> mapped_buffers;
 
-		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
+		for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
 		{
 			LLDrawable* drawablep = *drawable_iter;
 
@@ -4709,14 +4721,8 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 						if (buff)
 						{
 							llassert(!face->isState(LLFace::RIGGED));
-
-							if (!face->getGeometryVolume(*volume, face->getTEOffset(), 
-								vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex()))
-							{ //something's gone wrong with the vertex buffer accounting, rebuild this group 
-								group->dirtyGeom();
-								gPipeline.markRebuild(group, TRUE);
-							}
-
+							face->getGeometryVolume(*volume, face->getTEOffset(), 
+								vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex());
 
 							if (buff->isLocked())
 							{
@@ -4753,7 +4759,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 		if(num_mapped_veretx_buffer != LLVertexBuffer::sMappedCount) 
 		{
 			llwarns << "Not all mapped vertex buffers are unmapped!" << llendl ; 
-			for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
+			for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
 			{
 				LLDrawable* drawablep = *drawable_iter;
 				for (S32 i = 0; i < drawablep->getNumFaces(); ++i)
@@ -5050,11 +5056,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 
 					llassert(!facep->isState(LLFace::RIGGED));
 
-					if (!facep->getGeometryVolume(*volume, te_idx, 
-						vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true))
-					{
-						llwarns << "Failed to get geometry for face!" << llendl;
-					}
+					facep->getGeometryVolume(*volume, te_idx, 
+						vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true);
 
 					if (drawablep->isState(LLDrawable::ANIMATED_CHILD))
 					{
@@ -5224,7 +5227,7 @@ void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_coun
 
 	//for each drawable
 
-	for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
+	for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
 	{
 		LLDrawable* drawablep = *drawable_iter;
 		
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 8cb69930be..25fe085421 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -68,7 +68,7 @@ class LLVolumeInterface
 public:
 	virtual ~LLVolumeInterface() { }
 	virtual LLVolumeInterfaceType getInterfaceType() const = 0;
-	virtual void doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) = 0;
+	virtual BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) = 0;
 	virtual BOOL doUpdateGeometry(LLDrawable *drawable) = 0;
 	virtual LLVector3 getPivotPosition() const = 0;
 	virtual void onSetVolume(const LLVolumeParams &volume_params, const S32 detail) = 0;
@@ -174,6 +174,7 @@ public:
 
 	/*virtual*/ void	setScale(const LLVector3 &scale, BOOL damped);
 
+	/*virtual*/ void    changeTEImage(S32 index, LLViewerTexture* new_image)  ;
 	/*virtual*/ void	setNumTEs(const U8 num_tes);
 	/*virtual*/ void	setTEImage(const U8 te, LLViewerTexture *imagep);
 	/*virtual*/ S32		setTETexture(const U8 te, const LLUUID &uuid);
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 78ee3e4fd9..b061c90d98 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -657,10 +657,7 @@ void LLWorld::updateRegions(F32 max_update_time)
 		if (did_one && max_time <= 0.f)
 			break;
 		max_time = llmin(max_time, max_update_time*.1f);
-		if (regionp->idleUpdate(max_update_time))
-		{
-			did_one = TRUE;
-		}
+		did_one |= regionp->idleUpdate(max_update_time);
 	}
 }
 
@@ -840,9 +837,6 @@ void LLWorld::updateWaterObjects()
 	}
 	mHoleWaterObjects.clear();
 
-	// Use the water height of the region we're on for areas where there is no region
-	F32 water_height = gAgent.getRegion()->getWaterHeight();
-
 	// Now, get a list of the holes
 	S32 x, y;
 	for (x = min_x; x <= max_x; x += rwidth)
@@ -851,12 +845,12 @@ void LLWorld::updateWaterObjects()
 		{
 			U64 region_handle = to_region_handle(x, y);
 			if (!getRegionFromHandle(region_handle))
-			{	// No region at that area, so make water
+			{
 				LLVOWater* waterp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, gAgent.getRegion());
 				waterp->setUseTexture(FALSE);
 				waterp->setPositionGlobal(LLVector3d(x + rwidth/2,
 													 y + rwidth/2,
-													 256.f + water_height));
+													 256.f+DEFAULT_WATER_HEIGHT));
 				waterp->setScale(LLVector3((F32)rwidth, (F32)rwidth, 512.f));
 				gPipeline.createObject(waterp);
 				mHoleWaterObjects.push_back(waterp);
@@ -913,7 +907,7 @@ void LLWorld::updateWaterObjects()
 		}
 
 		waterp->setRegion(gAgent.getRegion());
-		LLVector3d water_pos(water_center_x, water_center_y, 256.f + water_height) ;
+		LLVector3d water_pos(water_center_x, water_center_y, 256.f+DEFAULT_WATER_HEIGHT) ;
 		LLVector3 water_scale((F32) dim[0], (F32) dim[1], 512.f);
 
 		//stretch out to horizon
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 7140515e46..f01626c0fc 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -120,8 +120,6 @@
 //#define DEBUG_INDICES
 #endif
 
-bool gShiftFrame = false;
-
 //cached settings
 BOOL LLPipeline::RenderAvatarVP;
 BOOL LLPipeline::VertexShaderEnable;
@@ -219,7 +217,7 @@ BOOL	gDebugPipeline = FALSE;
 LLPipeline gPipeline;
 const LLMatrix4* gGLLastMatrix = NULL;
 
-LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY("Render Geometry");
+LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY("Geometry");
 LLFastTimer::DeclareTimer FTM_RENDER_GRASS("Grass");
 LLFastTimer::DeclareTimer FTM_RENDER_INVISIBLE("Invisible");
 LLFastTimer::DeclareTimer FTM_RENDER_OCCLUSION("Occlusion");
@@ -236,13 +234,8 @@ LLFastTimer::DeclareTimer FTM_RENDER_BUMP("Bump");
 LLFastTimer::DeclareTimer FTM_RENDER_FULLBRIGHT("Fullbright");
 LLFastTimer::DeclareTimer FTM_RENDER_GLOW("Glow");
 LLFastTimer::DeclareTimer FTM_GEO_UPDATE("Geo Update");
-LLFastTimer::DeclareTimer FTM_PIPELINE_CREATE("Pipeline Create");
 LLFastTimer::DeclareTimer FTM_POOLRENDER("RenderPool");
 LLFastTimer::DeclareTimer FTM_POOLS("Pools");
-LLFastTimer::DeclareTimer FTM_DEFERRED_POOLRENDER("RenderPool (Deferred)");
-LLFastTimer::DeclareTimer FTM_DEFERRED_POOLS("Pools (Deferred)");
-LLFastTimer::DeclareTimer FTM_POST_DEFERRED_POOLRENDER("RenderPool (Post)");
-LLFastTimer::DeclareTimer FTM_POST_DEFERRED_POOLS("Pools (Post)");
 LLFastTimer::DeclareTimer FTM_RENDER_BLOOM_FBO("First FBO");
 LLFastTimer::DeclareTimer FTM_STATESORT("Sort Draw State");
 LLFastTimer::DeclareTimer FTM_PIPELINE("Pipeline");
@@ -1378,7 +1371,7 @@ public:
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
 
-		if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && !group->isEmpty())
+		if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && !group->getData().empty())
 		{
 			for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
 			{
@@ -1687,7 +1680,7 @@ U32 LLPipeline::addObject(LLViewerObject *vobj)
 
 void LLPipeline::createObjects(F32 max_dtime)
 {
-	LLFastTimer ftm(FTM_PIPELINE_CREATE);
+	LLFastTimer ftm(FTM_GEO_UPDATE);
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS);
 
 	LLTimer update_timer;
@@ -1983,7 +1976,7 @@ void LLPipeline::clearReferences()
 
 void check_references(LLSpatialGroup* group, LLDrawable* drawable)
 {
-	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 	{
 		if (drawable == *i)
 		{
@@ -2005,7 +1998,7 @@ void check_references(LLDrawable* drawable, LLFace* face)
 
 void check_references(LLSpatialGroup* group, LLFace* face)
 {
-	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		check_references(drawable, face);
@@ -2017,25 +2010,25 @@ void LLPipeline::checkReferences(LLFace* face)
 #if 0
 	if (sCull)
 	{
-		for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, face);
 		}
 
-		for (LLCullResult::sg_iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, face);
 		}
 
-		for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, face);
 		}
 
-		for (LLCullResult::drawable_iterator iter = sCull->beginVisibleList(); iter != sCull->endVisibleList(); ++iter)
+		for (LLCullResult::drawable_list_t::iterator iter = sCull->beginVisibleList(); iter != sCull->endVisibleList(); ++iter)
 		{
 			LLDrawable* drawable = *iter;
 			check_references(drawable, face);	
@@ -2049,25 +2042,25 @@ void LLPipeline::checkReferences(LLDrawable* drawable)
 #if 0
 	if (sCull)
 	{
-		for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, drawable);
 		}
 
-		for (LLCullResult::sg_iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, drawable);
 		}
 
-		for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, drawable);
 		}
 
-		for (LLCullResult::drawable_iterator iter = sCull->beginVisibleList(); iter != sCull->endVisibleList(); ++iter)
+		for (LLCullResult::drawable_list_t::iterator iter = sCull->beginVisibleList(); iter != sCull->endVisibleList(); ++iter)
 		{
 			if (drawable == *iter)
 			{
@@ -2100,19 +2093,19 @@ void LLPipeline::checkReferences(LLDrawInfo* draw_info)
 #if 0
 	if (sCull)
 	{
-		for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, draw_info);
 		}
 
-		for (LLCullResult::sg_iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, draw_info);
 		}
 
-		for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, draw_info);
@@ -2126,7 +2119,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 #if 0
 	if (sCull)
 	{
-		for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 		{
 			if (group == *iter)
 			{
@@ -2134,7 +2127,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 			}
 		}
 
-		for (LLCullResult::sg_iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
 		{
 			if (group == *iter)
 			{
@@ -2142,7 +2135,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 			}
 		}
 
-		for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 		{
 			if (group == *iter)
 			{
@@ -2298,7 +2291,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 		bound_shader = true;
 		gOcclusionCubeProgram.bind();
 	}
-
+	
 	if (sUseOcclusion > 1)
 	{
 		if (mCubeVB.isNull())
@@ -2381,7 +2374,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 
 void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
 {
-	if (group->isEmpty())
+	if (group->getData().empty())
 	{ 
 		return;
 	}
@@ -2476,7 +2469,7 @@ void LLPipeline::doOcclusion(LLCamera& camera)
 			{
 				gOcclusionCubeProgram.bind();
 			}
-			}
+		}
 
 		if (mCubeVB.isNull())
 		{ //cube VB will be used for issuing occlusion queries
@@ -2484,7 +2477,7 @@ void LLPipeline::doOcclusion(LLCamera& camera)
 		}
 		mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
 
-		for (LLCullResult::sg_iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter)
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			group->doOcclusion(&camera);
@@ -2520,24 +2513,14 @@ BOOL LLPipeline::updateDrawableGeom(LLDrawable* drawablep, BOOL priority)
 
 static LLFastTimer::DeclareTimer FTM_SEED_VBO_POOLS("Seed VBO Pool");
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_GL("Update GL");
-
 void LLPipeline::updateGL()
 {
+	while (!LLGLUpdate::sGLQ.empty())
 	{
-		LLFastTimer t(FTM_UPDATE_GL);
-		while (!LLGLUpdate::sGLQ.empty())
-		{
-			LLGLUpdate* glu = LLGLUpdate::sGLQ.front();
-			glu->updateGL();
-			glu->mInQ = FALSE;
-			LLGLUpdate::sGLQ.pop_front();
-		}
-
-	{ //seed VBO Pools
-		LLFastTimer t(FTM_SEED_VBO_POOLS);
-		LLVertexBuffer::seedPools();
-	}
+		LLGLUpdate* glu = LLGLUpdate::sGLQ.front();
+		glu->updateGL();
+		glu->mInQ = FALSE;
+		LLGLUpdate::sGLQ.pop_front();
 	}
 
 	{ //seed VBO Pools
@@ -2546,13 +2529,11 @@ void LLPipeline::updateGL()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_PRIORITY_GROUPS("Rebuild Priority Groups");
-
 void LLPipeline::rebuildPriorityGroups()
 {
-	LLFastTimer t(FTM_REBUILD_PRIORITY_GROUPS);
 	LLTimer update_timer;
 	LLMemType mt(LLMemType::MTYPE_PIPELINE);
+	
 	assertInitialized();
 
 	gMeshRepo.notifyLoadedMeshes();
@@ -2571,9 +2552,7 @@ void LLPipeline::rebuildPriorityGroups()
 	mGroupQ1Locked = false;
 
 }
-
-static LLFastTimer::DeclareTimer FTM_REBUILD_GROUPS("Rebuild Groups");
-
+		
 void LLPipeline::rebuildGroups()
 {
 	if (mGroupQ2.empty())
@@ -2581,7 +2560,6 @@ void LLPipeline::rebuildGroups()
 		return;
 	}
 
-	LLFastTimer t(FTM_REBUILD_GROUPS);
 	mGroupQ2Locked = true;
 	// Iterate through some drawables on the non-priority build queue
 	S32 size = (S32) mGroupQ2.size();
@@ -2825,10 +2803,6 @@ void LLPipeline::markShift(LLDrawable *drawablep)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_SHIFT_DRAWABLE("Shift Drawable");
-static LLFastTimer::DeclareTimer FTM_SHIFT_OCTREE("Shift Octree");
-static LLFastTimer::DeclareTimer FTM_SHIFT_HUD("Shift HUD");
-
 void LLPipeline::shiftObjects(const LLVector3 &offset)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS);
@@ -2841,46 +2815,35 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 	LLVector4a offseta;
 	offseta.load3(offset.mV);
 
+	for (LLDrawable::drawable_vector_t::iterator iter = mShiftList.begin();
+		 iter != mShiftList.end(); iter++)
 	{
-		LLFastTimer t(FTM_SHIFT_DRAWABLE);
-
-		for (LLDrawable::drawable_vector_t::iterator iter = mShiftList.begin();
-			 iter != mShiftList.end(); iter++)
+		LLDrawable *drawablep = *iter;
+		if (drawablep->isDead())
 		{
-			LLDrawable *drawablep = *iter;
-			if (drawablep->isDead())
-			{
-				continue;
-			}	
-			drawablep->shiftPos(offseta);	
-			drawablep->clearState(LLDrawable::ON_SHIFT_LIST);
-		}
-		mShiftList.resize(0);
+			continue;
+		}	
+		drawablep->shiftPos(offseta);	
+		drawablep->clearState(LLDrawable::ON_SHIFT_LIST);
 	}
+	mShiftList.resize(0);
 
-	
+	for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
+			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
 	{
-		LLFastTimer t(FTM_SHIFT_OCTREE);
-		for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
-				iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
+		LLViewerRegion* region = *iter;
+		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
-			LLViewerRegion* region = *iter;
-			for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
+			LLSpatialPartition* part = region->getSpatialPartition(i);
+			if (part)
 			{
-				LLSpatialPartition* part = region->getSpatialPartition(i);
-				if (part)
-				{
-					part->shift(offseta);
-				}
+				part->shift(offseta);
 			}
 		}
 	}
 
-	{
-		LLFastTimer t(FTM_SHIFT_HUD);
-		LLHUDText::shiftAll(offset);
-		LLHUDNameTag::shiftAll(offset);
-	}
+	LLHUDText::shiftAll(offset);
+	LLHUDNameTag::shiftAll(offset);
 	display_update_camera();
 }
 
@@ -2913,10 +2876,8 @@ void LLPipeline::markPartitionMove(LLDrawable* drawable)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_PROCESS_PARTITIONQ("PartitionQ");
 void LLPipeline::processPartitionQ()
 {
-	LLFastTimer t(FTM_PROCESS_PARTITIONQ);
 	for (LLDrawable::drawable_list_t::iterator iter = mPartitionQ.begin(); iter != mPartitionQ.end(); ++iter)
 	{
 		LLDrawable* drawable = *iter;
@@ -3032,7 +2993,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	//LLVertexBuffer::unbind();
 
 	grabReferences(result);
-	for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+	for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 	{
 		LLSpatialGroup* group = *iter;
 		group->checkOcclusion();
@@ -3043,7 +3004,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 		else
 		{
 			group->setVisible();
-			for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+			for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 			{
 				markVisible(*i, camera);
 			}
@@ -3058,9 +3019,9 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
 	{
 		LLSpatialGroup* last_group = NULL;
-		for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
+		for (LLCullResult::bridge_list_t::iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
 		{
-			LLCullResult::bridge_iterator cur_iter = i;
+			LLCullResult::bridge_list_t::iterator cur_iter = i;
 			LLSpatialBridge* bridge = *cur_iter;
 			LLSpatialGroup* group = bridge->getSpatialGroup();
 
@@ -3090,7 +3051,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 		}
 	}
 
-	for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+	for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 	{
 		LLSpatialGroup* group = *iter;
 		group->checkOcclusion();
@@ -3112,7 +3073,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	
 	{
 		LLFastTimer ftm(FTM_STATESORT_DRAWABLE);
-		for (LLCullResult::drawable_iterator iter = sCull->beginVisibleList();
+		for (LLCullResult::drawable_list_t::iterator iter = sCull->beginVisibleList();
 			 iter != sCull->endVisibleList(); ++iter)
 		{
 			LLDrawable *drawablep = *iter;
@@ -3131,7 +3092,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT);
 	if (group->changeLOD())
 	{
-		for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+		for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
 		{
 			LLDrawable* drawablep = *i;
 			stateSort(drawablep, camera);
@@ -3248,13 +3209,13 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera)
 }
 
 
-void forAllDrawables(LLCullResult::sg_iterator begin, 
-					 LLCullResult::sg_iterator end,
+void forAllDrawables(LLCullResult::sg_list_t::iterator begin, 
+					 LLCullResult::sg_list_t::iterator end,
 					 void (*func)(LLDrawable*))
 {
-	for (LLCullResult::sg_iterator i = begin; i != end; ++i)
+	for (LLCullResult::sg_list_t::iterator i = begin; i != end; ++i)
 	{
-		for (LLSpatialGroup::element_iter j = (*i)->getDataBegin(); j != (*i)->getDataEnd(); ++j)
+		for (LLSpatialGroup::element_iter j = (*i)->getData().begin(); j != (*i)->getData().end(); ++j)
 		{
 			func(*j);	
 		}
@@ -3321,11 +3282,11 @@ void renderScriptedTouchBeacons(LLDrawable* drawablep)
 				if (facep)
 				{
 					gPipeline.mHighlightFaces.push_back(facep);
-				}
 			}
 		}
 	}
 }
+}
 
 void renderPhysicalBeacons(LLDrawable* drawablep)
 {
@@ -3350,11 +3311,11 @@ void renderPhysicalBeacons(LLDrawable* drawablep)
 				if (facep)
 				{
 					gPipeline.mHighlightFaces.push_back(facep);
-				}
 			}
 		}
 	}
 }
+}
 
 void renderMOAPBeacons(LLDrawable* drawablep)
 {
@@ -3390,11 +3351,11 @@ void renderMOAPBeacons(LLDrawable* drawablep)
 				if (facep)
 				{
 					gPipeline.mHighlightFaces.push_back(facep);
-				}
 			}
 		}
 	}
 }
+}
 
 void renderParticleBeacons(LLDrawable* drawablep)
 {
@@ -3419,11 +3380,11 @@ void renderParticleBeacons(LLDrawable* drawablep)
 				if (facep)
 				{
 					gPipeline.mHighlightFaces.push_back(facep);
-				}
 			}
 		}
 	}
 }
+}
 
 void renderSoundHighlights(LLDrawable* drawablep)
 {
@@ -3441,11 +3402,11 @@ void renderSoundHighlights(LLDrawable* drawablep)
 				if (facep)
 				{
 					gPipeline.mHighlightFaces.push_back(facep);
-				}
 			}
 		}
 	}
 }
+}
 
 void LLPipeline::postSort(LLCamera& camera)
 {
@@ -3456,7 +3417,7 @@ void LLPipeline::postSort(LLCamera& camera)
 
 	llpushcallstacks ;
 	//rebuild drawable geometry
-	for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i)
+	for (LLCullResult::sg_list_t::iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		if (!sUseOcclusion || 
@@ -3474,7 +3435,7 @@ void LLPipeline::postSort(LLCamera& camera)
 
 
 	//build render map
-	for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
+	for (LLCullResult::sg_list_t::iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		if (sUseOcclusion && 
@@ -3658,7 +3619,7 @@ void LLPipeline::postSort(LLCamera& camera)
 						if (facep)
 						{
 							gPipeline.mSelectedFaces.push_back(facep);
-						}
+					}
 					}
 					return true;
 				}
@@ -4177,7 +4138,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 	LLMemType mt_rgd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED);
 	LLFastTimer t(FTM_RENDER_GEOMETRY);
 
-	LLFastTimer t2(FTM_DEFERRED_POOLS);
+	LLFastTimer t2(FTM_POOLS);
 
 	LLGLEnable cull(GL_CULL_FACE);
 
@@ -4219,7 +4180,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 		pool_set_t::iterator iter2 = iter1;
 		if (hasRenderType(poolp->getType()) && poolp->getNumDeferredPasses() > 0)
 		{
-			LLFastTimer t(FTM_DEFERRED_POOLRENDER);
+			LLFastTimer t(FTM_POOLRENDER);
 
 			gGLLastMatrix = NULL;
 			gGL.loadMatrix(gGLModelView);
@@ -4272,7 +4233,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
 {
 	LLMemType mt_rgpd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF);
-	LLFastTimer t(FTM_POST_DEFERRED_POOLS);
+	LLFastTimer t(FTM_POOLS);
 	U32 cur_type = 0;
 
 	LLGLEnable cull(GL_CULL_FACE);
@@ -4306,7 +4267,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
 		pool_set_t::iterator iter2 = iter1;
 		if (hasRenderType(poolp->getType()) && poolp->getNumPostDeferredPasses() > 0)
 		{
-			LLFastTimer t(FTM_POST_DEFERRED_POOLRENDER);
+			LLFastTimer t(FTM_POOLRENDER);
 
 			gGLLastMatrix = NULL;
 			gGL.loadMatrix(gGLModelView);
@@ -4496,7 +4457,7 @@ void LLPipeline::renderPhysicsDisplay()
 		}
 	}
 
-	for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
+	for (LLCullResult::bridge_list_t::const_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
 	{
 		LLSpatialBridge* bridge = *i;
 		if (!bridge->isDead() && hasRenderType(bridge->mDrawableType))
@@ -4918,7 +4879,7 @@ void LLPipeline::renderDebug()
 		}
 	}
 
-	for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
+	for (LLCullResult::bridge_list_t::const_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
 	{
 		LLSpatialBridge* bridge = *i;
 		if (!bridge->isDead() && hasRenderType(bridge->mDrawableType))
@@ -5170,11 +5131,8 @@ void LLPipeline::renderDebug()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_POOLS("Rebuild Pools");
-
 void LLPipeline::rebuildPools()
 {
-	LLFastTimer t(FTM_REBUILD_POOLS);
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_REBUILD_POOLS);
 
 	assertInitialized();
@@ -6733,16 +6691,13 @@ void LLPipeline::resetVertexBuffers()
 	mResetVertexBuffers = true;
 }
 
-static LLFastTimer::DeclareTimer FTM_RESET_VB("Reset VB");
-
 void LLPipeline::doResetVertexBuffers()
 {
 	if (!mResetVertexBuffers)
 	{
 		return;
 	}
-
-	LLFastTimer t(FTM_RESET_VB);
+	
 	mResetVertexBuffers = false;
 
 	mCubeVB = NULL;
@@ -9167,8 +9122,6 @@ void LLPipeline::generateHighlight(LLCamera& camera)
 }
 
 
-static LLFastTimer::DeclareTimer FTM_GEN_SUN_SHADOW("Gen Sun Shadow");
-
 void LLPipeline::generateSunShadow(LLCamera& camera)
 {
 	if (!sRenderDeferred || RenderShadowDetail <= 0)
@@ -9176,8 +9129,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		return;
 	}
 
-	LLFastTimer t(FTM_GEN_SUN_SHADOW);
-
 	BOOL skip_avatar_update = FALSE;
 	if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson)
 	{
@@ -9927,7 +9878,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 
 void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture)
 {
-	for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
+	for (LLCullResult::sg_list_t::iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		if (!group->isDead() &&
@@ -9940,12 +9891,6 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL textu
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_MARK_VISIBLE("Impostor Mark Visible");
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_SETUP("Impostor Setup");
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_BACKGROUND("Impostor Background");
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_ALLOCATE("Impostor Allocate");
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_RESIZE("Impostor Resize");
-
 void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 {
 	LLMemType mt_gi(LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR);
@@ -10001,115 +9946,102 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	sImpostorRender = TRUE;
 
 	LLViewerCamera* viewer_camera = LLViewerCamera::getInstance();
+	markVisible(avatar->mDrawable, *viewer_camera);
+	LLVOAvatar::sUseImpostors = FALSE;
 
+	LLVOAvatar::attachment_map_t::iterator iter;
+	for (iter = avatar->mAttachmentPoints.begin();
+		iter != avatar->mAttachmentPoints.end();
+		++iter)
 	{
-		LLFastTimer t(FTM_IMPOSTOR_MARK_VISIBLE);
-		markVisible(avatar->mDrawable, *viewer_camera);
-		LLVOAvatar::sUseImpostors = FALSE;
-
-		LLVOAvatar::attachment_map_t::iterator iter;
-		for (iter = avatar->mAttachmentPoints.begin();
-			iter != avatar->mAttachmentPoints.end();
-			++iter)
+		LLViewerJointAttachment *attachment = iter->second;
+		for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
+			 attachment_iter != attachment->mAttachedObjects.end();
+			 ++attachment_iter)
 		{
-			LLViewerJointAttachment *attachment = iter->second;
-			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-				 attachment_iter != attachment->mAttachedObjects.end();
-				 ++attachment_iter)
+			if (LLViewerObject* attached_object = (*attachment_iter))
 			{
-				if (LLViewerObject* attached_object = (*attachment_iter))
-				{
-					markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera);
-				}
+				markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera);
 			}
 		}
 	}
 
 	stateSort(*LLViewerCamera::getInstance(), result);
 	
+	const LLVector4a* ext = avatar->mDrawable->getSpatialExtents();
+	LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset());
+
 	LLCamera camera = *viewer_camera;
+
+	camera.lookAt(viewer_camera->getOrigin(), pos, viewer_camera->getUpAxis());
+	
 	LLVector2 tdim;
-	U32 resY = 0;
-	U32 resX = 0;
 
-	{
-		LLFastTimer t(FTM_IMPOSTOR_SETUP);
-		const LLVector4a* ext = avatar->mDrawable->getSpatialExtents();
-		LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset());
 
-		camera.lookAt(viewer_camera->getOrigin(), pos, viewer_camera->getUpAxis());
-	
-		LLVector4a half_height;
-		half_height.setSub(ext[1], ext[0]);
-		half_height.mul(0.5f);
+	LLVector4a half_height;
+	half_height.setSub(ext[1], ext[0]);
+	half_height.mul(0.5f);
 
-		LLVector4a left;
-		left.load3(camera.getLeftAxis().mV);
-		left.mul(left);
-		left.normalize3fast();
+	LLVector4a left;
+	left.load3(camera.getLeftAxis().mV);
+	left.mul(left);
+	left.normalize3fast();
 
-		LLVector4a up;
-		up.load3(camera.getUpAxis().mV);
-		up.mul(up);
-		up.normalize3fast();
+	LLVector4a up;
+	up.load3(camera.getUpAxis().mV);
+	up.mul(up);
+	up.normalize3fast();
 
-		tdim.mV[0] = fabsf(half_height.dot3(left).getF32());
-		tdim.mV[1] = fabsf(half_height.dot3(up).getF32());
+	tdim.mV[0] = fabsf(half_height.dot3(left).getF32());
+	tdim.mV[1] = fabsf(half_height.dot3(up).getF32());
 
-		gGL.matrixMode(LLRender::MM_PROJECTION);
-		gGL.pushMatrix();
+	gGL.matrixMode(LLRender::MM_PROJECTION);
+	gGL.pushMatrix();
 	
-		F32 distance = (pos-camera.getOrigin()).length();
-		F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG;
-		F32 aspect = tdim.mV[0]/tdim.mV[1];
-		glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f);
-		glh_set_current_projection(persp);
-		gGL.loadMatrix(persp.m);
+	F32 distance = (pos-camera.getOrigin()).length();
+	F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG;
+	F32 aspect = tdim.mV[0]/tdim.mV[1];
+	glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f);
+	glh_set_current_projection(persp);
+	gGL.loadMatrix(persp.m);
 
-		gGL.matrixMode(LLRender::MM_MODELVIEW);
-		gGL.pushMatrix();
-		glh::matrix4f mat;
-		camera.getOpenGLTransform(mat.m);
+	gGL.matrixMode(LLRender::MM_MODELVIEW);
+	gGL.pushMatrix();
+	glh::matrix4f mat;
+	camera.getOpenGLTransform(mat.m);
 
-		mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat;
+	mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat;
 
-		gGL.loadMatrix(mat.m);
-		glh_set_current_modelview(mat);
+	gGL.loadMatrix(mat.m);
+	glh_set_current_modelview(mat);
 
-		glClearColor(0.0f,0.0f,0.0f,0.0f);
-		gGL.setColorMask(true, true);
+	glClearColor(0.0f,0.0f,0.0f,0.0f);
+	gGL.setColorMask(true, true);
 	
-		// get the number of pixels per angle
-		F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * viewer_camera->getView());
-
-		//get resolution based on angle width and height of impostor (double desired resolution to prevent aliasing)
-		resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512);
-		resX = llmin(nhpo2((U32) (atanf(tdim.mV[0]/distance)*2.f*RAD_TO_DEG*pa)), (U32) 512);
+	// get the number of pixels per angle
+	F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * viewer_camera->getView());
 
-		if (!avatar->mImpostor.isComplete())
-		{
-			LLFastTimer t(FTM_IMPOSTOR_ALLOCATE);
-			avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,FALSE);
+	//get resolution based on angle width and height of impostor (double desired resolution to prevent aliasing)
+	U32 resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512);
+	U32 resX = llmin(nhpo2((U32) (atanf(tdim.mV[0]/distance)*2.f*RAD_TO_DEG*pa)), (U32) 512);
 
-			if (LLPipeline::sRenderDeferred)
-			{
-				addDeferredAttachments(avatar->mImpostor);
-			}
+	if (!avatar->mImpostor.isComplete() || resX != avatar->mImpostor.getWidth() ||
+		resY != avatar->mImpostor.getHeight())
+	{
+		avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,FALSE);
 		
-			gGL.getTexUnit(0)->bind(&avatar->mImpostor);
-			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
-			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-		}
-		else if(resX != avatar->mImpostor.getWidth() ||
-			resY != avatar->mImpostor.getHeight())
+		if (LLPipeline::sRenderDeferred)
 		{
-			LLFastTimer t(FTM_IMPOSTOR_RESIZE);
-			avatar->mImpostor.resize(resX,resY,GL_RGBA);
+			addDeferredAttachments(avatar->mImpostor);
 		}
-
-		avatar->mImpostor.bindTarget();
+		
+		gGL.getTexUnit(0)->bind(&avatar->mImpostor);
+		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
+		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	}
 
+	avatar->mImpostor.bindTarget();
+
 	if (LLPipeline::sRenderDeferred)
 	{
 		avatar->mImpostor.clear();
@@ -10125,7 +10057,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	}
 	
 	{ //create alpha mask based on depth buffer (grey out if muted)
-		LLFastTimer t(FTM_IMPOSTOR_BACKGROUND);
 		if (LLPipeline::sRenderDeferred)
 		{
 			GLuint buff = GL_COLOR_ATTACHMENT0;
@@ -10211,22 +10142,22 @@ BOOL LLPipeline::hasRenderBatches(const U32 type) const
 	return sCull->getRenderMapSize(type) > 0;
 }
 
-LLCullResult::drawinfo_iterator LLPipeline::beginRenderMap(U32 type)
+LLCullResult::drawinfo_list_t::iterator LLPipeline::beginRenderMap(U32 type)
 {
 	return sCull->beginRenderMap(type);
 }
 
-LLCullResult::drawinfo_iterator LLPipeline::endRenderMap(U32 type)
+LLCullResult::drawinfo_list_t::iterator LLPipeline::endRenderMap(U32 type)
 {
 	return sCull->endRenderMap(type);
 }
 
-LLCullResult::sg_iterator LLPipeline::beginAlphaGroups()
+LLCullResult::sg_list_t::iterator LLPipeline::beginAlphaGroups()
 {
 	return sCull->beginAlphaGroups();
 }
 
-LLCullResult::sg_iterator LLPipeline::endAlphaGroups()
+LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
 {
 	return sCull->endAlphaGroups();
 }
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 368be1c14d..ef1fd3279d 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -294,10 +294,10 @@ public:
 	void setLight(LLDrawable *drawablep, BOOL is_light);
 	
 	BOOL hasRenderBatches(const U32 type) const;
-	LLCullResult::drawinfo_iterator beginRenderMap(U32 type);
-	LLCullResult::drawinfo_iterator endRenderMap(U32 type);
-	LLCullResult::sg_iterator beginAlphaGroups();
-	LLCullResult::sg_iterator endAlphaGroups();
+	LLCullResult::drawinfo_list_t::iterator beginRenderMap(U32 type);
+	LLCullResult::drawinfo_list_t::iterator endRenderMap(U32 type);
+	LLCullResult::sg_list_t::iterator beginAlphaGroups();
+	LLCullResult::sg_list_t::iterator endAlphaGroups();
 	
 
 	void addTrianglesDrawn(S32 index_count, U32 render_type = LLRender::TRIANGLES);
diff --git a/indra/newview/skins/default/xui/de/menu_viewer.xml b/indra/newview/skins/default/xui/de/menu_viewer.xml
index c4c4defab9..856f91e214 100644
--- a/indra/newview/skins/default/xui/de/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/de/menu_viewer.xml
@@ -21,6 +21,7 @@
 			<menu_item_call label="Beschäftigt" name="Set Busy"/>
 		</menu>
 		<menu_item_call label="L$ kaufen..." name="Buy and Sell L$"/>
+		<menu_item_call label="Händler-Outbox..." name="MerchantOutbox"/>
 		<menu_item_call label="Kontoübersicht..." name="Manage My Account">
 			<menu_item_call.on_click name="ManageMyAccount_url" parameter="WebLaunchJoinNow,http://secondlife.com/account/index.php?lang=de"/>
 		</menu_item_call>
diff --git a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml
index 2e29c61cb2..6021ba0a5a 100644
--- a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml
+++ b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml
@@ -134,16 +134,6 @@
      top_delta="-25"
      name="Pipette"
      width="28" />
-   <check_box
-     follows="left|bottom"
-     height="20"
-     initial_value="true"
-     label="Live Preview"
-     layout="topleft"
-     left="4"
-     name="apply_immediate_check"
-     top="262"
-     width="120" />
    <text
      follows="left|bottom"
      height="20"
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index ae5278b7ec..c785cee856 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -7569,18 +7569,6 @@ You locally updated a [RESOLUTION] baked texture for '[BODYREGION]' after [TIME]
    name="LivePreviewUnavailable"
    type="alert">
    
-We cannot display a preview of this texture because it is no-copy and/or no-transfer.
-  <usetemplate
-    ignoretext="Warn me that Live Preview mode is not available for no-copy and/or no-transfer textures"
-    name="okignore"
-    yestext="OK"/>
-  </notification>
-
-  <notification
-   icon="alertmodal.tga"
-   name="LivePreviewUnavailable"
-   type="alert">
-   
 We cannot display a preview of this texture because it is no-copy and/or no-transfer.
   <usetemplate
     ignoretext="Warn me that Live Preview mode is not available for no-copy and/or no-transfer textures"
diff --git a/indra/newview/skins/default/xui/en/sidepanel_item_info.xml b/indra/newview/skins/default/xui/en/sidepanel_item_info.xml
index c5dfb703e5..54a312bd59 100644
--- a/indra/newview/skins/default/xui/en/sidepanel_item_info.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_item_info.xml
@@ -11,10 +11,6 @@
 		 name="unknown">
         (unknown)
 	</panel.string>
-    <panel.string
-         name="unknown_multiple">
-        (unknown / multiple)
-    </panel.string>
 	<panel.string
 		 name="public">
         (public)
diff --git a/indra/newview/skins/default/xui/en/sidepanel_task_info.xml b/indra/newview/skins/default/xui/en/sidepanel_task_info.xml
index e9a787cef0..e69a17e037 100644
--- a/indra/newview/skins/default/xui/en/sidepanel_task_info.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_task_info.xml
@@ -1,36 +1,36 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <panel
-    height="570"
-    layout="topleft"
-    name="object properties"
-    help_topic="object_properties"
-    title="Object Profile"
-    width="333">
-  <panel.string
-      name="text deed continued">
-    Deed
-  </panel.string>
-  <panel.string
-      name="text deed">
-    Deed
-  </panel.string>
-  <panel.string
-      name="text modify info 1">
-    You can modify this object
-  </panel.string>
-  <panel.string
-      name="text modify info 2">
-    You can modify these objects
-  </panel.string>
-  <panel.string
-      name="text modify info 3">
-    You can't modify this object
-  </panel.string>
-  <panel.string
-      name="text modify info 4">
-    You can't modify these objects
-  </panel.string>
-  <panel.string
+	 height="570"
+	 layout="topleft"
+	 name="object properties"
+	 help_topic="object_properties"
+	 title="Object Profile"
+	 width="333">
+	 <panel.string
+	  name="text deed continued">
+		Deed
+	 </panel.string>
+	<panel.string
+	 name="text deed">
+		Deed
+	</panel.string>
+            <panel.string
+             name="text modify info 1">
+                You can modify this object
+            </panel.string>
+            <panel.string
+             name="text modify info 2">
+                You can modify these objects
+            </panel.string>
+            <panel.string
+             name="text modify info 3">
+                You can't modify this object
+            </panel.string>
+            <panel.string
+             name="text modify info 4">
+                You can't modify these objects
+            </panel.string>
+            <panel.string
       name="text modify info 5">
     You can't modify this object across a region boundary
   </panel.string>
@@ -39,399 +39,399 @@
     You can't modify these objects across a region boundary
   </panel.string>
   <panel.string
-      name="text modify warning">
-    This object has linked parts
-  </panel.string>
-  <panel.string
-      name="Cost Default">
-    Price: L$
-  </panel.string>
-  <panel.string
-      name="Cost Total">
-    Total Price: L$
-  </panel.string>
-  <panel.string
-      name="Cost Per Unit">
-    Price Per: L$
-  </panel.string>
-  <panel.string
-      name="Cost Mixed">
-    Mixed Price
-  </panel.string>
-  <panel.string
-      name="Sale Mixed">
-    Mixed Sale
-  </panel.string>
-  <button
-      follows="top|left"
-      height="24"
-      image_hover_unselected="BackButton_Over"
-      image_pressed="BackButton_Press"
-      image_unselected="BackButton_Off"
-      layout="topleft"
-      left="8"
-      name="back_btn"
-      tab_stop="false"
-      top="0"
-      width="30"
-      use_draw_context_alpha="false" />
-  <text
-      follows="top|left|right"
-      font="SansSerifHuge"
-      height="26"
-      layout="topleft"
-      left_pad="10"
-      name="title"
-      text_color="LtGray"
-      top="0"
-      use_ellipses="true"
-      value="Object Profile"
-      width="290" />
-  <text
-      follows="top|left"
-      height="13"
-      layout="topleft"
-      left="45"
-      name="where"
-      text_color="LtGray_50"
-      value="(Inworld)"
-      width="150" />
-  <panel
-      follows="all"
-      height="490"
-      label=""
-      layout="topleft"
-      left="10"
-      help_topic=""
-      name="properties_panel"
-      top="45"
-      width="313"
-      background_visible="true"
-      bg_alpha_color="DkGray2">
-    <text
-        type="string"
-        length="1"
-        follows="left|top"
-        height="10"
-        layout="topleft"
-        left="5"
-        name="Name:"
-        top="10"
-        width="78">
-      Name:
-    </text>
-    <line_editor
-        border_style="line"
-        border_thickness="1"
-        follows="left|top|right"
-        height="20"
-        layout="topleft"
-        left_delta="78"
-        max_length_bytes="63"
-        name="Object Name"
-        top_delta="0"
-        width="225" />
-    <text
-        type="string"
-        length="1"
-        follows="left|top"
-        height="10"
-        layout="topleft"
-        left="5"
-        name="Description:"
-        top_pad="10"
-        width="78">
-      Description:
-    </text>
-    <line_editor
-        border_style="line"
-        border_thickness="1"
-        follows="left|top|right"
-        height="23"
-        layout="topleft"
-        name="Object Description"
-        select_on_focus="true"
-        left_delta="78"
-        max_length_bytes="127"
-        top_delta="-5"
-        width="225"/>
-    <text
-        type="string"
-        length="1"
-        follows="left|top"
-        height="23"
-        layout="topleft"
-        left="5"
-        name="CreatorNameLabel"
-        top_pad="12"
-        width="78">
-      Creator:
-    </text>
-    <text
-        type="string"
-        follows="left|right|top"
-        font="SansSerifSmall"
-        height="15"
-        layout="topleft"
-        left_pad="0"
-        name="Creator Name"
-        top_delta="0"
-        translate="false"
-        use_ellipses="true" 
-        width="225">
-      TestString PleaseIgnore
-    </text>
-    <text
-        type="string"
-        length="1"
-        follows="left|top"
-        height="23"
-        layout="topleft"
-        left="5"
-        name="Owner:"
-        top_pad="15"
-        width="78">
-      Owner:
-    </text>
-    <text
-        type="string"
-        follows="left|right|top"
-        font="SansSerifSmall"
-        height="15"
-        layout="topleft"
-        left_pad="0"
-        name="Owner Name"
-        top_delta="0"
-        translate="false"
-        use_ellipses="true" 
-        width="225">
-      TestString PleaseIgnore
-    </text>
-    <text
-        type="string"
-        length="1"
-        follows="left|top"
-        height="23"
-        layout="topleft"
-        left="5"
-        name="Group_label"
-        top_pad="15"
-        width="78">
-      Group:
-    </text>
+             name="text modify warning">
+                This object has linked parts
+            </panel.string>
+            <panel.string
+             name="Cost Default">
+                Price: L$
+            </panel.string>
+            <panel.string
+             name="Cost Total">
+                Total Price: L$
+            </panel.string>
+            <panel.string
+             name="Cost Per Unit">
+                Price Per: L$
+            </panel.string>
+            <panel.string
+             name="Cost Mixed">
+                Mixed Price
+            </panel.string>
+            <panel.string
+             name="Sale Mixed">
+                Mixed Sale
+            </panel.string>
     <button
-        follows="top|left"
-        height="10"
-        image_disabled="Activate_Checkmark"
-        image_selected="Activate_Checkmark"
-        image_unselected="Activate_Checkmark"
-        image_color="White_50"
-        layout="topleft"
-        left_pad="0"
-        top_delta="0"
-        name="button set group"
-        tab_stop="false"
-        tool_tip="Choose a group to share this object's permissions"
-        width="10" />
-    <name_box
-        follows="left|top"
-        height="18"
-        initial_value="Loading..."
-        layout="topleft"
-        left_pad="5"
-        top_delta="-1"
-        name="Group Name Proxy"
-        width="150" />
-    <button
-        follows="top|left"
-        height="23"
-        label="Deed"
-        label_selected="Deed"
-        layout="topleft"
-        name="button deed"
-        top_pad="0"
-        left="81"
-        tool_tip="Deeding gives this item away with next owner permissions. Group shared objects can be deeded by a group officer."
-        width="100" />
-    <text
-        type="string"
-        length="1"
-        follows="left|top"
-        height="9"
-        layout="topleft"
-        top_pad="5"
-        left="5"
-        name="label click action"
-        width="280">
-      Click to:
-    </text>
-    <combo_box
-        follows="left|top"
-        height="23"
-        layout="topleft"
-        name="clickaction"
-        width="168"
-        left="81">
-      <combo_box.item
-          label="Touch  (default)"
-          name="Touch/grab(default)"
+     follows="top|left"
+     height="24"
+     image_hover_unselected="BackButton_Over"
+     image_pressed="BackButton_Press"
+     image_unselected="BackButton_Off"
+     layout="topleft"
+     left="8"
+     name="back_btn"
+     tab_stop="false"
+     top="0"
+     width="30"
+     use_draw_context_alpha="false" />
+        <text
+     follows="top|left|right"
+     font="SansSerifHuge"
+     height="26"
+     layout="topleft"
+     left_pad="10"
+     name="title"
+     text_color="LtGray"
+     top="0"
+     use_ellipses="true"
+     value="Object Profile"
+     width="290" />
+	    <text
+     follows="top|left"
+     height="13"
+     layout="topleft"
+     left="45"
+     name="where"
+     text_color="LtGray_50"
+     value="(Inworld)"
+     width="150" />
+	<panel
+         follows="all"
+         height="490"
+         label=""
+         layout="topleft"
+         left="10"
+         help_topic=""
+         name="properties_panel"
+         top="45"
+         width="313"
+   background_visible="true"
+   bg_alpha_color="DkGray2">
+	    	    <text
+		     type="string"
+		     length="1"
+		     follows="left|top"
+		     height="10"
+		     layout="topleft"
+		     left="5"
+             name="Name:"
+		     top="10"
+		     width="78">
+	        Name:
+	    </text>
+	    <line_editor
+		     border_style="line"
+		     border_thickness="1"
+	    	 follows="left|top|right"
+		     height="20"
+		     layout="topleft"
+	    	 left_delta="78"
+		     max_length_bytes="63"
+             name="Object Name"
+	    	 top_delta="0"
+		     width="225" />
+	    <text
+	    type="string"
+	    length="1"
+	    follows="left|top"
+	    height="10"
+	    layout="topleft"
+	    left="5"
+             name="Description:"
+	    top_pad="10"
+	    width="78">
+	        Description:
+	    </text>
+            <line_editor
+	     border_style="line"
+    	     border_thickness="1"
+             follows="left|top|right"
+             height="23"
+             layout="topleft"
+             name="Object Description"
+             select_on_focus="true"
+    		 left_delta="78"
+		     max_length_bytes="127"
+	    	 top_delta="-5"
+	    	 width="225"/>
+	    <text
+		     type="string"
+		     length="1"
+		     follows="left|top"
+		     height="23"
+		     layout="topleft"
+    		 left="5"
+		 name="CreatorNameLabel"
+		  top_pad="12"
+		     width="78">
+	        Creator:
+    	</text>
+	    <text
+		     type="string"
+     follows="left|right|top"
+     font="SansSerifSmall"
+     height="15"
+     layout="topleft"
+     left_pad="0"
+             name="Creator Name"
+		     top_delta="0"
+		     translate="false"
+         use_ellipses="true" 
+		     width="225">
+	        TestString PleaseIgnore
+	     </text>
+	    <text
+			 type="string"
+			 length="1"
+			 follows="left|top"
+			 height="23"
+			layout="topleft"
+			left="5"
+			name="Owner:"
+			top_pad="15"
+			 width="78">
+			    Owner:
+	     </text>
+	     <text
+			    type="string"
+			    follows="left|right|top"
+			    font="SansSerifSmall"
+			    height="15"
+			    layout="topleft"
+			    left_pad="0"
+			    name="Owner Name"
+			    top_delta="0"
+			    translate="false"
+          use_ellipses="true" 
+			    width="225">
+			    TestString PleaseIgnore
+	     </text>
+	    	    <text
+			 type="string"
+			 length="1"
+			 follows="left|top"
+			 height="23"
+			 layout="topleft"
+			 left="5"
+			name="Group_label"
+			top_pad="15"
+			width="78">
+			    Group:
+	     </text>
+      		<button
+			 follows="top|left"
+			 height="10"
+			 image_disabled="Activate_Checkmark"
+			 image_selected="Activate_Checkmark"
+			 image_unselected="Activate_Checkmark"
+			 image_color="White_50"
+			 layout="topleft"
+			 left_pad="0"
+			 top_delta="0"
+			 name="button set group"
+			 tab_stop="false"
+			 tool_tip="Choose a group to share this object's permissions"
+			 width="10" />
+            <name_box
+             follows="left|top"
+             height="18"
+             initial_value="Loading..."
+             layout="topleft"
+             left_pad="5"
+             top_delta="-1"
+             name="Group Name Proxy"
+             width="150" />
+            <button
+             follows="top|left"
+             height="23"
+             label="Deed"
+             label_selected="Deed"
+             layout="topleft"
+             name="button deed"
+             top_pad="0"
+             left="81"
+             tool_tip="Deeding gives this item away with next owner permissions. Group shared objects can be deeded by a group officer."
+             width="100" />
+            <text
+             type="string"
+             length="1"
+             follows="left|top"
+             height="9"
+             layout="topleft"
+             top_pad="5"
+             left="5"
+             name="label click action"
+             width="280">
+                Click to:
+            </text>
+            <combo_box
+             follows="left|top"
+             height="23"
+             layout="topleft"
+             name="clickaction"
+             width="168"
+             left="81">
+                <combo_box.item
+                 label="Touch  (default)"
+                 name="Touch/grab(default)"
           value="Touch" />
-      <combo_box.item
-          label="Sit on object"
-          name="Sitonobject"
+                <combo_box.item
+                 label="Sit on object"
+                 name="Sitonobject"
           value="Sit" />
-      <combo_box.item
-          label="Buy object"
-          name="Buyobject"
+                <combo_box.item
+                 label="Buy object"
+                 name="Buyobject"
           value="Buy" />
-      <combo_box.item
-          label="Pay object"
-          name="Payobject"
+                <combo_box.item
+                 label="Pay object"
+                 name="Payobject"
           value="Pay" />
-      <combo_box.item
-          label="Open"
-          name="Open"
-          value="Open" />
-    </combo_box>
-    <panel
-        border="false"
-        follows="left|top"
-        layout="topleft"
-        mouse_opaque="false"
-        background_visible="true"
-        bg_alpha_color="DkGray"
-        name="perms_inv"
-        left="0"
-        top_pad="15"
-        height="135"
-        width="313">
-      <text
-          type="string"
-          length="1"
+                <combo_box.item
+                 label="Open"
+                 name="Open"
+                 value="Open" />
+            </combo_box>
+	 <panel
+         border="false"
+         follows="left|top"
+         layout="topleft"
+         mouse_opaque="false"
+         background_visible="true"
+         bg_alpha_color="DkGray"
+         name="perms_inv"
+         left="0"
+         top_pad="15"
+         height="135"
+         width="313">
+	  <text
+             type="string"
+             length="1"
           left="5"
-          top_pad="15"
-          text_color="EmphasisColor"
-          height="15"
-          follows="left|top|right"
-          layout="topleft"
-          name="perm_modify"
-          width="310">
-        You can modify this object
-      </text>
-      <text
-          type="string"
-          length="1"
-          follows="left|top"
-          height="16"
-          layout="topleft"
-          left="10"
-          name="Anyone can:"
-          top_pad="8"
-          width="100">
-        Anyone:
-      </text>
-      <check_box
-          height="18"
-          label="Copy"
-          layout="topleft"
-          left_pad="0"
-          name="checkbox allow everyone copy"
-          top_delta="-2"
-          width="90" />
-      <check_box
-          height="18"
-          label="Move"
-          layout="topleft"
-          name="checkbox allow everyone move"
-          left_pad="0"
-          width="150" />
-      <text
-          type="string"
-          length="1"
-          follows="left|top"
-          height="16"
-          layout="topleft"
-          left="10"
-          name="GroupLabel"
-          top_pad="8"
-          width="100">
-        Group:
-      </text>
-      <check_box
-          height="18"
-          label="Share"
-          layout="topleft"
-          left_pad="90"
-          top_delta="-2"
-          name="checkbox share with group"
-          tool_tip="Allow all members of the set group to share your modify permissions for this object. You must Deed to enable role restrictions."
-          width="150" />
-      <text
-          type="string"
-          length="1"
-          follows="left|top"
-          height="16"
-          layout="topleft"
-          left="10"
-          name="NextOwnerLabel"
-          top_pad="8"
-          width="200"
-          word_wrap="true">
-        Next owner:
-      </text>
-      <check_box
-          height="18"
-          label="Modify"
-          layout="topleft"
-          left="20"
-          top_pad="0"
-          name="checkbox next owner can modify"
-          width="90" />
-      <check_box
-          height="18"
-          label="Copy"
-          layout="topleft"
-          left_pad="0"
-          name="checkbox next owner can copy"
-          width="90" />
-      <check_box
-          height="18"
-          label="Transfer"
-          layout="topleft"
-          left_pad="0"
-          name="checkbox next owner can transfer"
-          tool_tip="Next owner can give away or resell this object"
-          width="106" />
-    </panel>
-    <check_box
-        height="23"
-        label="For Sale"
-        layout="topleft"
-        left="20"
-        name="checkbox for sale"
-        top_pad="10"
-        width="100" />
-    <combo_box
-        height="23"
-        left_pad="0"
-        layout="topleft"
-        follows="left|top"
-        name="sale type"
-        width="170">
-      <combo_box.item
-          name="Copy"
-          label="Copy"
-          value="2" />
-      <combo_box.item
-          name="Contents"
-          label="Contents"
-          value="3" />
-      <combo_box.item
-          name="Original"
-          label="Original"
-          value="1" />
-    </combo_box>
-    <spinner
+             top_pad="15"
+             text_color="EmphasisColor"
+	     height="15"
+             follows="left|top|right"
+             layout="topleft"
+             name="perm_modify"
+             width="310">
+                You can modify this object
+            </text>
+	  	    <text
+			 type="string"
+			 length="1"
+			 follows="left|top"
+			 height="16"
+			 layout="topleft"
+			 left="10"
+               name="Anyone can:"
+			 top_pad="8"
+			 width="100">
+			Anyone:
+	    </text>
+	    <check_box
+			 height="18"
+			 label="Copy"
+			 layout="topleft"
+			 left_pad="0"
+             name="checkbox allow everyone copy"
+			 top_delta="-2"
+			 width="90" />
+	    <check_box
+             height="18"
+             label="Move"
+             layout="topleft"
+             name="checkbox allow everyone move"
+			 left_pad="0"
+             width="150" />
+	       	<text
+			 type="string"
+			 length="1"
+			 follows="left|top"
+			 height="16"
+			 layout="topleft"
+			 left="10"
+			 name="GroupLabel"
+			 top_pad="8"
+			 width="100">
+			Group:
+    	</text>
+			    <check_box
+			 height="18"
+			 label="Share"
+			 layout="topleft"
+			 left_pad="90"
+			 top_delta="-2"
+             name="checkbox share with group"
+			 tool_tip="Allow all members of the set group to share your modify permissions for this object. You must Deed to enable role restrictions."
+			 width="150" />
+	    	    <text
+			 type="string"
+			 length="1"
+			 follows="left|top"
+			 height="16"
+			 layout="topleft"
+			 left="10"
+			 name="NextOwnerLabel"
+			 top_pad="8"
+			 width="200"
+			 word_wrap="true">
+			Next owner:
+	    </text>
+	    <check_box
+			 height="18"
+			 label="Modify"
+			 layout="topleft"
+			 left="20"
+			 top_pad="0"
+             name="checkbox next owner can modify"
+			 width="90" />
+	    <check_box
+			 height="18"
+			 label="Copy"
+			 layout="topleft"
+			 left_pad="0"
+             name="checkbox next owner can copy"
+			 width="90" />
+	    <check_box
+			 height="18"
+			 label="Transfer"
+			 layout="topleft"
+			 left_pad="0"
+             name="checkbox next owner can transfer"
+			 tool_tip="Next owner can give away or resell this object"
+			 width="106" />
+	    </panel>
+	    <check_box
+			 height="23"
+			 label="For Sale"
+			 layout="topleft"
+			 left="20"
+             name="checkbox for sale"
+			 top_pad="10"
+			 width="100" />
+		<combo_box
+			 height="23"
+			 left_pad="0"
+			 layout="topleft"
+			 follows="left|top"
+            name="sale type"
+			 width="170">
+        <combo_box.item
+           name="Copy"
+           label="Copy"
+           value="2" />
+        <combo_box.item
+           name="Contents"
+           label="Contents"
+           value="3" />
+        <combo_box.item
+           name="Original"
+           label="Original"
+           value="1" />
+	    </combo_box>
+		<spinner
         follows="left|top"
         decimal_digits="0"
         increment="1"
@@ -445,17 +445,17 @@
         min_val="1"
         height="20"
         max_val="999999999" />
-    <check_box
-        height="20"
-        width="110"
-        top_pad="6"
-        label="Show in search"
-        layout="topleft"
-        left="120"
-        name="search_check"
-        tool_tip="Let people see this object in search results" />
-    <text
-        type="string"
+      <check_box
+	   height="20"
+	   width="110"
+	   top_pad="6"
+	   label="Show in search"
+       layout="topleft"
+	   left="120"
+       name="search_check"
+       tool_tip="Let people see this object in search results" />
+            <text
+             type="string"
         follows="left|top"
         name="pathfinding_attributes_label"
         top_pad="6"
@@ -466,7 +466,7 @@
     <text
         type="string"
         follows="left|top"
-        text_color="EmphasisColor"
+             text_color="EmphasisColor"
         name="pathfinding_attributes_value"
         width="130"
         word_wrap="false"
@@ -475,120 +475,120 @@
     <text
         type="string"
         text_color="EmphasisColor"
-        length="1"
+             length="1"
         top_pad="10"
-        follows="left|top"
-        layout="topleft"
-        left="10"
-        name="B:"
-        height="10"
-        width="50">
-      B:
-    </text>
-    <text
-        type="string"
-        text_color="White"
-        length="1"
-        follows="left|top"
-        layout="topleft"
-        left_pad="0"
-        name="O:"
-        height="10"
-        width="50">
-      O:
-    </text>
-    <text
-        type="string"
-        text_color="EmphasisColor"
-        length="1"
-        follows="left|top"
-        layout="topleft"
-        left_pad="0"
-        name="G:"
-        height="10"
-        width="50">
-      G:
-    </text>
-    <text
-        type="string"
-        text_color="White"
-        length="1"
-        follows="left|top"
-        left_pad="0"
-        layout="topleft"
-        name="E:"
-        height="10"
-        width="50">
-      E:
-    </text>
-    <text
-        type="string"
-        text_color="EmphasisColor"
-        length="1"
-        follows="left|top"
-        layout="topleft"
-        left_pad="0"
-        name="N:"
-        height="10"
-        width="50">
-      N:
-    </text>
-    <text
-        type="string"
-        text_color="White"
-        length="1"
-        follows="left|top"
-        layout="topleft"
-        left_pad="0"
-        name="F:"
-        height="10"
-        width="50">
-      F:
-    </text>
-  </panel>
-  <panel
-      height="25"
-      layout="bottomright"
-      name="button_panel"
-      left="5"
-      bottom="5"
-      width="313">
-    <button
-        follows="bottom|left"
-        height="23"
-        label="Open"
-        layout="topleft"
-        left="5"
-        name="open_btn"
-        top="0"
-        width="73" />
-    <button
-        follows="bottom|left"
-        height="23"
-        label="Pay"
-        layout="topleft"
-        left_pad="5"
-        name="pay_btn"
-        top="0"
-        width="73" />
-    <button
-        follows="bottom|left"
-        height="23"
-        label="Buy"
-        layout="topleft"
-        left_pad="5"
-        name="buy_btn"
-        top="0"
-        width="73" />
-    <button
-        follows="bottom|left"
-        height="23"
-        label="Details"
-        layout="topleft"
-        left_pad="5"
-        name="details_btn"
-        top="0"
-        width="74" />
+             follows="left|top"
+             layout="topleft"
+             left="10"
+             name="B:"
+             height="10"
+             width="50">
+                B:
+            </text>
+            <text
+             type="string"
+             text_color="White"
+             length="1"
+             follows="left|top"
+             layout="topleft"
+             left_pad="0"
+             name="O:"
+             height="10"
+             width="50">
+                O:
+            </text>
+            <text
+             type="string"
+             text_color="EmphasisColor"
+             length="1"
+             follows="left|top"
+             layout="topleft"
+             left_pad="0"
+             name="G:"
+             height="10"
+             width="50">
+                G:
+            </text>
+            <text
+             type="string"
+             text_color="White"
+             length="1"
+             follows="left|top"
+             left_pad="0"
+             layout="topleft"
+             name="E:"
+             height="10"
+             width="50">
+                E:
+            </text>
+            <text
+             type="string"
+             text_color="EmphasisColor"
+             length="1"
+             follows="left|top"
+             layout="topleft"
+             left_pad="0"
+             name="N:"
+             height="10"
+             width="50">
+                N:
+            </text>
+            <text
+             type="string"
+             text_color="White"
+             length="1"
+             follows="left|top"
+             layout="topleft"
+             left_pad="0"
+             name="F:"
+             height="10"
+             width="50">
+                F:
+            </text>
+		</panel>
+    <panel
+		 height="25"
+		 layout="bottomright"
+		 name="button_panel"
+		 left="5"
+		 bottom="5"
+		 width="313">
+        <button
+		     follows="bottom|left"
+		     height="23"
+		     label="Open"
+		     layout="topleft"
+		     left="5"
+		     name="open_btn"
+		     top="0"
+		     width="73" />
+	    <button
+		     follows="bottom|left"
+		     height="23"
+		     label="Pay"
+		     layout="topleft"
+		     left_pad="5"
+		     name="pay_btn"
+		     top="0"
+		     width="73" />
+	    <button
+		     follows="bottom|left"
+		     height="23"
+		     label="Buy"
+		     layout="topleft"
+		     left_pad="5"
+		     name="buy_btn"
+		     top="0"
+		     width="73" />
+        <button
+		     follows="bottom|left"
+		     height="23"
+		     label="Details"
+		     layout="topleft"
+		     left_pad="5"
+		     name="details_btn"
+		     top="0"
+		     width="74" />
 
-  </panel>
+	</panel>
 </panel>
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index d1c952ac3b..7c6b5403e1 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -1062,7 +1062,6 @@ class Linux_i686Manifest(LinuxManifest):
             self.path("libalut.so")
             self.path("libopenal.so", "libopenal.so.1")
             self.path("libopenal.so", "libvivoxoal.so.1") # vivox's sdk expects this soname
-
             # KLUDGE: As of 2012-04-11, the 'fontconfig' package installs
             # libfontconfig.so.1.4.4, along with symlinks libfontconfig.so.1
             # and libfontconfig.so. Before we added support for library-file
-- 
cgit v1.2.3


From 97d969a338c1e4f973eb817ba7701aff51a02ccb Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 12 Sep 2012 14:36:37 -0400
Subject: initial attempt to restore changes that make removing tcmalloc
 possible; not tested

---
 indra/cmake/Copy3rdPartyLibs.cmake      |  9 ++++---
 indra/cmake/GooglePerfTools.cmake       | 40 +++++++++++++++++++++--------
 indra/cmake/LLAddBuildTest.cmake        |  9 +++++++
 indra/llcommon/llallocator.cpp          |  2 +-
 indra/llcommon/llmemory.cpp             | 12 +++++++++
 indra/llcommon/llmemory.h               | 45 +++++++++++++++++++++++----------
 indra/llmath/CMakeLists.txt             |  1 +
 indra/llmath/llcamera.h                 | 12 ++++-----
 indra/llmath/llmatrix3a.h               |  2 +-
 indra/llmath/llmatrix4a.h               |  2 +-
 indra/llmath/lloctree.h                 |  4 +--
 indra/llmath/llplane.h                  |  4 ++-
 indra/llmath/llsimdmath.h               |  3 +--
 indra/llmath/llsimdtypes.inl            |  2 ++
 indra/llmath/llvector4a.cpp             |  8 +++++-
 indra/llmath/llvector4a.h               |  6 ++++-
 indra/llmath/llvector4a.inl             |  1 +
 indra/llmath/llvector4logical.h         |  2 ++
 indra/llmath/llvolume.cpp               | 45 ++++++++++++++-------------------
 indra/llmath/llvolumeoctree.h           | 26 ++++++++++++++++---
 indra/llprimitive/llmodel.cpp           |  3 ++-
 indra/newview/CMakeLists.txt            |  7 +++--
 indra/newview/llappviewerwin32.cpp      |  2 ++
 indra/newview/lldrawable.h              | 17 ++++++++++---
 indra/newview/lldynamictexture.h        | 12 ++++++++-
 indra/newview/llface.h                  | 11 ++++++++
 indra/newview/llfloatermodelpreview.cpp |  3 ++-
 indra/newview/llpolymesh.cpp            | 24 +++++++++---------
 indra/newview/llspatialpartition.cpp    |  3 +++
 indra/newview/llspatialpartition.h      | 36 ++++++++++++++++++++------
 indra/newview/llviewercamera.h          | 13 +++++++++-
 indra/newview/llviewerjointmesh.cpp     |  6 +++--
 indra/newview/llvoavatar.cpp            |  2 +-
 indra/newview/llvoavatar.h              | 12 ++++++++-
 indra/newview/llvoavatarself.h          | 10 ++++++++
 indra/newview/viewer_manifest.py        | 10 +++++++-
 36 files changed, 298 insertions(+), 108 deletions(-)

(limited to 'indra')

diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 224e0a8b51..9f05c4cff2 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -57,10 +57,10 @@ if(WINDOWS)
         libhunspell.dll
         )
 
-    if(USE_GOOGLE_PERFTOOLS)
+    if(USE_TCMALLOC)
       set(debug_files ${debug_files} libtcmalloc_minimal-debug.dll)
       set(release_files ${release_files} libtcmalloc_minimal.dll)
-    endif(USE_GOOGLE_PERFTOOLS)
+    endif(USE_TCMALLOC)
 
     if (FMOD)
       set(debug_files ${debug_files} fmod.dll)
@@ -272,13 +272,16 @@ elseif(LINUX)
         libopenal.so
         libopenjpeg.so
         libssl.so
-        libtcmalloc_minimal.so
         libuuid.so.16
         libuuid.so.16.0.22
         libssl.so.1.0.0
         libfontconfig.so.1.4.4
        )
 
+    if (USE_TCMALLOC)
+      set(release_files ${release_files} "libtcmalloc_minimal.so")
+    endif (USE_TCMALLOC)
+
     if (FMOD)
       set(release_files ${release_files} "libfmod-3.75.so")
     endif (FMOD)
diff --git a/indra/cmake/GooglePerfTools.cmake b/indra/cmake/GooglePerfTools.cmake
index d9f91193be..09501e0406 100644
--- a/indra/cmake/GooglePerfTools.cmake
+++ b/indra/cmake/GooglePerfTools.cmake
@@ -1,20 +1,34 @@
 # -*- cmake -*-
 include(Prebuilt)
 
+# If you want to enable or disable TCMALLOC in viewer builds, this is the place.
+# set ON or OFF as desired.
+set (USE_TCMALLOC ON)
+
 if (STANDALONE)
   include(FindGooglePerfTools)
 else (STANDALONE)
   if (WINDOWS)
-    use_prebuilt_binary(tcmalloc)
-    set(TCMALLOC_LIBRARIES 
-        debug libtcmalloc_minimal-debug
-        optimized libtcmalloc_minimal)
+    if (USE_TCMALLOC)
+       use_prebuilt_binary(tcmalloc)
+       set(TCMALLOC_LIBRARIES 
+         debug libtcmalloc_minimal-debug
+         optimized libtcmalloc_minimal)
+       set(TCMALLOC_LINK_FLAGS  "/INCLUDE:__tcmalloc")
+    else (USE_TCMALLOC)
+      set(TCMALLOC_LIBRARIES)
+      set(TCMALLOC_LINK_FLAGS)
+    endif (USE_TCMALLOC)
     set(GOOGLE_PERFTOOLS_FOUND "YES")
   endif (WINDOWS)
   if (LINUX)
-    use_prebuilt_binary(tcmalloc)
-    set(TCMALLOC_LIBRARIES 
-    tcmalloc)
+    if (USE_TCMALLOC)
+      use_prebuilt_binary(tcmalloc)
+      set(TCMALLOC_LIBRARIES 
+        tcmalloc)
+    else (USE_TCMALLOC)
+      set(TCMALLOC_LIBRARIES)
+    endif (USE_TCMALLOC)
     set(PROFILER_LIBRARIES profiler)
     set(GOOGLE_PERFTOOLS_INCLUDE_DIR
         ${LIBS_PREBUILT_DIR}/include)
@@ -29,13 +43,19 @@ if (GOOGLE_PERFTOOLS_FOUND)
 endif (GOOGLE_PERFTOOLS_FOUND)
 
 if (WINDOWS)
-    set(USE_GOOGLE_PERFTOOLS ON)
+   set(USE_GOOGLE_PERFTOOLS ON)
 endif (WINDOWS)
 
 if (USE_GOOGLE_PERFTOOLS)
-  set(TCMALLOC_FLAG -ULL_USE_TCMALLOC=1)
+  if (USE_TCMALLOC)
+    set(TCMALLOC_FLAG -DLL_USE_TCMALLOC=1)
+  else (USE_TCMALLOC)
+    set(TCMALLOC_FLAG -ULL_USE_TCMALLOC)
+  endif (USE_TCMALLOC)
+endif (USE_GOOGLE_PERFTOOLS)
+
+if (USE_GOOGLE_PERFTOOLS)
   include_directories(${GOOGLE_PERFTOOLS_INCLUDE_DIR})
   set(GOOGLE_PERFTOOLS_LIBRARIES ${TCMALLOC_LIBRARIES} ${STACKTRACE_LIBRARIES} ${PROFILER_LIBRARIES})
 else (USE_GOOGLE_PERFTOOLS)
-  set(TCMALLOC_FLAG -ULL_USE_TCMALLOC)
 endif (USE_GOOGLE_PERFTOOLS)
diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake
index 03ce46781c..543075db5b 100755
--- a/indra/cmake/LLAddBuildTest.cmake
+++ b/indra/cmake/LLAddBuildTest.cmake
@@ -214,6 +214,15 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
     SET_TARGET_PROPERTIES(INTEGRATION_TEST_${testname} PROPERTIES COMPILE_FLAGS -I"${TUT_INCLUDE_DIR}")
   endif(STANDALONE)
 
+  if (WINDOWS)
+    SET_TARGET_PROPERTIES(INTEGRATION_TEST_${testname}
+        PROPERTIES
+        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS ${TCMALLOC_LINK_FLAGS}"
+        LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" /INCREMENTAL:NO"
+        LINK_FLAGS_RELEASE ""
+        )
+  endif (WINDOWS)
+
   # Add link deps to the executable
   if(TEST_DEBUG)
     message(STATUS "TARGET_LINK_LIBRARIES(INTEGRATION_TEST_${testname} ${libraries})")
diff --git a/indra/llcommon/llallocator.cpp b/indra/llcommon/llallocator.cpp
index 6f6abefc67..87654b5b97 100644
--- a/indra/llcommon/llallocator.cpp
+++ b/indra/llcommon/llallocator.cpp
@@ -27,7 +27,7 @@
 #include "linden_common.h"
 #include "llallocator.h"
 
-#if LL_USE_TCMALLOC
+#if (LL_USE_TCMALLOC && LL_USE_HEAP_PROFILER)
 
 #include "google/heap-profiler.h"
 #include "google/commandlineflags_public.h"
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 3b9758f996..afaf366668 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -61,6 +61,18 @@ BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
 LLPrivateMemoryPoolManager::mem_allocation_info_t LLPrivateMemoryPoolManager::sMemAllocationTracker;
 #endif
 
+void ll_assert_aligned_func(uintptr_t ptr,U32 alignment)
+{
+#ifdef SHOW_ASSERT
+	// Redundant, place to set breakpoints.
+	if (ptr%alignment!=0)
+	{
+		llwarns << "alignment check failed" << llendl;
+	}
+	llassert(ptr%alignment==0);
+#endif
+}
+
 //static
 void LLMemory::initClass()
 {
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index bbbdaa6497..9dd776ff57 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -27,7 +27,6 @@
 #define LLMEMORY_H
 
 #include "llmemtype.h"
-#if LL_DEBUG
 inline void* ll_aligned_malloc( size_t size, int align )
 {
 	void* mem = malloc( size + (align - 1) + sizeof(void*) );
@@ -43,10 +42,11 @@ inline void ll_aligned_free( void* ptr )
 	free( ((void**)ptr)[-1] );
 }
 
+#if !LL_USE_TCMALLOC
 inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
 {
 #if defined(LL_WINDOWS)
-	return _mm_malloc(size, 16);
+	return _aligned_malloc(size, 16);
 #elif defined(LL_DARWIN)
 	return malloc(size); // default osx malloc is 16 byte aligned.
 #else
@@ -58,21 +58,38 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi
 #endif
 }
 
+inline void* ll_aligned_realloc_16(void* ptr, size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
+{
+#if defined(LL_WINDOWS)
+	return _aligned_realloc(ptr, size, 16);
+#elif defined(LL_DARWIN)
+	return realloc(ptr,size); // default osx malloc is 16 byte aligned.
+#else
+	return realloc(ptr,size); // FIXME not guaranteed to be aligned.
+#endif
+}
+
 inline void ll_aligned_free_16(void *p)
 {
 #if defined(LL_WINDOWS)
-	_mm_free(p);
+	_aligned_free(p);
 #elif defined(LL_DARWIN)
 	return free(p);
 #else
 	free(p); // posix_memalign() is compatible with heap deallocator
 #endif
 }
+#else // USE_TCMALLOC
+// ll_aligned_foo_16 are not needed with tcmalloc
+#define ll_aligned_malloc_16 malloc
+#define ll_aligned_realloc_16 realloc
+#define ll_aligned_free_16 free
+#endif // USE_TCMALLOC
 
 inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed with ll_aligned_free_32().
 {
 #if defined(LL_WINDOWS)
-	return _mm_malloc(size, 32);
+	return _aligned_malloc(size, 32);
 #elif defined(LL_DARWIN)
 	return ll_aligned_malloc( size, 32 );
 #else
@@ -87,22 +104,13 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi
 inline void ll_aligned_free_32(void *p)
 {
 #if defined(LL_WINDOWS)
-	_mm_free(p);
+	_aligned_free(p);
 #elif defined(LL_DARWIN)
 	ll_aligned_free( p );
 #else
 	free(p); // posix_memalign() is compatible with heap deallocator
 #endif
 }
-#else // LL_DEBUG
-// ll_aligned_foo are noops now that we use tcmalloc everywhere (tcmalloc aligns automatically at appropriate intervals)
-#define ll_aligned_malloc( size, align ) malloc(size)
-#define ll_aligned_free( ptr ) free(ptr)
-#define ll_aligned_malloc_16 malloc
-#define ll_aligned_free_16 free
-#define ll_aligned_malloc_32 malloc
-#define ll_aligned_free_32 free
-#endif // LL_DEBUG
 
 #ifndef __DEBUG_PRIVATE_MEM__
 #define __DEBUG_PRIVATE_MEM__  0
@@ -512,4 +520,13 @@ void  LLPrivateMemoryPoolTester::operator delete[](void* addr)
 
 // LLSingleton moved to llsingleton.h
 
+LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
+
+#ifdef SHOW_ASSERT
+#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast<uintptr_t>(ptr),((U32)alignment))
+#else
+#define ll_assert_aligned(ptr,alignment)
+#endif
+
+
 #endif
diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt
index b5e59c1ca3..5865ae030c 100644
--- a/indra/llmath/CMakeLists.txt
+++ b/indra/llmath/CMakeLists.txt
@@ -117,6 +117,7 @@ if (LL_TESTS)
   # INTEGRATION TESTS
   set(test_libs llmath llcommon ${LLCOMMON_LIBRARIES} ${WINDOWS_LIBRARIES})
   # TODO: Some of these need refactoring to be proper Unit tests rather than Integration tests.
+  LL_ADD_INTEGRATION_TEST(alignment "" "${test_libs}")
   LL_ADD_INTEGRATION_TEST(llbbox llbbox.cpp "${test_libs}")
   LL_ADD_INTEGRATION_TEST(llquaternion llquaternion.cpp "${test_libs}")
   LL_ADD_INTEGRATION_TEST(mathmisc "" "${test_libs}")
diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
index ec67b91d05..0b591be622 100644
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -60,7 +60,7 @@ static const F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD;
 // roll(), pitch(), yaw()
 // etc...
 
-
+LL_ALIGN_PREFIX(16)
 class LLCamera
 : 	public LLCoordFrame
 {
@@ -108,7 +108,7 @@ public:
 	};
 
 private:
-	LLPlane mAgentPlanes[7];  //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
+	LL_ALIGN_16(LLPlane mAgentPlanes[7]);  //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
 	U8 mPlaneMask[8];         // 8 for alignment	
 	
 	F32 mView;					// angle between top and bottom frustum planes in radians.
@@ -116,13 +116,13 @@ private:
 	S32 mViewHeightInPixels;	// for ViewHeightInPixels() only
 	F32 mNearPlane;
 	F32 mFarPlane;
-	LLPlane mLocalPlanes[4];
+	LL_ALIGN_16(LLPlane mLocalPlanes[4]);
 	F32 mFixedDistance;			// Always return this distance, unless < 0
 	LLVector3 mFrustCenter;		// center of frustum and radius squared for ultra-quick exclusion test
 	F32 mFrustRadiusSquared;
 	
-	LLPlane mWorldPlanes[PLANE_NUM];
-	LLPlane mHorizPlanes[HORIZ_PLANE_NUM];
+	LL_ALIGN_16(LLPlane mWorldPlanes[PLANE_NUM]);
+	LL_ALIGN_16(LLPlane mHorizPlanes[HORIZ_PLANE_NUM]);
 
 	U32 mPlaneCount;  //defaults to 6, if setUserClipPlane is called, uses user supplied clip plane in
 
@@ -208,7 +208,7 @@ protected:
 	void calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom);
 	void calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2);
 	void calculateWorldFrustumPlanes();
-};
+} LL_ALIGN_POSTFIX(16);
 
 
 #endif
diff --git a/indra/llmath/llmatrix3a.h b/indra/llmath/llmatrix3a.h
index adb7e3389d..9916cfd2da 100644
--- a/indra/llmath/llmatrix3a.h
+++ b/indra/llmath/llmatrix3a.h
@@ -111,7 +111,7 @@ public:
 
 protected:
 
-	LLVector4a mColumns[3];
+	LL_ALIGN_16(LLVector4a mColumns[3]);
 
 };
 
diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h
index 27cf5b79f6..c4cefdb4fa 100644
--- a/indra/llmath/llmatrix4a.h
+++ b/indra/llmath/llmatrix4a.h
@@ -34,7 +34,7 @@
 class LLMatrix4a
 {
 public:
-	LLVector4a mMatrix[4];
+	LL_ALIGN_16(LLVector4a mMatrix[4]);
 
 	inline void clear()
 	{
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 1b11e83b4a..6c7744cdf1 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -88,7 +88,7 @@ public:
 	typedef LLOctreeNode<T>		oct_node;
 	typedef LLOctreeListener<T>	oct_listener;
 
-	/*void* operator new(size_t size)
+	void* operator new(size_t size)
 	{
 		return ll_aligned_malloc_16(size);
 	}
@@ -96,7 +96,7 @@ public:
 	void operator delete(void* ptr)
 	{
 		ll_aligned_free_16(ptr);
-	}*/
+	}
 
 	LLOctreeNode(	const LLVector4a& center, 
 					const LLVector4a& size, 
diff --git a/indra/llmath/llplane.h b/indra/llmath/llplane.h
index a611894721..3c32441b11 100644
--- a/indra/llmath/llplane.h
+++ b/indra/llmath/llplane.h
@@ -36,6 +36,8 @@
 // The plane normal = [A, B, C]
 // The closest approach = D / sqrt(A*A + B*B + C*C)
 
+
+LL_ALIGN_PREFIX(16)
 class LLPlane
 {
 public:
@@ -94,7 +96,7 @@ public:
 		
 private:
 	LLVector4a mV;
-};
+} LL_ALIGN_POSTFIX(16);
 
 
 
diff --git a/indra/llmath/llsimdmath.h b/indra/llmath/llsimdmath.h
index c7cdf7b32c..01458521ec 100644
--- a/indra/llmath/llsimdmath.h
+++ b/indra/llmath/llsimdmath.h
@@ -67,11 +67,10 @@ template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address)
 
 #define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16)
 
-
-
 #include <xmmintrin.h>
 #include <emmintrin.h>
 
+#include "llmemory.h"
 #include "llsimdtypes.h"
 #include "llsimdtypes.inl"
 
diff --git a/indra/llmath/llsimdtypes.inl b/indra/llmath/llsimdtypes.inl
index 712239e425..e905c84954 100644
--- a/indra/llmath/llsimdtypes.inl
+++ b/indra/llmath/llsimdtypes.inl
@@ -62,6 +62,7 @@ inline LLSimdScalar operator/(const LLSimdScalar& a, const LLSimdScalar& b)
 inline LLSimdScalar operator-(const LLSimdScalar& a)
 {
 	static LL_ALIGN_16(const U32 signMask[4]) = {0x80000000, 0x80000000, 0x80000000, 0x80000000 };
+	ll_assert_aligned(signMask,16);
 	return _mm_xor_ps(*reinterpret_cast<const LLQuad*>(signMask), a);
 }
 
@@ -146,6 +147,7 @@ inline LLSimdScalar& LLSimdScalar::operator/=(const LLSimdScalar& rhs)
 inline LLSimdScalar LLSimdScalar::getAbs() const
 {
 	static const LL_ALIGN_16(U32 F_ABS_MASK_4A[4]) = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF };
+	ll_assert_aligned(F_ABS_MASK_4A,16);
 	return _mm_and_ps( mQ, *reinterpret_cast<const LLQuad*>(F_ABS_MASK_4A));
 }
 
diff --git a/indra/llmath/llvector4a.cpp b/indra/llmath/llvector4a.cpp
index b66b7a7076..6edeb0fefe 100644
--- a/indra/llmath/llvector4a.cpp
+++ b/indra/llmath/llvector4a.cpp
@@ -24,6 +24,7 @@
  * $/LicenseInfo$
  */
 
+#include "llmemory.h"
 #include "llmath.h"
 #include "llquantize.h"
 
@@ -44,7 +45,10 @@ extern const LLVector4a LL_V4A_EPSILON = reinterpret_cast<const LLVector4a&> ( F
 	assert(dst != NULL);
 	assert(bytes > 0);
 	assert((bytes % sizeof(F32))== 0); 
-	
+	ll_assert_aligned(src,16);
+	ll_assert_aligned(dst,16);
+	assert(bytes%16==0);
+
 	F32* end = dst + (bytes / sizeof(F32) );
 
 	if (bytes > 64)
@@ -189,6 +193,8 @@ void LLVector4a::quantize16( const LLVector4a& low, const LLVector4a& high )
 		LLVector4a oneOverDelta;
 		{
 			static LL_ALIGN_16( const F32 F_TWO_4A[4] ) = { 2.f, 2.f, 2.f, 2.f };
+			ll_assert_aligned(F_TWO_4A,16);
+			
 			LLVector4a two; two.load4a( F_TWO_4A );
 
 			// Here we use _mm_rcp_ps plus one round of newton-raphson
diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h
index 596082509d..0526793d3a 100644
--- a/indra/llmath/llvector4a.h
+++ b/indra/llmath/llvector4a.h
@@ -32,6 +32,7 @@ class LLRotation;
 
 #include <assert.h>
 #include "llpreprocessor.h"
+#include "llmemory.h"
 
 ///////////////////////////////////
 // FIRST TIME USERS PLEASE READ
@@ -46,6 +47,7 @@ class LLRotation;
 // LLVector3/LLVector4. 
 /////////////////////////////////
 
+LL_ALIGN_PREFIX(16)
 class LLVector4a
 {
 public:
@@ -82,6 +84,7 @@ public:
 	}
 
 	// Copy words 16-byte blocks from src to dst. Source and destination must not overlap. 
+	// Source and dest must be 16-byte aligned and size must be multiple of 16.
 	static void memcpyNonAliased16(F32* __restrict dst, const F32* __restrict src, size_t bytes);
 
 	////////////////////////////////////
@@ -90,6 +93,7 @@ public:
 	
 	LLVector4a()
 	{ //DO NOT INITIALIZE -- The overhead is completely unnecessary
+		ll_assert_aligned(this,16);
 	}
 	
 	LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f)
@@ -313,7 +317,7 @@ public:
 
 private:
 	LLQuad mQ;
-};
+} LL_ALIGN_POSTFIX(16);
 
 inline void update_min_max(LLVector4a& min, LLVector4a& max, const LLVector4a& p)
 {
diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl
index 7ad22a5631..7c52ffef21 100644
--- a/indra/llmath/llvector4a.inl
+++ b/indra/llmath/llvector4a.inl
@@ -475,6 +475,7 @@ inline void LLVector4a::setLerp(const LLVector4a& lhs, const LLVector4a& rhs, F3
 inline LLBool32 LLVector4a::isFinite3() const
 {
 	static LL_ALIGN_16(const U32 nanOrInfMask[4]) = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 };
+	ll_assert_aligned(nanOrInfMask,16);
 	const __m128i nanOrInfMaskV = *reinterpret_cast<const __m128i*> (nanOrInfMask);
 	const __m128i maskResult = _mm_and_si128( _mm_castps_si128(mQ), nanOrInfMaskV );
 	const LLVector4Logical equalityCheck = _mm_castsi128_ps(_mm_cmpeq_epi32( maskResult, nanOrInfMaskV ));
diff --git a/indra/llmath/llvector4logical.h b/indra/llmath/llvector4logical.h
index dd66b09d43..c5698f7cea 100644
--- a/indra/llmath/llvector4logical.h
+++ b/indra/llmath/llvector4logical.h
@@ -27,6 +27,7 @@
 #ifndef	LL_VECTOR4LOGICAL_H
 #define	LL_VECTOR4LOGICAL_H
 
+#include "llmemory.h"
 
 ////////////////////////////
 // LLVector4Logical
@@ -77,6 +78,7 @@ public:
 	inline LLVector4Logical& invert()
 	{
 		static const LL_ALIGN_16(U32 allOnes[4]) = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
+		ll_assert_aligned(allOnes,16);
 		mQ = _mm_andnot_ps( mQ, *(LLQuad*)(allOnes) );
 		return *this;
 	}
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index cc9744756f..11fa7080ce 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -95,17 +95,6 @@ const S32 SCULPT_MIN_AREA_DETAIL = 1;
 
 extern BOOL gDebugGL;
 
-void assert_aligned(void* ptr, uintptr_t alignment)
-{
-#if 0
-	uintptr_t t = (uintptr_t) ptr;
-	if (t%alignment != 0)
-	{
-		llerrs << "Alignment check failed." << llendl;
-	}
-#endif
-}
-
 BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
 {    
 	LLVector3 test = (pt2-pt1)%(pt3-pt2);
@@ -6962,14 +6951,14 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
 	if (num_verts)
 	{
 		mPositions = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts);
-		assert_aligned(mPositions, 16);
+		ll_assert_aligned(mPositions, 16);
 		mNormals = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts);
-		assert_aligned(mNormals, 16);
+		ll_assert_aligned(mNormals, 16);
 
 		//pad texture coordinate block end to allow for QWORD reads
 		S32 size = ((num_verts*sizeof(LLVector2)) + 0xF) & ~0xF;
 		mTexCoords = (LLVector2*) ll_aligned_malloc_16(size);
-		assert_aligned(mTexCoords, 16);
+		ll_assert_aligned(mTexCoords, 16);
 	}
 	else
 	{
@@ -6993,14 +6982,17 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 //	S32 old_size = mNumVertices*16;
 
 	//positions
-	mPositions = (LLVector4a*) realloc(mPositions, new_size);
+	mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_size);
+	ll_assert_aligned(mPositions,16);
 	
 	//normals
-	mNormals = (LLVector4a*) realloc(mNormals, new_size);
-	
+	mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_size);
+	ll_assert_aligned(mNormals,16);
+
 	//tex coords
 	new_size = ((new_verts*8)+0xF) & ~0xF;
-	mTexCoords = (LLVector2*) realloc(mTexCoords, new_size);
+	mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, new_size);
+	ll_assert_aligned(mTexCoords,16);
 	
 
 	//just clear binormals
@@ -7053,7 +7045,8 @@ void LLVolumeFace::pushIndex(const U16& idx)
 	S32 old_size = ((mNumIndices*2)+0xF) & ~0xF;
 	if (new_size != old_size)
 	{
-		mIndices = (U16*) realloc(mIndices, new_size);
+		mIndices = (U16*) ll_aligned_realloc_16(mIndices, new_size);
+		ll_assert_aligned(mIndices,16);
 	}
 	
 	mIndices[mNumIndices++] = idx;
@@ -7094,12 +7087,12 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	}
 
 	//allocate new buffer space
-	mPositions = (LLVector4a*) realloc(mPositions, new_count*sizeof(LLVector4a));
-	assert_aligned(mPositions, 16);
-	mNormals = (LLVector4a*) realloc(mNormals, new_count*sizeof(LLVector4a));
-	assert_aligned(mNormals, 16);
-	mTexCoords = (LLVector2*) realloc(mTexCoords, (new_count*sizeof(LLVector2)+0xF) & ~0xF);
-	assert_aligned(mTexCoords, 16);
+	mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_count*sizeof(LLVector4a));
+	ll_assert_aligned(mPositions, 16);
+	mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_count*sizeof(LLVector4a));
+	ll_assert_aligned(mNormals, 16);
+	mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, (new_count*sizeof(LLVector2)+0xF) & ~0xF);
+	ll_assert_aligned(mTexCoords, 16);
 	
 	mNumVertices = new_count;
 
@@ -7145,7 +7138,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	new_count = mNumIndices + face.mNumIndices;
 
 	//allocate new index buffer
-	mIndices = (U16*) realloc(mIndices, (new_count*sizeof(U16)+0xF) & ~0xF);
+	mIndices = (U16*) ll_aligned_realloc_16(mIndices, (new_count*sizeof(U16)+0xF) & ~0xF);
 	
 	//get destination address into new index buffer
 	U16* dst_idx = mIndices+mNumIndices;
diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h
index 688d91dc40..dac97b14b5 100644
--- a/indra/llmath/llvolumeoctree.h
+++ b/indra/llmath/llvolumeoctree.h
@@ -37,6 +37,16 @@
 class LLVolumeTriangle : public LLRefCount
 {
 public:
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	LLVolumeTriangle()
 	{
 		
@@ -58,7 +68,7 @@ public:
 	
 	}
 
-	LLVector4a mPositionGroup;
+	LL_ALIGN_16(LLVector4a mPositionGroup);
 
 	const LLVector4a* mV[3];
 	U16 mIndex[3];
@@ -73,6 +83,16 @@ class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeTriangle>
 {
 public:
 	
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	LLVolumeOctreeListener(LLOctreeNode<LLVolumeTriangle>* node);
 	~LLVolumeOctreeListener();
 	
@@ -99,8 +119,8 @@ public:
 	
 
 public:
-	LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
-	LLVector4a mExtents[2]; // extents (min, max) of this node and all its children
+	LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
 };
 
 class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle>
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index cb32a510b8..28ed051c55 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -1026,7 +1026,8 @@ void LLModel::setVolumeFaceData(
 
 	if (tc.get())
 	{
-		LLVector4a::memcpyNonAliased16((F32*) face.mTexCoords, (F32*) tc.get(), num_verts*2*sizeof(F32));
+		U32 tex_size = (num_verts*2*sizeof(F32)+0xF)&~0xF;
+		LLVector4a::memcpyNonAliased16((F32*) face.mTexCoords, (F32*) tc.get(), tex_size);
 	}
 	else
 	{
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index c0a252637f..2ae162a623 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1565,8 +1565,7 @@ if (WINDOWS)
     set_target_properties(${VIEWER_BINARY_NAME}
         PROPERTIES
         # *TODO -reenable this once we get server usage sorted out
-        #LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS /INCLUDE:\"__tcmalloc\""
-        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS /INCLUDE:__tcmalloc "
+        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS "
         LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" /INCREMENTAL:NO"
         LINK_FLAGS_RELEASE "/FORCE:MULTIPLE /MAP\"secondlife-bin.MAP\" /OPT:REF"
         )
@@ -1585,7 +1584,7 @@ if (WINDOWS)
     # In the meantime, if you have any ideas on how to easily maintain one list, either here or in viewer_manifest.py
     # and have the build deps get tracked *please* tell me about it.
 
-    if(USE_GOOGLE_PERFTOOLS)
+    if(USE_TCMALLOC)
       # Configure a var for tcmalloc location, if used.
       # Note the need to specify multiple names explicitly.
       set(GOOGLE_PERF_TOOLS_SOURCE
@@ -1593,7 +1592,7 @@ if (WINDOWS)
         ${SHARED_LIB_STAGING_DIR}/RelWithDebInfo/libtcmalloc_minimal.dll
         ${SHARED_LIB_STAGING_DIR}/Debug/libtcmalloc_minimal-debug.dll
         )
-     endif(USE_GOOGLE_PERFTOOLS)
+     endif(USE_TCMALLOC)
 
 
     set(COPY_INPUT_DEPENDENCIES
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index bad60a9757..53c77fa22e 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -130,6 +130,8 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 	// This results in a 2-3x improvement in opening a new Inventory window (which uses a large numebr of allocations)
 	// Note: This won't work when running from the debugger unless the _NO_DEBUG_HEAP environment variable is set to 1
 
+	// Enable to get mem debugging within visual studio.
+	//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
 	_CrtSetDbgFlag(0); // default, just making explicit
 	
 	ULONG ulEnableLFH = 2;
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index e2064b79f8..8c7db61502 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -59,6 +59,7 @@ class LLViewerTexture;
 const U32 SILHOUETTE_HIGHLIGHT = 0;
 
 // All data for new renderer goes into this class.
+LL_ALIGN_PREFIX(16)
 class LLDrawable : public LLRefCount
 {
 public:
@@ -75,6 +76,16 @@ public:
 
 	static void initClass();
 
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	LLDrawable()				{ init(); }
 	MEM_TYPE_NEW(LLMemType::MTYPE_DRAWABLE);
 	
@@ -281,8 +292,8 @@ public:
 	} EDrawableFlags;
 
 private: //aligned members
-	LLVector4a		mExtents[2];
-	LLVector4a		mPositionGroup;
+	LL_ALIGN_16(LLVector4a		mExtents[2]);
+	LL_ALIGN_16(LLVector4a		mPositionGroup);
 	
 public:
 	LLXformMatrix       mXform;
@@ -323,7 +334,7 @@ private:
 
 	static U32 sNumZombieDrawables;
 	static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList;
-};
+} LL_ALIGN_POSTFIX(16);
 
 
 inline LLFace* LLDrawable::getFace(const S32 i) const
diff --git a/indra/newview/lldynamictexture.h b/indra/newview/lldynamictexture.h
index e18090545d..c51e7d1e1a 100644
--- a/indra/newview/lldynamictexture.h
+++ b/indra/newview/lldynamictexture.h
@@ -36,6 +36,16 @@
 class LLViewerDynamicTexture : public LLViewerTexture
 {
 public:
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	enum
 	{
 		LL_VIEWER_DYNAMIC_TEXTURE = LLViewerTexture::DYNAMIC_TEXTURE,
@@ -85,7 +95,7 @@ protected:
 protected:
 	BOOL mClamp;
 	LLCoordGL mOrigin;
-	LLCamera mCamera;
+	LL_ALIGN_16(LLCamera mCamera);
 	
 	typedef std::set<LLViewerDynamicTexture*> instance_list_t;
 	static instance_list_t sInstances[ LLViewerDynamicTexture::ORDER_COUNT ];
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 76ea5c853a..5dca27487f 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -59,6 +59,17 @@ class LLFace
 {
 public:
 
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
+
 	LLFace(const LLFace& rhs)
 	{
 		*this = rhs;
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 3fe535cbe8..a071f338ba 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -4774,7 +4774,8 @@ void LLModelPreview::genBuffers(S32 lod, bool include_skin_weights)
 			if (vf.mTexCoords)
 			{
 				vb->getTexCoord0Strider(tc_strider);
-				LLVector4a::memcpyNonAliased16((F32*) tc_strider.get(), (F32*) vf.mTexCoords, num_vertices*2*sizeof(F32));
+				S32 tex_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF;
+				LLVector4a::memcpyNonAliased16((F32*) tc_strider.get(), (F32*) vf.mTexCoords, tex_size);
 			}
 			
 			if (vf.mNormals)
diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp
index 450f9b2be7..0860506086 100644
--- a/indra/newview/llpolymesh.cpp
+++ b/indra/newview/llpolymesh.cpp
@@ -129,22 +129,22 @@ void LLPolyMeshSharedData::freeMeshData()
         {
                 mNumVertices = 0;
 
-                delete [] mBaseCoords;
+                ll_aligned_free_16(mBaseCoords);
                 mBaseCoords = NULL;
 
-                delete [] mBaseNormals;
+                ll_aligned_free_16(mBaseNormals);
                 mBaseNormals = NULL;
 
-                delete [] mBaseBinormals;
+                ll_aligned_free_16(mBaseBinormals);
                 mBaseBinormals = NULL;
 
-                delete [] mTexCoords;
+                ll_aligned_free_16(mTexCoords);
                 mTexCoords = NULL;
 
-                delete [] mDetailTexCoords;
+                ll_aligned_free_16(mDetailTexCoords);
                 mDetailTexCoords = NULL;
 
-                delete [] mWeights;
+                ll_aligned_free_16(mWeights);
                 mWeights = NULL;
         }
 
@@ -229,12 +229,12 @@ U32 LLPolyMeshSharedData::getNumKB()
 BOOL LLPolyMeshSharedData::allocateVertexData( U32 numVertices )
 {
         U32 i;
-        mBaseCoords = new LLVector3[ numVertices ];
-        mBaseNormals = new LLVector3[ numVertices ];
-        mBaseBinormals = new LLVector3[ numVertices ];
-        mTexCoords = new LLVector2[ numVertices ];
-        mDetailTexCoords = new LLVector2[ numVertices ];
-        mWeights = new F32[ numVertices ];
+        mBaseCoords = (LLVector3*) ll_aligned_malloc_16(numVertices*sizeof(LLVector3));
+        mBaseNormals = (LLVector3*) ll_aligned_malloc_16(numVertices*sizeof(LLVector3));
+        mBaseBinormals = (LLVector3*) ll_aligned_malloc_16(numVertices*sizeof(LLVector3));
+        mTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
+        mDetailTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
+        mWeights = (F32*) ll_aligned_malloc_16(numVertices*sizeof(F32));
         for (i = 0; i < numVertices; i++)
         {
                 mWeights[i] = 0.f;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 325a2d3004..45ef8f1a6d 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -529,6 +529,7 @@ void LLSpatialGroup::setVisible()
 
 void LLSpatialGroup::validate()
 {
+	ll_assert_aligned(this,64);
 #if LL_OCTREE_PARANOIA_CHECK
 
 	sg_assert(!isState(DIRTY));
@@ -1195,6 +1196,8 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
 	mCurUpdatingSlotp(NULL),
 	mCurUpdatingTexture (NULL)
 {
+	ll_assert_aligned(this,16);
+	
 	sNodeCount++;
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index f0e4f15a83..7968c28900 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -68,6 +68,16 @@ protected:
 	~LLDrawInfo();	
 	
 public:
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 
 	LLDrawInfo(const LLDrawInfo& rhs)
 	{
@@ -106,7 +116,7 @@ public:
 	F32 mPartSize;
 	F32 mVSize;
 	LLSpatialGroup* mGroup;
-	LLFace* mFace; //associated face
+	LL_ALIGN_16(LLFace* mFace); //associated face
 	F32 mDistance;
 	U32 mDrawMode;
 
@@ -181,7 +191,7 @@ public:
 	};
 };
 
-LL_ALIGN_PREFIX(64)
+LL_ALIGN_PREFIX(16)
 class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 {
 	friend class LLSpatialPartition;
@@ -193,6 +203,16 @@ public:
 		*this = rhs;
 	}
 
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	const LLSpatialGroup& operator=(const LLSpatialGroup& rhs)
 	{
 		llerrs << "Illegal operation!" << llendl;
@@ -370,12 +390,12 @@ public:
 		V4_COUNT = 10
 	} eV4Index;
 
-	LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
-	LLVector4a mExtents[2]; // extents (min, max) of this node and all its children
-	LLVector4a mObjectExtents[2]; // extents (min, max) of objects in this node
-	LLVector4a mObjectBounds[2]; // bounding box (center, size) of objects in this node
-	LLVector4a mViewAngle;
-	LLVector4a mLastUpdateViewAngle;
+	LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
+	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
+	LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node
+	LL_ALIGN_16(LLVector4a mViewAngle);
+	LL_ALIGN_16(LLVector4a mLastUpdateViewAngle);
 
 	F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3()
 		
diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h
index 184033de42..b857c7fe89 100644
--- a/indra/newview/llviewercamera.h
+++ b/indra/newview/llviewercamera.h
@@ -51,9 +51,19 @@ const BOOL NOT_FOR_SELECTION = FALSE;
 extern template class LLViewerCamera* LLSingleton<class LLViewerCamera>::getInstance();
 #endif
 
+LL_ALIGN_PREFIX(16)
 class LLViewerCamera : public LLCamera, public LLSingleton<LLViewerCamera>
 {
 public:
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
 
 	typedef enum
 	{
@@ -137,6 +147,7 @@ protected:
 	S16					mZoomSubregion;
 
 public:
-};
+} LL_ALIGN_POSTFIX(16);
+
 
 #endif // LL_LLVIEWERCAMERA_H
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index f029ae5302..5d1aa870a3 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -729,8 +729,10 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 				F32* vw = (F32*) vertex_weightsp.get();
 				F32* cw = (F32*) clothing_weightsp.get();	
 
-				LLVector4a::memcpyNonAliased16(tc, (F32*) mMesh->getTexCoords(), num_verts*2*sizeof(F32));
-				LLVector4a::memcpyNonAliased16(vw, (F32*) mMesh->getWeights(), num_verts*sizeof(F32));	
+				S32 tc_size = (num_verts*2*sizeof(F32)+0xF) & ~0xF;
+				LLVector4a::memcpyNonAliased16(tc, (F32*) mMesh->getTexCoords(), tc_size);
+				S32 vw_size = (num_verts*sizeof(F32)+0xF) & ~0xF;	
+				LLVector4a::memcpyNonAliased16(vw, (F32*) mMesh->getWeights(), vw_size);	
 				LLVector4a::memcpyNonAliased16(cw, (F32*) mMesh->getClothingWeights(), num_verts*4*sizeof(F32));	
 			}
 
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 33dc12c473..1b7009a5c2 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2692,7 +2692,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 
 	if (isImpostor() && !mNeedsImpostorUpdate)
 	{
-		LLVector4a ext[2];
+		LL_ALIGN_16(LLVector4a ext[2]);
 		F32 distance;
 		LLVector3 angle;
 
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 6fb56a4c0b..4081a1408d 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -93,6 +93,16 @@ protected:
  **/
 
 public:
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	LLVOAvatar(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
 	virtual void		markDead();
 	static void			initClass(); // Initialize data that's only init'd once per class.
@@ -215,7 +225,7 @@ public:
 	bool isBuilt() const { return mIsBuilt; }
 
 private: //aligned members
-	LLVector4a	mImpostorExtents[2];
+	LL_ALIGN_16(LLVector4a	mImpostorExtents[2]);
 
 private:
 	BOOL			mSupportsAlphaLayers; // For backwards compatibility, TRUE for 1.23+ clients
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index 543891ca63..2b273e616c 100644
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -49,6 +49,16 @@ class LLVOAvatarSelf :
  **/
 
 public:
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	LLVOAvatarSelf(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
 	virtual 				~LLVOAvatarSelf();
 	virtual void			markDead();
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 7c6b5403e1..894d2f0925 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -1080,7 +1080,15 @@ class Linux_i686Manifest(LinuxManifest):
             # previous call did, without having to explicitly state the
             # version number.
             self.path("libfontconfig.so.*.*")
-            self.path("libtcmalloc.so*") #formerly called google perf tools
+            try:
+                self.path("libtcmalloc.so", "libtcmalloc.so") #formerly called google perf tools
+                self.path("libtcmalloc.so.0", "libtcmalloc.so.0") #formerly called google perf tools
+                self.path("libtcmalloc.so.0.1.0", "libtcmalloc.so.0.1.0") #formerly called google perf tools
+                pass
+            except:
+                print "tcmalloc files not found, skipping"
+                pass
+
             try:
                     self.path("libfmod-3.75.so")
                     pass
-- 
cgit v1.2.3


From d52c1c1c68c7cdcb791c6fb947fade96e4ef0048 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Wed, 12 Sep 2012 16:37:13 -0400
Subject: Fixing merge conflicts related to restoring DRTVWR-167 changes

---
 indra/newview/CMakeLists.txt | 2 +-
 indra/newview/llface.cpp     | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 indra/newview/CMakeLists.txt
 mode change 100644 => 100755 indra/newview/llface.cpp

(limited to 'indra')

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
old mode 100644
new mode 100755
index 2ae162a623..1809616042
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1565,7 +1565,7 @@ if (WINDOWS)
     set_target_properties(${VIEWER_BINARY_NAME}
         PROPERTIES
         # *TODO -reenable this once we get server usage sorted out
-        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS "
+        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS ${TCMALLOC_LINK_FLAGS}"
         LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" /INCREMENTAL:NO"
         LINK_FLAGS_RELEASE "/FORCE:MULTIPLE /MAP\"secondlife-bin.MAP\" /OPT:REF"
         )
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
old mode 100644
new mode 100755
index 373b1930f5..02a8d1244f
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1651,7 +1651,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 						if (!do_xform)
 						{
 							LLFastTimer t(FTM_FACE_TEX_QUICK_NO_XFORM);
-							LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, num_vertices*2*sizeof(F32));
+							S32 tc_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF;
+							LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, tc_size);
 						}
 						else
 						{
-- 
cgit v1.2.3


From 9ec263d2f1f51b334949281393ef2446796f1404 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 12 Sep 2012 15:44:36 -0500
Subject: MAINT-1503 Minimal set of changes needed to safely disable tcmalloc

---
 indra/cmake/GooglePerfTools.cmake     |  2 +-
 indra/llcommon/llmemory.h             | 24 ++++++++++++++++--------
 indra/llmath/llvolume.cpp             | 19 ++++++++++---------
 indra/llmath/tests/alignment_test.cpp |  2 +-
 4 files changed, 28 insertions(+), 19 deletions(-)

(limited to 'indra')

diff --git a/indra/cmake/GooglePerfTools.cmake b/indra/cmake/GooglePerfTools.cmake
index 09501e0406..73b3642ae6 100644
--- a/indra/cmake/GooglePerfTools.cmake
+++ b/indra/cmake/GooglePerfTools.cmake
@@ -3,7 +3,7 @@ include(Prebuilt)
 
 # If you want to enable or disable TCMALLOC in viewer builds, this is the place.
 # set ON or OFF as desired.
-set (USE_TCMALLOC ON)
+set (USE_TCMALLOC OFF)
 
 if (STANDALONE)
   include(FindGooglePerfTools)
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 9dd776ff57..f37e8459ff 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -58,27 +58,35 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi
 #endif
 }
 
-inline void* ll_aligned_realloc_16(void* ptr, size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
+inline void ll_aligned_free_16(void *p)
 {
 #if defined(LL_WINDOWS)
-	return _aligned_realloc(ptr, size, 16);
+	_aligned_free(p);
 #elif defined(LL_DARWIN)
-	return realloc(ptr,size); // default osx malloc is 16 byte aligned.
+	return free(p);
 #else
-	return realloc(ptr,size); // FIXME not guaranteed to be aligned.
+	free(p); // posix_memalign() is compatible with heap deallocator
 #endif
 }
 
-inline void ll_aligned_free_16(void *p)
+inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // returned hunk MUST be freed with ll_aligned_free_16().
 {
 #if defined(LL_WINDOWS)
-	_aligned_free(p);
+	return _aligned_realloc(ptr, size, 16);
 #elif defined(LL_DARWIN)
-	return free(p);
+	return realloc(ptr,size); // default osx malloc is 16 byte aligned.
 #else
-	free(p); // posix_memalign() is compatible with heap deallocator
+	//FIXME: memcpy is SLOW
+	void* ret = ll_aligned_malloc_16(size);
+	if (ptr)
+	{
+		memcpy(ret, ptr, old_size);
+		ll_aligned_free_16(ptr);
+	}
+	return ret;
 #endif
 }
+
 #else // USE_TCMALLOC
 // ll_aligned_foo_16 are not needed with tcmalloc
 #define ll_aligned_malloc_16 malloc
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 11fa7080ce..ea09a3afe7 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -6979,19 +6979,20 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 {
 	S32 new_verts = mNumVertices+1;
 	S32 new_size = new_verts*16;
-//	S32 old_size = mNumVertices*16;
+	S32 old_size = mNumVertices*16;
 
 	//positions
-	mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_size);
+	mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_size, old_size);
 	ll_assert_aligned(mPositions,16);
 	
 	//normals
-	mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_size);
+	mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_size, old_size);
 	ll_assert_aligned(mNormals,16);
 
 	//tex coords
 	new_size = ((new_verts*8)+0xF) & ~0xF;
-	mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, new_size);
+	old_size = ((mNumVertices*8)+0xF) & ~0xF;
+	mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, new_size, old_size);
 	ll_assert_aligned(mTexCoords,16);
 	
 
@@ -7045,7 +7046,7 @@ void LLVolumeFace::pushIndex(const U16& idx)
 	S32 old_size = ((mNumIndices*2)+0xF) & ~0xF;
 	if (new_size != old_size)
 	{
-		mIndices = (U16*) ll_aligned_realloc_16(mIndices, new_size);
+		mIndices = (U16*) ll_aligned_realloc_16(mIndices, new_size, old_size);
 		ll_assert_aligned(mIndices,16);
 	}
 	
@@ -7087,11 +7088,11 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	}
 
 	//allocate new buffer space
-	mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_count*sizeof(LLVector4a));
+	mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_count*sizeof(LLVector4a), mNumVertices*sizeof(LLVector4a));
 	ll_assert_aligned(mPositions, 16);
-	mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_count*sizeof(LLVector4a));
+	mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_count*sizeof(LLVector4a), mNumVertices*sizeof(LLVector4a));
 	ll_assert_aligned(mNormals, 16);
-	mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, (new_count*sizeof(LLVector2)+0xF) & ~0xF);
+	mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, (new_count*sizeof(LLVector2)+0xF) & ~0xF, (mNumVertices*sizeof(LLVector2)+0xF) & ~0xF);
 	ll_assert_aligned(mTexCoords, 16);
 	
 	mNumVertices = new_count;
@@ -7138,7 +7139,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	new_count = mNumIndices + face.mNumIndices;
 
 	//allocate new index buffer
-	mIndices = (U16*) ll_aligned_realloc_16(mIndices, (new_count*sizeof(U16)+0xF) & ~0xF);
+	mIndices = (U16*) ll_aligned_realloc_16(mIndices, (new_count*sizeof(U16)+0xF) & ~0xF, (mNumIndices*sizeof(U16)+0xF) & ~0xF);
 	
 	//get destination address into new index buffer
 	U16* dst_idx = mIndices+mNumIndices;
diff --git a/indra/llmath/tests/alignment_test.cpp b/indra/llmath/tests/alignment_test.cpp
index ac0c45ae6f..5c426c57c3 100644
--- a/indra/llmath/tests/alignment_test.cpp
+++ b/indra/llmath/tests/alignment_test.cpp
@@ -78,7 +78,7 @@ void alignment_test_object_t::test<1>()
 		align_ptr = ll_aligned_malloc_16(sizeof(MyVector4a));
 		ensure("ll_aligned_malloc_16 failed", is_aligned(align_ptr,16));
 
-		align_ptr = ll_aligned_realloc_16(align_ptr,2*sizeof(MyVector4a));
+		align_ptr = ll_aligned_realloc_16(align_ptr,2*sizeof(MyVector4a), sizeof(MyVector4a));
 		ensure("ll_aligned_realloc_16 failed", is_aligned(align_ptr,16));
 
 		ll_aligned_free_16(align_ptr);
-- 
cgit v1.2.3


From 225a3984cb95dee598d6cd175f0de199fbd71740 Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Thu, 13 Sep 2012 12:22:09 -0700
Subject: MAINT-1561: BUGFIX Another target omega fix for an issue detected
 with a clock pendulum.

---
 indra/newview/llviewerobject.cpp | 14 +++++++++++---
 indra/newview/llviewerobject.h   |  1 +
 2 files changed, 12 insertions(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 0a6c51b378..97783d843e 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -236,6 +236,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mTimeDilation(1.f),
 	mRotTime(0.f),
 	mAngularVelocityRot(),
+	mPreviousRotation(),
 	mJointInfo(NULL),
 	mState(0),
 	mMedia(NULL),
@@ -2072,10 +2073,14 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		}
 	}
 
-	if (new_rot != getRotation()
-		|| new_angv != old_angv)
+	if ((new_rot != getRotation())
+		|| (new_angv != old_angv))
 	{
-		if (new_angv != old_angv)
+		if (new_rot != mPreviousRotation)
+		{
+			resetRot();
+		}
+		else if (new_angv != old_angv)
 		{
 			if (flagUsePhysics() || new_angv.isExactlyZero())
 			{
@@ -2087,6 +2092,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 			}
 		}
 
+		// Remember the last rotation value
+		mPreviousRotation = new_rot;
+
 		// Set the rotation of the object followed by adjusting for the accumulated angular velocity (llSetTargetOmega)
 		setRotation(new_rot * mAngularVelocityRot);
 		setChanged(ROTATED | SILHOUETTE);
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 83e34dc6ca..fbf6361ffb 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -734,6 +734,7 @@ protected:
 	F32				mTimeDilation;				// Time dilation sent with the object.
 	F32				mRotTime;					// Amount (in seconds) that object has rotated according to angular velocity (llSetTargetOmega)
 	LLQuaternion	mAngularVelocityRot;		// accumulated rotation from the angular velocity computations
+	LLQuaternion	mPreviousRotation;
 
 	LLVOJointInfo*  mJointInfo;
 	U8				mState;	// legacy
-- 
cgit v1.2.3


From 8f7bb8f6d58dfa1d0b160948b2ca790cd6d4ae5c Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 13 Sep 2012 20:31:22 -0500
Subject: Port over Simon's fix for alignment test

---
 indra/llmath/tests/alignment_test.cpp | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

(limited to 'indra')

diff --git a/indra/llmath/tests/alignment_test.cpp b/indra/llmath/tests/alignment_test.cpp
index 5c426c57c3..9105b1c1fd 100644
--- a/indra/llmath/tests/alignment_test.cpp
+++ b/indra/llmath/tests/alignment_test.cpp
@@ -34,16 +34,6 @@
 #include "../llsimdmath.h"
 #include "../llvector4a.h"
 
-void* operator new(size_t size)
-{
-	return ll_aligned_malloc_16(size);
-}
-
-void operator delete(void *p)
-{
-	ll_aligned_free_16(p);
-}
-
 namespace tut
 {
 
@@ -59,6 +49,27 @@ tut::alignment_test_t tut_alignment_test("LLAlignment");
 LL_ALIGN_PREFIX(16)
 class MyVector4a
 {
+public:
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void *p)
+	{
+		ll_aligned_free_16(p);
+	}
+
+	void* operator new[](size_t count)
+	{	// try to allocate count bytes for an array
+		return ll_aligned_malloc_16(count);
+	}
+
+	void operator delete[](void *p)
+	{
+		ll_aligned_free_16(p);
+	}
+
 	LLQuad mQ;
 } LL_ALIGN_POSTFIX(16);
 
-- 
cgit v1.2.3


From 1ba00693c7c28730b7a953b2805ec6d6f42e1b36 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:48:51 -0400
Subject: reapply 38b7779af5f9: MAINT-646 Faster traversal of render batch
 lists.

---
 indra/newview/lldrawpool.cpp         |   2 +-
 indra/newview/lldrawpoolalpha.cpp    |   4 +-
 indra/newview/lldrawpoolavatar.cpp   |  78 +++++++++++++-------
 indra/newview/lldrawpoolbump.cpp     |  12 ++--
 indra/newview/llspatialpartition.cpp | 134 ++++++++++++++++++++++-------------
 indra/newview/llspatialpartition.h   |  68 +++++++++++-------
 indra/newview/llvoavatar.cpp         |   2 +-
 indra/newview/pipeline.cpp           |  64 ++++++++---------
 indra/newview/pipeline.h             |   8 +--
 9 files changed, 225 insertions(+), 147 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index 81f4e3d48f..859c561a6d 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -443,7 +443,7 @@ void LLRenderPass::renderTexture(U32 type, U32 mask)
 
 void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures)
 {
-	for (LLCullResult::drawinfo_list_t::iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i)	
+	for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i)	
 	{
 		LLDrawInfo* pparams = *i;
 		if (pparams) 
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 5f2a982ed3..313b310e1e 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -348,7 +348,7 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask)
 {
-	for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
+	for (LLCullResult::sg_iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		if (group->mSpatialPartition->mRenderByGroup &&
@@ -385,7 +385,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 	
 	BOOL use_shaders = gPipeline.canUseVertexShaders();
 		
-	for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
+	for (LLCullResult::sg_iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		llassert(group);
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index ace3a20bbb..730ad1a364 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1036,9 +1036,13 @@ void LLDrawPoolAvatar::endDeferredSkinned()
 	gGL.getTexUnit(0)->activate();
 }
 
+static LLFastTimer::DeclareTimer FTM_RENDER_AVATARS("renderAvatars");
+
 
 void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 {
+	LLFastTimer t(FTM_RENDER_AVATARS);
+
 	if (pass == -1)
 	{
 		for (S32 i = 1; i < getNumPasses(); i++)
@@ -1195,15 +1199,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 
 	if (pass >= 7 && pass < 9)
 	{
-		LLGLEnable blend(GL_BLEND);
-
-		gGL.setColorMask(true, true);
-		gGL.blendFunc(LLRender::BF_SOURCE_ALPHA,
-					  LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
-					  LLRender::BF_ZERO,
-					  LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
-
-		
 		if (pass == 7)
 		{
 			renderRiggedAlpha(avatarp);
@@ -1219,20 +1214,8 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 
 	if (pass == 9)
 	{
-		LLGLEnable blend(GL_BLEND);
-		LLGLDisable test(GL_ALPHA_TEST);
-		gGL.flush();
-
-		LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
-		glPolygonOffset(-1.0f, -1.0f);
-		gGL.setSceneBlendType(LLRender::BT_ADD);
-
-		LLGLDepthTest depth(GL_TRUE, GL_FALSE);
-		gGL.setColorMask(false, true);
-
 		renderRiggedGlow(avatarp);
-		gGL.setColorMask(true, false);
-		gGL.setSceneBlendType(LLRender::BT_ALPHA);
+		
 		return;
 	}
 	
@@ -1430,7 +1413,7 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace*
 
 void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 {
-	if (avatar->isSelf() && !gAgent.needsRenderAvatar() || !gMeshRepo.meshRezEnabled())
+	if (avatar->isSelf() && !gAgent.needsRenderAvatar())
 	{
 		return;
 	}
@@ -1559,8 +1542,12 @@ void LLDrawPoolAvatar::renderDeferredRiggedBump(LLVOAvatar* avatar)
 	renderRigged(avatar, RIGGED_DEFERRED_BUMP);
 }
 
+static LLFastTimer::DeclareTimer FTM_RIGGED_VBO("Rigged VBO");
+
 void LLDrawPoolAvatar::updateRiggedVertexBuffers(LLVOAvatar* avatar)
 {
+	LLFastTimer t(FTM_RIGGED_VBO);
+
 	//update rigged vertex buffers
 	for (U32 type = 0; type < NUM_RIGGED_PASSES; ++type)
 	{
@@ -1632,17 +1619,56 @@ void LLDrawPoolAvatar::renderRiggedFullbrightShiny(LLVOAvatar* avatar)
 
 void LLDrawPoolAvatar::renderRiggedAlpha(LLVOAvatar* avatar)
 {
-	renderRigged(avatar, RIGGED_ALPHA);
+	if (!mRiggedFace[RIGGED_ALPHA].empty())
+	{
+		LLGLEnable blend(GL_BLEND);
+
+		gGL.setColorMask(true, true);
+		gGL.blendFunc(LLRender::BF_SOURCE_ALPHA,
+						LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
+						LLRender::BF_ZERO,
+						LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
+
+		renderRigged(avatar, RIGGED_ALPHA);
+	}
 }
 
 void LLDrawPoolAvatar::renderRiggedFullbrightAlpha(LLVOAvatar* avatar)
 {
-	renderRigged(avatar, RIGGED_FULLBRIGHT_ALPHA);
+	if (!mRiggedFace[RIGGED_FULLBRIGHT_ALPHA].empty())
+	{
+		LLGLEnable blend(GL_BLEND);
+
+		gGL.setColorMask(true, true);
+		gGL.blendFunc(LLRender::BF_SOURCE_ALPHA,
+						LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
+						LLRender::BF_ZERO,
+						LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
+
+		renderRigged(avatar, RIGGED_FULLBRIGHT_ALPHA);
+	}
 }
 
 void LLDrawPoolAvatar::renderRiggedGlow(LLVOAvatar* avatar)
 {
-	renderRigged(avatar, RIGGED_GLOW, true);
+	if (!mRiggedFace[RIGGED_GLOW].empty())
+	{
+		LLGLEnable blend(GL_BLEND);
+		LLGLDisable test(GL_ALPHA_TEST);
+		gGL.flush();
+
+		LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
+		glPolygonOffset(-1.0f, -1.0f);
+		gGL.setSceneBlendType(LLRender::BT_ADD);
+
+		LLGLDepthTest depth(GL_TRUE, GL_FALSE);
+		gGL.setColorMask(false, true);
+
+		renderRigged(avatar, RIGGED_GLOW, true);
+
+		gGL.setColorMask(true, false);
+		gGL.setSceneBlendType(LLRender::BT_ALPHA);
+	}
 }
 
 
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 6f71e6ebc8..a264eae302 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -847,12 +847,12 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
 	LLFastTimer ftm(FTM_RENDER_BUMP);
 
 	U32 type = LLRenderPass::PASS_BUMP;
-	LLCullResult::drawinfo_list_t::iterator begin = gPipeline.beginRenderMap(type);
-	LLCullResult::drawinfo_list_t::iterator end = gPipeline.endRenderMap(type);
+	LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type);
+	LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type);
 
 	U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_BINORMAL | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_COLOR;
 	
-	for (LLCullResult::drawinfo_list_t::iterator i = begin; i != end; ++i)	
+	for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i)	
 	{
 		LLDrawInfo& params = **i;
 
@@ -1448,10 +1448,10 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 
 void LLDrawPoolBump::renderBump(U32 type, U32 mask)
 {	
-	LLCullResult::drawinfo_list_t::iterator begin = gPipeline.beginRenderMap(type);
-	LLCullResult::drawinfo_list_t::iterator end = gPipeline.endRenderMap(type);
+	LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type);
+	LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type);
 
-	for (LLCullResult::drawinfo_list_t::iterator i = begin; i != end; ++i)	
+	for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i)	
 	{
 		LLDrawInfo& params = **i;
 
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 45ef8f1a6d..ceeed8156c 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -4180,7 +4180,7 @@ public:
 						{
 							if (index < 255)
 							{
-								if (facep->mDrawInfo->mTextureList.size() <= index)
+								if (facep->mDrawInfo->mTextureList.size()<= index)
 								{
 									llerrs << "Face texture index out of bounds." << llendl;
 								}
@@ -4693,28 +4693,62 @@ LLVertexBuffer* LLGeometryManager::createVertexBuffer(U32 type_mask, U32 usage)
 
 LLCullResult::LLCullResult() 
 {
+	mVisibleGroupsAllocated = 0;
+	mAlphaGroupsAllocated = 0;
+	mOcclusionGroupsAllocated = 0;
+	mDrawableGroupsAllocated = 0;
+	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;
+
+	for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
+	{
+		mRenderMap[i] = NULL;
+		mRenderMapEnd[i] = NULL;
+		mRenderMapAllocated[i] = NULL;
+	}
+
 	clear();
 }
 
+void LLCullResult::pushBack(void**& head, U32& count, void* val)
+{
+	count++;
+	head = (void**) realloc((void*) head, sizeof(void*) * count);
+	head[count-1] = val;
+}
+
 void LLCullResult::clear()
 {
 	mVisibleGroupsSize = 0;
-	mVisibleGroupsEnd = mVisibleGroups.begin();
+	mVisibleGroupsEnd = mVisibleGroups;
 
 	mAlphaGroupsSize = 0;
-	mAlphaGroupsEnd = mAlphaGroups.begin();
+	mAlphaGroupsEnd = mAlphaGroups;
 
 	mOcclusionGroupsSize = 0;
-	mOcclusionGroupsEnd = mOcclusionGroups.begin();
+	mOcclusionGroupsEnd = mOcclusionGroups;
 
 	mDrawableGroupsSize = 0;
-	mDrawableGroupsEnd = mDrawableGroups.begin();
+	mDrawableGroupsEnd = mDrawableGroups;
 
 	mVisibleListSize = 0;
-	mVisibleListEnd = mVisibleList.begin();
+	mVisibleListEnd = mVisibleList;
 
 	mVisibleBridgeSize = 0;
-	mVisibleBridgeEnd = mVisibleBridge.begin();
+	mVisibleBridgeEnd = mVisibleBridge;
 
 
 	for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
@@ -4724,176 +4758,176 @@ void LLCullResult::clear()
 			mRenderMap[i][j] = 0;
 		}
 		mRenderMapSize[i] = 0;
-		mRenderMapEnd[i] = mRenderMap[i].begin();
+		mRenderMapEnd[i] = mRenderMap[i];
 	}
 }
 
-LLCullResult::sg_list_t::iterator LLCullResult::beginVisibleGroups()
+LLCullResult::sg_iterator LLCullResult::beginVisibleGroups()
 {
-	return mVisibleGroups.begin();
+	return mVisibleGroups;
 }
 
-LLCullResult::sg_list_t::iterator LLCullResult::endVisibleGroups()
+LLCullResult::sg_iterator LLCullResult::endVisibleGroups()
 {
 	return mVisibleGroupsEnd;
 }
 
-LLCullResult::sg_list_t::iterator LLCullResult::beginAlphaGroups()
+LLCullResult::sg_iterator LLCullResult::beginAlphaGroups()
 {
-	return mAlphaGroups.begin();
+	return mAlphaGroups;
 }
 
-LLCullResult::sg_list_t::iterator LLCullResult::endAlphaGroups()
+LLCullResult::sg_iterator LLCullResult::endAlphaGroups()
 {
 	return mAlphaGroupsEnd;
 }
 
-LLCullResult::sg_list_t::iterator LLCullResult::beginOcclusionGroups()
+LLCullResult::sg_iterator LLCullResult::beginOcclusionGroups()
 {
-	return mOcclusionGroups.begin();
+	return mOcclusionGroups;
 }
 
-LLCullResult::sg_list_t::iterator LLCullResult::endOcclusionGroups()
+LLCullResult::sg_iterator LLCullResult::endOcclusionGroups()
 {
 	return mOcclusionGroupsEnd;
 }
 
-LLCullResult::sg_list_t::iterator LLCullResult::beginDrawableGroups()
+LLCullResult::sg_iterator LLCullResult::beginDrawableGroups()
 {
-	return mDrawableGroups.begin();
+	return mDrawableGroups;
 }
 
-LLCullResult::sg_list_t::iterator LLCullResult::endDrawableGroups()
+LLCullResult::sg_iterator LLCullResult::endDrawableGroups()
 {
 	return mDrawableGroupsEnd;
 }
 
-LLCullResult::drawable_list_t::iterator LLCullResult::beginVisibleList()
+LLCullResult::drawable_iterator LLCullResult::beginVisibleList()
 {
-	return mVisibleList.begin();
+	return mVisibleList;
 }
 
-LLCullResult::drawable_list_t::iterator LLCullResult::endVisibleList()
+LLCullResult::drawable_iterator LLCullResult::endVisibleList()
 {
 	return mVisibleListEnd;
 }
 
-LLCullResult::bridge_list_t::iterator LLCullResult::beginVisibleBridge()
+LLCullResult::bridge_iterator LLCullResult::beginVisibleBridge()
 {
-	return mVisibleBridge.begin();
+	return mVisibleBridge;
 }
 
-LLCullResult::bridge_list_t::iterator LLCullResult::endVisibleBridge()
+LLCullResult::bridge_iterator LLCullResult::endVisibleBridge()
 {
 	return mVisibleBridgeEnd;
 }
 
-LLCullResult::drawinfo_list_t::iterator LLCullResult::beginRenderMap(U32 type)
+LLCullResult::drawinfo_iterator LLCullResult::beginRenderMap(U32 type)
 {
-	return mRenderMap[type].begin();
+	return mRenderMap[type];
 }
 
-LLCullResult::drawinfo_list_t::iterator LLCullResult::endRenderMap(U32 type)
+LLCullResult::drawinfo_iterator LLCullResult::endRenderMap(U32 type)
 {
 	return mRenderMapEnd[type];
 }
 
 void LLCullResult::pushVisibleGroup(LLSpatialGroup* group)
 {
-	if (mVisibleGroupsSize < mVisibleGroups.size())
+	if (mVisibleGroupsSize < mVisibleGroupsAllocated)
 	{
 		mVisibleGroups[mVisibleGroupsSize] = group;
 	}
 	else
 	{
-		mVisibleGroups.push_back(group);
+		pushBack((void**&) mVisibleGroups, mVisibleGroupsAllocated, (void*) group);
 	}
 	++mVisibleGroupsSize;
-	mVisibleGroupsEnd = mVisibleGroups.begin()+mVisibleGroupsSize;
+	mVisibleGroupsEnd = mVisibleGroups+mVisibleGroupsSize;
 }
 
 void LLCullResult::pushAlphaGroup(LLSpatialGroup* group)
 {
-	if (mAlphaGroupsSize < mAlphaGroups.size())
+	if (mAlphaGroupsSize < mAlphaGroupsAllocated)
 	{
 		mAlphaGroups[mAlphaGroupsSize] = group;
 	}
 	else
 	{
-		mAlphaGroups.push_back(group);
+		pushBack((void**&) mAlphaGroups, mAlphaGroupsAllocated, (void*) group);
 	}
 	++mAlphaGroupsSize;
-	mAlphaGroupsEnd = mAlphaGroups.begin()+mAlphaGroupsSize;
+	mAlphaGroupsEnd = mAlphaGroups+mAlphaGroupsSize;
 }
 
 void LLCullResult::pushOcclusionGroup(LLSpatialGroup* group)
 {
-	if (mOcclusionGroupsSize < mOcclusionGroups.size())
+	if (mOcclusionGroupsSize < mOcclusionGroupsAllocated)
 	{
 		mOcclusionGroups[mOcclusionGroupsSize] = group;
 	}
 	else
 	{
-		mOcclusionGroups.push_back(group);
+		pushBack((void**&) mOcclusionGroups, mOcclusionGroupsAllocated, (void*) group);
 	}
 	++mOcclusionGroupsSize;
-	mOcclusionGroupsEnd = mOcclusionGroups.begin()+mOcclusionGroupsSize;
+	mOcclusionGroupsEnd = mOcclusionGroups+mOcclusionGroupsSize;
 }
 
 void LLCullResult::pushDrawableGroup(LLSpatialGroup* group)
 {
-	if (mDrawableGroupsSize < mDrawableGroups.size())
+	if (mDrawableGroupsSize < mDrawableGroupsAllocated)
 	{
 		mDrawableGroups[mDrawableGroupsSize] = group;
 	}
 	else
 	{
-		mDrawableGroups.push_back(group);
+		pushBack((void**&) mDrawableGroups, mDrawableGroupsAllocated, (void*) group);
 	}
 	++mDrawableGroupsSize;
-	mDrawableGroupsEnd = mDrawableGroups.begin()+mDrawableGroupsSize;
+	mDrawableGroupsEnd = mDrawableGroups+mDrawableGroupsSize;
 }
 
 void LLCullResult::pushDrawable(LLDrawable* drawable)
 {
-	if (mVisibleListSize < mVisibleList.size())
+	if (mVisibleListSize < mVisibleListAllocated)
 	{
 		mVisibleList[mVisibleListSize] = drawable;
 	}
 	else
 	{
-		mVisibleList.push_back(drawable);
+		pushBack((void**&) mVisibleList, mVisibleListAllocated, (void*) drawable);
 	}
 	++mVisibleListSize;
-	mVisibleListEnd = mVisibleList.begin()+mVisibleListSize;
+	mVisibleListEnd = mVisibleList+mVisibleListSize;
 }
 
 void LLCullResult::pushBridge(LLSpatialBridge* bridge)
 {
-	if (mVisibleBridgeSize < mVisibleBridge.size())
+	if (mVisibleBridgeSize < mVisibleBridgeAllocated)
 	{
 		mVisibleBridge[mVisibleBridgeSize] = bridge;
 	}
 	else
 	{
-		mVisibleBridge.push_back(bridge);
+		pushBack((void**&) mVisibleBridge, mVisibleBridgeAllocated, (void*) bridge);
 	}
 	++mVisibleBridgeSize;
-	mVisibleBridgeEnd = mVisibleBridge.begin()+mVisibleBridgeSize;
+	mVisibleBridgeEnd = mVisibleBridge+mVisibleBridgeSize;
 }
 
 void LLCullResult::pushDrawInfo(U32 type, LLDrawInfo* draw_info)
 {
-	if (mRenderMapSize[type] < mRenderMap[type].size())
+	if (mRenderMapSize[type] < mRenderMapAllocated[type])
 	{
 		mRenderMap[type][mRenderMapSize[type]] = draw_info;
 	}
 	else
 	{
-		mRenderMap[type].push_back(draw_info);
+		pushBack((void**&) mRenderMap[type], mRenderMapAllocated[type], (void*) draw_info);
 	}
 	++mRenderMapSize[type];
-	mRenderMapEnd[type] = mRenderMap[type].begin() + mRenderMapSize[type];
+	mRenderMapEnd[type] = mRenderMap[type] + mRenderMapSize[type];
 }
 
 
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 7968c28900..d935c1f140 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -562,34 +562,39 @@ class LLCullResult
 public:
 	LLCullResult();
 
-	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_list_t;
+	typedef LLDrawable** drawable_list_t;
+	typedef LLSpatialBridge** bridge_list_t;
+	typedef LLDrawInfo** drawinfo_list_t;
+
+	typedef LLSpatialGroup** sg_iterator;
+	typedef LLSpatialBridge** bridge_iterator;
+	typedef LLDrawInfo** drawinfo_iterator;
+	typedef LLDrawable** drawable_iterator;
 
 	void clear();
 	
-	sg_list_t::iterator beginVisibleGroups();
-	sg_list_t::iterator endVisibleGroups();
+	sg_iterator beginVisibleGroups();
+	sg_iterator endVisibleGroups();
 
-	sg_list_t::iterator beginAlphaGroups();
-	sg_list_t::iterator endAlphaGroups();
+	sg_iterator beginAlphaGroups();
+	sg_iterator endAlphaGroups();
 
 	bool hasOcclusionGroups() { return mOcclusionGroupsSize > 0; }
-	sg_list_t::iterator beginOcclusionGroups();
-	sg_list_t::iterator endOcclusionGroups();
+	sg_iterator beginOcclusionGroups();
+	sg_iterator endOcclusionGroups();
 
-	sg_list_t::iterator beginDrawableGroups();
-	sg_list_t::iterator endDrawableGroups();
+	sg_iterator beginDrawableGroups();
+	sg_iterator endDrawableGroups();
 
-	drawable_list_t::iterator beginVisibleList();
-	drawable_list_t::iterator endVisibleList();
+	drawable_iterator beginVisibleList();
+	drawable_iterator endVisibleList();
 
-	bridge_list_t::iterator beginVisibleBridge();
-	bridge_list_t::iterator endVisibleBridge();
+	bridge_iterator beginVisibleBridge();
+	bridge_iterator endVisibleBridge();
 
-	drawinfo_list_t::iterator beginRenderMap(U32 type);
-	drawinfo_list_t::iterator endRenderMap(U32 type);
+	drawinfo_iterator beginRenderMap(U32 type);
+	drawinfo_iterator endRenderMap(U32 type);
 
 	void pushVisibleGroup(LLSpatialGroup* group);
 	void pushAlphaGroup(LLSpatialGroup* group);
@@ -609,28 +614,41 @@ public:
 	void assertDrawMapsEmpty();
 
 private:
+
+	void pushBack(void** &head, U32& count, void* val);
+
 	U32					mVisibleGroupsSize;
 	U32					mAlphaGroupsSize;
 	U32					mOcclusionGroupsSize;
 	U32					mDrawableGroupsSize;
 	U32					mVisibleListSize;
 	U32					mVisibleBridgeSize;
+
+	U32					mVisibleGroupsAllocated;
+	U32					mAlphaGroupsAllocated;
+	U32					mOcclusionGroupsAllocated;
+	U32					mDrawableGroupsAllocated;
+	U32					mVisibleListAllocated;
+	U32					mVisibleBridgeAllocated;
+
 	U32					mRenderMapSize[LLRenderPass::NUM_RENDER_TYPES];
 
 	sg_list_t			mVisibleGroups;
-	sg_list_t::iterator mVisibleGroupsEnd;
+	sg_iterator			mVisibleGroupsEnd;
 	sg_list_t			mAlphaGroups;
-	sg_list_t::iterator mAlphaGroupsEnd;
+	sg_iterator			mAlphaGroupsEnd;
 	sg_list_t			mOcclusionGroups;
-	sg_list_t::iterator	mOcclusionGroupsEnd;
+	sg_iterator			mOcclusionGroupsEnd;
 	sg_list_t			mDrawableGroups;
-	sg_list_t::iterator mDrawableGroupsEnd;
+	sg_iterator			mDrawableGroupsEnd;
 	drawable_list_t		mVisibleList;
-	drawable_list_t::iterator mVisibleListEnd;
+	drawable_iterator	mVisibleListEnd;
 	bridge_list_t		mVisibleBridge;
-	bridge_list_t::iterator mVisibleBridgeEnd;
+	bridge_iterator		mVisibleBridgeEnd;
 	drawinfo_list_t		mRenderMap[LLRenderPass::NUM_RENDER_TYPES];
-	drawinfo_list_t::iterator mRenderMapEnd[LLRenderPass::NUM_RENDER_TYPES];
+	U32					mRenderMapAllocated[LLRenderPass::NUM_RENDER_TYPES];
+	drawinfo_iterator mRenderMapEnd[LLRenderPass::NUM_RENDER_TYPES];
+
 };
 
 
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 1b7009a5c2..493e9cf392 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2390,7 +2390,7 @@ S32 LLVOAvatar::setTETexture(const U8 te, const LLUUID& uuid)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_AVATAR_UPDATE("Update Avatar");
+static LLFastTimer::DeclareTimer FTM_AVATAR_UPDATE("Avatar Update");
 static LLFastTimer::DeclareTimer FTM_JOINT_UPDATE("Update Joints");
 
 //------------------------------------------------------------------------
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index f01626c0fc..ec0e200ae0 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2010,25 +2010,25 @@ void LLPipeline::checkReferences(LLFace* face)
 #if 0
 	if (sCull)
 	{
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, face);
 		}
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, face);
 		}
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, face);
 		}
 
-		for (LLCullResult::drawable_list_t::iterator iter = sCull->beginVisibleList(); iter != sCull->endVisibleList(); ++iter)
+		for (LLCullResult::drawable_iterator iter = sCull->beginVisibleList(); iter != sCull->endVisibleList(); ++iter)
 		{
 			LLDrawable* drawable = *iter;
 			check_references(drawable, face);	
@@ -2042,25 +2042,25 @@ void LLPipeline::checkReferences(LLDrawable* drawable)
 #if 0
 	if (sCull)
 	{
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, drawable);
 		}
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, drawable);
 		}
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, drawable);
 		}
 
-		for (LLCullResult::drawable_list_t::iterator iter = sCull->beginVisibleList(); iter != sCull->endVisibleList(); ++iter)
+		for (LLCullResult::drawable_iterator iter = sCull->beginVisibleList(); iter != sCull->endVisibleList(); ++iter)
 		{
 			if (drawable == *iter)
 			{
@@ -2093,19 +2093,19 @@ void LLPipeline::checkReferences(LLDrawInfo* draw_info)
 #if 0
 	if (sCull)
 	{
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, draw_info);
 		}
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, draw_info);
 		}
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			check_references(group, draw_info);
@@ -2119,7 +2119,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 #if 0
 	if (sCull)
 	{
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 		{
 			if (group == *iter)
 			{
@@ -2127,7 +2127,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 			}
 		}
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
 		{
 			if (group == *iter)
 			{
@@ -2135,7 +2135,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 			}
 		}
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 		{
 			if (group == *iter)
 			{
@@ -2477,7 +2477,7 @@ void LLPipeline::doOcclusion(LLCamera& camera)
 		}
 		mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
 
-		for (LLCullResult::sg_list_t::iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter)
+		for (LLCullResult::sg_iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter)
 		{
 			LLSpatialGroup* group = *iter;
 			group->doOcclusion(&camera);
@@ -2993,7 +2993,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	//LLVertexBuffer::unbind();
 
 	grabReferences(result);
-	for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+	for (LLCullResult::sg_iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
 	{
 		LLSpatialGroup* group = *iter;
 		group->checkOcclusion();
@@ -3019,9 +3019,9 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
 	{
 		LLSpatialGroup* last_group = NULL;
-		for (LLCullResult::bridge_list_t::iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
+		for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
 		{
-			LLCullResult::bridge_list_t::iterator cur_iter = i;
+			LLCullResult::bridge_iterator cur_iter = i;
 			LLSpatialBridge* bridge = *cur_iter;
 			LLSpatialGroup* group = bridge->getSpatialGroup();
 
@@ -3051,7 +3051,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 		}
 	}
 
-	for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+	for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 	{
 		LLSpatialGroup* group = *iter;
 		group->checkOcclusion();
@@ -3073,7 +3073,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	
 	{
 		LLFastTimer ftm(FTM_STATESORT_DRAWABLE);
-		for (LLCullResult::drawable_list_t::iterator iter = sCull->beginVisibleList();
+		for (LLCullResult::drawable_iterator iter = sCull->beginVisibleList();
 			 iter != sCull->endVisibleList(); ++iter)
 		{
 			LLDrawable *drawablep = *iter;
@@ -3209,11 +3209,11 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera)
 }
 
 
-void forAllDrawables(LLCullResult::sg_list_t::iterator begin, 
-					 LLCullResult::sg_list_t::iterator end,
+void forAllDrawables(LLCullResult::sg_iterator begin, 
+					 LLCullResult::sg_iterator end,
 					 void (*func)(LLDrawable*))
 {
-	for (LLCullResult::sg_list_t::iterator i = begin; i != end; ++i)
+	for (LLCullResult::sg_iterator i = begin; i != end; ++i)
 	{
 		for (LLSpatialGroup::element_iter j = (*i)->getData().begin(); j != (*i)->getData().end(); ++j)
 		{
@@ -3417,7 +3417,7 @@ void LLPipeline::postSort(LLCamera& camera)
 
 	llpushcallstacks ;
 	//rebuild drawable geometry
-	for (LLCullResult::sg_list_t::iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i)
+	for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		if (!sUseOcclusion || 
@@ -3435,7 +3435,7 @@ void LLPipeline::postSort(LLCamera& camera)
 
 
 	//build render map
-	for (LLCullResult::sg_list_t::iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
+	for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		if (sUseOcclusion && 
@@ -4457,7 +4457,7 @@ void LLPipeline::renderPhysicsDisplay()
 		}
 	}
 
-	for (LLCullResult::bridge_list_t::const_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
+	for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
 	{
 		LLSpatialBridge* bridge = *i;
 		if (!bridge->isDead() && hasRenderType(bridge->mDrawableType))
@@ -4879,7 +4879,7 @@ void LLPipeline::renderDebug()
 		}
 	}
 
-	for (LLCullResult::bridge_list_t::const_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
+	for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
 	{
 		LLSpatialBridge* bridge = *i;
 		if (!bridge->isDead() && hasRenderType(bridge->mDrawableType))
@@ -9878,7 +9878,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 
 void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture)
 {
-	for (LLCullResult::sg_list_t::iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
+	for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
 		if (!group->isDead() &&
@@ -10142,22 +10142,22 @@ BOOL LLPipeline::hasRenderBatches(const U32 type) const
 	return sCull->getRenderMapSize(type) > 0;
 }
 
-LLCullResult::drawinfo_list_t::iterator LLPipeline::beginRenderMap(U32 type)
+LLCullResult::drawinfo_iterator LLPipeline::beginRenderMap(U32 type)
 {
 	return sCull->beginRenderMap(type);
 }
 
-LLCullResult::drawinfo_list_t::iterator LLPipeline::endRenderMap(U32 type)
+LLCullResult::drawinfo_iterator LLPipeline::endRenderMap(U32 type)
 {
 	return sCull->endRenderMap(type);
 }
 
-LLCullResult::sg_list_t::iterator LLPipeline::beginAlphaGroups()
+LLCullResult::sg_iterator LLPipeline::beginAlphaGroups()
 {
 	return sCull->beginAlphaGroups();
 }
 
-LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
+LLCullResult::sg_iterator LLPipeline::endAlphaGroups()
 {
 	return sCull->endAlphaGroups();
 }
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index ef1fd3279d..368be1c14d 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -294,10 +294,10 @@ public:
 	void setLight(LLDrawable *drawablep, BOOL is_light);
 	
 	BOOL hasRenderBatches(const U32 type) const;
-	LLCullResult::drawinfo_list_t::iterator beginRenderMap(U32 type);
-	LLCullResult::drawinfo_list_t::iterator endRenderMap(U32 type);
-	LLCullResult::sg_list_t::iterator beginAlphaGroups();
-	LLCullResult::sg_list_t::iterator endAlphaGroups();
+	LLCullResult::drawinfo_iterator beginRenderMap(U32 type);
+	LLCullResult::drawinfo_iterator endRenderMap(U32 type);
+	LLCullResult::sg_iterator beginAlphaGroups();
+	LLCullResult::sg_iterator endAlphaGroups();
 	
 
 	void addTrianglesDrawn(S32 index_count, U32 render_type = LLRender::TRIANGLES);
-- 
cgit v1.2.3


From 5c3c556e949d92a74abe1b3a250c25e5c547133c Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:48:52 -0400
Subject: reapply 4f8ca653a394: Fix for linux build.

---
 indra/newview/llspatialpartition.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index ceeed8156c..ccc5dc7bea 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -4717,7 +4717,7 @@ LLCullResult::LLCullResult()
 	{
 		mRenderMap[i] = NULL;
 		mRenderMapEnd[i] = NULL;
-		mRenderMapAllocated[i] = NULL;
+		mRenderMapAllocated[i] = 0;
 	}
 
 	clear();
-- 
cgit v1.2.3


From 9bf49903edd5c67a2decdbe7bc0ca5b089763914 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:48:53 -0400
Subject: reapply 230c111ab816: Add some timers.

---
 indra/llcharacter/llcharacter.cpp          |  6 +++++-
 indra/llcharacter/lleditingmotion.cpp      |  3 +++
 indra/llcharacter/llkeyframewalkmotion.cpp |  4 ++++
 indra/llcharacter/llmotioncontroller.cpp   | 24 ++++++++++++++++++++----
 4 files changed, 32 insertions(+), 5 deletions(-)

(limited to 'indra')

diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index c9fb8534f1..0a6a8f9fa6 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -189,6 +189,7 @@ void LLCharacter::requestStopMotion( LLMotion* motion)
 //-----------------------------------------------------------------------------
 static LLFastTimer::DeclareTimer FTM_UPDATE_ANIMATION("Update Animation");
 static LLFastTimer::DeclareTimer FTM_UPDATE_HIDDEN_ANIMATION("Update Hidden Anim");
+static LLFastTimer::DeclareTimer FTM_UPDATE_MOTIONS("Update Motions");
 
 void LLCharacter::updateMotions(e_update_t update_type)
 {
@@ -206,7 +207,10 @@ void LLCharacter::updateMotions(e_update_t update_type)
 			mMotionController.unpauseAllMotions();
 		}
 		bool force_update = (update_type == FORCE_UPDATE);
-		mMotionController.updateMotions(force_update);
+		{
+			LLFastTimer t(FTM_UPDATE_MOTIONS);
+			mMotionController.updateMotions(force_update);
+		}
 	}
 }
 
diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp
index 66b3c2bd25..830e323476 100644
--- a/indra/llcharacter/lleditingmotion.cpp
+++ b/indra/llcharacter/lleditingmotion.cpp
@@ -158,11 +158,14 @@ BOOL LLEditingMotion::onActivate()
 	return TRUE;
 }
 
+static LLFastTimer::DeclareTimer FTM_EDITING_MOTION("Editing Motion");
+
 //-----------------------------------------------------------------------------
 // LLEditingMotion::onUpdate()
 //-----------------------------------------------------------------------------
 BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask)
 {
+	LLFastTimer t(FTM_EDITING_MOTION);
 	LLVector3 focus_pt;
 	LLVector3* pointAtPt = (LLVector3*)mCharacter->getAnimationData("PointAtPoint");
 
diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp
index d52eb89a5c..ea63f9f8dc 100644
--- a/indra/llcharacter/llkeyframewalkmotion.cpp
+++ b/indra/llcharacter/llkeyframewalkmotion.cpp
@@ -196,11 +196,15 @@ BOOL LLWalkAdjustMotion::onActivate()
 	return TRUE;
 }
 
+static LLFastTimer::DeclareTimer FTM_WALK_ADJUST_MOTION("Walk Adjust");
+
 //-----------------------------------------------------------------------------
 // LLWalkAdjustMotion::onUpdate()
 //-----------------------------------------------------------------------------
 BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask)
 {
+	LLFastTimer t(FTM_WALK_ADJUST_MOTION);
+
 	// delta_time is guaranteed to be non zero
 	F32 delta_time = llclamp(time - mLastTime, TIME_EPSILON, MAX_TIME_DELTA);
 	mLastTime = time;
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index bb892f4a7f..e7ec83efc0 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -539,11 +539,14 @@ void LLMotionController::updateIdleActiveMotions()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_UPDATE_MOTIONS_BY_TYPE("Update Motions By Type");
+
 //-----------------------------------------------------------------------------
 // updateMotionsByType()
 //-----------------------------------------------------------------------------
 void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_type)
 {
+	LLFastTimer t(FTM_UPDATE_MOTIONS_BY_TYPE);
 	BOOL update_result = TRUE;
 	U8 last_joint_signature[LL_CHARACTER_MAX_JOINTS];
 
@@ -795,6 +798,9 @@ void LLMotionController::updateLoadingMotions()
 // call updateMotion() or updateMotionsMinimal() every frame
 //-----------------------------------------------------------------------------
 
+static LLFastTimer::DeclareTimer FTM_UPDATE_MOTION_PURGE_EXCESS("Purge Excess Motions");
+static LLFastTimer::DeclareTimer FTM_UPDATE_LOADING_MOTIONS("Update Loading Motions");
+
 //-----------------------------------------------------------------------------
 // updateMotion()
 //-----------------------------------------------------------------------------
@@ -808,8 +814,11 @@ void LLMotionController::updateMotions(bool force_update)
 	mPrevTimerElapsed = cur_time;
 	mLastTime = mAnimTime;
 
-	// Always cap the number of loaded motions
-	purgeExcessMotions();
+	{
+		LLFastTimer t(FTM_UPDATE_MOTION_PURGE_EXCESS);
+		// Always cap the number of loaded motions
+		purgeExcessMotions();
+	}
 	
 	// Update timing info for this time step.
 	if (!mPaused)
@@ -831,7 +840,11 @@ void LLMotionController::updateMotions(bool force_update)
 					mLastInterp = interp;
 				}
 
-				updateLoadingMotions();
+				{
+					LLFastTimer t(FTM_UPDATE_LOADING_MOTIONS);
+					updateLoadingMotions();
+				}
+
 				return;
 			}
 			
@@ -849,7 +862,10 @@ void LLMotionController::updateMotions(bool force_update)
 		}
 	}
 
-	updateLoadingMotions();
+	{
+		LLFastTimer t(FTM_UPDATE_LOADING_MOTIONS);
+		updateLoadingMotions();
+	}
 
 	resetJointSignatures();
 
-- 
cgit v1.2.3


From f80d16808d21eaa9a3e8550284d25a43e2669ae2 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:48:54 -0400
Subject: reapply 15b05dc53770: MAINT-646 Profile based optimization -- add a
 lookup map for joints to remove hotspot in LLJoint::findJoint

---
 indra/newview/llvoavatar.cpp | 17 ++++++++++++++++-
 indra/newview/llvoavatar.h   |  4 ++++
 2 files changed, 20 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 493e9cf392..dee19032f1 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -817,6 +817,7 @@ LLVOAvatar::~LLVOAvatar()
 	lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl;
 
 	mRoot.removeAllChildren();
+	mJointMap.clear();
 
 	deleteAndClearArray(mSkeleton);
 	deleteAndClearArray(mCollisionVolumes);
@@ -1934,6 +1935,7 @@ void LLVOAvatar::buildCharacter()
 	// remove all of mRoot's children
 	//-------------------------------------------------------------------------
 	mRoot.removeAllChildren();
+	mJointMap.clear();
 	mIsBuilt = FALSE;
 
 	//-------------------------------------------------------------------------
@@ -5137,7 +5139,20 @@ const LLUUID& LLVOAvatar::getID() const
 // RN: avatar joints are multi-rooted to include screen-based attachments
 LLJoint *LLVOAvatar::getJoint( const std::string &name )
 {
-	LLJoint* jointp = mRoot.findJoint(name);
+	joint_map_t::iterator iter = mJointMap.find(name);
+
+	LLJoint* jointp = NULL;
+
+	if (iter == mJointMap.end())
+	{ //search for joint and cache found joint in lookup table
+		LLJoint* jointp = mRoot.findJoint(name);
+		mJointMap[name] = jointp;
+	}
+	else
+	{ //return cached pointer
+		jointp = iter->second;
+	}
+
 	return jointp;
 }
 
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 4081a1408d..f5692bb52f 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -366,6 +366,10 @@ public:
 
 	LLVector3			mHeadOffset; // current head position
 	LLViewerJoint		mRoot;
+
+	typedef std::map<std::string, LLJoint*> joint_map_t;
+	joint_map_t			mJointMap;
+
 protected:
 	static BOOL			parseSkeletonFile(const std::string& filename);
 	void				buildCharacter();
-- 
cgit v1.2.3


From cf98064700a736f73a6c21ce899b186919cbeb64 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:48:55 -0400
Subject: reapply 52b6c9168974: MAINT-646 Factor std::set out of lloctree

---
 indra/llcharacter/llcharacter.cpp          |   7 --
 indra/llcharacter/lleditingmotion.cpp      |   3 -
 indra/llcharacter/llkeyframewalkmotion.cpp |   4 -
 indra/llcharacter/llmotioncontroller.cpp   |  29 ++-----
 indra/llmath/lloctree.h                    | 125 ++++++++++++++++++++++-------
 indra/llmath/llvolume.cpp                  |   6 +-
 indra/llmath/llvolumeoctree.cpp            |   6 +-
 indra/llmath/llvolumeoctree.h              |   9 ++-
 indra/newview/lldrawable.cpp               |   4 +
 indra/newview/lldrawable.h                 |   4 +
 indra/newview/llface.cpp                   |  13 +--
 indra/newview/llspatialpartition.cpp       |  42 +++++-----
 indra/newview/llspatialpartition.h         |   5 ++
 indra/newview/llvograss.cpp                |   2 +-
 indra/newview/llvopartgroup.cpp            |   2 +-
 indra/newview/llvovolume.cpp               |  10 +--
 indra/newview/pipeline.cpp                 |  14 ++--
 17 files changed, 168 insertions(+), 117 deletions(-)

(limited to 'indra')

diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index 0a6a8f9fa6..07f0baae51 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -187,20 +187,14 @@ void LLCharacter::requestStopMotion( LLMotion* motion)
 //-----------------------------------------------------------------------------
 // updateMotions()
 //-----------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_UPDATE_ANIMATION("Update Animation");
-static LLFastTimer::DeclareTimer FTM_UPDATE_HIDDEN_ANIMATION("Update Hidden Anim");
-static LLFastTimer::DeclareTimer FTM_UPDATE_MOTIONS("Update Motions");
-
 void LLCharacter::updateMotions(e_update_t update_type)
 {
 	if (update_type == HIDDEN_UPDATE)
 	{
-		LLFastTimer t(FTM_UPDATE_HIDDEN_ANIMATION);
 		mMotionController.updateMotionsMinimal();
 	}
 	else
 	{
-		LLFastTimer t(FTM_UPDATE_ANIMATION);
 		// unpause if the number of outstanding pause requests has dropped to the initial one
 		if (mMotionController.isPaused() && mPauseRequest->getNumRefs() == 1)
 		{
@@ -208,7 +202,6 @@ void LLCharacter::updateMotions(e_update_t update_type)
 		}
 		bool force_update = (update_type == FORCE_UPDATE);
 		{
-			LLFastTimer t(FTM_UPDATE_MOTIONS);
 			mMotionController.updateMotions(force_update);
 		}
 	}
diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp
index 830e323476..66b3c2bd25 100644
--- a/indra/llcharacter/lleditingmotion.cpp
+++ b/indra/llcharacter/lleditingmotion.cpp
@@ -158,14 +158,11 @@ BOOL LLEditingMotion::onActivate()
 	return TRUE;
 }
 
-static LLFastTimer::DeclareTimer FTM_EDITING_MOTION("Editing Motion");
-
 //-----------------------------------------------------------------------------
 // LLEditingMotion::onUpdate()
 //-----------------------------------------------------------------------------
 BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask)
 {
-	LLFastTimer t(FTM_EDITING_MOTION);
 	LLVector3 focus_pt;
 	LLVector3* pointAtPt = (LLVector3*)mCharacter->getAnimationData("PointAtPoint");
 
diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp
index ea63f9f8dc..d52eb89a5c 100644
--- a/indra/llcharacter/llkeyframewalkmotion.cpp
+++ b/indra/llcharacter/llkeyframewalkmotion.cpp
@@ -196,15 +196,11 @@ BOOL LLWalkAdjustMotion::onActivate()
 	return TRUE;
 }
 
-static LLFastTimer::DeclareTimer FTM_WALK_ADJUST_MOTION("Walk Adjust");
-
 //-----------------------------------------------------------------------------
 // LLWalkAdjustMotion::onUpdate()
 //-----------------------------------------------------------------------------
 BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask)
 {
-	LLFastTimer t(FTM_WALK_ADJUST_MOTION);
-
 	// delta_time is guaranteed to be non zero
 	F32 delta_time = llclamp(time - mLastTime, TIME_EPSILON, MAX_TIME_DELTA);
 	mLastTime = time;
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index e7ec83efc0..236b8c616d 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -539,14 +539,11 @@ void LLMotionController::updateIdleActiveMotions()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_MOTIONS_BY_TYPE("Update Motions By Type");
-
 //-----------------------------------------------------------------------------
 // updateMotionsByType()
 //-----------------------------------------------------------------------------
 void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_type)
 {
-	LLFastTimer t(FTM_UPDATE_MOTIONS_BY_TYPE);
 	BOOL update_result = TRUE;
 	U8 last_joint_signature[LL_CHARACTER_MAX_JOINTS];
 
@@ -798,9 +795,6 @@ void LLMotionController::updateLoadingMotions()
 // call updateMotion() or updateMotionsMinimal() every frame
 //-----------------------------------------------------------------------------
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_MOTION_PURGE_EXCESS("Purge Excess Motions");
-static LLFastTimer::DeclareTimer FTM_UPDATE_LOADING_MOTIONS("Update Loading Motions");
-
 //-----------------------------------------------------------------------------
 // updateMotion()
 //-----------------------------------------------------------------------------
@@ -814,12 +808,9 @@ void LLMotionController::updateMotions(bool force_update)
 	mPrevTimerElapsed = cur_time;
 	mLastTime = mAnimTime;
 
-	{
-		LLFastTimer t(FTM_UPDATE_MOTION_PURGE_EXCESS);
-		// Always cap the number of loaded motions
-		purgeExcessMotions();
-	}
-	
+	// Always cap the number of loaded motions
+	purgeExcessMotions();
+		
 	// Update timing info for this time step.
 	if (!mPaused)
 	{
@@ -840,11 +831,8 @@ void LLMotionController::updateMotions(bool force_update)
 					mLastInterp = interp;
 				}
 
-				{
-					LLFastTimer t(FTM_UPDATE_LOADING_MOTIONS);
-					updateLoadingMotions();
-				}
-
+				updateLoadingMotions();
+				
 				return;
 			}
 			
@@ -862,11 +850,8 @@ void LLMotionController::updateMotions(bool force_update)
 		}
 	}
 
-	{
-		LLFastTimer t(FTM_UPDATE_LOADING_MOTIONS);
-		updateLoadingMotions();
-	}
-
+	updateLoadingMotions();
+	
 	resetJointSignatures();
 
 	if (mPaused && !force_update)
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 6c7744cdf1..a7e176fd51 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -79,9 +79,9 @@ public:
 
 	typedef LLOctreeTraveler<T>									oct_traveler;
 	typedef LLTreeTraveler<T>									tree_traveler;
-	typedef typename std::set<LLPointer<T> >					element_list;
-	typedef typename element_list::iterator						element_iter;
-	typedef typename element_list::const_iterator	const_element_iter;
+	typedef 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;
 	typedef typename std::vector<LLOctreeNode<T>* >				child_list;
 	typedef LLTreeNode<T>		BaseType;
@@ -105,6 +105,9 @@ public:
 	:	mParent((oct_node*)parent), 
 		mOctant(octant) 
 	{ 
+		mData = NULL;
+		mDataEnd = NULL;
+
 		mCenter = center;
 		mSize = size;
 
@@ -123,6 +126,16 @@ public:
 	{ 
 		BaseType::destroyListeners(); 
 		
+		for (U32 i = 0; i < mElementCount; ++i)
+		{
+			mData[i]->setBinIndex(-1);
+			mData[i] = NULL;
+		}
+
+		free(mData);
+		mData = NULL;
+		mDataEnd = NULL;
+
 		for (U32 i = 0; i < getChildCount(); i++)
 		{
 			delete getChild(i);
@@ -222,9 +235,14 @@ public:
 	virtual bool isLeaf() const						{ return mChild.empty(); }
 	
 	U32 getElementCount() const						{ return mElementCount; }
+	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 getDataEnd()						{ return mDataEnd; }
+	const_element_iter getDataBegin() const			{ return mData; }
+	const_element_iter getDataEnd() const			{ return mDataEnd; }
+		
 	U32 getChildCount()	const						{ return mChildCount; }
 	oct_node* getChild(U32 index)					{ return mChild[index]; }
 	const oct_node* getChild(U32 index) const		{ return mChild[index]; }
@@ -289,7 +307,7 @@ public:
 	
 	virtual bool insert(T* data)
 	{
-		if (data == NULL)
+		if (data == NULL || data->getBinIndex() != -1)
 		{
 			OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << llendl;
 			return false;
@@ -302,13 +320,16 @@ public:
 			if ((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius()) ||
 				(data->getBinRadius() > getSize()[0] &&	parent && parent->getElementCount() >= gOctreeMaxCapacity))) 
 			{ //it belongs here
-				//if this is a redundant insertion, error out (should never happen)
-				llassert(mData.find(data) == mData.end());
+				mElementCount++;
+				mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
 
-				mData.insert(data);
-				BaseType::insert(data);
+				//avoid unref on uninitialized memory
+				memset(mData+mElementCount-1, 0, sizeof(LLPointer<T>));
 
-				mElementCount = mData.size();
+				mData[mElementCount-1] = data;
+				mDataEnd = mData + mElementCount;
+				data->setBinIndex(mElementCount-1);
+				BaseType::insert(data);
 				return true;
 			}
 			else
@@ -342,10 +363,16 @@ public:
 
 				if( lt == 0x7 )
 				{
-					mData.insert(data);
-					BaseType::insert(data);
+					mElementCount++;
+					mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
+
+					//avoid unref on uninitialized memory
+					memset(mData+mElementCount-1, 0, sizeof(LLPointer<T>));
 
-					mElementCount = mData.size();
+					mData[mElementCount-1] = data;
+					mDataEnd = mData + mElementCount;
+					data->setBinIndex(mElementCount-1);
+					BaseType::insert(data);
 					return true;
 				}
 
@@ -394,23 +421,59 @@ public:
 		return false;
 	}
 
+	void _remove(T* data, S32 i)
+	{ //precondition -- mElementCount > 0, idx is in range [0, mElementCount)
+
+		mElementCount--;
+		data->setBinIndex(-1); 
+		
+		if (mElementCount > 0)
+		{
+			if (mElementCount != i)
+			{
+				mData[i] = mData[mElementCount]; //might unref data, do not access data after this point
+				mData[i]->setBinIndex(i);
+			}
+
+			mData[mElementCount] = NULL; //needed for unref
+			mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
+			mDataEnd = mData+mElementCount;
+		}
+		else
+		{
+			mData[0] = NULL; //needed for unref
+			free(mData);
+			mData = NULL;
+			mDataEnd = NULL;
+		}
+
+		notifyRemoval(data);
+		checkAlive();
+	}
+
 	bool remove(T* data)
 	{
-		if (mData.find(data) != mData.end())
-		{	//we have data
-			mData.erase(data);
-			mElementCount = mData.size();
-			notifyRemoval(data);
-			checkAlive();
-			return true;
-		}
-		else if (isInside(data))
+		S32 i = data->getBinIndex();
+
+		if (i >= 0 && i < mElementCount)
+		{
+			if (mData[i] == data)
+			{ //found it
+				_remove(data, i);
+				llassert(data->getBinIndex() == -1);
+				return true;
+			}
+		}
+		
+		if (isInside(data))
 		{
 			oct_node* dest = getNodeAt(data);
 
 			if (dest != this)
 			{
-				return dest->remove(data);
+				bool ret = dest->remove(data);
+				llassert(data->getBinIndex() == -1);
+				return ret;
 			}
 		}
 
@@ -429,19 +492,20 @@ public:
 		//node is now root
 		llwarns << "!!! OCTREE REMOVING FACE BY ADDRESS, SEVERE PERFORMANCE PENALTY |||" << llendl;
 		node->removeByAddress(data);
+		llassert(data->getBinIndex() == -1);
 		return true;
 	}
 
 	void removeByAddress(T* data)
 	{
-        if (mData.find(data) != mData.end())
+        for (U32 i = 0; i < mElementCount; ++i)
 		{
-			mData.erase(data);
-			mElementCount = mData.size();
-			notifyRemoval(data);
-			llwarns << "FOUND!" << llendl;
-			checkAlive();
-			return;
+			if (mData[i] == data)
+			{ //we have data
+				_remove(data, i);
+				llwarns << "FOUND!" << llendl;
+				return;
+			}
 		}
 		
 		for (U32 i = 0; i < getChildCount(); i++)
@@ -606,6 +670,7 @@ protected:
 	U32 mChildCount;
 
 	element_list mData;
+	element_iter mDataEnd;
 	U32 mElementCount;
 		
 }; 
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index ea09a3afe7..919079fa88 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -317,16 +317,16 @@ public:
 		LLVector4a& min = node->mExtents[0];
 		LLVector4a& max = node->mExtents[1];
 
-		if (!branch->getData().empty())
+		if (!branch->isEmpty())
 		{ //node has data, find AABB that binds data set
-			const LLVolumeTriangle* tri = *(branch->getData().begin());
+			const LLVolumeTriangle* tri = *(branch->getDataBegin());
 			
 			//initialize min/max to first available vertex
 			min = *(tri->mV[0]);
 			max = *(tri->mV[0]);
 			
 			for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = 
-				branch->getData().begin(); iter != branch->getData().end(); ++iter)
+				branch->getDataBegin(); iter != branch->getDataEnd(); ++iter)
 			{ //for each triangle in node
 
 				//stretch by triangles in node
diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp
index b5a935c2b5..cc83cb7235 100644
--- a/indra/llmath/llvolumeoctree.cpp
+++ b/indra/llmath/llvolumeoctree.cpp
@@ -131,7 +131,7 @@ void LLOctreeTriangleRayIntersect::traverse(const LLOctreeNode<LLVolumeTriangle>
 void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode<LLVolumeTriangle>* node)
 {
 	for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = 
-			node->getData().begin(); iter != node->getData().end(); ++iter)
+			node->getDataBegin(); iter != node->getDataEnd(); ++iter)
 	{
 		const LLVolumeTriangle* tri = *iter;
 
@@ -236,8 +236,8 @@ void LLVolumeOctreeValidate::visit(const LLOctreeNode<LLVolumeTriangle>* branch)
 	}
 
 	//children fit, check data
-	for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getData().begin(); 
-			iter != branch->getData().end(); ++iter)
+	for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getDataBegin(); 
+			iter != branch->getDataEnd(); ++iter)
 	{
 		const LLVolumeTriangle* tri = *iter;
 
diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h
index dac97b14b5..9ae34a0c4e 100644
--- a/indra/llmath/llvolumeoctree.h
+++ b/indra/llmath/llvolumeoctree.h
@@ -49,7 +49,7 @@ public:
 
 	LLVolumeTriangle()
 	{
-		
+		mBinIndex = -1;	
 	}
 
 	LLVolumeTriangle(const LLVolumeTriangle& rhs)
@@ -74,9 +74,16 @@ public:
 	U16 mIndex[3];
 
 	F32 mRadius;
+	mutable S32 mBinIndex;
+
 
 	virtual const LLVector4a& getPositionGroup() const;
 	virtual const F32& getBinRadius() const;
+	
+	S32 getBinIndex() const { return mBinIndex; }
+	void setBinIndex(S32 idx) const { mBinIndex = idx; }
+
+
 };
 
 class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeTriangle>
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 108ec92f6d..4435e04b6c 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -108,6 +108,8 @@ void LLDrawable::init()
 	
 	mGeneration = -1;
 	mBinRadius = 1.f;
+	mBinIndex = -1;
+
 	mSpatialBridge = NULL;
 }
 
@@ -1087,6 +1089,8 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat
 	mDrawable = root;
 	root->setSpatialBridge(this);
 	
+	mBinIndex = -1;
+
 	mRenderType = mDrawable->mRenderType;
 	mDrawableType = mDrawable->mRenderType;
 	
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 8c7db61502..08511bb9fc 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -120,6 +120,9 @@ public:
 	F32			          getIntensity() const			{ return llmin(mXform.getScale().mV[0], 4.f); }
 	S32					  getLOD() const				{ return mVObjp ? mVObjp->getLOD() : 1; }
 	F32					  getBinRadius() const			{ return mBinRadius; }
+	S32					  getBinIndex() const			{ return mBinIndex; }
+	void				  setBinIndex(S32 index) const	{ mBinIndex = index; }
+
 	void  getMinMax(LLVector3& min,LLVector3& max) const { mXform.getMinMax(min,max); }
 	LLXformMatrix*		getXform() { return &mXform; }
 
@@ -326,6 +329,7 @@ private:
 	mutable U32		mVisible;
 	F32				mRadius;
 	F32				mBinRadius;
+	mutable S32		mBinIndex;
 	S32				mGeneration;
 	
 	LLVector3		mCurrentScale;
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 02a8d1244f..eea5161538 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -163,15 +163,10 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
 	mGeomCount		= 0;
 	mGeomIndex		= 0;
 	mIndicesCount	= 0;
-	if (drawablep->getRenderType() == LLPipeline::RENDER_TYPE_PARTICLES ||
-		drawablep->getRenderType() == LLPipeline::RENDER_TYPE_HUD_PARTICLES)
-	{ //indicate to LLParticlePartition that this particle is uninitialized
-		mIndicesIndex = 0xFFFFFFFF;
-	}
-	else
-	{
-		mIndicesIndex	= 0;
-	}
+
+	//special value to indicate uninitialized position
+	mIndicesIndex	= 0xFFFFFFFF;
+	
 	mIndexInTex = 0;
 	mTexture		= NULL;
 	mTEOffset		= -1;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index ccc5dc7bea..a71529a3bd 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -542,7 +542,7 @@ void LLSpatialGroup::validate()
 
 	validateDrawMap();
 
-	for (element_iter i = getData().begin(); i != getData().end(); ++i)
+	for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		sg_assert(drawable->getSpatialGroup() == this);
@@ -759,7 +759,7 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& ma
 {	
 	const OctreeNode* node = mOctreeNode;
 
-	if (node->getData().empty())
+	if (node->isEmpty())
 	{	//don't do anything if there are no objects
 		if (empty && mOctreeNode->getParent())
 		{	//only root is allowed to be empty
@@ -776,14 +776,14 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& ma
 		clearState(OBJECT_DIRTY);
 
 		//initialize bounding box to first element
-		OctreeNode::const_element_iter i = node->getData().begin();
+		OctreeNode::const_element_iter i = node->getDataBegin();
 		LLDrawable* drawablep = *i;
 		const LLVector4a* minMax = drawablep->getSpatialExtents();
 
 		newMin = minMax[0];
 		newMax = minMax[1];
 
-		for (++i; i != node->getData().end(); ++i)
+		for (++i; i != node->getDataEnd(); ++i)
 		{
 			drawablep = *i;
 			minMax = drawablep->getSpatialExtents();
@@ -1247,7 +1247,7 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 		llerrs << "Spatial group dirty on distance update." << llendl;
 	}
 #endif
-	if (!getData().empty())
+	if (!isEmpty())
 	{
 		mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].getLength3().getF32() :
 						(F32) mOctreeNode->getSize().getLength3().getF32();
@@ -1398,7 +1398,7 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	setState(DEAD);
 	
-	for (element_iter i = getData().begin(); i != getData().end(); ++i)
+	for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		if (drawable->getSpatialGroup() == this)
@@ -1485,7 +1485,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 	}
 
 
-	for (LLSpatialGroup::element_iter i = getData().begin(); i != getData().end(); ++i)
+	for (LLSpatialGroup::element_iter i = getDataBegin(); i != getDataEnd(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		for (S32 j = 0; j < drawable->getNumFaces(); j++)
@@ -2117,7 +2117,7 @@ public:
 
 	virtual void processGroup(LLSpatialGroup* group)
 	{
-		llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->getData().empty())
+		llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->isEmpty())
 		
 		if (mRes < 2)
 		{
@@ -2184,7 +2184,7 @@ public:
 	{
 		LLSpatialGroup::OctreeNode* branch = group->mOctreeNode;
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
+		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
 		{
 			LLDrawable* drawable = *i;
 			
@@ -2308,7 +2308,7 @@ public:
 		LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0);
 		group->destroyGL();
 
-		for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+		for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 		{
 			LLDrawable* drawable = *i;
 			if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup)
@@ -2618,7 +2618,7 @@ void renderOctree(LLSpatialGroup* group)
 			gGL.flush();
 			glLineWidth(1.f);
 			gGL.flush();
-			for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+			for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 			{
 				LLDrawable* drawable = *i;
 				if (!group->mSpatialPartition->isBridge())
@@ -2664,7 +2664,7 @@ void renderOctree(LLSpatialGroup* group)
 	}
 	else
 	{
-		if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->getData().empty() 
+		if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->isEmpty() 
 			&& group->mSpatialPartition->mRenderByGroup)
 		{
 			col.setVec(0.8f, 0.4f, 0.1f, 0.1f);
@@ -2732,7 +2732,7 @@ void renderVisibility(LLSpatialGroup* group, LLCamera* camera)
 	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 
 	BOOL render_objects = (!LLPipeline::sUseOcclusion || !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) && group->isVisible() &&
-							!group->getData().empty();
+							!group->isEmpty();
 
 	if (render_objects)
 	{
@@ -3463,7 +3463,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
 
 void renderPhysicsShapes(LLSpatialGroup* group)
 {
-	for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+	for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		LLVOVolume* volume = drawable->getVOVolume();
@@ -3812,7 +3812,7 @@ public:
 
 		LLVector3 center, size;
 		
-		if (branch->getData().empty())
+		if (branch->isEmpty())
 		{
 			gGL.diffuseColor3f(1.f,0.2f,0.f);
 			center.set(branch->getCenter().getF32ptr());
@@ -3848,8 +3848,8 @@ public:
 			}
 
 			gGL.begin(LLRender::TRIANGLES);
-			for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getData().begin();
-					iter != branch->getData().end();
+			for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getDataBegin();
+					iter != branch->getDataEnd();
 					++iter)
 			{
 				const LLVolumeTriangle* tri = *iter;
@@ -4086,7 +4086,7 @@ public:
 
 		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BBOXES))
 		{
-			if (!group->getData().empty())
+			if (!group->isEmpty())
 			{
 				gGL.diffuseColor3f(0,0,1);
 				drawBoxOutline(group->mObjectBounds[0],
@@ -4094,7 +4094,7 @@ public:
 			}
 		}
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
+		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
 		{
 			LLDrawable* drawable = *i;
 					
@@ -4283,7 +4283,7 @@ public:
 			return;
 		}
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
+		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
 		{
 			LLDrawable* drawable = *i;
 						
@@ -4507,7 +4507,7 @@ public:
 	
 	virtual void visit(const LLSpatialGroup::OctreeNode* branch) 
 	{	
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
+		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
 		{
 			check(*i);
 		}
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index d935c1f140..f050df2b39 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -345,8 +345,13 @@ public:
 
 	void dirtyGeom() { setState(GEOM_DIRTY); }
 	void dirtyMesh() { setState(MESH_DIRTY); }
+
+	//octree wrappers to make code more readable
 	element_list& getData() { return mOctreeNode->getData(); }
+	element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
+	element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
 	U32 getElementCount() const { return mOctreeNode->getElementCount(); }
+	bool isEmpty() const { return mOctreeNode->isEmpty(); }
 
 	void drawObjectBox(LLColor4 col);
 
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index 44968342bf..5ad9ccc9af 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -622,7 +622,7 @@ void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count
 	mFaceList.clear();
 
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
-	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
 		LLDrawable* drawablep = *i;
 		
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index e21358b65a..02282fd6a6 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -554,7 +554,7 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co
 	mFaceList.clear();
 
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
-	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
 		LLDrawable* drawablep = *i;
 		
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 0abe73d55e..d1c668f984 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4251,7 +4251,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 		LLFastTimer t(FTM_REBUILD_VOLUME_FACE_LIST);
 
 		//get all the faces into a list
-		for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
+		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 		{
 			LLDrawable* drawablep = *drawable_iter;
 		
@@ -4657,7 +4657,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 	if (!LLPipeline::sDelayVBUpdate)
 	{
 		//drawables have been rebuilt, clear rebuild status
-		for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
+		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 		{
 			LLDrawable* drawablep = *drawable_iter;
 			drawablep->clearState(LLDrawable::REBUILD_ALL);
@@ -4697,7 +4697,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 		
 		std::set<LLVertexBuffer*> mapped_buffers;
 
-		for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
+		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 		{
 			LLDrawable* drawablep = *drawable_iter;
 
@@ -4759,7 +4759,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 		if(num_mapped_veretx_buffer != LLVertexBuffer::sMappedCount) 
 		{
 			llwarns << "Not all mapped vertex buffers are unmapped!" << llendl ; 
-			for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
+			for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 			{
 				LLDrawable* drawablep = *drawable_iter;
 				for (S32 i = 0; i < drawablep->getNumFaces(); ++i)
@@ -5227,7 +5227,7 @@ void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_coun
 
 	//for each drawable
 
-	for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
+	for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 	{
 		LLDrawable* drawablep = *drawable_iter;
 		
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index ec0e200ae0..49a9b31c14 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1371,7 +1371,7 @@ public:
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
 
-		if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && !group->getData().empty())
+		if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && !group->isEmpty())
 		{
 			for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
 			{
@@ -1976,7 +1976,7 @@ void LLPipeline::clearReferences()
 
 void check_references(LLSpatialGroup* group, LLDrawable* drawable)
 {
-	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
 		if (drawable == *i)
 		{
@@ -1998,7 +1998,7 @@ void check_references(LLDrawable* drawable, LLFace* face)
 
 void check_references(LLSpatialGroup* group, LLFace* face)
 {
-	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
 		LLDrawable* drawable = *i;
 		check_references(drawable, face);
@@ -2374,7 +2374,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 
 void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
 {
-	if (group->getData().empty())
+	if (group->isEmpty())
 	{ 
 		return;
 	}
@@ -3004,7 +3004,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 		else
 		{
 			group->setVisible();
-			for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+			for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 			{
 				markVisible(*i, camera);
 			}
@@ -3092,7 +3092,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT);
 	if (group->changeLOD())
 	{
-		for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+		for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 		{
 			LLDrawable* drawablep = *i;
 			stateSort(drawablep, camera);
@@ -3215,7 +3215,7 @@ void forAllDrawables(LLCullResult::sg_iterator begin,
 {
 	for (LLCullResult::sg_iterator i = begin; i != end; ++i)
 	{
-		for (LLSpatialGroup::element_iter j = (*i)->getData().begin(); j != (*i)->getData().end(); ++j)
+		for (LLSpatialGroup::element_iter j = (*i)->getDataBegin(); j != (*i)->getDataEnd(); ++j)
 		{
 			func(*j);	
 		}
-- 
cgit v1.2.3


From 4127f3e7fcc725dbbf500c52605c5b950073c828 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:48:56 -0400
Subject: reapply efcec3eb374f: MAINT-646 Factor std::vector out of lloctree

---
 indra/llmath/lloctree.h   | 18 +++++++++++-------
 indra/llmath/llvolume.cpp |  2 +-
 2 files changed, 12 insertions(+), 8 deletions(-)

(limited to 'indra')

diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index a7e176fd51..c3f6f7de2a 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -31,7 +31,6 @@
 #include "v3math.h"
 #include "llvector4a.h"
 #include <vector>
-#include <set>
 
 #define OCT_ERRS LL_WARNS("OctreeErrors")
 
@@ -83,7 +82,9 @@ public:
 	typedef LLPointer<T>*										element_iter;
 	typedef const LLPointer<T>*									const_element_iter;
 	typedef typename std::vector<LLTreeListener<T>*>::iterator	tree_listener_iter;
-	typedef typename std::vector<LLOctreeNode<T>* >				child_list;
+	typedef LLOctreeNode<T>**									child_list;
+	typedef LLOctreeNode<T>**									child_iter;
+
 	typedef LLTreeNode<T>		BaseType;
 	typedef LLOctreeNode<T>		oct_node;
 	typedef LLOctreeListener<T>	oct_listener;
@@ -232,7 +233,7 @@ public:
 	}
 
 	void accept(oct_traveler* visitor)				{ visitor->visit(this); }
-	virtual bool isLeaf() const						{ return mChild.empty(); }
+	virtual bool isLeaf() const						{ return mChildCount == 0; }
 	
 	U32 getElementCount() const						{ return mElementCount; }
 	bool isEmpty() const							{ return mElementCount == 0; }
@@ -517,8 +518,8 @@ public:
 
 	void clearChildren()
 	{
-		mChild.clear();
 		mChildCount = 0;
+
 		U32* foo = (U32*) mChildMap;
 		foo[0] = foo[1] = 0xFFFFFFFF;
 	}
@@ -580,7 +581,7 @@ public:
 
 		mChildMap[child->getOctant()] = mChildCount;
 
-		mChild.push_back(child);
+		mChild[mChildCount] = child;
 		++mChildCount;
 		child->setParent(this);
 
@@ -607,9 +608,12 @@ public:
 			mChild[index]->destroy();
 			delete mChild[index];
 		}
-		mChild.erase(mChild.begin() + index);
+
 		--mChildCount;
 
+		mChild[index] = mChild[mChildCount];
+		
+
 		//rebuild child map
 		U32* foo = (U32*) mChildMap;
 		foo[0] = foo[1] = 0xFFFFFFFF;
@@ -665,7 +669,7 @@ protected:
 	oct_node* mParent;
 	U8 mOctant;
 
-	child_list mChild;
+	LLOctreeNode<T>* mChild[8];
 	U8 mChildMap[8];
 	U32 mChildCount;
 
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 919079fa88..85ea14f9bc 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -341,7 +341,7 @@ public:
 				max.setMax(max, *tri->mV[2]);
 			}
 		}
-		else if (!branch->getChildren().empty())
+		else if (!branch->isLeaf())
 		{ //no data, but child nodes exist
 			LLVolumeOctreeListener* child = (LLVolumeOctreeListener*) branch->getChild(0)->getListener(0);
 
-- 
cgit v1.2.3


From 6a09bc187c59645e647adaa3c70e55efa979b5ec Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:48:56 -0400
Subject: reapply 0f20bb7cb9ee: MAINT-1147 Don't rebuild volume meshes on
 region crossing.

---
 indra/newview/llspatialpartition.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index a71529a3bd..70bafc8b2e 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -924,7 +924,7 @@ void LLSpatialGroup::shift(const LLVector4a &offset)
 	mObjectExtents[0].add(offset);
 	mObjectExtents[1].add(offset);
 
-	//if (!mSpatialPartition->mRenderByGroup)
+	if (!mSpatialPartition->mRenderByGroup)
 	{
 		setState(GEOM_DIRTY);
 		gPipeline.markRebuild(this, TRUE);
-- 
cgit v1.2.3


From 28b43b783232eb54b01d1d918457b0865ddac093 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:48:57 -0400
Subject: reapply b895285ab0de: MAINT-646 Don't spend so much time fetching
 avatar physics params.

---
 indra/newview/llphysicsmotion.cpp | 77 +++++++++++++++++++++++++++++++--------
 1 file changed, 62 insertions(+), 15 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index e124916c48..cb6989c9dd 100644
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -67,6 +67,19 @@ inline F64 llsgn(const F64 a)
 class LLPhysicsMotion
 {
 public:
+	typedef enum
+	{
+		SMOOTHING = 0,
+		MASS,
+		GRAVITY,
+		SPRING,
+		GAIN,
+		DAMPING,
+		DRAG,
+		MAX_EFFECT,
+		NUM_PARAMS
+	} eParamName;
+
         /*
           param_driver_name: The param that controls the params that are being affected by the physics.
           joint_name: The joint that the body part is attached to.  The joint is
@@ -98,6 +111,11 @@ public:
                 mPositionLastUpdate_local(0)
         {
                 mJointState = new LLJointState;
+
+				for (U32 i = 0; i < NUM_PARAMS; ++i)
+				{
+					mParamCache[i] = NULL;
+				}
         }
 
         BOOL initialize();
@@ -111,16 +129,43 @@ public:
                 return mJointState;
         }
 protected:
-        F32 getParamValue(const std::string& controller_key)
-        {
-                const controller_map_t::const_iterator& entry = mParamControllers.find(controller_key);
+
+		F32 getParamValue(eParamName param)
+		{
+			static std::string controller_key[] = 
+			{
+				"Smoothing",
+				"Mass",
+				"Gravity",
+				"Spring",
+				"Gain",
+				"Damping",
+				"Drag",
+				"MaxEffect"
+			};
+
+			if (!mParamCache[param])
+			{
+				const controller_map_t::const_iterator& entry = mParamControllers.find(controller_key[param]);
                 if (entry == mParamControllers.end())
                 {
-                        return sDefaultController[controller_key];
+                        return sDefaultController[controller_key[param]];
                 }
                 const std::string& param_name = (*entry).second.c_str();
-                return mCharacter->getVisualParamWeight(param_name.c_str());
-        }
+                mParamCache[param] = mCharacter->getVisualParam(param_name.c_str());
+			}
+				
+			if (mParamCache[param])
+			{
+				return mParamCache[param]->getWeight();
+			}
+			else
+			{
+				return sDefaultController[controller_key[param]];
+			}
+		}
+
+        
         void setParamValue(LLViewerVisualParam *param,
                            const F32 new_value_local,
                                                    F32 behavior_maxeffect);
@@ -150,6 +195,8 @@ private:
 
         F32 mLastTime;
         
+		LLVisualParam* mParamCache[NUM_PARAMS];
+
         static default_controller_map_t sDefaultController;
 };
 
@@ -427,7 +474,6 @@ BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask)
         return TRUE;
 }
 
-
 // Return TRUE if character has to update visual params.
 BOOL LLPhysicsMotion::onUpdate(F32 time)
 {
@@ -471,15 +517,16 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
 
         LLJoint *joint = mJointState->getJoint();
 
-        const F32 behavior_mass = getParamValue("Mass");
-        const F32 behavior_gravity = getParamValue("Gravity");
-        const F32 behavior_spring = getParamValue("Spring");
-        const F32 behavior_gain = getParamValue("Gain");
-        const F32 behavior_damping = getParamValue("Damping");
-        const F32 behavior_drag = getParamValue("Drag");
-        const BOOL physics_test = FALSE; // Enable this to simulate bouncing on all parts.
+		const F32 behavior_mass = getParamValue(MASS);
+		const F32 behavior_gravity = getParamValue(GRAVITY);
+		const F32 behavior_spring = getParamValue(SPRING);
+		const F32 behavior_gain = getParamValue(GAIN);
+		const F32 behavior_damping = getParamValue(DAMPING);
+		const F32 behavior_drag = getParamValue(DRAG);
+		F32 behavior_maxeffect = getParamValue(MAX_EFFECT);
+		
+		const BOOL physics_test = FALSE; // Enable this to simulate bouncing on all parts.
         
-        F32 behavior_maxeffect = getParamValue("MaxEffect");
         if (physics_test)
                 behavior_maxeffect = 1.0f;
 
-- 
cgit v1.2.3


From 55e1557b8af1c02d6b50214f9f24d5a384aa3b3a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:54:49 -0400
Subject: reapply 668dcacd6e76: MAINT-646 Vectorize LLPolyMesh

---
 indra/llcharacter/llcharacter.cpp        |   7 ++
 indra/llcharacter/llmotioncontroller.cpp |  12 +-
 indra/newview/lldriverparam.cpp          |  26 +++--
 indra/newview/lldriverparam.h            |  10 +-
 indra/newview/llpolymesh.cpp             | 191 ++++++++++++++++++-------------
 indra/newview/llpolymesh.h               |  52 ++++-----
 indra/newview/llpolymorph.cpp            | 165 +++++++++++++++-----------
 indra/newview/llpolymorph.h              |  18 +--
 indra/newview/lltexlayerparams.h         |  20 ++--
 indra/newview/llviewervisualparam.h      |   8 +-
 10 files changed, 295 insertions(+), 214 deletions(-)

(limited to 'indra')

diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index 07f0baae51..0a6a8f9fa6 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -187,14 +187,20 @@ void LLCharacter::requestStopMotion( LLMotion* motion)
 //-----------------------------------------------------------------------------
 // updateMotions()
 //-----------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_UPDATE_ANIMATION("Update Animation");
+static LLFastTimer::DeclareTimer FTM_UPDATE_HIDDEN_ANIMATION("Update Hidden Anim");
+static LLFastTimer::DeclareTimer FTM_UPDATE_MOTIONS("Update Motions");
+
 void LLCharacter::updateMotions(e_update_t update_type)
 {
 	if (update_type == HIDDEN_UPDATE)
 	{
+		LLFastTimer t(FTM_UPDATE_HIDDEN_ANIMATION);
 		mMotionController.updateMotionsMinimal();
 	}
 	else
 	{
+		LLFastTimer t(FTM_UPDATE_ANIMATION);
 		// unpause if the number of outstanding pause requests has dropped to the initial one
 		if (mMotionController.isPaused() && mPauseRequest->getNumRefs() == 1)
 		{
@@ -202,6 +208,7 @@ void LLCharacter::updateMotions(e_update_t update_type)
 		}
 		bool force_update = (update_type == FORCE_UPDATE);
 		{
+			LLFastTimer t(FTM_UPDATE_MOTIONS);
 			mMotionController.updateMotions(force_update);
 		}
 	}
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index 236b8c616d..4f6351709e 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -542,6 +542,8 @@ void LLMotionController::updateIdleActiveMotions()
 //-----------------------------------------------------------------------------
 // updateMotionsByType()
 //-----------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_MOTION_ON_UPDATE("Motion onUpdate");
+
 void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_type)
 {
 	BOOL update_result = TRUE;
@@ -699,7 +701,10 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
 			}
 
 			// perform motion update
-			update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
+			{
+				LLFastTimer t(FTM_MOTION_ON_UPDATE);
+				update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
+			}
 		}
 
 		//**********************
@@ -862,11 +867,12 @@ void LLMotionController::updateMotions(bool force_update)
 	{
 		// update additive motions
 		updateAdditiveMotions();
+				
 		resetJointSignatures();
-
+		
 		// update all regular motions
 		updateRegularMotions();
-
+		
 		if (use_quantum)
 		{
 			mPoseBlender.blendAndCache(TRUE);
diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp
index 64eb11fc9b..885cae1737 100644
--- a/indra/newview/lldriverparam.cpp
+++ b/indra/newview/lldriverparam.cpp
@@ -155,6 +155,7 @@ LLDriverParam::LLDriverParam(LLVOAvatar *avatarp) :
 	mAvatarp(avatarp), 
 	mWearablep(NULL)
 {
+	mDefaultVec.clear();
 }
 
 LLDriverParam::LLDriverParam(LLWearable *wearablep) : 
@@ -162,6 +163,7 @@ LLDriverParam::LLDriverParam(LLWearable *wearablep) :
 	mAvatarp(NULL), 
 	mWearablep(wearablep)
 {
+	mDefaultVec.clear();
 }
 
 LLDriverParam::~LLDriverParam()
@@ -341,18 +343,19 @@ F32	LLDriverParam::getTotalDistortion()
 	return sum; 
 }
 
-const LLVector3	&LLDriverParam::getAvgDistortion()	
+const LLVector4a	&LLDriverParam::getAvgDistortion()	
 {
 	// It's not actually correct to take the average of averages, but it good enough here.
-	LLVector3 sum;
+	LLVector4a sum;
+	sum.clear();
 	S32 count = 0;
 	for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
 	{
 		LLDrivenEntry* driven = &(*iter);
-		sum += driven->mParam->getAvgDistortion();
+		sum.add(driven->mParam->getAvgDistortion());
 		count++;
 	}
-	sum /= (F32)count;
+	sum.mul( 1.f/(F32)count);
 
 	mDefaultVec = sum;
 	return mDefaultVec; 
@@ -375,21 +378,22 @@ F32	LLDriverParam::getMaxDistortion()
 }
 
 
-LLVector3	LLDriverParam::getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)
+LLVector4a	LLDriverParam::getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)
 {
-	LLVector3 sum;
+	LLVector4a sum;
+	sum.clear();
 	for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
 	{
 		LLDrivenEntry* driven = &(*iter);
-		sum += driven->mParam->getVertexDistortion( index, poly_mesh );
+		sum.add(driven->mParam->getVertexDistortion( index, poly_mesh ));
 	}
 	return sum;
 }
 
-const LLVector3*	LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
+const LLVector4a*	LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
 {
 	mCurrentDistortionParam = NULL;
-	const LLVector3* v = NULL;
+	const LLVector4a* v = NULL;
 	for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
 	{
 		LLDrivenEntry* driven = &(*iter);
@@ -404,7 +408,7 @@ const LLVector3*	LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **poly
 	return v;
 };
 
-const LLVector3*	LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
+const LLVector4a*	LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
 {
 	llassert( mCurrentDistortionParam );
 	if( !mCurrentDistortionParam )
@@ -432,7 +436,7 @@ const LLVector3*	LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_
 	}
 
 	// We're already in the middle of a param's distortions, so get the next one.
-	const LLVector3* v = driven->mParam->getNextDistortion( index, poly_mesh );
+	const LLVector4a* v = driven->mParam->getNextDistortion( index, poly_mesh );
 	if( (!v) && (iter != mDriven.end()) )
 	{
 		// This param is finished, so start the next param.  It might not have any
diff --git a/indra/newview/lldriverparam.h b/indra/newview/lldriverparam.h
index fb1b44458c..7a4d711d4e 100644
--- a/indra/newview/lldriverparam.h
+++ b/indra/newview/lldriverparam.h
@@ -105,18 +105,18 @@ public:
 	
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion();
-	/*virtual*/ const LLVector3&	getAvgDistortion();
+	/*virtual*/ const LLVector4a&	getAvgDistortion();
 	/*virtual*/ F32					getMaxDistortion();
-	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
-	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
-	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
+	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
+	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
+	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
 
 protected:
 	F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight);
 	void setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake);
 
 
-	LLVector3	mDefaultVec; // temp holder
+	LLVector4a	mDefaultVec; // temp holder
 	typedef std::vector<LLDrivenEntry> entry_list_t;
 	entry_list_t mDriven;
 	LLViewerVisualParam* mCurrentDistortionParam;
diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp
index 0860506086..c6b9aaae4b 100644
--- a/indra/newview/llpolymesh.cpp
+++ b/indra/newview/llpolymesh.cpp
@@ -229,15 +229,18 @@ U32 LLPolyMeshSharedData::getNumKB()
 BOOL LLPolyMeshSharedData::allocateVertexData( U32 numVertices )
 {
         U32 i;
-        mBaseCoords = (LLVector3*) ll_aligned_malloc_16(numVertices*sizeof(LLVector3));
-        mBaseNormals = (LLVector3*) ll_aligned_malloc_16(numVertices*sizeof(LLVector3));
-        mBaseBinormals = (LLVector3*) ll_aligned_malloc_16(numVertices*sizeof(LLVector3));
+        mBaseCoords = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
+        mBaseNormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
+        mBaseBinormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
         mTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
         mDetailTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
         mWeights = (F32*) ll_aligned_malloc_16(numVertices*sizeof(F32));
         for (i = 0; i < numVertices; i++)
         {
-                mWeights[i] = 0.f;
+			mBaseCoords[i].clear();
+			mBaseNormals[i].clear();
+			mBaseBinormals[i].clear();
+			mWeights[i] = 0.f;
         }
         mNumVertices = numVertices;
         return TRUE;
@@ -408,39 +411,47 @@ BOOL LLPolyMeshSharedData::loadMesh( const std::string& fileName )
 
                         allocateVertexData( numVertices );      
 
-                        //----------------------------------------------------------------
-                        // Coords
-                        //----------------------------------------------------------------
-                        numRead = fread(mBaseCoords, 3*sizeof(float), numVertices, fp);
-                        llendianswizzle(mBaseCoords, sizeof(float), 3*numVertices);
-                        if (numRead != numVertices)
-                        {
-                                llerrs << "can't read Coordinates from " << fileName << llendl;
-                                return FALSE;
-                        }
-
-                        //----------------------------------------------------------------
-                        // Normals
-                        //----------------------------------------------------------------
-                        numRead = fread(mBaseNormals, 3*sizeof(float), numVertices, fp);
-                        llendianswizzle(mBaseNormals, sizeof(float), 3*numVertices);
-                        if (numRead != numVertices)
-                        {
-                                llerrs << " can't read Normals from " << fileName << llendl;
-                                return FALSE;
-                        }
-
-                        //----------------------------------------------------------------
-                        // Binormals
-                        //----------------------------------------------------------------
-                        numRead = fread(mBaseBinormals, 3*sizeof(float), numVertices, fp);
-                        llendianswizzle(mBaseBinormals, sizeof(float), 3*numVertices);
-                        if (numRead != numVertices)
-                        {
-                                llerrs << " can't read Binormals from " << fileName << llendl;
-                                return FALSE;
-                        }
-
+						for (U16 i = 0; i < numVertices; ++i)
+						{
+							//----------------------------------------------------------------
+							// Coords
+							//----------------------------------------------------------------
+							numRead = fread(&mBaseCoords[i], sizeof(float), 3, fp);
+							llendianswizzle(&mBaseCoords[i], sizeof(float), 3);
+							if (numRead != 3)
+							{
+									llerrs << "can't read Coordinates from " << fileName << llendl;
+									return FALSE;
+							}
+						}
+
+						for (U16 i = 0; i < numVertices; ++i)
+						{
+							//----------------------------------------------------------------
+							// Normals
+							//----------------------------------------------------------------
+							numRead = fread(&mBaseNormals[i], sizeof(float), 3, fp);
+							llendianswizzle(&mBaseNormals[i], sizeof(float), 3);
+							if (numRead != 3)
+							{
+									llerrs << " can't read Normals from " << fileName << llendl;
+									return FALSE;
+							}
+						}
+
+						for (U16 i = 0; i < numVertices; ++i)
+						{
+							//----------------------------------------------------------------
+							// Binormals
+							//----------------------------------------------------------------
+							numRead = fread(&mBaseBinormals[i], sizeof(float), 3, fp);
+							llendianswizzle(&mBaseBinormals[i], sizeof(float), 3);
+							if (numRead != 3)
+							{
+									llerrs << " can't read Binormals from " << fileName << llendl;
+									return FALSE;
+							}
+						}
 
                         //----------------------------------------------------------------
                         // TexCoords
@@ -767,21 +778,28 @@ LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_
 	{
 		// Allocate memory without initializing every vector
 		// NOTE: This makes asusmptions about the size of LLVector[234]
-		int nverts = mSharedData->mNumVertices;
-		int nfloats = nverts * (2*4 + 3*3 + 2 + 4);
+		S32 nverts = mSharedData->mNumVertices;
+		//make sure it's an even number of verts for alignment
+		nverts += nverts%2;
+		S32 nfloats = nverts * (
+					4 + //coords
+					4 + //normals
+					4 + //weights
+					2 + //coords
+					4 + //scaled normals
+					4 + //binormals
+					4); //scaled binormals
+
 		//use 16 byte aligned vertex data to make LLPolyMesh SSE friendly
 		mVertexData = (F32*) ll_aligned_malloc_16(nfloats*4);
-		int offset = 0;
-		mCoords				= 	(LLVector4*)(mVertexData + offset); offset += 4*nverts;
-		mNormals			=	(LLVector4*)(mVertexData + offset); offset += 4*nverts;
-		mClothingWeights	= 	(LLVector4*)(mVertexData + offset); offset += 4*nverts;
-		mTexCoords			= 	(LLVector2*)(mVertexData + offset); offset += 2*nverts;
-
-		// these members don't need to be 16-byte aligned, but the first one might be
-		// read during an aligned memcpy of mTexCoords
-		mScaledNormals =                (LLVector3*)(mVertexData + offset); offset += 3*nverts;
-		mBinormals =                    (LLVector3*)(mVertexData + offset); offset += 3*nverts;
-		mScaledBinormals =              (LLVector3*)(mVertexData + offset); offset += 3*nverts; 
+		S32 offset = 0;
+		mCoords				= 	(LLVector4a*)(mVertexData + offset); offset += 4*nverts;
+		mNormals			=	(LLVector4a*)(mVertexData + offset); offset += 4*nverts;
+		mClothingWeights	= 	(LLVector4a*)(mVertexData + offset); offset += 4*nverts;
+		mTexCoords			= 	(LLVector2*)(mVertexData + offset);  offset += 2*nverts;
+		mScaledNormals		=   (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
+		mBinormals			=   (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
+		mScaledBinormals	=   (LLVector4a*)(mVertexData + offset); offset += 4*nverts; 
 		initializeForMorph();
 	}
 }
@@ -906,7 +924,7 @@ void LLPolyMesh::dumpDiagInfo()
 //-----------------------------------------------------------------------------
 // getWritableCoords()
 //-----------------------------------------------------------------------------
-LLVector4 *LLPolyMesh::getWritableCoords()
+LLVector4a *LLPolyMesh::getWritableCoords()
 {
         return mCoords;
 }
@@ -914,7 +932,7 @@ LLVector4 *LLPolyMesh::getWritableCoords()
 //-----------------------------------------------------------------------------
 // getWritableNormals()
 //-----------------------------------------------------------------------------
-LLVector4 *LLPolyMesh::getWritableNormals()
+LLVector4a *LLPolyMesh::getWritableNormals()
 {
         return mNormals;
 }
@@ -922,7 +940,7 @@ LLVector4 *LLPolyMesh::getWritableNormals()
 //-----------------------------------------------------------------------------
 // getWritableBinormals()
 //-----------------------------------------------------------------------------
-LLVector3 *LLPolyMesh::getWritableBinormals()
+LLVector4a *LLPolyMesh::getWritableBinormals()
 {
         return mBinormals;
 }
@@ -931,7 +949,7 @@ LLVector3 *LLPolyMesh::getWritableBinormals()
 //-----------------------------------------------------------------------------
 // getWritableClothingWeights()
 //-----------------------------------------------------------------------------
-LLVector4       *LLPolyMesh::getWritableClothingWeights()
+LLVector4a       *LLPolyMesh::getWritableClothingWeights()
 {
         return mClothingWeights;
 }
@@ -947,7 +965,7 @@ LLVector2       *LLPolyMesh::getWritableTexCoords()
 //-----------------------------------------------------------------------------
 // getScaledNormals()
 //-----------------------------------------------------------------------------
-LLVector3 *LLPolyMesh::getScaledNormals()
+LLVector4a *LLPolyMesh::getScaledNormals()
 {
         return mScaledNormals;
 }
@@ -955,7 +973,7 @@ LLVector3 *LLPolyMesh::getScaledNormals()
 //-----------------------------------------------------------------------------
 // getScaledBinormals()
 //-----------------------------------------------------------------------------
-LLVector3 *LLPolyMesh::getScaledBinormals()
+LLVector4a *LLPolyMesh::getScaledBinormals()
 {
         return mScaledBinormals;
 }
@@ -966,17 +984,17 @@ LLVector3 *LLPolyMesh::getScaledBinormals()
 //-----------------------------------------------------------------------------
 void LLPolyMesh::initializeForMorph()
 {
-    for (U32 i = 0; i < mSharedData->mNumVertices; ++i)
+    LLVector4a::memcpyNonAliased16((F32*) mCoords, (F32*) mSharedData->mBaseCoords, sizeof(LLVector4a) * mSharedData->mNumVertices);
+	LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
+	LLVector4a::memcpyNonAliased16((F32*) mScaledNormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
+	LLVector4a::memcpyNonAliased16((F32*) mBinormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
+	LLVector4a::memcpyNonAliased16((F32*) mScaledBinormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
+	LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) mSharedData->mTexCoords, sizeof(LLVector2) * (mSharedData->mNumVertices + mSharedData->mNumVertices%2));
+
+	for (U32 i = 0; i < mSharedData->mNumVertices; ++i)
 	{
-		mCoords[i] = LLVector4(mSharedData->mBaseCoords[i]);
-		mNormals[i] = LLVector4(mSharedData->mBaseNormals[i]);
+		mClothingWeights[i].clear();
 	}
-
-	memcpy(mScaledNormals, mSharedData->mBaseNormals, sizeof(LLVector3) * mSharedData->mNumVertices);	/*Flawfinder: ignore*/
-	memcpy(mBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices);	/*Flawfinder: ignore*/
-	memcpy(mScaledBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices);		/*Flawfinder: ignore*/
-	memcpy(mTexCoords, mSharedData->mTexCoords, sizeof(LLVector2) * mSharedData->mNumVertices);		/*Flawfinder: ignore*/
-	memset(mClothingWeights, 0, sizeof(LLVector4) * mSharedData->mNumVertices);
 }
 
 //-----------------------------------------------------------------------------
@@ -1098,7 +1116,7 @@ BOOL LLPolySkeletalDistortionInfo::parseXml(LLXmlTreeNode* node)
 LLPolySkeletalDistortion::LLPolySkeletalDistortion(LLVOAvatar *avatarp)
 {
         mAvatar = avatarp;
-        mDefaultVec.setVec(0.001f, 0.001f, 0.001f);
+        mDefaultVec.splat(0.001f);
 }
 
 //-----------------------------------------------------------------------------
@@ -1171,8 +1189,12 @@ BOOL LLPolySkeletalDistortion::setInfo(LLPolySkeletalDistortionInfo *info)
 //-----------------------------------------------------------------------------
 // apply()
 //-----------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_POLYSKELETAL_DISTORTION_APPLY("Skeletal Distortion");
+
 void LLPolySkeletalDistortion::apply( ESex avatar_sex )
 {
+	LLFastTimer t(FTM_POLYSKELETAL_DISTORTION_APPLY);
+
         F32 effective_weight = ( getSex() & avatar_sex ) ? mCurWeight : getDefaultWeight();
 
         LLJoint* joint;
@@ -1228,11 +1250,14 @@ LLPolyMorphData *clone_morph_param_direction(const LLPolyMorphData *src_data,
 {
         LLPolyMorphData* cloned_morph_data = new LLPolyMorphData(*src_data);
         cloned_morph_data->mName = name;
+		LLVector4a dir;
+		dir.load3(direction.mV);
+
         for (U32 v=0; v < cloned_morph_data->mNumIndices; v++)
         {
-                cloned_morph_data->mCoords[v] = direction;
-                cloned_morph_data->mNormals[v] = LLVector3(0,0,0);
-                cloned_morph_data->mBinormals[v] = LLVector3(0,0,0);
+                cloned_morph_data->mCoords[v] = dir;
+                cloned_morph_data->mNormals[v].clear();
+                cloned_morph_data->mBinormals[v].clear();
         }
         return cloned_morph_data;
 }
@@ -1243,17 +1268,27 @@ LLPolyMorphData *clone_morph_param_cleavage(const LLPolyMorphData *src_data,
 {
         LLPolyMorphData* cloned_morph_data = new LLPolyMorphData(*src_data);
         cloned_morph_data->mName = name;
+
+		LLVector4a sc;
+		sc.splat(scale);
+
+		LLVector4a nsc;
+		nsc.set(scale, -scale, scale, scale);
+
         for (U32 v=0; v < cloned_morph_data->mNumIndices; v++)
         {
-                cloned_morph_data->mCoords[v] = src_data->mCoords[v]*scale;
-                cloned_morph_data->mNormals[v] = src_data->mNormals[v]*scale;
-                cloned_morph_data->mBinormals[v] = src_data->mBinormals[v]*scale;
-                if (cloned_morph_data->mCoords[v][1] < 0)
-                {
-                        cloned_morph_data->mCoords[v][1] *= -1;
-                        cloned_morph_data->mNormals[v][1] *= -1;
-                        cloned_morph_data->mBinormals[v][1] *= -1;
-                }
+            if (cloned_morph_data->mCoords[v][1] < 0)
+            {
+                cloned_morph_data->mCoords[v].setMul(src_data->mCoords[v],nsc);
+				cloned_morph_data->mNormals[v].setMul(src_data->mNormals[v],nsc);
+				cloned_morph_data->mBinormals[v].setMul(src_data->mBinormals[v],nsc);
+			}
+			else
+			{
+				cloned_morph_data->mCoords[v].setMul(src_data->mCoords[v],sc);
+				cloned_morph_data->mNormals[v].setMul(src_data->mNormals[v], sc);
+				cloned_morph_data->mBinormals[v].setMul(src_data->mBinormals[v],sc);
+			}
         }
         return cloned_morph_data;
 }
diff --git a/indra/newview/llpolymesh.h b/indra/newview/llpolymesh.h
index ba2bf85570..ffb11a3f7e 100644
--- a/indra/newview/llpolymesh.h
+++ b/indra/newview/llpolymesh.h
@@ -73,9 +73,9 @@ private:
 							
 	// vertex data			
 	S32						mNumVertices;
-	LLVector3				*mBaseCoords;
-	LLVector3				*mBaseNormals;
-	LLVector3				*mBaseBinormals;
+	LLVector4a				*mBaseCoords;
+	LLVector4a				*mBaseNormals;
+	LLVector4a				*mBaseBinormals;
 	LLVector2				*mTexCoords;
 	LLVector2				*mDetailTexCoords;
 	F32						*mWeights;
@@ -217,41 +217,41 @@ public:
 	}
 
 	// Get coords
-	const LLVector4	*getCoords() const{
+	const LLVector4a	*getCoords() const{
 		return mCoords;
 	}
 
 	// non const version
-	LLVector4 *getWritableCoords();
+	LLVector4a *getWritableCoords();
 
 	// Get normals
-	const LLVector4	*getNormals() const{ 
+	const LLVector4a	*getNormals() const{ 
 		return mNormals; 
 	}
 
 	// Get normals
-	const LLVector3	*getBinormals() const{ 
+	const LLVector4a	*getBinormals() const{ 
 		return mBinormals; 
 	}
 
 	// Get base mesh normals
-	const LLVector3 *getBaseNormals() const{
+	const LLVector4a *getBaseNormals() const{
 		llassert(mSharedData);
 		return mSharedData->mBaseNormals;
 	}
 
 	// Get base mesh normals
-	const LLVector3 *getBaseBinormals() const{
+	const LLVector4a *getBaseBinormals() const{
 		llassert(mSharedData);
 		return mSharedData->mBaseBinormals;
 	}
 
 	// intermediate morphed normals and output normals
-	LLVector4 *getWritableNormals();
-	LLVector3 *getScaledNormals();
+	LLVector4a *getWritableNormals();
+	LLVector4a *getScaledNormals();
 
-	LLVector3 *getWritableBinormals();
-	LLVector3 *getScaledBinormals();
+	LLVector4a *getWritableBinormals();
+	LLVector4a *getScaledBinormals();
 
 	// Get texCoords
 	const LLVector2	*getTexCoords() const { 
@@ -275,9 +275,9 @@ public:
 
 	F32			*getWritableWeights() const;
 
-	LLVector4	*getWritableClothingWeights();
+	LLVector4a	*getWritableClothingWeights();
 
-	const LLVector4		*getClothingWeights()
+	const LLVector4a		*getClothingWeights()
 	{
 		return mClothingWeights;	
 	}
@@ -341,17 +341,17 @@ protected:
 	// Single array of floats for allocation / deletion
 	F32						*mVertexData;
 	// deformed vertices (resulting from application of morph targets)
-	LLVector4				*mCoords;
+	LLVector4a				*mCoords;
 	// deformed normals (resulting from application of morph targets)
-	LLVector3				*mScaledNormals;
+	LLVector4a				*mScaledNormals;
 	// output normals (after normalization)
-	LLVector4				*mNormals;
+	LLVector4a				*mNormals;
 	// deformed binormals (resulting from application of morph targets)
-	LLVector3				*mScaledBinormals;
+	LLVector4a				*mScaledBinormals;
 	// output binormals (after normalization)
-	LLVector3				*mBinormals;
+	LLVector4a				*mBinormals;
 	// weight values that mark verts as clothing/skin
-	LLVector4				*mClothingWeights;
+	LLVector4a				*mClothingWeights;
 	// output texture coordinates
 	LLVector2				*mTexCoords;
 	
@@ -419,17 +419,17 @@ public:
 	
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion() { return 0.1f; }
-	/*virtual*/ const LLVector3&	getAvgDistortion()	{ return mDefaultVec; }
+	/*virtual*/ const LLVector4a&	getAvgDistortion()	{ return mDefaultVec; }
 	/*virtual*/ F32					getMaxDistortion() { return 0.1f; }
-	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh){return LLVector3(0.001f, 0.001f, 0.001f);}
-	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh){index = 0; poly_mesh = NULL; return &mDefaultVec;};
-	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh){index = 0; poly_mesh = NULL; return NULL;};
+	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh){return LLVector4a(0.001f, 0.001f, 0.001f);}
+	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh){index = 0; poly_mesh = NULL; return &mDefaultVec;};
+	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh){index = 0; poly_mesh = NULL; return NULL;};
 
 protected:
 	typedef std::map<LLJoint*, LLVector3> joint_vec_map_t;
 	joint_vec_map_t mJointScales;
 	joint_vec_map_t mJointOffsets;
-	LLVector3	mDefaultVec;
+	LLVector4a	mDefaultVec;
 	// Backlink only; don't make this an LLPointer.
 	LLVOAvatar *mAvatar;
 };
diff --git a/indra/newview/llpolymorph.cpp b/indra/newview/llpolymorph.cpp
index cefd7df3fe..69109a9ab1 100644
--- a/indra/newview/llpolymorph.cpp
+++ b/indra/newview/llpolymorph.cpp
@@ -48,7 +48,7 @@ LLPolyMorphData::LLPolyMorphData(const std::string& morph_name)
 	mNumIndices = 0;
 	mCurrentIndex = 0;
 	mTotalDistortion = 0.f;
-	mAvgDistortion.zeroVec();
+	mAvgDistortion.clear();
 	mMaxDistortion = 0.f;
 	mVertexIndices = NULL;
 	mCoords = NULL;
@@ -73,9 +73,9 @@ LLPolyMorphData::LLPolyMorphData(const LLPolyMorphData &rhs) :
 {
 	const S32 numVertices = mNumIndices;
 
-	mCoords = new LLVector3[numVertices];
-	mNormals = new LLVector3[numVertices];
-	mBinormals = new LLVector3[numVertices];
+	mCoords = new LLVector4a[numVertices];
+	mNormals = new LLVector4a[numVertices];
+	mBinormals = new LLVector4a[numVertices];
 	mTexCoords = new LLVector2[numVertices];
 	mVertexIndices = new U32[numVertices];
 	
@@ -121,16 +121,16 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
 	//-------------------------------------------------------------------------
 	// allocate vertices
 	//-------------------------------------------------------------------------
-	mCoords = new LLVector3[numVertices];
-	mNormals = new LLVector3[numVertices];
-	mBinormals = new LLVector3[numVertices];
+	mCoords = new LLVector4a[numVertices];
+	mNormals = new LLVector4a[numVertices];
+	mBinormals = new LLVector4a[numVertices];
 	mTexCoords = new LLVector2[numVertices];
 	// Actually, we are allocating more space than we need for the skiplist
 	mVertexIndices = new U32[numVertices];
 	mNumIndices = 0;
 	mTotalDistortion = 0.f;
 	mMaxDistortion = 0.f;
-	mAvgDistortion.zeroVec();
+	mAvgDistortion.clear();
 	mMesh = mesh;
 
 	//-------------------------------------------------------------------------
@@ -152,36 +152,36 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
 		}
 
 
-		numRead = fread(&mCoords[v].mV, sizeof(F32), 3, fp);
-		llendianswizzle(&mCoords[v].mV, sizeof(F32), 3);
+		numRead = fread(&mCoords[v], sizeof(F32), 3, fp);
+		llendianswizzle(&mCoords[v], sizeof(F32), 3);
 		if (numRead != 3)
 		{
 			llwarns << "Can't read morph target vertex coordinates" << llendl;
 			return FALSE;
 		}
 
-		F32 magnitude = mCoords[v].magVec();
+		F32 magnitude = mCoords[v].getLength3().getF32();
 		
 		mTotalDistortion += magnitude;
-		mAvgDistortion.mV[VX] += fabs(mCoords[v].mV[VX]);
-		mAvgDistortion.mV[VY] += fabs(mCoords[v].mV[VY]);
-		mAvgDistortion.mV[VZ] += fabs(mCoords[v].mV[VZ]);
+		LLVector4a t;
+		t.setAbs(mCoords[v]);
+		mAvgDistortion.add(t);
 		
 		if (magnitude > mMaxDistortion)
 		{
 			mMaxDistortion = magnitude;
 		}
 
-		numRead = fread(&mNormals[v].mV, sizeof(F32), 3, fp);
-		llendianswizzle(&mNormals[v].mV, sizeof(F32), 3);
+		numRead = fread(&mNormals[v], sizeof(F32), 3, fp);
+		llendianswizzle(&mNormals[v], sizeof(F32), 3);
 		if (numRead != 3)
 		{
 			llwarns << "Can't read morph target normal" << llendl;
 			return FALSE;
 		}
 
-		numRead = fread(&mBinormals[v].mV, sizeof(F32), 3, fp);
-		llendianswizzle(&mBinormals[v].mV, sizeof(F32), 3);
+		numRead = fread(&mBinormals[v], sizeof(F32), 3, fp);
+		llendianswizzle(&mBinormals[v], sizeof(F32), 3);
 		if (numRead != 3)
 		{
 			llwarns << "Can't read morph target binormal" << llendl;
@@ -200,8 +200,8 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
 		mNumIndices++;
 	}
 
-	mAvgDistortion = mAvgDistortion * (1.f/(F32)mNumIndices);
-	mAvgDistortion.normVec();
+	mAvgDistortion.mul(1.f/(F32)mNumIndices);
+	mAvgDistortion.normalize3fast();
 
 	return TRUE;
 }
@@ -367,9 +367,9 @@ BOOL LLPolyMorphTarget::parseData(LLXmlTreeNode* node)
 //-----------------------------------------------------------------------------
 // getVertexDistortion()
 //-----------------------------------------------------------------------------
-LLVector3 LLPolyMorphTarget::getVertexDistortion(S32 requested_index, LLPolyMesh *mesh)
+LLVector4a LLPolyMorphTarget::getVertexDistortion(S32 requested_index, LLPolyMesh *mesh)
 {
-	if (!mMorphData || mMesh != mesh) return LLVector3::zero;
+	if (!mMorphData || mMesh != mesh) return LLVector4a::getZero();
 
 	for(U32 index = 0; index < mMorphData->mNumIndices; index++)
 	{
@@ -379,17 +379,17 @@ LLVector3 LLPolyMorphTarget::getVertexDistortion(S32 requested_index, LLPolyMesh
 		}
 	}
 
-	return LLVector3::zero;
+	return LLVector4a::getZero();
 }
 
 //-----------------------------------------------------------------------------
 // getFirstDistortion()
 //-----------------------------------------------------------------------------
-const LLVector3 *LLPolyMorphTarget::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
+const LLVector4a *LLPolyMorphTarget::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
 {
-	if (!mMorphData) return &LLVector3::zero;
+	if (!mMorphData) return &LLVector4a::getZero();
 
-	LLVector3* resultVec;
+	LLVector4a* resultVec;
 	mMorphData->mCurrentIndex = 0;
 	if (mMorphData->mNumIndices)
 	{
@@ -411,11 +411,11 @@ const LLVector3 *LLPolyMorphTarget::getFirstDistortion(U32 *index, LLPolyMesh **
 //-----------------------------------------------------------------------------
 // getNextDistortion()
 //-----------------------------------------------------------------------------
-const LLVector3 *LLPolyMorphTarget::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
+const LLVector4a *LLPolyMorphTarget::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
 {
-	if (!mMorphData) return &LLVector3::zero;
+	if (!mMorphData) return &LLVector4a::getZero();
 
-	LLVector3* resultVec;
+	LLVector4a* resultVec;
 	mMorphData->mCurrentIndex++;
 	if (mMorphData->mCurrentIndex < mMorphData->mNumIndices)
 	{
@@ -451,7 +451,7 @@ F32	LLPolyMorphTarget::getTotalDistortion()
 //-----------------------------------------------------------------------------
 // getAvgDistortion()
 //-----------------------------------------------------------------------------
-const LLVector3& LLPolyMorphTarget::getAvgDistortion()	
+const LLVector4a& LLPolyMorphTarget::getAvgDistortion()	
 {
 	if (mMorphData) 
 	{
@@ -459,7 +459,7 @@ const LLVector3& LLPolyMorphTarget::getAvgDistortion()
 	}
 	else 
 	{
-		return LLVector3::zero;
+		return LLVector4a::getZero();
 	}
 }
 
@@ -481,6 +481,8 @@ F32	LLPolyMorphTarget::getMaxDistortion()
 //-----------------------------------------------------------------------------
 // apply()
 //-----------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_APPLY_MORPH_TARGET("Apply Morph");
+
 void LLPolyMorphTarget::apply( ESex avatar_sex )
 {
 	if (!mMorphData || mNumMorphMasksPending > 0)
@@ -488,6 +490,8 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 		return;
 	}
 
+	LLFastTimer t(FTM_APPLY_MORPH_TARGET);
+
 	mLastSex = avatar_sex;
 
 	// Check for NaN condition (NaN is detected if a variable doesn't equal itself.
@@ -508,15 +512,15 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 	if (delta_weight != 0.f)
 	{
 		llassert(!mMesh->isLOD());
-		LLVector4 *coords = mMesh->getWritableCoords();
+		LLVector4a *coords = mMesh->getWritableCoords();
 
-		LLVector3 *scaled_normals = mMesh->getScaledNormals();
-		LLVector4 *normals = mMesh->getWritableNormals();
+		LLVector4a *scaled_normals = mMesh->getScaledNormals();
+		LLVector4a *normals = mMesh->getWritableNormals();
 
-		LLVector3 *scaled_binormals = mMesh->getScaledBinormals();
-		LLVector3 *binormals = mMesh->getWritableBinormals();
+		LLVector4a *scaled_binormals = mMesh->getScaledBinormals();
+		LLVector4a *binormals = mMesh->getWritableBinormals();
 
-		LLVector4 *clothing_weights = mMesh->getWritableClothingWeights();
+		LLVector4a *clothing_weights = mMesh->getWritableClothingWeights();
 		LLVector2 *tex_coords = mMesh->getWritableTexCoords();
 
 		F32 *maskWeightArray = (mVertMask) ? mVertMask->getMorphMaskWeights() : NULL;
@@ -531,31 +535,38 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 				maskWeight = maskWeightArray[vert_index_morph];
 			}
 
-			coords[vert_index_mesh] += LLVector4(mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight);
+
+			LLVector4a pos = mMorphData->mCoords[vert_index_morph];
+			pos.mul(delta_weight*maskWeight);
+			coords[vert_index_mesh].add(pos);
 
 			if (getInfo()->mIsClothingMorph && clothing_weights)
 			{
-				LLVector3 clothing_offset = mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight;
-				LLVector4* clothing_weight = &clothing_weights[vert_index_mesh];
-				clothing_weight->mV[VX] += clothing_offset.mV[VX];
-				clothing_weight->mV[VY] += clothing_offset.mV[VY];
-				clothing_weight->mV[VZ] += clothing_offset.mV[VZ];
-				clothing_weight->mV[VW] = maskWeight;
+				LLVector4a clothing_offset = mMorphData->mCoords[vert_index_morph];
+				clothing_offset.mul(delta_weight * maskWeight);
+				LLVector4a* clothing_weight = &clothing_weights[vert_index_mesh];
+				clothing_weight->add(clothing_offset);
+				clothing_weight->getF32ptr()[VW] = maskWeight;
 			}
 
 			// calculate new normals based on half angles
-			scaled_normals[vert_index_mesh] += mMorphData->mNormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR;
-			LLVector3 normalized_normal = scaled_normals[vert_index_mesh];
-			normalized_normal.normVec();
-			normals[vert_index_mesh] = LLVector4(normalized_normal);
+			LLVector4a norm = mMorphData->mNormals[vert_index_morph];
+			norm.mul(delta_weight*maskWeight*NORMAL_SOFTEN_FACTOR);
+			scaled_normals[vert_index_mesh].add(norm);
+			norm = scaled_normals[vert_index_mesh];
+			norm.normalize3fast();
+			normals[vert_index_mesh] = norm;
 
 			// calculate new binormals
-			scaled_binormals[vert_index_mesh] += mMorphData->mBinormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR;
-			LLVector3 tangent = scaled_binormals[vert_index_mesh] % normalized_normal;
-			LLVector3 normalized_binormal = normalized_normal % tangent; 
-			normalized_binormal.normVec();
-			binormals[vert_index_mesh] = normalized_binormal;
-
+			LLVector4a binorm = mMorphData->mBinormals[vert_index_morph];
+			binorm.mul(delta_weight*maskWeight*NORMAL_SOFTEN_FACTOR);
+			scaled_binormals[vert_index_mesh].add(binorm);
+			LLVector4a tangent;
+			tangent.setCross3(scaled_binormals[vert_index_mesh], norm);
+			LLVector4a& normalized_binormal = binormals[vert_index_mesh];
+			normalized_binormal.setCross3(norm, tangent); 
+			normalized_binormal.normalize3fast();
+			
 			tex_coords[vert_index_mesh] += mMorphData->mTexCoords[vert_index_morph] * delta_weight * maskWeight;
 		}
 
@@ -582,7 +593,7 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 //-----------------------------------------------------------------------------
 void	LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S32 num_components, BOOL invert)
 {
-	LLVector4 *clothing_weights = getInfo()->mIsClothingMorph ? mMesh->getWritableClothingWeights() : NULL;
+	LLVector4a *clothing_weights = getInfo()->mIsClothingMorph ? mMesh->getWritableClothingWeights() : NULL;
 
 	if (!mVertMask)
 	{
@@ -596,29 +607,47 @@ void	LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S3
 
 		if (maskWeights)
 		{
-			LLVector4 *coords = mMesh->getWritableCoords();
-			LLVector3 *scaled_normals = mMesh->getScaledNormals();
-			LLVector3 *scaled_binormals = mMesh->getScaledBinormals();
+			LLVector4a *coords = mMesh->getWritableCoords();
+			LLVector4a *scaled_normals = mMesh->getScaledNormals();
+			LLVector4a *scaled_binormals = mMesh->getScaledBinormals();
 			LLVector2 *tex_coords = mMesh->getWritableTexCoords();
 
+			LLVector4Logical clothing_mask;
+			clothing_mask.clear();
+			clothing_mask.setElement<0>();
+			clothing_mask.setElement<1>();
+			clothing_mask.setElement<2>();
+
+
 			for(U32 vert = 0; vert < mMorphData->mNumIndices; vert++)
 			{
 				F32 lastMaskWeight = mLastWeight * maskWeights[vert];
 				S32 out_vert = mMorphData->mVertexIndices[vert];
 
 				// remove effect of existing masked morph
-				coords[out_vert] -= LLVector4(mMorphData->mCoords[vert]) * lastMaskWeight;
-				scaled_normals[out_vert] -= mMorphData->mNormals[vert] * lastMaskWeight * NORMAL_SOFTEN_FACTOR;
-				scaled_binormals[out_vert] -= mMorphData->mBinormals[vert] * lastMaskWeight * NORMAL_SOFTEN_FACTOR;
+				LLVector4a t;
+				t = mMorphData->mCoords[vert];
+				t.mul(lastMaskWeight);
+				coords[out_vert].sub(t);
+
+				t = mMorphData->mNormals[vert];
+				t.mul(lastMaskWeight*NORMAL_SOFTEN_FACTOR);
+				scaled_normals[out_vert].sub(t);
+
+				t = mMorphData->mBinormals[vert];
+				t.mul(lastMaskWeight*NORMAL_SOFTEN_FACTOR);
+				scaled_binormals[out_vert].sub(t);
+
 				tex_coords[out_vert] -= mMorphData->mTexCoords[vert] * lastMaskWeight;
 
 				if (clothing_weights)
 				{
-					LLVector3 clothing_offset = mMorphData->mCoords[vert] * lastMaskWeight;
-					LLVector4* clothing_weight = &clothing_weights[out_vert];
-					clothing_weight->mV[VX] -= clothing_offset.mV[VX];
-					clothing_weight->mV[VY] -= clothing_offset.mV[VY];
-					clothing_weight->mV[VZ] -= clothing_offset.mV[VZ];
+					LLVector4a clothing_offset = mMorphData->mCoords[vert];
+					clothing_offset.mul(lastMaskWeight);
+					LLVector4a* clothing_weight = &clothing_weights[out_vert];
+					LLVector4a t;
+					t.setSub(*clothing_weight, clothing_offset);
+					clothing_weight->setSelectWithMask(clothing_mask, clothing_offset, *clothing_weight);
 				}
 			}
 		}
@@ -654,7 +683,7 @@ LLPolyVertexMask::~LLPolyVertexMask()
 //-----------------------------------------------------------------------------
 // generateMask()
 //-----------------------------------------------------------------------------
-void LLPolyVertexMask::generateMask(U8 *maskTextureData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4 *clothing_weights)
+void LLPolyVertexMask::generateMask(U8 *maskTextureData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4a *clothing_weights)
 {
 // RN debug output that uses Image Debugger (http://www.cs.unc.edu/~baxter/projects/imdebug/)
 //	BOOL debugImg = FALSE; 
@@ -698,7 +727,7 @@ void LLPolyVertexMask::generateMask(U8 *maskTextureData, S32 width, S32 height,
 
 		if (clothing_weights)
 		{
-			clothing_weights[vertIndex].mV[VW] = mWeights[index];
+			clothing_weights[vertIndex].getF32ptr()[VW] = mWeights[index];
 		}
 	}
 	mWeightsGenerated = TRUE;
diff --git a/indra/newview/llpolymorph.h b/indra/newview/llpolymorph.h
index 8a024f2e9e..46e23b7792 100644
--- a/indra/newview/llpolymorph.h
+++ b/indra/newview/llpolymorph.h
@@ -58,14 +58,14 @@ public:
 	U32					mNumIndices;
 	U32*				mVertexIndices;
 	U32					mCurrentIndex;
-	LLVector3*			mCoords;
-	LLVector3*			mNormals;
-	LLVector3*			mBinormals;
+	LLVector4a*			mCoords;
+	LLVector4a*			mNormals;
+	LLVector4a*			mBinormals;
 	LLVector2*			mTexCoords;
 
 	F32					mTotalDistortion;	// vertex distortion summed over entire morph
 	F32					mMaxDistortion;		// maximum single vertex distortion in a given morph
-	LLVector3			mAvgDistortion;		// average vertex distortion, to infer directionality of the morph
+	LLVector4a			mAvgDistortion;		// average vertex distortion, to infer directionality of the morph
 	LLPolyMeshSharedData*	mMesh;
 };
 
@@ -78,7 +78,7 @@ public:
 	LLPolyVertexMask(LLPolyMorphData* morph_data);
 	~LLPolyVertexMask();
 
-	void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4 *clothing_weights);
+	void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4a *clothing_weights);
 	F32* getMorphMaskWeights();
 
 
@@ -157,11 +157,11 @@ public:
 	
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion();
-	/*virtual*/ const LLVector3&	getAvgDistortion();
+	/*virtual*/ const LLVector4a&	getAvgDistortion();
 	/*virtual*/ F32					getMaxDistortion();
-	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
-	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
-	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
+	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
+	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
+	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
 
 	void	applyMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert);
 	void	addPendingMorphMask() { mNumMorphMasksPending++; }
diff --git a/indra/newview/lltexlayerparams.h b/indra/newview/lltexlayerparams.h
index 74c22b0cdf..2c0da60b48 100644
--- a/indra/newview/lltexlayerparams.h
+++ b/indra/newview/lltexlayerparams.h
@@ -76,11 +76,11 @@ public:
 
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion()									{ return 1.f; }
-	/*virtual*/ const LLVector3&	getAvgDistortion()										{ return mAvgDistortionVec; }
+	/*virtual*/ const LLVector4a&	getAvgDistortion()										{ return mAvgDistortionVec; }
 	/*virtual*/ F32					getMaxDistortion()										{ return 3.f; }
-	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector3(1.f, 1.f, 1.f);}
-	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
-	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
+	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector4a(1.f, 1.f, 1.f);}
+	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
+	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
 
 	// New functions
 	BOOL					render( S32 x, S32 y, S32 width, S32 height );
@@ -94,7 +94,7 @@ private:
 	LLPointer<LLImageRaw>	mStaticImageRaw;
 	BOOL					mNeedsCreateTexture;
 	BOOL					mStaticImageInvalid;
-	LLVector3				mAvgDistortionVec;
+	LLVector4a				mAvgDistortionVec;
 	F32						mCachedEffectiveWeight;
 
 public:
@@ -155,18 +155,18 @@ public:
 
 	// LLViewerVisualParam Virtual functions
 	/*virtual*/ F32					getTotalDistortion()									{ return 1.f; }
-	/*virtual*/ const LLVector3&	getAvgDistortion()										{ return mAvgDistortionVec; }
+	/*virtual*/ const LLVector4a&	getAvgDistortion()										{ return mAvgDistortionVec; }
 	/*virtual*/ F32					getMaxDistortion()										{ return 3.f; }
-	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector3(1.f, 1.f, 1.f); }
-	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
-	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
+	/*virtual*/ LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector4a(1.f, 1.f, 1.f); }
+	/*virtual*/ const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
+	/*virtual*/ const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
 
 	// New functions
 	LLColor4				getNetColor() const;
 protected:
 	virtual void onGlobalColorChanged(bool upload_bake) {}
 private:
-	LLVector3				mAvgDistortionVec;
+	LLVector4a				mAvgDistortionVec;
 };
 
 class LLTexLayerParamColorInfo : public LLViewerVisualParamInfo
diff --git a/indra/newview/llviewervisualparam.h b/indra/newview/llviewervisualparam.h
index dd7751acd7..3bc95cbfbf 100644
--- a/indra/newview/llviewervisualparam.h
+++ b/indra/newview/llviewervisualparam.h
@@ -83,11 +83,11 @@ public:
 
 	// New Virtual functions
 	virtual F32					getTotalDistortion() = 0;
-	virtual const LLVector3&	getAvgDistortion() = 0;
+	virtual const LLVector4a&	getAvgDistortion() = 0;
 	virtual F32					getMaxDistortion() = 0;
-	virtual LLVector3			getVertexDistortion(S32 index, LLPolyMesh *mesh) = 0;
-	virtual const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **mesh) = 0;
-	virtual const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **mesh) = 0;
+	virtual LLVector4a			getVertexDistortion(S32 index, LLPolyMesh *mesh) = 0;
+	virtual const LLVector4a*	getFirstDistortion(U32 *index, LLPolyMesh **mesh) = 0;
+	virtual const LLVector4a*	getNextDistortion(U32 *index, LLPolyMesh **mesh) = 0;
 	
 	// interface methods
 	F32					getDisplayOrder() const		{ return getInfo()->mEditGroupDisplayOrder; }
-- 
cgit v1.2.3


From c2d0531a0ed2236addfd5377af65efbf745892ed Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:56:36 -0400
Subject: reapply 71673401390a: MAINT-646 Knock out some extraneous performance
 timers

---
 indra/newview/llviewerobject.cpp | 4 ++--
 indra/newview/llvovolume.cpp     | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 97783d843e..890528266d 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2190,8 +2190,8 @@ BOOL LLViewerObject::isActive() const
 
 BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
-	static LLFastTimer::DeclareTimer ftm("Viewer Object");
-	LLFastTimer t(ftm);
+	//static LLFastTimer::DeclareTimer ftm("Viewer Object");
+	//LLFastTimer t(ftm);
 
 	if (mDead)
 	{
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index d1c668f984..f4cde65cdf 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -639,8 +639,8 @@ BOOL LLVOVolume::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
 	LLViewerObject::idleUpdate(agent, world, time);
 
-	static LLFastTimer::DeclareTimer ftm("Volume Idle");
-	LLFastTimer t(ftm);
+	//static LLFastTimer::DeclareTimer ftm("Volume Idle");
+	//LLFastTimer t(ftm);
 
 	if (mDead || mDrawable.isNull())
 	{
-- 
cgit v1.2.3


From 6d5381d012bd9358dfb0a83125d96bb70fa73f43 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 09:56:37 -0400
Subject: reapply 4a8388c13e56: MAINT-646 Enable /fp:fast in Visual Studio

---
 indra/cmake/00-Common.cmake | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra')

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 98eeed09b3..00baf626d2 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -69,6 +69,7 @@ if (WINDOWS)
       /Oy-
       /Zc:wchar_t-
       /arch:SSE2
+      /fp:fast
       )
      
   # Are we using the crummy Visual Studio KDU build workaround?
-- 
cgit v1.2.3


From 898e58987eb8df65d3c0889b8d23c4261eec45d0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 10:00:32 -0400
Subject: reapply b0148737d316: MAINT-646 Optimize
 LLVolumeImplFlexible::doIdleUpdate()

---
 indra/newview/llflexibleobject.cpp | 130 ++++++++++++++++++-------------------
 indra/newview/llflexibleobject.h   |   5 +-
 indra/newview/llvovolume.h         |   2 +-
 3 files changed, 69 insertions(+), 68 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 3d64ceb71d..9745bb6d64 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -65,7 +65,7 @@ LLVolumeImplFlexible::LLVolumeImplFlexible(LLViewerObject* vo, LLFlexibleObjectD
 	mFrameNum = 0;
 	mCollisionSphereRadius = 0.f;
 	mRenderRes = 1;
-
+	
 	if(mVO->mDrawable.notNull())
 	{
 		mVO->mDrawable->makeActive() ;
@@ -255,50 +255,28 @@ void LLVolumeImplFlexible::onSetVolume(const LLVolumeParams &volume_params, cons
 {
 }
 
-//---------------------------------------------------------------------------------
-// This calculates the physics of the flexible object. Note that it has to be 0
-// updated every time step. In the future, perhaps there could be an 
-// optimization similar to what Havok does for objects that are stationary. 
-//---------------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_FLEXIBLE_UPDATE("Update Flexies");
-BOOL LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
-{
-	if (mVO->mDrawable.isNull())
-	{
-		// Don't do anything until we have a drawable
-		return FALSE; // (we are not initialized or updated)
-	}
-
-	BOOL force_update = mSimulateRes == 0 ? TRUE : FALSE;
 
-	//flexible objects never go static
-	mVO->mDrawable->mQuietCount = 0;
-	if (!mVO->mDrawable->isRoot())
-	{
-		LLViewerObject* parent = (LLViewerObject*) mVO->getParent();
-		parent->mDrawable->mQuietCount = 0;
-	}
+void LLVolumeImplFlexible::updateRenderRes()
+{
+	LLDrawable* drawablep = mVO->mDrawable;
 
-	LLFastTimer ftm(FTM_FLEXIBLE_UPDATE);
-		
 	S32 new_res = mAttributes->getSimulateLOD();
 
-	//number of segments only cares about z axis
-	F32 app_angle = llround((F32) atan2( mVO->getScale().mV[2]*2.f, mVO->mDrawable->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f);
+#if 1 //optimal approximation of previous behavior that doesn't rely on atan2
+	F32 app_angle = mVO->getScale().mV[2]/drawablep->mDistanceWRTCamera;
 
 	// Rendering sections increases with visible angle on the screen
-	mRenderRes = (S32)(FLEXIBLE_OBJECT_MAX_SECTIONS*4*app_angle*DEG_TO_RAD/LLViewerCamera::getInstance()->getView());
-	if (mRenderRes > FLEXIBLE_OBJECT_MAX_SECTIONS)
-	{
-		mRenderRes = FLEXIBLE_OBJECT_MAX_SECTIONS;
-	}
-
+	mRenderRes = (S32) (12.f*app_angle);
+#else //legacy behavior
+	//number of segments only cares about z axis
+	F32 app_angle = llround((F32) atan2( mVO->getScale().mV[2]*2.f, drawablep->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f);
 
-	// Bottom cap at 1/4 the original number of sections
-	if (mRenderRes < mAttributes->getSimulateLOD()-1)
-	{
-		mRenderRes = mAttributes->getSimulateLOD()-1;
-	}
+ 	// Rendering sections increases with visible angle on the screen
+	mRenderRes = (S32)(FLEXIBLE_OBJECT_MAX_SECTIONS*4*app_angle*DEG_TO_RAD/LLViewerCamera::getInstance()->getView());
+#endif
+		
+	mRenderRes = llclamp(mRenderRes, new_res-1, (S32) FLEXIBLE_OBJECT_MAX_SECTIONS);
+		
 	// Throttle back simulation of segments we're not rendering
 	if (mRenderRes < new_res)
 	{
@@ -311,43 +289,65 @@ BOOL LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F6
 		setAttributesOfAllSections();
 		mInitialized = TRUE;
 	}
-	if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE))
-	{
-		return FALSE; // (we are not initialized or updated)
-	}
-
-	bool visible = mVO->mDrawable->isVisible();
+}
+//---------------------------------------------------------------------------------
+// This calculates the physics of the flexible object. Note that it has to be 0
+// updated every time step. In the future, perhaps there could be an 
+// optimization similar to what Havok does for objects that are stationary. 
+//---------------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_FLEXIBLE_UPDATE("Update Flexies");
+void LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
+{
+	LLDrawable* drawablep = mVO->mDrawable;
 
-	if (force_update && visible)
-	{
-		gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_POSITION, FALSE);
-	}
-	else if	(visible &&
-		!mVO->mDrawable->isState(LLDrawable::IN_REBUILD_Q1) &&
-		mVO->getPixelArea() > 256.f)
+	if (drawablep)
 	{
-		U32 id;
-		F32 pixel_area = mVO->getPixelArea();
+		//LLFastTimer ftm(FTM_FLEXIBLE_UPDATE);
 
-		if (mVO->isRootEdit())
+		//flexible objects never go static
+		drawablep->mQuietCount = 0;
+		if (!drawablep->isRoot())
 		{
-			id = mID;
+			LLViewerObject* parent = (LLViewerObject*) mVO->getParent();
+			parent->mDrawable->mQuietCount = 0;
 		}
-		else
+
+		if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE))
 		{
-			LLVOVolume* parent = (LLVOVolume*) mVO->getParent();
-			id = parent->getVolumeInterfaceID();
-		}
+			bool visible = drawablep->isVisible();
 
-		U32 update_period = (U32) (LLViewerCamera::getInstance()->getScreenPixelArea()*0.01f/(pixel_area*(sUpdateFactor+1.f)))+1;
+			if ((mSimulateRes == 0) && visible)
+			{
+				updateRenderRes();
+				gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE);
+			}
+			else if	(visible &&
+				!drawablep->isState(LLDrawable::IN_REBUILD_Q1) &&
+				mVO->getPixelArea() > 256.f)
+			{
+				U32 id;
+				F32 pixel_area = mVO->getPixelArea();
 
-		if ((LLDrawable::getCurrentFrame()+id)%update_period == 0)
-		{
-			gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_POSITION, FALSE);
+				if (mVO->isRootEdit())
+				{
+					id = mID;
+				}
+				else
+				{
+					LLVOVolume* parent = (LLVOVolume*) mVO->getParent();
+					id = parent->getVolumeInterfaceID();
+				}
+
+				U32 update_period = (U32) (LLViewerCamera::getInstance()->getScreenPixelArea()*0.01f/(pixel_area*(sUpdateFactor+1.f)))+1;
+
+				if ((LLDrawable::getCurrentFrame()+id)%update_period == 0)
+				{
+					updateRenderRes();
+					gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE);
+				}
+			}
 		}
 	}
-	
-	return force_update;
 }
 
 inline S32 log2(S32 x)
diff --git a/indra/newview/llflexibleobject.h b/indra/newview/llflexibleobject.h
index 371d6a0773..56d579d86f 100644
--- a/indra/newview/llflexibleobject.h
+++ b/indra/newview/llflexibleobject.h
@@ -78,7 +78,8 @@ class LLVolumeImplFlexible : public LLVolumeInterface
 		LLVector3 getFramePosition() const;
 		LLQuaternion getFrameRotation() const;
 		LLVolumeInterfaceType getInterfaceType() const		{ return INTERFACE_FLEXIBLE; }
-		BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
+		void updateRenderRes();
+		void doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 		BOOL doUpdateGeometry(LLDrawable *drawable);
 		LLVector3 getPivotPosition() const;
 		void onSetVolume(const LLVolumeParams &volume_params, const S32 detail);
@@ -128,7 +129,7 @@ class LLVolumeImplFlexible : public LLVolumeInterface
 		LLVector3					mCollisionSpherePosition;
 		F32							mCollisionSphereRadius;
 		U32							mID;
-
+		
 		//--------------------------------------
 		// private methods
 		//--------------------------------------
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 25fe085421..798927a45f 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -68,7 +68,7 @@ class LLVolumeInterface
 public:
 	virtual ~LLVolumeInterface() { }
 	virtual LLVolumeInterfaceType getInterfaceType() const = 0;
-	virtual BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) = 0;
+	virtual void doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) = 0;
 	virtual BOOL doUpdateGeometry(LLDrawable *drawable) = 0;
 	virtual LLVector3 getPivotPosition() const = 0;
 	virtual void onSetVolume(const LLVolumeParams &volume_params, const S32 detail) = 0;
-- 
cgit v1.2.3


From b4c8a982fc863debe28407d4cc3519b111309725 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 10:00:53 -0400
Subject: reapply fde2ac0276e2: MAINT-646 Get rid of a hotspot in
 LLViewerObjectList::update, fix for error in llpolymorph

---
 indra/newview/llpolymorph.cpp        |  2 +-
 indra/newview/llviewerobject.cpp     |  9 +++--
 indra/newview/llviewerobject.h       |  5 +++
 indra/newview/llviewerobjectlist.cpp | 66 ++++++++++++++++++++++++++++--------
 indra/newview/llviewerobjectlist.h   |  4 ++-
 5 files changed, 66 insertions(+), 20 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llpolymorph.cpp b/indra/newview/llpolymorph.cpp
index 69109a9ab1..d25d1420ee 100644
--- a/indra/newview/llpolymorph.cpp
+++ b/indra/newview/llpolymorph.cpp
@@ -647,7 +647,7 @@ void	LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S3
 					LLVector4a* clothing_weight = &clothing_weights[out_vert];
 					LLVector4a t;
 					t.setSub(*clothing_weight, clothing_offset);
-					clothing_weight->setSelectWithMask(clothing_mask, clothing_offset, *clothing_weight);
+					clothing_weight->setSelectWithMask(clothing_mask, t, *clothing_weight);
 				}
 			}
 		}
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 890528266d..1447f133e6 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -199,6 +199,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mID(id),
 	mLocalID(0),
 	mTotalCRC(0),
+	mListIndex(-1),
 	mTEImages(NULL),
 	mGLName(0),
 	mbCanSelect(TRUE),
@@ -4811,9 +4812,11 @@ void LLViewerObject::deleteParticleSource()
 // virtual
 void LLViewerObject::updateDrawable(BOOL force_damped)
 {
-	if (mDrawable.notNull() && 
-		!mDrawable->isState(LLDrawable::ON_MOVE_LIST) &&
-		isChanged(MOVED))
+	if (!isChanged(MOVED))
+	{ //most common case, having an empty if case here makes for better branch prediction
+	}
+	else if (mDrawable.notNull() && 
+		!mDrawable->isState(LLDrawable::ON_MOVE_LIST))
 	{
 		BOOL damped_motion = 
 			!isChanged(SHIFTED) &&										// not shifted between regions this frame and...
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index fbf6361ffb..6f5f7aae42 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -232,6 +232,8 @@ public:
 	const LLUUID &getID() const						{ return mID; }
 	U32 getLocalID() const							{ return mLocalID; }
 	U32 getCRC() const								{ return mTotalCRC; }
+	S32 getListIndex() const						{ return mListIndex; }
+	void setListIndex(S32 idx)						{ mListIndex = idx; }
 
 	virtual BOOL isFlexible() const					{ return FALSE; }
 	virtual BOOL isSculpted() const 				{ return FALSE; }
@@ -606,6 +608,9 @@ public:
 	// Last total CRC received from sim, used for caching
 	U32				mTotalCRC;
 
+	// index into LLViewerObjectList::mActiveObjects or -1 if not in list
+	S32				mListIndex;
+
 	LLPointer<LLViewerTexture> *mTEImages;
 
 	// Selection, picking and rendering variables
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 28298cedf9..8f75ba322e 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -914,21 +914,30 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	LLViewerObject *objectp = NULL;	
 	
 	// Make a copy of the list in case something in idleUpdate() messes with it
-	std::vector<LLViewerObject*> idle_list;
-	
+	static std::vector<LLViewerObject*> idle_list;
+
+	U32 idle_count = 0;
+		
 	static LLFastTimer::DeclareTimer idle_copy("Idle Copy");
 
 	{
 		LLFastTimer t(idle_copy);
-		idle_list.reserve( mActiveObjects.size() );
-
- 		for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
+		
+ 		for (std::vector<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
 			active_iter != mActiveObjects.end(); active_iter++)
 		{
 			objectp = *active_iter;
 			if (objectp)
 			{
-				idle_list.push_back( objectp );
+				if (idle_count >= idle_list.size())
+				{
+					idle_list.push_back( objectp );
+				}
+				else
+				{
+					idle_list[idle_count] = objectp;
+				}
+				++idle_count;
 			}
 			else
 			{	// There shouldn't be any NULL pointers in the list, but they have caused
@@ -938,10 +947,13 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 		}
 	}
 
+	std::vector<LLViewerObject*>::iterator idle_end = idle_list.begin()+idle_count;
+
 	if (gSavedSettings.getBOOL("FreezeTime"))
 	{
+		
 		for (std::vector<LLViewerObject*>::iterator iter = idle_list.begin();
-			iter != idle_list.end(); iter++)
+			iter != idle_end; iter++)
 		{
 			objectp = *iter;
 			if (objectp->isAvatar())
@@ -953,17 +965,17 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	else
 	{
 		for (std::vector<LLViewerObject*>::iterator idle_iter = idle_list.begin();
-			idle_iter != idle_list.end(); idle_iter++)
+			idle_iter != idle_end; idle_iter++)
 		{
 			objectp = *idle_iter;
-			if (!objectp->idleUpdate(agent, world, frame_time))
+			if (objectp->idleUpdate(agent, world, frame_time))
 			{
-				//  If Idle Update returns false, kill object!
-				kill_list.push_back(objectp);
+				num_active_objects++;				
 			}
 			else
 			{
-				num_active_objects++;
+				//  If Idle Update returns false, kill object!
+				kill_list.push_back(objectp);
 			}
 		}
 		for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin();
@@ -1201,7 +1213,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 	{
 		//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list in cleanupReferences." << llendl;
 		objectp->setOnActiveList(FALSE);
-		mActiveObjects.erase(objectp);
+		removeFromActiveList(objectp);
 	}
 
 	if (objectp->isOnMap())
@@ -1378,6 +1390,26 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer)
 	mNumDeadObjects = 0;
 }
 
+void LLViewerObjectList::removeFromActiveList(LLViewerObject* objectp)
+{
+	S32 idx = objectp->getListIndex();
+	if (idx != -1)
+	{ //remove by moving last element to this object's position
+		llassert(mActiveObjects[idx] == objectp);
+		
+		objectp->setListIndex(-1);
+
+		S32 last_index = mActiveObjects.size()-1;
+
+		if (idx != last_index)
+		{
+			mActiveObjects[idx] = mActiveObjects[last_index];
+			mActiveObjects[idx]->setListIndex(idx);
+			mActiveObjects.pop_back();
+		}
+	}
+}
+
 void LLViewerObjectList::updateActive(LLViewerObject *objectp)
 {
 	LLMemType mt(LLMemType::MTYPE_OBJECT);
@@ -1392,13 +1424,17 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
 		if (active)
 		{
 			//llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl;
-			mActiveObjects.insert(objectp);
+			llassert(objectp->getListIndex() == -1);
+
+			mActiveObjects.push_back(objectp);
+			objectp->setListIndex(mActiveObjects.size()-1);
+
 			objectp->setOnActiveList(TRUE);
 		}
 		else
 		{
 			//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << llendl;
-			mActiveObjects.erase(objectp);
+			removeFromActiveList(objectp);
 			objectp->setOnActiveList(FALSE);
 		}
 	}
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 64925f46ae..9936432a71 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -118,7 +118,9 @@ public:
 
 	void dirtyAllObjectInventory();
 
+	void removeFromActiveList(LLViewerObject* objectp);
 	void updateActive(LLViewerObject *objectp);
+	
 	void updateAvatarVisibility();
 
 	// Selection related stuff
@@ -197,7 +199,7 @@ protected:
 	typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
 
 	vobj_list_t mObjects;
-	std::set<LLPointer<LLViewerObject> > mActiveObjects;
+	std::vector<LLPointer<LLViewerObject> > mActiveObjects;
 
 	vobj_list_t mMapObjects;
 
-- 
cgit v1.2.3


From 8d3885f3bdca588efdef35e5d9c78d20036e81a9 Mon Sep 17 00:00:00 2001
From: "simon@Simon-PC.lindenlab.com" <simon@Simon-PC.lindenlab.com>
Date: Thu, 20 Sep 2012 10:00:54 -0400
Subject: reapply 8a625610cd5d: MAINT-1161:  non standard sea level not
 correctly rendered around private islands. Reviewed by Kelly

---
 indra/newview/llsurface.cpp | 2 +-
 indra/newview/llworld.cpp   | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp
index 65393cc168..94907ee4cc 100644
--- a/indra/newview/llsurface.cpp
+++ b/indra/newview/llsurface.cpp
@@ -294,7 +294,7 @@ void LLSurface::initTextures()
 		mWaterObjp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, mRegionp);
 		gPipeline.createObject(mWaterObjp);
 		LLVector3d water_pos_global = from_region_handle(mRegionp->getHandle());
-		water_pos_global += LLVector3d(128.0, 128.0, DEFAULT_WATER_HEIGHT);
+		water_pos_global += LLVector3d(128.0, 128.0, DEFAULT_WATER_HEIGHT);		// region doesn't have a valid water height yet
 		mWaterObjp->setPositionGlobal(water_pos_global);
 	}
 }
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index b061c90d98..1a9ff608e0 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -837,6 +837,9 @@ void LLWorld::updateWaterObjects()
 	}
 	mHoleWaterObjects.clear();
 
+	// Use the water height of the region we're on for areas where there is no region
+	F32 water_height = gAgent.getRegion()->getWaterHeight();
+
 	// Now, get a list of the holes
 	S32 x, y;
 	for (x = min_x; x <= max_x; x += rwidth)
@@ -845,12 +848,12 @@ void LLWorld::updateWaterObjects()
 		{
 			U64 region_handle = to_region_handle(x, y);
 			if (!getRegionFromHandle(region_handle))
-			{
+			{	// No region at that area, so make water
 				LLVOWater* waterp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, gAgent.getRegion());
 				waterp->setUseTexture(FALSE);
 				waterp->setPositionGlobal(LLVector3d(x + rwidth/2,
 													 y + rwidth/2,
-													 256.f+DEFAULT_WATER_HEIGHT));
+													 256.f + water_height));
 				waterp->setScale(LLVector3((F32)rwidth, (F32)rwidth, 512.f));
 				gPipeline.createObject(waterp);
 				mHoleWaterObjects.push_back(waterp);
@@ -907,7 +910,7 @@ void LLWorld::updateWaterObjects()
 		}
 
 		waterp->setRegion(gAgent.getRegion());
-		LLVector3d water_pos(water_center_x, water_center_y, 256.f+DEFAULT_WATER_HEIGHT) ;
+		LLVector3d water_pos(water_center_x, water_center_y, 256.f + water_height) ;
 		LLVector3 water_scale((F32) dim[0], (F32) dim[1], 512.f);
 
 		//stretch out to horizon
-- 
cgit v1.2.3


From 683c43c2e0f6e4d34592528c219f34f638059223 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 10:00:55 -0400
Subject: reapply 448b02f5b56f: MAINT-1147 Fix for frame stall on region
 crossing.

---
 indra/llrender/llimagegl.cpp         |   2 +
 indra/llrender/llrendertarget.cpp    |  36 +++++
 indra/llrender/llrendertarget.h      |   8 +-
 indra/newview/lldrawable.cpp         |  25 +++-
 indra/newview/lldrawpool.cpp         |  42 ------
 indra/newview/lldrawpool.h           |   4 -
 indra/newview/lldrawpoolterrain.cpp  |  28 ++++
 indra/newview/lldrawpoolterrain.h    |   1 +
 indra/newview/lldrawpooltree.cpp     |  15 ++
 indra/newview/llspatialpartition.cpp |  11 +-
 indra/newview/llsurface.cpp          |   6 +
 indra/newview/llsurfacepatch.cpp     |  14 +-
 indra/newview/llviewerdisplay.cpp    |  32 ++++-
 indra/newview/llviewermessage.cpp    |   2 +
 indra/newview/llviewerobjectlist.cpp |  39 +++++-
 indra/newview/llviewerregion.cpp     |   3 +-
 indra/newview/llviewerwindow.cpp     |   3 +
 indra/newview/llvoavatar.cpp         |   6 +-
 indra/newview/llvotree.cpp           |   6 +-
 indra/newview/llworld.cpp            |   5 +-
 indra/newview/pipeline.cpp           | 258 ++++++++++++++++++++++-------------
 21 files changed, 369 insertions(+), 177 deletions(-)

(limited to 'indra')

diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 659d3ca409..a842211764 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -237,9 +237,11 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat)
 
 //----------------------------------------------------------------------------
 
+static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_STATS("Image Stats");
 // static
 void LLImageGL::updateStats(F32 current_time)
 {
+	LLFastTimer t(FTM_IMAGE_UPDATE_STATS);
 	sLastFrameTime = current_time;
 	sBoundTextureMemoryInBytes = sCurBoundTextureMemory;
 	sCurBoundTextureMemory = 0;
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 99f0da330c..cc5c232380 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -69,6 +69,42 @@ LLRenderTarget::~LLRenderTarget()
 	release();
 }
 
+void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt)
+{ 
+	//for accounting, get the number of pixels added/subtracted
+	S32 pix_diff = (resx*resy)-(mResX*mResY);
+		
+	mResX = resx;
+	mResY = resy;
+
+	for (U32 i = 0; i < mTex.size(); ++i)
+	{ //resize color attachments
+		gGL.getTexUnit(0)->bindManual(mUsage, mTex[i]);
+		LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false);
+		sBytesAllocated += pix_diff*4;
+	}
+
+	if (mDepth)
+	{ //resize depth attachment
+		if (mStencil)
+		{
+			//use render buffers where stencil buffers are in play
+			glBindRenderbuffer(GL_RENDERBUFFER, mDepth);
+			glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, mResX, mResY);
+			glBindRenderbuffer(GL_RENDERBUFFER, 0);
+		}
+		else
+		{
+			gGL.getTexUnit(0)->bindManual(mUsage, mDepth);
+			U32 internal_type = LLTexUnit::getInternalType(mUsage);
+			LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL, false);
+		}
+
+		sBytesAllocated += pix_diff*4;
+	}
+}
+	
+
 bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples)
 {
 	stop_glerror();
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h
index 8360458840..e1a51304f1 100644
--- a/indra/llrender/llrendertarget.h
+++ b/indra/llrender/llrendertarget.h
@@ -57,8 +57,6 @@
 
 */
 
-class LLMultisampleBuffer;
-
 class LLRenderTarget
 {
 public:
@@ -74,6 +72,12 @@ public:
 	//multiple calls will release previously allocated resources
 	bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, bool use_fbo = false, S32 samples = 0);
 
+	//resize existing attachments to use new resolution and color format
+	// CAUTION: if the GL runs out of memory attempting to resize, this render target will be undefined
+	// DO NOT use for screen space buffers or for scratch space for an image that might be uploaded
+	// DO use for render targets that resize often and aren't likely to ruin someone's day if they break
+	void resize(U32 resx, U32 resy, U32 color_fmt);
+
 	//add color buffer attachment
 	//limit of 4 color attachments per render target
 	bool addColorAttachment(U32 color_fmt);
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 4435e04b6c..25603ccdcf 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -57,6 +57,8 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 
 static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
 
+extern bool gShiftFrame;
+
 
 ////////////////////////
 //
@@ -716,6 +718,11 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 		return;
 	}
 
+	if (gShiftFrame)
+	{
+		return;
+	}
+
 	//switch LOD with the spatial group to avoid artifacts
 	//LLSpatialGroup* sg = getSpatialGroup();
 
@@ -813,14 +820,19 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 		mXform.setPosition(mVObjp->getPositionAgent());
 	}
 
-	mXform.setRotation(mVObjp->getRotation());
-	mXform.setScale(1,1,1);
 	mXform.updateMatrix();
 
 	if (isStatic())
 	{
 		LLVOVolume* volume = getVOVolume();
-		if (!volume)
+
+		bool rebuild = (!volume && 
+						getRenderType() != LLPipeline::RENDER_TYPE_TREE &&
+						getRenderType() != LLPipeline::RENDER_TYPE_TERRAIN &&
+						getRenderType() != LLPipeline::RENDER_TYPE_SKY &&
+						getRenderType() != LLPipeline::RENDER_TYPE_GROUND);
+
+		if (rebuild)
 		{
 			gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE);
 		}
@@ -834,7 +846,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 				facep->mExtents[0].add(shift_vector);
 				facep->mExtents[1].add(shift_vector);
 			
-				if (!volume && facep->hasGeometry())
+				if (rebuild && facep->hasGeometry())
 				{
 					facep->clearVertexBuffer();
 				}
@@ -1394,6 +1406,11 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 		markDead();
 		return;
 	}
+	
+	if (gShiftFrame)
+	{
+		return;
+	}
 
 	if (mDrawable->getVObj())
 	{
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index 859c561a6d..013c698445 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -254,48 +254,6 @@ void LLFacePool::dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures
 {
 }
 
-// static
-S32 LLFacePool::drawLoop(face_array_t& face_list)
-{
-	S32 res = 0;
-	if (!face_list.empty())
-	{
-		for (std::vector<LLFace*>::iterator iter = face_list.begin();
-			 iter != face_list.end(); iter++)
-		{
-			LLFace *facep = *iter;
-			res += facep->renderIndexed();
-		}
-	}
-	return res;
-}
-
-// static
-S32 LLFacePool::drawLoopSetTex(face_array_t& face_list, S32 stage)
-{
-	S32 res = 0;
-	if (!face_list.empty())
-	{
-		for (std::vector<LLFace*>::iterator iter = face_list.begin();
-			 iter != face_list.end(); iter++)
-		{
-			LLFace *facep = *iter;
-			gGL.getTexUnit(stage)->bind(facep->getTexture(), TRUE) ;
-			gGL.getTexUnit(0)->activate();
-			res += facep->renderIndexed();
-		}
-	}
-	return res;
-}
-
-void LLFacePool::drawLoop()
-{
-	if (!mDrawFace.empty())
-	{
-		drawLoop(mDrawFace);
-	}
-}
-
 void LLFacePool::enqueue(LLFace* facep)
 {
 	mDrawFace.push_back(facep);
diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index 977acf7aec..ab9bb9e611 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -190,10 +190,6 @@ public:
 
 	void buildEdges();
 
-	static S32 drawLoop(face_array_t& face_list);
-	static S32 drawLoopSetTex(face_array_t& face_list, S32 stage);
-	void drawLoop();
-
 	void addFaceReference(LLFace *facep);
 	void removeFaceReference(LLFace *facep);
 
diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp
index b95d8296fa..7fc78fb382 100644
--- a/indra/newview/lldrawpoolterrain.cpp
+++ b/indra/newview/lldrawpoolterrain.cpp
@@ -294,6 +294,34 @@ void LLDrawPoolTerrain::renderShadow(S32 pass)
 	//glCullFace(GL_BACK);
 }
 
+
+void LLDrawPoolTerrain::drawLoop()
+{
+	if (!mDrawFace.empty())
+	{
+		for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+			 iter != mDrawFace.end(); iter++)
+		{
+			LLFace *facep = *iter;
+
+			LLMatrix4* model_matrix = &(facep->getDrawable()->getRegion()->mRenderMatrix);
+
+			if (model_matrix != gGLLastMatrix)
+			{
+				gGLLastMatrix = model_matrix;
+				gGL.loadMatrix(gGLModelView);
+				if (model_matrix)
+				{
+					gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
+				}
+				gPipeline.mMatrixOpCount++;
+			}
+
+			facep->renderIndexed();
+		}
+	}
+}
+
 void LLDrawPoolTerrain::renderFullShader()
 {
 	// Hack! Get the region that this draw pool is rendering from!
diff --git a/indra/newview/lldrawpoolterrain.h b/indra/newview/lldrawpoolterrain.h
index 283ed87f1a..2163d087e1 100644
--- a/indra/newview/lldrawpoolterrain.h
+++ b/indra/newview/lldrawpoolterrain.h
@@ -83,6 +83,7 @@ protected:
 	void renderFull2TU();
 	void renderFull4TU();
 	void renderFullShader();
+	void drawLoop();
 };
 
 #endif // LL_LLDRAWPOOLSIMPLE_H
diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp
index 3165a3516c..83f04e45a8 100644
--- a/indra/newview/lldrawpooltree.cpp
+++ b/indra/newview/lldrawpooltree.cpp
@@ -37,6 +37,7 @@
 #include "llviewershadermgr.h"
 #include "llrender.h"
 #include "llviewercontrol.h"
+#include "llviewerregion.h"
 
 S32 LLDrawPoolTree::sDiffTex = 0;
 static LLGLSLShader* shader = NULL;
@@ -104,8 +105,22 @@ void LLDrawPoolTree::render(S32 pass)
 	{
 		LLFace *face = *iter;
 		LLVertexBuffer* buff = face->getVertexBuffer();
+
 		if(buff)
 		{
+			LLMatrix4* model_matrix = &(face->getDrawable()->getRegion()->mRenderMatrix);
+
+			if (model_matrix != gGLLastMatrix)
+			{
+				gGLLastMatrix = model_matrix;
+				gGL.loadMatrix(gGLModelView);
+				if (model_matrix)
+				{
+					gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
+				}
+				gPipeline.mMatrixOpCount++;
+			}
+
 			buff->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
 			buff->drawRange(LLRender::TRIANGLES, 0, buff->getNumVerts()-1, buff->getNumIndices(), 0); 
 			gPipeline.addTrianglesDrawn(buff->getNumIndices());
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 70bafc8b2e..d4a3e9d8f5 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -68,6 +68,7 @@ const F32 SG_OCCLUSION_FUDGE = 0.25f;
 #define assert_states_valid(x)
 #endif
 
+extern bool gShiftFrame;
 
 static U32 sZombieGroups = 0;
 U32 LLSpatialGroup::sNodeCount = 0;
@@ -924,7 +925,10 @@ void LLSpatialGroup::shift(const LLVector4a &offset)
 	mObjectExtents[0].add(offset);
 	mObjectExtents[1].add(offset);
 
-	if (!mSpatialPartition->mRenderByGroup)
+	if (!mSpatialPartition->mRenderByGroup && 
+		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TREE &&
+		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TERRAIN &&
+		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_BRIDGE)
 	{
 		setState(GEOM_DIRTY);
 		gPipeline.markRebuild(this, TRUE);
@@ -1241,6 +1245,11 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 		return;
 	}
 
+	if (gShiftFrame)
+	{
+		return;
+	}
+
 #if !LL_RELEASE_FOR_DOWNLOAD
 	if (isState(LLSpatialGroup::OBJECT_DIRTY))
 	{
diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp
index 94907ee4cc..f64a72a616 100644
--- a/indra/newview/llsurface.cpp
+++ b/indra/newview/llsurface.cpp
@@ -56,6 +56,7 @@
 #include "lldrawable.h"
 
 extern LLPipeline gPipeline;
+extern bool gShiftFrame;
 
 LLColor4U MAX_WATER_COLOR(0, 48, 96, 240);
 
@@ -621,6 +622,11 @@ void LLSurface::moveZ(const S32 x, const S32 y, const F32 delta)
 
 void LLSurface::updatePatchVisibilities(LLAgent &agent) 
 {
+	if (gShiftFrame)
+	{
+		return;
+	}
+
 	LLVector3 pos_region = mRegionp->getPosRegionFromGlobal(gAgentCamera.getCameraPositionGlobal());
 
 	LLSurfacePatch *patchp;
diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp
index 5077c2c7e1..a9ba2bce9c 100644
--- a/indra/newview/llsurfacepatch.cpp
+++ b/indra/newview/llsurfacepatch.cpp
@@ -43,6 +43,7 @@
 #include "lldrawpool.h"
 #include "noise.h"
 
+extern bool gShiftFrame;
 extern U64 gFrameTime;
 extern LLPipeline gPipeline;
 
@@ -218,7 +219,7 @@ void LLSurfacePatch::eval(const U32 x, const U32 y, const U32 stride, LLVector3
 	pos_agent.mV[VX] += x * mSurfacep->getMetersPerGrid();
 	pos_agent.mV[VY] += y * mSurfacep->getMetersPerGrid();
 	pos_agent.mV[VZ]  = *(mDataZ + point_offset);
-	*vertex     = pos_agent;
+	*vertex     = pos_agent-mVObjp->getRegion()->getOriginAgent();
 
 	LLVector3 rel_pos = pos_agent - mSurfacep->getOriginAgent();
 	LLVector3 tex_pos = rel_pos * (1.f/surface_stride);
@@ -366,10 +367,13 @@ void LLSurfacePatch::updateCameraDistanceRegion(const LLVector3 &pos_region)
 {
 	if (LLPipeline::sDynamicLOD)
 	{
-		LLVector3 dv = pos_region;
-		dv -= mCenterRegion;
-		mVisInfo.mDistance = llmax(0.f, (F32)(dv.magVec() - mRadius))/
-			llmax(LLVOSurfacePatch::sLODFactor, 0.1f);
+		if (!gShiftFrame)
+		{
+			LLVector3 dv = pos_region;
+			dv -= mCenterRegion;
+			mVisInfo.mDistance = llmax(0.f, (F32)(dv.magVec() - mRadius))/
+				llmax(LLVOSurfacePatch::sLODFactor, 0.1f);
+		}
 	}
 	else
 	{
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 9ef012ece1..d58ee05fb6 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -79,6 +79,7 @@
 #include "llpostprocess.h"
 
 extern LLPointer<LLViewerTexture> gStartTexture;
+extern bool gShiftFrame;
 
 LLPointer<LLViewerTexture> gDisconnectedImagep = NULL;
 
@@ -162,8 +163,11 @@ void display_startup()
 	glClear(GL_DEPTH_BUFFER_BIT);
 }
 
+static LLFastTimer::DeclareTimer FTM_UPDATE_CAMERA("Update Camera");
+
 void display_update_camera()
 {
+	LLFastTimer t(FTM_UPDATE_CAMERA);
 	LLMemType mt_uc(LLMemType::MTYPE_DISPLAY_UPDATE_CAMERA);
 	// TODO: cut draw distance down if customizing avatar?
 	// TODO: cut draw distance on per-parcel basis?
@@ -217,6 +221,11 @@ static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_CLASS("Class");
 static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_BUMP("Bump");
 static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_LIST("List");
 static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_DELETE("Delete");
+static LLFastTimer::DeclareTimer FTM_RESIZE_WINDOW("Resize Window");
+static LLFastTimer::DeclareTimer FTM_HUD_UPDATE("HUD Update");
+static LLFastTimer::DeclareTimer FTM_DISPLAY_UPDATE_GEOM("Update Geom");
+static LLFastTimer::DeclareTimer FTM_TEXTURE_UNBIND("Texture Unbind");
+static LLFastTimer::DeclareTimer FTM_TELEPORT_DISPLAY("Teleport Display");
 
 // Paint the display!
 void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
@@ -226,6 +235,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 	if (gWindowResized)
 	{ //skip render on frames where window has been resized
+		LLFastTimer t(FTM_RESIZE_WINDOW);
 		gGL.flush();
 		glClear(GL_COLOR_BUFFER_BIT);
 		gViewerWindow->getWindow()->swapBuffers();
@@ -362,6 +372,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 	if (gTeleportDisplay)
 	{
+		LLFastTimer t(FTM_TELEPORT_DISPLAY);
 		LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport");
 		const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived.
 
@@ -591,6 +602,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 				
 		// *TODO: merge these two methods
 		{
+			LLFastTimer t(FTM_HUD_UPDATE);
 			LLMemType mt_uh(LLMemType::MTYPE_DISPLAY_UPDATE_HUD);
 			LLHUDManager::getInstance()->updateEffects();
 			LLHUDObject::updateAll();
@@ -598,6 +610,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		}
 
 		{
+			LLFastTimer t(FTM_DISPLAY_UPDATE_GEOM);
 			LLMemType mt_ug(LLMemType::MTYPE_DISPLAY_UPDATE_GEOM);
 			const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time
 			gPipeline.createObjects(max_geom_update_time);
@@ -607,6 +620,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		}
 
 		gPipeline.updateGL();
+		
 		stop_glerror();
 
 		S32 water_clip = 0;
@@ -938,14 +952,18 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			stop_glerror();
 		}
 
-		for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++)
-		{ //dummy cleanup of any currently bound textures
-			if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE)
-			{
-				gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType());
-				gGL.getTexUnit(i)->disable();
+		{
+			LLFastTimer t(FTM_TEXTURE_UNBIND);
+			for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++)
+			{ //dummy cleanup of any currently bound textures
+				if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE)
+				{
+					gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType());
+					gGL.getTexUnit(i)->disable();
+				}
 			}
 		}
+
 		LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush");		
 		
 		if (to_texture)
@@ -1011,6 +1029,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 	display_stats();
 				
 	LLAppViewer::instance()->pingMainloopTimeout("Display:Done");
+
+	gShiftFrame = false;
 }
 
 void render_hud_attachments()
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7d7d1f3047..903f4437a7 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -134,6 +134,7 @@ static const U32 LLREQUEST_PERMISSION_THROTTLE_LIMIT	= 5;     // requests
 static const F32 LLREQUEST_PERMISSION_THROTTLE_INTERVAL	= 10.0f; // seconds
 
 extern BOOL gDebugClicks;
+extern bool gShiftFrame;
 
 // function prototypes
 bool check_offer_throttle(const std::string& from_name, bool check_only);
@@ -3930,6 +3931,7 @@ void process_avatar_init_complete(LLMessageSystem* msg, void**)
 
 void process_agent_movement_complete(LLMessageSystem* msg, void**)
 {
+	gShiftFrame = true;
 	gAgentMovementCompleted = true;
 
 	LLUUID agent_id;
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 8f75ba322e..ea20950b36 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1424,12 +1424,24 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
 		if (active)
 		{
 			//llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl;
-			llassert(objectp->getListIndex() == -1);
-
-			mActiveObjects.push_back(objectp);
-			objectp->setListIndex(mActiveObjects.size()-1);
+			S32 idx = objectp->getListIndex();
+			if (idx <= -1)
+			{
+				mActiveObjects.push_back(objectp);
+				objectp->setListIndex(mActiveObjects.size()-1);
+				objectp->setOnActiveList(TRUE);
+			}
+			else
+			{
+				llassert(idx < mActiveObjects.size());
+				llassert(mActiveObjects[idx] == objectp);
 
-			objectp->setOnActiveList(TRUE);
+				if (idx >= mActiveObjects.size() ||
+					mActiveObjects[idx] != objectp)
+				{
+					llwarns << "Invalid object list index detected!" << llendl;
+				}
+			}
 		}
 		else
 		{
@@ -1508,6 +1520,10 @@ void LLViewerObjectList::onPhysicsFlagsFetchFailure(const LLUUID& object_id)
 	mPendingPhysicsFlags.erase(object_id);
 }
 
+static LLFastTimer::DeclareTimer FTM_SHIFT_OBJECTS("Shift Objects");
+static LLFastTimer::DeclareTimer FTM_PIPELINE_SHIFT("Pipeline Shift");
+static LLFastTimer::DeclareTimer FTM_REGION_SHIFT("Region Shift");
+
 void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 {
 	// This is called when we shift our origin when we cross region boundaries...
@@ -1519,6 +1535,8 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 		return;
 	}
 
+	LLFastTimer t(FTM_SHIFT_OBJECTS);
+
 	LLViewerObject *objectp;
 	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 	{
@@ -1535,8 +1553,15 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 		}
 	}
 
-	gPipeline.shiftObjects(offset);
-	LLWorld::getInstance()->shiftRegions(offset);
+	{
+		LLFastTimer t(FTM_PIPELINE_SHIFT);
+		gPipeline.shiftObjects(offset);
+	}
+
+	{
+		LLFastTimer t(FTM_REGION_SHIFT);
+		LLWorld::getInstance()->shiftRegions(offset);
+	}
 }
 
 void LLViewerObjectList::repartitionObjects()
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 493195aaa3..05c7ef5381 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1487,7 +1487,8 @@ void LLViewerRegion::unpackRegionHandshake()
 		// all of our terrain stuff, by
 		if (compp->getParamsReady())
 		{
-			getLand().dirtyAllPatches();
+			//this line creates frame stalls on region crossing and removing it appears to have no effect
+			//getLand().dirtyAllPatches();
 		}
 		else
 		{
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 30bb787fa7..af2eec9ba8 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -4768,8 +4768,11 @@ void LLViewerWindow::requestResolutionUpdate()
 	mResDirty = true;
 }
 
+static LLFastTimer::DeclareTimer FTM_WINDOW_CHECK_SETTINGS("Window Settings");
+
 void LLViewerWindow::checkSettings()
 {
+	LLFastTimer t(FTM_WINDOW_CHECK_SETTINGS);
 	if (mStatesDirty)
 	{
 		gGL.refreshState();
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index dee19032f1..05febdf93b 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1460,8 +1460,6 @@ void LLVOAvatar::onShift(const LLVector4a& shift_vector)
 	const LLVector3& shift = reinterpret_cast<const LLVector3&>(shift_vector);
 	mLastAnimExtents[0] += shift;
 	mLastAnimExtents[1] += shift;
-	mNeedsImpostorUpdate = TRUE;
-	mNeedsAnimUpdate = TRUE;
 }
 
 void LLVOAvatar::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
@@ -5143,9 +5141,9 @@ LLJoint *LLVOAvatar::getJoint( const std::string &name )
 
 	LLJoint* jointp = NULL;
 
-	if (iter == mJointMap.end())
+	if (iter == mJointMap.end() || iter->second == NULL)
 	{ //search for joint and cache found joint in lookup table
-		LLJoint* jointp = mRoot.findJoint(name);
+		jointp = mRoot.findJoint(name);
 		mJointMap[name] = jointp;
 	}
 	else
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 3556bde9a8..337ddfb24d 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -374,7 +374,7 @@ BOOL LLVOTree::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 		// *TODO: I don't know what's so special about trees
 		// that they don't get REBUILD_POSITION automatically
 		// at a higher level.
-		const LLVector3 &this_position = getPositionAgent();
+		const LLVector3 &this_position = getPositionRegion();
 		if (this_position != mLastPosition)
 		{
 			gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION);
@@ -843,10 +843,10 @@ void LLVOTree::updateMesh()
 	LLMatrix4 matrix;
 	
 	// Translate to tree base  HACK - adjustment in Z plants tree underground
-	const LLVector3 &pos_agent = getPositionAgent();
+	const LLVector3 &pos_region = getPositionRegion();
 	//gGL.translatef(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);
 	LLMatrix4 trans_mat;
-	trans_mat.setTranslation(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);
+	trans_mat.setTranslation(pos_region.mV[VX], pos_region.mV[VY], pos_region.mV[VZ] - 0.1f);
 	trans_mat *= matrix;
 	
 	// Rotate to tree position and bend for current trunk/wind
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 1a9ff608e0..78ee3e4fd9 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -657,7 +657,10 @@ void LLWorld::updateRegions(F32 max_update_time)
 		if (did_one && max_time <= 0.f)
 			break;
 		max_time = llmin(max_time, max_update_time*.1f);
-		did_one |= regionp->idleUpdate(max_update_time);
+		if (regionp->idleUpdate(max_update_time))
+		{
+			did_one = TRUE;
+		}
 	}
 }
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 49a9b31c14..2edb5cf852 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -120,6 +120,8 @@
 //#define DEBUG_INDICES
 #endif
 
+bool gShiftFrame = false;
+
 //cached settings
 BOOL LLPipeline::RenderAvatarVP;
 BOOL LLPipeline::VertexShaderEnable;
@@ -217,7 +219,7 @@ BOOL	gDebugPipeline = FALSE;
 LLPipeline gPipeline;
 const LLMatrix4* gGLLastMatrix = NULL;
 
-LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY("Geometry");
+LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY("Render Geometry");
 LLFastTimer::DeclareTimer FTM_RENDER_GRASS("Grass");
 LLFastTimer::DeclareTimer FTM_RENDER_INVISIBLE("Invisible");
 LLFastTimer::DeclareTimer FTM_RENDER_OCCLUSION("Occlusion");
@@ -234,8 +236,13 @@ LLFastTimer::DeclareTimer FTM_RENDER_BUMP("Bump");
 LLFastTimer::DeclareTimer FTM_RENDER_FULLBRIGHT("Fullbright");
 LLFastTimer::DeclareTimer FTM_RENDER_GLOW("Glow");
 LLFastTimer::DeclareTimer FTM_GEO_UPDATE("Geo Update");
+LLFastTimer::DeclareTimer FTM_PIPELINE_CREATE("Pipeline Create");
 LLFastTimer::DeclareTimer FTM_POOLRENDER("RenderPool");
 LLFastTimer::DeclareTimer FTM_POOLS("Pools");
+LLFastTimer::DeclareTimer FTM_DEFERRED_POOLRENDER("RenderPool (Deferred)");
+LLFastTimer::DeclareTimer FTM_DEFERRED_POOLS("Pools (Deferred)");
+LLFastTimer::DeclareTimer FTM_POST_DEFERRED_POOLRENDER("RenderPool (Post)");
+LLFastTimer::DeclareTimer FTM_POST_DEFERRED_POOLS("Pools (Post)");
 LLFastTimer::DeclareTimer FTM_RENDER_BLOOM_FBO("First FBO");
 LLFastTimer::DeclareTimer FTM_STATESORT("Sort Draw State");
 LLFastTimer::DeclareTimer FTM_PIPELINE("Pipeline");
@@ -1680,7 +1687,7 @@ U32 LLPipeline::addObject(LLViewerObject *vobj)
 
 void LLPipeline::createObjects(F32 max_dtime)
 {
-	LLFastTimer ftm(FTM_GEO_UPDATE);
+	LLFastTimer ftm(FTM_PIPELINE_CREATE);
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS);
 
 	LLTimer update_timer;
@@ -2513,14 +2520,19 @@ BOOL LLPipeline::updateDrawableGeom(LLDrawable* drawablep, BOOL priority)
 
 static LLFastTimer::DeclareTimer FTM_SEED_VBO_POOLS("Seed VBO Pool");
 
+static LLFastTimer::DeclareTimer FTM_UPDATE_GL("Update GL");
+
 void LLPipeline::updateGL()
 {
-	while (!LLGLUpdate::sGLQ.empty())
 	{
-		LLGLUpdate* glu = LLGLUpdate::sGLQ.front();
-		glu->updateGL();
-		glu->mInQ = FALSE;
-		LLGLUpdate::sGLQ.pop_front();
+		LLFastTimer t(FTM_UPDATE_GL);
+		while (!LLGLUpdate::sGLQ.empty())
+		{
+			LLGLUpdate* glu = LLGLUpdate::sGLQ.front();
+			glu->updateGL();
+			glu->mInQ = FALSE;
+			LLGLUpdate::sGLQ.pop_front();
+		}
 	}
 
 	{ //seed VBO Pools
@@ -2529,11 +2541,13 @@ void LLPipeline::updateGL()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_REBUILD_PRIORITY_GROUPS("Rebuild Priority Groups");
+
 void LLPipeline::rebuildPriorityGroups()
 {
+	LLFastTimer t(FTM_REBUILD_PRIORITY_GROUPS);
 	LLTimer update_timer;
 	LLMemType mt(LLMemType::MTYPE_PIPELINE);
-	
 	assertInitialized();
 
 	gMeshRepo.notifyLoadedMeshes();
@@ -2552,7 +2566,9 @@ void LLPipeline::rebuildPriorityGroups()
 	mGroupQ1Locked = false;
 
 }
-		
+
+static LLFastTimer::DeclareTimer FTM_REBUILD_GROUPS("Rebuild Groups");
+
 void LLPipeline::rebuildGroups()
 {
 	if (mGroupQ2.empty())
@@ -2560,6 +2576,7 @@ void LLPipeline::rebuildGroups()
 		return;
 	}
 
+	LLFastTimer t(FTM_REBUILD_GROUPS);
 	mGroupQ2Locked = true;
 	// Iterate through some drawables on the non-priority build queue
 	S32 size = (S32) mGroupQ2.size();
@@ -2803,6 +2820,10 @@ void LLPipeline::markShift(LLDrawable *drawablep)
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_SHIFT_DRAWABLE("Shift Drawable");
+static LLFastTimer::DeclareTimer FTM_SHIFT_OCTREE("Shift Octree");
+static LLFastTimer::DeclareTimer FTM_SHIFT_HUD("Shift HUD");
+
 void LLPipeline::shiftObjects(const LLVector3 &offset)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS);
@@ -2815,35 +2836,46 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 	LLVector4a offseta;
 	offseta.load3(offset.mV);
 
-	for (LLDrawable::drawable_vector_t::iterator iter = mShiftList.begin();
-		 iter != mShiftList.end(); iter++)
 	{
-		LLDrawable *drawablep = *iter;
-		if (drawablep->isDead())
+		LLFastTimer t(FTM_SHIFT_DRAWABLE);
+
+		for (LLDrawable::drawable_vector_t::iterator iter = mShiftList.begin();
+			 iter != mShiftList.end(); iter++)
 		{
-			continue;
-		}	
-		drawablep->shiftPos(offseta);	
-		drawablep->clearState(LLDrawable::ON_SHIFT_LIST);
+			LLDrawable *drawablep = *iter;
+			if (drawablep->isDead())
+			{
+				continue;
+			}	
+			drawablep->shiftPos(offseta);	
+			drawablep->clearState(LLDrawable::ON_SHIFT_LIST);
+		}
+		mShiftList.resize(0);
 	}
-	mShiftList.resize(0);
 
-	for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
-			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
+	
 	{
-		LLViewerRegion* region = *iter;
-		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
+		LLFastTimer t(FTM_SHIFT_OCTREE);
+		for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
+				iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
 		{
-			LLSpatialPartition* part = region->getSpatialPartition(i);
-			if (part)
+			LLViewerRegion* region = *iter;
+			for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 			{
-				part->shift(offseta);
+				LLSpatialPartition* part = region->getSpatialPartition(i);
+				if (part)
+				{
+					part->shift(offseta);
+				}
 			}
 		}
 	}
 
-	LLHUDText::shiftAll(offset);
-	LLHUDNameTag::shiftAll(offset);
+	{
+		LLFastTimer t(FTM_SHIFT_HUD);
+		LLHUDText::shiftAll(offset);
+		LLHUDNameTag::shiftAll(offset);
+	}
 	display_update_camera();
 }
 
@@ -2876,8 +2908,10 @@ void LLPipeline::markPartitionMove(LLDrawable* drawable)
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_PROCESS_PARTITIONQ("PartitionQ");
 void LLPipeline::processPartitionQ()
 {
+	LLFastTimer t(FTM_PROCESS_PARTITIONQ);
 	for (LLDrawable::drawable_list_t::iterator iter = mPartitionQ.begin(); iter != mPartitionQ.end(); ++iter)
 	{
 		LLDrawable* drawable = *iter;
@@ -4138,7 +4172,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 	LLMemType mt_rgd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED);
 	LLFastTimer t(FTM_RENDER_GEOMETRY);
 
-	LLFastTimer t2(FTM_POOLS);
+	LLFastTimer t2(FTM_DEFERRED_POOLS);
 
 	LLGLEnable cull(GL_CULL_FACE);
 
@@ -4180,7 +4214,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 		pool_set_t::iterator iter2 = iter1;
 		if (hasRenderType(poolp->getType()) && poolp->getNumDeferredPasses() > 0)
 		{
-			LLFastTimer t(FTM_POOLRENDER);
+			LLFastTimer t(FTM_DEFERRED_POOLRENDER);
 
 			gGLLastMatrix = NULL;
 			gGL.loadMatrix(gGLModelView);
@@ -4233,7 +4267,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
 {
 	LLMemType mt_rgpd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF);
-	LLFastTimer t(FTM_POOLS);
+	LLFastTimer t(FTM_POST_DEFERRED_POOLS);
 	U32 cur_type = 0;
 
 	LLGLEnable cull(GL_CULL_FACE);
@@ -4267,7 +4301,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
 		pool_set_t::iterator iter2 = iter1;
 		if (hasRenderType(poolp->getType()) && poolp->getNumPostDeferredPasses() > 0)
 		{
-			LLFastTimer t(FTM_POOLRENDER);
+			LLFastTimer t(FTM_POST_DEFERRED_POOLRENDER);
 
 			gGLLastMatrix = NULL;
 			gGL.loadMatrix(gGLModelView);
@@ -5131,8 +5165,11 @@ void LLPipeline::renderDebug()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_REBUILD_POOLS("Rebuild Pools");
+
 void LLPipeline::rebuildPools()
 {
+	LLFastTimer t(FTM_REBUILD_POOLS);
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_REBUILD_POOLS);
 
 	assertInitialized();
@@ -6691,13 +6728,16 @@ void LLPipeline::resetVertexBuffers()
 	mResetVertexBuffers = true;
 }
 
+static LLFastTimer::DeclareTimer FTM_RESET_VB("Reset VB");
+
 void LLPipeline::doResetVertexBuffers()
 {
 	if (!mResetVertexBuffers)
 	{
 		return;
 	}
-	
+
+	LLFastTimer t(FTM_RESET_VB);
 	mResetVertexBuffers = false;
 
 	mCubeVB = NULL;
@@ -9122,6 +9162,8 @@ void LLPipeline::generateHighlight(LLCamera& camera)
 }
 
 
+static LLFastTimer::DeclareTimer FTM_GEN_SUN_SHADOW("Gen Sun Shadow");
+
 void LLPipeline::generateSunShadow(LLCamera& camera)
 {
 	if (!sRenderDeferred || RenderShadowDetail <= 0)
@@ -9129,6 +9171,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		return;
 	}
 
+	LLFastTimer t(FTM_GEN_SUN_SHADOW);
+
 	BOOL skip_avatar_update = FALSE;
 	if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson)
 	{
@@ -9891,6 +9935,12 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL textu
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_IMPOSTOR_MARK_VISIBLE("Impostor Mark Visible");
+static LLFastTimer::DeclareTimer FTM_IMPOSTOR_SETUP("Impostor Setup");
+static LLFastTimer::DeclareTimer FTM_IMPOSTOR_BACKGROUND("Impostor Background");
+static LLFastTimer::DeclareTimer FTM_IMPOSTOR_ALLOCATE("Impostor Allocate");
+static LLFastTimer::DeclareTimer FTM_IMPOSTOR_RESIZE("Impostor Resize");
+
 void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 {
 	LLMemType mt_gi(LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR);
@@ -9946,101 +9996,114 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	sImpostorRender = TRUE;
 
 	LLViewerCamera* viewer_camera = LLViewerCamera::getInstance();
-	markVisible(avatar->mDrawable, *viewer_camera);
-	LLVOAvatar::sUseImpostors = FALSE;
 
-	LLVOAvatar::attachment_map_t::iterator iter;
-	for (iter = avatar->mAttachmentPoints.begin();
-		iter != avatar->mAttachmentPoints.end();
-		++iter)
 	{
-		LLViewerJointAttachment *attachment = iter->second;
-		for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-			 attachment_iter != attachment->mAttachedObjects.end();
-			 ++attachment_iter)
+		LLFastTimer t(FTM_IMPOSTOR_MARK_VISIBLE);
+		markVisible(avatar->mDrawable, *viewer_camera);
+		LLVOAvatar::sUseImpostors = FALSE;
+
+		LLVOAvatar::attachment_map_t::iterator iter;
+		for (iter = avatar->mAttachmentPoints.begin();
+			iter != avatar->mAttachmentPoints.end();
+			++iter)
 		{
-			if (LLViewerObject* attached_object = (*attachment_iter))
+			LLViewerJointAttachment *attachment = iter->second;
+			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
+				 attachment_iter != attachment->mAttachedObjects.end();
+				 ++attachment_iter)
 			{
-				markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera);
+				if (LLViewerObject* attached_object = (*attachment_iter))
+				{
+					markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera);
+				}
 			}
 		}
 	}
 
 	stateSort(*LLViewerCamera::getInstance(), result);
 	
-	const LLVector4a* ext = avatar->mDrawable->getSpatialExtents();
-	LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset());
-
 	LLCamera camera = *viewer_camera;
-
-	camera.lookAt(viewer_camera->getOrigin(), pos, viewer_camera->getUpAxis());
-	
 	LLVector2 tdim;
+	U32 resY = 0;
+	U32 resX = 0;
 
+	{
+		LLFastTimer t(FTM_IMPOSTOR_SETUP);
+		const LLVector4a* ext = avatar->mDrawable->getSpatialExtents();
+		LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset());
 
-	LLVector4a half_height;
-	half_height.setSub(ext[1], ext[0]);
-	half_height.mul(0.5f);
+		camera.lookAt(viewer_camera->getOrigin(), pos, viewer_camera->getUpAxis());
+	
+		LLVector4a half_height;
+		half_height.setSub(ext[1], ext[0]);
+		half_height.mul(0.5f);
 
-	LLVector4a left;
-	left.load3(camera.getLeftAxis().mV);
-	left.mul(left);
-	left.normalize3fast();
+		LLVector4a left;
+		left.load3(camera.getLeftAxis().mV);
+		left.mul(left);
+		left.normalize3fast();
 
-	LLVector4a up;
-	up.load3(camera.getUpAxis().mV);
-	up.mul(up);
-	up.normalize3fast();
+		LLVector4a up;
+		up.load3(camera.getUpAxis().mV);
+		up.mul(up);
+		up.normalize3fast();
 
-	tdim.mV[0] = fabsf(half_height.dot3(left).getF32());
-	tdim.mV[1] = fabsf(half_height.dot3(up).getF32());
+		tdim.mV[0] = fabsf(half_height.dot3(left).getF32());
+		tdim.mV[1] = fabsf(half_height.dot3(up).getF32());
 
-	gGL.matrixMode(LLRender::MM_PROJECTION);
-	gGL.pushMatrix();
+		gGL.matrixMode(LLRender::MM_PROJECTION);
+		gGL.pushMatrix();
 	
-	F32 distance = (pos-camera.getOrigin()).length();
-	F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG;
-	F32 aspect = tdim.mV[0]/tdim.mV[1];
-	glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f);
-	glh_set_current_projection(persp);
-	gGL.loadMatrix(persp.m);
+		F32 distance = (pos-camera.getOrigin()).length();
+		F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG;
+		F32 aspect = tdim.mV[0]/tdim.mV[1];
+		glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f);
+		glh_set_current_projection(persp);
+		gGL.loadMatrix(persp.m);
 
-	gGL.matrixMode(LLRender::MM_MODELVIEW);
-	gGL.pushMatrix();
-	glh::matrix4f mat;
-	camera.getOpenGLTransform(mat.m);
+		gGL.matrixMode(LLRender::MM_MODELVIEW);
+		gGL.pushMatrix();
+		glh::matrix4f mat;
+		camera.getOpenGLTransform(mat.m);
 
-	mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat;
+		mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat;
 
-	gGL.loadMatrix(mat.m);
-	glh_set_current_modelview(mat);
+		gGL.loadMatrix(mat.m);
+		glh_set_current_modelview(mat);
 
-	glClearColor(0.0f,0.0f,0.0f,0.0f);
-	gGL.setColorMask(true, true);
+		glClearColor(0.0f,0.0f,0.0f,0.0f);
+		gGL.setColorMask(true, true);
 	
-	// get the number of pixels per angle
-	F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * viewer_camera->getView());
+		// get the number of pixels per angle
+		F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * viewer_camera->getView());
 
-	//get resolution based on angle width and height of impostor (double desired resolution to prevent aliasing)
-	U32 resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512);
-	U32 resX = llmin(nhpo2((U32) (atanf(tdim.mV[0]/distance)*2.f*RAD_TO_DEG*pa)), (U32) 512);
+		//get resolution based on angle width and height of impostor (double desired resolution to prevent aliasing)
+		resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512);
+		resX = llmin(nhpo2((U32) (atanf(tdim.mV[0]/distance)*2.f*RAD_TO_DEG*pa)), (U32) 512);
 
-	if (!avatar->mImpostor.isComplete() || resX != avatar->mImpostor.getWidth() ||
-		resY != avatar->mImpostor.getHeight())
-	{
-		avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,FALSE);
+		if (!avatar->mImpostor.isComplete())
+		{
+			LLFastTimer t(FTM_IMPOSTOR_ALLOCATE);
+			avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,FALSE);
+
+			if (LLPipeline::sRenderDeferred)
+			{
+				addDeferredAttachments(avatar->mImpostor);
+			}
 		
-		if (LLPipeline::sRenderDeferred)
+			gGL.getTexUnit(0)->bind(&avatar->mImpostor);
+			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
+			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+		}
+		else if(resX != avatar->mImpostor.getWidth() ||
+			resY != avatar->mImpostor.getHeight())
 		{
-			addDeferredAttachments(avatar->mImpostor);
+			LLFastTimer t(FTM_IMPOSTOR_RESIZE);
+			avatar->mImpostor.resize(resX,resY,GL_RGBA);
 		}
-		
-		gGL.getTexUnit(0)->bind(&avatar->mImpostor);
-		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
-		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-	}
 
-	avatar->mImpostor.bindTarget();
+		avatar->mImpostor.bindTarget();
+	}
 
 	if (LLPipeline::sRenderDeferred)
 	{
@@ -10057,6 +10120,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	}
 	
 	{ //create alpha mask based on depth buffer (grey out if muted)
+		LLFastTimer t(FTM_IMPOSTOR_BACKGROUND);
 		if (LLPipeline::sRenderDeferred)
 		{
 			GLuint buff = GL_COLOR_ATTACHMENT0;
-- 
cgit v1.2.3


From b5e71964e5f2b6cfa792cc30f7f694ee7096c828 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 10:00:56 -0400
Subject: reapply c77cea5c6e41: MAINT-646 Cleanup some warnings from previous
 changes.

---
 indra/newview/lldrawable.cpp         | 23 +++++++++++++++++++++--
 indra/newview/lldrawable.h           |  2 +-
 indra/newview/llface.cpp             | 22 ++++++++++++++--------
 indra/newview/llspatialpartition.cpp |  6 ++++--
 indra/newview/llvovolume.cpp         | 17 +++++++++++++----
 5 files changed, 53 insertions(+), 17 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 25603ccdcf..89a2e9f407 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -957,6 +957,12 @@ void LLDrawable::updateUVMinMax()
 {
 }
 
+LLSpatialGroup* LLDrawable::getSpatialGroup() const
+{ 
+	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
+	return mSpatialGroupp; 
+}
+
 void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 {
 /*if (mSpatialGroupp && (groupp != mSpatialGroupp))
@@ -979,6 +985,8 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 	}
 
 	mSpatialGroupp = groupp;
+
+	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
 }
 
 LLSpatialPartition* LLDrawable::getSpatialPartition()
@@ -1489,7 +1497,13 @@ void LLSpatialBridge::cleanupReferences()
 	LLDrawable::cleanupReferences();
 	if (mDrawable)
 	{
-		mDrawable->setSpatialGroup(NULL);
+		LLSpatialGroup* group = mDrawable->getSpatialGroup();
+		if (group)
+		{
+			group->mOctreeNode->remove(mDrawable);
+			mDrawable->setSpatialGroup(NULL);
+		}
+		
 		if (mDrawable->getVObj())
 		{
 			LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren();
@@ -1500,7 +1514,12 @@ void LLSpatialBridge::cleanupReferences()
 				LLDrawable* drawable = child->mDrawable;					
 				if (drawable)
 				{
-					drawable->setSpatialGroup(NULL);
+					LLSpatialGroup* group = drawable->getSpatialGroup();
+					if (group)
+					{
+						group->mOctreeNode->remove(drawable);
+						drawable->setSpatialGroup(NULL);
+					}
 				}
 			}
 		}
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 08511bb9fc..960c64fa9e 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -208,7 +208,7 @@ public:
 	S32 findReferences(LLDrawable *drawablep); // Not const because of @#$! iterators...
 
 	void setSpatialGroup(LLSpatialGroup *groupp);
-	LLSpatialGroup *getSpatialGroup() const			{ return mSpatialGroupp; }
+	LLSpatialGroup *getSpatialGroup() const;
 	LLSpatialPartition* getSpatialPartition();
 	
 	// Statics
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index eea5161538..2074cb6514 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1202,19 +1202,25 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	{
 		if (num_indices + (S32) mIndicesIndex > mVertexBuffer->getNumIndices())
 		{
-			llwarns	<< "Index buffer overflow!" << llendl;
-			llwarns << "Indices Count: " << mIndicesCount
-					<< " VF Num Indices: " << num_indices
-					<< " Indices Index: " << mIndicesIndex
-					<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
-			llwarns	<< " Face Index: " << f
-					<< " Pool Type: " << mPoolType << llendl;
+			if (gDebugGL)
+			{
+				llwarns	<< "Index buffer overflow!" << llendl;
+				llwarns << "Indices Count: " << mIndicesCount
+						<< " VF Num Indices: " << num_indices
+						<< " Indices Index: " << mIndicesIndex
+						<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
+				llwarns	<< " Face Index: " << f
+						<< " Pool Type: " << mPoolType << llendl;
+			}
 			return FALSE;
 		}
 
 		if (num_vertices + mGeomIndex > mVertexBuffer->getNumVerts())
 		{
-			llwarns << "Vertex buffer overflow!" << llendl;
+			if (gDebugGL)
+			{
+				llwarns << "Vertex buffer overflow!" << llendl;
+			}
 			return FALSE;
 		}
 	}
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index d4a3e9d8f5..78c905f6ff 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1850,12 +1850,14 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
 {
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	
-	drawablep->setSpatialGroup(NULL);
-
 	if (!curp->removeObject(drawablep))
 	{
 		OCT_ERRS << "Failed to remove drawable from octree!" << llendl;
 	}
+	else
+	{
+		drawablep->setSpatialGroup(NULL);
+	}
 
 	assert_octree_valid(mOctree);
 	
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index f4cde65cdf..0a5c8b5139 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4721,8 +4721,14 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 						if (buff)
 						{
 							llassert(!face->isState(LLFace::RIGGED));
-							face->getGeometryVolume(*volume, face->getTEOffset(), 
-								vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex());
+
+							if (!face->getGeometryVolume(*volume, face->getTEOffset(), 
+								vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex()))
+							{ //something's gone wrong with the vertex buffer accounting, rebuild this group 
+								group->dirtyGeom();
+								gPipeline.markRebuild(group, TRUE);
+							}
+
 
 							if (buff->isLocked())
 							{
@@ -5056,8 +5062,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 
 					llassert(!facep->isState(LLFace::RIGGED));
 
-					facep->getGeometryVolume(*volume, te_idx, 
-						vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true);
+					if (!facep->getGeometryVolume(*volume, te_idx, 
+						vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true))
+					{
+						llwarns << "Failed to get geometry for face!" << llendl;
+					}
 
 					if (drawablep->isState(LLDrawable::ANIMATED_CHILD))
 					{
-- 
cgit v1.2.3


From e756a1523c8ba1b36d72bf424d97c6bbfb8e9d83 Mon Sep 17 00:00:00 2001
From: "simon@Simon-PC.lindenlab.com" <simon@Simon-PC.lindenlab.com>
Date: Thu, 20 Sep 2012 10:00:57 -0400
Subject: reapply 72c9af4eec84: MAINT-840 VWR-28604 DEV-2548:  [PUBLIC]Object
 by multiple creators shows creator as "(unknown)" in Inventory.   Now shows
 "(unknown / multiple)".  Reviewed by Kelly

---
 indra/newview/llsidepaneliteminfo.cpp                      | 2 +-
 indra/newview/skins/default/xui/en/sidepanel_item_info.xml | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp
index 1ce05da849..92c2863ffd 100644
--- a/indra/newview/llsidepaneliteminfo.cpp
+++ b/indra/newview/llsidepaneliteminfo.cpp
@@ -352,7 +352,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 		getChildView("BtnCreator")->setEnabled(FALSE);
 		getChildView("LabelCreatorTitle")->setEnabled(FALSE);
 		getChildView("LabelCreatorName")->setEnabled(FALSE);
-		getChild<LLUICtrl>("LabelCreatorName")->setValue(getString("unknown"));
+		getChild<LLUICtrl>("LabelCreatorName")->setValue(getString("unknown_multiple"));
 	}
 
 	////////////////
diff --git a/indra/newview/skins/default/xui/en/sidepanel_item_info.xml b/indra/newview/skins/default/xui/en/sidepanel_item_info.xml
index 54a312bd59..c5dfb703e5 100644
--- a/indra/newview/skins/default/xui/en/sidepanel_item_info.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_item_info.xml
@@ -11,6 +11,10 @@
 		 name="unknown">
         (unknown)
 	</panel.string>
+    <panel.string
+         name="unknown_multiple">
+        (unknown / multiple)
+    </panel.string>
 	<panel.string
 		 name="public">
         (public)
-- 
cgit v1.2.3


From 60cf43bad98d620f6024c9fe3f0b48aeecad2de7 Mon Sep 17 00:00:00 2001
From: "simon@Simon-PC.lindenlab.com" <simon@Simon-PC.lindenlab.com>
Date: Thu, 20 Sep 2012 10:00:58 -0400
Subject: reapply 51dcb8c70f33: MAINT-442: [PUBLIC]Unable to change parcel
 restrictions for a scripts-disabled parcel in a damage-enabled region. 
 Reviewed by Kelly

---
 indra/newview/llfloaterland.cpp | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 61da99fe3a..df8ecb6fd9 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -2212,8 +2212,8 @@ void LLPanelLandOptions::onCommitAny(LLUICtrl *ctrl, void *userdata)
 	BOOL allow_damage		= !self->mCheckSafe->get();
 	BOOL allow_fly			= self->mCheckFly->get();
 	BOOL allow_landmark		= TRUE; // cannot restrict landmark creation
-	BOOL allow_group_scripts	= self->mCheckGroupScripts->get() || self->mCheckOtherScripts->get();
 	BOOL allow_other_scripts	= self->mCheckOtherScripts->get();
+	BOOL allow_group_scripts	= self->mCheckGroupScripts->get() || allow_other_scripts;
 	BOOL allow_publish		= FALSE;
 	BOOL mature_publish		= self->mMatureCtrl->get();
 	BOOL push_restriction	= self->mPushRestrictionCtrl->get();
@@ -2226,11 +2226,16 @@ void LLPanelLandOptions::onCommitAny(LLUICtrl *ctrl, void *userdata)
 	LLViewerRegion* region;
 	region = LLViewerParcelMgr::getInstance()->getSelectionRegion();
 
-	if (!allow_other_scripts && region && region->getAllowDamage())
-	{
-
-		LLNotificationsUtil::add("UnableToDisableOutsideScripts");
-		return;
+	if (region && region->getAllowDamage())
+	{	// Damage is allowed on the region - server will always allow scripts
+		if ( (!allow_other_scripts && parcel->getParcelFlag(PF_ALLOW_OTHER_SCRIPTS)) ||
+			 (!allow_group_scripts && parcel->getParcelFlag(PF_ALLOW_GROUP_SCRIPTS)) )
+		{	// Don't allow turning off "Run Scripts" if damage is allowed in the region
+			self->mCheckOtherScripts->set(parcel->getParcelFlag(PF_ALLOW_OTHER_SCRIPTS));	// Restore UI to actual settings
+			self->mCheckGroupScripts->set(parcel->getParcelFlag(PF_ALLOW_GROUP_SCRIPTS));
+			LLNotificationsUtil::add("UnableToDisableOutsideScripts");
+			return;
+		}
 	}
 
 	// Push data into current parcel
-- 
cgit v1.2.3


From 7fc702dc4930445b87dc2cd1d52c0cc64295f26c Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 10:00:58 -0400
Subject: reapply 04fdf7945708: MAINT-775 Fix for particle index pool
 corruption on teleport.

---
 indra/newview/llappviewer.cpp   |  4 ++++
 indra/newview/llface.cpp        |  7 ++-----
 indra/newview/llface.h          |  1 +
 indra/newview/llvopartgroup.cpp | 10 +++++++---
 indra/newview/llvopartgroup.h   |  1 +
 5 files changed, 15 insertions(+), 8 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index e8934d9a9e..cb69048c60 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -89,6 +89,7 @@
 #include "lllogininstance.h"
 #include "llprogressview.h"
 #include "llvocache.h"
+#include "llvopartgroup.h"
 #include "llweb.h"
 #include "llsecondlifeurls.h"
 #include "llupdaterservice.h"
@@ -679,6 +680,9 @@ bool LLAppViewer::init()
 	// initialize SSE options
 	LLVector4a::initClass();
 
+	//initialize particle index pool
+	LLVOPartGroup::initClass();
+
 	// Need to do this initialization before we do anything else, since anything
 	// that touches files should really go through the lldir API
 	gDirUtilp->initAppDirs("SecondLife");
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 2074cb6514..582f06eeb0 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -202,13 +202,10 @@ void LLFace::destroy()
 		mTexture->removeFace(this) ;
 	}
 	
-	if (mDrawablep.notNull() &&
-		(mDrawablep->getRenderType() == LLPipeline::RENDER_TYPE_PARTICLES ||
-		mDrawablep->getRenderType() == LLPipeline::RENDER_TYPE_HUD_PARTICLES) &&
-		mIndicesIndex != 0xFFFFFFFF)
+	if (isState(LLFace::PARTICLE))
 	{
 		LLVOPartGroup::freeVBSlot(getGeomIndex()/4);
-		mIndicesIndex = 0xFFFFFFFF;
+		clearState(LLFace::PARTICLE);
 	}
 
 	if (mDrawPoolp)
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 5dca27487f..efc3424858 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -90,6 +90,7 @@ public:
 		USE_FACE_COLOR	= 0x0010,
 		TEXTURE_ANIM	= 0x0020, 
 		RIGGED			= 0x0040,
+		PARTICLE		= 0x0080,
 	};
 
 	static void initClass();
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 02282fd6a6..9cce68fff6 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -52,8 +52,7 @@ LLPointer<LLVertexBuffer> LLVOPartGroup::sVB = NULL;
 S32 LLVOPartGroup::sVBSlotFree[];
 S32* LLVOPartGroup::sVBSlotCursor = NULL;
 
-//static
-void LLVOPartGroup::restoreGL()
+void LLVOPartGroup::initClass()
 {
 	for (S32 i = 0; i < LL_MAX_PARTICLE_COUNT; ++i)
 	{
@@ -61,7 +60,11 @@ void LLVOPartGroup::restoreGL()
 	}
 
 	sVBSlotCursor = sVBSlotFree;
+}
 
+//static
+void LLVOPartGroup::restoreGL()
+{
 	sVB = new LLVertexBuffer(VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB);
 	U32 count = LL_MAX_PARTICLE_COUNT;
 	sVB->allocateBuffer(count*4, count*6, true);
@@ -626,7 +629,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
 		LLFace* facep = *i;
 		LLAlphaObject* object = (LLAlphaObject*) facep->getViewerObject();
 
-		if (facep->getIndicesStart() == 0xFFFFFFFF)
+		if (!facep->isState(LLFace::PARTICLE))
 		{ //set the indices of this face
 			S32 idx = LLVOPartGroup::findAvailableVBSlot();
 			if (idx >= 0)
@@ -635,6 +638,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
 				facep->setIndicesIndex(idx*6);
 				facep->setVertexBuffer(LLVOPartGroup::sVB);
 				facep->setPoolType(LLDrawPool::POOL_ALPHA);
+				facep->setState(LLFace::PARTICLE);
 			}
 			else
 			{
diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h
index 6160bceb24..43b2844f07 100644
--- a/indra/newview/llvopartgroup.h
+++ b/indra/newview/llvopartgroup.h
@@ -45,6 +45,7 @@ public:
 	static S32 sVBSlotFree[LL_MAX_PARTICLE_COUNT];
 	static S32* sVBSlotCursor;
 
+	static void initClass();
 	static void restoreGL();
 	static void destroyGL();
 	static S32 findAvailableVBSlot();
-- 
cgit v1.2.3


From 5ec24ecd69986eada6e185e922df5a82bc7dd48d Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 Sep 2012 10:13:45 -0400
Subject: reapply a577ec5b3e5f: Fix for linux build (skip llhttpclient unit
 tests that post to google.com)

---
 indra/llmessage/llurlrequest.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp
index a16f5c7bf0..f3f0007205 100644
--- a/indra/llmessage/llurlrequest.cpp
+++ b/indra/llmessage/llurlrequest.cpp
@@ -289,6 +289,8 @@ LLIOPipe::EStatus LLURLRequest::handleError(
 }
 
 static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST("URL Request");
+static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST_GET_RESULT("Get Result");
+static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform");
 
 // virtual
 LLIOPipe::EStatus LLURLRequest::process_impl(
@@ -358,7 +360,6 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
 	{
 		PUMP_DEBUG;
 		LLIOPipe::EStatus status = STATUS_BREAK;
-		static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform");
 		{
 			LLFastTimer t(FTM_URL_PERFORM);
 			if(!mDetail->mCurlRequest->wait())
@@ -371,8 +372,6 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
 		{
 			CURLcode result;
 
-			static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST_GET_RESULT("Get Result");
-
 			bool newmsg = false;
 			{
 				LLFastTimer t(FTM_PROCESS_URL_REQUEST_GET_RESULT);
-- 
cgit v1.2.3


From 29cdf94e95d0a4365bd18860c4759f9a6a13f45a Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Thu, 20 Sep 2012 18:48:15 -0700
Subject: Correcting dynamic allocation issues with classes that have aligned
 data members.

---
 indra/newview/lldriverparam.h    | 10 +++++++
 indra/newview/llpolymesh.h       | 10 +++++++
 indra/newview/llpolymorph.cpp    | 60 ++++++++++++++++++++++++++++++++--------
 indra/newview/llpolymorph.h      | 13 +++++++++
 indra/newview/lltexlayerparams.h | 20 ++++++++++++++
 5 files changed, 101 insertions(+), 12 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/lldriverparam.h b/indra/newview/lldriverparam.h
index 7a4d711d4e..c0976d1d43 100644
--- a/indra/newview/lldriverparam.h
+++ b/indra/newview/lldriverparam.h
@@ -83,6 +83,16 @@ public:
 	LLDriverParam(LLWearable *wearablep);
 	~LLDriverParam();
 
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	// Special: These functions are overridden by child classes
 	LLDriverParamInfo*		getInfo() const { return (LLDriverParamInfo*)mInfo; }
 	//   This sets mInfo and calls initialization functions
diff --git a/indra/newview/llpolymesh.h b/indra/newview/llpolymesh.h
index ffb11a3f7e..850171d169 100644
--- a/indra/newview/llpolymesh.h
+++ b/indra/newview/llpolymesh.h
@@ -406,6 +406,16 @@ public:
 	LLPolySkeletalDistortion(LLVOAvatar *avatarp);
 	~LLPolySkeletalDistortion();
 
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	// Special: These functions are overridden by child classes
 	LLPolySkeletalDistortionInfo*	getInfo() const { return (LLPolySkeletalDistortionInfo*)mInfo; }
 	//   This sets mInfo and calls initialization functions
diff --git a/indra/newview/llpolymorph.cpp b/indra/newview/llpolymorph.cpp
index d25d1420ee..bd96608641 100644
--- a/indra/newview/llpolymorph.cpp
+++ b/indra/newview/llpolymorph.cpp
@@ -73,9 +73,9 @@ LLPolyMorphData::LLPolyMorphData(const LLPolyMorphData &rhs) :
 {
 	const S32 numVertices = mNumIndices;
 
-	mCoords = new LLVector4a[numVertices];
-	mNormals = new LLVector4a[numVertices];
-	mBinormals = new LLVector4a[numVertices];
+	mCoords = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
+	mNormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
+	mBinormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
 	mTexCoords = new LLVector2[numVertices];
 	mVertexIndices = new U32[numVertices];
 	
@@ -89,17 +89,12 @@ LLPolyMorphData::LLPolyMorphData(const LLPolyMorphData &rhs) :
 	}
 }
 
-
 //-----------------------------------------------------------------------------
 // ~LLPolyMorphData()
 //-----------------------------------------------------------------------------
 LLPolyMorphData::~LLPolyMorphData()
 {
-	delete [] mVertexIndices;
-	delete [] mCoords;
-	delete [] mNormals;
-	delete [] mBinormals;
-	delete [] mTexCoords;
+	freeData();
 }
 
 //-----------------------------------------------------------------------------
@@ -118,12 +113,17 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
 		return FALSE;
 	}
 
+	//-------------------------------------------------------------------------
+	// free any existing data
+	//-------------------------------------------------------------------------
+	freeData();
+
 	//-------------------------------------------------------------------------
 	// allocate vertices
 	//-------------------------------------------------------------------------
-	mCoords = new LLVector4a[numVertices];
-	mNormals = new LLVector4a[numVertices];
-	mBinormals = new LLVector4a[numVertices];
+	mCoords = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
+	mNormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
+	mBinormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
 	mTexCoords = new LLVector2[numVertices];
 	// Actually, we are allocating more space than we need for the skiplist
 	mVertexIndices = new U32[numVertices];
@@ -206,6 +206,42 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
 	return TRUE;
 }
 
+//-----------------------------------------------------------------------------
+// freeData()
+//-----------------------------------------------------------------------------
+void LLPolyMorphData::freeData()
+{
+	if (mCoords != NULL)
+	{
+		ll_aligned_free_16(mCoords);
+		mCoords = NULL;
+	}
+
+	if (mNormals != NULL)
+	{
+		ll_aligned_free_16(mNormals);
+		mNormals = NULL;
+	}
+
+	if (mBinormals != NULL)
+	{
+		ll_aligned_free_16(mBinormals);
+		mBinormals = NULL;
+	}
+
+	if (mTexCoords != NULL)
+	{
+		delete [] mTexCoords;
+		mTexCoords = NULL;
+	}
+
+	if (mVertexIndices != NULL)
+	{
+		delete [] mVertexIndices;
+		mVertexIndices = NULL;
+	}
+}
+
 //-----------------------------------------------------------------------------
 // LLPolyMorphTargetInfo()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llpolymorph.h b/indra/newview/llpolymorph.h
index 46e23b7792..678599d7e1 100644
--- a/indra/newview/llpolymorph.h
+++ b/indra/newview/llpolymorph.h
@@ -48,6 +48,16 @@ public:
 	~LLPolyMorphData();
 	LLPolyMorphData(const LLPolyMorphData &rhs);
 
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	BOOL			loadBinary(LLFILE* fp, LLPolyMeshSharedData *mesh);
 	const std::string& getName() { return mName; }
 
@@ -67,6 +77,9 @@ public:
 	F32					mMaxDistortion;		// maximum single vertex distortion in a given morph
 	LLVector4a			mAvgDistortion;		// average vertex distortion, to infer directionality of the morph
 	LLPolyMeshSharedData*	mMesh;
+
+private:
+	void freeData();
 };
 
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/lltexlayerparams.h b/indra/newview/lltexlayerparams.h
index 2c0da60b48..fffe20208f 100644
--- a/indra/newview/lltexlayerparams.h
+++ b/indra/newview/lltexlayerparams.h
@@ -67,6 +67,16 @@ public:
 
 	/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable = NULL) const;
 
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	// LLVisualParam Virtual functions
 	///*virtual*/ BOOL		parseData(LLXmlTreeNode* node);
 	/*virtual*/ void		apply( ESex avatar_sex ) {}
@@ -143,6 +153,16 @@ public:
 	LLTexLayerParamColor( LLVOAvatar* avatar );
 	/* virtual */ ~LLTexLayerParamColor();
 
+	void* operator new(size_t size)
+	{
+		return ll_aligned_malloc_16(size);
+	}
+
+	void operator delete(void* ptr)
+	{
+		ll_aligned_free_16(ptr);
+	}
+
 	/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable = NULL) const;
 
 	// LLVisualParam Virtual functions
-- 
cgit v1.2.3


From b63c21a13eb4bb5bb6630bc360de2383814816c9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 27 Sep 2012 14:13:03 -0500
Subject: Modify installer to remove libtcmalloc_minimal.dll

---
 indra/newview/viewer_manifest.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 894d2f0925..027bdbfb30 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -404,11 +404,9 @@ class WindowsManifest(ViewerManifest):
             self.path("libhunspell.dll")
 
             # For google-perftools tcmalloc allocator.
+            # no longer used, make sure old .dll is removed
             try:
-                if self.args['configuration'].lower() == 'debug':
-                    self.path('libtcmalloc_minimal-debug.dll')
-                else:
-                    self.path('libtcmalloc_minimal.dll')
+                self.remove('libtcmalloc_minimal.dll')
             except:
                 print "Skipping libtcmalloc_minimal.dll"
 
-- 
cgit v1.2.3


From 39907b9b565eafb859101e67d0a49a69e409241a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 27 Sep 2012 14:52:10 -0500
Subject: Another attempt at deleting tcmalloc_minimal.dll

---
 indra/newview/viewer_manifest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 027bdbfb30..175c6f9903 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -406,7 +406,7 @@ class WindowsManifest(ViewerManifest):
             # For google-perftools tcmalloc allocator.
             # no longer used, make sure old .dll is removed
             try:
-                self.remove('libtcmalloc_minimal.dll')
+                self.remove(self.dst_path_of('libtcmalloc_minimal.dll'))
             except:
                 print "Skipping libtcmalloc_minimal.dll"
 
-- 
cgit v1.2.3


From 603a48af9479ad119a4526a80ac24c866c2bc1c9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 27 Sep 2012 17:01:57 -0500
Subject: Yet another attempt at deleting tcmalloc

---
 indra/newview/viewer_manifest.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 175c6f9903..87366caf1b 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -404,9 +404,11 @@ class WindowsManifest(ViewerManifest):
             self.path("libhunspell.dll")
 
             # For google-perftools tcmalloc allocator.
-            # no longer used, make sure old .dll is removed
             try:
-                self.remove(self.dst_path_of('libtcmalloc_minimal.dll'))
+                if self.args['configuration'].lower() == 'debug':
+                    self.path('libtcmalloc_minimal-debug.dll')
+                else:
+                    self.path('libtcmalloc_minimal.dll')
             except:
                 print "Skipping libtcmalloc_minimal.dll"
 
@@ -535,6 +537,10 @@ class WindowsManifest(ViewerManifest):
                 result += 'File ' + pkg_file + '\n'
             else:
                 result += 'Delete ' + wpath(os.path.join('$INSTDIR', rel_file)) + '\n'
+
+        if install
+            result += 'Delete ' + wpath(os.path.join('$INSTDIR', 'libtcmalloc_minimal.dll')) + '\n'
+
         # at the end of a delete, just rmdir all the directories
         if not install:
             deleted_file_dirs = [os.path.dirname(pair[1].replace(self.get_dst_prefix()+os.path.sep,'')) for pair in self.file_list]
-- 
cgit v1.2.3


From c69855f2333f9fb094e235b84d275d43fdeda3c3 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 1 Oct 2012 16:26:12 -0500
Subject: Only enable breakpad error handing if crash reporting is enabled

---
 indra/llcommon/llapp.cpp           | 3 ++-
 indra/llcommon/llqueuedthread.cpp  | 4 ++--
 indra/newview/llappviewerwin32.cpp | 5 ++++-
 indra/newview/viewer_manifest.py   | 3 ---
 4 files changed, 8 insertions(+), 7 deletions(-)

(limited to 'indra')

diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index ed192a9975..ca258900c7 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -289,6 +289,7 @@ void LLApp::setupErrorHandling()
 	// occasionally checks to see if the app is in an error state, and sees if it needs to be run.
 
 #if LL_WINDOWS
+#if LL_SEND_CRASH_REPORTS
 	// This sets a callback to handle w32 signals to the console window.
 	// The viewer shouldn't be affected, sicne its a windowed app.
 	SetConsoleCtrlHandler( (PHANDLER_ROUTINE) ConsoleCtrlHandler, TRUE);
@@ -300,7 +301,7 @@ void LLApp::setupErrorHandling()
 		mExceptionHandler = new google_breakpad::ExceptionHandler(
 			L"C:\\Temp\\", 0, windows_post_minidump_callback, 0, google_breakpad::ExceptionHandler::HANDLER_ALL);
 	}
-
+#endif
 #else
 	//
 	// Start up signal handling.
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index 1738c16dea..abf47a0f57 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -134,8 +134,8 @@ S32 LLQueuedThread::updateQueue(F32 max_time_ms)
 		pending = getPending();
 		if(pending > 0)
 		{
-		unpause();
-	}
+			unpause();
+		}
 	}
 	else
 	{
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 53c77fa22e..e0ca1232b0 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -131,7 +131,9 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 	// Note: This won't work when running from the debugger unless the _NO_DEBUG_HEAP environment variable is set to 1
 
 	// Enable to get mem debugging within visual studio.
-	//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+#if LL_DEBUG
+	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+#else
 	_CrtSetDbgFlag(0); // default, just making explicit
 	
 	ULONG ulEnableLFH = 2;
@@ -145,6 +147,7 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 		else
 			heap_enable_lfh_error[i] = GetLastError();
 	}
+#endif
 #endif
 	
 	// *FIX: global
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 87366caf1b..61d99333c2 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -538,9 +538,6 @@ class WindowsManifest(ViewerManifest):
             else:
                 result += 'Delete ' + wpath(os.path.join('$INSTDIR', rel_file)) + '\n'
 
-        if install
-            result += 'Delete ' + wpath(os.path.join('$INSTDIR', 'libtcmalloc_minimal.dll')) + '\n'
-
         # at the end of a delete, just rmdir all the directories
         if not install:
             deleted_file_dirs = [os.path.dirname(pair[1].replace(self.get_dst_prefix()+os.path.sep,'')) for pair in self.file_list]
-- 
cgit v1.2.3


From bc0abc773451d5a71f7f0b024e8d389327425446 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 2 Oct 2012 12:11:42 -0500
Subject: Fix up some assertions in lloctree.h

---
 indra/newview/lldrawable.cpp         | 12 +++++++++++-
 indra/newview/llspatialpartition.cpp |  4 ++--
 indra/newview/llspatialpartition.h   |  2 ++
 3 files changed, 15 insertions(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 108ec92f6d..0722e66571 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -945,6 +945,12 @@ void LLDrawable::updateUVMinMax()
 
 void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 {
+	//precondition: mSpatialGroupp MUST be null or DEAD or mSpatialGroupp MUST NOT contain this
+	llassert(!mSpatialGroupp || mSpatialGroupp->isDead() || !mSpatialGroupp->hasElement(this));
+
+	//precondition: groupp MUST be null or groupp MUST contain this
+	llassert(!groupp || groupp->hasElement(this));
+
 /*if (mSpatialGroupp && (groupp != mSpatialGroupp))
 	{
 		mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY);
@@ -1468,6 +1474,10 @@ void LLSpatialBridge::cleanupReferences()
 	LLDrawable::cleanupReferences();
 	if (mDrawable)
 	{
+		/*
+		
+		DON'T DO THIS -- this should happen through octree destruction
+
 		mDrawable->setSpatialGroup(NULL);
 		if (mDrawable->getVObj())
 		{
@@ -1482,7 +1492,7 @@ void LLSpatialBridge::cleanupReferences()
 					drawable->setSpatialGroup(NULL);
 				}
 			}
-		}
+		}*/
 
 		LLDrawable* drawablep = mDrawable;
 		mDrawable = NULL;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 45ef8f1a6d..9a6cb78333 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1841,13 +1841,13 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
 {
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	
-	drawablep->setSpatialGroup(NULL);
-
 	if (!curp->removeObject(drawablep))
 	{
 		OCT_ERRS << "Failed to remove drawable from octree!" << llendl;
 	}
 
+	drawablep->setSpatialGroup(NULL);
+
 	assert_octree_valid(mOctree);
 	
 	return TRUE;
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 7968c28900..d3cda2ff6a 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -346,6 +346,8 @@ public:
 	void dirtyGeom() { setState(GEOM_DIRTY); }
 	void dirtyMesh() { setState(MESH_DIRTY); }
 	element_list& getData() { return mOctreeNode->getData(); }
+	bool hasElement(LLDrawable* drawablep) { return mOctreeNode->getData().find(drawablep) != mOctreeNode->getData().end(); }
+
 	U32 getElementCount() const { return mOctreeNode->getElementCount(); }
 
 	void drawObjectBox(LLColor4 col);
-- 
cgit v1.2.3


From 983f62cc9e8077f9ce51672334bd359fb8bc4129 Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Tue, 2 Oct 2012 11:13:27 -0700
Subject: Adding libtcmalloc to the linux installer package.

---
 indra/newview/viewer_manifest.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 894d2f0925..876d43d12e 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -1081,9 +1081,7 @@ class Linux_i686Manifest(LinuxManifest):
             # version number.
             self.path("libfontconfig.so.*.*")
             try:
-                self.path("libtcmalloc.so", "libtcmalloc.so") #formerly called google perf tools
-                self.path("libtcmalloc.so.0", "libtcmalloc.so.0") #formerly called google perf tools
-                self.path("libtcmalloc.so.0.1.0", "libtcmalloc.so.0.1.0") #formerly called google perf tools
+                self.path("libtcmalloc.so*") #formerly called google perf tools
                 pass
             except:
                 print "tcmalloc files not found, skipping"
-- 
cgit v1.2.3


From 05dbd7dafe0e060e82aeedb5404101367bd4c622 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 2 Oct 2012 16:06:14 -0500
Subject: Instrument debug builds on windows to help track down source of heap
 corruption

---
 indra/llcommon/llmemory.h     |  7 +++++++
 indra/llmessage/llcurl.cpp    | 42 +++++++++++++++++++++++++++++++++++++-----
 indra/newview/llappviewer.cpp |  2 ++
 3 files changed, 46 insertions(+), 5 deletions(-)

(limited to 'indra')

diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index f37e8459ff..fd3b9d342a 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -27,6 +27,13 @@
 #define LLMEMORY_H
 
 #include "llmemtype.h"
+
+#if LL_WINDOWS && LL_DEBUG
+#define LL_CHECK_MEMORY llassert(_CrtCheckMemory());
+#else
+#define LL_CHECK_MEMORY
+#endif
+
 inline void* ll_aligned_malloc( size_t size, int align )
 {
 	void* mem = malloc( size + (align - 1) + sizeof(void*) );
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 5ea9b58300..0de47e0181 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -315,18 +315,23 @@ LLCurl::Easy* LLCurl::Easy::getEasy()
 
 LLCurl::Easy::~Easy()
 {
+	LL_CHECK_MEMORY
 	releaseEasyHandle(mCurlEasyHandle);
+	LL_CHECK_MEMORY
 	--gCurlEasyCount;
 	curl_slist_free_all(mHeaders);
+	LL_CHECK_MEMORY
 	for_each(mStrings.begin(), mStrings.end(), DeletePointerArray());
-
+	LL_CHECK_MEMORY
 	if (mResponder && LLCurl::sNotQuitting) //aborted
 	{	
 		std::string reason("Request timeout, aborted.") ;
 		mResponder->completedRaw(408, //HTTP_REQUEST_TIME_OUT, timeout, abort
 			reason, mChannels, mOutput);		
+		LL_CHECK_MEMORY
 	}
 	mResponder = NULL;
+	LL_CHECK_MEMORY
 }
 
 void LLCurl::Easy::resetState()
@@ -599,35 +604,49 @@ void LLCurl::Multi::cleanup(bool deleted)
 	llassert_always(deleted || !mValid) ;
 
 	LLMutexLock lock(mDeletionMutexp);
-	
+
+
 	// Clean up active
 	for(easy_active_list_t::iterator iter = mEasyActiveList.begin();
 		iter != mEasyActiveList.end(); ++iter)
 	{
 		Easy* easy = *iter;
+		LL_CHECK_MEMORY
 		check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle()));
-
+		LL_CHECK_MEMORY
 		if(deleted)
 		{
 			easy->mResponder = NULL ; //avoid triggering mResponder.
 		}
 		delete easy;
+		LL_CHECK_MEMORY
 	}
 	mEasyActiveList.clear();
 	mEasyActiveMap.clear();
 	
-	// Clean up freed
+	LL_CHECK_MEMORY
+	
+		// Clean up freed
 	for_each(mEasyFreeList.begin(), mEasyFreeList.end(), DeletePointer());	
 	mEasyFreeList.clear();
-
+	
+	LL_CHECK_MEMORY
+		
 	check_curl_multi_code(LLCurl::deleteMultiHandle(mCurlMultiHandle));
 	mCurlMultiHandle = NULL ;
+
+	LL_CHECK_MEMORY
 	
 	delete mMutexp ;
 	mMutexp = NULL ;
+
+	LL_CHECK_MEMORY
+
 	delete mEasyMutexp ;
 	mEasyMutexp = NULL ;
 
+	LL_CHECK_MEMORY
+
 	mQueued = 0 ;
 	mState = STATE_COMPLETED;
 	
@@ -1504,29 +1523,42 @@ void LLCurl::cleanupClass()
 			break ;
 		}
 	}
+	LL_CHECK_MEMORY
 	sCurlThread->shutdown() ;
+	LL_CHECK_MEMORY
 	delete sCurlThread ;
 	sCurlThread = NULL ;
+	LL_CHECK_MEMORY
 
 #if SAFE_SSL
 	CRYPTO_set_locking_callback(NULL);
 	for_each(sSSLMutex.begin(), sSSLMutex.end(), DeletePointer());
 #endif
+	
+	LL_CHECK_MEMORY
 
 	for (std::set<CURL*>::iterator iter = Easy::sFreeHandles.begin(); iter != Easy::sFreeHandles.end(); ++iter)
 	{
 		CURL* curl = *iter;
 		LLCurl::deleteEasyHandle(curl);
 	}
+	
+	LL_CHECK_MEMORY
 
 	Easy::sFreeHandles.clear();
 
+	LL_CHECK_MEMORY
+
 	delete Easy::sHandleMutexp ;
 	Easy::sHandleMutexp = NULL ;
 
+	LL_CHECK_MEMORY
+
 	delete sHandleMutexp ;
 	sHandleMutexp = NULL ;
 
+	LL_CHECK_MEMORY
+
 	// removed as per https://jira.secondlife.com/browse/SH-3115
 	//llassert(Easy::sActiveHandles.empty());
 }
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index e8934d9a9e..fa68b9322e 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1958,7 +1958,9 @@ bool LLAppViewer::cleanup()
 	end_messaging_system();
 
 	// *NOTE:Mani - The following call is not thread safe. 
+	LL_CHECK_MEMORY
 	LLCurl::cleanupClass();
+	LL_CHECK_MEMORY
 
 	// If we're exiting to launch an URL, do that here so the screen
 	// is at the right resolution before we launch IE.
-- 
cgit v1.2.3


From 374f20edf09ff8194c715d190c114eaacac00bfe Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 3 Oct 2012 14:30:21 -0500
Subject: Fix non-thread-safe refcounting of LLHTTPClient::Responder and fix
 out-of-order deletion of LLTextureFetch on shutdown

---
 indra/llcommon/llthread.cpp                        | 35 ++++++++++++++-----
 indra/llcommon/llthread.h                          | 30 ++++++++++++-----
 indra/llmessage/llcurl.cpp                         | 38 +++++++--------------
 indra/llmessage/llcurl.h                           | 15 +++------
 indra/newview/llappviewer.cpp                      |  6 ++--
 indra/newview/llassetuploadresponders.cpp          |  8 ++---
 indra/newview/lleventpoll.cpp                      |  2 +-
 indra/newview/llfloatertos.cpp                     |  6 ++--
 indra/newview/lltexturefetch.cpp                   |  2 ++
 indra/newview/lltranslate.h                        |  4 +--
 indra/newview/llviewermessage.cpp                  |  4 +--
 indra/newview/llviewerregion.cpp                   |  5 ++-
 .../viewer_components/updater/llupdatechecker.cpp  | 39 +---------------------
 indra/viewer_components/updater/llupdatechecker.h  | 34 +++++++++++++++++--
 14 files changed, 117 insertions(+), 111 deletions(-)

(limited to 'indra')

diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index a6ad6b125c..c2fbb544a8 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -114,7 +114,7 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
 		apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread
 	}
 	mRunCondition = new LLCondition(mAPRPoolp);
-
+	mDataLock = new LLMutex(mAPRPoolp);
 	mLocalAPRFilePoolp = NULL ;
 }
 
@@ -173,7 +173,10 @@ void LLThread::shutdown()
 	}
 
 	delete mRunCondition;
-	mRunCondition = 0;
+	mRunCondition = NULL;
+
+	delete mDataLock;
+	mDataLock = NULL;
 	
 	if (mIsLocalPool && mAPRPoolp)
 	{
@@ -242,28 +245,30 @@ bool LLThread::runCondition(void)
 // Stop thread execution if requested until unpaused.
 void LLThread::checkPause()
 {
-	mRunCondition->lock();
+	mDataLock->lock();
 
 	// This is in a while loop because the pthread API allows for spurious wakeups.
 	while(shouldSleep())
 	{
+		mDataLock->unlock();
 		mRunCondition->wait(); // unlocks mRunCondition
+		mDataLock->lock();
 		// mRunCondition is locked when the thread wakes up
 	}
 	
- 	mRunCondition->unlock();
+ 	mDataLock->unlock();
 }
 
 //============================================================================
 
 void LLThread::setQuitting()
 {
-	mRunCondition->lock();
+	mDataLock->lock();
 	if (mStatus == RUNNING)
 	{
 		mStatus = QUITTING;
 	}
-	mRunCondition->unlock();
+	mDataLock->unlock();
 	wake();
 }
 
@@ -285,12 +290,12 @@ void LLThread::yield()
 
 void LLThread::wake()
 {
-	mRunCondition->lock();
+	mDataLock->lock();
 	if(!shouldSleep())
 	{
 		mRunCondition->signal();
 	}
-	mRunCondition->unlock();
+	mDataLock->unlock();
 }
 
 void LLThread::wakeLocked()
@@ -481,6 +486,19 @@ LLThreadSafeRefCount::LLThreadSafeRefCount() :
 {
 }
 
+LLThreadSafeRefCount::LLThreadSafeRefCount(const LLThreadSafeRefCount& src)
+{
+	if (sMutex)
+	{
+		sMutex->lock();
+	}
+	mRef = 0;
+	if (sMutex)
+	{
+		sMutex->unlock();
+	}
+}
+
 LLThreadSafeRefCount::~LLThreadSafeRefCount()
 { 
 	if (mRef != 0)
@@ -489,6 +507,7 @@ LLThreadSafeRefCount::~LLThreadSafeRefCount()
 	}
 }
 
+
 //============================================================================
 
 LLResponder::~LLResponder()
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index b52e70ab2e..892e144911 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -97,6 +97,7 @@ private:
 protected:
 	std::string			mName;
 	LLCondition*		mRunCondition;
+	LLMutex*			mDataLock;
 
 	apr_thread_t		*mAPRThreadp;
 	apr_pool_t			*mAPRPoolp;
@@ -122,15 +123,15 @@ protected:
 	inline void unlockData();
 	
 	// This is the predicate that decides whether the thread should sleep.  
-	// It should only be called with mRunCondition locked, since the virtual runCondition() function may need to access
+	// It should only be called with mDataLock locked, since the virtual runCondition() function may need to access
 	// data structures that are thread-unsafe.
 	bool shouldSleep(void) { return (mStatus == RUNNING) && (isPaused() || (!runCondition())); }
 
 	// To avoid spurious signals (and the associated context switches) when the condition may or may not have changed, you can do the following:
-	// mRunCondition->lock();
+	// mDataLock->lock();
 	// if(!shouldSleep())
 	//     mRunCondition->signal();
-	// mRunCondition->unlock();
+	// mDataLock->unlock();
 };
 
 //============================================================================
@@ -205,12 +206,12 @@ private:
 
 void LLThread::lockData()
 {
-	mRunCondition->lock();
+	mDataLock->lock();
 }
 
 void LLThread::unlockData()
 {
-	mRunCondition->unlock();
+	mDataLock->unlock();
 }
 
 
@@ -227,15 +228,26 @@ public:
 private:
 	static LLMutex* sMutex;
 
-private:
-	LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented
-	LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented
-
 protected:
 	virtual ~LLThreadSafeRefCount(); // use unref()
 	
 public:
 	LLThreadSafeRefCount();
+	LLThreadSafeRefCount(const LLThreadSafeRefCount&);
+	LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount& ref) 
+	{
+		if (sMutex)
+		{
+			sMutex->lock();
+		}
+		mRef = 0;
+		if (sMutex)
+		{
+			sMutex->unlock();
+		}
+	}
+
+
 	
 	void ref()
 	{
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 0de47e0181..158e4ce091 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -133,12 +133,12 @@ std::string LLCurl::getVersionString()
 //////////////////////////////////////////////////////////////////////////////
 
 LLCurl::Responder::Responder()
-	: mReferenceCount(0)
 {
 }
 
 LLCurl::Responder::~Responder()
 {
+	LL_CHECK_MEMORY
 }
 
 // virtual
@@ -202,23 +202,6 @@ void LLCurl::Responder::completedHeader(U32 status, const std::string& reason, c
 
 }
 
-namespace boost
-{
-	void intrusive_ptr_add_ref(LLCurl::Responder* p)
-	{
-		++p->mReferenceCount;
-	}
-	
-	void intrusive_ptr_release(LLCurl::Responder* p)
-	{
-		if (p && 0 == --p->mReferenceCount)
-		{
-			delete p;
-		}
-	}
-};
-
-
 //////////////////////////////////////////////////////////////////////////////
 
 std::set<CURL*> LLCurl::Easy::sFreeHandles;
@@ -267,15 +250,18 @@ void LLCurl::Easy::releaseEasyHandle(CURL* handle)
 	LLMutexLock lock(sHandleMutexp) ;
 	if (sActiveHandles.find(handle) != sActiveHandles.end())
 	{
+		LL_CHECK_MEMORY
 		sActiveHandles.erase(handle);
-
+		LL_CHECK_MEMORY
 		if(sFreeHandles.size() < MAX_NUM_FREE_HANDLES)
 		{
-		sFreeHandles.insert(handle);
-	}
-	else
-	{
+			sFreeHandles.insert(handle);
+			LL_CHECK_MEMORY
+		}
+		else
+		{
 			LLCurl::deleteEasyHandle(handle) ;
+			LL_CHECK_MEMORY
 		}
 	}
 	else
@@ -315,9 +301,7 @@ LLCurl::Easy* LLCurl::Easy::getEasy()
 
 LLCurl::Easy::~Easy()
 {
-	LL_CHECK_MEMORY
 	releaseEasyHandle(mCurlEasyHandle);
-	LL_CHECK_MEMORY
 	--gCurlEasyCount;
 	curl_slist_free_all(mHeaders);
 	LL_CHECK_MEMORY
@@ -331,7 +315,6 @@ LLCurl::Easy::~Easy()
 		LL_CHECK_MEMORY
 	}
 	mResponder = NULL;
-	LL_CHECK_MEMORY
 }
 
 void LLCurl::Easy::resetState()
@@ -617,6 +600,7 @@ void LLCurl::Multi::cleanup(bool deleted)
 		if(deleted)
 		{
 			easy->mResponder = NULL ; //avoid triggering mResponder.
+			LL_CHECK_MEMORY
 		}
 		delete easy;
 		LL_CHECK_MEMORY
@@ -1623,7 +1607,9 @@ void  LLCurl::deleteEasyHandle(CURL* handle)
 	if(handle)
 	{
 		LLMutexLock lock(sHandleMutexp) ;
+		LL_CHECK_MEMORY
 		curl_easy_cleanup(handle) ;
+		LL_CHECK_MEMORY
 		sTotalHandles-- ;
 	}
 }
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index d6a7714d4c..62947bdb9d 100644
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -44,6 +44,8 @@
 #include "llthread.h"
 #include "llqueuedthread.h"
 #include "llframetimer.h"
+#include "llpointer.h"
+
 
 class LLMutex;
 class LLCurlThread;
@@ -67,7 +69,7 @@ public:
 		F64 mSpeedDownload;
 	};
 	
-	class Responder
+	class Responder : public LLThreadSafeRefCount
 	{
 	//LOG_CLASS(Responder);
 	public:
@@ -126,13 +128,10 @@ public:
 				return false;
 			}
 
-	public: /* but not really -- don't touch this */
-		U32 mReferenceCount;
-
 	private:
 		std::string mURL;
 	};
-	typedef boost::intrusive_ptr<Responder>	ResponderPtr;
+	typedef LLPointer<Responder>	ResponderPtr;
 
 
 	/**
@@ -378,12 +377,6 @@ private:
 	void cleanupMulti(LLCurl::Multi* multi) ;
 } ;
 
-namespace boost
-{
-	void intrusive_ptr_add_ref(LLCurl::Responder* p);
-	void intrusive_ptr_release(LLCurl::Responder* p);
-};
-
 
 class LLCurlRequest
 {
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index fa68b9322e..2b6d6d15fa 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1888,8 +1888,6 @@ bool LLAppViewer::cleanup()
 
 	delete sTextureCache;
     sTextureCache = NULL;
-	delete sTextureFetch;
-    sTextureFetch = NULL;
 	delete sImageDecodeThread;
     sImageDecodeThread = NULL;
 	delete mFastTimerLogThread;
@@ -1962,6 +1960,10 @@ bool LLAppViewer::cleanup()
 	LLCurl::cleanupClass();
 	LL_CHECK_MEMORY
 
+	//MUST happen AFTER LLCurl::cleanupClass
+	delete sTextureFetch;
+    sTextureFetch = NULL;
+	
 	// If we're exiting to launch an URL, do that here so the screen
 	// is at the right resolution before we launch IE.
 	if (!gLaunchFileOnQuit.empty())
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 65bfc990d1..7b2c536f5a 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -919,7 +919,7 @@ public:
 	bool uploadConfirmationCallback(
 		const LLSD& notification,
 		const LLSD& response,
-		boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder> responder)
+		LLPointer<LLNewAgentInventoryVariablePriceResponder> responder)
 	{
 		S32 option;
 		std::string confirmation_url;
@@ -949,7 +949,7 @@ public:
 
 	void confirmUpload(
 		const std::string& confirmation_url,
-		boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder> responder)
+		LLPointer<LLNewAgentInventoryVariablePriceResponder> responder)
 	{
 		if ( getFilename().empty() )
 		{
@@ -1124,7 +1124,7 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 		// and cause sadness.
 		mImpl->confirmUpload(
 			confirmation_url,
-			boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder>(this));
+			LLPointer<LLNewAgentInventoryVariablePriceResponder>(this));
 	}
 	else
 	{
@@ -1157,7 +1157,7 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 				mImpl,
 				_1,
 				_2,
-				boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder>(this)));
+				LLPointer<LLNewAgentInventoryVariablePriceResponder>(this)));
 	}
 }
 
diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp
index 4f4d9a40b4..2c786b7f8b 100644
--- a/indra/newview/lleventpoll.cpp
+++ b/indra/newview/lleventpoll.cpp
@@ -86,7 +86,7 @@ namespace
 
 	class LLEventPollEventTimer : public LLEventTimer
 	{
-		typedef boost::intrusive_ptr<LLEventPollResponder> EventPollResponderPtr;
+		typedef LLPointer<LLEventPollResponder> EventPollResponderPtr;
 
 	public:
 		LLEventPollEventTimer(F32 period, EventPollResponderPtr responder)
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp
index c5df7e16e9..a242b224cd 100644
--- a/indra/newview/llfloatertos.cpp
+++ b/indra/newview/llfloatertos.cpp
@@ -71,9 +71,9 @@ class LLIamHere : public LLHTTPClient::Responder
 
 	public:
 
-		static boost::intrusive_ptr< LLIamHere > build( LLFloaterTOS* parent )
+		static LLIamHere* build( LLFloaterTOS* parent )
 		{
-			return boost::intrusive_ptr< LLIamHere >( new LLIamHere( parent ) );
+			return new LLIamHere( parent );
 		};
 		
 		virtual void  setParent( LLFloaterTOS* parentIn )
@@ -102,7 +102,7 @@ class LLIamHere : public LLHTTPClient::Responder
 
 // this is global and not a class member to keep crud out of the header file
 namespace {
-	boost::intrusive_ptr< LLIamHere > gResponsePtr = 0;
+	LLPointer< LLIamHere > gResponsePtr = 0;
 };
 
 BOOL LLFloaterTOS::postBuild()
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 7e6dfbc9d9..a5eebf6c77 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2944,7 +2944,9 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
         
         ~lcl_responder()
             {
+				LL_CHECK_MEMORY
                 mFetcher->decrCurlPOSTCount();
+				LL_CHECK_MEMORY
             }
 
 		// virtual
diff --git a/indra/newview/lltranslate.h b/indra/newview/lltranslate.h
index c58e1adb8c..db5ad9479c 100755
--- a/indra/newview/lltranslate.h
+++ b/indra/newview/lltranslate.h
@@ -263,8 +263,8 @@ public :
 		EService mService;
 	};
 
-	typedef boost::intrusive_ptr<TranslationReceiver> TranslationReceiverPtr;
-	typedef boost::intrusive_ptr<KeyVerificationReceiver> KeyVerificationReceiverPtr;
+	typedef LLPointer<TranslationReceiver> TranslationReceiverPtr;
+	typedef LLPointer<KeyVerificationReceiver> KeyVerificationReceiverPtr;
 
 	/**
 	 * Translate given text.
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7d7d1f3047..04c7a87374 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -3339,9 +3339,9 @@ public :
 	{
 	}
 
-	static boost::intrusive_ptr<ChatTranslationReceiver> build(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, const LLChat &chat, const LLSD &toast_args)
+	static ChatTranslationReceiver* build(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, const LLChat &chat, const LLSD &toast_args)
 	{
-		return boost::intrusive_ptr<ChatTranslationReceiver>(new ChatTranslationReceiver(from_lang, to_lang, mesg, chat, toast_args));
+		return new ChatTranslationReceiver(from_lang, to_lang, mesg, chat, toast_args);
 	}
 
 protected:
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 493195aaa3..1ef729e2ff 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -255,10 +255,9 @@ public:
 		}
 	}
 
-    static boost::intrusive_ptr<BaseCapabilitiesComplete> build( U64 region_handle, S32 id )
+    static BaseCapabilitiesComplete* build( U64 region_handle, S32 id )
     {
-		return boost::intrusive_ptr<BaseCapabilitiesComplete>( 
-				new BaseCapabilitiesComplete(region_handle, id) );
+		return new BaseCapabilitiesComplete(region_handle, id);
     }
 
 private:
diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp
index 4da774a5f6..5edbbf9914 100644
--- a/indra/viewer_components/updater/llupdatechecker.cpp
+++ b/indra/viewer_components/updater/llupdatechecker.cpp
@@ -51,37 +51,6 @@ public:
 };
 
 
-class LLUpdateChecker::Implementation:
-	public LLHTTPClient::Responder
-{
-public:
-	Implementation(Client & client);
-	~Implementation();
-	void checkVersion(std::string const & protocolVersion, std::string const & hostUrl, 
-			   std::string const & servicePath, std::string channel, std::string version);
-	
-	// Responder:
-	virtual void completed(U32 status,
-						   const std::string & reason,
-						   const LLSD& content);
-	virtual void error(U32 status, const std::string & reason);
-	
-private:	
-	static const char * sProtocolVersion;
-	
-	Client & mClient;
-	LLHTTPClient mHttpClient;
-	bool mInProgress;
-	std::string mVersion;
-	
-	std::string buildUrl(std::string const & protocolVersion, std::string const & hostUrl, 
-						 std::string const & servicePath, std::string channel, std::string version);
-
-	LOG_CLASS(LLUpdateChecker::Implementation);
-};
-
-
-
 // LLUpdateChecker
 //-----------------------------------------------------------------------------
 
@@ -134,13 +103,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & protocolV
 	std::string checkUrl = buildUrl(protocolVersion, hostUrl, servicePath, channel, version);
 	LL_INFOS("UpdateCheck") << "checking for updates at " << checkUrl << llendl;
 	
-	// The HTTP client will wrap a raw pointer in a boost::intrusive_ptr causing the
-	// passed object to be silently and automatically deleted.  We pass a self-
-	// referential intrusive pointer to which we add a reference to keep the
-	// client from deleting the update checker implementation instance.
-	LLHTTPClient::ResponderPtr temporaryPtr(this);
-	boost::intrusive_ptr_add_ref(temporaryPtr.get());
-	mHttpClient.get(checkUrl, temporaryPtr);
+	mHttpClient.get(checkUrl, this);
 }
 
 void LLUpdateChecker::Implementation::completed(U32 status,
diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h
index d882169068..23f62a7c5e 100644
--- a/indra/viewer_components/updater/llupdatechecker.h
+++ b/indra/viewer_components/updater/llupdatechecker.h
@@ -29,6 +29,7 @@
 
 #include <boost/shared_ptr.hpp>
 
+#include "llhttpclient.h"
 
 //
 // Implements asynchronous checking for updates.
@@ -36,7 +37,36 @@
 class LLUpdateChecker {
 public:
 	class Client;
-	class Implementation;
+	class Implementation:
+
+	public LLHTTPClient::Responder
+	{
+	public:
+		Implementation(Client & client);
+		~Implementation();
+		void checkVersion(std::string const & protocolVersion, std::string const & hostUrl, 
+				   std::string const & servicePath, std::string channel, std::string version);
+	
+		// Responder:
+		virtual void completed(U32 status,
+							   const std::string & reason,
+							   const LLSD& content);
+		virtual void error(U32 status, const std::string & reason);
+	
+	private:	
+		static const char * sProtocolVersion;
+	
+		Client & mClient;
+		LLHTTPClient mHttpClient;
+		bool mInProgress;
+		std::string mVersion;
+	
+		std::string buildUrl(std::string const & protocolVersion, std::string const & hostUrl, 
+							 std::string const & servicePath, std::string channel, std::string version);
+
+		LOG_CLASS(LLUpdateChecker::Implementation);
+	};
+
 	
 	// An exception that may be raised on check errors.
 	class CheckError;
@@ -48,7 +78,7 @@ public:
 			   std::string const & servicePath, std::string channel, std::string version);
 	
 private:
-	boost::shared_ptr<Implementation> mImplementation;
+	LLPointer<Implementation> mImplementation;
 };
 
 
-- 
cgit v1.2.3


From 20e1f567d5c09df10fe120fde0d5f294eff0fff4 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 3 Oct 2012 15:17:55 -0500
Subject: Fix for tests

---
 indra/llmessage/tests/llcurl_stub.cpp       | 17 -----------------
 indra/llmessage/tests/llhttpclient_test.cpp |  4 ++--
 indra/newview/tests/lltranslate_test.cpp    |  7 +------
 3 files changed, 3 insertions(+), 25 deletions(-)

(limited to 'indra')

diff --git a/indra/llmessage/tests/llcurl_stub.cpp b/indra/llmessage/tests/llcurl_stub.cpp
index d84fe0a49f..9b298d0c04 100644
--- a/indra/llmessage/tests/llcurl_stub.cpp
+++ b/indra/llmessage/tests/llcurl_stub.cpp
@@ -28,7 +28,6 @@
 #include "llcurl.h"
 
 LLCurl::Responder::Responder()
-	: mReferenceCount(0)
 {
 }
 
@@ -77,19 +76,3 @@ void LLCurl::Responder::result(LLSD const&)
 {
 }
 
-namespace boost
-{
-	void intrusive_ptr_add_ref(LLCurl::Responder* p)
-	{
-		++p->mReferenceCount;
-	}
-
-	void intrusive_ptr_release(LLCurl::Responder* p)
-	{
-		if(p && 0 == --p->mReferenceCount)
-		{
-			delete p;
-		}
-	}
-};
-
diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp
index 843c3bcc4b..a2be307cc8 100644
--- a/indra/llmessage/tests/llhttpclient_test.cpp
+++ b/indra/llmessage/tests/llhttpclient_test.cpp
@@ -189,9 +189,9 @@ namespace tut
 			}
 		
 		public:
-			static boost::intrusive_ptr<Result> build(HTTPClientTestData& client)
+			static Result* build(HTTPClientTestData& client)
 			{
-				return boost::intrusive_ptr<Result>(new Result(client));
+				return new Result(client);
 			}
 			
 			~Result()
diff --git a/indra/newview/tests/lltranslate_test.cpp b/indra/newview/tests/lltranslate_test.cpp
index 10e37fae97..fd9527d631 100644
--- a/indra/newview/tests/lltranslate_test.cpp
+++ b/indra/newview/tests/lltranslate_test.cpp
@@ -299,11 +299,6 @@ LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker<LLCo
 std::string LLControlGroup::getString(const std::string& name) { return "dummy"; }
 LLControlGroup::~LLControlGroup() {}
 
-namespace boost {
-	void intrusive_ptr_add_ref(LLCurl::Responder*) {}
-	void intrusive_ptr_release(LLCurl::Responder*) {}
-}
-
 LLCurl::Responder::Responder() {}
 void LLCurl::Responder::completedHeader(U32, std::string const&, LLSD const&) {}
 void LLCurl::Responder::completedRaw(U32, const std::string&, const LLChannelDescriptors&, const LLIOPipe::buffer_ptr_t& buffer) {}
@@ -314,7 +309,7 @@ void LLCurl::Responder::result(LLSD const&) {}
 LLCurl::Responder::~Responder() {}
 
 void LLHTTPClient::get(const std::string&, const LLSD&, ResponderPtr, const LLSD&, const F32) {}
-void LLHTTPClient::get(const std::string&, boost::intrusive_ptr<LLCurl::Responder>, const LLSD&, const F32) {}
+void LLHTTPClient::get(const std::string&, LLPointer<LLCurl::Responder>, const LLSD&, const F32) {}
 
 LLBufferStream::LLBufferStream(const LLChannelDescriptors& channels, LLBufferArray* buffer)
 :	std::iostream(&mStreamBuf), mStreamBuf(channels, buffer) {}
-- 
cgit v1.2.3


From 6b0fe3258a43159a0b2751cedae4d36bb9c09436 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 3 Oct 2012 16:02:22 -0500
Subject: Fix for mac/linux build

---
 indra/llaudio/llaudiodecodemgr.cpp | 2 +-
 indra/llcommon/llthread.h          | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp
index 6c97a64ed7..7768c3da0c 100644
--- a/indra/llaudio/llaudiodecodemgr.cpp
+++ b/indra/llaudio/llaudiodecodemgr.cpp
@@ -690,7 +690,7 @@ BOOL LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid)
 	return FALSE;
 }
 
-#if LL_DARWIN || LL_LINUX
+#if LL_DARWIN
 // HACK: to fool the compiler into not emitting unused warnings.
 namespace {
 	const ov_callbacks callback_array[4] = {OV_CALLBACKS_DEFAULT, OV_CALLBACKS_NOCLOSE, OV_CALLBACKS_STREAMONLY, 
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index 892e144911..115bf47553 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -234,7 +234,7 @@ protected:
 public:
 	LLThreadSafeRefCount();
 	LLThreadSafeRefCount(const LLThreadSafeRefCount&);
-	LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount& ref) 
+	LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) 
 	{
 		if (sMutex)
 		{
@@ -245,6 +245,7 @@ public:
 		{
 			sMutex->unlock();
 		}
+		return *this;
 	}
 
 
-- 
cgit v1.2.3


From ce007b124b26b6d320b7164aca498bf9638388ae Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 3 Oct 2012 16:32:09 -0500
Subject: Fix for linux build

---
 indra/llaudio/llaudiodecodemgr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp
index 7768c3da0c..6c97a64ed7 100644
--- a/indra/llaudio/llaudiodecodemgr.cpp
+++ b/indra/llaudio/llaudiodecodemgr.cpp
@@ -690,7 +690,7 @@ BOOL LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid)
 	return FALSE;
 }
 
-#if LL_DARWIN
+#if LL_DARWIN || LL_LINUX
 // HACK: to fool the compiler into not emitting unused warnings.
 namespace {
 	const ov_callbacks callback_array[4] = {OV_CALLBACKS_DEFAULT, OV_CALLBACKS_NOCLOSE, OV_CALLBACKS_STREAMONLY, 
-- 
cgit v1.2.3


From aa860853479a641bb63e55a7d7921fc36065ea05 Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Fri, 5 Oct 2012 15:58:38 -0700
Subject: MAINT-1636: Turning off tcmalloc for the build now that davep's
 changes are in to fix our major crasher.

---
 indra/cmake/GooglePerfTools.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/cmake/GooglePerfTools.cmake b/indra/cmake/GooglePerfTools.cmake
index 09501e0406..73b3642ae6 100644
--- a/indra/cmake/GooglePerfTools.cmake
+++ b/indra/cmake/GooglePerfTools.cmake
@@ -3,7 +3,7 @@ include(Prebuilt)
 
 # If you want to enable or disable TCMALLOC in viewer builds, this is the place.
 # set ON or OFF as desired.
-set (USE_TCMALLOC ON)
+set (USE_TCMALLOC OFF)
 
 if (STANDALONE)
   include(FindGooglePerfTools)
-- 
cgit v1.2.3


From 827d8814cf1e6511333824273b624f0b814ce359 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 9 Oct 2012 13:34:28 -0500
Subject: MAINT-1688 Potential fix for crash on exit in LLTextureFetch

---
 indra/llmessage/llcurl.cpp    |  6 ++++++
 indra/newview/llappviewer.cpp | 23 +++++++++++------------
 2 files changed, 17 insertions(+), 12 deletions(-)

(limited to 'indra')

diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 158e4ce091..10c83e6572 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -1104,6 +1104,7 @@ bool LLCurlRequest::getByteRange(const std::string& url,
 								 S32 offset, S32 length,
 								 LLCurl::ResponderPtr responder)
 {
+	llassert(LLCurl::sNotQuitting);
 	LLCurl::Easy* easy = allocEasy();
 	if (!easy)
 	{
@@ -1126,6 +1127,7 @@ bool LLCurlRequest::post(const std::string& url,
 						 const LLSD& data,
 						 LLCurl::ResponderPtr responder, S32 time_out)
 {
+	llassert(LLCurl::sNotQuitting);
 	LLCurl::Easy* easy = allocEasy();
 	if (!easy)
 	{
@@ -1153,6 +1155,7 @@ bool LLCurlRequest::post(const std::string& url,
 						 const std::string& data,
 						 LLCurl::ResponderPtr responder, S32 time_out)
 {
+	llassert(LLCurl::sNotQuitting);
 	LLCurl::Easy* easy = allocEasy();
 	if (!easy)
 	{
@@ -1550,6 +1553,8 @@ void LLCurl::cleanupClass()
 //static 
 CURLM* LLCurl::newMultiHandle()
 {
+	llassert(sNotQuitting);
+
 	LLMutexLock lock(sHandleMutexp) ;
 
 	if(sTotalHandles + 1 > sMaxHandles)
@@ -1583,6 +1588,7 @@ CURLMcode  LLCurl::deleteMultiHandle(CURLM* handle)
 //static 
 CURL*  LLCurl::newEasyHandle()
 {
+	llassert(sNotQuitting);
 	LLMutexLock lock(sHandleMutexp) ;
 
 	if(sTotalHandles + 1 > sMaxHandles)
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 2b6d6d15fa..b8b7cc0655 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1884,10 +1884,21 @@ bool LLAppViewer::cleanup()
 	sTextureFetch->shutDownTextureCacheThread() ;
 	sTextureFetch->shutDownImageDecodeThread() ;
 
+	llinfos << "Shutting down message system" << llendflush;
+	end_messaging_system();
+
+	// *NOTE:Mani - The following call is not thread safe. 
+	LL_CHECK_MEMORY
+	LLCurl::cleanupClass();
+	LL_CHECK_MEMORY
+
 	LLFilePickerThread::cleanupClass();
 
+	//MUST happen AFTER LLCurl::cleanupClass
 	delete sTextureCache;
     sTextureCache = NULL;
+	delete sTextureFetch;
+    sTextureFetch = NULL;
 	delete sImageDecodeThread;
     sImageDecodeThread = NULL;
 	delete mFastTimerLogThread;
@@ -1952,18 +1963,6 @@ bool LLAppViewer::cleanup()
 
 	LLViewerAssetStatsFF::cleanup();
 	
-	llinfos << "Shutting down message system" << llendflush;
-	end_messaging_system();
-
-	// *NOTE:Mani - The following call is not thread safe. 
-	LL_CHECK_MEMORY
-	LLCurl::cleanupClass();
-	LL_CHECK_MEMORY
-
-	//MUST happen AFTER LLCurl::cleanupClass
-	delete sTextureFetch;
-    sTextureFetch = NULL;
-	
 	// If we're exiting to launch an URL, do that here so the screen
 	// is at the right resolution before we launch IE.
 	if (!gLaunchFileOnQuit.empty())
-- 
cgit v1.2.3


From 8b4423d428a0a209711eb18cc003d9ca4970e17a Mon Sep 17 00:00:00 2001
From: MaximB ProductEngine <mberezhnoy@productengine.com>
Date: Wed, 10 Oct 2012 20:04:56 +0300
Subject: CHUI-377 (Icons in message panel out of position when nearby chat
 conversation selected)         FIXED

---
 indra/newview/llimconversation.cpp | 33 ++++++++++++++++++++++-----------
 indra/newview/llimconversation.h   |  2 ++
 2 files changed, 24 insertions(+), 11 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llimconversation.cpp b/indra/newview/llimconversation.cpp
index 2ad7f9b193..3b334df189 100644
--- a/indra/newview/llimconversation.cpp
+++ b/indra/newview/llimconversation.cpp
@@ -393,7 +393,7 @@ void LLIMConversation::updateHeaderAndToolbar()
 	// prevent start conversation before its container
     LLIMFloaterContainer::getInstance();
 
-	bool is_torn_off = !getHost();
+	bool is_torn_off = checkIfTornOff();
 	if (!is_torn_off)
 	{
 		hideAllStandardButtons();
@@ -505,16 +505,7 @@ void LLIMConversation::onSlide(LLIMConversation* self)
 /*virtual*/
 void LLIMConversation::onOpen(const LLSD& key)
 {
-	LLIMFloaterContainer* host_floater = dynamic_cast<LLIMFloaterContainer*>(getHost());
-    bool is_hosted = !!host_floater;
-	if (is_hosted)
-	{
-		// Show the messages pane when opening a floater hosted in the Conversations
-		host_floater->collapseMessagesPane(false);
-	}
-
-	setTornOff(!is_hosted);
-	updateHeaderAndToolbar();
+	checkIfTornOff();
 }
 
 // virtual
@@ -546,3 +537,23 @@ bool LLIMConversation::isChatMultiTab()
 	// Restart is required in order to change chat window type.
 	return true;
 }
+
+bool LLIMConversation::checkIfTornOff()
+{
+	bool isTorn = !getHost();
+	if (!isTorn)
+	{
+		LLIMFloaterContainer* host_floater = dynamic_cast<LLIMFloaterContainer*>(getHost());
+
+		// Show the messages pane when opening a floater hosted in the Conversations
+		host_floater->collapseMessagesPane(false);
+	}
+	
+	if (isTorn != isTornOff())
+	{
+		setTornOff(isTorn);
+		updateHeaderAndToolbar();
+	}
+
+	return isTorn;
+}
\ No newline at end of file
diff --git a/indra/newview/llimconversation.h b/indra/newview/llimconversation.h
index c54081d316..0960d6db88 100644
--- a/indra/newview/llimconversation.h
+++ b/indra/newview/llimconversation.h
@@ -138,6 +138,8 @@ private:
 	 */
 	void reshapeChatHistory();
 
+	bool checkIfTornOff();
+
 	LLTimer* mRefreshTimer; ///< Defines the rate at which refresh() is called.
 
 	bool mHadFocus;
-- 
cgit v1.2.3


From 830ecff00bd8a4111169ed52bec2384122ff2c01 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 10 Oct 2012 14:13:52 -0500
Subject: DRTVWR-225 Cleanup assertions

---
 indra/newview/lldrawable.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 55c780ecba..a0289cd2af 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -990,9 +990,12 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 		}
 	}
 
-	mSpatialGroupp = groupp;
+	//postcondition: if next group is NULL, previous group must be dead OR NULL OR binIndex must be -1
+	//postcondition: if next group is NOT NULL, binIndex must not be -1
+	llassert(groupp == NULL ? (mSpatialGroupp == NULL || mSpatialGroupp->isDead()) || getBinIndex() == -1 :
+							getBinIndex() != -1);
 
-	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
+	mSpatialGroupp = groupp;
 }
 
 LLSpatialPartition* LLDrawable::getSpatialPartition()
-- 
cgit v1.2.3


From 82e5649fba22f7fa0cb4744f632aa836f0855f85 Mon Sep 17 00:00:00 2001
From: MaximB ProductEngine <mberezhnoy@productengine.com>
Date: Thu, 11 Oct 2012 14:06:35 +0300
Subject: CHUI-377 (Icons in message panel out of position when nearby chat
 conversation selected)         Fixed bug with collapsing messages pane

---
 indra/newview/llimconversation.cpp | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llimconversation.cpp b/indra/newview/llimconversation.cpp
index 3b334df189..9f3c6d0f3d 100644
--- a/indra/newview/llimconversation.cpp
+++ b/indra/newview/llimconversation.cpp
@@ -505,7 +505,12 @@ void LLIMConversation::onSlide(LLIMConversation* self)
 /*virtual*/
 void LLIMConversation::onOpen(const LLSD& key)
 {
-	checkIfTornOff();
+	if (!checkIfTornOff())
+	{
+		LLIMFloaterContainer* host_floater = dynamic_cast<LLIMFloaterContainer*>(getHost());
+		// Show the messages pane when opening a floater hosted in the Conversations
+		host_floater->collapseMessagesPane(false);
+	}
 }
 
 // virtual
@@ -541,13 +546,6 @@ bool LLIMConversation::isChatMultiTab()
 bool LLIMConversation::checkIfTornOff()
 {
 	bool isTorn = !getHost();
-	if (!isTorn)
-	{
-		LLIMFloaterContainer* host_floater = dynamic_cast<LLIMFloaterContainer*>(getHost());
-
-		// Show the messages pane when opening a floater hosted in the Conversations
-		host_floater->collapseMessagesPane(false);
-	}
 	
 	if (isTorn != isTornOff())
 	{
@@ -556,4 +554,4 @@ bool LLIMConversation::checkIfTornOff()
 	}
 
 	return isTorn;
-}
\ No newline at end of file
+}
-- 
cgit v1.2.3


From 0ff5a0c8ceebfab0d786aaf027c7c548170afe8d Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Thu, 11 Oct 2012 19:58:26 +0300
Subject: CHUI-356 FIXED Call notifyObserverSessionIDUpdated() only after
 initing IM floater with new session id

---
 indra/newview/llimview.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index b45903835a..a604c884ca 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -643,6 +643,12 @@ void LLIMModel::processSessionInitializedReply(const LLUUID& old_session_id, con
 	{
 		session->sessionInitReplyReceived(new_session_id);
 
+		LLIMFloater* im_floater = LLIMFloater::findInstance(old_session_id);
+		if (im_floater)
+		{
+			im_floater->sessionInitReplyReceived(new_session_id);
+		}
+
 		if (old_session_id != new_session_id)
 		{
 			mId2SessionMap.erase(old_session_id);
@@ -651,12 +657,6 @@ void LLIMModel::processSessionInitializedReply(const LLUUID& old_session_id, con
 			gIMMgr->notifyObserverSessionIDUpdated(old_session_id, new_session_id);
 		}
 
-		LLIMFloater* im_floater = LLIMFloater::findInstance(old_session_id);
-		if (im_floater)
-		{
-			im_floater->sessionInitReplyReceived(new_session_id);
-		}
-
 		// auto-start the call on session initialization?
 		if (session->mStartCallOnInitialize)
 		{
-- 
cgit v1.2.3


From 8aa424128ad06567f4c32c6672dc63d9b2111efa Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Thu, 11 Oct 2012 10:38:34 -0700
Subject: CHUI-380: Before code review changes. Now the user selects a
 conversation or participant of a conversation the correct chat floater will
 appear. Focus will be redirected to the chat input text box automatically
 allowing the user to type into the input text box.

---
 indra/newview/llconversationview.cpp | 28 ++++++++++++++++++++++++---
 indra/newview/llconversationview.h   |  1 +
 indra/newview/llimfloater.cpp        | 37 +++++++++++++++++++++---------------
 indra/newview/llimfloater.h          |  1 +
 indra/newview/llnearbychat.cpp       | 20 +++++++++++++++++++
 indra/newview/llnearbychat.h         |  2 +-
 6 files changed, 70 insertions(+), 19 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index d4eb551f7a..112c38d8b8 100755
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -32,6 +32,8 @@
 #include <boost/bind.hpp>
 #include "llagentdata.h"
 #include "llconversationmodel.h"
+#include "llimfloater.h"
+#include "llnearbychat.h"
 #include "llimconversation.h"
 #include "llimfloatercontainer.h"
 #include "llfloaterreg.h"
@@ -407,21 +409,41 @@ void LLConversationViewParticipant::draw()
     static LLUIColor sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE);
 
     const BOOL show_context = (getRoot() ? getRoot()->getShowSelectionContext() : FALSE);
-    const BOOL filled = show_context || (getRoot() ? getRoot()->getParentPanel()->hasFocus() : FALSE); // If we have keyboard focus, draw selection filled
 
     const LLFontGL* font = getLabelFontForStyle(mLabelStyle);
     F32 right_x  = 0;
 
     F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad;
     F32 text_left = (F32)getLabelXPos();
-    LLColor4 color = (mIsSelected && filled) ? sHighlightFgColor : sFgColor;
+    LLColor4 color = mIsSelected ? sHighlightFgColor : sFgColor;
 
-    drawHighlight(show_context, filled, sHighlightBgColor, sFocusOutlineColor, sMouseOverColor);
+    drawHighlight(show_context, true, sHighlightBgColor, sFocusOutlineColor, sMouseOverColor);
     drawLabel(font, text_left, y, color, right_x);
 
     LLView::draw();
 }
 
+void LLConversationViewParticipant::selectItem()
+{
+    LLConversationItem* vmi = this->getParentFolder() ? static_cast<LLConversationItem*>(this->getParentFolder()->getViewModelItem()) : NULL;
+    
+    if(vmi)
+    {
+        //When null, show the nearby chat conversation floater
+        if(vmi->getUUID().isNull())
+        {
+            LLNearbyChat* nearbyChat = LLFloaterReg::findTypedInstance<LLNearbyChat>("nearby_chat");
+            nearbyChat->show();
+        }
+        //Otherwise, show the IM conversation floater
+        else
+        {
+            LLIMFloater::show(vmi->getUUID());
+        }
+    }
+
+    LLFolderViewItem::selectItem();
+}
 
 void LLConversationViewParticipant::refresh()
 {
diff --git a/indra/newview/llconversationview.h b/indra/newview/llconversationview.h
index c81c70b456..bd95387bbe 100755
--- a/indra/newview/llconversationview.h
+++ b/indra/newview/llconversationview.h
@@ -113,6 +113,7 @@ public:
 	};
 	
     virtual ~LLConversationViewParticipant( void ) { }
+    void selectItem();	
     bool hasSameValue(const LLUUID& uuid) { return (uuid == mUUID); }
     virtual void refresh();
     void addToFolder(LLFolderViewFolder* folder);
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index 99337bd5f3..990b9c45f9 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -719,6 +719,27 @@ void LLIMFloater::setDocked(bool docked, bool pop_on_undock)
 	}
 }
 
+void LLIMFloater::setFocus(BOOL focusFlag)
+{
+    LLTransientDockableFloater::setFocus(focusFlag);
+
+    BOOL is_minimized = focusFlag && isChatMultiTab()
+        ? LLIMFloaterContainer::getInstance()->isMinimized()
+        : !focusFlag;
+
+    //Redirect focus to input editor
+    if (!is_minimized && mChatHistory && mInputEditor)
+    {
+        //only if floater was construced and initialized from xml
+        updateMessages();
+        //prevent stealing focus when opening a background IM tab (EXT-5387, checking focus for EXT-6781)
+        if (!isChatMultiTab() || hasFocus())
+        {
+            mInputEditor->setFocus(TRUE);
+        }
+    }
+}
+
 void LLIMFloater::setVisible(BOOL visible)
 {
 	LLNotificationsUI::LLScreenChannel* channel = static_cast<LLNotificationsUI::LLScreenChannel*>
@@ -734,21 +755,6 @@ void LLIMFloater::setVisible(BOOL visible)
 		channel->redrawToasts();
 	}
 
-	BOOL is_minimized = visible && isChatMultiTab()
-		? LLIMFloaterContainer::getInstance()->isMinimized()
-		: !visible;
-
-	if (!is_minimized && mChatHistory && mInputEditor)
-	{
-		//only if floater was construced and initialized from xml
-		updateMessages();
-		//prevent stealing focus when opening a background IM tab (EXT-5387, checking focus for EXT-6781)
-		if (!isChatMultiTab() || hasFocus())
-		{
-			mInputEditor->setFocus(TRUE);
-		}
-	}
-
 	if(!visible)
 	{
 		LLIMChiclet* chiclet = LLChicletBar::getInstance()->getChicletPanel()->findChiclet<LLIMChiclet>(mSessionID);
@@ -761,6 +767,7 @@ void LLIMFloater::setVisible(BOOL visible)
 	if (visible && isInVisibleChain())
 	{
 		sIMFloaterShowedSignal(mSessionID);
+        setFocus(TRUE);
 	}
 }
 
diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h
index 5ed1d1ab35..26daf00afd 100644
--- a/indra/newview/llimfloater.h
+++ b/indra/newview/llimfloater.h
@@ -65,6 +65,7 @@ public:
 
 	// LLView overrides
 	/*virtual*/ BOOL postBuild();
+    /*virtual*/ void setFocus(BOOL focusFlag);
 	/*virtual*/ void setVisible(BOOL visible);
 	/*virtual*/ BOOL getVisible();
 	// Check typing timeout timer.
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index b96b486868..e0778afd86 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -271,11 +271,31 @@ void LLNearbyChat::removeScreenChat()
 	}
 }
 
+void LLNearbyChat::setFocus(BOOL focusFlag)
+{
+    LLTransientDockableFloater::setFocus(focusFlag);
+
+    BOOL is_minimized = focusFlag && isChatMultiTab()
+        ? LLIMFloaterContainer::getInstance()->isMinimized()
+        : !focusFlag;
+
+    //Redirect focus to input editor
+    if (!is_minimized && mChatHistory && mInputEditor)
+    {
+        //prevent stealing focus when opening a background IM tab (EXT-5387, checking focus for EXT-6781)
+        if (!isChatMultiTab() || hasFocus())
+        {
+            mInputEditor->setFocus(TRUE);
+        }
+    }
+}
+
 void	LLNearbyChat::setVisible(BOOL visible)
 {
 	if(visible)
 	{
 		removeScreenChat();
+        setFocus(TRUE);
 	}
 
 	LLIMConversation::setVisible(visible);
diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h
index 93168ba96a..7ada4daea8 100644
--- a/indra/newview/llnearbychat.h
+++ b/indra/newview/llnearbychat.h
@@ -52,7 +52,7 @@ public:
 
 	/*virtual*/ BOOL postBuild();
 	/*virtual*/ void onOpen(const LLSD& key);
-
+    /*virtual*/ void setFocus(BOOL focusFlag);
 	/*virtual*/ void	setVisible(BOOL visible);
 
 	void loadHistory();
-- 
cgit v1.2.3


From 375f380ea388b37c34ace9570822d0c117b3d2f1 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Thu, 11 Oct 2012 12:17:46 -0700
Subject: CHUI-380: Code cleanup after code review.

---
 indra/newview/llimfloater.cpp  | 13 ++-----------
 indra/newview/llnearbychat.cpp | 12 ++----------
 2 files changed, 4 insertions(+), 21 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index 990b9c45f9..a1ed1e0b01 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -723,20 +723,11 @@ void LLIMFloater::setFocus(BOOL focusFlag)
 {
     LLTransientDockableFloater::setFocus(focusFlag);
 
-    BOOL is_minimized = focusFlag && isChatMultiTab()
-        ? LLIMFloaterContainer::getInstance()->isMinimized()
-        : !focusFlag;
-
     //Redirect focus to input editor
-    if (!is_minimized && mChatHistory && mInputEditor)
+    if (focusFlag)
     {
-        //only if floater was construced and initialized from xml
         updateMessages();
-        //prevent stealing focus when opening a background IM tab (EXT-5387, checking focus for EXT-6781)
-        if (!isChatMultiTab() || hasFocus())
-        {
-            mInputEditor->setFocus(TRUE);
-        }
+        mInputEditor->setFocus(TRUE);
     }
 }
 
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index e0778afd86..a0ddc9b52b 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -275,18 +275,10 @@ void LLNearbyChat::setFocus(BOOL focusFlag)
 {
     LLTransientDockableFloater::setFocus(focusFlag);
 
-    BOOL is_minimized = focusFlag && isChatMultiTab()
-        ? LLIMFloaterContainer::getInstance()->isMinimized()
-        : !focusFlag;
-
     //Redirect focus to input editor
-    if (!is_minimized && mChatHistory && mInputEditor)
+    if (focusFlag)
     {
-        //prevent stealing focus when opening a background IM tab (EXT-5387, checking focus for EXT-6781)
-        if (!isChatMultiTab() || hasFocus())
-        {
-            mInputEditor->setFocus(TRUE);
-        }
+        mInputEditor->setFocus(TRUE);
     }
 }
 
-- 
cgit v1.2.3


From 572d4bc071578edb62a71d787a4c20124b755f16 Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Thu, 11 Oct 2012 16:47:16 -0700
Subject: MAINT-1684: Attempt at correcting the linux crash on startup. 
 Replacing the memory allocations and frees in the LLPrivateMemoryPool with
 aligned memory allocations and frees.

---
 indra/llcommon/llmemory.cpp | 31 ++++++++-----------------------
 1 file changed, 8 insertions(+), 23 deletions(-)

(limited to 'indra')

diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index afaf366668..eaa7b58e08 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -252,21 +252,6 @@ U32 LLMemory::getAllocatedMemKB()
 	return sAllocatedMemInKB ;
 }
 
-void* ll_allocate (size_t size)
-{
-	if (size == 0)
-	{
-		llwarns << "Null allocation" << llendl;
-	}
-	void *p = malloc(size);
-	if (p == NULL)
-	{
-		LLMemory::freeReserve();
-		llerrs << "Out of memory Error" << llendl;
-	}
-	return p;
-}
-
 //----------------------------------------------------------------------------
 
 #if defined(LL_WINDOWS)
@@ -1365,7 +1350,7 @@ char* LLPrivateMemoryPool::allocate(U32 size)
 	//if the asked size larger than MAX_BLOCK_SIZE, fetch from heap directly, the pool does not manage it
 	if(size >= CHUNK_SIZE)
 	{
-		return (char*)malloc(size) ;
+		return (char*)ll_aligned_malloc_16(size) ;
 	}
 
 	char* p = NULL ;
@@ -1422,7 +1407,7 @@ char* LLPrivateMemoryPool::allocate(U32 size)
 			to_log = false ;
 		}
 
-		return (char*)malloc(size) ;
+		return (char*)ll_aligned_malloc_16(size) ;
 	}
 
 	return p ;
@@ -1441,7 +1426,7 @@ void LLPrivateMemoryPool::freeMem(void* addr)
 	
 	if(!chunk)
 	{
-		free(addr) ; //release from heap
+		ll_aligned_free(addr) ; //release from heap
 	}
 	else
 	{
@@ -1565,7 +1550,7 @@ LLPrivateMemoryPool::LLMemoryChunk* LLPrivateMemoryPool::addChunk(S32 chunk_inde
 
 	mReservedPoolSize += preferred_size + overhead ;
 
-	char* buffer = (char*)malloc(preferred_size + overhead) ;
+	char* buffer = (char*)ll_aligned_malloc_16(preferred_size + overhead) ;
 	if(!buffer)
 	{
 		return NULL ;
@@ -1633,7 +1618,7 @@ void LLPrivateMemoryPool::removeChunk(LLMemoryChunk* chunk)
 	mReservedPoolSize -= chunk->getBufferSize() ;
 	
 	//release memory
-	free(chunk->getBuffer()) ;
+	ll_aligned_free(chunk->getBuffer()) ;
 }
 
 U16 LLPrivateMemoryPool::findHashKey(const char* addr)
@@ -1977,7 +1962,7 @@ char* LLPrivateMemoryPoolManager::allocate(LLPrivateMemoryPool* poolp, U32 size,
 
 	if(!poolp)
 	{
-		p = (char*)malloc(size) ;
+		p = (char*)ll_aligned_malloc_16(size) ;
 	}
 	else
 	{
@@ -2006,7 +1991,7 @@ char* LLPrivateMemoryPoolManager::allocate(LLPrivateMemoryPool* poolp, U32 size)
 	}
 	else
 	{
-		return (char*)malloc(size) ;
+		return (char*)ll_aligned_malloc_16(size) ;
 	}
 }
 #endif
@@ -2031,7 +2016,7 @@ void  LLPrivateMemoryPoolManager::freeMem(LLPrivateMemoryPool* poolp, void* addr
 	{
 		if(!sPrivatePoolEnabled)
 		{
-			free(addr) ; //private pool is disabled.
+			ll_aligned_free(addr) ; //private pool is disabled.
 		}
 		else if(!sInstance) //the private memory manager is destroyed, try the dangling list
 		{
-- 
cgit v1.2.3


From f4b10aaebbaf8eb66d41ffa703f6ed7b909ba7e7 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Thu, 11 Oct 2012 17:48:39 -0700
Subject: CHUI-380: Fixing a bug that occurred when right clicking nearby chat
 and then right clicking a participant under a conversation. This would result
 in both the participant and conversation to be highlighted. Still a work in
 progress. This change involves introducing an old bug CHUI 289 and finding a
 different approach to solving it.

---
 indra/newview/llconversationview.cpp |  2 +-
 indra/newview/llimconversation.cpp   |  4 ++--
 indra/newview/llimfloater.cpp        |  5 ++++-
 indra/newview/llnearbychat.cpp       | 15 ++++++++-------
 4 files changed, 15 insertions(+), 11 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index f9a3a05e59..70f2446752 100755
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -415,7 +415,7 @@ void LLConversationViewParticipant::draw()
     F32 text_left = (F32)getLabelXPos();
     LLColor4 color = mIsSelected ? sHighlightFgColor : sFgColor;
 
-    drawHighlight(show_context, true, sHighlightBgColor, sFocusOutlineColor, sMouseOverColor);
+    drawHighlight(show_context, mIsSelected, sHighlightBgColor, sFocusOutlineColor, sMouseOverColor);
     drawLabel(font, text_left, y, color, right_x);
 
     LLView::draw();
diff --git a/indra/newview/llimconversation.cpp b/indra/newview/llimconversation.cpp
index 9f3c6d0f3d..2027f79eea 100644
--- a/indra/newview/llimconversation.cpp
+++ b/indra/newview/llimconversation.cpp
@@ -222,8 +222,8 @@ void LLIMConversation::onFocusReceived()
 
 	if (! mHadFocus)
 	{
-	    LLIMFloaterContainer* container = LLIMFloaterContainer::getInstance();
-	    container->setConvItemSelect(mSessionID);
+	//    LLIMFloaterContainer* container = LLIMFloaterContainer::getInstance();
+	//    container->setConvItemSelect(mSessionID);
 	}
 }
 
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index a8add9c6ab..e4032738a7 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -725,6 +725,7 @@ void LLIMFloater::setFocus(BOOL focusFlag)
         updateMessages();
         mInputEditor->setFocus(TRUE);
     }
+    
 }
 
 void LLIMFloater::setVisible(BOOL visible)
@@ -754,8 +755,10 @@ void LLIMFloater::setVisible(BOOL visible)
 	if (visible && isInVisibleChain())
 	{
 		sIMFloaterShowedSignal(mSessionID);
-        setFocus(TRUE);
+        
 	}
+
+    setFocus(visible);
 }
 
 BOOL LLIMFloater::getVisible()
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index a0ddc9b52b..a89ae4a2dc 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -274,23 +274,24 @@ void LLNearbyChat::removeScreenChat()
 void LLNearbyChat::setFocus(BOOL focusFlag)
 {
     LLTransientDockableFloater::setFocus(focusFlag);
-
+    
     //Redirect focus to input editor
     if (focusFlag)
     {
         mInputEditor->setFocus(TRUE);
     }
+    
 }
 
 void	LLNearbyChat::setVisible(BOOL visible)
 {
-	if(visible)
-	{
-		removeScreenChat();
-        setFocus(TRUE);
-	}
-
 	LLIMConversation::setVisible(visible);
+
+    if(visible)
+    {
+        removeScreenChat();
+    }
+    setFocus(visible);
 }
 
 
-- 
cgit v1.2.3


From e1bc3cb096414493203763301314566709cff8bd Mon Sep 17 00:00:00 2001
From: William Todd Stinson <stinson@lindenlab.com>
Date: Thu, 11 Oct 2012 18:25:13 -0700
Subject: MAINT-1684: Correcting the calls to ll_aligned_free() which should
 have actually been to ll_aligned_free_16().

---
 indra/llcommon/llmemory.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index eaa7b58e08..70ad10ad55 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -1426,7 +1426,7 @@ void LLPrivateMemoryPool::freeMem(void* addr)
 	
 	if(!chunk)
 	{
-		ll_aligned_free(addr) ; //release from heap
+		ll_aligned_free_16(addr) ; //release from heap
 	}
 	else
 	{
@@ -1618,7 +1618,7 @@ void LLPrivateMemoryPool::removeChunk(LLMemoryChunk* chunk)
 	mReservedPoolSize -= chunk->getBufferSize() ;
 	
 	//release memory
-	ll_aligned_free(chunk->getBuffer()) ;
+	ll_aligned_free_16(chunk->getBuffer()) ;
 }
 
 U16 LLPrivateMemoryPool::findHashKey(const char* addr)
@@ -2016,7 +2016,7 @@ void  LLPrivateMemoryPoolManager::freeMem(LLPrivateMemoryPool* poolp, void* addr
 	{
 		if(!sPrivatePoolEnabled)
 		{
-			ll_aligned_free(addr) ; //private pool is disabled.
+			ll_aligned_free_16(addr) ; //private pool is disabled.
 		}
 		else if(!sInstance) //the private memory manager is destroyed, try the dangling list
 		{
-- 
cgit v1.2.3


From 9aa03f0bf284bbfa3f50883351c6e39f7ffa41c5 Mon Sep 17 00:00:00 2001
From: MaximB ProductEngine <mberezhnoy@productengine.com>
Date: Fri, 12 Oct 2012 14:29:44 +0300
Subject: CHUI-402 (Double-click on conversation participant should begin IM
 session)

---
 indra/newview/llimfloatercontainer.cpp | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'indra')

diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 5f111b39d4..0f44d42780 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -142,6 +142,9 @@ BOOL LLIMFloaterContainer::postBuild()
 	
 	mConversationsListPanel = getChild<LLPanel>("conversations_list_panel");
 
+	// Open IM session with selected participant on double click event
+	mConversationsListPanel->setDoubleClickCallback(boost::bind(&LLIMFloaterContainer::doToSelected, this, LLSD("im")));
+
 	// Create the root model and view for all conversation sessions
 	LLConversationItem* base_item = new LLConversationItem(getRootViewModel());
 
-- 
cgit v1.2.3


From 19c5b35a86dbe641fe397baf9a8194d78e440af8 Mon Sep 17 00:00:00 2001
From: maksymsproductengine <maksymsproductengine@lindenlab.com>
Date: Fri, 12 Oct 2012 20:10:13 +0300
Subject: CHUI-385 FIXED All user's do not receive ad hoc messages after adding
 a user to a conversation

---
 indra/newview/llimfloatercontainer.cpp | 15 ++++++++++-----
 indra/newview/llimfloatercontainer.h   |  4 ++--
 indra/newview/llimview.cpp             |  9 ++++++---
 3 files changed, 18 insertions(+), 10 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 0f44d42780..2248699e5e 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -109,8 +109,7 @@ void LLIMFloaterContainer::sessionVoiceOrIMStarted(const LLUUID& session_id)
 
 void LLIMFloaterContainer::sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id)
 {
-	removeConversationListItem(old_session_id);
-	addConversationListItem(new_session_id);
+	addConversationListItem(new_session_id, removeConversationListItem(old_session_id));
 }
 
 void LLIMFloaterContainer::sessionRemoved(const LLUUID& session_id)
@@ -1118,7 +1117,7 @@ void LLIMFloaterContainer::setNearbyDistances()
 	}
 }
 
-void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid)
+void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid, bool isWidgetSelected /*= false*/)
 {
 	bool is_nearby_chat = uuid.isNull();
 	
@@ -1173,7 +1172,10 @@ void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid)
 		current_participant_model++;
 	}
 
-	setConvItemSelect(uuid);
+	if (isWidgetSelected)
+	{
+		setConvItemSelect(uuid);
+	}
 	
 	// set the widget to minimized mode if conversations pane is collapsed
 	widget->toggleMinimizedMode(mConversationsPane->isCollapsed());
@@ -1181,17 +1183,19 @@ void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid)
 	return;
 }
 
-void LLIMFloaterContainer::removeConversationListItem(const LLUUID& uuid, bool change_focus)
+bool LLIMFloaterContainer::removeConversationListItem(const LLUUID& uuid, bool change_focus)
 {
 	// Delete the widget and the associated conversation item
 	// Note : since the mConversationsItems is also the listener to the widget, deleting 
 	// the widget will also delete its listener
+	bool isWidgetSelected = false;
 	conversations_widgets_map::iterator widget_it = mConversationsWidgets.find(uuid);
 	if (widget_it != mConversationsWidgets.end())
 	{
 		LLFolderViewItem* widget = widget_it->second;
 		if (widget)
 		{
+			isWidgetSelected = widget->isSelected();
 			widget->destroyView();
 		}
 	}
@@ -1211,6 +1215,7 @@ void LLIMFloaterContainer::removeConversationListItem(const LLUUID& uuid, bool c
 			widget->selectItem();
 		}
 	}
+	return isWidgetSelected;
 }
 
 LLConversationViewSession* LLIMFloaterContainer::createConversationItemWidget(LLConversationItem* item)
diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h
index ceb054dfa3..5c11577154 100644
--- a/indra/newview/llimfloatercontainer.h
+++ b/indra/newview/llimfloatercontainer.h
@@ -133,8 +133,8 @@ private:
 
 	// Conversation list implementation
 public:
-	void removeConversationListItem(const LLUUID& uuid, bool change_focus = true);
-	void addConversationListItem(const LLUUID& uuid);
+	bool removeConversationListItem(const LLUUID& uuid, bool change_focus = true);
+	void addConversationListItem(const LLUUID& uuid, bool isWidgetSelected = false);
 	void setTimeNow(const LLUUID& session_id, const LLUUID& participant_id);
 	void setNearbyDistances();
 
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index a604c884ca..aa5b9ce006 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -643,6 +643,12 @@ void LLIMModel::processSessionInitializedReply(const LLUUID& old_session_id, con
 	{
 		session->sessionInitReplyReceived(new_session_id);
 
+		if (old_session_id != new_session_id)
+		{
+			mId2SessionMap.erase(old_session_id);
+			mId2SessionMap[new_session_id] = session;
+		}
+
 		LLIMFloater* im_floater = LLIMFloater::findInstance(old_session_id);
 		if (im_floater)
 		{
@@ -651,9 +657,6 @@ void LLIMModel::processSessionInitializedReply(const LLUUID& old_session_id, con
 
 		if (old_session_id != new_session_id)
 		{
-			mId2SessionMap.erase(old_session_id);
-			mId2SessionMap[new_session_id] = session;
-
 			gIMMgr->notifyObserverSessionIDUpdated(old_session_id, new_session_id);
 		}
 
-- 
cgit v1.2.3


From d7d0416547958792517a9b739b370e51c717fb23 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Fri, 12 Oct 2012 20:15:57 -0700
Subject: CHUI-380: (In progress) Refactoring needed to fix focusing issues
 when selecting an existing conversation item. This commit resolves
 re-introducing bug CHUI-289. Will code review and cleanup code in next
 commit.

---
 indra/llkdu/llimagej2ckdu.cpp          |  4 ++--
 indra/newview/llchiclet.h              |  1 +
 indra/newview/llchicletbar.h           |  1 +
 indra/newview/llconversationlog.h      |  1 +
 indra/newview/llconversationview.cpp   |  6 ++++--
 indra/newview/llimconversation.cpp     | 11 -----------
 indra/newview/llimconversation.h       |  3 ---
 indra/newview/llimfloatercontainer.cpp | 19 +++++++++++++++++++
 indra/newview/llimfloatercontainer.h   |  3 +++
 indra/newview/llimview.cpp             | 13 +++++++++++++
 indra/newview/llimview.h               |  2 ++
 indra/newview/llsyswellwindow.h        |  1 +
 12 files changed, 47 insertions(+), 18 deletions(-)

(limited to 'indra')

diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp
index cf88de12b4..db75b6e003 100644
--- a/indra/llkdu/llimagej2ckdu.cpp
+++ b/indra/llkdu/llimagej2ckdu.cpp
@@ -166,12 +166,12 @@ void LLKDUMessageWarning::put_text(const kdu_uint16 *s)
 
 void LLKDUMessageError::put_text(const char *s)
 {
-	llinfos << "KDU Error: " << s << llendl;
+	//llinfos << "KDU Error: " << s << llendl;
 }
 
 void LLKDUMessageError::put_text(const kdu_uint16 *s)
 {
-	llinfos << "KDU Error: " << s << llendl;
+	//llinfos << "KDU Error: " << s << llendl;
 }
 
 void LLKDUMessageError::flush(bool end_of_message)
diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h
index f51d7b622c..3a52b0a67b 100644
--- a/indra/newview/llchiclet.h
+++ b/indra/newview/llchiclet.h
@@ -874,6 +874,7 @@ class LLIMWellChiclet : public LLSysWellChiclet, LLIMSessionObserver
 	friend class LLUICtrlFactory;
 public:
 	/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}
+    /*virtual*/ void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}
 	/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id) {};
 	/*virtual*/ void sessionRemoved(const LLUUID& session_id) { messageCountChanged(LLSD()); }
 	/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id) {}
diff --git a/indra/newview/llchicletbar.h b/indra/newview/llchicletbar.h
index 7d0d904810..0589a9fccc 100644
--- a/indra/newview/llchicletbar.h
+++ b/indra/newview/llchicletbar.h
@@ -51,6 +51,7 @@ public:
 
 	// LLIMSessionObserver observe triggers
 	/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
+    /*virtual*/ void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {};
 	/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id) {};
 	/*virtual*/ void sessionRemoved(const LLUUID& session_id);
 	/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h
index 373406aa6f..70f04b21c8 100644
--- a/indra/newview/llconversationlog.h
+++ b/indra/newview/llconversationlog.h
@@ -124,6 +124,7 @@ public:
 
 	// LLIMSessionObserver triggers
 	virtual void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
+    virtual void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}; // Stub
 	virtual void sessionRemoved(const LLUUID& session_id){}											// Stub
 	virtual void sessionVoiceOrIMStarted(const LLUUID& session_id){};								// Stub
 	virtual void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id){};	// Stub
diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index 70f2446752..637f30635e 100755
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -424,8 +424,10 @@ void LLConversationViewParticipant::draw()
 void LLConversationViewParticipant::selectItem()
 {
     LLConversationItem* vmi = this->getParentFolder() ? static_cast<LLConversationItem*>(this->getParentFolder()->getViewModelItem()) : NULL;
-    
-    if(vmi)
+    LLIMFloaterContainer* container = LLIMFloaterContainer::getInstance();
+
+    //Only execute when switching floaters (conversations)
+    if(vmi && vmi->getUUID() != container->getSelectedSession())
     {
         //When null, show the nearby chat conversation floater
         if(vmi->getUUID().isNull())
diff --git a/indra/newview/llimconversation.cpp b/indra/newview/llimconversation.cpp
index 2027f79eea..bd2a2419a8 100644
--- a/indra/newview/llimconversation.cpp
+++ b/indra/newview/llimconversation.cpp
@@ -54,7 +54,6 @@ LLIMConversation::LLIMConversation(const LLSD& session_id)
   , mInputEditor(NULL)
   , mInputEditorTopPad(0)
   , mRefreshTimer(new LLTimer())
-  , mHasFocus(false)
 {
 	mSession = LLIMModel::getInstance()->findIMSession(mSessionID);
 
@@ -216,21 +215,11 @@ void LLIMConversation::onFocusReceived()
 	}
 
 	LLTransientDockableFloater::onFocusReceived();
-
-    mHadFocus = mHasFocus;
-    mHasFocus = true;
-
-	if (! mHadFocus)
-	{
-	//    LLIMFloaterContainer* container = LLIMFloaterContainer::getInstance();
-	//    container->setConvItemSelect(mSessionID);
-	}
 }
 
 void LLIMConversation::onFocusLost()
 {
 	setBackgroundOpaque(false);
-	mHasFocus = false;
 	LLTransientDockableFloater::onFocusLost();
 }
 
diff --git a/indra/newview/llimconversation.h b/indra/newview/llimconversation.h
index 0960d6db88..603e0d0197 100644
--- a/indra/newview/llimconversation.h
+++ b/indra/newview/llimconversation.h
@@ -141,9 +141,6 @@ private:
 	bool checkIfTornOff();
 
 	LLTimer* mRefreshTimer; ///< Defines the rate at which refresh() is called.
-
-	bool mHadFocus;
-	bool mHasFocus;
 };
 
 
diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 5f111b39d4..0250854f36 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -101,6 +101,11 @@ void LLIMFloaterContainer::sessionAdded(const LLUUID& session_id, const std::str
 	addConversationListItem(session_id);
 }
 
+void LLIMFloaterContainer::sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
+{
+    doSomething(session_id);
+}
+
 void LLIMFloaterContainer::sessionVoiceOrIMStarted(const LLUUID& session_id)
 {
 	LLIMFloater::addToHost(session_id, true);
@@ -1069,6 +1074,19 @@ void LLIMFloaterContainer::setConvItemSelect(const LLUUID& session_id)
 	}
 }
 
+void LLIMFloaterContainer::doSomething(const LLUUID& session_id)
+{
+    LLConversationItem* vmi = static_cast<LLConversationItem*>(mConversationsRoot->getCurSelectedItem()->getParentFolder()->getViewModelItem());
+
+    if(session_id != vmi->getUUID())
+    {
+        mSelectedSession = session_id;
+        LLFolderViewItem* widget = mConversationsWidgets[session_id];
+        (widget->getRoot())->setSelection(widget, FALSE, FALSE);
+    }
+}
+
+
 void LLIMFloaterContainer::setTimeNow(const LLUUID& session_id, const LLUUID& participant_id)
 {
 	conversations_items_map::iterator item_it = mConversationsItems.find(session_id);
@@ -1204,6 +1222,7 @@ void LLIMFloaterContainer::removeConversationListItem(const LLUUID& uuid, bool c
 		conversations_widgets_map::iterator widget_it = mConversationsWidgets.begin();
 		if (widget_it != mConversationsWidgets.end())
 		{
+            mSelectedSession = widget_it->first;
 			LLFolderViewItem* widget = widget_it->second;
 			widget->selectItem();
 		}
diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h
index ceb054dfa3..da134c498f 100644
--- a/indra/newview/llimfloatercontainer.h
+++ b/indra/newview/llimfloatercontainer.h
@@ -64,6 +64,7 @@ public:
 								BOOL select_added_floater, 
 								LLTabContainer::eInsertionPoint insertion_point = LLTabContainer::END);
     void setConvItemSelect(const LLUUID& session_id);
+    void doSomething(const LLUUID& session_id);
 	/*virtual*/ void tabClose();
 
 	static LLFloater* getCurrentVoiceFloater();
@@ -81,11 +82,13 @@ public:
 
 	// LLIMSessionObserver observe triggers
 	/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
+    /*virtual*/ void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
 	/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id);
 	/*virtual*/ void sessionRemoved(const LLUUID& session_id);
 	/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
 
 	LLConversationViewModel& getRootViewModel() { return mConversationViewModel; }
+    LLUUID getSelectedSession() { return mSelectedSession; }
 
 private:
 	typedef std::map<LLUUID,LLFloater*> avatarID_panel_map_t;
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index a604c884ca..e75db1b7af 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -2654,6 +2654,11 @@ LLUUID LLIMMgr::addSession(
 	{
 		LLIMModel::getInstance()->newSession(session_id, name, dialog, other_participant_id, ids, voice);
 	}
+    else
+    {
+        std::string session_name = LLIMModel::getInstance()->getName(session_id);
+        LLIMMgr::getInstance()->notifyObserverSessionAlreadyAdded(session_id, session_name, other_participant_id);
+    }
 
 	//we don't need to show notes about online/offline, mute/unmute users' statuses for existing sessions
 	if (!new_session) return session_id;
@@ -2956,6 +2961,14 @@ void LLIMMgr::notifyObserverSessionAdded(const LLUUID& session_id, const std::st
 	}
 }
 
+void LLIMMgr::notifyObserverSessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
+{
+    for (session_observers_list_t::iterator it = mSessionObservers.begin(); it != mSessionObservers.end(); it++)
+    {
+        (*it)->sessionAlreadyAdded(session_id, name, other_participant_id);
+    }
+}
+
 void LLIMMgr::notifyObserverSessionVoiceOrIMStarted(const LLUUID& session_id)
 {
 	for (session_observers_list_t::iterator it = mSessionObservers.begin(); it != mSessionObservers.end(); it++)
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index 82cfa394a6..a34359eb00 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -303,6 +303,7 @@ class LLIMSessionObserver
 public:
 	virtual ~LLIMSessionObserver() {}
 	virtual void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) = 0;
+    virtual void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) = 0;
 	virtual void sessionVoiceOrIMStarted(const LLUUID& session_id) = 0;
 	virtual void sessionRemoved(const LLUUID& session_id) = 0;
 	virtual void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id) = 0;
@@ -469,6 +470,7 @@ private:
 	static void onInviteNameLookup(LLSD payload, const LLUUID& id, const std::string& name, bool is_group);
 
 	void notifyObserverSessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
+    void notifyObserverSessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
 	void notifyObserverSessionVoiceOrIMStarted(const LLUUID& session_id);
 	void notifyObserverSessionRemoved(const LLUUID& session_id);
 	void notifyObserverSessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
diff --git a/indra/newview/llsyswellwindow.h b/indra/newview/llsyswellwindow.h
index 6be12711ac..302007c9aa 100644
--- a/indra/newview/llsyswellwindow.h
+++ b/indra/newview/llsyswellwindow.h
@@ -171,6 +171,7 @@ public:
 
 	// LLIMSessionObserver observe triggers
 	/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
+    /*virtual*/ void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}
 	/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id) {};
 	/*virtual*/ void sessionRemoved(const LLUUID& session_id);
 	/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
-- 
cgit v1.2.3


From f609f4cca3a91c8d6ea7c55b61d0b2cfd29be6b7 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Mon, 15 Oct 2012 13:55:12 +0300
Subject: CHUI-400 FIXED Disable "Activate Group" menu item if selected group
 is the active group

---
 indra/newview/llimfloatercontainer.cpp                   | 6 ++++++
 indra/newview/skins/default/xui/en/menu_conversation.xml | 1 +
 2 files changed, 7 insertions(+)

(limited to 'indra')

diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 2248699e5e..16751a6ea1 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -961,6 +961,12 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata)
     uuid_vec_t mUUIDs;
     getParticipantUUIDs(mUUIDs);
 
+    if(item == std::string("can_activate_group"))
+    {
+    	LLUUID selected_group_id = getCurSelectedViewModelItem()->getUUID();
+    	return gAgent.getGroupID() != selected_group_id;
+    }
+
     if(mUUIDs.size() <= 0)
     {
         return false;
diff --git a/indra/newview/skins/default/xui/en/menu_conversation.xml b/indra/newview/skins/default/xui/en/menu_conversation.xml
index 912ff811d9..682d70e4f0 100644
--- a/indra/newview/skins/default/xui/en/menu_conversation.xml
+++ b/indra/newview/skins/default/xui/en/menu_conversation.xml
@@ -117,6 +117,7 @@
      layout="topleft"
      name="activate_group">
         <on_click function="Group.DoToSelected" parameter="activate_group"/>
+        <on_enable function="Avatar.EnableItem" parameter="can_activate_group" />
     </menu_item_call>		
     <menu_item_call
      label="Leave Group"
-- 
cgit v1.2.3


From 5a5df259ffc23a6289d25deac906047a7356fb42 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Mon, 15 Oct 2012 13:58:21 -0700
Subject: CHUI-380: Final commit for this issue. After code review changed some
 method names to be more accurate. Also using dynamic_cast instead of
 static_cast for safety.

---
 indra/llkdu/llimagej2ckdu.cpp          |  4 ++--
 indra/newview/llchiclet.h              |  2 +-
 indra/newview/llchicletbar.h           |  2 +-
 indra/newview/llconversationlog.h      |  2 +-
 indra/newview/llimfloatercontainer.cpp | 24 ++++++++++++++++--------
 indra/newview/llimfloatercontainer.h   |  4 ++--
 indra/newview/llimview.cpp             |  8 +++++---
 indra/newview/llimview.h               |  5 +++--
 indra/newview/llsyswellwindow.h        |  2 +-
 9 files changed, 32 insertions(+), 21 deletions(-)

(limited to 'indra')

diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp
index db75b6e003..cf88de12b4 100644
--- a/indra/llkdu/llimagej2ckdu.cpp
+++ b/indra/llkdu/llimagej2ckdu.cpp
@@ -166,12 +166,12 @@ void LLKDUMessageWarning::put_text(const kdu_uint16 *s)
 
 void LLKDUMessageError::put_text(const char *s)
 {
-	//llinfos << "KDU Error: " << s << llendl;
+	llinfos << "KDU Error: " << s << llendl;
 }
 
 void LLKDUMessageError::put_text(const kdu_uint16 *s)
 {
-	//llinfos << "KDU Error: " << s << llendl;
+	llinfos << "KDU Error: " << s << llendl;
 }
 
 void LLKDUMessageError::flush(bool end_of_message)
diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h
index 3a52b0a67b..6395f5b694 100644
--- a/indra/newview/llchiclet.h
+++ b/indra/newview/llchiclet.h
@@ -874,7 +874,7 @@ class LLIMWellChiclet : public LLSysWellChiclet, LLIMSessionObserver
 	friend class LLUICtrlFactory;
 public:
 	/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}
-    /*virtual*/ void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}
+    /*virtual*/ void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}
 	/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id) {};
 	/*virtual*/ void sessionRemoved(const LLUUID& session_id) { messageCountChanged(LLSD()); }
 	/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id) {}
diff --git a/indra/newview/llchicletbar.h b/indra/newview/llchicletbar.h
index 0589a9fccc..a9a5b61ae7 100644
--- a/indra/newview/llchicletbar.h
+++ b/indra/newview/llchicletbar.h
@@ -51,7 +51,7 @@ public:
 
 	// LLIMSessionObserver observe triggers
 	/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
-    /*virtual*/ void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {};
+    /*virtual*/ void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {};
 	/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id) {};
 	/*virtual*/ void sessionRemoved(const LLUUID& session_id);
 	/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h
index 70f04b21c8..b92cf0f5e2 100644
--- a/indra/newview/llconversationlog.h
+++ b/indra/newview/llconversationlog.h
@@ -124,7 +124,7 @@ public:
 
 	// LLIMSessionObserver triggers
 	virtual void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
-    virtual void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}; // Stub
+    virtual void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}; // Stub
 	virtual void sessionRemoved(const LLUUID& session_id){}											// Stub
 	virtual void sessionVoiceOrIMStarted(const LLUUID& session_id){};								// Stub
 	virtual void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id){};	// Stub
diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 0250854f36..c8897c1f92 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -101,9 +101,9 @@ void LLIMFloaterContainer::sessionAdded(const LLUUID& session_id, const std::str
 	addConversationListItem(session_id);
 }
 
-void LLIMFloaterContainer::sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
+void LLIMFloaterContainer::sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
 {
-    doSomething(session_id);
+    setItemSelect(session_id);
 }
 
 void LLIMFloaterContainer::sessionVoiceOrIMStarted(const LLUUID& session_id)
@@ -1064,6 +1064,7 @@ bool LLIMFloaterContainer::checkContextMenuItem(const LLSD& userdata)
     return false;
 }
 
+//Will select only the conversation item
 void LLIMFloaterContainer::setConvItemSelect(const LLUUID& session_id)
 {
 	LLFolderViewItem* widget = mConversationsWidgets[session_id];
@@ -1074,15 +1075,22 @@ void LLIMFloaterContainer::setConvItemSelect(const LLUUID& session_id)
 	}
 }
 
-void LLIMFloaterContainer::doSomething(const LLUUID& session_id)
+//Will select the conversation/participant item
+void LLIMFloaterContainer::setItemSelect(const LLUUID& session_id)
 {
-    LLConversationItem* vmi = static_cast<LLConversationItem*>(mConversationsRoot->getCurSelectedItem()->getParentFolder()->getViewModelItem());
 
-    if(session_id != vmi->getUUID())
+    if(mConversationsRoot->getCurSelectedItem() && mConversationsRoot->getCurSelectedItem()->getParentFolder())
     {
-        mSelectedSession = session_id;
-        LLFolderViewItem* widget = mConversationsWidgets[session_id];
-        (widget->getRoot())->setSelection(widget, FALSE, FALSE);
+        //Retreive the conversation id. When a participant is selected, then have to to get the converation id from the parent.
+        LLConversationItem* vmi = dynamic_cast<LLConversationItem*>(mConversationsRoot->getCurSelectedItem()->getParentFolder()->getViewModelItem());
+
+        //Will allow selection/highlighting of the conversation/participant
+        if(session_id != vmi->getUUID())
+        {
+            mSelectedSession = session_id;
+            LLFolderViewItem* widget = mConversationsWidgets[session_id];
+            (widget->getRoot())->setSelection(widget, FALSE, FALSE);
+        }
     }
 }
 
diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h
index da134c498f..c9da213f8c 100644
--- a/indra/newview/llimfloatercontainer.h
+++ b/indra/newview/llimfloatercontainer.h
@@ -64,7 +64,7 @@ public:
 								BOOL select_added_floater, 
 								LLTabContainer::eInsertionPoint insertion_point = LLTabContainer::END);
     void setConvItemSelect(const LLUUID& session_id);
-    void doSomething(const LLUUID& session_id);
+    void setItemSelect(const LLUUID& session_id);
 	/*virtual*/ void tabClose();
 
 	static LLFloater* getCurrentVoiceFloater();
@@ -82,7 +82,7 @@ public:
 
 	// LLIMSessionObserver observe triggers
 	/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
-    /*virtual*/ void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
+    /*virtual*/ void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
 	/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id);
 	/*virtual*/ void sessionRemoved(const LLUUID& session_id);
 	/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index e75db1b7af..eea59c223a 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -2650,14 +2650,16 @@ LLUUID LLIMMgr::addSession(
 		}
 	}
 
+    //Notify observers that a session was added
 	if (new_session)
 	{
 		LLIMModel::getInstance()->newSession(session_id, name, dialog, other_participant_id, ids, voice);
 	}
+    //Notifies observers that the session was already added
     else
     {
         std::string session_name = LLIMModel::getInstance()->getName(session_id);
-        LLIMMgr::getInstance()->notifyObserverSessionAlreadyAdded(session_id, session_name, other_participant_id);
+        LLIMMgr::getInstance()->notifyObserverSessionActivated(session_id, session_name, other_participant_id);
     }
 
 	//we don't need to show notes about online/offline, mute/unmute users' statuses for existing sessions
@@ -2961,11 +2963,11 @@ void LLIMMgr::notifyObserverSessionAdded(const LLUUID& session_id, const std::st
 	}
 }
 
-void LLIMMgr::notifyObserverSessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
+void LLIMMgr::notifyObserverSessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
 {
     for (session_observers_list_t::iterator it = mSessionObservers.begin(); it != mSessionObservers.end(); it++)
     {
-        (*it)->sessionAlreadyAdded(session_id, name, other_participant_id);
+        (*it)->sessionActivated(session_id, name, other_participant_id);
     }
 }
 
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index a34359eb00..00b67f520c 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -303,7 +303,7 @@ class LLIMSessionObserver
 public:
 	virtual ~LLIMSessionObserver() {}
 	virtual void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) = 0;
-    virtual void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) = 0;
+    virtual void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) = 0;
 	virtual void sessionVoiceOrIMStarted(const LLUUID& session_id) = 0;
 	virtual void sessionRemoved(const LLUUID& session_id) = 0;
 	virtual void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id) = 0;
@@ -470,7 +470,8 @@ private:
 	static void onInviteNameLookup(LLSD payload, const LLUUID& id, const std::string& name, bool is_group);
 
 	void notifyObserverSessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
-    void notifyObserverSessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
+    //Triggers when a session has already been added
+    void notifyObserverSessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
 	void notifyObserverSessionVoiceOrIMStarted(const LLUUID& session_id);
 	void notifyObserverSessionRemoved(const LLUUID& session_id);
 	void notifyObserverSessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
diff --git a/indra/newview/llsyswellwindow.h b/indra/newview/llsyswellwindow.h
index 302007c9aa..378d5e0aa2 100644
--- a/indra/newview/llsyswellwindow.h
+++ b/indra/newview/llsyswellwindow.h
@@ -171,7 +171,7 @@ public:
 
 	// LLIMSessionObserver observe triggers
 	/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
-    /*virtual*/ void sessionAlreadyAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}
+    /*virtual*/ void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) {}
 	/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id) {};
 	/*virtual*/ void sessionRemoved(const LLUUID& session_id);
 	/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
-- 
cgit v1.2.3


From c97730988eccf10ce8a93e3f564d2b248b17abc8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 15 Oct 2012 15:59:41 -0500
Subject: MAINT-1721 Fix for crash when clicking "back" button after editing
 appearance.

Reviewed by VoidPointer
---
 indra/llimage/llimage.cpp    | 6 ++++++
 indra/llimage/llimage.h      | 2 +-
 indra/newview/lltexlayer.cpp | 8 +++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 6775b005f4..825878c5ef 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -1660,6 +1660,12 @@ static void avg4_colors2(const U8* a, const U8* b, const U8* c, const U8* d, U8*
 	dst[1] = (U8)(((U32)(a[1]) + b[1] + c[1] + d[1])>>2);
 }
 
+void LLImageBase::setDataAndSize(U8 *data, S32 size)
+{ 
+	ll_assert_aligned(data, 16);
+	mData = data; mDataSize = size; 
+}	
+
 //static
 void LLImageBase::generateMip(const U8* indata, U8* mipdata, S32 width, S32 height, S32 nchannels)
 {
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 46e6d1a901..9ce77a0d01 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -148,7 +148,7 @@ public:
 
 protected:
 	// special accessor to allow direct setting of mData and mDataSize by LLImageFormatted
-	void setDataAndSize(U8 *data, S32 size) { mData = data; mDataSize = size; }	
+	void setDataAndSize(U8 *data, S32 size);
 	
 public:
 	static void generateMip(const U8 *indata, U8* mipdata, int width, int height, S32 nchannels);
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index 467115c928..ad09af6594 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -510,7 +510,13 @@ void LLTexLayerSetBuffer::doUpload()
 			BOOL valid = FALSE;
 			LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C;
 			S32 file_size = 0;
-			U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size);
+			
+			//data buffer MUST be allocated using LLImageBase
+			LLVFile file(gVFS, asset_id, LLAssetType::AT_TEXTURE);
+			file_size = file.getSize();
+			U8* data = integrity_test->allocateData(file_size);
+			file.read(data, file_size);
+			
 			if (data)
 			{
 				valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data'
-- 
cgit v1.2.3


From 699e0a1e0b89e4d3c2d1342c821496c5699b8c52 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Mon, 15 Oct 2012 14:28:07 -0700
Subject: CHUI-380: Merge fix, the addConverationListItem API was changedso
 that it does not by default select the new conversation item. Adjusted
 sessionAdded and sessionVoiceOrImStarted functions to specify that the first
 item should be selected when calling addConversationListItem().

---
 indra/newview/llimfloatercontainer.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 8a30b5cd68..5c1105531e 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -98,7 +98,7 @@ LLIMFloaterContainer::~LLIMFloaterContainer()
 void LLIMFloaterContainer::sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
 {
 	LLIMFloater::addToHost(session_id, true);
-	addConversationListItem(session_id);
+	addConversationListItem(session_id, true);
 }
 
 void LLIMFloaterContainer::sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
@@ -109,7 +109,7 @@ void LLIMFloaterContainer::sessionActivated(const LLUUID& session_id, const std:
 void LLIMFloaterContainer::sessionVoiceOrIMStarted(const LLUUID& session_id)
 {
 	LLIMFloater::addToHost(session_id, true);
-	addConversationListItem(session_id);
+	addConversationListItem(session_id, true);
 }
 
 void LLIMFloaterContainer::sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id)
-- 
cgit v1.2.3


From d0f9600f37a87b2d6c7a2c3cfbbc5d793e505872 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Mon, 15 Oct 2012 16:06:02 -0700
Subject: CHUI-380: Bug fix after merge. When selecting the participant of a
 conversation focus would be lost on the converstation floater. This was
 because focus would be set to the participant folder item. Resolution: Now
 delegate focus from the particiapnt folder item to the conversation floater.

---
 indra/newview/llconversationview.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'indra')

diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index 637f30635e..b7ebb70e86 100755
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -425,6 +425,7 @@ void LLConversationViewParticipant::selectItem()
 {
     LLConversationItem* vmi = this->getParentFolder() ? static_cast<LLConversationItem*>(this->getParentFolder()->getViewModelItem()) : NULL;
     LLIMFloaterContainer* container = LLIMFloaterContainer::getInstance();
+    LLFloater* session_floater;
 
     //Only execute when switching floaters (conversations)
     if(vmi && vmi->getUUID() != container->getSelectedSession())
@@ -441,6 +442,12 @@ void LLConversationViewParticipant::selectItem()
             LLIMFloater::show(vmi->getUUID());
         }
     }
+    //Focus the current conversation floater (it is already visible so just focus it)
+    else
+    {
+        session_floater = LLIMConversation::getConversation(vmi->getUUID());
+        session_floater->setFocus(TRUE);
+    }
 
     LLFolderViewItem::selectItem();
 }
-- 
cgit v1.2.3


From 5a22949cf509ebd1a3c7dfbd029b4bc188fee4a3 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Tue, 16 Oct 2012 15:33:12 +0300
Subject: CHUI-388 FIXED Do not add menu items to Participant Menu if own
 avatar is selected in participant list. Do not show Menu if all menu items
 are disabled.

---
 indra/llui/llmenugl.cpp               | 12 +++++++++++-
 indra/newview/llconversationmodel.cpp |  6 +++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 5182a8cea1..ae4aa1e1dd 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -3037,7 +3037,17 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
 	const S32 CURSOR_HEIGHT = 22;		// Approximate "normal" cursor size
 	const S32 CURSOR_WIDTH = 12;
 
-	if(menu->getChildList()->empty())
+	//Do not show menu if all menu items are disabled
+	BOOL item_enabled = false;
+	for (LLView::child_list_t::const_iterator itor = menu->getChildList()->begin();
+			 itor != menu->getChildList()->end();
+			 ++itor)
+	{
+		LLView *menu_item = (*itor);
+		item_enabled = item_enabled || menu_item->getEnabled();
+	}
+
+	if(menu->getChildList()->empty() || !item_enabled)
 	{
 		return;
 	}
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp
index 29e7ac4e12..e5232d730c 100644
--- a/indra/newview/llconversationmodel.cpp
+++ b/indra/newview/llconversationmodel.cpp
@@ -27,6 +27,7 @@
 
 #include "llviewerprecompiledheaders.h"
 
+#include "llagent.h"
 #include "llavatarnamecache.h"
 #include "llavataractions.h"
 #include "llevents.h"
@@ -374,7 +375,10 @@ void LLConversationItemParticipant::buildContextMenu(LLMenuGL& menu, U32 flags)
     menuentry_vec_t items;
     menuentry_vec_t disabled_items;
 
-    buildParticipantMenuOptions(items);
+    if(gAgent.getID() != mUUID)
+    {
+    	buildParticipantMenuOptions(items);
+    }
     hide_context_entries(menu, items, disabled_items);
 }
 
-- 
cgit v1.2.3


From ae093e02a126666c9137d9eb6d9aeea0c1c73a8a Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Tue, 16 Oct 2012 11:38:36 -0700
Subject: CHUI-380: Realized that the when clicking the
 participant/conversation item that the active session wasn't being stored.
 This caused the right side conversation floater to not change when selecting
 a participant under a conersation. Resolution: now when clicking on a
 conversation or participant the active session is stored using
 setActiveSession().

---
 indra/newview/llconversationview.cpp | 6 ++++++
 indra/newview/llimfloatercontainer.h | 1 +
 2 files changed, 7 insertions(+)

(limited to 'indra')

diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index b7ebb70e86..1b450665b3 100755
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -242,6 +242,9 @@ void LLConversationViewSession::selectItem()
 	
 	// Set the focus on the selected floater
 	session_floater->setFocus(TRUE);
+    // Store the active session
+    LLIMFloaterContainer::getInstance()->setSelectedSession(item->getUUID());
+
 
 	LLFolderViewItem::selectItem();
 }
@@ -441,6 +444,9 @@ void LLConversationViewParticipant::selectItem()
         {
             LLIMFloater::show(vmi->getUUID());
         }
+
+        // Store the active session
+        container->setSelectedSession(vmi->getUUID());
     }
     //Focus the current conversation floater (it is already visible so just focus it)
     else
diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h
index 6643471d97..579f62c688 100644
--- a/indra/newview/llimfloatercontainer.h
+++ b/indra/newview/llimfloatercontainer.h
@@ -89,6 +89,7 @@ public:
 
 	LLConversationViewModel& getRootViewModel() { return mConversationViewModel; }
     LLUUID getSelectedSession() { return mSelectedSession; }
+    void setSelectedSession(LLUUID sessionID) { mSelectedSession = sessionID; }
 
 private:
 	typedef std::map<LLUUID,LLFloater*> avatarID_panel_map_t;
-- 
cgit v1.2.3


From 1251f45e6246d81658cf4fe6f2654472c772e94b Mon Sep 17 00:00:00 2001
From: maksymsproductengine <maksymsproductengine@lindenlab.com>
Date: Wed, 17 Oct 2012 00:16:18 +0300
Subject: CHUI-394 FIXED Group moderation tools missing in right click menus

---
 indra/llui/llmenugl.cpp                            | 117 +++----
 indra/llui/llmenugl.h                              |  35 +-
 indra/llui/lltoggleablemenu.cpp                    |   5 +
 indra/llui/lltoggleablemenu.h                      |   2 +
 indra/newview/llconversationmodel.cpp              |  13 +
 indra/newview/llimfloatercontainer.cpp             | 344 ++++++++++++++++----
 indra/newview/llimfloatercontainer.h               |  13 +
 indra/newview/llinventorybridge.cpp                |   2 +-
 indra/newview/llparticipantlist.cpp                | 361 ---------------------
 indra/newview/llparticipantlist.h                  |  75 -----
 .../skins/default/xui/en/menu_conversation.xml     |  45 +++
 11 files changed, 435 insertions(+), 577 deletions(-)

(limited to 'indra')

diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index ae4aa1e1dd..93dc13475b 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -1764,6 +1764,26 @@ bool LLMenuGL::addChild(LLView* view, S32 tab_group)
 	return false;
 }
 
+// Used in LLContextMenu and in LLTogleableMenu
+
+// Add an item to the context menu branch
+bool LLMenuGL::addContextChild(LLView* view, S32 tab_group)
+{
+	LLContextMenu* context = dynamic_cast<LLContextMenu*>(view);
+	if (context)
+		return appendContextSubMenu(context);
+
+	LLMenuItemSeparatorGL* separator = dynamic_cast<LLMenuItemSeparatorGL*>(view);
+	if (separator)
+		return append(separator);
+
+	LLMenuItemGL* item = dynamic_cast<LLMenuItemGL*>(view);
+	if (item)
+		return append(item);
+
+	return false;
+}
+
 void LLMenuGL::removeChild( LLView* ctrl)
 {
 	// previously a dynamic_cast with if statement to check validity
@@ -2501,6 +2521,32 @@ BOOL LLMenuGL::appendMenu( LLMenuGL* menu )
 	return success;
 }
 
+// add a context menu branch
+
+BOOL LLMenuGL::appendContextSubMenu(LLMenuGL *menu)
+
+{
+	if (menu == this)
+	{
+		llerrs << "Can't attach a context menu to itself" << llendl;
+	}
+
+	LLContextMenuBranch *item;
+	LLContextMenuBranch::Params p;
+
+	p.name = menu->getName();
+	p.label = menu->getLabel();
+	p.branch = (LLContextMenu *)menu;
+	p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor");
+	p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor");
+	p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor");
+	p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor");
+	item = LLUICtrlFactory::create<LLContextMenuBranch>(p);
+	LLMenuGL::sMenuContainer->addChild(item->getBranch());
+
+	return append( item );
+}
+
 void LLMenuGL::setEnabledSubMenus(BOOL enable)
 {
 	setEnabled(enable);
@@ -3735,39 +3781,6 @@ void LLTearOffMenu::closeTearOff()
 	mMenu->setDropShadowed(TRUE);
 }
 
-
-//-----------------------------------------------------------------------------
-// class LLContextMenuBranch
-// A branch to another context menu
-//-----------------------------------------------------------------------------
-class LLContextMenuBranch : public LLMenuItemGL
-{
-public:
-	struct Params : public LLInitParam::Block<Params, LLMenuItemGL::Params>
-	{
-		Mandatory<LLContextMenu*> branch;
-	};
-
-	LLContextMenuBranch(const Params&);
-
-	virtual ~LLContextMenuBranch()
-	{}
-
-	// called to rebuild the draw label
-	virtual void	buildDrawLabel( void );
-
-	// onCommit() - do the primary funcationality of the menu item.
-	virtual void	onCommit( void );
-
-	LLContextMenu*	getBranch() { return mBranch.get(); }
-	void			setHighlight( BOOL highlight );
-
-protected:
-	void	showSubMenu();
-
-	LLHandle<LLContextMenu> mBranch;
-};
-
 LLContextMenuBranch::LLContextMenuBranch(const LLContextMenuBranch::Params& p) 
 :	LLMenuItemGL(p),
 	mBranch( p.branch()->getHandle() )
@@ -4039,44 +4052,8 @@ BOOL LLContextMenu::handleRightMouseUp( S32 x, S32 y, MASK mask )
 	return result;
 }
 
-BOOL LLContextMenu::appendContextSubMenu(LLContextMenu *menu)
-{
-	
-	if (menu == this)
-	{
-		llerrs << "Can't attach a context menu to itself" << llendl;
-	}
-
-	LLContextMenuBranch *item;
-	LLContextMenuBranch::Params p;
-	p.name = menu->getName();
-	p.label = menu->getLabel();
-	p.branch = menu;
-	p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor");
-	p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor");
-	p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor");
-	p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor");
-	
-	item = LLUICtrlFactory::create<LLContextMenuBranch>(p);
-	LLMenuGL::sMenuContainer->addChild(item->getBranch());
-
-	return append( item );
-}
-
 bool LLContextMenu::addChild(LLView* view, S32 tab_group)
 {
-	LLContextMenu* context = dynamic_cast<LLContextMenu*>(view);
-	if (context)
-		return appendContextSubMenu(context);
-
-	LLMenuItemSeparatorGL* separator = dynamic_cast<LLMenuItemSeparatorGL*>(view);
-	if (separator)
-		return append(separator);
-
-	LLMenuItemGL* item = dynamic_cast<LLMenuItemGL*>(view);
-	if (item)
-		return append(item);
-
-	return false;
+	return addContextChild(view, tab_group);
 }
 
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index a9de3ef937..3e03232e92 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -519,6 +519,9 @@ public:
 	void resetScrollPositionOnShow(bool reset_scroll_pos) { mResetScrollPositionOnShow = reset_scroll_pos; }
 	bool isScrollPositionOnShowReset() { return mResetScrollPositionOnShow; }
 
+	// add a context menu branch
+	BOOL appendContextSubMenu(LLMenuGL *menu);
+
 protected:
 	void createSpilloverBranch();
 	void cleanupSpilloverBranch();
@@ -528,6 +531,10 @@ protected:
 	// add a menu - this will create a cascading menu
 	virtual BOOL appendMenu( LLMenuGL* menu );
 
+	// Used in LLContextMenu and in LLTogleableMenu
+	// to add an item of context menu branch
+	bool addContextChild(LLView* view, S32 tab_group);
+
 	// TODO: create accessor methods for these?
 	typedef std::list< LLMenuItemGL* > item_list_t;
 	item_list_t mItems;
@@ -677,8 +684,6 @@ public:
 
 	virtual bool	addChild			(LLView* view, S32 tab_group = 0);
 
-			BOOL	appendContextSubMenu(LLContextMenu *menu);
-
 			LLHandle<LLContextMenu> getHandle() { return getDerivedHandle<LLContextMenu>(); }
 
 			LLView*	getSpawningView() const		{ return mSpawningViewHandle.get(); }
@@ -691,7 +696,33 @@ protected:
 	LLHandle<LLView>			mSpawningViewHandle;
 };
 
+//-----------------------------------------------------------------------------
+// class LLContextMenuBranch
+// A branch to another context menu
+//-----------------------------------------------------------------------------
+class LLContextMenuBranch : public LLMenuItemGL
+{
+public:
+	struct Params : public LLInitParam::Block<Params, LLMenuItemGL::Params>
+	{
+		Mandatory<LLContextMenu*> branch;
+	};
+
+	LLContextMenuBranch(const Params&);
+
+	// Called to rebuild strings for this item
+	virtual void	buildDrawLabel( void );
 
+	// Performed when menu item clicked
+	virtual void	onCommit( void );
+
+	LLContextMenu*	getBranch() { return mBranch.get(); }
+	void			setHighlight( BOOL highlight );
+
+protected:
+	void			showSubMenu();
+	LLHandle<LLContextMenu> mBranch;
+};
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // Class LLMenuBarGL
diff --git a/indra/llui/lltoggleablemenu.cpp b/indra/llui/lltoggleablemenu.cpp
index d29260750f..b4c6c6162b 100644
--- a/indra/llui/lltoggleablemenu.cpp
+++ b/indra/llui/lltoggleablemenu.cpp
@@ -99,3 +99,8 @@ bool LLToggleableMenu::toggleVisibility()
 
 	return true;
 }
+
+bool LLToggleableMenu::addChild(LLView* view, S32 tab_group)
+{
+	return addContextChild(view, tab_group);
+}
diff --git a/indra/llui/lltoggleablemenu.h b/indra/llui/lltoggleablemenu.h
index dd9ac5b8c1..57b8f62eb6 100644
--- a/indra/llui/lltoggleablemenu.h
+++ b/indra/llui/lltoggleablemenu.h
@@ -47,6 +47,8 @@ public:
 
 	virtual void handleVisibilityChange (BOOL curVisibilityIn);
 
+	virtual bool addChild (LLView* view, S32 tab_group = 0);
+	
 	const LLRect& getButtonRect() const { return mButtonRect; }
 
 	// Converts the given local button rect to a screen rect
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp
index e5232d730c..f0c8658cfe 100644
--- a/indra/newview/llconversationmodel.cpp
+++ b/indra/newview/llconversationmodel.cpp
@@ -114,6 +114,19 @@ void LLConversationItem::buildParticipantMenuOptions(menuentry_vec_t&   items)
     items.push_back(std::string("share"));
     items.push_back(std::string("pay"));
     items.push_back(std::string("block_unblock"));
+
+	if(this->getType() != CONV_SESSION_1_ON_1)
+	{
+		items.push_back(std::string("Moderator Options Separator"));
+		items.push_back(std::string("Moderator Options"));
+		items.push_back(std::string("AllowTextChat"));
+		items.push_back(std::string("moderate_voice_separator"));
+		items.push_back(std::string("ModerateVoiceMuteSelected"));
+		items.push_back(std::string("ModerateVoiceUnMuteSelected"));
+		items.push_back(std::string("ModerateVoiceMute"));
+		items.push_back(std::string("ModerateVoiceUnmute"));
+	}
+
 }
 
 //
diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 5c1105531e..c9c7e94af9 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -44,6 +44,7 @@
 #include "llfloateravatarpicker.h"
 #include "llfloaterpreference.h"
 #include "llimview.h"
+#include "llnotificationsutil.h"
 #include "lltransientfloatermgr.h"
 #include "llviewercontrol.h"
 #include "llconversationview.h"
@@ -830,59 +831,67 @@ void LLIMFloaterContainer::getParticipantUUIDs(uuid_vec_t& selected_uuids)
 
 void LLIMFloaterContainer::doToParticipants(const std::string& command, uuid_vec_t& selectedIDS)
 {
-    if(selectedIDS.size() > 0)
-{
-        const LLUUID userID = selectedIDS.front();
+	if(selectedIDS.size() > 0)
+	{
+		const LLUUID& userID = selectedIDS.front();
 
-    if ("view_profile" == command)
-    {
-        LLAvatarActions::showProfile(userID);
-    }
-    else if("im" == command)
-    {
-        LLAvatarActions::startIM(userID);
-    }
-    else if("offer_teleport" == command)
-    {
-        LLAvatarActions::offerTeleport(selectedIDS);
-    }
-    else if("voice_call" == command)
-    {
-        LLAvatarActions::startCall(userID);
-    }
-    else if("chat_history" == command)
-    {
-        LLAvatarActions::viewChatHistory(userID);
-    }
-    else if("add_friend" == command)
-    {
-        LLAvatarActions::requestFriendshipDialog(userID);
-    }
-    else if("remove_friend" == command)
-    {
-        LLAvatarActions::removeFriendDialog(userID);
-    }
-    else if("invite_to_group" == command)
-    {
-        LLAvatarActions::inviteToGroup(userID);
-    }
-    else if("map" == command)
-    {
-        LLAvatarActions::showOnMap(userID);
-    }
-    else if("share" == command)
-    {
-        LLAvatarActions::share(userID);
-    }
-    else if("pay" == command)
-    {
-        LLAvatarActions::pay(userID);
-    }
-    else if("block_unblock" == command)
-    {
-        LLAvatarActions::toggleBlock(userID);
-    }
-}
+		if ("view_profile" == command)
+		{
+			LLAvatarActions::showProfile(userID);
+		}
+		else if("im" == command)
+		{
+			LLAvatarActions::startIM(userID);
+		}
+		else if("offer_teleport" == command)
+		{
+			LLAvatarActions::offerTeleport(selectedIDS);
+		}
+		else if("voice_call" == command)
+		{
+			LLAvatarActions::startCall(userID);
+		}
+		else if("chat_history" == command)
+		{
+			LLAvatarActions::viewChatHistory(userID);
+		}
+		else if("add_friend" == command)
+		{
+			LLAvatarActions::requestFriendshipDialog(userID);
+		}
+		else if("remove_friend" == command)
+		{
+			LLAvatarActions::removeFriendDialog(userID);
+		}
+		else if("invite_to_group" == command)
+		{
+			LLAvatarActions::inviteToGroup(userID);
+		}
+		else if("map" == command)
+		{
+			LLAvatarActions::showOnMap(userID);
+		}
+		else if("share" == command)
+		{
+			LLAvatarActions::share(userID);
+		}
+		else if("pay" == command)
+		{
+			LLAvatarActions::pay(userID);
+		}
+		else if("block_unblock" == command)
+		{
+			LLAvatarActions::toggleBlock(userID);
+		}
+		else if("selected" == command || "mute_all" == command || "unmute_all" == command)
+		{
+			moderateVoice(command, userID);
+		}
+		else if ("toggle_allow_text_chat" == command)
+		{
+			toggleAllowTextChat(userID);
+		}
+	}
 }
 
 void LLIMFloaterContainer::doToSelectedConversation(const std::string& command, uuid_vec_t& selectedIDS)
@@ -963,8 +972,8 @@ void LLIMFloaterContainer::doToSelectedGroup(const LLSD& userdata)
 bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata)
 {
     std::string item = userdata.asString();
-    uuid_vec_t mUUIDs;
-    getParticipantUUIDs(mUUIDs);
+	uuid_vec_t uuids;
+	getParticipantUUIDs(uuids);
 
     if(item == std::string("can_activate_group"))
     {
@@ -972,7 +981,7 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata)
     	return gAgent.getGroupID() != selected_group_id;
     }
 
-    if(mUUIDs.size() <= 0)
+	if(uuids.size() <= 0)
     {
         return false;
     }
@@ -982,7 +991,7 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata)
 
     if (item == std::string("can_block"))
     {
-        const LLUUID& id = mUUIDs.front();
+		const LLUUID& id = uuids.front();
         return LLAvatarActions::canBlock(id);
     }
     else if (item == std::string("can_add"))
@@ -992,7 +1001,7 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata)
         // - and there are no friends among selection yet.
 
         //EXT-7389 - disable for more than 1
-        if(mUUIDs.size() > 1)
+		if(uuids.size() > 1)
         {
             return false;
         }
@@ -1000,8 +1009,8 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata)
         bool result = true;
 
         uuid_vec_t::const_iterator
-            id = mUUIDs.begin(),
-            uuids_end = mUUIDs.end();
+			id = uuids.begin(),
+			uuids_end = uuids.end();
 
         for (;id != uuids_end; ++id)
         {
@@ -1020,11 +1029,11 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata)
         // - there are selected people
         // - and there are only friends among selection.
 
-        bool result = (mUUIDs.size() > 0);
+        bool result = (uuids.size() > 0);
 
         uuid_vec_t::const_iterator
-            id = mUUIDs.begin(),
-            uuids_end = mUUIDs.end();
+			id = uuids.begin(),
+			uuids_end = uuids.end();
 
         for (;id != uuids_end; ++id)
         {
@@ -1043,15 +1052,20 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata)
     }
     else if (item == std::string("can_show_on_map"))
     {
-        const LLUUID& id = mUUIDs.front();
+		const LLUUID& id = uuids.front();
 
         return (LLAvatarTracker::instance().isBuddyOnline(id) && is_agent_mappable(id))
             || gAgent.isGodlike();
     }
     else if(item == std::string("can_offer_teleport"))
     {
-        return LLAvatarActions::canOfferTeleport(mUUIDs);
+		return LLAvatarActions::canOfferTeleport(uuids);
     }
+	else if("can_moderate_voice" == item || "can_allow_text_chat" == item || "can_mute" == item || "can_unmute" == item)
+	{
+		return enableModerateContextMenuItem(item);
+	}
+
     return false;
 }
 
@@ -1063,10 +1077,19 @@ bool LLIMFloaterContainer::checkContextMenuItem(const LLSD& userdata)
 
     if(mUUIDs.size() > 0 )
     {
-    if (item == std::string("is_blocked"))
-    {
-            return LLAvatarActions::isBlocked(mUUIDs.front());
-        }
+		if ("is_blocked" == item)
+		{
+			return LLAvatarActions::isBlocked(mUUIDs.front());
+		}
+		else if ("is_allowed_text_chat" == item)
+		{
+			const LLSpeaker * speakerp = getSpeakerOfSelectedParticipant(getSpeakerMgrForSelectedParticipant());
+
+			if (NULL != speakerp)
+			{
+				return !speakerp->mModeratorMutedText;
+			}
+		}
     }
 
     return false;
@@ -1284,4 +1307,189 @@ LLConversationViewParticipant* LLIMFloaterContainer::createConversationViewParti
 	return LLUICtrlFactory::create<LLConversationViewParticipant>(params);
 }
 
+bool LLIMFloaterContainer::enableModerateContextMenuItem(const std::string& userdata)
+{
+	// only group moderators can perform actions related to this "enable callback"
+	if (!isGroupModerator())
+	{
+		return false;
+	}
+
+	LLSpeaker * speakerp = getSpeakerOfSelectedParticipant(getSpeakerMgrForSelectedParticipant());
+	if (NULL == speakerp)
+	{
+		return false;
+	}
+
+	bool voice_channel = speakerp->isInVoiceChannel();
+
+	if ("can_moderate_voice" == userdata)
+	{
+		return voice_channel;
+	}
+	else if ("can_mute" == userdata)
+	{
+		return voice_channel && !isMuted(getCurSelectedViewModelItem()->getUUID());
+	}
+	else if ("can_unmute" == userdata)
+	{
+		return voice_channel && isMuted(getCurSelectedViewModelItem()->getUUID());
+	}
+
+	// The last invoke is used to check whether the "can_allow_text_chat" will enabled
+	return LLVoiceClient::getInstance()->isParticipantAvatar(getCurSelectedViewModelItem()->getUUID());
+}
+
+bool LLIMFloaterContainer::isGroupModerator()
+{
+	LLSpeakerMgr * speaker_manager = getSpeakerMgrForSelectedParticipant();
+	if (NULL == speaker_manager)
+	{
+		llwarns << "Speaker manager is missing" << llendl;
+		return false;
+	}
+
+	// Is session a group call/chat?
+	if(gAgent.isInGroup(speaker_manager->getSessionID()))
+	{
+		LLSpeaker * speaker = speaker_manager->findSpeaker(gAgentID).get();
+
+		// Is agent a moderator?
+		return speaker && speaker->mIsModerator;
+	}
+
+	return false;
+}
+
+void LLIMFloaterContainer::moderateVoice(const std::string& command, const LLUUID& userID)
+{
+	if (!gAgent.getRegion()) return;
+
+	if (command.compare("selected"))
+	{
+		moderateVoiceAllParticipants(command.compare("mute_all"));
+	}
+	else
+	{
+		moderateVoiceParticipant(userID, isMuted(userID));
+	}
+}
+
+bool LLIMFloaterContainer::isMuted(const LLUUID& avatar_id)
+{
+	const LLSpeaker * speakerp = getSpeakerOfSelectedParticipant(getSpeakerMgrForSelectedParticipant());
+	return NULL == speakerp ? true : speakerp->mStatus == LLSpeaker::STATUS_MUTED;
+}
+
+void LLIMFloaterContainer::moderateVoiceAllParticipants(bool unmute)
+{
+	LLIMSpeakerMgr * speaker_managerp = dynamic_cast<LLIMSpeakerMgr*>(getSpeakerMgrForSelectedParticipant());
+
+	if (NULL != speaker_managerp)
+	{
+		if (!unmute)
+		{
+			LLSD payload;
+			payload["session_id"] = speaker_managerp->getSessionID();
+			LLNotificationsUtil::add("ConfirmMuteAll", LLSD(), payload, confirmMuteAllCallback);
+			return;
+		}
+
+		speaker_managerp->moderateVoiceAllParticipants(unmute);
+	}
+}
+
+// static
+void LLIMFloaterContainer::confirmMuteAllCallback(const LLSD& notification, const LLSD& response)
+{
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	// if Cancel pressed
+	if (option == 1)
+	{
+		return;
+	}
+
+	const LLSD& payload = notification["payload"];
+	const LLUUID& session_id = payload["session_id"];
+
+	LLIMSpeakerMgr * speaker_manager = dynamic_cast<LLIMSpeakerMgr*> (
+		LLIMModel::getInstance()->getSpeakerManager(session_id));
+	if (speaker_manager)
+	{
+		speaker_manager->moderateVoiceAllParticipants(false);
+	}
+
+	return;
+}
+
+void LLIMFloaterContainer::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute)
+{
+	LLIMSpeakerMgr * speaker_managerp = dynamic_cast<LLIMSpeakerMgr *>(getSpeakerMgrForSelectedParticipant());
+
+	if (NULL != speaker_managerp)
+	{
+		speaker_managerp->moderateVoiceParticipant(avatar_id, unmute);
+	}
+}
+
+LLSpeakerMgr * LLIMFloaterContainer::getSpeakerMgrForSelectedParticipant()
+{
+	LLFolderViewItem * selected_folder_itemp = mConversationsRoot->getCurSelectedItem();
+	if (NULL == selected_folder_itemp)
+	{
+		llwarns << "Current selected item is null" << llendl;
+		return NULL;
+	}
+
+	LLFolderViewFolder * conversation_itemp = selected_folder_itemp->getParentFolder();
+
+	conversations_widgets_map::const_iterator iter = mConversationsWidgets.begin();
+	conversations_widgets_map::const_iterator end = mConversationsWidgets.end();
+	const LLUUID * conversation_uuidp = NULL;
+	while(iter != end)
+	{
+		if (iter->second == conversation_itemp)
+		{
+			conversation_uuidp = &iter->first;
+			break;
+		}
+		++iter;
+	}
+	if (NULL == conversation_uuidp)
+	{
+		llwarns << "Cannot find conversation item widget" << llendl;
+		return NULL;
+	}
+
+	return conversation_uuidp->isNull() ? (LLSpeakerMgr *)LLLocalSpeakerMgr::getInstance()
+		: LLIMModel::getInstance()->getSpeakerManager(*conversation_uuidp);
+}
+
+LLSpeaker * LLIMFloaterContainer::getSpeakerOfSelectedParticipant(LLSpeakerMgr * speaker_managerp)
+{
+	if (NULL == speaker_managerp)
+	{
+		llwarns << "Speaker manager is missing" << llendl;
+		return NULL;
+	}
+
+	const LLConversationItem * participant_itemp = getCurSelectedViewModelItem();
+	if (NULL == participant_itemp)
+	{
+		llwarns << "Cannot evaluate current selected view model item" << llendl;
+		return NULL;
+	}
+
+	return speaker_managerp->findSpeaker(participant_itemp->getUUID());
+}
+
+void LLIMFloaterContainer::toggleAllowTextChat(const LLUUID& participant_uuid)
+{
+	LLIMSpeakerMgr * speaker_managerp = dynamic_cast<LLIMSpeakerMgr*>(getSpeakerMgrForSelectedParticipant());
+	if (NULL != speaker_managerp)
+	{
+		speaker_managerp->toggleAllowTextChat(participant_uuid);
+	}
+}
+
 // EOF
diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h
index 579f62c688..ba2d085858 100644
--- a/indra/newview/llimfloatercontainer.h
+++ b/indra/newview/llimfloatercontainer.h
@@ -45,6 +45,8 @@ class LLLayoutPanel;
 class LLLayoutStack;
 class LLTabContainer;
 class LLIMFloaterContainer;
+class LLSpeaker;
+class LLSpeakerMgr;
 
 class LLIMFloaterContainer
 	: public LLMultiFloater
@@ -126,6 +128,17 @@ private:
     bool checkContextMenuItem(const LLSD& userdata);
     bool enableContextMenuItem(const LLSD& userdata);
 
+	static void confirmMuteAllCallback(const LLSD& notification, const LLSD& response);
+	bool enableModerateContextMenuItem(const std::string& userdata);
+	LLSpeaker * getSpeakerOfSelectedParticipant(LLSpeakerMgr * speaker_managerp);
+	LLSpeakerMgr * getSpeakerMgrForSelectedParticipant();
+	bool isGroupModerator();
+	bool isMuted(const LLUUID& avatar_id);
+	void moderateVoice(const std::string& command, const LLUUID& userID);
+	void moderateVoiceAllParticipants(bool unmute);
+	void moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute);
+	void toggleAllowTextChat(const LLUUID& participant_uuid);
+
 	LLButton* mExpandCollapseBtn;
 	LLLayoutPanel* mMessagesPane;
 	LLLayoutPanel* mConversationsPane;
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 139713b96e..28c2edbe84 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -577,7 +577,7 @@ void hide_context_entries(LLMenuGL& menu,
 
 		// descend into split menus:
 		LLMenuItemBranchGL* branchp = dynamic_cast<LLMenuItemBranchGL*>(menu_item);
-		if ((name == "More") && branchp)
+		if (NULL != branchp)
 		{
 			hide_context_entries(*branchp->getBranch(), entries_to_show, disabled_entries);
 		}
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index 90226e7fba..b263143bd1 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -213,7 +213,6 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source,
 	LLConversationItemSession(data_source->getSessionID(), root_view_model),
 	mSpeakerMgr(data_source),
 	mAvatarList(avatar_list),
-	mParticipantListMenu(NULL),
 	mExcludeAgent(exclude_agent),
 	mValidateSpeakerCallback(NULL)
 {
@@ -248,8 +247,6 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source,
 
 		if (use_context_menu)
 		{
-			//mParticipantListMenu = new LLParticipantListMenu(*this);
-			//mAvatarList->setContextMenu(mParticipantListMenu);
 			mAvatarList->setContextMenu(&LLPanelPeopleMenus::gNearbyMenu);
 		}
 		else
@@ -316,20 +313,6 @@ LLParticipantList::~LLParticipantList()
 		mAvatarListToggleIconsConnection.disconnect();
 	}
 
-	// It is possible Participant List will be re-created from LLCallFloater::onCurrentChannelChanged()
-	// See ticket EXT-3427
-	// hide menu before deleting it to stop enable and check handlers from triggering.
-	if(mParticipantListMenu && !LLApp::isExiting())
-	{
-		mParticipantListMenu->hide();
-	}
-
-	if (mParticipantListMenu)
-	{
-		delete mParticipantListMenu;
-		mParticipantListMenu = NULL;
-	}
-
 	if (mAvatarList)
 	{
 		mAvatarList->setContextMenu(NULL);
@@ -786,350 +769,6 @@ bool LLParticipantList::SpeakerMuteListener::handleEvent(LLPointer<LLOldEvents::
 	return mParent.onSpeakerMuteEvent(event, userdata);
 }
 
-/*LLContextMenu* LLParticipantList::LLParticipantListMenu::createMenu()
-{
-	// set up the callbacks for all of the avatar menu items
-	LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
-	LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
-	
-	registrar.add("ParticipantList.Sort", boost::bind(&LLParticipantList::LLParticipantListMenu::sortParticipantList, this, _2));
-	registrar.add("ParticipantList.ToggleAllowTextChat", boost::bind(&LLParticipantList::LLParticipantListMenu::toggleAllowTextChat, this, _2));
-	registrar.add("ParticipantList.ToggleMuteText", boost::bind(&LLParticipantList::LLParticipantListMenu::toggleMuteText, this, _2));
-
-	registrar.add("Avatar.Profile",	boost::bind(&LLAvatarActions::showProfile, mUUIDs.front()));
-	registrar.add("Avatar.IM", boost::bind(&LLAvatarActions::startIM, mUUIDs.front()));
-	registrar.add("Avatar.AddFriend", boost::bind(&LLAvatarActions::requestFriendshipDialog, mUUIDs.front()));
-	registrar.add("Avatar.BlockUnblock", boost::bind(&LLParticipantList::LLParticipantListMenu::toggleMuteVoice, this, _2));
-	registrar.add("Avatar.Share", boost::bind(&LLAvatarActions::share, mUUIDs.front()));
-	registrar.add("Avatar.Pay",	boost::bind(&LLAvatarActions::pay, mUUIDs.front()));
-	registrar.add("Avatar.Call", boost::bind(&LLAvatarActions::startCall, mUUIDs.front()));
-
-	registrar.add("ParticipantList.ModerateVoice", boost::bind(&LLParticipantList::LLParticipantListMenu::moderateVoice, this, _2));
-
-	enable_registrar.add("ParticipantList.EnableItem", boost::bind(&LLParticipantList::LLParticipantListMenu::enableContextMenuItem,	this, _2));
-	enable_registrar.add("ParticipantList.EnableItem.Moderate", boost::bind(&LLParticipantList::LLParticipantListMenu::enableModerateContextMenuItem,	this, _2));
-	enable_registrar.add("ParticipantList.CheckItem",  boost::bind(&LLParticipantList::LLParticipantListMenu::checkContextMenuItem,	this, _2));
-
-	// create the context menu from the XUI
-	LLContextMenu* main_menu = createFromFile("menu_participant_list.xml");
-
-	// Don't show sort options for P2P chat
-	bool is_sort_visible = (mParent.mAvatarList && mParent.mAvatarList->size() > 1);
-	main_menu->setItemVisible("SortByName", is_sort_visible);
-	main_menu->setItemVisible("SortByRecentSpeakers", is_sort_visible);
-	main_menu->setItemVisible("Moderator Options Separator", isGroupModerator());
-	main_menu->setItemVisible("Moderator Options", isGroupModerator());
-	main_menu->setItemVisible("View Icons Separator", mParent.mAvatarListToggleIconsConnection.connected());
-	main_menu->setItemVisible("View Icons", mParent.mAvatarListToggleIconsConnection.connected());
-	main_menu->arrangeAndClear();
-
-	return main_menu;
-}*/
-
-void LLParticipantList::LLParticipantListMenu::show(LLView* spawning_view, const uuid_vec_t& uuids, S32 x, S32 y)
-{
-	if (uuids.size() == 0) return;
-
-	LLListContextMenu::show(spawning_view, uuids, x, y);
-
-	const LLUUID& speaker_id = mUUIDs.front();
-	BOOL is_muted = isMuted(speaker_id);
-
-	if (is_muted)
-	{
-		LLMenuGL::sMenuContainer->getChildView("ModerateVoiceMuteSelected")->setVisible( false);
-	}
-	else
-	{
-		LLMenuGL::sMenuContainer->getChildView("ModerateVoiceUnMuteSelected")->setVisible( false);
-	}
-}
-
-void LLParticipantList::LLParticipantListMenu::sortParticipantList(const LLSD& userdata)
-{
-	std::string param = userdata.asString();
-	if ("sort_by_name" == param)
-	{
-		mParent.setSortOrder(E_SORT_BY_NAME);
-	}
-	else if ("sort_by_recent_speakers" == param)
-	{
-		mParent.setSortOrder(E_SORT_BY_RECENT_SPEAKERS);
-	}
-}
-
-void LLParticipantList::LLParticipantListMenu::toggleAllowTextChat(const LLSD& userdata)
-{
-
-	LLIMSpeakerMgr* mgr = dynamic_cast<LLIMSpeakerMgr*>(mParent.mSpeakerMgr);
-	if (mgr)
-	{
-		const LLUUID speaker_id = mUUIDs.front();
-		mgr->toggleAllowTextChat(speaker_id);
-	}
-}
-
-void LLParticipantList::LLParticipantListMenu::toggleMute(const LLSD& userdata, U32 flags)
-{
-	const LLUUID speaker_id = mUUIDs.front();
-	BOOL is_muted = LLMuteList::getInstance()->isMuted(speaker_id, flags);
-	std::string name;
-
-	//fill in name using voice client's copy of name cache
-	LLPointer<LLSpeaker> speakerp = mParent.mSpeakerMgr->findSpeaker(speaker_id);
-	if (speakerp.isNull())
-	{
-		LL_WARNS("Speakers") << "Speaker " << speaker_id << " not found" << llendl;
-		return;
-	}
-	LLAvatarListItem* item = (mParent.mAvatarList ? dynamic_cast<LLAvatarListItem*>(mParent.mAvatarList->getItemByValue(speaker_id)) : NULL);
-	if (NULL == item) return;
-
-	name = item->getAvatarName();
-
-	LLMute::EType mute_type;
-	switch (speakerp->mType)
-	{
-		case LLSpeaker::SPEAKER_AGENT:
-			mute_type = LLMute::AGENT;
-			break;
-		case LLSpeaker::SPEAKER_OBJECT:
-			mute_type = LLMute::OBJECT;
-			break;
-		case LLSpeaker::SPEAKER_EXTERNAL:
-		default:
-			mute_type = LLMute::EXTERNAL;
-			break;
-	}
-	LLMute mute(speaker_id, name, mute_type);
-
-	if (!is_muted)
-	{
-		LLMuteList::getInstance()->add(mute, flags);
-	}
-	else
-	{
-		LLMuteList::getInstance()->remove(mute, flags);
-	}
-}
-
-void LLParticipantList::LLParticipantListMenu::toggleMuteText(const LLSD& userdata)
-{
-	toggleMute(userdata, LLMute::flagTextChat);
-}
-
-void LLParticipantList::LLParticipantListMenu::toggleMuteVoice(const LLSD& userdata)
-{
-	toggleMute(userdata, LLMute::flagVoiceChat);
-}
-
-bool LLParticipantList::LLParticipantListMenu::isGroupModerator()
-{
-	if (!mParent.mSpeakerMgr)
-	{
-		llwarns << "Speaker manager is missing" << llendl;
-		return false;
-	}
-
-	// Is session a group call/chat?
-	if(gAgent.isInGroup(mParent.mSpeakerMgr->getSessionID()))
-	{
-		LLSpeaker* speaker = mParent.mSpeakerMgr->findSpeaker(gAgentID).get();
-
-		// Is agent a moderator?
-		return speaker && speaker->mIsModerator;
-	}
-	return false;
-}
-
-bool LLParticipantList::LLParticipantListMenu::isMuted(const LLUUID& avatar_id)
-{
-	LLPointer<LLSpeaker> selected_speakerp = mParent.mSpeakerMgr->findSpeaker(avatar_id);
-	if (!selected_speakerp) return true;
-
-	return selected_speakerp->mStatus == LLSpeaker::STATUS_MUTED;
-}
-
-void LLParticipantList::LLParticipantListMenu::moderateVoice(const LLSD& userdata)
-{
-	if (!gAgent.getRegion()) return;
-
-	bool moderate_selected = userdata.asString() == "selected";
-
-	if (moderate_selected)
-	{
-		const LLUUID& selected_avatar_id = mUUIDs.front();
-		bool is_muted = isMuted(selected_avatar_id);
-		moderateVoiceParticipant(selected_avatar_id, is_muted);
-	}
-	else
-	{
-		bool unmute_all = userdata.asString() == "unmute_all";
-		moderateVoiceAllParticipants(unmute_all);
-	}
-}
-
-void LLParticipantList::LLParticipantListMenu::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute)
-{
-	LLIMSpeakerMgr* mgr = dynamic_cast<LLIMSpeakerMgr*>(mParent.mSpeakerMgr);
-	if (mgr)
-	{
-		mgr->moderateVoiceParticipant(avatar_id, unmute);
-	}
-}
-
-void LLParticipantList::LLParticipantListMenu::moderateVoiceAllParticipants(bool unmute)
-{
-	LLIMSpeakerMgr* mgr = dynamic_cast<LLIMSpeakerMgr*>(mParent.mSpeakerMgr);
-	if (mgr)
-	{
-		if (!unmute)
-		{
-			LLSD payload;
-			payload["session_id"] = mgr->getSessionID();
-			LLNotificationsUtil::add("ConfirmMuteAll", LLSD(), payload, confirmMuteAllCallback);
-			return;
-		}
-
-		mgr->moderateVoiceAllParticipants(unmute);
-	}
-}
-
-// static
-void LLParticipantList::LLParticipantListMenu::confirmMuteAllCallback(const LLSD& notification, const LLSD& response)
-{
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	// if Cancel pressed
-	if (option == 1)
-	{
-		return;
-	}
-
-	const LLSD& payload = notification["payload"];
-	const LLUUID& session_id = payload["session_id"];
-
-	LLIMSpeakerMgr * speaker_manager = dynamic_cast<LLIMSpeakerMgr*> (
-		LLIMModel::getInstance()->getSpeakerManager(session_id));
-	if (speaker_manager)
-	{
-		speaker_manager->moderateVoiceAllParticipants(false);
-	}
-
-	return;
-}
-
-
-bool LLParticipantList::LLParticipantListMenu::enableContextMenuItem(const LLSD& userdata)
-{
-	std::string item = userdata.asString();
-	const LLUUID& participant_id = mUUIDs.front();
-
-	// For now non of "can_view_profile" action and menu actions listed below except "can_block"
-	// can be performed for Avaline callers.
-	bool is_participant_avatar = LLVoiceClient::getInstance()->isParticipantAvatar(participant_id);
-	if (!is_participant_avatar && "can_block" != item) return false;
-
-	if (item == "can_mute_text" || "can_block" == item || "can_share" == item || "can_im" == item 
-		|| "can_pay" == item)
-	{
-		return mUUIDs.front() != gAgentID;
-	}
-	else if (item == std::string("can_add"))
-	{
-		// We can add friends if:
-		// - there are selected people
-		// - and there are no friends among selection yet.
-
-		bool result = (mUUIDs.size() > 0);
-
-		uuid_vec_t::const_iterator
-			id = mUUIDs.begin(),
-			uuids_end = mUUIDs.end();
-
-		for (;id != uuids_end; ++id)
-		{
-			if ( *id == gAgentID || LLAvatarActions::isFriend(*id) )
-			{
-				result = false;
-				break;
-			}
-		}
-		return result;
-	}
-	else if (item == "can_call")
-	{
-		bool not_agent = mUUIDs.front() != gAgentID;
-		bool can_call = not_agent &&  LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking();
-		return can_call;
-	}
-
-	return true;
-}
-
-/*
-  Processed menu items with such parameters:
-  can_allow_text_chat
-  can_moderate_voice
-*/
-bool LLParticipantList::LLParticipantListMenu::enableModerateContextMenuItem(const LLSD& userdata)
-{
-	// only group moderators can perform actions related to this "enable callback"
-	if (!isGroupModerator()) return false;
-
-	const LLUUID& participant_id = mUUIDs.front();
-	LLPointer<LLSpeaker> speakerp = mParent.mSpeakerMgr->findSpeaker(participant_id);
-
-	// not in voice participants can not be moderated
-	bool speaker_in_voice = speakerp.notNull() && speakerp->isInVoiceChannel();
-
-	const std::string& item = userdata.asString();
-
-	if ("can_moderate_voice" == item)
-	{
-		return speaker_in_voice;
-	}
-
-	// For now non of menu actions except "can_moderate_voice" can be performed for Avaline callers.
-	bool is_participant_avatar = LLVoiceClient::getInstance()->isParticipantAvatar(participant_id);
-	if (!is_participant_avatar) return false;
-
-	return true;
-}
-
-bool LLParticipantList::LLParticipantListMenu::checkContextMenuItem(const LLSD& userdata)
-{
-	std::string item = userdata.asString();
-	const LLUUID& id = mUUIDs.front();
-
-	if (item == "is_muted")
-	{
-		return LLMuteList::getInstance()->isMuted(id, LLMute::flagTextChat);
-	}
-	else if (item == "is_allowed_text_chat")
-	{
-		LLPointer<LLSpeaker> selected_speakerp = mParent.mSpeakerMgr->findSpeaker(id);
-
-		if (selected_speakerp.notNull())
-		{
-			return !selected_speakerp->mModeratorMutedText;
-		}
-	}
-	else if(item == "is_blocked")
-	{
-		return LLMuteList::getInstance()->isMuted(id, LLMute::flagVoiceChat);
-	}
-	else if(item == "is_sorted_by_name")
-	{
-		return E_SORT_BY_NAME == mParent.getSortOrder();
-	}
-	else if(item == "is_sorted_by_recent_speakers")
-	{
-		return E_SORT_BY_RECENT_SPEAKERS == mParent.getSortOrder();
-	}
-
-	return false;
-}
-
 bool LLParticipantList::LLAvatarItemRecentSpeakerComparator::doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const
 {
 	if (mParent.mSpeakerMgr)
diff --git a/indra/newview/llparticipantlist.h b/indra/newview/llparticipantlist.h
index acee68873c..aaf1e070a5 100644
--- a/indra/newview/llparticipantlist.h
+++ b/indra/newview/llparticipantlist.h
@@ -159,79 +159,6 @@ protected:
 		/*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
 	};
 
-	/**
-	 * Menu used in the participant list.
-	 */
-	class LLParticipantListMenu : public LLListContextMenu
-	{
-	public:
-		LLParticipantListMenu(LLParticipantList& parent):mParent(parent){};
-		/*virtual*/ LLContextMenu* createMenu();
-		/*virtual*/ void show(LLView* spawning_view, const uuid_vec_t& uuids, S32 x, S32 y);
-	protected:
-		LLParticipantList& mParent;
-	private:
-		bool enableContextMenuItem(const LLSD& userdata);
-		bool enableModerateContextMenuItem(const LLSD& userdata);
-		bool checkContextMenuItem(const LLSD& userdata);
-
-		void sortParticipantList(const LLSD& userdata);
-		void toggleAllowTextChat(const LLSD& userdata);
-		void toggleMute(const LLSD& userdata, U32 flags);
-		void toggleMuteText(const LLSD& userdata);
-		void toggleMuteVoice(const LLSD& userdata);
-		
-		/**
-		 * Return true if Agent is group moderator(and moderator of group call).
-		 */
-		bool isGroupModerator();
-
-		// Voice moderation support
-		/**
-		 * Check whether specified by argument avatar is muted for group chat or not.
-		 */
-		bool isMuted(const LLUUID& avatar_id);
-
-		/**
-		 * Processes Voice moderation menu items.
-		 *
-		 * It calls either moderateVoiceParticipant() or moderateVoiceParticipant() depend on
-		 * passed parameter.
-		 *
-		 * @param userdata can be "selected" or "others".
-		 *
-		 * @see moderateVoiceParticipant()
-		 * @see moderateVoiceAllParticipants()
-		 */
-		void moderateVoice(const LLSD& userdata);
-
-		/**
-		 * Mutes/Unmutes avatar for current group voice chat.
-		 *
-		 * It only marks avatar as muted for session and does not use local Agent's Block list.
-		 * It does not mute Agent itself.
-		 *
-		 * @param[in] avatar_id UUID of avatar to be processed
-		 * @param[in] unmute if true - specified avatar will be muted, otherwise - unmuted.
-		 *
-		 * @see moderateVoiceAllParticipants()
-		 */
-		void moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute);
-
-		/**
-		 * Mutes/Unmutes all avatars for current group voice chat.
-		 *
-		 * It only marks avatars as muted for session and does not use local Agent's Block list.
-		 *
-		 * @param[in] unmute if true - avatars will be muted, otherwise - unmuted.
-		 *
-		 * @see moderateVoiceParticipant()
-		 */
-		void moderateVoiceAllParticipants(bool unmute);
-
-		static void confirmMuteAllCallback(const LLSD& notification, const LLSD& response);
-	};
-
 	/**
 	 * Comparator for comparing avatar items by last spoken time
 	 */
@@ -276,8 +203,6 @@ private:
 	LLPointer<SpeakerModeratorUpdateListener>	mSpeakerModeratorListener;
 	LLPointer<SpeakerMuteListener>				mSpeakerMuteListener;
 
-	LLParticipantListMenu*    mParticipantListMenu;
-
 	/**
 	 * This field manages an adding  a new avatar_id in the mAvatarList
 	 * If true, then agent_id wont  be added into mAvatarList
diff --git a/indra/newview/skins/default/xui/en/menu_conversation.xml b/indra/newview/skins/default/xui/en/menu_conversation.xml
index 682d70e4f0..2e9bda5804 100644
--- a/indra/newview/skins/default/xui/en/menu_conversation.xml
+++ b/indra/newview/skins/default/xui/en/menu_conversation.xml
@@ -125,4 +125,49 @@
      name="leave_group">
         <on_click function="Group.DoToSelected" parameter="leave_group"/>
     </menu_item_call>
+	<menu_item_separator
+	 layout="topleft"
+	 name="Moderator Options Separator"/>
+	<context_menu
+	 label="Moderator Options"
+	 layout="topleft"
+	 name="Moderator Options">
+		<menu_item_check
+		 label="Allow text chat"
+		 layout="topleft"
+		 name="AllowTextChat">
+			<on_check function="Avatar.CheckItem" parameter="is_allowed_text_chat" />
+			<on_click function="Avatar.DoToSelected" parameter="toggle_allow_text_chat" />
+			<on_enable function="Avatar.EnableItem" parameter="can_allow_text_chat" />
+		</menu_item_check>
+		<menu_item_separator layout="topleft" name="moderate_voice_separator" />
+		<menu_item_call
+		 label="Mute this participant"
+		 layout="topleft"
+		 name="ModerateVoiceMuteSelected">
+			<on_click function="Avatar.DoToSelected" parameter="selected" />
+			<on_enable function="Avatar.EnableItem" parameter="can_mute" />
+		</menu_item_call>
+		<menu_item_call
+		 label="Unmute this participant"
+		 layout="topleft"
+		 name="ModerateVoiceUnMuteSelected">
+			<on_click function="Avatar.DoToSelected" parameter="selected" />
+			<on_enable function="Avatar.EnableItem" parameter="can_unmute" />
+		</menu_item_call>
+		<menu_item_call
+		 label="Mute everyone"
+		 layout="topleft"
+		 name="ModerateVoiceMute">
+			<on_click function="Avatar.DoToSelected" parameter="mute_all" />
+			<on_enable function="Avatar.EnableItem" parameter="can_moderate_voice" />
+		</menu_item_call>
+		<menu_item_call
+		 label="Unmute everyone"
+		 layout="topleft"
+		 name="ModerateVoiceUnmute">
+			<on_click function="Avatar.DoToSelected" parameter="unmute_all" />
+			<on_enable function="Avatar.EnableItem" parameter="can_moderate_voice" />
+		</menu_item_call>
+	</context_menu>
 </toggleable_menu>
-- 
cgit v1.2.3


From 30a04430df02c6f3e949af0e457fe4ed49474ee3 Mon Sep 17 00:00:00 2001
From: maksymsproductengine <maksymsproductengine@lindenlab.com>
Date: Wed, 17 Oct 2012 19:16:13 +0300
Subject: CHUI-419 FIXED Selecting the drop down arrow to list participants for
 a conversation does not select that conversation

---
 indra/newview/llconversationview.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'indra')

diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index 1b450665b3..9144f402b4 100755
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -222,6 +222,13 @@ void LLConversationViewSession::toggleOpen()
 	if (!mMinimizedMode)
 	{
 		LLFolderViewFolder::toggleOpen();
+
+		// do item's selection when opened
+		if (LLFolderViewFolder::isOpen())
+		{
+			getParentFolder()->setSelection(this, true);
+		}
+		
 	}
 }
 
-- 
cgit v1.2.3


From 8a42d5cea3787edf294eec135af38c12ae322325 Mon Sep 17 00:00:00 2001
From: MaximB ProductEngine <mberezhnoy@productengine.com>
Date: Thu, 18 Oct 2012 00:04:46 +0300
Subject: CHUI-399 (When user has Pressing Letter Keys starts local chat
 setting on, first presses of letter keys do not open chat) fixed

---
 indra/newview/llviewerwindow.cpp | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 403288b2fd..f80abc816f 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2561,9 +2561,16 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 	// If "Pressing letter keys starts local chat" option is selected, we are not in mouselook, 
 	// no view has keyboard focus, this is a printable character key (and no modifier key is 
 	// pressed except shift), then give focus to nearby chat (STORM-560)
-	if ( nearby_chat && gSavedSettings.getS32("LetterKeysFocusChatBar") && !gAgentCamera.cameraMouselook() &&
-		!keyboard_focus && key < 0x80 && (mask == MASK_NONE || mask == MASK_SHIFT) )
-	{
+	if ( gSavedSettings.getS32("LetterKeysFocusChatBar") && !gAgentCamera.cameraMouselook() &&
+		!keyboard_focus && key < 0x80 && (mask == MASK_NONE || mask == MASK_SHIFT) )
+	{
+		// Initialize nearby chat if it's missing
+		if (!nearby_chat)
+		{	
+			LLSD name("im_container");
+			LLFloaterReg::toggleInstanceOrBringToFront(name);
+		}
+
 		LLChatEntry* chat_editor = LLFloaterReg::findTypedInstance<LLNearbyChat>("nearby_chat")->getChatBox();
 		if (chat_editor)
 		{
-- 
cgit v1.2.3


From 05a72687d848c13754039f6e720a137827533fdb Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Wed, 17 Oct 2012 14:55:36 -0700
Subject: CHUI-410: Now when a converation floater is focused the default text
 'To <Some User>' displays only when the text input field is empty.

---
 indra/llui/llchatentry.cpp                         | 28 ++++++++++++++++++++++
 indra/llui/llchatentry.h                           |  5 ++++
 indra/llui/lltextbase.cpp                          | 20 ++++++++++++++--
 indra/llui/lltextbase.h                            |  4 +++-
 .../skins/default/xui/en/floater_im_session.xml    |  3 ++-
 5 files changed, 56 insertions(+), 4 deletions(-)

(limited to 'indra')

diff --git a/indra/llui/llchatentry.cpp b/indra/llui/llchatentry.cpp
index 2a6ccc3dc9..38e2a8106a 100644
--- a/indra/llui/llchatentry.cpp
+++ b/indra/llui/llchatentry.cpp
@@ -136,6 +136,34 @@ void LLChatEntry::updateHistory()
 	}
 }
 
+void LLChatEntry::beforeValueChange()
+{
+    if(this->getLength() == 0 && !mLabel.empty())
+    {
+        this->clearSegments();
+    }
+}
+
+void LLChatEntry::onValueChange(S32 start, S32 end)
+{
+    resetLabel();
+}
+
+BOOL LLChatEntry::useLabel()
+{
+    return !getLength() && !mLabel.empty();
+}
+
+void LLChatEntry::onFocusReceived()
+{
+
+}
+
+void LLChatEntry::onFocusLost()
+{
+
+}
+
 BOOL LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
 {
 	BOOL handled = FALSE;
diff --git a/indra/llui/llchatentry.h b/indra/llui/llchatentry.h
index 10a4594e83..1f3fcf8945 100644
--- a/indra/llui/llchatentry.h
+++ b/indra/llui/llchatentry.h
@@ -54,11 +54,16 @@ protected:
 
 	friend class LLUICtrlFactory;
 	LLChatEntry(const Params& p);
+    /*virtual*/ void    beforeValueChange();
+    /*virtual*/ void    onValueChange(S32 start, S32 end);
+    /*virtual*/ BOOL    useLabel();
 
 public:
 
 	virtual void	draw();
 	virtual	void	onCommit();
+    /*virtual*/ void	onFocusReceived();
+    /*virtual*/ void	onFocusLost();
 
 	boost::signals2::connection setTextExpandedCallback(const commit_signal_t::slot_type& cb);
 
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 98624f42b9..15856ae4ef 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -338,6 +338,11 @@ const LLStyle::Params& LLTextBase::getStyleParams()
 	return mStyle;
 }
 
+void LLTextBase::beforeValueChange()
+{
+
+}
+
 void LLTextBase::onValueChange(S32 start, S32 end)
 {
 }
@@ -530,7 +535,7 @@ void LLTextBase::drawText()
 	{
 		return;
 	}
-	else if (text_len <= 0 && !mLabel.empty() && !hasFocus())
+	else if (useLabel() == TRUE)
 	{
 		text_len = mLabel.getWString().length();
 	}
@@ -747,6 +752,8 @@ void LLTextBase::drawText()
 
 S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::segment_vec_t* segments )
 {
+    beforeValueChange();
+
 	S32 old_len = getLength();		// length() returns character length
 	S32 insert_len = wstr.length();
 
@@ -822,6 +829,8 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
 
 S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
 {
+
+    beforeValueChange();
 	segment_set_t::iterator seg_iter = getSegIterContaining(pos);
 	while(seg_iter != mSegments.end())
 	{
@@ -880,6 +889,8 @@ S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
 
 S32 LLTextBase::overwriteCharNoUndo(S32 pos, llwchar wc)
 {
+    beforeValueChange();
+
 	if (pos > (S32)getLength())
 	{
 		return 0;
@@ -2048,7 +2059,7 @@ BOOL LLTextBase::setLabelArg(const std::string& key, const LLStringExplicit& tex
 
 void LLTextBase::resetLabel()
 {
-	if (!getLength() && !mLabel.empty() && !hasFocus())
+	if (useLabel() == TRUE)
 	{
 		clearSegments();
 
@@ -2061,6 +2072,11 @@ void LLTextBase::resetLabel()
 	}
 }
 
+BOOL LLTextBase::useLabel()
+{
+    return !getLength() && !mLabel.empty() && !hasFocus();
+}
+
 void LLTextBase::setFont(const LLFontGL* font)
 {
 	mFont = font;
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 79662ebd33..44b149d264 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -382,7 +382,7 @@ public:
 
 	/**
 	 * If label is set, draws text label (which is LLLabelTextSegment)
-	 * that is visible when no user text provided and has no focus
+	 * that is visible when no user text provided
 	 */
 	void					resetLabel();
 
@@ -501,7 +501,9 @@ protected:
 	LLTextBase(const Params &p);
 	virtual ~LLTextBase();
 	void							initFromParams(const Params& p);
+    virtual void					beforeValueChange();
 	virtual void					onValueChange(S32 start, S32 end);
+    virtual BOOL                    useLabel();
 
 	// draw methods
 	void							drawSelectionBackground(); // draws the black box behind the selected text
diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml
index 8cd0463de8..2b542595c5 100644
--- a/indra/newview/skins/default/xui/en/floater_im_session.xml
+++ b/indra/newview/skins/default/xui/en/floater_im_session.xml
@@ -255,11 +255,12 @@
              bottom="0"
              expand_lines_count="5"
              follows="left|right|bottom"
-	         font="SansSerifSmall"
+	           font="SansSerifSmall"
              visible="true"
              height="20"
              is_expandable="true"
              label="To"
+             text_tentative_color="TextFgTentativeColor"
              layout="bottomleft"
              name="chat_editor"
              max_length="1023"
-- 
cgit v1.2.3


From 3ee73ee98d31e572e284371074b7cd4744005a29 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Wed, 17 Oct 2012 15:26:51 -0700
Subject: warn-on-failure:unix-eol

---
 indra/newview/llviewerwindow.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 403288b2fd..11fe8fda26 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -283,7 +283,7 @@ private:
 	struct Line
 	{
 		Line(const std::string& in_text, S32 in_x, S32 in_y) : text(in_text), x(in_x), y(in_y) {}
-		std::string text;
+		std::string text; 
 		S32 x,y;
 	};
 
-- 
cgit v1.2.3


From 49ad7fd4b57cec635c557070be02556094e90ff6 Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Wed, 17 Oct 2012 17:52:10 -0700
Subject: CHUI-410: Post code review submit, changed useLabel() to return bool
 instead of BOOL. Adjusted code accordingly.

---
 indra/llui/llchatentry.cpp | 3 ++-
 indra/llui/llchatentry.h   | 2 +-
 indra/llui/lltextbase.cpp  | 6 +++---
 indra/llui/lltextbase.h    | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

(limited to 'indra')

diff --git a/indra/llui/llchatentry.cpp b/indra/llui/llchatentry.cpp
index 38e2a8106a..8e9c6555c3 100644
--- a/indra/llui/llchatentry.cpp
+++ b/indra/llui/llchatentry.cpp
@@ -146,10 +146,11 @@ void LLChatEntry::beforeValueChange()
 
 void LLChatEntry::onValueChange(S32 start, S32 end)
 {
+    //Internally resetLabel() must meet a condition before it can reset the label
     resetLabel();
 }
 
-BOOL LLChatEntry::useLabel()
+bool LLChatEntry::useLabel()
 {
     return !getLength() && !mLabel.empty();
 }
diff --git a/indra/llui/llchatentry.h b/indra/llui/llchatentry.h
index 1f3fcf8945..49181c8d78 100644
--- a/indra/llui/llchatentry.h
+++ b/indra/llui/llchatentry.h
@@ -56,7 +56,7 @@ protected:
 	LLChatEntry(const Params& p);
     /*virtual*/ void    beforeValueChange();
     /*virtual*/ void    onValueChange(S32 start, S32 end);
-    /*virtual*/ BOOL    useLabel();
+    /*virtual*/ bool    useLabel();
 
 public:
 
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 15856ae4ef..b827acb185 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -535,7 +535,7 @@ void LLTextBase::drawText()
 	{
 		return;
 	}
-	else if (useLabel() == TRUE)
+	else if (useLabel())
 	{
 		text_len = mLabel.getWString().length();
 	}
@@ -2059,7 +2059,7 @@ BOOL LLTextBase::setLabelArg(const std::string& key, const LLStringExplicit& tex
 
 void LLTextBase::resetLabel()
 {
-	if (useLabel() == TRUE)
+	if (useLabel())
 	{
 		clearSegments();
 
@@ -2072,7 +2072,7 @@ void LLTextBase::resetLabel()
 	}
 }
 
-BOOL LLTextBase::useLabel()
+bool LLTextBase::useLabel()
 {
     return !getLength() && !mLabel.empty() && !hasFocus();
 }
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 44b149d264..629b304b25 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -503,7 +503,7 @@ protected:
 	void							initFromParams(const Params& p);
     virtual void					beforeValueChange();
 	virtual void					onValueChange(S32 start, S32 end);
-    virtual BOOL                    useLabel();
+    virtual bool                    useLabel();
 
 	// draw methods
 	void							drawSelectionBackground(); // draws the black box behind the selected text
-- 
cgit v1.2.3