From 3e80fa3dbc943de9b784fedc202ba38cf238f46d Mon Sep 17 00:00:00 2001
From: David Parks <davep@lindenlab.com>
Date: Mon, 2 Nov 2009 19:55:37 +0000
Subject: [PATCH 001/683] Sync up with render-pipeline-7 ignore-dead-branch

---
 indra/cmake/00-Common.cmake                   |   5 +-
 indra/cmake/LLPrimitive.cmake                 |  22 +-
 indra/llcommon/llassettype.cpp                |   1 +
 indra/llcommon/llassettype.h                  |   6 +-
 indra/llcommon/llthread.cpp                   |   2 +-
 indra/llcommon/stdenums.h                     |   3 +-
 indra/llinventory/llinventorytype.cpp         |   7 +-
 indra/llinventory/llinventorytype.h           |   3 +-
 indra/llmath/llvolume.cpp                     | 350 +++++++++-
 indra/llmath/llvolume.h                       |  22 +-
 indra/llmath/llvolumemgr.cpp                  |   2 +-
 indra/llmath/m4math.cpp                       |  11 +
 indra/llmath/m4math.h                         |   1 +
 indra/llmath/v2math.cpp                       |  15 +
 indra/llmath/v2math.h                         |   3 +
 indra/llmessage/llassetstorage.cpp            |   2 +-
 indra/llmessage/lltransfermanager.cpp         |   2 +-
 indra/llmessage/lltransfersourceasset.cpp     |   2 +
 indra/llprimitive/CMakeLists.txt              |   4 +
 indra/llprimitive/llprimitive.cpp             |  15 +-
 indra/llprimitive/llprimitive.h               |   2 +-
 indra/llvfs/llvfile.cpp                       |   2 +-
 indra/llvfs/llvfs.cpp                         |   3 +
 indra/newview/CMakeLists.txt                  |  10 +
 indra/newview/app_settings/settings.xml       |  14 +-
 .../class2/deferred/multiSpotLightF.glsl      |   2 +-
 .../shaders/class2/deferred/sunLightF.glsl    |   4 +-
 indra/newview/licenses-win32.txt              |  69 ++
 indra/newview/llassetuploadresponders.cpp     | 661 +++++++++++++++---
 indra/newview/llassetuploadresponders.h       |  51 +-
 indra/newview/lldrawable.h                    |   6 +-
 indra/newview/lldrawpoolbump.cpp              |  12 +
 indra/newview/lldrawpoolbump.h                |   2 +-
 indra/newview/llface.cpp                      |   2 +-
 indra/newview/llfilepicker.cpp                |   5 +
 indra/newview/llfilepicker.h                  |   3 +
 indra/newview/llfloaterinventory.cpp          |   3 +
 indra/newview/llhudtext.cpp                   |  12 +
 indra/newview/llhudtext.h                     |   1 +
 indra/newview/llinventorybridge.cpp           |  94 ++-
 indra/newview/llinventorybridge.h             |  35 +-
 indra/newview/llpanelgroupnotices.cpp         |   1 +
 indra/newview/llselectmgr.cpp                 |  80 ++-
 indra/newview/llselectmgr.h                   |   1 +
 indra/newview/llspatialpartition.cpp          |   1 -
 indra/newview/llspatialpartition.h            |   1 +
 indra/newview/lltexturectrl.cpp               |   6 +-
 indra/newview/lltooldraganddrop.cpp           |  11 +
 indra/newview/llviewerdisplay.cpp             |   8 +-
 indra/newview/llviewerfloaterreg.cpp          |   4 +-
 indra/newview/llviewermenu.cpp                |   2 +-
 indra/newview/llviewermenufile.cpp            | 330 +++++++--
 indra/newview/llviewermenufile.h              |  77 +-
 indra/newview/llviewermessage.cpp             |   1 +
 indra/newview/llviewerregion.cpp              |   2 +
 indra/newview/llviewertexteditor.cpp          |   1 +
 indra/newview/llviewertexture.cpp             |   2 +-
 indra/newview/llviewerwindow.cpp              | 134 ----
 indra/newview/llvovolume.cpp                  | 183 ++++-
 indra/newview/llvovolume.h                    |   9 +
 indra/newview/pipeline.cpp                    | 241 ++++++-
 indra/newview/pipeline.h                      |  33 +
 .../skins/default/textures/textures.xml       |   2 +
 .../skins/default/xui/en/floater_about.xml    |   3 +
 .../default/xui/en/floater_inventory.xml      |  10 +
 .../skins/default/xui/en/floater_tools.xml    |   3 +
 .../skins/default/xui/en/menu_viewer.xml      |   4 +-
 .../skins/default/xui/en/notifications.xml    |  25 +-
 .../newview/skins/default/xui/en/strings.xml  |   1 +
 indra/newview/viewer_manifest.py              |   6 +
 install.xml                                   | 166 +++++
 71 files changed, 2351 insertions(+), 468 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 173e650961d..3bd10ea9ee9 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -49,11 +49,12 @@ if (WINDOWS)
 
   add_definitions(
       /DLL_WINDOWS=1
+      /DDOM_DYNAMIC
       /DUNICODE
       /D_UNICODE 
       /GS
       /TP
-      /W3
+      /W2
       /c
       /Zc:forScope
       /nologo
@@ -195,7 +196,7 @@ endif (DARWIN)
 
 
 if (LINUX OR DARWIN)
-  set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-non-virtual-dtor -Woverloaded-virtual")
+  set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-non-virtual-dtor")
 
   if (NOT GCC_DISABLE_FATAL_WARNINGS)
     set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
diff --git a/indra/cmake/LLPrimitive.cmake b/indra/cmake/LLPrimitive.cmake
index d397b78f1c9..9f8d99a0bf0 100644
--- a/indra/cmake/LLPrimitive.cmake
+++ b/indra/cmake/LLPrimitive.cmake
@@ -1,7 +1,27 @@
 # -*- cmake -*-
 
+# these should be moved to their own cmake file
+include(Prebuilt)
+use_prebuilt_binary(colladadom)
+use_prebuilt_binary(pcre)
+use_prebuilt_binary(libxml)
+
 set(LLPRIMITIVE_INCLUDE_DIRS
     ${LIBS_OPEN_DIR}/llprimitive
     )
 
-set(LLPRIMITIVE_LIBRARIES llprimitive)
+if (WINDOWS)
+    set(LLPRIMITIVE_LIBRARIES 
+        llprimitive
+        libcollada14dom21
+        )
+else (WINDOWS)
+    set(LLPRIMITIVE_LIBRARIES 
+        llprimitive
+        collada14dom
+        xml2
+        pcrecpp
+        pcre
+        )
+endif (WINDOWS)
+
diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp
index 0b016b81fbe..d57494b444c 100644
--- a/indra/llcommon/llassettype.cpp
+++ b/indra/llcommon/llassettype.cpp
@@ -107,6 +107,7 @@ LLAssetDictionary::LLAssetDictionary()
 
 	addEntry(LLAssetType::AT_LINK, 				new AssetEntry("LINK",				"link",		"symbolic link",	"Link", 			DAD_LINK,		FALSE,		TRUE));
 	addEntry(LLAssetType::AT_LINK_FOLDER, 		new AssetEntry("FOLDER_LINK",		"link_f", 	"symbolic folder link", "New Folder", 	DAD_LINK,		FALSE,		TRUE));
+	addEntry(LLAssetType::AT_MESH,              new AssetEntry("MESH",              "mesh",     "mesh",             "Meshes",           DAD_MESH,       FALSE,		TRUE));
 
 	for (S32 ensemble_num = S32(LLAssetType::AT_FOLDER_ENSEMBLE_START); 
 		 ensemble_num <= S32(LLAssetType::AT_FOLDER_ENSEMBLE_END); 
diff --git a/indra/llcommon/llassettype.h b/indra/llcommon/llassettype.h
index 5e511885416..a1154d16e3f 100644
--- a/indra/llcommon/llassettype.h
+++ b/indra/llcommon/llassettype.h
@@ -147,9 +147,11 @@ class LLAssetType
 
 		AT_MY_OUTFITS = 48,
 			// Folder that holds your outfits.
+			
+		AT_MESH = 49,
+		    // Mesh data in our proprietary SLM format
 
-		
-		AT_COUNT = 49,
+		AT_COUNT = 50,
 			// +*********************************************************+
 			// |  TO ADD AN ELEMENT TO THIS ENUM:                        |
 			// +*********************************************************+
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index 920d8c09777..e3906bc86e3 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -75,7 +75,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
 	// Run the user supplied function
 	threadp->run();
 
-	llinfos << "LLThread::staticRun() Exiting: " << threadp->mName << llendl;
+	//llinfos << "LLThread::staticRun() Exiting: " << threadp->mName << llendl;
 	
 	// We're done with the run function, this thread is done executing now.
 	threadp->mStatus = STOPPED;
diff --git a/indra/llcommon/stdenums.h b/indra/llcommon/stdenums.h
index 1a5678dde13..6eead924dad 100644
--- a/indra/llcommon/stdenums.h
+++ b/indra/llcommon/stdenums.h
@@ -55,7 +55,8 @@ enum EDragAndDropType
 	DAD_ANIMATION		= 12,
 	DAD_GESTURE			= 13,
 	DAD_LINK			= 14,
-	DAD_COUNT			= 15,   // number of types in this enum
+	DAD_MESH           		= 15,
+	DAD_COUNT			= 16,   // number of types in this enum
 };
 
 // Reasons for drags to be denied.
diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp
index a445466b26a..ae3cb2697b7 100644
--- a/indra/llinventory/llinventorytype.cpp
+++ b/indra/llinventory/llinventorytype.cpp
@@ -96,7 +96,9 @@ LLInventoryDictionary::LLInventoryDictionary()
 	addEntry(LLInventoryType::IT_WEARABLE,            new InventoryEntry("wearable",  "wearable",      2, LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART));
 	addEntry(LLInventoryType::IT_ANIMATION,           new InventoryEntry("animation", "animation",     1, LLAssetType::AT_ANIMATION));  
 	addEntry(LLInventoryType::IT_GESTURE,             new InventoryEntry("gesture",   "gesture",       1, LLAssetType::AT_GESTURE)); 
-	addEntry(LLInventoryType::IT_FAVORITE,            new InventoryEntry("favorite",  "favorite",      1, LLAssetType::AT_FAVORITE)); 
+	addEntry(LLInventoryType::IT_FAVORITE,            new InventoryEntry("favorite",  "favorite",      1, LLAssetType::AT_FAVORITE));
+	addEntry(LLInventoryType::IT_MESH,                new InventoryEntry("mesh",      "mesh",          1, LLAssetType::AT_MESH));
+
 }
 
 
@@ -132,7 +134,7 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
 
 	LLInventoryType::IT_NONE,			// AT_LINK
 	LLInventoryType::IT_NONE,			// AT_LINK_FOLDER
-
+	
 	LLInventoryType::IT_CATEGORY,		// AT_ENSEMBLE
 	LLInventoryType::IT_CATEGORY,		// AT_ENSEMBLE
 	LLInventoryType::IT_CATEGORY,		// AT_ENSEMBLE
@@ -157,6 +159,7 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
 	LLInventoryType::IT_CATEGORY,		// AT_CURRENT_OUTFIT
 	LLInventoryType::IT_CATEGORY,		// AT_OUTFIT
 	LLInventoryType::IT_CATEGORY,		// AT_MY_OUTFITS
+	LLInventoryType::IT_MESH,           // AT_MESH
 };
 
 // static
diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h
index 14b28bfe4b8..0d580d30005 100644
--- a/indra/llinventory/llinventorytype.h
+++ b/indra/llinventory/llinventorytype.h
@@ -68,7 +68,8 @@ class LLInventoryType
 		IT_ANIMATION = 19,
 		IT_GESTURE = 20,
 		IT_FAVORITE = 21,
-		IT_COUNT = 22,
+		IT_MESH = 22,
+		IT_COUNT = 23,
 
 		IT_NONE = -1
 	};
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index b8ef92f9a98..afa82ed3995 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -46,6 +46,9 @@
 #include "lldarray.h"
 #include "llvolume.h"
 #include "llstl.h"
+#include "llsdserialize.h"
+#include "zlib/zlib.h"
+
 
 #define DEBUG_SILHOUETTE_BINORMALS 0
 #define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette
@@ -1688,7 +1691,7 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 	mGenerateSingleFace = generate_single_face;
 
 	generate();
-	if (mParams.getSculptID().isNull())
+	if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
 	{
 		createVolumeFaces();
 	}
@@ -1839,6 +1842,295 @@ BOOL LLVolume::generate()
 	return FALSE;
 }
 
+bool LLVolumeFace::VertexData::operator<(const LLVolumeFace::VertexData& rhs)const
+{
+	const U8* l = (const U8*) this;
+	const U8* r = (const U8*) &rhs;
+
+	for (U32 i = 0; i < sizeof(VertexData); ++i)
+	{
+		if (l[i] != r[i])
+		{
+			return r[i] < l[i];
+		}
+	}
+	
+	return false;
+}
+
+bool LLVolumeFace::VertexData::operator==(const LLVolumeFace::VertexData& rhs)const
+{
+	const U8* l = (const U8*) this;
+	const U8* r = (const U8*) &rhs;
+
+	for (U32 i = 0; i < sizeof(VertexData); ++i)
+	{
+		if (l[i] != r[i])
+		{
+			return false;
+		}
+	}
+	
+	return true;
+}
+
+
+BOOL LLVolume::createVolumeFacesFromFile(const std::string& file_name)
+{
+	std::ifstream is;
+	
+	is.open(file_name.c_str(), std::ifstream::in | std::ifstream::binary);
+
+	BOOL success = createVolumeFacesFromStream(is);
+	
+	is.close();
+
+	return success;
+}
+
+BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
+{
+	mSculptLevel = -1;  // default is an error occured
+	
+	LLSD header;
+	{
+		if (!LLSDSerialize::deserialize(header, is, 1024*1024*1024))
+		{
+			llwarns << "not a valid mesh asset!" << llendl;
+			return FALSE;
+		}
+	}
+	
+	std::string nm[] = 
+	{
+		"impostor",
+		"low_lod",
+		"medium_lod",
+		"high_lod"
+	};
+
+	S32 lod = llclamp((S32) mDetail, 0, 3);
+
+	while (lod < 4 && header[nm[lod]]["offset"].asInteger() == -1)
+	{
+		++lod;
+	}
+
+	if (lod >= 4)
+	{
+		llwarns << "Couldn't load model for given lod" << llendl;
+		return FALSE;
+	}
+
+	is.seekg(header[nm[lod]]["offset"].asInteger(), std::ios_base::cur);
+	
+
+	U8* result = NULL;
+	U32 cur_size = 0;
+
+	{
+		//input stream is now pointing at a zlib compressed block of LLSD
+		//decompress block
+		z_stream strm;
+		
+		const U32 CHUNK = 65536;
+
+		S32 size = header[nm[lod]]["size"].asInteger();
+		U8 *in = new U8[size];
+		is.read((char*) in, size); 
+
+		U8 out[CHUNK];
+			
+		strm.zalloc = Z_NULL;
+		strm.zfree = Z_NULL;
+		strm.opaque = Z_NULL;
+		strm.avail_in = size;
+		strm.next_in = in;
+
+		S32 ret = inflateInit(&strm);
+
+		if (ret != Z_OK)
+		{
+			llerrs << "WTF?" << llendl;
+		}
+		
+		do
+		{
+			strm.avail_out = CHUNK;
+			strm.next_out = out;
+			ret = inflate(&strm, Z_NO_FLUSH);
+			if (ret == Z_STREAM_ERROR)
+			{
+				inflateEnd(&strm);
+				free(result);
+				delete [] in;
+				return FALSE;
+			}
+			
+			switch (ret)
+			{
+			case Z_NEED_DICT:
+				ret = Z_DATA_ERROR;
+			case Z_DATA_ERROR:
+			case Z_MEM_ERROR:
+				inflateEnd(&strm);
+				free(result);
+				delete [] in;
+				return FALSE;
+				break;
+			}
+
+			U32 have = CHUNK-strm.avail_out;
+
+			result = (U8*) realloc(result, cur_size + have);
+			memcpy(result+cur_size, out, have);
+			cur_size += have;
+
+		} while (strm.avail_out == 0);
+
+		inflateEnd(&strm);
+		delete [] in;
+
+		if (ret != Z_STREAM_END)
+		{
+			free(result);
+			return FALSE;
+		}
+	}
+
+	//result now points to the decompressed LLSD block
+
+	LLSD mdl;
+
+	{
+		std::string res_str((char*) result, cur_size);
+		std::istringstream istr(res_str);
+
+		if (!LLSDSerialize::deserialize(mdl, istr, cur_size))
+		{
+			llwarns << "not a valid mesh asset!" << llendl;
+			return FALSE;
+		}
+	}
+
+
+	free(result);
+
+
+	{
+		U32 face_count = mdl.size();
+
+		mVolumeFaces.resize(face_count);
+
+		for (U32 i = 0; i < face_count; ++i)
+		{
+			LLSD::Binary pos = mdl[i]["Position"];
+			LLSD::Binary norm = mdl[i]["Normal"];
+			LLSD::Binary tc = mdl[i]["TexCoord0"];
+			LLSD::Binary idx = mdl[i]["TriangleList"];
+
+			LLVolumeFace& face = mVolumeFaces[i];
+
+			face.mHasBinormals = FALSE;
+
+			//copy out indices
+			face.mIndices.resize(idx.size()/2);
+			if (idx.empty())
+			{ //why is there an empty index list?
+				continue;
+			}
+
+			U16* indices = (U16*) &(idx[0]);
+			for (U32 j = 0; j < idx.size()/2; ++j)
+			{
+				face.mIndices[j] = indices[j];
+			}
+
+			//copy out vertices
+			U32 num_verts = pos.size()/(3*2);
+			face.mVertices.resize(num_verts);
+
+			LLVector3 min_pos;
+			LLVector3 max_pos;
+			LLVector2 min_tc; 
+			LLVector2 max_tc; 
+
+			min_pos.setValue(mdl[i]["PositionDomain"]["Min"]);
+			max_pos.setValue(mdl[i]["PositionDomain"]["Max"]);
+			min_tc.setValue(mdl[i]["TexCoord0Domain"]["Min"]);
+			max_tc.setValue(mdl[i]["TexCoord0Domain"]["Max"]);
+
+			F32 scale = llclamp((F32) mdl[i]["Scale"].asReal(), 1.f, 10.f);
+
+			LLVector3 pos_range = max_pos - min_pos;
+			LLVector2 tc_range = max_tc - min_tc;
+
+			LLVector3& min = face.mExtents[0];
+			LLVector3& max = face.mExtents[1];
+
+			min = max = LLVector3(0,0,0);
+
+			for (U32 j = 0; j < num_verts; ++j)
+			{
+				U16* v = (U16*) &(pos[j*3*2]);
+
+				face.mVertices[j].mPosition.setVec(
+					(F32) v[0] / 65535.f * pos_range.mV[0] + min_pos.mV[0],
+					(F32) v[1] / 65535.f * pos_range.mV[1] + min_pos.mV[1],
+					(F32) v[2] / 65535.f * pos_range.mV[2] + min_pos.mV[2]);
+
+				face.mVertices[j].mPosition *= scale;
+
+				if (j == 0)
+				{
+					min = max = face.mVertices[j].mPosition;
+				}
+				else
+				{
+					update_min_max(min,max,face.mVertices[j].mPosition);
+				}
+
+				U16* n = (U16*) &(norm[j*3*2]);
+
+				face.mVertices[j].mNormal.setVec(
+					(F32) n[0] / 65535.f * 2.f - 1.f,
+					(F32) n[1] / 65535.f * 2.f - 1.f,
+					(F32) n[2] / 65535.f * 2.f - 1.f);
+
+				U16* t = (U16*) &(tc[j*2*2]);
+
+				face.mVertices[j].mTexCoord.setVec(
+					(F32) t[0] / 65535.f * tc_range.mV[0] + min_tc.mV[0],
+					(F32) t[1] / 65535.f * tc_range.mV[1] + min_tc.mV[1]);
+			}
+
+		}
+	}
+
+	mSculptLevel = 0;  // success!
+	return TRUE;
+}
+
+void LLVolume::copyVolumeFaces(LLVolume* volume)
+{
+	mVolumeFaces = volume->mVolumeFaces;
+	mSculptLevel = 0;
+}
+
+S32 const LL_SCULPT_MESH_MAX_FACES = 8;
+
+S32	LLVolume::getNumFaces() const
+{
+	U8 sculpt_type = (mParams.getSculptType() & LL_SCULPT_TYPE_MASK);
+
+	if (sculpt_type == LL_SCULPT_TYPE_MESH)
+	{
+		return LL_SCULPT_MESH_MAX_FACES;
+	}
+
+	return (S32)mProfilep->mFaces.size();
+}
+
 
 void LLVolume::createVolumeFaces()
 {
@@ -1864,6 +2156,11 @@ void LLVolume::createVolumeFaces()
 			LLProfile::Face& face = mProfilep->mFaces[i];
 			vf.mBeginS = face.mIndex;
 			vf.mNumS = face.mCount;
+			if (vf.mNumS < 0)
+			{
+				llerrs << "Volume face corruption detected." << llendl;
+			}
+
 			vf.mBeginT = 0;
 			vf.mNumT= getPath().mPath.size();
 			vf.mID = i;
@@ -1907,6 +2204,10 @@ void LLVolume::createVolumeFaces()
 					if (face.mFlat && vf.mNumS > 2)
 					{ //flat inner faces have to copy vert normals
 						vf.mNumS = vf.mNumS*2;
+						if (vf.mNumS < 0)
+						{
+							llerrs << "Volume face corruption detected." << llendl;
+						}
 					}
 				}
 				else
@@ -2309,7 +2610,6 @@ bool LLVolumeParams::operator<(const LLVolumeParams &params) const
 		return mSculptID < params.mSculptID;
 	}
 
-
 	return mSculptType < params.mSculptType;
 
 
@@ -3379,22 +3679,29 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 										  S32 face_mask)
 {
 	LLMemType m1(LLMemType::MTYPE_VOLUME);
-	
+
 	vertices.clear();
 	normals.clear();
 	segments.clear();
 
+	if (mParams.getSculptType() == LL_SCULPT_TYPE_MESH)
+	{
+		return;
+	}
+	
 	S32 cur_index = 0;
 	//for each face
 	for (face_list_t::iterator iter = mVolumeFaces.begin();
 		 iter != mVolumeFaces.end(); ++iter)
 	{
-		const LLVolumeFace& face = *iter;
+		LLVolumeFace& face = *iter;
 	
-		if (!(face_mask & (0x1 << cur_index++)))
+		if (!(face_mask & (0x1 << cur_index++)) ||
+		     face.mIndices.empty() || face.mEdge.empty())
 		{
 			continue;
 		}
+
 		if (face.mTypeMask & (LLVolumeFace::CAP_MASK)) {
 	
 		}
@@ -3594,6 +3901,8 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 	F32 closest_t = 2.f; // must be larger than 1
 	
+	end_face = llmin(end_face, getNumVolumeFaces()-1);
+
 	for (S32 i = start_face; i <= end_face; i++)
 	{
 		const LLVolumeFace &face = getVolumeFace((U32)i);
@@ -4103,11 +4412,28 @@ BOOL LLVolumeParams::exportLegacyStream(std::ostream& output_stream) const
 	return TRUE;
 }
 
+LLSD LLVolumeParams::sculptAsLLSD() const
+{
+	LLSD sd = LLSD();
+	sd["id"] = getSculptID();
+	sd["type"] = getSculptType();
+
+	return sd;
+}
+
+bool LLVolumeParams::sculptFromLLSD(LLSD& sd)
+{
+	setSculptID(sd["id"].asUUID(), (U8)sd["type"].asInteger());
+	return true;
+}
+
 LLSD LLVolumeParams::asLLSD() const
 {
 	LLSD sd = LLSD();
 	sd["path"] = mPathParams;
 	sd["profile"] = mProfileParams;
+	sd["sculpt"] = sculptAsLLSD();
+	
 	return sd;
 }
 
@@ -4115,6 +4441,8 @@ bool LLVolumeParams::fromLLSD(LLSD& sd)
 {
 	mPathParams.fromLLSD(sd["path"]);
 	mProfileParams.fromLLSD(sd["profile"]);
+	sculptFromLLSD(sd["sculpt"]);
+		
 	return true;
 }
 
@@ -4157,6 +4485,12 @@ const F32 MIN_CONCAVE_PATH_WEDGE = 0.111111f;	// 1/9 unity
 // for collison purposes
 BOOL LLVolumeParams::isConvex() const
 {
+	if (!getSculptID().isNull())
+	{
+		// can't determine, be safe and say no:
+		return FALSE;
+	}
+	
 	F32 path_length = mPathParams.getEnd() - mPathParams.getBegin();
 	F32 hollow = mProfileParams.getHollow();
 	 
@@ -5011,7 +5345,11 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 	if (!partial_build)
 	{
 		mIndices.resize(num_indices);
-		mEdge.resize(num_indices);
+
+		if (volume->getParams().getSculptType() != LL_SCULPT_TYPE_MESH)
+		{
+			mEdge.resize(num_indices);
+		}
 	}
 	else
 	{
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 871b3344521..9f595ccbc4a 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -186,6 +186,9 @@ const U8 LL_SCULPT_TYPE_CYLINDER  = 4;
 
 const U8 LL_SCULPT_TYPE_MASK      = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE | LL_SCULPT_TYPE_CYLINDER;
 
+// need to change this (these) names
+const U8 LL_SCULPT_TYPE_MESH      = 5;
+
 const U8 LL_SCULPT_FLAG_INVERT    = 64;
 const U8 LL_SCULPT_FLAG_MIRROR    = 128;
 
@@ -575,6 +578,9 @@ class LLVolumeParams
 	BOOL importLegacyStream(std::istream& input_stream);
 	BOOL exportLegacyStream(std::ostream& output_stream) const;
 
+	LLSD sculptAsLLSD() const;
+	bool sculptFromLLSD(LLSD& sd);
+	
 	LLSD asLLSD() const;
 	operator LLSD() const { return asLLSD(); }
 	bool fromLLSD(LLSD& sd);
@@ -634,7 +640,6 @@ class LLVolumeParams
 	const F32&  getSkew() const			{ return mPathParams.getSkew();			}
 	const LLUUID& getSculptID() const	{ return mSculptID;						}
 	const U8& getSculptType() const     { return mSculptType;                   }
-
 	BOOL isConvex() const;
 
 	// 'begin' and 'end' should be in range [0, 1] (they will be clamped)
@@ -798,7 +803,7 @@ class LLVolumeFace
 
 	BOOL create(LLVolume* volume, BOOL partial_build = FALSE);
 	void createBinormals();
-
+	
 	class VertexData
 	{
 	public:
@@ -806,6 +811,9 @@ class LLVolumeFace
 		LLVector3 mNormal;
 		LLVector3 mBinormal;
 		LLVector2 mTexCoord;
+
+		bool operator<(const VertexData& rhs) const;
+		bool operator==(const VertexData& rhs) const;
 	};
 
 	enum
@@ -851,8 +859,7 @@ class LLVolume : public LLRefCount
 {
 	friend class LLVolumeLODGroup;
 
-private:
-	LLVolume(const LLVolume&);  // Don't implement
+protected:
 	~LLVolume(); // use unref
 
 public:
@@ -874,7 +881,7 @@ class LLVolume : public LLRefCount
 	
 	U8 getProfileType()	const								{ return mParams.getProfileParams().getCurveType(); }
 	U8 getPathType() const									{ return mParams.getPathParams().getCurveType(); }
-	S32	getNumFaces() const									{ return (S32)mProfilep->mFaces.size(); }
+	S32	getNumFaces() const;
 	S32 getNumVolumeFaces() const							{ return mVolumeFaces.size(); }
 	F32 getDetail() const									{ return mDetail; }
 	const LLVolumeParams& getParams() const					{ return mParams; }
@@ -946,6 +953,8 @@ class LLVolume : public LLRefCount
 	LLVector3			mLODScaleBias;		// vector for biasing LOD based on scale
 	
 	void sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level);
+	void copyVolumeFaces(LLVolume* volume);
+
 private:
 	void sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type);
 	F32 sculptGetSurfaceArea();
@@ -956,6 +965,9 @@ class LLVolume : public LLRefCount
 protected:
 	BOOL generate();
 	void createVolumeFaces();
+public:
+	virtual BOOL createVolumeFacesFromFile(const std::string& file_name);
+	virtual BOOL createVolumeFacesFromStream(std::istream& is);
 
  protected:
 	BOOL mUnique;
diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp
index 53641fceab1..61c5a0adc90 100644
--- a/indra/llmath/llvolumemgr.cpp
+++ b/indra/llmath/llvolumemgr.cpp
@@ -320,7 +320,7 @@ BOOL LLVolumeLODGroup::derefLOD(LLVolume *volumep)
 		{
 			llassert_always(mLODRefs[i] > 0);
 			mLODRefs[i]--;
-#if 1 // SJB: Possible opt: keep other lods around
+#if 0 // SJB: Possible opt: keep other lods around
 			if (!mLODRefs[i])
 			{
 				mVolumeLODs[i] = NULL;
diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp
index d8e7b4aaf9c..7c7f60154da 100644
--- a/indra/llmath/m4math.cpp
+++ b/indra/llmath/m4math.cpp
@@ -428,6 +428,17 @@ const LLMatrix4&  	LLMatrix4::initRotTrans(const LLQuaternion &q, const LLVector
 	return (*this);
 }
 
+const LLMatrix4& LLMatrix4::initScale(const LLVector3 &scale)
+{
+	setIdentity();
+
+	mMatrix[VX][VX] = scale.mV[VX];
+	mMatrix[VY][VY] = scale.mV[VY];
+	mMatrix[VZ][VZ] = scale.mV[VZ];
+	
+	return (*this);
+}
+
 const LLMatrix4& LLMatrix4::initAll(const LLVector3 &scale, const LLQuaternion &q, const LLVector3 &pos)
 {
 	F32		sx, sy, sz;
diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h
index e74b7afe9bd..de981b76466 100644
--- a/indra/llmath/m4math.h
+++ b/indra/llmath/m4math.h
@@ -159,6 +159,7 @@ class LLMatrix4
 	const LLMatrix4& initRotTrans(const F32 roll, const F32 pitch, const F32 yaw, const LLVector4 &pos); // Rotation from Euler + translation
 	const LLMatrix4& initRotTrans(const LLQuaternion &q, const LLVector4 &pos);	// Set with Quaternion and position
 
+	const LLMatrix4& initScale(const LLVector3 &scale);
 
 	// Set all
 	const LLMatrix4& initAll(const LLVector3 &scale, const LLQuaternion &q, const LLVector3 &pos);	
diff --git a/indra/llmath/v2math.cpp b/indra/llmath/v2math.cpp
index 555e1f92bbb..220336e0c2a 100644
--- a/indra/llmath/v2math.cpp
+++ b/indra/llmath/v2math.cpp
@@ -115,3 +115,18 @@ LLVector2 lerp(const LLVector2 &a, const LLVector2 &b, F32 u)
 		a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u,
 		a.mV[VY] + (b.mV[VY] - a.mV[VY]) * u );
 }
+
+LLSD LLVector2::getValue() const
+{
+	LLSD ret;
+	ret[0] = mV[0];
+	ret[1] = mV[1];
+	return ret;
+}
+
+void LLVector2::setValue(LLSD& sd)
+{
+	mV[0] = (F32) sd[0].asReal();
+	mV[1] = (F32) sd[1].asReal();
+}
+
diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h
index 9fef8851cc6..f9f1c024f2a 100644
--- a/indra/llmath/v2math.h
+++ b/indra/llmath/v2math.h
@@ -66,6 +66,9 @@ class LLVector2
 		void	set(const LLVector2 &vec);	// Sets LLVector2 to vec
 		void	set(const F32 *vec);			// Sets LLVector2 to vec
 
+		LLSD	getValue() const;
+		void	setValue(LLSD& sd);
+
 		void	setVec(F32 x, F32 y);	        // deprecated
 		void	setVec(const LLVector2 &vec);	// deprecated
 		void	setVec(const F32 *vec);			// deprecated
diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp
index b3087bcc3f8..eeb903de6ae 100644
--- a/indra/llmessage/llassetstorage.cpp
+++ b/indra/llmessage/llassetstorage.cpp
@@ -502,7 +502,7 @@ void LLAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::EType at
 			tpvf.setAsset(uuid, atype);
 			tpvf.setCallback(downloadCompleteCallback, req);
 
-			llinfos << "Starting transfer for " << uuid << llendl;
+			//llinfos << "Starting transfer for " << uuid << llendl;
 			LLTransferTargetChannel *ttcp = gTransferManager.getTargetChannel(mUpstreamHost, LLTCT_ASSET);
 			ttcp->requestTransfer(spa, tpvf, 100.f + (is_priority ? 1.f : 0.f));
 		}
diff --git a/indra/llmessage/lltransfermanager.cpp b/indra/llmessage/lltransfermanager.cpp
index d67911e8e2a..72662bb782e 100644
--- a/indra/llmessage/lltransfermanager.cpp
+++ b/indra/llmessage/lltransfermanager.cpp
@@ -344,7 +344,7 @@ void LLTransferManager::processTransferInfo(LLMessageSystem *msgp, void **)
 		}
 	}
 
-	llinfos << "Receiving " << transfer_id << ", size " << size << " bytes" << llendl;
+	//llinfos << "Receiving " << transfer_id << ", size " << size << " bytes" << llendl;
 	ttp->setSize(size);
 	ttp->setGotInfo(TRUE);
 
diff --git a/indra/llmessage/lltransfersourceasset.cpp b/indra/llmessage/lltransfersourceasset.cpp
index 5a1cd95ffcd..f255a2cf7ec 100644
--- a/indra/llmessage/lltransfersourceasset.cpp
+++ b/indra/llmessage/lltransfersourceasset.cpp
@@ -271,6 +271,7 @@ bool is_asset_fetch_by_id_allowed(LLAssetType::EType type)
 		case LLAssetType::AT_ANIMATION:
 		case LLAssetType::AT_GESTURE:
 		case LLAssetType::AT_FAVORITE:
+		case LLAssetType::AT_MESH:
 			rv = true;
 			break;
 		default:
@@ -296,6 +297,7 @@ bool is_asset_id_knowable(LLAssetType::EType type)
 		case LLAssetType::AT_FAVORITE:
 		case LLAssetType::AT_LINK:
 		case LLAssetType::AT_LINK_FOLDER:
+	    case LLAssetType::AT_MESH:
 			rv = true;
 			break;
 		default:
diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt
index d1305136378..f9392a2b75f 100644
--- a/indra/llprimitive/CMakeLists.txt
+++ b/indra/llprimitive/CMakeLists.txt
@@ -13,11 +13,14 @@ include_directories(
     ${LLMATH_INCLUDE_DIRS}
     ${LLMESSAGE_INCLUDE_DIRS}
     ${LLXML_INCLUDE_DIRS}
+    ${LIBS_PREBUILT_DIR}/include/collada
+    ${LIBS_PREBUILT_DIR}/include/collada/1.4
     )
 
 set(llprimitive_SOURCE_FILES
     llmaterialtable.cpp
     llmediaentry.cpp
+    llmodel.cpp
     llprimitive.cpp
     llprimtexturelist.cpp
     lltextureanim.cpp
@@ -33,6 +36,7 @@ set(llprimitive_HEADER_FILES
     legacy_object_types.h
     llmaterialtable.h
     llmediaentry.h
+    llmodel.h
     llprimitive.h
     llprimtexturelist.h
     lltextureanim.h
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index b102254b62f..2675a27c08e 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -744,18 +744,11 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
 		return TRUE;
 	}
 
-	U32 old_face_mask = mVolumep->mFaceMask;
-
 	// build the new object
 	sVolumeManager->unrefVolume(mVolumep);
 	mVolumep = volumep;
-	
-	U32 new_face_mask = mVolumep->mFaceMask;
-	if (old_face_mask != new_face_mask) 
-	{
-		setNumTEs(mVolumep->getNumFaces());
-	}
-
+	setNumTEs(mVolumep->getNumFaces());
+		
 	return TRUE;
 }
 
@@ -898,7 +891,7 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
 	U8 packed_buffer[MAX_TE_BUFFER];
 	U8 *cur_ptr = packed_buffer;
 	
-	S32 last_face_index = getNumTEs() - 1;
+	S32 last_face_index = llmin((U32) getNumTEs(), MAX_TES) - 1;
 	
 	if (last_face_index > -1)
 	{
@@ -1179,7 +1172,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
 		return retval;
 	}
 
-	face_count = getNumTEs();
+	face_count = llmin((U32) getNumTEs(), MAX_TES);
 	U32 i;
 
 	cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_data, 16, face_count, MVT_LLUUID);
diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index 4f828186cbb..4db7aa7261d 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -328,7 +328,7 @@ class LLPrimitive : public LLXform
 	const LLVolume *getVolumeConst() const { return mVolumep; }		// HACK for Windoze confusion about ostream operator in LLVolume
 	LLVolume *getVolume() const { return mVolumep; }
 	virtual BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
-
+	
 	// Modify texture entry properties
 	inline BOOL validTE(const U8 te_num) const;
 	LLTextureEntry* getTE(const U8 te_num) const;
diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp
index 5fdf41188d4..e0e282d7afa 100644
--- a/indra/llvfs/llvfile.cpp
+++ b/indra/llvfs/llvfile.cpp
@@ -428,7 +428,7 @@ bool LLVFile::isLocked(EVFSLock lock)
 
 void LLVFile::waitForLock(EVFSLock lock)
 {
-	LLFastTimer t(FTM_VFILE_WAIT);
+	//LLFastTimer t(FTM_VFILE_WAIT);
 	// spin until the lock clears
 	while (isLocked(lock))
 	{
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index 9ce1e75d06f..ddb76fb2ba1 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -2041,6 +2041,9 @@ std::string get_extension(LLAssetType::EType type)
 	case LLAssetType::AT_ANIMATION:
 		extension = ".lla";
 		break;
+	case LLAssetType::AT_MESH:
+		extension = ".slm";
+		break;
 	default:
 		// Just use the asset server filename extension in most cases
 		extension += ".";
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 26170d17137..3cee6394e03 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -36,6 +36,7 @@ include(UI)
 include(UnixInstall)
 include(LLKDU)
 include(ViewerMiscLibs)
+include(GLOD)
 
 if (WINDOWS)
     include(CopyWinLibs)
@@ -44,6 +45,7 @@ endif (WINDOWS)
 include_directories(
     ${DBUSGLIB_INCLUDE_DIRS}
     ${ELFIO_INCLUDE_DIR}
+    ${GLOD_INCLUDE_DIR}
     ${LLAUDIO_INCLUDE_DIRS}
     ${LLCHARACTER_INCLUDE_DIRS}
     ${LLCOMMON_INCLUDE_DIRS}
@@ -61,6 +63,8 @@ include_directories(
     ${LLXUIXML_INCLUDE_DIRS}
     ${LSCRIPT_INCLUDE_DIRS}
     ${LSCRIPT_INCLUDE_DIRS}/lscript_compile
+    ${LIBS_PREBUILT_DIR}/include/collada
+    ${LIBS_PREBUILT_DIR}/include/collada/1.4
     )
 
 set(viewer_SOURCE_FILES
@@ -175,6 +179,7 @@ set(viewer_SOURCE_FILES
     llfloatermediasettings.cpp
     llfloaterhud.cpp
     llfloaterimagepreview.cpp
+    llfloaterimportcollada.cpp
     llfloaterinspect.cpp
     llfloaterinventory.cpp
     llfloaterjoystick.cpp
@@ -183,6 +188,7 @@ set(viewer_SOURCE_FILES
     llfloaterlandholdings.cpp
     llfloatermap.cpp
     llfloatermemleak.cpp
+    llfloatermodelpreview.cpp
     llfloaternamedesc.cpp
     llfloaternotificationsconsole.cpp
     llfloateropenobject.cpp
@@ -647,6 +653,7 @@ set(viewer_HEADER_FILES
     llfloatermediasettings.h
     llfloaterhud.h
     llfloaterimagepreview.h
+    llfloaterimportcollada.h
     llfloaterinspect.h
     llfloaterinventory.h
     llfloaterjoystick.h
@@ -655,6 +662,7 @@ set(viewer_HEADER_FILES
     llfloaterlandholdings.h
     llfloatermap.h
     llfloatermemleak.h
+    llfloatermodelpreview.h
     llfloaternamedesc.h
     llfloaternotificationsconsole.h
     llfloateropenobject.h
@@ -1139,6 +1147,7 @@ if (WINDOWS)
         ${DXGUID_LIBRARY}
         fmodvc
         kernel32
+        libboost_system
         odbc32
         odbccp32
         ole32
@@ -1405,6 +1414,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
     ${DBUSGLIB_LIBRARIES}
     ${OPENGL_LIBRARIES}
     ${FMODWRAPPER_LIBRARY}
+    ${GLOD_LIBRARIES}
     ${OPENGL_LIBRARIES}
     ${SDL_LIBRARY}
     ${SMARTHEAP_LIBRARY}
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 7e368b0c9c8..073ea766fe7 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7252,7 +7252,19 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>SafeMode</key>
+  <key>MeshThreadCount</key>
+  <map>
+    <key>Comment</key>
+    <string>Number of threads to use for loading meshes.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>U32</string>
+    <key>Value</key>
+    <integer>8</integer>
+  </map>
+
+  <key>SafeMode</key>
     <map>
       <key>Comment</key>
       <string>Reset preferences, run in safe mode.</string>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 651959413cd..45884d57324 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -137,7 +137,7 @@ void main()
 		}
 		
 		//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
-		vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_ambient_lod);
+		vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_lod);
 							
 		amb_da += (da*da*0.5+0.5)*proj_ambiance;
 				
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index a0026edcd21..4333cc64a78 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -224,11 +224,11 @@ void main()
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.1).x; 
+	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x; 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.1).x; 
+	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x; 
 
 	//gl_FragColor.rgb = pos.xyz;
 	//gl_FragColor.b = shadow;
diff --git a/indra/newview/licenses-win32.txt b/indra/newview/licenses-win32.txt
index 7e6d4b4561c..87366269074 100644
--- a/indra/newview/licenses-win32.txt
+++ b/indra/newview/licenses-win32.txt
@@ -769,3 +769,72 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+=============
+GLOD license
+=============
+The GLOD Open-Source License   Version 1.0                June 16, 2004
+
+Copyright (C) 2003-04 Jonathan Cohen, Nat Duca, Chris Niski, Johns 
+Hopkins University and David Luebke, Brenden Schubert, University of 
+Virginia. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, is permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer and
+   request.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer and
+   request in the documentation and/or other materials provided with
+   the distribution.
+
+3. The name "GLOD" must not be used to endorse or promote products
+   derived from this software without prior written permission.
+
+4. Redistributions of any modified version of this source, whether in
+   source or binary form , must include a form of the following
+   acknowledgment: "This product is derived from the GLOD library,
+   which is available from http://www.cs.jhu.edu/~graphics/GLOD."
+
+5. Redistributions of any modified version of this source in binary
+   form must provide, free of charge, access to the modified version
+   of the code.
+
+6. This license shall be governed by and construed and enforced in
+   accordance with the laws of the State of Maryland, without
+   reference to its conflicts of law provisions. The exclusive
+   jurisdiction and venue for all legal actions relating to this
+   license shall be in courts of competent subject matter jurisdiction
+   located in the State of Maryland.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, GLOD IS PROVIDED
+UNDER THIS LICENSE ON AN AS IS BASIS, WITHOUT WARRANTY OF ANY KIND,
+EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
+THAT GLOD IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+PURPOSE OR NON-INFRINGING. ALL WARRANTIES ARE DISCLAIMED AND THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE CODE IS WITH
+YOU. SHOULD ANY CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+COPYRIGHT HOLDER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY
+NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY
+CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY CODE IS
+AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+THE COPYRIGHT HOLDER OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
+SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES FOR LOSS OF
+PROFITS, REVENUE, OR FOR LOSS OF INFORMATION OR ANY OTHER LOSS.
+
+YOU EXPRESSLY AGREE TO FOREVER INDEMNIFY, DEFEND AND HOLD HARMLESS THE
+COPYRIGHT HOLDERS AND CONTRIBUTORS OF GLOD AGAINST ALL CLAIMS,
+DEMANDS, SUITS OR OTHER ACTIONS ARISING DIRECTLY OR INDIRECTLY FROM
+YOUR ACCEPTANCE AND USE OF GLOD.
+
+Although NOT REQUIRED, we would appreciate it if active users of GLOD
+put a link on their web site to the GLOD web site when possible.
+
+
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index cd3963050f6..cb03379b23d 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -64,6 +64,7 @@
 #include "llfocusmgr.h"
 #include "llscrolllistctrl.h"
 #include "llsdserialize.h"
+#include "llsdutil.h"
 #include "llvfs.h"
 
 // When uploading multiple files, don't display any of them when uploading more than this number.
@@ -71,6 +72,120 @@ static const S32 FILE_COUNT_DISPLAY_THRESHOLD = 5;
 
 void dialog_refresh_all();
 
+void on_new_single_inventory_upload_complete(
+	LLAssetType::EType asset_type,
+	LLInventoryType::EType inventory_type,
+	const std::string inventory_type_string,
+	const LLUUID& item_folder_id,
+	const std::string& item_name,
+	const std::string& item_description,
+	const LLSD& server_response,
+	S32 upload_price)
+{
+	if ( upload_price > 0 )
+	{
+		// this upload costed us L$, update our balance
+		// and display something saying that it cost L$
+		LLStatusBar::sendMoneyBalanceRequest();
+
+		LLSD args;
+		args["AMOUNT"] = llformat("%d", upload_price);
+		LLNotifications::instance().add("UploadPayment", args);
+	}
+
+	// Actually add the upload to viewer inventory
+	llinfos << "Adding " << server_response["new_inventory_item"].asUUID()
+			<< " " << server_response["new_asset"].asUUID()
+			<< " to inventory." << llendl;
+
+	if( item_folder_id.notNull() )
+	{
+		U32 everyone_perms = PERM_NONE;
+		U32 group_perms = PERM_NONE;
+		U32 next_owner_perms = PERM_ALL;
+		if( server_response.has("new_next_owner_mask") )
+		{
+			// The server provided creation perms so use them.
+			// Do not assume we got the perms we asked for in
+			// since the server may not have granted them all.
+			everyone_perms = server_response["new_everyone_mask"].asInteger();
+			group_perms = server_response["new_group_mask"].asInteger();
+			next_owner_perms = server_response["new_next_owner_mask"].asInteger();
+		}
+		else 
+		{
+			// The server doesn't provide creation perms
+			// so use old assumption-based perms.
+			if( inventory_type_string != "snapshot")
+			{
+				next_owner_perms = PERM_MOVE | PERM_TRANSFER;
+			}
+		}
+
+		LLPermissions new_perms;
+		new_perms.init(
+			gAgent.getID(),
+			gAgent.getID(),
+			LLUUID::null,
+			LLUUID::null);
+
+		new_perms.initMasks(
+			PERM_ALL,
+			PERM_ALL,
+			everyone_perms,
+			group_perms,
+			next_owner_perms);
+
+		S32 creation_date_now = time_corrected();
+		LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(
+			server_response["new_inventory_item"].asUUID(),
+			item_folder_id,
+			new_perms,
+			server_response["new_asset"].asUUID(),
+			asset_type,
+			inventory_type,
+			item_name,
+			item_description,
+			LLSaleInfo::DEFAULT,
+			LLInventoryItem::II_FLAGS_NONE,
+			creation_date_now);
+
+		gInventory.updateItem(item);
+		gInventory.notifyObservers();
+
+		// Show the preview panel for textures and sounds to let
+		// user know that the image (or snapshot) arrived intact.
+		LLFloaterInventory* view = LLFloaterInventory::getActiveInventory();
+		if ( view )
+		{
+			LLFocusableElement* focus = gFocusMgr.getKeyboardFocus();
+
+			view->getPanel()->setSelection(
+				server_response["new_inventory_item"].asUUID(),
+				TAKE_FOCUS_NO);
+
+			if(
+				(LLAssetType::AT_TEXTURE == asset_type ||
+				 LLAssetType::AT_SOUND == asset_type) &&
+				(LLFilePicker::instance().getFileCount() <=
+				 FILE_COUNT_DISPLAY_THRESHOLD) )
+			{
+				view->getPanel()->openSelected();
+			}
+
+			// restore keyboard focus
+			gFocusMgr.setKeyboardFocus(focus);
+		}
+	}
+	else
+	{
+		llwarns << "Can't find a folder to put it in" << llendl;
+	}
+
+	// remove the "Uploading..." message
+	LLUploadDialog::modalUploadFinished();	
+}
+
 LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data,
 											   const LLUUID& vfile_id,
 											   LLAssetType::EType asset_type)
@@ -88,9 +203,10 @@ LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data,
 	}
 }
 
-LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data,
-											   const std::string& file_name, 
-											   LLAssetType::EType asset_type)
+LLAssetUploadResponder::LLAssetUploadResponder(
+	const LLSD &post_data,
+	const std::string& file_name, 
+	LLAssetType::EType asset_type)
 	: LLHTTPClient::Responder(),
 	  mPostData(post_data),
 	  mFileName(file_name),
@@ -196,15 +312,19 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)
 {
 }
 
-LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data,
-														   const LLUUID& vfile_id,
-														   LLAssetType::EType asset_type)
-: LLAssetUploadResponder(post_data, vfile_id, asset_type)
+LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
+	const LLSD& post_data,
+	const LLUUID& vfile_id,
+	LLAssetType::EType asset_type)
+	: LLAssetUploadResponder(post_data, vfile_id, asset_type)
 {
 }
 
-LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name, LLAssetType::EType asset_type)
-: LLAssetUploadResponder(post_data, file_name, asset_type)
+LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
+	const LLSD& post_data,
+	const std::string& file_name,
+	LLAssetType::EType asset_type)
+	: LLAssetUploadResponder(post_data, file_name, asset_type)
 {
 }
 
@@ -219,96 +339,31 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 
 	LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString());
 	LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString());
-	S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
+	S32 expected_upload_cost = 0;
 
 	// Update L$ and ownership credit information
 	// since it probably changed on the server
 	if (asset_type == LLAssetType::AT_TEXTURE ||
 		asset_type == LLAssetType::AT_SOUND ||
-		asset_type == LLAssetType::AT_ANIMATION)
+		asset_type == LLAssetType::AT_ANIMATION ||
+		asset_type == LLAssetType::AT_MESH)
 	{
-		LLStatusBar::sendMoneyBalanceRequest();
-
-		LLSD args;
-		args["AMOUNT"] = llformat("%d", expected_upload_cost);
-		LLNotifications::instance().add("UploadPayment", args);
+		expected_upload_cost = 
+			LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
 	}
 
-	// Actually add the upload to viewer inventory
-	llinfos << "Adding " << content["new_inventory_item"].asUUID() << " "
-			<< content["new_asset"].asUUID() << " to inventory." << llendl;
-	if(mPostData["folder_id"].asUUID().notNull())
-	{
-		//std::ostringstream out;
-		//LLSDXMLFormatter *formatter = new LLSDXMLFormatter;
-		//formatter->format(mPostData, out, LLSDFormatter::OPTIONS_PRETTY);
-		//llinfos << "Post Data: " << out.str() << llendl;
-
-		U32 everyone_perms = PERM_NONE;
-		U32 group_perms = PERM_NONE;
-		U32 next_owner_perms = PERM_ALL;
-		if(content.has("new_next_owner_mask"))
-		{
-			// This is a new sim that provides creation perms so use them.
-			// Do not assume we got the perms we asked for in mPostData 
-			// since the sim may not have granted them all.
-			everyone_perms = content["new_everyone_mask"].asInteger();
-			group_perms = content["new_group_mask"].asInteger();
-			next_owner_perms = content["new_next_owner_mask"].asInteger();
-		}
-		else 
-		{
-			// This old sim doesn't provide creation perms so use old assumption-based perms.
-			if(mPostData["inventory_type"].asString() != "snapshot")
-			{
-				next_owner_perms = PERM_MOVE | PERM_TRANSFER;
-			}
-		}
-		LLPermissions new_perms;
-		new_perms.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
-		new_perms.initMasks(PERM_ALL, PERM_ALL, everyone_perms, group_perms, next_owner_perms);
-		S32 creation_date_now = time_corrected();
-		LLPointer<LLViewerInventoryItem> item
-			= new LLViewerInventoryItem(content["new_inventory_item"].asUUID(),
-										mPostData["folder_id"].asUUID(),
-										new_perms,
-										content["new_asset"].asUUID(),
-										asset_type,
-										inventory_type,
-										mPostData["name"].asString(),
-										mPostData["description"].asString(),
-										LLSaleInfo::DEFAULT,
-										LLInventoryItem::II_FLAGS_NONE,
-										creation_date_now);
-		gInventory.updateItem(item);
-		gInventory.notifyObservers();
-
-		// Show the preview panel for textures and sounds to let
-		// user know that the image (or snapshot) arrived intact.
-		LLFloaterInventory* view = LLFloaterInventory::getActiveInventory();
-		if(view)
-		{
-			LLFocusableElement* focus = gFocusMgr.getKeyboardFocus();
+	on_new_single_inventory_upload_complete(
+		asset_type,
+		inventory_type,
+		mPostData["asset_type"].asString(),
+		mPostData["folder_id"].asUUID(),
+		mPostData["name"],
+		mPostData["description"],
+		content,
+		expected_upload_cost);
 
-			view->getPanel()->setSelection(content["new_inventory_item"].asUUID(), TAKE_FOCUS_NO);
-			if((LLAssetType::AT_TEXTURE == asset_type || LLAssetType::AT_SOUND == asset_type)
-				&& LLFilePicker::instance().getFileCount() <= FILE_COUNT_DISPLAY_THRESHOLD)
-			{
-				view->getPanel()->openSelected();
-			}
-			//LLFloaterInventory::dumpSelectionInformation((void*)view);
-			// restore keyboard focus
-			gFocusMgr.setKeyboardFocus(focus);
-		}
-	}
-	else
-	{
-		llwarns << "Can't find a folder to put it in" << llendl;
-	}
+	// continue uploading for bulk uploads
 
-	// remove the "Uploading..." message
-	LLUploadDialog::modalUploadFinished();
-	
 	// *FIX: This is a pretty big hack. What this does is check the
 	// file picker if there are any more pending uploads. If so,
 	// upload that file.
@@ -325,18 +380,39 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 
 		// Continuing the horrible hack above, we need to extract the originally requested permissions data, if any,
 		// and use them for each next file to be uploaded. Note the requested perms are not the same as the
-		// granted ones found in the given "content" structure but can still be found in mPostData. -MG
-		U32 everyone_perms   = mPostData.has("everyone_mask")   ? mPostData.get("everyone_mask"  ).asInteger() : PERM_NONE;
-		U32 group_perms      = mPostData.has("group_mask")      ? mPostData.get("group_mask"     ).asInteger() : PERM_NONE;
-		U32 next_owner_perms = mPostData.has("next_owner_mask") ? mPostData.get("next_owner_mask").asInteger() : PERM_NONE;
+		U32 everyone_perms =
+			content.has("everyone_mask") ?
+			content["everyone_mask"].asInteger() :
+			PERM_NONE;
+
+		U32 group_perms =
+			content.has("group_mask") ?
+			content["group_mask"].asInteger() :
+			PERM_NONE;
+
+		U32 next_owner_perms =
+			content.has("next_owner_mask") ?
+			content["next_owner_mask"].asInteger() :
+			PERM_NONE;
+
 		std::string display_name = LLStringUtil::null;
 		LLAssetStorage::LLStoreAssetCallback callback = NULL;
 		void *userdata = NULL;
-		upload_new_resource(next_file, asset_name, asset_name,
-				    0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE,
-				    next_owner_perms, group_perms,
-				    everyone_perms, display_name,
-				    callback, expected_upload_cost, userdata);
+
+		upload_new_resource(
+			next_file,
+			asset_name,
+			asset_name,
+			0,
+			LLAssetType::AT_NONE,
+			LLInventoryType::IT_NONE,
+			next_owner_perms,
+			group_perms,
+			everyone_perms,
+			display_name,
+			callback,
+			LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(),
+			userdata);
 	}
 }
 
@@ -383,17 +459,19 @@ void LLSendTexLayerResponder::uploadComplete(const LLSD& content)
 }
 
 
-LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data,
-																 const LLUUID& vfile_id,
-																 LLAssetType::EType asset_type)
-: LLAssetUploadResponder(post_data, vfile_id, asset_type)
+LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(
+	const LLSD& post_data,
+	const LLUUID& vfile_id,
+	LLAssetType::EType asset_type)
+	: LLAssetUploadResponder(post_data, vfile_id, asset_type)
 {
 }
 
-LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data,
-																 const std::string& file_name,
-																 LLAssetType::EType asset_type)
-: LLAssetUploadResponder(post_data, file_name, asset_type)
+LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(
+	const LLSD& post_data,
+	const std::string& file_name,
+	LLAssetType::EType asset_type)
+	: LLAssetUploadResponder(post_data, file_name, asset_type)
 {
 }
 
@@ -576,3 +654,374 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
 		break;
 	}
 }
+
+
+/////////////////////////////////////////////////////
+// LLNewAgentInventoryVariablePriceResponder::Impl //
+/////////////////////////////////////////////////////
+class LLNewAgentInventoryVariablePriceResponder::Impl
+{
+public:
+	Impl(
+		const LLUUID& vfile_id,
+		const LLSD& inventory_data) :
+		mVFileID(vfile_id),
+		mInventoryData(inventory_data)
+	{
+	}
+
+	Impl(
+		const std::string& file_name,
+		const LLSD& inventory_data) :
+		mFileName(file_name),
+		mInventoryData(inventory_data)
+	{
+	}
+
+	std::string getFilenameOrIDString() const
+	{
+		return (mFileName.empty() ? mVFileID.asString() : mFileName);
+	}
+
+	LLUUID getVFileID() const
+	{
+		return mVFileID;
+	}
+
+	std::string getFilename() const
+	{
+		return mFileName;
+	}
+
+	LLAssetType::EType getAssetType() const
+	{
+		return LLAssetType::lookup(
+			mInventoryData["asset_type"].asString());
+	}
+
+	LLInventoryType::EType getInventoryType() const
+	{
+		return LLInventoryType::lookup(
+			mInventoryData["inventory_type"].asString());
+	}
+
+	std::string getInventoryTypeString() const
+	{
+		return mInventoryData["inventory_type"].asString();
+	}
+
+	LLUUID getFolderID() const
+	{
+		return mInventoryData["folder_id"].asUUID();
+	}
+
+	std::string getItemName() const
+	{
+		return mInventoryData["name"].asString();
+	}
+
+	std::string getItemDescription() const
+	{
+		return mInventoryData["description"].asString();
+	}
+
+	void displayCannotUploadReason(const std::string& reason)
+	{
+		LLSD args;
+		args["FILE"] = getFilenameOrIDString();
+		args["REASON"] = reason;
+
+
+		LLNotifications::instance().add("CannotUploadReason", args);
+		LLUploadDialog::modalUploadFinished();
+	}
+
+	void onApplicationLevelError(const std::string& error_identifier)
+	{
+		// TODO*: Pull these user visible strings from an xml file
+		// to be localized
+		static const std::string _INSUFFICIENT_FUNDS =
+			"NewAgentInventory_InsufficientLindenDollarBalance";
+
+
+		if ( _INSUFFICIENT_FUNDS == error_identifier )
+		{
+			displayCannotUploadReason("You do not have a sufficient L$ balance to complete this upload.");
+		}
+		else
+		{
+			displayCannotUploadReason("Unknown Error");
+
+		}
+	}
+
+	void onTransportError()
+	{
+		displayCannotUploadReason(
+				"The server is experiencing unexpected difficulties.");
+	}
+
+	void onTransportError(const std::string& error_identifier)
+	{
+		// TODO*: Pull these user visible strings from an xml file
+		// to be localized
+
+		static const std::string _SERVER_ERROR_AFTER_CHARGE =
+			"NewAgentInventory_ServerErrorAfterCharge";
+
+		if ( _SERVER_ERROR_AFTER_CHARGE == error_identifier )
+		{
+			displayCannotUploadReason(
+				"The server is experiencing unexpected difficulties.  You may have been charged for the upload.");
+		}
+		else
+		{
+			displayCannotUploadReason(
+				"The server is experiencing unexpected difficulties.");
+		}
+
+	}
+
+	bool uploadConfirmationCallback(
+		const LLSD& notification,
+		const LLSD& response,
+		boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder> responder)
+	{
+		S32 option;
+		std::string confirmation_url;
+
+		option = LLNotification::getSelectedOption(
+			notification,
+			response);
+
+		confirmation_url =
+			notification["payload"]["confirmation_url"].asString();
+
+		// Yay!  We are confirming or cancelling our upload
+		LLSD body;
+
+		body["confirm_upload"] = false;
+
+		switch(option)
+		{
+		case 0:
+		    {
+				body["confirm_upload"] = true;
+				body["expected_upload_price"] =
+					notification["payload"]["expected_upload_price"];
+			}
+			break;
+		case 1:
+		default:
+			break;
+		}
+
+		LLHTTPClient::post(confirmation_url, body, responder);
+
+		return false;
+	}
+	
+private:
+	std::string mFileName;
+
+	LLSD mInventoryData;
+	LLUUID mVFileID;
+};
+
+///////////////////////////////////////////////
+// LLNewAgentInventoryVariablePriceResponder //
+///////////////////////////////////////////////
+LLNewAgentInventoryVariablePriceResponder::LLNewAgentInventoryVariablePriceResponder(
+	const LLUUID& vfile_id,
+	const LLSD& inventory_info)
+{
+	mImpl = new Impl(
+		vfile_id,
+		inventory_info);
+}
+
+LLNewAgentInventoryVariablePriceResponder::LLNewAgentInventoryVariablePriceResponder(
+	const std::string& file_name,
+	const LLSD& inventory_info)
+{
+	mImpl = new Impl(
+		file_name,
+		inventory_info);
+}
+
+LLNewAgentInventoryVariablePriceResponder::~LLNewAgentInventoryVariablePriceResponder()
+{
+	delete mImpl;
+}
+
+void LLNewAgentInventoryVariablePriceResponder::errorWithContent(
+	U32 statusNum,
+	const std::string& reason,
+	const LLSD& content)
+{
+	llinfos << "LLNewAgentInventoryVariablePrice::error " << statusNum 
+			<< " reason: " << reason << llendl;
+
+	if ( content.has("error") )
+	{
+		static const std::string _ERROR = "error";
+		static const std::string _IDENTIFIER = "identifier";
+
+		mImpl->onTransportError(content[_ERROR][_IDENTIFIER].asString());
+	}
+	else
+	{
+		mImpl->onTransportError();
+	}
+}
+
+void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
+{
+	// Parse out application level errors and the appropriate
+	// responses for them
+	static const std::string _ERROR = "error";
+	static const std::string _IDENTIFIER = "identifier";
+	static const std::string _STATE = "state";
+
+	static const std::string _COMPLETE = "complete";
+	static const std::string _COST_ANALYSIS = "cost_analysis";
+	static const std::string _NEEDS_CONFIRMATION = "needs_confirmation";
+	static const std::string _CANCEL = "cancel";
+
+	static const std::string _RESOURCE_COST = "resource_cost";
+	static const std::string _UPLOAD_PRICE = "upload_price";
+
+	static const std::string _ANALYZER = "analyzer";
+	static const std::string _RSVP = "rsvp";
+
+	// Check for application level errors
+	if ( content.has(_ERROR) )
+	{
+		onApplicationLevelError(content[_ERROR][_IDENTIFIER].asString());
+		return;
+	}
+
+	std::string state = content[_STATE];
+	LLAssetType::EType asset_type = mImpl->getAssetType();
+
+	if ( _COST_ANALYSIS == state )
+	{
+		std::string analyzer_url = content[_ANALYZER];
+
+		if ( mImpl->getFilename().empty() )
+		{
+			// we have no filename, use virtual file ID instead
+			LLHTTPClient::postFile(
+				analyzer_url,
+				mImpl->getVFileID(),
+				asset_type,
+				this);
+		}
+		else
+		{
+			LLHTTPClient::postFile(
+				analyzer_url,
+				mImpl->getFilename(),
+				this);
+		}
+	}
+	else if ( _COMPLETE == state )
+	{
+		// rename file in VFS with new asset id
+		if (mImpl->getFilename().empty())
+		{
+			// rename the file in the VFS to the actual asset id
+			// llinfos << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << llendl;
+			gVFS->renameFile(
+				mImpl->getVFileID(),
+				asset_type,
+				content["new_asset"].asUUID(),
+				asset_type);
+		}
+
+ 		on_new_single_inventory_upload_complete(
+ 			asset_type,
+ 			mImpl->getInventoryType(),
+			mImpl->getInventoryTypeString(),
+			mImpl->getFolderID(),
+			mImpl->getItemName(),
+			mImpl->getItemDescription(),
+			content,
+			content["upload_price"].asInteger());
+
+		// TODO* Add bulk (serial) uploading or add
+		// a super class of this that does so
+	}
+	else if ( _NEEDS_CONFIRMATION == state )
+	{
+		showConfirmationDialog(
+			content[_UPLOAD_PRICE].asInteger(),
+			content[_RESOURCE_COST].asInteger(),
+			content[_RSVP].asString());
+	}
+	else if ( _CANCEL == state )
+	{
+		// cancelled, do nothing
+	}
+	else
+	{
+		onApplicationLevelError("");
+	}
+}
+
+void LLNewAgentInventoryVariablePriceResponder::onApplicationLevelError(
+	const std::string& error_identifier)
+{
+	mImpl->onApplicationLevelError(error_identifier);
+}
+
+void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
+	S32 upload_price,
+	S32 resource_cost,
+	const std::string& confirmation_url)
+{
+	if ( 0 == upload_price ) 
+	{
+		// don't show confirmation dialog for free uploads, I mean,
+		// they're free!
+		LLSD body;
+		body["confirm_upload"] = true;
+		body["expected_upload_price"] = upload_price;
+
+		LLHTTPClient::post(confirmation_url, body, this);
+	}
+	else
+	{
+		LLSD substitutions;
+		LLSD payload;
+
+		substitutions["PRICE"] = upload_price;
+
+		payload["confirmation_url"] = confirmation_url;
+		payload["expected_upload_price"] = upload_price;
+
+		// The creating of a new instrusive_ptr(this)
+		// creates a new boost::intrusive_ptr
+		// which is a copy of this.  This code is required because
+		// 'this' is always of type Class* and not the intrusive_ptr,
+		// and thus, a reference to 'this' is not registered
+		// by using just plain 'this'.
+
+		// Since LLNewAgentInventoryVariablePriceResponder is a
+		// reference counted class, it is possible (since the
+		// reference to a plain 'this' would be missed here) that,
+		// when using plain ol' 'this', that this object
+		// would be deleted before the callback is triggered
+		// and cause sadness.
+		LLNotifications::instance().add(
+			"UploadCostConfirmation",
+			substitutions,
+			payload,
+			boost::bind(
+				&LLNewAgentInventoryVariablePriceResponder::Impl::uploadConfirmationCallback,
+				mImpl,
+				_1,
+				_2,
+				boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder>(this)));
+	}
+}
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index a08d70213c3..adbf13519b8 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -61,17 +61,58 @@ class LLAssetUploadResponder : public LLHTTPClient::Responder
 	std::string mFileName;
 };
 
+
+// TODO*: Remove this once deprecated
 class LLNewAgentInventoryResponder : public LLAssetUploadResponder
 {
 public:
-	LLNewAgentInventoryResponder(const LLSD& post_data,
-								const LLUUID& vfile_id,
-								LLAssetType::EType asset_type);
-	LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name,
-											   LLAssetType::EType asset_type);
+	LLNewAgentInventoryResponder(
+		const LLSD& post_data,
+		const LLUUID& vfile_id,
+		LLAssetType::EType asset_type);
+	LLNewAgentInventoryResponder(
+		const LLSD& post_data,
+		const std::string& file_name,
+		LLAssetType::EType asset_type);
 	virtual void uploadComplete(const LLSD& content);
 };
 
+// A base class which goes through and performs some default
+// actions for variable price uploads.  If more specific actions
+// are needed (such as different confirmation messages, etc.)
+// the functions onApplicationLevelError and showConfirmationDialog.
+class LLNewAgentInventoryVariablePriceResponder :
+	public LLHTTPClient::Responder
+{
+public:
+	LLNewAgentInventoryVariablePriceResponder(
+		const LLUUID& vfile_id,
+		const LLSD& inventory_info);
+
+	LLNewAgentInventoryVariablePriceResponder(
+		const std::string& file_name,
+		const LLSD& inventory_info);
+
+	virtual ~LLNewAgentInventoryVariablePriceResponder();
+
+	void errorWithContent(
+		U32 statusNum,
+		const std::string& reason,
+		const LLSD& content);
+	void result(const LLSD& content);
+
+	virtual void onApplicationLevelError(
+		const std::string& error_identifier);
+	virtual void showConfirmationDialog(
+		S32 upload_price,
+		S32 resource_cost,
+		const std::string& confirmation_url);
+
+private:
+	class Impl;
+	Impl* mImpl;
+};
+
 class LLBakedUploadData;
 class LLSendTexLayerResponder : public LLAssetUploadResponder
 {
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 5a10b688da4..27c9ab319a8 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -314,8 +314,10 @@ class LLDrawable : public LLRefCount
 
 inline LLFace* LLDrawable::getFace(const S32 i) const
 {
-	llassert((U32)i < mFaces.size());
-	llassert(mFaces[i]);
+	if ((U32) i >= mFaces.size())
+	{
+		return NULL;
+	}
 	return mFaces[i];
 }
 
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index e087feeaecf..e74b488be96 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -701,6 +701,18 @@ void LLDrawPoolBump::endBump()
 	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 }
 
+S32 LLDrawPoolBump::getNumDeferredPasses()
+{ 
+	if (gSavedSettings.getBOOL("RenderObjectBump"))
+	{
+		return 1;
+	}
+	else
+	{
+		return 0;
+	}
+}
+
 void LLDrawPoolBump::beginDeferredPass(S32 pass)
 {
 	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index bf940cf1e46..2019f1df269 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -79,7 +79,7 @@ protected :
 	void renderBump();
 	void endBump();
 
-	virtual S32 getNumDeferredPasses() { return 1; }
+	virtual S32 getNumDeferredPasses();
 	/*virtual*/ void beginDeferredPass(S32 pass);
 	/*virtual*/ void endDeferredPass(S32 pass);
 	/*virtual*/ void renderDeferred(S32 pass);
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 4246cbc27f2..e49ef8b9699 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1040,7 +1040,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	if (full_rebuild)
 	{
 		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
-		for (U16 i = 0; i < num_indices; i++)
+		for (S32 i = 0; i < num_indices; i++)
 		{
 			*indicesp++ = vf.mIndices[i] + index_offset;
 		}
diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index 028e1cc098c..e12db901bd6 100644
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -61,6 +61,7 @@ LLFilePicker LLFilePicker::sInstance;
 #define XML_FILTER L"XML files (*.xml)\0*.xml\0"
 #define SLOBJECT_FILTER L"Objects (*.slobject)\0*.slobject\0"
 #define RAW_FILTER L"RAW files (*.raw)\0*.raw\0"
+#define MODEL_FILTER L"Model files (*.dae)\0*.dae\0"
 #endif
 
 //
@@ -193,6 +194,10 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)
 		mOFN.lpstrFilter = RAW_FILTER \
 			L"\0";
 		break;
+	case FFLOAD_MODEL:
+		mOFN.lpstrFilter = MODEL_FILTER \
+			L"\0";
+		break;
 	default:
 		res = FALSE;
 		break;
diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h
index ab2455620fe..7600922e9c0 100644
--- a/indra/newview/llfilepicker.h
+++ b/indra/newview/llfilepicker.h
@@ -93,6 +93,7 @@ class LLFilePicker
 		FFLOAD_XML = 6,
 		FFLOAD_SLOBJECT = 7,
 		FFLOAD_RAW = 8,
+		FFLOAD_MODEL = 9,
 	};
 
 	enum ESaveFilter
@@ -198,4 +199,6 @@ class LLFilePicker
 	~LLFilePicker();
 };
 
+const std::string upload_pick(void* data);
+
 #endif
diff --git a/indra/newview/llfloaterinventory.cpp b/indra/newview/llfloaterinventory.cpp
index c890f9f1226..364c79e3c14 100644
--- a/indra/newview/llfloaterinventory.cpp
+++ b/indra/newview/llfloaterinventory.cpp
@@ -1143,6 +1143,9 @@ const std::string& get_item_icon_name(LLAssetType::EType asset_type,
 	case LLAssetType::AT_LINK_FOLDER:
 		idx = LINKFOLDER_ICON_NAME;
 		break;
+	case LLAssetType::AT_MESH:
+		idx = MESH_ICON_NAME;
+		break;
 	default:
 		break;
 	}
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 55019f91f89..58637329d75 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -567,6 +567,18 @@ void LLHUDText::setStringUTF8(const std::string &wtext)
 	setString(utf8str_to_wstring(wtext));
 }
 
+std::string LLHUDText::getString()
+{
+	std::ostringstream ostr;
+	for (U32 i = 0; i < mTextSegments.size(); ++i)
+	{
+		const std::string str = wstring_to_utf8str(mTextSegments[i].getText());
+		ostr << str;
+	}
+
+	return ostr.str();
+}
+
 void LLHUDText::setString(const LLWString &wtext)
 {
 	mTextSegments.clear();
diff --git a/indra/newview/llhudtext.h b/indra/newview/llhudtext.h
index dc14a8c764a..4787a15eafe 100644
--- a/indra/newview/llhudtext.h
+++ b/indra/newview/llhudtext.h
@@ -90,6 +90,7 @@ class LLHUDText : public LLHUDObject
 
 public:
 	void setStringUTF8(const std::string &utf8string);
+	std::string getString();
 	void setString(const LLWString &wstring);
 	void clearString();
 	void addLine(const std::string &text, const LLColor4& color, const LLFontGL::StyleFlags style = LLFontGL::NORMAL);
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index ca9ebf8dc14..028505456bc 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -154,7 +154,9 @@ std::string ICON_NAME[ICON_NAME_COUNT] =
 	"Inv_Gesture",
 
 	"inv_item_linkitem.tga",
-	"inv_item_linkfolder.tga"
+	"inv_item_linkfolder.tga",
+	
+	"inv_item_mesh.tga"
 };
 
 
@@ -891,6 +893,14 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 			// Only should happen for broken links.
 			new_listener = new LLLinkItemBridge(inventory, uuid);
 			break;
+	        case LLAssetType::AT_MESH:
+			if(!(inv_type == LLInventoryType::IT_MESH))
+			{
+				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << safe_inv_type_lookup(inv_type) << " on uuid " << uuid << llendl;
+			}
+			new_listener = new LLMeshBridge(inventory, uuid);
+			break;
+
 		default:
 			llinfos << "Unhandled asset type (llassetstorage.h): "
 					<< (S32)asset_type << llendl;
@@ -2189,6 +2199,9 @@ LLUIImagePtr LLFolderBridge::getIcon(LLAssetType::EType preferred_type)
 {
 	// we only have one folder image now
 	return LLUI::getUIImage("Inv_FolderClosed");
+		/*case LLAssetType::AT_MESH:
+			control = "inv_folder_mesh.tga";
+			break;*/
 }
 
 BOOL LLFolderBridge::renameItem(const std::string& new_name)
@@ -2558,6 +2571,7 @@ BOOL LLFolderBridge::dragOrDrop(MASK mask, BOOL drop,
 		case DAD_ANIMATION:
 		case DAD_GESTURE:
 		case DAD_LINK:
+		case DAD_MESH:
 			accept = dragItemIntoFolder((LLInventoryItem*)cargo_data,
 										drop);
 			break;
@@ -3457,6 +3471,7 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop,
 		case DAD_BODYPART:
 		case DAD_ANIMATION:
 		case DAD_GESTURE:
+		case DAD_MESH:
 			{
 				LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
 				const LLPermissions& perm = inv_item->getPermissions();
@@ -4713,6 +4728,65 @@ void LLWearableBridge::onRemoveFromAvatarArrived(LLWearable* wearable,
 	delete on_remove_struct;
 }
 
+
+// +=================================================+
+// |        LLMeshBridge                             |
+// +=================================================+
+
+LLUIImagePtr LLMeshBridge::getIcon() const
+{
+	return get_item_icon(LLAssetType::AT_MESH, LLInventoryType::IT_MESH, 0, FALSE);
+}
+
+void LLMeshBridge::openItem()
+{
+	LLViewerInventoryItem* item = getItem();
+	
+	if (item)
+	{
+		// open mesh
+	}
+}
+
+void LLMeshBridge::previewItem()
+{
+	LLViewerInventoryItem* item = getItem();
+	if(item)
+	{
+		// preview mesh
+	}
+}
+
+
+void LLMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
+{
+	lldebugs << "LLMeshBridge::buildContextMenu()" << llendl;
+	std::vector<std::string> items;
+	std::vector<std::string> disabled_items;
+
+	if(isInTrash())
+	{
+		items.push_back(std::string("Purge Item"));
+		if (!isItemRemovable())
+		{
+			disabled_items.push_back(std::string("Purge Item"));
+		}
+
+		items.push_back(std::string("Restore Item"));
+	}
+	else
+	{
+		items.push_back(std::string("Properties"));
+
+		getClipboardEntries(true, items, disabled_items, flags);
+	}
+
+
+	hideContextEntries(menu, items, disabled_items);
+}
+
+
+
 LLInvFVBridgeAction* LLInvFVBridgeAction::createAction(LLAssetType::EType asset_type,
 													   const LLUUID& uuid,LLInventoryModel* model)
 {
@@ -4761,6 +4835,12 @@ LLInvFVBridgeAction* LLInvFVBridgeAction::createAction(LLAssetType::EType asset_
 
 		break;
 
+	case LLAssetType::AT_MESH:
+		action = new LLMeshBridgeAction(uuid,model);
+		break;
+
+
+		
 	default:
 		break;
 	}
@@ -4998,6 +5078,18 @@ void LLWearableBridgeAction::doIt()
 	LLInvFVBridgeAction::doIt();
 }
 
+//virtual
+void	LLMeshBridgeAction::doIt() 
+{
+	LLViewerInventoryItem* item = getItem();
+	if(item)
+	{
+		// do it
+	}
+	
+	LLInvFVBridgeAction::doIt();
+}
+
 // +=================================================+
 // |        LLLinkItemBridge                         |
 // +=================================================+
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index 6b2a2d32dec..95a5f97e7bf 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -79,6 +79,8 @@ enum EInventoryIcon
 
 	LINKITEM_ICON_NAME,
 	LINKFOLDER_ICON_NAME,
+	
+	MESH_ICON_NAME,
 
 	ICON_NAME_COUNT
 };
@@ -609,7 +611,6 @@ class LLLinkItemBridge : public LLItemBridge
 	static std::string sPrefix;
 };
 
-
 class LLLinkFolderBridge : public LLItemBridge
 {
 	friend class LLInvFVBridge;
@@ -630,6 +631,25 @@ class LLLinkFolderBridge : public LLItemBridge
 	static std::string sPrefix;
 };
 
+
+
+class LLMeshBridge : public LLItemBridge
+{
+	friend class LLInvFVBridge;
+public:
+	virtual LLUIImagePtr getIcon() const;
+	virtual void openItem();
+	virtual void previewItem();
+	virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
+
+protected:
+	LLMeshBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
+		LLItemBridge(inventory, uuid) {}
+};
+
+
+
+
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // Class LLInvFVBridgeAction (& its derived classes)
 //
@@ -790,6 +810,19 @@ class LLWearableBridgeAction: public LLInvFVBridgeAction
 
 };
 
+class LLMeshBridgeAction: public LLInvFVBridgeAction
+{
+	friend class LLInvFVBridgeAction;
+public:
+	virtual void	doIt() ;
+	virtual ~LLMeshBridgeAction(){}
+protected:
+	LLMeshBridgeAction(const LLUUID& id,LLInventoryModel* model):LLInvFVBridgeAction(id,model){}
+
+};
+
+
+
 void wear_inventory_item_on_avatar(LLInventoryItem* item);
 
 class LLViewerJointAttachment;
diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp
index 0ce85818dd6..a8240257239 100644
--- a/indra/newview/llpanelgroupnotices.cpp
+++ b/indra/newview/llpanelgroupnotices.cpp
@@ -157,6 +157,7 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 		case DAD_ANIMATION:
 		case DAD_GESTURE:
 		case DAD_CALLINGCARD:
+		case DAD_MESH:
 		{
 			LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
 			if(gInventory.getItem(inv_item->getUUID())
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index a7f0ce16d38..a5e3a0492be 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -173,7 +173,6 @@ LLObjectSelection *get_null_object_selection()
 	return sNullSelection;
 }
 
-
 //-----------------------------------------------------------------------------
 // LLSelectMgr()
 //-----------------------------------------------------------------------------
@@ -5301,6 +5300,78 @@ BOOL LLSelectNode::allowOperationOnNode(PermissionBit op, U64 group_proxy_power)
 	return (mPermissions->allowOperationBy(op, proxy_agent_id, group_id));
 }
 
+void LLSelectNode::renderOneWireframe(const LLColor4& color)
+{
+	LLViewerObject* objectp = getObject();
+	if (!objectp)
+	{
+		return;
+	}
+
+	LLDrawable* drawable = objectp->mDrawable;
+	if(!drawable)
+	{
+		return;
+	}
+
+	glMatrixMode(GL_MODELVIEW);
+	gGL.pushMatrix();
+
+	BOOL is_hud_object = objectp->isHUDAttachment();
+
+	if (!is_hud_object)
+	{
+		glLoadIdentity();
+		glMultMatrixd(gGLModelView);
+	}
+	
+	if (drawable->isActive())
+	{
+		glMultMatrixf((F32*) objectp->getRenderMatrix().mMatrix);
+	}
+
+	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+	
+	if (LLSelectMgr::sRenderHiddenSelections) // && gFloaterTools && gFloaterTools->getVisible())
+	{
+		gGL.blendFunc(LLRender::BF_SOURCE_COLOR, LLRender::BF_ONE);
+		LLGLEnable fog(GL_FOG);
+		glFogi(GL_FOG_MODE, GL_LINEAR);
+		float d = (LLViewerCamera::getInstance()->getPointOfInterest()-LLViewerCamera::getInstance()->getOrigin()).magVec();
+		LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgent.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0);
+		glFogf(GL_FOG_START, d);
+		glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV())));
+		glFogfv(GL_FOG_COLOR, fogCol.mV);
+
+		LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL);
+		gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
+		{
+			glColor4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f);
+			for (S32 i = 0; i < drawable->getNumFaces(); ++i)
+			{
+				LLFace* face = drawable->getFace(i);
+				pushVerts(face, LLVertexBuffer::MAP_VERTEX);
+			}
+		}
+	}
+
+	gGL.flush();
+	gGL.setSceneBlendType(LLRender::BT_ALPHA);
+
+	glColor4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2);
+	LLGLEnable offset(GL_POLYGON_OFFSET_LINE);
+	glPolygonOffset(3.f, 2.f);
+	glLineWidth(3.f);
+	for (S32 i = 0; i < drawable->getNumFaces(); ++i)
+	{
+		LLFace* face = drawable->getFace(i);
+		pushVerts(face, LLVertexBuffer::MAP_VERTEX);
+	}
+	glLineWidth(1.f);
+	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+	gGL.popMatrix();
+}
+
 //-----------------------------------------------------------------------------
 // renderOneSilhouette()
 //-----------------------------------------------------------------------------
@@ -5318,6 +5389,13 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
 		return;
 	}
 
+	LLVOVolume* vobj = drawable->getVOVolume();
+	if (vobj && vobj->isMesh())
+	{
+		renderOneWireframe(color);
+		return;
+	}
+
 	if (!mSilhouetteExists)
 	{
 		return;
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 6e757ef976f..b5187659461 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -140,6 +140,7 @@ class LLSelectNode
 	BOOL isTESelected(S32 te_index);
 	S32 getLastSelectedTE();
 	S32 getTESelectMask() { return mTESelectMask; }
+	void renderOneWireframe(const LLColor4& color);
 	void renderOneSilhouette(const LLColor4 &color);
 	void setTransient(BOOL transient) { mTransient = transient; }
 	BOOL isTransient() { return mTransient; }
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 9f317803ce7..9704fe71b78 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2294,7 +2294,6 @@ void pushVerts(LLFace* face, U32 mask)
 		U16 offset = face->getIndicesStart();
 		buffer->drawRange(LLRender::TRIANGLES, start, end, count, offset);
 	}
-
 }
 
 void pushBufferVerts(LLVertexBuffer* buffer, U32 mask)
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 64c2a9acbc7..1d9127639af 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -59,6 +59,7 @@ class LLTextureAtlasSlot;
 
 S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad);
 S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared);
+void pushVerts(LLFace* face, U32 mask);
 
 // get index buffer for binary encoded axis vertex buffer given a box at center being viewed by given camera
 U8* get_box_fan_indices(LLCamera* camera, const LLVector3& center);
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index b5aec1b80bc..ae4ec75a1b4 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -289,7 +289,7 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop(
 {
 	BOOL handled = FALSE;
 
-	if (cargo_type == DAD_TEXTURE)
+	if ((cargo_type == DAD_TEXTURE) || (cargo_type == DAD_MESH))
 	{
 		LLInventoryItem *item = (LLInventoryItem *)cargo_data;
 
@@ -1152,7 +1152,9 @@ BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
 	// returns true, then the cast was valid, and we can perform
 	// the third test without problems.
 	LLInventoryItem* item = (LLInventoryItem*)cargo_data; 
-	if (getEnabled() && (cargo_type == DAD_TEXTURE) && allowDrop(item))
+	if (getEnabled() &&
+		((cargo_type == DAD_TEXTURE) || (cargo_type == DAD_MESH)) &&
+		 allowDrop(item))
 	{
 		if (drop)
 		{
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 9a63f07a7e5..643a81be1f6 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -483,6 +483,16 @@ LLToolDragAndDrop::dragOrDrop3dImpl LLToolDragAndDrop::sDragAndDrop3d[DAD_COUNT]
 		&LLToolDragAndDrop::dad3dNULL, // Dest: DT_OBJECT
 		&LLToolDragAndDrop::dad3dNULL,//dad3dAssetOnLand, // Dest: DT_LAND
 	},
+
+
+//	Source: DAD_MESH
+	{
+		&LLToolDragAndDrop::dad3dNULL, // Dest: DT_NONE
+		&LLToolDragAndDrop::dad3dNULL, // Dest: DT_SELF
+		&LLToolDragAndDrop::dad3dGiveInventory, // Dest: DT_AVATAR
+		&LLToolDragAndDrop::dad3dUpdateInventory, // Dest: DT_OBJECT
+		&LLToolDragAndDrop::dad3dNULL,//dad3dAssetOnLand, // Dest: DT_LAND
+	},
 };
 
 LLToolDragAndDrop::LLToolDragAndDrop()
@@ -2007,6 +2017,7 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_
 	case DAD_ANIMATION:
 	case DAD_GESTURE:
 	case DAD_CALLINGCARD:
+	case DAD_MESH:
 	{
 		LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
 		if(gInventory.getItem(inv_item->getUUID())
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index a6a72e96661..3b727e28611 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -869,12 +869,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			}
 		}
 
-		/// We copy the frame buffer straight into a texture here,
-		/// and then display it again with compositor effects.
-		/// Using render to texture would be faster/better, but I don't have a 
-		/// grasp of their full display stack just yet.
-		// gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight());
-		
 		if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender)
 		{
 			gPipeline.renderDeferredLighting();
@@ -1097,7 +1091,7 @@ void render_ui(F32 zoom_factor, int subfield)
 		{
 			gPipeline.renderBloom(gSnapshot, zoom_factor, subfield);
 		}
-
+		
 		render_hud_elements();
 		render_hud_attachments();
 	}
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index dace3f875f5..7c5f5e8b2f9 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -122,6 +122,8 @@
 #include "llpreviewsound.h"
 #include "llpreviewtexture.h"
 #include "llsyswellwindow.h"
+#include "llfloatermodelpreview.h"
+
 // *NOTE: Please add files in alphabetical order to keep merges easy.
 
 
@@ -236,7 +238,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("upload_anim", "floater_animation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload");
 	LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
 	LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
-	
+	LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
 	LLFloaterReg::add("voice_call", "floater_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCall>);
 	
 	LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>);	
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index dc291d6c34c..56f70e0f5dd 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -268,7 +268,6 @@ LLMenuItemCallGL* gBusyMenu = NULL;
 // Local prototypes
 
 // File Menu
-const char* upload_pick(void* data);
 void handle_compress_image(void*);
 
 
@@ -557,6 +556,7 @@ void init_menus()
 	gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost);
 	gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost);
 	gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", upload_cost);
+	gMenuHolder->childSetLabelArg("Upload Model", "[COST]", upload_cost);
 
 	gAFKMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Away", TRUE);
 	gBusyMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Busy", TRUE);
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index d3a9e1cef8a..836ac79a87d 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -39,6 +39,7 @@
 #include "llfilepicker.h"
 #include "llfloaterreg.h"
 #include "llfloaterbuycurrency.h"
+#include "llfloatermodelpreview.h"
 #include "llfloatersnapshot.h"
 #include "llinventorymodel.h"	// gInventory
 #include "llresourcedata.h"
@@ -62,6 +63,7 @@
 #include "lleconomy.h"
 #include "llhttpclient.h"
 #include "llsdserialize.h"
+#include "llsdutil.h"
 #include "llstring.h"
 #include "lltransactiontypes.h"
 #include "lluuid.h"
@@ -101,6 +103,7 @@ static std::string XML_EXTENSIONS = "xml";
 static std::string SLOBJECT_EXTENSIONS = "slobject";
 #endif
 static std::string ALL_FILE_EXTENSIONS = "*.*";
+static std::string MODEL_EXTENSIONS = "dae";
 
 std::string build_extensions_string(LLFilePicker::ELoadFilter filter)
 {
@@ -115,6 +118,8 @@ std::string build_extensions_string(LLFilePicker::ELoadFilter filter)
 		return ANIM_EXTENSIONS;
 	case LLFilePicker::FFLOAD_SLOBJECT:
 		return SLOBJECT_EXTENSIONS;
+	case LLFilePicker::FFLOAD_MODEL:
+		return MODEL_EXTENSIONS;
 #ifdef _CORY_TESTING
 	case LLFilePicker::FFLOAD_GEOMETRY:
 		return GEOMETRY_EXTENSIONS;
@@ -258,6 +263,16 @@ class LLFileUploadImage : public view_listener_t
 	}
 };
 
+class LLFileUploadModel : public view_listener_t
+{
+	bool handleEvent(const LLSD& userdata)
+	{
+		LLFloaterReg::showInstance("upload_model");
+		
+		return TRUE;
+	}
+};
+	
 class LLFileUploadSound : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
@@ -319,10 +334,21 @@ class LLFileUploadBulk : public view_listener_t
 			LLAssetStorage::LLStoreAssetCallback callback = NULL;
 			S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
 			void *userdata = NULL;
-			upload_new_resource(filename, asset_name, asset_name, 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE,
-				LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
-					    display_name,
-					    callback, expected_upload_cost, userdata);
+
+			upload_new_resource(
+				filename,
+				asset_name,
+				asset_name,
+				0,
+				LLAssetType::AT_NONE,
+				LLInventoryType::IT_NONE,
+				LLFloaterPerms::getNextOwnerPerms(),
+				LLFloaterPerms::getGroupPerms(),
+				LLFloaterPerms::getEveryonePerms(),
+				display_name,
+				callback,
+				expected_upload_cost,
+				userdata);
 
 			// *NOTE: Ew, we don't iterate over the file list here,
 			// we handle the next files in upload_done_callback()
@@ -491,17 +517,20 @@ void handle_compress_image(void*)
 	}
 }
 
-void upload_new_resource(const std::string& src_filename, std::string name,
-			 std::string desc, S32 compression_info,
-			 LLAssetType::EType destination_folder_type,
-			 LLInventoryType::EType inv_type,
-			 U32 next_owner_perms,
-			 U32 group_perms,
-			 U32 everyone_perms,
-			 const std::string& display_name,
-			 LLAssetStorage::LLStoreAssetCallback callback,
-			 S32 expected_upload_cost,
-			 void *userdata)
+void upload_new_resource(
+	const std::string& src_filename,
+	std::string name,
+	std::string desc,
+	S32 compression_info,
+	LLAssetType::EType destination_folder_type,
+	LLInventoryType::EType inv_type,
+	U32 next_owner_perms,
+	U32 group_perms,
+	U32 everyone_perms,
+	const std::string& display_name,
+	LLAssetStorage::LLStoreAssetCallback callback,
+	S32 expected_upload_cost,
+	void *userdata)
 {	
 	// Generate the temporary UUID.
 	std::string filename = gDirUtilp->getTempFilename();
@@ -783,9 +812,21 @@ void upload_new_resource(const std::string& src_filename, std::string name,
 		{
 			t_disp_name = src_filename;
 		}
-		upload_new_resource(tid, asset_type, name, desc, compression_info, // tid
-				    destination_folder_type, inv_type, next_owner_perms, group_perms, everyone_perms,
-				    display_name, callback, expected_upload_cost, userdata);
+		upload_new_resource(
+			tid,
+			asset_type,
+			name,
+			desc,
+			compression_info, // tid
+			destination_folder_type,
+			inv_type,
+			next_owner_perms,
+			group_perms,
+			everyone_perms,
+			display_name,
+			callback,
+			expected_upload_cost,
+			userdata);
 	}
 	else
 	{
@@ -801,7 +842,11 @@ void upload_new_resource(const std::string& src_filename, std::string name,
 	}
 }
 
-void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed)
+void upload_done_callback(
+	const LLUUID& uuid,
+	void* user_data,
+	S32 result,
+	LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLResourceData* data = (LLResourceData*)user_data;
 	S32 expected_upload_cost = data ? data->mExpectedUploadCost : 0;
@@ -902,71 +947,134 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
 		std::string display_name = LLStringUtil::null;
 		LLAssetStorage::LLStoreAssetCallback callback = NULL;
 		void *userdata = NULL;
-		upload_new_resource(next_file, asset_name, asset_name,	// file
-				    0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE,
-				    PERM_NONE, PERM_NONE, PERM_NONE,
-				    display_name,
-				    callback,
-				    expected_upload_cost, // assuming next in a group of uploads is of roughly the same type, i.e. same upload cost
-				    userdata);
+		upload_new_resource(
+			next_file,
+			asset_name,
+			asset_name,	// file
+			0,
+			LLAssetType::AT_NONE,
+			LLInventoryType::IT_NONE,
+			PERM_NONE,
+			PERM_NONE,
+			PERM_NONE,
+			display_name,
+			callback,
+			expected_upload_cost, // assuming next in a group of uploads is of roughly the same type, i.e. same upload cost
+			userdata);
 	}
 }
 
-void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type,
-			 std::string name,
-			 std::string desc, S32 compression_info,
-			 LLAssetType::EType destination_folder_type,
-			 LLInventoryType::EType inv_type,
-			 U32 next_owner_perms,
-			 U32 group_perms,
-			 U32 everyone_perms,
-			 const std::string& display_name,
-			 LLAssetStorage::LLStoreAssetCallback callback,
-			 S32 expected_upload_cost,
-			 void *userdata)
+LLAssetID upload_new_resource_prep(
+	const LLTransactionID &tid,
+	LLAssetType::EType asset_type,
+	LLInventoryType::EType& inventory_type,
+	std::string& name,
+	const std::string& display_name,
+	std::string& description)
 {
-	if(gDisconnected)
+	if ( gDisconnected )
 	{
-		return ;
+		LLAssetID rv;
+
+		rv.setNull();
+		return rv;
 	}
 
 	LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID());
 	
-	if( LLAssetType::AT_SOUND == asset_type )
+	if ( LLAssetType::AT_SOUND == asset_type )
 	{
-		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT );
+		LLViewerStats::getInstance()->incStat(
+			LLViewerStats::ST_UPLOAD_SOUND_COUNT );
 	}
-	else
-	if( LLAssetType::AT_TEXTURE == asset_type )
+	else if ( LLAssetType::AT_TEXTURE == asset_type )
 	{
-		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
+		LLViewerStats::getInstance()->incStat(
+			LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
 	}
-	else
-	if( LLAssetType::AT_ANIMATION == asset_type)
+	else if ( LLAssetType::AT_ANIMATION == asset_type )
 	{
-		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT );
+		LLViewerStats::getInstance()->incStat(
+			LLViewerStats::ST_UPLOAD_ANIM_COUNT );
 	}
 
-	if(LLInventoryType::IT_NONE == inv_type)
+	if ( LLInventoryType::IT_NONE == inventory_type )
 	{
-		inv_type = LLInventoryType::defaultForAssetType(asset_type);
+		inventory_type = LLInventoryType::defaultForAssetType(asset_type);
 	}
 	LLStringUtil::stripNonprintable(name);
-	LLStringUtil::stripNonprintable(desc);
-	if(name.empty())
+	LLStringUtil::stripNonprintable(description);
+
+	if ( name.empty() )
 	{
 		name = "(No Name)";
 	}
-	if(desc.empty())
+	if ( description.empty() )
 	{
-		desc = "(No Description)";
+		description = "(No Description)";
 	}
-	
+
 	// At this point, we're ready for the upload.
 	std::string upload_message = "Uploading...\n\n";
 	upload_message.append(display_name);
 	LLUploadDialog::modalUploadDialog(upload_message);
 
+	return uuid;
+}
+
+LLSD generate_new_resource_upload_capability_body(
+	LLAssetType::EType asset_type,
+	const std::string& name,
+	const std::string& desc,
+	LLAssetType::EType destination_folder_type,
+	LLInventoryType::EType inv_type,
+	U32 next_owner_perms,
+	U32 group_perms,
+	U32 everyone_perms)
+{
+	LLSD body;
+
+	body["folder_id"] = gInventory.findCategoryUUIDForType(
+		(destination_folder_type == LLAssetType::AT_NONE) ?
+		asset_type :
+		destination_folder_type);
+
+	body["asset_type"] = LLAssetType::lookup(asset_type);
+	body["inventory_type"] = LLInventoryType::lookup(inv_type);
+	body["name"] = name;
+	body["description"] = desc;
+	body["next_owner_mask"] = LLSD::Integer(next_owner_perms);
+	body["group_mask"] = LLSD::Integer(group_perms);
+	body["everyone_mask"] = LLSD::Integer(everyone_perms);
+
+	return body;
+}
+
+void upload_new_resource(
+	const LLTransactionID &tid,
+	LLAssetType::EType asset_type,
+	std::string name,
+	std::string desc,
+	S32 compression_info,
+	LLAssetType::EType destination_folder_type,
+	LLInventoryType::EType inv_type,
+	U32 next_owner_perms,
+	U32 group_perms,
+	U32 everyone_perms,
+	const std::string& display_name,
+	LLAssetStorage::LLStoreAssetCallback callback,
+	S32 expected_upload_cost,
+	void *userdata)
+{
+	LLAssetID uuid = 
+		upload_new_resource_prep(
+			tid,
+			asset_type,
+			inv_type,
+			name,
+			display_name,
+			desc);
+
 	llinfos << "*** Uploading: " << llendl;
 	llinfos << "Type: " << LLAssetType::lookup(asset_type) << llendl;
 	llinfos << "UUID: " << uuid << llendl;
@@ -975,26 +1083,32 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
 	llinfos << "Expected Upload Cost: " << expected_upload_cost << llendl;
 	lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLAssetType::AT_NONE) ? asset_type : destination_folder_type) << llendl;
 	lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl;
-	std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory");
-	if (!url.empty())
+
+	std::string url = gAgent.getRegion()->getCapability(
+		"NewFileAgentInventory");
+
+	if ( !url.empty() )
 	{
 		llinfos << "New Agent Inventory via capability" << llendl;
-		LLSD body;
-		body["folder_id"] = gInventory.findCategoryUUIDForType((destination_folder_type == LLAssetType::AT_NONE) ? asset_type : destination_folder_type);
-		body["asset_type"] = LLAssetType::lookup(asset_type);
-		body["inventory_type"] = LLInventoryType::lookup(inv_type);
-		body["name"] = name;
-		body["description"] = desc;
-		body["next_owner_mask"] = LLSD::Integer(next_owner_perms);
-		body["group_mask"] = LLSD::Integer(group_perms);
-		body["everyone_mask"] = LLSD::Integer(everyone_perms);
-		body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost);
-		
-		//std::ostringstream llsdxml;
-		//LLSDSerialize::toPrettyXML(body, llsdxml);
-		//llinfos << "posting body to capability: " << llsdxml.str() << llendl;
 
-		LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type));
+		LLSD body;
+		body = generate_new_resource_upload_capability_body(
+			asset_type,
+			name,
+			desc,
+			destination_folder_type,
+			inv_type,
+			next_owner_perms,
+			group_perms,
+			everyone_perms);
+
+		LLHTTPClient::post(
+			url,
+			body,
+			new LLNewAgentInventoryResponder(
+				body,
+				uuid,
+				asset_type));
 	}
 	else
 	{
@@ -1039,11 +1153,83 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
 	}
 }
 
+BOOL upload_new_variable_cost_resource(
+	const LLTransactionID &tid, 
+	LLAssetType::EType asset_type,
+	std::string name,
+	std::string desc, 
+	S32 compression_info,
+	LLAssetType::EType destination_folder_type,
+	LLInventoryType::EType inv_type,
+	U32 next_owner_perms,
+	U32 group_perms,
+	U32 everyone_perms,
+	const std::string& display_name,
+	LLAssetStorage::LLStoreAssetCallback callback,
+	void *userdata)
+{
+	LLAssetID uuid = 
+		upload_new_resource_prep(
+			tid,
+			asset_type,
+			inv_type,
+			name,
+			display_name,
+			desc);
+
+	llinfos << "*** Uploading: " << llendl;
+	llinfos << "Type: " << LLAssetType::lookup(asset_type) << llendl;
+	llinfos << "UUID: " << uuid << llendl;
+	llinfos << "Name: " << name << llendl;
+	llinfos << "Desc: " << desc << llendl;
+	lldebugs << "Folder: "
+ << gInventory.findCategoryUUIDForType((destination_folder_type == LLAssetType::AT_NONE) ? asset_type : destination_folder_type) << llendl;
+	lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl;
+
+	std::string url = gAgent.getRegion()->getCapability(
+		"NewFileAgentInventoryVariablePrice");
+
+	if ( !url.empty() )
+	{
+		llinfos << "New Agent Inventory variable price upload"
+				<< llendl;
+
+		// Each of the two capabilities has similar data, so
+		// let's reuse that code
+
+		LLSD body;
+
+		body = generate_new_resource_upload_capability_body(
+			asset_type,
+			name,
+			desc,
+			destination_folder_type,
+			inv_type,
+			next_owner_perms,
+			group_perms,
+			everyone_perms);
+
+		LLHTTPClient::post(
+			url,
+			body,
+			new LLNewAgentInventoryVariablePriceResponder(
+				uuid,
+				body));
+
+		return TRUE;
+	}
+	else
+	{
+		return FALSE;
+	}
+}
+
 void init_menu_file()
 {
 	view_listener_t::addCommit(new LLFileUploadImage(), "File.UploadImage");
 	view_listener_t::addCommit(new LLFileUploadSound(), "File.UploadSound");
 	view_listener_t::addCommit(new LLFileUploadAnim(), "File.UploadAnim");
+	view_listener_t::addCommit(new LLFileUploadModel(), "File.UploadModel");
 	view_listener_t::addCommit(new LLFileUploadBulk(), "File.UploadBulk");
 	view_listener_t::addCommit(new LLFileCloseWindow(), "File.CloseWindow");
 	view_listener_t::addCommit(new LLFileCloseAllWindows(), "File.CloseAllWindows");
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index bf21292082b..b51192b499f 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -41,33 +41,56 @@ class LLTransactionID;
 
 void init_menu_file();
 
-void upload_new_resource(const std::string& src_filename, 
-			 std::string name,
-			 std::string desc, 
-			 S32 compression_info,
-			 LLAssetType::EType destination_folder_type,
-			 LLInventoryType::EType inv_type,
-			 U32 next_owner_perms,
-			 U32 group_perms,
-			 U32 everyone_perms,
-			 const std::string& display_name,
-			 LLAssetStorage::LLStoreAssetCallback callback,
-			 S32 expected_upload_cost,
-			 void *userdata);
+void upload_new_resource(
+	const std::string& src_filename, 
+	std::string name,
+	std::string desc, 
+	S32 compression_info,
+	LLAssetType::EType destination_folder_type,
+	LLInventoryType::EType inv_type,
+	U32 next_owner_perms,
+	U32 group_perms,
+	U32 everyone_perms,
+	const std::string& display_name,
+	LLAssetStorage::LLStoreAssetCallback callback,
+	S32 expected_upload_cost,
+	void *userdata);
+
+void upload_new_resource(
+	const LLTransactionID &tid, 
+	LLAssetType::EType type,
+	std::string name,
+	std::string desc, 
+	S32 compression_info,
+	LLAssetType::EType destination_folder_type,
+	LLInventoryType::EType inv_type,
+	U32 next_owner_perms,
+	U32 group_perms,
+	U32 everyone_perms,
+	const std::string& display_name,
+	LLAssetStorage::LLStoreAssetCallback callback,
+	S32 expected_upload_cost,
+	void *userdata);
+
+// TODO* : Move all uploads to use this new function
+// since at some point, that upload path will be deprecated and no longer
+// used
+
+// We make a new function here to ensure that previous code is not broken
+BOOL upload_new_variable_cost_resource(
+	const LLTransactionID &tid, 
+	LLAssetType::EType type,
+	std::string name,
+	std::string desc, 
+	S32 compression_info,
+	LLAssetType::EType destination_folder_type,
+	LLInventoryType::EType inv_type,
+	U32 next_owner_perms,
+	U32 group_perms,
+	U32 everyone_perms,
+	const std::string& display_name,
+	LLAssetStorage::LLStoreAssetCallback callback,
+	void *userdata);
 
-void upload_new_resource(const LLTransactionID &tid, 
-			 LLAssetType::EType type,
-			 std::string name,
-			 std::string desc, 
-			 S32 compression_info,
-			 LLAssetType::EType destination_folder_type,
-			 LLInventoryType::EType inv_type,
-			 U32 next_owner_perms,
-			 U32 group_perms,
-			 U32 everyone_perms,
-			 const std::string& display_name,
-			 LLAssetStorage::LLStoreAssetCallback callback,
-			 S32 expected_upload_cost,
-			 void *userdata);
 
 #endif
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 791ec073491..f16465acba0 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4530,6 +4530,7 @@ void process_economy_data(LLMessageSystem *msg, void** /*user_data*/)
 
 	gMenuHolder->childSetLabelArg("Upload Image", "[COST]", llformat("%d", upload_cost));
 	gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", llformat("%d", upload_cost));
+	gMenuHolder->childSetLabelArg("Upload Model", "[COST]", llformat("%d", upload_cost));
 	gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", llformat("%d", upload_cost));
 	gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", llformat("%d", upload_cost));
 }
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 7ea55b49e86..986264ad347 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1437,6 +1437,8 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("MapLayer");
 	capabilityNames.append("MapLayerGod");
 	capabilityNames.append("NewFileAgentInventory");
+	capabilityNames.append("NewFileAgentInventoryVariablePrice");
+	capabilityNames.append("ObjectAdd");
 	capabilityNames.append("ParcelPropertiesUpdate");
 	capabilityNames.append("ParcelMediaURLFilterList");
 	capabilityNames.append("ParcelNavigateMedia");
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 65994dfb308..ed8d8208444 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -477,6 +477,7 @@ LLUIImagePtr LLEmbeddedItems::getItemImage(llwchar ext_char) const
 			case LLAssetType::AT_GESTURE:			img_name = "Inv_Gesture";	break;
 				//TODO need img_name
 			case LLAssetType::AT_FAVORITE:		img_name = "Inv_Landmark";	 break;
+			case LLAssetType::AT_MESH:            img_name = "inv_item_mesh.tga";	 break;
 			default: llassert(0); 
 		}
 
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index a0ab4cb1e68..32baa29afbe 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -583,7 +583,7 @@ BOOL LLViewerTexture::createGLTexture(S32 discard_level, const LLImageRaw* image
 	llassert_always(mGLTexturep.notNull()) ;	
 
 	BOOL ret = mGLTexturep->createGLTexture(discard_level, imageraw, usename) ;
-	
+
 	if(ret)
 	{
 		mFullWidth = mGLTexturep->getCurrentWidth() ;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 5f95e9ccf1b..72e40e30302 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -3733,140 +3733,6 @@ void LLViewerWindow::playSnapshotAnimAndSound()
 BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type)
 {
 	return rawSnapshot(raw, preview_width, preview_height, FALSE, FALSE, show_ui, do_rebuild, type);
-	
-	// *TODO below code was broken in deferred pipeline
-	/*
-	if ((!raw) || preview_width < 10 || preview_height < 10)
-	{
-		return FALSE;
-	}
-
-	if(gResizeScreenTexture) //the window is resizing
-	{
-		return FALSE ;
-	}
-
-	setCursor(UI_CURSOR_WAIT);
-
-	// Hide all the UI widgets first and draw a frame
-	BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI);
-
-	if ( prev_draw_ui != show_ui)
-	{
-		LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI);
-	}
-
-	BOOL hide_hud = !gSavedSettings.getBOOL("RenderHUDInSnapshot") && LLPipeline::sShowHUDAttachments;
-	if (hide_hud)
-	{
-		LLPipeline::sShowHUDAttachments = FALSE;
-	}
-
-	S32 render_name = gSavedSettings.getS32("RenderName");
-	gSavedSettings.setS32("RenderName", 0);
-	LLVOAvatar::updateFreezeCounter(1) ; //pause avatar updating for one frame
-	
-	S32 w = preview_width ;
-	S32 h = preview_height ;
-	LLVector2 display_scale = mDisplayScale ;
-	mDisplayScale.setVec((F32)w / mWindowRect.getWidth(), (F32)h / mWindowRect.getHeight()) ;
-	LLRect window_rect = mWindowRect;
-	mWindowRect.set(0, h, w, 0);
-	
-	gDisplaySwapBuffers = FALSE;
-	gDepthDirty = TRUE;
-	glClearColor(0.f, 0.f, 0.f, 0.f);
-	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-	setup3DRender();
-
-	LLFontGL::setFontDisplay(FALSE) ;
-	LLHUDText::setDisplayText(FALSE) ;
-	if (type == SNAPSHOT_TYPE_OBJECT_ID)
-	{
-		gObjectList.renderPickList(gViewerWindow->getVirtualWindowRect(), FALSE, FALSE);
-	}
-	else
-	{
-		display(do_rebuild, 1.0f, 0, TRUE);
-		render_ui();
-	}
-
-	S32 glformat, gltype, glpixel_length ;
-	if(SNAPSHOT_TYPE_DEPTH == type)
-	{
-		glpixel_length = 4 ;
-		glformat = GL_DEPTH_COMPONENT ; 
-		gltype = GL_FLOAT ;
-	}
-	else
-	{
-		glpixel_length = 3 ;
-		glformat = GL_RGB ;
-		gltype = GL_UNSIGNED_BYTE ;
-	}
-
-	raw->resize(w, h, glpixel_length);
-	glReadPixels(0, 0, w, h, glformat, gltype, raw->getData());
-
-	if(SNAPSHOT_TYPE_DEPTH == type)
-	{
-		LLViewerCamera* camerap = LLViewerCamera::getInstance();
-		F32 depth_conversion_factor_1 = (camerap->getFar() + camerap->getNear()) / (2.f * camerap->getFar() * camerap->getNear());
-		F32 depth_conversion_factor_2 = (camerap->getFar() - camerap->getNear()) / (2.f * camerap->getFar() * camerap->getNear());
-
-		//calculate the depth 
-		for (S32 y = 0 ; y < h ; y++)
-		{
-			for(S32 x = 0 ; x < w ; x++)
-			{
-				S32 i = (w * y + x) << 2 ;
-				
-				F32 depth_float_i = *(F32*)(raw->getData() + i);
-				
-				F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float_i * depth_conversion_factor_2));
-				U8 depth_byte = F32_to_U8(linear_depth_float, camerap->getNear(), camerap->getFar());
-				*(raw->getData() + i + 0) = depth_byte;
-				*(raw->getData() + i + 1) = depth_byte;
-				*(raw->getData() + i + 2) = depth_byte;
-				*(raw->getData() + i + 3) = 255;
-			}
-		}		
-	}
-
-	LLFontGL::setFontDisplay(TRUE) ;
-	LLHUDText::setDisplayText(TRUE) ;
-	mDisplayScale.setVec(display_scale) ;
-	mWindowRect = window_rect;	
-	setup3DRender();
-	gDisplaySwapBuffers = FALSE;
-	gDepthDirty = TRUE;
-
-	// POST SNAPSHOT
-	if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
-	{
-		LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI);
-	}
-
-	if (hide_hud)
-	{
-		LLPipeline::sShowHUDAttachments = TRUE;
-	}
-
-	setCursor(UI_CURSOR_ARROW);
-
-	if (do_rebuild)
-	{
-		// If we had to do a rebuild, that means that the lists of drawables to be rendered
-		// was empty before we started.
-		// Need to reset these, otherwise we call state sort on it again when render gets called the next time
-		// and we stand a good chance of crashing on rebuild because the render drawable arrays have multiple copies of
-		// objects on them.
-		gPipeline.resetDrawOrders();
-	}
-	
-	gSavedSettings.setS32("RenderName", render_name);	
-	
-	return TRUE;*/
 }
 
 // Saves the image from the screen to the specified filename and path.
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 583246c23e8..ef3244b199a 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -36,6 +36,8 @@
 
 #include "llvovolume.h"
 
+#include <sstream>
+
 #include "llviewercontrol.h"
 #include "lldir.h"
 #include "llflexibleobject.h"
@@ -61,6 +63,7 @@
 #include "llsky.h"
 #include "llviewercamera.h"
 #include "llviewertexturelist.h"
+#include "llviewerobjectlist.h"
 #include "llviewerregion.h"
 #include "llviewertextureanim.h"
 #include "llworld.h"
@@ -90,6 +93,12 @@ LLPointer<LLObjectMediaNavigateClient> LLVOVolume::sObjectMediaNavigateClient =
 
 static LLFastTimer::DeclareTimer FTM_GEN_TRIANGLES("Generate Triangles");
 static LLFastTimer::DeclareTimer FTM_GEN_VOLUME("Generate Volumes");
+static LLFastTimer::DeclareTimer FTM_BUILD_MESH("Mesh");
+static LLFastTimer::DeclareTimer FTM_MESH_VFS("VFS");
+static LLFastTimer::DeclareTimer FTM_MESH_STREAM("Stream");
+static LLFastTimer::DeclareTimer FTM_MESH_FACES("Faces");
+static LLFastTimer::DeclareTimer FTM_VOLUME_TEXTURES("Volume Textures");
+
 
 LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
 	: LLViewerObject(id, pcode, regionp),
@@ -513,6 +522,7 @@ void LLVOVolume::updateTextures(LLAgent &agent)
 
 void LLVOVolume::updateTextures()
 {
+	LLFastTimer ftm(FTM_VOLUME_TEXTURES);
 	// Update the pixel area of all faces
 
 	if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE))
@@ -599,36 +609,60 @@ void LLVOVolume::updateTextures()
 	if (isSculpted())
 	{
 		LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
-		LLUUID id =  sculpt_params->getSculptTexture(); 
-		mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE);
-		if (mSculptTexture.notNull())
-		{
-			S32 lod = llmin(mLOD, 3);
-			F32 lodf = ((F32)(lod + 1.0f)/4.f); 
-			F32 tex_size = lodf * MAX_SCULPT_REZ;
-			mSculptTexture->addTextureStats(2.f * tex_size * tex_size);
-			mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(),
-												(S32)LLViewerTexture::BOOST_SCULPTED));
-			mSculptTexture->setForSculpt() ;
-		}
-
-		S32 texture_discard = mSculptTexture->getDiscardLevel(); //try to match the texture
-		S32 current_discard = mSculptLevel;
+		LLUUID id =  sculpt_params->getSculptTexture();
+		U8 sculpt_type = sculpt_params->getSculptType();
 
-		if (texture_discard >= 0 && //texture has some data available
-			(texture_discard < current_discard || //texture has more data than last rebuild
-			current_discard < 0)) //no previous rebuild
+		if ((sculpt_type & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
+			// mesh is a mesh
 		{
-			gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
-			mSculptChanged = TRUE;
+			if (mSculptLevel == -2)
+			{
+				// get the asset please
+				gPipeline.loadMesh(this, id);
+				/*gAssetStorage->getAssetData(id,	LLAssetType::AT_MESH, (LLGetAssetCallback)NULL, NULL, TRUE);
+
+				if (gAssetStorage->hasLocalAsset(id, LLAssetType::AT_MESH))
+				{
+					gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
+					mSculptChanged = TRUE;
+				}*/
+			}
 		}
 
-		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED))
+		else
+			// mesh is a sculptie
+		{
+			mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE);
+
+			if (mSculptTexture.notNull())
+			{
+				S32 lod = llmin(mLOD, 3);
+				F32 lodf = ((F32)(lod + 1.0f)/4.f); 
+				F32 tex_size = lodf * MAX_SCULPT_REZ;
+				mSculptTexture->addTextureStats(2.f * tex_size * tex_size);
+				mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(),
+												(S32)LLViewerTexture::BOOST_SCULPTED));
+				mSculptTexture->setForSculpt() ;
+			}
+
+			S32 texture_discard = mSculptTexture->getDiscardLevel(); //try to match the texture
+			S32 current_discard = mSculptLevel;
+
+			if (texture_discard >= 0 && //texture has some data available
+				(texture_discard < current_discard || //texture has more data than last rebuild
+				 current_discard < 0)) //no previous rebuild
+			{
+				gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
+				mSculptChanged = TRUE;
+			}
+
+			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED))
 			{
 				setDebugText(llformat("T%d C%d V%d\n%dx%d",
 									  texture_discard, current_discard, getVolume()->getSculptLevel(),
 									  mSculptTexture->getHeight(), mSculptTexture->getWidth()));
 			}
+		}
 	}
 
 	if (getLightTextureID().notNull())
@@ -771,8 +805,10 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline)
 }
 
 
-BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume)
+BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool unique_volume)
 {
+	LLVolumeParams volume_params = params;
+
 	// Check if we need to change implementations
 	bool is_flexible = (volume_params.getPathParams().getCurveType() == LL_PCODE_PATH_FLEXIBLE);
 	if (is_flexible)
@@ -811,21 +847,39 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail
 		
 		if (isSculpted())
 		{
-			mSculptTexture = LLViewerTextureManager::getFetchedTexture(volume_params.getSculptID(), TRUE, FALSE, LLViewerTexture::LOD_TEXTURE);
-			if (mSculptTexture.notNull())
+			// if it's a mesh
+			if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 			{
-				//ignore sculpt GL usage since bao fixed this in a separate branch
-				if (!gGLActive)
+				if (getVolume()->getNumVolumeFaces() == 0)
 				{
-					gGLActive = TRUE;
-					sculpt();
-					gGLActive = FALSE;
+					//mesh is not loaded, request pipeline load this mesh
+					LLUUID asset_id = volume_params.getSculptID();
+					gPipeline.loadMesh(this, asset_id);
 				}
 				else
 				{
-					sculpt();
+					mSculptLevel = 1;
+				}
+			}
+			else // otherwise is sculptie
+			{
+				mSculptTexture = LLViewerTextureManager::getFetchedTexture(volume_params.getSculptID(), TRUE, FALSE, LLViewerTexture::LOD_TEXTURE);
+
+				if (mSculptTexture.notNull())
+				{
+					//ignore sculpt GL usage since bao fixed this in a separate branch
+					if (!gGLActive)
+					{
+						gGLActive = TRUE;
+						sculpt();
+						gGLActive = FALSE;
+					}
+					else
+					{
+						sculpt();
+					}
+					mSculptLevel = getVolume()->getSculptLevel();
 				}
-				mSculptLevel = getVolume()->getSculptLevel();
 			}
 		}
 		else
@@ -838,6 +892,14 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail
 	return FALSE;
 }
 
+
+
+void LLVOVolume::notifyMeshLoaded()
+{ 
+	mSculptChanged = TRUE;
+	gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY);
+}
+
 // sculpt replaces generate() for sculpted surfaces
 void LLVOVolume::sculpt()
 {
@@ -1039,6 +1101,11 @@ void LLVOVolume::updateFaceFlags()
 	for (S32 i = 0; i < getVolume()->getNumFaces(); i++)
 	{
 		LLFace *face = mDrawable->getFace(i);
+		if (!face)
+		{
+			return;
+		}
+
 		BOOL fullbright = getTE(i)->getFullbright();
 		face->clearState(LLFace::FULLBRIGHT | LLFace::HUD_RENDER | LLFace::LIGHT);
 
@@ -1111,6 +1178,10 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
 	for (S32 i = 0; i < getVolume()->getNumFaces(); i++)
 	{
 		LLFace *face = mDrawable->getFace(i);
+		if (!face)
+		{
+			continue;
+		}
 		res &= face->genVolumeBBoxes(*getVolume(), i,
 										mRelativeXform, mRelativeXformInvTrans,
 										(mVolumeImpl && mVolumeImpl->isVolumeGlobal()) || force_global);
@@ -2218,6 +2289,23 @@ BOOL LLVOVolume::isSculpted() const
 	return FALSE;
 }
 
+BOOL LLVOVolume::isMesh() const
+{
+	if (isSculpted())
+	{
+		LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
+		U8 sculpt_type = sculpt_params->getSculptType();
+
+		if ((sculpt_type & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
+			// mesh is a mesh
+		{
+			return TRUE;	
+		}
+	}
+
+	return FALSE;
+}
+
 BOOL LLVOVolume::hasLightTexture() const
 {
 	if (getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE))
@@ -2423,6 +2511,30 @@ F32 LLVOVolume::getBinRadius()
 {
 	F32 radius;
 	
+	F32 scale = 1.f;
+
+	if (isSculpted())
+	{
+		LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
+		LLUUID id =  sculpt_params->getSculptTexture();
+		U8 sculpt_type = sculpt_params->getSculptType();
+
+		if ((sculpt_type & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
+			// mesh is a mesh
+		{
+			LLVolume* volume = getVolume();
+			U32 vert_count = 0;
+
+			for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i)
+			{
+				const LLVolumeFace& face = volume->getVolumeFace(i);
+				vert_count += face.mVertices.size();
+			}
+
+			scale = 1.f/llmax(vert_count/1024.f, 1.f);
+		}
+	}
+
 	const LLVector3* ext = mDrawable->getSpatialExtents();
 	
 	BOOL shrink_wrap = mDrawable->isAnimating();
@@ -2481,7 +2593,7 @@ F32 LLVOVolume::getBinRadius()
 		radius = 8.f;
 	}
 
-	return llclamp(radius, 0.5f, 256.f);
+	return llclamp(radius*scale, 0.5f, 256.f);
 }
 
 const LLVector3 LLVOVolume::getPivotPositionAgent() const
@@ -3071,6 +3183,11 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 						face->getGeometryVolume(*volume, face->getTEOffset(), 
 							vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex());
 					}
+
+					if (!face)
+					{
+						llerrs << "WTF?" << llendl;
+					}
 				}
 
 				drawablep->clearState(LLDrawable::REBUILD_ALL);
@@ -3354,7 +3471,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				}
 				else
 				{
-					if (LLPipeline::sRenderDeferred && te->getBumpmap())
+					if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap())
 					{
 						registerFace(group, facep, LLRenderPass::PASS_BUMP);
 					}
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 250c3ed9170..6aaf5b2fddb 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -182,6 +182,11 @@ class LLVOVolume : public LLViewerObject
 
 	/*virtual*/ BOOL	setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
 				void	sculpt();
+	 static     void    rebuildMeshAssetCallback(LLVFS *vfs,
+														  const LLUUID& asset_uuid,
+														  LLAssetType::EType type,
+														  void* user_data, S32 status, LLExtStat ext_status);
+					
 				void	updateRelativeXform();
 	/*virtual*/ BOOL	updateGeometry(LLDrawable *drawable);
 	/*virtual*/ void	updateFaceSize(S32 idx);
@@ -227,6 +232,7 @@ class LLVOVolume : public LLViewerObject
 	U32 getVolumeInterfaceID() const;
 	virtual BOOL isFlexible() const;
 	virtual BOOL isSculpted() const;
+	virtual BOOL isMesh() const;
 	virtual BOOL hasLightTexture() const;
 
 	BOOL isVolumeGlobal() const;
@@ -235,6 +241,7 @@ class LLVOVolume : public LLViewerObject
 
 	void updateObjectMediaData(const LLSD &media_data_duples);
 	void mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin, LLViewerMediaObserver::EMediaEvent event);
+			
 
 	// Sync the given media data with the impl and the given te
 	void syncMediaData(S32 te, const LLSD &media_data, bool merge, bool ignore_agent);
@@ -247,6 +254,8 @@ class LLVOVolume : public LLViewerObject
    
 	bool hasMedia() const;
 
+	void notifyMeshLoaded();
+
 protected:
 	S32	computeLODDetail(F32	distance, F32 radius);
 	BOOL calcLOD();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index b50e71bf485..7cf5cf75ad2 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -342,6 +342,8 @@ LLPipeline::LLPipeline() :
 	mGlowPool(NULL),
 	mBumpPool(NULL),
 	mWLSkyPool(NULL),
+	mMeshMutex(NULL),
+	mMeshThreadCount(0),
 	mLightMask(0),
 	mLightMovingMask(0),
 	mLightingDetail(0)
@@ -399,6 +401,7 @@ void LLPipeline::init()
 
 	stop_glerror();
 
+	mMeshMutex = new LLMutex(NULL);
 	for (U32 i = 0; i < 2; ++i)
 	{
 		mSpotLightFade[i] = 1.f;
@@ -473,6 +476,9 @@ void LLPipeline::cleanup()
 	//delete mWLSkyPool;
 	mWLSkyPool = NULL;
 
+	delete mMeshMutex;
+	mMeshMutex = NULL;
+
 	releaseGLBuffers();
 
 	mBloomImagep = NULL;
@@ -1783,6 +1789,8 @@ void LLPipeline::rebuildPriorityGroups()
 	
 	assertInitialized();
 
+	notifyLoadedMeshes();
+
 	// Iterate through all drawables on the priority build queue,
 	for (LLSpatialGroup::sg_list_t::iterator iter = mGroupQ1.begin();
 		 iter != mGroupQ1.end(); ++iter)
@@ -1793,6 +1801,7 @@ void LLPipeline::rebuildPriorityGroups()
 	}
 
 	mGroupQ1.clear();
+
 }
 		
 void LLPipeline::rebuildGroups()
@@ -3419,27 +3428,14 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
 	gGLLastMatrix = NULL;
 	glLoadMatrixd(gGLModelView);
 
-	renderHighlights();
-	mHighlightFaces.clear();
-
-	renderDebug();
-
-	LLVertexBuffer::unbind();
-
-	if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
-	{
-		// Render debugging beacons.
-		gObjectList.renderObjectBeacons();
-		LLHUDObject::renderAll();
-		gObjectList.resetObjectBeacons();
-	}
-
 	if (occlude)
 	{
 		occlude = FALSE;
 		gGLLastMatrix = NULL;
 		glLoadMatrixd(gGLModelView);
 		doOcclusion(camera);
+		gGLLastMatrix = NULL;
+		glLoadMatrixd(gGLModelView);
 	}
 }
 
@@ -5836,6 +5832,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 		gGL.getTexUnit(0)->activate();
 		gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+
+		if (LLRenderTarget::sUseFBO)
+		{ //copy depth buffer from mScreen to framebuffer
+			LLRenderTarget::copyContentsToFramebuffer(mScreen, 0, 0, mScreen.getWidth(), mScreen.getHeight(), 
+				0, 0, mScreen.getWidth(), mScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+		}
 	}
 	
 
@@ -6912,6 +6914,24 @@ void LLPipeline::renderDeferredLighting()
 		mRenderTypeMask = render_mask;
 	}
 
+	{
+		//render highlights, etc.
+		renderHighlights();
+		mHighlightFaces.clear();
+
+		renderDebug();
+
+		LLVertexBuffer::unbind();
+
+		if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
+		{
+			// Render debugging beacons.
+			gObjectList.renderObjectBeacons();
+			LLHUDObject::renderAll();
+			gObjectList.resetObjectBeacons();
+		}
+	}
+
 	mScreen.flush();
 						
 }
@@ -7241,18 +7261,12 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 					LLGLDisable cull(GL_CULL_FACE);
 					updateCull(camera, ref_result, 1);
 					stateSort(camera, ref_result);
-					gGL.setColorMask(true, true);
-					mWaterRef.clear();
-					gGL.setColorMask(true, false);
-
-				}
-				else
-				{
-					gGL.setColorMask(true, true);
-					mWaterRef.clear();
-					gGL.setColorMask(true, false);
-				}
-
+				}	
+				
+				gGL.setColorMask(true, true);
+				mWaterRef.clear();
+				gGL.setColorMask(true, false);
+			
 				ref_mask = mRenderTypeMask;
 				mRenderTypeMask = mask;
 			}
@@ -7907,6 +7921,7 @@ void LLPipeline::generateHighlight(LLCamera& camera)
 
 		mHighlight.flush();
 		gGL.setColorMask(true, false);
+		gViewerWindow->setup3DViewport();
 	}
 }
 
@@ -8886,3 +8901,175 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
 }
 
 
+void LLPipeline::loadMesh(LLVOVolume* volume, LLUUID mesh_id)
+{
+
+	{
+		LLMutexLock lock(mMeshMutex);
+		//add volume to list of loading meshes
+		mesh_load_map::iterator iter = mLoadingMeshes.find(mesh_id);
+		if (iter != mLoadingMeshes.end())
+		{ //request pending for this mesh, append volume id to list
+			iter->second.insert(volume->getID());
+			return;
+		}
+
+		//first request for this mesh
+		mLoadingMeshes[mesh_id].insert(volume->getID());
+	}
+
+	if (gAssetStorage->hasLocalAsset(mesh_id, LLAssetType::AT_MESH))
+	{ //already have asset, load desired LOD in background
+		mPendingMeshes.push_back(new LLMeshThread(mesh_id, volume->getVolume()));
+	}
+	else
+	{ //fetch asset and load when done
+		gAssetStorage->getAssetData(mesh_id, LLAssetType::AT_MESH,
+									getMeshAssetCallback, volume->getVolume(), TRUE);
+	}
+
+}
+
+//static
+void LLPipeline::getMeshAssetCallback(LLVFS *vfs,
+										  const LLUUID& asset_uuid,
+										  LLAssetType::EType type,
+										  void* user_data, S32 status, LLExtStat ext_status)
+{
+	gPipeline.mPendingMeshes.push_back(new LLMeshThread(asset_uuid, (LLVolume*) user_data));
+}
+
+
+LLPipeline::LLMeshThread::LLMeshThread(LLUUID mesh_id, LLVolume* target)
+: LLThread("mesh_loading_thread")
+{
+	mMeshID = mesh_id;
+	mVolume = NULL;
+	mDetail = target->getDetail();
+	mTargetVolume = target;
+}
+
+LLPipeline::LLMeshThread::~LLMeshThread()
+{
+
+}
+
+void LLPipeline::LLMeshThread::run()
+{
+	if (!gAssetStorage || LLApp::instance()->isQuitting())
+	{
+		return;
+	}
+
+	char* buffer = NULL;
+	S32 size = 0;
+	
+	LLVFS* vfs = gAssetStorage->mVFS;
+
+	{
+		LLVFile file(vfs, mMeshID, LLAssetType::AT_MESH, LLVFile::READ);
+		file.waitForLock(VFSLOCK_READ);
+		size = file.getSize();
+		
+		if (size == 0)
+		{
+			gPipeline.meshLoaded(this);
+			return;
+		}
+		
+		buffer = new char[size];
+		file.read((U8*)&buffer[0], size);
+	}
+
+	{
+		std::string buffer_string(buffer, size);
+		std::istringstream buffer_stream(buffer_string);
+
+		{
+			LLVolumeParams volume_params;
+			volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+			mVolume = new LLVolume(volume_params, mDetail);
+			mVolume->createVolumeFacesFromStream(buffer_stream);
+		}
+	}
+	delete[] buffer;
+	
+	gPipeline.meshLoaded(this);
+}
+
+void LLPipeline::meshLoaded(LLPipeline::LLMeshThread* mesh_thread)
+{
+	LLMutexLock lock(mMeshMutex);
+	mLoadedMeshes.push_back(mesh_thread);
+}
+
+void LLPipeline::notifyLoadedMeshes()
+{ //called from main thread
+
+	U32 max_thread_count = llmax(gSavedSettings.getU32("MeshThreadCount"), (U32) 1);
+	while (mMeshThreadCount < max_thread_count && !mPendingMeshes.empty())
+	{
+		LLMeshThread* mesh_thread = mPendingMeshes.front();
+		mesh_thread->start();
+		++mMeshThreadCount;
+		mPendingMeshes.pop_front();
+	}
+
+	LLMutexLock lock(mMeshMutex);
+	std::list<LLMeshThread*> stopping_threads;
+
+	for (std::list<LLMeshThread*>::iterator iter = mLoadedMeshes.begin(); iter != mLoadedMeshes.end(); ++iter)
+	{ //for each mesh done loading
+		LLMeshThread* mesh = *iter;
+		
+		if (!mesh->isStopped())
+		{ //don't process a LLMeshThread until it's stopped
+			stopping_threads.push_back(mesh);
+			continue;
+		}
+
+		//get list of objects waiting to be notified this mesh is loaded
+		mesh_load_map::iterator obj_iter = mLoadingMeshes.find(mesh->mMeshID);
+
+		if (mesh->mVolume && obj_iter != mLoadingMeshes.end())
+		{
+			//make sure target volume is still valid
+			BOOL valid = FALSE;
+
+			for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
+			{
+				LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
+
+				if (vobj)
+				{
+					if (vobj->getVolume() == mesh->mTargetVolume)
+					{
+						valid = TRUE;
+					}
+				}
+			}
+
+
+			if (valid)
+			{
+				mesh->mTargetVolume->copyVolumeFaces(mesh->mVolume);
+				for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
+				{
+					LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
+					if (vobj)
+					{
+						vobj->notifyMeshLoaded();
+					}
+				}
+			}
+
+			mLoadingMeshes.erase(mesh->mMeshID);
+		}
+
+		delete mesh;
+		--mMeshThreadCount;
+	}
+
+	mLoadedMeshes = stopping_threads;
+}
+
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index ce50a374050..bf654f88b15 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -278,6 +278,10 @@ class LLPipeline
 	LLCullResult::sg_list_t::iterator beginAlphaGroups();
 	LLCullResult::sg_list_t::iterator endAlphaGroups();
 	
+
+	//mesh management functions
+	void loadMesh(LLVOVolume* volume, LLUUID mesh_id);
+	
 	void addTrianglesDrawn(S32 count);
 	BOOL hasRenderType(const U32 type) const				{ return (type && (mRenderTypeMask & (1<<type))) ? TRUE : FALSE; }
 	BOOL hasRenderDebugFeatureMask(const U32 mask) const	{ return (mRenderDebugFeatureMask & mask) ? TRUE : FALSE; }
@@ -672,6 +676,35 @@ class LLPipeline
 protected:
 	std::vector<LLFace*>		mSelectedFaces;
 
+	typedef std::map<LLUUID, std::set<LLUUID> > mesh_load_map;
+	mesh_load_map mLoadingMeshes;
+	
+	LLMutex*					mMeshMutex;
+
+	class LLMeshThread : public LLThread
+	{
+	public:
+		LLPointer<LLVolume> mVolume;
+		LLVolume* mTargetVolume;
+		LLUUID mMeshID;
+		F32 mDetail;
+		LLMeshThread(LLUUID mesh_id, LLVolume* target);
+		~LLMeshThread();
+		void run();
+	};
+	
+	static void getMeshAssetCallback(LLVFS *vfs,
+										  const LLUUID& asset_uuid,
+										  LLAssetType::EType type,
+										  void* user_data, S32 status, LLExtStat ext_status);
+
+	std::list<LLMeshThread*> mLoadedMeshes;
+	std::list<LLMeshThread*> mPendingMeshes;
+	U32 mMeshThreadCount;
+
+	void meshLoaded(LLMeshThread* mesh_thread);
+	void notifyLoadedMeshes();
+
 	LLPointer<LLViewerFetchedTexture>	mFaceSelectImagep;
 	LLPointer<LLViewerTexture>	mBloomImagep;
 	LLPointer<LLViewerTexture>	mBloomImage2p;
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index 01976c9a5c2..26b0b39a68f 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -568,6 +568,7 @@
   <texture name="inv_folder_landmark.tga" />
   <texture name="inv_folder_lostandfound.tga" />
   <texture name="inv_folder_my_outfits.tga" />
+  <texture name="inv_folder_mesh.tga"/>
   <texture name="inv_folder_notecard.tga" />
   <texture name="inv_folder_object.tga" />
   <texture name="inv_folder_outfit.tga" />
@@ -591,6 +592,7 @@
   <texture name="inv_item_landmark_visited.tga" />
   <texture name="inv_item_linkitem.tga" />
   <texture name="inv_item_linkfolder.tga" />
+  <texture name="inv_item_mesh.tga"/>
   <texture name="inv_item_notecard.tga" />
   <texture name="inv_item_object.tga" />
   <texture name="inv_item_object_multi.tga" />
diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml
index 4d7433233aa..09240a3e276 100644
--- a/indra/newview/skins/default/xui/en/floater_about.xml
+++ b/indra/newview/skins/default/xui/en/floater_about.xml
@@ -152,16 +152,19 @@ It is a rare mind indeed that can render the hitherto non-existent blindingly ob
        word_wrap="true">
 3Dconnexion SDK Copyright (C) 1992-2007 3Dconnexion
 APR Copyright (C) 2000-2004 The Apache Software Foundation
+  Collada DOM Copyright 2005 Sony Computer Entertainment Inc.
 cURL Copyright (C) 1996-2002, Daniel Stenberg, (daniel@haxx.se)
 DBus/dbus-glib Copyright (C) 2002, 2003  CodeFactory AB / Copyright (C) 2003, 2004 Red Hat, Inc.
 expat Copyright (C) 1998, 1999, 2000 Thai Open Source Software Center Ltd.
 FreeType Copyright (C) 1996-2002, The FreeType Project (www.freetype.org).
 GL Copyright (C) 1999-2004 Brian Paul.
+  GLOD Copyright (C) 2003-04 Jonathan Cohen, Nat Duca, Chris Niski, Johns Hopkins University and David Luebke, Brenden Schubert, University of Virginia.
 Havok.com(TM) Copyright (C) 1999-2001, Telekinesys Research Limited.
 jpeg2000 Copyright (C) 2001, David Taubman, The University of New South Wales (UNSW)
 jpeglib Copyright (C) 1991-1998, Thomas G. Lane.
 ogg/vorbis Copyright (C) 2001, Xiphophorus
 OpenSSL Copyright (C) 1998-2002 The OpenSSL Project.
+  PCRE Copyright (c) 1997-2008 University of Cambridge
 SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
 SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 xmlrpc-epi Copyright (C) 2000 Epinions, Inc.
diff --git a/indra/newview/skins/default/xui/en/floater_inventory.xml b/indra/newview/skins/default/xui/en/floater_inventory.xml
index 0f06558dd1f..6afeb4e82d2 100644
--- a/indra/newview/skins/default/xui/en/floater_inventory.xml
+++ b/indra/newview/skins/default/xui/en/floater_inventory.xml
@@ -123,6 +123,16 @@
                     <menu_item_call.on_enable
                      function="File.EnableUpload" />
                 </menu_item_call>
+              <menu_item_call
+                 label="Model (L$[COST])..."
+                 layout="topleft"
+                 name="Upload Model">
+                <menu_item_call.on_click
+                 function="File.UploadModel"
+                 parameter="" />
+                <menu_item_call.on_enable
+                 function="File.EnableUpload" />
+              </menu_item_call>
                 <menu_item_call
                  label="Animation (L$[COST])..."
                  layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index 7829a4fa933..c15811f0e8e 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1996,6 +1996,9 @@
                  label="Cylinder"
                  name="Cylinder"
                  value="Cylinder" />
+                <combo_box.item
+                 label="Mesh"
+                 value="Mesh" />
             </combo_box>
         </panel>
 
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 284594426c7..d90d1f0635b 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2210,10 +2210,10 @@
              name="Fast Alpha">
                 <menu_item_check.on_check
                  function="CheckControl"
-                 parameter="RenderDebugGL" />
+                 parameter="RenderFastAlpha" />
                 <menu_item_check.on_click
                  function="ToggleControl"
-                 parameter="RenderDebugGL" />
+                 parameter="RenderFastAlpha" />
             </menu_item_check>
             <menu_item_check
              label="Animation Textures"
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index d10bbe7569f..6831e56f0b9 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -6540,7 +6540,7 @@ Attachment has been saved.
 Unable to find the help topic for this element.
   </notification>
 
-    <notification
+     <notification
  icon="alertmodal.tga"
  name="ObjectMediaFailure"
  type="alertmodal">
@@ -6551,6 +6551,29 @@ Server Error: Media update or get failed.
          yestext="OK"/>
     </notification>
 
+    
+ <notification
+   icon="alertmodal.tga"
+   name="ConfirmClearTeleportHistory"
+   type="alertmodal">
+Are you sure you want to delete your teleport history?
+    <usetemplate
+     name="okcancelbuttons"
+     notext="Cancel"
+     yestext="OK"/>
+    </notification>
+
+     <notification
+   icon="alertmodal.tga"
+   name="UploadCostConfirmation"
+   type="alertmodal">
+This upload will cost L$[PRICE], do you wish to continue with the upload?
+    <usetemplate
+     name="okcancelbuttons"
+     notext="Cancel"
+     yestext="Upload"/>
+  </notification>
+
   <notification
    icon="alertmodal.tga"
    name="ConfirmClearTeleportHistory"
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index bdcea05c733..36f4fb98ed1 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -1872,6 +1872,7 @@ this texture in your inventory
 	<string name="InvFolder favorite">Favorites</string>
 	<string name="InvFolder Current Outfit">Current Outfit</string>
 	<string name="InvFolder My Outfits">My Outfits</string>
+	<string name="InvFolder Meshes">Meshes</string>
 
   <!-- are used for Friends and Friends/All folders in Inventory "Calling cards" folder. See EXT-694-->
 	<string name="InvFolder Friends">Friends</string>
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 045990811b4..db4b68e9d6d 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -194,6 +194,12 @@ def construct(self):
         # For using FMOD for sound... DJS
         self.path("fmod.dll")
 
+        # For automatic level of detail generation in mesh importer
+        self.path("glod.dll")
+
+        # For reading collada files
+        self.path("libcollada14dom21.dll")
+
         # For textures
         if self.prefix(src="../../libraries/i686-win32/lib/release", dst=""):
             self.path("openjpeg.dll")
diff --git a/install.xml b/install.xml
index 44224664cae..24ade320954 100644
--- a/install.xml
+++ b/install.xml
@@ -43,6 +43,39 @@
           </map>
         </map>
       </map>
+      <key>GLOD</key>
+      <map>
+        <key>copyright</key>
+        <string>Copyright (C) 2003-04 Jonathan Cohen, Nat Duca, Chris Niski, Johns Hopkins University and David Luebke, Brenden Schubert, University of Virginia. All rights reserved.</string>
+        <key>description</key>
+        <string>Geometric Level of Detail for OpenGL</string>
+        <key>license</key>
+        <string>GLOD</string>
+        <key>packages</key>
+        <map>
+          <key>darwin</key>
+          <map>
+            <key>md5sum</key>
+            <string>ab78835bafcad3bb7223eaeecb5a6a4b</string>
+            <key>url</key>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/GLOD-1.0pre4-darwin-20090918.tar.bz2</uri>
+          </map>
+          <key>linux</key>
+          <map>
+            <key>md5sum</key>
+            <string>66ae292063b80f3a9fecb46dcd4fe5ec</string>
+            <key>url</key>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/GLOD-1.0pre4-linux-20091023.tar.bz2</uri>
+          </map>
+          <key>windows</key>
+          <map>
+            <key>md5sum</key>
+            <string>b97aa644a548310ca3c916518bb07b7e</string>
+            <key>url</key>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/GLOD-windows-20090915.tar.bz2</uri>
+          </map>
+        </map>
+      </map>
       <key>SDL</key>
       <map>
         <key>copyright</key>
@@ -220,6 +253,39 @@
           </map>
         </map>
       </map>
+      <key>colladadom</key>
+      <map>
+        <key>copyright</key>
+        <string>Copyright 2005 Sony Computer Entertainment Inc.</string>
+        <key>description</key>
+        <string>Library for processing collada file format</string>
+        <key>license</key>
+        <string>scea</string>
+        <key>packages</key>
+        <map>
+          <key>darwin</key>
+          <map>
+            <key>md5sum</key>
+            <string>786de8bfebb5df3a3b51a7832119f8d8</string>
+            <key>url</key>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-darwin-20090731.tar.bz2</uri>
+          </map>
+          <key>linux</key>
+          <map>
+            <key>md5sum</key>
+            <string>01d17182ecc6728edaa520b3c780d194</string>
+            <key>url</key>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-linux-20090921.tar.bz2</uri>
+          </map>
+          <key>windows</key>
+          <map>
+            <key>md5sum</key>
+            <string>fd3e5dade35c586ae13a320ab731df0d</string>
+            <key>url</key>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-windows-20090908.tar.bz2</uri>
+          </map>
+        </map>
+      </map>
       <key>curl</key>
       <map>
         <key>copyright</key>
@@ -1186,6 +1252,32 @@ anguage Infrstructure (CLI) international standard</string>
           </map>
         </map>
       </map>
+      <key>pcre</key>
+      <map>
+        <key>copyright</key>
+        <string>Copyright (c) 1997-2008 University of Cambridge</string>
+        <key>description</key>
+        <string>Regular expression library</string>
+        <key>license</key>
+        <string>bsd</string>
+        <key>packages</key>
+        <map>
+          <key>darwin</key>
+          <map>
+            <key>md5sum</key>
+            <string>63e2dc55142b8b36521c1b0c9b6ed6bb</string>
+            <key>url</key>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/pcre-7.6-darwin-20090730.tar.bz2</uri>
+          </map>
+          <key>linux</key>
+          <map>
+            <key>md5sum</key>
+            <string>0886d0b1cdf104b6341df1832a8a7e09</string>
+            <key>url</key>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/pcre-7.6-linux-20090804.tar.bz2</uri>
+          </map>
+        </map>
+      </map>
       <key>quicktime</key>
       <map>
         <key>copyright</key>
@@ -1400,6 +1492,75 @@ anguage Infrstructure (CLI) international standard</string>
         <key>url</key>
         <string>http://www.xfree86.org/4.4.0/LICENSE9.html#sgi</string>
       </map>
+      <key>GLOD</key>
+      <map>
+        <key>text</key>
+        <string>The GLOD Open-Source License   Version 1.0             July 22, 2003
+
+Copyright (C) 2003 Jonathan Cohen, Nat Duca, Johns Hopkins University
+and David Luebke, Brenden Schubert, University of Virginia. All rights
+reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, is permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer and
+   request.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer and
+   request in the documentation and/or other materials provided with
+   the distribution.
+
+3. The name "GLOD" must not be used to endorse or promote products
+   derived from this software without prior written permission.
+
+4. Redistributions of any modified version of this source, whether in
+   source or binary form , must include a form of the following
+   acknowledgment: "This product is derived from the GLOD library,
+   which is available from http://www.cs.jhu.edu/~graphics/GLOD."
+
+5. Redistributions of any modified version of this source in binary
+   form must provide, free of charge, access to the modified version
+   of the code.
+
+6. This license shall be governed by and construed and enforced in
+   accordance with the laws of the State of Maryland, without
+   reference to its conflicts of law provisions. The exclusive
+   jurisdiction and venue for all legal actions relating to this
+   license shall be in courts of competent subject matter jurisdiction
+   located in the State of Maryland.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, GLOD IS PROVIDED
+UNDER THIS LICENSE ON AN AS IS BASIS, WITHOUT WARRANTY OF ANY KIND,
+EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
+THAT GLOD IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+PURPOSE OR NON-INFRINGING. ALL WARRANTIES ARE DISCLAIMED AND THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE CODE IS WITH
+YOU. SHOULD ANY CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+COPYRIGHT HOLDER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY
+NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY
+CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY CODE IS
+AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+THE COPYRIGHT HOLDER OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
+SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES FOR LOSS OF
+PROFITS, REVENUE, OR FOR LOSS OF INFORMATION OR ANY OTHER LOSS.
+
+YOU EXPRESSLY AGREE TO FOREVER INDEMNIFY, DEFEND AND HOLD HARMLESS THE
+COPYRIGHT HOLDERS AND CONTRIBUTORS OF GLOD AGAINST ALL CLAIMS,
+DEMANDS, SUITS OR OTHER ACTIONS ARISING DIRECTLY OR INDIRECTLY FROM
+YOUR ACCEPTANCE AND USE OF GLOD.
+
+Although NOT REQUIRED, we would appreciate it if active users of GLOD
+put a link on their web site to the GLOD web site when possible.
+</string>
+        <key>url</key>
+        <string>http://www.cs.jhu.edu/~graphics/GLOD/license/</string>
+      </map>
       <key>MSDTW</key>
       <map>
         <key>text</key>
@@ -1725,6 +1886,11 @@ IMPORTANT NOTE: To the extent this software may be used to reproduce materials,
 EA0300
 </string>
       </map>
+      <key>scea</key>
+      <map>
+        <key>url</key>
+        <string>http://research.scea.com/scea_shared_source_license.html</string>
+      </map>
       <key>sleepycat</key>
       <map>
         <key>url</key>
-- 
GitLab


From 63b9bd43ff41da01d549f630bd838caff0dffd97 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Mon, 2 Nov 2009 14:56:46 -0800
Subject: [PATCH 002/683] Repairing things that didn't quite merge properly.

---
 indra/llprimitive/llprimitive.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index c30ef0350f3..da1cfc2074b 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -743,6 +743,8 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
 		setNumTEs(mVolumep->getNumFaces());
 		return TRUE;
 	}
+	
+	U32 old_face_mask = mVolumep->mFaceMask;
 
 	S32 face_bit = 0;
 	S32 cur_mask = 0;
-- 
GitLab


From 9c3595465972ba4be916e871f6b0a62cc0c13d4a Mon Sep 17 00:00:00 2001
From: Jon Wolk <jwolk@lindenlab.com>
Date: Tue, 3 Nov 2009 19:36:39 +0000
Subject: [PATCH 003/683] Changed variable price upload responders to reflect
 server changes.  I hope this gets pulled into the hg repository

---
 indra/newview/llassetuploadresponders.cpp | 176 ++++++++++++++--------
 indra/newview/llassetuploadresponders.h   |   3 +-
 indra/newview/llviewermenufile.cpp        | 138 ++++++++++-------
 indra/newview/llviewermenufile.h          |  16 +-
 4 files changed, 212 insertions(+), 121 deletions(-)

diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index cb03379b23d..680d1acd819 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -72,7 +72,7 @@ static const S32 FILE_COUNT_DISPLAY_THRESHOLD = 5;
 
 void dialog_refresh_all();
 
-void on_new_single_inventory_upload_complete(
+static void on_new_single_inventory_upload_complete(
 	LLAssetType::EType asset_type,
 	LLInventoryType::EType inventory_type,
 	const std::string inventory_type_string,
@@ -736,22 +736,103 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 		LLUploadDialog::modalUploadFinished();
 	}
 
-	void onApplicationLevelError(const std::string& error_identifier)
+	void onApplicationLevelError(const LLSD& error)
 	{
-		// TODO*: Pull these user visible strings from an xml file
-		// to be localized
+		static const std::string _IDENTIFIER = "identifier";
+
 		static const std::string _INSUFFICIENT_FUNDS =
 			"NewAgentInventory_InsufficientLindenDollarBalance";
+		static const std::string _MISSING_REQUIRED_PARAMETER =
+			"NewAgentInventory_MissingRequiredParamater";
+		static const std::string _INVALID_REQUEST_BODY =
+			"NewAgentInventory_InvalidRequestBody";
+		static const std::string _RESOURCE_COST_DIFFERS =
+			"NewAgentInventory_ResourceCostDiffers";
+
+		static const std::string _MISSING_PARAMETER = "missing_parameter";
+		static const std::string _INVALID_PARAMETER = "invalid_parameter";
+		static const std::string _MISSING_RESOURCE = "missing_resource";
+		static const std::string _INVALID_RESOURCE = "invalid_resource";
+
+		// TODO* Add the other error_identifiers
 
+		std::string error_identifier = error[_IDENTIFIER].asString();
 
+		// TODO*: Pull these user visible strings from an xml file
+		// to be localized
 		if ( _INSUFFICIENT_FUNDS == error_identifier )
 		{
 			displayCannotUploadReason("You do not have a sufficient L$ balance to complete this upload.");
 		}
+		else if ( _MISSING_REQUIRED_PARAMETER == error_identifier )
+		{
+			// Missing parameters
+			if (error.has(_MISSING_PARAMETER) )
+			{
+				std::string message = 
+					"Upload request was missing required parameter '[P]'";
+				LLStringUtil::replaceString(
+					message,
+					"[P]",
+					error[_MISSING_PARAMETER].asString());
+
+				displayCannotUploadReason(message);
+			}
+			else
+			{
+				std::string message = 
+					"Upload request was missing a required parameter";
+				displayCannotUploadReason(message);					
+			}
+		}
+		else if ( _INVALID_REQUEST_BODY == error_identifier )
+		{
+			// Invalid request body, check to see if 
+			// a particular parameter was invalid
+			if ( error.has(_INVALID_PARAMETER) )
+			{
+				std::string message = "Upload parameter '[P]' is invalid.";
+				LLStringUtil::replaceString(
+					message,
+					"[P]",
+					error[_INVALID_PARAMETER].asString());
+
+				// See if the server also responds with what resource
+				// is missing.
+				if ( error.has(_MISSING_RESOURCE) )
+				{
+					message += "\nMissing resource '[R]'.";
+
+					LLStringUtil::replaceString(
+						message,
+						"[R]",
+						error[_MISSING_RESOURCE].asString());
+				}
+				else if ( error.has(_INVALID_RESOURCE) )
+				{
+					message += "\nInvalid resource '[R]'.";
+
+					LLStringUtil::replaceString(
+						message,
+						"[R]",
+						error[_INVALID_RESOURCE].asString());
+				}
+
+				displayCannotUploadReason(message);
+			}
+			else
+			{
+				std::string message = "Upload request was malformed";
+				displayCannotUploadReason(message);					
+			}
+		}
+		else if ( _RESOURCE_COST_DIFFERS == error_identifier )
+		{
+			displayCannotUploadReason("The resource cost associated with this upload is not consistent with the server.");
+		}
 		else
 		{
 			displayCannotUploadReason("Unknown Error");
-
 		}
 	}
 
@@ -761,14 +842,18 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 				"The server is experiencing unexpected difficulties.");
 	}
 
-	void onTransportError(const std::string& error_identifier)
+	void onTransportError(const LLSD& error)
 	{
-		// TODO*: Pull these user visible strings from an xml file
-		// to be localized
+		static const std::string _IDENTIFIER = "identifier";
 
 		static const std::string _SERVER_ERROR_AFTER_CHARGE =
 			"NewAgentInventory_ServerErrorAfterCharge";
 
+		std::string error_identifier = error[_IDENTIFIER].asString();
+
+		// TODO*: Pull the user visible strings from an xml file
+		// to be localized
+
 		if ( _SERVER_ERROR_AFTER_CHARGE == error_identifier )
 		{
 			displayCannotUploadReason(
@@ -779,7 +864,6 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 			displayCannotUploadReason(
 				"The server is experiencing unexpected difficulties.");
 		}
-
 	}
 
 	bool uploadConfirmationCallback(
@@ -798,17 +882,26 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 			notification["payload"]["confirmation_url"].asString();
 
 		// Yay!  We are confirming or cancelling our upload
-		LLSD body;
-
-		body["confirm_upload"] = false;
-
 		switch(option)
 		{
 		case 0:
 		    {
-				body["confirm_upload"] = true;
-				body["expected_upload_price"] =
-					notification["payload"]["expected_upload_price"];
+				if ( getFilename().empty() )
+				{
+					// we have no filename, use virtual file ID instead
+					LLHTTPClient::postFile(
+						confirmation_url,
+						getVFileID(),
+						getAssetType(),
+						responder);
+				}
+				else
+				{
+					LLHTTPClient::postFile(
+						confirmation_url,
+						getFilename(),
+						responder);
+				}
 			}
 			break;
 		case 1:
@@ -816,8 +909,6 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 			break;
 		}
 
-		LLHTTPClient::post(confirmation_url, body, responder);
-
 		return false;
 	}
 	
@@ -865,9 +956,8 @@ void LLNewAgentInventoryVariablePriceResponder::errorWithContent(
 	if ( content.has("error") )
 	{
 		static const std::string _ERROR = "error";
-		static const std::string _IDENTIFIER = "identifier";
 
-		mImpl->onTransportError(content[_ERROR][_IDENTIFIER].asString());
+		mImpl->onTransportError(content[_ERROR]);
 	}
 	else
 	{
@@ -880,52 +970,25 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
 	// Parse out application level errors and the appropriate
 	// responses for them
 	static const std::string _ERROR = "error";
-	static const std::string _IDENTIFIER = "identifier";
 	static const std::string _STATE = "state";
 
 	static const std::string _COMPLETE = "complete";
-	static const std::string _COST_ANALYSIS = "cost_analysis";
-	static const std::string _NEEDS_CONFIRMATION = "needs_confirmation";
-	static const std::string _CANCEL = "cancel";
+	static const std::string _CONFIRM_UPLOAD = "confirm_upload";
 
-	static const std::string _RESOURCE_COST = "resource_cost";
 	static const std::string _UPLOAD_PRICE = "upload_price";
-
-	static const std::string _ANALYZER = "analyzer";
 	static const std::string _RSVP = "rsvp";
 
 	// Check for application level errors
 	if ( content.has(_ERROR) )
 	{
-		onApplicationLevelError(content[_ERROR][_IDENTIFIER].asString());
+		onApplicationLevelError(content[_ERROR]);
 		return;
 	}
 
 	std::string state = content[_STATE];
 	LLAssetType::EType asset_type = mImpl->getAssetType();
 
-	if ( _COST_ANALYSIS == state )
-	{
-		std::string analyzer_url = content[_ANALYZER];
-
-		if ( mImpl->getFilename().empty() )
-		{
-			// we have no filename, use virtual file ID instead
-			LLHTTPClient::postFile(
-				analyzer_url,
-				mImpl->getVFileID(),
-				asset_type,
-				this);
-		}
-		else
-		{
-			LLHTTPClient::postFile(
-				analyzer_url,
-				mImpl->getFilename(),
-				this);
-		}
-	}
-	else if ( _COMPLETE == state )
+	if ( _COMPLETE == state )
 	{
 		// rename file in VFS with new asset id
 		if (mImpl->getFilename().empty())
@@ -952,17 +1015,12 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
 		// TODO* Add bulk (serial) uploading or add
 		// a super class of this that does so
 	}
-	else if ( _NEEDS_CONFIRMATION == state )
+	else if ( _CONFIRM_UPLOAD == state )
 	{
 		showConfirmationDialog(
 			content[_UPLOAD_PRICE].asInteger(),
-			content[_RESOURCE_COST].asInteger(),
 			content[_RSVP].asString());
 	}
-	else if ( _CANCEL == state )
-	{
-		// cancelled, do nothing
-	}
 	else
 	{
 		onApplicationLevelError("");
@@ -970,14 +1028,13 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
 }
 
 void LLNewAgentInventoryVariablePriceResponder::onApplicationLevelError(
-	const std::string& error_identifier)
+	const LLSD& error)
 {
-	mImpl->onApplicationLevelError(error_identifier);
+	mImpl->onApplicationLevelError(error);
 }
 
 void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 	S32 upload_price,
-	S32 resource_cost,
 	const std::string& confirmation_url)
 {
 	if ( 0 == upload_price ) 
@@ -998,7 +1055,6 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 		substitutions["PRICE"] = upload_price;
 
 		payload["confirmation_url"] = confirmation_url;
-		payload["expected_upload_price"] = upload_price;
 
 		// The creating of a new instrusive_ptr(this)
 		// creates a new boost::intrusive_ptr
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index adbf13519b8..04636d4977e 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -102,10 +102,9 @@ class LLNewAgentInventoryVariablePriceResponder :
 	void result(const LLSD& content);
 
 	virtual void onApplicationLevelError(
-		const std::string& error_identifier);
+		const LLSD& error);
 	virtual void showConfirmationDialog(
 		S32 upload_price,
-		S32 resource_cost,
 		const std::string& confirmation_url);
 
 private:
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 836ac79a87d..7b9494c02a4 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -964,60 +964,24 @@ void upload_done_callback(
 	}
 }
 
-LLAssetID upload_new_resource_prep(
-	const LLTransactionID &tid,
+static LLAssetID upload_new_resource_prep(
+	const LLTransactionID& tid,
 	LLAssetType::EType asset_type,
 	LLInventoryType::EType& inventory_type,
 	std::string& name,
 	const std::string& display_name,
 	std::string& description)
 {
-	if ( gDisconnected )
-	{
-		LLAssetID rv;
+	LLAssetID uuid = generate_asset_id_for_new_upload(tid);
 
-		rv.setNull();
-		return rv;
-	}
+	increase_new_upload_stats(asset_type);
 
-	LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID());
-	
-	if ( LLAssetType::AT_SOUND == asset_type )
-	{
-		LLViewerStats::getInstance()->incStat(
-			LLViewerStats::ST_UPLOAD_SOUND_COUNT );
-	}
-	else if ( LLAssetType::AT_TEXTURE == asset_type )
-	{
-		LLViewerStats::getInstance()->incStat(
-			LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
-	}
-	else if ( LLAssetType::AT_ANIMATION == asset_type )
-	{
-		LLViewerStats::getInstance()->incStat(
-			LLViewerStats::ST_UPLOAD_ANIM_COUNT );
-	}
-
-	if ( LLInventoryType::IT_NONE == inventory_type )
-	{
-		inventory_type = LLInventoryType::defaultForAssetType(asset_type);
-	}
-	LLStringUtil::stripNonprintable(name);
-	LLStringUtil::stripNonprintable(description);
-
-	if ( name.empty() )
-	{
-		name = "(No Name)";
-	}
-	if ( description.empty() )
-	{
-		description = "(No Description)";
-	}
-
-	// At this point, we're ready for the upload.
-	std::string upload_message = "Uploading...\n\n";
-	upload_message.append(display_name);
-	LLUploadDialog::modalUploadDialog(upload_message);
+	assign_defaults_and_show_upload_message(
+		asset_type,
+		inventory_type,
+		name,
+		display_name,
+		description);
 
 	return uuid;
 }
@@ -1146,27 +1110,27 @@ void upload_new_resource(
 		{
 			asset_callback = callback;
 		}
-		gAssetStorage->storeAssetData(data->mAssetInfo.mTransactionID, data->mAssetInfo.mType,
-										asset_callback,
-										(void*)data,
-										FALSE);
+		gAssetStorage->storeAssetData(
+			data->mAssetInfo.mTransactionID,
+			data->mAssetInfo.mType,
+			asset_callback,
+			(void*)data,
+			FALSE);
 	}
 }
 
-BOOL upload_new_variable_cost_resource(
+BOOL upload_new_variable_price_resource(
 	const LLTransactionID &tid, 
 	LLAssetType::EType asset_type,
 	std::string name,
 	std::string desc, 
-	S32 compression_info,
 	LLAssetType::EType destination_folder_type,
 	LLInventoryType::EType inv_type,
 	U32 next_owner_perms,
 	U32 group_perms,
 	U32 everyone_perms,
 	const std::string& display_name,
-	LLAssetStorage::LLStoreAssetCallback callback,
-	void *userdata)
+	const LLSD& asset_resources)
 {
 	LLAssetID uuid = 
 		upload_new_resource_prep(
@@ -1209,6 +1173,8 @@ BOOL upload_new_variable_cost_resource(
 			group_perms,
 			everyone_perms);
 
+		body["asset_resources"] = asset_resources;
+
 		LLHTTPClient::post(
 			url,
 			body,
@@ -1224,6 +1190,70 @@ BOOL upload_new_variable_cost_resource(
 	}
 }
 
+LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid)
+{
+	if ( gDisconnected )
+	{
+		LLAssetID rv;
+
+		rv.setNull();
+		return rv;
+	}
+
+	LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID());
+
+	return uuid;
+}
+
+void increase_new_upload_stats(LLAssetType::EType asset_type)
+{
+	if ( LLAssetType::AT_SOUND == asset_type )
+	{
+		LLViewerStats::getInstance()->incStat(
+			LLViewerStats::ST_UPLOAD_SOUND_COUNT );
+	}
+	else if ( LLAssetType::AT_TEXTURE == asset_type )
+	{
+		LLViewerStats::getInstance()->incStat(
+			LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
+	}
+	else if ( LLAssetType::AT_ANIMATION == asset_type )
+	{
+		LLViewerStats::getInstance()->incStat(
+			LLViewerStats::ST_UPLOAD_ANIM_COUNT );
+	}
+}
+
+void assign_defaults_and_show_upload_message(
+	LLAssetType::EType asset_type,
+	LLInventoryType::EType& inventory_type,
+	std::string& name,
+	const std::string& display_name,
+	std::string& description)
+{
+	if ( LLInventoryType::IT_NONE == inventory_type )
+	{
+		inventory_type = LLInventoryType::defaultForAssetType(asset_type);
+	}
+	LLStringUtil::stripNonprintable(name);
+	LLStringUtil::stripNonprintable(description);
+
+	if ( name.empty() )
+	{
+		name = "(No Name)";
+	}
+	if ( description.empty() )
+	{
+		description = "(No Description)";
+	}
+
+	// At this point, we're ready for the upload.
+	std::string upload_message = "Uploading...\n\n";
+	upload_message.append(display_name);
+	LLUploadDialog::modalUploadDialog(upload_message);
+}
+
+
 void init_menu_file()
 {
 	view_listener_t::addCommit(new LLFileUploadImage(), "File.UploadImage");
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index b51192b499f..858fcd51deb 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -77,20 +77,26 @@ void upload_new_resource(
 // used
 
 // We make a new function here to ensure that previous code is not broken
-BOOL upload_new_variable_cost_resource(
-	const LLTransactionID &tid, 
+BOOL upload_new_variable_price_resource(
+	const LLTransactionID& tid, 
 	LLAssetType::EType type,
 	std::string name,
 	std::string desc, 
-	S32 compression_info,
 	LLAssetType::EType destination_folder_type,
 	LLInventoryType::EType inv_type,
 	U32 next_owner_perms,
 	U32 group_perms,
 	U32 everyone_perms,
 	const std::string& display_name,
-	LLAssetStorage::LLStoreAssetCallback callback,
-	void *userdata);
+	const LLSD& asset_resources);
 
+LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid);
+void increase_new_upload_stats(LLAssetType::EType asset_type);
+void assign_defaults_and_show_upload_message(
+	LLAssetType::EType asset_type,
+	LLInventoryType::EType& inventory_type,
+	std::string& name,
+	const std::string& display_name,
+	std::string& description);
 
 #endif
-- 
GitLab


From e8eb8a86a69c7ba345dafbadb6aa72fc5bba090e Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Tue, 3 Nov 2009 17:22:01 -0800
Subject: [PATCH 004/683] Quick fix to get collada working.  Will need to make
 collada and boost happier.

---
 install.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/install.xml b/install.xml
index cb477701b72..2f22ba5c0d4 100644
--- a/install.xml
+++ b/install.xml
@@ -280,9 +280,9 @@
           <key>windows</key>
           <map>
             <key>md5sum</key>
-            <string>fd3e5dade35c586ae13a320ab731df0d</string>
+            <string>c239ce23ed3f0dbbe58a1ddba05aee0b</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-windows-20090908.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-windows-20091103.tar.bz2</uri>
           </map>
         </map>
       </map>
-- 
GitLab


From c3bb2669ce30681449f7fe68f0822878565c273f Mon Sep 17 00:00:00 2001
From: "palmer@sansome-guest-196.lindenlab.com"
 <palmer@sansome-guest-196.lindenlab.com>
Date: Tue, 3 Nov 2009 17:43:47 -0800
Subject: [PATCH 005/683] fix to make build run on mac

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

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index e7afe0ecba8..5c0e6399472 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -208,7 +208,7 @@ if (LINUX OR DARWIN)
     set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
   endif (NOT GCC_DISABLE_FATAL_WARNINGS)
 
-  set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor -Woverloaded-virtual")
+  set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor")
 
   set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}")
   set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
-- 
GitLab


From 88292104d9a2332e6169f2add8f0b590bb22dbff Mon Sep 17 00:00:00 2001
From: David Parks <davep@lindenlab.com>
Date: Wed, 4 Nov 2009 14:19:05 +0000
Subject: [PATCH 006/683] Fix for crash when loading some meshes. Added button
 to auto-fill LODs.

---
 indra/llmath/llvolume.cpp  | 4 +++-
 indra/newview/pipeline.cpp | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index afa82ed3995..ddd1b4b3db0 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1690,9 +1690,11 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 
 	mGenerateSingleFace = generate_single_face;
 
-	generate();
+	mLODScaleBias.setVec(1,1,1);
+
 	if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
 	{
+		generate();
 		createVolumeFaces();
 	}
 }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 7cf5cf75ad2..4fc94c08bc2 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8988,6 +8988,7 @@ void LLPipeline::LLMeshThread::run()
 		{
 			LLVolumeParams volume_params;
 			volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+			volume_params.setSculptID(mMeshID, LL_SCULPT_TYPE_MESH);
 			mVolume = new LLVolume(volume_params, mDetail);
 			mVolume->createVolumeFacesFromStream(buffer_stream);
 		}
-- 
GitLab


From 1c495c56c1011f4514d96b75cbcfb5a8256de78f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 5 Nov 2009 17:12:18 -0600
Subject: [PATCH 007/683] Fix for crash on teleport to mesh enabled region. Fix
 for flashing meshes on LOD switch.

---
 indra/llprimitive/llprimitive.cpp |  4 +++
 indra/newview/pipeline.cpp        | 47 +++++++++++++++++++++++++++----
 indra/newview/pipeline.h          |  2 +-
 3 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index da1cfc2074b..52265e7ad56 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -744,6 +744,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
 		return TRUE;
 	}
 	
+#if 0
 	U32 old_face_mask = mVolumep->mFaceMask;
 
 	S32 face_bit = 0;
@@ -941,6 +942,9 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
 			setTE(te_num, *(old_tes.getTexture(face_mapping[face_bit])));
 		}
 	}
+#else
+	setNumTEs(mVolumep->getNumFaces());
+#endif
 	return TRUE;
 }
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1a1d29ac324..4ac95fa939e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8902,33 +8902,68 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
 }
 
 
-void LLPipeline::loadMesh(LLVOVolume* volume, LLUUID mesh_id)
+void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 {
-
 	{
 		LLMutexLock lock(mMeshMutex);
 		//add volume to list of loading meshes
 		mesh_load_map::iterator iter = mLoadingMeshes.find(mesh_id);
 		if (iter != mLoadingMeshes.end())
 		{ //request pending for this mesh, append volume id to list
-			iter->second.insert(volume->getID());
+			iter->second.insert(vobj->getID());
 			return;
 		}
 
 		//first request for this mesh
-		mLoadingMeshes[mesh_id].insert(volume->getID());
+		mLoadingMeshes[mesh_id].insert(vobj->getID());
 	}
 
 	if (gAssetStorage->hasLocalAsset(mesh_id, LLAssetType::AT_MESH))
 	{ //already have asset, load desired LOD in background
-		mPendingMeshes.push_back(new LLMeshThread(mesh_id, volume->getVolume()));
+		mPendingMeshes.push_back(new LLMeshThread(mesh_id, vobj->getVolume()));
 	}
 	else
 	{ //fetch asset and load when done
 		gAssetStorage->getAssetData(mesh_id, LLAssetType::AT_MESH,
-									getMeshAssetCallback, volume->getVolume(), TRUE);
+									getMeshAssetCallback, vobj->getVolume(), TRUE);
 	}
 
+	//do a quick search to see if we can't display something while we wait for this mesh to load
+	LLVolume* volume = vobj->getVolume();
+
+	if (volume)
+	{
+		LLVolumeParams params = volume->getParams();
+
+		LLVolumeLODGroup* group = LLPrimitive::getVolumeManager()->getGroup(params);
+
+		if (group)
+		{
+			//first see what the next lowest LOD available might be
+			for (S32 i = detail-1; i >= 0; --i)
+			{
+				LLVolume* lod = group->refLOD(i);
+				if (lod && lod->getNumVolumeFaces() > 0)
+				{
+					volume->copyVolumeFaces(lod);
+					group->derefLOD(lod);
+					return;
+				}
+			}
+
+			//no lower LOD is a available, is a higher lod available?
+			for (S32 i = detail+1; i < 4; ++i)
+			{
+				LLVolume* lod = group->refLOD(i);
+				if (lod && lod->getNumVolumeFaces() > 0)
+				{
+					volume->copyVolumeFaces(lod);
+					group->derefLOD(lod);
+					return;
+				}
+			}
+		}
+	}
 }
 
 //static
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index bf654f88b15..3300f866e3f 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -280,7 +280,7 @@ class LLPipeline
 	
 
 	//mesh management functions
-	void loadMesh(LLVOVolume* volume, LLUUID mesh_id);
+	void loadMesh(LLVOVolume* volume, LLUUID mesh_id, S32 detail = 0);
 	
 	void addTrianglesDrawn(S32 count);
 	BOOL hasRenderType(const U32 type) const				{ return (type && (mRenderTypeMask & (1<<type))) ? TRUE : FALSE; }
-- 
GitLab


From 10069e0e13e3214ba9320fdce915440b2e12f938 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 5 Nov 2009 19:58:10 -0600
Subject: [PATCH 008/683] Fix for prims all being 0 lod. Fix for dangling prim
 references.

---
 indra/llmath/llvolume.cpp         | 3 ++-
 indra/llprimitive/llprimitive.cpp | 8 +++++++-
 indra/newview/llvovolume.cpp      | 2 +-
 indra/newview/pipeline.cpp        | 2 ++
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index ddd1b4b3db0..33a8d33ce10 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1692,9 +1692,10 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 
 	mLODScaleBias.setVec(1,1,1);
 
+	generate();
+
 	if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
 	{
-		generate();
 		createVolumeFaces();
 	}
 }
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index 52265e7ad56..340f60ed1ae 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -744,7 +744,10 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
 		return TRUE;
 	}
 	
-#if 0
+#if 0 
+	// #if 0'd out by davep
+	// this is a lot of cruft to set texture entry values that just stay the same for LOD switch 
+	// or immediately get overridden by an object update message, also crashes occasionally
 	U32 old_face_mask = mVolumep->mFaceMask;
 
 	S32 face_bit = 0;
@@ -943,6 +946,9 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
 		}
 	}
 #else
+	// build the new object
+	sVolumeManager->unrefVolume(mVolumep);
+	mVolumep = volumep;
 	setNumTEs(mVolumep->getNumFaces());
 #endif
 	return TRUE;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 78fd3710875..7666009a62d 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -919,7 +919,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 				{
 					//mesh is not loaded, request pipeline load this mesh
 					LLUUID asset_id = volume_params.getSculptID();
-					gPipeline.loadMesh(this, asset_id);
+					gPipeline.loadMesh(this, asset_id, detail);
 				}
 				else
 				{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 4ac95fa939e..3554ceb7f09 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8949,6 +8949,7 @@ void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 					group->derefLOD(lod);
 					return;
 				}
+				group->derefLOD(lod);
 			}
 
 			//no lower LOD is a available, is a higher lod available?
@@ -8961,6 +8962,7 @@ void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 					group->derefLOD(lod);
 					return;
 				}
+				group->derefLOD(lod);
 			}
 		}
 	}
-- 
GitLab


From 4e420a36c67e611cd7d85652b43d9cd65315e563 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 7 Nov 2009 08:22:39 -0600
Subject: [PATCH 009/683] Fix for missing LOD spam.

---
 indra/llmath/llvolume.cpp         | 21 +++++++++++++++------
 indra/llprimitive/llprimitive.cpp |  3 ++-
 indra/newview/pipeline.cpp        |  2 ++
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 33a8d33ce10..c8ef911cc1d 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1676,7 +1676,8 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 	mFaceMask = 0x0;
 	mDetail = detail;
 	mSculptLevel = -2;
-	
+	mLODScaleBias.setVec(1,1,1);
+
 	// set defaults
 	if (mParams.getPathParams().getCurveType() == LL_PCODE_PATH_FLEXIBLE)
 	{
@@ -1690,8 +1691,6 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 
 	mGenerateSingleFace = generate_single_face;
 
-	mLODScaleBias.setVec(1,1,1);
-
 	generate();
 
 	if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
@@ -1899,7 +1898,7 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 	{
 		if (!LLSDSerialize::deserialize(header, is, 1024*1024*1024))
 		{
-			llwarns << "not a valid mesh asset!" << llendl;
+			llwarns << "Mesh header parse error.  Not a valid mesh asset!" << llendl;
 			return FALSE;
 		}
 	}
@@ -1921,8 +1920,18 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 
 	if (lod >= 4)
 	{
-		llwarns << "Couldn't load model for given lod" << llendl;
-		return FALSE;
+		lod = llclamp((S32) mDetail, 0, 3);
+
+		while (lod >= 0 && header[nm[lod]]["offset"].asInteger() == -1)
+		{
+			--lod;
+		}
+
+		if (lod < 0)
+		{
+			llwarns << "Mesh header missing LOD offsets.  Not a valid mesh asset!" << llendl;
+			return FALSE;
+		}
 	}
 
 	is.seekg(header[nm[lod]]["offset"].asInteger(), std::ios_base::cur);
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index 340f60ed1ae..4c6d244f3c2 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -948,7 +948,8 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
 #else
 	// build the new object
 	sVolumeManager->unrefVolume(mVolumep);
-	mVolumep = volumep;
+	mVolumep = volumep; 
+
 	setNumTEs(mVolumep->getNumFaces());
 #endif
 	return TRUE;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 3554ceb7f09..f13bb73acfe 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8949,6 +8949,7 @@ void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 					group->derefLOD(lod);
 					return;
 				}
+
 				group->derefLOD(lod);
 			}
 
@@ -8962,6 +8963,7 @@ void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 					group->derefLOD(lod);
 					return;
 				}
+
 				group->derefLOD(lod);
 			}
 		}
-- 
GitLab


From 7fa698252060a72be6b5ebc52f0ff01bcea6134c Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Mon, 9 Nov 2009 17:57:21 -0600
Subject: [PATCH 010/683] super importer stuff (gui, texture upload, etc.)

---
 indra/newview/llassetuploadresponders.cpp     |  3 ++
 indra/newview/llfilepicker.cpp                | 23 +++++++++++
 indra/newview/llfilepicker.h                  |  1 +
 indra/newview/llviewerfloaterreg.cpp          |  2 +
 indra/newview/llviewermenufile.cpp            | 41 +++++++++++++------
 indra/newview/llviewermenufile.h              |  2 +-
 .../default/xui/en/floater_inventory.xml      | 10 +++++
 7 files changed, 69 insertions(+), 13 deletions(-)

diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 680d1acd819..2da40ba4b5a 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -42,6 +42,7 @@
 #include "llnotify.h"
 #include "llinventorymodel.h"
 #include "llfloaterinventory.h"
+#include "llfloaterimportcollada.h"
 #include "llpermissionsflags.h"
 #include "llpreviewnotecard.h"
 #include "llpreviewscript.h"
@@ -414,6 +415,8 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 			LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(),
 			userdata);
 	}
+
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE);
 }
 
 LLSendTexLayerResponder::LLSendTexLayerResponder(const LLSD& post_data,
diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index e12db901bd6..8dfb3335306 100644
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -55,6 +55,7 @@ LLFilePicker LLFilePicker::sInstance;
 #define SOUND_FILTER L"Sounds (*.wav)\0*.wav\0"
 #define IMAGE_FILTER L"Images (*.tga; *.bmp; *.jpg; *.jpeg; *.png)\0*.tga;*.bmp;*.jpg;*.jpeg;*.png\0"
 #define ANIM_FILTER L"Animations (*.bvh)\0*.bvh\0"
+#define COLLADA_FILTER L"Scene (*.dae)\0*.dae\0"
 #ifdef _CORY_TESTING
 #define GEOMETRY_FILTER L"SL Geometry (*.slg)\0*.slg\0"
 #endif
@@ -176,6 +177,10 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)
 		mOFN.lpstrFilter = ANIM_FILTER \
 			L"\0";
 		break;
+	case FFLOAD_COLLADA:
+		mOFN.lpstrFilter = COLLADA_FILTER \
+			L"\0";
+		break;
 #ifdef _CORY_TESTING
 	case FFLOAD_GEOMETRY:
 		mOFN.lpstrFilter = GEOMETRY_FILTER \
@@ -547,6 +552,15 @@ Boolean LLFilePicker::navOpenFilterProc(AEDesc *theItem, void *info, void *callB
 								result = false;
 							}
 						}
+						else if (filter == FFLOAD_COLLADA)
+						{
+							if (fileInfo.filetype != 'DAE ' && 
+								(fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("dae"), kCFCompareCaseInsensitive) != kCFCompareEqualTo))
+							)
+							{
+								result = false;
+							}
+						}
 #ifdef _CORY_TESTING
 						else if (filter == FFLOAD_GEOMETRY)
 						{
@@ -1093,6 +1107,12 @@ static std::string add_bvh_filter_to_gtkchooser(GtkWindow *picker)
 						       LLTrans::getString("animation_files") + " (*.bvh)");
 }
 
+static std::string add_collada_filter_to_gtkchooser(GtkWindow *picker)
+{
+	return add_simple_pattern_filter_to_gtkchooser(picker,  "*.dae",
+						       LLTrans::getString("scene_files") + " (*.dae)");
+}
+
 static std::string add_imageload_filter_to_gtkchooser(GtkWindow *picker)
 {
 	GtkFileFilter *gfilter = gtk_file_filter_new();
@@ -1217,6 +1237,9 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter )
 		case FFLOAD_ANIM:
 			filtername = add_bvh_filter_to_gtkchooser(picker);
 			break;
+		case FFLOAD_COLLADA:
+			filtername = add_collada_filter_to_gtkchooser(picker);
+			break;
 		case FFLOAD_IMAGE:
 			filtername = add_imageload_filter_to_gtkchooser(picker);
 			break;
diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h
index 7600922e9c0..10736c7dd06 100644
--- a/indra/newview/llfilepicker.h
+++ b/indra/newview/llfilepicker.h
@@ -94,6 +94,7 @@ class LLFilePicker
 		FFLOAD_SLOBJECT = 7,
 		FFLOAD_RAW = 8,
 		FFLOAD_MODEL = 9,
+		FFLOAD_COLLADA = 10,
 	};
 
 	enum ESaveFilter
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 4ff1e6c7032..f3bf6b70a36 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -73,6 +73,7 @@
 #include "llimpanel.h"
 #include "llfloaterinspect.h"
 #include "llfloaterinventory.h"
+#include "llfloaterimportcollada.h"
 #include "llfloaterjoystick.h"
 #include "llfloaterlagmeter.h"
 #include "llfloaterland.h"
@@ -172,6 +173,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("hud", "floater_hud.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHUD>);
 
 	LLFloaterReg::add("impanel", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMFloater>);
+	LLFloaterReg::add("import_collada", "floater_import_collada.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImportCollada>);
 	LLFloaterReg::add("inventory", "floater_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInventory>);
 	LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>);
 	LLInspectAvatarUtil::registerFloater();
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 7b9494c02a4..53067c5c930 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -39,6 +39,7 @@
 #include "llfilepicker.h"
 #include "llfloaterreg.h"
 #include "llfloaterbuycurrency.h"
+#include "llfloaterimportcollada.h"
 #include "llfloatermodelpreview.h"
 #include "llfloatersnapshot.h"
 #include "llinventorymodel.h"	// gInventory
@@ -56,7 +57,7 @@
 #include "llappviewer.h"
 #include "lluploaddialog.h"
 #include "lltrans.h"
-
+#include "llfloaterimportcollada.h"
 
 // linden libraries
 #include "llassetuploadresponders.h"
@@ -263,6 +264,19 @@ class LLFileUploadImage : public view_listener_t
 	}
 };
 
+class LLFileUploadScene : public view_listener_t
+{
+	bool handleEvent(const LLSD& userdata)
+	{
+		std::string filename = upload_pick((void *)LLFilePicker::FFLOAD_COLLADA);
+		if (!filename.empty())
+		{
+			LLImportCollada::getInstance()->importFile(filename);
+		}
+		return TRUE;
+	}
+};
+
 class LLFileUploadModel : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
@@ -517,7 +531,7 @@ void handle_compress_image(void*)
 	}
 }
 
-void upload_new_resource(
+LLUUID upload_new_resource(
 	const std::string& src_filename,
 	std::string name,
 	std::string desc,
@@ -555,7 +569,7 @@ void upload_new_resource(
 				short_name.c_str());
 		args["FILE"] = short_name;
  		upload_error(error_message, "NofileExtension", filename, args);
-		return;
+		return LLUUID();
 	}
 	else if( exten == "bmp")
 	{
@@ -569,7 +583,7 @@ void upload_new_resource(
 			args["FILE"] = src_filename;
 			args["ERROR"] = LLImage::getLastError();
 			upload_error(error_message, "ProblemWithFile", filename, args);
-			return;
+			return LLUUID();
 		}
 	}
 	else if( exten == "tga")
@@ -584,7 +598,7 @@ void upload_new_resource(
 			args["FILE"] = src_filename;
 			args["ERROR"] = LLImage::getLastError();
 			upload_error(error_message, "ProblemWithFile", filename, args);
-			return;
+			return LLUUID();
 		}
 	}
 	else if( exten == "jpg" || exten == "jpeg")
@@ -599,7 +613,7 @@ void upload_new_resource(
 			args["FILE"] = src_filename;
 			args["ERROR"] = LLImage::getLastError();
 			upload_error(error_message, "ProblemWithFile", filename, args);
-			return;
+			return LLUUID();
 		}
 	}
  	else if( exten == "png")
@@ -614,7 +628,7 @@ void upload_new_resource(
  			args["FILE"] = src_filename;
  			args["ERROR"] = LLImage::getLastError();
  			upload_error(error_message, "ProblemWithFile", filename, args);
- 			return;
+ 			return LLUUID();
  		}
  	}
 	else if(exten == "wav")
@@ -642,7 +656,7 @@ void upload_new_resource(
 					upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args);
 					break;	
 			}	
-			return;
+			return LLUUID();
 		}
 	}
 	else if(exten == "tmp")	 	
@@ -682,7 +696,7 @@ void upload_new_resource(
                                                  error_message = llformat("corrupt resource file: %s", src_filename.c_str());
 												 args["FILE"] = src_filename;
 												 upload_error(error_message, "CorruptResourceFile", filename, args);
-                                                 return;
+                                                 return LLUUID();
                                          }	 	
 
                                          if (2 == tokens_read)	 	
@@ -710,7 +724,7 @@ void upload_new_resource(
                                  error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str());
 								 args["FILE"] = src_filename;
 								 upload_error(error_message, "UnknownResourceFileVersion", filename, args);
-                                 return;
+                                 return LLUUID();
                          }	 	
                  }	 	
                  else	 	
@@ -752,7 +766,7 @@ void upload_new_resource(
                          error_message = llformat( "Unable to create output file: %s", filename.c_str());
 						 args["FILE"] = filename;
 						 upload_error(error_message, "UnableToCreateOutputFile", filename, args);
-                         return;
+                         return LLUUID();
                  }	 	
 
                  fclose(in);	 	
@@ -766,7 +780,7 @@ void upload_new_resource(
 	{
 		error_message = llformat("We do not currently support bulk upload of animation files\n");
 		upload_error(error_message, "DoNotSupportBulkAnimationUpload", filename, args);
-		return;
+		return LLUUID();
 	}
 	else
 	{
@@ -840,6 +854,8 @@ void upload_new_resource(
 		}
 		LLFilePicker::instance().reset();
 	}
+
+	return uuid;
 }
 
 void upload_done_callback(
@@ -1260,6 +1276,7 @@ void init_menu_file()
 	view_listener_t::addCommit(new LLFileUploadSound(), "File.UploadSound");
 	view_listener_t::addCommit(new LLFileUploadAnim(), "File.UploadAnim");
 	view_listener_t::addCommit(new LLFileUploadModel(), "File.UploadModel");
+	view_listener_t::addCommit(new LLFileUploadScene(), "File.UploadScene");
 	view_listener_t::addCommit(new LLFileUploadBulk(), "File.UploadBulk");
 	view_listener_t::addCommit(new LLFileCloseWindow(), "File.CloseWindow");
 	view_listener_t::addCommit(new LLFileCloseAllWindows(), "File.CloseAllWindows");
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 858fcd51deb..25469e0168d 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -41,7 +41,7 @@ class LLTransactionID;
 
 void init_menu_file();
 
-void upload_new_resource(
+LLUUID upload_new_resource(
 	const std::string& src_filename, 
 	std::string name,
 	std::string desc, 
diff --git a/indra/newview/skins/default/xui/en/floater_inventory.xml b/indra/newview/skins/default/xui/en/floater_inventory.xml
index c7fcacab8bc..5e324f1c6ec 100644
--- a/indra/newview/skins/default/xui/en/floater_inventory.xml
+++ b/indra/newview/skins/default/xui/en/floater_inventory.xml
@@ -135,6 +135,16 @@
                  parameter="" />
                 <menu_item_call.on_enable
                  function="File.EnableUpload" />
+              </menu_item_call>
+              <menu_item_call
+                 label="Scene..."
+                 layout="topleft"
+                 name="Upload Scene">
+                <menu_item_call.on_click
+                 function="File.UploadScene"
+                 parameter="" />
+                <menu_item_call.on_enable
+                 function="File.EnableUpload" />
               </menu_item_call>
                 <menu_item_call
                  label="Animation (L$[COST])..."
-- 
GitLab


From 41f48a16a9e4279eb7805f0ed725b0147305c6ba Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 12 Nov 2009 15:02:08 +0000
Subject: [PATCH 011/683] newlineorama.

---
 indra/llui/lluictrlfactory.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index 8ab015f2bb8..0d1c486a4b7 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -454,4 +454,5 @@ const std::string* LLUICtrlFactory::getWidgetTag(const std::type_info* widget_ty
 void LLUICtrlFactory::connect(LLView* parent, LLView* child)
 {
 	parent->addChild(child);
-}
\ No newline at end of file
+}
+
-- 
GitLab


From 842bf4d7bb7618f34522e9ee8817b7978229d692 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Thu, 12 Nov 2009 10:57:39 -0800
Subject: [PATCH 012/683] ignoring .orig files

---
 .hgignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.hgignore b/.hgignore
index 4d98acf5d97..1d4890810f9 100644
--- a/.hgignore
+++ b/.hgignore
@@ -9,6 +9,7 @@ syntax: glob
 .*.swp
 #OSX image cache file
 *.DS_Store
+*.orig
 LICENSES
 indra/.distcc
 indra/build-darwin-*
-- 
GitLab


From 596d3cfb6018789e3ffca5bf3ae9fa4e1e8a707a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 12 Nov 2009 13:23:48 -0600
Subject: [PATCH 013/683] CTS-15 Force loading of high LOD when opening model
 import floater. CTS-9 Auto-fill description field with

---
 indra/newview/llviewermenufile.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 505d2afb69a..2ce37612b28 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -281,7 +281,11 @@ class LLFileUploadModel : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
-		LLFloaterReg::showInstance("upload_model");
+		LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) LLFloaterReg::showInstance("upload_model");
+		if (fmp)
+		{
+			fmp->loadModel(3);
+		}
 		
 		return TRUE;
 	}
-- 
GitLab


From bb72788392ea6d25adb045abd555419cd60c4888 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Thu, 12 Nov 2009 14:05:01 -0800
Subject: [PATCH 014/683] Fixes for mesh inventory type correctness.

---
 indra/llinventory/llinventorytype.cpp  | 28 +++++++++++++++++++++++++-
 indra/newview/llinventoryfunctions.cpp |  3 +++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp
index 2460a2777a8..caf8e119299 100644
--- a/indra/llinventory/llinventorytype.cpp
+++ b/indra/llinventory/llinventorytype.cpp
@@ -125,7 +125,33 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
 
 	LLInventoryType::IT_NONE,			// AT_LINK
 	LLInventoryType::IT_NONE,			// AT_LINK_FOLDER
-	LLInventoryType::IT_MESH,           // AT_MESH
+
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	LLInventoryType::IT_NONE,			// AT_NONE
+	
+	LLInventoryType::IT_MESH            // AT_MESH
 };
 
 // static
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 75218e98e0a..01c7f0974d1 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -323,6 +323,9 @@ const std::string& get_item_icon_name(LLAssetType::EType asset_type,
 	case LLAssetType::AT_LINK_FOLDER:
 		idx = LINKFOLDER_ICON_NAME;
 		break;
+	case LLAssetType::AT_MESH:
+		idx = MESH_ICON_NAME;
+		break;
 	default:
 		break;
 	}
-- 
GitLab


From 0c50236a944898502405a31aa1f0b6ae61ae38ae Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 13 Nov 2009 08:59:12 -0600
Subject: [PATCH 015/683] CTS-26 Fix for LOD generation always using first file
 specified.

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

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index db4189dfea9..6e77bb2aab4 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -566,7 +566,7 @@ void LLVertexBuffer::destroyGLBuffer()
 	}
 	
 	mGLBuffer = 0;
-	unbind();
+	//unbind();
 }
 
 void LLVertexBuffer::destroyGLIndices()
@@ -593,7 +593,7 @@ void LLVertexBuffer::destroyGLIndices()
 	}
 
 	mGLIndices = 0;
-	unbind();
+	//unbind();
 }
 
 void LLVertexBuffer::updateNumVerts(S32 nverts)
-- 
GitLab


From c02702f3871979cb7745b49aa502ac3c71f77681 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 13 Nov 2009 17:01:56 -0600
Subject: [PATCH 016/683] CTS-7 Add hard edge threshold capability to normal
 generation.

---
 indra/llmath/llvolume.cpp | 12 ++++++++++++
 indra/llmath/llvolume.h   |  1 +
 2 files changed, 13 insertions(+)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 6286d1bcea2..f252b2a2327 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1876,6 +1876,18 @@ bool LLVolumeFace::VertexData::operator==(const LLVolumeFace::VertexData& rhs)co
 	return true;
 }
 
+bool LLVolumeFace::VertexData::compareNormal(const LLVolumeFace::VertexData& rhs, F32 angle_cutoff) const
+{
+	bool retval = false;
+	if (rhs.mPosition == mPosition && rhs.mTexCoord == mTexCoord)
+	{
+		F32 cur_angle = rhs.mNormal*mNormal;
+		
+		retval = cur_angle > angle_cutoff;
+	}
+
+	return retval;
+}
 
 BOOL LLVolume::createVolumeFacesFromFile(const std::string& file_name)
 {
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 9f595ccbc4a..d2727d8f21c 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -814,6 +814,7 @@ class LLVolumeFace
 
 		bool operator<(const VertexData& rhs) const;
 		bool operator==(const VertexData& rhs) const;
+		bool compareNormal(const VertexData& rhs, F32 angle_cutoff) const;
 	};
 
 	enum
-- 
GitLab


From a056423e62ad8525919526abb95e8b23f0681064 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Tue, 17 Nov 2009 13:42:19 -0800
Subject: [PATCH 017/683] Merge of latest viewer 2 changes

---
 indra/newview/llviewerwindow.cpp | 134 -------------------------------
 1 file changed, 134 deletions(-)

diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 7b35125b5b8..a1539e24a4c 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -3704,140 +3704,6 @@ void LLViewerWindow::playSnapshotAnimAndSound()
 BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type)
 {
 	return rawSnapshot(raw, preview_width, preview_height, FALSE, FALSE, show_ui, do_rebuild, type);
-	
-	// *TODO below code was broken in deferred pipeline
-	/*
-	if ((!raw) || preview_width < 10 || preview_height < 10)
-	{
-		return FALSE;
-	}
-
-	if(gResizeScreenTexture) //the window is resizing
-	{
-		return FALSE ;
-	}
-
-	setCursor(UI_CURSOR_WAIT);
-
-	// Hide all the UI widgets first and draw a frame
-	BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI);
-
-	if ( prev_draw_ui != show_ui)
-	{
-		LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI);
-	}
-
-	BOOL hide_hud = !gSavedSettings.getBOOL("RenderHUDInSnapshot") && LLPipeline::sShowHUDAttachments;
-	if (hide_hud)
-	{
-		LLPipeline::sShowHUDAttachments = FALSE;
-	}
-
-	S32 render_name = gSavedSettings.getS32("RenderName");
-	gSavedSettings.setS32("RenderName", 0);
-	LLVOAvatar::updateFreezeCounter(1) ; //pause avatar updating for one frame
-	
-	S32 w = preview_width ;
-	S32 h = preview_height ;
-	LLVector2 display_scale = mDisplayScale ;
-	mDisplayScale.setVec((F32)w / mWindowRectRaw.getWidth(), (F32)h / mWindowRectRaw.getHeight()) ;
-	LLRect window_rect = mWindowRectRaw;
-	mWindowRectRaw.set(0, h, w, 0);
-	
-	gDisplaySwapBuffers = FALSE;
-	gDepthDirty = TRUE;
-	glClearColor(0.f, 0.f, 0.f, 0.f);
-	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-	setup3DRender();
-
-	LLFontGL::setFontDisplay(FALSE) ;
-	LLHUDText::setDisplayText(FALSE) ;
-	if (type == SNAPSHOT_TYPE_OBJECT_ID)
-	{
-		gObjectList.renderPickList(gViewerWindow->getWindowRectScaled(), FALSE, FALSE);
-	}
-	else
-	{
-		display(do_rebuild, 1.0f, 0, TRUE);
-		render_ui();
-	}
-
-	S32 glformat, gltype, glpixel_length ;
-	if(SNAPSHOT_TYPE_DEPTH == type)
-	{
-		glpixel_length = 4 ;
-		glformat = GL_DEPTH_COMPONENT ; 
-		gltype = GL_FLOAT ;
-	}
-	else
-	{
-		glpixel_length = 3 ;
-		glformat = GL_RGB ;
-		gltype = GL_UNSIGNED_BYTE ;
-	}
-
-	raw->resize(w, h, glpixel_length);
-	glReadPixels(0, 0, w, h, glformat, gltype, raw->getData());
-
-	if(SNAPSHOT_TYPE_DEPTH == type)
-	{
-		LLViewerCamera* camerap = LLViewerCamera::getInstance();
-		F32 depth_conversion_factor_1 = (camerap->getFar() + camerap->getNear()) / (2.f * camerap->getFar() * camerap->getNear());
-		F32 depth_conversion_factor_2 = (camerap->getFar() - camerap->getNear()) / (2.f * camerap->getFar() * camerap->getNear());
-
-		//calculate the depth 
-		for (S32 y = 0 ; y < h ; y++)
-		{
-			for(S32 x = 0 ; x < w ; x++)
-			{
-				S32 i = (w * y + x) << 2 ;
-				
-				F32 depth_float_i = *(F32*)(raw->getData() + i);
-				
-				F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float_i * depth_conversion_factor_2));
-				U8 depth_byte = F32_to_U8(linear_depth_float, camerap->getNear(), camerap->getFar());
-				*(raw->getData() + i + 0) = depth_byte;
-				*(raw->getData() + i + 1) = depth_byte;
-				*(raw->getData() + i + 2) = depth_byte;
-				*(raw->getData() + i + 3) = 255;
-			}
-		}		
-	}
-
-	LLFontGL::setFontDisplay(TRUE) ;
-	LLHUDText::setDisplayText(TRUE) ;
-	mDisplayScale.setVec(display_scale) ;
-	mWindowRectRaw = window_rect;	
-	setup3DRender();
-	gDisplaySwapBuffers = FALSE;
-	gDepthDirty = TRUE;
-
-	// POST SNAPSHOT
-	if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
-	{
-		LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI);
-	}
-
-	if (hide_hud)
-	{
-		LLPipeline::sShowHUDAttachments = TRUE;
-	}
-
-	setCursor(UI_CURSOR_ARROW);
-
-	if (do_rebuild)
-	{
-		// If we had to do a rebuild, that means that the lists of drawables to be rendered
-		// was empty before we started.
-		// Need to reset these, otherwise we call state sort on it again when render gets called the next time
-		// and we stand a good chance of crashing on rebuild because the render drawable arrays have multiple copies of
-		// objects on them.
-		gPipeline.resetDrawOrders();
-	}
-	
-	gSavedSettings.setS32("RenderName", render_name);	
-	
-	return TRUE;*/
 }
 
 // Saves the image from the screen to the specified filename and path.
-- 
GitLab


From 1f71cd20e831983aa5f4682958a3619b9f37a6f1 Mon Sep 17 00:00:00 2001
From: "Jonathan@Chomp.lindenlab.com" <Jonathan@Chomp.lindenlab.com>
Date: Wed, 18 Nov 2009 11:38:31 -0800
Subject: [PATCH 018/683] Fixed variable price upload path.

---
 indra/newview/llassetuploadresponders.cpp | 98 ++++++++++++++++-------
 indra/newview/llassetuploadresponders.h   |  3 +
 indra/newview/llviewermenufile.cpp        |  7 +-
 3 files changed, 77 insertions(+), 31 deletions(-)

diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index f3dbe6fa31d..dddc6fef1c7 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -676,18 +676,32 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 public:
 	Impl(
 		const LLUUID& vfile_id,
+		LLAssetType::EType asset_type,
 		const LLSD& inventory_data) :
 		mVFileID(vfile_id),
-		mInventoryData(inventory_data)
+		mAssetType(asset_type),
+		mInventoryData(inventory_data),
+		mFileName("")
 	{
+		if (!gVFS->getExists(vfile_id, asset_type))
+		{
+			llwarns
+				<< "LLAssetUploadResponder called with nonexistant "
+				<< "vfile_id " << vfile_id << llendl;
+			mVFileID.setNull();
+			mAssetType = LLAssetType::AT_NONE;
+		}
 	}
 
 	Impl(
 		const std::string& file_name,
+		LLAssetType::EType asset_type,
 		const LLSD& inventory_data) :
 		mFileName(file_name),
+		mAssetType(asset_type),
 		mInventoryData(inventory_data)
 	{
+		mVFileID.setNull();
 	}
 
 	std::string getFilenameOrIDString() const
@@ -707,8 +721,7 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 
 	LLAssetType::EType getAssetType() const
 	{
-		return LLAssetType::lookup(
-			mInventoryData["asset_type"].asString());
+		return mAssetType;
 	}
 
 	LLInventoryType::EType getInventoryType() const
@@ -898,22 +911,7 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 		{
 		case 0:
 		    {
-				if ( getFilename().empty() )
-				{
-					// we have no filename, use virtual file ID instead
-					LLHTTPClient::postFile(
-						confirmation_url,
-						getVFileID(),
-						getAssetType(),
-						responder);
-				}
-				else
-				{
-					LLHTTPClient::postFile(
-						confirmation_url,
-						getFilename(),
-						responder);
-				}
+				confirmUpload(confirmation_url, responder);
 			}
 			break;
 		case 1:
@@ -923,11 +921,35 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 
 		return false;
 	}
-	
+
+	void confirmUpload(
+		const std::string& confirmation_url,
+		boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder> responder)
+	{
+		if ( getFilename().empty() )
+		{
+			// we have no filename, use virtual file ID instead
+			LLHTTPClient::postFile(
+				confirmation_url,
+				getVFileID(),
+				getAssetType(),
+				responder);
+		}
+		else
+		{
+			LLHTTPClient::postFile(
+				confirmation_url,
+				getFilename(),
+				responder);
+		}
+	}
+
+
 private:
 	std::string mFileName;
 
 	LLSD mInventoryData;
+	LLAssetType::EType mAssetType;
 	LLUUID mVFileID;
 };
 
@@ -936,19 +958,23 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 ///////////////////////////////////////////////
 LLNewAgentInventoryVariablePriceResponder::LLNewAgentInventoryVariablePriceResponder(
 	const LLUUID& vfile_id,
+	LLAssetType::EType asset_type,
 	const LLSD& inventory_info)
 {
 	mImpl = new Impl(
 		vfile_id,
+		asset_type,
 		inventory_info);
 }
 
 LLNewAgentInventoryVariablePriceResponder::LLNewAgentInventoryVariablePriceResponder(
 	const std::string& file_name,
+	LLAssetType::EType asset_type,
 	const LLSD& inventory_info)
 {
 	mImpl = new Impl(
 		file_name,
+		asset_type,
 		inventory_info);
 }
 
@@ -962,8 +988,9 @@ void LLNewAgentInventoryVariablePriceResponder::errorWithContent(
 	const std::string& reason,
 	const LLSD& content)
 {
-	llinfos << "LLNewAgentInventoryVariablePrice::error " << statusNum 
-			<< " reason: " << reason << llendl;
+	lldebugs 
+		<< "LLNewAgentInventoryVariablePrice::error " << statusNum 
+		<< " reason: " << reason << llendl;
 
 	if ( content.has("error") )
 	{
@@ -988,6 +1015,7 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
 	static const std::string _CONFIRM_UPLOAD = "confirm_upload";
 
 	static const std::string _UPLOAD_PRICE = "upload_price";
+	static const std::string _RESOURCE_COST = "resource_cost";
 	static const std::string _RSVP = "rsvp";
 
 	// Check for application level errors
@@ -1022,7 +1050,7 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
 			mImpl->getItemName(),
 			mImpl->getItemDescription(),
 			content,
-			content["upload_price"].asInteger());
+			content[_UPLOAD_PRICE].asInteger());
 
 		// TODO* Add bulk (serial) uploading or add
 		// a super class of this that does so
@@ -1031,6 +1059,7 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
 	{
 		showConfirmationDialog(
 			content[_UPLOAD_PRICE].asInteger(),
+			content[_RESOURCE_COST].asInteger(),
 			content[_RSVP].asString());
 	}
 	else
@@ -1047,17 +1076,30 @@ void LLNewAgentInventoryVariablePriceResponder::onApplicationLevelError(
 
 void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 	S32 upload_price,
+	S32 resource_cost,
 	const std::string& confirmation_url)
 {
-	if ( 0 == upload_price ) 
+	if ( 0 == upload_price )
 	{
 		// don't show confirmation dialog for free uploads, I mean,
 		// they're free!
-		LLSD body;
-		body["confirm_upload"] = true;
-		body["expected_upload_price"] = upload_price;
 
-		LLHTTPClient::post(confirmation_url, body, this);
+		// The creating of a new instrusive_ptr(this)
+		// creates a new boost::intrusive_ptr
+		// which is a copy of this.  This code is required because
+		// 'this' is always of type Class* and not the intrusive_ptr,
+		// and thus, a reference to 'this' is not registered
+		// by using just plain 'this'.
+
+		// Since LLNewAgentInventoryVariablePriceResponder is a
+		// reference counted class, it is possible (since the
+		// reference to a plain 'this' would be missed here) that,
+		// when using plain ol' 'this', that this object
+		// would be deleted before the callback is triggered
+		// and cause sadness.
+		mImpl->confirmUpload(
+			confirmation_url,
+			boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder>(this));
 	}
 	else
 	{
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index 9102f1597e8..929a7a5f74a 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -87,10 +87,12 @@ class LLNewAgentInventoryVariablePriceResponder :
 public:
 	LLNewAgentInventoryVariablePriceResponder(
 		const LLUUID& vfile_id,
+		LLAssetType::EType asset_type,
 		const LLSD& inventory_info);
 
 	LLNewAgentInventoryVariablePriceResponder(
 		const std::string& file_name,
+		LLAssetType::EType asset_type,
 		const LLSD& inventory_info);
 
 	virtual ~LLNewAgentInventoryVariablePriceResponder();
@@ -105,6 +107,7 @@ class LLNewAgentInventoryVariablePriceResponder :
 		const LLSD& error);
 	virtual void showConfirmationDialog(
 		S32 upload_price,
+		S32 resource_cost,
 		const std::string& confirmation_url);
 
 private:
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 8b101748a3d..2c0a41e1ff4 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -1175,9 +1175,9 @@ BOOL upload_new_variable_price_resource(
 
 	if ( !url.empty() )
 	{
-		llinfos << "New Agent Inventory variable price upload"
-				<< llendl;
-
+		lldebugs
+			<< "New Agent Inventory variable price upload" << llendl;
+		
 		// Each of the two capabilities has similar data, so
 		// let's reuse that code
 
@@ -1200,6 +1200,7 @@ BOOL upload_new_variable_price_resource(
 			body,
 			new LLNewAgentInventoryVariablePriceResponder(
 				uuid,
+				asset_type,
 				body));
 
 		return TRUE;
-- 
GitLab


From 81bfdcbfae4f203e60f00794966383b01475995b Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 18 Nov 2009 18:10:48 -0600
Subject: [PATCH 019/683] Tetrahedron displays in place of unloaded mesh. 
 Still has some LOD issues.

---
 indra/llmath/llvolume.cpp  | 96 +++++++++++++++++++++++++++++++++++++-
 indra/llmath/llvolume.h    |  1 +
 indra/newview/pipeline.cpp |  9 +++-
 3 files changed, 103 insertions(+), 3 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index f252b2a2327..84da1b3c62b 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1925,7 +1925,9 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 
 	S32 lod = llclamp((S32) mDetail, 0, 3);
 
-	while (lod < 4 && header[nm[lod]]["offset"].asInteger() == -1)
+	while (lod < 4 && 
+		(header[nm[lod]]["offset"].asInteger() == -1 || 
+		header[nm[lod]]["size"].asInteger() == 0 ))
 	{
 		++lod;
 	}
@@ -1934,7 +1936,9 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 	{
 		lod = llclamp((S32) mDetail, 0, 3);
 
-		while (lod >= 0 && header[nm[lod]]["offset"].asInteger() == -1)
+		while (lod >= 0 && 
+				(header[nm[lod]]["offset"].asInteger() == -1 ||
+				header[nm[lod]]["size"].asInteger() == 0) )
 		{
 			--lod;
 		}
@@ -2135,6 +2139,94 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 	return TRUE;
 }
 
+void tetrahedron_set_normal(LLVolumeFace::VertexData* cv)
+{
+	LLVector3 nrm = (cv[1].mPosition-cv[0].mPosition)%(cv[2].mPosition-cv[0].mPosition);
+
+	nrm.normVec();
+
+	cv[0].mNormal = nrm;
+	cv[1].mNormal = nrm;
+	cv[2].mNormal = nrm;
+}
+
+void LLVolume::makeTetrahedron()
+{
+	mVolumeFaces.clear();
+
+	LLVolumeFace face;
+
+	F32 x = 0.5f;
+	LLVector3 p[] = 
+	{ //unit tetrahedron corners
+		LLVector3(x,x,x),
+		LLVector3(-x,-x,x),
+		LLVector3(-x,x,-x),
+		LLVector3(x,-x,-x)
+	};
+
+	LLVolumeFace::VertexData cv[3];
+
+	//set texture coordinates
+	cv[0].mTexCoord = LLVector2(0,0);
+	cv[1].mTexCoord = LLVector2(1,0);
+	cv[2].mTexCoord = LLVector2(0.5f, 0.5f*F_SQRT3);
+
+
+	//side 1
+	cv[0].mPosition = p[1];
+	cv[1].mPosition = p[0];
+	cv[2].mPosition = p[2];
+
+	tetrahedron_set_normal(cv);
+
+	face.mVertices.push_back(cv[0]);
+	face.mVertices.push_back(cv[1]);
+	face.mVertices.push_back(cv[2]);
+	
+	//side 2
+	cv[0].mPosition = p[3];
+	cv[1].mPosition = p[0];
+	cv[2].mPosition = p[1];
+
+	tetrahedron_set_normal(cv);
+
+	face.mVertices.push_back(cv[0]);
+	face.mVertices.push_back(cv[1]);
+	face.mVertices.push_back(cv[2]);
+	
+	//side 3
+	cv[0].mPosition = p[3];
+	cv[1].mPosition = p[1];
+	cv[2].mPosition = p[2];
+
+	tetrahedron_set_normal(cv);
+
+	face.mVertices.push_back(cv[0]);
+	face.mVertices.push_back(cv[1]);
+	face.mVertices.push_back(cv[2]);
+	
+	//side 4
+	cv[0].mPosition = p[2];
+	cv[1].mPosition = p[0];
+	cv[2].mPosition = p[3];
+
+	tetrahedron_set_normal(cv);
+
+	face.mVertices.push_back(cv[0]);
+	face.mVertices.push_back(cv[1]);
+	face.mVertices.push_back(cv[2]);
+	
+	//set index buffer
+	for (U32 i = 0; i < 12; i++)
+	{
+		face.mIndices.push_back(i);
+	}
+	
+	mVolumeFaces.push_back(face);
+	mSculptLevel = 0;
+}
+
 void LLVolume::copyVolumeFaces(LLVolume* volume)
 {
 	mVolumeFaces = volume->mVolumeFaces;
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index d2727d8f21c..bf2854ede96 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -969,6 +969,7 @@ class LLVolume : public LLRefCount
 public:
 	virtual BOOL createVolumeFacesFromFile(const std::string& file_name);
 	virtual BOOL createVolumeFacesFromStream(std::istream& is);
+	virtual void makeTetrahedron();
 
  protected:
 	BOOL mUnique;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c262e94ff4d..3410ad6559e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8976,6 +8976,9 @@ void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 				group->derefLOD(lod);
 			}
 		}
+
+		//nothing found, so make a tetrahedron
+		volume->makeTetrahedron();
 	}
 }
 
@@ -9102,7 +9105,11 @@ void LLPipeline::notifyLoadedMeshes()
 
 			if (valid)
 			{
-				mesh->mTargetVolume->copyVolumeFaces(mesh->mVolume);
+				if (mesh->mVolume->getNumVolumeFaces() > 0)
+				{
+					mesh->mTargetVolume->copyVolumeFaces(mesh->mVolume);
+				}
+
 				for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
 				{
 					LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
-- 
GitLab


From 62233f22469cdc66042fc7bbbbd367dbb7212fde Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 24 Nov 2009 07:38:04 -0600
Subject: [PATCH 020/683] Fix for copying of tetrahedrons in place of mesh
 LODs. Fix for bad tetrahedron bounding box. Bad fix for simultaneous loading
 of multiple LODs.

---
 indra/llmath/llvolume.cpp    | 31 ++++++++++++++++++++--
 indra/llmath/llvolume.h      |  5 +++-
 indra/llmath/llvolumemgr.cpp | 13 ++++++++++
 indra/llmath/llvolumemgr.h   |  1 +
 indra/newview/llvovolume.cpp | 31 +++-------------------
 indra/newview/llvovolume.h   |  1 -
 indra/newview/pipeline.cpp   | 50 ++++++++++++++++++++++++++++--------
 indra/newview/pipeline.h     |  6 +++--
 8 files changed, 95 insertions(+), 43 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 84da1b3c62b..515b1061f93 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1676,6 +1676,7 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 	mFaceMask = 0x0;
 	mDetail = detail;
 	mSculptLevel = -2;
+	mIsTetrahedron = FALSE;
 	mLODScaleBias.setVec(1,1,1);
 
 	// set defaults
@@ -1905,7 +1906,7 @@ BOOL LLVolume::createVolumeFacesFromFile(const std::string& file_name)
 BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 {
 	mSculptLevel = -1;  // default is an error occured
-	
+
 	LLSD header;
 	{
 		if (!LLSDSerialize::deserialize(header, is, 1024*1024*1024))
@@ -2048,6 +2049,11 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 	{
 		U32 face_count = mdl.size();
 
+		if (face_count == 0)
+		{
+			llerrs << "WTF?" << llendl;
+		}
+
 		mVolumeFaces.resize(face_count);
 
 		for (U32 i = 0; i < face_count; ++i)
@@ -2063,8 +2069,9 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 
 			//copy out indices
 			face.mIndices.resize(idx.size()/2);
-			if (idx.empty())
+			if (idx.empty() || face.mIndices.size() < 3)
 			{ //why is there an empty index list?
+				llerrs <<"WTF?" << llendl;
 				continue;
 			}
 
@@ -2150,6 +2157,11 @@ void tetrahedron_set_normal(LLVolumeFace::VertexData* cv)
 	cv[2].mNormal = nrm;
 }
 
+BOOL LLVolume::isTetrahedron()
+{
+	return mIsTetrahedron;
+}
+
 void LLVolume::makeTetrahedron()
 {
 	mVolumeFaces.clear();
@@ -2165,6 +2177,9 @@ void LLVolume::makeTetrahedron()
 		LLVector3(x,-x,-x)
 	};
 
+	face.mExtents[0].setVec(-x,-x,-x);
+	face.mExtents[1].setVec(x,x,x);
+	
 	LLVolumeFace::VertexData cv[3];
 
 	//set texture coordinates
@@ -2225,12 +2240,19 @@ void LLVolume::makeTetrahedron()
 	
 	mVolumeFaces.push_back(face);
 	mSculptLevel = 0;
+	mIsTetrahedron = TRUE;
 }
 
 void LLVolume::copyVolumeFaces(LLVolume* volume)
 {
+	if (volume->isTetrahedron())
+	{
+		llerrs << "WTF?" << llendl;
+	}
+
 	mVolumeFaces = volume->mVolumeFaces;
 	mSculptLevel = 0;
+	mIsTetrahedron = FALSE;
 }
 
 S32 const LL_SCULPT_MESH_MAX_FACES = 8;
@@ -2615,6 +2637,11 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 	LLMemType m1(LLMemType::MTYPE_VOLUME);
     U8 sculpt_type = mParams.getSculptType();
 
+	if (sculpt_type & LL_SCULPT_TYPE_MASK == LL_SCULPT_TYPE_MESH)
+	{
+		llerrs << "WTF?" << llendl;
+	}
+
 	BOOL data_is_empty = FALSE;
 
 	if (sculpt_width == 0 || sculpt_height == 0 || sculpt_components < 3 || sculpt_data == NULL)
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index bf2854ede96..8e57f2e2807 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -904,7 +904,8 @@ class LLVolume : public LLRefCount
 	BOOL isUnique() const									{ return mUnique; }
 
 	S32 getSculptLevel() const                              { return mSculptLevel; }
-	
+	void setSculptLevel(S32 level)							{ mSculptLevel = level; }
+
 	S32 *getTriangleIndices(U32 &num_indices) const;
 
 	// returns number of triangle indeces required for path/profile mesh
@@ -970,11 +971,13 @@ class LLVolume : public LLRefCount
 	virtual BOOL createVolumeFacesFromFile(const std::string& file_name);
 	virtual BOOL createVolumeFacesFromStream(std::istream& is);
 	virtual void makeTetrahedron();
+	virtual BOOL isTetrahedron();
 
  protected:
 	BOOL mUnique;
 	F32 mDetail;
 	S32 mSculptLevel;
+	BOOL mIsTetrahedron;
 	
 	LLVolumeParams mParams;
 	LLPath *mPathp;
diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp
index 61c5a0adc90..419e0015ba7 100644
--- a/indra/llmath/llvolumemgr.cpp
+++ b/indra/llmath/llvolumemgr.cpp
@@ -375,6 +375,19 @@ F32 LLVolumeLODGroup::getVolumeScaleFromDetail(const S32 detail)
 	return mDetailScales[detail];
 }
 
+S32 LLVolumeLODGroup::getVolumeDetailFromScale(const F32 detail)
+{
+	for (S32 i = 1; i < 4; i++)
+	{
+		if (mDetailScales[i] > detail)
+		{
+			return i-1;
+		}
+	}
+
+	return 3;
+}
+
 F32 LLVolumeLODGroup::dump()
 {
 	F32 usage = 0.f;
diff --git a/indra/llmath/llvolumemgr.h b/indra/llmath/llvolumemgr.h
index a78ea76a1a8..f5dc4cd748d 100644
--- a/indra/llmath/llvolumemgr.h
+++ b/indra/llmath/llvolumemgr.h
@@ -59,6 +59,7 @@ class LLVolumeLODGroup
 	static S32 getDetailFromTan(const F32 tan_angle);
 	static void getDetailProximity(const F32 tan_angle, F32 &to_lower, F32& to_higher);
 	static F32 getVolumeScaleFromDetail(const S32 detail);
+	static S32 getVolumeDetailFromScale(F32 scale);
 
 	LLVolume* refLOD(const S32 detail);
 	BOOL derefLOD(LLVolume *volumep);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 4c126d8fd93..64c2e9e8ecc 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -163,7 +163,6 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re
 	mRelativeXformInvTrans.setIdentity();
 
 	mLOD = MIN_LOD;
-	mMeshSculptLevel = -2;
 	mTextureAnimp = NULL;
 	mVObjRadius = LLVector3(1,1,0.5f).length();
 	mNumFaces = 0;
@@ -682,25 +681,7 @@ void LLVOVolume::updateTextureVirtualSize()
 		LLUUID id =  sculpt_params->getSculptTexture();
 		U8 sculpt_type = sculpt_params->getSculptType();
 
-		if ((sculpt_type & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
-			// mesh is a mesh
-		{
-			if (mMeshSculptLevel == -2)
-			{
-				// get the asset please
-				gPipeline.loadMesh(this, id);
-				/*gAssetStorage->getAssetData(id,	LLAssetType::AT_MESH, (LLGetAssetCallback)NULL, NULL, TRUE);
-
-				if (gAssetStorage->hasLocalAsset(id, LLAssetType::AT_MESH))
-				{
-					gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
-					mSculptChanged = TRUE;
-				}*/
-			}
-		}
-
-		else
-			// mesh is a sculptie
+		if ((sculpt_type & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH)
 		{
 			mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
 
@@ -902,14 +883,10 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 			if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 			{
 				if (getVolume()->getNumVolumeFaces() == 0)
-				{
-					//mesh is not loaded, request pipeline load this mesh
+				{ 
+					//load request not yet issued, request pipeline load this mesh
 					LLUUID asset_id = volume_params.getSculptID();
-					gPipeline.loadMesh(this, asset_id, detail);
-				}
-				else
-				{
-					mMeshSculptLevel = 1;
+					gPipeline.loadMesh(this, asset_id, LLVolumeLODGroup::getVolumeDetailFromScale(getVolume()->getDetail()));
 				}
 			}
 			else // otherwise is sculptie
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 4b247f3778a..f14a71130b8 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -298,7 +298,6 @@ class LLVOVolume : public LLViewerObject
 	LLFrameTimer mTextureUpdateTimer;
 	S32			mLOD;
 	BOOL		mLODChanged;
-	S32         mMeshSculptLevel;
 	BOOL		mSculptChanged;
 	F32			mSpotLightPriority;
 	LLMatrix4	mRelativeXform;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 3410ad6559e..0ee619244b4 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8913,23 +8913,29 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
 
 void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 {
+
+	if (detail < 0 || detail > 4)
+	{
+		return;
+	}
+
 	{
 		LLMutexLock lock(mMeshMutex);
 		//add volume to list of loading meshes
-		mesh_load_map::iterator iter = mLoadingMeshes.find(mesh_id);
-		if (iter != mLoadingMeshes.end())
+		mesh_load_map::iterator iter = mLoadingMeshes[detail].find(mesh_id);
+		if (iter != mLoadingMeshes[detail].end())
 		{ //request pending for this mesh, append volume id to list
 			iter->second.insert(vobj->getID());
 			return;
 		}
 
 		//first request for this mesh
-		mLoadingMeshes[mesh_id].insert(vobj->getID());
+		mLoadingMeshes[detail][mesh_id].insert(vobj->getID());
 	}
 
 	if (gAssetStorage->hasLocalAsset(mesh_id, LLAssetType::AT_MESH))
 	{ //already have asset, load desired LOD in background
-		mPendingMeshes.push_back(new LLMeshThread(mesh_id, vobj->getVolume()));
+		mPendingMeshes.push_back(new LLMeshThread(mesh_id, vobj->getVolume(), detail));
 	}
 	else
 	{ //fetch asset and load when done
@@ -8952,7 +8958,7 @@ void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 			for (S32 i = detail-1; i >= 0; --i)
 			{
 				LLVolume* lod = group->refLOD(i);
-				if (lod && lod->getNumVolumeFaces() > 0)
+				if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0)
 				{
 					volume->copyVolumeFaces(lod);
 					group->derefLOD(lod);
@@ -8966,7 +8972,7 @@ void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 			for (S32 i = detail+1; i < 4; ++i)
 			{
 				LLVolume* lod = group->refLOD(i);
-				if (lod && lod->getNumVolumeFaces() > 0)
+				if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0)
 				{
 					volume->copyVolumeFaces(lod);
 					group->derefLOD(lod);
@@ -8976,6 +8982,10 @@ void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 				group->derefLOD(lod);
 			}
 		}
+		else
+		{
+			llerrs << "WTF?" << llendl;
+		}
 
 		//nothing found, so make a tetrahedron
 		volume->makeTetrahedron();
@@ -8992,12 +9002,22 @@ void LLPipeline::getMeshAssetCallback(LLVFS *vfs,
 }
 
 
-LLPipeline::LLMeshThread::LLMeshThread(LLUUID mesh_id, LLVolume* target)
+LLPipeline::LLMeshThread::LLMeshThread(LLUUID mesh_id, LLVolume* target, S32 detail)
 : LLThread("mesh_loading_thread")
 {
 	mMeshID = mesh_id;
 	mVolume = NULL;
 	mDetail = target->getDetail();
+
+	if (detail == -1)
+	{
+		mDetailIndex = LLVolumeLODGroup::getVolumeDetailFromScale(target->getDetail());
+	}
+	else
+	{
+		mDetailIndex = detail;
+	}
+
 	mTargetVolume = target;
 }
 
@@ -9073,6 +9093,10 @@ void LLPipeline::notifyLoadedMeshes()
 
 	for (std::list<LLMeshThread*>::iterator iter = mLoadedMeshes.begin(); iter != mLoadedMeshes.end(); ++iter)
 	{ //for each mesh done loading
+
+
+
+
 		LLMeshThread* mesh = *iter;
 		
 		if (!mesh->isStopped())
@@ -9081,10 +9105,12 @@ void LLPipeline::notifyLoadedMeshes()
 			continue;
 		}
 
+		S32 detail = mesh->mDetailIndex;
+
 		//get list of objects waiting to be notified this mesh is loaded
-		mesh_load_map::iterator obj_iter = mLoadingMeshes.find(mesh->mMeshID);
+		mesh_load_map::iterator obj_iter = mLoadingMeshes[detail].find(mesh->mMeshID);
 
-		if (mesh->mVolume && obj_iter != mLoadingMeshes.end())
+		if (mesh->mVolume && obj_iter != mLoadingMeshes[detail].end())
 		{
 			//make sure target volume is still valid
 			BOOL valid = FALSE;
@@ -9109,6 +9135,10 @@ void LLPipeline::notifyLoadedMeshes()
 				{
 					mesh->mTargetVolume->copyVolumeFaces(mesh->mVolume);
 				}
+				else
+				{
+					llwarns << "Mesh loading returned empty volume." << llendl;
+				}
 
 				for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
 				{
@@ -9120,7 +9150,7 @@ void LLPipeline::notifyLoadedMeshes()
 				}
 			}
 
-			mLoadingMeshes.erase(mesh->mMeshID);
+			mLoadingMeshes[detail].erase(mesh->mMeshID);
 		}
 
 		delete mesh;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 23e98aa0d6f..a31379a2092 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -676,8 +676,9 @@ class LLPipeline
 protected:
 	std::vector<LLFace*>		mSelectedFaces;
 
+
 	typedef std::map<LLUUID, std::set<LLUUID> > mesh_load_map;
-	mesh_load_map mLoadingMeshes;
+	mesh_load_map mLoadingMeshes[4];
 	
 	LLMutex*					mMeshMutex;
 
@@ -688,7 +689,8 @@ class LLPipeline
 		LLVolume* mTargetVolume;
 		LLUUID mMeshID;
 		F32 mDetail;
-		LLMeshThread(LLUUID mesh_id, LLVolume* target);
+		S32 mDetailIndex;
+		LLMeshThread(LLUUID mesh_id, LLVolume* target, S32 detail = -1);
 		~LLMeshThread();
 		void run();
 	};
-- 
GitLab


From 6d66910c6e2fbb25bf8b5c7b90e795f350342104 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 25 Nov 2009 11:35:41 -0600
Subject: [PATCH 021/683] Fix for spam on invalid mesh asset. Fix for index
 buffer overflow spam and crash in llvertexbuffer.

---
 indra/llmath/llvolume.cpp    |  5 -----
 indra/newview/llvovolume.cpp |  5 +++--
 indra/newview/pipeline.cpp   | 18 ++++++------------
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 515b1061f93..3e547aec6f9 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2245,11 +2245,6 @@ void LLVolume::makeTetrahedron()
 
 void LLVolume::copyVolumeFaces(LLVolume* volume)
 {
-	if (volume->isTetrahedron())
-	{
-		llerrs << "WTF?" << llendl;
-	}
-
 	mVolumeFaces = volume->mVolumeFaces;
 	mSculptLevel = 0;
 	mIsTetrahedron = FALSE;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 64c2e9e8ecc..3e9db86cfa6 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -882,7 +882,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 			// if it's a mesh
 			if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 			{
-				if (getVolume()->getNumVolumeFaces() == 0)
+				if (getVolume()->getNumVolumeFaces() == 0 || getVolume()->isTetrahedron())
 				{ 
 					//load request not yet issued, request pipeline load this mesh
 					LLUUID asset_id = volume_params.getSculptID();
@@ -924,7 +924,8 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 void LLVOVolume::notifyMeshLoaded()
 { 
 	mSculptChanged = TRUE;
-	gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY);
+	gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE);
+	dirtySpatialGroup(TRUE);
 }
 
 // sculpt replaces generate() for sculpted surfaces
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 0ee619244b4..af3a35615c7 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1807,8 +1807,6 @@ void LLPipeline::rebuildPriorityGroups()
 	
 	assertInitialized();
 
-	notifyLoadedMeshes();
-
 	// Iterate through all drawables on the priority build queue,
 	for (LLSpatialGroup::sg_list_t::iterator iter = mGroupQ1.begin();
 		 iter != mGroupQ1.end(); ++iter)
@@ -1888,6 +1886,8 @@ void LLPipeline::updateGeom(F32 max_dtime)
 	// for now, only LLVOVolume does this to throttle LOD changes
 	LLVOVolume::preUpdateGeom();
 
+	notifyLoadedMeshes();
+
 	// Iterate through all drawables on the priority build queue,
 	for (LLDrawable::drawable_list_t::iterator iter = mBuildQ1.begin();
 		 iter != mBuildQ1.end();)
@@ -8913,7 +8913,6 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
 
 void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
 {
-
 	if (detail < 0 || detail > 4)
 	{
 		return;
@@ -9093,10 +9092,6 @@ void LLPipeline::notifyLoadedMeshes()
 
 	for (std::list<LLMeshThread*>::iterator iter = mLoadedMeshes.begin(); iter != mLoadedMeshes.end(); ++iter)
 	{ //for each mesh done loading
-
-
-
-
 		LLMeshThread* mesh = *iter;
 		
 		if (!mesh->isStopped())
@@ -9131,14 +9126,13 @@ void LLPipeline::notifyLoadedMeshes()
 
 			if (valid)
 			{
-				if (mesh->mVolume->getNumVolumeFaces() > 0)
-				{
-					mesh->mTargetVolume->copyVolumeFaces(mesh->mVolume);
-				}
-				else
+				if (mesh->mVolume->getNumVolumeFaces() <= 0)
 				{
 					llwarns << "Mesh loading returned empty volume." << llendl;
+					mesh->mVolume->makeTetrahedron();
 				}
+				
+				mesh->mTargetVolume->copyVolumeFaces(mesh->mVolume);
 
 				for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
 				{
-- 
GitLab


From f31f817ee61fa0f8fc05d2caa24f7674852629e5 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Wed, 25 Nov 2009 13:10:09 -0600
Subject: [PATCH 022/683] retry asset upload failures.

---
 indra/newview/llassetuploadresponders.cpp | 17 +++++++++++++++++
 indra/newview/llassetuploadresponders.h   |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index dddc6fef1c7..6e32a910782 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -256,6 +256,7 @@ void LLAssetUploadResponder::result(const LLSD& content)
 	lldebugs << "LLAssetUploadResponder::result from capabilities" << llendl;
 
 	std::string state = content["state"];
+
 	if (state == "upload")
 	{
 		uploadUpload(content);
@@ -330,6 +331,22 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
 {
 }
 
+// virtual
+void LLNewAgentInventoryResponder::error(U32 statusNum, const std::string& reason)
+{
+	LLAssetUploadResponder::error(statusNum, reason);
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE);
+}
+
+
+//virtual 
+void LLNewAgentInventoryResponder::uploadFailure(const LLSD& content)
+{
+	LLAssetUploadResponder::uploadFailure(content);
+
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE);
+}
+
 //virtual 
 void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 {
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index 929a7a5f74a..c8699882035 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -74,7 +74,9 @@ class LLNewAgentInventoryResponder : public LLAssetUploadResponder
 		const LLSD& post_data,
 		const std::string& file_name,
 		LLAssetType::EType asset_type);
+    virtual void error(U32 statusNum, const std::string& reason);
 	virtual void uploadComplete(const LLSD& content);
+	virtual void uploadFailure(const LLSD& content);
 };
 
 // A base class which goes through and performs some default
-- 
GitLab


From 062a2dd309ca5521d4045eb721496476f43d24dc Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 30 Nov 2009 15:32:10 -0600
Subject: [PATCH 023/683] Remove zero area triangles from meshes post-import.

---
 indra/llmath/llvolume.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 3e547aec6f9..1d36da7f525 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1692,10 +1692,9 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 
 	mGenerateSingleFace = generate_single_face;
 
-	generate();
-
 	if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
 	{
+		generate();
 		createVolumeFaces();
 	}
 }
-- 
GitLab


From f039fa98efedc91965338ef53624279f99914205 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 30 Nov 2009 17:02:38 -0600
Subject: [PATCH 024/683] Fix for silly crash due to LLPrimitive having 0
 texture entries.

---
 indra/llmath/llvolume.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 1d36da7f525..858bd9edeab 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1692,9 +1692,10 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 
 	mGenerateSingleFace = generate_single_face;
 
+	generate();
+	
 	if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
 	{
-		generate();
 		createVolumeFaces();
 	}
 }
-- 
GitLab


From bb2631180a85df343e6d816fc37d881af31d49fb Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Tue, 1 Dec 2009 17:40:52 -0600
Subject: [PATCH 025/683] CTS-4 Only part of an uploaded mesh renders.

---
 indra/llmath/llvolume.cpp | 1 -
 indra/llmath/llvolume.h   | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 858bd9edeab..fb2de92e351 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2250,7 +2250,6 @@ void LLVolume::copyVolumeFaces(LLVolume* volume)
 	mIsTetrahedron = FALSE;
 }
 
-S32 const LL_SCULPT_MESH_MAX_FACES = 8;
 
 S32	LLVolume::getNumFaces() const
 {
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 8e57f2e2807..59c60ccd92b 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -192,6 +192,7 @@ const U8 LL_SCULPT_TYPE_MESH      = 5;
 const U8 LL_SCULPT_FLAG_INVERT    = 64;
 const U8 LL_SCULPT_FLAG_MIRROR    = 128;
 
+const S32 LL_SCULPT_MESH_MAX_FACES = 8;
 
 class LLProfileParams
 {
-- 
GitLab


From 00962a68e24c4b628716aaa4390468dc5cc6194e Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Wed, 2 Dec 2009 11:56:21 -0600
Subject: [PATCH 026/683] CTS-37 Mesh-type assets can't be added to the
 inventory of a prim

---
 indra/newview/llpanelobjectinventory.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index 0c2e87aa3d9..7a7372af6ee 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -1593,6 +1593,11 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory*
 										 object->getUUID(),
 										 object->getName());
 		break;
+	case LLAssetType::AT_MESH:
+		new_bridge = new LLTaskMeshBridge(panel,
+										  object->getUUID(),
+										  object->getName());
+		break;
 	
 		break;
 	default:
-- 
GitLab


From 9d3968bb837828568bf58113b8315c8ca2e8dae1 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Thu, 3 Dec 2009 15:12:30 -0800
Subject: [PATCH 027/683] hopefully: linux libraries for colladadom (pcre,
 etc.)

---
 install.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/install.xml b/install.xml
index 68562ca37af..56296824043 100644
--- a/install.xml
+++ b/install.xml
@@ -273,9 +273,9 @@
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>01d17182ecc6728edaa520b3c780d194</string>
+            <string>dde909f84fd2b7c56138f8fd193664c4</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-linux-20090921.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-linux-20091203.tar.bz2</uri>
           </map>
           <key>windows</key>
           <map>
-- 
GitLab


From 1590f187cf4e33bbb44215ea65fdc291eefd7971 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Mon, 7 Dec 2009 16:58:05 -0800
Subject: [PATCH 028/683] Fixing merge borkasaurs.

---
 indra/newview/llassetuploadresponders.cpp | 16 ++++++++--------
 indra/newview/lltooldraganddrop.cpp       | 11 +----------
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 6b1897d077e..bc606c04a96 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -92,7 +92,7 @@ static void on_new_single_inventory_upload_complete(
 
 		LLSD args;
 		args["AMOUNT"] = llformat("%d", upload_price);
-		LLNotifications::instance().add("UploadPayment", args);
+		LLNotificationsUtil::add("UploadPayment", args);
 	}
 
 	// Actually add the upload to viewer inventory
@@ -157,12 +157,12 @@ static void on_new_single_inventory_upload_complete(
 
 		// Show the preview panel for textures and sounds to let
 		// user know that the image (or snapshot) arrived intact.
-		LLFloaterInventory* view = LLFloaterInventory::getActiveInventory();
-		if ( view )
+		LLInventoryPanel* panel = LLInventoryPanel::getActiveInventoryPanel();
+		if ( panel )
 		{
 			LLFocusableElement* focus = gFocusMgr.getKeyboardFocus();
 
-			view->getPanel()->setSelection(
+			panel->setSelection(
 				server_response["new_inventory_item"].asUUID(),
 				TAKE_FOCUS_NO);
 
@@ -172,7 +172,7 @@ static void on_new_single_inventory_upload_complete(
 				(LLFilePicker::instance().getFileCount() <=
 				 FILE_COUNT_DISPLAY_THRESHOLD) )
 			{
-				view->getPanel()->openSelected();
+				panel->openSelected();
 			}
 
 			// restore keyboard focus
@@ -775,7 +775,7 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 		args["REASON"] = reason;
 
 
-		LLNotifications::instance().add("CannotUploadReason", args);
+		LLNotificationsUtil::add("CannotUploadReason", args);
 		LLUploadDialog::modalUploadFinished();
 	}
 
@@ -917,7 +917,7 @@ class LLNewAgentInventoryVariablePriceResponder::Impl
 		S32 option;
 		std::string confirmation_url;
 
-		option = LLNotification::getSelectedOption(
+		option = LLNotificationsUtil::getSelectedOption(
 			notification,
 			response);
 
@@ -1141,7 +1141,7 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 		// when using plain ol' 'this', that this object
 		// would be deleted before the callback is triggered
 		// and cause sadness.
-		LLNotifications::instance().add(
+		LLNotificationsUtil::add(
 			"UploadCostConfirmation",
 			substitutions,
 			payload,
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 03c3900235b..b367d6aec58 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -385,18 +385,9 @@ LLToolDragAndDrop::LLDragAndDropDictionary::LLDragAndDropDictionary()
 	addEntry(DAD_ANIMATION, 	new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dUpdateInventory,			&LLToolDragAndDrop::dad3dNULL));
 	addEntry(DAD_GESTURE, 		new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dActivateGesture,		&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dUpdateInventory,			&LLToolDragAndDrop::dad3dNULL));
 	addEntry(DAD_LINK, 			new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dNULL,						&LLToolDragAndDrop::dad3dNULL));
+	addEntry(DAD_MESH, 			new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dUpdateInventory,			&LLToolDragAndDrop::dad3dNULL));
 	// TODO: animation on self could play it?  edit it?
 	// TODO: gesture on self could play it?  edit it?
-
-
-//	Source: DAD_MESH
-	{
-		&LLToolDragAndDrop::dad3dNULL, // Dest: DT_NONE
-		&LLToolDragAndDrop::dad3dNULL, // Dest: DT_SELF
-		&LLToolDragAndDrop::dad3dGiveInventory, // Dest: DT_AVATAR
-		&LLToolDragAndDrop::dad3dUpdateInventory, // Dest: DT_OBJECT
-		&LLToolDragAndDrop::dad3dNULL,//dad3dAssetOnLand, // Dest: DT_LAND
-	},
 };
 
 LLToolDragAndDrop::LLToolDragAndDrop()
-- 
GitLab


From cd138869d5bfcf40d3d13d7b887e36263e2919d9 Mon Sep 17 00:00:00 2001
From: Palmer Truelson <palmer@lindenlab.com>
Date: Mon, 7 Dec 2009 17:38:45 -0800
Subject: [PATCH 029/683] fix of another merge borkasaurus

---
 indra/newview/llassetuploadresponders.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index bc606c04a96..f5d5559bda5 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -380,7 +380,6 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 		mPostData["description"],
 		content,
 		expected_upload_cost);
-			LLFocusableElement* focus = gFocusMgr.getKeyboardFocus();
 
 	// continue uploading for bulk uploads
 
-- 
GitLab


From 7a7eced4a619d98d808abba3f0bf951bcf4cd95a Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Tue, 8 Dec 2009 16:06:18 -0800
Subject: [PATCH 030/683] Fix of last merge borkasaur.  Left off a comma on
 defining the mesh array.  Also switched our mesh icon code to sync with
 viewer 2 and cleared out extra notification

---
 indra/newview/llinventorybridge.cpp           |  4 +--
 indra/newview/llviewertexteditor.cpp          |  2 +-
 .../skins/default/textures/textures.xml       |  1 +
 .../xui/en/floater_inventory_view_finder.xml  | 29 +++++++++++++++----
 .../skins/default/xui/en/notifications.xml    | 21 ++++----------
 5 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 59bfc777234..93cfbddc923 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -125,9 +125,9 @@ std::string ICON_NAME[ICON_NAME_COUNT] =
 	"Inv_Gesture",
 
 	"Inv_LinkItem",
-	"Inv_LinkFolder"
+	"Inv_LinkFolder",
 	
-	"inv_item_mesh.tga"
+	"Inv_Mesh"
 };
 
 // +=================================================+
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 569ceea4316..80b8999a7ae 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -534,7 +534,7 @@ LLUIImagePtr LLEmbeddedItems::getItemImage(llwchar ext_char) const
 			case LLAssetType::AT_BODYPART:		img_name = "Inv_Skin";		break;
 			case LLAssetType::AT_ANIMATION:		img_name = "Inv_Animation";	break;
 			case LLAssetType::AT_GESTURE:		img_name = "Inv_Gesture";	break;
-			case LLAssetType::AT_MESH:            img_name = "inv_item_mesh.tga";	 break;
+			case LLAssetType::AT_MESH:          img_name = "Inv_Mesh";	    break;
 			default: llassert(0);
 		}
 
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index ac840425844..ff9da8c8a03 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -233,6 +233,7 @@ with the same filename but different name
   <texture name="Inv_LookFolderOpen" file_name="icons/Inv_LookFolderOpen.png" preload="false" />
   <texture name="Inv_LookFolderClosed" file_name="icons/Inv_LookFolderClosed.png" preload="false" />
   <texture name="Inv_Landmark" file_name="icons/Inv_Landmark.png" preload="false" />
+  <texture name="Inv_Mesh" file_name="icons/Inv_Mesh.png" preload="false" />  
   <texture name="Inv_Notecard" file_name="icons/Inv_Notecard.png" preload="false" />
   <texture name="Inv_Object" file_name="icons/Inv_Object.png" preload="false" />
   <texture name="Inv_Pants" file_name="icons/Inv_Pants.png" preload="false" />
diff --git a/indra/newview/skins/default/xui/en/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/en/floater_inventory_view_finder.xml
index 90fee857fbb..388825d31a1 100644
--- a/indra/newview/skins/default/xui/en/floater_inventory_view_finder.xml
+++ b/indra/newview/skins/default/xui/en/floater_inventory_view_finder.xml
@@ -102,6 +102,23 @@
      name="icon_notecard"
      top="122"
      width="16" />
+    <check_box
+     height="16"
+     label="Meshes"
+     layout="topleft"
+     left_pad="2"
+     name="check_mesh"
+     top_delta="0"
+     width="126" />
+    <icon
+     height="16"
+     image_name="Inv_Mesh"
+     layout="topleft"
+     left="8"
+     mouse_opaque="true"
+     name="icon_mesh"
+     top="142"
+     width="16" />
     <check_box
      height="16"
      label="Notecards"
@@ -117,7 +134,7 @@
      left="8"
      mouse_opaque="true"
      name="icon_object"
-     top="142"
+     top="162"
      width="16" />
     <check_box
      height="16"
@@ -134,7 +151,7 @@
      left="8"
      mouse_opaque="true"
      name="icon_script"
-     top="162"
+     top="182"
      width="16" />
     <check_box
      height="16"
@@ -151,7 +168,7 @@
      left="8"
      mouse_opaque="true"
      name="icon_sound"
-     top="182"
+     top="202"
      width="16" />
     <check_box
      height="16"
@@ -168,7 +185,7 @@
      left="8"
      mouse_opaque="true"
      name="icon_texture"
-     top="202"
+     top="222"
      width="16" />
     <check_box
      height="16"
@@ -185,7 +202,7 @@
      left="8"
      mouse_opaque="true"
      name="icon_snapshot"
-     top="222"
+     top="242"
      width="16" />
     <check_box
      height="16"
@@ -203,7 +220,7 @@
      layout="topleft"
      left="8"
      name="All"
-     top="242"
+     top="262"
      width="100" />
     <button
      follows="left|top"
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index b8b9acbc107..4fbaf065533 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -5803,22 +5803,11 @@ Your voice has been muted by moderator.
          name="okbutton"
          yestext="OK"/>
     </notification>
-    
- <notification
-   icon="alertmodal.tga"
-   name="ConfirmClearTeleportHistory"
-   type="alertmodal">
-Are you sure you want to delete your teleport history?
-    <usetemplate
-     name="okcancelbuttons"
-     notext="Cancel"
-     yestext="OK"/>
-    </notification>
-
- <notification
-   icon="alertmodal.tga"
-   name="UploadCostConfirmation"
-   type="alertmodal">
+  
+   <notification
+    icon="alertmodal.tga"
+    name="UploadCostConfirmation"
+    type="alertmodal">
 This upload will cost L$[PRICE], do you wish to continue with the upload?
     <usetemplate
      name="okcancelbuttons"
-- 
GitLab


From 695969c77066de5032bdc9caefecf9b32b076b2f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 11 Dec 2009 14:47:11 -0600
Subject: [PATCH 031/683] HTTP Mesh fetch FTW.. still busted

---
 indra/llcommon/llthread.cpp             |  31 ++-
 indra/llcommon/llthread.h               |  22 ++
 indra/llmath/llvolume.cpp               |   7 +-
 indra/llmath/llvolume.h                 |   2 +
 indra/newview/CMakeLists.txt            |   2 +
 indra/newview/app_settings/settings.xml |   2 +-
 indra/newview/llappviewer.cpp           |   8 +
 indra/newview/llviewerregion.cpp        |   1 +
 indra/newview/llvovolume.cpp            |  15 +-
 indra/newview/pipeline.cpp              | 255 +-----------------------
 indra/newview/pipeline.h                |  34 +---
 11 files changed, 93 insertions(+), 286 deletions(-)

diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index b1175836b78..df7ea214cc5 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -62,6 +62,9 @@
 // 
 //----------------------------------------------------------------------------
 
+U32 ll_thread_local sThreadID = 0;
+U32 LLThread::sIDIter = 0;
+
 //
 // Handed to the APR thread creation function
 //
@@ -72,6 +75,8 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
 	// Set thread state to running
 	threadp->mStatus = RUNNING;
 
+	sThreadID = threadp->mID;
+
 	// Run the user supplied function
 	threadp->run();
 
@@ -90,6 +95,8 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
 	mAPRThreadp(NULL),
 	mStatus(STOPPED)
 {
+	mID = ++sIDIter;
+
 	// Thread creation probably CAN be paranoid about APR being initialized, if necessary
 	if (poolp)
 	{
@@ -273,7 +280,7 @@ void LLThread::wakeLocked()
 //============================================================================
 
 LLMutex::LLMutex(apr_pool_t *poolp) :
-	mAPRMutexp(NULL)
+	mAPRMutexp(NULL), mCount(0), mLockingThread(NO_THREAD)
 {
 	//if (poolp)
 	//{
@@ -305,7 +312,14 @@ LLMutex::~LLMutex()
 
 void LLMutex::lock()
 {
+	if (mLockingThread == sThreadID)
+	{ //redundant lock
+		mCount++;
+		return;
+	}
+
 	apr_thread_mutex_lock(mAPRMutexp);
+	
 #if MUTEX_DEBUG
 	// Have to have the lock before we can access the debug info
 	U32 id = LLThread::currentID();
@@ -313,10 +327,18 @@ void LLMutex::lock()
 		llerrs << "Already locked in Thread: " << id << llendl;
 	mIsLocked[id] = TRUE;
 #endif
+
+	mLockingThread = sThreadID;
 }
 
 void LLMutex::unlock()
 {
+	if (mCount > 0)
+	{ //not the root unlock
+		mCount--;
+		return;
+	}
+	
 #if MUTEX_DEBUG
 	// Access the debug info while we have the lock
 	U32 id = LLThread::currentID();
@@ -324,6 +346,8 @@ void LLMutex::unlock()
 		llerrs << "Not locked in Thread: " << id << llendl;	
 	mIsLocked[id] = FALSE;
 #endif
+
+	mLockingThread = NO_THREAD;
 	apr_thread_mutex_unlock(mAPRMutexp);
 }
 
@@ -341,6 +365,11 @@ bool LLMutex::isLocked()
 	}
 }
 
+U32 LLMutex::lockingThread() const
+{
+	return mLockingThread;
+}
+
 //============================================================================
 
 LLCondition::LLCondition(apr_pool_t *poolp) :
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index d8aa90de2e8..2d553b5258f 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -40,8 +40,17 @@ class LLThread;
 class LLMutex;
 class LLCondition;
 
+#if LL_WINDOWS
+#define ll_thread_local __declspec(thread)
+#else
+#define ll_thread_local __thread
+#endif
+
 class LL_COMMON_API LLThread
 {
+private:
+	static U32 sIDIter;
+
 public:
 	typedef enum e_thread_status
 	{
@@ -82,6 +91,8 @@ class LL_COMMON_API LLThread
 	apr_pool_t *getAPRPool() { return mAPRPoolp; }
 	LLVolatileAPRPool* getLocalAPRFilePool() { return mLocalAPRFilePoolp ; }
 
+	U32 getID() const { return mID; }
+
 private:
 	BOOL				mPaused;
 	
@@ -96,6 +107,7 @@ class LL_COMMON_API LLThread
 	apr_pool_t			*mAPRPoolp;
 	BOOL				mIsLocalPool;
 	EThreadStatus		mStatus;
+	U32					mID;
 
 	//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
 	//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
@@ -133,17 +145,27 @@ class LL_COMMON_API LLThread
 class LL_COMMON_API LLMutex
 {
 public:
+	typedef enum
+	{
+		NO_THREAD = 0xFFFFFFFF
+	} e_locking_thread;
+
 	LLMutex(apr_pool_t *apr_poolp); // NULL pool constructs a new pool for the mutex
 	~LLMutex();
 	
 	void lock();		// blocks
 	void unlock();
 	bool isLocked(); 	// non-blocking, but does do a lock/unlock so not free
+	U32 lockingThread() const; //get ID of locking thread
 	
 protected:
 	apr_thread_mutex_t *mAPRMutexp;
+	mutable U32			mCount;
+	mutable U32			mLockingThread;
+	
 	apr_pool_t			*mAPRPoolp;
 	BOOL				mIsLocalPool;
+	S32					mLockCount;
 #if MUTEX_DEBUG
 	std::map<U32, BOOL> mIsLocked;
 #endif
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index fb2de92e351..44ff1735023 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1952,8 +1952,12 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 	}
 
 	is.seekg(header[nm[lod]]["offset"].asInteger(), std::ios_base::cur);
-	
 
+	return unpackVolumeFaces(is, header[nm[lod]]["size"].asInteger());
+}
+
+BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
+{
 	U8* result = NULL;
 	U32 cur_size = 0;
 
@@ -1964,7 +1968,6 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 		
 		const U32 CHUNK = 65536;
 
-		S32 size = header[nm[lod]]["size"].asInteger();
 		U8 *in = new U8[size];
 		is.read((char*) in, size); 
 
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 59c60ccd92b..9970b24a943 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -971,6 +971,8 @@ class LLVolume : public LLRefCount
 public:
 	virtual BOOL createVolumeFacesFromFile(const std::string& file_name);
 	virtual BOOL createVolumeFacesFromStream(std::istream& is);
+	virtual BOOL unpackVolumeFaces(std::istream& is, S32 size);
+
 	virtual void makeTetrahedron();
 	virtual BOOL isTetrahedron();
 
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 23f8b4b9ca3..52adc740e37 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -284,6 +284,7 @@ set(viewer_SOURCE_FILES
     llmediaremotectrl.cpp
     llmemoryview.cpp
     llmenucommands.cpp
+    llmeshrepository.cpp
     llmetricperformancetester.cpp
     llmimetypes.cpp
     llmorphview.cpp
@@ -789,6 +790,7 @@ set(viewer_HEADER_FILES
     llmediaremotectrl.h
     llmemoryview.h
     llmenucommands.h
+    llmeshrepository.h
     llmetricperformancetester.h
     llmimetypes.h
     llmorphview.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4ed2927ce64..087472661ff 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9998,7 +9998,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>1</integer>
+      <integer>0</integer>
     </map>
     <key>UseStartScreen</key>
     <map>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ddc818172db..a56e86c9794 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -48,6 +48,7 @@
 #include "llwindow.h"
 #include "llviewerstats.h"
 #include "llmd5.h"
+#include "llmeshrepository.h"
 #include "llpumpio.h"
 #include "llmimetypes.h"
 #include "llslurl.h"
@@ -1266,6 +1267,9 @@ bool LLAppViewer::cleanup()
 
 	llinfos << "Cleaning Up" << llendflush;
 
+	// shut down mesh streamer
+	gMeshRepo.shutdown();
+
 	// Must clean up texture references before viewer window is destroyed.
 	LLHUDManager::getInstance()->updateEffects();
 	LLHUDObject::updateAll();
@@ -1678,6 +1682,9 @@ bool LLAppViewer::initThreads()
 		mFastTimerLogThread->start();
 	}
 
+	// Mesh streaming and caching
+	gMeshRepo.init();
+
 	// *FIX: no error handling here!
 	return true;
 }
@@ -2394,6 +2401,7 @@ bool LLAppViewer::initWindow()
 		gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
 	
 		gPipeline.init();
+		
 		stop_glerror();
 		gViewerWindow->initGLDefaults();
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 83178375209..f173149bf4f 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1432,6 +1432,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("FetchLib");
 	capabilityNames.append("FetchLibDescendents");
 	capabilityNames.append("GetTexture");
+	capabilityNames.append("GetMesh");
 	capabilityNames.append("GroupProposalBallot");
 	capabilityNames.append("HomeLocation");
 	capabilityNames.append("MapLayer");
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 7debfb91863..f66f0c2d720 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -70,6 +70,7 @@
 #include "llsdutil.h"
 #include "llmediaentry.h"
 #include "llmediadataclient.h"
+#include "llmeshrepository.h"
 #include "llagent.h"
 
 const S32 MIN_QUIET_FRAMES_COALESCE = 30;
@@ -861,6 +862,16 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 {
 	LLVolumeParams volume_params = params;
 
+	if (isSculpted())
+	{
+		// if it's a mesh
+		if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
+		{ //meshes might not have all LODs, get the force detail to best existing LOD
+			LLUUID mesh_id = params.getSculptID();
+			mLOD = gMeshRepo.getActualMeshLOD(mesh_id, mLOD);
+		}
+	}
+
 	// Check if we need to change implementations
 	bool is_flexible = (volume_params.getPathParams().getCurveType() == LL_PCODE_PATH_FLEXIBLE);
 	if (is_flexible)
@@ -888,6 +899,8 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 		}
 	}
 	
+	
+
 	if ((LLPrimitive::setVolume(volume_params, mLOD, (mVolumeImpl && mVolumeImpl->isVolumeUnique()))) || mSculptChanged)
 	{
 		mFaceMappingChanged = TRUE;
@@ -906,7 +919,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 				{ 
 					//load request not yet issued, request pipeline load this mesh
 					LLUUID asset_id = volume_params.getSculptID();
-					gPipeline.loadMesh(this, asset_id, LLVolumeLODGroup::getVolumeDetailFromScale(getVolume()->getDetail()));
+					gMeshRepo.loadMesh(this, asset_id, LLVolumeLODGroup::getVolumeDetailFromScale(getVolume()->getDetail()));
 				}
 			}
 			else // otherwise is sculptie
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 610804c5ebc..b37645d2de4 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -70,6 +70,7 @@
 #include "llgldbg.h"
 #include "llhudmanager.h"
 #include "lllightconstants.h"
+#include "llmeshrepository.h"
 #include "llresmgr.h"
 #include "llselectmgr.h"
 #include "llsky.h"
@@ -103,6 +104,7 @@
 #include "llspatialpartition.h"
 #include "llmutelist.h"
 #include "lltoolpie.h"
+#include "llcurl.h"
 
 
 #ifdef _DEBUG
@@ -342,8 +344,6 @@ LLPipeline::LLPipeline() :
 	mGlowPool(NULL),
 	mBumpPool(NULL),
 	mWLSkyPool(NULL),
-	mMeshMutex(NULL),
-	mMeshThreadCount(0),
 	mLightMask(0),
 	mLightMovingMask(0),
 	mLightingDetail(0),
@@ -403,7 +403,6 @@ void LLPipeline::init()
 
 	stop_glerror();
 
-	mMeshMutex = new LLMutex(NULL);
 	for (U32 i = 0; i < 2; ++i)
 	{
 		mSpotLightFade[i] = 1.f;
@@ -478,9 +477,6 @@ void LLPipeline::cleanup()
 	//delete mWLSkyPool;
 	mWLSkyPool = NULL;
 
-	delete mMeshMutex;
-	mMeshMutex = NULL;
-
 	releaseGLBuffers();
 
 	mBloomImagep = NULL;
@@ -1802,6 +1798,8 @@ void LLPipeline::rebuildPriorityGroups()
 	
 	assertInitialized();
 
+	gMeshRepo.notifyLoadedMeshes();
+
 	// Iterate through all drawables on the priority build queue,
 	for (LLSpatialGroup::sg_list_t::iterator iter = mGroupQ1.begin();
 		 iter != mGroupQ1.end(); ++iter)
@@ -1881,8 +1879,6 @@ void LLPipeline::updateGeom(F32 max_dtime)
 	// for now, only LLVOVolume does this to throttle LOD changes
 	LLVOVolume::preUpdateGeom();
 
-	notifyLoadedMeshes();
-
 	// Iterate through all drawables on the priority build queue,
 	for (LLDrawable::drawable_list_t::iterator iter = mBuildQ1.begin();
 		 iter != mBuildQ1.end();)
@@ -8912,246 +8908,3 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
 }
 
 
-void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
-{
-	if (detail < 0 || detail > 4)
-	{
-		return;
-	}
-
-	{
-		LLMutexLock lock(mMeshMutex);
-		//add volume to list of loading meshes
-		mesh_load_map::iterator iter = mLoadingMeshes[detail].find(mesh_id);
-		if (iter != mLoadingMeshes[detail].end())
-		{ //request pending for this mesh, append volume id to list
-			iter->second.insert(vobj->getID());
-			return;
-		}
-
-		//first request for this mesh
-		mLoadingMeshes[detail][mesh_id].insert(vobj->getID());
-	}
-
-	if (gAssetStorage->hasLocalAsset(mesh_id, LLAssetType::AT_MESH))
-	{ //already have asset, load desired LOD in background
-		mPendingMeshes.push_back(new LLMeshThread(mesh_id, vobj->getVolume(), detail));
-	}
-	else
-	{ //fetch asset and load when done
-		gAssetStorage->getAssetData(mesh_id, LLAssetType::AT_MESH,
-									getMeshAssetCallback, vobj->getVolume(), TRUE);
-	}
-
-	//do a quick search to see if we can't display something while we wait for this mesh to load
-	LLVolume* volume = vobj->getVolume();
-
-	if (volume)
-	{
-		LLVolumeParams params = volume->getParams();
-
-		LLVolumeLODGroup* group = LLPrimitive::getVolumeManager()->getGroup(params);
-
-		if (group)
-		{
-			//first see what the next lowest LOD available might be
-			for (S32 i = detail-1; i >= 0; --i)
-			{
-				LLVolume* lod = group->refLOD(i);
-				if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0)
-				{
-					volume->copyVolumeFaces(lod);
-					group->derefLOD(lod);
-					return;
-				}
-
-				group->derefLOD(lod);
-			}
-
-			//no lower LOD is a available, is a higher lod available?
-			for (S32 i = detail+1; i < 4; ++i)
-			{
-				LLVolume* lod = group->refLOD(i);
-				if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0)
-				{
-					volume->copyVolumeFaces(lod);
-					group->derefLOD(lod);
-					return;
-				}
-
-				group->derefLOD(lod);
-			}
-		}
-		else
-		{
-			llerrs << "WTF?" << llendl;
-		}
-
-		//nothing found, so make a tetrahedron
-		volume->makeTetrahedron();
-	}
-}
-
-//static
-void LLPipeline::getMeshAssetCallback(LLVFS *vfs,
-										  const LLUUID& asset_uuid,
-										  LLAssetType::EType type,
-										  void* user_data, S32 status, LLExtStat ext_status)
-{
-	gPipeline.mPendingMeshes.push_back(new LLMeshThread(asset_uuid, (LLVolume*) user_data));
-}
-
-
-LLPipeline::LLMeshThread::LLMeshThread(LLUUID mesh_id, LLVolume* target, S32 detail)
-: LLThread("mesh_loading_thread")
-{
-	mMeshID = mesh_id;
-	mVolume = NULL;
-	mDetail = target->getDetail();
-
-	if (detail == -1)
-	{
-		mDetailIndex = LLVolumeLODGroup::getVolumeDetailFromScale(target->getDetail());
-	}
-	else
-	{
-		mDetailIndex = detail;
-	}
-
-	mTargetVolume = target;
-}
-
-LLPipeline::LLMeshThread::~LLMeshThread()
-{
-
-}
-
-void LLPipeline::LLMeshThread::run()
-{
-	if (!gAssetStorage || LLApp::instance()->isQuitting())
-	{
-		return;
-	}
-
-	char* buffer = NULL;
-	S32 size = 0;
-	
-	LLVFS* vfs = gAssetStorage->mVFS;
-
-	{
-		LLVFile file(vfs, mMeshID, LLAssetType::AT_MESH, LLVFile::READ);
-		file.waitForLock(VFSLOCK_READ);
-		size = file.getSize();
-		
-		if (size == 0)
-		{
-			gPipeline.meshLoaded(this);
-			return;
-		}
-		
-		buffer = new char[size];
-		file.read((U8*)&buffer[0], size);
-	}
-
-	{
-		std::string buffer_string(buffer, size);
-		std::istringstream buffer_stream(buffer_string);
-
-		{
-			LLVolumeParams volume_params;
-			volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
-			volume_params.setSculptID(mMeshID, LL_SCULPT_TYPE_MESH);
-			mVolume = new LLVolume(volume_params, mDetail);
-			mVolume->createVolumeFacesFromStream(buffer_stream);
-		}
-	}
-	delete[] buffer;
-	
-	gPipeline.meshLoaded(this);
-}
-
-void LLPipeline::meshLoaded(LLPipeline::LLMeshThread* mesh_thread)
-{
-	LLMutexLock lock(mMeshMutex);
-	mLoadedMeshes.push_back(mesh_thread);
-}
-
-void LLPipeline::notifyLoadedMeshes()
-{ //called from main thread
-
-	U32 max_thread_count = llmax(gSavedSettings.getU32("MeshThreadCount"), (U32) 1);
-	while (mMeshThreadCount < max_thread_count && !mPendingMeshes.empty())
-	{
-		LLMeshThread* mesh_thread = mPendingMeshes.front();
-		mesh_thread->start();
-		++mMeshThreadCount;
-		mPendingMeshes.pop_front();
-	}
-
-	LLMutexLock lock(mMeshMutex);
-	std::list<LLMeshThread*> stopping_threads;
-
-	for (std::list<LLMeshThread*>::iterator iter = mLoadedMeshes.begin(); iter != mLoadedMeshes.end(); ++iter)
-	{ //for each mesh done loading
-		LLMeshThread* mesh = *iter;
-		
-		if (!mesh->isStopped())
-		{ //don't process a LLMeshThread until it's stopped
-			stopping_threads.push_back(mesh);
-			continue;
-		}
-
-		S32 detail = mesh->mDetailIndex;
-
-		//get list of objects waiting to be notified this mesh is loaded
-		mesh_load_map::iterator obj_iter = mLoadingMeshes[detail].find(mesh->mMeshID);
-
-		if (mesh->mVolume && obj_iter != mLoadingMeshes[detail].end())
-		{
-			//make sure target volume is still valid
-			BOOL valid = FALSE;
-
-			for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
-			{
-				LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
-
-				if (vobj)
-				{
-					if (vobj->getVolume() == mesh->mTargetVolume)
-					{
-						valid = TRUE;
-					}
-				}
-			}
-
-
-			if (valid)
-			{
-				if (mesh->mVolume->getNumVolumeFaces() <= 0)
-				{
-					llwarns << "Mesh loading returned empty volume." << llendl;
-					mesh->mVolume->makeTetrahedron();
-				}
-				
-				mesh->mTargetVolume->copyVolumeFaces(mesh->mVolume);
-
-				for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
-				{
-					LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
-					if (vobj)
-					{
-						vobj->notifyMeshLoaded();
-					}
-				}
-			}
-
-			mLoadingMeshes[detail].erase(mesh->mMeshID);
-		}
-
-		delete mesh;
-		--mMeshThreadCount;
-	}
-
-	mLoadedMeshes = stopping_threads;
-}
-
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index f41f6173a90..0b040acf51a 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -58,6 +58,8 @@ class LLCubeMap;
 class LLCullResult;
 class LLVOAvatar;
 class LLGLSLShader;
+class LLCurlRequest;
+class LLMeshResponder;
 
 typedef enum e_avatar_skinning_method
 {
@@ -278,10 +280,6 @@ class LLPipeline
 	LLCullResult::sg_list_t::iterator beginAlphaGroups();
 	LLCullResult::sg_list_t::iterator endAlphaGroups();
 	
-
-	//mesh management functions
-	void loadMesh(LLVOVolume* volume, LLUUID mesh_id, S32 detail = 0);
-	
 	void addTrianglesDrawn(S32 count);
 	BOOL hasRenderType(const U32 type) const				{ return (type && (mRenderTypeMask & (1<<type))) ? TRUE : FALSE; }
 	BOOL hasRenderDebugFeatureMask(const U32 mask) const	{ return (mRenderDebugFeatureMask & mask) ? TRUE : FALSE; }
@@ -683,32 +681,8 @@ class LLPipeline
 	typedef std::map<LLUUID, std::set<LLUUID> > mesh_load_map;
 	mesh_load_map mLoadingMeshes[4];
 	
-	LLMutex*					mMeshMutex;
-
-	class LLMeshThread : public LLThread
-	{
-	public:
-		LLPointer<LLVolume> mVolume;
-		LLVolume* mTargetVolume;
-		LLUUID mMeshID;
-		F32 mDetail;
-		S32 mDetailIndex;
-		LLMeshThread(LLUUID mesh_id, LLVolume* target, S32 detail = -1);
-		~LLMeshThread();
-		void run();
-	};
-	
-	static void getMeshAssetCallback(LLVFS *vfs,
-										  const LLUUID& asset_uuid,
-										  LLAssetType::EType type,
-										  void* user_data, S32 status, LLExtStat ext_status);
-
-	std::list<LLMeshThread*> mLoadedMeshes;
-	std::list<LLMeshThread*> mPendingMeshes;
-	U32 mMeshThreadCount;
-
-	void meshLoaded(LLMeshThread* mesh_thread);
-	void notifyLoadedMeshes();
+	typedef std::list<LLMeshResponder*> mesh_response_list;
+	mesh_response_list			mMeshResponseList;
 
 	LLPointer<LLViewerFetchedTexture>	mFaceSelectImagep;
 	LLPointer<LLViewerTexture>	mBloomImagep;
-- 
GitLab


From 1709f1efc042dc821888f92190637f6109c9a4ca Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 14 Dec 2009 08:07:31 -0600
Subject: [PATCH 032/683] Resolved timeout issues in mesh HTTP transfer.

---
 indra/llcommon/llthread.h | 560 +++++++++++++++++++-------------------
 1 file changed, 280 insertions(+), 280 deletions(-)

diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index 2d553b5258f..72c39f2e93c 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -1,284 +1,284 @@
-/** 
- * @file llthread.h
- * @brief Base classes for thread, mutex and condition handling.
- *
- * $LicenseInfo:firstyear=2004&license=viewergpl$
- * 
- * Copyright (c) 2004-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLTHREAD_H
-#define LL_LLTHREAD_H
-
-#include "llapp.h"
-#include "apr_thread_cond.h"
-
-class LLThread;
-class LLMutex;
-class LLCondition;
-
+/** 
+ * @file llthread.h
+ * @brief Base classes for thread, mutex and condition handling.
+ *
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLTHREAD_H
+#define LL_LLTHREAD_H
+
+#include "llapp.h"
+#include "apr_thread_cond.h"
+
+class LLThread;
+class LLMutex;
+class LLCondition;
+
 #if LL_WINDOWS
 #define ll_thread_local __declspec(thread)
 #else
 #define ll_thread_local __thread
-#endif
-
-class LL_COMMON_API LLThread
-{
-private:
-	static U32 sIDIter;
-
-public:
-	typedef enum e_thread_status
-	{
-		STOPPED = 0,	// The thread is not running.  Not started, or has exited its run function
-		RUNNING = 1,	// The thread is currently running
-		QUITTING= 2 	// Someone wants this thread to quit
-	} EThreadStatus;
-
-	LLThread(const std::string& name, apr_pool_t *poolp = NULL);
-	virtual ~LLThread(); // Warning!  You almost NEVER want to destroy a thread unless it's in the STOPPED state.
-	virtual void shutdown(); // stops the thread
-	
-	bool isQuitting() const { return (QUITTING == mStatus); }
-	bool isStopped() const { return (STOPPED == mStatus); }
-	
-	static U32 currentID(); // Return ID of current thread
-	static void yield(); // Static because it can be called by the main thread, which doesn't have an LLThread data structure.
-	
-public:
-	// PAUSE / RESUME functionality. See source code for important usage notes.
-	// Called from MAIN THREAD.
-	void pause();
-	void unpause();
-	bool isPaused() { return isStopped() || mPaused == TRUE; }
-	
-	// Cause the thread to wake up and check its condition
-	void wake();
-
-	// Same as above, but to be used when the condition is already locked.
-	void wakeLocked();
-
-	// Called from run() (CHILD THREAD). Pause the thread if requested until unpaused.
-	void checkPause();
-
-	// this kicks off the apr thread
-	void start(void);
-
-	apr_pool_t *getAPRPool() { return mAPRPoolp; }
-	LLVolatileAPRPool* getLocalAPRFilePool() { return mLocalAPRFilePoolp ; }
-
-	U32 getID() const { return mID; }
-
-private:
-	BOOL				mPaused;
-	
-	// static function passed to APR thread creation routine
-	static void *APR_THREAD_FUNC staticRun(apr_thread_t *apr_threadp, void *datap);
-
-protected:
-	std::string			mName;
-	LLCondition*		mRunCondition;
-
-	apr_thread_t		*mAPRThreadp;
-	apr_pool_t			*mAPRPoolp;
-	BOOL				mIsLocalPool;
-	EThreadStatus		mStatus;
-	U32					mID;
-
-	//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
-	//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
-	//      otherwise it will cause severe memory leaking!!! --bao
-	LLVolatileAPRPool  *mLocalAPRFilePoolp ; 
-
-	void setQuitting();
-	
-	// virtual function overridden by subclass -- this will be called when the thread runs
-	virtual void run(void) = 0; 
-	
-	// virtual predicate function -- returns true if the thread should wake up, false if it should sleep.
-	virtual bool runCondition(void);
-
-	// Lock/Unlock Run Condition -- use around modification of any variable used in runCondition()
-	inline void lockData();
-	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
-	// 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();
-	// if(!shouldSleep())
-	//     mRunCondition->signal();
-	// mRunCondition->unlock();
-};
-
-//============================================================================
-
-#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO)
-
-class LL_COMMON_API LLMutex
-{
-public:
-	typedef enum
-	{
-		NO_THREAD = 0xFFFFFFFF
-	} e_locking_thread;
-
-	LLMutex(apr_pool_t *apr_poolp); // NULL pool constructs a new pool for the mutex
-	~LLMutex();
-	
-	void lock();		// blocks
-	void unlock();
-	bool isLocked(); 	// non-blocking, but does do a lock/unlock so not free
-	U32 lockingThread() const; //get ID of locking thread
-	
-protected:
-	apr_thread_mutex_t *mAPRMutexp;
-	mutable U32			mCount;
-	mutable U32			mLockingThread;
-	
-	apr_pool_t			*mAPRPoolp;
-	BOOL				mIsLocalPool;
-	S32					mLockCount;
-#if MUTEX_DEBUG
-	std::map<U32, BOOL> mIsLocked;
-#endif
-};
-
-// Actually a condition/mutex pair (since each condition needs to be associated with a mutex).
-class LL_COMMON_API LLCondition : public LLMutex
-{
-public:
-	LLCondition(apr_pool_t *apr_poolp); // Defaults to global pool, could use the thread pool as well.
-	~LLCondition();
-	
-	void wait();		// blocks
-	void signal();
-	void broadcast();
-	
-protected:
-	apr_thread_cond_t *mAPRCondp;
-};
-
-class LLMutexLock
-{
-public:
-	LLMutexLock(LLMutex* mutex)
-	{
-		mMutex = mutex;
-		mMutex->lock();
-	}
-	~LLMutexLock()
-	{
-		mMutex->unlock();
-	}
-private:
-	LLMutex* mMutex;
-};
-
-//============================================================================
-
-void LLThread::lockData()
-{
-	mRunCondition->lock();
-}
-
-void LLThread::unlockData()
-{
-	mRunCondition->unlock();
-}
-
-
-//============================================================================
-
-// see llmemory.h for LLPointer<> definition
-
-class LL_COMMON_API LLThreadSafeRefCount
-{
-public:
-	static void initThreadSafeRefCount(); // creates sMutex
-	static void cleanupThreadSafeRefCount(); // destroys sMutex
-	
-private:
-	static LLMutex* sMutex;
-
-private:
-	LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented
-	LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented
-
-protected:
-	virtual ~LLThreadSafeRefCount(); // use unref()
-	
-public:
-	LLThreadSafeRefCount();
-	
-	void ref()
-	{
-		if (sMutex) sMutex->lock();
-		mRef++; 
-		if (sMutex) sMutex->unlock();
-	} 
-
-	S32 unref()
-	{
-		llassert(mRef >= 1);
-		if (sMutex) sMutex->lock();
-		S32 res = --mRef;
-		if (sMutex) sMutex->unlock();
-		if (0 == res) 
-		{
-			delete this; 
-			return 0;
-		}
-		return res;
-	}	
-	S32 getNumRefs() const
-	{
-		return mRef;
-	}
-
-private: 
-	S32	mRef; 
-};
-
-//============================================================================
-
-// Simple responder for self destructing callbacks
-// Pure virtual class
-class LL_COMMON_API LLResponder : public LLThreadSafeRefCount
-{
-protected:
-	virtual ~LLResponder();
-public:
-	virtual void completed(bool success) = 0;
-};
-
-//============================================================================
-
-#endif // LL_LLTHREAD_H
+#endif
+
+class LL_COMMON_API LLThread
+{
+private:
+	static U32 sIDIter;
+
+public:
+	typedef enum e_thread_status
+	{
+		STOPPED = 0,	// The thread is not running.  Not started, or has exited its run function
+		RUNNING = 1,	// The thread is currently running
+		QUITTING= 2 	// Someone wants this thread to quit
+	} EThreadStatus;
+
+	LLThread(const std::string& name, apr_pool_t *poolp = NULL);
+	virtual ~LLThread(); // Warning!  You almost NEVER want to destroy a thread unless it's in the STOPPED state.
+	virtual void shutdown(); // stops the thread
+	
+	bool isQuitting() const { return (QUITTING == mStatus); }
+	bool isStopped() const { return (STOPPED == mStatus); }
+	
+	static U32 currentID(); // Return ID of current thread
+	static void yield(); // Static because it can be called by the main thread, which doesn't have an LLThread data structure.
+	
+public:
+	// PAUSE / RESUME functionality. See source code for important usage notes.
+	// Called from MAIN THREAD.
+	void pause();
+	void unpause();
+	bool isPaused() { return isStopped() || mPaused == TRUE; }
+	
+	// Cause the thread to wake up and check its condition
+	void wake();
+
+	// Same as above, but to be used when the condition is already locked.
+	void wakeLocked();
+
+	// Called from run() (CHILD THREAD). Pause the thread if requested until unpaused.
+	void checkPause();
+
+	// this kicks off the apr thread
+	void start(void);
+
+	apr_pool_t *getAPRPool() { return mAPRPoolp; }
+	LLVolatileAPRPool* getLocalAPRFilePool() { return mLocalAPRFilePoolp ; }
+
+	U32 getID() const { return mID; }
+
+private:
+	BOOL				mPaused;
+	
+	// static function passed to APR thread creation routine
+	static void *APR_THREAD_FUNC staticRun(apr_thread_t *apr_threadp, void *datap);
+
+protected:
+	std::string			mName;
+	LLCondition*		mRunCondition;
+
+	apr_thread_t		*mAPRThreadp;
+	apr_pool_t			*mAPRPoolp;
+	BOOL				mIsLocalPool;
+	EThreadStatus		mStatus;
+	U32					mID;
+
+	//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
+	//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
+	//      otherwise it will cause severe memory leaking!!! --bao
+	LLVolatileAPRPool  *mLocalAPRFilePoolp ; 
+
+	void setQuitting();
+	
+	// virtual function overridden by subclass -- this will be called when the thread runs
+	virtual void run(void) = 0; 
+	
+	// virtual predicate function -- returns true if the thread should wake up, false if it should sleep.
+	virtual bool runCondition(void);
+
+	// Lock/Unlock Run Condition -- use around modification of any variable used in runCondition()
+	inline void lockData();
+	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
+	// 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();
+	// if(!shouldSleep())
+	//     mRunCondition->signal();
+	// mRunCondition->unlock();
+};
+
+//============================================================================
+
+#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO)
+
+class LL_COMMON_API LLMutex
+{
+public:
+	typedef enum
+	{
+		NO_THREAD = 0xFFFFFFFF
+	} e_locking_thread;
+
+	LLMutex(apr_pool_t *apr_poolp); // NULL pool constructs a new pool for the mutex
+	~LLMutex();
+	
+	void lock();		// blocks
+	void unlock();
+	bool isLocked(); 	// non-blocking, but does do a lock/unlock so not free
+	U32 lockingThread() const; //get ID of locking thread
+	
+protected:
+	apr_thread_mutex_t *mAPRMutexp;
+	mutable U32			mCount;
+	mutable U32			mLockingThread;
+	
+	apr_pool_t			*mAPRPoolp;
+	BOOL				mIsLocalPool;
+	S32					mLockCount;
+#if MUTEX_DEBUG
+	std::map<U32, BOOL> mIsLocked;
+#endif
+};
+
+// Actually a condition/mutex pair (since each condition needs to be associated with a mutex).
+class LL_COMMON_API LLCondition : public LLMutex
+{
+public:
+	LLCondition(apr_pool_t *apr_poolp); // Defaults to global pool, could use the thread pool as well.
+	~LLCondition();
+	
+	void wait();		// blocks
+	void signal();
+	void broadcast();
+	
+protected:
+	apr_thread_cond_t *mAPRCondp;
+};
+
+class LLMutexLock
+{
+public:
+	LLMutexLock(LLMutex* mutex)
+	{
+		mMutex = mutex;
+		mMutex->lock();
+	}
+	~LLMutexLock()
+	{
+		mMutex->unlock();
+	}
+private:
+	LLMutex* mMutex;
+};
+
+//============================================================================
+
+void LLThread::lockData()
+{
+	mRunCondition->lock();
+}
+
+void LLThread::unlockData()
+{
+	mRunCondition->unlock();
+}
+
+
+//============================================================================
+
+// see llmemory.h for LLPointer<> definition
+
+class LL_COMMON_API LLThreadSafeRefCount
+{
+public:
+	static void initThreadSafeRefCount(); // creates sMutex
+	static void cleanupThreadSafeRefCount(); // destroys sMutex
+	
+private:
+	static LLMutex* sMutex;
+
+private:
+	LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented
+	LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented
+
+protected:
+	virtual ~LLThreadSafeRefCount(); // use unref()
+	
+public:
+	LLThreadSafeRefCount();
+	
+	void ref()
+	{
+		if (sMutex) sMutex->lock();
+		mRef++; 
+		if (sMutex) sMutex->unlock();
+	} 
+
+	S32 unref()
+	{
+		llassert(mRef >= 1);
+		if (sMutex) sMutex->lock();
+		S32 res = --mRef;
+		if (sMutex) sMutex->unlock();
+		if (0 == res) 
+		{
+			delete this; 
+			return 0;
+		}
+		return res;
+	}	
+	S32 getNumRefs() const
+	{
+		return mRef;
+	}
+
+private: 
+	S32	mRef; 
+};
+
+//============================================================================
+
+// Simple responder for self destructing callbacks
+// Pure virtual class
+class LL_COMMON_API LLResponder : public LLThreadSafeRefCount
+{
+protected:
+	virtual ~LLResponder();
+public:
+	virtual void completed(bool success) = 0;
+};
+
+//============================================================================
+
+#endif // LL_LLTHREAD_H
-- 
GitLab


From 081fa98a47d2b592ada0fbb049ff959ac2cd6294 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 15 Dec 2009 17:43:05 -0600
Subject: [PATCH 033/683] HTTP Mesh transfer relatively blocking-free.

---
 indra/llmath/llvolume.cpp               |  2 +-
 indra/newview/app_settings/settings.xml | 11 +++++++++++
 indra/newview/llvovolume.cpp            | 20 ++++++++++++++++----
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 44ff1735023..844918432d2 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2171,7 +2171,7 @@ void LLVolume::makeTetrahedron()
 
 	LLVolumeFace face;
 
-	F32 x = 0.5f;
+	F32 x = 0.25f;
 	LLVector3 p[] = 
 	{ //unit tetrahedron corners
 		LLVector3(x,x,x),
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index a4142b41b04..4f17775dfd8 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7463,6 +7463,17 @@
     <key>Value</key>
     <integer>8</integer>
   </map>
+  <key>MeshMaxConcurrentRequests</key>
+  <map>
+    <key>Comment</key>
+    <string>Number of threads to use for loading meshes.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>U32</string>
+    <key>Value</key>
+    <integer>32</integer>
+  </map>
 
   <key>SafeMode</key>
     <map>
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index f66f0c2d720..ea0aa54751a 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -862,13 +862,21 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 {
 	LLVolumeParams volume_params = params;
 
+	S32 lod = mLOD;
+
 	if (isSculpted())
 	{
 		// if it's a mesh
 		if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 		{ //meshes might not have all LODs, get the force detail to best existing LOD
 			LLUUID mesh_id = params.getSculptID();
-			mLOD = gMeshRepo.getActualMeshLOD(mesh_id, mLOD);
+
+			//profile and path params don't matter for meshes
+			volume_params = LLVolumeParams();
+			volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+			volume_params.setSculptID(mesh_id, LL_SCULPT_TYPE_MESH);
+
+			lod = gMeshRepo.getActualMeshLOD(mesh_id, lod);
 		}
 	}
 
@@ -901,13 +909,13 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 	
 	
 
-	if ((LLPrimitive::setVolume(volume_params, mLOD, (mVolumeImpl && mVolumeImpl->isVolumeUnique()))) || mSculptChanged)
+	if ((LLPrimitive::setVolume(volume_params, lod, (mVolumeImpl && mVolumeImpl->isVolumeUnique()))) || mSculptChanged)
 	{
 		mFaceMappingChanged = TRUE;
 		
 		if (mVolumeImpl)
 		{
-			mVolumeImpl->onSetVolume(volume_params, detail);
+			mVolumeImpl->onSetVolume(volume_params, mLOD);
 		}
 		
 		if (isSculpted())
@@ -919,7 +927,11 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 				{ 
 					//load request not yet issued, request pipeline load this mesh
 					LLUUID asset_id = volume_params.getSculptID();
-					gMeshRepo.loadMesh(this, asset_id, LLVolumeLODGroup::getVolumeDetailFromScale(getVolume()->getDetail()));
+					S32 available_lod = gMeshRepo.loadMesh(this, asset_id, lod);
+					if (available_lod != lod)
+					{
+						LLPrimitive::setVolume(volume_params, available_lod);
+					}
 				}
 			}
 			else // otherwise is sculptie
-- 
GitLab


From c6aaf115ade4b335df9ca479992b08e028ffd910 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 16 Dec 2009 09:26:53 -0600
Subject: [PATCH 034/683] Quick 'n dirty prioritization scheme for mesh
 loading. Sprinkling of fast timers in areas that are likely to stall.

---
 indra/newview/llappviewer.cpp        | 57 ++++++++++++++++++++--------
 indra/newview/lldrawable.cpp         | 22 ++++++++---
 indra/newview/llface.cpp             | 29 ++++++++++++--
 indra/newview/llviewerobjectlist.cpp |  4 ++
 indra/newview/pipeline.cpp           | 27 +++++++++----
 5 files changed, 106 insertions(+), 33 deletions(-)

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 8dfc1657cf3..0461cf16120 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -3387,6 +3387,8 @@ static LLFastTimer::DeclareTimer FTM_OBJECTLIST_UPDATE("Update Objectlist");
 static LLFastTimer::DeclareTimer FTM_REGION_UPDATE("Update Region");
 static LLFastTimer::DeclareTimer FTM_WORLD_UPDATE("Update World");
 static LLFastTimer::DeclareTimer FTM_NETWORK("Network");
+static LLFastTimer::DeclareTimer FTM_AGENT_NETWORK("Agent Network");
+static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager");
 
 ///////////////////////////////////////////////////////
 // idle()
@@ -3457,7 +3459,7 @@ void LLAppViewer::idle()
 
 	if (!gDisconnected)
 	{
-		LLFastTimer t(FTM_NETWORK);
+		LLFastTimer t(FTM_AGENT_NETWORK);
 		// Update spaceserver timeinfo
 	    LLWorld::getInstance()->setSpaceTimeUSec(LLWorld::getInstance()->getSpaceTimeUSec() + (U32)(dt_raw * SEC_TO_MICROSEC));
     
@@ -3646,7 +3648,7 @@ void LLAppViewer::idle()
 	//
 
 	{
-		LLFastTimer t(FTM_NETWORK);
+		LLFastTimer t(FTM_VLMANAGER);
 		gVLManager.unpackData();
 	}
 	
@@ -3891,7 +3893,12 @@ void LLAppViewer::sendLogoutRequest()
 static F32 CheckMessagesMaxTime = CHECK_MESSAGES_DEFAULT_MAX_TIME;
 #endif
 
-static LLFastTimer::DeclareTimer FTM_IDLE_NETWORK("Network");
+static LLFastTimer::DeclareTimer FTM_IDLE_NETWORK("Idle Network");
+static LLFastTimer::DeclareTimer FTM_MESSAGE_ACKS("Message Acks");
+static LLFastTimer::DeclareTimer FTM_RETRANSMIT("Retransmit");
+static LLFastTimer::DeclareTimer FTM_TIMEOUT_CHECK("Timeout Check");
+static LLFastTimer::DeclareTimer FTM_DYNAMIC_THROTTLE("Dynamic Throttle");
+static LLFastTimer::DeclareTimer FTM_CHECK_REGION_CIRCUIT("Check Region Circuit");
 
 void LLAppViewer::idleNetwork()
 {
@@ -3945,7 +3952,10 @@ void LLAppViewer::idleNetwork()
 		}
 
 		// Handle per-frame message system processing.
-		gMessageSystem->processAcks();
+		{
+			LLFastTimer ftm(FTM_MESSAGE_ACKS);
+			gMessageSystem->processAcks();
+		}
 
 #ifdef TIME_THROTTLE_MESSAGES
 		if (total_time >= CheckMessagesMaxTime)
@@ -3983,26 +3993,41 @@ void LLAppViewer::idleNetwork()
 	LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects);
 
 	// Retransmit unacknowledged packets.
-	gXferManager->retransmitUnackedPackets();
-	gAssetStorage->checkForTimeouts();
+	{
+		LLFastTimer ftm(FTM_RETRANSMIT);
+		gXferManager->retransmitUnackedPackets();
+	}
+
+	{
+		LLFastTimer ftm(FTM_TIMEOUT_CHECK);
+		gAssetStorage->checkForTimeouts();
+	}
+
 	llpushcallstacks ;
-	gViewerThrottle.updateDynamicThrottle();
+
+	{
+		LLFastTimer ftm(FTM_DYNAMIC_THROTTLE);
+		gViewerThrottle.updateDynamicThrottle();
+	}
 
 	llpushcallstacks ;
 	// Check that the circuit between the viewer and the agent's current
 	// region is still alive
-	LLViewerRegion *agent_region = gAgent.getRegion();
-	if (agent_region && (LLStartUp::getStartupState()==STATE_STARTED))
 	{
-		LLUUID this_region_id = agent_region->getRegionID();
-		bool this_region_alive = agent_region->isAlive();
-		if ((mAgentRegionLastAlive && !this_region_alive) // newly dead
-		    && (mAgentRegionLastID == this_region_id)) // same region
+		LLFastTimer ftm(FTM_CHECK_REGION_CIRCUIT);
+		LLViewerRegion *agent_region = gAgent.getRegion();
+		if (agent_region && (LLStartUp::getStartupState()==STATE_STARTED))
 		{
-			forceDisconnect(LLTrans::getString("AgentLostConnection"));
+			LLUUID this_region_id = agent_region->getRegionID();
+			bool this_region_alive = agent_region->isAlive();
+			if ((mAgentRegionLastAlive && !this_region_alive) // newly dead
+				&& (mAgentRegionLastID == this_region_id)) // same region
+			{
+				forceDisconnect(LLTrans::getString("AgentLostConnection"));
+			}
+			mAgentRegionLastID = this_region_id;
+			mAgentRegionLastAlive = this_region_alive;
 		}
-		mAgentRegionLastID = this_region_id;
-		mAgentRegionLastAlive = this_region_alive;
 	}
 	llpushcallstacks ;
 }
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index d60330024af..9a3be975cd0 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -189,20 +189,30 @@ BOOL LLDrawable::isLight() const
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_CLEANUP_DRAWABLE("Cleanup Drawable");
+static LLFastTimer::DeclareTimer FTM_DEREF_DRAWABLE("Deref");
+static LLFastTimer::DeclareTimer FTM_DELETE_FACES("Faces");
+
 void LLDrawable::cleanupReferences()
 {
-	LLFastTimer t(FTM_PIPELINE);
+	LLFastTimer t(FTM_CLEANUP_DRAWABLE);
 	
-	std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
-	mFaces.clear();
+	{
+		LLFastTimer t(FTM_DELETE_FACES);
+		std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
+		mFaces.clear();
+	}
 
 	gObjectList.removeDrawable(this);
 	
 	gPipeline.unlinkDrawable(this);
 	
-	// Cleanup references to other objects
-	mVObjp = NULL;
-	mParent = NULL;
+	{
+		LLFastTimer t(FTM_DEREF_DRAWABLE);
+		// Cleanup references to other objects
+		mVObjp = NULL;
+		mParent = NULL;
+	}
 }
 
 void LLDrawable::cleanupDeadDrawables()
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 698d8572aaa..91e2fef28df 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -183,22 +183,33 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
 	mUsingAtlas  = FALSE ;
 }
 
+static LLFastTimer::DeclareTimer FTM_DESTROY_FACE("Destroy Face");
+static LLFastTimer::DeclareTimer FTM_DESTROY_TEXTURE("Texture");
+static LLFastTimer::DeclareTimer FTM_DESTROY_DRAWPOOL("Drawpool");
+static LLFastTimer::DeclareTimer FTM_DESTROY_TEXTURE_MATRIX("Texture Matrix");
+static LLFastTimer::DeclareTimer FTM_DESTROY_DRAW_INFO("Draw Info");
+static LLFastTimer::DeclareTimer FTM_DESTROY_ATLAS("Atlas");
+static LLFastTimer::DeclareTimer FTM_FACE_DEREF("Deref");
 
 void LLFace::destroy()
 {
+	LLFastTimer t(FTM_DESTROY_FACE);
 	if(mTexture.notNull())
 	{
+		LLFastTimer t(FTM_DESTROY_TEXTURE);
 		mTexture->removeFace(this) ;
 	}
 	
 	if (mDrawPoolp)
 	{
+		LLFastTimer t(FTM_DESTROY_DRAWPOOL);
 		mDrawPoolp->removeFace(this);
 		mDrawPoolp = NULL;
 	}
 
 	if (mTextureMatrix)
 	{
+		LLFastTimer t(FTM_DESTROY_TEXTURE_MATRIX);
 		delete mTextureMatrix;
 		mTextureMatrix = NULL;
 
@@ -213,11 +224,21 @@ void LLFace::destroy()
 		}
 	}
 	
-	setDrawInfo(NULL);
+	{
+		LLFastTimer t(FTM_DESTROY_DRAW_INFO);
+		setDrawInfo(NULL);
+	}
 	
-	removeAtlas();
-	mDrawablep = NULL;
-	mVObjp = NULL;
+	{
+		LLFastTimer t(FTM_DESTROY_ATLAS);
+		removeAtlas();
+	}
+	
+	{
+		LLFastTimer t(FTM_FACE_DEREF);
+		mDrawablep = NULL;
+		mVObjp = NULL;
+	}
 }
 
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 96828ee1b60..7a6f4796853 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -866,8 +866,12 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 	mNumDeadObjects++;
 }
 
+static LLFastTimer::DeclareTimer FTM_REMOVE_DRAWABLE("Remove Drawable");
+
 void LLViewerObjectList::removeDrawable(LLDrawable* drawablep)
 {
+	LLFastTimer t(FTM_REMOVE_DRAWABLE);
+
 	if (!drawablep)
 	{
 		return;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index b37645d2de4..cac266a6837 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1143,9 +1143,15 @@ void LLPipeline::allocDrawable(LLViewerObject *vobj)
 }
 
 
+static LLFastTimer::DeclareTimer FTM_UNLINK("Unlink");
+static LLFastTimer::DeclareTimer FTM_REMOVE_FROM_MOVE_LIST("Movelist");
+static LLFastTimer::DeclareTimer FTM_REMOVE_FROM_SPATIAL_PARTITION("Spatial Partition");
+static LLFastTimer::DeclareTimer FTM_REMOVE_FROM_LIGHT_SET("Light Set");
+static LLFastTimer::DeclareTimer FTM_REMOVE_FROM_HIGHLIGHT_SET("Highlight Set");
+
 void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 {
-	LLFastTimer t(FTM_PIPELINE);
+	LLFastTimer t(FTM_UNLINK);
 
 	assertInitialized();
 
@@ -1154,6 +1160,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 	// Based on flags, remove the drawable from the queues that it's on.
 	if (drawablep->isState(LLDrawable::ON_MOVE_LIST))
 	{
+		LLFastTimer t(FTM_REMOVE_FROM_MOVE_LIST);
 		LLDrawable::drawable_vector_t::iterator iter = std::find(mMovedList.begin(), mMovedList.end(), drawablep);
 		if (iter != mMovedList.end())
 		{
@@ -1163,6 +1170,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 
 	if (drawablep->getSpatialGroup())
 	{
+		LLFastTimer t(FTM_REMOVE_FROM_SPATIAL_PARTITION);
 		if (!drawablep->getSpatialGroup()->mSpatialPartition->remove(drawablep, drawablep->getSpatialGroup()))
 		{
 #ifdef LL_RELEASE_FOR_DOWNLOAD
@@ -1173,18 +1181,23 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 		}
 	}
 
-	mLights.erase(drawablep);
-	for (light_set_t::iterator iter = mNearbyLights.begin();
-				iter != mNearbyLights.end(); iter++)
 	{
-		if (iter->drawable == drawablep)
+		LLFastTimer t(FTM_REMOVE_FROM_LIGHT_SET);
+		mLights.erase(drawablep);
+
+		for (light_set_t::iterator iter = mNearbyLights.begin();
+					iter != mNearbyLights.end(); iter++)
 		{
-			mNearbyLights.erase(iter);
-			break;
+			if (iter->drawable == drawablep)
+			{
+				mNearbyLights.erase(iter);
+				break;
+			}
 		}
 	}
 
 	{
+		LLFastTimer t(FTM_REMOVE_FROM_HIGHLIGHT_SET);
 		HighlightItem item(drawablep);
 		mHighlightSet.erase(item);
 
-- 
GitLab


From edb67a898c4d20a1d4f18ad0db9ad02d6157b2ed Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 16 Dec 2009 11:20:44 -0600
Subject: [PATCH 035/683] Convert ll_face_list_t in llviewertexture to a
 std::set to improve performance on face deletion.

---
 indra/newview/llviewertexture.cpp | 12 ++++++------
 indra/newview/llviewertexture.h   |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index faf7a932818..c9558860dbe 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -614,13 +614,13 @@ void LLViewerTexture::setKnownDrawSize(S32 width, S32 height)
 //virtual
 void LLViewerTexture::addFace(LLFace* facep) 
 {
-	mFaceList.push_back(facep) ;
+	mFaceList.insert(facep) ;
 }
 
 //virtual
 void LLViewerTexture::removeFace(LLFace* facep) 
 {
-	mFaceList.remove(facep) ;
+	mFaceList.erase(facep);
 }
 
 //virtual
@@ -1519,7 +1519,7 @@ void LLViewerFetchedTexture::updateVirtualSize()
 	}
 	if(mFaceList.size() > 0) 
 	{				
-		for(std::list<LLFace*>::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter)
+		for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter)
 		{
 			LLFace* facep = *iter ;
 			if(facep->getDrawable()->isRecentlyVisible())
@@ -2391,7 +2391,7 @@ BOOL LLViewerFetchedTexture::insertToAtlas()
 	LLFace* facep;
 
 	//if the atlas slot pointers for some faces are null, process them later.
-	ll_face_list_t waiting_list ;
+	std::vector<LLFace*> waiting_list ;
 
 	for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter)
 	{
@@ -2475,7 +2475,7 @@ BOOL LLViewerFetchedTexture::insertToAtlas()
 	}
 
 	//process the waiting_list
-	for(ll_face_list_t::iterator iter = waiting_list.begin(); iter != waiting_list.end(); ++iter)
+	for(std::vector<LLFace*>::iterator iter = waiting_list.begin(); iter != waiting_list.end(); ++iter)
 	{
 		facep = (LLFace*)*iter ;	
 		groupp = facep->getDrawable()->getSpatialGroup() ;
@@ -3153,7 +3153,7 @@ F32 LLViewerMediaTexture::getMaxVirtualSize()
 	{
 		if(mFaceList.size() > 0) 
 		{				
-			for(std::list<LLFace*>::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter)
+			for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter)
 			{
 				LLFace* facep = *iter ;
 				if(facep->getDrawable()->isRecentlyVisible())
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 141979052d7..bf4b1cf800d 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -139,7 +139,7 @@ class LLViewerTexture : public LLTexture
 	static S32 getIndexFromCategory(S32 category) ;
 	static S32 getCategoryFromIndex(S32 index) ;
 
-	typedef std::list<LLFace*> ll_face_list_t ;
+	typedef std::set<LLFace*> ll_face_list_t ;
 
 protected:
 	virtual ~LLViewerTexture();
-- 
GitLab


From 4c9d37c0906bd0218a5db08ea4fc253adfc684c9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 16 Dec 2009 12:31:24 -0600
Subject: [PATCH 036/683] Tracking down stalls in llpumpio and agent updates.

---
 indra/llmessage/llpumpio.cpp  |  7 +++++--
 indra/newview/llappviewer.cpp | 33 ++++++++++++++++++++++++++-------
 2 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/indra/llmessage/llpumpio.cpp b/indra/llmessage/llpumpio.cpp
index 5e9dfd81faa..e3ce2c5ad34 100644
--- a/indra/llmessage/llpumpio.cpp
+++ b/indra/llmessage/llpumpio.cpp
@@ -444,13 +444,13 @@ void LLPumpIO::pump()
 	pump(DEFAULT_POLL_TIMEOUT);
 }
 
-static LLFastTimer::DeclareTimer FTM_PUMP("Pump");
+static LLFastTimer::DeclareTimer FTM_PUMP_IO("Pump IO");
 
 //timeout is in microseconds
 void LLPumpIO::pump(const S32& poll_timeout)
 {
 	LLMemType m1(LLMemType::MTYPE_IO_PUMP);
-	LLFastTimer t1(FTM_PUMP);
+	LLFastTimer t1(FTM_PUMP_IO);
 	//llinfos << "LLPumpIO::pump()" << llendl;
 
 	// Run any pending runners.
@@ -778,6 +778,8 @@ bool LLPumpIO::respond(
 	return true;
 }
 
+static LLFastTimer::DeclareTimer FTM_PUMP_CALLBACK_CHAIN("Chain");
+
 void LLPumpIO::callback()
 {
 	LLMemType m1(LLMemType::MTYPE_IO_PUMP);
@@ -799,6 +801,7 @@ void LLPumpIO::callback()
 		callbacks_t::iterator end = mCallbacks.end();
 		for(; it != end; ++it)
 		{
+			LLFastTimer t(FTM_PUMP_CALLBACK_CHAIN);
 			// it's always the first and last time for respone chains
 			(*it).mHead = (*it).mChainLinks.begin();
 			(*it).mInit = true;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0461cf16120..7fb821c61d9 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -921,6 +921,9 @@ static LLFastTimer::DeclareTimer FTM_LFS("LFS Thread");
 static LLFastTimer::DeclareTimer FTM_PAUSE_THREADS("Pause Threads");
 static LLFastTimer::DeclareTimer FTM_IDLE("Idle");
 static LLFastTimer::DeclareTimer FTM_PUMP("Pump");
+static LLFastTimer::DeclareTimer FTM_PUMP_ARES("Ares");
+static LLFastTimer::DeclareTimer FTM_PUMP_SERVICE("Service");
+static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback");
 
 bool LLAppViewer::mainLoop()
 {
@@ -1032,10 +1035,20 @@ bool LLAppViewer::mainLoop()
 						LLMemType mt_ip(LLMemType::MTYPE_IDLE_PUMP);
 						pingMainloopTimeout("Main:ServicePump");				
 						LLFastTimer t4(FTM_PUMP);
-						gAres->process();
-						// this pump is necessary to make the login screen show up
-						gServicePump->pump();
-						gServicePump->callback();
+						{
+							LLFastTimer t(FTM_PUMP_ARES);
+							gAres->process();
+						}
+						{
+							LLFastTimer t(FTM_PUMP_SERVICE);
+							// this pump is necessary to make the login screen show up
+							gServicePump->pump();
+
+							{
+								LLFastTimer t(FTM_SERVICE_CALLBACK);
+								gServicePump->callback();
+							}
+						}
 					}
 					
 					resumeMainloopTimeout();
@@ -3388,6 +3401,8 @@ static LLFastTimer::DeclareTimer FTM_REGION_UPDATE("Update Region");
 static LLFastTimer::DeclareTimer FTM_WORLD_UPDATE("Update World");
 static LLFastTimer::DeclareTimer FTM_NETWORK("Network");
 static LLFastTimer::DeclareTimer FTM_AGENT_NETWORK("Agent Network");
+static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot");
+static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update");
 static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager");
 
 ///////////////////////////////////////////////////////
@@ -3474,9 +3489,12 @@ void LLAppViewer::idle()
 			gAgent.moveYaw(-1.f);
 		}
 
-	    // Handle automatic walking towards points
-	    gAgentPilot.updateTarget();
-	    gAgent.autoPilot(&yaw);
+		{
+			LLFastTimer t(FTM_AGENT_AUTOPILOT);
+			// Handle automatic walking towards points
+			gAgentPilot.updateTarget();
+			gAgent.autoPilot(&yaw);
+		}
     
 	    static LLFrameTimer agent_update_timer;
 	    static U32 				last_control_flags;
@@ -3487,6 +3505,7 @@ void LLAppViewer::idle()
 		    
 	    if (flags_changed || (agent_update_time > (1.0f / (F32) AGENT_UPDATES_PER_SECOND)))
 	    {
+			LLFastTimer t(FTM_AGENT_UPDATE);
 		    // Send avatar and camera info
 		    last_control_flags = gAgent.getControlFlags();
 		    send_agent_update(TRUE);
-- 
GitLab


From 57c84c639781a9a6e1646db7cc38530400f0d22c Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Fri, 26 Mar 2010 13:55:35 -0700
Subject: [PATCH 037/683] Davep's LLDrawPoolBump changes from
 svn/linden/branches/viewer-mesh @ 114046 for deferred rendering

---
 indra/newview/lldrawpoolbump.cpp | 61 +++++++++++++++++++++-----------
 indra/newview/lldrawpoolbump.h   | 38 +++++++++++---------
 2 files changed, 62 insertions(+), 37 deletions(-)

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 7c09826c9d4..a4a8dc80b5b 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -2,25 +2,31 @@
  * @file lldrawpoolbump.cpp
  * @brief LLDrawPoolBump class implementation
  *
- * $LicenseInfo:firstyear=2003&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2003&license=viewergpl$
+ * 
+ * Copyright (c) 2003-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -141,9 +147,8 @@ void LLStandardBumpmap::restoreGL()
 										LLViewerTexture::BOOST_NONE, 
 										LLViewerTexture::LOD_TEXTURE,
 										0, 
-										0);									
-		gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setBoostLevel(LLViewerTexture::BOOST_BUMP) ;
-		gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setLoadedCallback(LLBumpImageList::onSourceStandardLoaded, 0, TRUE, FALSE, NULL, NULL );
+										0);																								
+		gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setLoadedCallback(LLBumpImageList::onSourceStandardLoaded, 0, TRUE, FALSE, NULL );
 		LLStandardBumpmap::sStandardBumpmapCount++;
 	}
 
@@ -696,6 +701,18 @@ void LLDrawPoolBump::endBump()
 	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 }
 
+S32 LLDrawPoolBump::getNumDeferredPasses()
+{ 
+	if (gSavedSettings.getBOOL("RenderObjectBump"))
+	{
+		return 1;
+	}
+	else
+	{
+		return 0;
+	}
+}
+
 void LLDrawPoolBump::beginDeferredPass(S32 pass)
 {
 	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
@@ -812,7 +829,7 @@ void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32
 	bump &= TEM_BUMP_MASK;
 	LLViewerFetchedTexture* bump_image = gStandardBumpmapList[bump].mImage;
 	if( bump_image )
-	{		
+	{
 		bump_image->addTextureStats(virtual_size);
 	}
 }
@@ -820,6 +837,7 @@ void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32
 
 void LLBumpImageList::updateImages()
 {	
+	llpushcallstacks ;
 	for (bump_image_map_t::iterator iter = mBrightnessEntries.begin(); iter != mBrightnessEntries.end(); )
 	{
 		bump_image_map_t::iterator curiter = iter++;
@@ -846,6 +864,7 @@ void LLBumpImageList::updateImages()
 			}
 		}
 	}
+	llpushcallstacks ;
 	for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); )
 	{
 		bump_image_map_t::iterator curiter = iter++;
@@ -872,6 +891,7 @@ void LLBumpImageList::updateImages()
 			}
 		}
 	}
+	llpushcallstacks ;
 }
 
 
@@ -916,8 +936,7 @@ LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedText
 			(*entries_list)[src_image->getID()]->setExplicitFormat(GL_ALPHA8, GL_ALPHA);			
 
 			// Note: this may create an LLImageGL immediately
-			src_image->setBoostLevel(LLViewerTexture::BOOST_BUMP) ;
-			src_image->setLoadedCallback( callback_func, 0, TRUE, FALSE, new LLUUID(src_image->getID()), NULL );
+			src_image->setLoadedCallback( callback_func, 0, TRUE, FALSE, new LLUUID(src_image->getID()) );
 			bump = (*entries_list)[src_image->getID()]; // In case callback was called immediately and replaced the image
 
 //			bump_total++;
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index d9c5e6ce870..2019f1df269 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -2,25 +2,31 @@
  * @file lldrawpoolbump.h
  * @brief LLDrawPoolBump class definition
  *
- * $LicenseInfo:firstyear=2003&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2003&license=viewergpl$
+ * 
+ * Copyright (c) 2003-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -73,7 +79,7 @@ protected :
 	void renderBump();
 	void endBump();
 
-	virtual S32 getNumDeferredPasses() { return 1; }
+	virtual S32 getNumDeferredPasses();
 	/*virtual*/ void beginDeferredPass(S32 pass);
 	/*virtual*/ void endDeferredPass(S32 pass);
 	/*virtual*/ void renderDeferred(S32 pass);
-- 
GitLab


From 6db60e1a695235ac6c572ac9b57ea2d26c69d115 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Mon, 5 Apr 2010 16:53:44 -0700
Subject: [PATCH 038/683] One last small change from svn//branches/viewer-mesh
 @ 114046 for render bump

---
 indra/newview/llvovolume.cpp | 56 ++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 4e3be0f703b..346fc0c4e4f 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2,25 +2,31 @@
  * @file llvovolume.cpp
  * @brief LLVOVolume class implementation
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -363,7 +369,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
 			S32 res2 = unpackTEMessage(*dp);
 			if (TEM_INVALID == res2)
 			{
-				// There's something bogus in the data that we're unpacking.
+				// Well, crap, there's something bogus in the data that we're unpacking.
 				dp->dumpBufferToLog();
 				llwarns << "Flushing cache files" << llendl;
 				std::string mask;
@@ -1850,11 +1856,6 @@ void LLVOVolume::syncMediaData(S32 texture_index, const LLSD &media_data, bool m
 	}
 	
 	LLTextureEntry *te = getTE(texture_index);
-	if(!te)
-	{
-		return ;
-	}
-
 	LL_DEBUGS("MediaOnAPrim") << "BEFORE: texture_index = " << texture_index
 		<< " hasMedia = " << te->hasMedia() << " : " 
 		<< ((NULL == te->getMediaData()) ? "NULL MEDIA DATA" : ll_pretty_print_sd(te->getMediaData()->asLLSD())) << llendl;
@@ -1972,13 +1973,9 @@ bool LLVOVolume::hasMediaPermission(const LLMediaEntry* media_entry, MediaPermTy
     }
     
     // Group permissions
-    else if (0 != (media_perms & LLMediaEntry::PERM_GROUP))
+    else if (0 != (media_perms & LLMediaEntry::PERM_GROUP) && permGroupOwner())
     {
-		LLPermissions* obj_perm = LLSelectMgr::getInstance()->findObjectPermissions(this);
-		if (obj_perm && gAgent.isInGroup(obj_perm->getGroup()))
-		{
-			return true;
-		}
+        return true;
     }
     
     // Owner permissions
@@ -3296,6 +3293,7 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
+	llpushcallstacks ;
 	if (group->changeLOD())
 	{
 		group->mLastUpdateDistance = group->mDistance;
@@ -3526,6 +3524,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 static LLFastTimer::DeclareTimer FTM_VOLUME_GEOM("Volume Geometry");
 void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 {
+	llpushcallstacks ;
 	llassert(group);
 	if (group && group->isState(LLSpatialGroup::MESH_DIRTY) && !group->isState(LLSpatialGroup::GEOM_DIRTY))
 	{
@@ -3617,6 +3616,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 
 void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort)
 {
+	llpushcallstacks ;
 	//calculate maximum number of vertices to store in a single buffer
 	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcStride(group->mSpatialPartition->mVertexDataMask);
 	max_vertices = llmin(max_vertices, (U32) 65535);
@@ -3839,7 +3839,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				}
 				else
 				{
-					if (LLPipeline::sRenderDeferred && te->getBumpmap())
+					if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap())
 					{
 						registerFace(group, facep, LLRenderPass::PASS_BUMP);
 					}
-- 
GitLab


From 92f630871386bafc4548eb9beb45063e40b6139c Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Mon, 5 Apr 2010 19:37:09 -0700
Subject: [PATCH 039/683] applied render-pipeline-7 @ 137608.  This fixes empty
 depth buffer during highlight render

---
 indra/newview/llviewerdisplay.cpp |  63 ++++++------
 indra/newview/pipeline.cpp        | 156 ++++++++++++++++--------------
 2 files changed, 118 insertions(+), 101 deletions(-)

diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 8c59b52dc28..f796fb54512 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -2,25 +2,31 @@
  * @file llviewerdisplay.cpp
  * @brief LLViewerDisplay class implementation
  *
- * $LicenseInfo:firstyear=2004&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -163,6 +169,7 @@ void display_startup()
 void display_update_camera()
 {
 	LLMemType mt_uc(LLMemType::MTYPE_DISPLAY_UPDATE_CAMERA);
+	llpushcallstacks ;
 	// TODO: cut draw distance down if customizing avatar?
 	// TODO: cut draw distance on per-parcel basis?
 
@@ -338,9 +345,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived.
 
 		S32 attach_count = 0;
-		if (isAgentAvatarValid())
+		if (gAgent.getAvatarObject())
 		{
-			attach_count = gAgentAvatarp->getAttachmentCount();
+			attach_count = gAgent.getAvatarObject()->getAttachmentCount();
 		}
 		F32 teleport_save_time = TELEPORT_EXPIRY + TELEPORT_EXPIRY_PER_ATTACHMENT * attach_count;
 		F32 teleport_elapsed = gTeleportDisplayTimer.getElapsedTimeF32();
@@ -591,7 +598,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 		LLPipeline::sFastAlpha = gSavedSettings.getBOOL("RenderFastAlpha");
 		LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip");
-		LLVOAvatar::sMaxVisible = (U32)gSavedSettings.getS32("RenderAvatarMaxVisible");
+		LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible");
 		LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate");
 
 		S32 occlusion = LLPipeline::sUseOcclusion;
@@ -693,7 +700,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		// Doing this here gives hardware occlusion queries extra time to complete
 		LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages");
 		LLError::LLCallStacks::clear() ;
-		
+		llpushcallstacks ;
+
 		{
 			LLMemType mt_iu(LLMemType::MTYPE_DISPLAY_IMAGE_UPDATE);
 			LLFastTimer t(FTM_IMAGE_UPDATE);
@@ -711,6 +719,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			LLImageGL::deleteDeadTextures();
 			stop_glerror();
 		}
+		llpushcallstacks ;
 		///////////////////////////////////
 		//
 		// StateSort
@@ -723,7 +732,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		{
 			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
 			LLMemType mt_ss(LLMemType::MTYPE_DISPLAY_STATE_SORT);
-			gPipeline.sAllowRebuildPriorityGroup = TRUE ;
 			gPipeline.stateSort(*LLViewerCamera::getInstance(), result);
 			stop_glerror();
 				
@@ -861,12 +869,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			}
 		}
 
-		/// We copy the frame buffer straight into a texture here,
-		/// and then display it again with compositor effects.
-		/// Using render to texture would be faster/better, but I don't have a 
-		/// grasp of their full display stack just yet.
-		// gPostProcess->apply(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw());
-		
 		if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender)
 		{
 			gPipeline.renderDeferredLighting();
@@ -1024,10 +1026,11 @@ LLRect get_whole_screen_region()
 
 bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model)
 {
-	if (isAgentAvatarValid() && gAgentAvatarp->hasHUDAttachment())
+	LLVOAvatar* my_avatarp = gAgent.getAvatarObject();
+	if (my_avatarp && my_avatarp->hasHUDAttachment())
 	{
 		F32 zoom_level = gAgentCamera.mHUDCurZoom;
-		LLBBox hud_bbox = gAgentAvatarp->getHUDBBox();
+		LLBBox hud_bbox = my_avatarp->getHUDBBox();
 		
 		F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
 		proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
@@ -1109,7 +1112,7 @@ void render_ui(F32 zoom_factor, int subfield)
 		{
 			gPipeline.renderBloom(gSnapshot, zoom_factor, subfield);
 		}
-
+		
 		render_hud_elements();
 		render_hud_attachments();
 	}
@@ -1291,7 +1294,7 @@ void render_ui_2d()
 	gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
 
 	// render outline for HUD
-	if (isAgentAvatarValid() && gAgentCamera.mHUDCurZoom < 0.98f)
+	if (gAgent.getAvatarObject() && gAgentCamera.mHUDCurZoom < 0.98f)
 	{
 		glPushMatrix();
 		S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index a3b402c1a37..5e54d4ab78f 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2,25 +2,31 @@
  * @file pipeline.cpp
  * @brief Rendering pipeline.
  *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2005&license=viewergpl$
+ * 
+ * Copyright (c) 2005-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -278,7 +284,6 @@ BOOL	LLPipeline::sRenderFrameTest = FALSE;
 BOOL	LLPipeline::sRenderAttachedLights = TRUE;
 BOOL	LLPipeline::sRenderAttachedParticles = TRUE;
 BOOL	LLPipeline::sRenderDeferred = FALSE;
-BOOL    LLPipeline::sAllowRebuildPriorityGroup = FALSE ;
 S32		LLPipeline::sVisibleLightCount = 0;
 F32		LLPipeline::sMinRenderSize = 0.f;
 
@@ -356,7 +361,6 @@ void LLPipeline::init()
 	sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
 	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
-	LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");
 	sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights");
 	sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles");
 
@@ -1776,19 +1780,13 @@ void LLPipeline::updateGL()
 
 void LLPipeline::rebuildPriorityGroups()
 {
-	if(!sAllowRebuildPriorityGroup)
-	{
-		return ;
-	}
-	sAllowRebuildPriorityGroup = FALSE ;
-
 	LLTimer update_timer;
 	LLMemType mt(LLMemType::MTYPE_PIPELINE);
 	
 	assertInitialized();
 
 	// Iterate through all drawables on the priority build queue,
-	for (LLSpatialGroup::sg_vector_t::iterator iter = mGroupQ1.begin();
+	for (LLSpatialGroup::sg_list_t::iterator iter = mGroupQ1.begin();
 		 iter != mGroupQ1.end(); ++iter)
 	{
 		LLSpatialGroup* group = *iter;
@@ -1801,6 +1799,7 @@ void LLPipeline::rebuildPriorityGroups()
 		
 void LLPipeline::rebuildGroups()
 {
+	llpushcallstacks ;
 	// Iterate through some drawables on the non-priority build queue
 	S32 size = (S32) mGroupQ2.size();
 	S32 min_count = llclamp((S32) ((F32) (size * size)/4096*0.25f), 1, size);
@@ -2202,6 +2201,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)
 	{
 		LLSpatialGroup* group = *iter;
@@ -2219,6 +2219,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 			}
 		}
 	}
+
 	for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
 	{
 		LLSpatialGroup* group = *iter;
@@ -2234,6 +2235,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 		}
 	}
 	
+
 	if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
 	{
 		for (LLCullResult::bridge_list_t::iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
@@ -2247,6 +2249,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 			}
 		}
 	}
+
 	{
 		LLFastTimer ftm(FTM_STATESORT_DRAWABLE);
 		for (LLCullResult::drawable_list_t::iterator iter = sCull->beginVisibleList();
@@ -2259,12 +2262,13 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 			}
 		}
 	}
+
 	{
 		LLFastTimer ftm(FTM_CLIENT_COPY);
 		LLVertexBuffer::clientCopy();
 	}
-	
-	postSort(camera);	
+
+	postSort(camera);
 }
 
 void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
@@ -2534,7 +2538,6 @@ void LLPipeline::postSort(LLCamera& camera)
 
 	assertInitialized();
 
-	llpushcallstacks ;
 	//rebuild drawable geometry
 	for (LLCullResult::sg_list_t::iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i)
 	{
@@ -2545,7 +2548,7 @@ void LLPipeline::postSort(LLCamera& camera)
 			group->rebuildGeom();
 		}
 	}
-	llpushcallstacks ;
+
 	//rebuild groups
 	sCull->assertDrawMapsEmpty();
 
@@ -2565,7 +2568,6 @@ void LLPipeline::postSort(LLCamera& camera)
 
 
 	rebuildPriorityGroups();
-	llpushcallstacks ;
 
 	const S32 bin_count = 1024*8;
 		
@@ -2667,7 +2669,7 @@ void LLPipeline::postSort(LLCamera& camera)
 
 		std::sort(sCull->beginAlphaGroups(), sCull->endAlphaGroups(), LLSpatialGroup::CompareDepthGreater());
 	}
-	llpushcallstacks ;
+	
 	// only render if the flag is set. The flag is only set if we are in edit mode or the toggle is set in the menus
 	if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender)
 	{
@@ -2715,7 +2717,7 @@ void LLPipeline::postSort(LLCamera& camera)
 			forAllVisibleDrawables(renderSoundHighlights);
 		}
 	}
-	llpushcallstacks ;
+
 	// If managing your telehub, draw beacons at telehub and currently selected spawnpoint.
 	if (LLFloaterTelehub::renderBeacons())
 	{
@@ -2745,7 +2747,6 @@ void LLPipeline::postSort(LLCamera& camera)
 	}
 
 	//LLSpatialGroup::sNoDelete = FALSE;
-	llpushcallstacks ;
 }
 
 
@@ -2957,9 +2958,6 @@ void LLPipeline::renderHighlights()
 	}
 }
 
-//debug use
-U32 LLPipeline::sCurRenderPoolType = 0 ;
-
 void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_RENDER_GEOM);
@@ -3069,9 +3067,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 			
 			cur_type = poolp->getType();
 
-			//debug use
-			sCurRenderPoolType = cur_type ;
-
 			if (occlude && cur_type >= LLDrawPool::POOL_GRASS)
 			{
 				occlude = FALSE;
@@ -3409,26 +3404,14 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
 	gGLLastMatrix = NULL;
 	glLoadMatrixd(gGLModelView);
 
-	renderHighlights();
-	mHighlightFaces.clear();
-
-	renderDebug();
-
-	LLVertexBuffer::unbind();
-
-	if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
-	{
-		// Render debugging beacons.
-		gObjectList.renderObjectBeacons();
-		gObjectList.resetObjectBeacons();
-	}
-
 	if (occlude)
 	{
 		occlude = FALSE;
 		gGLLastMatrix = NULL;
 		glLoadMatrixd(gGLModelView);
 		doOcclusion(camera);
+		gGLLastMatrix = NULL;
+		glLoadMatrix(gGLModelView);
 	}
 }
 
@@ -3861,14 +3844,15 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects, BOOL render
 	}
 
 	// pick HUD objects
-	if (isAgentAvatarValid() && sShowHUDAttachments)
+	LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+	if (avatarp && sShowHUDAttachments)
 	{
 		glh::matrix4f save_proj(glh_get_current_projection());
 		glh::matrix4f save_model(glh_get_current_modelview());
 
 		setup_hud_matrices(screen_rect);
-		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-			 iter != gAgentAvatarp->mAttachmentPoints.end(); )
+		for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); 
+			 iter != avatarp->mAttachmentPoints.end(); )
 		{
 			LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 			LLViewerJointAttachment* attachment = curiter->second;
@@ -3968,9 +3952,9 @@ void LLPipeline::rebuildPools()
 		max_count--;
 	}
 
-	if (isAgentAvatarValid())
+	if (gAgent.getAvatarObject())
 	{
-		gAgentAvatarp->rebuildHUD();
+		gAgent.getAvatarObject()->rebuildHUD();
 	}
 }
 
@@ -4602,8 +4586,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 		glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 	}
 
-	if (isAgentAvatarValid() &&
-		gAgentAvatarp->mSpecialRenderMode == 3)
+	if (gAgent.getAvatarObject() &&
+		gAgent.getAvatarObject()->mSpecialRenderMode == 3)
 	{
 		LLColor4  light_color = LLColor4::white;
 		light_color.mV[3] = 0.0f;
@@ -4712,13 +4696,15 @@ void LLPipeline::enableLightsDynamic()
 		glColor4f(0.f, 0.f, 0.f, 1.f); // no local lighting by default
 	}
 
-	if (isAgentAvatarValid() && getLightingDetail() <= 0)
+	LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+
+	if (avatarp && getLightingDetail() <= 0)
 	{
-		if (gAgentAvatarp->mSpecialRenderMode == 0) // normal
+		if (avatarp->mSpecialRenderMode == 0) // normal
 		{
 			gPipeline.enableLightsAvatar();
 		}
-		else if (gAgentAvatarp->mSpecialRenderMode >= 1)  // anim preview
+		else if (avatarp->mSpecialRenderMode >= 1)  // anim preview
 		{
 			gPipeline.enableLightsAvatarEdit(LLColor4(0.7f, 0.6f, 0.3f, 1.f));
 		}
@@ -5360,7 +5346,6 @@ void LLPipeline::resetVertexBuffers()
 {
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
 	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
-	LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");
 
 	for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
 			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
@@ -5818,6 +5803,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 		gGL.getTexUnit(0)->activate();
 		gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+
+		if (LLRenderTarget::sUseFBO)
+		{ //copy depth buffer from mScreen to framebuffer
+			LLRenderTarget::copyContentsToFramebuffer(mScreen, 0, 0, mScreen.getWidth(), mScreen.getHeight(), 
+				0, 0, mScreen.getWidth(), mScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+		}
 	}
 	
 
@@ -6896,6 +6887,24 @@ void LLPipeline::renderDeferredLighting()
 		mRenderTypeMask = render_mask;
 	}
 
+	{
+		//render highlights, etc.
+		renderHighlights();
+		mHighlightFaces.clear();
+
+		renderDebug();
+
+		LLVertexBuffer::unbind();
+
+		if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
+		{
+			// Render debugging beacons.
+			gObjectList.renderObjectBeacons();
+			LLHUDObject::renderAll();
+			gObjectList.resetObjectBeacons();
+		}
+	}
+
 	mScreen.flush();
 						
 }
@@ -7101,18 +7110,18 @@ inline float sgn(float a)
 }
 
 void LLPipeline::generateWaterReflection(LLCamera& camera_in)
-{	
+{
 	if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate)
 	{
-		BOOL skip_avatar_update = FALSE;
-		if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
+		LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+		if (gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
 		{
-			skip_avatar_update = TRUE;
+			avatarp = NULL;
 		}
 
-		if (!skip_avatar_update)
+		if (avatarp)
 		{
-			gAgentAvatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON);
+			avatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON);
 		}
 		LLVertexBuffer::unbind();
 
@@ -7197,6 +7206,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 
 			glCullFace(GL_FRONT);
 
+			
 			static LLCullResult ref_result;
 			U32 ref_mask = 0;
 			if (LLDrawPoolWater::sNeedsDistortionUpdate)
@@ -7248,6 +7258,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 				ref_mask = mRenderTypeMask;
 				mRenderTypeMask = mask;
 			}
+
 			if (LLDrawPoolWater::sNeedsDistortionUpdate)
 			{
 				mRenderTypeMask = ref_mask;
@@ -7265,6 +7276,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 		}
 
 		camera.setOrigin(camera_in.getOrigin());
+
 		//render distortion map
 		static BOOL last_update = TRUE;
 		if (last_update)
@@ -7321,6 +7333,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 			glClear(GL_DEPTH_BUFFER_BIT);
 		}
 		glClearColor(0.f, 0.f, 0.f, 0.f);
+
 		gViewerWindow->setup3DViewport();
 		mRenderTypeMask = type_mask;
 		LLDrawPoolWater::sNeedsReflectionUpdate = FALSE;
@@ -7332,9 +7345,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 		LLGLState::checkTextureChannels();
 		LLGLState::checkClientArrays();
 
-		if (!skip_avatar_update)
+		if (avatarp)
 		{
-			gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
+			avatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
 		}
 	}
 }
@@ -7833,6 +7846,7 @@ void LLPipeline::renderHighlight(const LLViewerObject* obj, F32 fade)
 void LLPipeline::generateHighlight(LLCamera& camera)
 {
 	//render highlighted object as white into offscreen render target
+	
 	if (mHighlightObject.notNull())
 	{
 		mHighlightSet.insert(HighlightItem(mHighlightObject));
-- 
GitLab


From 8eab0f9b41979cb5407d7dde3ded2774e8d2f571 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 16 Dec 2009 12:31:24 -0600
Subject: [PATCH 040/683] Tracking down stalls in llpumpio and agent updates.

---
 indra/llmessage/llpumpio.cpp  | 43 +++++++++++++++++++++--------------
 indra/newview/llappviewer.cpp | 33 +++++++++++++++++++++------
 2 files changed, 52 insertions(+), 24 deletions(-)

diff --git a/indra/llmessage/llpumpio.cpp b/indra/llmessage/llpumpio.cpp
index 393e6e98131..e3ce2c5ad34 100644
--- a/indra/llmessage/llpumpio.cpp
+++ b/indra/llmessage/llpumpio.cpp
@@ -4,25 +4,31 @@
  * @date 2004-11-21
  * @brief Implementation of the i/o pump and related functions.
  *
- * $LicenseInfo:firstyear=2004&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -438,13 +444,13 @@ void LLPumpIO::pump()
 	pump(DEFAULT_POLL_TIMEOUT);
 }
 
-static LLFastTimer::DeclareTimer FTM_PUMP("Pump");
+static LLFastTimer::DeclareTimer FTM_PUMP_IO("Pump IO");
 
 //timeout is in microseconds
 void LLPumpIO::pump(const S32& poll_timeout)
 {
 	LLMemType m1(LLMemType::MTYPE_IO_PUMP);
-	LLFastTimer t1(FTM_PUMP);
+	LLFastTimer t1(FTM_PUMP_IO);
 	//llinfos << "LLPumpIO::pump()" << llendl;
 
 	// Run any pending runners.
@@ -772,6 +778,8 @@ bool LLPumpIO::respond(
 	return true;
 }
 
+static LLFastTimer::DeclareTimer FTM_PUMP_CALLBACK_CHAIN("Chain");
+
 void LLPumpIO::callback()
 {
 	LLMemType m1(LLMemType::MTYPE_IO_PUMP);
@@ -793,6 +801,7 @@ void LLPumpIO::callback()
 		callbacks_t::iterator end = mCallbacks.end();
 		for(; it != end; ++it)
 		{
+			LLFastTimer t(FTM_PUMP_CALLBACK_CHAIN);
 			// it's always the first and last time for respone chains
 			(*it).mHead = (*it).mChainLinks.begin();
 			(*it).mInit = true;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 43c8c679c69..6ec42669252 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -922,6 +922,11 @@ static LLFastTimer::DeclareTimer FTM_LFS("LFS Thread");
 static LLFastTimer::DeclareTimer FTM_PAUSE_THREADS("Pause Threads");
 static LLFastTimer::DeclareTimer FTM_IDLE("Idle");
 static LLFastTimer::DeclareTimer FTM_PUMP("Pump");
+static LLFastTimer::DeclareTimer FTM_PUMP_ARES("Ares");
+static LLFastTimer::DeclareTimer FTM_PUMP_SERVICE("Service");
+static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback");
+static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot");
+static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update");
 
 bool LLAppViewer::mainLoop()
 {
@@ -1033,10 +1038,20 @@ bool LLAppViewer::mainLoop()
 						LLMemType mt_ip(LLMemType::MTYPE_IDLE_PUMP);
 						pingMainloopTimeout("Main:ServicePump");				
 						LLFastTimer t4(FTM_PUMP);
-						gAres->process();
-						// this pump is necessary to make the login screen show up
-						gServicePump->pump();
-						gServicePump->callback();
+						{
+							LLFastTimer t(FTM_PUMP_ARES);
+							gAres->process();
+						}
+						{
+							LLFastTimer t(FTM_PUMP_SERVICE);
+							// this pump is necessary to make the login screen show up
+							gServicePump->pump();
+
+							{
+								LLFastTimer t(FTM_SERVICE_CALLBACK);
+								gServicePump->callback();
+							}
+						}
 					}
 					
 					resumeMainloopTimeout();
@@ -3495,9 +3510,12 @@ void LLAppViewer::idle()
 			gAgent.moveYaw(-1.f);
 		}
 
-	    // Handle automatic walking towards points
-	    gAgentPilot.updateTarget();
-	    gAgent.autoPilot(&yaw);
+		{
+			LLFastTimer t(FTM_AGENT_AUTOPILOT);
+			// Handle automatic walking towards points
+			gAgentPilot.updateTarget();
+			gAgent.autoPilot(&yaw);
+		}
     
 	    static LLFrameTimer agent_update_timer;
 	    static U32 				last_control_flags;
@@ -3508,6 +3526,7 @@ void LLAppViewer::idle()
 		    
 	    if (flags_changed || (agent_update_time > (1.0f / (F32) AGENT_UPDATES_PER_SECOND)))
 	    {
+		    LLFastTimer t(FTM_AGENT_UPDATE);
 		    // Send avatar and camera info
 		    last_control_flags = gAgent.getControlFlags();
 		    send_agent_update(TRUE);
-- 
GitLab


From 5015886e1763887f534321790d56b6cee5a75dfa Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 18 Dec 2009 13:21:55 -0600
Subject: [PATCH 041/683] Timers to track time spent waiting on message system.

---
 indra/newview/llviewermessage.cpp | 2 ++
 indra/newview/llworld.cpp         | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 0f56b7ebd76..0489077dc89 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -3144,6 +3144,7 @@ const F32 THRESHOLD_HEAD_ROT_QDOT = 0.9997f;	// ~= 2.5 degrees -- if its less th
 const F32 MAX_HEAD_ROT_QDOT = 0.99999f;			// ~= 0.5 degrees -- if its greater than this then no need to update head_rot
 												// between these values we delay the updates (but no more than one second)
 
+static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE_SEND("Send Message");
 
 void send_agent_update(BOOL force_send, BOOL send_reliable)
 {
@@ -3302,6 +3303,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 
 	if (duplicate_count < DUP_MSGS && !gDisconnected)
 	{
+		LLFastTimer t(FTM_AGENT_UPDATE_SEND);
 		// Build the message
 		msg->newMessageFast(_PREHASH_AgentUpdate);
 		msg->nextBlockFast(_PREHASH_AgentData);
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 118d7f8d08d..feab6d126b8 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -1024,9 +1024,11 @@ void LLWorld::disconnectRegions()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_ENABLE_SIMULATOR("Enable Sim");
 
 void process_enable_simulator(LLMessageSystem *msg, void **user_data)
 {
+	LLFastTimer t(FTM_ENABLE_SIMULATOR);
 	// enable the appropriate circuit for this simulator and 
 	// add its values into the gSimulator structure
 	U64		handle;
-- 
GitLab


From 130b6fb7b56a832fa8a3be1c605a48d70cd1bee8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 18 Dec 2009 13:21:55 -0600
Subject: [PATCH 042/683] Timers to track time spent waiting on message system.

---
 indra/newview/llviewermessage.cpp | 2 ++
 indra/newview/llworld.cpp         | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index c542459cdbd..cb3f3c8edd9 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -3316,6 +3316,7 @@ const F32 THRESHOLD_HEAD_ROT_QDOT = 0.9997f;	// ~= 2.5 degrees -- if its less th
 const F32 MAX_HEAD_ROT_QDOT = 0.99999f;			// ~= 0.5 degrees -- if its greater than this then no need to update head_rot
 												// between these values we delay the updates (but no more than one second)
 
+static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE_SEND("Send Message");
 
 void send_agent_update(BOOL force_send, BOOL send_reliable)
 {
@@ -3474,6 +3475,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 
 	if (duplicate_count < DUP_MSGS && !gDisconnected)
 	{
+		LLFastTimer t(FTM_AGENT_UPDATE_SEND);
 		// Build the message
 		msg->newMessageFast(_PREHASH_AgentUpdate);
 		msg->nextBlockFast(_PREHASH_AgentData);
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 0b63f5efbde..c7148f88260 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -1028,9 +1028,11 @@ void LLWorld::disconnectRegions()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_ENABLE_SIMULATOR("Enable Sim");
 
 void process_enable_simulator(LLMessageSystem *msg, void **user_data)
 {
+	LLFastTimer t(FTM_ENABLE_SIMULATOR);
 	// enable the appropriate circuit for this simulator and 
 	// add its values into the gSimulator structure
 	U64		handle;
-- 
GitLab


From 0ed1cd97d4cd1fa11ca21b1b324c80f446f6e675 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 18 Dec 2009 17:14:38 -0600
Subject: [PATCH 043/683] Fix for compiler errors introduced in merge.

---
 indra/llcommon/llthread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index f8c7efa7cc8..5d5ecd62fc3 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -166,7 +166,7 @@ class LL_COMMON_API LLMutex
 	
 	apr_pool_t			*mAPRPoolp;
 	BOOL				mIsLocalPool;
-	S32					mLockCount;
+	
 #if MUTEX_DEBUG
 	std::map<U32, BOOL> mIsLocked;
 #endif
-- 
GitLab


From 5562dc36a1555480ffbc4e45342206de003254af Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 21 Dec 2009 12:23:58 -0600
Subject: [PATCH 044/683] Fix for OSX hating thread local state (hopefully).

---
 indra/llcommon/llthread.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index df7ea214cc5..0385569a02e 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -62,7 +62,10 @@
 // 
 //----------------------------------------------------------------------------
 
+#if !LL_DARWIN
 U32 ll_thread_local sThreadID = 0;
+#endif 
+
 U32 LLThread::sIDIter = 0;
 
 //
@@ -75,7 +78,9 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
 	// Set thread state to running
 	threadp->mStatus = RUNNING;
 
+#if !LL_DARWIN
 	sThreadID = threadp->mID;
+#endif
 
 	// Run the user supplied function
 	threadp->run();
@@ -312,12 +317,16 @@ LLMutex::~LLMutex()
 
 void LLMutex::lock()
 {
+#if LL_DARWIN
+	if (mLockingThread == LLThread::currentID())
+#else
 	if (mLockingThread == sThreadID)
+#endif
 	{ //redundant lock
 		mCount++;
 		return;
 	}
-
+	
 	apr_thread_mutex_lock(mAPRMutexp);
 	
 #if MUTEX_DEBUG
@@ -328,7 +337,11 @@ void LLMutex::lock()
 	mIsLocked[id] = TRUE;
 #endif
 
+#if LL_DARWIN
+	mLockingThread = LLThread::currentID();
+#else
 	mLockingThread = sThreadID;
+#endif
 }
 
 void LLMutex::unlock()
-- 
GitLab


From a0802dd33996df650a473577fc75bf8276f0d20b Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 22 Dec 2009 17:48:52 -0600
Subject: [PATCH 045/683] Added prim cost equivalency to UI for importer and
 tools floater.

---
 indra/newview/llfloatertools.cpp |  2 +-
 indra/newview/llselectmgr.cpp    | 25 ++++++++++++++++++++++++-
 indra/newview/llselectmgr.h      |  2 +-
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp
index babef5b63df..41bb239fda6 100644
--- a/indra/newview/llfloatertools.cpp
+++ b/indra/newview/llfloatertools.cpp
@@ -423,7 +423,7 @@ void LLFloaterTools::refresh()
 	LLResMgr::getInstance()->getIntegerString(obj_count_string, LLSelectMgr::getInstance()->getSelection()->getRootObjectCount());
 	childSetTextArg("obj_count",  "[COUNT]", obj_count_string);	
 	std::string prim_count_string;
-	LLResMgr::getInstance()->getIntegerString(prim_count_string, LLSelectMgr::getInstance()->getSelection()->getObjectCount());
+	LLResMgr::getInstance()->getIntegerString(prim_count_string, LLSelectMgr::getInstance()->getSelection()->getObjectCount(TRUE));
 	childSetTextArg("prim_count", "[COUNT]", prim_count_string);
 
 	// calculate selection rendering cost
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 852f58e3544..4ef68df634e 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -68,6 +68,7 @@
 #include "llhudmanager.h"
 #include "llinventorymodel.h"
 #include "llmenugl.h"
+#include "llmeshrepository.h"
 #include "llmutelist.h"
 #include "llsidepaneltaskinfo.h"
 #include "llslurl.h"
@@ -6124,10 +6125,32 @@ BOOL LLObjectSelection::isEmpty() const
 //-----------------------------------------------------------------------------
 // getObjectCount() - returns number of non null objects
 //-----------------------------------------------------------------------------
-S32 LLObjectSelection::getObjectCount()
+S32 LLObjectSelection::getObjectCount(BOOL mesh_adjust)
 {
 	cleanupNodes();
 	S32 count = mList.size();
+
+	if (mesh_adjust)
+	{
+		for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+		{
+			LLSelectNode* node = *iter;
+			LLViewerObject* object = node->getObject();
+			
+			if (object && object->getVolume())
+			{
+				LLVOVolume* vobj = (LLVOVolume*) object;
+				if (vobj->isMesh())
+				{
+					LLUUID mesh_id = vobj->getVolume()->getParams().getSculptID();
+					U32 cost = gMeshRepo.getResourceCost(mesh_id);
+					count += cost-1;
+				}
+			}
+
+		}
+	}
+
 	return count;
 }
 
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index f7ce3f72aab..066adf0c10f 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -291,7 +291,7 @@ class LLObjectSelection : public LLRefCount
 	LLSelectNode* findNode(LLViewerObject* objectp);
 
 	// count members
-	S32 getObjectCount();
+	S32 getObjectCount(BOOL mesh_adjust = FALSE);
 	S32 getTECount();
 	S32 getRootObjectCount();
 
-- 
GitLab


From 512a5736dceb1cc6db286e5f5baad867ac7a5935 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Wed, 23 Dec 2009 14:40:48 -0600
Subject: [PATCH 046/683] LODs for scene upload

---
 indra/llmath/llvolume.cpp    | 14 ++++++++++++++
 indra/llmath/llvolume.h      |  2 ++
 indra/newview/CMakeLists.txt |  2 ++
 3 files changed, 18 insertions(+)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 844918432d2..de32070da18 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -3807,6 +3807,20 @@ S32 LLVolume::getNumTriangleIndices() const
 	return count;
 }
 
+
+S32 LLVolume::getNumTriangles() const
+{
+	U32 triangle_count = 0;
+
+	for (S32 i = 0; i < getNumVolumeFaces(); ++i)
+	{
+		triangle_count += getVolumeFace(i).mIndices.size()/3;
+	}
+
+	return triangle_count;
+}
+
+
 //-----------------------------------------------------------------------------
 // generateSilhouetteVertices()
 //-----------------------------------------------------------------------------
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 9970b24a943..e3ab648fe33 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -912,6 +912,8 @@ class LLVolume : public LLRefCount
 	// returns number of triangle indeces required for path/profile mesh
 	S32 getNumTriangleIndices() const;
 
+	S32 getNumTriangles() const;
+
 	void generateSilhouetteVertices(std::vector<LLVector3> &vertices, 
 									std::vector<LLVector3> &normals, 
 									std::vector<S32> &segments, 
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 193109e9f4f..cae426e37be 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -285,6 +285,7 @@ set(viewer_SOURCE_FILES
     llmemoryview.cpp
     llmenucommands.cpp
     llmeshrepository.cpp
+    llmeshreduction.cpp
     llmetricperformancetester.cpp
     llmimetypes.cpp
     llmorphview.cpp
@@ -796,6 +797,7 @@ set(viewer_HEADER_FILES
     llmemoryview.h
     llmenucommands.h
     llmeshrepository.h
+    llmeshreduction.h
     llmetricperformancetester.h
     llmimetypes.h
     llmorphview.h
-- 
GitLab


From e833e7ad442f5b59f95c6ccfcaaf1d103d247d69 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 4 Jan 2010 11:50:04 -0600
Subject: [PATCH 047/683] CTS-54 Fix for SSAO artifacts far away.

---
 .../shaders/class1/deferred/sunLightF.glsl    | 82 +++++++++++--------
 .../shaders/class2/deferred/sunLightF.glsl    | 82 +++++++++++--------
 2 files changed, 92 insertions(+), 72 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
index 22bdd2c7f34..fafc2ae3cc0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -53,51 +53,61 @@ vec4 getPosition(vec2 pos_screen)
 //calculate decreases in ambient lighting when crowded out (SSAO)
 float calcAmbientOcclusion(vec4 pos, vec3 norm)
 {
-	vec2 kern[8];
-	// exponentially (^2) distant occlusion samples spread around origin
-	kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
-	kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
-	kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
-	kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
-	kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
-	kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
-	kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
-	kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
-	vec2 pos_screen = vary_fragcoord.xy;
-	vec3 pos_world = pos.xyz;
-	vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
+	float ret = 1.0;
 	
-	float angle_hidden = 0.0;
-	int points = 0;
+	float dist = dot(pos.xyz,pos.xyz);
 	
-	float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-	
-	// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
-	for (int i = 0; i < 8; i++)
+	if (dist < 64.0*64.0)
 	{
-		vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
-		vec3 samppos_world = getPosition(samppos_screen).xyz; 
+		vec2 kern[8];
+		// exponentially (^2) distant occlusion samples spread around origin
+		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+		vec2 pos_screen = vary_fragcoord.xy;
+		vec3 pos_world = pos.xyz;
+		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
 		
-		vec3 diff = pos_world - samppos_world;
-		float dist2 = dot(diff, diff);
+		float angle_hidden = 0.0;
+		int points = 0;
 		
-		// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
-		// --> solid angle shrinking by the square of distance
-		//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
-		//(k should vary inversely with # of samples, but this is taken care of later)
+		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
 		
-		//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
-		//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
-		angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+		for (int i = 0; i < 8; i++)
+		{
+			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+			vec3 samppos_world = getPosition(samppos_screen).xyz; 
+			
+			vec3 diff = pos_world - samppos_world;
+			float dist2 = dot(diff, diff);
+			
+			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+			// --> solid angle shrinking by the square of distance
+			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+			//(k should vary inversely with # of samples, but this is taken care of later)
+			
+			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
+			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
+			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+			
+			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
+			points = points + int(diff.z > -1.0);
+		}
 		
-		// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
-		points = points + int(diff.z > -1.0);
+		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+		
+		ret = (1.0 - (float(points != 0) * angle_hidden));
+		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
 	}
 	
-	angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-	
-	return (1.0 - (float(points != 0) * angle_hidden));
+	return min(ret, 1.0);
 }
 
 void main() 
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 4333cc64a78..74a948f584e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -55,51 +55,61 @@ vec4 getPosition(vec2 pos_screen)
 //calculate decreases in ambient lighting when crowded out (SSAO)
 float calcAmbientOcclusion(vec4 pos, vec3 norm)
 {
-	vec2 kern[8];
-	// exponentially (^2) distant occlusion samples spread around origin
-	kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
-	kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
-	kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
-	kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
-	kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
-	kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
-	kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
-	kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
-	vec2 pos_screen = vary_fragcoord.xy;
-	vec3 pos_world = pos.xyz;
-	vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-	
-	float angle_hidden = 0.0;
-	int points = 0;
+	float ret = 1.0;
 	
-	float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
+	float dist = dot(pos.xyz,pos.xyz);
 	
-	// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
-	for (int i = 0; i < 8; i++)
+	if (dist < 64.0*64.0)
 	{
-		vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
-		vec3 samppos_world = getPosition(samppos_screen).xyz; 
+		vec2 kern[8];
+		// exponentially (^2) distant occlusion samples spread around origin
+		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+		vec2 pos_screen = vary_fragcoord.xy;
+		vec3 pos_world = pos.xyz;
+		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
 		
-		vec3 diff = pos_world - samppos_world;
-		float dist2 = dot(diff, diff);
+		float angle_hidden = 0.0;
+		int points = 0;
 		
-		// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
-		// --> solid angle shrinking by the square of distance
-		//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
-		//(k should vary inversely with # of samples, but this is taken care of later)
+		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
 		
-		//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
-		//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
-		angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+		for (int i = 0; i < 8; i++)
+		{
+			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+			vec3 samppos_world = getPosition(samppos_screen).xyz; 
+			
+			vec3 diff = pos_world - samppos_world;
+			float dist2 = dot(diff, diff);
+			
+			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+			// --> solid angle shrinking by the square of distance
+			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+			//(k should vary inversely with # of samples, but this is taken care of later)
+			
+			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
+			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
+			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+			
+			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
+			points = points + int(diff.z > -1.0);
+		}
 		
-		// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
-		points = points + int(diff.z > -1.0);
+		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+		
+		ret = (1.0 - (float(points != 0) * angle_hidden));
+		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
 	}
 	
-	angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-	
-	return (1.0 - (float(points != 0) * angle_hidden));
+	return min(ret, 1.0);
 }
 
 float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
-- 
GitLab


From ba2a45ecaedf0a4e532e9634f2d751c1419d2b6c Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 4 Jan 2010 11:50:04 -0600
Subject: [PATCH 048/683] CTS-54 Fix for SSAO artifacts far away.

---
 .../shaders/class1/deferred/sunLightF.glsl    | 82 ++++++++++--------
 .../shaders/class2/deferred/sunLightF.glsl    | 86 +++++++++++--------
 2 files changed, 94 insertions(+), 74 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
index 22bdd2c7f34..fafc2ae3cc0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -53,51 +53,61 @@ vec4 getPosition(vec2 pos_screen)
 //calculate decreases in ambient lighting when crowded out (SSAO)
 float calcAmbientOcclusion(vec4 pos, vec3 norm)
 {
-	vec2 kern[8];
-	// exponentially (^2) distant occlusion samples spread around origin
-	kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
-	kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
-	kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
-	kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
-	kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
-	kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
-	kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
-	kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
-	vec2 pos_screen = vary_fragcoord.xy;
-	vec3 pos_world = pos.xyz;
-	vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
+	float ret = 1.0;
 	
-	float angle_hidden = 0.0;
-	int points = 0;
+	float dist = dot(pos.xyz,pos.xyz);
 	
-	float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-	
-	// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
-	for (int i = 0; i < 8; i++)
+	if (dist < 64.0*64.0)
 	{
-		vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
-		vec3 samppos_world = getPosition(samppos_screen).xyz; 
+		vec2 kern[8];
+		// exponentially (^2) distant occlusion samples spread around origin
+		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+		vec2 pos_screen = vary_fragcoord.xy;
+		vec3 pos_world = pos.xyz;
+		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
 		
-		vec3 diff = pos_world - samppos_world;
-		float dist2 = dot(diff, diff);
+		float angle_hidden = 0.0;
+		int points = 0;
 		
-		// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
-		// --> solid angle shrinking by the square of distance
-		//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
-		//(k should vary inversely with # of samples, but this is taken care of later)
+		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
 		
-		//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
-		//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
-		angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+		for (int i = 0; i < 8; i++)
+		{
+			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+			vec3 samppos_world = getPosition(samppos_screen).xyz; 
+			
+			vec3 diff = pos_world - samppos_world;
+			float dist2 = dot(diff, diff);
+			
+			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+			// --> solid angle shrinking by the square of distance
+			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+			//(k should vary inversely with # of samples, but this is taken care of later)
+			
+			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
+			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
+			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+			
+			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
+			points = points + int(diff.z > -1.0);
+		}
 		
-		// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
-		points = points + int(diff.z > -1.0);
+		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+		
+		ret = (1.0 - (float(points != 0) * angle_hidden));
+		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
 	}
 	
-	angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-	
-	return (1.0 - (float(points != 0) * angle_hidden));
+	return min(ret, 1.0);
 }
 
 void main() 
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index a0026edcd21..74a948f584e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -55,51 +55,61 @@ vec4 getPosition(vec2 pos_screen)
 //calculate decreases in ambient lighting when crowded out (SSAO)
 float calcAmbientOcclusion(vec4 pos, vec3 norm)
 {
-	vec2 kern[8];
-	// exponentially (^2) distant occlusion samples spread around origin
-	kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
-	kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
-	kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
-	kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
-	kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
-	kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
-	kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
-	kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
-	vec2 pos_screen = vary_fragcoord.xy;
-	vec3 pos_world = pos.xyz;
-	vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-	
-	float angle_hidden = 0.0;
-	int points = 0;
+	float ret = 1.0;
 	
-	float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
+	float dist = dot(pos.xyz,pos.xyz);
 	
-	// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
-	for (int i = 0; i < 8; i++)
+	if (dist < 64.0*64.0)
 	{
-		vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
-		vec3 samppos_world = getPosition(samppos_screen).xyz; 
+		vec2 kern[8];
+		// exponentially (^2) distant occlusion samples spread around origin
+		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+		vec2 pos_screen = vary_fragcoord.xy;
+		vec3 pos_world = pos.xyz;
+		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
 		
-		vec3 diff = pos_world - samppos_world;
-		float dist2 = dot(diff, diff);
+		float angle_hidden = 0.0;
+		int points = 0;
 		
-		// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
-		// --> solid angle shrinking by the square of distance
-		//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
-		//(k should vary inversely with # of samples, but this is taken care of later)
+		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
 		
-		//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
-		//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
-		angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+		for (int i = 0; i < 8; i++)
+		{
+			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+			vec3 samppos_world = getPosition(samppos_screen).xyz; 
+			
+			vec3 diff = pos_world - samppos_world;
+			float dist2 = dot(diff, diff);
+			
+			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+			// --> solid angle shrinking by the square of distance
+			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+			//(k should vary inversely with # of samples, but this is taken care of later)
+			
+			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
+			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
+			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+			
+			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
+			points = points + int(diff.z > -1.0);
+		}
 		
-		// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
-		points = points + int(diff.z > -1.0);
+		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+		
+		ret = (1.0 - (float(points != 0) * angle_hidden));
+		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
 	}
 	
-	angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-	
-	return (1.0 - (float(points != 0) * angle_hidden));
+	return min(ret, 1.0);
 }
 
 float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
@@ -224,11 +234,11 @@ void main()
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.1).x; 
+	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x; 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.1).x; 
+	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x; 
 
 	//gl_FragColor.rgb = pos.xyz;
 	//gl_FragColor.b = shadow;
-- 
GitLab


From 078278bf51b50ded63d5f7c4a9d99146f72aba69 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 6 Jan 2010 15:02:43 -0600
Subject: [PATCH 049/683] LLImportCollada no longer a singleton to prepare for
 subclassing.

---
 indra/newview/app_settings/logcontrol.xml |  2 ++
 indra/newview/llassetuploadresponders.cpp | 16 +++++++++-------
 indra/newview/llassetuploadresponders.h   | 11 ++++++++---
 indra/newview/llviewermenufile.cpp        |  8 ++++++--
 4 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index d7bb64ce8a7..a5e2837f165 100644
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -40,6 +40,8 @@
 						</array>
 					<key>tags</key>
 						<array>
+              <string>AppInit</string>
+              <string>Capabilities</string>
 						</array>
 				</map>
 			</array>
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index a0be6efdc25..6324da74993 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -317,16 +317,18 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)
 LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
 	const LLSD& post_data,
 	const LLUUID& vfile_id,
-	LLAssetType::EType asset_type)
-	: LLAssetUploadResponder(post_data, vfile_id, asset_type)
+	LLAssetType::EType asset_type,
+	LLImportCollada* import)
+	: LLAssetUploadResponder(post_data, vfile_id, asset_type), mImport(import)
 {
 }
 
 LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
 	const LLSD& post_data,
 	const std::string& file_name,
-	LLAssetType::EType asset_type)
-	: LLAssetUploadResponder(post_data, file_name, asset_type)
+	LLAssetType::EType asset_type,
+	LLImportCollada* import)
+	: LLAssetUploadResponder(post_data, file_name, asset_type), mImport(import)
 {
 }
 
@@ -334,7 +336,7 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
 void LLNewAgentInventoryResponder::error(U32 statusNum, const std::string& reason)
 {
 	LLAssetUploadResponder::error(statusNum, reason);
-	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE);
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE, mImport);
 }
 
 
@@ -343,7 +345,7 @@ void LLNewAgentInventoryResponder::uploadFailure(const LLSD& content)
 {
 	LLAssetUploadResponder::uploadFailure(content);
 
-	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE);
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE, mImport);
 }
 
 //virtual 
@@ -433,7 +435,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 			userdata);
 	}
 
-	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE);
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE, mImport);
 }
 
 LLSendTexLayerResponder::LLSendTexLayerResponder(const LLSD& post_data,
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index c8699882035..4b79e155291 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -61,19 +61,24 @@ class LLAssetUploadResponder : public LLHTTPClient::Responder
 	std::string mFileName;
 };
 
-
+class LLImportCollada;
 // TODO*: Remove this once deprecated
 class LLNewAgentInventoryResponder : public LLAssetUploadResponder
 {
 public:
+	LLImportCollada* mImport;
+
 	LLNewAgentInventoryResponder(
 		const LLSD& post_data,
 		const LLUUID& vfile_id,
-		LLAssetType::EType asset_type);
+		LLAssetType::EType asset_type,
+		LLImportCollada* import);
+
 	LLNewAgentInventoryResponder(
 		const LLSD& post_data,
 		const std::string& file_name,
-		LLAssetType::EType asset_type);
+		LLAssetType::EType asset_type,
+		LLImportCollada* import);
     virtual void error(U32 statusNum, const std::string& reason);
 	virtual void uploadComplete(const LLSD& content);
 	virtual void uploadFailure(const LLSD& content);
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index de6fcbd8bc4..47f9031ac26 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -272,7 +272,10 @@ class LLFileUploadScene : public view_listener_t
 		std::string filename = upload_pick((void *)LLFilePicker::FFLOAD_COLLADA);
 		if (!filename.empty())
 		{
-			LLImportCollada::getInstance()->importFile(filename);
+			LLFloaterReg::showInstance("import_collada");
+			LLFloaterImportCollada* floater = LLFloaterReg::findTypedInstance<LLFloaterImportCollada>("import_collada");
+			floater->enableOK(TRUE);
+			floater->importFile(filename);
 		}
 		return TRUE;
 	}
@@ -1080,7 +1083,8 @@ void upload_new_resource(
 			new LLNewAgentInventoryResponder(
 				body,
 				uuid,
-				asset_type));
+				asset_type,
+				(LLImportCollada*) userdata));
 	}
 	else
 	{
-- 
GitLab


From 3972ae18d195549968e21c3b744cc3a917679358 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 7 Jan 2010 08:49:34 -0600
Subject: [PATCH 050/683] Backed out changeset: 0e0f8b0b0fa8

---
 indra/newview/app_settings/logcontrol.xml |  2 --
 indra/newview/llassetuploadresponders.cpp | 16 +++++++---------
 indra/newview/llassetuploadresponders.h   | 11 +++--------
 indra/newview/llviewermenufile.cpp        |  8 ++------
 4 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index a5e2837f165..d7bb64ce8a7 100644
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -40,8 +40,6 @@
 						</array>
 					<key>tags</key>
 						<array>
-              <string>AppInit</string>
-              <string>Capabilities</string>
 						</array>
 				</map>
 			</array>
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 6324da74993..a0be6efdc25 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -317,18 +317,16 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)
 LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
 	const LLSD& post_data,
 	const LLUUID& vfile_id,
-	LLAssetType::EType asset_type,
-	LLImportCollada* import)
-	: LLAssetUploadResponder(post_data, vfile_id, asset_type), mImport(import)
+	LLAssetType::EType asset_type)
+	: LLAssetUploadResponder(post_data, vfile_id, asset_type)
 {
 }
 
 LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
 	const LLSD& post_data,
 	const std::string& file_name,
-	LLAssetType::EType asset_type,
-	LLImportCollada* import)
-	: LLAssetUploadResponder(post_data, file_name, asset_type), mImport(import)
+	LLAssetType::EType asset_type)
+	: LLAssetUploadResponder(post_data, file_name, asset_type)
 {
 }
 
@@ -336,7 +334,7 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
 void LLNewAgentInventoryResponder::error(U32 statusNum, const std::string& reason)
 {
 	LLAssetUploadResponder::error(statusNum, reason);
-	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE, mImport);
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, LLUUID(), FALSE);
 }
 
 
@@ -345,7 +343,7 @@ void LLNewAgentInventoryResponder::uploadFailure(const LLSD& content)
 {
 	LLAssetUploadResponder::uploadFailure(content);
 
-	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE, mImport);
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], FALSE);
 }
 
 //virtual 
@@ -435,7 +433,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 			userdata);
 	}
 
-	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE, mImport);
+	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE);
 }
 
 LLSendTexLayerResponder::LLSendTexLayerResponder(const LLSD& post_data,
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index 4b79e155291..c8699882035 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -61,24 +61,19 @@ class LLAssetUploadResponder : public LLHTTPClient::Responder
 	std::string mFileName;
 };
 
-class LLImportCollada;
+
 // TODO*: Remove this once deprecated
 class LLNewAgentInventoryResponder : public LLAssetUploadResponder
 {
 public:
-	LLImportCollada* mImport;
-
 	LLNewAgentInventoryResponder(
 		const LLSD& post_data,
 		const LLUUID& vfile_id,
-		LLAssetType::EType asset_type,
-		LLImportCollada* import);
-
+		LLAssetType::EType asset_type);
 	LLNewAgentInventoryResponder(
 		const LLSD& post_data,
 		const std::string& file_name,
-		LLAssetType::EType asset_type,
-		LLImportCollada* import);
+		LLAssetType::EType asset_type);
     virtual void error(U32 statusNum, const std::string& reason);
 	virtual void uploadComplete(const LLSD& content);
 	virtual void uploadFailure(const LLSD& content);
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 47f9031ac26..de6fcbd8bc4 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -272,10 +272,7 @@ class LLFileUploadScene : public view_listener_t
 		std::string filename = upload_pick((void *)LLFilePicker::FFLOAD_COLLADA);
 		if (!filename.empty())
 		{
-			LLFloaterReg::showInstance("import_collada");
-			LLFloaterImportCollada* floater = LLFloaterReg::findTypedInstance<LLFloaterImportCollada>("import_collada");
-			floater->enableOK(TRUE);
-			floater->importFile(filename);
+			LLImportCollada::getInstance()->importFile(filename);
 		}
 		return TRUE;
 	}
@@ -1083,8 +1080,7 @@ void upload_new_resource(
 			new LLNewAgentInventoryResponder(
 				body,
 				uuid,
-				asset_type,
-				(LLImportCollada*) userdata));
+				asset_type));
 	}
 	else
 	{
-- 
GitLab


From 728463b40b9794b9fa4cd5b7bad3f169033d0bc8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 8 Jan 2010 13:31:04 -0600
Subject: [PATCH 051/683] Cleaned up visible edges of projector frustum in
 diffuse/specular/ambient lighting from projectors.

---
 .../class1/deferred/multiSpotLightF.glsl      | 102 +++++++++++++-----
 .../class2/deferred/multiSpotLightF.glsl      |  58 +++++++++-
 .../shaders/class2/deferred/spotLightF.glsl   |  11 --
 3 files changed, 128 insertions(+), 43 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 28bcd720c0a..2c8d90d1a6e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -5,7 +5,6 @@
  * $License$
  */
 
-
 #version 120
 
 #extension GL_ARB_texture_rectangle : enable
@@ -15,6 +14,7 @@ uniform sampler2DRect specularRect;
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform samplerCube environmentMap;
+uniform sampler2DRect lightMap;
 uniform sampler2D noiseMap;
 uniform sampler2D lightFunc;
 uniform sampler2D projectionMap;
@@ -26,12 +26,15 @@ uniform vec3 proj_n;
 uniform float proj_focus; //distance from plane to begin blurring
 uniform float proj_lod;  //(number of mips in proj map)
 uniform float proj_range; //range between near clip and far clip plane of projection
+uniform float proj_ambient_lod;
 uniform float proj_ambiance;
 uniform float near_clip;
 uniform float far_clip;
 
 uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
 uniform float sun_wash;
+uniform int proj_shadow_idx;
+uniform float shadow_fade;
 
 varying vec4 vary_light;
 
@@ -40,6 +43,52 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
+vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = tc-vec2(0.5);
+	
+	float det = max(1.0-lod/(proj_lod*0.5), 0.0);
+	
+	float d = dot(dist,dist);
+		
+	ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0)+det, 1.0);
+	
+	return ret;
+}
+
+vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
+	
+	float det = min(lod/(proj_lod*0.5), 1.0);
+	
+	float d = min(dist.x, dist.y);
+	
+	float edge = 0.25*det;
+		
+	ret *= clamp(d/edge, 0.0, 1.0);
+	
+	return ret;
+}
+
+vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = tc-vec2(0.5);
+	
+	float d = dot(dist,dist);
+		
+	ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0);
+	
+	return ret;
+}
+
+
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -68,7 +117,7 @@ void main()
 	{
 		discard;
 	}
-	
+		
 	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
 	
 	norm = normalize(norm);
@@ -83,7 +132,11 @@ void main()
 	proj_tc.xyz /= proj_tc.w;
 	
 	float fa = gl_Color.a+1.0;
-	float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+	float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0);
+	if (dist_atten <= 0.0)
+	{
+		discard;
+	}
 	
 	lv = proj_origin-pos.xyz;
 	lv = normalize(lv);
@@ -101,32 +154,32 @@ void main()
 		proj_tc.y > 0.0)
 	{
 		float lit = 0.0;
+		float amb_da = proj_ambiance;
+		
 		if (da > 0.0)
 		{
 			float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
 			float lod = diff * proj_lod;
 			
-			vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
+			vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
 		
 			vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
 			
 			lit = da * dist_atten * noise;
 			
 			col = lcol*lit*diff_tex;
+			amb_da += (da*0.5)*proj_ambiance;
 		}
 		
-		float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
-		float lod = diff * proj_lod;
-		vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
-		//float amb_da = mix(proj_ambiance, proj_ambiance*max(-da, 0.0), max(da, 0.0));
-		float amb_da = proj_ambiance;
-		
+		//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
+		vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
+							
 		amb_da += (da*da*0.5+0.5)*proj_ambiance;
-			
+				
 		amb_da *= dist_atten * noise;
-		
+			
 		amb_da = min(amb_da, 1.0-lit);
-		
+			
 		col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
 	}
 	
@@ -144,35 +197,28 @@ void main()
 		{
 			vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
 			
-			vec3 stc = (proj_mat * vec4(pfinal.xyz, 1.0)).xyz;
+			vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
 
 			if (stc.z > 0.0)
 			{
-				stc.xy /= stc.z+proj_near;
-					
+				stc.xy /= stc.w;
+
+				float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0);
+				
+				stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
+								
 				if (stc.x < 1.0 &&
 					stc.y < 1.0 &&
 					stc.x > 0.0 &&
 					stc.y > 0.0)
 				{
-					vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
+					vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
 					col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb;
 				}
 			}
 		}
 	}
 	
-	/*if (spec.a > 0.0)
-	{
-		//vec3 ref = reflect(normalize(pos), norm);
-		float sa = dot(normalize(lv-normalize(pos)),norm);;
-		//sa = max(sa, 0.0);
-		//sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
-		sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
-		sa *= noise;
-		col += da*sa*lcol*spec.rgb;
-	}*/
-	
 	gl_FragColor.rgb = col;	
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 45884d57324..3e29c684e8b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -43,6 +43,52 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
+vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = tc-vec2(0.5);
+	
+	float det = max(1.0-lod/(proj_lod*0.5), 0.0);
+	
+	float d = dot(dist,dist);
+		
+	ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0)+det, 1.0);
+	
+	return ret;
+}
+
+vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
+	
+	float det = min(lod/(proj_lod*0.5), 1.0);
+	
+	float d = min(dist.x, dist.y);
+	
+	float edge = 0.25*det;
+		
+	ret *= clamp(d/edge, 0.0, 1.0);
+	
+	return ret;
+}
+
+vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = tc-vec2(0.5);
+	
+	float d = dot(dist,dist);
+		
+	ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0);
+	
+	return ret;
+}
+
+
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -126,7 +172,7 @@ void main()
 			float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
 			float lod = diff * proj_lod;
 			
-			vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
+			vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
 		
 			vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
 			
@@ -137,7 +183,7 @@ void main()
 		}
 		
 		//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
-		vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_lod);
+		vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
 							
 		amb_da += (da*da*0.5+0.5)*proj_ambiance;
 				
@@ -167,13 +213,17 @@ void main()
 			if (stc.z > 0.0)
 			{
 				stc.xy /= stc.w;
-					
+
+				float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0);
+				
+				stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
+								
 				if (stc.x < 1.0 &&
 					stc.y < 1.0 &&
 					stc.x > 0.0 &&
 					stc.y > 0.0)
 				{
-					vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
+					vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
 					col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow;
 				}
 			}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index d6534083cfe..6617e33c0d8 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -179,17 +179,6 @@ void main()
 		}
 	}
 	
-	/*if (spec.a > 0.0)
-	{
-		//vec3 ref = reflect(normalize(pos), norm);
-		float sa = dot(normalize(lv-normalize(pos)),norm);;
-		//sa = max(sa, 0.0);
-		//sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
-		sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
-		sa *= noise;
-		col += da*sa*lcol*spec.rgb;
-	}*/
-	
 	//attenuate point light contribution by SSAO component
 	col *= texture2DRect(lightMap, frag.xy).g;
 	
-- 
GitLab


From 176a8d90301815bfc88958ca0c58cfaab00c4122 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 8 Jan 2010 13:31:04 -0600
Subject: [PATCH 052/683] Cleaned up visible edges of projector frustum in
 diffuse/specular/ambient lighting from projectors.

---
 .../class1/deferred/multiSpotLightF.glsl      | 102 +++++++++++++-----
 .../class2/deferred/multiSpotLightF.glsl      |  58 +++++++++-
 .../shaders/class2/deferred/spotLightF.glsl   |  11 --
 3 files changed, 128 insertions(+), 43 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 28bcd720c0a..2c8d90d1a6e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -5,7 +5,6 @@
  * $License$
  */
 
-
 #version 120
 
 #extension GL_ARB_texture_rectangle : enable
@@ -15,6 +14,7 @@ uniform sampler2DRect specularRect;
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform samplerCube environmentMap;
+uniform sampler2DRect lightMap;
 uniform sampler2D noiseMap;
 uniform sampler2D lightFunc;
 uniform sampler2D projectionMap;
@@ -26,12 +26,15 @@ uniform vec3 proj_n;
 uniform float proj_focus; //distance from plane to begin blurring
 uniform float proj_lod;  //(number of mips in proj map)
 uniform float proj_range; //range between near clip and far clip plane of projection
+uniform float proj_ambient_lod;
 uniform float proj_ambiance;
 uniform float near_clip;
 uniform float far_clip;
 
 uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
 uniform float sun_wash;
+uniform int proj_shadow_idx;
+uniform float shadow_fade;
 
 varying vec4 vary_light;
 
@@ -40,6 +43,52 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
+vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = tc-vec2(0.5);
+	
+	float det = max(1.0-lod/(proj_lod*0.5), 0.0);
+	
+	float d = dot(dist,dist);
+		
+	ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0)+det, 1.0);
+	
+	return ret;
+}
+
+vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
+	
+	float det = min(lod/(proj_lod*0.5), 1.0);
+	
+	float d = min(dist.x, dist.y);
+	
+	float edge = 0.25*det;
+		
+	ret *= clamp(d/edge, 0.0, 1.0);
+	
+	return ret;
+}
+
+vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = tc-vec2(0.5);
+	
+	float d = dot(dist,dist);
+		
+	ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0);
+	
+	return ret;
+}
+
+
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -68,7 +117,7 @@ void main()
 	{
 		discard;
 	}
-	
+		
 	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
 	
 	norm = normalize(norm);
@@ -83,7 +132,11 @@ void main()
 	proj_tc.xyz /= proj_tc.w;
 	
 	float fa = gl_Color.a+1.0;
-	float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+	float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0);
+	if (dist_atten <= 0.0)
+	{
+		discard;
+	}
 	
 	lv = proj_origin-pos.xyz;
 	lv = normalize(lv);
@@ -101,32 +154,32 @@ void main()
 		proj_tc.y > 0.0)
 	{
 		float lit = 0.0;
+		float amb_da = proj_ambiance;
+		
 		if (da > 0.0)
 		{
 			float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
 			float lod = diff * proj_lod;
 			
-			vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
+			vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
 		
 			vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
 			
 			lit = da * dist_atten * noise;
 			
 			col = lcol*lit*diff_tex;
+			amb_da += (da*0.5)*proj_ambiance;
 		}
 		
-		float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
-		float lod = diff * proj_lod;
-		vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
-		//float amb_da = mix(proj_ambiance, proj_ambiance*max(-da, 0.0), max(da, 0.0));
-		float amb_da = proj_ambiance;
-		
+		//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
+		vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
+							
 		amb_da += (da*da*0.5+0.5)*proj_ambiance;
-			
+				
 		amb_da *= dist_atten * noise;
-		
+			
 		amb_da = min(amb_da, 1.0-lit);
-		
+			
 		col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
 	}
 	
@@ -144,35 +197,28 @@ void main()
 		{
 			vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
 			
-			vec3 stc = (proj_mat * vec4(pfinal.xyz, 1.0)).xyz;
+			vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
 
 			if (stc.z > 0.0)
 			{
-				stc.xy /= stc.z+proj_near;
-					
+				stc.xy /= stc.w;
+
+				float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0);
+				
+				stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
+								
 				if (stc.x < 1.0 &&
 					stc.y < 1.0 &&
 					stc.x > 0.0 &&
 					stc.y > 0.0)
 				{
-					vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
+					vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
 					col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb;
 				}
 			}
 		}
 	}
 	
-	/*if (spec.a > 0.0)
-	{
-		//vec3 ref = reflect(normalize(pos), norm);
-		float sa = dot(normalize(lv-normalize(pos)),norm);;
-		//sa = max(sa, 0.0);
-		//sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
-		sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
-		sa *= noise;
-		col += da*sa*lcol*spec.rgb;
-	}*/
-	
 	gl_FragColor.rgb = col;	
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 651959413cd..3e29c684e8b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -43,6 +43,52 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
+vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = tc-vec2(0.5);
+	
+	float det = max(1.0-lod/(proj_lod*0.5), 0.0);
+	
+	float d = dot(dist,dist);
+		
+	ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0)+det, 1.0);
+	
+	return ret;
+}
+
+vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
+	
+	float det = min(lod/(proj_lod*0.5), 1.0);
+	
+	float d = min(dist.x, dist.y);
+	
+	float edge = 0.25*det;
+		
+	ret *= clamp(d/edge, 0.0, 1.0);
+	
+	return ret;
+}
+
+vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
+{
+	vec4 ret = texture2DLod(projectionMap, tc, lod);
+	
+	vec2 dist = tc-vec2(0.5);
+	
+	float d = dot(dist,dist);
+		
+	ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0);
+	
+	return ret;
+}
+
+
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -126,7 +172,7 @@ void main()
 			float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
 			float lod = diff * proj_lod;
 			
-			vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
+			vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
 		
 			vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
 			
@@ -137,7 +183,7 @@ void main()
 		}
 		
 		//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
-		vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_ambient_lod);
+		vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
 							
 		amb_da += (da*da*0.5+0.5)*proj_ambiance;
 				
@@ -167,13 +213,17 @@ void main()
 			if (stc.z > 0.0)
 			{
 				stc.xy /= stc.w;
-					
+
+				float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0);
+				
+				stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
+								
 				if (stc.x < 1.0 &&
 					stc.y < 1.0 &&
 					stc.x > 0.0 &&
 					stc.y > 0.0)
 				{
-					vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
+					vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
 					col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow;
 				}
 			}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index d6534083cfe..6617e33c0d8 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -179,17 +179,6 @@ void main()
 		}
 	}
 	
-	/*if (spec.a > 0.0)
-	{
-		//vec3 ref = reflect(normalize(pos), norm);
-		float sa = dot(normalize(lv-normalize(pos)),norm);;
-		//sa = max(sa, 0.0);
-		//sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
-		sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
-		sa *= noise;
-		col += da*sa*lcol*spec.rgb;
-	}*/
-	
 	//attenuate point light contribution by SSAO component
 	col *= texture2DRect(lightMap, frag.xy).g;
 	
-- 
GitLab


From 19469efc76ff5e9d7eb03bad711b2c13c19ea404 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Wed, 13 Jan 2010 15:51:13 -0600
Subject: [PATCH 053/683] drag-and-drop mesh asset onto in-world object

---
 indra/newview/lltooldraganddrop.cpp | 67 ++++++++++++++++++++++++++---
 indra/newview/lltooldraganddrop.h   | 12 ++++++
 2 files changed, 72 insertions(+), 7 deletions(-)

diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 75092463746..f05da6e0ed9 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -385,7 +385,7 @@ LLToolDragAndDrop::LLDragAndDropDictionary::LLDragAndDropDictionary()
 	addEntry(DAD_ANIMATION, 	new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dUpdateInventory,			&LLToolDragAndDrop::dad3dNULL));
 	addEntry(DAD_GESTURE, 		new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dActivateGesture,		&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dUpdateInventory,			&LLToolDragAndDrop::dad3dNULL));
 	addEntry(DAD_LINK, 			new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dNULL,						&LLToolDragAndDrop::dad3dNULL));
-	addEntry(DAD_MESH, 			new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dUpdateInventory,			&LLToolDragAndDrop::dad3dNULL));
+	addEntry(DAD_MESH, 			new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dMeshObject,			&LLToolDragAndDrop::dad3dNULL));
 	// TODO: animation on self could play it?  edit it?
 	// TODO: gesture on self could play it?  edit it?
 };
@@ -1086,6 +1086,31 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
 	hit_obj->sendTEUpdate();
 }
 
+void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj,
+								 LLInventoryItem* item,
+								 LLToolDragAndDrop::ESource source,
+								 const LLUUID& src_id)
+{
+	if (!item)
+	{
+		llwarns << "no inventory item." << llendl;
+		return;
+	}
+	LLUUID asset_id = item->getAssetUUID();
+	BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id);
+	if(!success)
+	{
+		return;
+	}
+
+	LLSculptParams sculpt_params;
+	sculpt_params.setSculptTexture(asset_id);
+	sculpt_params.setSculptType(LL_SCULPT_TYPE_MESH);
+	hit_obj->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt_params, TRUE);
+	
+	dialog_refresh_all();
+}
+
 /*
 void LLToolDragAndDrop::dropTextureOneFaceAvatar(LLVOAvatar* avatar, S32 hit_face, LLInventoryItem* item)
 {
@@ -2216,10 +2241,10 @@ EAcceptance LLToolDragAndDrop::dad3dRezScript(
 	return rv;
 }
 
-EAcceptance LLToolDragAndDrop::dad3dTextureObject(
-	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
+EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
+	LLViewerObject* obj, S32 face, MASK mask, BOOL drop, EDragAndDropType cargo_type)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dTextureObject()" << llendl;
+	lldebugs << "LLToolDragAndDrop::dad3dApplyToObject()" << llendl;
 
 	// *HACK: In order to resolve SL-22177, we need to block drags
 	// from notecards and objects onto other objects.
@@ -2253,13 +2278,24 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject(
 
 	if(drop && (ACCEPT_YES_SINGLE <= rv))
 	{
-		if((mask & MASK_SHIFT))
+		if (cargo_type == DAD_TEXTURE)
 		{
-			dropTextureAllFaces(obj, item, mSource, mSourceID);
+			if((mask & MASK_SHIFT))
+			{
+				dropTextureAllFaces(obj, item, mSource, mSourceID);
+			}
+			else
+			{
+				dropTextureOneFace(obj, face, item, mSource, mSourceID);
+			}
+		}
+		else if (cargo_type == DAD_MESH)
+		{
+			dropMesh(obj, item, mSource, mSourceID);
 		}
 		else
 		{
-			dropTextureOneFace(obj, face, item, mSource, mSourceID);
+			llwarns << "unsupported asset type" << llendl;
 		}
 		
 		// VEFFECT: SetTexture
@@ -2273,6 +2309,23 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject(
 	// enable multi-drop, although last texture will win
 	return ACCEPT_YES_MULTI;
 }
+
+
+EAcceptance LLToolDragAndDrop::dad3dTextureObject(
+	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
+{
+	return dad3dApplyToObject(obj, face, mask, drop, DAD_TEXTURE);
+}
+
+EAcceptance LLToolDragAndDrop::dad3dMeshObject(
+	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
+{
+	return dad3dApplyToObject(obj, face, mask, drop, DAD_MESH);
+}
+
+
+
+
 /*
 EAcceptance LLToolDragAndDrop::dad3dTextureSelf(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h
index 79b2bc32a37..8a19eb6c9c3 100644
--- a/indra/newview/lltooldraganddrop.h
+++ b/indra/newview/lltooldraganddrop.h
@@ -154,6 +154,8 @@ class LLToolDragAndDrop : public LLTool, public LLSingleton<LLToolDragAndDrop>
 							   MASK mask, BOOL drop);
 	EAcceptance dad3dTextureObject(LLViewerObject* obj, S32 face,
 								   MASK mask, BOOL drop);
+	EAcceptance dad3dMeshObject(LLViewerObject* obj, S32 face,
+								   MASK mask, BOOL drop);
 //	EAcceptance dad3dTextureSelf(LLViewerObject* obj, S32 face,
 //								 MASK mask, BOOL drop);
 	EAcceptance dad3dWearItem(LLViewerObject* obj, S32 face,
@@ -185,6 +187,11 @@ class LLToolDragAndDrop : public LLTool, public LLSingleton<LLToolDragAndDrop>
 	EAcceptance dad3dActivateGesture(LLViewerObject *obj, S32 face,
 								 MASK mask, BOOL drop);
 
+	// helper called by methods above to handle "application" of an item
+	// to an object (texture applied to face, mesh applied to shape, etc.)
+	EAcceptance dad3dApplyToObject(LLViewerObject* obj, S32 face, MASK mask, BOOL drop, EDragAndDropType cargo_type);
+		
+	
 	// set the LLToolDragAndDrop's cursor based on the given acceptance
 	ECursorType acceptanceToCursor( EAcceptance acceptance );
 
@@ -253,6 +260,11 @@ class LLToolDragAndDrop : public LLTool, public LLSingleton<LLToolDragAndDrop>
 									LLInventoryItem* item,
 									ESource source,
 									const LLUUID& src_id);
+	static void dropMesh(LLViewerObject* hit_obj,
+						 LLInventoryItem* item,
+						 ESource source,
+						 const LLUUID& src_id);
+	
 	//static void	dropTextureOneFaceAvatar(LLVOAvatar* avatar,S32 hit_face,
 	//									 LLInventoryItem* item)
 
-- 
GitLab


From 04fe0399443cf4a5852e94cd3950ba1fd2d50562 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 14 Jan 2010 13:55:00 -0800
Subject: [PATCH 054/683] Backed out changeset d5b761982e63

This got pushed too early - sorry.  Sigh.
---
 indra/llcommon/llfasttimer.h                  | 163 +++++------
 indra/llplugin/llpluginclassmedia.cpp         |  30 +--
 indra/llplugin/llpluginclassmedia.h           |  12 -
 indra/llui/llfloater.cpp                      |  46 ++--
 indra/llui/llmenugl.cpp                       |   2 +-
 indra/llui/lltexteditor.cpp                   |   3 +-
 .../webkit/media_plugin_webkit.cpp            |   1 -
 indra/newview/CMakeLists.txt                  |   8 +-
 indra/newview/app_settings/settings.xml       |  13 +-
 .../darwin/fix_application_icon_position.sh   |  14 -
 indra/newview/llagent.cpp                     |   9 +-
 indra/newview/llagent.h                       |   1 -
 indra/newview/llavatarlist.cpp                |   7 +-
 indra/newview/llavatarlistitem.cpp            | 251 +++++++----------
 indra/newview/llavatarlistitem.h              |  71 ++---
 indra/newview/llbottomtray.cpp                |  17 +-
 indra/newview/llcallfloater.cpp               |  12 +-
 indra/newview/llchathistory.cpp               |  49 ++--
 indra/newview/llfloaterabout.cpp              |   2 +-
 indra/newview/llfloaterchat.cpp               |  15 +-
 indra/newview/llfloatergesture.cpp            |   2 +-
 indra/newview/llfloatergroups.cpp             |   9 +-
 indra/newview/llfloaterland.cpp               |   7 +-
 indra/newview/llfloaterland.h                 |   1 +
 indra/newview/llfloaterpreference.cpp         |   2 +-
 indra/newview/llfloaterregioninfo.cpp         |   5 -
 indra/newview/llgesturemgr.cpp                |  10 -
 indra/newview/llgesturemgr.h                  |   2 -
 indra/newview/llgroupactions.cpp              |  10 +-
 indra/newview/llimfloater.cpp                 |  86 +++---
 indra/newview/llimfloater.h                   |   5 +-
 indra/newview/llimfloatercontainer.cpp        |  11 -
 indra/newview/llimfloatercontainer.h          |   6 +-
 indra/newview/llimview.cpp                    |  19 +-
 indra/newview/llimview.h                      |   5 -
 indra/newview/llinspectavatar.cpp             |   1 -
 indra/newview/llinspecttoast.cpp              | 122 ---------
 indra/newview/llinspecttoast.h                |  40 ---
 indra/newview/llinventorymodel.cpp            |   8 +-
 indra/newview/llinventoryobserver.cpp         |  35 +--
 indra/newview/llmediactrl.cpp                 |  45 ++--
 indra/newview/llmediactrl.h                   |   1 +
 indra/newview/llnamebox.cpp                   |  24 +-
 indra/newview/llnamebox.h                     |   5 -
 indra/newview/llnearbychat.cpp                |  22 +-
 indra/newview/llnearbychatbar.cpp             | 252 +++++------------
 indra/newview/llnearbychatbar.h               |  47 +---
 indra/newview/llnearbychathandler.cpp         |  25 +-
 indra/newview/lloutputmonitorctrl.cpp         |  65 +----
 indra/newview/lloutputmonitorctrl.h           |  29 +-
 indra/newview/llpanelavatar.cpp               |  18 +-
 indra/newview/llpanelgroup.cpp                |  55 +---
 indra/newview/llpanelgroup.h                  |   4 -
 indra/newview/llpanelgroupgeneral.cpp         |  11 +-
 indra/newview/llpanelgrouproles.cpp           |  61 ++---
 indra/newview/llpanelgrouproles.h             |  13 +-
 indra/newview/llpanelimcontrolpanel.cpp       |   2 +-
 indra/newview/llpanelpeople.cpp               |   8 +-
 indra/newview/llpanelpick.cpp                 |  80 +++---
 indra/newview/llpanelpick.h                   |  18 +-
 indra/newview/llpanelplaces.h                 |   4 -
 indra/newview/llpanelteleporthistory.cpp      |   2 +-
 indra/newview/llpanelvolumepulldown.cpp       | 154 -----------
 indra/newview/llpanelvolumepulldown.h         |  64 -----
 indra/newview/llparticipantlist.cpp           |   8 +-
 indra/newview/llscreenchannel.cpp             | 149 ++++++++--
 indra/newview/llscreenchannel.h               |  19 +-
 indra/newview/llspeakers.cpp                  |   5 -
 indra/newview/llspeakers.h                    |   2 -
 indra/newview/llspeakingindicatormanager.cpp  | 254 ------------------
 indra/newview/llspeakingindicatormanager.h    |  67 -----
 indra/newview/llstatusbar.cpp                 |  19 +-
 indra/newview/llstatusbar.h                   |   2 +-
 indra/newview/llsyswellitem.cpp               |   3 +-
 indra/newview/llsyswellwindow.cpp             |   3 +-
 indra/newview/llsyswellwindow.h               |   3 -
 indra/newview/llteleporthistorystorage.cpp    |   7 +
 indra/newview/lltoastnotifypanel.cpp          |   4 +-
 indra/newview/llviewerdisplay.cpp             |  20 +-
 indra/newview/llviewerfloaterreg.cpp          |   5 +-
 indra/newview/llviewermessage.cpp             |  56 ++--
 indra/newview/llviewerwindow.cpp              |  34 ++-
 indra/newview/llvoiceclient.cpp               |  11 -
 indra/newview/llvoiceclient.h                 |   1 -
 .../textures/bottomtray/Unread_Chiclet.png    | Bin 328 -> 250 bytes
 .../textures/bottomtray/WellButton_Lit.png    | Bin 490 -> 553 bytes
 .../bottomtray/WellButton_Lit_Selected.png    | Bin 302 -> 687 bytes
 .../skins/default/textures/textures.xml       |  28 +-
 .../default/xui/de/floater_buy_currency.xml   |   2 +-
 .../default/xui/de/floater_help_browser.xml   |   4 +-
 .../newview/skins/default/xui/de/strings.xml  |  72 ++---
 .../skins/default/xui/en/floater_about.xml    |   2 +-
 .../default/xui/en/floater_about_land.xml     |   8 +-
 .../default/xui/en/floater_buy_currency.xml   |   4 +-
 .../default/xui/en/floater_customize.xml      | 120 ++++-----
 .../default/xui/en/floater_god_tools.xml      |   2 +-
 .../skins/default/xui/en/floater_im.xml       |   2 +-
 .../default/xui/en/floater_nearby_chat.xml    |   4 +-
 .../default/xui/en/floater_report_abuse.xml   |   4 +-
 .../default/xui/en/floater_select_key.xml     |   8 +-
 .../default/xui/en/floater_top_objects.xml    |  20 +-
 .../skins/default/xui/en/floater_tos.xml      |   6 +-
 .../default/xui/en/floater_voice_controls.xml | 143 ++++++----
 .../skins/default/xui/en/inspect_toast.xml    |  19 --
 .../skins/default/xui/en/menu_viewer.xml      |  36 ++-
 .../skins/default/xui/en/notifications.xml    |  33 +--
 .../xui/en/panel_adhoc_control_panel.xml      |  17 +-
 .../default/xui/en/panel_avatar_list_item.xml |   7 +-
 .../xui/en/panel_block_list_sidetray.xml      |   6 +-
 .../skins/default/xui/en/panel_bottomtray.xml |  45 ++--
 .../skins/default/xui/en/panel_edit_pick.xml  |  32 +--
 .../default/xui/en/panel_edit_profile.xml     |   3 +-
 .../skins/default/xui/en/panel_friends.xml    |   2 +-
 .../xui/en/panel_group_control_panel.xml      |  20 +-
 .../xui/en/panel_group_info_sidetray.xml      |  18 +-
 .../default/xui/en/panel_group_invite.xml     |  14 +-
 .../default/xui/en/panel_group_list_item.xml  |   1 -
 .../default/xui/en/panel_group_notices.xml    |   1 -
 .../default/xui/en/panel_group_roles.xml      |  55 ++--
 .../skins/default/xui/en/panel_login.xml      |   1 -
 .../xui/en/panel_media_settings_general.xml   |   5 +-
 .../skins/default/xui/en/panel_my_profile.xml |  20 +-
 .../default/xui/en/panel_navigation_bar.xml   |   4 +-
 .../default/xui/en/panel_nearby_chat_bar.xml  |   4 +-
 .../skins/default/xui/en/panel_notes.xml      |   6 +-
 .../skins/default/xui/en/panel_people.xml     |  10 +-
 .../skins/default/xui/en/panel_pick_info.xml  |  33 +--
 .../xui/en/panel_preferences_advanced.xml     |   1 +
 .../xui/en/panel_preferences_general.xml      |  15 +-
 .../xui/en/panel_preferences_graphics1.xml    |   4 +-
 .../xui/en/panel_prim_media_controls.xml      |   1 -
 .../skins/default/xui/en/panel_profile.xml    |  26 +-
 .../default/xui/en/panel_region_covenant.xml  |  10 +-
 .../default/xui/en/panel_region_estate.xml    |  12 +-
 .../default/xui/en/panel_region_texture.xml   |   4 +-
 .../skins/default/xui/en/panel_status_bar.xml |  36 +--
 .../default/xui/en/panel_volume_pulldown.xml  |  55 ----
 .../default/xui/en/sidepanel_task_info.xml    |  36 ++-
 .../newview/skins/default/xui/en/strings.xml  |  16 +-
 .../xui/en/widgets/chiclet_im_adhoc.xml       |  22 +-
 .../xui/en/widgets/chiclet_im_group.xml       |  23 +-
 .../default/xui/en/widgets/chiclet_im_p2p.xml |  18 +-
 .../default/xui/en/widgets/chiclet_offer.xml  |  14 +-
 .../default/xui/en/widgets/chiclet_script.xml |  14 +-
 .../xui/en/widgets/gesture_combo_box.xml      |  30 +++
 .../xui/en/widgets/gesture_combo_list.xml     |  21 --
 .../default/xui/en/widgets/location_input.xml |  18 +-
 .../default/xui/es/floater_buy_currency.xml   |   3 -
 .../default/xui/fr/floater_buy_currency.xml   |   4 +-
 .../default/xui/fr/floater_help_browser.xml   |   4 +-
 .../newview/skins/default/xui/fr/strings.xml  |  74 ++---
 .../default/xui/it/floater_buy_currency.xml   |   9 +-
 .../default/xui/ja/floater_buy_currency.xml   |   2 +-
 .../newview/skins/default/xui/ja/strings.xml  |  48 ++--
 .../default/xui/pt/floater_buy_currency.xml   |   3 -
 install.xml                                   |  12 +-
 156 files changed, 1460 insertions(+), 2689 deletions(-)
 delete mode 100644 indra/newview/installers/darwin/fix_application_icon_position.sh
 delete mode 100644 indra/newview/llinspecttoast.cpp
 delete mode 100644 indra/newview/llinspecttoast.h
 delete mode 100644 indra/newview/llpanelvolumepulldown.cpp
 delete mode 100644 indra/newview/llpanelvolumepulldown.h
 delete mode 100644 indra/newview/llspeakingindicatormanager.cpp
 delete mode 100644 indra/newview/llspeakingindicatormanager.h
 delete mode 100644 indra/newview/skins/default/xui/en/inspect_toast.xml
 delete mode 100644 indra/newview/skins/default/xui/en/panel_volume_pulldown.xml
 create mode 100644 indra/newview/skins/default/xui/en/widgets/gesture_combo_box.xml
 delete mode 100644 indra/newview/skins/default/xui/en/widgets/gesture_combo_list.xml

diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 5058a2e772d..f5c90291b80 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -39,30 +39,40 @@
 #define TIME_FAST_TIMERS 0
 
 #if LL_WINDOWS
-// because MS has different signatures for these functions in winnt.h
-// need to rename them to avoid conflicts
-#define _interlockedbittestandset _renamed_interlockedbittestandset
-#define _interlockedbittestandreset _renamed_interlockedbittestandreset
-#include <intrin.h>
-#undef _interlockedbittestandset
-#undef _interlockedbittestandreset
-
-#define LL_INLINE __forceinline
+
 // shift off lower 8 bits for lower resolution but longer term timing
 // on 1Ghz machine, a 32-bit word will hold ~1000 seconds of timing
 inline U32 get_cpu_clock_count_32()
 {
-	U64 time_stamp = __rdtsc();
-	return (U32)(time_stamp >> 8);
+	U32 ret_val;
+	__asm 
+	{
+        _emit   0x0f
+        _emit   0x31
+		shr eax,8
+		shl edx,24
+		or eax, edx
+		mov dword ptr [ret_val], eax
+	}
+    return ret_val;
 }
 
 // return full timer value, *not* shifted by 8 bits
 inline U64 get_cpu_clock_count_64()
 {
-	return __rdtsc();
+	U64 ret_val;
+	__asm 
+	{
+        _emit   0x0f
+        _emit   0x31
+		mov eax,eax
+		mov edx,edx
+		mov dword ptr [ret_val+4], edx
+		mov dword ptr [ret_val], eax
+	}
+    return ret_val;
 }
-#else
-#define LL_INLINE
+
 #endif // LL_WINDOWS
 
 #if (LL_LINUX || LL_SOLARIS || LL_DARWIN) && (defined(__i386__) || defined(__amd64__))
@@ -103,25 +113,10 @@ class LLMutex;
 #include <queue>
 #include "llsd.h"
 
+
 class LL_COMMON_API LLFastTimer
 {
 public:
-
-	class NamedTimer;
-
-	struct LL_COMMON_API FrameState
-	{
-		FrameState(NamedTimer* timerp);
-
-		U32 				mSelfTimeCounter;
-		U32 				mCalls;
-		FrameState*			mParent;		// info for caller timer
-		FrameState*			mLastCaller;	// used to bootstrap tree construction
-		NamedTimer*			mTimer;
-		U16					mActiveCount;	// number of timers with this ID active on stack
-		bool				mMoveUpTree;	// needs to be moved up the tree of timers at the end of frame
-	};
-
 	// stores a "named" timer instance to be reused via multiple LLFastTimer stack instances
 	class LL_COMMON_API NamedTimer 
 	:	public LLInstanceTracker<NamedTimer>
@@ -154,10 +149,24 @@ class LL_COMMON_API LLFastTimer
 
 		static NamedTimer& getRootNamedTimer();
 
+		struct FrameState
+		{
+			FrameState(NamedTimer* timerp);
+
+			U32 		mSelfTimeCounter;
+			U32 		mCalls;
+			FrameState*	mParent;		// info for caller timer
+			FrameState*	mLastCaller;	// used to bootstrap tree construction
+			NamedTimer*	mTimer;
+			U16			mActiveCount;	// number of timers with this ID active on stack
+			bool		mMoveUpTree;	// needs to be moved up the tree of timers at the end of frame
+		};
+
 		S32 getFrameStateIndex() const { return mFrameStateIndex; }
 
 		FrameState& getFrameState() const;
 
+
 	private: 
 		friend class LLFastTimer;
 		friend class NamedTimerFactory;
@@ -176,6 +185,7 @@ class LL_COMMON_API LLFastTimer
 		static void buildHierarchy();
 		static void resetFrame();
 		static void reset();
+
 	
 		//
 		// members
@@ -197,47 +207,58 @@ class LL_COMMON_API LLFastTimer
 		std::vector<NamedTimer*>	mChildren;
 		bool						mCollapsed;				// don't show children
 		bool						mNeedsSorting;			// sort children whenever child added
+
 	};
 
 	// used to statically declare a new named timer
 	class LL_COMMON_API DeclareTimer
 	:	public LLInstanceTracker<DeclareTimer>
 	{
-		friend class LLFastTimer;
 	public:
 		DeclareTimer(const std::string& name, bool open);
 		DeclareTimer(const std::string& name);
 
 		static void updateCachedPointers();
 
+		// convertable to NamedTimer::FrameState for convenient usage of LLFastTimer(declared_timer)
+		operator NamedTimer::FrameState&() { return *mFrameState; }
 	private:
-		NamedTimer&		mTimer;
-		FrameState*		mFrameState; 
+		NamedTimer&				mTimer;
+		NamedTimer::FrameState* mFrameState; 
 	};
 
+
 public:
-	LLFastTimer(LLFastTimer::FrameState* state);
+	static LLMutex* sLogLock;
+	static std::queue<LLSD> sLogQueue;
+	static BOOL sLog;
+	static BOOL sMetricLog;
+
+	typedef std::vector<NamedTimer::FrameState> info_list_t;
+	static info_list_t& getFrameStateList();
 
-	LL_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer)
-	:	mFrameState(timer.mFrameState)
+	enum RootTimerMarker { ROOT };
+	LLFastTimer(RootTimerMarker);
+
+	LLFastTimer(NamedTimer::FrameState& timer)
+	:	mFrameState(&timer)
 	{
 #if TIME_FAST_TIMERS
 		U64 timer_start = get_cpu_clock_count_64();
 #endif
 #if FAST_TIMER_ON
-		LLFastTimer::FrameState* frame_state = mFrameState;
-		mStartTime = get_cpu_clock_count_32();
+		NamedTimer::FrameState* frame_state = &timer;
+		U32 cur_time = get_cpu_clock_count_32();
+		mStartSelfTime = cur_time;
+		mStartTotalTime = cur_time;
 
 		frame_state->mActiveCount++;
 		frame_state->mCalls++;
 		// keep current parent as long as it is active when we are
 		frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0);
 	
-		LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData;
-		mLastTimerData = *cur_timer_data;
-		cur_timer_data->mCurTimer = this;
-		cur_timer_data->mFrameState = frame_state;
-		cur_timer_data->mChildTime = 0;
+		mLastTimer = sCurTimer;
+		sCurTimer = this;
 #endif
 #if TIME_FAST_TIMERS
 		U64 timer_end = get_cpu_clock_count_64();
@@ -245,26 +266,26 @@ class LL_COMMON_API LLFastTimer
 #endif
 	}
 
-	LL_INLINE ~LLFastTimer()
+	~LLFastTimer()
 	{
 #if TIME_FAST_TIMERS
 		U64 timer_start = get_cpu_clock_count_64();
 #endif
 #if FAST_TIMER_ON
-		LLFastTimer::FrameState* frame_state = mFrameState;
-		U32 total_time = get_cpu_clock_count_32() - mStartTime;
+		NamedTimer::FrameState* frame_state = mFrameState;
+		U32 cur_time = get_cpu_clock_count_32();
+		frame_state->mSelfTimeCounter += cur_time - mStartSelfTime;
 
-		frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime;
 		frame_state->mActiveCount--;
+		LLFastTimer* last_timer = mLastTimer;
+		sCurTimer = last_timer;
 
 		// store last caller to bootstrap tree creation
-		// do this in the destructor in case of recursion to get topmost caller
-		frame_state->mLastCaller = mLastTimerData.mFrameState;
+		frame_state->mLastCaller = last_timer->mFrameState;
 
 		// we are only tracking self time, so subtract our total time delta from parents
-		mLastTimerData.mChildTime += total_time;
-
-		LLFastTimer::sCurTimerData = mLastTimerData;
+		U32 total_time = cur_time - mStartTotalTime;
+		last_timer->mStartSelfTime += total_time;
 #endif
 #if TIME_FAST_TIMERS
 		U64 timer_end = get_cpu_clock_count_64();
@@ -273,20 +294,7 @@ class LL_COMMON_API LLFastTimer
 #endif	
 	}
 
-public:
-	static LLMutex*			sLogLock;
-	static std::queue<LLSD> sLogQueue;
-	static BOOL				sLog;
-	static BOOL				sMetricLog;
-	static bool 			sPauseHistory;
-	static bool 			sResetHistory;
-	static U64				sTimerCycles;
-	static U32				sTimerCalls;
 
-	typedef std::vector<FrameState> info_list_t;
-	static info_list_t& getFrameStateList();
-
-	
 	// call this once a frame to reset timers
 	static void nextFrame();
 
@@ -304,26 +312,23 @@ class LL_COMMON_API LLFastTimer
 	static void writeLog(std::ostream& os);
 	static const NamedTimer* getTimerByName(const std::string& name);
 
-	struct CurTimerData
-	{
-		LLFastTimer*	mCurTimer;
-		FrameState*		mFrameState;
-		U32				mChildTime;
-	};
-	static CurTimerData		sCurTimerData;
-
+public:
+	static bool 			sPauseHistory;
+	static bool 			sResetHistory;
+	static U64				sTimerCycles;
+	static U32				sTimerCalls;
+	
 private:
+	static LLFastTimer*		sCurTimer;
 	static S32				sCurFrameIndex;
 	static S32				sLastFrameIndex;
 	static U64				sLastFrameTime;
 	static info_list_t*		sTimerInfos;
 
-	U32							mStartTime;
-	LLFastTimer::FrameState*	mFrameState;
-	LLFastTimer::CurTimerData	mLastTimerData;
-
+	U32						mStartSelfTime;	// start time + time of all child timers
+	U32						mStartTotalTime;	// start time + time of all child timers
+	NamedTimer::FrameState*	mFrameState;
+	LLFastTimer*			mLastTimer;
 };
 
-typedef class LLFastTimer LLFastTimer;
-
 #endif // LL_LLFASTTIMER_H
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index 3d2eaed5c5a..ed8d10a88c4 100644
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -37,8 +37,6 @@
 #include "llpluginclassmedia.h"
 #include "llpluginmessageclasses.h"
 
-#include "llqtwebkit.h"
-
 static int LOW_PRIORITY_TEXTURE_SIZE_DEFAULT = 256;
 
 static int nextPowerOf2( int value )
@@ -126,7 +124,7 @@ void LLPluginClassMedia::reset()
 	mCanPaste = false;
 	mMediaName.clear();
 	mMediaDescription.clear();
-	mBackgroundColor = LLColor4(1.0f, 1.0f, 1.0f, 1.0f);
+	mBackgroundColor = LLColor4::white;
 	
 	// media_browser class
 	mNavigateURI.clear();
@@ -136,9 +134,6 @@ void LLPluginClassMedia::reset()
 	mHistoryForwardAvailable = false;
 	mStatusText.clear();
 	mProgressPercent = 0;	
-	mClickURL.clear();
-	mClickTarget.clear();
-	mClickTargetType = TARGET_NONE;
 	
 	// media_time class
 	mCurrentTime = 0.0f;
@@ -674,26 +669,6 @@ void LLPluginClassMedia::paste()
 	sendMessage(message);
 }
 
-LLPluginClassMedia::ETargetType getTargetTypeFromLLQtWebkit(int target_type)
-{
-	// convert a LinkTargetType value from llqtwebkit to an ETargetType
-	// so that we don't expose the llqtwebkit header in viewer code
-	switch (target_type)
-	{
-	case LinkTargetType::LTT_TARGET_NONE:
-		return LLPluginClassMedia::TARGET_NONE;
-
-	case LinkTargetType::LTT_TARGET_BLANK:
-		return LLPluginClassMedia::TARGET_BLANK;
-
-	case LinkTargetType::LTT_TARGET_EXTERNAL:
-		return LLPluginClassMedia::TARGET_EXTERNAL;
-
-	default:
-		return LLPluginClassMedia::TARGET_OTHER;
-	}
-}
-
 /* virtual */ 
 void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
 {
@@ -946,15 +921,12 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
 		{
 			mClickURL = message.getValue("uri");
 			mClickTarget = message.getValue("target");
-			U32 target_type = message.getValueU32("target_type");
-			mClickTargetType = ::getTargetTypeFromLLQtWebkit(target_type);
 			mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_CLICK_LINK_HREF);
 		}
 		else if(message_name == "click_nofollow")
 		{
 			mClickURL = message.getValue("uri");
 			mClickTarget.clear();
-			mClickTargetType = TARGET_NONE;
 			mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_CLICK_LINK_NOFOLLOW);
 		}
 		else
diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h
index ebb90995766..5a1928ab1df 100644
--- a/indra/llplugin/llpluginclassmedia.h
+++ b/indra/llplugin/llpluginclassmedia.h
@@ -214,17 +214,6 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 	// This is valid after MEDIA_EVENT_CLICK_LINK_HREF
 	std::string getClickTarget() const { return mClickTarget; };
 
-	typedef enum 
-	{
-		TARGET_NONE,        // empty href target string
-		TARGET_BLANK,       // target to open link in user's preferred browser
-		TARGET_EXTERNAL,    // target to open link in external browser
-		TARGET_OTHER        // nonempty and unsupported target type
-	}ETargetType;
-
-	// This is valid after MEDIA_EVENT_CLICK_LINK_HREF
-	ETargetType getClickTargetType() const { return mClickTargetType; };
-
 	std::string getMediaName() const { return mMediaName; };
 	std::string getMediaDescription() const { return mMediaDescription; };
 
@@ -355,7 +344,6 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 	std::string		mLocation;
 	std::string		mClickURL;
 	std::string		mClickTarget;
-	ETargetType     mClickTargetType;
 	
 	/////////////////////////////////////////
 	// media_time class
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index a17e3063258..845203b420e 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -878,11 +878,9 @@ void LLFloater::setSnappedTo(const LLView* snap_view)
 	else
 	{
 		//RN: assume it's a floater as it must be a sibling to our parent floater
-		const LLFloater* floaterp = dynamic_cast<const LLFloater*>(snap_view);
-		if (floaterp)
-		{
-			setSnapTarget(floaterp->getHandle());
-		}
+		LLFloater* floaterp = (LLFloater*)snap_view;
+		
+		setSnapTarget(floaterp->getHandle());
 	}
 }
 
@@ -1067,6 +1065,10 @@ void LLFloater::setMinimized(BOOL minimize)
 		reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE );
 	}
 	
+	// don't show the help button while minimized - it's
+	// not very useful when minimized and uses up space
+	mButtonsEnabled[BUTTON_HELP] = !minimize;
+
 	applyTitle ();
 
 	make_ui_sound("UISndWindowClose");
@@ -1739,32 +1741,14 @@ void LLFloater::updateButtons()
 	S32 button_count = 0;
 	for (S32 i = 0; i < BUTTON_COUNT; i++)
 	{
-		if (!mButtons[i])
-		{
-			continue;
-		}
+		if(!mButtons[i]) continue;
+		mButtons[i]->setEnabled(mButtonsEnabled[i]);
 
-		bool enabled = mButtonsEnabled[i];
-		if (i == BUTTON_HELP)
-		{
-			// don't show the help button if the floater is minimized
-			// or if it is a tear-off hosted floater
-			if (isMinimized() || mButtonsEnabled[BUTTON_TEAR_OFF])
-			{
-				enabled = false;
-			}
-		}
-		if (i == BUTTON_CLOSE && mButtonScale != 1.f)
-		{
-			//*HACK: always render close button for hosted floaters so
-			//that users don't accidentally hit the button when
-			//closing multiple windows in the chatterbox
-			enabled = true;
-		}
-
-		mButtons[i]->setEnabled(enabled);
-
-		if (enabled)
+		if (mButtonsEnabled[i] 
+			//*HACK: always render close button for hosted floaters
+			// so that users don't accidentally hit the button when closing multiple windows
+			// in the chatterbox
+			|| (i == BUTTON_CLOSE && mButtonScale != 1.f))
 		{
 			button_count++;
 
@@ -1791,7 +1775,7 @@ void LLFloater::updateButtons()
 			// the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater
 			mButtons[i]->setTabStop(i == BUTTON_RESTORE);
 		}
-		else
+		else if (mButtons[i])
 		{
 			mButtons[i]->setVisible(FALSE);
 		}
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 21f3f157390..bd67949c2ae 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -2966,7 +2966,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
 	LLUI::getMousePositionLocal(menu->getParent(), &mouse_x, &mouse_y);
 	LLMenuHolderGL::sContextMenuSpawnPos.set(mouse_x,mouse_y);
 
-	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getRect();
+	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
 
 	const S32 HPAD = 2;
 	LLRect rect = menu->getRect();
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index f2c3879a6c9..e8fc9475a54 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -308,8 +308,7 @@ LLTextEditor::~LLTextEditor()
 	// Scrollbar is deleted by LLView
 	std::for_each(mUndoStack.begin(), mUndoStack.end(), DeletePointer());
 
-	// context menu is owned by menu holder, not us
-	//delete mContextMenu;
+	delete mContextMenu;
 }
 
 ////////////////////////////////////////////////////////////
diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp
index 084cdd9561a..a0336f6156c 100644
--- a/indra/media_plugins/webkit/media_plugin_webkit.cpp
+++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp
@@ -429,7 +429,6 @@ class MediaPluginWebKit :
 		LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_href");
 		message.setValue("uri", event.getStringValue());
 		message.setValue("target", event.getStringValue2());
-		message.setValueU32("target_type", event.getLinkType());
 		sendMessage(message);
 	}
 	
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 5b4edefbc13..32761dbf275 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -218,6 +218,7 @@ set(viewer_SOURCE_FILES
     llfloaterurldisplay.cpp
     llfloaterurlentry.cpp
     llfloatervoicedevicesettings.cpp
+    llfloatervolumepulldown.cpp
     llfloaterwater.cpp
     llfloaterwhitelistentry.cpp
     llfloaterwindlight.cpp
@@ -255,7 +256,6 @@ set(viewer_SOURCE_FILES
     llinspectgroup.cpp
     llinspectobject.cpp
     llinspectremoteobject.cpp
-    llinspecttoast.cpp
     llinventorybridge.cpp
     llinventoryclipboard.cpp
     llinventoryfilter.cpp
@@ -355,7 +355,6 @@ set(viewer_SOURCE_FILES
     llpanelshower.cpp
     llpanelteleporthistory.cpp
     llpanelvolume.cpp
-    llpanelvolumepulldown.cpp
     llparcelselection.cpp
     llparticipantlist.cpp
     llpatchvertexarray.cpp
@@ -394,7 +393,6 @@ set(viewer_SOURCE_FILES
     llspatialpartition.cpp
     llspeakbutton.cpp
     llspeakers.cpp
-    llspeakingindicatormanager.cpp
     llsplitbutton.cpp
     llsprite.cpp
     llstartup.cpp
@@ -767,7 +765,6 @@ set(viewer_HEADER_FILES
     llinspectgroup.h
     llinspectobject.h
     llinspectremoteobject.h
-    llinspecttoast.h
     llinventorybridge.h
     llinventoryclipboard.h
     llinventoryfilter.h
@@ -863,7 +860,6 @@ set(viewer_HEADER_FILES
     llpanelshower.h
     llpanelteleporthistory.h
     llpanelvolume.h
-    llpanelvolumepulldown.h
     llparcelselection.h
     llparticipantlist.h
     llpatchvertexarray.h
@@ -904,7 +900,6 @@ set(viewer_HEADER_FILES
     llspatialpartition.h
     llspeakbutton.h
     llspeakers.h
-    llspeakingindicatormanager.h
     llsplitbutton.h
     llsprite.h
     llstartup.h
@@ -1775,7 +1770,6 @@ if (INSTALL)
 endif (INSTALL)
 
 if (LL_TESTS)
-else (LL_TESTS)
   # To add a viewer unit test, just add the test .cpp file below
   # This creates a separate test project per file listed.
   include(LLAddBuildTest)
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index db759f052a5..4bfc6f9e4f8 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1141,18 +1141,7 @@
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <integer>5</integer>
-    </map>
-    <key>CallFloaterMaxItems</key>
-    <map>
-      <key>Comment</key>
-      <string>Max number of visible participants in voice controls window</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
+      <string>Boolean</string>
       <key>Value</key>
       <integer>1</integer>
     </map>
diff --git a/indra/newview/installers/darwin/fix_application_icon_position.sh b/indra/newview/installers/darwin/fix_application_icon_position.sh
deleted file mode 100644
index a0b72a89f25..00000000000
--- a/indra/newview/installers/darwin/fix_application_icon_position.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-# just run this script each time after you change the installer's name to fix the icon misalignment 
-#!/bin/bash
-cp -r ./../../../build-darwin-i386/newview/*.dmg ~/Desktop/TempBuild.dmg
-hdid ~/Desktop/TempBuild.dmg
-open -a finder /Volumes/Second\ Life\ Installer
-osascript dmg-cleanup.applescript
-cp /Volumes/Second\ Life\ Installer/.DS_Store ~/Desktop/_DS_Store
-chflags nohidden ~/Desktop/_DS_Store
-cp ~/Desktop/_DS_Store ./firstlook-dmg/_DS_Store
-cp ~/Desktop/_DS_Store ./publicnightly-dmg/_DS_Store
-cp ~/Desktop/_DS_Store ./release-dmg/_DS_Store
-cp ~/Desktop/_DS_Store ./releasecandidate-dmg/_DS_Store
-umount /Volumes/Second\ Life\ Installer/
-rm ~/Desktop/_DS_Store ~/Desktop/TempBuild.dmg
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 5ea253709cf..5e2e374df65 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -514,8 +514,6 @@ void LLAgent::resetView(BOOL reset_camera, BOOL change_camera)
 		}
 
 		setFocusOnAvatar(TRUE, ANIMATE);
-
-		mCameraFOVZoomFactor = 0.f;
 	}
 
 	mHUDTargetZoom = 1.f;
@@ -3586,7 +3584,7 @@ F32	LLAgent::calcCameraFOVZoomFactor()
 	{
 		return 0.f;
 	}
-	else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar)
+	else if (mFocusObject.notNull() && !mFocusObject->isAvatar())
 	{
 		// don't FOV zoom on mostly transparent objects
 		LLVector3 focus_offset = mFocusObjectOffset;
@@ -5159,11 +5157,6 @@ BOOL LLAgent::setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOO
 	return FALSE;
 }
 
-BOOL LLAgent::canJoinGroups() const
-{
-	return mGroups.count() < MAX_AGENT_GROUPS;
-}
-
 LLQuaternion LLAgent::getHeadRotation()
 {
 	if (mAvatarObject.isNull() || !mAvatarObject->mPelvisp || !mAvatarObject->mHeadp)
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index beede7fbe34..2e95dc72be1 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -972,7 +972,6 @@ class LLAgent : public LLOldEvents::LLObservable
 	BOOL 			setGroupContribution(const LLUUID& group_id, S32 contribution);
 	BOOL 			setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOOL list_in_profile);
 	const std::string &getGroupName() const 	{ return mGroupName; }
-	BOOL			canJoinGroups() const;
 private:
 	std::string		mGroupName;
 	LLUUID			mGroupID;
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 19e9e52ddfd..5df73a994e4 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -82,7 +82,7 @@ void LLAvatarList::setSpeakingIndicatorsVisible(bool visible)
 	getItems(items);
 	for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++)
 	{
-		static_cast<LLAvatarListItem*>(*it)->showSpeakingIndicator(mShowSpeakingIndicator);
+		static_cast<LLAvatarListItem*>(*it)->setSpeakingIndicatorVisible(mShowSpeakingIndicator);
 	}
 }
 
@@ -323,15 +323,18 @@ boost::signals2::connection LLAvatarList::setRefreshCompleteCallback(const commi
 void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos)
 {
 	LLAvatarListItem* item = new LLAvatarListItem();
+	item->showInfoBtn(true);
+	item->showSpeakingIndicator(true);
 	item->setName(name);
 	item->setAvatarId(id, mIgnoreOnlineStatus);
 	item->setOnline(mIgnoreOnlineStatus ? true : is_online);
 	item->showLastInteractionTime(mShowLastInteractionTime);
 
+	item->childSetVisible("info_btn", false);
 	item->setAvatarIconVisible(mShowIcons);
 	item->setShowInfoBtn(mShowInfoBtn);
 	item->setShowProfileBtn(mShowProfileBtn);
-	item->showSpeakingIndicator(mShowSpeakingIndicator);
+	item->setSpeakingIndicatorVisible(mShowSpeakingIndicator);
 
 	addItem(item, id, pos);
 }
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index 1043858373c..6945ac69323 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -44,10 +44,10 @@
 #include "llbutton.h"
 
 bool LLAvatarListItem::sStaticInitialized = false;
-S32 LLAvatarListItem::sLeftPadding = 0;
-S32 LLAvatarListItem::sRightNamePadding = 0;
-S32 LLAvatarListItem::sChildrenWidths[LLAvatarListItem::ALIC_COUNT];
-
+S32 LLAvatarListItem::sIconWidth = 0;
+S32 LLAvatarListItem::sInfoBtnWidth = 0;
+S32 LLAvatarListItem::sProfileBtnWidth = 0;
+S32 LLAvatarListItem::sSpeakingIndicatorWidth = 0;
 
 LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/)
 :	LLPanel(),
@@ -91,25 +91,43 @@ BOOL  LLAvatarListItem::postBuild()
 	mProfileBtn->setVisible(false);
 	mProfileBtn->setClickedCallback(boost::bind(&LLAvatarListItem::onProfileBtnClick, this));
 
+	// Remember avatar icon width including its padding from the name text box,
+	// so that we can hide and show the icon again later.
 	if (!sStaticInitialized)
 	{
-		// Remember children widths including their padding from the next sibling,
-		// so that we can hide and show them again later.
-		initChildrenWidths(this);
+		sIconWidth = mAvatarName->getRect().mLeft - mAvatarIcon->getRect().mLeft;
+		sInfoBtnWidth = mInfoBtn->getRect().mRight - mSpeakingIndicator->getRect().mRight;
+		sProfileBtnWidth = mProfileBtn->getRect().mRight - mInfoBtn->getRect().mRight;
+		sSpeakingIndicatorWidth = mSpeakingIndicator->getRect().mRight - mAvatarName->getRect().mRight;
 
 		sStaticInitialized = true;
 	}
 
-	return TRUE;
-}
-
-S32 LLAvatarListItem::notifyParent(const LLSD& info)
-{
-	if (info.has("visibility_changed"))
+/*
+	if(!p.buttons.profile)
 	{
-		updateChildren();
+		delete mProfile;
+		mProfile = NULL;
+
+		LLRect rect;
+
+		rect.setLeftTopAndSize(mName->getRect().mLeft, mName->getRect().mTop, mName->getRect().getWidth() + 30, mName->getRect().getHeight());
+		mName->setRect(rect);
+
+		if(mLocator)
+		{
+			rect.setLeftTopAndSize(mLocator->getRect().mLeft + 30, mLocator->getRect().mTop, mLocator->getRect().getWidth(), mLocator->getRect().getHeight());
+			mLocator->setRect(rect);
+		}
+
+		if(mInfo)
+		{
+			rect.setLeftTopAndSize(mInfo->getRect().mLeft + 30, mInfo->getRect().mTop, mInfo->getRect().getWidth(), mInfo->getRect().getHeight());
+			mInfo->setRect(rect);
+		}
 	}
-	return 0;
+*/
+	return TRUE;
 }
 
 void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask)
@@ -119,8 +137,6 @@ void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask)
 	mProfileBtn->setVisible(mShowProfileBtn);
 
 	LLPanel::onMouseEnter(x, y, mask);
-
-	updateChildren();
 }
 
 void LLAvatarListItem::onMouseLeave(S32 x, S32 y, MASK mask)
@@ -130,8 +146,6 @@ void LLAvatarListItem::onMouseLeave(S32 x, S32 y, MASK mask)
 	mProfileBtn->setVisible(false);
 
 	LLPanel::onMouseLeave(x, y, mask);
-
-	updateChildren();
 }
 
 // virtual, called by LLAvatarTracker
@@ -201,8 +215,12 @@ void LLAvatarListItem::showLastInteractionTime(bool show)
 	if (show)
 		return;
 
+	LLRect	name_rect	= mAvatarName->getRect();
+	LLRect	time_rect	= mLastInteractionTime->getRect();
+
 	mLastInteractionTime->setVisible(false);
-	updateChildren();
+	name_rect.mRight += (time_rect.mRight - name_rect.mRight);
+	mAvatarName->setRect(name_rect);
 }
 
 void LLAvatarListItem::setLastInteractionTime(U32 secs_since)
@@ -216,6 +234,12 @@ void LLAvatarListItem::setShowInfoBtn(bool show)
 	if(mShowInfoBtn == show)
 		return;
 	mShowInfoBtn = show;
+	S32 width_delta = show ? - sInfoBtnWidth : sInfoBtnWidth;
+
+	//Translating speaking indicator
+	mSpeakingIndicator->translate(width_delta, 0);
+	//Reshaping avatar name
+	mAvatarName->reshape(mAvatarName->getRect().getWidth() + width_delta, mAvatarName->getRect().getHeight());
 }
 
 void LLAvatarListItem::setShowProfileBtn(bool show)
@@ -224,17 +248,24 @@ void LLAvatarListItem::setShowProfileBtn(bool show)
 	if(mShowProfileBtn == show)
 			return;
 	mShowProfileBtn = show;
+	S32 width_delta = show ? - sProfileBtnWidth : sProfileBtnWidth;
+
+	//Translating speaking indicator
+	mSpeakingIndicator->translate(width_delta, 0);
+	//Reshaping avatar name
+	mAvatarName->reshape(mAvatarName->getRect().getWidth() + width_delta, mAvatarName->getRect().getHeight());
 }
 
-void LLAvatarListItem::showSpeakingIndicator(bool visible)
+void LLAvatarListItem::setSpeakingIndicatorVisible(bool visible)
 {
 	// Already done? Then do nothing.
 	if (mSpeakingIndicator->getVisible() == (BOOL)visible)
 		return;
-// Disabled to not contradict with SpeakingIndicatorManager functionality. EXT-3976
-// probably this method should be totally removed.
-//	mSpeakingIndicator->setVisible(visible);
-//	updateChildren();
+	mSpeakingIndicator->setVisible(visible);
+	S32 width_delta = visible ? - sSpeakingIndicatorWidth : sSpeakingIndicatorWidth;
+
+	//Reshaping avatar name
+	mAvatarName->reshape(mAvatarName->getRect().getWidth() + width_delta, mAvatarName->getRect().getHeight());
 }
 
 void LLAvatarListItem::setAvatarIconVisible(bool visible)
@@ -245,12 +276,36 @@ void LLAvatarListItem::setAvatarIconVisible(bool visible)
 
 	// Show/hide avatar icon.
 	mAvatarIcon->setVisible(visible);
-	updateChildren();
+
+	// Move the avatar name horizontally by icon size + its distance from the avatar name.
+	LLRect name_rect = mAvatarName->getRect();
+	name_rect.mLeft += visible ? sIconWidth : -sIconWidth;
+	mAvatarName->setRect(name_rect);
 }
 
 void LLAvatarListItem::onInfoBtnClick()
 {
 	LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", mAvatarId));
+
+	/* TODO fix positioning of inspector
+	localPointToScreen(mXPos, mYPos, &mXPos, &mYPos);
+	
+	
+	LLRect rect;
+
+	// *TODO Vadim: rewrite this. "+= -" looks weird.
+	S32 delta = mYPos - inspector->getRect().getHeight();
+	if(delta < 0)
+	{
+		mYPos += -delta;
+	}
+	
+	rect.setLeftTopAndSize(mXPos, mYPos,
+	inspector->getRect().getWidth(), inspector->getRect().getHeight()); 
+	inspector->setRect(rect);
+	inspector->setFrontmost(true);
+	inspector->setVisible(true);
+	*/
 }
 
 void LLAvatarListItem::onProfileBtnClick()
@@ -289,6 +344,21 @@ void LLAvatarListItem::onNameCache(const std::string& first_name, const std::str
 	setName(name);
 }
 
+void LLAvatarListItem::reshapeAvatarName()
+{
+	S32 width_delta = 0;
+	width_delta += mShowProfileBtn ? sProfileBtnWidth : 0;
+	width_delta += mSpeakingIndicator->getVisible() ? sSpeakingIndicatorWidth : 0;
+	width_delta += mAvatarIcon->getVisible() ? sIconWidth : 0;
+	width_delta += mShowInfoBtn ? sInfoBtnWidth : 0;
+	width_delta += mLastInteractionTime->getVisible() ? mLastInteractionTime->getRect().getWidth() : 0;
+
+	S32 height = mAvatarName->getRect().getHeight();
+	S32 width  = getRect().getWidth() - width_delta;
+
+	mAvatarName->reshape(width, height);
+}
+
 // Convert given number of seconds to a string like "23 minutes", "15 hours" or "3 years",
 // taking i18n into account. The format string to use is taken from the panel XML.
 std::string LLAvatarListItem::formatSeconds(U32 secs)
@@ -422,133 +492,4 @@ LLAvatarListItem::icon_color_map_t& LLAvatarListItem::getItemIconColorMap()
 	return item_icon_color_map;
 }
 
-// static
-void LLAvatarListItem::initChildrenWidths(LLAvatarListItem* avatar_item)
-{
-	//profile btn width + padding
-	S32 profile_btn_width = avatar_item->getRect().getWidth() - avatar_item->mProfileBtn->getRect().mLeft;
-
-	//info btn width + padding
-	S32 info_btn_width = avatar_item->mProfileBtn->getRect().mLeft - avatar_item->mInfoBtn->getRect().mLeft;
-
-	//speaking indicator width + padding
-	S32 speaking_indicator_width = avatar_item->mInfoBtn->getRect().mLeft - avatar_item->mSpeakingIndicator->getRect().mLeft;
-
-	// last interaction time textbox width + padding
-	S32 last_interaction_time_width = avatar_item->mSpeakingIndicator->getRect().mLeft - avatar_item->mLastInteractionTime->getRect().mLeft;
-
-	// icon width + padding
-	S32 icon_width = avatar_item->mAvatarName->getRect().mLeft - avatar_item->mAvatarIcon->getRect().mLeft;
-
-	sLeftPadding = avatar_item->mAvatarIcon->getRect().mLeft;
-	sRightNamePadding = avatar_item->mLastInteractionTime->getRect().mLeft - avatar_item->mAvatarName->getRect().mRight;
-
-	S32 index = ALIC_COUNT;
-	sChildrenWidths[--index] = icon_width;
-	sChildrenWidths[--index] = 0; // for avatar name we don't need its width, it will be calculated as "left available space"
-	sChildrenWidths[--index] = last_interaction_time_width;
-	sChildrenWidths[--index] = speaking_indicator_width;
-	sChildrenWidths[--index] = info_btn_width;
-	sChildrenWidths[--index] = profile_btn_width;
-}
-
-void LLAvatarListItem::updateChildren()
-{
-	LL_DEBUGS("AvatarItemReshape") << LL_ENDL;
-	LL_DEBUGS("AvatarItemReshape") << "Updating for: " << getAvatarName() << LL_ENDL;
-
-	S32 name_new_width = getRect().getWidth();
-	S32 ctrl_new_left = name_new_width;
-	S32 name_new_left = sLeftPadding;
-
-	// iterate through all children and set them into correct position depend on each child visibility
-	// assume that child indexes are in back order: the first in Enum is the last (right) in the item
-	// iterate & set child views starting from right to left
-	for (S32 i = 0; i < ALIC_COUNT; ++i)
-	{
-		// skip "name" textbox, it will be processed out of loop later
-		if (ALIC_NAME == i) continue;
-
-		LLView* control = getItemChildView((EAvatarListItemChildIndex)i);
-
-		LL_DEBUGS("AvatarItemReshape") << "Processing control: " << control->getName() << LL_ENDL;
-		// skip invisible views
-		if (!control->getVisible()) continue;
-
-		S32 ctrl_width = sChildrenWidths[i]; // including space between current & left controls
-
-		// decrease available for 
-		name_new_width -= ctrl_width;
-		LL_DEBUGS("AvatarItemReshape") << "width: " << ctrl_width << ", name_new_width: " << name_new_width << LL_ENDL;
-
-		LLRect control_rect = control->getRect();
-		LL_DEBUGS("AvatarItemReshape") << "rect before: " << control_rect << LL_ENDL;
-
-		if (ALIC_ICON == i)
-		{
-			// assume that this is the last iteration,
-			// so it is not necessary to save "ctrl_new_left" value calculated on previous iterations
-			ctrl_new_left = sLeftPadding;
-			name_new_left = ctrl_new_left + ctrl_width;
-		}
-		else
-		{
-			ctrl_new_left -= ctrl_width;
-		}
-
-		LL_DEBUGS("AvatarItemReshape") << "ctrl_new_left: " << ctrl_new_left << LL_ENDL;
-
-		control_rect.setLeftTopAndSize(
-			ctrl_new_left,
-			control_rect.mTop,
-			control_rect.getWidth(),
-			control_rect.getHeight());
-
-		LL_DEBUGS("AvatarItemReshape") << "rect after: " << control_rect << LL_ENDL;
-		control->setShape(control_rect);
-	}
-
-	// set size and position of the "name" child
-	LLView* name_view = getItemChildView(ALIC_NAME);
-	LLRect name_view_rect = name_view->getRect();
-	LL_DEBUGS("AvatarItemReshape") << "name rect before: " << name_view_rect << LL_ENDL;
-
-	// apply paddings
-	name_new_width -= sLeftPadding;
-	name_new_width -= sRightNamePadding;
-
-	name_view_rect.setLeftTopAndSize(
-		name_new_left,
-		name_view_rect.mTop,
-		name_new_width,
-		name_view_rect.getHeight());
-
-	name_view->setShape(name_view_rect);
-
-	LL_DEBUGS("AvatarItemReshape") << "name rect after: " << name_view_rect << LL_ENDL;
-}
-
-LLView* LLAvatarListItem::getItemChildView(EAvatarListItemChildIndex child_view_index)
-{
-	LLView* child_view = mAvatarName;
-	if (child_view_index < 0 || ALIC_COUNT <= child_view_index)
-	{
-		LL_WARNS("AvatarItemReshape") << "Child view index is out of range: " << child_view_index << LL_ENDL;
-		return child_view;
-	}
-	switch (child_view_index)
-	{
-	case ALIC_ICON:					child_view = mAvatarIcon; break;
-	case ALIC_NAME:					child_view = mAvatarName; break;
-	case ALIC_INTERACTION_TIME:		child_view = mLastInteractionTime; break;
-	case ALIC_SPEAKER_INDICATOR:	child_view = mSpeakingIndicator; break;
-	case ALIC_INFO_BUTTON:			child_view = mInfoBtn; break;
-	case ALIC_PROFILE_BUTTON:		child_view = mProfileBtn; break;
-	default:
-		LL_WARNS("AvatarItemReshape") << "Unexpected child view index is passed: " << child_view_index << LL_ENDL;
-	}
-	
-	return child_view;
-}
-
 // EOF
diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h
index f76ffb391d4..96097bc9b52 100644
--- a/indra/newview/llavatarlistitem.h
+++ b/indra/newview/llavatarlistitem.h
@@ -74,11 +74,6 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	virtual ~LLAvatarListItem();
 
 	virtual BOOL postBuild();
-
-	/**
-	 * Processes notification from speaker indicator to update children when indicator's visibility is changed.
-	 */
-	virtual S32	notifyParent(const LLSD& info);
 	virtual void onMouseLeave(S32 x, S32 y, MASK mask);
 	virtual void onMouseEnter(S32 x, S32 y, MASK mask);
 	virtual void setValue(const LLSD& value);
@@ -93,8 +88,7 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	//Show/hide profile/info btn, translating speaker indicator and avatar name coordinates accordingly
 	void setShowProfileBtn(bool show);
 	void setShowInfoBtn(bool show);
-	void showSpeakingIndicator(bool show);
-	void showLastInteractionTime(bool show);
+	void setSpeakingIndicatorVisible(bool visible);
 	void setAvatarIconVisible(bool visible);
 	
 	const LLUUID& getAvatarId() const;
@@ -103,6 +97,17 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	void onInfoBtnClick();
 	void onProfileBtnClick();
 
+	void showSpeakingIndicator(bool show) { mSpeakingIndicator->setVisible(show); }
+	void showInfoBtn(bool show_info_btn) {mInfoBtn->setVisible(show_info_btn); }
+	void showLastInteractionTime(bool show);
+
+	/**
+	 * This method was added to fix EXT-2364 (Items in group/ad-hoc IM participant list (avatar names) should be reshaped when adding/removing the "(Moderator)" label)
+	 * But this is a *HACK. The real reason of it was in incorrect logic while hiding profile/info/speaker buttons
+	 * *TODO: new reshape method should be provided in lieu of this one to be called when visibility if those buttons is changed
+	 */
+	void reshapeAvatarName();
+
 protected:
 	/**
 	 * Contains indicator to show voice activity. 
@@ -119,23 +124,6 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 		E_UNKNOWN,
 	} EOnlineStatus;
 
-	/**
-	 * Enumeration of item elements in order from right to left.
-	 * 
-	 * updateChildren() assumes that indexes are in the such order to process avatar icon easier.
-	 *
-	 * @see updateChildren()
-	 */
-	typedef enum e_avatar_item_child {
-		ALIC_PROFILE_BUTTON,
-		ALIC_INFO_BUTTON,
-		ALIC_SPEAKER_INDICATOR,
-		ALIC_INTERACTION_TIME,
-		ALIC_NAME,
-		ALIC_ICON,
-		ALIC_COUNT,
-	} EAvatarListItemChildIndex;
-
 	void setNameInternal(const std::string& name, const std::string& highlight);
 	void onNameCache(const std::string& first_name, const std::string& last_name);
 
@@ -147,26 +135,6 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	typedef std::map<EItemState, LLColor4> icon_color_map_t;
 	static icon_color_map_t& getItemIconColorMap();
 
-	/**
-	 * Initializes widths of all children to use them while changing visibility of any of them.
-	 *
-	 * @see updateChildren()
-	 */
-	static void initChildrenWidths(LLAvatarListItem* self);
-
-	/**
-	 * Updates position and rectangle of visible children to fit all available item's width.
-	 */
-	void updateChildren();
-
-	/**
-	 * Gets child view specified by index.
-	 *
-	 * This method implemented via switch by all EAvatarListItemChildIndex values.
-	 * It is used to not store children in array or vector to avoid of increasing memory usage.
-	 */
-	LLView* getItemChildView(EAvatarListItemChildIndex child_index);
-
 	LLTextBox* mAvatarName;
 	LLTextBox* mLastInteractionTime;
 	LLStyle::Params mAvatarNameStyle;
@@ -183,17 +151,10 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	bool mShowProfileBtn;
 
 	static bool	sStaticInitialized; // this variable is introduced to improve code readability
-	static S32  sLeftPadding; // padding to first left visible child (icon or name)
-	static S32  sRightNamePadding; // right padding from name to next visible child
-
-	/**
-	 * Contains widths of each child specified by EAvatarListItemChildIndex
-	 * including padding to the next right one.
-	 *
-	 * @see initChildrenWidths()
-	 */
-	static S32 sChildrenWidths[ALIC_COUNT];
-
+	static S32	sIconWidth; // icon width + padding
+	static S32  sInfoBtnWidth; //info btn width + padding
+	static S32  sProfileBtnWidth; //profile btn width + padding
+	static S32  sSpeakingIndicatorWidth; //speaking indicator width + padding
 };
 
 #endif //LL_LLAVATARLISTITEM_H
diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp
index beccefa4301..976b3125093 100644
--- a/indra/newview/llbottomtray.cpp
+++ b/indra/newview/llbottomtray.cpp
@@ -161,9 +161,6 @@ void LLBottomTray::sessionAdded(const LLUUID& session_id, const std::string& nam
 	{
 		chiclet->setIMSessionName(name);
 		chiclet->setOtherParticipantId(other_participant_id);
-		
-		LLIMFloater::onIMChicletCreated(session_id);
-
 	}
 	else
 	{
@@ -254,24 +251,14 @@ void LLBottomTray::setVisible(BOOL visible)
 		{
 			LLView* viewp = *child_it;
 			std::string name = viewp->getName();
-
-			// Chat bar and gesture button are shown even in mouselook mode. But the move, camera and snapshot buttons shouldn't be displayed. See EXT-3988.
-			if ("chat_bar" == name || "gesture_panel" == name || (visibility && ("movement_panel" == name || "cam_panel" == name || "snapshot_panel" == name)))
+			
+			if ("chat_bar" == name || "movement_panel" == name || "cam_panel" == name || "snapshot_panel" == name || "gesture_panel" == name)
 				continue;
 			else 
 			{
 				viewp->setVisible(visibility);
 			}
 		}
-
-		// Apply the saved settings when we are not in mouselook mode, see EXT-3988.
-		if (visibility)
-		{
-			showCameraButton(gSavedSettings.getBOOL("ShowCameraButton"));
-			showSnapshotButton(gSavedSettings.getBOOL("ShowSnapshotButton"));
-			showMoveButton(gSavedSettings.getBOOL("ShowMoveButton"));
-			showGestureButton(gSavedSettings.getBOOL("ShowGestureButton"));
-		}
 	}
 }
 
diff --git a/indra/newview/llcallfloater.cpp b/indra/newview/llcallfloater.cpp
index c0efb85b512..1468f6d584f 100644
--- a/indra/newview/llcallfloater.cpp
+++ b/indra/newview/llcallfloater.cpp
@@ -51,7 +51,6 @@
 #include "lltransientfloatermgr.h"
 #include "llviewerwindow.h"
 #include "llvoicechannel.h"
-#include "lllayoutstack.h"
 
 static void get_voice_participants_uuids(std::vector<LLUUID>& speakers_uuids);
 
@@ -315,7 +314,7 @@ void LLCallFloater::updateSession()
 	
 	//hide "Leave Call" button for nearby chat
 	bool is_local_chat = mVoiceType == VC_LOCAL_CHAT;
-	childSetVisible("leave_call_btn_panel", !is_local_chat);
+	childSetVisible("leave_call_btn", !is_local_chat);
 	
 	refreshParticipantList();
 	updateAgentModeratorState();
@@ -819,8 +818,8 @@ void reshape_floater(LLCallFloater* floater, S32 delta_height)
 		}
 	}
 
-	floater->setShape(floater_rect);
-	floater->getChild<LLLayoutStack>("my_call_stack")->updateLayout(FALSE);
+	floater->reshape(floater_rect.getWidth(), floater_rect.getHeight());
+	floater->setRect(floater_rect);
 }
 
 void LLCallFloater::reshapeToFitContent()
@@ -865,8 +864,9 @@ S32 LLCallFloater::getParticipantItemHeight()
 
 S32 LLCallFloater::getMaxVisibleItems()
 {
-	static LLCachedControl<S32> max_visible_items(*LLUI::sSettingGroups["config"],"CallFloaterMaxItems");
-	return max_visible_items;
+	S32 value = 5; // default value, in case convertToS32() fails.
+	LLStringUtil::convertToS32(getString("max_visible_items"), value);
+	return value;
 }
 
 //EOF
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 2fc83c7e54f..cda3e3a4191 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -499,24 +499,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_
 	style_params.font.name(font_name);
 	style_params.font.size(font_size);	
 	style_params.font.style(input_append_params.font.style);
-
-	std::string prefix = chat.mText.substr(0, 4);
-
-	//IRC styled /me messages.
-	bool irc_me = prefix == "/me " || prefix == "/me'";
-
-	// Delimiter after a name in header copy/past and in plain text mode
-	std::string delimiter = (chat.mChatType != CHAT_TYPE_SHOUT && chat.mChatType != CHAT_TYPE_WHISPER)
-		? ": "
-		: " ";
-
-	// Don't add any delimiter after name in irc styled messages
-	if (irc_me || chat.mChatStyle == CHAT_STYLE_IRC)
-	{
-		delimiter = LLStringUtil::null;
-		style_params.font.style = "ITALIC";
-	}
-
+	
 	if (use_plain_text_chat_history)
 	{
 		mEditor->appendText("[" + chat.mTimeStr + "] ", mEditor->getText().size() != 0, style_params);
@@ -529,11 +512,11 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_
 				LLStyle::Params link_params(style_params);
 				link_params.fillFrom(LLStyleMap::instance().lookupAgent(chat.mFromID));
 				// Convert the name to a hotlink and add to message.
-				mEditor->appendText(chat.mFromName + delimiter, false, link_params);
+				mEditor->appendText(chat.mFromName + ": ", false, link_params);
 			}
 			else
 			{
-				mEditor->appendText(chat.mFromName + delimiter, false, style_params);
+				mEditor->appendText(chat.mFromName + ": ", false, style_params);
 			}
 		}
 	}
@@ -579,22 +562,36 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_
 
 		std::string header_text = "[" + chat.mTimeStr + "] ";
 		if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM)
-			header_text += chat.mFromName + delimiter;
+			header_text += chat.mFromName + ": ";
 
 		mEditor->appendWidget(p, header_text, false);
 		mLastFromName = chat.mFromName;
 		mLastFromID = chat.mFromID;
 		mLastMessageTime = new_message_time;
 	}
-
-	std::string message = irc_me ? chat.mText.substr(3) : chat.mText;
-	if ( message.size() > 0 && !LLStringOps::isSpace(message[message.size() - 1]) )
+	//Handle IRC styled /me messages.
+	std::string prefix = chat.mText.substr(0, 4);
+	if (prefix == "/me " || prefix == "/me'")
 	{
+		style_params.font.style = "ITALIC";
+
+		if (chat.mFromName.size() > 0)
+			mEditor->appendText(chat.mFromName, TRUE, style_params);
 		// Ensure that message ends with NewLine, to avoid losing of new lines
 		// while copy/paste from text chat. See EXT-3263.
-		message += NEW_LINE;
+		mEditor->appendText(chat.mText.substr(3) + NEW_LINE, FALSE, style_params);
+	}
+	else
+	{
+		std::string message(chat.mText);
+		if ( message.size() > 0 && !LLStringOps::isSpace(message[message.size() - 1]) )
+		{
+			// Ensure that message ends with NewLine, to avoid losing of new lines
+			// while copy/paste from text chat. See EXT-3263.
+			message += NEW_LINE;
+		}
+		mEditor->appendText(message, FALSE, style_params);
 	}
-	mEditor->appendText(message, FALSE, style_params);
 	mEditor->blockUndo();
 
 	// automatically scroll to end when receiving chat from myself
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index ef69f39ad2d..aa343b2f697 100644
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -269,7 +269,7 @@ LLSD LLFloaterAbout::getInfo()
 	info["VIVOX_VERSION"] = gVoiceClient ? gVoiceClient->getAPIVersion() : LLTrans::getString("NotConnected");
 
 	// TODO: Implement media plugin version query
-	info["QT_WEBKIT_VERSION"] = "4.6 (version number hard-coded)";
+	info["QT_WEBKIT_VERSION"] = "4.5.2 (version number hard-coded)";
 
 	if (gPacketsIn > 0)
 	{
diff --git a/indra/newview/llfloaterchat.cpp b/indra/newview/llfloaterchat.cpp
index 18b9f0484fd..b9e0f928f14 100644
--- a/indra/newview/llfloaterchat.cpp
+++ b/indra/newview/llfloaterchat.cpp
@@ -190,14 +190,7 @@ void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file)
 {	
 	if (log_to_file && (gSavedPerAccountSettings.getBOOL("LogChat"))) 
 	{
-		if (chat.mChatType != CHAT_TYPE_WHISPER && chat.mChatType != CHAT_TYPE_SHOUT)
-		{
-			LLLogChat::saveHistory("chat", chat.mFromName, chat.mFromID, chat.mText);
-		}
-		else
-		{
-			LLLogChat::saveHistory("chat", "", chat.mFromID, chat.mFromName + " " + chat.mText);
-		}
+		LLLogChat::saveHistory("chat", chat.mFromName, chat.mFromID, chat.mText);
 	}
 	
 	LLColor4 color = get_text_color(chat);
@@ -318,10 +311,8 @@ void LLFloaterChat::addChat(const LLChat& chat, BOOL from_instant_message, BOOL
 	triggerAlerts(chat.mText);
 
 	// Add the sender to the list of people with which we've recently interacted.
-	// this is not the best place to add _all_ messages to recent list
-	// comment this for now, may remove later on code cleanup
-	//if(chat.mSourceType == CHAT_SOURCE_AGENT && chat.mFromID.notNull())
-	//	LLRecentPeople::instance().add(chat.mFromID);
+	if(chat.mSourceType == CHAT_SOURCE_AGENT && chat.mFromID.notNull())
+		LLRecentPeople::instance().add(chat.mFromID);
 	
 	bool add_chat = true;
 	bool log_chat = true;
diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp
index 6a9c602db20..5072bc8c820 100644
--- a/indra/newview/llfloatergesture.cpp
+++ b/indra/newview/llfloatergesture.cpp
@@ -415,7 +415,7 @@ void LLFloaterGesture::onClickPlay()
 	LL_DEBUGS("Gesture")<<" Trying to play gesture id: "<< item_id <<LL_ENDL;
 	if(!LLGestureManager::instance().isGestureActive(item_id))
 	{
-		// we need to inform server about gesture activating to be consistent with LLPreviewGesture and  LLGestureComboList.
+		// we need to inform server about gesture activating to be consistent with LLPreviewGesture and  LLGestureComboBox.
 		BOOL inform_server = TRUE;
 		BOOL deactivate_similar = FALSE;
 		LLGestureManager::instance().setGestureLoadedCallback(item_id, boost::bind(&LLFloaterGesture::playGesture, this, item_id));
diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp
index 29f415bd439..7cb925bc0b0 100644
--- a/indra/newview/llfloatergroups.cpp
+++ b/indra/newview/llfloatergroups.cpp
@@ -247,7 +247,14 @@ void LLPanelGroups::enableButtons()
 		childDisable("IM");
 		childDisable("Leave");
 	}
-	childSetEnabled("Create", gAgent.canJoinGroups());
+	if(gAgent.mGroups.count() < MAX_AGENT_GROUPS)
+	{
+		childEnable("Create");
+	}
+	else
+	{
+		childDisable("Create");
+	}
 }
 
 
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 42c961a956b..598a13de158 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -276,7 +276,6 @@ void LLFloaterLand::refresh()
 	mPanelAudio->refresh();
 	mPanelMedia->refresh();
 	mPanelAccess->refresh();
-	mPanelCovenant->refresh();
 }
 
 
@@ -2796,6 +2795,12 @@ LLPanelLandCovenant::~LLPanelLandCovenant()
 {
 }
 
+BOOL LLPanelLandCovenant::postBuild()
+{
+	refresh();
+	return TRUE;
+}
+
 // virtual
 void LLPanelLandCovenant::refresh()
 {
diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h
index a4785e8f5b0..d7d02ba1a37 100644
--- a/indra/newview/llfloaterland.h
+++ b/indra/newview/llfloaterland.h
@@ -391,6 +391,7 @@ class LLPanelLandCovenant
 public:
 	LLPanelLandCovenant(LLSafeHandle<LLParcelSelection>& parcelp);
 	virtual ~LLPanelLandCovenant();
+	virtual BOOL postBuild();
 	void refresh();
 	static void updateCovenantText(const std::string& string);
 	static void updateEstateName(const std::string& name);
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 9af37e81749..d0716f67b80 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -602,8 +602,8 @@ void LLFloaterPreference::onBtnOK()
 		apply();
 		closeFloater(false);
 
-		LLUIColorTable::instance().saveUserSettings();
 		gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
+		LLUIColorTable::instance().saveUserSettings();
 		std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
 		// save all settings, even if equals defaults
 		gCrashSettings.saveToFile(crash_settings_filename, FALSE);
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 0402ba20e21..c4b87c1b2dc 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -406,11 +406,6 @@ LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant()
 
 void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region)
 {
-	if (!region)
-	{
-		return; 
-	}
-
 	// call refresh from region on all panels
 	std::for_each(
 		mInfoPanels.begin(),
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index 82293b4aa0b..df7aa9eabf3 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -417,16 +417,6 @@ BOOL LLGestureManager::isGesturePlaying(const LLUUID& item_id)
 	return gesture->mPlaying;
 }
 
-BOOL LLGestureManager::isGesturePlaying(LLMultiGesture* gesture)
-{
-	if(!gesture)
-	{
-		return FALSE;
-	}
-
-	return gesture->mPlaying;
-}
-
 void LLGestureManager::replaceGesture(const LLUUID& item_id, LLMultiGesture* new_gesture, const LLUUID& asset_id)
 {
 	const LLUUID& base_item_id = get_linked_uuid(item_id);
diff --git a/indra/newview/llgesturemgr.h b/indra/newview/llgesturemgr.h
index c562587c6fd..e80eea9ae90 100644
--- a/indra/newview/llgesturemgr.h
+++ b/indra/newview/llgesturemgr.h
@@ -103,8 +103,6 @@ class LLGestureManager : public LLSingleton<LLGestureManager>, public LLInventor
 
 	BOOL isGesturePlaying(const LLUUID& item_id);
 
-	BOOL isGesturePlaying(LLMultiGesture* gesture);
-
 	const item_map_t& getActiveGestures() const { return mActive; }
 	// Force a gesture to be played, for example, if it is being
 	// previewed.
diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp
index d6e2bb0445f..7dd8ea694e9 100644
--- a/indra/newview/llgroupactions.cpp
+++ b/indra/newview/llgroupactions.cpp
@@ -146,12 +146,6 @@ void LLGroupActions::startCall(const LLUUID& group_id)
 // static
 void LLGroupActions::join(const LLUUID& group_id)
 {
-	if (!gAgent.canJoinGroups())
-	{
-		LLNotificationsUtil::add("JoinedTooManyGroups");
-		return;
-	}
-
 	LLGroupMgrGroupData* gdatap = 
 		LLGroupMgr::getInstance()->getGroupData(group_id);
 
@@ -232,9 +226,7 @@ void LLGroupActions::activate(const LLUUID& group_id)
 
 static bool isGroupUIVisible()
 {
-	static LLPanel* panel = 0;
-	if(!panel)
-		panel = LLSideTray::getInstance()->findChild<LLPanel>("panel_group_info_sidetray");
+	LLPanel* panel = LLSideTray::getInstance()->findChild<LLPanel>("panel_group_info_sidetray");
 	if(!panel)
 		return false;
 	return panel->isInVisibleChain();
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index aee34eb0af5..b05568f353f 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -361,7 +361,35 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
 {
 	if (!gIMMgr->hasSession(session_id)) return NULL;
 
-	if(!isChatMultiTab())
+	// we should make sure all related chiclets are in place when the session is a voice call
+	// chiclets come firts, then comes IM window
+	if (gIMMgr->isVoiceCall(session_id))
+	{
+		LLIMModel* im_model = LLIMModel::getInstance();
+		LLBottomTray* b_tray = LLBottomTray::getInstance();
+		
+		//*TODO hide that into Bottom tray
+		if (!b_tray->getChicletPanel()->findChiclet<LLChiclet>(session_id))
+		{
+			LLIMChiclet* chiclet = b_tray->createIMChiclet(session_id);
+			if(chiclet)
+			{
+				chiclet->setIMSessionName(im_model->getName(session_id));
+				chiclet->setOtherParticipantId(im_model->getOtherParticipantID(session_id));
+			}
+		}
+
+		LLIMWellWindow::getInstance()->addIMRow(session_id);
+	}
+		
+	bool not_existed = true;
+
+	if(isChatMultiTab())
+	{
+		LLIMFloater* target_floater = findInstance(session_id);
+		not_existed = NULL == target_floater;
+	}
+	else
 	{
 		//hide all
 		LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("impanel");
@@ -376,33 +404,19 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
 		}
 	}
 
-	bool exist = findInstance(session_id);
-
-	LLIMFloater* floater = getInstance(session_id);
-	if (!floater) return NULL;
+	LLIMFloater* floater = LLFloaterReg::showTypedInstance<LLIMFloater>("impanel", session_id);
 
 	if(isChatMultiTab())
 	{
-		LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance();
-
 		// do not add existed floaters to avoid adding torn off instances
-		if (!exist)
+		if (not_existed)
 		{
 			//		LLTabContainer::eInsertionPoint i_pt = user_initiated ? LLTabContainer::RIGHT_OF_CURRENT : LLTabContainer::END;
 			// TODO: mantipov: use LLTabContainer::RIGHT_OF_CURRENT if it exists
 			LLTabContainer::eInsertionPoint i_pt = LLTabContainer::END;
-			
-			if (floater_container)
-			{
-				floater_container->addFloater(floater, TRUE, i_pt);
-			}
-		}
 
-		if (floater_container)
-		{
-			//selecting the panel resets a chiclet's counter
-			floater_container->selectFloater(floater);
-			floater_container->setVisible(TRUE);
+			LLIMFloaterContainer* floater_container = LLFloaterReg::showTypedInstance<LLIMFloaterContainer>("im_container");
+			floater_container->addFloater(floater, TRUE, i_pt);
 		}
 	}
 	else
@@ -429,8 +443,8 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
 		}
 
 		// window is positioned, now we can show it.
+		floater->setVisible(true);
 	}
-	floater->setVisible(TRUE);
 
 	return floater;
 }
@@ -470,6 +484,16 @@ void LLIMFloater::setDocked(bool docked, bool pop_on_undock)
 	}
 }
 
+void LLIMFloater::setTornOff(bool torn_off)
+{
+	// When IM Floater isn't torn off, "close" button should be hidden.
+	// This call will just disables it, since there is a hack in LLFloater::updateButton,
+	// which prevents hiding of close button in that case.
+	setCanClose(torn_off);
+
+	LLTransientDockableFloater::setTornOff(torn_off);
+}
+
 void LLIMFloater::setVisible(BOOL visible)
 {
 	LLNotificationsUI::LLScreenChannel* channel = dynamic_cast<LLNotificationsUI::LLScreenChannel*>
@@ -524,11 +548,6 @@ LLIMFloater* LLIMFloater::findInstance(const LLUUID& session_id)
 	return LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id);
 }
 
-LLIMFloater* LLIMFloater::getInstance(const LLUUID& session_id)
-{
-	return LLFloaterReg::getTypedInstance<LLIMFloater>("impanel", session_id);
-}
-
 void LLIMFloater::sessionInitReplyReceived(const LLUUID& im_session_id)
 {
 	mSessionInitialized = true;
@@ -1007,20 +1026,3 @@ void LLIMFloater::sRemoveTypingIndicator(const LLSD& data)
 
 	floater->removeTypingIndicator();
 }
-
-void LLIMFloater::onIMChicletCreated( const LLUUID& session_id )
-{
-
-	if (isChatMultiTab())
-	{
-		LLIMFloaterContainer* im_box = LLIMFloaterContainer::getInstance();
-		if (!im_box) return;
-
-		if (LLIMFloater::findInstance(session_id)) return;
-
-		LLIMFloater* new_tab = LLIMFloater::getInstance(session_id);
-
-		im_box->addFloater(new_tab, FALSE, LLTabContainer::END);
-	}
-
-}
diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h
index d9db385d06a..bc7a43e852a 100644
--- a/indra/newview/llimfloater.h
+++ b/indra/newview/llimfloater.h
@@ -64,6 +64,7 @@ class LLIMFloater : public LLTransientDockableFloater
 	// LLFloater overrides
 	/*virtual*/ void onClose(bool app_quitting);
 	/*virtual*/ void setDocked(bool docked, bool pop_on_undock = true);
+	/*virtual*/ void setTornOff(bool torn_off);
 
 	// Make IM conversion visible and update the message history
 	static LLIMFloater* show(const LLUUID& session_id);
@@ -74,8 +75,6 @@ class LLIMFloater : public LLTransientDockableFloater
 
 	static LLIMFloater* findInstance(const LLUUID& session_id);
 
-	static LLIMFloater* getInstance(const LLUUID& session_id);
-
 	void sessionInitReplyReceived(const LLUUID& im_session_id);
 
 	// get new messages from LLIMModel
@@ -114,8 +113,6 @@ class LLIMFloater : public LLTransientDockableFloater
 	//used as a callback on receiving new IM message
 	static void sRemoveTypingIndicator(const LLSD& data);
 
-	static void onIMChicletCreated(const LLUUID& session_id);
-
 private:
 	// process focus events to set a currently active session
 	/* virtual */ void onFocusLost();
diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 6cc985aef49..2d7333f7e47 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -34,7 +34,6 @@
 #include "llviewerprecompiledheaders.h"
 
 #include "llimfloatercontainer.h"
-#include "llfloaterreg.h"
 
 //
 // LLIMFloaterContainer
@@ -94,14 +93,4 @@ void LLIMFloaterContainer::addFloater(LLFloater* floaterp,
 	}
 }
 
-LLIMFloaterContainer* LLIMFloaterContainer::findInstance()
-{
-	return LLFloaterReg::findTypedInstance<LLIMFloaterContainer>("im_container");
-}
-
-LLIMFloaterContainer* LLIMFloaterContainer::getInstance()
-{
-	return LLFloaterReg::getTypedInstance<LLIMFloaterContainer>("im_container");
-}
-
 // EOF
diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h
index d4a542dfc22..ead7cf47309 100644
--- a/indra/newview/llimfloatercontainer.h
+++ b/indra/newview/llimfloatercontainer.h
@@ -52,11 +52,7 @@ class LLIMFloaterContainer : public LLMultiFloater
 								LLTabContainer::eInsertionPoint insertion_point = LLTabContainer::END);
 
 	static LLFloater* getCurrentVoiceFloater();
-
-	static LLIMFloaterContainer* findInstance();
-
-	static LLIMFloaterContainer* getInstance();
-
+	
 protected:
 	
 	LLFloater* mActiveVoiceFloater;
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index e9661003ea0..daabf1f7178 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -382,6 +382,10 @@ void LLIMModel::LLIMSession::addMessage(const std::string& from, const LLUUID& f
 		mSpeakers->speakerChatted(from_id);
 		mSpeakers->setSpeakerTyping(from_id, FALSE);
 	}
+
+	if( mSessionType == P2P_SESSION ||
+		mSessionType == ADHOC_SESSION)
+		LLRecentPeople::instance().add(from_id);
 }
 
 void LLIMModel::LLIMSession::addMessagesFromHistory(const std::list<LLSD>& history)
@@ -680,12 +684,6 @@ bool LLIMModel::addMessage(const LLUUID& session_id, const std::string& from, co
 	LLIMSession* session = addMessageSilently(session_id, from, from_id, utf8_text, log2file);
 	if (!session) return false;
 
-	//good place to add some1 to recent list
-	//other places may be called from message history.
-	if( !from_id.isNull() &&
-		( session->isP2PSessionType() || session->isAdHocSessionType() ) )
-		LLRecentPeople::instance().add(from_id);
-
 	// notify listeners
 	LLSD arg;
 	arg["session_id"] = session_id;
@@ -1379,7 +1377,7 @@ void LLCallDialogManager::onVoiceChannelChanged(const LLUUID &session_id)
 	}
 
 	sSession = session;
-	sSession->mVoiceChannel->setStateChangedCallback(boost::bind(LLCallDialogManager::onVoiceChannelStateChanged, _1, _2, _3));
+	sSession->mVoiceChannel->setStateChangedCallback(LLCallDialogManager::onVoiceChannelStateChanged);
 	if(sCurrentSessionlName != session->mName)
 	{
 		sPreviousSessionlName = sCurrentSessionlName;
@@ -1603,12 +1601,7 @@ void LLOutgoingCallDialog::show(const LLSD& key)
 
 	if (!mPayload["disconnected_channel_name"].asString().empty())
 	{
-		std::string channel_name = mPayload["disconnected_channel_name"].asString();
-		if (LLIMModel::LLIMSession::AVALINE_SESSION == mPayload["session_type"].asInteger())
-		{
-			channel_name = LLTextUtil::formatPhoneNumber(channel_name);
-		}
-		childSetTextArg("nearby", "[VOICE_CHANNEL_NAME]", channel_name);
+		childSetTextArg("nearby", "[VOICE_CHANNEL_NAME]", mPayload["disconnected_channel_name"].asString());
 		childSetTextArg("nearby_P2P", "[VOICE_CHANNEL_NAME]", mPayload["disconnected_channel_name"].asString());
 	}
 
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index e72bda6c2bf..20d8e283927 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -78,11 +78,6 @@ class LLIMModel :  public LLSingleton<LLIMModel>
 		bool isP2P();
 		bool isOtherParticipantAvaline();
 
-		bool isP2PSessionType() const { return mSessionType == P2P_SESSION;}
-		bool isAdHocSessionType() const { return mSessionType == ADHOC_SESSION;}
-		bool isGroupSessionType() const { return mSessionType == GROUP_SESSION;}
-		bool isAvalineSessionType() const { return mSessionType == AVALINE_SESSION;}
-
 		LLUUID mSessionID;
 		std::string mName;
 		EInstantMessage mType;
diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp
index 0374a1d25b0..8f4fba244d2 100644
--- a/indra/newview/llinspectavatar.cpp
+++ b/indra/newview/llinspectavatar.cpp
@@ -418,7 +418,6 @@ void LLInspectAvatar::updateModeratorPanel()
 				LLPointer<LLSpeaker> selected_speakerp = speaker_mgr->findSpeaker(mAvatarID);
 				
 				if(speaker_mgr->isVoiceActive() && selected_speakerp && 
-					selected_speakerp->isInVoiceChannel() &&
 					((self_speakerp && self_speakerp->mIsModerator) || gAgent.isGodlike()))
 				{
 					getChild<LLUICtrl>("enable_voice")->setVisible(selected_speakerp->mModeratorMutedVoice);
diff --git a/indra/newview/llinspecttoast.cpp b/indra/newview/llinspecttoast.cpp
deleted file mode 100644
index 3ca8fa2f56e..00000000000
--- a/indra/newview/llinspecttoast.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/** 
- * @file llinspecttoast.cpp
- * @brief Toast inspector implementation.
- *
- * $LicenseInfo:firstyear=2003&license=viewergpl$
- * 
- * Copyright (c) 2003-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h" // must be first include
-
-#include "llinspecttoast.h"
-#include "llinspect.h"
-#include "llfloaterreg.h"
-#include "llscreenchannel.h"
-#include "llchannelmanager.h"
-#include "lltransientfloatermgr.h"
-
-using namespace LLNotificationsUI;
-
-/**
- * Represents inspectable toast .
- */
-class LLInspectToast: public LLInspect
-{
-public:
-
-	LLInspectToast(const LLSD& notification_idl);
-	virtual ~LLInspectToast();
-
-	/*virtual*/ void onOpen(const LLSD& notification_id);
-private:
-	void onToastDestroy(LLToast * toast);
-
-private:
-	LLPanel* mPanel;
-	LLScreenChannel* mScreenChannel;
-};
-
-LLInspectToast::LLInspectToast(const LLSD& notification_id) :
-	LLInspect(LLSD()), mPanel(NULL)
-{
-	LLScreenChannelBase* channel = LLChannelManager::getInstance()->findChannelByID(
-																LLUUID(gSavedSettings.getString("NotificationChannelUUID")));
-	mScreenChannel = dynamic_cast<LLScreenChannel*>(channel);
-	if(NULL == mScreenChannel)
-	{
-		llwarns << "Could not get requested screen channel." << llendl;
-		return;
-	}
-
-	LLTransientFloaterMgr::getInstance()->addControlView(this);
-}
-LLInspectToast::~LLInspectToast()
-{
-	LLTransientFloaterMgr::getInstance()->removeControlView(this);
-}
-
-void LLInspectToast::onOpen(const LLSD& notification_id)
-{
-	LLInspect::onOpen(notification_id);
-	LLToast* toast = mScreenChannel->getToastByNotificationID(notification_id);
-	if (toast == NULL)
-	{
-		llwarns << "Could not get requested toast  from screen channel." << llendl;
-		return;
-	}
-	toast->setOnToastDestroyedCallback(boost::bind(&LLInspectToast::onToastDestroy, this, _1));
-
-	LLPanel * panel = toast->getPanel();
-	panel->setVisible(TRUE);
-	panel->setMouseOpaque(FALSE);
-	if(mPanel != NULL && mPanel->getParent() == this)
-	{
-		removeChild(mPanel);
-	}
-	addChild(panel);
-	panel->setFocus(TRUE);
-	mPanel = panel;
-
-
-	LLRect panel_rect;
-	panel_rect = panel->getRect();
-	reshape(panel_rect.getWidth(), panel_rect.getHeight());
-
-	LLUI::positionViewNearMouse(this);
-}
-
-void LLInspectToast::onToastDestroy(LLToast * toast)
-{
-	closeFloater(false);
-}
-
-void LLNotificationsUI::registerFloater()
-{
-	LLFloaterReg::add("inspect_toast", "inspect_toast.xml",
-			&LLFloaterReg::build<LLInspectToast>);
-}
-
diff --git a/indra/newview/llinspecttoast.h b/indra/newview/llinspecttoast.h
deleted file mode 100644
index ff547154b83..00000000000
--- a/indra/newview/llinspecttoast.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/** 
- * @file llinspecttoast.h
- *
- * $LicenseInfo:firstyear=2003&license=viewergpl$
- * 
- * Copyright (c) 2003-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLINSPECTTOAST_H
-#define LL_LLINSPECTTOAST_H
-
-namespace LLNotificationsUI
-{
-void registerFloater();
-}
-
-#endif
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index a468a9a95c4..711114173c9 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -2001,16 +2001,14 @@ void LLInventoryModel::accountForUpdate(const LLCategoryUpdate& update) const
 		}
 		if(!accounted)
 		{
-			// Error condition, this means that the category did not register that
-			// it got new descendents (perhaps because it is still being loaded)
-			// which means its descendent count will be wrong.
-			llwarns << "Accounting failed for '" << cat->getName() << "' version:"
+			lldebugs << "No accounting for: '" << cat->getName() << "' "
 					 << version << llendl;
 		}
 	}
 	else
 	{
-		llwarns << "No category found for update " << update.mCategoryID << llendl;
+		llwarns << "No category found for update " << update.mCategoryID
+				<< llendl;
 	}
 }
 
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 2fb8aea4e94..2d9ea21b5f2 100644
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -311,10 +311,10 @@ bool LLInventoryFetchDescendentsObserver::isEverythingComplete() const
 
 bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory* cat)
 {
-	const S32 version = cat->getVersion();
-	const S32 expected_num_descendents = cat->getDescendentCount();
-	if ((version == LLViewerInventoryCategory::VERSION_UNKNOWN) ||
-		(expected_num_descendents == LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN))
+	S32 version = cat->getVersion();
+	S32 descendents = cat->getDescendentCount();
+	if((LLViewerInventoryCategory::VERSION_UNKNOWN == version)
+	   || (LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN == descendents))
 	{
 		return false;
 	}
@@ -325,28 +325,15 @@ bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory*
 	gInventory.getDirectDescendentsOf(cat->getUUID(), cats, items);
 	if(!cats || !items)
 	{
-		llwarns << "Category '" << cat->getName() << "' descendents corrupted, fetch failed." << llendl;
-		// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
-		// that the cat just doesn't have any items or subfolders).
-		// Unrecoverable, so just return done so that this observer can be cleared
-		// from memory.
+		// bit of a hack - pretend we're done if they are gone or
+		// incomplete. should never know, but it would suck if this
+		// kept tight looping because of a corrupt memory state.
 		return true;
 	}
-	const S32 current_num_known_descendents = cats->count() + items->count();
-	
-	// Got the number of descendents that we were expecting, so we're done.
-	if (current_num_known_descendents == expected_num_descendents)
-	{
-		return true;
-	}
-
-	// Error condition, but recoverable.  This happens if something was added to the
-	// category before it was initialized, so accountForUpdate didn't update descendent
-	// count and thus the category thinks it has fewer descendents than it actually has.
-	if (current_num_known_descendents >= expected_num_descendents)
+	S32 known = cats->count() + items->count();
+	if(descendents == known)
 	{
-		llwarns << "Category '" << cat->getName() << "' expected descendentcount:" << expected_num_descendents << " descendents but got descendentcount:" << current_num_known_descendents << llendl;
-		cat->setDescendentCount(current_num_known_descendents);
+		// hey - we're done.
 		return true;
 	}
 	return false;
@@ -365,7 +352,7 @@ void LLInventoryFetchComboObserver::changed(U32 mask)
 				continue;
 			}
 			if(item->isComplete())
-		{	
+			{
 				mCompleteItems.push_back(*it);
 				it = mIncompleteItems.erase(it);
 				continue;
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 87ebce1d347..6b0f9b709d1 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -84,6 +84,7 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) :
 	mHomePageUrl( "" ),
 	mIgnoreUIScale( true ),
 	mAlwaysRefresh( false ),
+	mExternalUrl( "" ),
 	mMediaSource( 0 ),
 	mTakeFocusOnClick( true ),
 	mCurrentNavUrl( "" ),
@@ -876,27 +877,9 @@ bool LLMediaCtrl::onClickLinkExternalTarget(const LLSD& notification, const LLSD
 	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
 	if ( 0 == option )
 	{
-		LLSD payload = notification["payload"];
-		std::string url = payload["url"].asString();
-		S32 target_type = payload["target_type"].asInteger();
-
-		switch (target_type)
-		{
-		case LLPluginClassMedia::TARGET_EXTERNAL:
-			// load target in an external browser
-			LLWeb::loadURLExternal(url);
-			break;
-
-		case LLPluginClassMedia::TARGET_BLANK:
-			// load target in the user's preferred browser
-			LLWeb::loadURL(url);
-			break;
-
-		default:
-			// unsupported link target - shouldn't happen
-			LL_WARNS("LinkTarget") << "Unsupported link target type" << LL_ENDL;
-			break;
-		}
+		// open in external browser because we don't support 
+		// creation of our own secondary browser windows
+		LLWeb::loadURLExternal( notification["payload"]["external_url"].asString() );
 	}
 	return false;
 }
@@ -1010,18 +993,20 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event)
 void LLMediaCtrl::onClickLinkHref( LLPluginClassMedia* self )
 {
 	// retrieve the event parameters
+	std::string target = self->getClickTarget();
 	std::string url = self->getClickURL();
-	U32 target_type = self->getClickTargetType();
 	
-	// is there is a target specified for the link?
-	if (target_type == LLPluginClassMedia::TARGET_EXTERNAL ||
-		target_type == LLPluginClassMedia::TARGET_BLANK)
+	// if there is a value for the target
+	if ( !target.empty() )
 	{
-		LLSD payload;
-		payload["url"] = url;
-		payload["target_type"] = LLSD::Integer(target_type);
-		LLNotificationsUtil::add( "WebLaunchExternalTarget", LLSD(), payload, onClickLinkExternalTarget);
-		return;
+		if ( target == "_external" )		
+		{
+			mExternalUrl = url;
+			LLSD payload;
+			payload["external_url"] = mExternalUrl;
+			LLNotificationsUtil::add( "WebLaunchExternalTarget", LLSD(), payload, onClickLinkExternalTarget);
+			return;
+		}
 	}
 
 	const std::string protocol1( "http://" );
diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h
index b0aca3cfa46..8f9e6e71797 100644
--- a/indra/newview/llmediactrl.h
+++ b/indra/newview/llmediactrl.h
@@ -182,6 +182,7 @@ class LLMediaCtrl :
 		bool mOpenLinksInInternalBrowser;
 		bool mTrusted;
 		std::string mHomePageUrl;
+		std::string mExternalUrl;
 		std::string mCurrentNavUrl;
 		bool mIgnoreUIScale;
 		bool mAlwaysRefresh;
diff --git a/indra/newview/llnamebox.cpp b/indra/newview/llnamebox.cpp
index d4340178049..2f4a2661985 100644
--- a/indra/newview/llnamebox.cpp
+++ b/indra/newview/llnamebox.cpp
@@ -52,7 +52,6 @@ LLNameBox::LLNameBox(const Params& p)
 :	LLTextBox(p)
 {
 	mNameID = LLUUID::null;
-	mLink = p.link;
 	LLNameBox::sInstances.insert(this);
 	setText(LLStringUtil::null);
 }
@@ -77,7 +76,7 @@ void LLNameBox::setNameID(const LLUUID& name_id, BOOL is_group)
 		gCacheName->getGroupName(name_id, name);
 	}
 
-	setName(name, is_group);
+	setText(name);
 }
 
 void LLNameBox::refresh(const LLUUID& id, const std::string& firstname,
@@ -94,7 +93,7 @@ void LLNameBox::refresh(const LLUUID& id, const std::string& firstname,
 		{
 			name = firstname;
 		}
-		setName(name, is_group);
+		setText(name);
 	}
 }
 
@@ -110,22 +109,3 @@ void LLNameBox::refreshAll(const LLUUID& id, const std::string& firstname,
 		box->refresh(id, firstname, lastname, is_group);
 	}
 }
-
-void LLNameBox::setName(const std::string& name, BOOL is_group)
-{
-	if (mLink)
-	{
-		std::string url;
-
-		if (is_group)
-			url = "[secondlife:///app/group/" + LLURI::escape(name) + "/about " + name + "]";
-		else
-			url = "[secondlife:///app/agent/" + mNameID.asString() + "/about " + name + "]";
-
-		setText(url);
-	}
-	else
-	{
-		setText(name);
-	}
-}
diff --git a/indra/newview/llnamebox.h b/indra/newview/llnamebox.h
index 0109525e856..3edb36883f9 100644
--- a/indra/newview/llnamebox.h
+++ b/indra/newview/llnamebox.h
@@ -47,11 +47,9 @@ class LLNameBox
 	struct Params : public LLInitParam::Block<Params, LLTextBox::Params>
 	{
 		Optional<bool>		is_group;
-		Optional<bool>		link;
 
 		Params()
 		:	is_group("is_group", false)
-		,	link("link", false)
 		{}
 	};
 
@@ -69,13 +67,10 @@ class LLNameBox
 
 	friend class LLUICtrlFactory;
 private:
-	void setName(const std::string& name, BOOL is_group);
-
 	static std::set<LLNameBox*> sInstances;
 
 private:
 	LLUUID mNameID;
-	BOOL mLink;
 
 };
 
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index a7c1e73328e..fc0e51b76d1 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -179,7 +179,27 @@ void	LLNearbyChat::addMessage(const LLChat& chat,bool archive)
 	if (!chat.mMuted)
 	{
 		tmp_chat.mFromName = chat.mFromName;
-		mChatHistory->appendMessage(chat, use_plain_text_chat_history);
+
+		if (chat.mChatStyle == CHAT_STYLE_IRC)
+		{
+			LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
+			LLViewerChat::getChatColor(chat,txt_color);
+			LLFontGL* fontp = LLViewerChat::getChatFont();
+			std::string font_name = LLFontGL::nameFromFont(fontp);
+			std::string font_size = LLFontGL::sizeFromFont(fontp);
+			LLStyle::Params append_style_params;
+			append_style_params.color(txt_color);
+			append_style_params.readonly_color(txt_color);
+			append_style_params.font.name(font_name);
+			append_style_params.font.size(font_size);
+			append_style_params.font.style = "ITALIC";
+
+			mChatHistory->appendMessage(chat, use_plain_text_chat_history, append_style_params);
+		}
+		else
+		{
+			mChatHistory->appendMessage(chat, use_plain_text_chat_history);
+		}
 	}
 
 	if(archive)
diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index 6cf8bcb4178..8dbaa5ac53a 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -48,16 +48,13 @@
 #include "llcommandhandler.h"
 #include "llviewercontrol.h"
 #include "llnavigationbar.h"
-#include "llwindow.h"
-#include "llviewerwindow.h"
-#include "llrootview.h"
 
 S32 LLNearbyChatBar::sLastSpecialChatChannel = 0;
 
 // legacy callback glue
 void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel);
 
-static LLDefaultChildRegistry::Register<LLGestureComboList> r("gesture_combo_list");
+static LLDefaultChildRegistry::Register<LLGestureComboBox> r("gesture_combo_box");
 
 struct LLChatTypeTrigger {
 	std::string name;
@@ -69,42 +66,13 @@ static LLChatTypeTrigger sChatTypeTriggers[] = {
 	{ "/shout"	, CHAT_TYPE_SHOUT}
 };
 
-LLGestureComboList::Params::Params()
-:	combo_button("combo_button"),
-	combo_list("combo_list")
-{
-}
-
-LLGestureComboList::LLGestureComboList(const LLGestureComboList::Params& p)
-:	LLUICtrl(p)
+LLGestureComboBox::LLGestureComboBox(const LLGestureComboBox::Params& p)
+	: LLComboBox(p)
+	, mGestureLabelTimer()
 	, mLabel(p.label)
 	, mViewAllItemIndex(0)
 {
-	LLButton::Params button_params = p.combo_button;
-	button_params.follows.flags(FOLLOWS_LEFT|FOLLOWS_BOTTOM|FOLLOWS_RIGHT);
-
-	mButton = LLUICtrlFactory::create<LLButton>(button_params);
-	mButton->reshape(getRect().getWidth(),getRect().getHeight());
-	mButton->setCommitCallback(boost::bind(&LLGestureComboList::onButtonCommit, this));
-
-	addChild(mButton);
-
-	LLScrollListCtrl::Params params = p.combo_list;
-	params.name("GestureComboList");
-	params.commit_callback.function(boost::bind(&LLGestureComboList::onItemSelected, this, _2));
-	params.visible(false);
-	params.commit_on_keyboard_movement(false);
-
-	mList = LLUICtrlFactory::create<LLScrollListCtrl>(params);
-	
-	// *HACK: adding list as a child to NonSideTrayView to make it fully visible without
-	// making it top control (because it would cause problems).
-	gViewerWindow->getNonSideTrayView()->addChild(mList);
-	mList->setVisible(FALSE);
-
-	//****************************Gesture Part********************************/
-
-	setCommitCallback(boost::bind(&LLGestureComboList::onCommitGesture, this));
+	setCommitCallback(boost::bind(&LLGestureComboBox::onCommitGesture, this));
 
 	// now register us as observer since we have a place to put the results
 	LLGestureManager::instance().addObserver(this);
@@ -112,139 +80,23 @@ LLGestureComboList::LLGestureComboList(const LLGestureComboList::Params& p)
 	// refresh list from current active gestures
 	refreshGestures();
 
-	setFocusLostCallback(boost::bind(&LLGestureComboList::hideList, this));
-}
-
-BOOL LLGestureComboList::handleKey(KEY key, MASK mask, BOOL called_from_parent)
-{
-	BOOL handled = FALSE;
-	
-	if (key == KEY_ESCAPE && mask == MASK_NONE )
-	{
-		hideList();
-		handled = TRUE;
-	}
-	else
-	{
-		handled = mList->handleKey(key, mask, called_from_parent);
-	}
-
-	return handled; 		
-}
-
-void LLGestureComboList::showList()
-{
-	LLRect rect = mList->getRect();
-	LLRect screen;
-	mButton->localRectToScreen(getRect(), &screen);
-	
-	// Calculating amount of space between the navigation bar and gestures combo
-	LLNavigationBar* nb = LLNavigationBar::getInstance();
-
-	S32 x, nb_bottom;
-	nb->localPointToScreen(0, 0, &x, &nb_bottom);
-
-	S32 max_height = nb_bottom - screen.mTop;
-	mList->calcColumnWidths();
-	rect.setOriginAndSize(screen.mLeft, screen.mTop, llmax(mList->getMaxContentWidth(),mButton->getRect().getWidth()), max_height);
-
-	mList->setRect(rect);
-	mList->fitContents( llmax(mList->getMaxContentWidth(),mButton->getRect().getWidth()), max_height);
-
-	gFocusMgr.setKeyboardFocus(this);
-
-	// Show the list and push the button down
-	mButton->setToggleState(TRUE);
-	mList->setVisible(TRUE);
-}
-
-void LLGestureComboList::onButtonCommit()
-{
-	if (!mList->getVisible())
-	{
-		// highlight the last selected item from the original selection before potentially selecting a new item
-		// as visual cue to original value of combo box
-		LLScrollListItem* last_selected_item = mList->getLastSelectedItem();
-		if (last_selected_item)
-		{
-			mList->mouseOverHighlightNthItem(mList->getItemIndex(last_selected_item));
-		}
-
-		if (mList->getItemCount() != 0)
-		{
-			showList();
-		}
-	}
-	else
-	{
-		hideList();
-	} 
-}
-
-void LLGestureComboList::hideList()
-{
-	if (mList->getVisible())
-	{
-		mButton->setToggleState(FALSE);
-		mList->setVisible(FALSE);
-		mList->mouseOverHighlightNthItem(-1);
-		gFocusMgr.setKeyboardFocus(NULL);
-	}
-}
-
-S32 LLGestureComboList::getCurrentIndex() const
-{
-	LLScrollListItem* item = mList->getFirstSelected();
-	if( item )
-	{
-		return mList->getItemIndex( item );
-	}
-	return -1;
-}
-
-void LLGestureComboList::onItemSelected(const LLSD& data)
-{
-	const std::string name = mList->getSelectedItemLabel();
-
-	S32 cur_id = getCurrentIndex();
-	mLastSelectedIndex = cur_id;
-	if (cur_id != mList->getItemCount()-1 && cur_id != -1)
-	{
-		mButton->setLabel(name);
-	}
-
-	// hiding the list reasserts the old value stored in the text editor/dropdown button
-	hideList();
-
-	// commit does the reverse, asserting the value in the list
-	onCommit();
-}
-
-void LLGestureComboList::sortByName(bool ascending)
-{
-	mList->sortOnce(0, ascending);
+	// This forces using of halign from xml, since LLComboBox
+	// sets it to LLFontGL::LEFT, if text entry is disabled
+	mButton->setHAlign(p.drop_down_button.font_halign);
 }
 
-LLSD LLGestureComboList::getValue() const
+LLGestureComboBox::~LLGestureComboBox()
 {
-	LLScrollListItem* item = mList->getFirstSelected();
-	if( item )
-	{
-		return item->getValue();
-	}
-	else
-	{
-		return LLSD();
-	}
+	LLGestureManager::instance().removeObserver(this);
 }
 
-void LLGestureComboList::refreshGestures()
+void LLGestureComboBox::refreshGestures()
 {
 	//store current selection so we can maintain it
 	LLSD cur_gesture = getValue();
-	
-	mList->selectFirstItem();
-	mList->clearRows();
+	selectFirstItem();
+	// clear
+	clearRows();
 	mGestures.clear();
 
 	LLGestureManager::item_map_t::const_iterator it;
@@ -255,7 +107,7 @@ void LLGestureComboList::refreshGestures()
 		LLMultiGesture* gesture = (*it).second;
 		if (gesture)
 		{
-			mList->addSimpleElement(gesture->mName, ADD_BOTTOM, LLSD(idx));
+			addSimpleElement(gesture->mName, ADD_BOTTOM, LLSD(idx));
 			mGestures.push_back(gesture);
 			idx++;
 		}
@@ -265,42 +117,23 @@ void LLGestureComboList::refreshGestures()
 
 	// store index followed by the last added Gesture and add View All item at bottom
 	mViewAllItemIndex = idx;
-	
-	mList->addSimpleElement(LLTrans::getString("ViewAllGestures"), ADD_BOTTOM, LLSD(mViewAllItemIndex));
+	addSimpleElement(LLTrans::getString("ViewAllGestures"), ADD_BOTTOM, LLSD(mViewAllItemIndex));
 
 	// Insert label after sorting, at top, with separator below it
-	mList->addSeparator(ADD_TOP);	
-	mList->addSimpleElement(mLabel, ADD_TOP);
+	addSeparator(ADD_TOP);		
+	addSimpleElement(mLabel, ADD_TOP);
 
 	if (cur_gesture.isDefined())
 	{ 
-		mList->selectByValue(cur_gesture);
-
+		selectByValue(cur_gesture);
 	}
 	else
 	{
-		mList->selectFirstItem();
+		selectFirstItem();
 	}
-
-	LLCtrlListInterface* gestures = getListInterface();
-	LLMultiGesture* gesture = NULL;
-	
-	if (gestures)
-	{
-		S32 index = gestures->getSelectedValue().asInteger();
-		if(index > 0)
-			gesture = mGestures.at(index);
-	}
-	
-	if(gesture && LLGestureManager::instance().isGesturePlaying(gesture))
-	{
-		return;
-	}
-	
-	mButton->setLabel(mLabel);
 }
 
-void LLGestureComboList::onCommitGesture()
+void LLGestureComboBox::onCommitGesture()
 {
 	LLCtrlListInterface* gestures = getListInterface();
 	if (gestures)
@@ -331,11 +164,50 @@ void LLGestureComboList::onCommitGesture()
 			}
 		}
 	}
+
+	mGestureLabelTimer.start();
+	// free focus back to chat bar
+	setFocus(FALSE);
 }
 
-LLGestureComboList::~LLGestureComboList()
+//virtual
+void LLGestureComboBox::draw()
 {
-	LLGestureManager::instance().removeObserver(this);
+	// HACK: Leave the name of the gesture in place for a few seconds.
+	const F32 SHOW_GESTURE_NAME_TIME = 2.f;
+	if (mGestureLabelTimer.getStarted() && mGestureLabelTimer.getElapsedTimeF32() > SHOW_GESTURE_NAME_TIME)
+	{
+		LLCtrlListInterface* gestures = getListInterface();
+		if (gestures) gestures->selectFirstItem();
+		mGestureLabelTimer.stop();
+	}
+
+	LLComboBox::draw();
+}
+
+//virtual
+void LLGestureComboBox::showList()
+{
+	LLComboBox::showList();
+
+	// Calculating amount of space between the navigation bar and gestures combo
+	LLNavigationBar* nb = LLNavigationBar::getInstance();
+	S32 x, nb_bottom;
+	nb->localPointToScreen(0, 0, &x, &nb_bottom);
+	
+	S32 list_bottom;
+	mList->localPointToScreen(0, 0, &x, &list_bottom);
+
+	S32 max_height = nb_bottom - list_bottom;
+
+	LLRect rect = mList->getRect();
+	// List overlapped navigation bar, downsize it
+	if (rect.getHeight() > max_height) 
+	{
+		rect.setOriginAndSize(rect.mLeft, rect.mBottom, rect.getWidth(), max_height);
+		mList->setRect(rect);
+		mList->reshape(rect.getWidth(), rect.getHeight());
+	}
 }
 
 LLNearbyChatBar::LLNearbyChatBar() 
diff --git a/indra/newview/llnearbychatbar.h b/indra/newview/llnearbychatbar.h
index d9a7403611a..224118e088d 100644
--- a/indra/newview/llnearbychatbar.h
+++ b/indra/newview/llnearbychatbar.h
@@ -42,52 +42,33 @@
 #include "llspeakers.h"
 
 
-class LLGestureComboList
-	: public LLGestureManagerObserver
-	, public LLUICtrl
+class LLGestureComboBox
+	: public LLComboBox
+	, public LLGestureManagerObserver
 {
 public:
-	struct Params :	public LLInitParam::Block<Params, LLUICtrl::Params>
-	{
-		Optional<LLButton::Params>			combo_button;
-		Optional<LLScrollListCtrl::Params>	combo_list;
-		
-		Params();
-	};
-
+	struct Params : public LLInitParam::Block<Params, LLComboBox::Params> { };
 protected:
-	
+	LLGestureComboBox(const Params&);
 	friend class LLUICtrlFactory;
-	LLGestureComboList(const Params&);
-	std::vector<LLMultiGesture*> mGestures;
-	std::string mLabel;
-	LLSD::Integer mViewAllItemIndex;
-
 public:
+	~LLGestureComboBox();
 
-	~LLGestureComboList();
-
-	LLCtrlListInterface* getListInterface()		{ return (LLCtrlListInterface*)mList; };
-	virtual void	showList();
-	virtual void	hideList();
-	virtual BOOL	handleKey(KEY key, MASK mask, BOOL called_from_parent);
-
-	S32				getCurrentIndex() const;
-	void			onItemSelected(const LLSD& data);
-	void			sortByName(bool ascending = true);
 	void refreshGestures();
 	void onCommitGesture();
-	void onButtonCommit();
-	virtual LLSD	getValue() const;
+	virtual void draw();
 
 	// LLGestureManagerObserver trigger
 	virtual void changed() { refreshGestures(); }
 
-private:
+protected:
+
+	virtual void showList();
 
-	LLButton*			mButton;
-	LLScrollListCtrl*	mList;
-	S32                 mLastSelectedIndex;
+	LLFrameTimer mGestureLabelTimer;
+	std::vector<LLMultiGesture*> mGestures;
+	std::string mLabel;
+	LLSD::Integer mViewAllItemIndex;
 };
 
 class LLNearbyChatBar
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp
index 96442fafcc6..9e13a626b44 100644
--- a/indra/newview/llnearbychathandler.cpp
+++ b/indra/newview/llnearbychathandler.cpp
@@ -180,11 +180,6 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification)
 
 		if(panel && panel->messageID() == fromID && panel->canAddText())
 		{
-			if (CHAT_STYLE_IRC == notification["chat_style"].asInteger())
-			{
-				notification["message"] = notification["from"].asString() + notification["message"].asString();
-			}
-
 			panel->addMessage(notification);
 			toast->reshapeToPanel();
 			toast->resetTimer();
@@ -307,6 +302,7 @@ LLNearbyChatHandler::LLNearbyChatHandler(e_notification_type type, const LLSD& i
 	channel->setCreatePanelCallback(callback);
 
 	mChannel = LLChannelManager::getInstance()->addChannel(channel);
+	mChannel->setOverflowFormatString("You have %d unread nearby chat messages");
 }
 
 LLNearbyChatHandler::~LLNearbyChatHandler()
@@ -336,22 +332,25 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg)
 
 	LLChat& tmp_chat = const_cast<LLChat&>(chat_msg);
 
-	LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
+	if (tmp_chat.mChatStyle == CHAT_STYLE_IRC)
+	{
+		if(!tmp_chat.mFromName.empty())
+			tmp_chat.mText = tmp_chat.mFromName + tmp_chat.mText.substr(3);
+		else
+			tmp_chat.mText = tmp_chat.mText.substr(3);
+	}
+	
 	{
 		//sometimes its usefull to have no name at all...
 		//if(tmp_chat.mFromName.empty() && tmp_chat.mFromID!= LLUUID::null)
 		//	tmp_chat.mFromName = tmp_chat.mFromID.asString();
 	}
+	
+	LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
 	nearby_chat->addMessage(chat_msg);
 	if(nearby_chat->getVisible())
 		return;//no need in toast if chat is visible
-
-	// Handle irc styled messages for toast panel
-	if (tmp_chat.mChatStyle == CHAT_STYLE_IRC)
-	{
-		tmp_chat.mText = tmp_chat.mText.substr(3);
-	}
-
+	
 	// arrange a channel on a screen
 	if(!mChannel->getVisible())
 	{
diff --git a/indra/newview/lloutputmonitorctrl.cpp b/indra/newview/lloutputmonitorctrl.cpp
index f816dc589d6..63803469dd1 100644
--- a/indra/newview/lloutputmonitorctrl.cpp
+++ b/indra/newview/lloutputmonitorctrl.cpp
@@ -77,9 +77,7 @@ LLOutputMonitorCtrl::LLOutputMonitorCtrl(const LLOutputMonitorCtrl::Params& p)
 	mImageLevel3(p.image_level_3),
 	mAutoUpdate(p.auto_update),
 	mSpeakerId(p.speaker_id),
-	mIsAgentControl(false),
-	mIsSwitchDirty(false),
-	mShouldSwitchOn(false)
+	mIsAgentControl(false)
 {
 	//static LLUIColor output_monitor_muted_color = LLUIColorTable::instance().getColor("OutputMonitorMutedColor", LLColor4::orange);
 	//static LLUIColor output_monitor_overdriven_color = LLUIColorTable::instance().getColor("OutputMonitorOverdrivenColor", LLColor4::red);
@@ -110,7 +108,6 @@ LLOutputMonitorCtrl::LLOutputMonitorCtrl(const LLOutputMonitorCtrl::Params& p)
 LLOutputMonitorCtrl::~LLOutputMonitorCtrl()
 {
 	LLMuteList::getInstance()->removeObserver(this);
-	LLSpeakingIndicatorManager::unregisterSpeakingIndicator(mSpeakerId, this);
 }
 
 void LLOutputMonitorCtrl::setPower(F32 val)
@@ -120,26 +117,6 @@ void LLOutputMonitorCtrl::setPower(F32 val)
 
 void LLOutputMonitorCtrl::draw()
 {
-	// see also switchIndicator()
-	if (mIsSwitchDirty)
-	{
-		mIsSwitchDirty = false;
-		if (mShouldSwitchOn)
-		{
-			// just notify parent visibility may have changed
-			notifyParentVisibilityChanged();
-		}
-		else
-		{
-			// make itself invisible and notify parent about this
-			setVisible(FALSE);
-			notifyParentVisibilityChanged();
-
-			// no needs to render for invisible element
-			return;
-		}
-	}
-
 	// Copied from llmediaremotectrl.cpp
 	// *TODO: Give the LLOutputMonitorCtrl an agent-id to monitor, then
 	// call directly into gVoiceClient to ask if that agent-id is muted, is
@@ -252,7 +229,6 @@ void LLOutputMonitorCtrl::setSpeakerId(const LLUUID& speaker_id)
 	if (speaker_id.isNull() || speaker_id == mSpeakerId) return;
 
 	mSpeakerId = speaker_id;
-	LLSpeakingIndicatorManager::registerSpeakingIndicator(mSpeakerId, this);
 
 	//mute management
 	if (mAutoUpdate)
@@ -275,42 +251,3 @@ void LLOutputMonitorCtrl::onChange()
 	// check only blocking on voice. EXT-3542
 	setIsMuted(LLMuteList::getInstance()->isMuted(mSpeakerId, LLMute::flagVoiceChat));
 }
-
-// virtual
-void LLOutputMonitorCtrl::switchIndicator(bool switch_on)
-{
-	// ensure indicator is visible in case it is not in visible chain
-	// to be called when parent became visible next time to notify parent that visibility is changed.
-	setVisible(TRUE);
-
-	// if parent is in visible chain apply switch_on state and notify it immediately
-	if (getParent() && getParent()->isInVisibleChain())
-	{
-		LL_DEBUGS("SpeakingIndicator") << "Indicator is in visible chain, notifying parent: " << mSpeakerId << LL_ENDL;
-		setVisible((BOOL)switch_on);
-		notifyParentVisibilityChanged();
-	}
-
-	// otherwise remember necessary state and mark itself as dirty.
-	// State will be applied i next draw when parents chain became visible.
-	else
-	{
-		LL_DEBUGS("SpeakingIndicator") << "Indicator is not in visible chain, parent won't be notified: " << mSpeakerId << LL_ENDL;
-		mIsSwitchDirty = true;
-		mShouldSwitchOn = switch_on;
-	}
-}
-
-//////////////////////////////////////////////////////////////////////////
-// PRIVATE SECTION
-//////////////////////////////////////////////////////////////////////////
-void LLOutputMonitorCtrl::notifyParentVisibilityChanged()
-{
-	LL_DEBUGS("SpeakingIndicator") << "Notify parent that visibility was changed: " << mSpeakerId << " ,new_visibility: " << getVisible() << LL_ENDL;
-
-	LLSD params = LLSD().with("visibility_changed", getVisible());
-
-	notifyParent(params);
-}
-
-// EOF
diff --git a/indra/newview/lloutputmonitorctrl.h b/indra/newview/lloutputmonitorctrl.h
index 2bbfa251e9d..85ea552a572 100644
--- a/indra/newview/lloutputmonitorctrl.h
+++ b/indra/newview/lloutputmonitorctrl.h
@@ -36,7 +36,6 @@
 #include "v4color.h"
 #include "llview.h"
 #include "llmutelist.h"
-#include "llspeakingindicatormanager.h"
 
 class LLTextBox;
 class LLUICtrlFactory;
@@ -46,7 +45,7 @@ class LLUICtrlFactory;
 //
 
 class LLOutputMonitorCtrl
-: public LLView, public LLSpeakingIndicator, LLMuteListObserver
+: public LLView, LLMuteListObserver
 {
 public:
 	struct Params : public LLInitParam::Block<Params, LLView::Params>
@@ -91,29 +90,7 @@ class LLOutputMonitorCtrl
 	//called by mute list
 	virtual void onChange();
 
-	/**
-	 * Implementation of LLSpeakingIndicator interface.
-	 * Behavior is implemented via changing visibility.
-	 *
-	 * If instance is in visible chain now (all parents are visible) it changes visibility 
-	 * and notify parent about this.
-	 *
-	 * Otherwise it marks an instance as dirty and stores necessary visibility.
-	 * It will be applied in next draw and parent will be notified.
-	 */
-	virtual void	switchIndicator(bool switch_on);
-
 private:
-
-	/**
-	 * Notifies parent about changed visibility.
-	 *
-	 * Passes LLSD with "visibility_changed" => <current visibility> value.
-	 * For now it is processed by LLAvatarListItem to update (reshape) its children.
-	 * Implemented fo complete EXT-3976
-	 */
-	void			notifyParentVisibilityChanged();
-
 	//static LLColor4	sColorMuted;
 	//static LLColor4	sColorNormal;
 	//static LLColor4	sColorOverdriven;
@@ -140,10 +117,6 @@ class LLOutputMonitorCtrl
 
 	/** uuid of a speaker being monitored */
 	LLUUID			mSpeakerId;
-
-	/** indicates if the instance is dirty and should notify parent */
-	bool			mIsSwitchDirty;
-	bool			mShouldSwitchOn;
 };
 
 #endif
diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index 85e95ca1d65..fb898f7cdf6 100644
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -52,7 +52,6 @@
 #include "llfloaterreg.h"
 #include "llnotificationsutil.h"
 #include "llvoiceclient.h"
-#include "llnamebox.h"
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // Class LLDropTarget
@@ -596,10 +595,7 @@ void LLPanelAvatarProfile::processGroupProperties(const LLAvatarGroups* avatar_g
 			groups += ", ";
 
 		std::string group_name = LLURI::escape(it->first);
-		std::string group_url= it->second.notNull()
-				? "[secondlife:///app/group/" + it->second.asString() + "/about " + group_name + "]"
-						: getString("no_group_text");
-
+		std::string group_url="[secondlife:///app/group/" + it->second.asString() + "/about " + group_name + "]";
 		groups += group_url;
 	}
 
@@ -625,15 +621,19 @@ void LLPanelAvatarProfile::fillCommonData(const LLAvatarData* avatar_data)
 
 void LLPanelAvatarProfile::fillPartnerData(const LLAvatarData* avatar_data)
 {
-	LLNameBox* name_box = getChild<LLNameBox>("partner_text");
 	if (avatar_data->partner_id.notNull())
 	{
-		name_box->setNameID(avatar_data->partner_id, FALSE);
+		std::string first, last;
+		BOOL found = gCacheName->getName(avatar_data->partner_id, first, last);
+		if (found)
+		{
+			childSetTextArg("partner_text", "[FIRST]", first);
+			childSetTextArg("partner_text", "[LAST]", last);
+		}
 	}
 	else
 	{
-		name_box->setNameID(LLUUID::null, FALSE);
-		name_box->setText(getString("no_partner_text"));
+		childSetTextArg("partner_text", "[FIRST]", getString("no_partner_text"));
 	}
 }
 
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index daec793d756..94de17c17d8 100644
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -151,11 +151,6 @@ BOOL LLPanelGroup::postBuild()
 	button->setVisible(true);
 	button->setEnabled(false);
 
-	button = getChild<LLButton>("btn_call");
-	button->setClickedCallback(onBtnGroupCallClicked, this);
-
-	button = getChild<LLButton>("btn_chat");
-	button->setClickedCallback(onBtnGroupChatClicked, this);
 
 	button = getChild<LLButton>("btn_join");
 	button->setVisible(false);
@@ -220,8 +215,6 @@ void LLPanelGroup::reposButtons()
 	reposButton("btn_create");
 	reposButton("btn_refresh");
 	reposButton("btn_cancel");
-	reposButton("btn_chat");
-	reposButton("btn_call");
 }
 
 void LLPanelGroup::reshape(S32 width, S32 height, BOOL called_from_parent )
@@ -269,18 +262,6 @@ void LLPanelGroup::onBtnApply(void* user_data)
 	self->apply();
 }
 
-void LLPanelGroup::onBtnGroupCallClicked(void* user_data)
-{
-	LLPanelGroup* self = static_cast<LLPanelGroup*>(user_data);
-	self->callGroup();
-}
-
-void LLPanelGroup::onBtnGroupChatClicked(void* user_data)
-{
-	LLPanelGroup* self = static_cast<LLPanelGroup*>(user_data);
-	self->chatGroup();
-}
-
 void LLPanelGroup::onBtnJoin()
 {
 	lldebugs << "joining group: " << mID << llendl;
@@ -368,8 +349,6 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 	LLButton* button_create = findChild<LLButton>("btn_create");
 	LLButton* button_join = findChild<LLButton>("btn_join");
 	LLButton* button_cancel = findChild<LLButton>("btn_cancel");
-	LLButton* button_call = findChild<LLButton>("btn_call");
-	LLButton* button_chat = findChild<LLButton>("btn_chat");
 
 
 	bool is_null_group_id = group_id == LLUUID::null;
@@ -383,11 +362,6 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 	if(button_cancel)
 		button_cancel->setVisible(!is_null_group_id);
 
-	if(button_call)
-			button_call->setVisible(!is_null_group_id);
-	if(button_chat)
-			button_chat->setVisible(!is_null_group_id);
-
 	getChild<LLUICtrl>("prepend_founded_by")->setVisible(!is_null_group_id);
 
 	LLAccordionCtrl* tab_ctrl = findChild<LLAccordionCtrl>("group_accordion");
@@ -449,15 +423,12 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 
 		getChild<LLUICtrl>("group_name")->setVisible(true);
 		getChild<LLUICtrl>("group_name_editor")->setVisible(false);
-
-		if(button_apply)
-			button_apply->setVisible(is_member);
 	}
 
 	reposButtons();
 }
 
-bool LLPanelGroup::apply(LLPanelGroupTab* tab)
+bool	LLPanelGroup::apply(LLPanelGroupTab* tab)
 {
 	if(!tab)
 		return false;
@@ -500,17 +471,12 @@ void LLPanelGroup::draw()
 		childEnable("btn_refresh");
 	}
 
-	LLButton* button_apply = findChild<LLButton>("btn_apply");
-	
-	if(button_apply && button_apply->getVisible())
-	{
-		bool enable = false;
-		std::string mesg;
-		for(std::vector<LLPanelGroupTab* >::iterator it = mTabs.begin();it!=mTabs.end();++it)
-			enable = enable || (*it)->needsApply(mesg);
+	bool enable = false;
+	std::string mesg;
+	for(std::vector<LLPanelGroupTab* >::iterator it = mTabs.begin();it!=mTabs.end();++it)
+		enable = enable || (*it)->needsApply(mesg);
 
-		childSetEnabled("btn_apply", enable);
-	}
+	childSetEnabled("btn_apply", enable);
 }
 
 void LLPanelGroup::refreshData()
@@ -525,15 +491,6 @@ void LLPanelGroup::refreshData()
 	mRefreshTimer.setTimerExpirySec(5);
 }
 
-void LLPanelGroup::callGroup()
-{
-	LLGroupActions::startCall(getID());
-}
-
-void LLPanelGroup::chatGroup()
-{
-	LLGroupActions::startIM(getID());
-}
 
 void LLPanelGroup::showNotice(const std::string& subject,
 							  const std::string& message,
diff --git a/indra/newview/llpanelgroup.h b/indra/newview/llpanelgroup.h
index 7ea5e67b44f..f6aefdb676d 100644
--- a/indra/newview/llpanelgroup.h
+++ b/indra/newview/llpanelgroup.h
@@ -74,8 +74,6 @@ class LLPanelGroup : public LLPanel,
 
 	bool apply();
 	void refreshData();
-	void callGroup();
-	void chatGroup();
 
 	virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
 
@@ -105,8 +103,6 @@ class LLPanelGroup : public LLPanel,
 
 	static void onBtnApply(void*);
 	static void onBtnRefresh(void*);
-	static void onBtnGroupCallClicked(void*);
-	static void onBtnGroupChatClicked(void*);
 
 	void reposButton(const std::string& name);
 	void reposButtons();
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 21b253223f0..31dfdde887c 100644
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -580,6 +580,7 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 			}
 		}
 
+		mComboActiveTitle->resetDirty();
 	}
 
 	// If this was just a titles update, we are done.
@@ -594,6 +595,8 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 	{
 		mCtrlShowInGroupList->set(gdatap->mShowInList);
 		mCtrlShowInGroupList->setEnabled(mAllowEdit && can_change_ident);
+		mCtrlShowInGroupList->resetDirty();
+
 	}
 	if (mComboMature)
 	{
@@ -607,16 +610,19 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 		}
 		mComboMature->setEnabled(mAllowEdit && can_change_ident);
 		mComboMature->setVisible( !gAgent.isTeen() );
+		mComboMature->resetDirty();
 	}
 	if (mCtrlOpenEnrollment) 
 	{
 		mCtrlOpenEnrollment->set(gdatap->mOpenEnrollment);
 		mCtrlOpenEnrollment->setEnabled(mAllowEdit && can_change_member_opts);
+		mCtrlOpenEnrollment->resetDirty();
 	}
 	if (mCtrlEnrollmentFee) 
 	{	
 		mCtrlEnrollmentFee->set(gdatap->mMembershipFee > 0);
 		mCtrlEnrollmentFee->setEnabled(mAllowEdit && can_change_member_opts);
+		mCtrlEnrollmentFee->resetDirty();
 	}
 	
 	if (mSpinEnrollmentFee)
@@ -626,6 +632,7 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 		mSpinEnrollmentFee->setEnabled( mAllowEdit &&
 						(fee > 0) &&
 						can_change_member_opts);
+		mSpinEnrollmentFee->resetDirty();
 	}
 	if (mCtrlReceiveNotices)
 	{
@@ -634,6 +641,7 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 		{
 			mCtrlReceiveNotices->setEnabled(mAllowEdit);
 		}
+		mCtrlReceiveNotices->resetDirty();
 	}
 
 
@@ -657,6 +665,7 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 	if (mEditCharter)
 	{
 		mEditCharter->setText(gdatap->mCharter);
+		mEditCharter->resetDirty();
 	}
 	
 	if (mListVisibleMembers)
@@ -684,8 +693,6 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 			mListVisibleMembers->addElement(row);
 		}
 	}
-
-	resetDirty();
 }
 
 void LLPanelGroupGeneral::updateMembers()
diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp
index 0e55ff3214d..29b647415c3 100644
--- a/indra/newview/llpanelgrouproles.cpp
+++ b/indra/newview/llpanelgrouproles.cpp
@@ -460,8 +460,17 @@ LLPanelGroupSubTab::~LLPanelGroupSubTab()
 {
 }
 
-BOOL LLPanelGroupSubTab::postBuildSubTab(LLView* root) 
-{ 
+BOOL LLPanelGroupSubTab::postBuild()
+{
+	// Hook up the search widgets.
+	bool recurse = true;
+	mSearchEditor = getChild<LLFilterEditor>("filter_input", recurse);
+
+	if (!mSearchEditor) 
+		return FALSE;
+
+	mSearchEditor->setCommitCallback(boost::bind(&LLPanelGroupSubTab::setSearchFilter, this, _2));
+	
 	// Get icons for later use.
 	mActionIcons.clear();
 
@@ -479,19 +488,6 @@ BOOL LLPanelGroupSubTab::postBuildSubTab(LLView* root)
 	{
 		mActionIcons["partial"] = getString("power_partial_icon");
 	}
-	return TRUE; 
-}
-
-BOOL LLPanelGroupSubTab::postBuild()
-{
-	// Hook up the search widgets.
-	bool recurse = true;
-	mSearchEditor = getChild<LLFilterEditor>("filter_input", recurse);
-
-	if (!mSearchEditor) 
-		return FALSE;
-
-	mSearchEditor->setCommitCallback(boost::bind(&LLPanelGroupSubTab::setSearchFilter, this, _2));
 
 	return LLPanelGroupTab::postBuild();
 }
@@ -571,6 +567,7 @@ bool LLPanelGroupSubTab::matchesActionSearchFilter(std::string action)
 void LLPanelGroupSubTab::buildActionsList(LLScrollListCtrl* ctrl, 
 										  U64 allowed_by_some, 
 										  U64 allowed_by_all,
+										  icon_map_t& icons,
 										  LLUICtrl::commit_callback_t commit_callback,
 										  BOOL show_all,
 										  BOOL filter,
@@ -591,6 +588,7 @@ void LLPanelGroupSubTab::buildActionsList(LLScrollListCtrl* ctrl,
 							allowed_by_some,
 							allowed_by_all,
 							(*ras_it),
+							icons, 
 							commit_callback,
 							show_all,
 							filter,
@@ -602,6 +600,7 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 											 U64 allowed_by_some,
 											 U64 allowed_by_all,
 											 LLRoleActionSet* action_set,
+											 icon_map_t& icons,
 											 LLUICtrl::commit_callback_t commit_callback,
 											 BOOL show_all,
 											 BOOL filter,
@@ -615,26 +614,26 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 		LLSD row;
 
 		row["columns"][0]["column"] = "icon";
-		row["columns"][0]["type"] = "icon";
-		
-		icon_map_t::iterator iter = mActionIcons.find("folder");
-		if (iter != mActionIcons.end())
+		icon_map_t::iterator iter = icons.find("folder");
+		if (iter != icons.end())
 		{
+			row["columns"][0]["type"] = "icon";
 			row["columns"][0]["value"] = (*iter).second;
 		}
 
 		row["columns"][1]["column"] = "action";
-		row["columns"][1]["type"] = "text";
 		row["columns"][1]["value"] = action_set->mActionSetData->mName;
 		row["columns"][1]["font"]["name"] = "SANSSERIF_SMALL";
-		
+		row["columns"][1]["font"]["style"] = "BOLD";
 
 		LLScrollListItem* title_row = ctrl->addElement(row, ADD_BOTTOM, action_set->mActionSetData);
 		
-		LLScrollListText* name_textp = dynamic_cast<LLScrollListText*>(title_row->getColumn(2)); //?? I have no idea fix getColumn(1) return column spacer...
+		LLScrollListText* name_textp = dynamic_cast<LLScrollListText*>(title_row->getColumn(1));
 		if (name_textp)
 			name_textp->setFontStyle(LLFontGL::BOLD);
 
+
+
 		bool category_matches_filter = (filter) ? matchesActionSearchFilter(action_set->mActionSetData->mName) : true;
 
 		std::vector<LLRoleAction*>::iterator ra_it = action_set->mActions.begin();
@@ -687,8 +686,8 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 			{
 				if (show_full_strength)
 				{
-					icon_map_t::iterator iter = mActionIcons.find("full");
-					if (iter != mActionIcons.end())
+					icon_map_t::iterator iter = icons.find("full");
+					if (iter != icons.end())
 					{
 						row["columns"][column_index]["column"] = "checkbox";
 						row["columns"][column_index]["type"] = "icon";
@@ -698,8 +697,8 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 				}
 				else
 				{
-					icon_map_t::iterator iter = mActionIcons.find("partial");
-					if (iter != mActionIcons.end())
+					icon_map_t::iterator iter = icons.find("partial");
+					if (iter != icons.end())
 					{
 						row["columns"][column_index]["column"] = "checkbox";
 						row["columns"][column_index]["type"] = "icon";
@@ -793,8 +792,6 @@ LLPanelGroupMembersSubTab::~LLPanelGroupMembersSubTab()
 
 BOOL LLPanelGroupMembersSubTab::postBuildSubTab(LLView* root)
 {
-	LLPanelGroupSubTab::postBuildSubTab(root);
-	
 	// Upcast parent so we can ask it for sibling controls.
 	LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root;
 
@@ -891,6 +888,7 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
 	buildActionsList(mAllowedActionsList,
 					 allowed_by_some,
 					 allowed_by_all,
+					 mActionIcons,
 					 NULL,
 					 FALSE,
 					 FALSE,
@@ -1213,6 +1211,7 @@ void LLPanelGroupMembersSubTab::handleRoleCheck(const LLUUID& role_id,
 	buildActionsList(mAllowedActionsList,
 					 powers_some_have,
 					 powers_all_have,
+					 mActionIcons,
 					 NULL,
 					 FALSE,
 					 FALSE,
@@ -1685,8 +1684,6 @@ LLPanelGroupRolesSubTab::~LLPanelGroupRolesSubTab()
 
 BOOL LLPanelGroupRolesSubTab::postBuildSubTab(LLView* root)
 {
-	LLPanelGroupSubTab::postBuildSubTab(root);
-
 	// Upcast parent so we can ask it for sibling controls.
 	LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root;
 
@@ -1997,6 +1994,7 @@ void LLPanelGroupRolesSubTab::handleRoleSelect()
 		buildActionsList(mAllowedActionsList,
 						 rd.mRolePowers,
 						 0LL,
+						 mActionIcons,
 						 boost::bind(&LLPanelGroupRolesSubTab::handleActionCheck, this, _1, false),
 						 TRUE,
 						 FALSE,
@@ -2383,8 +2381,6 @@ LLPanelGroupActionsSubTab::~LLPanelGroupActionsSubTab()
 
 BOOL LLPanelGroupActionsSubTab::postBuildSubTab(LLView* root)
 {
-	LLPanelGroupSubTab::postBuildSubTab(root);
-
 	// Upcast parent so we can ask it for sibling controls.
 	LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root;
 
@@ -2452,6 +2448,7 @@ void LLPanelGroupActionsSubTab::update(LLGroupChange gc)
 	buildActionsList(mActionList,
 					 GP_ALL_POWERS,
 					 GP_ALL_POWERS,
+					 mActionIcons,
 					 NULL,
 					 FALSE,
 					 TRUE,
diff --git a/indra/newview/llpanelgrouproles.h b/indra/newview/llpanelgrouproles.h
index 2f81900e609..bb3c9096cf4 100644
--- a/indra/newview/llpanelgrouproles.h
+++ b/indra/newview/llpanelgrouproles.h
@@ -108,7 +108,7 @@ class LLPanelGroupSubTab : public LLPanelGroupTab
 	virtual BOOL postBuild();
 
 	// This allows sub-tabs to collect child widgets from a higher level in the view hierarchy.
-	virtual BOOL postBuildSubTab(LLView* root);
+	virtual BOOL postBuildSubTab(LLView* root) { return TRUE; }
 
 	virtual void setSearchFilter( const std::string& filter );
 
@@ -117,15 +117,10 @@ class LLPanelGroupSubTab : public LLPanelGroupTab
 
 	// Helper functions
 	bool matchesActionSearchFilter(std::string action);
-
-
-	void setFooterEnabled(BOOL enable);
-
-	virtual void setGroupID(const LLUUID& id);
-protected:
 	void buildActionsList(LLScrollListCtrl* ctrl,
 								 U64 allowed_by_some,
 								 U64 allowed_by_all,
+								 icon_map_t& icons,
 						  		 LLUICtrl::commit_callback_t commit_callback,
 								 BOOL show_all,
 								 BOOL filter,
@@ -134,11 +129,15 @@ class LLPanelGroupSubTab : public LLPanelGroupTab
 									U64 allowed_by_some,
 									U64 allowed_by_all,
 									LLRoleActionSet* action_set,
+									icon_map_t& icons,
 									LLUICtrl::commit_callback_t commit_callback,
 									BOOL show_all,
 									BOOL filter,
 									BOOL is_owner_role);
 
+	void setFooterEnabled(BOOL enable);
+
+	virtual void setGroupID(const LLUUID& id);
 protected:
 	LLPanel* mHeader;
 	LLPanel* mFooter;
diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp
index 0cfe501fab5..b547997e7aa 100644
--- a/indra/newview/llpanelimcontrolpanel.cpp
+++ b/indra/newview/llpanelimcontrolpanel.cpp
@@ -302,7 +302,7 @@ void LLPanelGroupControlPanel::setSessionId(const LLUUID& session_id)
 {
 	LLPanelChatControlPanel::setSessionId(session_id);
 
-	mGroupID = session_id;
+	mGroupID = LLIMModel::getInstance()->getOtherParticipantID(session_id);
 
 	// for group and Ad-hoc chat we need to include agent into list 
 	if(!mParticipantList)
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 03cc870a595..e14a5778adc 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -35,7 +35,6 @@
 // libs
 #include "llfloaterreg.h"
 #include "llmenugl.h"
-#include "llnotificationsutil.h"
 #include "llfiltereditor.h"
 #include "lltabcontainer.h"
 #include "lluictrlfactory.h"
@@ -751,6 +750,7 @@ void LLPanelPeople::updateButtons()
 
 		LLPanel* groups_panel = mTabContainer->getCurrentPanel();
 		groups_panel->childSetEnabled("activate_btn",	item_selected && !cur_group_active); // "none" or a non-active group selected
+		groups_panel->childSetEnabled("plus_btn",		item_selected);
 		groups_panel->childSetEnabled("minus_btn",		item_selected && selected_id.notNull());
 	}
 	else
@@ -1138,12 +1138,6 @@ void LLPanelPeople::onAvatarPicked(
 
 void LLPanelPeople::onGroupPlusButtonClicked()
 {
-	if (!gAgent.canJoinGroups())
-	{
-		LLNotificationsUtil::add("JoinedTooManyGroups");
-		return;
-	}
-
 	LLMenuGL* plus_menu = (LLMenuGL*)mGroupPlusMenuHandle.get();
 	if (!plus_menu)
 		return;
diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp
index e7615929c82..7a4dd3569d5 100644
--- a/indra/newview/llpanelpick.cpp
+++ b/indra/newview/llpanelpick.cpp
@@ -35,30 +35,24 @@
 // profile.
 
 #include "llviewerprecompiledheaders.h"
-
-#include "llpanelpick.h"
-
+#include "llpanel.h"
 #include "message.h"
-
-#include "llparcel.h"
-
+#include "llagent.h"
+#include "llagentpicksinfo.h"
 #include "llbutton.h"
-#include "llfloaterreg.h"
 #include "lliconctrl.h"
 #include "lllineeditor.h"
-#include "llpanel.h"
-#include "llscrollcontainer.h"
+#include "llparcel.h"
+#include "llviewerparcelmgr.h"
 #include "lltexteditor.h"
-
-#include "llagent.h"
-#include "llagentpicksinfo.h"
-#include "llavatarpropertiesprocessor.h"
-#include "llfloaterworldmap.h"
 #include "lltexturectrl.h"
 #include "lluiconstants.h"
-#include "llviewerparcelmgr.h"
 #include "llviewerregion.h"
 #include "llworldmap.h"
+#include "llfloaterworldmap.h"
+#include "llfloaterreg.h"
+#include "llavatarpropertiesprocessor.h"
+#include "llpanelpick.h"
 
 
 #define XML_PANEL_EDIT_PICK "panel_edit_pick.xml"
@@ -99,10 +93,6 @@ LLPanelPickInfo::LLPanelPickInfo()
  , mPickId(LLUUID::null)
  , mParcelId(LLUUID::null)
  , mRequestedId(LLUUID::null)
- , mScrollingPanelMinHeight(0)
- , mScrollingPanelWidth(0)
- , mScrollingPanel(NULL)
- , mScrollContainer(NULL)
 {
 }
 
@@ -156,35 +146,9 @@ BOOL LLPanelPickInfo::postBuild()
 	childSetAction("show_on_map_btn", boost::bind(&LLPanelPickInfo::onClickMap, this));
 	childSetAction("back_btn", boost::bind(&LLPanelPickInfo::onClickBack, this));
 
-	mScrollingPanel = getChild<LLPanel>("scroll_content_panel");
-	mScrollContainer = getChild<LLScrollContainer>("profile_scroll");
-
-	mScrollingPanelMinHeight = mScrollContainer->getScrolledViewRect().getHeight();
-	mScrollingPanelWidth = mScrollingPanel->getRect().getWidth();
-
 	return TRUE;
 }
 
-void LLPanelPickInfo::reshape(S32 width, S32 height, BOOL called_from_parent)
-{
-	LLPanel::reshape(width, height, called_from_parent);
-
-	if (!mScrollContainer || !mScrollingPanel)
-		return;
-
-	static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
-
-	S32 scroll_height = mScrollContainer->getRect().getHeight();
-	if (mScrollingPanelMinHeight >= scroll_height)
-	{
-		mScrollingPanel->reshape(mScrollingPanelWidth, mScrollingPanelMinHeight);
-	}
-	else
-	{
-		mScrollingPanel->reshape(mScrollingPanelWidth + scrollbar_size, scroll_height);
-	}
-}
-
 void LLPanelPickInfo::processProperties(void* data, EAvatarProcessorType type)
 {
 	if(APT_PICK_INFO != type)
@@ -320,6 +284,7 @@ void LLPanelPickInfo::setPickName(const std::string& name)
 void LLPanelPickInfo::setPickDesc(const std::string& desc)
 {
 	childSetValue(XML_DESC, desc);
+	updateContentPanelRect();
 }
 
 void LLPanelPickInfo::setPickLocation(const std::string& location)
@@ -327,6 +292,31 @@ void LLPanelPickInfo::setPickLocation(const std::string& location)
 	childSetValue(XML_LOCATION, location);
 }
 
+void LLPanelPickInfo::updateContentPanelRect()
+{
+	LLTextBox* desc = getChild<LLTextBox>(XML_DESC);
+
+	S32 text_height = desc->getTextPixelHeight();
+	LLRect text_rect = desc->getRect();
+
+	// let text-box height fit text height
+	text_rect.set(text_rect.mLeft, text_rect.mTop, text_rect.mRight, text_rect.mTop - text_height);
+	desc->setRect(text_rect);
+	desc->reshape(text_rect.getWidth(), text_rect.getHeight());
+	// force reflow
+	desc->setText(desc->getText());
+
+	// bottom of description text-box will be bottom of content panel
+	desc->localRectToOtherView(desc->getLocalRect(), &text_rect, getChild<LLView>("profile_scroll"));
+
+	LLPanel* content_panel = getChild<LLPanel>("scroll_content_panel");
+	LLRect content_rect = content_panel->getRect();
+	content_rect.set(content_rect.mLeft, content_rect.mTop, content_rect.mRight, text_rect.mBottom);
+	// Somehow setRect moves all elements down.
+	// Single reshape() updates rect and does not move anything.
+	content_panel->reshape(content_rect.getWidth(), content_rect.getHeight());
+}
+
 void LLPanelPickInfo::onClickMap()
 {
 	LLFloaterWorldMap::getInstance()->trackLocation(getPosGlobal());
diff --git a/indra/newview/llpanelpick.h b/indra/newview/llpanelpick.h
index 62c3b20c0da..12b5a116b48 100644
--- a/indra/newview/llpanelpick.h
+++ b/indra/newview/llpanelpick.h
@@ -43,7 +43,6 @@
 
 class LLIconCtrl;
 class LLTextureCtrl;
-class LLScrollContainer;
 class LLMessageSystem;
 class LLAvatarPropertiesObserver;
 
@@ -70,8 +69,6 @@ class LLPanelPickInfo : public LLPanel, public LLAvatarPropertiesObserver, LLRem
 
 	/*virtual*/ BOOL postBuild();
 
-	/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
-
 	/*virtual*/ void processProperties(void* data, EAvatarProcessorType type);
 
 	/**
@@ -142,6 +139,15 @@ class LLPanelPickInfo : public LLPanel, public LLAvatarPropertiesObserver, LLRem
 	virtual void setPosGlobal(const LLVector3d& pos) { mPosGlobal = pos; }
 	virtual LLVector3d& getPosGlobal() { return mPosGlobal; }
 
+	/**
+	 * Reshapes content panel to fit all elements.
+	 *
+	 * Assume that description text-box is the last element of panel.
+	 * Reshape text-box to fit text height and then reshape content panel to fit 
+	 * text-box bottom. EXT-1326
+	 */
+	void updateContentPanelRect();
+
 	/**
 	 * Callback for "Map" button, opens Map
 	 */
@@ -156,11 +162,7 @@ class LLPanelPickInfo : public LLPanel, public LLAvatarPropertiesObserver, LLRem
 
 protected:
 
-	S32						mScrollingPanelMinHeight;
-	S32						mScrollingPanelWidth;
-	LLScrollContainer*		mScrollContainer;
-	LLPanel*				mScrollingPanel;
-	LLTextureCtrl*			mSnapshotCtrl;
+	LLTextureCtrl* mSnapshotCtrl;
 
 	LLUUID mAvatarId;
 	LLVector3d mPosGlobal;
diff --git a/indra/newview/llpanelplaces.h b/indra/newview/llpanelplaces.h
index b134cf0cba6..5ee87049926 100644
--- a/indra/newview/llpanelplaces.h
+++ b/indra/newview/llpanelplaces.h
@@ -71,10 +71,6 @@ class LLPanelPlaces : public LLPanel
 
 	void setItem(LLInventoryItem* item);
 
-	LLInventoryItem* getItem() { return mItem; }
-
-	std::string getPlaceInfoType() { return mPlaceInfoType; }
-
 private:
 	void onLandmarkLoaded(LLLandmark* landmark);
 	void onFilterEdit(const std::string& search_string, bool force_filter);
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 0a2217fc51c..65a3d9d41b9 100644
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -550,7 +550,7 @@ void LLTeleportHistoryPanel::updateVerbs()
 
 	LLTeleportHistoryFlatItem* itemp = dynamic_cast<LLTeleportHistoryFlatItem *> (mLastSelectedFlatlList->getSelectedItem());
 
-	mTeleportBtn->setEnabled(NULL != itemp);
+	mTeleportBtn->setEnabled(NULL != itemp && itemp->getIndex() < (S32)mTeleportHistory->getItems().size() - 1);
 	mShowOnMapBtn->setEnabled(NULL != itemp);
 }
 
diff --git a/indra/newview/llpanelvolumepulldown.cpp b/indra/newview/llpanelvolumepulldown.cpp
deleted file mode 100644
index 74e37efe4e4..00000000000
--- a/indra/newview/llpanelvolumepulldown.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/** 
- * @file llpanelvolumepulldown.cpp
- * @author Tofu Linden
- * @brief A floater showing the master volume pull-down
- *
- * $LicenseInfo:firstyear=2008&license=viewergpl$
- * 
- * Copyright (c) 2008-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llpanelvolumepulldown.h"
-
-// Viewer libs
-#include "llviewercontrol.h"
-#include "llstatusbar.h"
-
-// Linden libs
-#include "llbutton.h"
-#include "lltabcontainer.h"
-#include "llfloaterreg.h"
-#include "llfloaterpreference.h"
-#include "llslider.h"
-
-/* static */ const F32 LLPanelVolumePulldown::sAutoCloseFadeStartTimeSec = 4.0f;
-/* static */ const F32 LLPanelVolumePulldown::sAutoCloseTotalTimeSec = 5.0f;
-
-///----------------------------------------------------------------------------
-/// Class LLPanelVolumePulldown
-///----------------------------------------------------------------------------
-
-// Default constructor
-LLPanelVolumePulldown::LLPanelVolumePulldown()
-{
-    mCommitCallbackRegistrar.add("Vol.setControlFalse", boost::bind(&LLPanelVolumePulldown::setControlFalse, this, _2));
-	mCommitCallbackRegistrar.add("Vol.GoAudioPrefs", boost::bind(&LLPanelVolumePulldown::onAdvancedButtonClick, this, _2));
-	LLUICtrlFactory::instance().buildPanel(this, "panel_volume_pulldown.xml");
-}
-
-BOOL LLPanelVolumePulldown::postBuild()
-{
-	// set the initial volume-slider's position to reflect reality
-	LLSlider* volslider =  getChild<LLSlider>( "mastervolume" );
-	volslider->setValue(gSavedSettings.getF32("AudioLevelMaster"));
-
-	return LLPanel::postBuild();
-}
-
-/*virtual*/
-void LLPanelVolumePulldown::onMouseEnter(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.stop();
-	LLPanel::onMouseEnter(x,y,mask);
-}
-
-
-/*virtual*/
-void LLPanelVolumePulldown::onMouseLeave(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.start();
-	LLPanel::onMouseLeave(x,y,mask);
-}
-
-/*virtual*/ 
-void LLPanelVolumePulldown::handleVisibilityChange ( BOOL new_visibility )
-{
-	if (new_visibility)	
-	{
-		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
-		gFocusMgr.setTopCtrl(this);
-	}
-	else
-	{
-		mHoverTimer.stop();
-		gFocusMgr.setTopCtrl(NULL);
-	}
-}
-
-/*virtual*/ 
-void LLPanelVolumePulldown::onTopLost()
-{
-	setVisible(FALSE);
-}
-
-void LLPanelVolumePulldown::onAdvancedButtonClick(const LLSD& user_data)
-{
-	// close the global volume minicontrol, we're bringing up the big one
-	setVisible(FALSE);
-
-	// bring up the prefs floater
-	LLFloaterPreference* prefsfloater = dynamic_cast<LLFloaterPreference*>
-		(LLFloaterReg::showInstance("preferences"));
-	if (prefsfloater)
-	{
-		// grab the 'audio' panel from the preferences floater and
-		// bring it the front!
-		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-		LLPanel* audiopanel = prefsfloater->getChild<LLPanel>("audio");
-		if (tabcontainer && audiopanel)
-		{
-			tabcontainer->selectTabPanel(audiopanel);
-		}
-	}
-}
-
-void LLPanelVolumePulldown::setControlFalse(const LLSD& user_data)
-{
-	std::string control_name = user_data.asString();
-	LLControlVariable* control = findControl(control_name);
-	
-	if (control)
-		control->set(LLSD(FALSE));
-}
-
-//virtual
-void LLPanelVolumePulldown::draw()
-{
-	F32 alpha = mHoverTimer.getStarted() 
-		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
-		: 1.0f;
-	LLViewDrawContext context(alpha);
-
-	LLPanel::draw();
-
-	if (alpha == 0.f)
-	{
-		setVisible(FALSE);
-	}
-}
-
diff --git a/indra/newview/llpanelvolumepulldown.h b/indra/newview/llpanelvolumepulldown.h
deleted file mode 100644
index 9f20caa1a8b..00000000000
--- a/indra/newview/llpanelvolumepulldown.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/** 
- * @file llpanelvolumepulldown.h
- * @author Tofu Linden
- * @brief A panel showing the master volume pull-down
- *
- * $LicenseInfo:firstyear=2008&license=viewergpl$
- * 
- * Copyright (c) 2008-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLPANELVOLUMEPULLDOWN_H
-#define LL_LLPANELVOLUMEPULLDOWN_H
-
-#include "linden_common.h"
-
-#include "llpanel.h"
-
-class LLFrameTimer;
-
-class LLPanelVolumePulldown : public LLPanel
-{
- public:
-	LLPanelVolumePulldown();
-	/*virtual*/ void draw();
-	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
-	/*virtual*/ void handleVisibilityChange ( BOOL new_visibility );
-	/*virtual*/ void onTopLost();
-	/*virtual*/ BOOL postBuild();
-	
- private:
-	void setControlFalse(const LLSD& user_data);
-	void onAdvancedButtonClick(const LLSD& user_data);
-
-	LLFrameTimer mHoverTimer;
-	static const F32 sAutoCloseFadeStartTimeSec;
-	static const F32 sAutoCloseTotalTimeSec;
-};
-
-
-#endif // LL_LLPANELVOLUMEPULLDOWN_H
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index b6f78d08f12..e2da4c44758 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -166,6 +166,7 @@ void LLParticipantList::onAvatarListRefreshed(LLUICtrl* ctrl, const LLSD& param)
 				{
 					name.erase(found, moderator_indicator_len);
 					item->setName(name);
+					item->reshapeAvatarName();
 				}
 			}
 		}
@@ -187,6 +188,7 @@ void LLParticipantList::onAvatarListRefreshed(LLUICtrl* ctrl, const LLSD& param)
 					name += " ";
 					name += moderator_indicator;
 					item->setName(name);
+					item->reshapeAvatarName();
 				}
 			}
 		}
@@ -277,9 +279,6 @@ bool LLParticipantList::onModeratorUpdateEvent(LLPointer<LLOldEvents::LLEvent> e
 					mModeratorList.erase(id);
 				}
 			}
-
-			// apply changes immediately
-			onAvatarListRefreshed(mAvatarList, LLSD());
 		}
 	}
 	return true;
@@ -593,7 +592,8 @@ bool LLParticipantList::LLParticipantListMenu::enableContextMenuItem(const LLSD&
 			if (speakerp.notNull())
 			{
 				// not in voice participants can not be moderated
-				return speakerp->isInVoiceChannel();
+				return speakerp->mStatus == LLSpeaker::STATUS_VOICE_ACTIVE
+					|| speakerp->mStatus == LLSpeaker::STATUS_MUTED;
 			}
 		}
 		return false;
diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp
index 027f3daffbd..da3f1543dda 100644
--- a/indra/newview/llscreenchannel.cpp
+++ b/indra/newview/llscreenchannel.cpp
@@ -59,14 +59,17 @@ bool LLScreenChannel::mWasStartUpToastShown = false;
 // LLScreenChannelBase
 //////////////////////
 LLScreenChannelBase::LLScreenChannelBase(const LLUUID& id) :
-												mToastAlignment(NA_BOTTOM)
+												mOverflowToastPanel(NULL) 
+												,mToastAlignment(NA_BOTTOM)
 												,mCanStoreToasts(true)
 												,mHiddenToastsNum(0)
+												,mOverflowToastHidden(false)
 												,mHoveredToast(NULL)
 												,mControlHovering(false)
 												,mShowToasts(true)
 {	
 	mID = id;
+	mOverflowFormatString = LLTrans::getString("OverflowInfoChannelString");
 	mWorldViewRectConnection = gViewerWindow->setOnWorldViewRectUpdated(boost::bind(&LLScreenChannelBase::updatePositionAndSize, this, _1, _2));
 	setMouseOpaque( false );
 	setVisible(FALSE);
@@ -214,6 +217,11 @@ void LLScreenChannel::addToast(const LLToast::Params& p)
 
 	ToastElem new_toast_elem(p);
 
+	// reset HIDDEN flags for the Overflow Toast
+	mOverflowToastHidden = false;
+	if(mOverflowToastPanel)
+		mOverflowToastPanel->setIsHidden(false);
+	
 	new_toast_elem.toast->setOnFadeCallback(boost::bind(&LLScreenChannel::onToastFade, this, _1));
 	new_toast_elem.toast->setOnToastDestroyedCallback(boost::bind(&LLScreenChannel::onToastDestroyed, this, _1));
 	if(mControlHovering)
@@ -314,6 +322,8 @@ void LLScreenChannel::loadStoredToastsToChannel()
 
 	if(mStoredToastList.size() == 0)
 		return;
+	
+	mOverflowToastHidden = false;
 
 	for(it = mStoredToastList.begin(); it != mStoredToastList.end(); ++it)
 	{
@@ -334,6 +344,8 @@ void LLScreenChannel::loadStoredToastByNotificationIDToChannel(LLUUID id)
 	if( it == mStoredToastList.end() )
 		return;
 
+	mOverflowToastHidden = false;
+
 	LLToast* toast = (*it).toast;
 
 	if(toast->getVisible())
@@ -345,6 +357,7 @@ void LLScreenChannel::loadStoredToastByNotificationIDToChannel(LLUUID id)
 	toast->setIsHidden(false);
 	toast->resetTimer();
 	mToastList.push_back((*it));
+	mStoredToastList.erase(it);
 
 	redrawToasts();
 }
@@ -478,7 +491,7 @@ void LLScreenChannel::showToastsBottom()
 		if(floater && floater->overlapsScreenChannel())
 		{
 			LLRect world_rect = gViewerWindow->getWorldViewRectScaled();
-			if(toast_rect.mTop > world_rect.mTop)
+			if(toast_rect.mTop + getOverflowToastHeight() + toast_margin > world_rect.mTop)
 			{
 				break;
 			}
@@ -514,7 +527,7 @@ void LLScreenChannel::showToastsBottom()
 		}		
 	}
 
-	if(it != mToastList.rend())
+	if(it != mToastList.rend() && !mOverflowToastHidden)
 	{
 		mHiddenToastsNum = 0;
 		for(; it != mToastList.rend(); it++)
@@ -523,6 +536,7 @@ void LLScreenChannel::showToastsBottom()
 			(*it).toast->setVisible(FALSE);
 			mHiddenToastsNum++;
 		}
+		createOverflowToast(bottom, gSavedSettings.getS32("NotificationTipToastLifeTime"));
 	}
 	else
 	{
@@ -552,6 +566,94 @@ void LLScreenChannel::showToastsTop()
 {
 }
 
+//--------------------------------------------------------------------------
+void LLScreenChannel::createOverflowToast(S32 bottom, F32 timer)
+{
+	LLRect toast_rect;
+	LLToast::Params p;
+	p.lifetime_secs = timer;
+
+	if(!mOverflowToastPanel)
+		mOverflowToastPanel = new LLToast(p);
+
+	if(!mOverflowToastPanel)
+		return;
+
+	mOverflowToastPanel->startFading();
+	mOverflowToastPanel->setOnFadeCallback(boost::bind(&LLScreenChannel::onOverflowToastHide, this));
+
+	LLTextBox* text_box = mOverflowToastPanel->getChild<LLTextBox>("toast_text");
+	std::string	text = llformat(mOverflowFormatString.c_str(),mHiddenToastsNum);
+	if(mHiddenToastsNum == 1)
+	{
+		text += ".";
+	}
+	else
+	{
+		text += "s.";
+	}
+
+	toast_rect = mOverflowToastPanel->getRect();
+	mOverflowToastPanel->reshape(getRect().getWidth(), toast_rect.getHeight(), true);
+	toast_rect.setLeftTopAndSize(getRect().mLeft, bottom + toast_rect.getHeight()+gSavedSettings.getS32("ToastGap"), getRect().getWidth(), toast_rect.getHeight());	
+	mOverflowToastPanel->setRect(toast_rect);
+
+	// don't show overflow toast if there is not enough space for it.
+	LLDockableFloater* floater = dynamic_cast<LLDockableFloater*>(LLDockableFloater::getInstanceHandle().get());
+	if(floater && floater->overlapsScreenChannel())
+	{
+		LLRect world_rect = gViewerWindow->getWorldViewRectScaled();
+		if(toast_rect.mTop > world_rect.mTop)
+		{
+			closeOverflowToastPanel();
+			return;
+		}
+	}
+
+	text_box->setValue(text);
+	text_box->setVisible(TRUE);
+
+	mOverflowToastPanel->setVisible(TRUE);
+}
+
+//--------------------------------------------------------------------------
+void LLScreenChannel::onOverflowToastHide()
+{
+	mOverflowToastHidden = true;
+
+	// remove all hidden toasts from channel and save interactive notifications
+	for(std::vector<ToastElem>::iterator it = mToastList.begin(); it != mToastList.end();)
+	{
+		if(!(*it).toast->getVisible())
+		{
+			if((*it).toast->getCanBeStored())
+			{
+				storeToast((*it));
+			}
+			else
+			{
+				deleteToast((*it).toast);
+			}
+
+			it = mToastList.erase(it);
+		}
+		else
+		{
+			++it;
+		}
+	}
+}
+
+//--------------------------------------------------------------------------
+void LLScreenChannel::closeOverflowToastPanel()
+{
+	if(mOverflowToastPanel != NULL)
+	{
+		mOverflowToastPanel->setVisible(FALSE);
+		mOverflowToastPanel->stopFading();
+	}
+}
+
 //--------------------------------------------------------------------------
 void LLScreenChannel::createStartUpToast(S32 notif_num, F32 timer)
 {
@@ -597,6 +699,24 @@ F32 LLScreenChannel::getHeightRatio()
 	return ratio;
 }
 
+S32 LLScreenChannel::getOverflowToastHeight()
+{
+	if(mOverflowToastPanel)
+	{
+		return mOverflowToastPanel->getRect().getHeight();
+	}
+
+	static S32 height = 0;
+	if(0 == height)
+	{
+		LLToast::Params p;
+		LLToast* toast = new LLToast(p);
+		height = toast->getRect().getHeight();
+		delete toast;
+	}
+	return height;
+}
+
 //--------------------------------------------------------------------------
 void LLScreenChannel::updateStartUpString(S32 num)
 {
@@ -658,19 +778,6 @@ void LLScreenChannel::hideToastsFromScreen()
 		(*it).toast->setVisible(FALSE);
 }
 
-//--------------------------------------------------------------------------
-void LLScreenChannel::hideToast(const LLUUID& notification_id)
-{
-	std::vector<ToastElem>::iterator it = find(mToastList.begin(), mToastList.end(), notification_id);
-	if(mToastList.end() != it)
-	{
-		ToastElem te = *it;
-		te.toast->setVisible(FALSE);
-		te.toast->stopTimer();
-		mToastList.erase(it);
-	}
-}
-
 //--------------------------------------------------------------------------
 void LLScreenChannel::removeToastsFromChannel()
 {
@@ -789,13 +896,3 @@ void LLScreenChannel::updateShowToastsState()
 
 //--------------------------------------------------------------------------
 
-LLToast* LLScreenChannel::getToastByNotificationID(LLUUID id)
-{
-	std::vector<ToastElem>::iterator it = find(mStoredToastList.begin(),
-			mStoredToastList.end(), id);
-
-	if (it == mStoredToastList.end())
-		return NULL;
-
-	return it->toast;
-}
diff --git a/indra/newview/llscreenchannel.h b/indra/newview/llscreenchannel.h
index 88053d87d9d..38f27f756b6 100644
--- a/indra/newview/llscreenchannel.h
+++ b/indra/newview/llscreenchannel.h
@@ -72,7 +72,8 @@ class LLScreenChannelBase : public LLUICtrl
 	virtual void		setToastAlignment(EToastAlignment align) {mToastAlignment = align;}
 	
 	virtual void		setChannelAlignment(EChannelAlignment align) {mChannelAlignment = align;}
-
+	virtual void		setOverflowFormatString ( const std::string& str)  { mOverflowFormatString = str; }
+	
 	// kill or modify a toast by its ID
 	virtual void		killToastByNotificationID(LLUUID id) {};
 	virtual void		modifyToastNotificationByID(LLUUID id, LLSD data) {};
@@ -120,13 +121,17 @@ class LLScreenChannelBase : public LLUICtrl
 	LLToast*		mHoveredToast;
 	bool		mCanStoreToasts;
 	bool		mDisplayToastsAlways;
+	bool		mOverflowToastHidden;
 	// controls whether a channel shows toasts or not
 	bool		mShowToasts;
 	// 
 	EToastAlignment		mToastAlignment;
 	EChannelAlignment	mChannelAlignment;
 
+	// attributes for the Overflow Toast
 	S32			mHiddenToastsNum;
+	LLToast*	mOverflowToastPanel;	
+	std::string mOverflowFormatString;
 
 	// channel's ID
 	LLUUID	mID;
@@ -171,8 +176,6 @@ class LLScreenChannel : public LLScreenChannelBase
 	void		modifyToastByNotificationID(LLUUID id, LLPanel* panel);
 	// hide all toasts from screen, but not remove them from a channel
 	void		hideToastsFromScreen();
-	// hide toast by notification id
-	void		hideToast(const LLUUID& notification_id);
 	// removes all toasts from a channel
 	void		removeToastsFromChannel();
 	// show all toasts in a channel
@@ -187,6 +190,8 @@ class LLScreenChannel : public LLScreenChannelBase
 	void		removeToastsBySessionID(LLUUID id);
 	// remove all storable toasts from screen and store them
 	void		removeAndStoreAllStorableToasts();
+	// close the Overflow Toast
+	void 		closeOverflowToastPanel();
 	// close the StartUp Toast
 	void		closeStartUpToast();
 
@@ -209,8 +214,6 @@ class LLScreenChannel : public LLScreenChannelBase
 	// update number of notifications in the StartUp Toast
 	void	updateStartUpString(S32 num);
 
-	LLToast* getToastByNotificationID(LLUUID id);
-
 	// Channel's signals
 	// signal on storing of faded toasts event
 	typedef boost::function<void (LLPanel* info_panel, const LLUUID id)> store_tost_callback_t;
@@ -254,6 +257,7 @@ class LLScreenChannel : public LLScreenChannelBase
 	void	onToastHover(LLToast* toast, bool mouse_enter);
 	void	onToastFade(LLToast* toast);
 	void	onToastDestroyed(LLToast* toast);
+	void	onOverflowToastHide();
 	void	onStartUpToastHide();
 
 	//
@@ -266,6 +270,9 @@ class LLScreenChannel : public LLScreenChannelBase
 	void	showToastsCentre();
 	void	showToastsTop();
 	
+	// create the Overflow Toast
+	void	createOverflowToast(S32 bottom, F32 timer);
+
 	// create the StartUp Toast
 	void	createStartUpToast(S32 notif_num, F32 timer);
 
@@ -274,6 +281,8 @@ class LLScreenChannel : public LLScreenChannelBase
 	 */
 	static F32 getHeightRatio();
 
+	S32 getOverflowToastHeight();
+
 	// Channel's flags
 	static bool	mWasStartUpToastShown;
 
diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp
index 0dd9203c6d9..010dfd1b331 100644
--- a/indra/newview/llspeakers.cpp
+++ b/indra/newview/llspeakers.cpp
@@ -88,11 +88,6 @@ void LLSpeaker::onAvatarNameLookup(const LLUUID& id, const std::string& first, c
 	mDisplayName = first + " " + last;
 }
 
-bool LLSpeaker::isInVoiceChannel()
-{
-	return mStatus == LLSpeaker::STATUS_VOICE_ACTIVE || mStatus == LLSpeaker::STATUS_MUTED;
-}
-
 LLSpeakerUpdateModeratorEvent::LLSpeakerUpdateModeratorEvent(LLSpeaker* source)
 : LLEvent(source, "Speaker add moderator event"),
   mSpeakerID (source->mID),
diff --git a/indra/newview/llspeakers.h b/indra/newview/llspeakers.h
index da8dfdf548e..1a8c23f56a2 100644
--- a/indra/newview/llspeakers.h
+++ b/indra/newview/llspeakers.h
@@ -67,8 +67,6 @@ class LLSpeaker : public LLRefCount, public LLOldEvents::LLObservable, public LL
 
 	void onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group);
 
-	bool isInVoiceChannel();
-
 	ESpeakerStatus	mStatus;			// current activity status in speech group
 	F32				mLastSpokeTime;		// timestamp when this speaker last spoke
 	F32				mSpeechVolume;		// current speech amplitude (timea average rms amplitude?)
diff --git a/indra/newview/llspeakingindicatormanager.cpp b/indra/newview/llspeakingindicatormanager.cpp
deleted file mode 100644
index 42db6bf9c3f..00000000000
--- a/indra/newview/llspeakingindicatormanager.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/** 
- * @file llspeakingindicatormanager.cpp
- * @author Mike Antipov
- * @brief Implementation of SpeackerIndicatorManager class to process registered LLSpeackerIndicator
- * depend on avatars are in the same voice channel.
- *
- * $LicenseInfo:firstyear=2010&license=viewergpl$
- * 
- * Copyright (c) 2010, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llspeakingindicatormanager.h"
-
-
-#include "llagentdata.h"
-#include "llvoicechannel.h"
-#include "llvoiceclient.h"
-
-/**
- * This class intended to control visibility of avatar speaking indicators depend on whether avatars
- * are in the same voice channel.
- *
- * Speaking indicator should be visible for avatars in the same voice channel. See EXT-3976.
- *
- * It stores passed instances of LLOutputMonitorCtrl in a multimap by avatar LLUUID.
- * It observes changing of voice channel and changing of participant list in voice channel.
- * When voice channel or voice participant list is changed it updates visibility of an appropriate 
- * speaking indicator.
- *
- * Several indicators can be registered for the same avatar.
- */
-class SpeakingIndicatorManager : public LLSingleton<SpeakingIndicatorManager>, LLVoiceClientParticipantObserver
-{
-	LOG_CLASS(SpeakingIndicatorManager);
-public:
-
-	/**
-	 * Stores passed speaking indicator to control its visibility.
-	 *
-	 * Registered indicator is set visible if an appropriate avatar is in the same voice channel with Agent.
-	 * It ignores instances of Agent's indicator.
-	 *
-	 * @param speaker_id LLUUID of an avatar whose speaking indicator is registered.
-	 * @param speaking_indicator instance of the speaking indicator to be registered.
-	 */
-	void registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator);
-
-	/**
-	 * Removes passed speaking indicator from observing.
-	 *
-	 * @param speaker_id LLUUID of an avatar whose speaking indicator should be unregistered.
-	 * @param speaking_indicator instance of the speaking indicator to be unregistered.
-	 */
-	void unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator);
-
-private:
-	typedef std::set<LLUUID> speaker_ids_t;
-	typedef std::multimap<LLUUID, LLSpeakingIndicator*> speaking_indicators_mmap_t;
-	typedef speaking_indicators_mmap_t::value_type speaking_indicator_value_t;
-	typedef speaking_indicators_mmap_t::const_iterator indicator_const_iterator;
-	typedef std::pair<indicator_const_iterator, indicator_const_iterator> indicator_range_t;
-
-	friend class LLSingleton<SpeakingIndicatorManager>;
-	SpeakingIndicatorManager();
-	~SpeakingIndicatorManager();
-
-	/**
-	 * Callback to determine when voice channel is changed.
-	 *
-	 * It switches all registered speaking indicators off.
-	 * To reduce overheads only switched on indicators are processed.
-	 */
-	void sOnCurrentChannelChanged(const LLUUID& session_id);
-
-	/**
-	 * Callback of changing voice participant list (from LLVoiceClientParticipantObserver).
-	 *
-	 * Switches off indicators had been switched on and switches on indicators of current participants list.
-	 * There is only a few indicators in lists should be switched off/on.
-	 * So, method does not calculate difference between these list it only switches off already 
-	 * switched on indicators and switches on indicators of voice channel participants
-	 */
-	void onChange();
-
-	/**
-	 * Changes state of indicators specified by LLUUIDs
-	 *
-	 * @param speakers_uuids - avatars' LLUUIDs whose speaking indicators should be switched
-	 * @param switch_on - if TRUE specified indicator will be switched on, off otherwise.
-	 */
-	void switchSpeakerIndicators(const speaker_ids_t& speakers_uuids, BOOL switch_on);
-
-	/**
-	 * Multimap with all registered speaking indicators
-	 */
-	speaking_indicators_mmap_t mSpeakingIndicators;
-
-	/**
-	 * LUUIDs of avatar for which we have speaking indicators switched on.
-	 *
-	 * Is used to switch off all previously ON indicators when voice participant list is changed.
-	 *
-	 * @see onChange()
-	 */
-	speaker_ids_t mSwitchedIndicatorsOn;
-};
-
-//////////////////////////////////////////////////////////////////////////
-// PUBLIC SECTION
-//////////////////////////////////////////////////////////////////////////
-void SpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator)
-{
-	if (speaker_id == gAgentID) return;
-
-	LL_DEBUGS("SpeakingIndicator") << "Registering indicator: " << speaker_id << LL_ENDL;
-	speaking_indicator_value_t value_type(speaker_id, speaking_indicator);
-	mSpeakingIndicators.insert(value_type);
-
-	speaker_ids_t speakers_uuids;
-	BOOL is_in_same_voice = LLVoiceClient::getInstance()->findParticipantByID(speaker_id) != NULL;
-
-	speakers_uuids.insert(speaker_id);
-	switchSpeakerIndicators(speakers_uuids, is_in_same_voice);
-}
-
-void SpeakingIndicatorManager::unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator)
-{
-	speaking_indicators_mmap_t::iterator it;
-	it = mSpeakingIndicators.find(speaker_id);
-	for (;it != mSpeakingIndicators.end(); ++it)
-	{
-		if (it->second == speaking_indicator)
-		{
-			mSpeakingIndicators.erase(it);
-			break;
-		}
-	}
-}
-
-//////////////////////////////////////////////////////////////////////////
-// PRIVATE SECTION
-//////////////////////////////////////////////////////////////////////////
-SpeakingIndicatorManager::SpeakingIndicatorManager()
-{
-	LLVoiceChannel::setCurrentVoiceChannelChangedCallback(boost::bind(&SpeakingIndicatorManager::sOnCurrentChannelChanged, this, _1));
-	LLVoiceClient::getInstance()->addObserver(this);
-}
-
-SpeakingIndicatorManager::~SpeakingIndicatorManager()
-{
-	// Don't use LLVoiceClient::getInstance() here without check
-	// singleton MAY have already been destroyed.
-	if(LLVoiceClient::instanceExists())
-	{
-		LLVoiceClient::getInstance()->removeObserver(this);
-	}
-}
-
-void SpeakingIndicatorManager::sOnCurrentChannelChanged(const LLUUID& /*session_id*/)
-{
-	switchSpeakerIndicators(mSwitchedIndicatorsOn, FALSE);
-	mSwitchedIndicatorsOn.clear();
-}
-
-void SpeakingIndicatorManager::onChange()
-{
-	LL_DEBUGS("SpeakingIndicator") << "Voice participant list was changed, updating indicators" << LL_ENDL;
-
-	speaker_ids_t speakers_uuids;
-	LLVoiceClient::getInstance()->getParticipantsUUIDSet(speakers_uuids);
-
-	LL_DEBUGS("SpeakingIndicator") << "Switching all OFF, count: " << mSwitchedIndicatorsOn.size() << LL_ENDL;
-	// switch all indicators off
-	switchSpeakerIndicators(mSwitchedIndicatorsOn, FALSE);
-	mSwitchedIndicatorsOn.clear();
-
-	LL_DEBUGS("SpeakingIndicator") << "Switching all ON, count: " << speakers_uuids.size() << LL_ENDL;
-	// then switch current voice participants indicators on
-	switchSpeakerIndicators(speakers_uuids, TRUE);
-}
-
-void SpeakingIndicatorManager::switchSpeakerIndicators(const speaker_ids_t& speakers_uuids, BOOL switch_on)
-{
-	speaker_ids_t::const_iterator it_uuid = speakers_uuids.begin(); 
-	for (; it_uuid != speakers_uuids.end(); ++it_uuid)
-	{
-		LL_DEBUGS("SpeakingIndicator") << "Looking for indicator: " << *it_uuid << LL_ENDL;
-		indicator_range_t it_range = mSpeakingIndicators.equal_range(*it_uuid);
-		indicator_const_iterator it_indicator = it_range.first;
-		bool was_found = false;
-		for (; it_indicator != it_range.second; ++it_indicator)
-		{
-			was_found = true;
-			LLSpeakingIndicator* indicator = (*it_indicator).second;
-			indicator->switchIndicator(switch_on);
-		}
-
-		if (was_found)
-		{
-			LL_DEBUGS("SpeakingIndicator") << mSpeakingIndicators.count(*it_uuid) << " indicators where found" << LL_ENDL;
-
-			if (switch_on)
-			{
-				// store switched on indicator to be able switch it off
-				mSwitchedIndicatorsOn.insert(*it_uuid);
-			}
-		}
-		else
-		{
-			LL_WARNS("SpeakingIndicator") << "indicator was not found among registered: " << *it_uuid << LL_ENDL;
-		}
-	}
-}
-
-/************************************************************************/
-/*         LLSpeakingIndicatorManager namespace implementation          */
-/************************************************************************/
-
-void LLSpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator)
-{
-	SpeakingIndicatorManager::instance().registerSpeakingIndicator(speaker_id, speaking_indicator);
-}
-
-void LLSpeakingIndicatorManager::unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator)
-{
-	SpeakingIndicatorManager::instance().unregisterSpeakingIndicator(speaker_id, speaking_indicator);
-}
-
-// EOF
-
diff --git a/indra/newview/llspeakingindicatormanager.h b/indra/newview/llspeakingindicatormanager.h
deleted file mode 100644
index ce0158f7d86..00000000000
--- a/indra/newview/llspeakingindicatormanager.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/** 
- * @file llspeakingindicatormanager.h
- * @author Mike Antipov
- * @brief Interfeace of LLSpeackerIndicator class to be processed depend on avatars are in the same voice channel.
- * Also register/unregister methods for this class are declared
- *
- * $LicenseInfo:firstyear=2010&license=viewergpl$
- * 
- * Copyright (c) 2010, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLSPEAKINGINDICATORMANAGER_H
-#define LL_LLSPEAKINGINDICATORMANAGER_H
-
-class LLSpeakingIndicator
-{
-public:
-	virtual void switchIndicator(bool switch_on) = 0;
-};
-
-// See EXT-3976.
-namespace LLSpeakingIndicatorManager
-{
-	/**
-	 * Stores passed speaking indicator to control its visibility.
-	 *
-	 * Registered indicator is set visible if an appropriate avatar is in the same voice channel with Agent.
-	 * It ignores instances of Agent's indicator.
-	 *
-	 * @param speaker_id LLUUID of an avatar whose speaker indicator is registered.
-	 * @param speaking_indicator instance of the speaker indicator to be registered.
-	 */
-	void registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator);
-
-	/**
-	 * Removes passed speaking indicator from observing.
-	 *
-	 * @param speaker_id LLUUID of an avatar whose speaker indicator should be unregistered.
-	 * @param speaking_indicator instance of the speaker indicator to be unregistered.
-	 */
-	void unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator);
-}
-
-#endif // LL_LLSPEAKINGINDICATORMANAGER_H
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index b3b2b9ee5d5..5ce3bbb9f62 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -42,7 +42,7 @@
 #include "llfloaterbuycurrency.h"
 #include "llfloaterchat.h"
 #include "llfloaterlagmeter.h"
-#include "llpanelvolumepulldown.h"
+#include "llfloatervolumepulldown.h"
 #include "llfloaterregioninfo.h"
 #include "llfloaterscriptdebug.h"
 #include "llhudicon.h"
@@ -204,21 +204,6 @@ LLStatusBar::LLStatusBar(const LLRect& rect)
 	addChild(mSGPacketLoss);
 
 	childSetActionTextbox("stat_btn", onClickStatGraph);
-
-	mPanelVolumePulldown = new LLPanelVolumePulldown();
-	addChild(mPanelVolumePulldown);
-
-	LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect();
-	LLButton* volbtn =  getChild<LLButton>( "volume_btn" );
-	volume_pulldown_rect.setLeftTopAndSize(volbtn->getRect().mLeft -
-	     (volume_pulldown_rect.getWidth() - volbtn->getRect().getWidth())/2,
-			       volbtn->calcScreenRect().mBottom,
-			       volume_pulldown_rect.getWidth(),
-			       volume_pulldown_rect.getHeight());
-
-	mPanelVolumePulldown->setShape(volume_pulldown_rect);
-	mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-	mPanelVolumePulldown->setVisible(FALSE);
 }
 
 LLStatusBar::~LLStatusBar()
@@ -516,7 +501,7 @@ static void onClickScriptDebug(void*)
 void LLStatusBar::onMouseEnterVolume(LLUICtrl* ctrl)
 {
 	// show the master volume pull-down
-	gStatusBar->mPanelVolumePulldown->setVisible(TRUE);
+	LLFloaterReg::showInstance("volume_pulldown");
 }
 
 static void onClickVolume(void* data)
diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h
index 0e98da0fe45..f77cc1acb86 100644
--- a/indra/newview/llstatusbar.h
+++ b/indra/newview/llstatusbar.h
@@ -112,7 +112,7 @@ class LLStatusBar
 	S32				mSquareMetersCommitted;
 	LLFrameTimer*	mBalanceTimer;
 	LLFrameTimer*	mHealthTimer;
-	LLPanelVolumePulldown* mPanelVolumePulldown;
+		
 	static std::vector<std::string> sDays;
 	static std::vector<std::string> sMonths;
 	static const U32 MAX_DATE_STRING_LENGTH;
diff --git a/indra/newview/llsyswellitem.cpp b/indra/newview/llsyswellitem.cpp
index 0cfcfdc6345..eef84350064 100644
--- a/indra/newview/llsyswellitem.cpp
+++ b/indra/newview/llsyswellitem.cpp
@@ -77,11 +77,10 @@ void LLSysWellItem::onClickCloseBtn()
 //---------------------------------------------------------------------------------
 BOOL LLSysWellItem::handleMouseDown(S32 x, S32 y, MASK mask)
 {
-	BOOL res = LLPanel::handleMouseDown(x, y, mask);
 	if(!mCloseBtn->getRect().pointInRect(x, y))
 		mOnItemClick(this);
 
-	return res;
+	return LLPanel::handleMouseDown(x, y, mask);
 }
 
 //---------------------------------------------------------------------------------
diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp
index ba15053381c..44cf82540a0 100644
--- a/indra/newview/llsyswellwindow.cpp
+++ b/indra/newview/llsyswellwindow.cpp
@@ -700,7 +700,8 @@ void LLNotificationWellWindow::connectListUpdaterToSignal(std::string notificati
 void LLNotificationWellWindow::onItemClick(LLSysWellItem* item)
 {
 	LLUUID id = item->getID();
-	LLFloaterReg::showInstance("inspect_toast", id);
+	if(mChannel)
+		mChannel->loadStoredToastByNotificationIDToChannel(id);
 }
 
 void LLNotificationWellWindow::onItemClose(LLSysWellItem* item)
diff --git a/indra/newview/llsyswellwindow.h b/indra/newview/llsyswellwindow.h
index 0c81d1f369b..ded3abcbf40 100644
--- a/indra/newview/llsyswellwindow.h
+++ b/indra/newview/llsyswellwindow.h
@@ -162,9 +162,6 @@ class LLNotificationWellWindow : public LLSysWellWindow
 	void onItemClick(LLSysWellItem* item);
 	void onItemClose(LLSysWellItem* item);
 
-	// ID of a toast loaded by user (by clicking notification well item)
-	LLUUID mLoadedToastId;
-
 };
 
 /**
diff --git a/indra/newview/llteleporthistorystorage.cpp b/indra/newview/llteleporthistorystorage.cpp
index c635f914239..d3bbda1c72c 100644
--- a/indra/newview/llteleporthistorystorage.cpp
+++ b/indra/newview/llteleporthistorystorage.cpp
@@ -246,6 +246,13 @@ void LLTeleportHistoryStorage::goToItem(S32 idx)
 		dump();
 		return;
 	}
+	
+	if (idx == (S32)mItems.size() - 1)
+	{
+		llwarns << "Will not teleport to the same location." << llendl;
+		dump();
+		return;
+	}
 
 	// Attempt to teleport to the requested item.
 	gAgent.teleportViaLocation(mItems[idx].mGlobalPos);
diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp
index d0c125eb771..766cf83a012 100644
--- a/indra/newview/lltoastnotifypanel.cpp
+++ b/indra/newview/lltoastnotifypanel.cpp
@@ -179,9 +179,7 @@ void LLToastNotifyPanel::adjustPanelForScriptNotice(const LLNotificationFormPtr
 	//adjust layout
 	LLRect button_rect = mControlPanel->getRect();
 	reshape(getRect().getWidth(), mInfoPanel->getRect().getHeight() + button_panel_height);
-	button_rect.set(0, button_rect.mBottom + button_panel_height, button_rect.getWidth(), button_rect.mBottom);
 	mControlPanel->reshape(button_rect.getWidth(), button_panel_height);
-	mControlPanel->setRect(button_rect);
 }
 
 // static
@@ -219,7 +217,7 @@ LLButton* LLToastNotifyPanel::addButton(const std::string& name, const std::stri
 	S32 ignore_pad = 0;
 	S32 button_index = mNumButtons;
 	S32 index = button_index;
-	S32 x = HPAD * 2; // *2 - to make a nice offset
+	S32 x = (HPAD * 4) + 32;
 
 	if (mIsScriptDialog)
 	{
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index b16134cc28e..66451f47a30 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1005,7 +1005,7 @@ void render_hud_attachments()
 
 LLRect get_whole_screen_region()
 {
-	LLRect whole_screen = gViewerWindow->getWorldViewRectScaled();
+	LLRect whole_screen = gViewerWindow->getWindowRectScaled();
 	
 	// apply camera zoom transform (for high res screenshots)
 	F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor();
@@ -1013,13 +1013,13 @@ LLRect get_whole_screen_region()
 	if (zoom_factor > 1.f)
 	{
 		S32 num_horizontal_tiles = llceil(zoom_factor);
-		S32 tile_width = llround((F32)gViewerWindow->getWorldViewWidthScaled() / zoom_factor);
-		S32 tile_height = llround((F32)gViewerWindow->getWorldViewHeightScaled() / zoom_factor);
+		S32 tile_width = llround((F32)gViewerWindow->getWindowWidthScaled() / zoom_factor);
+		S32 tile_height = llround((F32)gViewerWindow->getWindowHeightScaled() / zoom_factor);
 		int tile_y = sub_region / num_horizontal_tiles;
 		int tile_x = sub_region - (tile_y * num_horizontal_tiles);
 		glh::matrix4f mat;
 		
-		whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWorldViewHeightScaled() - (tile_y * tile_height), tile_width, tile_height);
+		whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWindowHeightScaled() - (tile_y * tile_height), tile_width, tile_height);
 	}
 	return whole_screen;
 }
@@ -1039,12 +1039,12 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
 		F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect();
 		
 		glh::matrix4f mat;
-		F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth();
-		F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight();
+		F32 scale_x = (F32)gViewerWindow->getWindowWidthScaled() / (F32)screen_region.getWidth();
+		F32 scale_y = (F32)gViewerWindow->getWindowHeightScaled() / (F32)screen_region.getHeight();
 		mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f));
 		mat.set_translate(
-			glh::vec3f(clamp_rescale((F32)screen_region.getCenterX(), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
-					   clamp_rescale((F32)screen_region.getCenterY(), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
+			glh::vec3f(clamp_rescale((F32)screen_region.getCenterX(), 0.f, (F32)gViewerWindow->getWindowWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
+					   clamp_rescale((F32)screen_region.getCenterY(), 0.f, (F32)gViewerWindow->getWindowHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
 					   0.f));
 		proj *= mat;
 		
@@ -1294,8 +1294,8 @@ void render_ui_2d()
 	if (gAgent.getAvatarObject() && gAgent.mHUDCurZoom < 0.98f)
 	{
 		glPushMatrix();
-		S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2);
-		S32 half_height = (gViewerWindow->getWorldViewHeightScaled() / 2);
+		S32 half_width = (gViewerWindow->getWindowWidthScaled() / 2);
+		S32 half_height = (gViewerWindow->getWindowHeightScaled() / 2);
 		glScalef(LLUI::sGLScaleFactor.mV[0], LLUI::sGLScaleFactor.mV[1], 1.f);
 		glTranslatef((F32)half_width, (F32)half_height, 0.f);
 		F32 zoom = gAgent.mHUDCurZoom;
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 0edd4ac0256..801c2d0fd24 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -107,6 +107,7 @@
 #include "llfloateruipreview.h"
 #include "llfloaterurldisplay.h"
 #include "llfloatervoicedevicesettings.h"
+#include "llfloatervolumepulldown.h"
 #include "llfloaterwater.h"
 #include "llfloaterwhitelistentry.h"
 #include "llfloaterwindlight.h"
@@ -117,7 +118,6 @@
 #include "llinspectgroup.h"
 #include "llinspectobject.h"
 #include "llinspectremoteobject.h"
-#include "llinspecttoast.h"
 #include "llmediaremotectrl.h"
 #include "llmoveview.h"
 #include "llnearbychat.h"
@@ -189,7 +189,6 @@ void LLViewerFloaterReg::registerFloaters()
 	LLInspectGroupUtil::registerFloater();
 	LLInspectObjectUtil::registerFloater();
 	LLInspectRemoteObjectUtil::registerFloater();
-	LLNotificationsUI::registerFloater();
 	
 	LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>);
 	LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>);
@@ -261,7 +260,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
 	LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
 	LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
-
+	LLFloaterReg::add("volume_pulldown", "floater_volume_pulldown.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVolumePulldown>);
 	LLFloaterReg::add("voice_controls", "floater_voice_controls.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLCallFloater>);
 	
 	LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>);	
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 43c75748300..42c45589c08 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -904,19 +904,7 @@ void open_inventory_offer(const std::vector<LLUUID>& items, const std::string& f
 						LLPanelPlaces *places_panel = dynamic_cast<LLPanelPlaces*>(LLSideTray::getInstance()->showPanel("panel_places", LLSD()));
 						if (places_panel)
 						{
-							// we are creating a landmark
-							if("create_landmark" == places_panel->getPlaceInfoType() && !places_panel->getItem())
-							{
-								places_panel->setItem(item);
-							}
-							// we are opening a group notice attachment
-							else
-							{
-								LLSD args;
-								args["type"] = "landmark";
-								args["id"] = item_id;
-								LLSideTray::getInstance()->showPanel("panel_places", args);
-							}
+							places_panel->setItem(item);
 						}
 					}
 				}
@@ -1110,6 +1098,28 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 		gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,_4,this));
 	}
 
+	// *NOTE dzaporozhan
+	// Restored from viewer-1-23 to fix EXT-3520
+	// Saves Group Notice Attachments to inventory.
+	LLMessageSystem* msg = gMessageSystem;
+	msg->newMessageFast(_PREHASH_ImprovedInstantMessage);
+	msg->nextBlockFast(_PREHASH_AgentData);
+	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+	msg->nextBlockFast(_PREHASH_MessageBlock);
+	msg->addBOOLFast(_PREHASH_FromGroup, FALSE);
+	msg->addUUIDFast(_PREHASH_ToAgentID, mFromID);
+	msg->addU8Fast(_PREHASH_Offline, IM_ONLINE);
+	msg->addUUIDFast(_PREHASH_ID, mTransactionID);
+	msg->addU32Fast(_PREHASH_Timestamp, NO_TIMESTAMP); // no timestamp necessary
+	std::string name;
+	LLAgentUI::buildFullname(name);
+	msg->addStringFast(_PREHASH_FromAgentName, name);
+	msg->addStringFast(_PREHASH_Message, ""); 
+	msg->addU32Fast(_PREHASH_ParentEstateID, 0);
+	msg->addUUIDFast(_PREHASH_RegionID, LLUUID::null);
+	msg->addVector3Fast(_PREHASH_Position, gAgent.getPositionAgent());
+
 	std::string from_string; // Used in the pop-up.
 	std::string chatHistory_string;  // Used in chat history.
 	
@@ -1145,10 +1155,8 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 				}
 			}
 			break;
-		case IM_GROUP_NOTICE:
-			send_auto_receive_response();
-			break;
 		case IM_TASK_INVENTORY_OFFERED:
+		case IM_GROUP_NOTICE:
 		case IM_GROUP_NOTICE_REQUESTED:
 			// This is an offer from a task or group.
 			// We don't use a new instance of an opener
@@ -1163,6 +1171,10 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 		// end switch (mIM)
 			
 	case IOR_ACCEPT:
+		msg->addU8Fast(_PREHASH_Dialog, (U8)(mIM + 1));
+		msg->addBinaryDataFast(_PREHASH_BinaryBucket, &(mFolderID.mData), sizeof(mFolderID.mData));
+		msg->sendReliable(mHost);
+
 		//don't spam them if they are getting flooded
 		if (check_offer_throttle(mFromName, true))
 		{
@@ -1185,10 +1197,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 			{
 				chat.mMuted = TRUE;
 			}
-
-			// *NOTE dzaporozhan
-			// Disabled logging to old chat floater to fix crash in group notices - EXT-4149
-			// LLFloaterChat::addChatHistory(chat);
+			LLFloaterChat::addChatHistory(chat);
 			
 			LLInventoryFetchComboObserver::folder_ref_t folders;
 			LLInventoryFetchComboObserver::item_ref_t items;
@@ -1759,9 +1768,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 		}
 		else if (from_id.isNull())
 		{
-			LLSD args;
-			args["MESSAGE"] = message;
-			LLNotificationsUtil::add("SystemMessage", args);
+			// Messages from "Second Life" ID don't go to IM history
+			// messages which should be routed to IM window come from a user ID with name=SYSTEM_NAME
+			chat.mText = name + ": " + message;
+			LLFloaterChat::addChat(chat, FALSE, FALSE);
 		}
 		else if (to_id.isNull())
 		{
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 33bfee798a1..9285ab94dcb 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -604,6 +604,7 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 {
 	const char* buttonname = "";
 	const char* buttonstatestr = "";
+	BOOL handled = FALSE;	
 	S32 x = pos.mX;
 	S32 y = pos.mY;
 	x = llround((F32)x / mDisplayScale.mV[VX]);
@@ -698,10 +699,7 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 		}
 		else
 		{
-			if (top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask))
-			{
-				return TRUE;
-			}
+			handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask);
 		}
 	}
 
@@ -719,12 +717,34 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 		llinfos << buttonname << " Mouse " << buttonstatestr << " not handled by view" << llendl;
 	}
 
-	// Do not allow tool manager to handle mouseclicks if we have disconnected	
-	if(!gDisconnected && LLToolMgr::getInstance()->getCurrentTool()->handleAnyMouseClick( x, y, mask, clicktype, down ) )
+	if (down)
 	{
-		return TRUE;
+		if (gDisconnected)
+		{
+			return FALSE;
+		}
+	
+		if(LLToolMgr::getInstance()->getCurrentTool()->handleAnyMouseClick( x, y, mask, clicktype, down ) )
+		{
+			return TRUE;
+		}
 	}
+	else
+	{
+		if( !handled )
+		{
+			handled = mRootView->handleAnyMouseClick(x, y, mask, clicktype, down);
+		}
 	
+		if( !handled )
+		{
+			LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
+			if (tool)
+			{
+				handled = tool->handleAnyMouseClick(x, y, mask, clicktype, down);
+			}
+		}
+	}
 
 	// If we got this far on a down-click, it wasn't handled.
 	// Up-clicks, though, are always handled as far as the OS is concerned.
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 42b8a1c2b6b..423c46e14c7 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -5004,17 +5004,6 @@ LLVoiceClient::participantMap *LLVoiceClient::getParticipantList(void)
 	return result;
 }
 
-void LLVoiceClient::getParticipantsUUIDSet(std::set<LLUUID>& participant_uuids)
-{
-	if (NULL == mAudioSession) return;
-
-	participantUUIDMap::const_iterator it = mAudioSession->mParticipantsByUUID.begin(),
-		it_end = mAudioSession->mParticipantsByUUID.end();
-	for (; it != it_end; ++it)
-	{
-		participant_uuids.insert((*(*it).first));
-	}
-}
 
 LLVoiceClient::participantState *LLVoiceClient::sessionState::findParticipant(const std::string &uri)
 {
diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h
index 6231c6ba29f..724179847dc 100644
--- a/indra/newview/llvoiceclient.h
+++ b/indra/newview/llvoiceclient.h
@@ -354,7 +354,6 @@ static	void updatePosition(void);
 
 		participantState *findParticipantByID(const LLUUID& id);
 		participantMap *getParticipantList(void);
-		void getParticipantsUUIDSet(std::set<LLUUID>& participant_uuids);
 		
 		typedef std::map<const std::string*, sessionState*, stringMapComparitor> sessionMap;
 		typedef std::set<sessionState*> sessionSet;
diff --git a/indra/newview/skins/default/textures/bottomtray/Unread_Chiclet.png b/indra/newview/skins/default/textures/bottomtray/Unread_Chiclet.png
index 6343ddf035a738440af60dbc13317f33587e39db..447e0af0be61761287ef55d611d7e96428174a53 100644
GIT binary patch
delta 199
zcmV;&067210{Q`v7YYjq1^@s6Pldc<ks&C5oJmAMRCwBA{Qv(y0}43EXagiAfH)Y4
zd5~mM8SMYRfN>b%8V@oW0Lg5qCS2eM5HAE70MU4m(F3Z981My%3mN|(06S+knzIOj
zBTP^Yq-X*G6(*?FUr5w=hY9G>FJKQ74?rQi5It0z3Hc2csw~LXqnXNp7BwjG$O5%8
z4HP)#NQ!m>6|KQ%H4D^<<<OA51J$&HkVgRm3;>Z+G{?neYefJ6002ovPDHLkV1lF7
BN>u;=

delta 278
zcmV+x0qOqw0muT77YYst1^@s6A4o0Hks&C5>PbXFRCwBA{Qv(y137>ZS>xPC&)9&J
zJrFAbu`v+;0^+kkyf0Z!>Jf&<8TTJD1KF8CTmi(=I4s!##043O@;BicC*8ii6v&Pu
z!i8Ue*e6d_^&n&Cl}jKEOG)tFYamu)`SI(AABo{23dDXa-+z7MBqLBIfEvGV1(`s9
zqQ>Lkz)9b;ZVQm(O{AvjGhKqRSU@bGtr0+~1&H(UX!r}#1d0-j1Q5Dmt`?Arg<?>A
zf+GDg6wg{6kbEC&%7FpDRa1`vDIp*>-xQYp5u5ca=mH+g`aynu2gLq6q6$9}l~zds
c009O7nMqhi-AyM#00000NkvXXu0mh|f^X<`2LJ#7

diff --git a/indra/newview/skins/default/textures/bottomtray/WellButton_Lit.png b/indra/newview/skins/default/textures/bottomtray/WellButton_Lit.png
index 661d1c5611030be801d620730b1979c79e474a09..dd9133bcc463fe3303ae364bdd381ae3132f66a0 100644
GIT binary patch
delta 526
zcmaFGyplz+Gr-TCmrII^fq{Y7)59eQNGk%dI0rM3+$4GJ?L<ZOdWJs%J|V7c;c_J|
zg41#>JE9bTKvYyzM@L6cP*6@zPD)BjNJvOoS-H@WTSq~x%w4F)Uq(qusl-)KTU)y^
zLao9}q&-TxF-SVgUMSm1tUf@hE>N~TLcYpNxF=CZQBko!MYl6nqtZvpL`$hJS+5~T
zwmU(~z`#IOR<^%BS-&e@vol7uEkdz1Lb)+mF3(X&US7U6!7$T7*ic<wPfu@po^^$%
za95maXN+=Nlxlsfc}u8VwYP|{uy9wbnzXcZU65R<n^0@Gd`FT=wVzC(16R2#Ph+5X
zgTHuFuw<=|NQnzii8FUwxNMmVceR&LONg|gp<#hNXOUw)mw<r4m$Wacz#w5Q3Gxg6
z4+IRqxA6so!pPIbF{I*F&!wZHOpXE!7unK8qwm}Wg2aT+=UJ^9ULLo<zOiBDq&zN-
zNv9-M-1NM!b?MzU36I-XPN*4u$t(*vWhfB+!f3`$>xEfG2EzJI4Bdxj1{_{gq>{72
zV?IZ)&N1;6CxPx?lLZbYm8$;Om?6Vqtn-QANv8Wnufc&se-(H9(=Mw%^ebFrruo6e
z#S;$k6+U>8A>(y!g6oQxQ&JO7K8>l^bnS6j!kG_ZJ3DeVtY=_mF#EK5GEaKwe4z6g
NJYD@<);T3K0RSRgwgCVD

delta 463
zcmV;=0Wkil1nL7JiBL{Q4GJ0x0000DNk~Le0000W0000N2nGNE0BQwI;gKOHe*uh1
zL_t(|+QgMHOT$nQfbZqKBt<2Hx(MQ+TS0NDi&ZFvy0pKhn{?0Af8r!KI0;&WIyksF
zxM(LqA=275&AaElnA+-|>yd-^rtj{%dqfyxKnM{4K#g*n(w_5-gz}m4lGvY$;2WjN
z@mZyQy1%-<wgL<>91P;C^NSL(e?ujutd{Gw1Mpq%?c+U0gC<WnL80LJ&Ji&mZtkjz
zH0*#9>T5LAb{rf*EOcFE*}Do6ecQA~%|o|AB!yBC+g0{%wc8IEV>;@z0Ikum8c3OP
zRsgjRhF3t!oEe~DXwtxHKuY*y02gb(&<-H)4rCpt1q}Lq7{y~&1BvI)e+)QEqC~~I
z1H_!)0s9Dem%uWA3&<(}<}I8v@N?xg0RIfYLJcfn1XG@J9A|8R*?-0(_QVN-pcfBE
zF<k`P6C{>p68l9p8jVi3bH7(C9~S+B=d%2YH71X@-6zWyGz-~ox3|JDJc*)cGf9%A
zoV(Z5`D?4yx^6a`J&`SgB}2JP>1OA=$3LO$TN&R13;>Yp<c70)<_Q1*002ovPDHLk
FV1mZ)&r$#Y

diff --git a/indra/newview/skins/default/textures/bottomtray/WellButton_Lit_Selected.png b/indra/newview/skins/default/textures/bottomtray/WellButton_Lit_Selected.png
index f927fd3989b32ab663cdc45f238f1158ee2b0638..0080e71f4191729d2902dc07d49329c185833100 100644
GIT binary patch
delta 661
zcmV;G0&4xP0<Q%jiBL{Q4GJ0x0000DNk~Le0000X0000N2m=5B0J0g@?U5lTe*sWX
zOjJc}K^9go3m_mM2?+@-EG$(m3rHgZIwTY~A`=i05FH&IQYiybC<7uQA{-nX6%`dm
zAp%4o0wW_M3JMBcGYoJ;7FH_+Y(N%QFbi5U5LYb(X+IW6FC9}g86F-UWH}F8G7M8N
z6HF)yVKoaQ92Z$K4?-#$L@**<e>N0NHYILE8)!TdSu+x6JQOW0Em|%HVmTCNJP}GM
z3r998NH8BZArfam8#yBsRW1xS9SIl_3}iSC6ciLf9|A-z98@zFVmAzFJ{DOq3{E^Q
zTr>=9K^Rm%ElDvTQ7Q>YG9qn48CEY19~l!WDk?!A1Zh4LKQbmuG$BGOe;QFM3@jN7
zD=RBhDg+M?4^%7)8xsv?I}-~F3k(blU^^KW78WotFmgo}RX{CYI2C6(3~oRZX*>^a
zK@?~^4QxIUTQ3DMF)>&y1X?ZxUNHq-Fa-z*2+JL_;{X5v19VbOQ~&<}*UAk+0002y
zNkl<Zc-mrM;^K_X#{rnbf4P{L82D6-o!t^~08Jk`CI-%cKzofO93WPfUx<NOUC}_C
z0S6E_6J}w^_tfzhO~3&}weqtV^4%r1({KVWkO~u3!xWsr6{JGOTRsCPkOrx+v#?IZ
z2^>Kxf+8H!aRObC3N;VqWSk%hq{5s{Di0@c0jXeT%g)6KM2J)&YaoW(76p(B4uP;t
zoWKdJLXbNLCy*dY1+%FwPc}}#D4fN>8REwyhD(9I5q}l~pOvK&D=Q;bz#1Is%fi6K
v6c>XtCEMs_2?15`hQ?>%0xY~t009O7&a(liW03Bh00000NkvXXu0mjfIwiIW

delta 273
zcmV+s0q*{<1+D@iiBL{Q4GJ0x0000DNk~Le0000U0000K2m$~A02Rp^laV1Oe*n-)
zL_t(|+O(9h3c^4TL@$?(V4;GAjg=rml%W6r6N05b5Rh1T9>ipK+)E+Y?+we9k70K9
z=y+~+r+Tqk3d9*HhWGt?qy423;PLDrX6Ta2ZG9jV2qD11*+~Yesu_uZ?fm`(K+z&>
zk7j1lhz%F`=NgHf0WCZQlEJk?XKB=^neDSKHEZn$!`?LueUf@}bm2hyq{+Z0y>cD<
zK&J8~W$JY<w0GG=n8MC*jUZOC%dkc*Umv3{yzMvQy_aF6SKG}uYpN>K9ZGDUUjYUH
XIkBEHgwRw600000NkvXXu0mjf8g_O?

diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index cfa7479fa98..db60b90a930 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -224,7 +224,7 @@ with the same filename but different name
            scale.left="4" scale.top="28" scale.right="60" scale.bottom="4" />
   <texture name="Inspector_Hover" file_name="windows/Inspector_Hover.png" preload="false" />
   <texture name="Inspector_I" file_name="windows/Inspector_I.png" preload="false" />
-
+  
   <texture name="Inv_Acessories" file_name="icons/Inv_Accessories.png" preload="false" />
   <texture name="Inv_Alpha" file_name="icons/Inv_Alpha.png" preload="false" />
   <texture name="Inv_Animation" file_name="icons/Inv_Animation.png" preload="false" />
@@ -650,12 +650,6 @@ with the same filename but different name
   <texture name="PowerOff_Over" file_name="icons/PowerOff_Over.png" preload="false" />
   <texture name="PowerOff_Press" file_name="icons/PowerOff_Press.png" preload="false" />
 
-  <texture name="pixiesmall.j2c" use_mips="true" />
-  <texture name="script_error.j2c" use_mips="true" />
-  <texture name="silhouette.j2c" use_mips="true" />
-  <texture name="foot_shadow.j2c" use_mips="true" />
-  <texture name="cloud-particle.j2c" use_mips="true" />
-
   <!--WARNING OLD ART BELOW *do not use*-->
   <texture name="icn_chatbar.tga" />
   <texture name="icn_media_web.tga" preload="true" />
@@ -684,6 +678,8 @@ with the same filename but different name
 
   <texture name="toggle_button_off" file_name="toggle_button_off.png" preload="true" />
   <texture name="toggle_button_selected" file_name="toggle_button_selected.png" preload="true" />
+
+  <texture name="sm_rounded_corners_simple.tga" scale.left="4" scale.top="4" scale.bottom="4" scale.right="4" />
   <texture name="color_swatch_alpha.tga" preload="true" />
 
   <texture name="button_anim_pause.tga" />
@@ -702,6 +698,7 @@ with the same filename but different name
   <texture name="icon_event_mature.tga" />
   <texture name="icon_for_sale.tga" />
   <texture name="icon_place_for_sale.tga" />
+  <texture name="icon_popular.tga" />
   <texture name="icon_top_pick.tga" />
 
   <texture name="inv_folder_mesh.tga"/>
@@ -722,10 +719,27 @@ with the same filename but different name
   <texture name="map_telehub.tga" />
   <texture name="map_track_16.tga" />
 
+  <texture name="media_icon.tga" file_name="icn_label_media.tga" />
+  <texture name="music_icon.tga" file_name="icn_label_music.tga" />
+
+  <texture name="notify_tip_icon.tga" />
   <texture name="notify_caution_icon.tga" />
   <texture name="notify_next.png" preload="true" />
   <texture name="notify_box_icon.tga" />
 
+  <texture name="pixiesmall.j2c" use_mips="true" />
+  <texture name="script_error.j2c" use_mips="true" />
+  <texture name="silhouette.j2c" use_mips="true" />
+  <texture name="foot_shadow.j2c" use_mips="true" />
+  <texture name="cloud-particle.j2c" use_mips="true" />
+
+  <texture name="status_no_build.tga" />
+  <texture name="status_voice.tga" />
+  <texture name="status_no_fly.tga" />
+  <texture name="status_health.tga" />
+  <texture name="status_no_push.tga" />
+  <texture name="status_no_scripts.tga" />
+
   <texture name="icn_active-speakers-dot-lvl0.tga" />
   <texture name="icn_active-speakers-dot-lvl1.tga" />
   <texture name="icn_active-speakers-dot-lvl2.tga" />
diff --git a/indra/newview/skins/default/xui/de/floater_buy_currency.xml b/indra/newview/skins/default/xui/de/floater_buy_currency.xml
index c320e796c20..3c336cc40b0 100644
--- a/indra/newview/skins/default/xui/de/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/de/floater_buy_currency.xml
@@ -46,7 +46,7 @@
 		[AMT] L$
 	</text>
 	<text name="currency_links">
-		[http://www.secondlife.com/my/account/payment_method_management.php?lang=de-DE payment method] | [http://www.secondlife.com/my/account/currency.php?lang=de-DE currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=de-DE exchange rate]
+		[http://www.secondlife.com/ payment method] | [http://www.secondlife.com/ currency] | [http://www.secondlife.com exchange rate]
 	</text>
 	<text name="exchange_rate_note">
 		Geben Sie den Betrag erneut ein, um die aktuellste Umtauschrate anzuzeigen.
diff --git a/indra/newview/skins/default/xui/de/floater_help_browser.xml b/indra/newview/skins/default/xui/de/floater_help_browser.xml
index 2344d6f412a..53bddcced13 100644
--- a/indra/newview/skins/default/xui/de/floater_help_browser.xml
+++ b/indra/newview/skins/default/xui/de/floater_help_browser.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <floater name="floater_help_browser" title="HILFE-BROWSER">
 	<floater.string name="home_page_url">
-		http://de.secondlife.com
+		http://www.secondlife.com
 	</floater.string>
 	<floater.string name="support_page_url">
-		http://de.secondlife.com/support
+		http://support.secondlife.com
 	</floater.string>
 	<layout_stack name="stack1">
 		<layout_panel name="external_controls">
diff --git a/indra/newview/skins/default/xui/de/strings.xml b/indra/newview/skins/default/xui/de/strings.xml
index e93a38f187a..809ac33e154 100644
--- a/indra/newview/skins/default/xui/de/strings.xml
+++ b/indra/newview/skins/default/xui/de/strings.xml
@@ -166,7 +166,7 @@
 	<string name="TooltipSLAPP">
 		Anklicken, um Befehl secondlife:// auszuführen
 	</string>
-	<string name="CurrentURL" value=" CurrentURL: [CurrentURL]"/>
+	<string name="CurrentURL" value="CurrentURL: [CurrentURL]"/>
 	<string name="SLurlLabelTeleport">
 		Teleportieren nach
 	</string>
@@ -821,46 +821,46 @@
 	<string name="InventoryNoTexture">
 		Sie haben keine Kopie dieser Textur in Ihrem Inventar.
 	</string>
-	<string name="no_transfer" value=" (kein Transferieren)"/>
-	<string name="no_modify" value=" (kein Bearbeiten)"/>
-	<string name="no_copy" value=" (kein Kopieren)"/>
-	<string name="worn" value=" (getragen)"/>
-	<string name="link" value=" (Link)"/>
-	<string name="broken_link" value=" (unvollständiger_Link)"/>
+	<string name="no_transfer" value="(kein Transferieren)"/>
+	<string name="no_modify" value="(kein Bearbeiten)"/>
+	<string name="no_copy" value="(kein Kopieren)"/>
+	<string name="worn" value="(getragen)"/>
+	<string name="link" value="(Link)"/>
+	<string name="broken_link" value="(unvollständiger_Link)"/>
 	<string name="LoadingContents">
 		Inhalte werden geladen...
 	</string>
 	<string name="NoContents">
 		Keine Inhalte
 	</string>
-	<string name="WornOnAttachmentPoint" value=" (getragen am [ATTACHMENT_POINT])"/>
+	<string name="WornOnAttachmentPoint" value="(getragen am [ATTACHMENT_POINT])"/>
 	<string name="PermYes">
 		Ja
 	</string>
 	<string name="PermNo">
 		Nein
 	</string>
-	<string name="Chat" value=" Chat:"/>
-	<string name="Sound" value=" Sound:"/>
-	<string name="Wait" value=" --- Warten:"/>
-	<string name="AnimFlagStop" value=" Animation stoppen:"/>
-	<string name="AnimFlagStart" value=" Animation starten:"/>
-	<string name="Wave" value=" Winken"/>
-	<string name="HelloAvatar" value=" Hallo Avatar!"/>
-	<string name="ViewAllGestures" value="  Alle anzeigen &gt;&gt;"/>
-	<string name="Animations" value=" Animationen,"/>
-	<string name="Calling Cards" value=" Visitenkarten,"/>
-	<string name="Clothing" value=" Kleidung,"/>
-	<string name="Gestures" value=" Gesten,"/>
-	<string name="Landmarks" value=" Landmarken,"/>
-	<string name="Notecards" value=" Notizkarten,"/>
-	<string name="Objects" value=" Objekte,"/>
-	<string name="Scripts" value=" Skripts,"/>
-	<string name="Sounds" value=" Sounds,"/>
-	<string name="Textures" value=" Texturen,"/>
-	<string name="Snapshots" value=" Fotos,"/>
-	<string name="No Filters" value="Nein "/>
-	<string name="Since Logoff" value=" - Seit Abmeldung"/>
+	<string name="Chat" value="Chat:"/>
+	<string name="Sound" value="Sound:"/>
+	<string name="Wait" value="--- Warten:"/>
+	<string name="AnimFlagStop" value="Animation stoppen:"/>
+	<string name="AnimFlagStart" value="Animation starten:"/>
+	<string name="Wave" value="Winken"/>
+	<string name="HelloAvatar" value="Hallo Avatar!"/>
+	<string name="ViewAllGestures" value="Alle anzeigen &gt;&gt;"/>
+	<string name="Animations" value="Animationen,"/>
+	<string name="Calling Cards" value="Visitenkarten,"/>
+	<string name="Clothing" value="Kleidung,"/>
+	<string name="Gestures" value="Gesten,"/>
+	<string name="Landmarks" value="Landmarken,"/>
+	<string name="Notecards" value="Notizkarten,"/>
+	<string name="Objects" value="Objekte,"/>
+	<string name="Scripts" value="Skripts,"/>
+	<string name="Sounds" value="Sounds,"/>
+	<string name="Textures" value="Texturen,"/>
+	<string name="Snapshots" value="Fotos,"/>
+	<string name="No Filters" value="Nein"/>
+	<string name="Since Logoff" value="- Seit Abmeldung"/>
 	<string name="InvFolder My Inventory">
 		Mein Inventar
 	</string>
@@ -1239,13 +1239,13 @@
 	<string name="GroupsNone">
 		keine
 	</string>
-	<string name="Group" value=" (Gruppe)"/>
+	<string name="Group" value="(Gruppe)"/>
 	<string name="Unknown">
 		(unbekannt)
 	</string>
-	<string name="SummaryForTheWeek" value="Zusammenfassung für diese Woche, beginnend am "/>
-	<string name="NextStipendDay" value="Der nächste Stipendium-Tag ist "/>
-	<string name="GroupIndividualShare" value="                      Gruppenanteil       Einzelanteil"/>
+	<string name="SummaryForTheWeek" value="Zusammenfassung für diese Woche, beginnend am"/>
+	<string name="NextStipendDay" value="Der nächste Stipendium-Tag ist"/>
+	<string name="GroupIndividualShare" value="Gruppenanteil	Einzelanteil"/>
 	<string name="Balance">
 		Kontostand
 	</string>
@@ -1324,8 +1324,8 @@
 	<string name="covenant_last_modified">
 		Zuletzt geändert:
 	</string>
-	<string name="none_text" value=" (keiner)"/>
-	<string name="never_text" value=" (nie)"/>
+	<string name="none_text" value="(keiner)"/>
+	<string name="never_text" value="(nie)"/>
 	<string name="GroupOwned">
 		In Gruppenbesitz
 	</string>
@@ -1616,7 +1616,7 @@ Falls der Fehler dann weiterhin auftritt, müssen Sie [APP_NAME] von Ihrem Syste
 		Unbehebbarer Fehler
 	</string>
 	<string name="MBRequiresAltiVec">
-		 [APP_NAME] erfordert einen Prozessor mit AltiVec (G4 oder später).
+		[APP_NAME] erfordert einen Prozessor mit AltiVec (G4 oder später).
 	</string>
 	<string name="MBAlreadyRunning">
 		[APP_NAME] läuft bereits.
diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml
index 9806f45bc4f..82ed1a7d7fb 100644
--- a/indra/newview/skins/default/xui/en/floater_about.xml
+++ b/indra/newview/skins/default/xui/en/floater_about.xml
@@ -112,7 +112,7 @@ Packets Lost: [PACKETS_LOST,number,0]/[PACKETS_IN,number,0] ([PACKETS_PCT,number
        word_wrap="true">
 Second Life is brought to you by Philip, Tessa, Andrew, Cory, James, Ben, Char, Charlie, Colin, Dan, Daniel, Doug, Eric, Hamlet, Haney, Eve, Hunter, Ian, Jeff, Jennifer, Jim, John, Lee, Mark, Peter, Phoenix, Richard, Robin, Xenon, Steve, Tanya, Eddie, Avi, Frank, Bruce, Aaron, Alice, Bob, Debra, Eileen, Helen, Janet, Louie, Leviathania, Stefan, Ray, Kevin, Tom, Mikeb, MikeT, Burgess, Elena, Tracy, Bill, Todd, Ryan, Zach, Sarah, Nova, Tim, Stephanie, Michael, Evan, Nicolas, Catherine, Rachelle, Dave, Holly, Bub, Kelly, Magellan, Ramzi, Don, Sabin, Jill, Rheya, Jeska, Torley, Kona, Callum, Charity, Ventrella, Jack, Vektor, Iris, Chris, Nicole, Mick, Reuben, Blue, Babbage, Yedwab, Deana, Lauren, Brent, Pathfinder, Chadrick, Altruima, Jesse, Teeny, Monroe, Icculus, David, Tess, Lizzie, Patsy, Isaac, Lawrence, Cyn, Bo, Gia, Annette, Marius, Tbone, Jonathan, Karen, Ginsu, Satoko, Yuko, Makiko, Thomas, Harry, Seth, Alexei, Brian, Guy, Runitai, Ethan, Data, Cornelius, Kenny, Swiss, Zero, Natria, Wendy, Stephen, Teeple, Thumper, Lucy, Dee, Mia, Liana, Warren, Branka, Aura, beez, Milo, Hermia, Red, Thrax, Joe, Sally, Magenta, Mogura, Paul, Jose, Rejean, Henrik, Lexie, Amber, Logan, Xan, Nora, Morpheus, Donovan, Leyla, MichaelFrancis, Beast, Cube, Bucky, Joshua, Stryfe, Harmony, Teresa, Claudia, Walker, Glenn, Fritz, Fordak, June, Cleopetra, Jean, Ivy, Betsy, Roosevelt, Spike, Ken, Which, Tofu, Chiyo, Rob, Zee, dustin, George, Del, Matthew, Cat, Jacqui, Lightfoot, Adrian, Viola, Alfred, Noel, Irfan, Sunil, Yool, Rika, Jane, Xtreme, Frontier, a2, Neo, Siobhan, Yoz, Justin, Elle, Qarl, Benjamin, Isabel, Gulliver, Everett, Christopher, Izzy, Stephany, Garry, Sejong, Sean, Tobin, Iridium, Meta, Anthony, Jeremy, JP, Jake, Maurice, Madhavi, Leopard, Kyle, Joon, Kari, Bert, Belinda, Jon, Kristi, Bridie, Pramod, KJ, Socrates, Maria, Ivan, Aric, Yamasaki, Adreanne, Jay, MitchK, Ceren, Coco, Durl, Jenny, Periapse, Kartic, Storrs, Lotte, Sandy, Rohn, Colossus, Zen, BigPapi, Brad, Pastrami, Kurz, Mani, Neuro, Jaime, MJ, Rowan, Sgt, Elvis, Gecko, Samuel, Sardonyx, Leo, Bryan, Niko, Soft, Poppy, Rachel, Aki, Angelo, Banzai, Alexa, Sue, CeeLo, Bender, CG, Gillian, Pelle, Nick, Echo, Zara, Christine, Shamiran, Emma, Blake, Keiko, Plexus, Joppa, Sidewinder, Erica, Ashlei, Twilight, Kristen, Brett, Q, Enus, Simon, Bevis, Kraft, Kip, Chandler, Ron, LauraP, Ram, KyleJM, Scouse, Prospero, Melissa, Marty, Nat, Hamilton, Kend, Lordan, Jimmy, Kosmo, Seraph, Green, Ekim, Wiggo, JT, Rome, Doris, Miz, Benoc, Whump, Trinity, Patch, Kate, TJ, Bao, Joohwan, Christy, Sofia, Matias, Cogsworth, Johan, Oreh, Cheah, Angela, Brandy, Mango, Lan, Aleks, Gloria, Heidy, Mitchell, Space, Colton, Bambers, Einstein, Maggie, Malbers, Rose, Winnie, Stella, Milton, Rothman, Niall, Marin, Allison, Katie, Dawn, Katt, Dusty, Kalpana, Judy, Andrea, Ambroff, Infinity, Gail, Rico, Raymond, Yi, William, Christa, M, Teagan, Scout, Molly, Dante, Corr, Dynamike, Usi, Kaylee, Vidtuts, Lil, Danica, Sascha, Kelv, Jacob, Nya, Rodney, Brandon, Elsie, Blondin, Grant, Katrin, Nyx, Gabriel, Locklainn, Claire, Devin, Minerva, Monty, Austin, Bradford, Si, Keira, H, Caitlin, Dita, Makai, Jenn, Ann, Meredith, Clare, Joy, Praveen, Cody, Edmund, Ruthe, Sirena, Gayathri, Spider, FJ, Davidoff, Tian, Jennie, Louise, Oskar, Landon, Noelle, Jarv, Ingrid, Al, Sommer, Doc, Aria, Huin, Gray, Lili, Vir, DJ, Yang, T, Simone, Maestro, Scott, Charlene, Quixote, Amanda, Susan, Zed, Anne, Enkidu, Esbee, Joroan, Katelin, Roxie, Tay, Scarlet, Kevin, Johnny, Wolfgang, Andren, Bob, Howard, Merov, Rand, Ray, Michon, Newell, Galen, Dessie, Les and many others.
 
-Thank you to the following Residents for helping to ensure that this is the best version yet: (in progress)
+Thank you to the following residents for helping to ensure that this is the best version yet: (in progress)
 
 
 
diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml
index 900f4c5956a..33fdd923ad2 100644
--- a/indra/newview/skins/default/xui/en/floater_about_land.xml
+++ b/indra/newview/skins/default/xui/en/floater_about_land.xml
@@ -1036,7 +1036,7 @@ Leyla Linden               </text>
              name="Autoreturn"
              top="164"
              width="294">
-                Autoreturn other Residents&apos; objects (minutes, 0 for off):
+                Autoreturn other residents&apos; objects (minutes, 0 for off):
             </text>
             <line_editor
              border_style="line"
@@ -1175,7 +1175,7 @@ Only large parcels can be listed in search.
              name="allow_label"
              top="10"
              width="278">
-                Allow other Residents to:
+                Allow other residents to:
             </text>
             <check_box
              height="16"
@@ -1917,7 +1917,7 @@ Only large parcels can be listed in search.
              layout="topleft"
              left_delta="0"
              name="limit_payment"
-             tool_tip="Ban unidentified Residents."
+             tool_tip="Ban unidentified residents."
              top_pad="4"
              width="278" />
             <check_box
@@ -1927,7 +1927,7 @@ Only large parcels can be listed in search.
              layout="topleft"
              left_delta="0"
              name="limit_age_verified"
-             tool_tip="Ban Residents who have not verified their age. See the [SUPPORT_SITE] for more information."
+             tool_tip="Ban residents who have not verified their age. See the [SUPPORT_SITE] for more information."
              top_pad="4"
              width="278" />
             <check_box
diff --git a/indra/newview/skins/default/xui/en/floater_buy_currency.xml b/indra/newview/skins/default/xui/en/floater_buy_currency.xml
index d202bf1b9f1..86229c6691f 100644
--- a/indra/newview/skins/default/xui/en/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/en/floater_buy_currency.xml
@@ -107,7 +107,7 @@
      height="16"
      layout="topleft"
      top_delta="0"
-     left="217"
+     left="242"
      name="currency_label"
      width="15">
       L$
@@ -123,7 +123,7 @@
      label="L$"
      left_pad="3"
      name="currency_amt"
-     width="85">
+     width="60">
         1234
     </line_editor>
     <text
diff --git a/indra/newview/skins/default/xui/en/floater_customize.xml b/indra/newview/skins/default/xui/en/floater_customize.xml
index ddc0d9af729..0dc7d62b19f 100644
--- a/indra/newview/skins/default/xui/en/floater_customize.xml
+++ b/indra/newview/skins/default/xui/en/floater_customize.xml
@@ -260,9 +260,10 @@
              left="10"
              name="not worn instructions"
              top="31"
-             word_wrap="true"
              width="373">
-                Put on a new shape by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new shape by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -273,7 +274,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -300,7 +300,7 @@
              left="10"
              name="Create New"
              top="104"
-             width="160" />
+             width="140" />
             <button
              follows="right|bottom"
              height="23"
@@ -463,9 +463,10 @@
              left="10"
              name="not worn instructions"
              top="31"
-             word_wrap="true"
              width="373">
-                Put on a new skin by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new skin by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -476,7 +477,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -542,7 +542,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-249"
-             width="160" />
+             width="120" />
             <button
              follows="right|bottom"
              height="23"
@@ -713,9 +713,10 @@
              left="10"
              name="not worn instructions"
              top="31"
-             word_wrap="true"
              width="373">
-                Put on a new hair by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new hair by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -726,7 +727,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -765,7 +765,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-89"
-             width="160" />
+             width="120" />
             <button
              follows="right|bottom"
              height="23"
@@ -898,9 +898,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on a new set of eyes by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new eyes by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -911,7 +912,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -950,7 +950,7 @@
              left_delta="0"
              name="Create New"
              top_delta="39"
-             width="160" />
+             width="120" />
             <button
              follows="right|bottom"
              height="23"
@@ -1056,7 +1056,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="160" />
+             width="120" />
             <button
              follows="left|top"
              height="23"
@@ -1170,9 +1170,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on a new shirt by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new shirt by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -1183,7 +1184,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1262,7 +1262,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="160" />
+             width="120" />
             <button
              follows="left|top"
              height="23"
@@ -1376,9 +1376,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on new pants by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new pants by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -1389,7 +1390,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1509,9 +1509,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on a new pair of shoes by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new shoes by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -1522,7 +1523,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1572,7 +1572,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="160" />
+             width="120" />
             <button
              follows="left|top"
              height="23"
@@ -1715,9 +1715,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on new socks by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new socks by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -1728,7 +1729,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1778,7 +1778,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="160" />
+             width="120" />
             <button
              follows="left|top"
              height="23"
@@ -1921,9 +1921,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on a new jacket by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new jacket by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -1934,7 +1935,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1996,7 +1996,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-121"
-             width="160" />
+             width="140" />
             <button
              follows="left|top"
              height="23"
@@ -2139,9 +2139,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on new gloves by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new gloves by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -2152,7 +2153,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -2202,7 +2202,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="160" />
+             width="130" />
             <button
              follows="left|top"
              height="23"
@@ -2345,9 +2345,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on a new undershirt by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new undershirt by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -2358,7 +2359,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -2551,9 +2551,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on new underpants by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new underpants by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -2564,7 +2565,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -2757,9 +2757,10 @@
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
-             word_wrap="true"
              width="373">
-                Put on a new skirt by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new skirt by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -2770,7 +2771,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -2820,7 +2820,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="160" />
+             width="120" />
             <button
              follows="left|top"
              height="23"
@@ -2962,10 +2962,11 @@
              layout="topleft"
              left_delta="-2"
              name="not worn instructions"
-             top_pad="8"
-             word_wrap="true"
+             top_delta="2"
              width="373">
-                Put on a new alpha mask by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new alpha mask by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -2976,7 +2977,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -3108,7 +3108,7 @@
              left="8"
              name="Create New"
              top="104"
-             width="160" />
+             width="120" />
             <button
              follows="left|top"
              height="23"
@@ -3250,10 +3250,11 @@
              layout="topleft"
              left_delta="-2"
              name="not worn instructions"
-             top_pad="8"
-             word_wrap="true"
+             top_delta="2"
              width="373">
-                Put on a new tattoo by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
+                Put on a new tattoo by dragging one from your inventory
+to your avatar. Alternately, you create a new one from
+scratch and wear it.
             </text>
             <text
              type="string"
@@ -3264,7 +3265,6 @@
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
-             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -3327,7 +3327,7 @@
              left_delta="0"
              name="Create New"
              top_delta="-121"
-             width="160" />
+             width="120" />
             <button
              follows="left|top"
              height="23"
diff --git a/indra/newview/skins/default/xui/en/floater_god_tools.xml b/indra/newview/skins/default/xui/en/floater_god_tools.xml
index 0fac6cd5f17..b01c0edc8bc 100644
--- a/indra/newview/skins/default/xui/en/floater_god_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_god_tools.xml
@@ -123,7 +123,7 @@
              layout="topleft"
              left_delta="0"
              name="check reset home"
-             tool_tip="When Resident teleports out, reset their home to the destination position."
+             tool_tip="When resident teleports out, reset their home to the destination position."
              top_pad="4"
              width="180">
 			       <check_box.commit_callback
diff --git a/indra/newview/skins/default/xui/en/floater_im.xml b/indra/newview/skins/default/xui/en/floater_im.xml
index a21242ffe17..92a61117598 100644
--- a/indra/newview/skins/default/xui/en/floater_im.xml
+++ b/indra/newview/skins/default/xui/en/floater_im.xml
@@ -26,7 +26,7 @@
     </multi_floater.string>
     <multi_floater.string
      name="muted_message">
-        You have blocked this Resident. Sending a message will automatically unblock them.
+        You have blocked this resident. Sending a message will automatically unblock them.
     </multi_floater.string>
     <multi_floater.string
      name="generic_request_error">
diff --git a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
index ae686d9ab7a..920f0c909a7 100644
--- a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
+++ b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
@@ -4,8 +4,8 @@
  border_drop_shadow_visible="false"
  drop_shadow_visible="false"
  border="false"
- bg_opaque_image="Window_Foreground" 
- bg_alpha_image="Window_Background" 
+ bg_opaque_image="Inspector_Background"
+ bg_alpha_image="Toast_Background"
  bg_alpha_color="0 0 0 0"
  legacy_header_height="18"
  can_minimize="true"
diff --git a/indra/newview/skins/default/xui/en/floater_report_abuse.xml b/indra/newview/skins/default/xui/en/floater_report_abuse.xml
index aa219b96152..f1a75bfcb4d 100644
--- a/indra/newview/skins/default/xui/en/floater_report_abuse.xml
+++ b/indra/newview/skins/default/xui/en/floater_report_abuse.xml
@@ -201,11 +201,11 @@
          name="Age__Age_play"
          value="31" />
         <combo_box.item
-         label="Age &gt; Adult Resident on Teen Second Life"
+         label="Age &gt; Adult resident on Teen Second Life"
          name="Age__Adult_resident_on_Teen_Second_Life"
          value="32" />
         <combo_box.item
-         label="Age &gt; Underage Resident outside of Teen Second Life"
+         label="Age &gt; Underage resident outside of Teen Second Life"
          name="Age__Underage_resident_outside_of_Teen_Second_Life"
          value="33" />
         <combo_box.item
diff --git a/indra/newview/skins/default/xui/en/floater_select_key.xml b/indra/newview/skins/default/xui/en/floater_select_key.xml
index 4e89df5a735..93aa1f0e31a 100644
--- a/indra/newview/skins/default/xui/en/floater_select_key.xml
+++ b/indra/newview/skins/default/xui/en/floater_select_key.xml
@@ -15,12 +15,13 @@
      follows="left|top"
      height="30"
      layout="topleft"
-     left="30"
+     left="10"
      name="Save item as:"
      top="25"
      word_wrap="true"
-     width="180">
-        Press a key to set your Speak button trigger.
+     width="220">
+        Press a key to set your
+Speak button trigger.
     </text>
     <button
      height="23"
@@ -29,6 +30,5 @@
      layout="topleft"
      right="-10"
      name="Cancel"
-     top_pad="8"
      width="100" />
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_top_objects.xml b/indra/newview/skins/default/xui/en/floater_top_objects.xml
index b06c6dc215d..68bb500c785 100644
--- a/indra/newview/skins/default/xui/en/floater_top_objects.xml
+++ b/indra/newview/skins/default/xui/en/floater_top_objects.xml
@@ -9,7 +9,7 @@
  name="top_objects"
  help_topic="top_objects"
  title="Top Objects"
- width="800">
+ width="550">
     <floater.string
      name="top_scripts_title">
         Top Scripts
@@ -64,7 +64,7 @@
      multi_select="true"
      name="objects_list"
      top_delta="17"
-     width="780">
+     width="530">
         <scroll_list.columns
          label="Score"
          name="score"
@@ -84,15 +84,11 @@
         <scroll_list.columns
          label="Time"
          name="time"
-         width="150" />
+         width="100" />
         <scroll_list.columns
          label="Mono Time"
          name="mono_time"
-         width="100" />
-          <scroll_list.columns
-          	label="URLs"
-          	name="URLs"
-          	width="100" />
+         width="55" />
 		<scroll_list.commit_callback
           function="TopObjects.CommitObjectsList" />
     </scroll_list>
@@ -116,7 +112,7 @@
      left_pad="3"
      name="id_editor"
      top_delta="-3"
-     width="575" />
+     width="325" />
     <button
      follows="bottom|right"
      height="23"
@@ -148,7 +144,7 @@
      left_pad="3"
      name="object_name_editor"
      top_delta="-3"
-     width="575" />
+     width="325" />
     <button
      follows="bottom|right"
      height="23"
@@ -180,7 +176,7 @@
      left_pad="3"
      name="owner_name_editor"
      top_delta="-3"
-     width="575" />
+     width="325" />
     <button
      follows="bottom|right"
      height="23"
@@ -194,7 +190,7 @@
           function="TopObjects.GetByOwnerName" />
     </button>
     <button
-     follows="bottom|right"
+     follows="top|left"
      height="22"
      image_overlay="Refresh_Off"
      layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/floater_tos.xml b/indra/newview/skins/default/xui/en/floater_tos.xml
index 5e168fe4aa6..1adb824e2a6 100644
--- a/indra/newview/skins/default/xui/en/floater_tos.xml
+++ b/indra/newview/skins/default/xui/en/floater_tos.xml
@@ -49,9 +49,9 @@
      left_delta="0"
      name="tos_heading"
      top_delta="-399"
-     word_wrap="true"
      width="552">
-        Please read the following Terms of Service carefully. To continue logging in to [SECOND_LIFE], you must accept the agreement.
+        Please read the following Terms of Service carefully. To continue logging in to [SECOND_LIFE],
+you must accept the agreement.
     </text>
     <web_browser
      follows="left|top"
@@ -60,6 +60,6 @@
      left_delta="0"
      name="tos_html"
      start_url="data:text/html,%3Chtml%3E%3Chead%3E%3C/head%3E%3Cbody text=%22000000%22%3E%3Ch2%3E Loading %3Ca%20target%3D%22_external%22%20href%3D%22http%3A//secondlife.com/app/tos/%22%3ETerms%20of%20Service%3C/a%3E...%3C/h2%3E %3C/body%3E %3C/html%3E"
-     top_delta="40"
+     top_delta="0"
      width="568" />
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_voice_controls.xml b/indra/newview/skins/default/xui/en/floater_voice_controls.xml
index ae198d69a37..b9649e9c577 100644
--- a/indra/newview/skins/default/xui/en/floater_voice_controls.xml
+++ b/indra/newview/skins/default/xui/en/floater_voice_controls.xml
@@ -3,9 +3,9 @@
  can_resize="true"
  can_minimize="true"
  can_close="false"
- height="275"
+ height="270"
  layout="topleft"
- min_height="100"
+ min_height="122"
  min_width="190"
  name="floater_voice_controls"
  help_topic="floater_voice_controls"
@@ -33,23 +33,27 @@
      name="no_one_near">
         No one near has voice enabled
     </string>
-      <layout_stack
-         clip="false"
-         follows="all"
-         height="262"
+    <string
+     name="max_visible_items">
+        5
+    </string>
+    <panel
+     bevel_style="out"
+     border="true"
+     follows="left|right|top"
+     height="62"
+     layout="topleft"
+     left="0"
+     name="control_panel"
+     top="0"
+     width="282">
+        <panel
+         height="18"
+         follows="top|left|right"
          layout="topleft"
          left="10"
-         mouse_opaque="false"
-         name="my_call_stack"
-         orientation="vertical"
+         name="my_panel"
          width="263">
-        <layout_panel
-         follows="top|left|right"
-          user_resize="false" 
-         auto_resize="false" 
-         layout="topleft"
-         height="26"
-         name="my_panel">
             <avatar_icon
              enabled="false"
              follows="left|top"
@@ -75,57 +79,92 @@
             <output_monitor
              auto_update="true"
              draw_border="false"
-             follows="top|right"
+             follows="right"
              height="16"
              layout="topleft"
              name="speaking_indicator"
-             left_pad="5"
+             right="-1"
+             top="2"
              visible="true"
              width="20" />
-        </layout_panel>
+        </panel>
+        <layout_stack
+         border_size="0"
+         clip="false"
+         follows="all"
+         height="28"
+         layout="topleft"
+         left="10"
+         mouse_opaque="false"
+         name="leave_call_stack"
+         orientation="horizontal"
+         top_pad="5"
+         width="263">
+         <layout_panel
+          auto_resize="true"
+          follows="left|right"
+          height="26"
+          layout="topleft"
+          min_height="23"
+          min_width="5"
+          mouse_opaque="false"
+          name="left_anchor"
+          width="80"/>
          <layout_panel
           auto_resize="false"
-          user_resize="false" 
-          follows="top|left"
+          follows="left|right"
           height="26"
-          visible="true"
           layout="topleft"
+          mouse_opaque="false"
+          min_height="24"
+          min_width="100"
           name="leave_call_btn_panel"
           width="100">
            <button
-          follows="right|top"
-            height="23"
-            top_pad="0"
+            follows="left|right"
+            height="24"
             label="Leave Call"
+            left="0"
             name="leave_call_btn"
+            top="0"
             width="100" />
          </layout_panel>
-      <layout_panel
-          follows="all"
-          layout="topleft"
-          left="2"
-          top_pad="0"
-          height="205" 
-          name="callers_panel"
-          user_resize="false" 
-          width="280">
-        <avatar_list
-         follows="all"
-         height="205"
-         ignore_online_status="true"
-         layout="topleft"
-         multi_select="true"
-         name="speakers_list"
-         width="280" />
-        <panel
-         filename="panel_avatar_list_item.xml"
-         follows="left|right|top"
-         height="24"
+         <layout_panel
+         auto_resize="true"
+         follows="left|right"
+         height="26"
          layout="topleft"
-         left="0"
-         name="non_avatar_caller"
-         top="10"
-         width="276" />
-      </layout_panel>
-    </layout_stack>
+         mouse_opaque="false"
+         min_height="24"
+         min_width="5"
+         name="right_anchor"
+         width="80"/>
+        </layout_stack>
+    </panel>
+    <avatar_list
+     follows="all"
+     height="197"
+     ignore_online_status="true"
+     layout="topleft"
+     left="0"
+     multi_select="true"
+     name="speakers_list"
+     width="282" />
+    <panel
+     filename="panel_avatar_list_item.xml"
+     follows="left|right|top"
+     height="24"
+     layout="topleft"
+     left="0"
+     name="non_avatar_caller"
+     top="70"
+     width="282" />
+    <view_border
+     bevel_style="out"
+     follows="left|top|right|bottom"
+     height="206"
+     layout="topleft"
+     left="0"
+     top="63"
+     width="282" />
 </floater>
diff --git a/indra/newview/skins/default/xui/en/inspect_toast.xml b/indra/newview/skins/default/xui/en/inspect_toast.xml
deleted file mode 100644
index 0221397a8ca..00000000000
--- a/indra/newview/skins/default/xui/en/inspect_toast.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<!--
-  Not can_close / no title to avoid window chrome
-  Single instance - only have one at a time, recycle it each spawn
--->
-<floater
- legacy_header_height="25"
- bevel_style="in"
- bg_opaque_image="Inspector_Background"
- can_close="false"
- can_minimize="false"
- height="148"
- layout="topleft"
- name="inspect_toast"
- single_instance="true"
- sound_flags="0"
- visible="true"
- width="228">
-</floater>
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 45100eb1ffa..fa7e3e86a33 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -198,6 +198,40 @@
              function="Floater.Toggle"
              parameter="nearby_media" />
         </menu_item_check>
+        <!--menu_item_check
+         label="Block List"
+         layout="topleft"
+         name="Mute List">
+            <menu_item_check.on_check
+             function="Floater.Visible"
+             parameter="mute" />
+            <menu_item_check.on_click
+             function="Floater.Toggle"
+             parameter="mute" />
+        </menu_item_check-->
+        <menu_item_separator
+         layout="topleft" />
+        <menu_item_check
+         label="(Legacy) Communicate"
+         layout="topleft"
+         name="Instant Message"
+         shortcut="control|T">
+            <menu_item_check.on_check
+             function="Floater.Visible"
+             parameter="communicate" />
+            <menu_item_check.on_click
+             function="Floater.Toggle"
+             parameter="communicate" />
+        </menu_item_check>
+        <menu_item_call
+         label="(Temp) Media Remote Ctrl"
+         layout="topleft"
+         name="Preferences"
+         shortcut="control|alt|M">
+            <menu_item_call.on_click
+             function="Floater.Toggle"
+             parameter="media_remote_ctrl" />
+        </menu_item_call>
     </menu>
     <menu
      label="World"
@@ -249,7 +283,7 @@
             </menu_item_call>
       <menu
            create_jump_keys="true"
-           label="Place Profile"
+           label="About This Place"
            layout="topleft"
            name="Land"
            tear_off="true">
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 5ec8018eaec..eb82dd4a7f0 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -246,7 +246,7 @@ Save all changes to clothing/body parts?
    icon="alertmodal.tga"
    name="GrantModifyRights"
    type="alertmodal">
-Granting modify rights to another Resident allows them to change, delete or take ANY objects you may have in-world. Be VERY careful when handing out this permission.
+Granting modify rights to another resident allows them to change, delete or take ANY objects you may have in-world. Be VERY careful when handing out this permission.
 Do you want to grant modify rights for [FIRST_NAME] [LAST_NAME]?
     <usetemplate
      name="okcancelbuttons"
@@ -258,7 +258,7 @@ Do you want to grant modify rights for [FIRST_NAME] [LAST_NAME]?
    icon="alertmodal.tga"
    name="GrantModifyRightsMultiple"
    type="alertmodal">
-Granting modify rights to another Resident allows them to change ANY objects you may have in-world. Be VERY careful when handing out this permission.
+Granting modify rights to another resident allows them to change ANY objects you may have in-world. Be VERY careful when handing out this permission.
 Do you want to grant modify rights for the selected Residents?
     <usetemplate
      name="okcancelbuttons"
@@ -1597,8 +1597,7 @@ Unable to force land ownership because selection spans multiple regions. Please
    icon="alertmodal.tga"
    name="ForceOwnerAuctionWarning"
    type="alertmodal">
-This parcel is up for auction. Forcing ownership will cancel the auction and potentially make some Residents unhappy if bidding has begun.
-Force ownership?
+This parcel is up for auction. Forcing ownership will cancel the auction and potentially make some residents unhappy if bidding has begun. Force ownership?
     <usetemplate
      name="okcancelbuttons"
      notext="Cancel"
@@ -2916,16 +2915,6 @@ You have reached your maximum number of groups. Please leave another group befor
      yestext="Join"/>
   </notification>
 
-  <notification
-   icon="alert.tga"
-   name="JoinedTooManyGroups"
-   type="alert">
-You have reached your maximum number of groups. Please leave some group before joining or creating a new one.
-    <usetemplate
-     name="okbutton"
-     yestext="OK"/>
-  </notification>
-
   <notification
    icon="alert.tga"
    name="KickUser"
@@ -3564,7 +3553,7 @@ Type a short announcement which will be sent to everyone in this region.
 The maturity rating for this region has been updated.
 It may take some time for the change to be reflected on the map.
 
-To enter Adult regions, Residents must be Account Verified, either by age-verification or payment-verification.
+To enter Adult regions, residents must be Account Verified, either by age-verification or payment-verification.
   </notification>
 
   <notification
@@ -4554,8 +4543,8 @@ Click on any landmark to select it, then click &apos;Teleport&apos; at the botto
    icon="notifytip.tga"
    name="TeleportToPerson"
    type="notifytip">
-You can contact Residents like &apos;[NAME]&apos; by opening the People panel on the right side of your screen.
-Select the Resident from the list, then click &apos;IM&apos; at the bottom of the panel.
+You can contact residents like &apos;[NAME]&apos; by opening the People panel on the right side of your screen.
+Select the resident from the list, then click &apos;IM&apos; at the bottom of the panel.
 (You can also double-click on their name in the list, or right-click and choose &apos;IM&apos;).
   </notification>
 
@@ -4704,7 +4693,7 @@ The objects on the selected parcel of land that is owned by [FIRST] [LAST] have
    icon="notify.tga"
    name="OtherObjectsReturned2"
    type="notify">
-The objects on the selected parcel of land owned by the Resident &apos;[NAME]&apos; have been returned to their owner.
+The objects on the selected parcel of land owned by the resident &apos;[NAME]&apos; have been returned to their owner.
   </notification>
 
   <notification
@@ -4985,7 +4974,7 @@ No valid parcel could be found.
    icon="notify.tga"
    name="ObjectGiveItem"
    type="offer">
-An object named [OBJECTFROMNAME] owned by [NAME_SLURL] has given you this [OBJECTTYPE]:
+An object named [OBJECTFROMNAME] owned by [NAME_SLURL] has given you [OBJECTTYPE]:
 [ITEM_SLURL]
     <form name="form">
       <button
@@ -5007,7 +4996,7 @@ An object named [OBJECTFROMNAME] owned by [NAME_SLURL] has given you this [OBJEC
    icon="notify.tga"
    name="ObjectGiveItemUnknownUser"
    type="offer">
-An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you this [OBJECTTYPE]:
+An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you [OBJECTTYPE]:
 [ITEM_SLURL]
     <form name="form">
       <button
@@ -5029,7 +5018,7 @@ An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you th
    icon="notify.tga"
    name="UserGiveItem"
    type="offer">
-[NAME_SLURL] has given you this [OBJECTTYPE]:
+[NAME_SLURL] has given you [OBJECTTYPE]:
 [ITEM_SLURL]
     <form name="form">
       <button
@@ -5192,7 +5181,7 @@ An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you th
    name="OfferCallingCard"
    type="notify">
 [FIRST] [LAST] is offering their calling card.
-This will add a bookmark in your inventory so you can quickly IM this Resident.
+This will add a bookmark in your inventory so you can quickly IM this resident.
     <form name="form">
       <button
        index="0"
diff --git a/indra/newview/skins/default/xui/en/panel_adhoc_control_panel.xml b/indra/newview/skins/default/xui/en/panel_adhoc_control_panel.xml
index 28a6995186b..6c54532a3a8 100644
--- a/indra/newview/skins/default/xui/en/panel_adhoc_control_panel.xml
+++ b/indra/newview/skins/default/xui/en/panel_adhoc_control_panel.xml
@@ -4,7 +4,7 @@
  follows="all"
  height="215"
  name="panel_im_control_panel"
- width="150">
+ width="180">
     <layout_stack
      mouse_opaque="false"
      border_size="0"
@@ -16,16 +16,15 @@
      name="vertical_stack"
      orientation="vertical"
      top="0"
-     width="147">
+     width="177">
         <layout_panel
          auto_resize="true"
          follows="top|left"
          height="130"
          layout="topleft"
-         left="0"
          min_height="0"
          mouse_opaque="false"
-         width="147"
+         width="180"
          top="0"
          name="speakers_list_panel"
          user_resize="false">
@@ -40,7 +39,7 @@
              show_info_btn="false"
              show_profile_btn="false"
              show_speaking_indicator="false"
-             width="147" />
+             width="180" />
         </layout_panel>
         <layout_panel
          auto_resize="false"
@@ -48,7 +47,7 @@
          height="25"
          layout="topleft"
          min_height="25"
-         width="130"
+         width="160"
          name="call_btn_panel"
          user_resize="false"
          visible="false">
@@ -57,7 +56,7 @@
              height="20"
              label="Call"
              name="call_btn"
-             width="130"
+             width="160"
              top="5" />
         </layout_panel>
         <layout_panel
@@ -66,7 +65,7 @@
          height="25"
          layout="topleft"
          min_height="25"
-         width="130"
+         width="160"
          name="end_call_btn_panel"
          user_resize="false"
          visible="false">
@@ -83,7 +82,7 @@
          height="25"
          layout="topleft"
          min_height="25"
-         width="130"
+         width="160"
          name="voice_ctrls_btn_panel"
          user_resize="false"
          visible="false">
diff --git a/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml
index 615ade99a2b..45f9d9c7b65 100644
--- a/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml
@@ -58,13 +58,13 @@
      top="6"
      use_ellipses="true"
      value="Unknown"
-     width="180" />
+     width="182" />
     <text
      follows="right"
      font="SansSerifSmall"
      height="15"
      layout="topleft"
-     left_pad="5"
+     left_pad="8"
      name="last_interaction"
      text_color="LtGray_50"
      value="0s"
@@ -75,7 +75,7 @@
      draw_border="false"
      height="16"
      layout="topleft"
-     left_pad="5"
+     left_pad="0"
      mouse_opaque="true"
      name="speaking_indicator"
      visible="true"
@@ -98,7 +98,6 @@
      left_pad="5"
      right="-3"
      name="profile_btn"
-     tool_tip="View profile"
      top_delta="-2"
      width="20" />
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml b/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml
index 39170b90ca3..003e1baa7eb 100644
--- a/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml
+++ b/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml
@@ -37,7 +37,7 @@
      layout="topleft"
      left="5"
      name="blocked"
-     tool_tip="List of currently blocked Residents"
+     tool_tip="List of currently blocked residents"
      top="30"
      width="270" />
     <button
@@ -47,7 +47,7 @@
      layout="topleft"
      left_delta="0"
      name="Block resident..."
-     tool_tip="Pick a Resident to block"
+     tool_tip="Pick a resident to block"
      top_pad="4"
      width="210">
         <button.commit_callback
@@ -74,7 +74,7 @@
      layout="topleft"
      left_delta="0"
      name="Unblock"
-     tool_tip="Remove Resident or object from blocked list"
+     tool_tip="Remove resident or object from blocked list"
      top_pad="4"
      width="210" >
         <button.commit_callback
diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml
index 4b39210f30c..aeaa049f1ff 100644
--- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml
+++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml
@@ -33,10 +33,10 @@
          height="10"
          image_name="spacer24.tga"
          layout="topleft"
-         min_width="2"
+         min_width="4"
          left="0"
          top="0"
-         width="2" />
+         width="4" />
         <layout_panel
  	mouse_opaque="false"
          auto_resize="false"
@@ -71,7 +71,7 @@
            layout="topleft"
            left="0"
            name="talk"
-           top="5"
+           top="4"
           width="100">
               <show_button>
                   <show_button.init_callback
@@ -103,20 +103,20 @@
          min_width="52"
          name="gesture_panel"
          user_resize="false">
-         <gesture_combo_list
+         <gesture_combo_box
           follows="left|right"
           height="23"
           label="Gesture"
           layout="topleft"
           name="Gesture"
           left="0"
-          top="5"
+          top="4"
           width="82"
           tool_tip="Shows/hides gestures">
-             <gesture_combo_list.combo_button
+             <gesture_combo_box.drop_down_button
               pad_right="10"
               use_ellipses="true" />
-         </gesture_combo_list>
+         </gesture_combo_box>
         </layout_panel>
 		 <icon
          auto_resize="false"
@@ -153,7 +153,7 @@
              layout="topleft"
              name="movement_btn"
              tool_tip="Shows/hides movement controls"
-             top="5"
+             top="4"
              width="80">
                 <button.init_callback
                  function="Button.SetDockableFloaterToggle"
@@ -195,7 +195,7 @@
              layout="topleft"
              left="0"
              tool_tip="Shows/hides camera controls"
-             top="5"
+             top="4"
              name="camera_btn"
              width="80">
                 <button.init_callback
@@ -235,7 +235,7 @@
              layout="topleft"
              name="snapshots"
              width="36"
-             top="5"
+             top="4"
              is_toggle="true"
              image_overlay="Snapshot_Off"
              tool_tip="Take snapshot">
@@ -338,7 +338,7 @@ as for parent layout_panel (chiclet_list_panel) to resize bottom tray properly.
              layout="topleft"
              left="0"
              name="im_well"
-             top="5"
+             top="4"
              width="35">
              <!--
 Emulate 4 states of button by background images, see details in EXT-3147. The same should be for notification_well button
@@ -362,6 +362,8 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
                  label_color="Black"
                  left="0"
                  name="Unread IM messages"
+                 pad_left="0"
+                 pad_right="0"
                  tool_tip="Conversations"
                  width="35" >
                     <button.init_callback
@@ -379,8 +381,8 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
          top="0"
          left_pad="3"
          name="notification_well_panel"
-         width="40"
-         min_width="40"
+         width="35"
+         min_width="35"
          user_resize="false">
             <chiclet_notification
              flash_period="0.25"
@@ -390,7 +392,7 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
              left="0"
              max_displayed_count="99"
              name="notification_well"
-             top="5"
+             top="4"
              width="35">
               <button
                  bottom_pad="3"
@@ -403,11 +405,11 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
                follows="right"
                flash_color="ChicletFlashColor"
                 label_color="Black"
-               left="0"
+               left="5"
                name="Unread"
                image_overlay="Notices_Unread"
                image_overlay_alignment="center"
-               pad_right="15"
+               pad_right="5"
                tool_tip="Notifications"
                width="35" >
                   <button.init_callback
@@ -416,5 +418,16 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
               </button>
 	    </chiclet_notification>
         </layout_panel>
+        <icon
+         auto_resize="false"
+         color="0 0 0 0"
+         follows="left|right"
+         height="10"
+         image_name="spacer24.tga"
+         layout="topleft"
+         min_width="4"
+         right="-1"
+         top="0"
+         width="4"/>
     </layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_edit_pick.xml b/indra/newview/skins/default/xui/en/panel_edit_pick.xml
index 7769189219c..d6de5af32d3 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_pick.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_pick.xml
@@ -38,27 +38,28 @@
    <scroll_container
      color="DkGray2"
      follows="all"
-     height="500"
+     height="510"
      layout="topleft"
      left="10"
      top_pad="10"
      name="profile_scroll"
+     reserve_scroll_corner="false"
      opaque="true"
      width="313">
     <panel
      name="scroll_content_panel"
-     follows="left|top|right"
+     follows="left|top"
      min_height="300"
      layout="topleft"
      top="0"
      background_visible="false"
-     height="500"
+     height="510"
      left="0"
-     width="285">
+     width="295">
     <texture_picker
      follows="left|top|right"
      height="197"
-     width="280"
+     width="290"
      layout="topleft"
      top="20"
      left="10"
@@ -76,7 +77,7 @@
         <text
          type="string"
          length="1"
-         follows="left|top|right"
+         follows="left|top"
          height="15"
          font="SansSerifSmall"
          font.style="BOLD"
@@ -85,7 +86,7 @@
          top="215"
          name="Name:"
          text_color="white"
-         width="280">
+         width="290">
             Title:
         </text>
         <line_editor
@@ -98,11 +99,11 @@
          max_length="63"
          name="pick_name"
          text_color="black"
-         width="280" />
+         width="290" />
         <text
          type="string"
          length="1"
-         follows="left|top|right"
+         follows="left|top"
          height="15"
          font="SansSerifSmall"
          font.style="BOLD"
@@ -111,13 +112,13 @@
          top_pad="20"
          name="description_label"
          text_color="white"
-         width="280">
+         width="290">
             Description:
         </text>
         <text_editor
          follows="left|top|right"
          height="100"
-         width="280"
+         width="290"
          hide_scrollbar="false"
          layout="topleft"
          left="10"
@@ -131,26 +132,27 @@
          length="1"
          font="SansSerifSmall"
          font.style="BOLD"
-         follows="left|top|right"
+         follows="left|top"
          height="15"
          layout="topleft"
          left="10"
          name="location_label"
          text_color="white"
          top_pad="20"
-         width="280">
+         width="290">
             Location:
         </text>
         <text
          type="string"
          length="1"
-         follows="left|top|right"
+         follows="left|top"
          height="50"
          layout="topleft"
          left="10"
          name="pick_location"
+         right="-10"
          top_pad="2"
-         width="280"
+         width="290"
          word_wrap="true">
             loading...
         </text>
diff --git a/indra/newview/skins/default/xui/en/panel_edit_profile.xml b/indra/newview/skins/default/xui/en/panel_edit_profile.xml
index 172cf18fc4b..be3c0bbd969 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_profile.xml
@@ -301,13 +301,14 @@
          left="10"
          name="partner_data_panel"
          width="285">
-            <name_box
+            <text
              follows="left|top|right"
              height="30"
              layout="topleft"
              left="0"
              name="partner_text"
              top="0"
+             value="[FIRST] [LAST]"
              width="285"
              word_wrap="true" />
          </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_friends.xml b/indra/newview/skins/default/xui/en/panel_friends.xml
index c315adb33eb..ac731bcdf00 100644
--- a/indra/newview/skins/default/xui/en/panel_friends.xml
+++ b/indra/newview/skins/default/xui/en/panel_friends.xml
@@ -118,7 +118,7 @@
      layout="topleft"
      left_delta="0"
      name="add_btn"
-     tool_tip="Offer friendship to a Resident"
+     tool_tip="Offer friendship to a resident"
      top_pad="13"
      width="80" />
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_group_control_panel.xml b/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
index aa7d621e4c8..4073ef158bb 100644
--- a/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
@@ -4,7 +4,7 @@
  follows="all"
  height="238"
  name="panel_im_control_panel"
- width="150">
+ width="180">
     <layout_stack
      mouse_opaque="false"
      border_size="0"
@@ -16,7 +16,7 @@
      name="vertical_stack"
      orientation="vertical"
      top="0"
-     width="145">
+     width="175">
         <layout_panel
          auto_resize="true"
          follows="top|left"
@@ -24,7 +24,7 @@
          layout="topleft"
          min_height="0"
          mouse_opaque="false"
-         width="145"
+         width="180"
          top="0"
          name="speakers_list_panel"
          user_resize="false">
@@ -39,7 +39,7 @@
              show_info_btn="false"
              show_profile_btn="false"
              show_speaking_indicator="false"
-             width="145" />
+             width="180" />
         </layout_panel>
         <layout_panel
          auto_resize="false"
@@ -47,7 +47,7 @@
          height="28"
          layout="topleft"
          min_height="28"
-         width="130"
+         width="160"
          name="group_info_btn_panel"
          user_resize="false">
             <button
@@ -57,7 +57,7 @@
              name="group_info_btn"
              use_ellipses="true"
              top="5"
-             width="130" />
+             width="160" />
         </layout_panel>
         <layout_panel
          auto_resize="false"
@@ -65,7 +65,7 @@
          height="28"
          layout="topleft"
          min_height="28"
-         width="130"
+         width="160"
          name="call_btn_panel"
          user_resize="false">
             <button
@@ -74,7 +74,7 @@
              label="Call Group"
              name="call_btn"
              use_ellipses="true" 
-             width="130" />
+             width="160" />
         </layout_panel>
         <layout_panel
          auto_resize="false"
@@ -82,7 +82,7 @@
          height="28"
          layout="topleft"
          min_height="28"
-         width="130"
+         width="160"
          name="end_call_btn_panel"
          user_resize="false"
          visible="false">
@@ -99,7 +99,7 @@
          height="28"
          layout="topleft"
          min_height="28"
-         width="130"
+         width="160"
          name="voice_ctrls_btn_panel"
          user_resize="false"
          visible="false">
diff --git a/indra/newview/skins/default/xui/en/panel_group_info_sidetray.xml b/indra/newview/skins/default/xui/en/panel_group_info_sidetray.xml
index 81880488218..c0db734f8c1 100644
--- a/indra/newview/skins/default/xui/en/panel_group_info_sidetray.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_info_sidetray.xml
@@ -216,28 +216,12 @@ background_visible="true"
      visible="false"
      width="65" />-->
      <button
-     follows="bottom|right"          
-     label="Group Chat"
-     name="btn_chat"
-     right="-184"
-     left_pad="2"     
-     height="22"          
-     width="85" />
-     <button
-     follows="bottom|right"          
-     label="Group Call"
-     name="btn_call"
-     right="-97"
-     left_pad="2"     
-     height="22"          
-     width="85" />
-     <button
      height="22"
      label="Save"
      label_selected="Save"
      name="btn_apply"
      left_pad="10"
      right="-10"
-     width="85" />
+     width="100" />
      </panel>
 </panel>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/panel_group_invite.xml b/indra/newview/skins/default/xui/en/panel_group_invite.xml
index 48083b7677d..37578eae703 100644
--- a/indra/newview/skins/default/xui/en/panel_group_invite.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_invite.xml
@@ -17,7 +17,7 @@
     </panel.string>
     <panel.string
      name="already_in_group">
-        Some Residents you chose are already in the group, and so were not sent an invitation.
+        Some avatars are already in group and were not invited.
     </panel.string>
     <text
      type="string"
@@ -26,10 +26,11 @@
      layout="topleft"
      left="7"
      name="help_text"
-     top="28"
-     word_wrap="true"
+     top="24"
      width="200">
-        You can select multiple Residents to invite to your group. Click &apos;Open Resident Chooser&apos; to start.
+        You can select multiple residents to 
+invite to your group. Click &apos;Open 
+Resident Chooser&apos; to start.
     </text>
     <button
      height="20"
@@ -47,7 +48,7 @@
      left_delta="0"
      multi_select="true"
      name="invitee_list"
-     tool_tip="Hold the Ctrl key and click Resident names to multi-select"
+     tool_tip="Hold the Ctrl key and click resident names to multi-select"
      top_pad="4"
      width="200" />
     <button
@@ -56,7 +57,7 @@
      layout="topleft"
      left_delta="0"
      name="remove_button"
-     tool_tip="Removes the Residents selected above from the invite list"
+     tool_tip="Removes residents selected above from the invite list"
      top_pad="4"
      width="200" />
     <text
@@ -67,7 +68,6 @@
      left_delta="4"
      name="role_text"
      top_pad="5"
-     word_wrap="true"
      width="200">
         Choose what Role to assign them to:
     </text>
diff --git a/indra/newview/skins/default/xui/en/panel_group_list_item.xml b/indra/newview/skins/default/xui/en/panel_group_list_item.xml
index c243d08b97e..5f6b911620f 100644
--- a/indra/newview/skins/default/xui/en/panel_group_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_list_item.xml
@@ -65,7 +65,6 @@
      left_pad="5"
      right="-3"
      name="profile_btn"
-     tool_tip="View profile"
      top_delta="-2"
      width="20" />
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_group_notices.xml b/indra/newview/skins/default/xui/en/panel_group_notices.xml
index 0d9c2c21627..e096715ceec 100644
--- a/indra/newview/skins/default/xui/en/panel_group_notices.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_notices.xml
@@ -136,7 +136,6 @@ Maximum 200 per group daily
          left_pad="3"
          max_length="63"
          name="create_subject"
-         prevalidate_callback="ascii"
          width="220" />
         <text
          follows="left|top"
diff --git a/indra/newview/skins/default/xui/en/panel_group_roles.xml b/indra/newview/skins/default/xui/en/panel_group_roles.xml
index 6b3fb045499..a5bab3232cf 100644
--- a/indra/newview/skins/default/xui/en/panel_group_roles.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_roles.xml
@@ -210,18 +210,6 @@ including the Everyone and Owner Roles.
                 Abilities allow Members in Roles to do specific
 things in this group. There&apos;s a broad variety of Abilities.
             </panel.string>
-            <panel.string
-             name="power_folder_icon">
-                Inv_FolderClosed
-            </panel.string>
-            <panel.string
-             name="power_all_have_icon">
-                Checkbox_On
-            </panel.string>
-            <panel.string
-             name="power_partial_icon">
-                Checkbox_Off
-            </panel.string>
          <filter_editor
          layout="topleft"
          top="5"
@@ -232,32 +220,23 @@ things in this group. There&apos;s a broad variety of Abilities.
          max_length="250"
          label="Filter Abilities"
          name="filter_input" />
-
-        <scroll_list
-         column_padding="0"
-         draw_stripes="true"
-         height="200"
-         follows="left|top"
-         layout="topleft"
-         left="0"
-         name="action_list"
-         search_column="2"
-         tool_tip="Select an Ability to view more details"
-         top_pad="5"
-         width="300">
-            <scroll_list.columns
-             label=""
-             name="icon"
-             width="2" />
-            <scroll_list.columns
-             label=""
-             name="checkbox"
-             width="20" />
-            <scroll_list.columns
-             label=""
-             name="action"
-             width="270" />
-        </scroll_list>
+            <scroll_list
+             column_padding="0"
+             draw_stripes="false"
+             follows="left|top"
+             height="200"
+             layout="topleft"
+             left="0"
+             multi_select="true"
+             name="action_list"
+             search_column="1"
+             tool_tip="Select an Ability to view more details"
+             top_pad="5"
+             width="300">
+                <scroll_list.columns
+                 name="action"
+                 width="300" />
+            </scroll_list>
         </panel>
     </tab_container>
     <panel
diff --git a/indra/newview/skins/default/xui/en/panel_login.xml b/indra/newview/skins/default/xui/en/panel_login.xml
index df942b1a267..e5df37e366c 100644
--- a/indra/newview/skins/default/xui/en/panel_login.xml
+++ b/indra/newview/skins/default/xui/en/panel_login.xml
@@ -186,7 +186,6 @@ height="80">
    <text
 follows="right|bottom"
 font="SansSerifSmall"
-text_color="EmphasisColor"
 halign="right"
 height="16"
 top="12"
diff --git a/indra/newview/skins/default/xui/en/panel_media_settings_general.xml b/indra/newview/skins/default/xui/en/panel_media_settings_general.xml
index 38e8b9844f5..5217ab35717 100644
--- a/indra/newview/skins/default/xui/en/panel_media_settings_general.xml
+++ b/indra/newview/skins/default/xui/en/panel_media_settings_general.xml
@@ -30,7 +30,6 @@
     (This page does not pass the specified whitelist)
   </text>
   <line_editor 
-   max_length="1024"
    bottom_delta="-24" 
    enabled="true" 
    follows="left|top" 
@@ -73,15 +72,13 @@
     Current Page:
   </text>
   <text 
-   name="current_url"
-   max_length="1024"
-   use_ellipses="true"
    bottom_delta="-20" 
    enabled="false" 
    follows="left|top" 
    font="SansSerif"
    height="20" 
    left="10" 
+   name="current_url"
    tool_tip="The current page for this media source"
    value="" 
    width="340" />
diff --git a/indra/newview/skins/default/xui/en/panel_my_profile.xml b/indra/newview/skins/default/xui/en/panel_my_profile.xml
index 27c1af1860c..8327edfdd08 100644
--- a/indra/newview/skins/default/xui/en/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_my_profile.xml
@@ -27,9 +27,6 @@
     <string
      name="no_partner_text"
      value="None" />
-    <string
-     name="no_group_text"
-     value="None" />
     <string
 	 name="RegisterDateFormat">
 	 [REG_DATE] ([AGE])
@@ -65,11 +62,10 @@
           <panel
                 layout="topleft"
           follows="left|top|right"
-                height="505"
                name="scroll_content_panel"
                 top="0"
                 left="0"
-                width="297">
+                width="303">
             <panel
                   follows="left|top|right"
                   height="117"
@@ -77,7 +73,7 @@
                   left="10"
                   name="second_life_image_panel"
                   top="0"
-                  width="297">
+                  width="300">
               <texture_picker
                allow_no_texture="true"
                default_image_name="None"
@@ -118,7 +114,7 @@
                textbox.max_length="512"
                name="sl_description_edit"
                top_pad="-3"
-               width="181"
+               width="188"
                expanded_bg_visible="true"
                expanded_bg_color="DkGray">
                 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum. adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum. adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum.
@@ -131,7 +127,7 @@
        top_pad="10"
              left="10"
              name="first_life_image_panel"
-             width="297">
+             width="300">
               <texture_picker
                allow_no_texture="true"
                default_image_name="None"
@@ -171,7 +167,7 @@
                textbox.max_length="512"
                name="fl_description_edit"
                top_pad="-3"
-               width="181"
+               width="188"
                expanded_bg_visible="true"
                expanded_bg_color="DkGray">
                 Lorem ipsum dolor sit amet, consectetur adlkjpiscing elit moose moose. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet. adipiscing elit. Aenean rigviverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet sorbet ipsum. adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum.
@@ -264,14 +260,14 @@
              name="partner_data_panel"
              top_pad="0"
              width="300">
-              <name_box
+              <text
                follows="left|top"
                height="10"
                layout="topleft"
                left="0"
-               link="true"
                name="partner_text"
                top="0"
+               value="[FIRST] [LAST]"
            width="300"
                word_wrap="true" />
             </panel>
@@ -316,7 +312,7 @@
          left="0"
          mouse_opaque="false"
          name="add_friend"
-         tool_tip="Offer friendship to the Resident"
+         tool_tip="Offer friendship to the resident"
          top="5"
          width="80" />
         <button
diff --git a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
index 9ad99b1f135..e2884dbedcf 100644
--- a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
@@ -47,7 +47,7 @@
 	     left="10"
 	     name="back_btn"
 	     tool_tip="Go back to previous location"
-	     top="2"
+	     top="3"
 	     width="31" />
 	    <button
 	     follows="left|top"
@@ -92,6 +92,7 @@
 	         width="20" />
 	      -->
 	    </location_input>
+
 	<!--     <button -->
 	<!--      follows="right|top" -->
 	<!--      height="20" -->
@@ -107,6 +108,7 @@
 	<!--      name="search_bg" -->
 	<!--      top_delta="0" -->
 	<!--      width="168" /> -->
+
         <search_combo_box
 	     bevel_style="none"
 	     border_style="line"
diff --git a/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml b/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
index 2b361c06286..f09a0e03ed0 100644
--- a/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
@@ -27,7 +27,7 @@
      max_length="512"
      name="chat_box"
      tool_tip="Press Enter to say, Ctrl+Enter to shout"
-     top="2"
+     top="1"
      width="283" />
     <output_monitor
      auto_update="true"
@@ -45,7 +45,7 @@
      follows="right"
      is_toggle="true"
      width="20"
-     top="2"
+     top="1"
      layout="topleft"
      left_pad="4"
      image_disabled="ComboButton_UpOff"
diff --git a/indra/newview/skins/default/xui/en/panel_notes.xml b/indra/newview/skins/default/xui/en/panel_notes.xml
index 45b64d5e26b..73528b28ad2 100644
--- a/indra/newview/skins/default/xui/en/panel_notes.xml
+++ b/indra/newview/skins/default/xui/en/panel_notes.xml
@@ -120,7 +120,7 @@
          left="0"
          mouse_opaque="false"
          name="add_friend"
-         tool_tip="Offer friendship to the Resident"
+         tool_tip="Offer friendship to the resident"
          top="5"
          width="80" />
         <button
@@ -139,7 +139,7 @@
          label="Call"
          layout="topleft"
          name="call"
-         tool_tip="Call this Resident"
+         tool_tip="Call this resident"
          left_pad="3"
          top="5"
          width="45" />
@@ -150,7 +150,7 @@
          label="Map"
          layout="topleft"
          name="show_on_map_btn"
-         tool_tip="Show the Resident on the map"
+         tool_tip="Show the resident on the map"
          top="5"
          left_pad="3"
          width="45" />
diff --git a/indra/newview/skins/default/xui/en/panel_people.xml b/indra/newview/skins/default/xui/en/panel_people.xml
index 8a02637817a..adf22f825ff 100644
--- a/indra/newview/skins/default/xui/en/panel_people.xml
+++ b/indra/newview/skins/default/xui/en/panel_people.xml
@@ -106,7 +106,7 @@ background_visible="true"
                  left_pad="5"
                  name="add_friend_btn"
                  top_delta="0"
-                 tool_tip="Add selected Resident to your friends List"
+                 tool_tip="Add selected resident to your friends List"
                  width="18">
                <commit_callback
                   function="People.addFriend" />
@@ -192,7 +192,7 @@ background_visible="true"
                  layout="topleft"
                  left_pad="5"
                  name="add_btn"
-                 tool_tip="Offer friendship to a Resident"
+                 tool_tip="Offer friendship to a resident"
                  top_delta="0"
                  width="18" />
                 <button
@@ -327,7 +327,7 @@ background_visible="true"
                  left_pad="5"
                  name="add_friend_btn"
                  top_delta="0"
-                 tool_tip="Add selected Resident to your friends List"
+                 tool_tip="Add selected resident to your friends List"
                  width="18">
                 <commit_callback
                    function="People.addFriend" />
@@ -350,7 +350,7 @@ background_visible="true"
          label="Profile"
          layout="topleft"
          name="view_profile_btn"
-         tool_tip="Show picture, groups, and other Residents information"
+         tool_tip="Show picture, groups, and other residents information"
          width="70" />
         <button
          follows="bottom|left"
@@ -370,7 +370,7 @@ background_visible="true"
          label="Call"
          layout="topleft"
          name="call_btn"
-         tool_tip="Call this Resident"
+         tool_tip="Call this resident"
          width="50" />
         <button
          follows="left|top"
diff --git a/indra/newview/skins/default/xui/en/panel_pick_info.xml b/indra/newview/skins/default/xui/en/panel_pick_info.xml
index 9c7f38e6888..f68202d2878 100644
--- a/indra/newview/skins/default/xui/en/panel_pick_info.xml
+++ b/indra/newview/skins/default/xui/en/panel_pick_info.xml
@@ -40,30 +40,31 @@
      left="10"
      top_pad="10"
      name="profile_scroll"
+     reserve_scroll_corner="false"
      width="313">
     <panel
      name="scroll_content_panel"
-     follows="left|top|right"
+     follows="left|top"
      min_height="300"
      layout="topleft"
      top="0"
      background_visible="false"
-     height="400"
+     height="470"
      left="0"
-     width="285">
+     width="295">
         <texture_picker
          enabled="false"
-         follows="left|top|right"
+         follows="left|top"
          height="197"
          layout="topleft"
          left="10"
          name="pick_snapshot"
          top="20"
-         width="280" />
+         width="290" />
         <text
          follows="left|top|right"
          height="35"
-         width="280"
+         width="290"
          layout="topleft"
          font="SansSerifBig"
          font.style="BOLD"
@@ -74,29 +75,23 @@
          value="[name]"
          use_ellipses="true" />
         <text
-         follows="left|top|right"
+         follows="left|top"
          height="25"
          layout="topleft"
          left="10"
          name="pick_location"
-         width="280"
+         width="290"
          word_wrap="true"
          value="[loading...]" />
-        <text_editor
-         bg_readonly_color="DkGray2"
-         follows="all"
-         height="100"
-         width="280"
-         hide_scrollbar="false"
+        <text
+         follows="left|top|right"
+         height="280"
          layout="topleft"
          left="10"
-         top_pad="2"
-         max_length="1023"
          name="pick_desc"
-         read_only="true"
-         text_readonly_color="white"
+         width="290"
          value="[description]"
-         wrap="true" />
+         word_wrap="true" />
     </panel>
     </scroll_container>
     <panel
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml b/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml
index 1e7acb566fe..17651b8caae 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml
@@ -2,6 +2,7 @@
 
 <panel
  border="true"
+ background_visible="true"
  follows="left|top|right|bottom"
  height="408"
  layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_general.xml b/indra/newview/skins/default/xui/en/panel_preferences_general.xml
index 22c75a595ed..c98555735a7 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_general.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_general.xml
@@ -260,7 +260,7 @@
      width="200">
         My effects:
     </text>
-    <text
+  <text
       type="string"
       length="1"
       follows="left|top"
@@ -270,23 +270,16 @@
       name="title_afk_text"
       width="190">
     Away timeout:
-    </text>
+  </text>
     <color_swatch
-	 can_apply_immediately="true"
+     control_name="EffectColor"
      follows="left|top"
      height="50"
      layout="topleft"
      left="50"
      name="effect_color_swatch"
      tool_tip="Click to open Color Picker"
-     width="38">
-		<color_swatch.init_callback
-		 function="Pref.getUIColor"
-		 parameter="EffectColor" />
-		<color_swatch.commit_callback
-		 function="Pref.applyUIColor"
-		 parameter="EffectColor" />
-	</color_swatch>
+     width="38" />
   <combo_box
             height="23"
             layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index a0fcf59fc8d..cc00abf5a0d 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -378,7 +378,7 @@
 		layout="topleft"
 		left_delta="250"
 		name="DrawDistanceMeterText2"
-		top_delta="0"
+		top_delta="1"
 		width="128">
 			m
 		</text>
@@ -395,7 +395,7 @@
 		left="216"
 		max_val="8192"
 		name="MaxParticleCount"
-		top_pad="7"
+		top_pad="6"
 		width="262" />
 		<slider
 		control_name="RenderGlowResolutionPow"
diff --git a/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml b/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml
index ab6384203fa..075d9232b1d 100644
--- a/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml
+++ b/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml
@@ -321,7 +321,6 @@
 		min_width="90">
 	  <line_editor 
 		  name="media_address_url"
-		  max_length="1024"
 		  follows="top|left|right" 
 		  height="22"
 		  top="0"
diff --git a/indra/newview/skins/default/xui/en/panel_profile.xml b/indra/newview/skins/default/xui/en/panel_profile.xml
index 597b6410cda..43947262ec5 100644
--- a/indra/newview/skins/default/xui/en/panel_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_profile.xml
@@ -27,9 +27,6 @@
     <string
      name="no_partner_text"
      value="None" />
-    <string
-     name="no_group_text"
-     value="None" />
     <string
 	 name="RegisterDateFormat">
 	 [REG_DATE] ([AGE])
@@ -65,11 +62,10 @@
           <panel
                 layout="topleft"
           follows="left|top|right"
-                height="505"
                 name="profile_scroll_panel"
                 top="0"
                 left="0"
-                width="297">
+                width="303">
             <panel
                   follows="left|top|right"
                   height="117"
@@ -77,7 +73,7 @@
                   left="10"
                   name="second_life_image_panel"
                   top="0"
-                  width="297">
+                  width="303">
               <texture_picker
                allow_no_texture="true"
                default_image_name="None"
@@ -121,7 +117,7 @@
        top_pad="10"
              left="10"
              name="first_life_image_panel"
-             width="297">
+             width="303">
               <texture_picker
                allow_no_texture="true"
                default_image_name="None"
@@ -244,14 +240,14 @@
              name="partner_data_panel"
              top_pad="0"
              width="300">
-              <name_box
+              <text
                follows="left|top"
                height="10"
                layout="topleft"
                left="0"
-               link="true"
                name="partner_text"
                top="0"
+               value="[FIRST] [LAST]"
            width="300"
                word_wrap="true" />
             </panel>
@@ -273,7 +269,7 @@
             left="7"
             name="sl_groups"
             top_pad="0"
-            width="290"
+            width="298"
             expanded_bg_visible="true"
             expanded_bg_color="DkGray">
               Lorem ipsum dolor sit amet, consectetur adlkjpiscing elit moose moose. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet. adipiscing elit. Aenean rigviverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet sorbet ipsum. adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum. Aenean viverra tulip moosetop. Slan de heelish marfnik tooplod. Sum sum to whop de wompam booster copm.
@@ -296,7 +292,7 @@
          left="0"
          mouse_opaque="false"
          name="add_friend"
-         tool_tip="Offer friendship to the Resident"
+         tool_tip="Offer friendship to the resident"
          top="5"
          width="80" />
         <button
@@ -315,7 +311,7 @@
          label="Call"
          layout="topleft"
          name="call"
-         tool_tip="Call this Resident"
+         tool_tip="Call this resident"
          left_pad="3"
          top="5"
          width="45" />
@@ -326,7 +322,7 @@
          label="Map"
          layout="topleft"
          name="show_on_map_btn"
-         tool_tip="Show the Resident on the map"
+         tool_tip="Show the resident on the map"
          top="5"
          left_pad="3"
          width="45" />
@@ -346,7 +342,7 @@
          label="â–¼"
          layout="topleft"
          name="overflow_btn"
-         tool_tip="Pay money to or share inventory with the Resident"
+         tool_tip="Pay money to or share inventory with the resident"
          right="-1"
          top="5"
 	 left_pad="3"
@@ -379,4 +375,4 @@
         </layout_panel>
     
 </layout_stack>
-</panel>
+</panel>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/panel_region_covenant.xml b/indra/newview/skins/default/xui/en/panel_region_covenant.xml
index dc8f71c868a..ff55090f162 100644
--- a/indra/newview/skins/default/xui/en/panel_region_covenant.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_covenant.xml
@@ -135,8 +135,7 @@
      left="120"
      name="covenant_help_text"
      top_pad="10"
-     word_wrap="true"
-     width="360">
+     width="460">
         Changes to the covenant will show on all parcels in the estate.
     </text>
     <text
@@ -146,10 +145,9 @@
      left_delta="0"
      name="covenant_instructions"
      top_pad="5"
-     word_wrap="true"
-     font.style="ITALIC"
-     width="360">
-        Drag and drop a notecard to change the Covenant for this estate.
+     width="465">
+        Drag and drop a notecard to change
+        the Covenant for this Estate.
     </text>
 
     <text
diff --git a/indra/newview/skins/default/xui/en/panel_region_estate.xml b/indra/newview/skins/default/xui/en/panel_region_estate.xml
index 3980eb86d30..ba39e880249 100644
--- a/indra/newview/skins/default/xui/en/panel_region_estate.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_estate.xml
@@ -19,9 +19,9 @@
      left="10"
      name="estate_help_text"
      top="14"
-     word_wrap="true"
-     width="275">
-        Changes to settings on this tab will affect all regions in the estate.
+     width="313">
+        Changes to settings on this tab will affect all
+regions in the estate.
     </text>
     <text
      type="string"
@@ -138,7 +138,7 @@
      name="Only Allow"
      top="250"
      width="278">
-        Restrict Access to accounts verified by:
+        Restrict Access to Accounts Verified by:
     </text>
     <check_box
      follows="top|left"
@@ -147,7 +147,7 @@
      layout="topleft"
      left_delta="0"
      name="limit_payment"
-     tool_tip="Ban unidentified Residents"
+     tool_tip="Ban unidentified residents"
      top_pad="2"
      width="278" />
     <check_box
@@ -157,7 +157,7 @@
      layout="topleft"
      left_delta="0"
      name="limit_age_verified"
-     tool_tip="Ban Residents who have not verified their age. See the [SUPPORT_SITE] for more information."
+     tool_tip="Ban residents who have not verified their age. See the [SUPPORT_SITE] for more information."
      top_pad="2"
      width="278" />
     <check_box
diff --git a/indra/newview/skins/default/xui/en/panel_region_texture.xml b/indra/newview/skins/default/xui/en/panel_region_texture.xml
index 04dbf73be94..502a5804c31 100644
--- a/indra/newview/skins/default/xui/en/panel_region_texture.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_texture.xml
@@ -292,7 +292,7 @@
        name="height_text_lbl10"
        top_delta="30"
        width="400"
-       word_wrap="true">
+       wrap="true">
         These values represent the blend range for the textures above.
       </text>
       <text
@@ -303,7 +303,7 @@
        name="height_text_lbl11"
        top_delta="32"
        width="400"
-       word_wrap="true">
+       wrap="true">
         Measured in meters, the LOW value is the MAXIMUM height of Texture #1, and the HIGH value is the MINIMUM height of Texture #4.
       </text>
     <button
diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml
index bfca2f2e46c..00f54feabde 100644
--- a/indra/newview/skins/default/xui/en/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml
@@ -42,36 +42,18 @@
     <button
      auto_resize="true"
      halign="right"
-     font="SansSerifSmall"
-     follows="right|top"
-     image_overlay=""
-     image_selected="spacer35.tga"
-     image_unselected="spacer35.tga"
-     image_pressed="spacer35.tga"
-     height="16"
-     right="-228"
-     label_shadow="false"
-     name="buycurrency"
-     tool_tip="My Balance"
-     top="5"
-     width="100" />
-    <button
-     auto_resize="true"
-     halign="right"
-     font="SansSerifSmall"
      follows="right|top"
      image_selected="BuyArrow_Over"
      image_unselected="BuyArrow_Over"
      image_pressed="BuyArrow_Press"
      height="16"
-     label="Buy L$"
-     label_color="EmphasisColor"
-     left_pad="0"
+     right="-128"
+     label_color="White"
      label_shadow="false"
-     name="buyL"
+     name="buycurrency"
      pad_right="20px"
-     tool_tip="Click to buy more L$"
-     top="5"
+     tool_tip="My Balance: Click to buy more L$"
+     top="3"
      width="100" />
     <text
      type="string"
@@ -80,27 +62,29 @@
      follows="right|bottom"
      halign="right"
      height="16"
-     top="7"
+     top="4"
      layout="topleft"
      left_pad="0"
      name="TimeText"
+     text_color="TimeTextColor"
      tool_tip="Current time (Pacific)"
      width="85">
         12:00 AM
     </text>
     <button
      follows="right|bottom"
-     height="15"
+     height="16"
      image_selected="AudioMute_Off"
      image_pressed="Audio_Press"
      image_unselected="Audio_Off"
      is_toggle="true"
      left_pad="18"
-     top="4"
+     top="1"
      name="volume_btn"
      tool_tip="Global Volume Control"
      width="16" />
     <text
+     enabled="true"
      follows="right|bottom"
      halign="center"
      height="12"
diff --git a/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml b/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml
deleted file mode 100644
index 60d4a7e00b5..00000000000
--- a/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<panel
- background_opaque="true"
- background_visible="false"
- border_visible="false"
- border="false"
- chrome="true" 
- follows="bottom"
- height="150"
- layout="topleft"
- name="volumepulldown_floater"
- width="32">
-  <!-- floater background image -->
-  <icon
-   height="150"
-   image_name="Inspector_Background"
-   layout="topleft"
-   left="0"
-   name="normal_background"
-   top="0"
-   width="32" />
- <slider
-  control_name="AudioLevelMaster"
-  follows="left|top"
-  left="0"
-  top="1"
-  orientation="vertical"
-  height="120"
-  increment="0.05"
-  initial_value="0.5"
-  layout="topleft"
-  name="mastervolume"
-  show_text="false"
-  slider_label.halign="right"
-  top_pad="2"
-  volume="true">
-  <slider.commit_callback
-   function="Vol.setControlFalse"
-   parameter="MuteAudio" />
-  </slider>
-  <button
-    left="7"
-    top_pad="9"
-    width="18"
-    height="12"
-    follows="top|left"
-    name="prefs_btn"
-    image_unselected="Icon_Gear_Foreground"
-    image_disabled="Icon_Gear_Background"
-    image_pressed="Icon_Gear_Press"
-    scale_image="false">
-    <button.commit_callback
-       function="Vol.GoAudioPrefs" />
-  </button>
-</panel>
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 2dfcdf4a4cf..d26e855e2f6 100644
--- a/indra/newview/skins/default/xui/en/sidepanel_task_info.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_task_info.xml
@@ -153,19 +153,28 @@
 		     layout="topleft"
     		 left="5"
 		 name="CreatorNameLabel"
-		  top_pad="12"
+		  top_pad="10"
 		     width="78">
 	        Creator:
     	</text>
+	    	<avatar_icon
+     follows="top|left"
+     height="20"
+     default_icon_name="Generic_Person"
+     layout="topleft"
+     left_pad="0"
+      top_delta="-6"
+     mouse_opaque="true"
+     width="20" />
 	    <text
 		     type="string"
-     follows="left|right|top"
+     follows="left|right"
      font="SansSerifSmall"
      height="15"
      layout="topleft"
-     left_pad="0"
+     left_pad="5"
              name="Creator Name"
-		     top_delta="0"
+		     top_delta="6"
 		     width="140">
 	        Erica Linden
 	     </text>
@@ -177,19 +186,28 @@
 			layout="topleft"
 			left="5"
 			name="Owner:"
-			top_pad="15"
+			top_pad="10"
 			 width="78">
 			    Owner:
 	     </text>
+	     <avatar_icon
+     follows="top|left"
+     height="20"
+     default_icon_name="Generic_Person"
+     layout="topleft"
+     left_pad="0"
+	    top_delta="-6"
+	    mouse_opaque="true"
+     width="20" />
 	     <text
 			    type="string"
-			    follows="left|right|top"
+			    follows="left|right"
 			    font="SansSerifSmall"
 			    height="15"
 			    layout="topleft"
-			    left_pad="0"
+			    left_pad="5"
 			    name="Owner Name"
-			    top_delta="0"
+			    top_delta="6"
 			    width="140">
 			    Erica Linden
 	     </text>
@@ -201,7 +219,7 @@
 			 layout="topleft"
 			 left="5"
 			name="Group_label"
-			top_pad="15"
+			top_pad="10"
 			width="78">
 			    Group:
 	     </text>
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index fbdac7164dd..bd868ef61e1 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -67,7 +67,7 @@
 	<!-- tooltips for Urls -->
 	<string name="TooltipHttpUrl">Click to view this web page</string>
 	<string name="TooltipSLURL">Click to view this location's information</string>
-	<string name="TooltipAgentUrl">Click to view this Resident's profile</string>
+	<string name="TooltipAgentUrl">Click to view this resident's profile</string>
 	<string name="TooltipGroupUrl">Click to view this group's description</string>
 	<string name="TooltipEventUrl">Click to view this event's description</string>
 	<string name="TooltipClassifiedUrl">Click to view this classified</string>
@@ -1609,11 +1609,11 @@ Sends an HTTP request to the specified url with the body of the request and para
 	</string>
 	<string name="LSLTipText_llResetLandBanList" translate="false">
 llResetLandBanList()
-Removes all Residents from the land ban list
+Removes all residents from the land ban list
 	</string>
 	<string name="LSLTipText_llResetLandPassList" translate="false">
 llResetLandPassList()
-Removes all Residents from the land access/pass list
+Removes all residents from the land access/pass list
 	</string>
 	<string name="LSLTipText_llGetObjectPrimCount" translate="false">
 integer llGetObjectPrimCount(key object_id)
@@ -1621,7 +1621,7 @@ Returns the total number of prims for an object in the region
 	</string>
 	<string name="LSLTipText_llGetParcelPrimOwners" translate="false">
 list llGetParcelPrimOwners(vector pos)
-Returns a list of all Residents who own objects on the parcel at pos and with individual prim counts.
+Returns a list of all residents who own objects on the parcel at pos and with individual prim counts.
 Requires owner-like permissions for the parcel.
 	</string>
 	<string name="LSLTipText_llGetParcelPrimCount" translate="false">
@@ -1808,7 +1808,7 @@ Clears (deletes) the media and all params from the given face.
 
 	<!-- inventory -->
 	<string name="InventoryNoMatchingItems">No matching items found in inventory.</string>
-  <string name="FavoritesNoMatchingItems">Drag a landmark here to add it to your favorites.</string>
+  <string name="FavoritesNoMatchingItems">Drag and drop a landmark here to add to your favorites.</string>
 	<string name="InventoryNoTexture">
 		You do not have a copy of
 this texture in your inventory
@@ -2040,7 +2040,7 @@ this texture in your inventory
 	<string name="RegionInfoAllEstatesYouManage">
 		all estates that you manage for [OWNER]
 	</string>
-	<string name="RegionInfoAllowedResidents">Allowed Residents: ([ALLOWEDAGENTS], max [MAXACCESS])</string>
+	<string name="RegionInfoAllowedResidents">Allowed residents: ([ALLOWEDAGENTS], max [MAXACCESS])</string>
 	<string name="RegionInfoAllowedGroups">Allowed groups: ([ALLOWEDGROUPS], max [MAXACCESS])</string>
 
 	<!-- script limits floater -->
@@ -2111,7 +2111,7 @@ this texture in your inventory
 
 	<!-- Mute -->
 	<string name="MuteByName">(by name)</string>
-	<string name="MuteAgent">(Resident)</string>
+	<string name="MuteAgent">(resident)</string>
 	<string name="MuteObject">(object)</string>
 	<string name="MuteGroup">(group)</string>
 
@@ -2938,7 +2938,7 @@ If you continue to receive this message, contact the [SUPPORT_SITE].
     Click the [BUTTON NAME] button to accept/connect to this voice chat.
   </string>
   <string name="muted_message">
-    You have blocked this Resident. Sending a message will automatically unblock them.
+    You have blocked this resident. Sending a message will automatically unblock them.
   </string>
   <!--Some times string name is getting from the body of server response.
   For ex.: from gIMMgr::showSessionStartError in the LLViewerChatterBoxSessionStartReply::post. 
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_im_adhoc.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_im_adhoc.xml
index 693c43f141b..af0d3382565 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_im_adhoc.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_im_adhoc.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_im_adhoc
+ font="SansSerif"
  height="25"
  name="im_adhoc_chiclet"
  show_speaker="false"
@@ -11,14 +12,15 @@
      left="25"
      name="speaker"
      visible="false"
-     width="20" />
+     width="20"/>
     <chiclet_im_adhoc.avatar_icon
      follows="left|top|bottom"
      height="22"
      mouse_opaque="true"
      name="adhoc_icon"
-     width="22" />
+     width="22"/>
     <chiclet_im_adhoc.unread_notifications
+     font="SansSerif"
      font_halign="center"
      height="25"
      left="25"
@@ -27,13 +29,13 @@
      text_color="white"
      v_pad="5"
      visible="false"
-     width="20" />
+     width="20"/>
     <chiclet_im_adhoc.new_message_icon
-  bottom="11"
-  height="14"
-  image_name="Unread_Chiclet"
-  left="12"
-  name="new_message_icon"
-  visible="false"
-  width="14" />
+     bottom="12"
+     height="13"
+     image_name="Unread_Chiclet"
+     left="12"
+     name="new_message_icon"
+     visible="false"
+     width="13" />
 </chiclet_im_adhoc>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_im_group.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_im_group.xml
index f4fc58701c6..b1988a2d200 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_im_group.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_im_group.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_im_group
+ font="SansSerif"
  height="25"
  name="im_group_chiclet"
  show_speaker="false"
@@ -11,17 +12,17 @@
      left="25"
      name="speaker"
      visible="false"
-     width="20" />
+     width="20"/>
     <chiclet_im_group.group_icon
      default_icon="Generic_Group"
      follows="left|top|bottom"
-     height="18"
-  bottom_pad="4"
+     height="22"
      mouse_opaque="true"
      name="group_icon"
-     width="18" />
+     width="22"/>
     <chiclet_im_group.unread_notifications
      height="25"
+     font="SansSerif"
      font_halign="center"
      left="25"
      mouse_opaque="false"
@@ -31,11 +32,11 @@
      visible="false"
      width="20"/>
     <chiclet_im_group.new_message_icon
-bottom="11"
-  height="14"
-  image_name="Unread_Chiclet"
-  left="12"
-  name="new_message_icon"
-  visible="false"
-  width="14" />
+     bottom="12"
+     height="13"
+     image_name="Unread_Chiclet"
+     left="12"
+     name="new_message_icon"
+     visible="false"
+     width="13" />
 </chiclet_im_group>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_im_p2p.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_im_p2p.xml
index 535113f7176..52fbce0de76 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_im_p2p.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_im_p2p.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_im_p2p
+ font="SansSerif"
  height="25"
  name="im_p2p_chiclet"
  show_speaker="false"
@@ -17,9 +18,10 @@
      height="22"
      mouse_opaque="true"
      name="avatar_icon"
-     width="22" />
+     width="22"/>
     <chiclet_im_p2p.unread_notifications
      height="25"
+     font="SansSerif"
      font_halign="center"
      left="25"
      mouse_opaque="false"
@@ -29,11 +31,11 @@
      visible="false"
      width="20"/>
     <chiclet_im_p2p.new_message_icon
-  bottom="11"
-  height="14"
-  image_name="Unread_Chiclet"
-  left="12"
-  name="new_message_icon"
-  visible="false"
-  width="14" />
+     bottom="12"
+     height="13"
+     image_name="Unread_Chiclet"
+     left="12"
+     name="new_message_icon"
+     visible="false"
+     width="13" />
 </chiclet_im_p2p>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_offer.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_offer.xml
index 86bea9be504..33f85a964cf 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_offer.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_offer.xml
@@ -1,22 +1,22 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_offer
+ font="SansSerif"
  height="25"
  name="offer_chiclet"
  width="25">
  <chiclet_offer.icon
-  default_icon="Generic_Object_Small"
+  default_icon="Generic_Object_Small" 
   follows="all"
-  height="20"
+  height="22"
   mouse_opaque="false"
   name="chiclet_icon"
-  bottom_pad="2"
-  width="20" />
+  width="22"/>
  <chiclet_offer.new_message_icon
-  bottom="11"
-  height="14"
+  bottom="12"
+  height="13"
   image_name="Unread_Chiclet"
   left="12"
   name="new_message_icon"
   visible="false"
-  width="14" />
+  width="13" />
 </chiclet_offer>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_script.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_script.xml
index b1f9f5b0e80..560c8e6ea5c 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_script.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_script.xml
@@ -1,22 +1,22 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_script
+ font="SansSerif"
  height="25"
  name="script_chiclet"
  width="25">
  <chiclet_script.icon
   follows="all"
-  height="20"
-  image_name="Generic_Object_Small"
+  height="22"
+  image_name="Generic_Object_Small" 
   mouse_opaque="false"
   name="chiclet_icon"
-  width="20"
-  bottom_pad="2" />
+  width="22"/>
  <chiclet_script.new_message_icon
-  bottom="11"
-  height="14"
+  bottom="12"
+  height="13"
   image_name="Unread_Chiclet"
   left="12"
   name="new_message_icon"
   visible="false"
-  width="14" />
+  width="13" />
 </chiclet_script>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/gesture_combo_box.xml b/indra/newview/skins/default/xui/en/widgets/gesture_combo_box.xml
new file mode 100644
index 00000000000..4229f34c09f
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/widgets/gesture_combo_box.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<gesture_combo_box
+           label="Gestures" 
+           list_position="below"
+           max_chars="20"
+           follows="right|top">
+  <gesture_combo_box.combo_button name="Combobox Button"
+                          label=""
+                          hover_glow_amount="0.15"
+                          scale_image="true"
+                          image_unselected="ComboButton_Off"
+                          image_selected="ComboButton_Selected"
+                          image_disabled="ComboButton_Disabled"
+                          image_disabled_selected="ComboButton_Disabled_Selected" />
+  <gesture_combo_box.drop_down_button name="Drop Down Button"
+                              label=""
+                              halign="center"
+                              hover_glow_amount="0.15"
+                              scale_image="true"
+                 image_selected="PushButton_Selected_Press"
+                 image_pressed="PushButton_Press"
+		 image_pressed_selected="PushButton_Selected_Press"
+                              image_unselected="PushButton_Off"
+                              image_disabled="PushButton_Disabled"
+                              image_disabled_selected="PushButton_Selected_Disabled" />
+  <gesture_combo_box.combo_list bg_writeable_color="MenuDefaultBgColor"
+                                scroll_bar_bg_visible="false" />
+  <gesture_combo_box.combo_editor name="Combo Text Entry"
+                          select_on_focus="true" />
+</gesture_combo_box>
diff --git a/indra/newview/skins/default/xui/en/widgets/gesture_combo_list.xml b/indra/newview/skins/default/xui/en/widgets/gesture_combo_list.xml
deleted file mode 100644
index 808683864d9..00000000000
--- a/indra/newview/skins/default/xui/en/widgets/gesture_combo_list.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<gesture_combo_list
-    follows="right|top">
-    <gesture_combo_list.combo_button
-     name="Combolist Button"
-     label=""
-     layout="topleft"
-     halign="center"
-     hover_glow_amount="0.15"
-     mouse_opaque="false"
-     scale_image="true"
-     image_selected="PushButton_Selected_Press"
-     image_pressed="PushButton_Press"
-     image_pressed_selected="PushButton_Selected_Press"
-     image_unselected="PushButton_Off"
-     image_disabled="PushButton_Disabled"
-     image_disabled_selected="PushButton_Selected_Disabled" />
-    <gesture_combo_list.combo_list 
-     bg_writeable_color="MenuDefaultBgColor"
-     scroll_bar_bg_visible="false" />
-</gesture_combo_list>
diff --git a/indra/newview/skins/default/xui/en/widgets/location_input.xml b/indra/newview/skins/default/xui/en/widgets/location_input.xml
index 1c0a8ba7c5e..67bb7c1896f 100644
--- a/indra/newview/skins/default/xui/en/widgets/location_input.xml
+++ b/indra/newview/skins/default/xui/en/widgets/location_input.xml
@@ -96,7 +96,7 @@
     name="damage_icon"
     width="14"
     height="13"
-    top="25"
+    top="22"
     left="2"
     follows="right|top"
     image_name="Parcel_Damage_Dark"
@@ -112,19 +112,17 @@
 	font="SansSerifSmall"
 	text_color="TextFgColor"
 	/>
-  <combo_button
-		name="Location History"
-                label=""
-                pad_right="0"/>
-  <combo_list
-	      bg_writeable_color="MenuDefaultBgColor"
-	      page_lines="10"
+
+  <combo_button name="Location History"
+                          label=""
+                          pad_right="0"/>
+  <combo_list bg_writeable_color="MenuDefaultBgColor" page_lines="10"
               scroll_bar_bg_visible="true" />
   <combo_editor name="Combo Text Entry"
-                text_pad_left="27"
+                text_pad_left="22"
                 select_on_focus="false"
                 font="SansSerifSmall"
                 bevel_style="none"
                 border_style="line"
-                border.border_thickness="0" />
+                border.border_thickness="0"/>
 </location_input>
diff --git a/indra/newview/skins/default/xui/es/floater_buy_currency.xml b/indra/newview/skins/default/xui/es/floater_buy_currency.xml
index 1ecb813dd1e..eb25493adce 100644
--- a/indra/newview/skins/default/xui/es/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/es/floater_buy_currency.xml
@@ -52,9 +52,6 @@
 	<text name="total_amount">
 		[AMT] L$
 	</text>
-	<text name="currency_links">
-		[http://www.secondlife.com/my/account/payment_method_management.php?lang=es-ES payment method] | [http://www.secondlife.com/my/account/currency.php?lang=es-ES currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=es-ES exchange rate]
-	</text>
 	<text name="purchase_warning_repurchase" right="-10">
 		Confirmando esta compra sólo compra la moneda.
 Tendrá que intentar de nuevo la operación.
diff --git a/indra/newview/skins/default/xui/fr/floater_buy_currency.xml b/indra/newview/skins/default/xui/fr/floater_buy_currency.xml
index 9a92c446f25..e6a49cbc6fe 100644
--- a/indra/newview/skins/default/xui/fr/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/fr/floater_buy_currency.xml
@@ -46,12 +46,12 @@
 		[AMT] L$
 	</text>
 	<text name="currency_links">
-		[http://www.secondlife.com/my/account/payment_method_management.php?lang=fr-FR payment method] | [http://www.secondlife.com/my/account/currency.php?lang=fr-FR currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=fr-FR exchange rate]
+		[http://www.secondlife.com/ payment method] | [http://www.secondlife.com/ currency] | [http://www.secondlife.com exchange rate]
 	</text>
 	<text name="exchange_rate_note">
 		Saisissez à nouveau le montant pour voir le taux de change actuel.
 	</text>
-	<text name="purchase_warning_repurchase">
+	<text bottom_delta="-64" height="48" name="purchase_warning_repurchase" right="-10">
 		La confirmation de cet achat n&apos;achète que des L$, pas l&apos;objet.
 	</text>
 	<text bottom_delta="16" name="purchase_warning_notenough">
diff --git a/indra/newview/skins/default/xui/fr/floater_help_browser.xml b/indra/newview/skins/default/xui/fr/floater_help_browser.xml
index 20894d42fc3..0eb3ea3d219 100644
--- a/indra/newview/skins/default/xui/fr/floater_help_browser.xml
+++ b/indra/newview/skins/default/xui/fr/floater_help_browser.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <floater name="floater_help_browser" title="NAVIGATEUR D&apos;AIDE">
 	<floater.string name="home_page_url">
-		http://fr.secondlife.com
+		http://www.secondlife.com
 	</floater.string>
 	<floater.string name="support_page_url">
-		http://fr.secondlife.com/support
+		http://support.secondlife.com
 	</floater.string>
 	<layout_stack name="stack1">
 		<layout_panel name="external_controls">
diff --git a/indra/newview/skins/default/xui/fr/strings.xml b/indra/newview/skins/default/xui/fr/strings.xml
index 3ff829bfb7f..2f0c7038fc0 100644
--- a/indra/newview/skins/default/xui/fr/strings.xml
+++ b/indra/newview/skins/default/xui/fr/strings.xml
@@ -166,7 +166,7 @@
 	<string name="TooltipSLAPP">
 		Cliquez pour exécuter la commande secondlife:// command
 	</string>
-	<string name="CurrentURL" value=" URL actuelle : [CurrentURL]"/>
+	<string name="CurrentURL" value="URL actuelle : [CurrentURL]"/>
 	<string name="SLurlLabelTeleport">
 		Me téléporter vers
 	</string>
@@ -174,7 +174,7 @@
 		Afficher la carte pour
 	</string>
 	<string name="BUTTON_CLOSE_DARWIN">
-		Fermer (&#8984;W)
+		Fermer (⌘W)
 	</string>
 	<string name="BUTTON_CLOSE_WIN">
 		Fermer (Ctrl+W)
@@ -821,46 +821,46 @@
 	<string name="InventoryNoTexture">
 		Vous n&apos;avez pas de copie de cette texture dans votre inventaire
 	</string>
-	<string name="no_transfer" value=" (pas de transfert)"/>
-	<string name="no_modify" value=" (pas de modification)"/>
-	<string name="no_copy" value=" (pas de copie)"/>
-	<string name="worn" value=" (porté)"/>
-	<string name="link" value=" (lien)"/>
-	<string name="broken_link" value=" (broken_link)"/>
+	<string name="no_transfer" value="(pas de transfert)"/>
+	<string name="no_modify" value="(pas de modification)"/>
+	<string name="no_copy" value="(pas de copie)"/>
+	<string name="worn" value="(porté)"/>
+	<string name="link" value="(lien)"/>
+	<string name="broken_link" value="(broken_link)"/>
 	<string name="LoadingContents">
 		chargement des contenus en cours...
 	</string>
 	<string name="NoContents">
 		Aucun contenu
 	</string>
-	<string name="WornOnAttachmentPoint" value=" (porté sur [ATTACHMENT_POINT])"/>
+	<string name="WornOnAttachmentPoint" value="(porté sur [ATTACHMENT_POINT])"/>
 	<string name="PermYes">
 		Oui
 	</string>
 	<string name="PermNo">
 		Non
 	</string>
-	<string name="Chat" value=" Chat :"/>
-	<string name="Sound" value=" Son :"/>
-	<string name="Wait" value=" --- Attendre :"/>
-	<string name="AnimFlagStop" value=" Arrêter l&apos;animation :"/>
-	<string name="AnimFlagStart" value=" Démarrer l&apos;animation :"/>
-	<string name="Wave" value=" Faire signe"/>
-	<string name="HelloAvatar" value=" Bonjour, avatar !"/>
-	<string name="ViewAllGestures" value="  Tout afficher &gt;&gt;"/>
-	<string name="Animations" value=" Animations,"/>
-	<string name="Calling Cards" value=" Cartes de visite,"/>
-	<string name="Clothing" value=" Habits,"/>
-	<string name="Gestures" value=" Gestes,"/>
-	<string name="Landmarks" value=" Repères,"/>
-	<string name="Notecards" value=" Notes,"/>
-	<string name="Objects" value=" Objets,"/>
-	<string name="Scripts" value=" Scripts,"/>
-	<string name="Sounds" value=" Sons,"/>
-	<string name="Textures" value=" Textures,"/>
-	<string name="Snapshots" value=" Photos,"/>
-	<string name="No Filters" value="Non "/>
-	<string name="Since Logoff" value=" - Depuis la déconnexion"/>
+	<string name="Chat" value="Chat :"/>
+	<string name="Sound" value="Son :"/>
+	<string name="Wait" value="--- Attendre :"/>
+	<string name="AnimFlagStop" value="Arrêter l&apos;animation :"/>
+	<string name="AnimFlagStart" value="Démarrer l&apos;animation :"/>
+	<string name="Wave" value="Faire signe"/>
+	<string name="HelloAvatar" value="Bonjour, avatar !"/>
+	<string name="ViewAllGestures" value="Tout afficher &gt;&gt;"/>
+	<string name="Animations" value="Animations,"/>
+	<string name="Calling Cards" value="Cartes de visite,"/>
+	<string name="Clothing" value="Habits,"/>
+	<string name="Gestures" value="Gestes,"/>
+	<string name="Landmarks" value="Repères,"/>
+	<string name="Notecards" value="Notes,"/>
+	<string name="Objects" value="Objets,"/>
+	<string name="Scripts" value="Scripts,"/>
+	<string name="Sounds" value="Sons,"/>
+	<string name="Textures" value="Textures,"/>
+	<string name="Snapshots" value="Photos,"/>
+	<string name="No Filters" value="Non"/>
+	<string name="Since Logoff" value="- Depuis la déconnexion"/>
 	<string name="InvFolder My Inventory">
 		Mon inventaire
 	</string>
@@ -1239,13 +1239,13 @@
 	<string name="GroupsNone">
 		aucun
 	</string>
-	<string name="Group" value=" (groupe)"/>
+	<string name="Group" value="(groupe)"/>
 	<string name="Unknown">
 		(Inconnu)
 	</string>
-	<string name="SummaryForTheWeek" value="Récapitulatif de la semaine, début le "/>
-	<string name="NextStipendDay" value="Prochaine prime le "/>
-	<string name="GroupIndividualShare" value="                      Groupe    Part individuelle"/>
+	<string name="SummaryForTheWeek" value="Récapitulatif de la semaine, début le"/>
+	<string name="NextStipendDay" value="Prochaine prime le"/>
+	<string name="GroupIndividualShare" value="Groupe 	 Part individuelle"/>
 	<string name="Balance">
 		Solde
 	</string>
@@ -1324,8 +1324,8 @@
 	<string name="covenant_last_modified">
 		Dernière modification :
 	</string>
-	<string name="none_text" value=" (aucun)"/>
-	<string name="never_text" value=" (jamais)"/>
+	<string name="none_text" value="(aucun)"/>
+	<string name="never_text" value="(jamais)"/>
 	<string name="GroupOwned">
 		Propriété du groupe
 	</string>
@@ -1616,7 +1616,7 @@ Si le problème persiste, vous devrez peut-être complètement désinstaller pui
 		Erreur fatale
 	</string>
 	<string name="MBRequiresAltiVec">
-		 [APP_NAME] nécessite un microprocesseur AltiVec (version G4 ou antérieure).
+		[APP_NAME] nécessite un microprocesseur AltiVec (version G4 ou antérieure).
 	</string>
 	<string name="MBAlreadyRunning">
 		[APP_NAME] est déjà en cours d&apos;exécution.
diff --git a/indra/newview/skins/default/xui/it/floater_buy_currency.xml b/indra/newview/skins/default/xui/it/floater_buy_currency.xml
index 8a597642516..a22850bc4b9 100644
--- a/indra/newview/skins/default/xui/it/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/it/floater_buy_currency.xml
@@ -52,11 +52,10 @@
 	<text name="total_amount">
 		[AMT]L$
 	</text>
-	<text name="currency_links">
-		[http://www.secondlife.com/my/account/payment_method_management.php?lang=it-IT payment method] | [http://www.secondlife.com/my/account/currency.php?lang=it-IT currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=it-IT exchange rate]
-	</text>
-	<text name="purchase_warning_repurchase">
-		Confermando questa operazione si acquisterà solo la valuta. Per acquistare il bene, dovrai riprovare l&apos;operazione nuovamente.
+	<text name="purchase_warning_repurchase" height="48" bottom_delta="-64" right="-10">
+		Confermando questa operazione si acquisterà solo
+la valuta. Per acquistare il bene, dovrai riprovare
+l&apos;operazione nuovamente.
 	</text>
 	<text name="purchase_warning_notenough" bottom_delta="16">
 		Non stai comprando abbastanza denaro.
diff --git a/indra/newview/skins/default/xui/ja/floater_buy_currency.xml b/indra/newview/skins/default/xui/ja/floater_buy_currency.xml
index 9d49a389822..03cd0f391ad 100644
--- a/indra/newview/skins/default/xui/ja/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/ja/floater_buy_currency.xml
@@ -46,7 +46,7 @@
 		L$ [AMT]
 	</text>
 	<text name="currency_links">
-		[http://www.secondlife.com/my/account/payment_method_management.php?lang=ja-JP payment method] | [http://www.secondlife.com/my/account/currency.php?lang=ja-JP currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=ja-JP exchange rate]
+		[http://www.secondlife.com/ payment method] | [http://www.secondlife.com/ currency] | [http://www.secondlife.com exchange rate]
 	</text>
 	<text name="exchange_rate_note">
 		金額を再入力して最新換算レートを確認します。
diff --git a/indra/newview/skins/default/xui/ja/strings.xml b/indra/newview/skins/default/xui/ja/strings.xml
index b37d97bc5dc..4d395b474f3 100644
--- a/indra/newview/skins/default/xui/ja/strings.xml
+++ b/indra/newview/skins/default/xui/ja/strings.xml
@@ -166,7 +166,7 @@
 	<string name="TooltipSLAPP">
 		クリックして secondlife:// コマンドを出す
 	</string>
-	<string name="CurrentURL" value=" 現在のURL: [CurrentURL]"/>
+	<string name="CurrentURL" value="現在のURL: [CurrentURL]"/>
 	<string name="SLurlLabelTeleport">
 		テレポート
 	</string>
@@ -174,7 +174,7 @@
 		地図に表示
 	</string>
 	<string name="BUTTON_CLOSE_DARWIN">
-		閉じる (&#8984;W)
+		閉じる (⌘W)
 	</string>
 	<string name="BUTTON_CLOSE_WIN">
 		閉じる (Ctrl+W)
@@ -821,33 +821,33 @@
 	<string name="InventoryNoTexture">
 		持ち物内にこのテクスチャのコピーがありません
 	</string>
-	<string name="no_transfer" value=" (再販/プレゼント不可)"/>
-	<string name="no_modify" value=" (編集不可)"/>
-	<string name="no_copy" value=" (コピー不可)"/>
-	<string name="worn" value=" (着用中)"/>
-	<string name="link" value=" (リンク)"/>
-	<string name="broken_link" value=" (壊れたリンク)"/>
+	<string name="no_transfer" value="(再販/プレゼント不可)"/>
+	<string name="no_modify" value="(編集不可)"/>
+	<string name="no_copy" value="(コピー不可)"/>
+	<string name="worn" value="(着用中)"/>
+	<string name="link" value="(リンク)"/>
+	<string name="broken_link" value="(壊れたリンク)"/>
 	<string name="LoadingContents">
 		コンテンツをロード中です...
 	</string>
 	<string name="NoContents">
 		コンテンツなし
 	</string>
-	<string name="WornOnAttachmentPoint" value=" ([ATTACHMENT_POINT] に装着中)"/>
+	<string name="WornOnAttachmentPoint" value="([ATTACHMENT_POINT] に装着中)"/>
 	<string name="PermYes">
 		はい
 	</string>
 	<string name="PermNo">
 		いいえ
 	</string>
-	<string name="Chat" value=" チャット:"/>
-	<string name="Sound" value=" サウンド:"/>
-	<string name="Wait" value=" --- 待機::"/>
-	<string name="AnimFlagStop" value=" アニメーションを停止:"/>
-	<string name="AnimFlagStart" value=" アニメーションを開始:"/>
-	<string name="Wave" value=" 手を振る"/>
-	<string name="HelloAvatar" value=" やあ、アバター!"/>
-	<string name="ViewAllGestures" value="  すべて表示 &gt;&gt;"/>
+	<string name="Chat" value="チャット:"/>
+	<string name="Sound" value="サウンド:"/>
+	<string name="Wait" value="--- 待機::"/>
+	<string name="AnimFlagStop" value="アニメーションを停止:"/>
+	<string name="AnimFlagStart" value="アニメーションを開始:"/>
+	<string name="Wave" value="手を振る"/>
+	<string name="HelloAvatar" value="やあ、アバター!"/>
+	<string name="ViewAllGestures" value="すべて表示 &gt;&gt;"/>
 	<string name="Animations" value="アニメーション、"/>
 	<string name="Calling Cards" value="コーリングカード、"/>
 	<string name="Clothing" value="衣類、"/>
@@ -859,8 +859,8 @@
 	<string name="Sounds" value="サウンド、"/>
 	<string name="Textures" value="テクスチャ、"/>
 	<string name="Snapshots" value="スナップショット、"/>
-	<string name="No Filters" value="いいえ "/>
-	<string name="Since Logoff" value=" - ログオフ以来"/>
+	<string name="No Filters" value="いいえ"/>
+	<string name="Since Logoff" value="- ログオフ以来"/>
 	<string name="InvFolder My Inventory">
 		マイ 持ち物
 	</string>
@@ -1239,13 +1239,13 @@
 	<string name="GroupsNone">
 		なし
 	</string>
-	<string name="Group" value=" (グループ)"/>
+	<string name="Group" value="(グループ)"/>
 	<string name="Unknown">
 		(不明)
 	</string>
 	<string name="SummaryForTheWeek" value="今週のまとめ。開始日は"/>
 	<string name="NextStipendDay" value="次回のお小遣い支給日は"/>
-	<string name="GroupIndividualShare" value="                      グループ       個人の割り当て"/>
+	<string name="GroupIndividualShare" value="グループ   個人の割り当て"/>
 	<string name="Balance">
 		残高
 	</string>
@@ -1324,8 +1324,8 @@
 	<string name="covenant_last_modified">
 		最終修正日:
 	</string>
-	<string name="none_text" value=" (なし)"/>
-	<string name="never_text" value=" (無)"/>
+	<string name="none_text" value="(なし)"/>
+	<string name="never_text" value="(無)"/>
 	<string name="GroupOwned">
 		グループ所有
 	</string>
@@ -1616,7 +1616,7 @@
 		致命的なエラー
 	</string>
 	<string name="MBRequiresAltiVec">
-		 [APP_NAME] は、AltiVec搭載のプロセッサが必要です。(G4 以降)
+		[APP_NAME] は、AltiVec搭載のプロセッサが必要です。(G4 以降)
 	</string>
 	<string name="MBAlreadyRunning">
 		[APP_NAME] はすでに実行中です。
diff --git a/indra/newview/skins/default/xui/pt/floater_buy_currency.xml b/indra/newview/skins/default/xui/pt/floater_buy_currency.xml
index f17c069ecf0..aac8438fdcf 100644
--- a/indra/newview/skins/default/xui/pt/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/pt/floater_buy_currency.xml
@@ -52,9 +52,6 @@
 	<text name="total_amount">
 		L$ [AMT]
 	</text>
-	<text name="currency_links">
-		[http://www.secondlife.com/my/account/payment_method_management.php?lang=pt-BR payment method] | [http://www.secondlife.com/my/account/currency.php?lang=pt-BR currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=pt-BR exchange rate]
-	</text>
 	<text name="purchase_warning_repurchase">
 		Confirmando esta compra só compra a moeda.
 Você precisará tentar novamente a operação.
diff --git a/install.xml b/install.xml
index e912ddfd8b0..41f8a28044c 100644
--- a/install.xml
+++ b/install.xml
@@ -1014,23 +1014,23 @@ anguage Infrstructure (CLI) international standard</string>
           <key>darwin</key>
           <map>
             <key>md5sum</key>
-            <string>2eb58f544c0d912aa382de2c947be7f1</string>
+            <string>5362a53488693f9bd7d9083758af25eb</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-4.6-darwin-20100104.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-4.6-darwin-20091218.tar.bz2</uri>
           </map>
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>c4c40fca14a8bd32096f8a27c75c526f</string>
+            <string>09674cbae982e7e7f6ebc7e1d06580e8</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-linux-20100105c.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-linux-20091216.tar.bz2</uri>
           </map>
           <key>windows</key>
           <map>
             <key>md5sum</key>
-            <string>b50db4fdb833111e1e679188e4cb5815</string>
+            <string>4dd305f2ce38b2e55a2014ad3a2de34d</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-windows-qt4.6-20100104.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-windows-qt4.6-20091218.tar.bz2</uri>
           </map>
         </map>
       </map>
-- 
GitLab


From 1a8008ea150d1eb9a8f4036988ef971fb1901cb3 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 14 Jan 2010 14:44:43 -0800
Subject: [PATCH 055/683] Backed out changeset f34a69c2af56

(this backs-out my backout, now that I'm happy the original merge works okay :))
---
 indra/llcommon/llfasttimer.h                  | 163 ++++++-----
 indra/llplugin/llpluginclassmedia.cpp         |  30 ++-
 indra/llplugin/llpluginclassmedia.h           |  12 +
 indra/llui/llfloater.cpp                      |  46 ++--
 indra/llui/llmenugl.cpp                       |   2 +-
 indra/llui/lltexteditor.cpp                   |   3 +-
 .../webkit/media_plugin_webkit.cpp            |   1 +
 indra/newview/CMakeLists.txt                  |   8 +-
 indra/newview/app_settings/settings.xml       |  13 +-
 .../darwin/fix_application_icon_position.sh   |  14 +
 indra/newview/llagent.cpp                     |   9 +-
 indra/newview/llagent.h                       |   1 +
 indra/newview/llavatarlist.cpp                |   7 +-
 indra/newview/llavatarlistitem.cpp            | 251 ++++++++++-------
 indra/newview/llavatarlistitem.h              |  71 +++--
 indra/newview/llbottomtray.cpp                |  17 +-
 indra/newview/llcallfloater.cpp               |  12 +-
 indra/newview/llchathistory.cpp               |  49 ++--
 indra/newview/llfloaterabout.cpp              |   2 +-
 indra/newview/llfloaterchat.cpp               |  15 +-
 indra/newview/llfloatergesture.cpp            |   2 +-
 indra/newview/llfloatergroups.cpp             |   9 +-
 indra/newview/llfloaterland.cpp               |   7 +-
 indra/newview/llfloaterland.h                 |   1 -
 indra/newview/llfloaterpreference.cpp         |   2 +-
 indra/newview/llfloaterregioninfo.cpp         |   5 +
 indra/newview/llgesturemgr.cpp                |  10 +
 indra/newview/llgesturemgr.h                  |   2 +
 indra/newview/llgroupactions.cpp              |  10 +-
 indra/newview/llimfloater.cpp                 |  86 +++---
 indra/newview/llimfloater.h                   |   5 +-
 indra/newview/llimfloatercontainer.cpp        |  11 +
 indra/newview/llimfloatercontainer.h          |   6 +-
 indra/newview/llimview.cpp                    |  19 +-
 indra/newview/llimview.h                      |   5 +
 indra/newview/llinspectavatar.cpp             |   1 +
 indra/newview/llinspecttoast.cpp              | 122 +++++++++
 indra/newview/llinspecttoast.h                |  40 +++
 indra/newview/llinventorymodel.cpp            |   8 +-
 indra/newview/llinventoryobserver.cpp         |  35 ++-
 indra/newview/llmediactrl.cpp                 |  45 ++--
 indra/newview/llmediactrl.h                   |   1 -
 indra/newview/llnamebox.cpp                   |  24 +-
 indra/newview/llnamebox.h                     |   5 +
 indra/newview/llnearbychat.cpp                |  22 +-
 indra/newview/llnearbychatbar.cpp             | 252 ++++++++++++-----
 indra/newview/llnearbychatbar.h               |  47 +++-
 indra/newview/llnearbychathandler.cpp         |  25 +-
 indra/newview/lloutputmonitorctrl.cpp         |  65 ++++-
 indra/newview/lloutputmonitorctrl.h           |  29 +-
 indra/newview/llpanelavatar.cpp               |  18 +-
 indra/newview/llpanelgroup.cpp                |  55 +++-
 indra/newview/llpanelgroup.h                  |   4 +
 indra/newview/llpanelgroupgeneral.cpp         |  11 +-
 indra/newview/llpanelgrouproles.cpp           |  61 +++--
 indra/newview/llpanelgrouproles.h             |  13 +-
 indra/newview/llpanelimcontrolpanel.cpp       |   2 +-
 indra/newview/llpanelpeople.cpp               |   8 +-
 indra/newview/llpanelpick.cpp                 |  80 +++---
 indra/newview/llpanelpick.h                   |  18 +-
 indra/newview/llpanelplaces.h                 |   4 +
 indra/newview/llpanelteleporthistory.cpp      |   2 +-
 indra/newview/llpanelvolumepulldown.cpp       | 154 +++++++++++
 indra/newview/llpanelvolumepulldown.h         |  64 +++++
 indra/newview/llparticipantlist.cpp           |   8 +-
 indra/newview/llscreenchannel.cpp             | 149 ++--------
 indra/newview/llscreenchannel.h               |  19 +-
 indra/newview/llspeakers.cpp                  |   5 +
 indra/newview/llspeakers.h                    |   2 +
 indra/newview/llspeakingindicatormanager.cpp  | 254 ++++++++++++++++++
 indra/newview/llspeakingindicatormanager.h    |  67 +++++
 indra/newview/llstatusbar.cpp                 |  19 +-
 indra/newview/llstatusbar.h                   |   2 +-
 indra/newview/llsyswellitem.cpp               |   3 +-
 indra/newview/llsyswellwindow.cpp             |   3 +-
 indra/newview/llsyswellwindow.h               |   3 +
 indra/newview/llteleporthistorystorage.cpp    |   7 -
 indra/newview/lltoastnotifypanel.cpp          |   4 +-
 indra/newview/llviewerdisplay.cpp             |  20 +-
 indra/newview/llviewerfloaterreg.cpp          |   5 +-
 indra/newview/llviewermessage.cpp             |  56 ++--
 indra/newview/llviewerwindow.cpp              |  34 +--
 indra/newview/llvoiceclient.cpp               |  11 +
 indra/newview/llvoiceclient.h                 |   1 +
 .../textures/bottomtray/Unread_Chiclet.png    | Bin 250 -> 328 bytes
 .../textures/bottomtray/WellButton_Lit.png    | Bin 553 -> 490 bytes
 .../bottomtray/WellButton_Lit_Selected.png    | Bin 687 -> 302 bytes
 .../skins/default/textures/textures.xml       |  28 +-
 .../default/xui/de/floater_buy_currency.xml   |   2 +-
 .../default/xui/de/floater_help_browser.xml   |   4 +-
 .../newview/skins/default/xui/de/strings.xml  |  72 ++---
 .../skins/default/xui/en/floater_about.xml    |   2 +-
 .../default/xui/en/floater_about_land.xml     |   8 +-
 .../default/xui/en/floater_buy_currency.xml   |   4 +-
 .../default/xui/en/floater_customize.xml      | 120 ++++-----
 .../default/xui/en/floater_god_tools.xml      |   2 +-
 .../skins/default/xui/en/floater_im.xml       |   2 +-
 .../default/xui/en/floater_nearby_chat.xml    |   4 +-
 .../default/xui/en/floater_report_abuse.xml   |   4 +-
 .../default/xui/en/floater_select_key.xml     |   8 +-
 .../default/xui/en/floater_top_objects.xml    |  20 +-
 .../skins/default/xui/en/floater_tos.xml      |   6 +-
 .../default/xui/en/floater_voice_controls.xml | 143 ++++------
 .../skins/default/xui/en/inspect_toast.xml    |  19 ++
 .../skins/default/xui/en/menu_viewer.xml      |  36 +--
 .../skins/default/xui/en/notifications.xml    |  33 ++-
 .../xui/en/panel_adhoc_control_panel.xml      |  17 +-
 .../default/xui/en/panel_avatar_list_item.xml |   7 +-
 .../xui/en/panel_block_list_sidetray.xml      |   6 +-
 .../skins/default/xui/en/panel_bottomtray.xml |  45 ++--
 .../skins/default/xui/en/panel_edit_pick.xml  |  32 ++-
 .../default/xui/en/panel_edit_profile.xml     |   3 +-
 .../skins/default/xui/en/panel_friends.xml    |   2 +-
 .../xui/en/panel_group_control_panel.xml      |  20 +-
 .../xui/en/panel_group_info_sidetray.xml      |  18 +-
 .../default/xui/en/panel_group_invite.xml     |  14 +-
 .../default/xui/en/panel_group_list_item.xml  |   1 +
 .../default/xui/en/panel_group_notices.xml    |   1 +
 .../default/xui/en/panel_group_roles.xml      |  55 ++--
 .../skins/default/xui/en/panel_login.xml      |   1 +
 .../xui/en/panel_media_settings_general.xml   |   5 +-
 .../skins/default/xui/en/panel_my_profile.xml |  20 +-
 .../default/xui/en/panel_navigation_bar.xml   |   4 +-
 .../default/xui/en/panel_nearby_chat_bar.xml  |   4 +-
 .../skins/default/xui/en/panel_notes.xml      |   6 +-
 .../skins/default/xui/en/panel_people.xml     |  10 +-
 .../skins/default/xui/en/panel_pick_info.xml  |  33 ++-
 .../xui/en/panel_preferences_advanced.xml     |   1 -
 .../xui/en/panel_preferences_general.xml      |  15 +-
 .../xui/en/panel_preferences_graphics1.xml    |   4 +-
 .../xui/en/panel_prim_media_controls.xml      |   1 +
 .../skins/default/xui/en/panel_profile.xml    |  26 +-
 .../default/xui/en/panel_region_covenant.xml  |  10 +-
 .../default/xui/en/panel_region_estate.xml    |  12 +-
 .../default/xui/en/panel_region_texture.xml   |   4 +-
 .../skins/default/xui/en/panel_status_bar.xml |  36 ++-
 .../default/xui/en/panel_volume_pulldown.xml  |  55 ++++
 .../default/xui/en/sidepanel_task_info.xml    |  36 +--
 .../newview/skins/default/xui/en/strings.xml  |  16 +-
 .../xui/en/widgets/chiclet_im_adhoc.xml       |  22 +-
 .../xui/en/widgets/chiclet_im_group.xml       |  23 +-
 .../default/xui/en/widgets/chiclet_im_p2p.xml |  18 +-
 .../default/xui/en/widgets/chiclet_offer.xml  |  14 +-
 .../default/xui/en/widgets/chiclet_script.xml |  14 +-
 .../xui/en/widgets/gesture_combo_box.xml      |  30 ---
 .../xui/en/widgets/gesture_combo_list.xml     |  21 ++
 .../default/xui/en/widgets/location_input.xml |  18 +-
 .../default/xui/es/floater_buy_currency.xml   |   3 +
 .../default/xui/fr/floater_buy_currency.xml   |   4 +-
 .../default/xui/fr/floater_help_browser.xml   |   4 +-
 .../newview/skins/default/xui/fr/strings.xml  |  74 ++---
 .../default/xui/it/floater_buy_currency.xml   |   9 +-
 .../default/xui/ja/floater_buy_currency.xml   |   2 +-
 .../newview/skins/default/xui/ja/strings.xml  |  48 ++--
 .../default/xui/pt/floater_buy_currency.xml   |   3 +
 install.xml                                   |  12 +-
 156 files changed, 2689 insertions(+), 1460 deletions(-)
 create mode 100644 indra/newview/installers/darwin/fix_application_icon_position.sh
 create mode 100644 indra/newview/llinspecttoast.cpp
 create mode 100644 indra/newview/llinspecttoast.h
 create mode 100644 indra/newview/llpanelvolumepulldown.cpp
 create mode 100644 indra/newview/llpanelvolumepulldown.h
 create mode 100644 indra/newview/llspeakingindicatormanager.cpp
 create mode 100644 indra/newview/llspeakingindicatormanager.h
 create mode 100644 indra/newview/skins/default/xui/en/inspect_toast.xml
 create mode 100644 indra/newview/skins/default/xui/en/panel_volume_pulldown.xml
 delete mode 100644 indra/newview/skins/default/xui/en/widgets/gesture_combo_box.xml
 create mode 100644 indra/newview/skins/default/xui/en/widgets/gesture_combo_list.xml

diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index f5c90291b80..5058a2e772d 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -39,40 +39,30 @@
 #define TIME_FAST_TIMERS 0
 
 #if LL_WINDOWS
-
+// because MS has different signatures for these functions in winnt.h
+// need to rename them to avoid conflicts
+#define _interlockedbittestandset _renamed_interlockedbittestandset
+#define _interlockedbittestandreset _renamed_interlockedbittestandreset
+#include <intrin.h>
+#undef _interlockedbittestandset
+#undef _interlockedbittestandreset
+
+#define LL_INLINE __forceinline
 // shift off lower 8 bits for lower resolution but longer term timing
 // on 1Ghz machine, a 32-bit word will hold ~1000 seconds of timing
 inline U32 get_cpu_clock_count_32()
 {
-	U32 ret_val;
-	__asm 
-	{
-        _emit   0x0f
-        _emit   0x31
-		shr eax,8
-		shl edx,24
-		or eax, edx
-		mov dword ptr [ret_val], eax
-	}
-    return ret_val;
+	U64 time_stamp = __rdtsc();
+	return (U32)(time_stamp >> 8);
 }
 
 // return full timer value, *not* shifted by 8 bits
 inline U64 get_cpu_clock_count_64()
 {
-	U64 ret_val;
-	__asm 
-	{
-        _emit   0x0f
-        _emit   0x31
-		mov eax,eax
-		mov edx,edx
-		mov dword ptr [ret_val+4], edx
-		mov dword ptr [ret_val], eax
-	}
-    return ret_val;
+	return __rdtsc();
 }
-
+#else
+#define LL_INLINE
 #endif // LL_WINDOWS
 
 #if (LL_LINUX || LL_SOLARIS || LL_DARWIN) && (defined(__i386__) || defined(__amd64__))
@@ -113,10 +103,25 @@ class LLMutex;
 #include <queue>
 #include "llsd.h"
 
-
 class LL_COMMON_API LLFastTimer
 {
 public:
+
+	class NamedTimer;
+
+	struct LL_COMMON_API FrameState
+	{
+		FrameState(NamedTimer* timerp);
+
+		U32 				mSelfTimeCounter;
+		U32 				mCalls;
+		FrameState*			mParent;		// info for caller timer
+		FrameState*			mLastCaller;	// used to bootstrap tree construction
+		NamedTimer*			mTimer;
+		U16					mActiveCount;	// number of timers with this ID active on stack
+		bool				mMoveUpTree;	// needs to be moved up the tree of timers at the end of frame
+	};
+
 	// stores a "named" timer instance to be reused via multiple LLFastTimer stack instances
 	class LL_COMMON_API NamedTimer 
 	:	public LLInstanceTracker<NamedTimer>
@@ -149,24 +154,10 @@ class LL_COMMON_API LLFastTimer
 
 		static NamedTimer& getRootNamedTimer();
 
-		struct FrameState
-		{
-			FrameState(NamedTimer* timerp);
-
-			U32 		mSelfTimeCounter;
-			U32 		mCalls;
-			FrameState*	mParent;		// info for caller timer
-			FrameState*	mLastCaller;	// used to bootstrap tree construction
-			NamedTimer*	mTimer;
-			U16			mActiveCount;	// number of timers with this ID active on stack
-			bool		mMoveUpTree;	// needs to be moved up the tree of timers at the end of frame
-		};
-
 		S32 getFrameStateIndex() const { return mFrameStateIndex; }
 
 		FrameState& getFrameState() const;
 
-
 	private: 
 		friend class LLFastTimer;
 		friend class NamedTimerFactory;
@@ -185,7 +176,6 @@ class LL_COMMON_API LLFastTimer
 		static void buildHierarchy();
 		static void resetFrame();
 		static void reset();
-
 	
 		//
 		// members
@@ -207,58 +197,47 @@ class LL_COMMON_API LLFastTimer
 		std::vector<NamedTimer*>	mChildren;
 		bool						mCollapsed;				// don't show children
 		bool						mNeedsSorting;			// sort children whenever child added
-
 	};
 
 	// used to statically declare a new named timer
 	class LL_COMMON_API DeclareTimer
 	:	public LLInstanceTracker<DeclareTimer>
 	{
+		friend class LLFastTimer;
 	public:
 		DeclareTimer(const std::string& name, bool open);
 		DeclareTimer(const std::string& name);
 
 		static void updateCachedPointers();
 
-		// convertable to NamedTimer::FrameState for convenient usage of LLFastTimer(declared_timer)
-		operator NamedTimer::FrameState&() { return *mFrameState; }
 	private:
-		NamedTimer&				mTimer;
-		NamedTimer::FrameState* mFrameState; 
+		NamedTimer&		mTimer;
+		FrameState*		mFrameState; 
 	};
 
-
 public:
-	static LLMutex* sLogLock;
-	static std::queue<LLSD> sLogQueue;
-	static BOOL sLog;
-	static BOOL sMetricLog;
-
-	typedef std::vector<NamedTimer::FrameState> info_list_t;
-	static info_list_t& getFrameStateList();
+	LLFastTimer(LLFastTimer::FrameState* state);
 
-	enum RootTimerMarker { ROOT };
-	LLFastTimer(RootTimerMarker);
-
-	LLFastTimer(NamedTimer::FrameState& timer)
-	:	mFrameState(&timer)
+	LL_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer)
+	:	mFrameState(timer.mFrameState)
 	{
 #if TIME_FAST_TIMERS
 		U64 timer_start = get_cpu_clock_count_64();
 #endif
 #if FAST_TIMER_ON
-		NamedTimer::FrameState* frame_state = &timer;
-		U32 cur_time = get_cpu_clock_count_32();
-		mStartSelfTime = cur_time;
-		mStartTotalTime = cur_time;
+		LLFastTimer::FrameState* frame_state = mFrameState;
+		mStartTime = get_cpu_clock_count_32();
 
 		frame_state->mActiveCount++;
 		frame_state->mCalls++;
 		// keep current parent as long as it is active when we are
 		frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0);
 	
-		mLastTimer = sCurTimer;
-		sCurTimer = this;
+		LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData;
+		mLastTimerData = *cur_timer_data;
+		cur_timer_data->mCurTimer = this;
+		cur_timer_data->mFrameState = frame_state;
+		cur_timer_data->mChildTime = 0;
 #endif
 #if TIME_FAST_TIMERS
 		U64 timer_end = get_cpu_clock_count_64();
@@ -266,26 +245,26 @@ class LL_COMMON_API LLFastTimer
 #endif
 	}
 
-	~LLFastTimer()
+	LL_INLINE ~LLFastTimer()
 	{
 #if TIME_FAST_TIMERS
 		U64 timer_start = get_cpu_clock_count_64();
 #endif
 #if FAST_TIMER_ON
-		NamedTimer::FrameState* frame_state = mFrameState;
-		U32 cur_time = get_cpu_clock_count_32();
-		frame_state->mSelfTimeCounter += cur_time - mStartSelfTime;
+		LLFastTimer::FrameState* frame_state = mFrameState;
+		U32 total_time = get_cpu_clock_count_32() - mStartTime;
 
+		frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime;
 		frame_state->mActiveCount--;
-		LLFastTimer* last_timer = mLastTimer;
-		sCurTimer = last_timer;
 
 		// store last caller to bootstrap tree creation
-		frame_state->mLastCaller = last_timer->mFrameState;
+		// do this in the destructor in case of recursion to get topmost caller
+		frame_state->mLastCaller = mLastTimerData.mFrameState;
 
 		// we are only tracking self time, so subtract our total time delta from parents
-		U32 total_time = cur_time - mStartTotalTime;
-		last_timer->mStartSelfTime += total_time;
+		mLastTimerData.mChildTime += total_time;
+
+		LLFastTimer::sCurTimerData = mLastTimerData;
 #endif
 #if TIME_FAST_TIMERS
 		U64 timer_end = get_cpu_clock_count_64();
@@ -294,7 +273,20 @@ class LL_COMMON_API LLFastTimer
 #endif	
 	}
 
+public:
+	static LLMutex*			sLogLock;
+	static std::queue<LLSD> sLogQueue;
+	static BOOL				sLog;
+	static BOOL				sMetricLog;
+	static bool 			sPauseHistory;
+	static bool 			sResetHistory;
+	static U64				sTimerCycles;
+	static U32				sTimerCalls;
 
+	typedef std::vector<FrameState> info_list_t;
+	static info_list_t& getFrameStateList();
+
+	
 	// call this once a frame to reset timers
 	static void nextFrame();
 
@@ -312,23 +304,26 @@ class LL_COMMON_API LLFastTimer
 	static void writeLog(std::ostream& os);
 	static const NamedTimer* getTimerByName(const std::string& name);
 
-public:
-	static bool 			sPauseHistory;
-	static bool 			sResetHistory;
-	static U64				sTimerCycles;
-	static U32				sTimerCalls;
-	
+	struct CurTimerData
+	{
+		LLFastTimer*	mCurTimer;
+		FrameState*		mFrameState;
+		U32				mChildTime;
+	};
+	static CurTimerData		sCurTimerData;
+
 private:
-	static LLFastTimer*		sCurTimer;
 	static S32				sCurFrameIndex;
 	static S32				sLastFrameIndex;
 	static U64				sLastFrameTime;
 	static info_list_t*		sTimerInfos;
 
-	U32						mStartSelfTime;	// start time + time of all child timers
-	U32						mStartTotalTime;	// start time + time of all child timers
-	NamedTimer::FrameState*	mFrameState;
-	LLFastTimer*			mLastTimer;
+	U32							mStartTime;
+	LLFastTimer::FrameState*	mFrameState;
+	LLFastTimer::CurTimerData	mLastTimerData;
+
 };
 
+typedef class LLFastTimer LLFastTimer;
+
 #endif // LL_LLFASTTIMER_H
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index ed8d10a88c4..3d2eaed5c5a 100644
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -37,6 +37,8 @@
 #include "llpluginclassmedia.h"
 #include "llpluginmessageclasses.h"
 
+#include "llqtwebkit.h"
+
 static int LOW_PRIORITY_TEXTURE_SIZE_DEFAULT = 256;
 
 static int nextPowerOf2( int value )
@@ -124,7 +126,7 @@ void LLPluginClassMedia::reset()
 	mCanPaste = false;
 	mMediaName.clear();
 	mMediaDescription.clear();
-	mBackgroundColor = LLColor4::white;
+	mBackgroundColor = LLColor4(1.0f, 1.0f, 1.0f, 1.0f);
 	
 	// media_browser class
 	mNavigateURI.clear();
@@ -134,6 +136,9 @@ void LLPluginClassMedia::reset()
 	mHistoryForwardAvailable = false;
 	mStatusText.clear();
 	mProgressPercent = 0;	
+	mClickURL.clear();
+	mClickTarget.clear();
+	mClickTargetType = TARGET_NONE;
 	
 	// media_time class
 	mCurrentTime = 0.0f;
@@ -669,6 +674,26 @@ void LLPluginClassMedia::paste()
 	sendMessage(message);
 }
 
+LLPluginClassMedia::ETargetType getTargetTypeFromLLQtWebkit(int target_type)
+{
+	// convert a LinkTargetType value from llqtwebkit to an ETargetType
+	// so that we don't expose the llqtwebkit header in viewer code
+	switch (target_type)
+	{
+	case LinkTargetType::LTT_TARGET_NONE:
+		return LLPluginClassMedia::TARGET_NONE;
+
+	case LinkTargetType::LTT_TARGET_BLANK:
+		return LLPluginClassMedia::TARGET_BLANK;
+
+	case LinkTargetType::LTT_TARGET_EXTERNAL:
+		return LLPluginClassMedia::TARGET_EXTERNAL;
+
+	default:
+		return LLPluginClassMedia::TARGET_OTHER;
+	}
+}
+
 /* virtual */ 
 void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
 {
@@ -921,12 +946,15 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
 		{
 			mClickURL = message.getValue("uri");
 			mClickTarget = message.getValue("target");
+			U32 target_type = message.getValueU32("target_type");
+			mClickTargetType = ::getTargetTypeFromLLQtWebkit(target_type);
 			mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_CLICK_LINK_HREF);
 		}
 		else if(message_name == "click_nofollow")
 		{
 			mClickURL = message.getValue("uri");
 			mClickTarget.clear();
+			mClickTargetType = TARGET_NONE;
 			mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_CLICK_LINK_NOFOLLOW);
 		}
 		else
diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h
index 5a1928ab1df..ebb90995766 100644
--- a/indra/llplugin/llpluginclassmedia.h
+++ b/indra/llplugin/llpluginclassmedia.h
@@ -214,6 +214,17 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 	// This is valid after MEDIA_EVENT_CLICK_LINK_HREF
 	std::string getClickTarget() const { return mClickTarget; };
 
+	typedef enum 
+	{
+		TARGET_NONE,        // empty href target string
+		TARGET_BLANK,       // target to open link in user's preferred browser
+		TARGET_EXTERNAL,    // target to open link in external browser
+		TARGET_OTHER        // nonempty and unsupported target type
+	}ETargetType;
+
+	// This is valid after MEDIA_EVENT_CLICK_LINK_HREF
+	ETargetType getClickTargetType() const { return mClickTargetType; };
+
 	std::string getMediaName() const { return mMediaName; };
 	std::string getMediaDescription() const { return mMediaDescription; };
 
@@ -344,6 +355,7 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
 	std::string		mLocation;
 	std::string		mClickURL;
 	std::string		mClickTarget;
+	ETargetType     mClickTargetType;
 	
 	/////////////////////////////////////////
 	// media_time class
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 845203b420e..a17e3063258 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -878,9 +878,11 @@ void LLFloater::setSnappedTo(const LLView* snap_view)
 	else
 	{
 		//RN: assume it's a floater as it must be a sibling to our parent floater
-		LLFloater* floaterp = (LLFloater*)snap_view;
-		
-		setSnapTarget(floaterp->getHandle());
+		const LLFloater* floaterp = dynamic_cast<const LLFloater*>(snap_view);
+		if (floaterp)
+		{
+			setSnapTarget(floaterp->getHandle());
+		}
 	}
 }
 
@@ -1065,10 +1067,6 @@ void LLFloater::setMinimized(BOOL minimize)
 		reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE );
 	}
 	
-	// don't show the help button while minimized - it's
-	// not very useful when minimized and uses up space
-	mButtonsEnabled[BUTTON_HELP] = !minimize;
-
 	applyTitle ();
 
 	make_ui_sound("UISndWindowClose");
@@ -1741,14 +1739,32 @@ void LLFloater::updateButtons()
 	S32 button_count = 0;
 	for (S32 i = 0; i < BUTTON_COUNT; i++)
 	{
-		if(!mButtons[i]) continue;
-		mButtons[i]->setEnabled(mButtonsEnabled[i]);
+		if (!mButtons[i])
+		{
+			continue;
+		}
 
-		if (mButtonsEnabled[i] 
-			//*HACK: always render close button for hosted floaters
-			// so that users don't accidentally hit the button when closing multiple windows
-			// in the chatterbox
-			|| (i == BUTTON_CLOSE && mButtonScale != 1.f))
+		bool enabled = mButtonsEnabled[i];
+		if (i == BUTTON_HELP)
+		{
+			// don't show the help button if the floater is minimized
+			// or if it is a tear-off hosted floater
+			if (isMinimized() || mButtonsEnabled[BUTTON_TEAR_OFF])
+			{
+				enabled = false;
+			}
+		}
+		if (i == BUTTON_CLOSE && mButtonScale != 1.f)
+		{
+			//*HACK: always render close button for hosted floaters so
+			//that users don't accidentally hit the button when
+			//closing multiple windows in the chatterbox
+			enabled = true;
+		}
+
+		mButtons[i]->setEnabled(enabled);
+
+		if (enabled)
 		{
 			button_count++;
 
@@ -1775,7 +1791,7 @@ void LLFloater::updateButtons()
 			// the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater
 			mButtons[i]->setTabStop(i == BUTTON_RESTORE);
 		}
-		else if (mButtons[i])
+		else
 		{
 			mButtons[i]->setVisible(FALSE);
 		}
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index bd67949c2ae..21f3f157390 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -2966,7 +2966,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
 	LLUI::getMousePositionLocal(menu->getParent(), &mouse_x, &mouse_y);
 	LLMenuHolderGL::sContextMenuSpawnPos.set(mouse_x,mouse_y);
 
-	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
+	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getRect();
 
 	const S32 HPAD = 2;
 	LLRect rect = menu->getRect();
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index e8fc9475a54..f2c3879a6c9 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -308,7 +308,8 @@ LLTextEditor::~LLTextEditor()
 	// Scrollbar is deleted by LLView
 	std::for_each(mUndoStack.begin(), mUndoStack.end(), DeletePointer());
 
-	delete mContextMenu;
+	// context menu is owned by menu holder, not us
+	//delete mContextMenu;
 }
 
 ////////////////////////////////////////////////////////////
diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp
index a0336f6156c..084cdd9561a 100644
--- a/indra/media_plugins/webkit/media_plugin_webkit.cpp
+++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp
@@ -429,6 +429,7 @@ class MediaPluginWebKit :
 		LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_href");
 		message.setValue("uri", event.getStringValue());
 		message.setValue("target", event.getStringValue2());
+		message.setValueU32("target_type", event.getLinkType());
 		sendMessage(message);
 	}
 	
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 32761dbf275..5b4edefbc13 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -218,7 +218,6 @@ set(viewer_SOURCE_FILES
     llfloaterurldisplay.cpp
     llfloaterurlentry.cpp
     llfloatervoicedevicesettings.cpp
-    llfloatervolumepulldown.cpp
     llfloaterwater.cpp
     llfloaterwhitelistentry.cpp
     llfloaterwindlight.cpp
@@ -256,6 +255,7 @@ set(viewer_SOURCE_FILES
     llinspectgroup.cpp
     llinspectobject.cpp
     llinspectremoteobject.cpp
+    llinspecttoast.cpp
     llinventorybridge.cpp
     llinventoryclipboard.cpp
     llinventoryfilter.cpp
@@ -355,6 +355,7 @@ set(viewer_SOURCE_FILES
     llpanelshower.cpp
     llpanelteleporthistory.cpp
     llpanelvolume.cpp
+    llpanelvolumepulldown.cpp
     llparcelselection.cpp
     llparticipantlist.cpp
     llpatchvertexarray.cpp
@@ -393,6 +394,7 @@ set(viewer_SOURCE_FILES
     llspatialpartition.cpp
     llspeakbutton.cpp
     llspeakers.cpp
+    llspeakingindicatormanager.cpp
     llsplitbutton.cpp
     llsprite.cpp
     llstartup.cpp
@@ -765,6 +767,7 @@ set(viewer_HEADER_FILES
     llinspectgroup.h
     llinspectobject.h
     llinspectremoteobject.h
+    llinspecttoast.h
     llinventorybridge.h
     llinventoryclipboard.h
     llinventoryfilter.h
@@ -860,6 +863,7 @@ set(viewer_HEADER_FILES
     llpanelshower.h
     llpanelteleporthistory.h
     llpanelvolume.h
+    llpanelvolumepulldown.h
     llparcelselection.h
     llparticipantlist.h
     llpatchvertexarray.h
@@ -900,6 +904,7 @@ set(viewer_HEADER_FILES
     llspatialpartition.h
     llspeakbutton.h
     llspeakers.h
+    llspeakingindicatormanager.h
     llsplitbutton.h
     llsprite.h
     llstartup.h
@@ -1770,6 +1775,7 @@ if (INSTALL)
 endif (INSTALL)
 
 if (LL_TESTS)
+else (LL_TESTS)
   # To add a viewer unit test, just add the test .cpp file below
   # This creates a separate test project per file listed.
   include(LLAddBuildTest)
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4bfc6f9e4f8..db759f052a5 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1141,7 +1141,18 @@
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
-      <string>Boolean</string>
+      <string>S32</string>
+      <key>Value</key>
+      <integer>5</integer>
+    </map>
+    <key>CallFloaterMaxItems</key>
+    <map>
+      <key>Comment</key>
+      <string>Max number of visible participants in voice controls window</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>S32</string>
       <key>Value</key>
       <integer>1</integer>
     </map>
diff --git a/indra/newview/installers/darwin/fix_application_icon_position.sh b/indra/newview/installers/darwin/fix_application_icon_position.sh
new file mode 100644
index 00000000000..a0b72a89f25
--- /dev/null
+++ b/indra/newview/installers/darwin/fix_application_icon_position.sh
@@ -0,0 +1,14 @@
+# just run this script each time after you change the installer's name to fix the icon misalignment 
+#!/bin/bash
+cp -r ./../../../build-darwin-i386/newview/*.dmg ~/Desktop/TempBuild.dmg
+hdid ~/Desktop/TempBuild.dmg
+open -a finder /Volumes/Second\ Life\ Installer
+osascript dmg-cleanup.applescript
+cp /Volumes/Second\ Life\ Installer/.DS_Store ~/Desktop/_DS_Store
+chflags nohidden ~/Desktop/_DS_Store
+cp ~/Desktop/_DS_Store ./firstlook-dmg/_DS_Store
+cp ~/Desktop/_DS_Store ./publicnightly-dmg/_DS_Store
+cp ~/Desktop/_DS_Store ./release-dmg/_DS_Store
+cp ~/Desktop/_DS_Store ./releasecandidate-dmg/_DS_Store
+umount /Volumes/Second\ Life\ Installer/
+rm ~/Desktop/_DS_Store ~/Desktop/TempBuild.dmg
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 5e2e374df65..5ea253709cf 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -514,6 +514,8 @@ void LLAgent::resetView(BOOL reset_camera, BOOL change_camera)
 		}
 
 		setFocusOnAvatar(TRUE, ANIMATE);
+
+		mCameraFOVZoomFactor = 0.f;
 	}
 
 	mHUDTargetZoom = 1.f;
@@ -3584,7 +3586,7 @@ F32	LLAgent::calcCameraFOVZoomFactor()
 	{
 		return 0.f;
 	}
-	else if (mFocusObject.notNull() && !mFocusObject->isAvatar())
+	else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar)
 	{
 		// don't FOV zoom on mostly transparent objects
 		LLVector3 focus_offset = mFocusObjectOffset;
@@ -5157,6 +5159,11 @@ BOOL LLAgent::setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOO
 	return FALSE;
 }
 
+BOOL LLAgent::canJoinGroups() const
+{
+	return mGroups.count() < MAX_AGENT_GROUPS;
+}
+
 LLQuaternion LLAgent::getHeadRotation()
 {
 	if (mAvatarObject.isNull() || !mAvatarObject->mPelvisp || !mAvatarObject->mHeadp)
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 2e95dc72be1..beede7fbe34 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -972,6 +972,7 @@ class LLAgent : public LLOldEvents::LLObservable
 	BOOL 			setGroupContribution(const LLUUID& group_id, S32 contribution);
 	BOOL 			setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOOL list_in_profile);
 	const std::string &getGroupName() const 	{ return mGroupName; }
+	BOOL			canJoinGroups() const;
 private:
 	std::string		mGroupName;
 	LLUUID			mGroupID;
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 5df73a994e4..19e9e52ddfd 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -82,7 +82,7 @@ void LLAvatarList::setSpeakingIndicatorsVisible(bool visible)
 	getItems(items);
 	for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++)
 	{
-		static_cast<LLAvatarListItem*>(*it)->setSpeakingIndicatorVisible(mShowSpeakingIndicator);
+		static_cast<LLAvatarListItem*>(*it)->showSpeakingIndicator(mShowSpeakingIndicator);
 	}
 }
 
@@ -323,18 +323,15 @@ boost::signals2::connection LLAvatarList::setRefreshCompleteCallback(const commi
 void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos)
 {
 	LLAvatarListItem* item = new LLAvatarListItem();
-	item->showInfoBtn(true);
-	item->showSpeakingIndicator(true);
 	item->setName(name);
 	item->setAvatarId(id, mIgnoreOnlineStatus);
 	item->setOnline(mIgnoreOnlineStatus ? true : is_online);
 	item->showLastInteractionTime(mShowLastInteractionTime);
 
-	item->childSetVisible("info_btn", false);
 	item->setAvatarIconVisible(mShowIcons);
 	item->setShowInfoBtn(mShowInfoBtn);
 	item->setShowProfileBtn(mShowProfileBtn);
-	item->setSpeakingIndicatorVisible(mShowSpeakingIndicator);
+	item->showSpeakingIndicator(mShowSpeakingIndicator);
 
 	addItem(item, id, pos);
 }
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index 6945ac69323..1043858373c 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -44,10 +44,10 @@
 #include "llbutton.h"
 
 bool LLAvatarListItem::sStaticInitialized = false;
-S32 LLAvatarListItem::sIconWidth = 0;
-S32 LLAvatarListItem::sInfoBtnWidth = 0;
-S32 LLAvatarListItem::sProfileBtnWidth = 0;
-S32 LLAvatarListItem::sSpeakingIndicatorWidth = 0;
+S32 LLAvatarListItem::sLeftPadding = 0;
+S32 LLAvatarListItem::sRightNamePadding = 0;
+S32 LLAvatarListItem::sChildrenWidths[LLAvatarListItem::ALIC_COUNT];
+
 
 LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/)
 :	LLPanel(),
@@ -91,43 +91,25 @@ BOOL  LLAvatarListItem::postBuild()
 	mProfileBtn->setVisible(false);
 	mProfileBtn->setClickedCallback(boost::bind(&LLAvatarListItem::onProfileBtnClick, this));
 
-	// Remember avatar icon width including its padding from the name text box,
-	// so that we can hide and show the icon again later.
 	if (!sStaticInitialized)
 	{
-		sIconWidth = mAvatarName->getRect().mLeft - mAvatarIcon->getRect().mLeft;
-		sInfoBtnWidth = mInfoBtn->getRect().mRight - mSpeakingIndicator->getRect().mRight;
-		sProfileBtnWidth = mProfileBtn->getRect().mRight - mInfoBtn->getRect().mRight;
-		sSpeakingIndicatorWidth = mSpeakingIndicator->getRect().mRight - mAvatarName->getRect().mRight;
+		// Remember children widths including their padding from the next sibling,
+		// so that we can hide and show them again later.
+		initChildrenWidths(this);
 
 		sStaticInitialized = true;
 	}
 
-/*
-	if(!p.buttons.profile)
-	{
-		delete mProfile;
-		mProfile = NULL;
-
-		LLRect rect;
-
-		rect.setLeftTopAndSize(mName->getRect().mLeft, mName->getRect().mTop, mName->getRect().getWidth() + 30, mName->getRect().getHeight());
-		mName->setRect(rect);
-
-		if(mLocator)
-		{
-			rect.setLeftTopAndSize(mLocator->getRect().mLeft + 30, mLocator->getRect().mTop, mLocator->getRect().getWidth(), mLocator->getRect().getHeight());
-			mLocator->setRect(rect);
-		}
+	return TRUE;
+}
 
-		if(mInfo)
-		{
-			rect.setLeftTopAndSize(mInfo->getRect().mLeft + 30, mInfo->getRect().mTop, mInfo->getRect().getWidth(), mInfo->getRect().getHeight());
-			mInfo->setRect(rect);
-		}
+S32 LLAvatarListItem::notifyParent(const LLSD& info)
+{
+	if (info.has("visibility_changed"))
+	{
+		updateChildren();
 	}
-*/
-	return TRUE;
+	return 0;
 }
 
 void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask)
@@ -137,6 +119,8 @@ void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask)
 	mProfileBtn->setVisible(mShowProfileBtn);
 
 	LLPanel::onMouseEnter(x, y, mask);
+
+	updateChildren();
 }
 
 void LLAvatarListItem::onMouseLeave(S32 x, S32 y, MASK mask)
@@ -146,6 +130,8 @@ void LLAvatarListItem::onMouseLeave(S32 x, S32 y, MASK mask)
 	mProfileBtn->setVisible(false);
 
 	LLPanel::onMouseLeave(x, y, mask);
+
+	updateChildren();
 }
 
 // virtual, called by LLAvatarTracker
@@ -215,12 +201,8 @@ void LLAvatarListItem::showLastInteractionTime(bool show)
 	if (show)
 		return;
 
-	LLRect	name_rect	= mAvatarName->getRect();
-	LLRect	time_rect	= mLastInteractionTime->getRect();
-
 	mLastInteractionTime->setVisible(false);
-	name_rect.mRight += (time_rect.mRight - name_rect.mRight);
-	mAvatarName->setRect(name_rect);
+	updateChildren();
 }
 
 void LLAvatarListItem::setLastInteractionTime(U32 secs_since)
@@ -234,12 +216,6 @@ void LLAvatarListItem::setShowInfoBtn(bool show)
 	if(mShowInfoBtn == show)
 		return;
 	mShowInfoBtn = show;
-	S32 width_delta = show ? - sInfoBtnWidth : sInfoBtnWidth;
-
-	//Translating speaking indicator
-	mSpeakingIndicator->translate(width_delta, 0);
-	//Reshaping avatar name
-	mAvatarName->reshape(mAvatarName->getRect().getWidth() + width_delta, mAvatarName->getRect().getHeight());
 }
 
 void LLAvatarListItem::setShowProfileBtn(bool show)
@@ -248,24 +224,17 @@ void LLAvatarListItem::setShowProfileBtn(bool show)
 	if(mShowProfileBtn == show)
 			return;
 	mShowProfileBtn = show;
-	S32 width_delta = show ? - sProfileBtnWidth : sProfileBtnWidth;
-
-	//Translating speaking indicator
-	mSpeakingIndicator->translate(width_delta, 0);
-	//Reshaping avatar name
-	mAvatarName->reshape(mAvatarName->getRect().getWidth() + width_delta, mAvatarName->getRect().getHeight());
 }
 
-void LLAvatarListItem::setSpeakingIndicatorVisible(bool visible)
+void LLAvatarListItem::showSpeakingIndicator(bool visible)
 {
 	// Already done? Then do nothing.
 	if (mSpeakingIndicator->getVisible() == (BOOL)visible)
 		return;
-	mSpeakingIndicator->setVisible(visible);
-	S32 width_delta = visible ? - sSpeakingIndicatorWidth : sSpeakingIndicatorWidth;
-
-	//Reshaping avatar name
-	mAvatarName->reshape(mAvatarName->getRect().getWidth() + width_delta, mAvatarName->getRect().getHeight());
+// Disabled to not contradict with SpeakingIndicatorManager functionality. EXT-3976
+// probably this method should be totally removed.
+//	mSpeakingIndicator->setVisible(visible);
+//	updateChildren();
 }
 
 void LLAvatarListItem::setAvatarIconVisible(bool visible)
@@ -276,36 +245,12 @@ void LLAvatarListItem::setAvatarIconVisible(bool visible)
 
 	// Show/hide avatar icon.
 	mAvatarIcon->setVisible(visible);
-
-	// Move the avatar name horizontally by icon size + its distance from the avatar name.
-	LLRect name_rect = mAvatarName->getRect();
-	name_rect.mLeft += visible ? sIconWidth : -sIconWidth;
-	mAvatarName->setRect(name_rect);
+	updateChildren();
 }
 
 void LLAvatarListItem::onInfoBtnClick()
 {
 	LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", mAvatarId));
-
-	/* TODO fix positioning of inspector
-	localPointToScreen(mXPos, mYPos, &mXPos, &mYPos);
-	
-	
-	LLRect rect;
-
-	// *TODO Vadim: rewrite this. "+= -" looks weird.
-	S32 delta = mYPos - inspector->getRect().getHeight();
-	if(delta < 0)
-	{
-		mYPos += -delta;
-	}
-	
-	rect.setLeftTopAndSize(mXPos, mYPos,
-	inspector->getRect().getWidth(), inspector->getRect().getHeight()); 
-	inspector->setRect(rect);
-	inspector->setFrontmost(true);
-	inspector->setVisible(true);
-	*/
 }
 
 void LLAvatarListItem::onProfileBtnClick()
@@ -344,21 +289,6 @@ void LLAvatarListItem::onNameCache(const std::string& first_name, const std::str
 	setName(name);
 }
 
-void LLAvatarListItem::reshapeAvatarName()
-{
-	S32 width_delta = 0;
-	width_delta += mShowProfileBtn ? sProfileBtnWidth : 0;
-	width_delta += mSpeakingIndicator->getVisible() ? sSpeakingIndicatorWidth : 0;
-	width_delta += mAvatarIcon->getVisible() ? sIconWidth : 0;
-	width_delta += mShowInfoBtn ? sInfoBtnWidth : 0;
-	width_delta += mLastInteractionTime->getVisible() ? mLastInteractionTime->getRect().getWidth() : 0;
-
-	S32 height = mAvatarName->getRect().getHeight();
-	S32 width  = getRect().getWidth() - width_delta;
-
-	mAvatarName->reshape(width, height);
-}
-
 // Convert given number of seconds to a string like "23 minutes", "15 hours" or "3 years",
 // taking i18n into account. The format string to use is taken from the panel XML.
 std::string LLAvatarListItem::formatSeconds(U32 secs)
@@ -492,4 +422,133 @@ LLAvatarListItem::icon_color_map_t& LLAvatarListItem::getItemIconColorMap()
 	return item_icon_color_map;
 }
 
+// static
+void LLAvatarListItem::initChildrenWidths(LLAvatarListItem* avatar_item)
+{
+	//profile btn width + padding
+	S32 profile_btn_width = avatar_item->getRect().getWidth() - avatar_item->mProfileBtn->getRect().mLeft;
+
+	//info btn width + padding
+	S32 info_btn_width = avatar_item->mProfileBtn->getRect().mLeft - avatar_item->mInfoBtn->getRect().mLeft;
+
+	//speaking indicator width + padding
+	S32 speaking_indicator_width = avatar_item->mInfoBtn->getRect().mLeft - avatar_item->mSpeakingIndicator->getRect().mLeft;
+
+	// last interaction time textbox width + padding
+	S32 last_interaction_time_width = avatar_item->mSpeakingIndicator->getRect().mLeft - avatar_item->mLastInteractionTime->getRect().mLeft;
+
+	// icon width + padding
+	S32 icon_width = avatar_item->mAvatarName->getRect().mLeft - avatar_item->mAvatarIcon->getRect().mLeft;
+
+	sLeftPadding = avatar_item->mAvatarIcon->getRect().mLeft;
+	sRightNamePadding = avatar_item->mLastInteractionTime->getRect().mLeft - avatar_item->mAvatarName->getRect().mRight;
+
+	S32 index = ALIC_COUNT;
+	sChildrenWidths[--index] = icon_width;
+	sChildrenWidths[--index] = 0; // for avatar name we don't need its width, it will be calculated as "left available space"
+	sChildrenWidths[--index] = last_interaction_time_width;
+	sChildrenWidths[--index] = speaking_indicator_width;
+	sChildrenWidths[--index] = info_btn_width;
+	sChildrenWidths[--index] = profile_btn_width;
+}
+
+void LLAvatarListItem::updateChildren()
+{
+	LL_DEBUGS("AvatarItemReshape") << LL_ENDL;
+	LL_DEBUGS("AvatarItemReshape") << "Updating for: " << getAvatarName() << LL_ENDL;
+
+	S32 name_new_width = getRect().getWidth();
+	S32 ctrl_new_left = name_new_width;
+	S32 name_new_left = sLeftPadding;
+
+	// iterate through all children and set them into correct position depend on each child visibility
+	// assume that child indexes are in back order: the first in Enum is the last (right) in the item
+	// iterate & set child views starting from right to left
+	for (S32 i = 0; i < ALIC_COUNT; ++i)
+	{
+		// skip "name" textbox, it will be processed out of loop later
+		if (ALIC_NAME == i) continue;
+
+		LLView* control = getItemChildView((EAvatarListItemChildIndex)i);
+
+		LL_DEBUGS("AvatarItemReshape") << "Processing control: " << control->getName() << LL_ENDL;
+		// skip invisible views
+		if (!control->getVisible()) continue;
+
+		S32 ctrl_width = sChildrenWidths[i]; // including space between current & left controls
+
+		// decrease available for 
+		name_new_width -= ctrl_width;
+		LL_DEBUGS("AvatarItemReshape") << "width: " << ctrl_width << ", name_new_width: " << name_new_width << LL_ENDL;
+
+		LLRect control_rect = control->getRect();
+		LL_DEBUGS("AvatarItemReshape") << "rect before: " << control_rect << LL_ENDL;
+
+		if (ALIC_ICON == i)
+		{
+			// assume that this is the last iteration,
+			// so it is not necessary to save "ctrl_new_left" value calculated on previous iterations
+			ctrl_new_left = sLeftPadding;
+			name_new_left = ctrl_new_left + ctrl_width;
+		}
+		else
+		{
+			ctrl_new_left -= ctrl_width;
+		}
+
+		LL_DEBUGS("AvatarItemReshape") << "ctrl_new_left: " << ctrl_new_left << LL_ENDL;
+
+		control_rect.setLeftTopAndSize(
+			ctrl_new_left,
+			control_rect.mTop,
+			control_rect.getWidth(),
+			control_rect.getHeight());
+
+		LL_DEBUGS("AvatarItemReshape") << "rect after: " << control_rect << LL_ENDL;
+		control->setShape(control_rect);
+	}
+
+	// set size and position of the "name" child
+	LLView* name_view = getItemChildView(ALIC_NAME);
+	LLRect name_view_rect = name_view->getRect();
+	LL_DEBUGS("AvatarItemReshape") << "name rect before: " << name_view_rect << LL_ENDL;
+
+	// apply paddings
+	name_new_width -= sLeftPadding;
+	name_new_width -= sRightNamePadding;
+
+	name_view_rect.setLeftTopAndSize(
+		name_new_left,
+		name_view_rect.mTop,
+		name_new_width,
+		name_view_rect.getHeight());
+
+	name_view->setShape(name_view_rect);
+
+	LL_DEBUGS("AvatarItemReshape") << "name rect after: " << name_view_rect << LL_ENDL;
+}
+
+LLView* LLAvatarListItem::getItemChildView(EAvatarListItemChildIndex child_view_index)
+{
+	LLView* child_view = mAvatarName;
+	if (child_view_index < 0 || ALIC_COUNT <= child_view_index)
+	{
+		LL_WARNS("AvatarItemReshape") << "Child view index is out of range: " << child_view_index << LL_ENDL;
+		return child_view;
+	}
+	switch (child_view_index)
+	{
+	case ALIC_ICON:					child_view = mAvatarIcon; break;
+	case ALIC_NAME:					child_view = mAvatarName; break;
+	case ALIC_INTERACTION_TIME:		child_view = mLastInteractionTime; break;
+	case ALIC_SPEAKER_INDICATOR:	child_view = mSpeakingIndicator; break;
+	case ALIC_INFO_BUTTON:			child_view = mInfoBtn; break;
+	case ALIC_PROFILE_BUTTON:		child_view = mProfileBtn; break;
+	default:
+		LL_WARNS("AvatarItemReshape") << "Unexpected child view index is passed: " << child_view_index << LL_ENDL;
+	}
+	
+	return child_view;
+}
+
 // EOF
diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h
index 96097bc9b52..f76ffb391d4 100644
--- a/indra/newview/llavatarlistitem.h
+++ b/indra/newview/llavatarlistitem.h
@@ -74,6 +74,11 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	virtual ~LLAvatarListItem();
 
 	virtual BOOL postBuild();
+
+	/**
+	 * Processes notification from speaker indicator to update children when indicator's visibility is changed.
+	 */
+	virtual S32	notifyParent(const LLSD& info);
 	virtual void onMouseLeave(S32 x, S32 y, MASK mask);
 	virtual void onMouseEnter(S32 x, S32 y, MASK mask);
 	virtual void setValue(const LLSD& value);
@@ -88,7 +93,8 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	//Show/hide profile/info btn, translating speaker indicator and avatar name coordinates accordingly
 	void setShowProfileBtn(bool show);
 	void setShowInfoBtn(bool show);
-	void setSpeakingIndicatorVisible(bool visible);
+	void showSpeakingIndicator(bool show);
+	void showLastInteractionTime(bool show);
 	void setAvatarIconVisible(bool visible);
 	
 	const LLUUID& getAvatarId() const;
@@ -97,17 +103,6 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	void onInfoBtnClick();
 	void onProfileBtnClick();
 
-	void showSpeakingIndicator(bool show) { mSpeakingIndicator->setVisible(show); }
-	void showInfoBtn(bool show_info_btn) {mInfoBtn->setVisible(show_info_btn); }
-	void showLastInteractionTime(bool show);
-
-	/**
-	 * This method was added to fix EXT-2364 (Items in group/ad-hoc IM participant list (avatar names) should be reshaped when adding/removing the "(Moderator)" label)
-	 * But this is a *HACK. The real reason of it was in incorrect logic while hiding profile/info/speaker buttons
-	 * *TODO: new reshape method should be provided in lieu of this one to be called when visibility if those buttons is changed
-	 */
-	void reshapeAvatarName();
-
 protected:
 	/**
 	 * Contains indicator to show voice activity. 
@@ -124,6 +119,23 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 		E_UNKNOWN,
 	} EOnlineStatus;
 
+	/**
+	 * Enumeration of item elements in order from right to left.
+	 * 
+	 * updateChildren() assumes that indexes are in the such order to process avatar icon easier.
+	 *
+	 * @see updateChildren()
+	 */
+	typedef enum e_avatar_item_child {
+		ALIC_PROFILE_BUTTON,
+		ALIC_INFO_BUTTON,
+		ALIC_SPEAKER_INDICATOR,
+		ALIC_INTERACTION_TIME,
+		ALIC_NAME,
+		ALIC_ICON,
+		ALIC_COUNT,
+	} EAvatarListItemChildIndex;
+
 	void setNameInternal(const std::string& name, const std::string& highlight);
 	void onNameCache(const std::string& first_name, const std::string& last_name);
 
@@ -135,6 +147,26 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	typedef std::map<EItemState, LLColor4> icon_color_map_t;
 	static icon_color_map_t& getItemIconColorMap();
 
+	/**
+	 * Initializes widths of all children to use them while changing visibility of any of them.
+	 *
+	 * @see updateChildren()
+	 */
+	static void initChildrenWidths(LLAvatarListItem* self);
+
+	/**
+	 * Updates position and rectangle of visible children to fit all available item's width.
+	 */
+	void updateChildren();
+
+	/**
+	 * Gets child view specified by index.
+	 *
+	 * This method implemented via switch by all EAvatarListItemChildIndex values.
+	 * It is used to not store children in array or vector to avoid of increasing memory usage.
+	 */
+	LLView* getItemChildView(EAvatarListItemChildIndex child_index);
+
 	LLTextBox* mAvatarName;
 	LLTextBox* mLastInteractionTime;
 	LLStyle::Params mAvatarNameStyle;
@@ -151,10 +183,17 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	bool mShowProfileBtn;
 
 	static bool	sStaticInitialized; // this variable is introduced to improve code readability
-	static S32	sIconWidth; // icon width + padding
-	static S32  sInfoBtnWidth; //info btn width + padding
-	static S32  sProfileBtnWidth; //profile btn width + padding
-	static S32  sSpeakingIndicatorWidth; //speaking indicator width + padding
+	static S32  sLeftPadding; // padding to first left visible child (icon or name)
+	static S32  sRightNamePadding; // right padding from name to next visible child
+
+	/**
+	 * Contains widths of each child specified by EAvatarListItemChildIndex
+	 * including padding to the next right one.
+	 *
+	 * @see initChildrenWidths()
+	 */
+	static S32 sChildrenWidths[ALIC_COUNT];
+
 };
 
 #endif //LL_LLAVATARLISTITEM_H
diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp
index 976b3125093..beccefa4301 100644
--- a/indra/newview/llbottomtray.cpp
+++ b/indra/newview/llbottomtray.cpp
@@ -161,6 +161,9 @@ void LLBottomTray::sessionAdded(const LLUUID& session_id, const std::string& nam
 	{
 		chiclet->setIMSessionName(name);
 		chiclet->setOtherParticipantId(other_participant_id);
+		
+		LLIMFloater::onIMChicletCreated(session_id);
+
 	}
 	else
 	{
@@ -251,14 +254,24 @@ void LLBottomTray::setVisible(BOOL visible)
 		{
 			LLView* viewp = *child_it;
 			std::string name = viewp->getName();
-			
-			if ("chat_bar" == name || "movement_panel" == name || "cam_panel" == name || "snapshot_panel" == name || "gesture_panel" == name)
+
+			// Chat bar and gesture button are shown even in mouselook mode. But the move, camera and snapshot buttons shouldn't be displayed. See EXT-3988.
+			if ("chat_bar" == name || "gesture_panel" == name || (visibility && ("movement_panel" == name || "cam_panel" == name || "snapshot_panel" == name)))
 				continue;
 			else 
 			{
 				viewp->setVisible(visibility);
 			}
 		}
+
+		// Apply the saved settings when we are not in mouselook mode, see EXT-3988.
+		if (visibility)
+		{
+			showCameraButton(gSavedSettings.getBOOL("ShowCameraButton"));
+			showSnapshotButton(gSavedSettings.getBOOL("ShowSnapshotButton"));
+			showMoveButton(gSavedSettings.getBOOL("ShowMoveButton"));
+			showGestureButton(gSavedSettings.getBOOL("ShowGestureButton"));
+		}
 	}
 }
 
diff --git a/indra/newview/llcallfloater.cpp b/indra/newview/llcallfloater.cpp
index 1468f6d584f..c0efb85b512 100644
--- a/indra/newview/llcallfloater.cpp
+++ b/indra/newview/llcallfloater.cpp
@@ -51,6 +51,7 @@
 #include "lltransientfloatermgr.h"
 #include "llviewerwindow.h"
 #include "llvoicechannel.h"
+#include "lllayoutstack.h"
 
 static void get_voice_participants_uuids(std::vector<LLUUID>& speakers_uuids);
 
@@ -314,7 +315,7 @@ void LLCallFloater::updateSession()
 	
 	//hide "Leave Call" button for nearby chat
 	bool is_local_chat = mVoiceType == VC_LOCAL_CHAT;
-	childSetVisible("leave_call_btn", !is_local_chat);
+	childSetVisible("leave_call_btn_panel", !is_local_chat);
 	
 	refreshParticipantList();
 	updateAgentModeratorState();
@@ -818,8 +819,8 @@ void reshape_floater(LLCallFloater* floater, S32 delta_height)
 		}
 	}
 
-	floater->reshape(floater_rect.getWidth(), floater_rect.getHeight());
-	floater->setRect(floater_rect);
+	floater->setShape(floater_rect);
+	floater->getChild<LLLayoutStack>("my_call_stack")->updateLayout(FALSE);
 }
 
 void LLCallFloater::reshapeToFitContent()
@@ -864,9 +865,8 @@ S32 LLCallFloater::getParticipantItemHeight()
 
 S32 LLCallFloater::getMaxVisibleItems()
 {
-	S32 value = 5; // default value, in case convertToS32() fails.
-	LLStringUtil::convertToS32(getString("max_visible_items"), value);
-	return value;
+	static LLCachedControl<S32> max_visible_items(*LLUI::sSettingGroups["config"],"CallFloaterMaxItems");
+	return max_visible_items;
 }
 
 //EOF
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index cda3e3a4191..2fc83c7e54f 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -499,7 +499,24 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_
 	style_params.font.name(font_name);
 	style_params.font.size(font_size);	
 	style_params.font.style(input_append_params.font.style);
-	
+
+	std::string prefix = chat.mText.substr(0, 4);
+
+	//IRC styled /me messages.
+	bool irc_me = prefix == "/me " || prefix == "/me'";
+
+	// Delimiter after a name in header copy/past and in plain text mode
+	std::string delimiter = (chat.mChatType != CHAT_TYPE_SHOUT && chat.mChatType != CHAT_TYPE_WHISPER)
+		? ": "
+		: " ";
+
+	// Don't add any delimiter after name in irc styled messages
+	if (irc_me || chat.mChatStyle == CHAT_STYLE_IRC)
+	{
+		delimiter = LLStringUtil::null;
+		style_params.font.style = "ITALIC";
+	}
+
 	if (use_plain_text_chat_history)
 	{
 		mEditor->appendText("[" + chat.mTimeStr + "] ", mEditor->getText().size() != 0, style_params);
@@ -512,11 +529,11 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_
 				LLStyle::Params link_params(style_params);
 				link_params.fillFrom(LLStyleMap::instance().lookupAgent(chat.mFromID));
 				// Convert the name to a hotlink and add to message.
-				mEditor->appendText(chat.mFromName + ": ", false, link_params);
+				mEditor->appendText(chat.mFromName + delimiter, false, link_params);
 			}
 			else
 			{
-				mEditor->appendText(chat.mFromName + ": ", false, style_params);
+				mEditor->appendText(chat.mFromName + delimiter, false, style_params);
 			}
 		}
 	}
@@ -562,36 +579,22 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_
 
 		std::string header_text = "[" + chat.mTimeStr + "] ";
 		if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM)
-			header_text += chat.mFromName + ": ";
+			header_text += chat.mFromName + delimiter;
 
 		mEditor->appendWidget(p, header_text, false);
 		mLastFromName = chat.mFromName;
 		mLastFromID = chat.mFromID;
 		mLastMessageTime = new_message_time;
 	}
-	//Handle IRC styled /me messages.
-	std::string prefix = chat.mText.substr(0, 4);
-	if (prefix == "/me " || prefix == "/me'")
-	{
-		style_params.font.style = "ITALIC";
 
-		if (chat.mFromName.size() > 0)
-			mEditor->appendText(chat.mFromName, TRUE, style_params);
+	std::string message = irc_me ? chat.mText.substr(3) : chat.mText;
+	if ( message.size() > 0 && !LLStringOps::isSpace(message[message.size() - 1]) )
+	{
 		// Ensure that message ends with NewLine, to avoid losing of new lines
 		// while copy/paste from text chat. See EXT-3263.
-		mEditor->appendText(chat.mText.substr(3) + NEW_LINE, FALSE, style_params);
-	}
-	else
-	{
-		std::string message(chat.mText);
-		if ( message.size() > 0 && !LLStringOps::isSpace(message[message.size() - 1]) )
-		{
-			// Ensure that message ends with NewLine, to avoid losing of new lines
-			// while copy/paste from text chat. See EXT-3263.
-			message += NEW_LINE;
-		}
-		mEditor->appendText(message, FALSE, style_params);
+		message += NEW_LINE;
 	}
+	mEditor->appendText(message, FALSE, style_params);
 	mEditor->blockUndo();
 
 	// automatically scroll to end when receiving chat from myself
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index aa343b2f697..ef69f39ad2d 100644
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -269,7 +269,7 @@ LLSD LLFloaterAbout::getInfo()
 	info["VIVOX_VERSION"] = gVoiceClient ? gVoiceClient->getAPIVersion() : LLTrans::getString("NotConnected");
 
 	// TODO: Implement media plugin version query
-	info["QT_WEBKIT_VERSION"] = "4.5.2 (version number hard-coded)";
+	info["QT_WEBKIT_VERSION"] = "4.6 (version number hard-coded)";
 
 	if (gPacketsIn > 0)
 	{
diff --git a/indra/newview/llfloaterchat.cpp b/indra/newview/llfloaterchat.cpp
index b9e0f928f14..18b9f0484fd 100644
--- a/indra/newview/llfloaterchat.cpp
+++ b/indra/newview/llfloaterchat.cpp
@@ -190,7 +190,14 @@ void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file)
 {	
 	if (log_to_file && (gSavedPerAccountSettings.getBOOL("LogChat"))) 
 	{
-		LLLogChat::saveHistory("chat", chat.mFromName, chat.mFromID, chat.mText);
+		if (chat.mChatType != CHAT_TYPE_WHISPER && chat.mChatType != CHAT_TYPE_SHOUT)
+		{
+			LLLogChat::saveHistory("chat", chat.mFromName, chat.mFromID, chat.mText);
+		}
+		else
+		{
+			LLLogChat::saveHistory("chat", "", chat.mFromID, chat.mFromName + " " + chat.mText);
+		}
 	}
 	
 	LLColor4 color = get_text_color(chat);
@@ -311,8 +318,10 @@ void LLFloaterChat::addChat(const LLChat& chat, BOOL from_instant_message, BOOL
 	triggerAlerts(chat.mText);
 
 	// Add the sender to the list of people with which we've recently interacted.
-	if(chat.mSourceType == CHAT_SOURCE_AGENT && chat.mFromID.notNull())
-		LLRecentPeople::instance().add(chat.mFromID);
+	// this is not the best place to add _all_ messages to recent list
+	// comment this for now, may remove later on code cleanup
+	//if(chat.mSourceType == CHAT_SOURCE_AGENT && chat.mFromID.notNull())
+	//	LLRecentPeople::instance().add(chat.mFromID);
 	
 	bool add_chat = true;
 	bool log_chat = true;
diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp
index 5072bc8c820..6a9c602db20 100644
--- a/indra/newview/llfloatergesture.cpp
+++ b/indra/newview/llfloatergesture.cpp
@@ -415,7 +415,7 @@ void LLFloaterGesture::onClickPlay()
 	LL_DEBUGS("Gesture")<<" Trying to play gesture id: "<< item_id <<LL_ENDL;
 	if(!LLGestureManager::instance().isGestureActive(item_id))
 	{
-		// we need to inform server about gesture activating to be consistent with LLPreviewGesture and  LLGestureComboBox.
+		// we need to inform server about gesture activating to be consistent with LLPreviewGesture and  LLGestureComboList.
 		BOOL inform_server = TRUE;
 		BOOL deactivate_similar = FALSE;
 		LLGestureManager::instance().setGestureLoadedCallback(item_id, boost::bind(&LLFloaterGesture::playGesture, this, item_id));
diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp
index 7cb925bc0b0..29f415bd439 100644
--- a/indra/newview/llfloatergroups.cpp
+++ b/indra/newview/llfloatergroups.cpp
@@ -247,14 +247,7 @@ void LLPanelGroups::enableButtons()
 		childDisable("IM");
 		childDisable("Leave");
 	}
-	if(gAgent.mGroups.count() < MAX_AGENT_GROUPS)
-	{
-		childEnable("Create");
-	}
-	else
-	{
-		childDisable("Create");
-	}
+	childSetEnabled("Create", gAgent.canJoinGroups());
 }
 
 
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 598a13de158..42c961a956b 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -276,6 +276,7 @@ void LLFloaterLand::refresh()
 	mPanelAudio->refresh();
 	mPanelMedia->refresh();
 	mPanelAccess->refresh();
+	mPanelCovenant->refresh();
 }
 
 
@@ -2795,12 +2796,6 @@ LLPanelLandCovenant::~LLPanelLandCovenant()
 {
 }
 
-BOOL LLPanelLandCovenant::postBuild()
-{
-	refresh();
-	return TRUE;
-}
-
 // virtual
 void LLPanelLandCovenant::refresh()
 {
diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h
index d7d02ba1a37..a4785e8f5b0 100644
--- a/indra/newview/llfloaterland.h
+++ b/indra/newview/llfloaterland.h
@@ -391,7 +391,6 @@ class LLPanelLandCovenant
 public:
 	LLPanelLandCovenant(LLSafeHandle<LLParcelSelection>& parcelp);
 	virtual ~LLPanelLandCovenant();
-	virtual BOOL postBuild();
 	void refresh();
 	static void updateCovenantText(const std::string& string);
 	static void updateEstateName(const std::string& name);
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index d0716f67b80..9af37e81749 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -602,8 +602,8 @@ void LLFloaterPreference::onBtnOK()
 		apply();
 		closeFloater(false);
 
-		gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
 		LLUIColorTable::instance().saveUserSettings();
+		gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
 		std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
 		// save all settings, even if equals defaults
 		gCrashSettings.saveToFile(crash_settings_filename, FALSE);
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index c4b87c1b2dc..0402ba20e21 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -406,6 +406,11 @@ LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant()
 
 void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region)
 {
+	if (!region)
+	{
+		return; 
+	}
+
 	// call refresh from region on all panels
 	std::for_each(
 		mInfoPanels.begin(),
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index df7aa9eabf3..82293b4aa0b 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -417,6 +417,16 @@ BOOL LLGestureManager::isGesturePlaying(const LLUUID& item_id)
 	return gesture->mPlaying;
 }
 
+BOOL LLGestureManager::isGesturePlaying(LLMultiGesture* gesture)
+{
+	if(!gesture)
+	{
+		return FALSE;
+	}
+
+	return gesture->mPlaying;
+}
+
 void LLGestureManager::replaceGesture(const LLUUID& item_id, LLMultiGesture* new_gesture, const LLUUID& asset_id)
 {
 	const LLUUID& base_item_id = get_linked_uuid(item_id);
diff --git a/indra/newview/llgesturemgr.h b/indra/newview/llgesturemgr.h
index e80eea9ae90..c562587c6fd 100644
--- a/indra/newview/llgesturemgr.h
+++ b/indra/newview/llgesturemgr.h
@@ -103,6 +103,8 @@ class LLGestureManager : public LLSingleton<LLGestureManager>, public LLInventor
 
 	BOOL isGesturePlaying(const LLUUID& item_id);
 
+	BOOL isGesturePlaying(LLMultiGesture* gesture);
+
 	const item_map_t& getActiveGestures() const { return mActive; }
 	// Force a gesture to be played, for example, if it is being
 	// previewed.
diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp
index 7dd8ea694e9..d6e2bb0445f 100644
--- a/indra/newview/llgroupactions.cpp
+++ b/indra/newview/llgroupactions.cpp
@@ -146,6 +146,12 @@ void LLGroupActions::startCall(const LLUUID& group_id)
 // static
 void LLGroupActions::join(const LLUUID& group_id)
 {
+	if (!gAgent.canJoinGroups())
+	{
+		LLNotificationsUtil::add("JoinedTooManyGroups");
+		return;
+	}
+
 	LLGroupMgrGroupData* gdatap = 
 		LLGroupMgr::getInstance()->getGroupData(group_id);
 
@@ -226,7 +232,9 @@ void LLGroupActions::activate(const LLUUID& group_id)
 
 static bool isGroupUIVisible()
 {
-	LLPanel* panel = LLSideTray::getInstance()->findChild<LLPanel>("panel_group_info_sidetray");
+	static LLPanel* panel = 0;
+	if(!panel)
+		panel = LLSideTray::getInstance()->findChild<LLPanel>("panel_group_info_sidetray");
 	if(!panel)
 		return false;
 	return panel->isInVisibleChain();
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index b05568f353f..aee34eb0af5 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -361,35 +361,7 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
 {
 	if (!gIMMgr->hasSession(session_id)) return NULL;
 
-	// we should make sure all related chiclets are in place when the session is a voice call
-	// chiclets come firts, then comes IM window
-	if (gIMMgr->isVoiceCall(session_id))
-	{
-		LLIMModel* im_model = LLIMModel::getInstance();
-		LLBottomTray* b_tray = LLBottomTray::getInstance();
-		
-		//*TODO hide that into Bottom tray
-		if (!b_tray->getChicletPanel()->findChiclet<LLChiclet>(session_id))
-		{
-			LLIMChiclet* chiclet = b_tray->createIMChiclet(session_id);
-			if(chiclet)
-			{
-				chiclet->setIMSessionName(im_model->getName(session_id));
-				chiclet->setOtherParticipantId(im_model->getOtherParticipantID(session_id));
-			}
-		}
-
-		LLIMWellWindow::getInstance()->addIMRow(session_id);
-	}
-		
-	bool not_existed = true;
-
-	if(isChatMultiTab())
-	{
-		LLIMFloater* target_floater = findInstance(session_id);
-		not_existed = NULL == target_floater;
-	}
-	else
+	if(!isChatMultiTab())
 	{
 		//hide all
 		LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("impanel");
@@ -404,19 +376,33 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
 		}
 	}
 
-	LLIMFloater* floater = LLFloaterReg::showTypedInstance<LLIMFloater>("impanel", session_id);
+	bool exist = findInstance(session_id);
+
+	LLIMFloater* floater = getInstance(session_id);
+	if (!floater) return NULL;
 
 	if(isChatMultiTab())
 	{
+		LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance();
+
 		// do not add existed floaters to avoid adding torn off instances
-		if (not_existed)
+		if (!exist)
 		{
 			//		LLTabContainer::eInsertionPoint i_pt = user_initiated ? LLTabContainer::RIGHT_OF_CURRENT : LLTabContainer::END;
 			// TODO: mantipov: use LLTabContainer::RIGHT_OF_CURRENT if it exists
 			LLTabContainer::eInsertionPoint i_pt = LLTabContainer::END;
+			
+			if (floater_container)
+			{
+				floater_container->addFloater(floater, TRUE, i_pt);
+			}
+		}
 
-			LLIMFloaterContainer* floater_container = LLFloaterReg::showTypedInstance<LLIMFloaterContainer>("im_container");
-			floater_container->addFloater(floater, TRUE, i_pt);
+		if (floater_container)
+		{
+			//selecting the panel resets a chiclet's counter
+			floater_container->selectFloater(floater);
+			floater_container->setVisible(TRUE);
 		}
 	}
 	else
@@ -443,8 +429,8 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
 		}
 
 		// window is positioned, now we can show it.
-		floater->setVisible(true);
 	}
+	floater->setVisible(TRUE);
 
 	return floater;
 }
@@ -484,16 +470,6 @@ void LLIMFloater::setDocked(bool docked, bool pop_on_undock)
 	}
 }
 
-void LLIMFloater::setTornOff(bool torn_off)
-{
-	// When IM Floater isn't torn off, "close" button should be hidden.
-	// This call will just disables it, since there is a hack in LLFloater::updateButton,
-	// which prevents hiding of close button in that case.
-	setCanClose(torn_off);
-
-	LLTransientDockableFloater::setTornOff(torn_off);
-}
-
 void LLIMFloater::setVisible(BOOL visible)
 {
 	LLNotificationsUI::LLScreenChannel* channel = dynamic_cast<LLNotificationsUI::LLScreenChannel*>
@@ -548,6 +524,11 @@ LLIMFloater* LLIMFloater::findInstance(const LLUUID& session_id)
 	return LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id);
 }
 
+LLIMFloater* LLIMFloater::getInstance(const LLUUID& session_id)
+{
+	return LLFloaterReg::getTypedInstance<LLIMFloater>("impanel", session_id);
+}
+
 void LLIMFloater::sessionInitReplyReceived(const LLUUID& im_session_id)
 {
 	mSessionInitialized = true;
@@ -1026,3 +1007,20 @@ void LLIMFloater::sRemoveTypingIndicator(const LLSD& data)
 
 	floater->removeTypingIndicator();
 }
+
+void LLIMFloater::onIMChicletCreated( const LLUUID& session_id )
+{
+
+	if (isChatMultiTab())
+	{
+		LLIMFloaterContainer* im_box = LLIMFloaterContainer::getInstance();
+		if (!im_box) return;
+
+		if (LLIMFloater::findInstance(session_id)) return;
+
+		LLIMFloater* new_tab = LLIMFloater::getInstance(session_id);
+
+		im_box->addFloater(new_tab, FALSE, LLTabContainer::END);
+	}
+
+}
diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h
index bc7a43e852a..d9db385d06a 100644
--- a/indra/newview/llimfloater.h
+++ b/indra/newview/llimfloater.h
@@ -64,7 +64,6 @@ class LLIMFloater : public LLTransientDockableFloater
 	// LLFloater overrides
 	/*virtual*/ void onClose(bool app_quitting);
 	/*virtual*/ void setDocked(bool docked, bool pop_on_undock = true);
-	/*virtual*/ void setTornOff(bool torn_off);
 
 	// Make IM conversion visible and update the message history
 	static LLIMFloater* show(const LLUUID& session_id);
@@ -75,6 +74,8 @@ class LLIMFloater : public LLTransientDockableFloater
 
 	static LLIMFloater* findInstance(const LLUUID& session_id);
 
+	static LLIMFloater* getInstance(const LLUUID& session_id);
+
 	void sessionInitReplyReceived(const LLUUID& im_session_id);
 
 	// get new messages from LLIMModel
@@ -113,6 +114,8 @@ class LLIMFloater : public LLTransientDockableFloater
 	//used as a callback on receiving new IM message
 	static void sRemoveTypingIndicator(const LLSD& data);
 
+	static void onIMChicletCreated(const LLUUID& session_id);
+
 private:
 	// process focus events to set a currently active session
 	/* virtual */ void onFocusLost();
diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 2d7333f7e47..6cc985aef49 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -34,6 +34,7 @@
 #include "llviewerprecompiledheaders.h"
 
 #include "llimfloatercontainer.h"
+#include "llfloaterreg.h"
 
 //
 // LLIMFloaterContainer
@@ -93,4 +94,14 @@ void LLIMFloaterContainer::addFloater(LLFloater* floaterp,
 	}
 }
 
+LLIMFloaterContainer* LLIMFloaterContainer::findInstance()
+{
+	return LLFloaterReg::findTypedInstance<LLIMFloaterContainer>("im_container");
+}
+
+LLIMFloaterContainer* LLIMFloaterContainer::getInstance()
+{
+	return LLFloaterReg::getTypedInstance<LLIMFloaterContainer>("im_container");
+}
+
 // EOF
diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h
index ead7cf47309..d4a542dfc22 100644
--- a/indra/newview/llimfloatercontainer.h
+++ b/indra/newview/llimfloatercontainer.h
@@ -52,7 +52,11 @@ class LLIMFloaterContainer : public LLMultiFloater
 								LLTabContainer::eInsertionPoint insertion_point = LLTabContainer::END);
 
 	static LLFloater* getCurrentVoiceFloater();
-	
+
+	static LLIMFloaterContainer* findInstance();
+
+	static LLIMFloaterContainer* getInstance();
+
 protected:
 	
 	LLFloater* mActiveVoiceFloater;
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index daabf1f7178..e9661003ea0 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -382,10 +382,6 @@ void LLIMModel::LLIMSession::addMessage(const std::string& from, const LLUUID& f
 		mSpeakers->speakerChatted(from_id);
 		mSpeakers->setSpeakerTyping(from_id, FALSE);
 	}
-
-	if( mSessionType == P2P_SESSION ||
-		mSessionType == ADHOC_SESSION)
-		LLRecentPeople::instance().add(from_id);
 }
 
 void LLIMModel::LLIMSession::addMessagesFromHistory(const std::list<LLSD>& history)
@@ -684,6 +680,12 @@ bool LLIMModel::addMessage(const LLUUID& session_id, const std::string& from, co
 	LLIMSession* session = addMessageSilently(session_id, from, from_id, utf8_text, log2file);
 	if (!session) return false;
 
+	//good place to add some1 to recent list
+	//other places may be called from message history.
+	if( !from_id.isNull() &&
+		( session->isP2PSessionType() || session->isAdHocSessionType() ) )
+		LLRecentPeople::instance().add(from_id);
+
 	// notify listeners
 	LLSD arg;
 	arg["session_id"] = session_id;
@@ -1377,7 +1379,7 @@ void LLCallDialogManager::onVoiceChannelChanged(const LLUUID &session_id)
 	}
 
 	sSession = session;
-	sSession->mVoiceChannel->setStateChangedCallback(LLCallDialogManager::onVoiceChannelStateChanged);
+	sSession->mVoiceChannel->setStateChangedCallback(boost::bind(LLCallDialogManager::onVoiceChannelStateChanged, _1, _2, _3));
 	if(sCurrentSessionlName != session->mName)
 	{
 		sPreviousSessionlName = sCurrentSessionlName;
@@ -1601,7 +1603,12 @@ void LLOutgoingCallDialog::show(const LLSD& key)
 
 	if (!mPayload["disconnected_channel_name"].asString().empty())
 	{
-		childSetTextArg("nearby", "[VOICE_CHANNEL_NAME]", mPayload["disconnected_channel_name"].asString());
+		std::string channel_name = mPayload["disconnected_channel_name"].asString();
+		if (LLIMModel::LLIMSession::AVALINE_SESSION == mPayload["session_type"].asInteger())
+		{
+			channel_name = LLTextUtil::formatPhoneNumber(channel_name);
+		}
+		childSetTextArg("nearby", "[VOICE_CHANNEL_NAME]", channel_name);
 		childSetTextArg("nearby_P2P", "[VOICE_CHANNEL_NAME]", mPayload["disconnected_channel_name"].asString());
 	}
 
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index 20d8e283927..e72bda6c2bf 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -78,6 +78,11 @@ class LLIMModel :  public LLSingleton<LLIMModel>
 		bool isP2P();
 		bool isOtherParticipantAvaline();
 
+		bool isP2PSessionType() const { return mSessionType == P2P_SESSION;}
+		bool isAdHocSessionType() const { return mSessionType == ADHOC_SESSION;}
+		bool isGroupSessionType() const { return mSessionType == GROUP_SESSION;}
+		bool isAvalineSessionType() const { return mSessionType == AVALINE_SESSION;}
+
 		LLUUID mSessionID;
 		std::string mName;
 		EInstantMessage mType;
diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp
index 8f4fba244d2..0374a1d25b0 100644
--- a/indra/newview/llinspectavatar.cpp
+++ b/indra/newview/llinspectavatar.cpp
@@ -418,6 +418,7 @@ void LLInspectAvatar::updateModeratorPanel()
 				LLPointer<LLSpeaker> selected_speakerp = speaker_mgr->findSpeaker(mAvatarID);
 				
 				if(speaker_mgr->isVoiceActive() && selected_speakerp && 
+					selected_speakerp->isInVoiceChannel() &&
 					((self_speakerp && self_speakerp->mIsModerator) || gAgent.isGodlike()))
 				{
 					getChild<LLUICtrl>("enable_voice")->setVisible(selected_speakerp->mModeratorMutedVoice);
diff --git a/indra/newview/llinspecttoast.cpp b/indra/newview/llinspecttoast.cpp
new file mode 100644
index 00000000000..3ca8fa2f56e
--- /dev/null
+++ b/indra/newview/llinspecttoast.cpp
@@ -0,0 +1,122 @@
+/** 
+ * @file llinspecttoast.cpp
+ * @brief Toast inspector implementation.
+ *
+ * $LicenseInfo:firstyear=2003&license=viewergpl$
+ * 
+ * Copyright (c) 2003-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h" // must be first include
+
+#include "llinspecttoast.h"
+#include "llinspect.h"
+#include "llfloaterreg.h"
+#include "llscreenchannel.h"
+#include "llchannelmanager.h"
+#include "lltransientfloatermgr.h"
+
+using namespace LLNotificationsUI;
+
+/**
+ * Represents inspectable toast .
+ */
+class LLInspectToast: public LLInspect
+{
+public:
+
+	LLInspectToast(const LLSD& notification_idl);
+	virtual ~LLInspectToast();
+
+	/*virtual*/ void onOpen(const LLSD& notification_id);
+private:
+	void onToastDestroy(LLToast * toast);
+
+private:
+	LLPanel* mPanel;
+	LLScreenChannel* mScreenChannel;
+};
+
+LLInspectToast::LLInspectToast(const LLSD& notification_id) :
+	LLInspect(LLSD()), mPanel(NULL)
+{
+	LLScreenChannelBase* channel = LLChannelManager::getInstance()->findChannelByID(
+																LLUUID(gSavedSettings.getString("NotificationChannelUUID")));
+	mScreenChannel = dynamic_cast<LLScreenChannel*>(channel);
+	if(NULL == mScreenChannel)
+	{
+		llwarns << "Could not get requested screen channel." << llendl;
+		return;
+	}
+
+	LLTransientFloaterMgr::getInstance()->addControlView(this);
+}
+LLInspectToast::~LLInspectToast()
+{
+	LLTransientFloaterMgr::getInstance()->removeControlView(this);
+}
+
+void LLInspectToast::onOpen(const LLSD& notification_id)
+{
+	LLInspect::onOpen(notification_id);
+	LLToast* toast = mScreenChannel->getToastByNotificationID(notification_id);
+	if (toast == NULL)
+	{
+		llwarns << "Could not get requested toast  from screen channel." << llendl;
+		return;
+	}
+	toast->setOnToastDestroyedCallback(boost::bind(&LLInspectToast::onToastDestroy, this, _1));
+
+	LLPanel * panel = toast->getPanel();
+	panel->setVisible(TRUE);
+	panel->setMouseOpaque(FALSE);
+	if(mPanel != NULL && mPanel->getParent() == this)
+	{
+		removeChild(mPanel);
+	}
+	addChild(panel);
+	panel->setFocus(TRUE);
+	mPanel = panel;
+
+
+	LLRect panel_rect;
+	panel_rect = panel->getRect();
+	reshape(panel_rect.getWidth(), panel_rect.getHeight());
+
+	LLUI::positionViewNearMouse(this);
+}
+
+void LLInspectToast::onToastDestroy(LLToast * toast)
+{
+	closeFloater(false);
+}
+
+void LLNotificationsUI::registerFloater()
+{
+	LLFloaterReg::add("inspect_toast", "inspect_toast.xml",
+			&LLFloaterReg::build<LLInspectToast>);
+}
+
diff --git a/indra/newview/llinspecttoast.h b/indra/newview/llinspecttoast.h
new file mode 100644
index 00000000000..ff547154b83
--- /dev/null
+++ b/indra/newview/llinspecttoast.h
@@ -0,0 +1,40 @@
+/** 
+ * @file llinspecttoast.h
+ *
+ * $LicenseInfo:firstyear=2003&license=viewergpl$
+ * 
+ * Copyright (c) 2003-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLINSPECTTOAST_H
+#define LL_LLINSPECTTOAST_H
+
+namespace LLNotificationsUI
+{
+void registerFloater();
+}
+
+#endif
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 711114173c9..a468a9a95c4 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -2001,14 +2001,16 @@ void LLInventoryModel::accountForUpdate(const LLCategoryUpdate& update) const
 		}
 		if(!accounted)
 		{
-			lldebugs << "No accounting for: '" << cat->getName() << "' "
+			// Error condition, this means that the category did not register that
+			// it got new descendents (perhaps because it is still being loaded)
+			// which means its descendent count will be wrong.
+			llwarns << "Accounting failed for '" << cat->getName() << "' version:"
 					 << version << llendl;
 		}
 	}
 	else
 	{
-		llwarns << "No category found for update " << update.mCategoryID
-				<< llendl;
+		llwarns << "No category found for update " << update.mCategoryID << llendl;
 	}
 }
 
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 2d9ea21b5f2..2fb8aea4e94 100644
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -311,10 +311,10 @@ bool LLInventoryFetchDescendentsObserver::isEverythingComplete() const
 
 bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory* cat)
 {
-	S32 version = cat->getVersion();
-	S32 descendents = cat->getDescendentCount();
-	if((LLViewerInventoryCategory::VERSION_UNKNOWN == version)
-	   || (LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN == descendents))
+	const S32 version = cat->getVersion();
+	const S32 expected_num_descendents = cat->getDescendentCount();
+	if ((version == LLViewerInventoryCategory::VERSION_UNKNOWN) ||
+		(expected_num_descendents == LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN))
 	{
 		return false;
 	}
@@ -325,15 +325,28 @@ bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory*
 	gInventory.getDirectDescendentsOf(cat->getUUID(), cats, items);
 	if(!cats || !items)
 	{
-		// bit of a hack - pretend we're done if they are gone or
-		// incomplete. should never know, but it would suck if this
-		// kept tight looping because of a corrupt memory state.
+		llwarns << "Category '" << cat->getName() << "' descendents corrupted, fetch failed." << llendl;
+		// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
+		// that the cat just doesn't have any items or subfolders).
+		// Unrecoverable, so just return done so that this observer can be cleared
+		// from memory.
 		return true;
 	}
-	S32 known = cats->count() + items->count();
-	if(descendents == known)
+	const S32 current_num_known_descendents = cats->count() + items->count();
+	
+	// Got the number of descendents that we were expecting, so we're done.
+	if (current_num_known_descendents == expected_num_descendents)
+	{
+		return true;
+	}
+
+	// Error condition, but recoverable.  This happens if something was added to the
+	// category before it was initialized, so accountForUpdate didn't update descendent
+	// count and thus the category thinks it has fewer descendents than it actually has.
+	if (current_num_known_descendents >= expected_num_descendents)
 	{
-		// hey - we're done.
+		llwarns << "Category '" << cat->getName() << "' expected descendentcount:" << expected_num_descendents << " descendents but got descendentcount:" << current_num_known_descendents << llendl;
+		cat->setDescendentCount(current_num_known_descendents);
 		return true;
 	}
 	return false;
@@ -352,7 +365,7 @@ void LLInventoryFetchComboObserver::changed(U32 mask)
 				continue;
 			}
 			if(item->isComplete())
-			{
+		{	
 				mCompleteItems.push_back(*it);
 				it = mIncompleteItems.erase(it);
 				continue;
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 6b0f9b709d1..87ebce1d347 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -84,7 +84,6 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) :
 	mHomePageUrl( "" ),
 	mIgnoreUIScale( true ),
 	mAlwaysRefresh( false ),
-	mExternalUrl( "" ),
 	mMediaSource( 0 ),
 	mTakeFocusOnClick( true ),
 	mCurrentNavUrl( "" ),
@@ -877,9 +876,27 @@ bool LLMediaCtrl::onClickLinkExternalTarget(const LLSD& notification, const LLSD
 	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
 	if ( 0 == option )
 	{
-		// open in external browser because we don't support 
-		// creation of our own secondary browser windows
-		LLWeb::loadURLExternal( notification["payload"]["external_url"].asString() );
+		LLSD payload = notification["payload"];
+		std::string url = payload["url"].asString();
+		S32 target_type = payload["target_type"].asInteger();
+
+		switch (target_type)
+		{
+		case LLPluginClassMedia::TARGET_EXTERNAL:
+			// load target in an external browser
+			LLWeb::loadURLExternal(url);
+			break;
+
+		case LLPluginClassMedia::TARGET_BLANK:
+			// load target in the user's preferred browser
+			LLWeb::loadURL(url);
+			break;
+
+		default:
+			// unsupported link target - shouldn't happen
+			LL_WARNS("LinkTarget") << "Unsupported link target type" << LL_ENDL;
+			break;
+		}
 	}
 	return false;
 }
@@ -993,20 +1010,18 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event)
 void LLMediaCtrl::onClickLinkHref( LLPluginClassMedia* self )
 {
 	// retrieve the event parameters
-	std::string target = self->getClickTarget();
 	std::string url = self->getClickURL();
+	U32 target_type = self->getClickTargetType();
 	
-	// if there is a value for the target
-	if ( !target.empty() )
+	// is there is a target specified for the link?
+	if (target_type == LLPluginClassMedia::TARGET_EXTERNAL ||
+		target_type == LLPluginClassMedia::TARGET_BLANK)
 	{
-		if ( target == "_external" )		
-		{
-			mExternalUrl = url;
-			LLSD payload;
-			payload["external_url"] = mExternalUrl;
-			LLNotificationsUtil::add( "WebLaunchExternalTarget", LLSD(), payload, onClickLinkExternalTarget);
-			return;
-		}
+		LLSD payload;
+		payload["url"] = url;
+		payload["target_type"] = LLSD::Integer(target_type);
+		LLNotificationsUtil::add( "WebLaunchExternalTarget", LLSD(), payload, onClickLinkExternalTarget);
+		return;
 	}
 
 	const std::string protocol1( "http://" );
diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h
index 8f9e6e71797..b0aca3cfa46 100644
--- a/indra/newview/llmediactrl.h
+++ b/indra/newview/llmediactrl.h
@@ -182,7 +182,6 @@ class LLMediaCtrl :
 		bool mOpenLinksInInternalBrowser;
 		bool mTrusted;
 		std::string mHomePageUrl;
-		std::string mExternalUrl;
 		std::string mCurrentNavUrl;
 		bool mIgnoreUIScale;
 		bool mAlwaysRefresh;
diff --git a/indra/newview/llnamebox.cpp b/indra/newview/llnamebox.cpp
index 2f4a2661985..d4340178049 100644
--- a/indra/newview/llnamebox.cpp
+++ b/indra/newview/llnamebox.cpp
@@ -52,6 +52,7 @@ LLNameBox::LLNameBox(const Params& p)
 :	LLTextBox(p)
 {
 	mNameID = LLUUID::null;
+	mLink = p.link;
 	LLNameBox::sInstances.insert(this);
 	setText(LLStringUtil::null);
 }
@@ -76,7 +77,7 @@ void LLNameBox::setNameID(const LLUUID& name_id, BOOL is_group)
 		gCacheName->getGroupName(name_id, name);
 	}
 
-	setText(name);
+	setName(name, is_group);
 }
 
 void LLNameBox::refresh(const LLUUID& id, const std::string& firstname,
@@ -93,7 +94,7 @@ void LLNameBox::refresh(const LLUUID& id, const std::string& firstname,
 		{
 			name = firstname;
 		}
-		setText(name);
+		setName(name, is_group);
 	}
 }
 
@@ -109,3 +110,22 @@ void LLNameBox::refreshAll(const LLUUID& id, const std::string& firstname,
 		box->refresh(id, firstname, lastname, is_group);
 	}
 }
+
+void LLNameBox::setName(const std::string& name, BOOL is_group)
+{
+	if (mLink)
+	{
+		std::string url;
+
+		if (is_group)
+			url = "[secondlife:///app/group/" + LLURI::escape(name) + "/about " + name + "]";
+		else
+			url = "[secondlife:///app/agent/" + mNameID.asString() + "/about " + name + "]";
+
+		setText(url);
+	}
+	else
+	{
+		setText(name);
+	}
+}
diff --git a/indra/newview/llnamebox.h b/indra/newview/llnamebox.h
index 3edb36883f9..0109525e856 100644
--- a/indra/newview/llnamebox.h
+++ b/indra/newview/llnamebox.h
@@ -47,9 +47,11 @@ class LLNameBox
 	struct Params : public LLInitParam::Block<Params, LLTextBox::Params>
 	{
 		Optional<bool>		is_group;
+		Optional<bool>		link;
 
 		Params()
 		:	is_group("is_group", false)
+		,	link("link", false)
 		{}
 	};
 
@@ -67,10 +69,13 @@ class LLNameBox
 
 	friend class LLUICtrlFactory;
 private:
+	void setName(const std::string& name, BOOL is_group);
+
 	static std::set<LLNameBox*> sInstances;
 
 private:
 	LLUUID mNameID;
+	BOOL mLink;
 
 };
 
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index fc0e51b76d1..a7c1e73328e 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -179,27 +179,7 @@ void	LLNearbyChat::addMessage(const LLChat& chat,bool archive)
 	if (!chat.mMuted)
 	{
 		tmp_chat.mFromName = chat.mFromName;
-
-		if (chat.mChatStyle == CHAT_STYLE_IRC)
-		{
-			LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
-			LLViewerChat::getChatColor(chat,txt_color);
-			LLFontGL* fontp = LLViewerChat::getChatFont();
-			std::string font_name = LLFontGL::nameFromFont(fontp);
-			std::string font_size = LLFontGL::sizeFromFont(fontp);
-			LLStyle::Params append_style_params;
-			append_style_params.color(txt_color);
-			append_style_params.readonly_color(txt_color);
-			append_style_params.font.name(font_name);
-			append_style_params.font.size(font_size);
-			append_style_params.font.style = "ITALIC";
-
-			mChatHistory->appendMessage(chat, use_plain_text_chat_history, append_style_params);
-		}
-		else
-		{
-			mChatHistory->appendMessage(chat, use_plain_text_chat_history);
-		}
+		mChatHistory->appendMessage(chat, use_plain_text_chat_history);
 	}
 
 	if(archive)
diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index 8dbaa5ac53a..6cf8bcb4178 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -48,13 +48,16 @@
 #include "llcommandhandler.h"
 #include "llviewercontrol.h"
 #include "llnavigationbar.h"
+#include "llwindow.h"
+#include "llviewerwindow.h"
+#include "llrootview.h"
 
 S32 LLNearbyChatBar::sLastSpecialChatChannel = 0;
 
 // legacy callback glue
 void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel);
 
-static LLDefaultChildRegistry::Register<LLGestureComboBox> r("gesture_combo_box");
+static LLDefaultChildRegistry::Register<LLGestureComboList> r("gesture_combo_list");
 
 struct LLChatTypeTrigger {
 	std::string name;
@@ -66,13 +69,42 @@ static LLChatTypeTrigger sChatTypeTriggers[] = {
 	{ "/shout"	, CHAT_TYPE_SHOUT}
 };
 
-LLGestureComboBox::LLGestureComboBox(const LLGestureComboBox::Params& p)
-	: LLComboBox(p)
-	, mGestureLabelTimer()
+LLGestureComboList::Params::Params()
+:	combo_button("combo_button"),
+	combo_list("combo_list")
+{
+}
+
+LLGestureComboList::LLGestureComboList(const LLGestureComboList::Params& p)
+:	LLUICtrl(p)
 	, mLabel(p.label)
 	, mViewAllItemIndex(0)
 {
-	setCommitCallback(boost::bind(&LLGestureComboBox::onCommitGesture, this));
+	LLButton::Params button_params = p.combo_button;
+	button_params.follows.flags(FOLLOWS_LEFT|FOLLOWS_BOTTOM|FOLLOWS_RIGHT);
+
+	mButton = LLUICtrlFactory::create<LLButton>(button_params);
+	mButton->reshape(getRect().getWidth(),getRect().getHeight());
+	mButton->setCommitCallback(boost::bind(&LLGestureComboList::onButtonCommit, this));
+
+	addChild(mButton);
+
+	LLScrollListCtrl::Params params = p.combo_list;
+	params.name("GestureComboList");
+	params.commit_callback.function(boost::bind(&LLGestureComboList::onItemSelected, this, _2));
+	params.visible(false);
+	params.commit_on_keyboard_movement(false);
+
+	mList = LLUICtrlFactory::create<LLScrollListCtrl>(params);
+	
+	// *HACK: adding list as a child to NonSideTrayView to make it fully visible without
+	// making it top control (because it would cause problems).
+	gViewerWindow->getNonSideTrayView()->addChild(mList);
+	mList->setVisible(FALSE);
+
+	//****************************Gesture Part********************************/
+
+	setCommitCallback(boost::bind(&LLGestureComboList::onCommitGesture, this));
 
 	// now register us as observer since we have a place to put the results
 	LLGestureManager::instance().addObserver(this);
@@ -80,23 +112,139 @@ LLGestureComboBox::LLGestureComboBox(const LLGestureComboBox::Params& p)
 	// refresh list from current active gestures
 	refreshGestures();
 
-	// This forces using of halign from xml, since LLComboBox
-	// sets it to LLFontGL::LEFT, if text entry is disabled
-	mButton->setHAlign(p.drop_down_button.font_halign);
+	setFocusLostCallback(boost::bind(&LLGestureComboList::hideList, this));
 }
 
-LLGestureComboBox::~LLGestureComboBox()
+BOOL LLGestureComboList::handleKey(KEY key, MASK mask, BOOL called_from_parent)
 {
-	LLGestureManager::instance().removeObserver(this);
+	BOOL handled = FALSE;
+	
+	if (key == KEY_ESCAPE && mask == MASK_NONE )
+	{
+		hideList();
+		handled = TRUE;
+	}
+	else
+	{
+		handled = mList->handleKey(key, mask, called_from_parent);
+	}
+
+	return handled; 		
+}
+
+void LLGestureComboList::showList()
+{
+	LLRect rect = mList->getRect();
+	LLRect screen;
+	mButton->localRectToScreen(getRect(), &screen);
+	
+	// Calculating amount of space between the navigation bar and gestures combo
+	LLNavigationBar* nb = LLNavigationBar::getInstance();
+
+	S32 x, nb_bottom;
+	nb->localPointToScreen(0, 0, &x, &nb_bottom);
+
+	S32 max_height = nb_bottom - screen.mTop;
+	mList->calcColumnWidths();
+	rect.setOriginAndSize(screen.mLeft, screen.mTop, llmax(mList->getMaxContentWidth(),mButton->getRect().getWidth()), max_height);
+
+	mList->setRect(rect);
+	mList->fitContents( llmax(mList->getMaxContentWidth(),mButton->getRect().getWidth()), max_height);
+
+	gFocusMgr.setKeyboardFocus(this);
+
+	// Show the list and push the button down
+	mButton->setToggleState(TRUE);
+	mList->setVisible(TRUE);
+}
+
+void LLGestureComboList::onButtonCommit()
+{
+	if (!mList->getVisible())
+	{
+		// highlight the last selected item from the original selection before potentially selecting a new item
+		// as visual cue to original value of combo box
+		LLScrollListItem* last_selected_item = mList->getLastSelectedItem();
+		if (last_selected_item)
+		{
+			mList->mouseOverHighlightNthItem(mList->getItemIndex(last_selected_item));
+		}
+
+		if (mList->getItemCount() != 0)
+		{
+			showList();
+		}
+	}
+	else
+	{
+		hideList();
+	} 
+}
+
+void LLGestureComboList::hideList()
+{
+	if (mList->getVisible())
+	{
+		mButton->setToggleState(FALSE);
+		mList->setVisible(FALSE);
+		mList->mouseOverHighlightNthItem(-1);
+		gFocusMgr.setKeyboardFocus(NULL);
+	}
+}
+
+S32 LLGestureComboList::getCurrentIndex() const
+{
+	LLScrollListItem* item = mList->getFirstSelected();
+	if( item )
+	{
+		return mList->getItemIndex( item );
+	}
+	return -1;
+}
+
+void LLGestureComboList::onItemSelected(const LLSD& data)
+{
+	const std::string name = mList->getSelectedItemLabel();
+
+	S32 cur_id = getCurrentIndex();
+	mLastSelectedIndex = cur_id;
+	if (cur_id != mList->getItemCount()-1 && cur_id != -1)
+	{
+		mButton->setLabel(name);
+	}
+
+	// hiding the list reasserts the old value stored in the text editor/dropdown button
+	hideList();
+
+	// commit does the reverse, asserting the value in the list
+	onCommit();
+}
+
+void LLGestureComboList::sortByName(bool ascending)
+{
+	mList->sortOnce(0, ascending);
+}
+
+LLSD LLGestureComboList::getValue() const
+{
+	LLScrollListItem* item = mList->getFirstSelected();
+	if( item )
+	{
+		return item->getValue();
+	}
+	else
+	{
+		return LLSD();
+	}
 }
 
-void LLGestureComboBox::refreshGestures()
+void LLGestureComboList::refreshGestures()
 {
 	//store current selection so we can maintain it
 	LLSD cur_gesture = getValue();
-	selectFirstItem();
-	// clear
-	clearRows();
+	
+	mList->selectFirstItem();
+	mList->clearRows();
 	mGestures.clear();
 
 	LLGestureManager::item_map_t::const_iterator it;
@@ -107,7 +255,7 @@ void LLGestureComboBox::refreshGestures()
 		LLMultiGesture* gesture = (*it).second;
 		if (gesture)
 		{
-			addSimpleElement(gesture->mName, ADD_BOTTOM, LLSD(idx));
+			mList->addSimpleElement(gesture->mName, ADD_BOTTOM, LLSD(idx));
 			mGestures.push_back(gesture);
 			idx++;
 		}
@@ -117,23 +265,42 @@ void LLGestureComboBox::refreshGestures()
 
 	// store index followed by the last added Gesture and add View All item at bottom
 	mViewAllItemIndex = idx;
-	addSimpleElement(LLTrans::getString("ViewAllGestures"), ADD_BOTTOM, LLSD(mViewAllItemIndex));
+	
+	mList->addSimpleElement(LLTrans::getString("ViewAllGestures"), ADD_BOTTOM, LLSD(mViewAllItemIndex));
 
 	// Insert label after sorting, at top, with separator below it
-	addSeparator(ADD_TOP);		
-	addSimpleElement(mLabel, ADD_TOP);
+	mList->addSeparator(ADD_TOP);	
+	mList->addSimpleElement(mLabel, ADD_TOP);
 
 	if (cur_gesture.isDefined())
 	{ 
-		selectByValue(cur_gesture);
+		mList->selectByValue(cur_gesture);
+
 	}
 	else
 	{
-		selectFirstItem();
+		mList->selectFirstItem();
 	}
+
+	LLCtrlListInterface* gestures = getListInterface();
+	LLMultiGesture* gesture = NULL;
+	
+	if (gestures)
+	{
+		S32 index = gestures->getSelectedValue().asInteger();
+		if(index > 0)
+			gesture = mGestures.at(index);
+	}
+	
+	if(gesture && LLGestureManager::instance().isGesturePlaying(gesture))
+	{
+		return;
+	}
+	
+	mButton->setLabel(mLabel);
 }
 
-void LLGestureComboBox::onCommitGesture()
+void LLGestureComboList::onCommitGesture()
 {
 	LLCtrlListInterface* gestures = getListInterface();
 	if (gestures)
@@ -164,50 +331,11 @@ void LLGestureComboBox::onCommitGesture()
 			}
 		}
 	}
-
-	mGestureLabelTimer.start();
-	// free focus back to chat bar
-	setFocus(FALSE);
 }
 
-//virtual
-void LLGestureComboBox::draw()
+LLGestureComboList::~LLGestureComboList()
 {
-	// HACK: Leave the name of the gesture in place for a few seconds.
-	const F32 SHOW_GESTURE_NAME_TIME = 2.f;
-	if (mGestureLabelTimer.getStarted() && mGestureLabelTimer.getElapsedTimeF32() > SHOW_GESTURE_NAME_TIME)
-	{
-		LLCtrlListInterface* gestures = getListInterface();
-		if (gestures) gestures->selectFirstItem();
-		mGestureLabelTimer.stop();
-	}
-
-	LLComboBox::draw();
-}
-
-//virtual
-void LLGestureComboBox::showList()
-{
-	LLComboBox::showList();
-
-	// Calculating amount of space between the navigation bar and gestures combo
-	LLNavigationBar* nb = LLNavigationBar::getInstance();
-	S32 x, nb_bottom;
-	nb->localPointToScreen(0, 0, &x, &nb_bottom);
-	
-	S32 list_bottom;
-	mList->localPointToScreen(0, 0, &x, &list_bottom);
-
-	S32 max_height = nb_bottom - list_bottom;
-
-	LLRect rect = mList->getRect();
-	// List overlapped navigation bar, downsize it
-	if (rect.getHeight() > max_height) 
-	{
-		rect.setOriginAndSize(rect.mLeft, rect.mBottom, rect.getWidth(), max_height);
-		mList->setRect(rect);
-		mList->reshape(rect.getWidth(), rect.getHeight());
-	}
+	LLGestureManager::instance().removeObserver(this);
 }
 
 LLNearbyChatBar::LLNearbyChatBar() 
diff --git a/indra/newview/llnearbychatbar.h b/indra/newview/llnearbychatbar.h
index 224118e088d..d9a7403611a 100644
--- a/indra/newview/llnearbychatbar.h
+++ b/indra/newview/llnearbychatbar.h
@@ -42,33 +42,52 @@
 #include "llspeakers.h"
 
 
-class LLGestureComboBox
-	: public LLComboBox
-	, public LLGestureManagerObserver
+class LLGestureComboList
+	: public LLGestureManagerObserver
+	, public LLUICtrl
 {
 public:
-	struct Params : public LLInitParam::Block<Params, LLComboBox::Params> { };
+	struct Params :	public LLInitParam::Block<Params, LLUICtrl::Params>
+	{
+		Optional<LLButton::Params>			combo_button;
+		Optional<LLScrollListCtrl::Params>	combo_list;
+		
+		Params();
+	};
+
 protected:
-	LLGestureComboBox(const Params&);
+	
 	friend class LLUICtrlFactory;
+	LLGestureComboList(const Params&);
+	std::vector<LLMultiGesture*> mGestures;
+	std::string mLabel;
+	LLSD::Integer mViewAllItemIndex;
+
 public:
-	~LLGestureComboBox();
 
+	~LLGestureComboList();
+
+	LLCtrlListInterface* getListInterface()		{ return (LLCtrlListInterface*)mList; };
+	virtual void	showList();
+	virtual void	hideList();
+	virtual BOOL	handleKey(KEY key, MASK mask, BOOL called_from_parent);
+
+	S32				getCurrentIndex() const;
+	void			onItemSelected(const LLSD& data);
+	void			sortByName(bool ascending = true);
 	void refreshGestures();
 	void onCommitGesture();
-	virtual void draw();
+	void onButtonCommit();
+	virtual LLSD	getValue() const;
 
 	// LLGestureManagerObserver trigger
 	virtual void changed() { refreshGestures(); }
 
-protected:
-
-	virtual void showList();
+private:
 
-	LLFrameTimer mGestureLabelTimer;
-	std::vector<LLMultiGesture*> mGestures;
-	std::string mLabel;
-	LLSD::Integer mViewAllItemIndex;
+	LLButton*			mButton;
+	LLScrollListCtrl*	mList;
+	S32                 mLastSelectedIndex;
 };
 
 class LLNearbyChatBar
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp
index 9e13a626b44..96442fafcc6 100644
--- a/indra/newview/llnearbychathandler.cpp
+++ b/indra/newview/llnearbychathandler.cpp
@@ -180,6 +180,11 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification)
 
 		if(panel && panel->messageID() == fromID && panel->canAddText())
 		{
+			if (CHAT_STYLE_IRC == notification["chat_style"].asInteger())
+			{
+				notification["message"] = notification["from"].asString() + notification["message"].asString();
+			}
+
 			panel->addMessage(notification);
 			toast->reshapeToPanel();
 			toast->resetTimer();
@@ -302,7 +307,6 @@ LLNearbyChatHandler::LLNearbyChatHandler(e_notification_type type, const LLSD& i
 	channel->setCreatePanelCallback(callback);
 
 	mChannel = LLChannelManager::getInstance()->addChannel(channel);
-	mChannel->setOverflowFormatString("You have %d unread nearby chat messages");
 }
 
 LLNearbyChatHandler::~LLNearbyChatHandler()
@@ -332,25 +336,22 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg)
 
 	LLChat& tmp_chat = const_cast<LLChat&>(chat_msg);
 
-	if (tmp_chat.mChatStyle == CHAT_STYLE_IRC)
-	{
-		if(!tmp_chat.mFromName.empty())
-			tmp_chat.mText = tmp_chat.mFromName + tmp_chat.mText.substr(3);
-		else
-			tmp_chat.mText = tmp_chat.mText.substr(3);
-	}
-	
+	LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
 	{
 		//sometimes its usefull to have no name at all...
 		//if(tmp_chat.mFromName.empty() && tmp_chat.mFromID!= LLUUID::null)
 		//	tmp_chat.mFromName = tmp_chat.mFromID.asString();
 	}
-	
-	LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
 	nearby_chat->addMessage(chat_msg);
 	if(nearby_chat->getVisible())
 		return;//no need in toast if chat is visible
-	
+
+	// Handle irc styled messages for toast panel
+	if (tmp_chat.mChatStyle == CHAT_STYLE_IRC)
+	{
+		tmp_chat.mText = tmp_chat.mText.substr(3);
+	}
+
 	// arrange a channel on a screen
 	if(!mChannel->getVisible())
 	{
diff --git a/indra/newview/lloutputmonitorctrl.cpp b/indra/newview/lloutputmonitorctrl.cpp
index 63803469dd1..f816dc589d6 100644
--- a/indra/newview/lloutputmonitorctrl.cpp
+++ b/indra/newview/lloutputmonitorctrl.cpp
@@ -77,7 +77,9 @@ LLOutputMonitorCtrl::LLOutputMonitorCtrl(const LLOutputMonitorCtrl::Params& p)
 	mImageLevel3(p.image_level_3),
 	mAutoUpdate(p.auto_update),
 	mSpeakerId(p.speaker_id),
-	mIsAgentControl(false)
+	mIsAgentControl(false),
+	mIsSwitchDirty(false),
+	mShouldSwitchOn(false)
 {
 	//static LLUIColor output_monitor_muted_color = LLUIColorTable::instance().getColor("OutputMonitorMutedColor", LLColor4::orange);
 	//static LLUIColor output_monitor_overdriven_color = LLUIColorTable::instance().getColor("OutputMonitorOverdrivenColor", LLColor4::red);
@@ -108,6 +110,7 @@ LLOutputMonitorCtrl::LLOutputMonitorCtrl(const LLOutputMonitorCtrl::Params& p)
 LLOutputMonitorCtrl::~LLOutputMonitorCtrl()
 {
 	LLMuteList::getInstance()->removeObserver(this);
+	LLSpeakingIndicatorManager::unregisterSpeakingIndicator(mSpeakerId, this);
 }
 
 void LLOutputMonitorCtrl::setPower(F32 val)
@@ -117,6 +120,26 @@ void LLOutputMonitorCtrl::setPower(F32 val)
 
 void LLOutputMonitorCtrl::draw()
 {
+	// see also switchIndicator()
+	if (mIsSwitchDirty)
+	{
+		mIsSwitchDirty = false;
+		if (mShouldSwitchOn)
+		{
+			// just notify parent visibility may have changed
+			notifyParentVisibilityChanged();
+		}
+		else
+		{
+			// make itself invisible and notify parent about this
+			setVisible(FALSE);
+			notifyParentVisibilityChanged();
+
+			// no needs to render for invisible element
+			return;
+		}
+	}
+
 	// Copied from llmediaremotectrl.cpp
 	// *TODO: Give the LLOutputMonitorCtrl an agent-id to monitor, then
 	// call directly into gVoiceClient to ask if that agent-id is muted, is
@@ -229,6 +252,7 @@ void LLOutputMonitorCtrl::setSpeakerId(const LLUUID& speaker_id)
 	if (speaker_id.isNull() || speaker_id == mSpeakerId) return;
 
 	mSpeakerId = speaker_id;
+	LLSpeakingIndicatorManager::registerSpeakingIndicator(mSpeakerId, this);
 
 	//mute management
 	if (mAutoUpdate)
@@ -251,3 +275,42 @@ void LLOutputMonitorCtrl::onChange()
 	// check only blocking on voice. EXT-3542
 	setIsMuted(LLMuteList::getInstance()->isMuted(mSpeakerId, LLMute::flagVoiceChat));
 }
+
+// virtual
+void LLOutputMonitorCtrl::switchIndicator(bool switch_on)
+{
+	// ensure indicator is visible in case it is not in visible chain
+	// to be called when parent became visible next time to notify parent that visibility is changed.
+	setVisible(TRUE);
+
+	// if parent is in visible chain apply switch_on state and notify it immediately
+	if (getParent() && getParent()->isInVisibleChain())
+	{
+		LL_DEBUGS("SpeakingIndicator") << "Indicator is in visible chain, notifying parent: " << mSpeakerId << LL_ENDL;
+		setVisible((BOOL)switch_on);
+		notifyParentVisibilityChanged();
+	}
+
+	// otherwise remember necessary state and mark itself as dirty.
+	// State will be applied i next draw when parents chain became visible.
+	else
+	{
+		LL_DEBUGS("SpeakingIndicator") << "Indicator is not in visible chain, parent won't be notified: " << mSpeakerId << LL_ENDL;
+		mIsSwitchDirty = true;
+		mShouldSwitchOn = switch_on;
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////
+// PRIVATE SECTION
+//////////////////////////////////////////////////////////////////////////
+void LLOutputMonitorCtrl::notifyParentVisibilityChanged()
+{
+	LL_DEBUGS("SpeakingIndicator") << "Notify parent that visibility was changed: " << mSpeakerId << " ,new_visibility: " << getVisible() << LL_ENDL;
+
+	LLSD params = LLSD().with("visibility_changed", getVisible());
+
+	notifyParent(params);
+}
+
+// EOF
diff --git a/indra/newview/lloutputmonitorctrl.h b/indra/newview/lloutputmonitorctrl.h
index 85ea552a572..2bbfa251e9d 100644
--- a/indra/newview/lloutputmonitorctrl.h
+++ b/indra/newview/lloutputmonitorctrl.h
@@ -36,6 +36,7 @@
 #include "v4color.h"
 #include "llview.h"
 #include "llmutelist.h"
+#include "llspeakingindicatormanager.h"
 
 class LLTextBox;
 class LLUICtrlFactory;
@@ -45,7 +46,7 @@ class LLUICtrlFactory;
 //
 
 class LLOutputMonitorCtrl
-: public LLView, LLMuteListObserver
+: public LLView, public LLSpeakingIndicator, LLMuteListObserver
 {
 public:
 	struct Params : public LLInitParam::Block<Params, LLView::Params>
@@ -90,7 +91,29 @@ class LLOutputMonitorCtrl
 	//called by mute list
 	virtual void onChange();
 
+	/**
+	 * Implementation of LLSpeakingIndicator interface.
+	 * Behavior is implemented via changing visibility.
+	 *
+	 * If instance is in visible chain now (all parents are visible) it changes visibility 
+	 * and notify parent about this.
+	 *
+	 * Otherwise it marks an instance as dirty and stores necessary visibility.
+	 * It will be applied in next draw and parent will be notified.
+	 */
+	virtual void	switchIndicator(bool switch_on);
+
 private:
+
+	/**
+	 * Notifies parent about changed visibility.
+	 *
+	 * Passes LLSD with "visibility_changed" => <current visibility> value.
+	 * For now it is processed by LLAvatarListItem to update (reshape) its children.
+	 * Implemented fo complete EXT-3976
+	 */
+	void			notifyParentVisibilityChanged();
+
 	//static LLColor4	sColorMuted;
 	//static LLColor4	sColorNormal;
 	//static LLColor4	sColorOverdriven;
@@ -117,6 +140,10 @@ class LLOutputMonitorCtrl
 
 	/** uuid of a speaker being monitored */
 	LLUUID			mSpeakerId;
+
+	/** indicates if the instance is dirty and should notify parent */
+	bool			mIsSwitchDirty;
+	bool			mShouldSwitchOn;
 };
 
 #endif
diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index fb898f7cdf6..85e95ca1d65 100644
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -52,6 +52,7 @@
 #include "llfloaterreg.h"
 #include "llnotificationsutil.h"
 #include "llvoiceclient.h"
+#include "llnamebox.h"
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // Class LLDropTarget
@@ -595,7 +596,10 @@ void LLPanelAvatarProfile::processGroupProperties(const LLAvatarGroups* avatar_g
 			groups += ", ";
 
 		std::string group_name = LLURI::escape(it->first);
-		std::string group_url="[secondlife:///app/group/" + it->second.asString() + "/about " + group_name + "]";
+		std::string group_url= it->second.notNull()
+				? "[secondlife:///app/group/" + it->second.asString() + "/about " + group_name + "]"
+						: getString("no_group_text");
+
 		groups += group_url;
 	}
 
@@ -621,19 +625,15 @@ void LLPanelAvatarProfile::fillCommonData(const LLAvatarData* avatar_data)
 
 void LLPanelAvatarProfile::fillPartnerData(const LLAvatarData* avatar_data)
 {
+	LLNameBox* name_box = getChild<LLNameBox>("partner_text");
 	if (avatar_data->partner_id.notNull())
 	{
-		std::string first, last;
-		BOOL found = gCacheName->getName(avatar_data->partner_id, first, last);
-		if (found)
-		{
-			childSetTextArg("partner_text", "[FIRST]", first);
-			childSetTextArg("partner_text", "[LAST]", last);
-		}
+		name_box->setNameID(avatar_data->partner_id, FALSE);
 	}
 	else
 	{
-		childSetTextArg("partner_text", "[FIRST]", getString("no_partner_text"));
+		name_box->setNameID(LLUUID::null, FALSE);
+		name_box->setText(getString("no_partner_text"));
 	}
 }
 
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index 94de17c17d8..daec793d756 100644
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -151,6 +151,11 @@ BOOL LLPanelGroup::postBuild()
 	button->setVisible(true);
 	button->setEnabled(false);
 
+	button = getChild<LLButton>("btn_call");
+	button->setClickedCallback(onBtnGroupCallClicked, this);
+
+	button = getChild<LLButton>("btn_chat");
+	button->setClickedCallback(onBtnGroupChatClicked, this);
 
 	button = getChild<LLButton>("btn_join");
 	button->setVisible(false);
@@ -215,6 +220,8 @@ void LLPanelGroup::reposButtons()
 	reposButton("btn_create");
 	reposButton("btn_refresh");
 	reposButton("btn_cancel");
+	reposButton("btn_chat");
+	reposButton("btn_call");
 }
 
 void LLPanelGroup::reshape(S32 width, S32 height, BOOL called_from_parent )
@@ -262,6 +269,18 @@ void LLPanelGroup::onBtnApply(void* user_data)
 	self->apply();
 }
 
+void LLPanelGroup::onBtnGroupCallClicked(void* user_data)
+{
+	LLPanelGroup* self = static_cast<LLPanelGroup*>(user_data);
+	self->callGroup();
+}
+
+void LLPanelGroup::onBtnGroupChatClicked(void* user_data)
+{
+	LLPanelGroup* self = static_cast<LLPanelGroup*>(user_data);
+	self->chatGroup();
+}
+
 void LLPanelGroup::onBtnJoin()
 {
 	lldebugs << "joining group: " << mID << llendl;
@@ -349,6 +368,8 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 	LLButton* button_create = findChild<LLButton>("btn_create");
 	LLButton* button_join = findChild<LLButton>("btn_join");
 	LLButton* button_cancel = findChild<LLButton>("btn_cancel");
+	LLButton* button_call = findChild<LLButton>("btn_call");
+	LLButton* button_chat = findChild<LLButton>("btn_chat");
 
 
 	bool is_null_group_id = group_id == LLUUID::null;
@@ -362,6 +383,11 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 	if(button_cancel)
 		button_cancel->setVisible(!is_null_group_id);
 
+	if(button_call)
+			button_call->setVisible(!is_null_group_id);
+	if(button_chat)
+			button_chat->setVisible(!is_null_group_id);
+
 	getChild<LLUICtrl>("prepend_founded_by")->setVisible(!is_null_group_id);
 
 	LLAccordionCtrl* tab_ctrl = findChild<LLAccordionCtrl>("group_accordion");
@@ -423,12 +449,15 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 
 		getChild<LLUICtrl>("group_name")->setVisible(true);
 		getChild<LLUICtrl>("group_name_editor")->setVisible(false);
+
+		if(button_apply)
+			button_apply->setVisible(is_member);
 	}
 
 	reposButtons();
 }
 
-bool	LLPanelGroup::apply(LLPanelGroupTab* tab)
+bool LLPanelGroup::apply(LLPanelGroupTab* tab)
 {
 	if(!tab)
 		return false;
@@ -471,12 +500,17 @@ void LLPanelGroup::draw()
 		childEnable("btn_refresh");
 	}
 
-	bool enable = false;
-	std::string mesg;
-	for(std::vector<LLPanelGroupTab* >::iterator it = mTabs.begin();it!=mTabs.end();++it)
-		enable = enable || (*it)->needsApply(mesg);
+	LLButton* button_apply = findChild<LLButton>("btn_apply");
+	
+	if(button_apply && button_apply->getVisible())
+	{
+		bool enable = false;
+		std::string mesg;
+		for(std::vector<LLPanelGroupTab* >::iterator it = mTabs.begin();it!=mTabs.end();++it)
+			enable = enable || (*it)->needsApply(mesg);
 
-	childSetEnabled("btn_apply", enable);
+		childSetEnabled("btn_apply", enable);
+	}
 }
 
 void LLPanelGroup::refreshData()
@@ -491,6 +525,15 @@ void LLPanelGroup::refreshData()
 	mRefreshTimer.setTimerExpirySec(5);
 }
 
+void LLPanelGroup::callGroup()
+{
+	LLGroupActions::startCall(getID());
+}
+
+void LLPanelGroup::chatGroup()
+{
+	LLGroupActions::startIM(getID());
+}
 
 void LLPanelGroup::showNotice(const std::string& subject,
 							  const std::string& message,
diff --git a/indra/newview/llpanelgroup.h b/indra/newview/llpanelgroup.h
index f6aefdb676d..7ea5e67b44f 100644
--- a/indra/newview/llpanelgroup.h
+++ b/indra/newview/llpanelgroup.h
@@ -74,6 +74,8 @@ class LLPanelGroup : public LLPanel,
 
 	bool apply();
 	void refreshData();
+	void callGroup();
+	void chatGroup();
 
 	virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
 
@@ -103,6 +105,8 @@ class LLPanelGroup : public LLPanel,
 
 	static void onBtnApply(void*);
 	static void onBtnRefresh(void*);
+	static void onBtnGroupCallClicked(void*);
+	static void onBtnGroupChatClicked(void*);
 
 	void reposButton(const std::string& name);
 	void reposButtons();
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 31dfdde887c..21b253223f0 100644
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -580,7 +580,6 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 			}
 		}
 
-		mComboActiveTitle->resetDirty();
 	}
 
 	// If this was just a titles update, we are done.
@@ -595,8 +594,6 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 	{
 		mCtrlShowInGroupList->set(gdatap->mShowInList);
 		mCtrlShowInGroupList->setEnabled(mAllowEdit && can_change_ident);
-		mCtrlShowInGroupList->resetDirty();
-
 	}
 	if (mComboMature)
 	{
@@ -610,19 +607,16 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 		}
 		mComboMature->setEnabled(mAllowEdit && can_change_ident);
 		mComboMature->setVisible( !gAgent.isTeen() );
-		mComboMature->resetDirty();
 	}
 	if (mCtrlOpenEnrollment) 
 	{
 		mCtrlOpenEnrollment->set(gdatap->mOpenEnrollment);
 		mCtrlOpenEnrollment->setEnabled(mAllowEdit && can_change_member_opts);
-		mCtrlOpenEnrollment->resetDirty();
 	}
 	if (mCtrlEnrollmentFee) 
 	{	
 		mCtrlEnrollmentFee->set(gdatap->mMembershipFee > 0);
 		mCtrlEnrollmentFee->setEnabled(mAllowEdit && can_change_member_opts);
-		mCtrlEnrollmentFee->resetDirty();
 	}
 	
 	if (mSpinEnrollmentFee)
@@ -632,7 +626,6 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 		mSpinEnrollmentFee->setEnabled( mAllowEdit &&
 						(fee > 0) &&
 						can_change_member_opts);
-		mSpinEnrollmentFee->resetDirty();
 	}
 	if (mCtrlReceiveNotices)
 	{
@@ -641,7 +634,6 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 		{
 			mCtrlReceiveNotices->setEnabled(mAllowEdit);
 		}
-		mCtrlReceiveNotices->resetDirty();
 	}
 
 
@@ -665,7 +657,6 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 	if (mEditCharter)
 	{
 		mEditCharter->setText(gdatap->mCharter);
-		mEditCharter->resetDirty();
 	}
 	
 	if (mListVisibleMembers)
@@ -693,6 +684,8 @@ void LLPanelGroupGeneral::update(LLGroupChange gc)
 			mListVisibleMembers->addElement(row);
 		}
 	}
+
+	resetDirty();
 }
 
 void LLPanelGroupGeneral::updateMembers()
diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp
index 29b647415c3..0e55ff3214d 100644
--- a/indra/newview/llpanelgrouproles.cpp
+++ b/indra/newview/llpanelgrouproles.cpp
@@ -460,17 +460,8 @@ LLPanelGroupSubTab::~LLPanelGroupSubTab()
 {
 }
 
-BOOL LLPanelGroupSubTab::postBuild()
-{
-	// Hook up the search widgets.
-	bool recurse = true;
-	mSearchEditor = getChild<LLFilterEditor>("filter_input", recurse);
-
-	if (!mSearchEditor) 
-		return FALSE;
-
-	mSearchEditor->setCommitCallback(boost::bind(&LLPanelGroupSubTab::setSearchFilter, this, _2));
-	
+BOOL LLPanelGroupSubTab::postBuildSubTab(LLView* root) 
+{ 
 	// Get icons for later use.
 	mActionIcons.clear();
 
@@ -488,6 +479,19 @@ BOOL LLPanelGroupSubTab::postBuild()
 	{
 		mActionIcons["partial"] = getString("power_partial_icon");
 	}
+	return TRUE; 
+}
+
+BOOL LLPanelGroupSubTab::postBuild()
+{
+	// Hook up the search widgets.
+	bool recurse = true;
+	mSearchEditor = getChild<LLFilterEditor>("filter_input", recurse);
+
+	if (!mSearchEditor) 
+		return FALSE;
+
+	mSearchEditor->setCommitCallback(boost::bind(&LLPanelGroupSubTab::setSearchFilter, this, _2));
 
 	return LLPanelGroupTab::postBuild();
 }
@@ -567,7 +571,6 @@ bool LLPanelGroupSubTab::matchesActionSearchFilter(std::string action)
 void LLPanelGroupSubTab::buildActionsList(LLScrollListCtrl* ctrl, 
 										  U64 allowed_by_some, 
 										  U64 allowed_by_all,
-										  icon_map_t& icons,
 										  LLUICtrl::commit_callback_t commit_callback,
 										  BOOL show_all,
 										  BOOL filter,
@@ -588,7 +591,6 @@ void LLPanelGroupSubTab::buildActionsList(LLScrollListCtrl* ctrl,
 							allowed_by_some,
 							allowed_by_all,
 							(*ras_it),
-							icons, 
 							commit_callback,
 							show_all,
 							filter,
@@ -600,7 +602,6 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 											 U64 allowed_by_some,
 											 U64 allowed_by_all,
 											 LLRoleActionSet* action_set,
-											 icon_map_t& icons,
 											 LLUICtrl::commit_callback_t commit_callback,
 											 BOOL show_all,
 											 BOOL filter,
@@ -614,26 +615,26 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 		LLSD row;
 
 		row["columns"][0]["column"] = "icon";
-		icon_map_t::iterator iter = icons.find("folder");
-		if (iter != icons.end())
+		row["columns"][0]["type"] = "icon";
+		
+		icon_map_t::iterator iter = mActionIcons.find("folder");
+		if (iter != mActionIcons.end())
 		{
-			row["columns"][0]["type"] = "icon";
 			row["columns"][0]["value"] = (*iter).second;
 		}
 
 		row["columns"][1]["column"] = "action";
+		row["columns"][1]["type"] = "text";
 		row["columns"][1]["value"] = action_set->mActionSetData->mName;
 		row["columns"][1]["font"]["name"] = "SANSSERIF_SMALL";
-		row["columns"][1]["font"]["style"] = "BOLD";
+		
 
 		LLScrollListItem* title_row = ctrl->addElement(row, ADD_BOTTOM, action_set->mActionSetData);
 		
-		LLScrollListText* name_textp = dynamic_cast<LLScrollListText*>(title_row->getColumn(1));
+		LLScrollListText* name_textp = dynamic_cast<LLScrollListText*>(title_row->getColumn(2)); //?? I have no idea fix getColumn(1) return column spacer...
 		if (name_textp)
 			name_textp->setFontStyle(LLFontGL::BOLD);
 
-
-
 		bool category_matches_filter = (filter) ? matchesActionSearchFilter(action_set->mActionSetData->mName) : true;
 
 		std::vector<LLRoleAction*>::iterator ra_it = action_set->mActions.begin();
@@ -686,8 +687,8 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 			{
 				if (show_full_strength)
 				{
-					icon_map_t::iterator iter = icons.find("full");
-					if (iter != icons.end())
+					icon_map_t::iterator iter = mActionIcons.find("full");
+					if (iter != mActionIcons.end())
 					{
 						row["columns"][column_index]["column"] = "checkbox";
 						row["columns"][column_index]["type"] = "icon";
@@ -697,8 +698,8 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 				}
 				else
 				{
-					icon_map_t::iterator iter = icons.find("partial");
-					if (iter != icons.end())
+					icon_map_t::iterator iter = mActionIcons.find("partial");
+					if (iter != mActionIcons.end())
 					{
 						row["columns"][column_index]["column"] = "checkbox";
 						row["columns"][column_index]["type"] = "icon";
@@ -792,6 +793,8 @@ LLPanelGroupMembersSubTab::~LLPanelGroupMembersSubTab()
 
 BOOL LLPanelGroupMembersSubTab::postBuildSubTab(LLView* root)
 {
+	LLPanelGroupSubTab::postBuildSubTab(root);
+	
 	// Upcast parent so we can ask it for sibling controls.
 	LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root;
 
@@ -888,7 +891,6 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
 	buildActionsList(mAllowedActionsList,
 					 allowed_by_some,
 					 allowed_by_all,
-					 mActionIcons,
 					 NULL,
 					 FALSE,
 					 FALSE,
@@ -1211,7 +1213,6 @@ void LLPanelGroupMembersSubTab::handleRoleCheck(const LLUUID& role_id,
 	buildActionsList(mAllowedActionsList,
 					 powers_some_have,
 					 powers_all_have,
-					 mActionIcons,
 					 NULL,
 					 FALSE,
 					 FALSE,
@@ -1684,6 +1685,8 @@ LLPanelGroupRolesSubTab::~LLPanelGroupRolesSubTab()
 
 BOOL LLPanelGroupRolesSubTab::postBuildSubTab(LLView* root)
 {
+	LLPanelGroupSubTab::postBuildSubTab(root);
+
 	// Upcast parent so we can ask it for sibling controls.
 	LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root;
 
@@ -1994,7 +1997,6 @@ void LLPanelGroupRolesSubTab::handleRoleSelect()
 		buildActionsList(mAllowedActionsList,
 						 rd.mRolePowers,
 						 0LL,
-						 mActionIcons,
 						 boost::bind(&LLPanelGroupRolesSubTab::handleActionCheck, this, _1, false),
 						 TRUE,
 						 FALSE,
@@ -2381,6 +2383,8 @@ LLPanelGroupActionsSubTab::~LLPanelGroupActionsSubTab()
 
 BOOL LLPanelGroupActionsSubTab::postBuildSubTab(LLView* root)
 {
+	LLPanelGroupSubTab::postBuildSubTab(root);
+
 	// Upcast parent so we can ask it for sibling controls.
 	LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root;
 
@@ -2448,7 +2452,6 @@ void LLPanelGroupActionsSubTab::update(LLGroupChange gc)
 	buildActionsList(mActionList,
 					 GP_ALL_POWERS,
 					 GP_ALL_POWERS,
-					 mActionIcons,
 					 NULL,
 					 FALSE,
 					 TRUE,
diff --git a/indra/newview/llpanelgrouproles.h b/indra/newview/llpanelgrouproles.h
index bb3c9096cf4..2f81900e609 100644
--- a/indra/newview/llpanelgrouproles.h
+++ b/indra/newview/llpanelgrouproles.h
@@ -108,7 +108,7 @@ class LLPanelGroupSubTab : public LLPanelGroupTab
 	virtual BOOL postBuild();
 
 	// This allows sub-tabs to collect child widgets from a higher level in the view hierarchy.
-	virtual BOOL postBuildSubTab(LLView* root) { return TRUE; }
+	virtual BOOL postBuildSubTab(LLView* root);
 
 	virtual void setSearchFilter( const std::string& filter );
 
@@ -117,10 +117,15 @@ class LLPanelGroupSubTab : public LLPanelGroupTab
 
 	// Helper functions
 	bool matchesActionSearchFilter(std::string action);
+
+
+	void setFooterEnabled(BOOL enable);
+
+	virtual void setGroupID(const LLUUID& id);
+protected:
 	void buildActionsList(LLScrollListCtrl* ctrl,
 								 U64 allowed_by_some,
 								 U64 allowed_by_all,
-								 icon_map_t& icons,
 						  		 LLUICtrl::commit_callback_t commit_callback,
 								 BOOL show_all,
 								 BOOL filter,
@@ -129,15 +134,11 @@ class LLPanelGroupSubTab : public LLPanelGroupTab
 									U64 allowed_by_some,
 									U64 allowed_by_all,
 									LLRoleActionSet* action_set,
-									icon_map_t& icons,
 									LLUICtrl::commit_callback_t commit_callback,
 									BOOL show_all,
 									BOOL filter,
 									BOOL is_owner_role);
 
-	void setFooterEnabled(BOOL enable);
-
-	virtual void setGroupID(const LLUUID& id);
 protected:
 	LLPanel* mHeader;
 	LLPanel* mFooter;
diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp
index b547997e7aa..0cfe501fab5 100644
--- a/indra/newview/llpanelimcontrolpanel.cpp
+++ b/indra/newview/llpanelimcontrolpanel.cpp
@@ -302,7 +302,7 @@ void LLPanelGroupControlPanel::setSessionId(const LLUUID& session_id)
 {
 	LLPanelChatControlPanel::setSessionId(session_id);
 
-	mGroupID = LLIMModel::getInstance()->getOtherParticipantID(session_id);
+	mGroupID = session_id;
 
 	// for group and Ad-hoc chat we need to include agent into list 
 	if(!mParticipantList)
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index e14a5778adc..03cc870a595 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -35,6 +35,7 @@
 // libs
 #include "llfloaterreg.h"
 #include "llmenugl.h"
+#include "llnotificationsutil.h"
 #include "llfiltereditor.h"
 #include "lltabcontainer.h"
 #include "lluictrlfactory.h"
@@ -750,7 +751,6 @@ void LLPanelPeople::updateButtons()
 
 		LLPanel* groups_panel = mTabContainer->getCurrentPanel();
 		groups_panel->childSetEnabled("activate_btn",	item_selected && !cur_group_active); // "none" or a non-active group selected
-		groups_panel->childSetEnabled("plus_btn",		item_selected);
 		groups_panel->childSetEnabled("minus_btn",		item_selected && selected_id.notNull());
 	}
 	else
@@ -1138,6 +1138,12 @@ void LLPanelPeople::onAvatarPicked(
 
 void LLPanelPeople::onGroupPlusButtonClicked()
 {
+	if (!gAgent.canJoinGroups())
+	{
+		LLNotificationsUtil::add("JoinedTooManyGroups");
+		return;
+	}
+
 	LLMenuGL* plus_menu = (LLMenuGL*)mGroupPlusMenuHandle.get();
 	if (!plus_menu)
 		return;
diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp
index 7a4dd3569d5..e7615929c82 100644
--- a/indra/newview/llpanelpick.cpp
+++ b/indra/newview/llpanelpick.cpp
@@ -35,24 +35,30 @@
 // profile.
 
 #include "llviewerprecompiledheaders.h"
-#include "llpanel.h"
+
+#include "llpanelpick.h"
+
 #include "message.h"
-#include "llagent.h"
-#include "llagentpicksinfo.h"
+
+#include "llparcel.h"
+
 #include "llbutton.h"
+#include "llfloaterreg.h"
 #include "lliconctrl.h"
 #include "lllineeditor.h"
-#include "llparcel.h"
-#include "llviewerparcelmgr.h"
+#include "llpanel.h"
+#include "llscrollcontainer.h"
 #include "lltexteditor.h"
+
+#include "llagent.h"
+#include "llagentpicksinfo.h"
+#include "llavatarpropertiesprocessor.h"
+#include "llfloaterworldmap.h"
 #include "lltexturectrl.h"
 #include "lluiconstants.h"
+#include "llviewerparcelmgr.h"
 #include "llviewerregion.h"
 #include "llworldmap.h"
-#include "llfloaterworldmap.h"
-#include "llfloaterreg.h"
-#include "llavatarpropertiesprocessor.h"
-#include "llpanelpick.h"
 
 
 #define XML_PANEL_EDIT_PICK "panel_edit_pick.xml"
@@ -93,6 +99,10 @@ LLPanelPickInfo::LLPanelPickInfo()
  , mPickId(LLUUID::null)
  , mParcelId(LLUUID::null)
  , mRequestedId(LLUUID::null)
+ , mScrollingPanelMinHeight(0)
+ , mScrollingPanelWidth(0)
+ , mScrollingPanel(NULL)
+ , mScrollContainer(NULL)
 {
 }
 
@@ -146,9 +156,35 @@ BOOL LLPanelPickInfo::postBuild()
 	childSetAction("show_on_map_btn", boost::bind(&LLPanelPickInfo::onClickMap, this));
 	childSetAction("back_btn", boost::bind(&LLPanelPickInfo::onClickBack, this));
 
+	mScrollingPanel = getChild<LLPanel>("scroll_content_panel");
+	mScrollContainer = getChild<LLScrollContainer>("profile_scroll");
+
+	mScrollingPanelMinHeight = mScrollContainer->getScrolledViewRect().getHeight();
+	mScrollingPanelWidth = mScrollingPanel->getRect().getWidth();
+
 	return TRUE;
 }
 
+void LLPanelPickInfo::reshape(S32 width, S32 height, BOOL called_from_parent)
+{
+	LLPanel::reshape(width, height, called_from_parent);
+
+	if (!mScrollContainer || !mScrollingPanel)
+		return;
+
+	static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
+
+	S32 scroll_height = mScrollContainer->getRect().getHeight();
+	if (mScrollingPanelMinHeight >= scroll_height)
+	{
+		mScrollingPanel->reshape(mScrollingPanelWidth, mScrollingPanelMinHeight);
+	}
+	else
+	{
+		mScrollingPanel->reshape(mScrollingPanelWidth + scrollbar_size, scroll_height);
+	}
+}
+
 void LLPanelPickInfo::processProperties(void* data, EAvatarProcessorType type)
 {
 	if(APT_PICK_INFO != type)
@@ -284,7 +320,6 @@ void LLPanelPickInfo::setPickName(const std::string& name)
 void LLPanelPickInfo::setPickDesc(const std::string& desc)
 {
 	childSetValue(XML_DESC, desc);
-	updateContentPanelRect();
 }
 
 void LLPanelPickInfo::setPickLocation(const std::string& location)
@@ -292,31 +327,6 @@ void LLPanelPickInfo::setPickLocation(const std::string& location)
 	childSetValue(XML_LOCATION, location);
 }
 
-void LLPanelPickInfo::updateContentPanelRect()
-{
-	LLTextBox* desc = getChild<LLTextBox>(XML_DESC);
-
-	S32 text_height = desc->getTextPixelHeight();
-	LLRect text_rect = desc->getRect();
-
-	// let text-box height fit text height
-	text_rect.set(text_rect.mLeft, text_rect.mTop, text_rect.mRight, text_rect.mTop - text_height);
-	desc->setRect(text_rect);
-	desc->reshape(text_rect.getWidth(), text_rect.getHeight());
-	// force reflow
-	desc->setText(desc->getText());
-
-	// bottom of description text-box will be bottom of content panel
-	desc->localRectToOtherView(desc->getLocalRect(), &text_rect, getChild<LLView>("profile_scroll"));
-
-	LLPanel* content_panel = getChild<LLPanel>("scroll_content_panel");
-	LLRect content_rect = content_panel->getRect();
-	content_rect.set(content_rect.mLeft, content_rect.mTop, content_rect.mRight, text_rect.mBottom);
-	// Somehow setRect moves all elements down.
-	// Single reshape() updates rect and does not move anything.
-	content_panel->reshape(content_rect.getWidth(), content_rect.getHeight());
-}
-
 void LLPanelPickInfo::onClickMap()
 {
 	LLFloaterWorldMap::getInstance()->trackLocation(getPosGlobal());
diff --git a/indra/newview/llpanelpick.h b/indra/newview/llpanelpick.h
index 12b5a116b48..62c3b20c0da 100644
--- a/indra/newview/llpanelpick.h
+++ b/indra/newview/llpanelpick.h
@@ -43,6 +43,7 @@
 
 class LLIconCtrl;
 class LLTextureCtrl;
+class LLScrollContainer;
 class LLMessageSystem;
 class LLAvatarPropertiesObserver;
 
@@ -69,6 +70,8 @@ class LLPanelPickInfo : public LLPanel, public LLAvatarPropertiesObserver, LLRem
 
 	/*virtual*/ BOOL postBuild();
 
+	/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
+
 	/*virtual*/ void processProperties(void* data, EAvatarProcessorType type);
 
 	/**
@@ -139,15 +142,6 @@ class LLPanelPickInfo : public LLPanel, public LLAvatarPropertiesObserver, LLRem
 	virtual void setPosGlobal(const LLVector3d& pos) { mPosGlobal = pos; }
 	virtual LLVector3d& getPosGlobal() { return mPosGlobal; }
 
-	/**
-	 * Reshapes content panel to fit all elements.
-	 *
-	 * Assume that description text-box is the last element of panel.
-	 * Reshape text-box to fit text height and then reshape content panel to fit 
-	 * text-box bottom. EXT-1326
-	 */
-	void updateContentPanelRect();
-
 	/**
 	 * Callback for "Map" button, opens Map
 	 */
@@ -162,7 +156,11 @@ class LLPanelPickInfo : public LLPanel, public LLAvatarPropertiesObserver, LLRem
 
 protected:
 
-	LLTextureCtrl* mSnapshotCtrl;
+	S32						mScrollingPanelMinHeight;
+	S32						mScrollingPanelWidth;
+	LLScrollContainer*		mScrollContainer;
+	LLPanel*				mScrollingPanel;
+	LLTextureCtrl*			mSnapshotCtrl;
 
 	LLUUID mAvatarId;
 	LLVector3d mPosGlobal;
diff --git a/indra/newview/llpanelplaces.h b/indra/newview/llpanelplaces.h
index 5ee87049926..b134cf0cba6 100644
--- a/indra/newview/llpanelplaces.h
+++ b/indra/newview/llpanelplaces.h
@@ -71,6 +71,10 @@ class LLPanelPlaces : public LLPanel
 
 	void setItem(LLInventoryItem* item);
 
+	LLInventoryItem* getItem() { return mItem; }
+
+	std::string getPlaceInfoType() { return mPlaceInfoType; }
+
 private:
 	void onLandmarkLoaded(LLLandmark* landmark);
 	void onFilterEdit(const std::string& search_string, bool force_filter);
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 65a3d9d41b9..0a2217fc51c 100644
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -550,7 +550,7 @@ void LLTeleportHistoryPanel::updateVerbs()
 
 	LLTeleportHistoryFlatItem* itemp = dynamic_cast<LLTeleportHistoryFlatItem *> (mLastSelectedFlatlList->getSelectedItem());
 
-	mTeleportBtn->setEnabled(NULL != itemp && itemp->getIndex() < (S32)mTeleportHistory->getItems().size() - 1);
+	mTeleportBtn->setEnabled(NULL != itemp);
 	mShowOnMapBtn->setEnabled(NULL != itemp);
 }
 
diff --git a/indra/newview/llpanelvolumepulldown.cpp b/indra/newview/llpanelvolumepulldown.cpp
new file mode 100644
index 00000000000..74e37efe4e4
--- /dev/null
+++ b/indra/newview/llpanelvolumepulldown.cpp
@@ -0,0 +1,154 @@
+/** 
+ * @file llpanelvolumepulldown.cpp
+ * @author Tofu Linden
+ * @brief A floater showing the master volume pull-down
+ *
+ * $LicenseInfo:firstyear=2008&license=viewergpl$
+ * 
+ * Copyright (c) 2008-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llpanelvolumepulldown.h"
+
+// Viewer libs
+#include "llviewercontrol.h"
+#include "llstatusbar.h"
+
+// Linden libs
+#include "llbutton.h"
+#include "lltabcontainer.h"
+#include "llfloaterreg.h"
+#include "llfloaterpreference.h"
+#include "llslider.h"
+
+/* static */ const F32 LLPanelVolumePulldown::sAutoCloseFadeStartTimeSec = 4.0f;
+/* static */ const F32 LLPanelVolumePulldown::sAutoCloseTotalTimeSec = 5.0f;
+
+///----------------------------------------------------------------------------
+/// Class LLPanelVolumePulldown
+///----------------------------------------------------------------------------
+
+// Default constructor
+LLPanelVolumePulldown::LLPanelVolumePulldown()
+{
+    mCommitCallbackRegistrar.add("Vol.setControlFalse", boost::bind(&LLPanelVolumePulldown::setControlFalse, this, _2));
+	mCommitCallbackRegistrar.add("Vol.GoAudioPrefs", boost::bind(&LLPanelVolumePulldown::onAdvancedButtonClick, this, _2));
+	LLUICtrlFactory::instance().buildPanel(this, "panel_volume_pulldown.xml");
+}
+
+BOOL LLPanelVolumePulldown::postBuild()
+{
+	// set the initial volume-slider's position to reflect reality
+	LLSlider* volslider =  getChild<LLSlider>( "mastervolume" );
+	volslider->setValue(gSavedSettings.getF32("AudioLevelMaster"));
+
+	return LLPanel::postBuild();
+}
+
+/*virtual*/
+void LLPanelVolumePulldown::onMouseEnter(S32 x, S32 y, MASK mask)
+{
+	mHoverTimer.stop();
+	LLPanel::onMouseEnter(x,y,mask);
+}
+
+
+/*virtual*/
+void LLPanelVolumePulldown::onMouseLeave(S32 x, S32 y, MASK mask)
+{
+	mHoverTimer.start();
+	LLPanel::onMouseLeave(x,y,mask);
+}
+
+/*virtual*/ 
+void LLPanelVolumePulldown::handleVisibilityChange ( BOOL new_visibility )
+{
+	if (new_visibility)	
+	{
+		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
+		gFocusMgr.setTopCtrl(this);
+	}
+	else
+	{
+		mHoverTimer.stop();
+		gFocusMgr.setTopCtrl(NULL);
+	}
+}
+
+/*virtual*/ 
+void LLPanelVolumePulldown::onTopLost()
+{
+	setVisible(FALSE);
+}
+
+void LLPanelVolumePulldown::onAdvancedButtonClick(const LLSD& user_data)
+{
+	// close the global volume minicontrol, we're bringing up the big one
+	setVisible(FALSE);
+
+	// bring up the prefs floater
+	LLFloaterPreference* prefsfloater = dynamic_cast<LLFloaterPreference*>
+		(LLFloaterReg::showInstance("preferences"));
+	if (prefsfloater)
+	{
+		// grab the 'audio' panel from the preferences floater and
+		// bring it the front!
+		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
+		LLPanel* audiopanel = prefsfloater->getChild<LLPanel>("audio");
+		if (tabcontainer && audiopanel)
+		{
+			tabcontainer->selectTabPanel(audiopanel);
+		}
+	}
+}
+
+void LLPanelVolumePulldown::setControlFalse(const LLSD& user_data)
+{
+	std::string control_name = user_data.asString();
+	LLControlVariable* control = findControl(control_name);
+	
+	if (control)
+		control->set(LLSD(FALSE));
+}
+
+//virtual
+void LLPanelVolumePulldown::draw()
+{
+	F32 alpha = mHoverTimer.getStarted() 
+		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
+		: 1.0f;
+	LLViewDrawContext context(alpha);
+
+	LLPanel::draw();
+
+	if (alpha == 0.f)
+	{
+		setVisible(FALSE);
+	}
+}
+
diff --git a/indra/newview/llpanelvolumepulldown.h b/indra/newview/llpanelvolumepulldown.h
new file mode 100644
index 00000000000..9f20caa1a8b
--- /dev/null
+++ b/indra/newview/llpanelvolumepulldown.h
@@ -0,0 +1,64 @@
+/** 
+ * @file llpanelvolumepulldown.h
+ * @author Tofu Linden
+ * @brief A panel showing the master volume pull-down
+ *
+ * $LicenseInfo:firstyear=2008&license=viewergpl$
+ * 
+ * Copyright (c) 2008-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLPANELVOLUMEPULLDOWN_H
+#define LL_LLPANELVOLUMEPULLDOWN_H
+
+#include "linden_common.h"
+
+#include "llpanel.h"
+
+class LLFrameTimer;
+
+class LLPanelVolumePulldown : public LLPanel
+{
+ public:
+	LLPanelVolumePulldown();
+	/*virtual*/ void draw();
+	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
+	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
+	/*virtual*/ void handleVisibilityChange ( BOOL new_visibility );
+	/*virtual*/ void onTopLost();
+	/*virtual*/ BOOL postBuild();
+	
+ private:
+	void setControlFalse(const LLSD& user_data);
+	void onAdvancedButtonClick(const LLSD& user_data);
+
+	LLFrameTimer mHoverTimer;
+	static const F32 sAutoCloseFadeStartTimeSec;
+	static const F32 sAutoCloseTotalTimeSec;
+};
+
+
+#endif // LL_LLPANELVOLUMEPULLDOWN_H
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index e2da4c44758..b6f78d08f12 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -166,7 +166,6 @@ void LLParticipantList::onAvatarListRefreshed(LLUICtrl* ctrl, const LLSD& param)
 				{
 					name.erase(found, moderator_indicator_len);
 					item->setName(name);
-					item->reshapeAvatarName();
 				}
 			}
 		}
@@ -188,7 +187,6 @@ void LLParticipantList::onAvatarListRefreshed(LLUICtrl* ctrl, const LLSD& param)
 					name += " ";
 					name += moderator_indicator;
 					item->setName(name);
-					item->reshapeAvatarName();
 				}
 			}
 		}
@@ -279,6 +277,9 @@ bool LLParticipantList::onModeratorUpdateEvent(LLPointer<LLOldEvents::LLEvent> e
 					mModeratorList.erase(id);
 				}
 			}
+
+			// apply changes immediately
+			onAvatarListRefreshed(mAvatarList, LLSD());
 		}
 	}
 	return true;
@@ -592,8 +593,7 @@ bool LLParticipantList::LLParticipantListMenu::enableContextMenuItem(const LLSD&
 			if (speakerp.notNull())
 			{
 				// not in voice participants can not be moderated
-				return speakerp->mStatus == LLSpeaker::STATUS_VOICE_ACTIVE
-					|| speakerp->mStatus == LLSpeaker::STATUS_MUTED;
+				return speakerp->isInVoiceChannel();
 			}
 		}
 		return false;
diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp
index da3f1543dda..027f3daffbd 100644
--- a/indra/newview/llscreenchannel.cpp
+++ b/indra/newview/llscreenchannel.cpp
@@ -59,17 +59,14 @@ bool LLScreenChannel::mWasStartUpToastShown = false;
 // LLScreenChannelBase
 //////////////////////
 LLScreenChannelBase::LLScreenChannelBase(const LLUUID& id) :
-												mOverflowToastPanel(NULL) 
-												,mToastAlignment(NA_BOTTOM)
+												mToastAlignment(NA_BOTTOM)
 												,mCanStoreToasts(true)
 												,mHiddenToastsNum(0)
-												,mOverflowToastHidden(false)
 												,mHoveredToast(NULL)
 												,mControlHovering(false)
 												,mShowToasts(true)
 {	
 	mID = id;
-	mOverflowFormatString = LLTrans::getString("OverflowInfoChannelString");
 	mWorldViewRectConnection = gViewerWindow->setOnWorldViewRectUpdated(boost::bind(&LLScreenChannelBase::updatePositionAndSize, this, _1, _2));
 	setMouseOpaque( false );
 	setVisible(FALSE);
@@ -217,11 +214,6 @@ void LLScreenChannel::addToast(const LLToast::Params& p)
 
 	ToastElem new_toast_elem(p);
 
-	// reset HIDDEN flags for the Overflow Toast
-	mOverflowToastHidden = false;
-	if(mOverflowToastPanel)
-		mOverflowToastPanel->setIsHidden(false);
-	
 	new_toast_elem.toast->setOnFadeCallback(boost::bind(&LLScreenChannel::onToastFade, this, _1));
 	new_toast_elem.toast->setOnToastDestroyedCallback(boost::bind(&LLScreenChannel::onToastDestroyed, this, _1));
 	if(mControlHovering)
@@ -322,8 +314,6 @@ void LLScreenChannel::loadStoredToastsToChannel()
 
 	if(mStoredToastList.size() == 0)
 		return;
-	
-	mOverflowToastHidden = false;
 
 	for(it = mStoredToastList.begin(); it != mStoredToastList.end(); ++it)
 	{
@@ -344,8 +334,6 @@ void LLScreenChannel::loadStoredToastByNotificationIDToChannel(LLUUID id)
 	if( it == mStoredToastList.end() )
 		return;
 
-	mOverflowToastHidden = false;
-
 	LLToast* toast = (*it).toast;
 
 	if(toast->getVisible())
@@ -357,7 +345,6 @@ void LLScreenChannel::loadStoredToastByNotificationIDToChannel(LLUUID id)
 	toast->setIsHidden(false);
 	toast->resetTimer();
 	mToastList.push_back((*it));
-	mStoredToastList.erase(it);
 
 	redrawToasts();
 }
@@ -491,7 +478,7 @@ void LLScreenChannel::showToastsBottom()
 		if(floater && floater->overlapsScreenChannel())
 		{
 			LLRect world_rect = gViewerWindow->getWorldViewRectScaled();
-			if(toast_rect.mTop + getOverflowToastHeight() + toast_margin > world_rect.mTop)
+			if(toast_rect.mTop > world_rect.mTop)
 			{
 				break;
 			}
@@ -527,7 +514,7 @@ void LLScreenChannel::showToastsBottom()
 		}		
 	}
 
-	if(it != mToastList.rend() && !mOverflowToastHidden)
+	if(it != mToastList.rend())
 	{
 		mHiddenToastsNum = 0;
 		for(; it != mToastList.rend(); it++)
@@ -536,7 +523,6 @@ void LLScreenChannel::showToastsBottom()
 			(*it).toast->setVisible(FALSE);
 			mHiddenToastsNum++;
 		}
-		createOverflowToast(bottom, gSavedSettings.getS32("NotificationTipToastLifeTime"));
 	}
 	else
 	{
@@ -566,94 +552,6 @@ void LLScreenChannel::showToastsTop()
 {
 }
 
-//--------------------------------------------------------------------------
-void LLScreenChannel::createOverflowToast(S32 bottom, F32 timer)
-{
-	LLRect toast_rect;
-	LLToast::Params p;
-	p.lifetime_secs = timer;
-
-	if(!mOverflowToastPanel)
-		mOverflowToastPanel = new LLToast(p);
-
-	if(!mOverflowToastPanel)
-		return;
-
-	mOverflowToastPanel->startFading();
-	mOverflowToastPanel->setOnFadeCallback(boost::bind(&LLScreenChannel::onOverflowToastHide, this));
-
-	LLTextBox* text_box = mOverflowToastPanel->getChild<LLTextBox>("toast_text");
-	std::string	text = llformat(mOverflowFormatString.c_str(),mHiddenToastsNum);
-	if(mHiddenToastsNum == 1)
-	{
-		text += ".";
-	}
-	else
-	{
-		text += "s.";
-	}
-
-	toast_rect = mOverflowToastPanel->getRect();
-	mOverflowToastPanel->reshape(getRect().getWidth(), toast_rect.getHeight(), true);
-	toast_rect.setLeftTopAndSize(getRect().mLeft, bottom + toast_rect.getHeight()+gSavedSettings.getS32("ToastGap"), getRect().getWidth(), toast_rect.getHeight());	
-	mOverflowToastPanel->setRect(toast_rect);
-
-	// don't show overflow toast if there is not enough space for it.
-	LLDockableFloater* floater = dynamic_cast<LLDockableFloater*>(LLDockableFloater::getInstanceHandle().get());
-	if(floater && floater->overlapsScreenChannel())
-	{
-		LLRect world_rect = gViewerWindow->getWorldViewRectScaled();
-		if(toast_rect.mTop > world_rect.mTop)
-		{
-			closeOverflowToastPanel();
-			return;
-		}
-	}
-
-	text_box->setValue(text);
-	text_box->setVisible(TRUE);
-
-	mOverflowToastPanel->setVisible(TRUE);
-}
-
-//--------------------------------------------------------------------------
-void LLScreenChannel::onOverflowToastHide()
-{
-	mOverflowToastHidden = true;
-
-	// remove all hidden toasts from channel and save interactive notifications
-	for(std::vector<ToastElem>::iterator it = mToastList.begin(); it != mToastList.end();)
-	{
-		if(!(*it).toast->getVisible())
-		{
-			if((*it).toast->getCanBeStored())
-			{
-				storeToast((*it));
-			}
-			else
-			{
-				deleteToast((*it).toast);
-			}
-
-			it = mToastList.erase(it);
-		}
-		else
-		{
-			++it;
-		}
-	}
-}
-
-//--------------------------------------------------------------------------
-void LLScreenChannel::closeOverflowToastPanel()
-{
-	if(mOverflowToastPanel != NULL)
-	{
-		mOverflowToastPanel->setVisible(FALSE);
-		mOverflowToastPanel->stopFading();
-	}
-}
-
 //--------------------------------------------------------------------------
 void LLScreenChannel::createStartUpToast(S32 notif_num, F32 timer)
 {
@@ -699,24 +597,6 @@ F32 LLScreenChannel::getHeightRatio()
 	return ratio;
 }
 
-S32 LLScreenChannel::getOverflowToastHeight()
-{
-	if(mOverflowToastPanel)
-	{
-		return mOverflowToastPanel->getRect().getHeight();
-	}
-
-	static S32 height = 0;
-	if(0 == height)
-	{
-		LLToast::Params p;
-		LLToast* toast = new LLToast(p);
-		height = toast->getRect().getHeight();
-		delete toast;
-	}
-	return height;
-}
-
 //--------------------------------------------------------------------------
 void LLScreenChannel::updateStartUpString(S32 num)
 {
@@ -778,6 +658,19 @@ void LLScreenChannel::hideToastsFromScreen()
 		(*it).toast->setVisible(FALSE);
 }
 
+//--------------------------------------------------------------------------
+void LLScreenChannel::hideToast(const LLUUID& notification_id)
+{
+	std::vector<ToastElem>::iterator it = find(mToastList.begin(), mToastList.end(), notification_id);
+	if(mToastList.end() != it)
+	{
+		ToastElem te = *it;
+		te.toast->setVisible(FALSE);
+		te.toast->stopTimer();
+		mToastList.erase(it);
+	}
+}
+
 //--------------------------------------------------------------------------
 void LLScreenChannel::removeToastsFromChannel()
 {
@@ -896,3 +789,13 @@ void LLScreenChannel::updateShowToastsState()
 
 //--------------------------------------------------------------------------
 
+LLToast* LLScreenChannel::getToastByNotificationID(LLUUID id)
+{
+	std::vector<ToastElem>::iterator it = find(mStoredToastList.begin(),
+			mStoredToastList.end(), id);
+
+	if (it == mStoredToastList.end())
+		return NULL;
+
+	return it->toast;
+}
diff --git a/indra/newview/llscreenchannel.h b/indra/newview/llscreenchannel.h
index 38f27f756b6..88053d87d9d 100644
--- a/indra/newview/llscreenchannel.h
+++ b/indra/newview/llscreenchannel.h
@@ -72,8 +72,7 @@ class LLScreenChannelBase : public LLUICtrl
 	virtual void		setToastAlignment(EToastAlignment align) {mToastAlignment = align;}
 	
 	virtual void		setChannelAlignment(EChannelAlignment align) {mChannelAlignment = align;}
-	virtual void		setOverflowFormatString ( const std::string& str)  { mOverflowFormatString = str; }
-	
+
 	// kill or modify a toast by its ID
 	virtual void		killToastByNotificationID(LLUUID id) {};
 	virtual void		modifyToastNotificationByID(LLUUID id, LLSD data) {};
@@ -121,17 +120,13 @@ class LLScreenChannelBase : public LLUICtrl
 	LLToast*		mHoveredToast;
 	bool		mCanStoreToasts;
 	bool		mDisplayToastsAlways;
-	bool		mOverflowToastHidden;
 	// controls whether a channel shows toasts or not
 	bool		mShowToasts;
 	// 
 	EToastAlignment		mToastAlignment;
 	EChannelAlignment	mChannelAlignment;
 
-	// attributes for the Overflow Toast
 	S32			mHiddenToastsNum;
-	LLToast*	mOverflowToastPanel;	
-	std::string mOverflowFormatString;
 
 	// channel's ID
 	LLUUID	mID;
@@ -176,6 +171,8 @@ class LLScreenChannel : public LLScreenChannelBase
 	void		modifyToastByNotificationID(LLUUID id, LLPanel* panel);
 	// hide all toasts from screen, but not remove them from a channel
 	void		hideToastsFromScreen();
+	// hide toast by notification id
+	void		hideToast(const LLUUID& notification_id);
 	// removes all toasts from a channel
 	void		removeToastsFromChannel();
 	// show all toasts in a channel
@@ -190,8 +187,6 @@ class LLScreenChannel : public LLScreenChannelBase
 	void		removeToastsBySessionID(LLUUID id);
 	// remove all storable toasts from screen and store them
 	void		removeAndStoreAllStorableToasts();
-	// close the Overflow Toast
-	void 		closeOverflowToastPanel();
 	// close the StartUp Toast
 	void		closeStartUpToast();
 
@@ -214,6 +209,8 @@ class LLScreenChannel : public LLScreenChannelBase
 	// update number of notifications in the StartUp Toast
 	void	updateStartUpString(S32 num);
 
+	LLToast* getToastByNotificationID(LLUUID id);
+
 	// Channel's signals
 	// signal on storing of faded toasts event
 	typedef boost::function<void (LLPanel* info_panel, const LLUUID id)> store_tost_callback_t;
@@ -257,7 +254,6 @@ class LLScreenChannel : public LLScreenChannelBase
 	void	onToastHover(LLToast* toast, bool mouse_enter);
 	void	onToastFade(LLToast* toast);
 	void	onToastDestroyed(LLToast* toast);
-	void	onOverflowToastHide();
 	void	onStartUpToastHide();
 
 	//
@@ -270,9 +266,6 @@ class LLScreenChannel : public LLScreenChannelBase
 	void	showToastsCentre();
 	void	showToastsTop();
 	
-	// create the Overflow Toast
-	void	createOverflowToast(S32 bottom, F32 timer);
-
 	// create the StartUp Toast
 	void	createStartUpToast(S32 notif_num, F32 timer);
 
@@ -281,8 +274,6 @@ class LLScreenChannel : public LLScreenChannelBase
 	 */
 	static F32 getHeightRatio();
 
-	S32 getOverflowToastHeight();
-
 	// Channel's flags
 	static bool	mWasStartUpToastShown;
 
diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp
index 010dfd1b331..0dd9203c6d9 100644
--- a/indra/newview/llspeakers.cpp
+++ b/indra/newview/llspeakers.cpp
@@ -88,6 +88,11 @@ void LLSpeaker::onAvatarNameLookup(const LLUUID& id, const std::string& first, c
 	mDisplayName = first + " " + last;
 }
 
+bool LLSpeaker::isInVoiceChannel()
+{
+	return mStatus == LLSpeaker::STATUS_VOICE_ACTIVE || mStatus == LLSpeaker::STATUS_MUTED;
+}
+
 LLSpeakerUpdateModeratorEvent::LLSpeakerUpdateModeratorEvent(LLSpeaker* source)
 : LLEvent(source, "Speaker add moderator event"),
   mSpeakerID (source->mID),
diff --git a/indra/newview/llspeakers.h b/indra/newview/llspeakers.h
index 1a8c23f56a2..da8dfdf548e 100644
--- a/indra/newview/llspeakers.h
+++ b/indra/newview/llspeakers.h
@@ -67,6 +67,8 @@ class LLSpeaker : public LLRefCount, public LLOldEvents::LLObservable, public LL
 
 	void onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group);
 
+	bool isInVoiceChannel();
+
 	ESpeakerStatus	mStatus;			// current activity status in speech group
 	F32				mLastSpokeTime;		// timestamp when this speaker last spoke
 	F32				mSpeechVolume;		// current speech amplitude (timea average rms amplitude?)
diff --git a/indra/newview/llspeakingindicatormanager.cpp b/indra/newview/llspeakingindicatormanager.cpp
new file mode 100644
index 00000000000..42db6bf9c3f
--- /dev/null
+++ b/indra/newview/llspeakingindicatormanager.cpp
@@ -0,0 +1,254 @@
+/** 
+ * @file llspeakingindicatormanager.cpp
+ * @author Mike Antipov
+ * @brief Implementation of SpeackerIndicatorManager class to process registered LLSpeackerIndicator
+ * depend on avatars are in the same voice channel.
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+#include "llspeakingindicatormanager.h"
+
+
+#include "llagentdata.h"
+#include "llvoicechannel.h"
+#include "llvoiceclient.h"
+
+/**
+ * This class intended to control visibility of avatar speaking indicators depend on whether avatars
+ * are in the same voice channel.
+ *
+ * Speaking indicator should be visible for avatars in the same voice channel. See EXT-3976.
+ *
+ * It stores passed instances of LLOutputMonitorCtrl in a multimap by avatar LLUUID.
+ * It observes changing of voice channel and changing of participant list in voice channel.
+ * When voice channel or voice participant list is changed it updates visibility of an appropriate 
+ * speaking indicator.
+ *
+ * Several indicators can be registered for the same avatar.
+ */
+class SpeakingIndicatorManager : public LLSingleton<SpeakingIndicatorManager>, LLVoiceClientParticipantObserver
+{
+	LOG_CLASS(SpeakingIndicatorManager);
+public:
+
+	/**
+	 * Stores passed speaking indicator to control its visibility.
+	 *
+	 * Registered indicator is set visible if an appropriate avatar is in the same voice channel with Agent.
+	 * It ignores instances of Agent's indicator.
+	 *
+	 * @param speaker_id LLUUID of an avatar whose speaking indicator is registered.
+	 * @param speaking_indicator instance of the speaking indicator to be registered.
+	 */
+	void registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator);
+
+	/**
+	 * Removes passed speaking indicator from observing.
+	 *
+	 * @param speaker_id LLUUID of an avatar whose speaking indicator should be unregistered.
+	 * @param speaking_indicator instance of the speaking indicator to be unregistered.
+	 */
+	void unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator);
+
+private:
+	typedef std::set<LLUUID> speaker_ids_t;
+	typedef std::multimap<LLUUID, LLSpeakingIndicator*> speaking_indicators_mmap_t;
+	typedef speaking_indicators_mmap_t::value_type speaking_indicator_value_t;
+	typedef speaking_indicators_mmap_t::const_iterator indicator_const_iterator;
+	typedef std::pair<indicator_const_iterator, indicator_const_iterator> indicator_range_t;
+
+	friend class LLSingleton<SpeakingIndicatorManager>;
+	SpeakingIndicatorManager();
+	~SpeakingIndicatorManager();
+
+	/**
+	 * Callback to determine when voice channel is changed.
+	 *
+	 * It switches all registered speaking indicators off.
+	 * To reduce overheads only switched on indicators are processed.
+	 */
+	void sOnCurrentChannelChanged(const LLUUID& session_id);
+
+	/**
+	 * Callback of changing voice participant list (from LLVoiceClientParticipantObserver).
+	 *
+	 * Switches off indicators had been switched on and switches on indicators of current participants list.
+	 * There is only a few indicators in lists should be switched off/on.
+	 * So, method does not calculate difference between these list it only switches off already 
+	 * switched on indicators and switches on indicators of voice channel participants
+	 */
+	void onChange();
+
+	/**
+	 * Changes state of indicators specified by LLUUIDs
+	 *
+	 * @param speakers_uuids - avatars' LLUUIDs whose speaking indicators should be switched
+	 * @param switch_on - if TRUE specified indicator will be switched on, off otherwise.
+	 */
+	void switchSpeakerIndicators(const speaker_ids_t& speakers_uuids, BOOL switch_on);
+
+	/**
+	 * Multimap with all registered speaking indicators
+	 */
+	speaking_indicators_mmap_t mSpeakingIndicators;
+
+	/**
+	 * LUUIDs of avatar for which we have speaking indicators switched on.
+	 *
+	 * Is used to switch off all previously ON indicators when voice participant list is changed.
+	 *
+	 * @see onChange()
+	 */
+	speaker_ids_t mSwitchedIndicatorsOn;
+};
+
+//////////////////////////////////////////////////////////////////////////
+// PUBLIC SECTION
+//////////////////////////////////////////////////////////////////////////
+void SpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator)
+{
+	if (speaker_id == gAgentID) return;
+
+	LL_DEBUGS("SpeakingIndicator") << "Registering indicator: " << speaker_id << LL_ENDL;
+	speaking_indicator_value_t value_type(speaker_id, speaking_indicator);
+	mSpeakingIndicators.insert(value_type);
+
+	speaker_ids_t speakers_uuids;
+	BOOL is_in_same_voice = LLVoiceClient::getInstance()->findParticipantByID(speaker_id) != NULL;
+
+	speakers_uuids.insert(speaker_id);
+	switchSpeakerIndicators(speakers_uuids, is_in_same_voice);
+}
+
+void SpeakingIndicatorManager::unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator)
+{
+	speaking_indicators_mmap_t::iterator it;
+	it = mSpeakingIndicators.find(speaker_id);
+	for (;it != mSpeakingIndicators.end(); ++it)
+	{
+		if (it->second == speaking_indicator)
+		{
+			mSpeakingIndicators.erase(it);
+			break;
+		}
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////
+// PRIVATE SECTION
+//////////////////////////////////////////////////////////////////////////
+SpeakingIndicatorManager::SpeakingIndicatorManager()
+{
+	LLVoiceChannel::setCurrentVoiceChannelChangedCallback(boost::bind(&SpeakingIndicatorManager::sOnCurrentChannelChanged, this, _1));
+	LLVoiceClient::getInstance()->addObserver(this);
+}
+
+SpeakingIndicatorManager::~SpeakingIndicatorManager()
+{
+	// Don't use LLVoiceClient::getInstance() here without check
+	// singleton MAY have already been destroyed.
+	if(LLVoiceClient::instanceExists())
+	{
+		LLVoiceClient::getInstance()->removeObserver(this);
+	}
+}
+
+void SpeakingIndicatorManager::sOnCurrentChannelChanged(const LLUUID& /*session_id*/)
+{
+	switchSpeakerIndicators(mSwitchedIndicatorsOn, FALSE);
+	mSwitchedIndicatorsOn.clear();
+}
+
+void SpeakingIndicatorManager::onChange()
+{
+	LL_DEBUGS("SpeakingIndicator") << "Voice participant list was changed, updating indicators" << LL_ENDL;
+
+	speaker_ids_t speakers_uuids;
+	LLVoiceClient::getInstance()->getParticipantsUUIDSet(speakers_uuids);
+
+	LL_DEBUGS("SpeakingIndicator") << "Switching all OFF, count: " << mSwitchedIndicatorsOn.size() << LL_ENDL;
+	// switch all indicators off
+	switchSpeakerIndicators(mSwitchedIndicatorsOn, FALSE);
+	mSwitchedIndicatorsOn.clear();
+
+	LL_DEBUGS("SpeakingIndicator") << "Switching all ON, count: " << speakers_uuids.size() << LL_ENDL;
+	// then switch current voice participants indicators on
+	switchSpeakerIndicators(speakers_uuids, TRUE);
+}
+
+void SpeakingIndicatorManager::switchSpeakerIndicators(const speaker_ids_t& speakers_uuids, BOOL switch_on)
+{
+	speaker_ids_t::const_iterator it_uuid = speakers_uuids.begin(); 
+	for (; it_uuid != speakers_uuids.end(); ++it_uuid)
+	{
+		LL_DEBUGS("SpeakingIndicator") << "Looking for indicator: " << *it_uuid << LL_ENDL;
+		indicator_range_t it_range = mSpeakingIndicators.equal_range(*it_uuid);
+		indicator_const_iterator it_indicator = it_range.first;
+		bool was_found = false;
+		for (; it_indicator != it_range.second; ++it_indicator)
+		{
+			was_found = true;
+			LLSpeakingIndicator* indicator = (*it_indicator).second;
+			indicator->switchIndicator(switch_on);
+		}
+
+		if (was_found)
+		{
+			LL_DEBUGS("SpeakingIndicator") << mSpeakingIndicators.count(*it_uuid) << " indicators where found" << LL_ENDL;
+
+			if (switch_on)
+			{
+				// store switched on indicator to be able switch it off
+				mSwitchedIndicatorsOn.insert(*it_uuid);
+			}
+		}
+		else
+		{
+			LL_WARNS("SpeakingIndicator") << "indicator was not found among registered: " << *it_uuid << LL_ENDL;
+		}
+	}
+}
+
+/************************************************************************/
+/*         LLSpeakingIndicatorManager namespace implementation          */
+/************************************************************************/
+
+void LLSpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator)
+{
+	SpeakingIndicatorManager::instance().registerSpeakingIndicator(speaker_id, speaking_indicator);
+}
+
+void LLSpeakingIndicatorManager::unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator)
+{
+	SpeakingIndicatorManager::instance().unregisterSpeakingIndicator(speaker_id, speaking_indicator);
+}
+
+// EOF
+
diff --git a/indra/newview/llspeakingindicatormanager.h b/indra/newview/llspeakingindicatormanager.h
new file mode 100644
index 00000000000..ce0158f7d86
--- /dev/null
+++ b/indra/newview/llspeakingindicatormanager.h
@@ -0,0 +1,67 @@
+/** 
+ * @file llspeakingindicatormanager.h
+ * @author Mike Antipov
+ * @brief Interfeace of LLSpeackerIndicator class to be processed depend on avatars are in the same voice channel.
+ * Also register/unregister methods for this class are declared
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLSPEAKINGINDICATORMANAGER_H
+#define LL_LLSPEAKINGINDICATORMANAGER_H
+
+class LLSpeakingIndicator
+{
+public:
+	virtual void switchIndicator(bool switch_on) = 0;
+};
+
+// See EXT-3976.
+namespace LLSpeakingIndicatorManager
+{
+	/**
+	 * Stores passed speaking indicator to control its visibility.
+	 *
+	 * Registered indicator is set visible if an appropriate avatar is in the same voice channel with Agent.
+	 * It ignores instances of Agent's indicator.
+	 *
+	 * @param speaker_id LLUUID of an avatar whose speaker indicator is registered.
+	 * @param speaking_indicator instance of the speaker indicator to be registered.
+	 */
+	void registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator);
+
+	/**
+	 * Removes passed speaking indicator from observing.
+	 *
+	 * @param speaker_id LLUUID of an avatar whose speaker indicator should be unregistered.
+	 * @param speaking_indicator instance of the speaker indicator to be unregistered.
+	 */
+	void unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator);
+}
+
+#endif // LL_LLSPEAKINGINDICATORMANAGER_H
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 5ce3bbb9f62..b3b2b9ee5d5 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -42,7 +42,7 @@
 #include "llfloaterbuycurrency.h"
 #include "llfloaterchat.h"
 #include "llfloaterlagmeter.h"
-#include "llfloatervolumepulldown.h"
+#include "llpanelvolumepulldown.h"
 #include "llfloaterregioninfo.h"
 #include "llfloaterscriptdebug.h"
 #include "llhudicon.h"
@@ -204,6 +204,21 @@ LLStatusBar::LLStatusBar(const LLRect& rect)
 	addChild(mSGPacketLoss);
 
 	childSetActionTextbox("stat_btn", onClickStatGraph);
+
+	mPanelVolumePulldown = new LLPanelVolumePulldown();
+	addChild(mPanelVolumePulldown);
+
+	LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect();
+	LLButton* volbtn =  getChild<LLButton>( "volume_btn" );
+	volume_pulldown_rect.setLeftTopAndSize(volbtn->getRect().mLeft -
+	     (volume_pulldown_rect.getWidth() - volbtn->getRect().getWidth())/2,
+			       volbtn->calcScreenRect().mBottom,
+			       volume_pulldown_rect.getWidth(),
+			       volume_pulldown_rect.getHeight());
+
+	mPanelVolumePulldown->setShape(volume_pulldown_rect);
+	mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+	mPanelVolumePulldown->setVisible(FALSE);
 }
 
 LLStatusBar::~LLStatusBar()
@@ -501,7 +516,7 @@ static void onClickScriptDebug(void*)
 void LLStatusBar::onMouseEnterVolume(LLUICtrl* ctrl)
 {
 	// show the master volume pull-down
-	LLFloaterReg::showInstance("volume_pulldown");
+	gStatusBar->mPanelVolumePulldown->setVisible(TRUE);
 }
 
 static void onClickVolume(void* data)
diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h
index f77cc1acb86..0e98da0fe45 100644
--- a/indra/newview/llstatusbar.h
+++ b/indra/newview/llstatusbar.h
@@ -112,7 +112,7 @@ class LLStatusBar
 	S32				mSquareMetersCommitted;
 	LLFrameTimer*	mBalanceTimer;
 	LLFrameTimer*	mHealthTimer;
-		
+	LLPanelVolumePulldown* mPanelVolumePulldown;
 	static std::vector<std::string> sDays;
 	static std::vector<std::string> sMonths;
 	static const U32 MAX_DATE_STRING_LENGTH;
diff --git a/indra/newview/llsyswellitem.cpp b/indra/newview/llsyswellitem.cpp
index eef84350064..0cfcfdc6345 100644
--- a/indra/newview/llsyswellitem.cpp
+++ b/indra/newview/llsyswellitem.cpp
@@ -77,10 +77,11 @@ void LLSysWellItem::onClickCloseBtn()
 //---------------------------------------------------------------------------------
 BOOL LLSysWellItem::handleMouseDown(S32 x, S32 y, MASK mask)
 {
+	BOOL res = LLPanel::handleMouseDown(x, y, mask);
 	if(!mCloseBtn->getRect().pointInRect(x, y))
 		mOnItemClick(this);
 
-	return LLPanel::handleMouseDown(x, y, mask);
+	return res;
 }
 
 //---------------------------------------------------------------------------------
diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp
index 44cf82540a0..ba15053381c 100644
--- a/indra/newview/llsyswellwindow.cpp
+++ b/indra/newview/llsyswellwindow.cpp
@@ -700,8 +700,7 @@ void LLNotificationWellWindow::connectListUpdaterToSignal(std::string notificati
 void LLNotificationWellWindow::onItemClick(LLSysWellItem* item)
 {
 	LLUUID id = item->getID();
-	if(mChannel)
-		mChannel->loadStoredToastByNotificationIDToChannel(id);
+	LLFloaterReg::showInstance("inspect_toast", id);
 }
 
 void LLNotificationWellWindow::onItemClose(LLSysWellItem* item)
diff --git a/indra/newview/llsyswellwindow.h b/indra/newview/llsyswellwindow.h
index ded3abcbf40..0c81d1f369b 100644
--- a/indra/newview/llsyswellwindow.h
+++ b/indra/newview/llsyswellwindow.h
@@ -162,6 +162,9 @@ class LLNotificationWellWindow : public LLSysWellWindow
 	void onItemClick(LLSysWellItem* item);
 	void onItemClose(LLSysWellItem* item);
 
+	// ID of a toast loaded by user (by clicking notification well item)
+	LLUUID mLoadedToastId;
+
 };
 
 /**
diff --git a/indra/newview/llteleporthistorystorage.cpp b/indra/newview/llteleporthistorystorage.cpp
index d3bbda1c72c..c635f914239 100644
--- a/indra/newview/llteleporthistorystorage.cpp
+++ b/indra/newview/llteleporthistorystorage.cpp
@@ -246,13 +246,6 @@ void LLTeleportHistoryStorage::goToItem(S32 idx)
 		dump();
 		return;
 	}
-	
-	if (idx == (S32)mItems.size() - 1)
-	{
-		llwarns << "Will not teleport to the same location." << llendl;
-		dump();
-		return;
-	}
 
 	// Attempt to teleport to the requested item.
 	gAgent.teleportViaLocation(mItems[idx].mGlobalPos);
diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp
index 766cf83a012..d0c125eb771 100644
--- a/indra/newview/lltoastnotifypanel.cpp
+++ b/indra/newview/lltoastnotifypanel.cpp
@@ -179,7 +179,9 @@ void LLToastNotifyPanel::adjustPanelForScriptNotice(const LLNotificationFormPtr
 	//adjust layout
 	LLRect button_rect = mControlPanel->getRect();
 	reshape(getRect().getWidth(), mInfoPanel->getRect().getHeight() + button_panel_height);
+	button_rect.set(0, button_rect.mBottom + button_panel_height, button_rect.getWidth(), button_rect.mBottom);
 	mControlPanel->reshape(button_rect.getWidth(), button_panel_height);
+	mControlPanel->setRect(button_rect);
 }
 
 // static
@@ -217,7 +219,7 @@ LLButton* LLToastNotifyPanel::addButton(const std::string& name, const std::stri
 	S32 ignore_pad = 0;
 	S32 button_index = mNumButtons;
 	S32 index = button_index;
-	S32 x = (HPAD * 4) + 32;
+	S32 x = HPAD * 2; // *2 - to make a nice offset
 
 	if (mIsScriptDialog)
 	{
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 66451f47a30..b16134cc28e 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1005,7 +1005,7 @@ void render_hud_attachments()
 
 LLRect get_whole_screen_region()
 {
-	LLRect whole_screen = gViewerWindow->getWindowRectScaled();
+	LLRect whole_screen = gViewerWindow->getWorldViewRectScaled();
 	
 	// apply camera zoom transform (for high res screenshots)
 	F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor();
@@ -1013,13 +1013,13 @@ LLRect get_whole_screen_region()
 	if (zoom_factor > 1.f)
 	{
 		S32 num_horizontal_tiles = llceil(zoom_factor);
-		S32 tile_width = llround((F32)gViewerWindow->getWindowWidthScaled() / zoom_factor);
-		S32 tile_height = llround((F32)gViewerWindow->getWindowHeightScaled() / zoom_factor);
+		S32 tile_width = llround((F32)gViewerWindow->getWorldViewWidthScaled() / zoom_factor);
+		S32 tile_height = llround((F32)gViewerWindow->getWorldViewHeightScaled() / zoom_factor);
 		int tile_y = sub_region / num_horizontal_tiles;
 		int tile_x = sub_region - (tile_y * num_horizontal_tiles);
 		glh::matrix4f mat;
 		
-		whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWindowHeightScaled() - (tile_y * tile_height), tile_width, tile_height);
+		whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWorldViewHeightScaled() - (tile_y * tile_height), tile_width, tile_height);
 	}
 	return whole_screen;
 }
@@ -1039,12 +1039,12 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
 		F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect();
 		
 		glh::matrix4f mat;
-		F32 scale_x = (F32)gViewerWindow->getWindowWidthScaled() / (F32)screen_region.getWidth();
-		F32 scale_y = (F32)gViewerWindow->getWindowHeightScaled() / (F32)screen_region.getHeight();
+		F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth();
+		F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight();
 		mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f));
 		mat.set_translate(
-			glh::vec3f(clamp_rescale((F32)screen_region.getCenterX(), 0.f, (F32)gViewerWindow->getWindowWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
-					   clamp_rescale((F32)screen_region.getCenterY(), 0.f, (F32)gViewerWindow->getWindowHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
+			glh::vec3f(clamp_rescale((F32)screen_region.getCenterX(), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
+					   clamp_rescale((F32)screen_region.getCenterY(), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
 					   0.f));
 		proj *= mat;
 		
@@ -1294,8 +1294,8 @@ void render_ui_2d()
 	if (gAgent.getAvatarObject() && gAgent.mHUDCurZoom < 0.98f)
 	{
 		glPushMatrix();
-		S32 half_width = (gViewerWindow->getWindowWidthScaled() / 2);
-		S32 half_height = (gViewerWindow->getWindowHeightScaled() / 2);
+		S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2);
+		S32 half_height = (gViewerWindow->getWorldViewHeightScaled() / 2);
 		glScalef(LLUI::sGLScaleFactor.mV[0], LLUI::sGLScaleFactor.mV[1], 1.f);
 		glTranslatef((F32)half_width, (F32)half_height, 0.f);
 		F32 zoom = gAgent.mHUDCurZoom;
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 801c2d0fd24..0edd4ac0256 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -107,7 +107,6 @@
 #include "llfloateruipreview.h"
 #include "llfloaterurldisplay.h"
 #include "llfloatervoicedevicesettings.h"
-#include "llfloatervolumepulldown.h"
 #include "llfloaterwater.h"
 #include "llfloaterwhitelistentry.h"
 #include "llfloaterwindlight.h"
@@ -118,6 +117,7 @@
 #include "llinspectgroup.h"
 #include "llinspectobject.h"
 #include "llinspectremoteobject.h"
+#include "llinspecttoast.h"
 #include "llmediaremotectrl.h"
 #include "llmoveview.h"
 #include "llnearbychat.h"
@@ -189,6 +189,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLInspectGroupUtil::registerFloater();
 	LLInspectObjectUtil::registerFloater();
 	LLInspectRemoteObjectUtil::registerFloater();
+	LLNotificationsUI::registerFloater();
 	
 	LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>);
 	LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>);
@@ -260,7 +261,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
 	LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
 	LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
-	LLFloaterReg::add("volume_pulldown", "floater_volume_pulldown.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVolumePulldown>);
+
 	LLFloaterReg::add("voice_controls", "floater_voice_controls.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLCallFloater>);
 	
 	LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>);	
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 42c45589c08..43c75748300 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -904,7 +904,19 @@ void open_inventory_offer(const std::vector<LLUUID>& items, const std::string& f
 						LLPanelPlaces *places_panel = dynamic_cast<LLPanelPlaces*>(LLSideTray::getInstance()->showPanel("panel_places", LLSD()));
 						if (places_panel)
 						{
-							places_panel->setItem(item);
+							// we are creating a landmark
+							if("create_landmark" == places_panel->getPlaceInfoType() && !places_panel->getItem())
+							{
+								places_panel->setItem(item);
+							}
+							// we are opening a group notice attachment
+							else
+							{
+								LLSD args;
+								args["type"] = "landmark";
+								args["id"] = item_id;
+								LLSideTray::getInstance()->showPanel("panel_places", args);
+							}
 						}
 					}
 				}
@@ -1098,28 +1110,6 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 		gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,_4,this));
 	}
 
-	// *NOTE dzaporozhan
-	// Restored from viewer-1-23 to fix EXT-3520
-	// Saves Group Notice Attachments to inventory.
-	LLMessageSystem* msg = gMessageSystem;
-	msg->newMessageFast(_PREHASH_ImprovedInstantMessage);
-	msg->nextBlockFast(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	msg->nextBlockFast(_PREHASH_MessageBlock);
-	msg->addBOOLFast(_PREHASH_FromGroup, FALSE);
-	msg->addUUIDFast(_PREHASH_ToAgentID, mFromID);
-	msg->addU8Fast(_PREHASH_Offline, IM_ONLINE);
-	msg->addUUIDFast(_PREHASH_ID, mTransactionID);
-	msg->addU32Fast(_PREHASH_Timestamp, NO_TIMESTAMP); // no timestamp necessary
-	std::string name;
-	LLAgentUI::buildFullname(name);
-	msg->addStringFast(_PREHASH_FromAgentName, name);
-	msg->addStringFast(_PREHASH_Message, ""); 
-	msg->addU32Fast(_PREHASH_ParentEstateID, 0);
-	msg->addUUIDFast(_PREHASH_RegionID, LLUUID::null);
-	msg->addVector3Fast(_PREHASH_Position, gAgent.getPositionAgent());
-
 	std::string from_string; // Used in the pop-up.
 	std::string chatHistory_string;  // Used in chat history.
 	
@@ -1155,8 +1145,10 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 				}
 			}
 			break;
-		case IM_TASK_INVENTORY_OFFERED:
 		case IM_GROUP_NOTICE:
+			send_auto_receive_response();
+			break;
+		case IM_TASK_INVENTORY_OFFERED:
 		case IM_GROUP_NOTICE_REQUESTED:
 			// This is an offer from a task or group.
 			// We don't use a new instance of an opener
@@ -1171,10 +1163,6 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 		// end switch (mIM)
 			
 	case IOR_ACCEPT:
-		msg->addU8Fast(_PREHASH_Dialog, (U8)(mIM + 1));
-		msg->addBinaryDataFast(_PREHASH_BinaryBucket, &(mFolderID.mData), sizeof(mFolderID.mData));
-		msg->sendReliable(mHost);
-
 		//don't spam them if they are getting flooded
 		if (check_offer_throttle(mFromName, true))
 		{
@@ -1197,7 +1185,10 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 			{
 				chat.mMuted = TRUE;
 			}
-			LLFloaterChat::addChatHistory(chat);
+
+			// *NOTE dzaporozhan
+			// Disabled logging to old chat floater to fix crash in group notices - EXT-4149
+			// LLFloaterChat::addChatHistory(chat);
 			
 			LLInventoryFetchComboObserver::folder_ref_t folders;
 			LLInventoryFetchComboObserver::item_ref_t items;
@@ -1768,10 +1759,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 		}
 		else if (from_id.isNull())
 		{
-			// Messages from "Second Life" ID don't go to IM history
-			// messages which should be routed to IM window come from a user ID with name=SYSTEM_NAME
-			chat.mText = name + ": " + message;
-			LLFloaterChat::addChat(chat, FALSE, FALSE);
+			LLSD args;
+			args["MESSAGE"] = message;
+			LLNotificationsUtil::add("SystemMessage", args);
 		}
 		else if (to_id.isNull())
 		{
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 9285ab94dcb..33bfee798a1 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -604,7 +604,6 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 {
 	const char* buttonname = "";
 	const char* buttonstatestr = "";
-	BOOL handled = FALSE;	
 	S32 x = pos.mX;
 	S32 y = pos.mY;
 	x = llround((F32)x / mDisplayScale.mV[VX]);
@@ -699,7 +698,10 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 		}
 		else
 		{
-			handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask);
+			if (top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask))
+			{
+				return TRUE;
+			}
 		}
 	}
 
@@ -717,34 +719,12 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 		llinfos << buttonname << " Mouse " << buttonstatestr << " not handled by view" << llendl;
 	}
 
-	if (down)
+	// Do not allow tool manager to handle mouseclicks if we have disconnected	
+	if(!gDisconnected && LLToolMgr::getInstance()->getCurrentTool()->handleAnyMouseClick( x, y, mask, clicktype, down ) )
 	{
-		if (gDisconnected)
-		{
-			return FALSE;
-		}
-	
-		if(LLToolMgr::getInstance()->getCurrentTool()->handleAnyMouseClick( x, y, mask, clicktype, down ) )
-		{
-			return TRUE;
-		}
+		return TRUE;
 	}
-	else
-	{
-		if( !handled )
-		{
-			handled = mRootView->handleAnyMouseClick(x, y, mask, clicktype, down);
-		}
 	
-		if( !handled )
-		{
-			LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
-			if (tool)
-			{
-				handled = tool->handleAnyMouseClick(x, y, mask, clicktype, down);
-			}
-		}
-	}
 
 	// If we got this far on a down-click, it wasn't handled.
 	// Up-clicks, though, are always handled as far as the OS is concerned.
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 423c46e14c7..42b8a1c2b6b 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -5004,6 +5004,17 @@ LLVoiceClient::participantMap *LLVoiceClient::getParticipantList(void)
 	return result;
 }
 
+void LLVoiceClient::getParticipantsUUIDSet(std::set<LLUUID>& participant_uuids)
+{
+	if (NULL == mAudioSession) return;
+
+	participantUUIDMap::const_iterator it = mAudioSession->mParticipantsByUUID.begin(),
+		it_end = mAudioSession->mParticipantsByUUID.end();
+	for (; it != it_end; ++it)
+	{
+		participant_uuids.insert((*(*it).first));
+	}
+}
 
 LLVoiceClient::participantState *LLVoiceClient::sessionState::findParticipant(const std::string &uri)
 {
diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h
index 724179847dc..6231c6ba29f 100644
--- a/indra/newview/llvoiceclient.h
+++ b/indra/newview/llvoiceclient.h
@@ -354,6 +354,7 @@ static	void updatePosition(void);
 
 		participantState *findParticipantByID(const LLUUID& id);
 		participantMap *getParticipantList(void);
+		void getParticipantsUUIDSet(std::set<LLUUID>& participant_uuids);
 		
 		typedef std::map<const std::string*, sessionState*, stringMapComparitor> sessionMap;
 		typedef std::set<sessionState*> sessionSet;
diff --git a/indra/newview/skins/default/textures/bottomtray/Unread_Chiclet.png b/indra/newview/skins/default/textures/bottomtray/Unread_Chiclet.png
index 447e0af0be61761287ef55d611d7e96428174a53..6343ddf035a738440af60dbc13317f33587e39db 100644
GIT binary patch
delta 278
zcmV+x0qOqw0muT77YYst1^@s6A4o0Hks&C5>PbXFRCwBA{Qv(y137>ZS>xPC&)9&J
zJrFAbu`v+;0^+kkyf0Z!>Jf&<8TTJD1KF8CTmi(=I4s!##043O@;BicC*8ii6v&Pu
z!i8Ue*e6d_^&n&Cl}jKEOG)tFYamu)`SI(AABo{23dDXa-+z7MBqLBIfEvGV1(`s9
zqQ>Lkz)9b;ZVQm(O{AvjGhKqRSU@bGtr0+~1&H(UX!r}#1d0-j1Q5Dmt`?Arg<?>A
zf+GDg6wg{6kbEC&%7FpDRa1`vDIp*>-xQYp5u5ca=mH+g`aynu2gLq6q6$9}l~zds
c009O7nMqhi-AyM#00000NkvXXu0mh|f^X<`2LJ#7

delta 199
zcmV;&067210{Q`v7YYjq1^@s6Pldc<ks&C5oJmAMRCwBA{Qv(y0}43EXagiAfH)Y4
zd5~mM8SMYRfN>b%8V@oW0Lg5qCS2eM5HAE70MU4m(F3Z981My%3mN|(06S+knzIOj
zBTP^Yq-X*G6(*?FUr5w=hY9G>FJKQ74?rQi5It0z3Hc2csw~LXqnXNp7BwjG$O5%8
z4HP)#NQ!m>6|KQ%H4D^<<<OA51J$&HkVgRm3;>Z+G{?neYefJ6002ovPDHLkV1lF7
BN>u;=

diff --git a/indra/newview/skins/default/textures/bottomtray/WellButton_Lit.png b/indra/newview/skins/default/textures/bottomtray/WellButton_Lit.png
index dd9133bcc463fe3303ae364bdd381ae3132f66a0..661d1c5611030be801d620730b1979c79e474a09 100644
GIT binary patch
delta 463
zcmV;=0Wkil1nL7JiBL{Q4GJ0x0000DNk~Le0000W0000N2nGNE0BQwI;gKOHe*uh1
zL_t(|+QgMHOT$nQfbZqKBt<2Hx(MQ+TS0NDi&ZFvy0pKhn{?0Af8r!KI0;&WIyksF
zxM(LqA=275&AaElnA+-|>yd-^rtj{%dqfyxKnM{4K#g*n(w_5-gz}m4lGvY$;2WjN
z@mZyQy1%-<wgL<>91P;C^NSL(e?ujutd{Gw1Mpq%?c+U0gC<WnL80LJ&Ji&mZtkjz
zH0*#9>T5LAb{rf*EOcFE*}Do6ecQA~%|o|AB!yBC+g0{%wc8IEV>;@z0Ikum8c3OP
zRsgjRhF3t!oEe~DXwtxHKuY*y02gb(&<-H)4rCpt1q}Lq7{y~&1BvI)e+)QEqC~~I
z1H_!)0s9Dem%uWA3&<(}<}I8v@N?xg0RIfYLJcfn1XG@J9A|8R*?-0(_QVN-pcfBE
zF<k`P6C{>p68l9p8jVi3bH7(C9~S+B=d%2YH71X@-6zWyGz-~ox3|JDJc*)cGf9%A
zoV(Z5`D?4yx^6a`J&`SgB}2JP>1OA=$3LO$TN&R13;>Yp<c70)<_Q1*002ovPDHLk
FV1mZ)&r$#Y

delta 526
zcmaFGyplz+Gr-TCmrII^fq{Y7)59eQNGk%dI0rM3+$4GJ?L<ZOdWJs%J|V7c;c_J|
zg41#>JE9bTKvYyzM@L6cP*6@zPD)BjNJvOoS-H@WTSq~x%w4F)Uq(qusl-)KTU)y^
zLao9}q&-TxF-SVgUMSm1tUf@hE>N~TLcYpNxF=CZQBko!MYl6nqtZvpL`$hJS+5~T
zwmU(~z`#IOR<^%BS-&e@vol7uEkdz1Lb)+mF3(X&US7U6!7$T7*ic<wPfu@po^^$%
za95maXN+=Nlxlsfc}u8VwYP|{uy9wbnzXcZU65R<n^0@Gd`FT=wVzC(16R2#Ph+5X
zgTHuFuw<=|NQnzii8FUwxNMmVceR&LONg|gp<#hNXOUw)mw<r4m$Wacz#w5Q3Gxg6
z4+IRqxA6so!pPIbF{I*F&!wZHOpXE!7unK8qwm}Wg2aT+=UJ^9ULLo<zOiBDq&zN-
zNv9-M-1NM!b?MzU36I-XPN*4u$t(*vWhfB+!f3`$>xEfG2EzJI4Bdxj1{_{gq>{72
zV?IZ)&N1;6CxPx?lLZbYm8$;Om?6Vqtn-QANv8Wnufc&se-(H9(=Mw%^ebFrruo6e
z#S;$k6+U>8A>(y!g6oQxQ&JO7K8>l^bnS6j!kG_ZJ3DeVtY=_mF#EK5GEaKwe4z6g
NJYD@<);T3K0RSRgwgCVD

diff --git a/indra/newview/skins/default/textures/bottomtray/WellButton_Lit_Selected.png b/indra/newview/skins/default/textures/bottomtray/WellButton_Lit_Selected.png
index 0080e71f4191729d2902dc07d49329c185833100..f927fd3989b32ab663cdc45f238f1158ee2b0638 100644
GIT binary patch
delta 273
zcmV+s0q*{<1+D@iiBL{Q4GJ0x0000DNk~Le0000U0000K2m$~A02Rp^laV1Oe*n-)
zL_t(|+O(9h3c^4TL@$?(V4;GAjg=rml%W6r6N05b5Rh1T9>ipK+)E+Y?+we9k70K9
z=y+~+r+Tqk3d9*HhWGt?qy423;PLDrX6Ta2ZG9jV2qD11*+~Yesu_uZ?fm`(K+z&>
zk7j1lhz%F`=NgHf0WCZQlEJk?XKB=^neDSKHEZn$!`?LueUf@}bm2hyq{+Z0y>cD<
zK&J8~W$JY<w0GG=n8MC*jUZOC%dkc*Umv3{yzMvQy_aF6SKG}uYpN>K9ZGDUUjYUH
XIkBEHgwRw600000NkvXXu0mjf8g_O?

delta 661
zcmV;G0&4xP0<Q%jiBL{Q4GJ0x0000DNk~Le0000X0000N2m=5B0J0g@?U5lTe*sWX
zOjJc}K^9go3m_mM2?+@-EG$(m3rHgZIwTY~A`=i05FH&IQYiybC<7uQA{-nX6%`dm
zAp%4o0wW_M3JMBcGYoJ;7FH_+Y(N%QFbi5U5LYb(X+IW6FC9}g86F-UWH}F8G7M8N
z6HF)yVKoaQ92Z$K4?-#$L@**<e>N0NHYILE8)!TdSu+x6JQOW0Em|%HVmTCNJP}GM
z3r998NH8BZArfam8#yBsRW1xS9SIl_3}iSC6ciLf9|A-z98@zFVmAzFJ{DOq3{E^Q
zTr>=9K^Rm%ElDvTQ7Q>YG9qn48CEY19~l!WDk?!A1Zh4LKQbmuG$BGOe;QFM3@jN7
zD=RBhDg+M?4^%7)8xsv?I}-~F3k(blU^^KW78WotFmgo}RX{CYI2C6(3~oRZX*>^a
zK@?~^4QxIUTQ3DMF)>&y1X?ZxUNHq-Fa-z*2+JL_;{X5v19VbOQ~&<}*UAk+0002y
zNkl<Zc-mrM;^K_X#{rnbf4P{L82D6-o!t^~08Jk`CI-%cKzofO93WPfUx<NOUC}_C
z0S6E_6J}w^_tfzhO~3&}weqtV^4%r1({KVWkO~u3!xWsr6{JGOTRsCPkOrx+v#?IZ
z2^>Kxf+8H!aRObC3N;VqWSk%hq{5s{Di0@c0jXeT%g)6KM2J)&YaoW(76p(B4uP;t
zoWKdJLXbNLCy*dY1+%FwPc}}#D4fN>8REwyhD(9I5q}l~pOvK&D=Q;bz#1Is%fi6K
v6c>XtCEMs_2?15`hQ?>%0xY~t009O7&a(liW03Bh00000NkvXXu0mjfIwiIW

diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index db60b90a930..cfa7479fa98 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -224,7 +224,7 @@ with the same filename but different name
            scale.left="4" scale.top="28" scale.right="60" scale.bottom="4" />
   <texture name="Inspector_Hover" file_name="windows/Inspector_Hover.png" preload="false" />
   <texture name="Inspector_I" file_name="windows/Inspector_I.png" preload="false" />
-  
+
   <texture name="Inv_Acessories" file_name="icons/Inv_Accessories.png" preload="false" />
   <texture name="Inv_Alpha" file_name="icons/Inv_Alpha.png" preload="false" />
   <texture name="Inv_Animation" file_name="icons/Inv_Animation.png" preload="false" />
@@ -650,6 +650,12 @@ with the same filename but different name
   <texture name="PowerOff_Over" file_name="icons/PowerOff_Over.png" preload="false" />
   <texture name="PowerOff_Press" file_name="icons/PowerOff_Press.png" preload="false" />
 
+  <texture name="pixiesmall.j2c" use_mips="true" />
+  <texture name="script_error.j2c" use_mips="true" />
+  <texture name="silhouette.j2c" use_mips="true" />
+  <texture name="foot_shadow.j2c" use_mips="true" />
+  <texture name="cloud-particle.j2c" use_mips="true" />
+
   <!--WARNING OLD ART BELOW *do not use*-->
   <texture name="icn_chatbar.tga" />
   <texture name="icn_media_web.tga" preload="true" />
@@ -678,8 +684,6 @@ with the same filename but different name
 
   <texture name="toggle_button_off" file_name="toggle_button_off.png" preload="true" />
   <texture name="toggle_button_selected" file_name="toggle_button_selected.png" preload="true" />
-
-  <texture name="sm_rounded_corners_simple.tga" scale.left="4" scale.top="4" scale.bottom="4" scale.right="4" />
   <texture name="color_swatch_alpha.tga" preload="true" />
 
   <texture name="button_anim_pause.tga" />
@@ -698,7 +702,6 @@ with the same filename but different name
   <texture name="icon_event_mature.tga" />
   <texture name="icon_for_sale.tga" />
   <texture name="icon_place_for_sale.tga" />
-  <texture name="icon_popular.tga" />
   <texture name="icon_top_pick.tga" />
 
   <texture name="inv_folder_mesh.tga"/>
@@ -719,27 +722,10 @@ with the same filename but different name
   <texture name="map_telehub.tga" />
   <texture name="map_track_16.tga" />
 
-  <texture name="media_icon.tga" file_name="icn_label_media.tga" />
-  <texture name="music_icon.tga" file_name="icn_label_music.tga" />
-
-  <texture name="notify_tip_icon.tga" />
   <texture name="notify_caution_icon.tga" />
   <texture name="notify_next.png" preload="true" />
   <texture name="notify_box_icon.tga" />
 
-  <texture name="pixiesmall.j2c" use_mips="true" />
-  <texture name="script_error.j2c" use_mips="true" />
-  <texture name="silhouette.j2c" use_mips="true" />
-  <texture name="foot_shadow.j2c" use_mips="true" />
-  <texture name="cloud-particle.j2c" use_mips="true" />
-
-  <texture name="status_no_build.tga" />
-  <texture name="status_voice.tga" />
-  <texture name="status_no_fly.tga" />
-  <texture name="status_health.tga" />
-  <texture name="status_no_push.tga" />
-  <texture name="status_no_scripts.tga" />
-
   <texture name="icn_active-speakers-dot-lvl0.tga" />
   <texture name="icn_active-speakers-dot-lvl1.tga" />
   <texture name="icn_active-speakers-dot-lvl2.tga" />
diff --git a/indra/newview/skins/default/xui/de/floater_buy_currency.xml b/indra/newview/skins/default/xui/de/floater_buy_currency.xml
index 3c336cc40b0..c320e796c20 100644
--- a/indra/newview/skins/default/xui/de/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/de/floater_buy_currency.xml
@@ -46,7 +46,7 @@
 		[AMT] L$
 	</text>
 	<text name="currency_links">
-		[http://www.secondlife.com/ payment method] | [http://www.secondlife.com/ currency] | [http://www.secondlife.com exchange rate]
+		[http://www.secondlife.com/my/account/payment_method_management.php?lang=de-DE payment method] | [http://www.secondlife.com/my/account/currency.php?lang=de-DE currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=de-DE exchange rate]
 	</text>
 	<text name="exchange_rate_note">
 		Geben Sie den Betrag erneut ein, um die aktuellste Umtauschrate anzuzeigen.
diff --git a/indra/newview/skins/default/xui/de/floater_help_browser.xml b/indra/newview/skins/default/xui/de/floater_help_browser.xml
index 53bddcced13..2344d6f412a 100644
--- a/indra/newview/skins/default/xui/de/floater_help_browser.xml
+++ b/indra/newview/skins/default/xui/de/floater_help_browser.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <floater name="floater_help_browser" title="HILFE-BROWSER">
 	<floater.string name="home_page_url">
-		http://www.secondlife.com
+		http://de.secondlife.com
 	</floater.string>
 	<floater.string name="support_page_url">
-		http://support.secondlife.com
+		http://de.secondlife.com/support
 	</floater.string>
 	<layout_stack name="stack1">
 		<layout_panel name="external_controls">
diff --git a/indra/newview/skins/default/xui/de/strings.xml b/indra/newview/skins/default/xui/de/strings.xml
index 809ac33e154..e93a38f187a 100644
--- a/indra/newview/skins/default/xui/de/strings.xml
+++ b/indra/newview/skins/default/xui/de/strings.xml
@@ -166,7 +166,7 @@
 	<string name="TooltipSLAPP">
 		Anklicken, um Befehl secondlife:// auszuführen
 	</string>
-	<string name="CurrentURL" value="CurrentURL: [CurrentURL]"/>
+	<string name="CurrentURL" value=" CurrentURL: [CurrentURL]"/>
 	<string name="SLurlLabelTeleport">
 		Teleportieren nach
 	</string>
@@ -821,46 +821,46 @@
 	<string name="InventoryNoTexture">
 		Sie haben keine Kopie dieser Textur in Ihrem Inventar.
 	</string>
-	<string name="no_transfer" value="(kein Transferieren)"/>
-	<string name="no_modify" value="(kein Bearbeiten)"/>
-	<string name="no_copy" value="(kein Kopieren)"/>
-	<string name="worn" value="(getragen)"/>
-	<string name="link" value="(Link)"/>
-	<string name="broken_link" value="(unvollständiger_Link)"/>
+	<string name="no_transfer" value=" (kein Transferieren)"/>
+	<string name="no_modify" value=" (kein Bearbeiten)"/>
+	<string name="no_copy" value=" (kein Kopieren)"/>
+	<string name="worn" value=" (getragen)"/>
+	<string name="link" value=" (Link)"/>
+	<string name="broken_link" value=" (unvollständiger_Link)"/>
 	<string name="LoadingContents">
 		Inhalte werden geladen...
 	</string>
 	<string name="NoContents">
 		Keine Inhalte
 	</string>
-	<string name="WornOnAttachmentPoint" value="(getragen am [ATTACHMENT_POINT])"/>
+	<string name="WornOnAttachmentPoint" value=" (getragen am [ATTACHMENT_POINT])"/>
 	<string name="PermYes">
 		Ja
 	</string>
 	<string name="PermNo">
 		Nein
 	</string>
-	<string name="Chat" value="Chat:"/>
-	<string name="Sound" value="Sound:"/>
-	<string name="Wait" value="--- Warten:"/>
-	<string name="AnimFlagStop" value="Animation stoppen:"/>
-	<string name="AnimFlagStart" value="Animation starten:"/>
-	<string name="Wave" value="Winken"/>
-	<string name="HelloAvatar" value="Hallo Avatar!"/>
-	<string name="ViewAllGestures" value="Alle anzeigen &gt;&gt;"/>
-	<string name="Animations" value="Animationen,"/>
-	<string name="Calling Cards" value="Visitenkarten,"/>
-	<string name="Clothing" value="Kleidung,"/>
-	<string name="Gestures" value="Gesten,"/>
-	<string name="Landmarks" value="Landmarken,"/>
-	<string name="Notecards" value="Notizkarten,"/>
-	<string name="Objects" value="Objekte,"/>
-	<string name="Scripts" value="Skripts,"/>
-	<string name="Sounds" value="Sounds,"/>
-	<string name="Textures" value="Texturen,"/>
-	<string name="Snapshots" value="Fotos,"/>
-	<string name="No Filters" value="Nein"/>
-	<string name="Since Logoff" value="- Seit Abmeldung"/>
+	<string name="Chat" value=" Chat:"/>
+	<string name="Sound" value=" Sound:"/>
+	<string name="Wait" value=" --- Warten:"/>
+	<string name="AnimFlagStop" value=" Animation stoppen:"/>
+	<string name="AnimFlagStart" value=" Animation starten:"/>
+	<string name="Wave" value=" Winken"/>
+	<string name="HelloAvatar" value=" Hallo Avatar!"/>
+	<string name="ViewAllGestures" value="  Alle anzeigen &gt;&gt;"/>
+	<string name="Animations" value=" Animationen,"/>
+	<string name="Calling Cards" value=" Visitenkarten,"/>
+	<string name="Clothing" value=" Kleidung,"/>
+	<string name="Gestures" value=" Gesten,"/>
+	<string name="Landmarks" value=" Landmarken,"/>
+	<string name="Notecards" value=" Notizkarten,"/>
+	<string name="Objects" value=" Objekte,"/>
+	<string name="Scripts" value=" Skripts,"/>
+	<string name="Sounds" value=" Sounds,"/>
+	<string name="Textures" value=" Texturen,"/>
+	<string name="Snapshots" value=" Fotos,"/>
+	<string name="No Filters" value="Nein "/>
+	<string name="Since Logoff" value=" - Seit Abmeldung"/>
 	<string name="InvFolder My Inventory">
 		Mein Inventar
 	</string>
@@ -1239,13 +1239,13 @@
 	<string name="GroupsNone">
 		keine
 	</string>
-	<string name="Group" value="(Gruppe)"/>
+	<string name="Group" value=" (Gruppe)"/>
 	<string name="Unknown">
 		(unbekannt)
 	</string>
-	<string name="SummaryForTheWeek" value="Zusammenfassung für diese Woche, beginnend am"/>
-	<string name="NextStipendDay" value="Der nächste Stipendium-Tag ist"/>
-	<string name="GroupIndividualShare" value="Gruppenanteil	Einzelanteil"/>
+	<string name="SummaryForTheWeek" value="Zusammenfassung für diese Woche, beginnend am "/>
+	<string name="NextStipendDay" value="Der nächste Stipendium-Tag ist "/>
+	<string name="GroupIndividualShare" value="                      Gruppenanteil       Einzelanteil"/>
 	<string name="Balance">
 		Kontostand
 	</string>
@@ -1324,8 +1324,8 @@
 	<string name="covenant_last_modified">
 		Zuletzt geändert:
 	</string>
-	<string name="none_text" value="(keiner)"/>
-	<string name="never_text" value="(nie)"/>
+	<string name="none_text" value=" (keiner)"/>
+	<string name="never_text" value=" (nie)"/>
 	<string name="GroupOwned">
 		In Gruppenbesitz
 	</string>
@@ -1616,7 +1616,7 @@ Falls der Fehler dann weiterhin auftritt, müssen Sie [APP_NAME] von Ihrem Syste
 		Unbehebbarer Fehler
 	</string>
 	<string name="MBRequiresAltiVec">
-		[APP_NAME] erfordert einen Prozessor mit AltiVec (G4 oder später).
+		 [APP_NAME] erfordert einen Prozessor mit AltiVec (G4 oder später).
 	</string>
 	<string name="MBAlreadyRunning">
 		[APP_NAME] läuft bereits.
diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml
index 82ed1a7d7fb..9806f45bc4f 100644
--- a/indra/newview/skins/default/xui/en/floater_about.xml
+++ b/indra/newview/skins/default/xui/en/floater_about.xml
@@ -112,7 +112,7 @@ Packets Lost: [PACKETS_LOST,number,0]/[PACKETS_IN,number,0] ([PACKETS_PCT,number
        word_wrap="true">
 Second Life is brought to you by Philip, Tessa, Andrew, Cory, James, Ben, Char, Charlie, Colin, Dan, Daniel, Doug, Eric, Hamlet, Haney, Eve, Hunter, Ian, Jeff, Jennifer, Jim, John, Lee, Mark, Peter, Phoenix, Richard, Robin, Xenon, Steve, Tanya, Eddie, Avi, Frank, Bruce, Aaron, Alice, Bob, Debra, Eileen, Helen, Janet, Louie, Leviathania, Stefan, Ray, Kevin, Tom, Mikeb, MikeT, Burgess, Elena, Tracy, Bill, Todd, Ryan, Zach, Sarah, Nova, Tim, Stephanie, Michael, Evan, Nicolas, Catherine, Rachelle, Dave, Holly, Bub, Kelly, Magellan, Ramzi, Don, Sabin, Jill, Rheya, Jeska, Torley, Kona, Callum, Charity, Ventrella, Jack, Vektor, Iris, Chris, Nicole, Mick, Reuben, Blue, Babbage, Yedwab, Deana, Lauren, Brent, Pathfinder, Chadrick, Altruima, Jesse, Teeny, Monroe, Icculus, David, Tess, Lizzie, Patsy, Isaac, Lawrence, Cyn, Bo, Gia, Annette, Marius, Tbone, Jonathan, Karen, Ginsu, Satoko, Yuko, Makiko, Thomas, Harry, Seth, Alexei, Brian, Guy, Runitai, Ethan, Data, Cornelius, Kenny, Swiss, Zero, Natria, Wendy, Stephen, Teeple, Thumper, Lucy, Dee, Mia, Liana, Warren, Branka, Aura, beez, Milo, Hermia, Red, Thrax, Joe, Sally, Magenta, Mogura, Paul, Jose, Rejean, Henrik, Lexie, Amber, Logan, Xan, Nora, Morpheus, Donovan, Leyla, MichaelFrancis, Beast, Cube, Bucky, Joshua, Stryfe, Harmony, Teresa, Claudia, Walker, Glenn, Fritz, Fordak, June, Cleopetra, Jean, Ivy, Betsy, Roosevelt, Spike, Ken, Which, Tofu, Chiyo, Rob, Zee, dustin, George, Del, Matthew, Cat, Jacqui, Lightfoot, Adrian, Viola, Alfred, Noel, Irfan, Sunil, Yool, Rika, Jane, Xtreme, Frontier, a2, Neo, Siobhan, Yoz, Justin, Elle, Qarl, Benjamin, Isabel, Gulliver, Everett, Christopher, Izzy, Stephany, Garry, Sejong, Sean, Tobin, Iridium, Meta, Anthony, Jeremy, JP, Jake, Maurice, Madhavi, Leopard, Kyle, Joon, Kari, Bert, Belinda, Jon, Kristi, Bridie, Pramod, KJ, Socrates, Maria, Ivan, Aric, Yamasaki, Adreanne, Jay, MitchK, Ceren, Coco, Durl, Jenny, Periapse, Kartic, Storrs, Lotte, Sandy, Rohn, Colossus, Zen, BigPapi, Brad, Pastrami, Kurz, Mani, Neuro, Jaime, MJ, Rowan, Sgt, Elvis, Gecko, Samuel, Sardonyx, Leo, Bryan, Niko, Soft, Poppy, Rachel, Aki, Angelo, Banzai, Alexa, Sue, CeeLo, Bender, CG, Gillian, Pelle, Nick, Echo, Zara, Christine, Shamiran, Emma, Blake, Keiko, Plexus, Joppa, Sidewinder, Erica, Ashlei, Twilight, Kristen, Brett, Q, Enus, Simon, Bevis, Kraft, Kip, Chandler, Ron, LauraP, Ram, KyleJM, Scouse, Prospero, Melissa, Marty, Nat, Hamilton, Kend, Lordan, Jimmy, Kosmo, Seraph, Green, Ekim, Wiggo, JT, Rome, Doris, Miz, Benoc, Whump, Trinity, Patch, Kate, TJ, Bao, Joohwan, Christy, Sofia, Matias, Cogsworth, Johan, Oreh, Cheah, Angela, Brandy, Mango, Lan, Aleks, Gloria, Heidy, Mitchell, Space, Colton, Bambers, Einstein, Maggie, Malbers, Rose, Winnie, Stella, Milton, Rothman, Niall, Marin, Allison, Katie, Dawn, Katt, Dusty, Kalpana, Judy, Andrea, Ambroff, Infinity, Gail, Rico, Raymond, Yi, William, Christa, M, Teagan, Scout, Molly, Dante, Corr, Dynamike, Usi, Kaylee, Vidtuts, Lil, Danica, Sascha, Kelv, Jacob, Nya, Rodney, Brandon, Elsie, Blondin, Grant, Katrin, Nyx, Gabriel, Locklainn, Claire, Devin, Minerva, Monty, Austin, Bradford, Si, Keira, H, Caitlin, Dita, Makai, Jenn, Ann, Meredith, Clare, Joy, Praveen, Cody, Edmund, Ruthe, Sirena, Gayathri, Spider, FJ, Davidoff, Tian, Jennie, Louise, Oskar, Landon, Noelle, Jarv, Ingrid, Al, Sommer, Doc, Aria, Huin, Gray, Lili, Vir, DJ, Yang, T, Simone, Maestro, Scott, Charlene, Quixote, Amanda, Susan, Zed, Anne, Enkidu, Esbee, Joroan, Katelin, Roxie, Tay, Scarlet, Kevin, Johnny, Wolfgang, Andren, Bob, Howard, Merov, Rand, Ray, Michon, Newell, Galen, Dessie, Les and many others.
 
-Thank you to the following residents for helping to ensure that this is the best version yet: (in progress)
+Thank you to the following Residents for helping to ensure that this is the best version yet: (in progress)
 
 
 
diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml
index 33fdd923ad2..900f4c5956a 100644
--- a/indra/newview/skins/default/xui/en/floater_about_land.xml
+++ b/indra/newview/skins/default/xui/en/floater_about_land.xml
@@ -1036,7 +1036,7 @@ Leyla Linden               </text>
              name="Autoreturn"
              top="164"
              width="294">
-                Autoreturn other residents&apos; objects (minutes, 0 for off):
+                Autoreturn other Residents&apos; objects (minutes, 0 for off):
             </text>
             <line_editor
              border_style="line"
@@ -1175,7 +1175,7 @@ Only large parcels can be listed in search.
              name="allow_label"
              top="10"
              width="278">
-                Allow other residents to:
+                Allow other Residents to:
             </text>
             <check_box
              height="16"
@@ -1917,7 +1917,7 @@ Only large parcels can be listed in search.
              layout="topleft"
              left_delta="0"
              name="limit_payment"
-             tool_tip="Ban unidentified residents."
+             tool_tip="Ban unidentified Residents."
              top_pad="4"
              width="278" />
             <check_box
@@ -1927,7 +1927,7 @@ Only large parcels can be listed in search.
              layout="topleft"
              left_delta="0"
              name="limit_age_verified"
-             tool_tip="Ban residents who have not verified their age. See the [SUPPORT_SITE] for more information."
+             tool_tip="Ban Residents who have not verified their age. See the [SUPPORT_SITE] for more information."
              top_pad="4"
              width="278" />
             <check_box
diff --git a/indra/newview/skins/default/xui/en/floater_buy_currency.xml b/indra/newview/skins/default/xui/en/floater_buy_currency.xml
index 86229c6691f..d202bf1b9f1 100644
--- a/indra/newview/skins/default/xui/en/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/en/floater_buy_currency.xml
@@ -107,7 +107,7 @@
      height="16"
      layout="topleft"
      top_delta="0"
-     left="242"
+     left="217"
      name="currency_label"
      width="15">
       L$
@@ -123,7 +123,7 @@
      label="L$"
      left_pad="3"
      name="currency_amt"
-     width="60">
+     width="85">
         1234
     </line_editor>
     <text
diff --git a/indra/newview/skins/default/xui/en/floater_customize.xml b/indra/newview/skins/default/xui/en/floater_customize.xml
index 0dc7d62b19f..ddc0d9af729 100644
--- a/indra/newview/skins/default/xui/en/floater_customize.xml
+++ b/indra/newview/skins/default/xui/en/floater_customize.xml
@@ -260,10 +260,9 @@
              left="10"
              name="not worn instructions"
              top="31"
+             word_wrap="true"
              width="373">
-                Put on a new shape by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new shape by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -274,6 +273,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -300,7 +300,7 @@ scratch and wear it.
              left="10"
              name="Create New"
              top="104"
-             width="140" />
+             width="160" />
             <button
              follows="right|bottom"
              height="23"
@@ -463,10 +463,9 @@ scratch and wear it.
              left="10"
              name="not worn instructions"
              top="31"
+             word_wrap="true"
              width="373">
-                Put on a new skin by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new skin by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -477,6 +476,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -542,7 +542,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-249"
-             width="120" />
+             width="160" />
             <button
              follows="right|bottom"
              height="23"
@@ -713,10 +713,9 @@ scratch and wear it.
              left="10"
              name="not worn instructions"
              top="31"
+             word_wrap="true"
              width="373">
-                Put on a new hair by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new hair by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -727,6 +726,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -765,7 +765,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-89"
-             width="120" />
+             width="160" />
             <button
              follows="right|bottom"
              height="23"
@@ -898,10 +898,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new eyes by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new set of eyes by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -912,6 +911,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -950,7 +950,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="39"
-             width="120" />
+             width="160" />
             <button
              follows="right|bottom"
              height="23"
@@ -1056,7 +1056,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="120" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
@@ -1170,10 +1170,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new shirt by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new shirt by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -1184,6 +1183,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1262,7 +1262,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="120" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
@@ -1376,10 +1376,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new pants by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on new pants by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -1390,6 +1389,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1509,10 +1509,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new shoes by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new pair of shoes by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -1523,6 +1522,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1572,7 +1572,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="120" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
@@ -1715,10 +1715,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new socks by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on new socks by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -1729,6 +1728,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1778,7 +1778,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="120" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
@@ -1921,10 +1921,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new jacket by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new jacket by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -1935,6 +1934,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -1996,7 +1996,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-121"
-             width="140" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
@@ -2139,10 +2139,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new gloves by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on new gloves by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -2153,6 +2152,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -2202,7 +2202,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="130" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
@@ -2345,10 +2345,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new undershirt by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new undershirt by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -2359,6 +2358,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -2551,10 +2551,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new underpants by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on new underpants by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -2565,6 +2564,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -2757,10 +2757,9 @@ scratch and wear it.
              left_delta="0"
              name="not worn instructions"
              top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new skirt by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new skirt by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -2771,6 +2770,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -2820,7 +2820,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-41"
-             width="120" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
@@ -2962,11 +2962,10 @@ scratch and wear it.
              layout="topleft"
              left_delta="-2"
              name="not worn instructions"
-             top_delta="2"
+             top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new alpha mask by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new alpha mask by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -2977,6 +2976,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -3108,7 +3108,7 @@ scratch and wear it.
              left="8"
              name="Create New"
              top="104"
-             width="120" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
@@ -3250,11 +3250,10 @@ scratch and wear it.
              layout="topleft"
              left_delta="-2"
              name="not worn instructions"
-             top_delta="2"
+             top_pad="8"
+             word_wrap="true"
              width="373">
-                Put on a new tattoo by dragging one from your inventory
-to your avatar. Alternately, you create a new one from
-scratch and wear it.
+                Put on a new tattoo by dragging one from your inventory to your avatar. Alternately, you create a new one from scratch and wear it.
             </text>
             <text
              type="string"
@@ -3265,6 +3264,7 @@ scratch and wear it.
              left_delta="0"
              name="no modify instructions"
              top_delta="0"
+             word_wrap="true"
              width="373">
                 You do not have permission to modify this wearable.
             </text>
@@ -3327,7 +3327,7 @@ scratch and wear it.
              left_delta="0"
              name="Create New"
              top_delta="-121"
-             width="120" />
+             width="160" />
             <button
              follows="left|top"
              height="23"
diff --git a/indra/newview/skins/default/xui/en/floater_god_tools.xml b/indra/newview/skins/default/xui/en/floater_god_tools.xml
index b01c0edc8bc..0fac6cd5f17 100644
--- a/indra/newview/skins/default/xui/en/floater_god_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_god_tools.xml
@@ -123,7 +123,7 @@
              layout="topleft"
              left_delta="0"
              name="check reset home"
-             tool_tip="When resident teleports out, reset their home to the destination position."
+             tool_tip="When Resident teleports out, reset their home to the destination position."
              top_pad="4"
              width="180">
 			       <check_box.commit_callback
diff --git a/indra/newview/skins/default/xui/en/floater_im.xml b/indra/newview/skins/default/xui/en/floater_im.xml
index 92a61117598..a21242ffe17 100644
--- a/indra/newview/skins/default/xui/en/floater_im.xml
+++ b/indra/newview/skins/default/xui/en/floater_im.xml
@@ -26,7 +26,7 @@
     </multi_floater.string>
     <multi_floater.string
      name="muted_message">
-        You have blocked this resident. Sending a message will automatically unblock them.
+        You have blocked this Resident. Sending a message will automatically unblock them.
     </multi_floater.string>
     <multi_floater.string
      name="generic_request_error">
diff --git a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
index 920f0c909a7..ae686d9ab7a 100644
--- a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
+++ b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
@@ -4,8 +4,8 @@
  border_drop_shadow_visible="false"
  drop_shadow_visible="false"
  border="false"
- bg_opaque_image="Inspector_Background"
- bg_alpha_image="Toast_Background"
+ bg_opaque_image="Window_Foreground" 
+ bg_alpha_image="Window_Background" 
  bg_alpha_color="0 0 0 0"
  legacy_header_height="18"
  can_minimize="true"
diff --git a/indra/newview/skins/default/xui/en/floater_report_abuse.xml b/indra/newview/skins/default/xui/en/floater_report_abuse.xml
index f1a75bfcb4d..aa219b96152 100644
--- a/indra/newview/skins/default/xui/en/floater_report_abuse.xml
+++ b/indra/newview/skins/default/xui/en/floater_report_abuse.xml
@@ -201,11 +201,11 @@
          name="Age__Age_play"
          value="31" />
         <combo_box.item
-         label="Age &gt; Adult resident on Teen Second Life"
+         label="Age &gt; Adult Resident on Teen Second Life"
          name="Age__Adult_resident_on_Teen_Second_Life"
          value="32" />
         <combo_box.item
-         label="Age &gt; Underage resident outside of Teen Second Life"
+         label="Age &gt; Underage Resident outside of Teen Second Life"
          name="Age__Underage_resident_outside_of_Teen_Second_Life"
          value="33" />
         <combo_box.item
diff --git a/indra/newview/skins/default/xui/en/floater_select_key.xml b/indra/newview/skins/default/xui/en/floater_select_key.xml
index 93aa1f0e31a..4e89df5a735 100644
--- a/indra/newview/skins/default/xui/en/floater_select_key.xml
+++ b/indra/newview/skins/default/xui/en/floater_select_key.xml
@@ -15,13 +15,12 @@
      follows="left|top"
      height="30"
      layout="topleft"
-     left="10"
+     left="30"
      name="Save item as:"
      top="25"
      word_wrap="true"
-     width="220">
-        Press a key to set your
-Speak button trigger.
+     width="180">
+        Press a key to set your Speak button trigger.
     </text>
     <button
      height="23"
@@ -30,5 +29,6 @@ Speak button trigger.
      layout="topleft"
      right="-10"
      name="Cancel"
+     top_pad="8"
      width="100" />
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_top_objects.xml b/indra/newview/skins/default/xui/en/floater_top_objects.xml
index 68bb500c785..b06c6dc215d 100644
--- a/indra/newview/skins/default/xui/en/floater_top_objects.xml
+++ b/indra/newview/skins/default/xui/en/floater_top_objects.xml
@@ -9,7 +9,7 @@
  name="top_objects"
  help_topic="top_objects"
  title="Top Objects"
- width="550">
+ width="800">
     <floater.string
      name="top_scripts_title">
         Top Scripts
@@ -64,7 +64,7 @@
      multi_select="true"
      name="objects_list"
      top_delta="17"
-     width="530">
+     width="780">
         <scroll_list.columns
          label="Score"
          name="score"
@@ -84,11 +84,15 @@
         <scroll_list.columns
          label="Time"
          name="time"
-         width="100" />
+         width="150" />
         <scroll_list.columns
          label="Mono Time"
          name="mono_time"
-         width="55" />
+         width="100" />
+          <scroll_list.columns
+          	label="URLs"
+          	name="URLs"
+          	width="100" />
 		<scroll_list.commit_callback
           function="TopObjects.CommitObjectsList" />
     </scroll_list>
@@ -112,7 +116,7 @@
      left_pad="3"
      name="id_editor"
      top_delta="-3"
-     width="325" />
+     width="575" />
     <button
      follows="bottom|right"
      height="23"
@@ -144,7 +148,7 @@
      left_pad="3"
      name="object_name_editor"
      top_delta="-3"
-     width="325" />
+     width="575" />
     <button
      follows="bottom|right"
      height="23"
@@ -176,7 +180,7 @@
      left_pad="3"
      name="owner_name_editor"
      top_delta="-3"
-     width="325" />
+     width="575" />
     <button
      follows="bottom|right"
      height="23"
@@ -190,7 +194,7 @@
           function="TopObjects.GetByOwnerName" />
     </button>
     <button
-     follows="top|left"
+     follows="bottom|right"
      height="22"
      image_overlay="Refresh_Off"
      layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/floater_tos.xml b/indra/newview/skins/default/xui/en/floater_tos.xml
index 1adb824e2a6..5e168fe4aa6 100644
--- a/indra/newview/skins/default/xui/en/floater_tos.xml
+++ b/indra/newview/skins/default/xui/en/floater_tos.xml
@@ -49,9 +49,9 @@
      left_delta="0"
      name="tos_heading"
      top_delta="-399"
+     word_wrap="true"
      width="552">
-        Please read the following Terms of Service carefully. To continue logging in to [SECOND_LIFE],
-you must accept the agreement.
+        Please read the following Terms of Service carefully. To continue logging in to [SECOND_LIFE], you must accept the agreement.
     </text>
     <web_browser
      follows="left|top"
@@ -60,6 +60,6 @@ you must accept the agreement.
      left_delta="0"
      name="tos_html"
      start_url="data:text/html,%3Chtml%3E%3Chead%3E%3C/head%3E%3Cbody text=%22000000%22%3E%3Ch2%3E Loading %3Ca%20target%3D%22_external%22%20href%3D%22http%3A//secondlife.com/app/tos/%22%3ETerms%20of%20Service%3C/a%3E...%3C/h2%3E %3C/body%3E %3C/html%3E"
-     top_delta="0"
+     top_delta="40"
      width="568" />
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_voice_controls.xml b/indra/newview/skins/default/xui/en/floater_voice_controls.xml
index b9649e9c577..ae198d69a37 100644
--- a/indra/newview/skins/default/xui/en/floater_voice_controls.xml
+++ b/indra/newview/skins/default/xui/en/floater_voice_controls.xml
@@ -3,9 +3,9 @@
  can_resize="true"
  can_minimize="true"
  can_close="false"
- height="270"
+ height="275"
  layout="topleft"
- min_height="122"
+ min_height="100"
  min_width="190"
  name="floater_voice_controls"
  help_topic="floater_voice_controls"
@@ -33,27 +33,23 @@
      name="no_one_near">
         No one near has voice enabled
     </string>
-    <string
-     name="max_visible_items">
-        5
-    </string>
-    <panel
-     bevel_style="out"
-     border="true"
-     follows="left|right|top"
-     height="62"
-     layout="topleft"
-     left="0"
-     name="control_panel"
-     top="0"
-     width="282">
-        <panel
-         height="18"
-         follows="top|left|right"
+      <layout_stack
+         clip="false"
+         follows="all"
+         height="262"
          layout="topleft"
          left="10"
-         name="my_panel"
+         mouse_opaque="false"
+         name="my_call_stack"
+         orientation="vertical"
          width="263">
+        <layout_panel
+         follows="top|left|right"
+          user_resize="false" 
+         auto_resize="false" 
+         layout="topleft"
+         height="26"
+         name="my_panel">
             <avatar_icon
              enabled="false"
              follows="left|top"
@@ -79,92 +75,57 @@
             <output_monitor
              auto_update="true"
              draw_border="false"
-             follows="right"
+             follows="top|right"
              height="16"
              layout="topleft"
              name="speaking_indicator"
-             right="-1"
-             top="2"
+             left_pad="5"
              visible="true"
              width="20" />
-        </panel>
-        <layout_stack
-         border_size="0"
-         clip="false"
-         follows="all"
-         height="28"
-         layout="topleft"
-         left="10"
-         mouse_opaque="false"
-         name="leave_call_stack"
-         orientation="horizontal"
-         top_pad="5"
-         width="263">
-         <layout_panel
-          auto_resize="true"
-          follows="left|right"
-          height="26"
-          layout="topleft"
-          min_height="23"
-          min_width="5"
-          mouse_opaque="false"
-          name="left_anchor"
-          width="80"/>
+        </layout_panel>
          <layout_panel
           auto_resize="false"
-          follows="left|right"
+          user_resize="false" 
+          follows="top|left"
           height="26"
+          visible="true"
           layout="topleft"
-          mouse_opaque="false"
-          min_height="24"
-          min_width="100"
           name="leave_call_btn_panel"
           width="100">
            <button
-            follows="left|right"
-            height="24"
+          follows="right|top"
+            height="23"
+            top_pad="0"
             label="Leave Call"
-            left="0"
             name="leave_call_btn"
-            top="0"
             width="100" />
          </layout_panel>
-         <layout_panel
-         auto_resize="true"
-         follows="left|right"
-         height="26"
+      <layout_panel
+          follows="all"
+          layout="topleft"
+          left="2"
+          top_pad="0"
+          height="205" 
+          name="callers_panel"
+          user_resize="false" 
+          width="280">
+        <avatar_list
+         follows="all"
+         height="205"
+         ignore_online_status="true"
          layout="topleft"
-         mouse_opaque="false"
-         min_height="24"
-         min_width="5"
-         name="right_anchor"
-         width="80"/>
-        </layout_stack>
-    </panel>
-    <avatar_list
-     follows="all"
-     height="197"
-     ignore_online_status="true"
-     layout="topleft"
-     left="0"
-     multi_select="true"
-     name="speakers_list"
-     width="282" />
-    <panel
-     filename="panel_avatar_list_item.xml"
-     follows="left|right|top"
-     height="24"
-     layout="topleft"
-     left="0"
-     name="non_avatar_caller"
-     top="70"
-     width="282" />
-    <view_border
-     bevel_style="out"
-     follows="left|top|right|bottom"
-     height="206"
-     layout="topleft"
-     left="0"
-     top="63"
-     width="282" />
+         multi_select="true"
+         name="speakers_list"
+         width="280" />
+        <panel
+         filename="panel_avatar_list_item.xml"
+         follows="left|right|top"
+         height="24"
+         layout="topleft"
+         left="0"
+         name="non_avatar_caller"
+         top="10"
+         width="276" />
+      </layout_panel>
+    </layout_stack>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/inspect_toast.xml b/indra/newview/skins/default/xui/en/inspect_toast.xml
new file mode 100644
index 00000000000..0221397a8ca
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/inspect_toast.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<!--
+  Not can_close / no title to avoid window chrome
+  Single instance - only have one at a time, recycle it each spawn
+-->
+<floater
+ legacy_header_height="25"
+ bevel_style="in"
+ bg_opaque_image="Inspector_Background"
+ can_close="false"
+ can_minimize="false"
+ height="148"
+ layout="topleft"
+ name="inspect_toast"
+ single_instance="true"
+ sound_flags="0"
+ visible="true"
+ width="228">
+</floater>
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index fa7e3e86a33..45100eb1ffa 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -198,40 +198,6 @@
              function="Floater.Toggle"
              parameter="nearby_media" />
         </menu_item_check>
-        <!--menu_item_check
-         label="Block List"
-         layout="topleft"
-         name="Mute List">
-            <menu_item_check.on_check
-             function="Floater.Visible"
-             parameter="mute" />
-            <menu_item_check.on_click
-             function="Floater.Toggle"
-             parameter="mute" />
-        </menu_item_check-->
-        <menu_item_separator
-         layout="topleft" />
-        <menu_item_check
-         label="(Legacy) Communicate"
-         layout="topleft"
-         name="Instant Message"
-         shortcut="control|T">
-            <menu_item_check.on_check
-             function="Floater.Visible"
-             parameter="communicate" />
-            <menu_item_check.on_click
-             function="Floater.Toggle"
-             parameter="communicate" />
-        </menu_item_check>
-        <menu_item_call
-         label="(Temp) Media Remote Ctrl"
-         layout="topleft"
-         name="Preferences"
-         shortcut="control|alt|M">
-            <menu_item_call.on_click
-             function="Floater.Toggle"
-             parameter="media_remote_ctrl" />
-        </menu_item_call>
     </menu>
     <menu
      label="World"
@@ -283,7 +249,7 @@
             </menu_item_call>
       <menu
            create_jump_keys="true"
-           label="About This Place"
+           label="Place Profile"
            layout="topleft"
            name="Land"
            tear_off="true">
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index eb82dd4a7f0..5ec8018eaec 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -246,7 +246,7 @@ Save all changes to clothing/body parts?
    icon="alertmodal.tga"
    name="GrantModifyRights"
    type="alertmodal">
-Granting modify rights to another resident allows them to change, delete or take ANY objects you may have in-world. Be VERY careful when handing out this permission.
+Granting modify rights to another Resident allows them to change, delete or take ANY objects you may have in-world. Be VERY careful when handing out this permission.
 Do you want to grant modify rights for [FIRST_NAME] [LAST_NAME]?
     <usetemplate
      name="okcancelbuttons"
@@ -258,7 +258,7 @@ Do you want to grant modify rights for [FIRST_NAME] [LAST_NAME]?
    icon="alertmodal.tga"
    name="GrantModifyRightsMultiple"
    type="alertmodal">
-Granting modify rights to another resident allows them to change ANY objects you may have in-world. Be VERY careful when handing out this permission.
+Granting modify rights to another Resident allows them to change ANY objects you may have in-world. Be VERY careful when handing out this permission.
 Do you want to grant modify rights for the selected Residents?
     <usetemplate
      name="okcancelbuttons"
@@ -1597,7 +1597,8 @@ Unable to force land ownership because selection spans multiple regions. Please
    icon="alertmodal.tga"
    name="ForceOwnerAuctionWarning"
    type="alertmodal">
-This parcel is up for auction. Forcing ownership will cancel the auction and potentially make some residents unhappy if bidding has begun. Force ownership?
+This parcel is up for auction. Forcing ownership will cancel the auction and potentially make some Residents unhappy if bidding has begun.
+Force ownership?
     <usetemplate
      name="okcancelbuttons"
      notext="Cancel"
@@ -2915,6 +2916,16 @@ You have reached your maximum number of groups. Please leave another group befor
      yestext="Join"/>
   </notification>
 
+  <notification
+   icon="alert.tga"
+   name="JoinedTooManyGroups"
+   type="alert">
+You have reached your maximum number of groups. Please leave some group before joining or creating a new one.
+    <usetemplate
+     name="okbutton"
+     yestext="OK"/>
+  </notification>
+
   <notification
    icon="alert.tga"
    name="KickUser"
@@ -3553,7 +3564,7 @@ Type a short announcement which will be sent to everyone in this region.
 The maturity rating for this region has been updated.
 It may take some time for the change to be reflected on the map.
 
-To enter Adult regions, residents must be Account Verified, either by age-verification or payment-verification.
+To enter Adult regions, Residents must be Account Verified, either by age-verification or payment-verification.
   </notification>
 
   <notification
@@ -4543,8 +4554,8 @@ Click on any landmark to select it, then click &apos;Teleport&apos; at the botto
    icon="notifytip.tga"
    name="TeleportToPerson"
    type="notifytip">
-You can contact residents like &apos;[NAME]&apos; by opening the People panel on the right side of your screen.
-Select the resident from the list, then click &apos;IM&apos; at the bottom of the panel.
+You can contact Residents like &apos;[NAME]&apos; by opening the People panel on the right side of your screen.
+Select the Resident from the list, then click &apos;IM&apos; at the bottom of the panel.
 (You can also double-click on their name in the list, or right-click and choose &apos;IM&apos;).
   </notification>
 
@@ -4693,7 +4704,7 @@ The objects on the selected parcel of land that is owned by [FIRST] [LAST] have
    icon="notify.tga"
    name="OtherObjectsReturned2"
    type="notify">
-The objects on the selected parcel of land owned by the resident &apos;[NAME]&apos; have been returned to their owner.
+The objects on the selected parcel of land owned by the Resident &apos;[NAME]&apos; have been returned to their owner.
   </notification>
 
   <notification
@@ -4974,7 +4985,7 @@ No valid parcel could be found.
    icon="notify.tga"
    name="ObjectGiveItem"
    type="offer">
-An object named [OBJECTFROMNAME] owned by [NAME_SLURL] has given you [OBJECTTYPE]:
+An object named [OBJECTFROMNAME] owned by [NAME_SLURL] has given you this [OBJECTTYPE]:
 [ITEM_SLURL]
     <form name="form">
       <button
@@ -4996,7 +5007,7 @@ An object named [OBJECTFROMNAME] owned by [NAME_SLURL] has given you [OBJECTTYPE
    icon="notify.tga"
    name="ObjectGiveItemUnknownUser"
    type="offer">
-An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you [OBJECTTYPE]:
+An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you this [OBJECTTYPE]:
 [ITEM_SLURL]
     <form name="form">
       <button
@@ -5018,7 +5029,7 @@ An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you [O
    icon="notify.tga"
    name="UserGiveItem"
    type="offer">
-[NAME_SLURL] has given you [OBJECTTYPE]:
+[NAME_SLURL] has given you this [OBJECTTYPE]:
 [ITEM_SLURL]
     <form name="form">
       <button
@@ -5181,7 +5192,7 @@ An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you [O
    name="OfferCallingCard"
    type="notify">
 [FIRST] [LAST] is offering their calling card.
-This will add a bookmark in your inventory so you can quickly IM this resident.
+This will add a bookmark in your inventory so you can quickly IM this Resident.
     <form name="form">
       <button
        index="0"
diff --git a/indra/newview/skins/default/xui/en/panel_adhoc_control_panel.xml b/indra/newview/skins/default/xui/en/panel_adhoc_control_panel.xml
index 6c54532a3a8..28a6995186b 100644
--- a/indra/newview/skins/default/xui/en/panel_adhoc_control_panel.xml
+++ b/indra/newview/skins/default/xui/en/panel_adhoc_control_panel.xml
@@ -4,7 +4,7 @@
  follows="all"
  height="215"
  name="panel_im_control_panel"
- width="180">
+ width="150">
     <layout_stack
      mouse_opaque="false"
      border_size="0"
@@ -16,15 +16,16 @@
      name="vertical_stack"
      orientation="vertical"
      top="0"
-     width="177">
+     width="147">
         <layout_panel
          auto_resize="true"
          follows="top|left"
          height="130"
          layout="topleft"
+         left="0"
          min_height="0"
          mouse_opaque="false"
-         width="180"
+         width="147"
          top="0"
          name="speakers_list_panel"
          user_resize="false">
@@ -39,7 +40,7 @@
              show_info_btn="false"
              show_profile_btn="false"
              show_speaking_indicator="false"
-             width="180" />
+             width="147" />
         </layout_panel>
         <layout_panel
          auto_resize="false"
@@ -47,7 +48,7 @@
          height="25"
          layout="topleft"
          min_height="25"
-         width="160"
+         width="130"
          name="call_btn_panel"
          user_resize="false"
          visible="false">
@@ -56,7 +57,7 @@
              height="20"
              label="Call"
              name="call_btn"
-             width="160"
+             width="130"
              top="5" />
         </layout_panel>
         <layout_panel
@@ -65,7 +66,7 @@
          height="25"
          layout="topleft"
          min_height="25"
-         width="160"
+         width="130"
          name="end_call_btn_panel"
          user_resize="false"
          visible="false">
@@ -82,7 +83,7 @@
          height="25"
          layout="topleft"
          min_height="25"
-         width="160"
+         width="130"
          name="voice_ctrls_btn_panel"
          user_resize="false"
          visible="false">
diff --git a/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml
index 45f9d9c7b65..615ade99a2b 100644
--- a/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml
@@ -58,13 +58,13 @@
      top="6"
      use_ellipses="true"
      value="Unknown"
-     width="182" />
+     width="180" />
     <text
      follows="right"
      font="SansSerifSmall"
      height="15"
      layout="topleft"
-     left_pad="8"
+     left_pad="5"
      name="last_interaction"
      text_color="LtGray_50"
      value="0s"
@@ -75,7 +75,7 @@
      draw_border="false"
      height="16"
      layout="topleft"
-     left_pad="0"
+     left_pad="5"
      mouse_opaque="true"
      name="speaking_indicator"
      visible="true"
@@ -98,6 +98,7 @@
      left_pad="5"
      right="-3"
      name="profile_btn"
+     tool_tip="View profile"
      top_delta="-2"
      width="20" />
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml b/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml
index 003e1baa7eb..39170b90ca3 100644
--- a/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml
+++ b/indra/newview/skins/default/xui/en/panel_block_list_sidetray.xml
@@ -37,7 +37,7 @@
      layout="topleft"
      left="5"
      name="blocked"
-     tool_tip="List of currently blocked residents"
+     tool_tip="List of currently blocked Residents"
      top="30"
      width="270" />
     <button
@@ -47,7 +47,7 @@
      layout="topleft"
      left_delta="0"
      name="Block resident..."
-     tool_tip="Pick a resident to block"
+     tool_tip="Pick a Resident to block"
      top_pad="4"
      width="210">
         <button.commit_callback
@@ -74,7 +74,7 @@
      layout="topleft"
      left_delta="0"
      name="Unblock"
-     tool_tip="Remove resident or object from blocked list"
+     tool_tip="Remove Resident or object from blocked list"
      top_pad="4"
      width="210" >
         <button.commit_callback
diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml
index aeaa049f1ff..4b39210f30c 100644
--- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml
+++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml
@@ -33,10 +33,10 @@
          height="10"
          image_name="spacer24.tga"
          layout="topleft"
-         min_width="4"
+         min_width="2"
          left="0"
          top="0"
-         width="4" />
+         width="2" />
         <layout_panel
  	mouse_opaque="false"
          auto_resize="false"
@@ -71,7 +71,7 @@
            layout="topleft"
            left="0"
            name="talk"
-           top="4"
+           top="5"
           width="100">
               <show_button>
                   <show_button.init_callback
@@ -103,20 +103,20 @@
          min_width="52"
          name="gesture_panel"
          user_resize="false">
-         <gesture_combo_box
+         <gesture_combo_list
           follows="left|right"
           height="23"
           label="Gesture"
           layout="topleft"
           name="Gesture"
           left="0"
-          top="4"
+          top="5"
           width="82"
           tool_tip="Shows/hides gestures">
-             <gesture_combo_box.drop_down_button
+             <gesture_combo_list.combo_button
               pad_right="10"
               use_ellipses="true" />
-         </gesture_combo_box>
+         </gesture_combo_list>
         </layout_panel>
 		 <icon
          auto_resize="false"
@@ -153,7 +153,7 @@
              layout="topleft"
              name="movement_btn"
              tool_tip="Shows/hides movement controls"
-             top="4"
+             top="5"
              width="80">
                 <button.init_callback
                  function="Button.SetDockableFloaterToggle"
@@ -195,7 +195,7 @@
              layout="topleft"
              left="0"
              tool_tip="Shows/hides camera controls"
-             top="4"
+             top="5"
              name="camera_btn"
              width="80">
                 <button.init_callback
@@ -235,7 +235,7 @@
              layout="topleft"
              name="snapshots"
              width="36"
-             top="4"
+             top="5"
              is_toggle="true"
              image_overlay="Snapshot_Off"
              tool_tip="Take snapshot">
@@ -338,7 +338,7 @@ as for parent layout_panel (chiclet_list_panel) to resize bottom tray properly.
              layout="topleft"
              left="0"
              name="im_well"
-             top="4"
+             top="5"
              width="35">
              <!--
 Emulate 4 states of button by background images, see details in EXT-3147. The same should be for notification_well button
@@ -362,8 +362,6 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
                  label_color="Black"
                  left="0"
                  name="Unread IM messages"
-                 pad_left="0"
-                 pad_right="0"
                  tool_tip="Conversations"
                  width="35" >
                     <button.init_callback
@@ -381,8 +379,8 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
          top="0"
          left_pad="3"
          name="notification_well_panel"
-         width="35"
-         min_width="35"
+         width="40"
+         min_width="40"
          user_resize="false">
             <chiclet_notification
              flash_period="0.25"
@@ -392,7 +390,7 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
              left="0"
              max_displayed_count="99"
              name="notification_well"
-             top="4"
+             top="5"
              width="35">
               <button
                  bottom_pad="3"
@@ -405,11 +403,11 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
                follows="right"
                flash_color="ChicletFlashColor"
                 label_color="Black"
-               left="5"
+               left="0"
                name="Unread"
                image_overlay="Notices_Unread"
                image_overlay_alignment="center"
-               pad_right="5"
+               pad_right="15"
                tool_tip="Notifications"
                width="35" >
                   <button.init_callback
@@ -418,16 +416,5 @@ image_pressed_selected  "Lit" + "Selected" - there are new messages and the Well
               </button>
 	    </chiclet_notification>
         </layout_panel>
-        <icon
-         auto_resize="false"
-         color="0 0 0 0"
-         follows="left|right"
-         height="10"
-         image_name="spacer24.tga"
-         layout="topleft"
-         min_width="4"
-         right="-1"
-         top="0"
-         width="4"/>
     </layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_edit_pick.xml b/indra/newview/skins/default/xui/en/panel_edit_pick.xml
index d6de5af32d3..7769189219c 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_pick.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_pick.xml
@@ -38,28 +38,27 @@
    <scroll_container
      color="DkGray2"
      follows="all"
-     height="510"
+     height="500"
      layout="topleft"
      left="10"
      top_pad="10"
      name="profile_scroll"
-     reserve_scroll_corner="false"
      opaque="true"
      width="313">
     <panel
      name="scroll_content_panel"
-     follows="left|top"
+     follows="left|top|right"
      min_height="300"
      layout="topleft"
      top="0"
      background_visible="false"
-     height="510"
+     height="500"
      left="0"
-     width="295">
+     width="285">
     <texture_picker
      follows="left|top|right"
      height="197"
-     width="290"
+     width="280"
      layout="topleft"
      top="20"
      left="10"
@@ -77,7 +76,7 @@
         <text
          type="string"
          length="1"
-         follows="left|top"
+         follows="left|top|right"
          height="15"
          font="SansSerifSmall"
          font.style="BOLD"
@@ -86,7 +85,7 @@
          top="215"
          name="Name:"
          text_color="white"
-         width="290">
+         width="280">
             Title:
         </text>
         <line_editor
@@ -99,11 +98,11 @@
          max_length="63"
          name="pick_name"
          text_color="black"
-         width="290" />
+         width="280" />
         <text
          type="string"
          length="1"
-         follows="left|top"
+         follows="left|top|right"
          height="15"
          font="SansSerifSmall"
          font.style="BOLD"
@@ -112,13 +111,13 @@
          top_pad="20"
          name="description_label"
          text_color="white"
-         width="290">
+         width="280">
             Description:
         </text>
         <text_editor
          follows="left|top|right"
          height="100"
-         width="290"
+         width="280"
          hide_scrollbar="false"
          layout="topleft"
          left="10"
@@ -132,27 +131,26 @@
          length="1"
          font="SansSerifSmall"
          font.style="BOLD"
-         follows="left|top"
+         follows="left|top|right"
          height="15"
          layout="topleft"
          left="10"
          name="location_label"
          text_color="white"
          top_pad="20"
-         width="290">
+         width="280">
             Location:
         </text>
         <text
          type="string"
          length="1"
-         follows="left|top"
+         follows="left|top|right"
          height="50"
          layout="topleft"
          left="10"
          name="pick_location"
-         right="-10"
          top_pad="2"
-         width="290"
+         width="280"
          word_wrap="true">
             loading...
         </text>
diff --git a/indra/newview/skins/default/xui/en/panel_edit_profile.xml b/indra/newview/skins/default/xui/en/panel_edit_profile.xml
index be3c0bbd969..172cf18fc4b 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_profile.xml
@@ -301,14 +301,13 @@
          left="10"
          name="partner_data_panel"
          width="285">
-            <text
+            <name_box
              follows="left|top|right"
              height="30"
              layout="topleft"
              left="0"
              name="partner_text"
              top="0"
-             value="[FIRST] [LAST]"
              width="285"
              word_wrap="true" />
          </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_friends.xml b/indra/newview/skins/default/xui/en/panel_friends.xml
index ac731bcdf00..c315adb33eb 100644
--- a/indra/newview/skins/default/xui/en/panel_friends.xml
+++ b/indra/newview/skins/default/xui/en/panel_friends.xml
@@ -118,7 +118,7 @@
      layout="topleft"
      left_delta="0"
      name="add_btn"
-     tool_tip="Offer friendship to a resident"
+     tool_tip="Offer friendship to a Resident"
      top_pad="13"
      width="80" />
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_group_control_panel.xml b/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
index 4073ef158bb..aa7d621e4c8 100644
--- a/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_control_panel.xml
@@ -4,7 +4,7 @@
  follows="all"
  height="238"
  name="panel_im_control_panel"
- width="180">
+ width="150">
     <layout_stack
      mouse_opaque="false"
      border_size="0"
@@ -16,7 +16,7 @@
      name="vertical_stack"
      orientation="vertical"
      top="0"
-     width="175">
+     width="145">
         <layout_panel
          auto_resize="true"
          follows="top|left"
@@ -24,7 +24,7 @@
          layout="topleft"
          min_height="0"
          mouse_opaque="false"
-         width="180"
+         width="145"
          top="0"
          name="speakers_list_panel"
          user_resize="false">
@@ -39,7 +39,7 @@
              show_info_btn="false"
              show_profile_btn="false"
              show_speaking_indicator="false"
-             width="180" />
+             width="145" />
         </layout_panel>
         <layout_panel
          auto_resize="false"
@@ -47,7 +47,7 @@
          height="28"
          layout="topleft"
          min_height="28"
-         width="160"
+         width="130"
          name="group_info_btn_panel"
          user_resize="false">
             <button
@@ -57,7 +57,7 @@
              name="group_info_btn"
              use_ellipses="true"
              top="5"
-             width="160" />
+             width="130" />
         </layout_panel>
         <layout_panel
          auto_resize="false"
@@ -65,7 +65,7 @@
          height="28"
          layout="topleft"
          min_height="28"
-         width="160"
+         width="130"
          name="call_btn_panel"
          user_resize="false">
             <button
@@ -74,7 +74,7 @@
              label="Call Group"
              name="call_btn"
              use_ellipses="true" 
-             width="160" />
+             width="130" />
         </layout_panel>
         <layout_panel
          auto_resize="false"
@@ -82,7 +82,7 @@
          height="28"
          layout="topleft"
          min_height="28"
-         width="160"
+         width="130"
          name="end_call_btn_panel"
          user_resize="false"
          visible="false">
@@ -99,7 +99,7 @@
          height="28"
          layout="topleft"
          min_height="28"
-         width="160"
+         width="130"
          name="voice_ctrls_btn_panel"
          user_resize="false"
          visible="false">
diff --git a/indra/newview/skins/default/xui/en/panel_group_info_sidetray.xml b/indra/newview/skins/default/xui/en/panel_group_info_sidetray.xml
index c0db734f8c1..81880488218 100644
--- a/indra/newview/skins/default/xui/en/panel_group_info_sidetray.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_info_sidetray.xml
@@ -216,12 +216,28 @@ background_visible="true"
      visible="false"
      width="65" />-->
      <button
+     follows="bottom|right"          
+     label="Group Chat"
+     name="btn_chat"
+     right="-184"
+     left_pad="2"     
+     height="22"          
+     width="85" />
+     <button
+     follows="bottom|right"          
+     label="Group Call"
+     name="btn_call"
+     right="-97"
+     left_pad="2"     
+     height="22"          
+     width="85" />
+     <button
      height="22"
      label="Save"
      label_selected="Save"
      name="btn_apply"
      left_pad="10"
      right="-10"
-     width="100" />
+     width="85" />
      </panel>
 </panel>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/panel_group_invite.xml b/indra/newview/skins/default/xui/en/panel_group_invite.xml
index 37578eae703..48083b7677d 100644
--- a/indra/newview/skins/default/xui/en/panel_group_invite.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_invite.xml
@@ -17,7 +17,7 @@
     </panel.string>
     <panel.string
      name="already_in_group">
-        Some avatars are already in group and were not invited.
+        Some Residents you chose are already in the group, and so were not sent an invitation.
     </panel.string>
     <text
      type="string"
@@ -26,11 +26,10 @@
      layout="topleft"
      left="7"
      name="help_text"
-     top="24"
+     top="28"
+     word_wrap="true"
      width="200">
-        You can select multiple residents to 
-invite to your group. Click &apos;Open 
-Resident Chooser&apos; to start.
+        You can select multiple Residents to invite to your group. Click &apos;Open Resident Chooser&apos; to start.
     </text>
     <button
      height="20"
@@ -48,7 +47,7 @@ Resident Chooser&apos; to start.
      left_delta="0"
      multi_select="true"
      name="invitee_list"
-     tool_tip="Hold the Ctrl key and click resident names to multi-select"
+     tool_tip="Hold the Ctrl key and click Resident names to multi-select"
      top_pad="4"
      width="200" />
     <button
@@ -57,7 +56,7 @@ Resident Chooser&apos; to start.
      layout="topleft"
      left_delta="0"
      name="remove_button"
-     tool_tip="Removes residents selected above from the invite list"
+     tool_tip="Removes the Residents selected above from the invite list"
      top_pad="4"
      width="200" />
     <text
@@ -68,6 +67,7 @@ Resident Chooser&apos; to start.
      left_delta="4"
      name="role_text"
      top_pad="5"
+     word_wrap="true"
      width="200">
         Choose what Role to assign them to:
     </text>
diff --git a/indra/newview/skins/default/xui/en/panel_group_list_item.xml b/indra/newview/skins/default/xui/en/panel_group_list_item.xml
index 5f6b911620f..c243d08b97e 100644
--- a/indra/newview/skins/default/xui/en/panel_group_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_list_item.xml
@@ -65,6 +65,7 @@
      left_pad="5"
      right="-3"
      name="profile_btn"
+     tool_tip="View profile"
      top_delta="-2"
      width="20" />
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_group_notices.xml b/indra/newview/skins/default/xui/en/panel_group_notices.xml
index e096715ceec..0d9c2c21627 100644
--- a/indra/newview/skins/default/xui/en/panel_group_notices.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_notices.xml
@@ -136,6 +136,7 @@ Maximum 200 per group daily
          left_pad="3"
          max_length="63"
          name="create_subject"
+         prevalidate_callback="ascii"
          width="220" />
         <text
          follows="left|top"
diff --git a/indra/newview/skins/default/xui/en/panel_group_roles.xml b/indra/newview/skins/default/xui/en/panel_group_roles.xml
index a5bab3232cf..6b3fb045499 100644
--- a/indra/newview/skins/default/xui/en/panel_group_roles.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_roles.xml
@@ -210,6 +210,18 @@ including the Everyone and Owner Roles.
                 Abilities allow Members in Roles to do specific
 things in this group. There&apos;s a broad variety of Abilities.
             </panel.string>
+            <panel.string
+             name="power_folder_icon">
+                Inv_FolderClosed
+            </panel.string>
+            <panel.string
+             name="power_all_have_icon">
+                Checkbox_On
+            </panel.string>
+            <panel.string
+             name="power_partial_icon">
+                Checkbox_Off
+            </panel.string>
          <filter_editor
          layout="topleft"
          top="5"
@@ -220,23 +232,32 @@ things in this group. There&apos;s a broad variety of Abilities.
          max_length="250"
          label="Filter Abilities"
          name="filter_input" />
-            <scroll_list
-             column_padding="0"
-             draw_stripes="false"
-             follows="left|top"
-             height="200"
-             layout="topleft"
-             left="0"
-             multi_select="true"
-             name="action_list"
-             search_column="1"
-             tool_tip="Select an Ability to view more details"
-             top_pad="5"
-             width="300">
-                <scroll_list.columns
-                 name="action"
-                 width="300" />
-            </scroll_list>
+
+        <scroll_list
+         column_padding="0"
+         draw_stripes="true"
+         height="200"
+         follows="left|top"
+         layout="topleft"
+         left="0"
+         name="action_list"
+         search_column="2"
+         tool_tip="Select an Ability to view more details"
+         top_pad="5"
+         width="300">
+            <scroll_list.columns
+             label=""
+             name="icon"
+             width="2" />
+            <scroll_list.columns
+             label=""
+             name="checkbox"
+             width="20" />
+            <scroll_list.columns
+             label=""
+             name="action"
+             width="270" />
+        </scroll_list>
         </panel>
     </tab_container>
     <panel
diff --git a/indra/newview/skins/default/xui/en/panel_login.xml b/indra/newview/skins/default/xui/en/panel_login.xml
index e5df37e366c..df942b1a267 100644
--- a/indra/newview/skins/default/xui/en/panel_login.xml
+++ b/indra/newview/skins/default/xui/en/panel_login.xml
@@ -186,6 +186,7 @@ height="80">
    <text
 follows="right|bottom"
 font="SansSerifSmall"
+text_color="EmphasisColor"
 halign="right"
 height="16"
 top="12"
diff --git a/indra/newview/skins/default/xui/en/panel_media_settings_general.xml b/indra/newview/skins/default/xui/en/panel_media_settings_general.xml
index 5217ab35717..38e8b9844f5 100644
--- a/indra/newview/skins/default/xui/en/panel_media_settings_general.xml
+++ b/indra/newview/skins/default/xui/en/panel_media_settings_general.xml
@@ -30,6 +30,7 @@
     (This page does not pass the specified whitelist)
   </text>
   <line_editor 
+   max_length="1024"
    bottom_delta="-24" 
    enabled="true" 
    follows="left|top" 
@@ -72,13 +73,15 @@
     Current Page:
   </text>
   <text 
+   name="current_url"
+   max_length="1024"
+   use_ellipses="true"
    bottom_delta="-20" 
    enabled="false" 
    follows="left|top" 
    font="SansSerif"
    height="20" 
    left="10" 
-   name="current_url"
    tool_tip="The current page for this media source"
    value="" 
    width="340" />
diff --git a/indra/newview/skins/default/xui/en/panel_my_profile.xml b/indra/newview/skins/default/xui/en/panel_my_profile.xml
index 8327edfdd08..27c1af1860c 100644
--- a/indra/newview/skins/default/xui/en/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_my_profile.xml
@@ -27,6 +27,9 @@
     <string
      name="no_partner_text"
      value="None" />
+    <string
+     name="no_group_text"
+     value="None" />
     <string
 	 name="RegisterDateFormat">
 	 [REG_DATE] ([AGE])
@@ -62,10 +65,11 @@
           <panel
                 layout="topleft"
           follows="left|top|right"
+                height="505"
                name="scroll_content_panel"
                 top="0"
                 left="0"
-                width="303">
+                width="297">
             <panel
                   follows="left|top|right"
                   height="117"
@@ -73,7 +77,7 @@
                   left="10"
                   name="second_life_image_panel"
                   top="0"
-                  width="300">
+                  width="297">
               <texture_picker
                allow_no_texture="true"
                default_image_name="None"
@@ -114,7 +118,7 @@
                textbox.max_length="512"
                name="sl_description_edit"
                top_pad="-3"
-               width="188"
+               width="181"
                expanded_bg_visible="true"
                expanded_bg_color="DkGray">
                 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum. adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum. adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum.
@@ -127,7 +131,7 @@
        top_pad="10"
              left="10"
              name="first_life_image_panel"
-             width="300">
+             width="297">
               <texture_picker
                allow_no_texture="true"
                default_image_name="None"
@@ -167,7 +171,7 @@
                textbox.max_length="512"
                name="fl_description_edit"
                top_pad="-3"
-               width="188"
+               width="181"
                expanded_bg_visible="true"
                expanded_bg_color="DkGray">
                 Lorem ipsum dolor sit amet, consectetur adlkjpiscing elit moose moose. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet. adipiscing elit. Aenean rigviverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet sorbet ipsum. adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum.
@@ -260,14 +264,14 @@
              name="partner_data_panel"
              top_pad="0"
              width="300">
-              <text
+              <name_box
                follows="left|top"
                height="10"
                layout="topleft"
                left="0"
+               link="true"
                name="partner_text"
                top="0"
-               value="[FIRST] [LAST]"
            width="300"
                word_wrap="true" />
             </panel>
@@ -312,7 +316,7 @@
          left="0"
          mouse_opaque="false"
          name="add_friend"
-         tool_tip="Offer friendship to the resident"
+         tool_tip="Offer friendship to the Resident"
          top="5"
          width="80" />
         <button
diff --git a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
index e2884dbedcf..9ad99b1f135 100644
--- a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
@@ -47,7 +47,7 @@
 	     left="10"
 	     name="back_btn"
 	     tool_tip="Go back to previous location"
-	     top="3"
+	     top="2"
 	     width="31" />
 	    <button
 	     follows="left|top"
@@ -92,7 +92,6 @@
 	         width="20" />
 	      -->
 	    </location_input>
-
 	<!--     <button -->
 	<!--      follows="right|top" -->
 	<!--      height="20" -->
@@ -108,7 +107,6 @@
 	<!--      name="search_bg" -->
 	<!--      top_delta="0" -->
 	<!--      width="168" /> -->
-
         <search_combo_box
 	     bevel_style="none"
 	     border_style="line"
diff --git a/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml b/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
index f09a0e03ed0..2b361c06286 100644
--- a/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
@@ -27,7 +27,7 @@
      max_length="512"
      name="chat_box"
      tool_tip="Press Enter to say, Ctrl+Enter to shout"
-     top="1"
+     top="2"
      width="283" />
     <output_monitor
      auto_update="true"
@@ -45,7 +45,7 @@
      follows="right"
      is_toggle="true"
      width="20"
-     top="1"
+     top="2"
      layout="topleft"
      left_pad="4"
      image_disabled="ComboButton_UpOff"
diff --git a/indra/newview/skins/default/xui/en/panel_notes.xml b/indra/newview/skins/default/xui/en/panel_notes.xml
index 73528b28ad2..45b64d5e26b 100644
--- a/indra/newview/skins/default/xui/en/panel_notes.xml
+++ b/indra/newview/skins/default/xui/en/panel_notes.xml
@@ -120,7 +120,7 @@
          left="0"
          mouse_opaque="false"
          name="add_friend"
-         tool_tip="Offer friendship to the resident"
+         tool_tip="Offer friendship to the Resident"
          top="5"
          width="80" />
         <button
@@ -139,7 +139,7 @@
          label="Call"
          layout="topleft"
          name="call"
-         tool_tip="Call this resident"
+         tool_tip="Call this Resident"
          left_pad="3"
          top="5"
          width="45" />
@@ -150,7 +150,7 @@
          label="Map"
          layout="topleft"
          name="show_on_map_btn"
-         tool_tip="Show the resident on the map"
+         tool_tip="Show the Resident on the map"
          top="5"
          left_pad="3"
          width="45" />
diff --git a/indra/newview/skins/default/xui/en/panel_people.xml b/indra/newview/skins/default/xui/en/panel_people.xml
index adf22f825ff..8a02637817a 100644
--- a/indra/newview/skins/default/xui/en/panel_people.xml
+++ b/indra/newview/skins/default/xui/en/panel_people.xml
@@ -106,7 +106,7 @@ background_visible="true"
                  left_pad="5"
                  name="add_friend_btn"
                  top_delta="0"
-                 tool_tip="Add selected resident to your friends List"
+                 tool_tip="Add selected Resident to your friends List"
                  width="18">
                <commit_callback
                   function="People.addFriend" />
@@ -192,7 +192,7 @@ background_visible="true"
                  layout="topleft"
                  left_pad="5"
                  name="add_btn"
-                 tool_tip="Offer friendship to a resident"
+                 tool_tip="Offer friendship to a Resident"
                  top_delta="0"
                  width="18" />
                 <button
@@ -327,7 +327,7 @@ background_visible="true"
                  left_pad="5"
                  name="add_friend_btn"
                  top_delta="0"
-                 tool_tip="Add selected resident to your friends List"
+                 tool_tip="Add selected Resident to your friends List"
                  width="18">
                 <commit_callback
                    function="People.addFriend" />
@@ -350,7 +350,7 @@ background_visible="true"
          label="Profile"
          layout="topleft"
          name="view_profile_btn"
-         tool_tip="Show picture, groups, and other residents information"
+         tool_tip="Show picture, groups, and other Residents information"
          width="70" />
         <button
          follows="bottom|left"
@@ -370,7 +370,7 @@ background_visible="true"
          label="Call"
          layout="topleft"
          name="call_btn"
-         tool_tip="Call this resident"
+         tool_tip="Call this Resident"
          width="50" />
         <button
          follows="left|top"
diff --git a/indra/newview/skins/default/xui/en/panel_pick_info.xml b/indra/newview/skins/default/xui/en/panel_pick_info.xml
index f68202d2878..9c7f38e6888 100644
--- a/indra/newview/skins/default/xui/en/panel_pick_info.xml
+++ b/indra/newview/skins/default/xui/en/panel_pick_info.xml
@@ -40,31 +40,30 @@
      left="10"
      top_pad="10"
      name="profile_scroll"
-     reserve_scroll_corner="false"
      width="313">
     <panel
      name="scroll_content_panel"
-     follows="left|top"
+     follows="left|top|right"
      min_height="300"
      layout="topleft"
      top="0"
      background_visible="false"
-     height="470"
+     height="400"
      left="0"
-     width="295">
+     width="285">
         <texture_picker
          enabled="false"
-         follows="left|top"
+         follows="left|top|right"
          height="197"
          layout="topleft"
          left="10"
          name="pick_snapshot"
          top="20"
-         width="290" />
+         width="280" />
         <text
          follows="left|top|right"
          height="35"
-         width="290"
+         width="280"
          layout="topleft"
          font="SansSerifBig"
          font.style="BOLD"
@@ -75,23 +74,29 @@
          value="[name]"
          use_ellipses="true" />
         <text
-         follows="left|top"
+         follows="left|top|right"
          height="25"
          layout="topleft"
          left="10"
          name="pick_location"
-         width="290"
+         width="280"
          word_wrap="true"
          value="[loading...]" />
-        <text
-         follows="left|top|right"
-         height="280"
+        <text_editor
+         bg_readonly_color="DkGray2"
+         follows="all"
+         height="100"
+         width="280"
+         hide_scrollbar="false"
          layout="topleft"
          left="10"
+         top_pad="2"
+         max_length="1023"
          name="pick_desc"
-         width="290"
+         read_only="true"
+         text_readonly_color="white"
          value="[description]"
-         word_wrap="true" />
+         wrap="true" />
     </panel>
     </scroll_container>
     <panel
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml b/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml
index 17651b8caae..1e7acb566fe 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml
@@ -2,7 +2,6 @@
 
 <panel
  border="true"
- background_visible="true"
  follows="left|top|right|bottom"
  height="408"
  layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_general.xml b/indra/newview/skins/default/xui/en/panel_preferences_general.xml
index c98555735a7..22c75a595ed 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_general.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_general.xml
@@ -260,7 +260,7 @@
      width="200">
         My effects:
     </text>
-  <text
+    <text
       type="string"
       length="1"
       follows="left|top"
@@ -270,16 +270,23 @@
       name="title_afk_text"
       width="190">
     Away timeout:
-  </text>
+    </text>
     <color_swatch
-     control_name="EffectColor"
+	 can_apply_immediately="true"
      follows="left|top"
      height="50"
      layout="topleft"
      left="50"
      name="effect_color_swatch"
      tool_tip="Click to open Color Picker"
-     width="38" />
+     width="38">
+		<color_swatch.init_callback
+		 function="Pref.getUIColor"
+		 parameter="EffectColor" />
+		<color_swatch.commit_callback
+		 function="Pref.applyUIColor"
+		 parameter="EffectColor" />
+	</color_swatch>
   <combo_box
             height="23"
             layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index cc00abf5a0d..a0fcf59fc8d 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -378,7 +378,7 @@
 		layout="topleft"
 		left_delta="250"
 		name="DrawDistanceMeterText2"
-		top_delta="1"
+		top_delta="0"
 		width="128">
 			m
 		</text>
@@ -395,7 +395,7 @@
 		left="216"
 		max_val="8192"
 		name="MaxParticleCount"
-		top_pad="6"
+		top_pad="7"
 		width="262" />
 		<slider
 		control_name="RenderGlowResolutionPow"
diff --git a/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml b/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml
index 075d9232b1d..ab6384203fa 100644
--- a/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml
+++ b/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml
@@ -321,6 +321,7 @@
 		min_width="90">
 	  <line_editor 
 		  name="media_address_url"
+		  max_length="1024"
 		  follows="top|left|right" 
 		  height="22"
 		  top="0"
diff --git a/indra/newview/skins/default/xui/en/panel_profile.xml b/indra/newview/skins/default/xui/en/panel_profile.xml
index 43947262ec5..597b6410cda 100644
--- a/indra/newview/skins/default/xui/en/panel_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_profile.xml
@@ -27,6 +27,9 @@
     <string
      name="no_partner_text"
      value="None" />
+    <string
+     name="no_group_text"
+     value="None" />
     <string
 	 name="RegisterDateFormat">
 	 [REG_DATE] ([AGE])
@@ -62,10 +65,11 @@
           <panel
                 layout="topleft"
           follows="left|top|right"
+                height="505"
                 name="profile_scroll_panel"
                 top="0"
                 left="0"
-                width="303">
+                width="297">
             <panel
                   follows="left|top|right"
                   height="117"
@@ -73,7 +77,7 @@
                   left="10"
                   name="second_life_image_panel"
                   top="0"
-                  width="303">
+                  width="297">
               <texture_picker
                allow_no_texture="true"
                default_image_name="None"
@@ -117,7 +121,7 @@
        top_pad="10"
              left="10"
              name="first_life_image_panel"
-             width="303">
+             width="297">
               <texture_picker
                allow_no_texture="true"
                default_image_name="None"
@@ -240,14 +244,14 @@
              name="partner_data_panel"
              top_pad="0"
              width="300">
-              <text
+              <name_box
                follows="left|top"
                height="10"
                layout="topleft"
                left="0"
+               link="true"
                name="partner_text"
                top="0"
-               value="[FIRST] [LAST]"
            width="300"
                word_wrap="true" />
             </panel>
@@ -269,7 +273,7 @@
             left="7"
             name="sl_groups"
             top_pad="0"
-            width="298"
+            width="290"
             expanded_bg_visible="true"
             expanded_bg_color="DkGray">
               Lorem ipsum dolor sit amet, consectetur adlkjpiscing elit moose moose. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet. adipiscing elit. Aenean rigviverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet sorbet ipsum. adipiscing elit. Aenean viverra orci et justo sagittis aliquet. Nullam malesuada mauris sit amet ipsum. Aenean viverra tulip moosetop. Slan de heelish marfnik tooplod. Sum sum to whop de wompam booster copm.
@@ -292,7 +296,7 @@
          left="0"
          mouse_opaque="false"
          name="add_friend"
-         tool_tip="Offer friendship to the resident"
+         tool_tip="Offer friendship to the Resident"
          top="5"
          width="80" />
         <button
@@ -311,7 +315,7 @@
          label="Call"
          layout="topleft"
          name="call"
-         tool_tip="Call this resident"
+         tool_tip="Call this Resident"
          left_pad="3"
          top="5"
          width="45" />
@@ -322,7 +326,7 @@
          label="Map"
          layout="topleft"
          name="show_on_map_btn"
-         tool_tip="Show the resident on the map"
+         tool_tip="Show the Resident on the map"
          top="5"
          left_pad="3"
          width="45" />
@@ -342,7 +346,7 @@
          label="â–¼"
          layout="topleft"
          name="overflow_btn"
-         tool_tip="Pay money to or share inventory with the resident"
+         tool_tip="Pay money to or share inventory with the Resident"
          right="-1"
          top="5"
 	 left_pad="3"
@@ -375,4 +379,4 @@
         </layout_panel>
     
 </layout_stack>
-</panel>
\ No newline at end of file
+</panel>
diff --git a/indra/newview/skins/default/xui/en/panel_region_covenant.xml b/indra/newview/skins/default/xui/en/panel_region_covenant.xml
index ff55090f162..dc8f71c868a 100644
--- a/indra/newview/skins/default/xui/en/panel_region_covenant.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_covenant.xml
@@ -135,7 +135,8 @@
      left="120"
      name="covenant_help_text"
      top_pad="10"
-     width="460">
+     word_wrap="true"
+     width="360">
         Changes to the covenant will show on all parcels in the estate.
     </text>
     <text
@@ -145,9 +146,10 @@
      left_delta="0"
      name="covenant_instructions"
      top_pad="5"
-     width="465">
-        Drag and drop a notecard to change
-        the Covenant for this Estate.
+     word_wrap="true"
+     font.style="ITALIC"
+     width="360">
+        Drag and drop a notecard to change the Covenant for this estate.
     </text>
 
     <text
diff --git a/indra/newview/skins/default/xui/en/panel_region_estate.xml b/indra/newview/skins/default/xui/en/panel_region_estate.xml
index ba39e880249..3980eb86d30 100644
--- a/indra/newview/skins/default/xui/en/panel_region_estate.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_estate.xml
@@ -19,9 +19,9 @@
      left="10"
      name="estate_help_text"
      top="14"
-     width="313">
-        Changes to settings on this tab will affect all
-regions in the estate.
+     word_wrap="true"
+     width="275">
+        Changes to settings on this tab will affect all regions in the estate.
     </text>
     <text
      type="string"
@@ -138,7 +138,7 @@ regions in the estate.
      name="Only Allow"
      top="250"
      width="278">
-        Restrict Access to Accounts Verified by:
+        Restrict Access to accounts verified by:
     </text>
     <check_box
      follows="top|left"
@@ -147,7 +147,7 @@ regions in the estate.
      layout="topleft"
      left_delta="0"
      name="limit_payment"
-     tool_tip="Ban unidentified residents"
+     tool_tip="Ban unidentified Residents"
      top_pad="2"
      width="278" />
     <check_box
@@ -157,7 +157,7 @@ regions in the estate.
      layout="topleft"
      left_delta="0"
      name="limit_age_verified"
-     tool_tip="Ban residents who have not verified their age. See the [SUPPORT_SITE] for more information."
+     tool_tip="Ban Residents who have not verified their age. See the [SUPPORT_SITE] for more information."
      top_pad="2"
      width="278" />
     <check_box
diff --git a/indra/newview/skins/default/xui/en/panel_region_texture.xml b/indra/newview/skins/default/xui/en/panel_region_texture.xml
index 502a5804c31..04dbf73be94 100644
--- a/indra/newview/skins/default/xui/en/panel_region_texture.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_texture.xml
@@ -292,7 +292,7 @@
        name="height_text_lbl10"
        top_delta="30"
        width="400"
-       wrap="true">
+       word_wrap="true">
         These values represent the blend range for the textures above.
       </text>
       <text
@@ -303,7 +303,7 @@
        name="height_text_lbl11"
        top_delta="32"
        width="400"
-       wrap="true">
+       word_wrap="true">
         Measured in meters, the LOW value is the MAXIMUM height of Texture #1, and the HIGH value is the MINIMUM height of Texture #4.
       </text>
     <button
diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml
index 00f54feabde..bfca2f2e46c 100644
--- a/indra/newview/skins/default/xui/en/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml
@@ -42,18 +42,36 @@
     <button
      auto_resize="true"
      halign="right"
+     font="SansSerifSmall"
+     follows="right|top"
+     image_overlay=""
+     image_selected="spacer35.tga"
+     image_unselected="spacer35.tga"
+     image_pressed="spacer35.tga"
+     height="16"
+     right="-228"
+     label_shadow="false"
+     name="buycurrency"
+     tool_tip="My Balance"
+     top="5"
+     width="100" />
+    <button
+     auto_resize="true"
+     halign="right"
+     font="SansSerifSmall"
      follows="right|top"
      image_selected="BuyArrow_Over"
      image_unselected="BuyArrow_Over"
      image_pressed="BuyArrow_Press"
      height="16"
-     right="-128"
-     label_color="White"
+     label="Buy L$"
+     label_color="EmphasisColor"
+     left_pad="0"
      label_shadow="false"
-     name="buycurrency"
+     name="buyL"
      pad_right="20px"
-     tool_tip="My Balance: Click to buy more L$"
-     top="3"
+     tool_tip="Click to buy more L$"
+     top="5"
      width="100" />
     <text
      type="string"
@@ -62,29 +80,27 @@
      follows="right|bottom"
      halign="right"
      height="16"
-     top="4"
+     top="7"
      layout="topleft"
      left_pad="0"
      name="TimeText"
-     text_color="TimeTextColor"
      tool_tip="Current time (Pacific)"
      width="85">
         12:00 AM
     </text>
     <button
      follows="right|bottom"
-     height="16"
+     height="15"
      image_selected="AudioMute_Off"
      image_pressed="Audio_Press"
      image_unselected="Audio_Off"
      is_toggle="true"
      left_pad="18"
-     top="1"
+     top="4"
      name="volume_btn"
      tool_tip="Global Volume Control"
      width="16" />
     <text
-     enabled="true"
      follows="right|bottom"
      halign="center"
      height="12"
diff --git a/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml b/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml
new file mode 100644
index 00000000000..60d4a7e00b5
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel
+ background_opaque="true"
+ background_visible="false"
+ border_visible="false"
+ border="false"
+ chrome="true" 
+ follows="bottom"
+ height="150"
+ layout="topleft"
+ name="volumepulldown_floater"
+ width="32">
+  <!-- floater background image -->
+  <icon
+   height="150"
+   image_name="Inspector_Background"
+   layout="topleft"
+   left="0"
+   name="normal_background"
+   top="0"
+   width="32" />
+ <slider
+  control_name="AudioLevelMaster"
+  follows="left|top"
+  left="0"
+  top="1"
+  orientation="vertical"
+  height="120"
+  increment="0.05"
+  initial_value="0.5"
+  layout="topleft"
+  name="mastervolume"
+  show_text="false"
+  slider_label.halign="right"
+  top_pad="2"
+  volume="true">
+  <slider.commit_callback
+   function="Vol.setControlFalse"
+   parameter="MuteAudio" />
+  </slider>
+  <button
+    left="7"
+    top_pad="9"
+    width="18"
+    height="12"
+    follows="top|left"
+    name="prefs_btn"
+    image_unselected="Icon_Gear_Foreground"
+    image_disabled="Icon_Gear_Background"
+    image_pressed="Icon_Gear_Press"
+    scale_image="false">
+    <button.commit_callback
+       function="Vol.GoAudioPrefs" />
+  </button>
+</panel>
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 d26e855e2f6..2dfcdf4a4cf 100644
--- a/indra/newview/skins/default/xui/en/sidepanel_task_info.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_task_info.xml
@@ -153,28 +153,19 @@
 		     layout="topleft"
     		 left="5"
 		 name="CreatorNameLabel"
-		  top_pad="10"
+		  top_pad="12"
 		     width="78">
 	        Creator:
     	</text>
-	    	<avatar_icon
-     follows="top|left"
-     height="20"
-     default_icon_name="Generic_Person"
-     layout="topleft"
-     left_pad="0"
-      top_delta="-6"
-     mouse_opaque="true"
-     width="20" />
 	    <text
 		     type="string"
-     follows="left|right"
+     follows="left|right|top"
      font="SansSerifSmall"
      height="15"
      layout="topleft"
-     left_pad="5"
+     left_pad="0"
              name="Creator Name"
-		     top_delta="6"
+		     top_delta="0"
 		     width="140">
 	        Erica Linden
 	     </text>
@@ -186,28 +177,19 @@
 			layout="topleft"
 			left="5"
 			name="Owner:"
-			top_pad="10"
+			top_pad="15"
 			 width="78">
 			    Owner:
 	     </text>
-	     <avatar_icon
-     follows="top|left"
-     height="20"
-     default_icon_name="Generic_Person"
-     layout="topleft"
-     left_pad="0"
-	    top_delta="-6"
-	    mouse_opaque="true"
-     width="20" />
 	     <text
 			    type="string"
-			    follows="left|right"
+			    follows="left|right|top"
 			    font="SansSerifSmall"
 			    height="15"
 			    layout="topleft"
-			    left_pad="5"
+			    left_pad="0"
 			    name="Owner Name"
-			    top_delta="6"
+			    top_delta="0"
 			    width="140">
 			    Erica Linden
 	     </text>
@@ -219,7 +201,7 @@
 			 layout="topleft"
 			 left="5"
 			name="Group_label"
-			top_pad="10"
+			top_pad="15"
 			width="78">
 			    Group:
 	     </text>
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index bd868ef61e1..fbdac7164dd 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -67,7 +67,7 @@
 	<!-- tooltips for Urls -->
 	<string name="TooltipHttpUrl">Click to view this web page</string>
 	<string name="TooltipSLURL">Click to view this location's information</string>
-	<string name="TooltipAgentUrl">Click to view this resident's profile</string>
+	<string name="TooltipAgentUrl">Click to view this Resident's profile</string>
 	<string name="TooltipGroupUrl">Click to view this group's description</string>
 	<string name="TooltipEventUrl">Click to view this event's description</string>
 	<string name="TooltipClassifiedUrl">Click to view this classified</string>
@@ -1609,11 +1609,11 @@ Sends an HTTP request to the specified url with the body of the request and para
 	</string>
 	<string name="LSLTipText_llResetLandBanList" translate="false">
 llResetLandBanList()
-Removes all residents from the land ban list
+Removes all Residents from the land ban list
 	</string>
 	<string name="LSLTipText_llResetLandPassList" translate="false">
 llResetLandPassList()
-Removes all residents from the land access/pass list
+Removes all Residents from the land access/pass list
 	</string>
 	<string name="LSLTipText_llGetObjectPrimCount" translate="false">
 integer llGetObjectPrimCount(key object_id)
@@ -1621,7 +1621,7 @@ Returns the total number of prims for an object in the region
 	</string>
 	<string name="LSLTipText_llGetParcelPrimOwners" translate="false">
 list llGetParcelPrimOwners(vector pos)
-Returns a list of all residents who own objects on the parcel at pos and with individual prim counts.
+Returns a list of all Residents who own objects on the parcel at pos and with individual prim counts.
 Requires owner-like permissions for the parcel.
 	</string>
 	<string name="LSLTipText_llGetParcelPrimCount" translate="false">
@@ -1808,7 +1808,7 @@ Clears (deletes) the media and all params from the given face.
 
 	<!-- inventory -->
 	<string name="InventoryNoMatchingItems">No matching items found in inventory.</string>
-  <string name="FavoritesNoMatchingItems">Drag and drop a landmark here to add to your favorites.</string>
+  <string name="FavoritesNoMatchingItems">Drag a landmark here to add it to your favorites.</string>
 	<string name="InventoryNoTexture">
 		You do not have a copy of
 this texture in your inventory
@@ -2040,7 +2040,7 @@ this texture in your inventory
 	<string name="RegionInfoAllEstatesYouManage">
 		all estates that you manage for [OWNER]
 	</string>
-	<string name="RegionInfoAllowedResidents">Allowed residents: ([ALLOWEDAGENTS], max [MAXACCESS])</string>
+	<string name="RegionInfoAllowedResidents">Allowed Residents: ([ALLOWEDAGENTS], max [MAXACCESS])</string>
 	<string name="RegionInfoAllowedGroups">Allowed groups: ([ALLOWEDGROUPS], max [MAXACCESS])</string>
 
 	<!-- script limits floater -->
@@ -2111,7 +2111,7 @@ this texture in your inventory
 
 	<!-- Mute -->
 	<string name="MuteByName">(by name)</string>
-	<string name="MuteAgent">(resident)</string>
+	<string name="MuteAgent">(Resident)</string>
 	<string name="MuteObject">(object)</string>
 	<string name="MuteGroup">(group)</string>
 
@@ -2938,7 +2938,7 @@ If you continue to receive this message, contact the [SUPPORT_SITE].
     Click the [BUTTON NAME] button to accept/connect to this voice chat.
   </string>
   <string name="muted_message">
-    You have blocked this resident. Sending a message will automatically unblock them.
+    You have blocked this Resident. Sending a message will automatically unblock them.
   </string>
   <!--Some times string name is getting from the body of server response.
   For ex.: from gIMMgr::showSessionStartError in the LLViewerChatterBoxSessionStartReply::post. 
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_im_adhoc.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_im_adhoc.xml
index af0d3382565..693c43f141b 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_im_adhoc.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_im_adhoc.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_im_adhoc
- font="SansSerif"
  height="25"
  name="im_adhoc_chiclet"
  show_speaker="false"
@@ -12,15 +11,14 @@
      left="25"
      name="speaker"
      visible="false"
-     width="20"/>
+     width="20" />
     <chiclet_im_adhoc.avatar_icon
      follows="left|top|bottom"
      height="22"
      mouse_opaque="true"
      name="adhoc_icon"
-     width="22"/>
+     width="22" />
     <chiclet_im_adhoc.unread_notifications
-     font="SansSerif"
      font_halign="center"
      height="25"
      left="25"
@@ -29,13 +27,13 @@
      text_color="white"
      v_pad="5"
      visible="false"
-     width="20"/>
+     width="20" />
     <chiclet_im_adhoc.new_message_icon
-     bottom="12"
-     height="13"
-     image_name="Unread_Chiclet"
-     left="12"
-     name="new_message_icon"
-     visible="false"
-     width="13" />
+  bottom="11"
+  height="14"
+  image_name="Unread_Chiclet"
+  left="12"
+  name="new_message_icon"
+  visible="false"
+  width="14" />
 </chiclet_im_adhoc>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_im_group.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_im_group.xml
index b1988a2d200..f4fc58701c6 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_im_group.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_im_group.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_im_group
- font="SansSerif"
  height="25"
  name="im_group_chiclet"
  show_speaker="false"
@@ -12,17 +11,17 @@
      left="25"
      name="speaker"
      visible="false"
-     width="20"/>
+     width="20" />
     <chiclet_im_group.group_icon
      default_icon="Generic_Group"
      follows="left|top|bottom"
-     height="22"
+     height="18"
+  bottom_pad="4"
      mouse_opaque="true"
      name="group_icon"
-     width="22"/>
+     width="18" />
     <chiclet_im_group.unread_notifications
      height="25"
-     font="SansSerif"
      font_halign="center"
      left="25"
      mouse_opaque="false"
@@ -32,11 +31,11 @@
      visible="false"
      width="20"/>
     <chiclet_im_group.new_message_icon
-     bottom="12"
-     height="13"
-     image_name="Unread_Chiclet"
-     left="12"
-     name="new_message_icon"
-     visible="false"
-     width="13" />
+bottom="11"
+  height="14"
+  image_name="Unread_Chiclet"
+  left="12"
+  name="new_message_icon"
+  visible="false"
+  width="14" />
 </chiclet_im_group>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_im_p2p.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_im_p2p.xml
index 52fbce0de76..535113f7176 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_im_p2p.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_im_p2p.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_im_p2p
- font="SansSerif"
  height="25"
  name="im_p2p_chiclet"
  show_speaker="false"
@@ -18,10 +17,9 @@
      height="22"
      mouse_opaque="true"
      name="avatar_icon"
-     width="22"/>
+     width="22" />
     <chiclet_im_p2p.unread_notifications
      height="25"
-     font="SansSerif"
      font_halign="center"
      left="25"
      mouse_opaque="false"
@@ -31,11 +29,11 @@
      visible="false"
      width="20"/>
     <chiclet_im_p2p.new_message_icon
-     bottom="12"
-     height="13"
-     image_name="Unread_Chiclet"
-     left="12"
-     name="new_message_icon"
-     visible="false"
-     width="13" />
+  bottom="11"
+  height="14"
+  image_name="Unread_Chiclet"
+  left="12"
+  name="new_message_icon"
+  visible="false"
+  width="14" />
 </chiclet_im_p2p>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_offer.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_offer.xml
index 33f85a964cf..86bea9be504 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_offer.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_offer.xml
@@ -1,22 +1,22 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_offer
- font="SansSerif"
  height="25"
  name="offer_chiclet"
  width="25">
  <chiclet_offer.icon
-  default_icon="Generic_Object_Small" 
+  default_icon="Generic_Object_Small"
   follows="all"
-  height="22"
+  height="20"
   mouse_opaque="false"
   name="chiclet_icon"
-  width="22"/>
+  bottom_pad="2"
+  width="20" />
  <chiclet_offer.new_message_icon
-  bottom="12"
-  height="13"
+  bottom="11"
+  height="14"
   image_name="Unread_Chiclet"
   left="12"
   name="new_message_icon"
   visible="false"
-  width="13" />
+  width="14" />
 </chiclet_offer>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/chiclet_script.xml b/indra/newview/skins/default/xui/en/widgets/chiclet_script.xml
index 560c8e6ea5c..b1f9f5b0e80 100644
--- a/indra/newview/skins/default/xui/en/widgets/chiclet_script.xml
+++ b/indra/newview/skins/default/xui/en/widgets/chiclet_script.xml
@@ -1,22 +1,22 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <chiclet_script
- font="SansSerif"
  height="25"
  name="script_chiclet"
  width="25">
  <chiclet_script.icon
   follows="all"
-  height="22"
-  image_name="Generic_Object_Small" 
+  height="20"
+  image_name="Generic_Object_Small"
   mouse_opaque="false"
   name="chiclet_icon"
-  width="22"/>
+  width="20"
+  bottom_pad="2" />
  <chiclet_script.new_message_icon
-  bottom="12"
-  height="13"
+  bottom="11"
+  height="14"
   image_name="Unread_Chiclet"
   left="12"
   name="new_message_icon"
   visible="false"
-  width="13" />
+  width="14" />
 </chiclet_script>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/widgets/gesture_combo_box.xml b/indra/newview/skins/default/xui/en/widgets/gesture_combo_box.xml
deleted file mode 100644
index 4229f34c09f..00000000000
--- a/indra/newview/skins/default/xui/en/widgets/gesture_combo_box.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<gesture_combo_box
-           label="Gestures" 
-           list_position="below"
-           max_chars="20"
-           follows="right|top">
-  <gesture_combo_box.combo_button name="Combobox Button"
-                          label=""
-                          hover_glow_amount="0.15"
-                          scale_image="true"
-                          image_unselected="ComboButton_Off"
-                          image_selected="ComboButton_Selected"
-                          image_disabled="ComboButton_Disabled"
-                          image_disabled_selected="ComboButton_Disabled_Selected" />
-  <gesture_combo_box.drop_down_button name="Drop Down Button"
-                              label=""
-                              halign="center"
-                              hover_glow_amount="0.15"
-                              scale_image="true"
-                 image_selected="PushButton_Selected_Press"
-                 image_pressed="PushButton_Press"
-		 image_pressed_selected="PushButton_Selected_Press"
-                              image_unselected="PushButton_Off"
-                              image_disabled="PushButton_Disabled"
-                              image_disabled_selected="PushButton_Selected_Disabled" />
-  <gesture_combo_box.combo_list bg_writeable_color="MenuDefaultBgColor"
-                                scroll_bar_bg_visible="false" />
-  <gesture_combo_box.combo_editor name="Combo Text Entry"
-                          select_on_focus="true" />
-</gesture_combo_box>
diff --git a/indra/newview/skins/default/xui/en/widgets/gesture_combo_list.xml b/indra/newview/skins/default/xui/en/widgets/gesture_combo_list.xml
new file mode 100644
index 00000000000..808683864d9
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/widgets/gesture_combo_list.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<gesture_combo_list
+    follows="right|top">
+    <gesture_combo_list.combo_button
+     name="Combolist Button"
+     label=""
+     layout="topleft"
+     halign="center"
+     hover_glow_amount="0.15"
+     mouse_opaque="false"
+     scale_image="true"
+     image_selected="PushButton_Selected_Press"
+     image_pressed="PushButton_Press"
+     image_pressed_selected="PushButton_Selected_Press"
+     image_unselected="PushButton_Off"
+     image_disabled="PushButton_Disabled"
+     image_disabled_selected="PushButton_Selected_Disabled" />
+    <gesture_combo_list.combo_list 
+     bg_writeable_color="MenuDefaultBgColor"
+     scroll_bar_bg_visible="false" />
+</gesture_combo_list>
diff --git a/indra/newview/skins/default/xui/en/widgets/location_input.xml b/indra/newview/skins/default/xui/en/widgets/location_input.xml
index 67bb7c1896f..1c0a8ba7c5e 100644
--- a/indra/newview/skins/default/xui/en/widgets/location_input.xml
+++ b/indra/newview/skins/default/xui/en/widgets/location_input.xml
@@ -96,7 +96,7 @@
     name="damage_icon"
     width="14"
     height="13"
-    top="22"
+    top="25"
     left="2"
     follows="right|top"
     image_name="Parcel_Damage_Dark"
@@ -112,17 +112,19 @@
 	font="SansSerifSmall"
 	text_color="TextFgColor"
 	/>
-
-  <combo_button name="Location History"
-                          label=""
-                          pad_right="0"/>
-  <combo_list bg_writeable_color="MenuDefaultBgColor" page_lines="10"
+  <combo_button
+		name="Location History"
+                label=""
+                pad_right="0"/>
+  <combo_list
+	      bg_writeable_color="MenuDefaultBgColor"
+	      page_lines="10"
               scroll_bar_bg_visible="true" />
   <combo_editor name="Combo Text Entry"
-                text_pad_left="22"
+                text_pad_left="27"
                 select_on_focus="false"
                 font="SansSerifSmall"
                 bevel_style="none"
                 border_style="line"
-                border.border_thickness="0"/>
+                border.border_thickness="0" />
 </location_input>
diff --git a/indra/newview/skins/default/xui/es/floater_buy_currency.xml b/indra/newview/skins/default/xui/es/floater_buy_currency.xml
index eb25493adce..1ecb813dd1e 100644
--- a/indra/newview/skins/default/xui/es/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/es/floater_buy_currency.xml
@@ -52,6 +52,9 @@
 	<text name="total_amount">
 		[AMT] L$
 	</text>
+	<text name="currency_links">
+		[http://www.secondlife.com/my/account/payment_method_management.php?lang=es-ES payment method] | [http://www.secondlife.com/my/account/currency.php?lang=es-ES currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=es-ES exchange rate]
+	</text>
 	<text name="purchase_warning_repurchase" right="-10">
 		Confirmando esta compra sólo compra la moneda.
 Tendrá que intentar de nuevo la operación.
diff --git a/indra/newview/skins/default/xui/fr/floater_buy_currency.xml b/indra/newview/skins/default/xui/fr/floater_buy_currency.xml
index e6a49cbc6fe..9a92c446f25 100644
--- a/indra/newview/skins/default/xui/fr/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/fr/floater_buy_currency.xml
@@ -46,12 +46,12 @@
 		[AMT] L$
 	</text>
 	<text name="currency_links">
-		[http://www.secondlife.com/ payment method] | [http://www.secondlife.com/ currency] | [http://www.secondlife.com exchange rate]
+		[http://www.secondlife.com/my/account/payment_method_management.php?lang=fr-FR payment method] | [http://www.secondlife.com/my/account/currency.php?lang=fr-FR currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=fr-FR exchange rate]
 	</text>
 	<text name="exchange_rate_note">
 		Saisissez à nouveau le montant pour voir le taux de change actuel.
 	</text>
-	<text bottom_delta="-64" height="48" name="purchase_warning_repurchase" right="-10">
+	<text name="purchase_warning_repurchase">
 		La confirmation de cet achat n&apos;achète que des L$, pas l&apos;objet.
 	</text>
 	<text bottom_delta="16" name="purchase_warning_notenough">
diff --git a/indra/newview/skins/default/xui/fr/floater_help_browser.xml b/indra/newview/skins/default/xui/fr/floater_help_browser.xml
index 0eb3ea3d219..20894d42fc3 100644
--- a/indra/newview/skins/default/xui/fr/floater_help_browser.xml
+++ b/indra/newview/skins/default/xui/fr/floater_help_browser.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <floater name="floater_help_browser" title="NAVIGATEUR D&apos;AIDE">
 	<floater.string name="home_page_url">
-		http://www.secondlife.com
+		http://fr.secondlife.com
 	</floater.string>
 	<floater.string name="support_page_url">
-		http://support.secondlife.com
+		http://fr.secondlife.com/support
 	</floater.string>
 	<layout_stack name="stack1">
 		<layout_panel name="external_controls">
diff --git a/indra/newview/skins/default/xui/fr/strings.xml b/indra/newview/skins/default/xui/fr/strings.xml
index 2f0c7038fc0..3ff829bfb7f 100644
--- a/indra/newview/skins/default/xui/fr/strings.xml
+++ b/indra/newview/skins/default/xui/fr/strings.xml
@@ -166,7 +166,7 @@
 	<string name="TooltipSLAPP">
 		Cliquez pour exécuter la commande secondlife:// command
 	</string>
-	<string name="CurrentURL" value="URL actuelle : [CurrentURL]"/>
+	<string name="CurrentURL" value=" URL actuelle : [CurrentURL]"/>
 	<string name="SLurlLabelTeleport">
 		Me téléporter vers
 	</string>
@@ -174,7 +174,7 @@
 		Afficher la carte pour
 	</string>
 	<string name="BUTTON_CLOSE_DARWIN">
-		Fermer (⌘W)
+		Fermer (&#8984;W)
 	</string>
 	<string name="BUTTON_CLOSE_WIN">
 		Fermer (Ctrl+W)
@@ -821,46 +821,46 @@
 	<string name="InventoryNoTexture">
 		Vous n&apos;avez pas de copie de cette texture dans votre inventaire
 	</string>
-	<string name="no_transfer" value="(pas de transfert)"/>
-	<string name="no_modify" value="(pas de modification)"/>
-	<string name="no_copy" value="(pas de copie)"/>
-	<string name="worn" value="(porté)"/>
-	<string name="link" value="(lien)"/>
-	<string name="broken_link" value="(broken_link)"/>
+	<string name="no_transfer" value=" (pas de transfert)"/>
+	<string name="no_modify" value=" (pas de modification)"/>
+	<string name="no_copy" value=" (pas de copie)"/>
+	<string name="worn" value=" (porté)"/>
+	<string name="link" value=" (lien)"/>
+	<string name="broken_link" value=" (broken_link)"/>
 	<string name="LoadingContents">
 		chargement des contenus en cours...
 	</string>
 	<string name="NoContents">
 		Aucun contenu
 	</string>
-	<string name="WornOnAttachmentPoint" value="(porté sur [ATTACHMENT_POINT])"/>
+	<string name="WornOnAttachmentPoint" value=" (porté sur [ATTACHMENT_POINT])"/>
 	<string name="PermYes">
 		Oui
 	</string>
 	<string name="PermNo">
 		Non
 	</string>
-	<string name="Chat" value="Chat :"/>
-	<string name="Sound" value="Son :"/>
-	<string name="Wait" value="--- Attendre :"/>
-	<string name="AnimFlagStop" value="Arrêter l&apos;animation :"/>
-	<string name="AnimFlagStart" value="Démarrer l&apos;animation :"/>
-	<string name="Wave" value="Faire signe"/>
-	<string name="HelloAvatar" value="Bonjour, avatar !"/>
-	<string name="ViewAllGestures" value="Tout afficher &gt;&gt;"/>
-	<string name="Animations" value="Animations,"/>
-	<string name="Calling Cards" value="Cartes de visite,"/>
-	<string name="Clothing" value="Habits,"/>
-	<string name="Gestures" value="Gestes,"/>
-	<string name="Landmarks" value="Repères,"/>
-	<string name="Notecards" value="Notes,"/>
-	<string name="Objects" value="Objets,"/>
-	<string name="Scripts" value="Scripts,"/>
-	<string name="Sounds" value="Sons,"/>
-	<string name="Textures" value="Textures,"/>
-	<string name="Snapshots" value="Photos,"/>
-	<string name="No Filters" value="Non"/>
-	<string name="Since Logoff" value="- Depuis la déconnexion"/>
+	<string name="Chat" value=" Chat :"/>
+	<string name="Sound" value=" Son :"/>
+	<string name="Wait" value=" --- Attendre :"/>
+	<string name="AnimFlagStop" value=" Arrêter l&apos;animation :"/>
+	<string name="AnimFlagStart" value=" Démarrer l&apos;animation :"/>
+	<string name="Wave" value=" Faire signe"/>
+	<string name="HelloAvatar" value=" Bonjour, avatar !"/>
+	<string name="ViewAllGestures" value="  Tout afficher &gt;&gt;"/>
+	<string name="Animations" value=" Animations,"/>
+	<string name="Calling Cards" value=" Cartes de visite,"/>
+	<string name="Clothing" value=" Habits,"/>
+	<string name="Gestures" value=" Gestes,"/>
+	<string name="Landmarks" value=" Repères,"/>
+	<string name="Notecards" value=" Notes,"/>
+	<string name="Objects" value=" Objets,"/>
+	<string name="Scripts" value=" Scripts,"/>
+	<string name="Sounds" value=" Sons,"/>
+	<string name="Textures" value=" Textures,"/>
+	<string name="Snapshots" value=" Photos,"/>
+	<string name="No Filters" value="Non "/>
+	<string name="Since Logoff" value=" - Depuis la déconnexion"/>
 	<string name="InvFolder My Inventory">
 		Mon inventaire
 	</string>
@@ -1239,13 +1239,13 @@
 	<string name="GroupsNone">
 		aucun
 	</string>
-	<string name="Group" value="(groupe)"/>
+	<string name="Group" value=" (groupe)"/>
 	<string name="Unknown">
 		(Inconnu)
 	</string>
-	<string name="SummaryForTheWeek" value="Récapitulatif de la semaine, début le"/>
-	<string name="NextStipendDay" value="Prochaine prime le"/>
-	<string name="GroupIndividualShare" value="Groupe 	 Part individuelle"/>
+	<string name="SummaryForTheWeek" value="Récapitulatif de la semaine, début le "/>
+	<string name="NextStipendDay" value="Prochaine prime le "/>
+	<string name="GroupIndividualShare" value="                      Groupe    Part individuelle"/>
 	<string name="Balance">
 		Solde
 	</string>
@@ -1324,8 +1324,8 @@
 	<string name="covenant_last_modified">
 		Dernière modification :
 	</string>
-	<string name="none_text" value="(aucun)"/>
-	<string name="never_text" value="(jamais)"/>
+	<string name="none_text" value=" (aucun)"/>
+	<string name="never_text" value=" (jamais)"/>
 	<string name="GroupOwned">
 		Propriété du groupe
 	</string>
@@ -1616,7 +1616,7 @@ Si le problème persiste, vous devrez peut-être complètement désinstaller pui
 		Erreur fatale
 	</string>
 	<string name="MBRequiresAltiVec">
-		[APP_NAME] nécessite un microprocesseur AltiVec (version G4 ou antérieure).
+		 [APP_NAME] nécessite un microprocesseur AltiVec (version G4 ou antérieure).
 	</string>
 	<string name="MBAlreadyRunning">
 		[APP_NAME] est déjà en cours d&apos;exécution.
diff --git a/indra/newview/skins/default/xui/it/floater_buy_currency.xml b/indra/newview/skins/default/xui/it/floater_buy_currency.xml
index a22850bc4b9..8a597642516 100644
--- a/indra/newview/skins/default/xui/it/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/it/floater_buy_currency.xml
@@ -52,10 +52,11 @@
 	<text name="total_amount">
 		[AMT]L$
 	</text>
-	<text name="purchase_warning_repurchase" height="48" bottom_delta="-64" right="-10">
-		Confermando questa operazione si acquisterà solo
-la valuta. Per acquistare il bene, dovrai riprovare
-l&apos;operazione nuovamente.
+	<text name="currency_links">
+		[http://www.secondlife.com/my/account/payment_method_management.php?lang=it-IT payment method] | [http://www.secondlife.com/my/account/currency.php?lang=it-IT currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=it-IT exchange rate]
+	</text>
+	<text name="purchase_warning_repurchase">
+		Confermando questa operazione si acquisterà solo la valuta. Per acquistare il bene, dovrai riprovare l&apos;operazione nuovamente.
 	</text>
 	<text name="purchase_warning_notenough" bottom_delta="16">
 		Non stai comprando abbastanza denaro.
diff --git a/indra/newview/skins/default/xui/ja/floater_buy_currency.xml b/indra/newview/skins/default/xui/ja/floater_buy_currency.xml
index 03cd0f391ad..9d49a389822 100644
--- a/indra/newview/skins/default/xui/ja/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/ja/floater_buy_currency.xml
@@ -46,7 +46,7 @@
 		L$ [AMT]
 	</text>
 	<text name="currency_links">
-		[http://www.secondlife.com/ payment method] | [http://www.secondlife.com/ currency] | [http://www.secondlife.com exchange rate]
+		[http://www.secondlife.com/my/account/payment_method_management.php?lang=ja-JP payment method] | [http://www.secondlife.com/my/account/currency.php?lang=ja-JP currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=ja-JP exchange rate]
 	</text>
 	<text name="exchange_rate_note">
 		金額を再入力して最新換算レートを確認します。
diff --git a/indra/newview/skins/default/xui/ja/strings.xml b/indra/newview/skins/default/xui/ja/strings.xml
index 4d395b474f3..b37d97bc5dc 100644
--- a/indra/newview/skins/default/xui/ja/strings.xml
+++ b/indra/newview/skins/default/xui/ja/strings.xml
@@ -166,7 +166,7 @@
 	<string name="TooltipSLAPP">
 		クリックして secondlife:// コマンドを出す
 	</string>
-	<string name="CurrentURL" value="現在のURL: [CurrentURL]"/>
+	<string name="CurrentURL" value=" 現在のURL: [CurrentURL]"/>
 	<string name="SLurlLabelTeleport">
 		テレポート
 	</string>
@@ -174,7 +174,7 @@
 		地図に表示
 	</string>
 	<string name="BUTTON_CLOSE_DARWIN">
-		閉じる (⌘W)
+		閉じる (&#8984;W)
 	</string>
 	<string name="BUTTON_CLOSE_WIN">
 		閉じる (Ctrl+W)
@@ -821,33 +821,33 @@
 	<string name="InventoryNoTexture">
 		持ち物内にこのテクスチャのコピーがありません
 	</string>
-	<string name="no_transfer" value="(再販/プレゼント不可)"/>
-	<string name="no_modify" value="(編集不可)"/>
-	<string name="no_copy" value="(コピー不可)"/>
-	<string name="worn" value="(着用中)"/>
-	<string name="link" value="(リンク)"/>
-	<string name="broken_link" value="(壊れたリンク)"/>
+	<string name="no_transfer" value=" (再販/プレゼント不可)"/>
+	<string name="no_modify" value=" (編集不可)"/>
+	<string name="no_copy" value=" (コピー不可)"/>
+	<string name="worn" value=" (着用中)"/>
+	<string name="link" value=" (リンク)"/>
+	<string name="broken_link" value=" (壊れたリンク)"/>
 	<string name="LoadingContents">
 		コンテンツをロード中です...
 	</string>
 	<string name="NoContents">
 		コンテンツなし
 	</string>
-	<string name="WornOnAttachmentPoint" value="([ATTACHMENT_POINT] に装着中)"/>
+	<string name="WornOnAttachmentPoint" value=" ([ATTACHMENT_POINT] に装着中)"/>
 	<string name="PermYes">
 		はい
 	</string>
 	<string name="PermNo">
 		いいえ
 	</string>
-	<string name="Chat" value="チャット:"/>
-	<string name="Sound" value="サウンド:"/>
-	<string name="Wait" value="--- 待機::"/>
-	<string name="AnimFlagStop" value="アニメーションを停止:"/>
-	<string name="AnimFlagStart" value="アニメーションを開始:"/>
-	<string name="Wave" value="手を振る"/>
-	<string name="HelloAvatar" value="やあ、アバター!"/>
-	<string name="ViewAllGestures" value="すべて表示 &gt;&gt;"/>
+	<string name="Chat" value=" チャット:"/>
+	<string name="Sound" value=" サウンド:"/>
+	<string name="Wait" value=" --- 待機::"/>
+	<string name="AnimFlagStop" value=" アニメーションを停止:"/>
+	<string name="AnimFlagStart" value=" アニメーションを開始:"/>
+	<string name="Wave" value=" 手を振る"/>
+	<string name="HelloAvatar" value=" やあ、アバター!"/>
+	<string name="ViewAllGestures" value="  すべて表示 &gt;&gt;"/>
 	<string name="Animations" value="アニメーション、"/>
 	<string name="Calling Cards" value="コーリングカード、"/>
 	<string name="Clothing" value="衣類、"/>
@@ -859,8 +859,8 @@
 	<string name="Sounds" value="サウンド、"/>
 	<string name="Textures" value="テクスチャ、"/>
 	<string name="Snapshots" value="スナップショット、"/>
-	<string name="No Filters" value="いいえ"/>
-	<string name="Since Logoff" value="- ログオフ以来"/>
+	<string name="No Filters" value="いいえ "/>
+	<string name="Since Logoff" value=" - ログオフ以来"/>
 	<string name="InvFolder My Inventory">
 		マイ 持ち物
 	</string>
@@ -1239,13 +1239,13 @@
 	<string name="GroupsNone">
 		なし
 	</string>
-	<string name="Group" value="(グループ)"/>
+	<string name="Group" value=" (グループ)"/>
 	<string name="Unknown">
 		(不明)
 	</string>
 	<string name="SummaryForTheWeek" value="今週のまとめ。開始日は"/>
 	<string name="NextStipendDay" value="次回のお小遣い支給日は"/>
-	<string name="GroupIndividualShare" value="グループ   個人の割り当て"/>
+	<string name="GroupIndividualShare" value="                      グループ       個人の割り当て"/>
 	<string name="Balance">
 		残高
 	</string>
@@ -1324,8 +1324,8 @@
 	<string name="covenant_last_modified">
 		最終修正日:
 	</string>
-	<string name="none_text" value="(なし)"/>
-	<string name="never_text" value="(無)"/>
+	<string name="none_text" value=" (なし)"/>
+	<string name="never_text" value=" (無)"/>
 	<string name="GroupOwned">
 		グループ所有
 	</string>
@@ -1616,7 +1616,7 @@
 		致命的なエラー
 	</string>
 	<string name="MBRequiresAltiVec">
-		[APP_NAME] は、AltiVec搭載のプロセッサが必要です。(G4 以降)
+		 [APP_NAME] は、AltiVec搭載のプロセッサが必要です。(G4 以降)
 	</string>
 	<string name="MBAlreadyRunning">
 		[APP_NAME] はすでに実行中です。
diff --git a/indra/newview/skins/default/xui/pt/floater_buy_currency.xml b/indra/newview/skins/default/xui/pt/floater_buy_currency.xml
index aac8438fdcf..f17c069ecf0 100644
--- a/indra/newview/skins/default/xui/pt/floater_buy_currency.xml
+++ b/indra/newview/skins/default/xui/pt/floater_buy_currency.xml
@@ -52,6 +52,9 @@
 	<text name="total_amount">
 		L$ [AMT]
 	</text>
+	<text name="currency_links">
+		[http://www.secondlife.com/my/account/payment_method_management.php?lang=pt-BR payment method] | [http://www.secondlife.com/my/account/currency.php?lang=pt-BR currency] | [http://www.secondlife.com/my/account/exchange_rates.php?lang=pt-BR exchange rate]
+	</text>
 	<text name="purchase_warning_repurchase">
 		Confirmando esta compra só compra a moeda.
 Você precisará tentar novamente a operação.
diff --git a/install.xml b/install.xml
index 41f8a28044c..e912ddfd8b0 100644
--- a/install.xml
+++ b/install.xml
@@ -1014,23 +1014,23 @@ anguage Infrstructure (CLI) international standard</string>
           <key>darwin</key>
           <map>
             <key>md5sum</key>
-            <string>5362a53488693f9bd7d9083758af25eb</string>
+            <string>2eb58f544c0d912aa382de2c947be7f1</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-4.6-darwin-20091218.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-4.6-darwin-20100104.tar.bz2</uri>
           </map>
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>09674cbae982e7e7f6ebc7e1d06580e8</string>
+            <string>c4c40fca14a8bd32096f8a27c75c526f</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-linux-20091216.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-linux-20100105c.tar.bz2</uri>
           </map>
           <key>windows</key>
           <map>
             <key>md5sum</key>
-            <string>4dd305f2ce38b2e55a2014ad3a2de34d</string>
+            <string>b50db4fdb833111e1e679188e4cb5815</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-windows-qt4.6-20091218.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/llqtwebkit-windows-qt4.6-20100104.tar.bz2</uri>
           </map>
         </map>
       </map>
-- 
GitLab


From d3e84ea77baa7d60fe225f7b440297e9a49318a6 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 20 Jan 2010 15:08:29 -0600
Subject: [PATCH 056/683] First stab at making model importer act more like
 scene importer.  Upload button still doesn't work.

---
 indra/llmath/m4math.cpp | 17 +++++++++++++++++
 indra/llmath/m4math.h   |  1 +
 2 files changed, 18 insertions(+)

diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp
index 7c7f60154da..37001429824 100644
--- a/indra/llmath/m4math.cpp
+++ b/indra/llmath/m4math.cpp
@@ -785,6 +785,23 @@ bool operator!=(const LLMatrix4 &a, const LLMatrix4 &b)
 	return FALSE;
 }
 
+bool operator<(const LLMatrix4& a, const LLMatrix4 &b)
+{
+	U32		i, j;
+	for (i = 0; i < NUM_VALUES_IN_MAT4; i++)
+	{
+		for (j = 0; j < NUM_VALUES_IN_MAT4; j++)
+		{
+			if (a.mMatrix[i][j] != b.mMatrix[i][j])
+			{
+				return a.mMatrix[i][j] < b.mMatrix[i][j];
+			}
+		}
+	}
+
+	return false;
+}
+
 const LLMatrix4& operator*=(LLMatrix4 &a, F32 k)
 {
 	U32		i, j;
diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h
index de981b76466..6007b96bd9a 100644
--- a/indra/llmath/m4math.h
+++ b/indra/llmath/m4math.h
@@ -237,6 +237,7 @@ class LLMatrix4
 
 	friend bool operator==(const LLMatrix4 &a, const LLMatrix4 &b);			// Return a == b
 	friend bool operator!=(const LLMatrix4 &a, const LLMatrix4 &b);			// Return a != b
+	friend bool operator<(const LLMatrix4 &a, const LLMatrix4& b);			// Return a < b
 
 	friend const LLMatrix4& operator+=(LLMatrix4 &a, const LLMatrix4 &b);	// Return a + b
 	friend const LLMatrix4& operator-=(LLMatrix4 &a, const LLMatrix4 &b);	// Return a - b
-- 
GitLab


From f4b2de0d058d691afbb45315604c39dc05686586 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 20 Jan 2010 15:20:57 -0800
Subject: [PATCH 057/683] curse of the random coding policy hook.

---
 scripts/template_verifier.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/template_verifier.py b/scripts/template_verifier.py
index d5fc1192700..adcfcbcae63 100755
--- a/scripts/template_verifier.py
+++ b/scripts/template_verifier.py
@@ -103,7 +103,7 @@ def die(msg):
 PRODUCTION_ACCEPTABLE = (compatibility.Same, compatibility.Newer)
 DEVELOPMENT_ACCEPTABLE = (
     compatibility.Same, compatibility.Newer,
-    compatibility.Older, compatibility.Mixed)	
+    compatibility.Older, compatibility.Mixed)
 
 MAX_MASTER_AGE = 60 * 60 * 4   # refresh master cache every 4 hours
 
-- 
GitLab


From c3b37faba3cba425d749345a978ddec16bbd1338 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 16:20:06 -0800
Subject: [PATCH 058/683] first dribble of directional lights for shaderless
 path.

---
 indra/newview/pipeline.cpp | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index d66662ed49a..bced8a8e077 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4596,8 +4596,22 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
 			glLightf (gllight, GL_LINEAR_ATTENUATION,     atten);
 			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  quad);
-			glLightf (gllight, GL_SPOT_EXPONENT,          0.0f);
-			glLightf (gllight, GL_SPOT_CUTOFF,            180.0f);
+			if (light->getLightTexture()) // directional (spot-)light
+			{
+				LLVector3 spotparams = light->getSpotLightParams();
+				LLQuaternion quat = light->getRenderRotation();
+				LLVector3 at_axis(0,0,-1); // todo: verify against deferred
+				at_axis *= quat;
+				llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
+				glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
+				glLightf (gllight, GL_SPOT_EXPONENT,  0.0f); // fixme - focus
+				glLightf (gllight, GL_SPOT_CUTOFF,    22.0f); // fixme - fov
+			}
+			else // omnidirectional (point) light
+			{
+				glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
+				glLightf (gllight, GL_SPOT_CUTOFF,   180.0f);
+			}
 			cur_light++;
 			if (cur_light >= 8)
 			{
@@ -4613,7 +4627,6 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 		glLightfv(gllight, GL_AMBIENT,  LLColor4::black.mV);
 		glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 	}
-
 	if (gAgent.getAvatarObject() &&
 		gAgent.getAvatarObject()->mSpecialRenderMode == 3)
 	{
-- 
GitLab


From ec2eae01fa5f9f47492035537f9ddbee86471a84 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 16:20:06 -0800
Subject: [PATCH 059/683] first dribble of directional lights for shaderless
 path.

---
 indra/newview/pipeline.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 5940b354f48..060e8545aba 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4567,8 +4567,22 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
 			glLightf (gllight, GL_LINEAR_ATTENUATION,     atten);
 			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  quad);
-			glLightf (gllight, GL_SPOT_EXPONENT,          0.0f);
-			glLightf (gllight, GL_SPOT_CUTOFF,            180.0f);
+			if (light->getLightTexture()) // directional (spot-)light
+			{
+				LLVector3 spotparams = light->getSpotLightParams();
+				LLQuaternion quat = light->getRenderRotation();
+				LLVector3 at_axis(0,0,-1); // todo: verify against deferred
+				at_axis *= quat;
+				llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
+				glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
+				glLightf (gllight, GL_SPOT_EXPONENT,  0.0f); // fixme - focus
+				glLightf (gllight, GL_SPOT_CUTOFF,    22.0f); // fixme - fov
+			}
+			else // omnidirectional (point) light
+			{
+				glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
+				glLightf (gllight, GL_SPOT_CUTOFF,   180.0f);
+			}
 			cur_light++;
 			if (cur_light >= 8)
 			{
-- 
GitLab


From 73c98e1c1e3899aaae1de6bac51f9e21ea6432a1 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 18:01:12 -0800
Subject: [PATCH 060/683] enable basic directional lighting for
 basic/atmospheric shaders - yay.

next, needs the non-shader GL lighting model to be equally dumb (it's too smart - kill the spot angle.
---
 .../shaders/class1/lighting/lightFuncV.glsl   | 21 +++++++++++++++++++
 .../shaders/class2/lighting/sumLightsV.glsl   |  8 ++++---
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 3e8fdfb3e48..211de830fae 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -28,7 +28,28 @@ float calcPointLight(vec3 v, vec3 n, vec4 lp, float la)
 	
 	//angular attenuation
 	da *= calcDirectionalLight(n, lv);
+
+	return da;	
+}
+
+
+float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la)
+{
+	//get light vector
+	vec3 lv = lp.xyz-v;
 	
+	//get distance
+	float d = length(lv);
+	
+	//normalize light vector
+	lv *= 1.0/d;
+	
+	//distance attenuation
+	float da = clamp(1.0/(la * d), 0.0, 1.0);
+	
+	//angular attenuation
+	da *= dot(lv, -ln) * calcDirectionalLight(n, lv);
+
 	return da;	
 }
 
diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index f4c59734a47..fd264b9e747 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -7,6 +7,7 @@
 
 float calcDirectionalLight(vec3 n, vec3 l);
 float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -18,9 +19,10 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[1].diffuse.rgb * calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
-	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
+
+	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation);
+	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation);
+	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation);
 	col.rgb = scaleDownLight(col.rgb);
 
 	// Add windlight lights
-- 
GitLab


From b7aa0ce2446dfa586f4727d537cdf02fb643fbe9 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 18:01:12 -0800
Subject: [PATCH 061/683] enable basic directional lighting for
 basic/atmospheric shaders - yay.

next, needs the non-shader GL lighting model to be equally dumb (it's too smart - kill the spot angle.
---
 .../shaders/class1/lighting/lightFuncV.glsl   | 21 +++++++++++++++++++
 .../shaders/class2/lighting/sumLightsV.glsl   |  8 ++++---
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 3e8fdfb3e48..211de830fae 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -28,7 +28,28 @@ float calcPointLight(vec3 v, vec3 n, vec4 lp, float la)
 	
 	//angular attenuation
 	da *= calcDirectionalLight(n, lv);
+
+	return da;	
+}
+
+
+float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la)
+{
+	//get light vector
+	vec3 lv = lp.xyz-v;
 	
+	//get distance
+	float d = length(lv);
+	
+	//normalize light vector
+	lv *= 1.0/d;
+	
+	//distance attenuation
+	float da = clamp(1.0/(la * d), 0.0, 1.0);
+	
+	//angular attenuation
+	da *= dot(lv, -ln) * calcDirectionalLight(n, lv);
+
 	return da;	
 }
 
diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index f4c59734a47..fd264b9e747 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -7,6 +7,7 @@
 
 float calcDirectionalLight(vec3 n, vec3 l);
 float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -18,9 +19,10 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[1].diffuse.rgb * calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
-	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
+
+	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation);
+	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation);
+	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation);
 	col.rgb = scaleDownLight(col.rgb);
 
 	// Add windlight lights
-- 
GitLab


From cf3df7968ef654ba7cafeafd463e7107b80ca07f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 18:21:33 -0800
Subject: [PATCH 062/683] woo, dumb GL lights now match up to our dumb shader
 model pretty well.

next: shader model needs to grok point vs directional, shader model needs to resurrect ambient which I seem to have broken
---
 indra/newview/pipeline.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index bced8a8e077..71f9ce7eb2e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4284,7 +4284,7 @@ void LLPipeline::setupAvatarLights(BOOL for_edit)
 		glLightf (GL_LIGHT1, GL_LINEAR_ATTENUATION, 	 0.0f);
 		glLightf (GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.0f);
 		glLightf (GL_LIGHT1, GL_SPOT_EXPONENT, 		 0.0f);
-		glLightf (GL_LIGHT1, GL_SPOT_CUTOFF, 			 180.0f);
+		glLightf (GL_LIGHT1, GL_SPOT_CUTOFF,		 180.0f);
 	}
 	else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini)
 	{
@@ -4600,12 +4600,12 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			{
 				LLVector3 spotparams = light->getSpotLightParams();
 				LLQuaternion quat = light->getRenderRotation();
-				LLVector3 at_axis(0,0,-1); // todo: verify against deferred
+				LLVector3 at_axis(0,0,-1); // this matches deferred rendering's object light direction
 				at_axis *= quat;
 				llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
 				glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
-				glLightf (gllight, GL_SPOT_EXPONENT,  0.0f); // fixme - focus
-				glLightf (gllight, GL_SPOT_CUTOFF,    22.0f); // fixme - fov
+				glLightf (gllight, GL_SPOT_EXPONENT,  1.0f); // 1.0 = good old dot product
+				glLightf (gllight, GL_SPOT_CUTOFF,    90.0f); // hemisphere
 			}
 			else // omnidirectional (point) light
 			{
-- 
GitLab


From 941026459ddfdbc7dd8a7324b706ad404751592e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 18:21:33 -0800
Subject: [PATCH 063/683] woo, dumb GL lights now match up to our dumb shader
 model pretty well.

next: shader model needs to grok point vs directional, shader model needs to resurrect ambient which I seem to have broken
---
 indra/newview/pipeline.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 060e8545aba..891f83e8775 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4255,7 +4255,7 @@ void LLPipeline::setupAvatarLights(BOOL for_edit)
 		glLightf (GL_LIGHT1, GL_LINEAR_ATTENUATION, 	 0.0f);
 		glLightf (GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.0f);
 		glLightf (GL_LIGHT1, GL_SPOT_EXPONENT, 		 0.0f);
-		glLightf (GL_LIGHT1, GL_SPOT_CUTOFF, 			 180.0f);
+		glLightf (GL_LIGHT1, GL_SPOT_CUTOFF,		 180.0f);
 	}
 	else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini)
 	{
@@ -4571,12 +4571,12 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			{
 				LLVector3 spotparams = light->getSpotLightParams();
 				LLQuaternion quat = light->getRenderRotation();
-				LLVector3 at_axis(0,0,-1); // todo: verify against deferred
+				LLVector3 at_axis(0,0,-1); // this matches deferred rendering's object light direction
 				at_axis *= quat;
 				llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
 				glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
-				glLightf (gllight, GL_SPOT_EXPONENT,  0.0f); // fixme - focus
-				glLightf (gllight, GL_SPOT_CUTOFF,    22.0f); // fixme - fov
+				glLightf (gllight, GL_SPOT_EXPONENT,  1.0f); // 1.0 = good old dot product
+				glLightf (gllight, GL_SPOT_CUTOFF,    90.0f); // hemisphere
 			}
 			else // omnidirectional (point) light
 			{
-- 
GitLab


From c413a0e096f8897ddc4ee5b5a627e6bf6cce39bb Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 18:36:04 -0800
Subject: [PATCH 064/683] fix the shader dp light going negative!

---
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 211de830fae..0f03e336be2 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la)
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
 	//angular attenuation
-	da *= dot(lv, -ln) * calcDirectionalLight(n, lv);
+	da *= calcDirectionalLight(-ln, lv) * calcDirectionalLight(n, lv);
 
 	return da;	
 }
-- 
GitLab


From 4c8266e0a25648cb346400119b0c5ad96de0627c Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 18:36:04 -0800
Subject: [PATCH 065/683] fix the shader dp light going negative!

---
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 211de830fae..0f03e336be2 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la)
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
 	//angular attenuation
-	da *= dot(lv, -ln) * calcDirectionalLight(n, lv);
+	da *= calcDirectionalLight(-ln, lv) * calcDirectionalLight(n, lv);
 
 	return da;	
 }
-- 
GitLab


From f773b6ef9669bab6765678f8b07831144dd44a5e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 18:50:10 -0800
Subject: [PATCH 066/683] cheaply resurrect the difference between spotlight
 and omnidirectional, as far as the shader is concerned.

not complete.
---
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl    | 4 ++--
 indra/newview/pipeline.cpp                                  | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 0f03e336be2..b2d6d23b1e1 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -33,7 +33,7 @@ float calcPointLight(vec3 v, vec3 n, vec4 lp, float la)
 }
 
 
-float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la)
+float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional)
 {
 	//get light vector
 	vec3 lv = lp.xyz-v;
@@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la)
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
 	//angular attenuation
-	da *= calcDirectionalLight(-ln, lv) * calcDirectionalLight(n, lv);
+	da *= clamp(dot(-ln, lv)+is_omnidirectional, 0.0, 1.0) * calcDirectionalLight(n, lv);
 
 	return da;	
 }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 71f9ce7eb2e..6cd8b944053 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4592,7 +4592,6 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
 			glLightfv(gllight, GL_DIFFUSE,  light_color.mV);
 			glLightfv(gllight, GL_AMBIENT,  LLColor4::black.mV);
-			glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
 			glLightf (gllight, GL_LINEAR_ATTENUATION,     atten);
 			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  quad);
@@ -4606,11 +4605,16 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 				glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
 				glLightf (gllight, GL_SPOT_EXPONENT,  1.0f); // 1.0 = good old dot product
 				glLightf (gllight, GL_SPOT_CUTOFF,    90.0f); // hemisphere
+				glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 			}
 			else // omnidirectional (point) light
 			{
 				glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
 				glLightf (gllight, GL_SPOT_CUTOFF,   180.0f);
+
+				// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
+				const float specular = {0.f, 0.f, 0.f, 1.f},
+				glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 			}
 			cur_light++;
 			if (cur_light >= 8)
-- 
GitLab


From ae75d7b9dc3bac4a77068a3c7551ff70e8759a44 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 18:50:10 -0800
Subject: [PATCH 067/683] cheaply resurrect the difference between spotlight
 and omnidirectional, as far as the shader is concerned.

not complete.
---
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl    | 4 ++--
 indra/newview/pipeline.cpp                                  | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 0f03e336be2..b2d6d23b1e1 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -33,7 +33,7 @@ float calcPointLight(vec3 v, vec3 n, vec4 lp, float la)
 }
 
 
-float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la)
+float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional)
 {
 	//get light vector
 	vec3 lv = lp.xyz-v;
@@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la)
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
 	//angular attenuation
-	da *= calcDirectionalLight(-ln, lv) * calcDirectionalLight(n, lv);
+	da *= clamp(dot(-ln, lv)+is_omnidirectional, 0.0, 1.0) * calcDirectionalLight(n, lv);
 
 	return da;	
 }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 891f83e8775..2a1ed1b5ab2 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4563,7 +4563,6 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
 			glLightfv(gllight, GL_DIFFUSE,  light_color.mV);
 			glLightfv(gllight, GL_AMBIENT,  LLColor4::black.mV);
-			glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
 			glLightf (gllight, GL_LINEAR_ATTENUATION,     atten);
 			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  quad);
@@ -4577,11 +4576,16 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 				glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
 				glLightf (gllight, GL_SPOT_EXPONENT,  1.0f); // 1.0 = good old dot product
 				glLightf (gllight, GL_SPOT_CUTOFF,    90.0f); // hemisphere
+				glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 			}
 			else // omnidirectional (point) light
 			{
 				glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
 				glLightf (gllight, GL_SPOT_CUTOFF,   180.0f);
+
+				// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
+				const float specular = {0.f, 0.f, 0.f, 1.f},
+				glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 			}
 			cur_light++;
 			if (cur_light >= 8)
-- 
GitLab


From bc0a9fd5fe0675d7327ee182ff4ac20c39e76305 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 21:48:22 -0800
Subject: [PATCH 068/683] getting closer to point/spot interchangability

---
 .../app_settings/shaders/class2/lighting/sumLightsV.glsl    | 6 +++---
 indra/newview/pipeline.cpp                                  | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index fd264b9e747..e5bf76db555 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -20,9 +20,9 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[1].diffuse.rgb * calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 
-	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation);
-	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
 	col.rgb = scaleDownLight(col.rgb);
 
 	// Add windlight lights
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 6cd8b944053..e12412c58c8 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4613,8 +4613,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 				glLightf (gllight, GL_SPOT_CUTOFF,   180.0f);
 
 				// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
-				const float specular = {0.f, 0.f, 0.f, 1.f},
-				glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
+				const float specular[] = {0.f, 0.f, 0.f, 1.f};
+				glLightfv(gllight, GL_SPECULAR, specular);
 			}
 			cur_light++;
 			if (cur_light >= 8)
-- 
GitLab


From 1bf2a13835572e30e6fa7c73bf7c6d58b56f81a4 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 21:48:22 -0800
Subject: [PATCH 069/683] getting closer to point/spot interchangability

---
 .../app_settings/shaders/class2/lighting/sumLightsV.glsl    | 6 +++---
 indra/newview/pipeline.cpp                                  | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index fd264b9e747..e5bf76db555 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -20,9 +20,9 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[1].diffuse.rgb * calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 
-	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation);
-	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
 	col.rgb = scaleDownLight(col.rgb);
 
 	// Add windlight lights
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2a1ed1b5ab2..3dc175d7231 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4584,8 +4584,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 				glLightf (gllight, GL_SPOT_CUTOFF,   180.0f);
 
 				// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
-				const float specular = {0.f, 0.f, 0.f, 1.f},
-				glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
+				const float specular[] = {0.f, 0.f, 0.f, 1.f};
+				glLightfv(gllight, GL_SPECULAR, specular);
 			}
 			cur_light++;
 			if (cur_light >= 8)
-- 
GitLab


From 1237c123873b98f2987d8d9fb573f6f88f8eebc2 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 21:49:31 -0800
Subject: [PATCH 070/683] cheaper, cuter way to deal with spot vs point in the
 shader

---
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index b2d6d23b1e1..4525bf80b28 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnid
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
 	//angular attenuation
-	da *= clamp(dot(-ln, lv)+is_omnidirectional, 0.0, 1.0) * calcDirectionalLight(n, lv);
+	da *= max(dot(-ln, lv),is_omnidirectional) * calcDirectionalLight(n, lv);
 
 	return da;	
 }
-- 
GitLab


From 5a1cf512e9f7dbb3b95542bba1f5019e4cd4f9cd Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 21:49:31 -0800
Subject: [PATCH 071/683] cheaper, cuter way to deal with spot vs point in the
 shader

---
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index b2d6d23b1e1..4525bf80b28 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnid
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
 	//angular attenuation
-	da *= clamp(dot(-ln, lv)+is_omnidirectional, 0.0, 1.0) * calcDirectionalLight(n, lv);
+	da *= max(dot(-ln, lv),is_omnidirectional) * calcDirectionalLight(n, lv);
 
 	return da;	
 }
-- 
GitLab


From fcaca49a9496154419a8f44c17cba16b028d3518 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 23:58:50 -0800
Subject: [PATCH 072/683] cheap no-branch goodness for rendering both
 spotlights and pointlights with the same shader code.

kill already-nerfed quadratic attenuation which it seems we won't be supporting any decade soon.
---
 .../shaders/class1/lighting/lightFuncV.glsl   |  6 ++-
 .../shaders/class2/lighting/sumLightsV.glsl   |  2 +-
 indra/newview/pipeline.cpp                    | 42 +++++++------------
 3 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 4525bf80b28..2e41f24afed 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -47,8 +47,12 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnid
 	//distance attenuation
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
+	// spotlight coefficient.
+	float spot = max(dot(-ln, lv), is_omnidirectional);
+	da *= spot*spot; // GL_SPOT_EXPONENT=2
+
 	//angular attenuation
-	da *= max(dot(-ln, lv),is_omnidirectional) * calcDirectionalLight(n, lv);
+	da *= calcDirectionalLight(n, lv);
 
 	return da;	
 }
diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index e5bf76db555..4577b4be555 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -7,7 +7,7 @@
 
 float calcDirectionalLight(vec3 n, vec3 l);
 float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
-float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la);
+float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e12412c58c8..2ad0bad11fc 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4572,40 +4572,30 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			LLVector4 light_pos_gl(light_pos, 1.0f);
 	
 			F32 light_radius = llmax(light->getLightRadius(), 0.001f);
-			F32 atten, quad;
 
-#if 0 //1.9.1
-			if (pool->getVertexShaderLevel() > 0)
-			{
-				atten = light_radius;
-				quad = llmax(light->getLightFalloff(), 0.0001f);
-			}
-			else
-#endif
-			{
-				F32 x = (3.f * (1.f + light->getLightFalloff()));
-				atten = x / (light_radius); // % of brightness at radius
-				quad = 0.0f;
-			}
+			F32 x = (3.f * (1.f + light->getLightFalloff()));
+			float linatten = x / (light_radius); // % of brightness at radius
+
 			mHWLightColors[cur_light] = light_color;
 			S32 gllight = GL_LIGHT0+cur_light;
 			glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
 			glLightfv(gllight, GL_DIFFUSE,  light_color.mV);
 			glLightfv(gllight, GL_AMBIENT,  LLColor4::black.mV);
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
-			glLightf (gllight, GL_LINEAR_ATTENUATION,     atten);
-			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  quad);
+			glLightf (gllight, GL_LINEAR_ATTENUATION,     linatten);
+			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  0.0f);
 			if (light->getLightTexture()) // directional (spot-)light
 			{
 				LLVector3 spotparams = light->getSpotLightParams();
 				LLQuaternion quat = light->getRenderRotation();
 				LLVector3 at_axis(0,0,-1); // this matches deferred rendering's object light direction
 				at_axis *= quat;
-				llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
+				//llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
 				glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
-				glLightf (gllight, GL_SPOT_EXPONENT,  1.0f); // 1.0 = good old dot product
+				glLightf (gllight, GL_SPOT_EXPONENT,  2.0f); // 2.0 = good old dot product ^ 2
 				glLightf (gllight, GL_SPOT_CUTOFF,    90.0f); // hemisphere
-				glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
+				const float specular[] = {0.f, 0.f, 0.f, 0.f};
+				glLightfv(gllight, GL_SPECULAR, specular);
 			}
 			else // omnidirectional (point) light
 			{
@@ -4615,6 +4605,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 				// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
 				const float specular[] = {0.f, 0.f, 0.f, 1.f};
 				glLightfv(gllight, GL_SPECULAR, specular);
+				//llinfos << "boring light" << llendl;
 			}
 			cur_light++;
 			if (cur_light >= 8)
@@ -4641,13 +4632,10 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 		LLVector4 light_pos_gl(light_pos, 1.0f);
 
 		F32 light_radius = 16.f;
-		F32 atten, quad;
 
-		{
-			F32 x = 3.f;
-			atten = x / (light_radius); // % of brightness at radius
-			quad = 0.0f;
-		}
+		F32 x = 3.f;
+		float linatten = x / (light_radius); // % of brightness at radius
+
 		mHWLightColors[2] = light_color;
 		S32 gllight = GL_LIGHT2;
 		glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
@@ -4655,8 +4643,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 		glLightfv(gllight, GL_AMBIENT,  LLColor4::black.mV);
 		glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 		glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
-		glLightf (gllight, GL_LINEAR_ATTENUATION,     atten);
-		glLightf (gllight, GL_QUADRATIC_ATTENUATION,  quad);
+		glLightf (gllight, GL_LINEAR_ATTENUATION,     linatten);
+		glLightf (gllight, GL_QUADRATIC_ATTENUATION,  0.0f);
 		glLightf (gllight, GL_SPOT_EXPONENT,          0.0f);
 		glLightf (gllight, GL_SPOT_CUTOFF,            180.0f);
 	}
-- 
GitLab


From 7e7331c0e5213ecfe4f563786239e497c197c630 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 28 Jan 2010 23:58:50 -0800
Subject: [PATCH 073/683] cheap no-branch goodness for rendering both
 spotlights and pointlights with the same shader code.

kill already-nerfed quadratic attenuation which it seems we won't be supporting any decade soon.
---
 .../shaders/class1/lighting/lightFuncV.glsl   |  6 ++-
 .../shaders/class2/lighting/sumLightsV.glsl   |  2 +-
 indra/newview/pipeline.cpp                    | 42 +++++++------------
 3 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 4525bf80b28..2e41f24afed 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -47,8 +47,12 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnid
 	//distance attenuation
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
+	// spotlight coefficient.
+	float spot = max(dot(-ln, lv), is_omnidirectional);
+	da *= spot*spot; // GL_SPOT_EXPONENT=2
+
 	//angular attenuation
-	da *= max(dot(-ln, lv),is_omnidirectional) * calcDirectionalLight(n, lv);
+	da *= calcDirectionalLight(n, lv);
 
 	return da;	
 }
diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index e5bf76db555..4577b4be555 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -7,7 +7,7 @@
 
 float calcDirectionalLight(vec3 n, vec3 l);
 float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
-float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la);
+float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 3dc175d7231..1ef5b5ded16 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4543,40 +4543,30 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			LLVector4 light_pos_gl(light_pos, 1.0f);
 	
 			F32 light_radius = llmax(light->getLightRadius(), 0.001f);
-			F32 atten, quad;
 
-#if 0 //1.9.1
-			if (pool->getVertexShaderLevel() > 0)
-			{
-				atten = light_radius;
-				quad = llmax(light->getLightFalloff(), 0.0001f);
-			}
-			else
-#endif
-			{
-				F32 x = (3.f * (1.f + light->getLightFalloff()));
-				atten = x / (light_radius); // % of brightness at radius
-				quad = 0.0f;
-			}
+			F32 x = (3.f * (1.f + light->getLightFalloff()));
+			float linatten = x / (light_radius); // % of brightness at radius
+
 			mHWLightColors[cur_light] = light_color;
 			S32 gllight = GL_LIGHT0+cur_light;
 			glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
 			glLightfv(gllight, GL_DIFFUSE,  light_color.mV);
 			glLightfv(gllight, GL_AMBIENT,  LLColor4::black.mV);
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
-			glLightf (gllight, GL_LINEAR_ATTENUATION,     atten);
-			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  quad);
+			glLightf (gllight, GL_LINEAR_ATTENUATION,     linatten);
+			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  0.0f);
 			if (light->getLightTexture()) // directional (spot-)light
 			{
 				LLVector3 spotparams = light->getSpotLightParams();
 				LLQuaternion quat = light->getRenderRotation();
 				LLVector3 at_axis(0,0,-1); // this matches deferred rendering's object light direction
 				at_axis *= quat;
-				llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
+				//llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
 				glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
-				glLightf (gllight, GL_SPOT_EXPONENT,  1.0f); // 1.0 = good old dot product
+				glLightf (gllight, GL_SPOT_EXPONENT,  2.0f); // 2.0 = good old dot product ^ 2
 				glLightf (gllight, GL_SPOT_CUTOFF,    90.0f); // hemisphere
-				glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
+				const float specular[] = {0.f, 0.f, 0.f, 0.f};
+				glLightfv(gllight, GL_SPECULAR, specular);
 			}
 			else // omnidirectional (point) light
 			{
@@ -4586,6 +4576,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 				// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
 				const float specular[] = {0.f, 0.f, 0.f, 1.f};
 				glLightfv(gllight, GL_SPECULAR, specular);
+				//llinfos << "boring light" << llendl;
 			}
 			cur_light++;
 			if (cur_light >= 8)
@@ -4613,13 +4604,10 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 		LLVector4 light_pos_gl(light_pos, 1.0f);
 
 		F32 light_radius = 16.f;
-		F32 atten, quad;
 
-		{
-			F32 x = 3.f;
-			atten = x / (light_radius); // % of brightness at radius
-			quad = 0.0f;
-		}
+		F32 x = 3.f;
+		float linatten = x / (light_radius); // % of brightness at radius
+
 		mHWLightColors[2] = light_color;
 		S32 gllight = GL_LIGHT2;
 		glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
@@ -4627,8 +4615,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 		glLightfv(gllight, GL_AMBIENT,  LLColor4::black.mV);
 		glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
 		glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
-		glLightf (gllight, GL_LINEAR_ATTENUATION,     atten);
-		glLightf (gllight, GL_QUADRATIC_ATTENUATION,  quad);
+		glLightf (gllight, GL_LINEAR_ATTENUATION,     linatten);
+		glLightf (gllight, GL_QUADRATIC_ATTENUATION,  0.0f);
 		glLightf (gllight, GL_SPOT_EXPONENT,          0.0f);
 		glLightf (gllight, GL_SPOT_CUTOFF,            180.0f);
 	}
-- 
GitLab


From d0cf5b03f4fec29db367d8f1f387f2b0996f67e6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 29 Jan 2010 00:22:13 -0800
Subject: [PATCH 074/683] spot-aware light func usage in ALL shaders.

---
 .../shaders/class1/deferred/alphaV.glsl       | 14 ++++++------
 .../shaders/class1/deferred/avatarAlphaV.glsl | 14 ++++++------
 .../shaders/class1/lighting/lightFuncV.glsl   | 22 +------------------
 .../shaders/class2/deferred/alphaV.glsl       | 14 ++++++------
 .../shaders/class2/deferred/avatarAlphaV.glsl | 14 ++++++------
 .../shaders/class2/lighting/sumLightsV.glsl   |  9 ++++----
 .../shaders/class3/lighting/sumLightsV.glsl   | 15 +++++++------
 7 files changed, 41 insertions(+), 61 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 1a7d58b07ba..91793a29d3d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -9,7 +9,7 @@ vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
 void calcAtmospherics(vec3 inPositionEye);
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -49,12 +49,12 @@ void main()
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index c1988d3c783..e36564df108 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -10,7 +10,7 @@ mat4 getSkinnedTransform();
 void calcAtmospherics(vec3 inPositionEye);
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -55,12 +55,12 @@ void main()
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 2e41f24afed..d0f58cc1a4f 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -12,28 +12,8 @@ float calcDirectionalLight(vec3 n, vec3 l)
 	return a;
 }
 
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = length(lv);
-	
-	//normalize light vector
-	lv *= 1.0/d;
-	
-	//distance attenuation
-	float da = clamp(1.0/(la * d), 0.0, 1.0);
-	
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
-
-	return da;	
-}
-
 
-float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional)
+float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
 {
 	//get light vector
 	vec3 lv = lp.xyz-v;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index 5991e1f3b5e..eec655e3dfe 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -9,7 +9,7 @@ vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
 void calcAtmospherics(vec3 inPositionEye);
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -50,12 +50,12 @@ void main()
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index a939499b171..488bd677e10 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -10,7 +10,7 @@ mat4 getSkinnedTransform();
 void calcAtmospherics(vec3 inPositionEye);
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -61,12 +61,12 @@ void main()
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index 4577b4be555..19800d96dc6 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -6,8 +6,7 @@
  */
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
-float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -20,9 +19,9 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[1].diffuse.rgb * calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 
-	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
-	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
-	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLightOrSpotLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLightOrSpotLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLightOrSpotLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
 	col.rgb = scaleDownLight(col.rgb);
 
 	// Add windlight lights
diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
index 1c5234c4502..0fdfdf2ddea 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
@@ -6,7 +6,7 @@
  */
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -24,12 +24,13 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 				
-- 
GitLab


From a831136347eebc92019c121c5834a7e0fe629eef Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 29 Jan 2010 00:22:13 -0800
Subject: [PATCH 075/683] spot-aware light func usage in ALL shaders.

---
 .../shaders/class1/deferred/alphaV.glsl       | 14 ++++++------
 .../shaders/class1/deferred/avatarAlphaV.glsl | 14 ++++++------
 .../shaders/class1/lighting/lightFuncV.glsl   | 22 +------------------
 .../shaders/class2/deferred/alphaV.glsl       | 14 ++++++------
 .../shaders/class2/deferred/avatarAlphaV.glsl | 14 ++++++------
 .../shaders/class2/lighting/sumLightsV.glsl   |  9 ++++----
 .../shaders/class3/lighting/sumLightsV.glsl   | 15 +++++++------
 7 files changed, 41 insertions(+), 61 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 1a7d58b07ba..91793a29d3d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -9,7 +9,7 @@ vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
 void calcAtmospherics(vec3 inPositionEye);
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -49,12 +49,12 @@ void main()
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index c1988d3c783..e36564df108 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -10,7 +10,7 @@ mat4 getSkinnedTransform();
 void calcAtmospherics(vec3 inPositionEye);
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -55,12 +55,12 @@ void main()
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 2e41f24afed..d0f58cc1a4f 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -12,28 +12,8 @@ float calcDirectionalLight(vec3 n, vec3 l)
 	return a;
 }
 
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = length(lv);
-	
-	//normalize light vector
-	lv *= 1.0/d;
-	
-	//distance attenuation
-	float da = clamp(1.0/(la * d), 0.0, 1.0);
-	
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
-
-	return da;	
-}
-
 
-float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional)
+float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
 {
 	//get light vector
 	vec3 lv = lp.xyz-v;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index 5991e1f3b5e..eec655e3dfe 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -9,7 +9,7 @@ vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
 void calcAtmospherics(vec3 inPositionEye);
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -50,12 +50,12 @@ void main()
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index a939499b171..488bd677e10 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -10,7 +10,7 @@ mat4 getSkinnedTransform();
 void calcAtmospherics(vec3 inPositionEye);
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -61,12 +61,12 @@ void main()
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index 4577b4be555..19800d96dc6 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -6,8 +6,7 @@
  */
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
-float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -20,9 +19,9 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[1].diffuse.rgb * calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 
-	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
-	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
-	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight2(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLightOrSpotLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLightOrSpotLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	//col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLightOrSpotLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
 	col.rgb = scaleDownLight(col.rgb);
 
 	// Add windlight lights
diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
index 1c5234c4502..0fdfdf2ddea 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
@@ -6,7 +6,7 @@
  */
 
 float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
 
 vec3 atmosAmbient(vec3 light);
 vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -24,12 +24,13 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	col.rgb = scaleUpLight(col.rgb);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
-	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
-	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
-	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
- 	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
- 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 				
-- 
GitLab


From 71b35bd63daecfe6ca60560a13f72990afae81ac Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 29 Jan 2010 00:31:39 -0800
Subject: [PATCH 076/683] Don't scale windlight lights up just to scale them
 down again later.  avoid this with rearrangement.

not tested.
---
 .../shaders/class1/deferred/alphaV.glsl            | 10 ++++------
 .../shaders/class1/deferred/avatarAlphaV.glsl      | 10 ++++------
 .../shaders/class2/deferred/alphaV.glsl            | 10 ++++------
 .../shaders/class2/deferred/avatarAlphaV.glsl      | 10 ++++------
 .../shaders/class3/lighting/sumLightsV.glsl        | 14 +++++---------
 5 files changed, 21 insertions(+), 33 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 91793a29d3d..cb0d7b797b2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -41,12 +41,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col;
-	col.a = gl_Color.a;
-	
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	col.rgb = scaleUpLight(col.rgb);
+	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
@@ -58,6 +53,9 @@ void main()
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
 	vary_light = gl_LightSource[0].position.xyz;
 	
 	vary_ambient = col.rgb*gl_Color.rgb;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index e36564df108..e34f6ba5524 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -47,12 +47,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col;
-	col.a = gl_Color.a;
-	
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	col.rgb = scaleUpLight(col.rgb);
+	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
@@ -64,6 +59,9 @@ void main()
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
 	vary_ambient = col.rgb*gl_Color.rgb;
 	vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index eec655e3dfe..05a32578c16 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -42,12 +42,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col;
-	col.a = gl_Color.a;
-	
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	col.rgb = scaleUpLight(col.rgb);
+	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
@@ -59,6 +54,9 @@ void main()
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
 	vary_light = gl_LightSource[0].position.xyz;
 	
 	vary_ambient = col.rgb*gl_Color.rgb;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index 488bd677e10..d63baeb9131 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -53,12 +53,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col;
-	col.a = gl_Color.a;
-	
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	col.rgb = scaleUpLight(col.rgb);
+	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
@@ -70,6 +65,9 @@ void main()
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
 	vary_ambient = col.rgb*gl_Color.rgb;
 	vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
 	
diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
index 0fdfdf2ddea..371d6b526c7 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
@@ -15,16 +15,9 @@ vec3 scaleUpLight(vec3 light);
 
 vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 {
-	vec4 col;
-	col.a = color.a;
+	vec4 col(0.0, 0.0, 0.0, color.a);
 	
-	// Add windlight lights
-	col.rgb = atmosAffectDirectionalLight(calcDirectionalLight(norm, gl_LightSource[0].position.xyz));
-	col.rgb += atmosAmbient(baseLight.rgb);
-	col.rgb = scaleUpLight(col.rgb);
-
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
 	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
 	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
@@ -33,7 +26,10 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
-				
+
+	// Add windlight lights
+	col.rgb += atmosAffectDirectionalLight(calcDirectionalLight(norm, gl_LightSource[0].position.xyz));
+	col.rgb += atmosAmbient(baseLight.rgb);
 
 	col.rgb = min(col.rgb*color.rgb, 1.0);
 	
-- 
GitLab


From b734d11f8c929f1e2866e52a0727818e6fa3f3a4 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 29 Jan 2010 00:31:39 -0800
Subject: [PATCH 077/683] Don't scale windlight lights up just to scale them
 down again later.  avoid this with rearrangement.

not tested.
---
 .../shaders/class1/deferred/alphaV.glsl            | 10 ++++------
 .../shaders/class1/deferred/avatarAlphaV.glsl      | 10 ++++------
 .../shaders/class2/deferred/alphaV.glsl            | 10 ++++------
 .../shaders/class2/deferred/avatarAlphaV.glsl      | 10 ++++------
 .../shaders/class3/lighting/sumLightsV.glsl        | 14 +++++---------
 5 files changed, 21 insertions(+), 33 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 91793a29d3d..cb0d7b797b2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -41,12 +41,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col;
-	col.a = gl_Color.a;
-	
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	col.rgb = scaleUpLight(col.rgb);
+	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
@@ -58,6 +53,9 @@ void main()
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
 	vary_light = gl_LightSource[0].position.xyz;
 	
 	vary_ambient = col.rgb*gl_Color.rgb;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index e36564df108..e34f6ba5524 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -47,12 +47,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col;
-	col.a = gl_Color.a;
-	
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	col.rgb = scaleUpLight(col.rgb);
+	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
@@ -64,6 +59,9 @@ void main()
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
 	vary_ambient = col.rgb*gl_Color.rgb;
 	vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index eec655e3dfe..05a32578c16 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -42,12 +42,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col;
-	col.a = gl_Color.a;
-	
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	col.rgb = scaleUpLight(col.rgb);
+	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
@@ -59,6 +54,9 @@ void main()
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
 	vary_light = gl_LightSource[0].position.xyz;
 	
 	vary_ambient = col.rgb*gl_Color.rgb;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index 488bd677e10..d63baeb9131 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -53,12 +53,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col;
-	col.a = gl_Color.a;
-	
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	col.rgb = scaleUpLight(col.rgb);
+	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
@@ -70,6 +65,9 @@ void main()
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
 	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
 	vary_ambient = col.rgb*gl_Color.rgb;
 	vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
 	
diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
index 0fdfdf2ddea..371d6b526c7 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
@@ -15,16 +15,9 @@ vec3 scaleUpLight(vec3 light);
 
 vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 {
-	vec4 col;
-	col.a = color.a;
+	vec4 col(0.0, 0.0, 0.0, color.a);
 	
-	// Add windlight lights
-	col.rgb = atmosAffectDirectionalLight(calcDirectionalLight(norm, gl_LightSource[0].position.xyz));
-	col.rgb += atmosAmbient(baseLight.rgb);
-	col.rgb = scaleUpLight(col.rgb);
-
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
-
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
 	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
 	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
@@ -33,7 +26,10 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
 	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
 	col.rgb = scaleDownLight(col.rgb);
-				
+
+	// Add windlight lights
+	col.rgb += atmosAffectDirectionalLight(calcDirectionalLight(norm, gl_LightSource[0].position.xyz));
+	col.rgb += atmosAmbient(baseLight.rgb);
 
 	col.rgb = min(col.rgb*color.rgb, 1.0);
 	
-- 
GitLab


From 6df5cd7a18187c83b84915c8fa0d4c32f1282264 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 29 Jan 2010 00:57:28 -0800
Subject: [PATCH 078/683] duh, use the proper param name.

---
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index d0f58cc1a4f..2b7e8b125b4 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -28,7 +28,7 @@ float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
 	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_omnidirectional);
+	float spot = max(dot(-ln, lv), is_pointlight);
 	da *= spot*spot; // GL_SPOT_EXPONENT=2
 
 	//angular attenuation
-- 
GitLab


From fcfcb1860dd6e6fcfd85e4e242011637193f232f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 29 Jan 2010 00:57:28 -0800
Subject: [PATCH 079/683] duh, use the proper param name.

---
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index d0f58cc1a4f..2b7e8b125b4 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -28,7 +28,7 @@ float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	float da = clamp(1.0/(la * d), 0.0, 1.0);
 	
 	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_omnidirectional);
+	float spot = max(dot(-ln, lv), is_pointlight);
 	da *= spot*spot; // GL_SPOT_EXPONENT=2
 
 	//angular attenuation
-- 
GitLab


From aaae230bb135b9e57edb12a7374c711fd7e4adb4 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 29 Jan 2010 01:45:13 -0800
Subject: [PATCH 080/683] fix a variety of shader errors, mostly due to my
 confusing glsl with C++... again

---
 indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl | 3 ++-
 .../app_settings/shaders/class1/deferred/avatarAlphaV.glsl     | 3 ++-
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl       | 2 +-
 indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl | 2 +-
 .../app_settings/shaders/class2/deferred/avatarAlphaV.glsl     | 3 ++-
 .../app_settings/shaders/class3/lighting/sumLightsV.glsl       | 2 +-
 6 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index cb0d7b797b2..04e556c11ad 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -41,7 +41,8 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
+
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index e34f6ba5524..650fbcc3f5c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -47,7 +47,8 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
+
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 2b7e8b125b4..da49e59b89e 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -13,7 +13,7 @@ float calcDirectionalLight(vec3 n, vec3 l)
 }
 
 
-float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
 {
 	//get light vector
 	vec3 lv = lp.xyz-v;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index 05a32578c16..1fae8c4da38 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -42,7 +42,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index d63baeb9131..f8dd1b74314 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -53,7 +53,8 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
+
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
index 371d6b526c7..f129a1517b3 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
@@ -15,7 +15,7 @@ vec3 scaleUpLight(vec3 light);
 
 vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 {
-	vec4 col(0.0, 0.0, 0.0, color.a);
+	vec4 col = vec4(0.0, 0.0, 0.0, color.a);
 	
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
-- 
GitLab


From c8e4997395c8ffc71f838dcef142a56a5c6b781b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 29 Jan 2010 01:45:13 -0800
Subject: [PATCH 081/683] fix a variety of shader errors, mostly due to my
 confusing glsl with C++... again

---
 indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl | 3 ++-
 .../app_settings/shaders/class1/deferred/avatarAlphaV.glsl     | 3 ++-
 .../app_settings/shaders/class1/lighting/lightFuncV.glsl       | 2 +-
 indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl | 2 +-
 .../app_settings/shaders/class2/deferred/avatarAlphaV.glsl     | 3 ++-
 .../app_settings/shaders/class3/lighting/sumLightsV.glsl       | 2 +-
 6 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index cb0d7b797b2..04e556c11ad 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -41,7 +41,8 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
+
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index e34f6ba5524..650fbcc3f5c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -47,7 +47,8 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
+
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index 2b7e8b125b4..da49e59b89e 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -13,7 +13,7 @@ float calcDirectionalLight(vec3 n, vec3 l)
 }
 
 
-float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
 {
 	//get light vector
 	vec3 lv = lp.xyz-v;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index 05a32578c16..1fae8c4da38 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -42,7 +42,7 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index d63baeb9131..f8dd1b74314 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -53,7 +53,8 @@ void main()
 	calcAtmospherics(pos.xyz);
 
 	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
-	vec4 col(0.0, 0.0, 0.0, gl_Color.a);
+
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
index 371d6b526c7..f129a1517b3 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
@@ -15,7 +15,7 @@ vec3 scaleUpLight(vec3 light);
 
 vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
 {
-	vec4 col(0.0, 0.0, 0.0, color.a);
+	vec4 col = vec4(0.0, 0.0, 0.0, color.a);
 	
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
-- 
GitLab


From 024c0ebe19588f8452bae7ea01756fd7b4b30540 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Fri, 29 Jan 2010 14:33:04 -0600
Subject: [PATCH 082/683] enable mirror and invert flags for meshes.

---
 indra/llmath/llvolume.cpp    | 59 ++++++++++++++++++++++++++++++++++--
 indra/llmath/llvolume.h      |  7 ++---
 indra/newview/llvovolume.cpp |  7 ++---
 3 files changed, 62 insertions(+), 11 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index de32070da18..0328c09c9a7 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1694,7 +1694,7 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 
 	generate();
 	
-	if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
+	if (mParams.getSculptID().isNull() && mParams.getSculptType() == LL_SCULPT_TYPE_NONE)
 	{
 		createVolumeFaces();
 	}
@@ -2142,6 +2142,59 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 					(F32) t[1] / 65535.f * tc_range.mV[1] + min_tc.mV[1]);
 			}
 
+			
+			// modifier flags?
+			BOOL do_mirror = (mParams.getSculptType() & LL_SCULPT_FLAG_MIRROR);
+			BOOL do_invert = (mParams.getSculptType() &LL_SCULPT_FLAG_INVERT);
+			
+			
+			// translate to actions:
+			BOOL do_reflect_x = FALSE;
+			BOOL do_reverse_triangles = FALSE;
+			BOOL do_invert_normals = FALSE;
+			
+			if (do_mirror)
+			{
+				do_reflect_x = TRUE;
+				do_reverse_triangles = !do_reverse_triangles;
+			}
+			
+			if (do_invert)
+			{
+				do_invert_normals = TRUE;
+				do_reverse_triangles = !do_reverse_triangles;
+			}
+			
+			// now do the work
+
+			if (do_reflect_x)
+			{
+				for (S32 i = 0; i < face.mVertices.size(); i++)
+				{
+					face.mVertices[i].mPosition.mV[VX] *= -1.0f;
+					face.mVertices[i].mNormal.mV[VX] *= -1.0f;
+				}
+			}
+
+			if (do_invert_normals)
+			{
+				for (S32 i = 0; i < face.mVertices.size(); i++)
+				{
+					face.mVertices[i].mNormal *= -1.0f;
+				}
+			}
+
+			if (do_reverse_triangles)
+			{
+				for (U32 j = 0; j < face.mIndices.size(); j += 3)
+				{
+					// swap the 2nd and 3rd index
+					S32 swap = face.mIndices[j+1];
+					face.mIndices[j+1] = face.mIndices[j+2];
+					face.mIndices[j+2] = swap;
+				}
+			}
+
 		}
 	}
 
@@ -3838,7 +3891,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 	normals.clear();
 	segments.clear();
 
-	if (mParams.getSculptType() == LL_SCULPT_TYPE_MESH)
+	if ((mParams.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 	{
 		return;
 	}
@@ -5500,7 +5553,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 	{
 		mIndices.resize(num_indices);
 
-		if (volume->getParams().getSculptType() != LL_SCULPT_TYPE_MESH)
+		if ((volume->getParams().getSculptType() & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH)
 		{
 			mEdge.resize(num_indices);
 		}
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index e3ab648fe33..0bc64f44872 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -183,12 +183,11 @@ const U8 LL_SCULPT_TYPE_SPHERE    = 1;
 const U8 LL_SCULPT_TYPE_TORUS     = 2;
 const U8 LL_SCULPT_TYPE_PLANE     = 3;
 const U8 LL_SCULPT_TYPE_CYLINDER  = 4;
-
-const U8 LL_SCULPT_TYPE_MASK      = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE | LL_SCULPT_TYPE_CYLINDER;
-
-// need to change this (these) names
 const U8 LL_SCULPT_TYPE_MESH      = 5;
 
+const U8 LL_SCULPT_TYPE_MASK      = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE |
+	LL_SCULPT_TYPE_CYLINDER | LL_SCULPT_TYPE_MESH;
+
 const U8 LL_SCULPT_FLAG_INVERT    = 64;
 const U8 LL_SCULPT_FLAG_MIRROR    = 128;
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 4acf3cb6fbd..3f1ddc0ee79 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -905,14 +905,13 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 		// if it's a mesh
 		if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 		{ //meshes might not have all LODs, get the force detail to best existing LOD
+
 			LLUUID mesh_id = params.getSculptID();
 
 			//profile and path params don't matter for meshes
-			volume_params = LLVolumeParams();
 			volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
-			volume_params.setSculptID(mesh_id, LL_SCULPT_TYPE_MESH);
 
-			lod = gMeshRepo.getActualMeshLOD(mesh_id, lod);
+			lod = gMeshRepo.getActualMeshLOD(volume_params, lod);
 		}
 	}
 
@@ -963,7 +962,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 				{ 
 					//load request not yet issued, request pipeline load this mesh
 					LLUUID asset_id = volume_params.getSculptID();
-					S32 available_lod = gMeshRepo.loadMesh(this, asset_id, lod);
+					S32 available_lod = gMeshRepo.loadMesh(this, volume_params, lod);
 					if (available_lod != lod)
 					{
 						LLPrimitive::setVolume(volume_params, available_lod);
-- 
GitLab


From c504c40a754a79baf0e4b1d1c10ca44197d577df Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Fri, 29 Jan 2010 15:04:14 -0800
Subject: [PATCH 083/683] Added glod.txt and libraries no longer unzipped into
 newview

---
 indra/cmake/Copy3rdPartyLibs.cmake |  4 ++++
 indra/newview/viewer_manifest.py   | 11 +++++------
 install.xml                        |  8 ++++----
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index faf9da8b148..9a54c7a2e8c 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -38,6 +38,8 @@ if(WINDOWS)
         libapr-1.dll
         libaprutil-1.dll
         libapriconv-1.dll
+        libcollada14dom21.dll
+        glod.dll
         )
 
     # *TODO - update this to use LIBS_PREBUILT_DIR and LL_ARCH_DIR variables
@@ -48,6 +50,8 @@ if(WINDOWS)
         libapr-1.dll
         libaprutil-1.dll
         libapriconv-1.dll
+        libcollada14dom21.dll
+        glod.dll
         )
 
     if(USE_GOOGLE_PERFTOOLS)
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 37c2102e8f3..595afd86e00 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -268,12 +268,17 @@ def construct(self):
                 self.path('libapr-1.dll')
                 self.path('libaprutil-1.dll')
                 self.path('libapriconv-1.dll')
+                
             except RuntimeError, err:
                 print err.message
                 print "Skipping llcommon.dll (assuming llcommon was linked statically)"
 
             self.disable_manifest_check()
 
+            # Mesh 3rd party libs needed for auto LOD and collada reading
+            self.path("libcollada14dom21.dll")
+            self.path("glod.dll")
+
             # For textures
             if self.args['configuration'].lower() == 'debug':
                 self.path("openjpegd.dll")
@@ -320,12 +325,6 @@ def construct(self):
         # For using FMOD for sound... DJS
         self.path("fmod.dll")
        
-        # For automatic level of detail generation in mesh importer
-        self.path("glod.dll")
-
-        # For reading collada files
-        self.path("libcollada14dom21.dll")
-
         self.enable_no_crt_manifest_check()
 
         # Media plugins - QuickTime
diff --git a/install.xml b/install.xml
index 91276ca4980..c4c29044717 100644
--- a/install.xml
+++ b/install.xml
@@ -70,9 +70,9 @@
           <key>windows</key>
           <map>
             <key>md5sum</key>
-            <string>b97aa644a548310ca3c916518bb07b7e</string>
+            <string>39fae44d406aa56a0b3d00f5433bbf15</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/GLOD-windows-20090915.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/GLOD-1.0pre4-windows-20100129.tar.bz2</uri>
           </map>
         </map>
       </map>
@@ -280,9 +280,9 @@
           <key>windows</key>
           <map>
             <key>md5sum</key>
-            <string>c239ce23ed3f0dbbe58a1ddba05aee0b</string>
+            <string>6c2267ba2735bb5bc6229bc4366fce86</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-windows-20091103.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/colladadom-2.1.1-windows-20100129.tar.bz2</uri>
           </map>
         </map>
       </map>
-- 
GitLab


From f5f20a7851ddfa5f2b5d24c5a392acf9c0a745b5 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Fri, 29 Jan 2010 15:06:55 -0800
Subject: [PATCH 084/683] got rid of tab

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

diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 9a54c7a2e8c..c9dc301b8be 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -19,7 +19,7 @@ if(WINDOWS)
     set(vivox_src_dir "${CMAKE_SOURCE_DIR}/newview/vivox-runtime/i686-win32")
     set(vivox_files
         SLVoice.exe
-	libsndfile-1.dll
+        libsndfile-1.dll
         vivoxplatform.dll
         vivoxsdk.dll
         ortp.dll
-- 
GitLab


From e8899c4f4c2ae95f108b9bbf543e401debc9c588 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 1 Feb 2010 17:29:08 +0000
Subject: [PATCH 085/683] start to abstract-out the 'is a spotlight' question
 so one day we can perhaps make the UI hurt less.

---
 indra/llprimitive/llprimitive.h | 1 +
 indra/newview/llpanelvolume.cpp | 4 ++--
 indra/newview/llvovolume.cpp    | 7 +++++++
 indra/newview/llvovolume.h      | 1 +
 indra/newview/pipeline.cpp      | 6 +++---
 5 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index 4db7aa7261d..c25f9cf4a82 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -286,6 +286,7 @@ class LLLightImageParams : public LLNetworkData
 
 	void setLightTexture(const LLUUID& id) { mLightTexture = id; }
 	LLUUID getLightTexture() const         { return mLightTexture; }
+	bool isLightSpotlight() const         { return !mLightTexture.isNull(); }
 	void setParams(const LLVector3& params) { mParams = params; }
 	LLVector3 getParams() const			   { return mParams; }
 	
diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp
index fbe68b4d92f..8b016372392 100644
--- a/indra/newview/llpanelvolume.cpp
+++ b/indra/newview/llpanelvolume.cpp
@@ -574,7 +574,7 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
 		LLUUID id = LightTextureCtrl->getImageAssetID();
 		if (id.notNull())
 		{
-			if (volobjp->getLightTextureID().isNull())
+			if (!volobjp->isLightSpotlight())
 			{ //this commit is making this a spot light, set UI to default params
 				volobjp->setLightTextureID(id);
 				LLVector3 spot_params = volobjp->getSpotLightParams();
@@ -591,7 +591,7 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
 				volobjp->setSpotLightParams(spot_params);
 			}
 		}
-		else if (volobjp->getLightTextureID().notNull())
+		else if (volobjp->isLightSpotlight())
 		{ //no longer a spot light
 			volobjp->setLightTextureID(id);
 			//self->childDisable("Light FOV");
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 3f1ddc0ee79..305c0a19d67 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2462,6 +2462,13 @@ void LLVOVolume::updateSpotLightPriority()
 }
 
 
+bool LLVOVolume::isLightSpotlight()
+{
+	LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
+	return params->isLightSpotlight();
+}
+
+
 LLViewerTexture* LLVOVolume::getLightTexture()
 {
 	LLUUID id = getLightTextureID();
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index e414d9da4d8..280ffea76d3 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -218,6 +218,7 @@ class LLVOVolume : public LLViewerObject
 	LLColor3 getLightBaseColor() const; // not scaled by intensity
 	LLColor3 getLightColor() const; // scaled by intensity
 	LLUUID	getLightTextureID() const;
+	bool isLightSpotlight() const;
 	LLVector3 getSpotLightParams() const;
 	void	updateSpotLightPriority();
 	F32		getSpotLightPriority() const;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2ad0bad11fc..cb0baf77f18 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4584,7 +4584,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
 			glLightf (gllight, GL_LINEAR_ATTENUATION,     linatten);
 			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  0.0f);
-			if (light->getLightTexture()) // directional (spot-)light
+			if (light->isLightSpotlight()) // directional (spot-)light
 			{
 				LLVector3 spotparams = light->getSpotLightParams();
 				LLQuaternion quat = light->getRenderRotation();
@@ -6693,7 +6693,7 @@ void LLPipeline::renderDeferredLighting()
 					{ //draw box if camera is outside box
 						if (render_local)
 						{
-							if (volume->getLightTexture())
+							if (volume->isLightSpotlight())
 							{
 								drawablep->getVOVolume()->updateSpotLightPriority();
 								spot_lights.push_back(drawablep);
@@ -6710,7 +6710,7 @@ void LLPipeline::renderDeferredLighting()
 					}
 					else if (render_fullscreen)
 					{	
-						if (volume->getLightTexture())
+						if (volume->isLightSpotlight())
 						{
 							drawablep->getVOVolume()->updateSpotLightPriority();
 							fullscreen_spot_lights.push_back(drawablep);
-- 
GitLab


From 956074541f429725a5ba216d6a8fa8204a676e59 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 1 Feb 2010 17:29:08 +0000
Subject: [PATCH 086/683] start to abstract-out the 'is a spotlight' question
 so one day we can perhaps make the UI hurt less.

---
 indra/llprimitive/llprimitive.h | 37 +++++++++++++++++-------------
 indra/newview/llpanelvolume.cpp | 40 +++++++++++++++++++--------------
 indra/newview/llvovolume.cpp    |  7 ++++++
 indra/newview/llvovolume.h      | 37 +++++++++++++++++-------------
 indra/newview/pipeline.cpp      |  6 ++---
 5 files changed, 77 insertions(+), 50 deletions(-)

diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index 921f407859f..59697d1ebdc 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -2,25 +2,31 @@
  * @file llprimitive.h
  * @brief LLPrimitive base class
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -280,6 +286,7 @@ class LLLightImageParams : public LLNetworkData
 
 	void setLightTexture(const LLUUID& id) { mLightTexture = id; }
 	LLUUID getLightTexture() const         { return mLightTexture; }
+	bool isLightSpotlight() const         { return !mLightTexture.isNull(); }
 	void setParams(const LLVector3& params) { mParams = params; }
 	LLVector3 getParams() const			   { return mParams; }
 	
diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp
index faf260881ec..8b016372392 100644
--- a/indra/newview/llpanelvolume.cpp
+++ b/indra/newview/llpanelvolume.cpp
@@ -2,25 +2,31 @@
  * @file llpanelvolume.cpp
  * @brief Object editing (position, scale, etc.) in the tools floater
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -568,7 +574,7 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
 		LLUUID id = LightTextureCtrl->getImageAssetID();
 		if (id.notNull())
 		{
-			if (volobjp->getLightTextureID().isNull())
+			if (!volobjp->isLightSpotlight())
 			{ //this commit is making this a spot light, set UI to default params
 				volobjp->setLightTextureID(id);
 				LLVector3 spot_params = volobjp->getSpotLightParams();
@@ -585,7 +591,7 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
 				volobjp->setSpotLightParams(spot_params);
 			}
 		}
-		else if (volobjp->getLightTextureID().notNull())
+		else if (volobjp->isLightSpotlight())
 		{ //no longer a spot light
 			volobjp->setLightTextureID(id);
 			//self->childDisable("Light FOV");
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index e6de33c459b..b7b024fa1d6 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2451,6 +2451,13 @@ void LLVOVolume::updateSpotLightPriority()
 }
 
 
+bool LLVOVolume::isLightSpotlight()
+{
+	LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
+	return params->isLightSpotlight();
+}
+
+
 LLViewerTexture* LLVOVolume::getLightTexture()
 {
 	LLUUID id = getLightTextureID();
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index bf9536d0c2d..fbae011ffc8 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -2,25 +2,31 @@
  * @file llvovolume.h
  * @brief LLVOVolume class header file
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -209,6 +215,7 @@ class LLVOVolume : public LLViewerObject
 	LLColor3 getLightBaseColor() const; // not scaled by intensity
 	LLColor3 getLightColor() const; // scaled by intensity
 	LLUUID	getLightTextureID() const;
+	bool isLightSpotlight() const;
 	LLVector3 getSpotLightParams() const;
 	void	updateSpotLightPriority();
 	F32		getSpotLightPriority() const;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1ef5b5ded16..cceb4176341 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4555,7 +4555,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
 			glLightf (gllight, GL_LINEAR_ATTENUATION,     linatten);
 			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  0.0f);
-			if (light->getLightTexture()) // directional (spot-)light
+			if (light->isLightSpotlight()) // directional (spot-)light
 			{
 				LLVector3 spotparams = light->getSpotLightParams();
 				LLQuaternion quat = light->getRenderRotation();
@@ -6647,7 +6647,7 @@ void LLPipeline::renderDeferredLighting()
 					{ //draw box if camera is outside box
 						if (render_local)
 						{
-							if (volume->getLightTexture())
+							if (volume->isLightSpotlight())
 							{
 								drawablep->getVOVolume()->updateSpotLightPriority();
 								spot_lights.push_back(drawablep);
@@ -6664,7 +6664,7 @@ void LLPipeline::renderDeferredLighting()
 					}
 					else if (render_fullscreen)
 					{	
-						if (volume->getLightTexture())
+						if (volume->isLightSpotlight())
 						{
 							drawablep->getVOVolume()->updateSpotLightPriority();
 							fullscreen_spot_lights.push_back(drawablep);
-- 
GitLab


From 3dc32880ae0f2f0f5499a7f271df666759fc220a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 1 Feb 2010 17:50:55 +0000
Subject: [PATCH 087/683] const fix.

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

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 305c0a19d67..a6caa2362b9 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2462,7 +2462,7 @@ void LLVOVolume::updateSpotLightPriority()
 }
 
 
-bool LLVOVolume::isLightSpotlight()
+bool LLVOVolume::isLightSpotlight() const
 {
 	LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
 	return params->isLightSpotlight();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index cb0baf77f18..b25c7c92126 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4573,7 +4573,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 	
 			F32 light_radius = llmax(light->getLightRadius(), 0.001f);
 
-			F32 x = (3.f * (1.f + light->getLightFalloff()));
+			F32 x = (3.f * (1.f + light->getLightFalloff())); // why this magic?  probably trying to match a historic behavior.
 			float linatten = x / (light_radius); // % of brightness at radius
 
 			mHWLightColors[cur_light] = light_color;
-- 
GitLab


From a23a7131cd1f7890e2e58c06958b13ffafbd5a38 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 1 Feb 2010 17:50:55 +0000
Subject: [PATCH 088/683] const fix.

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

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index b7b024fa1d6..10160a42084 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2451,7 +2451,7 @@ void LLVOVolume::updateSpotLightPriority()
 }
 
 
-bool LLVOVolume::isLightSpotlight()
+bool LLVOVolume::isLightSpotlight() const
 {
 	LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
 	return params->isLightSpotlight();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index cceb4176341..3d700abd014 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4544,7 +4544,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 	
 			F32 light_radius = llmax(light->getLightRadius(), 0.001f);
 
-			F32 x = (3.f * (1.f + light->getLightFalloff()));
+			F32 x = (3.f * (1.f + light->getLightFalloff())); // why this magic?  probably trying to match a historic behavior.
 			float linatten = x / (light_radius); // % of brightness at radius
 
 			mHWLightColors[cur_light] = light_color;
-- 
GitLab


From 56bd8e1f4de45c63b896908c601aac13ffc57235 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 2 Feb 2010 22:38:39 +0000
Subject: [PATCH 089/683] Trying to resolve a strange crash in
 LLUUID::isNull()... by avoiding it for now.

---
 indra/llprimitive/llprimitive.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index c25f9cf4a82..a44b9a6c1f8 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -286,7 +286,7 @@ class LLLightImageParams : public LLNetworkData
 
 	void setLightTexture(const LLUUID& id) { mLightTexture = id; }
 	LLUUID getLightTexture() const         { return mLightTexture; }
-	bool isLightSpotlight() const         { return !mLightTexture.isNull(); }
+	bool isLightSpotlight() const         { return mLightTexture.notNull(); }
 	void setParams(const LLVector3& params) { mParams = params; }
 	LLVector3 getParams() const			   { return mParams; }
 	
-- 
GitLab


From bc9096bea2631f360f81b35a31a81b6cb6985d43 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 2 Feb 2010 22:38:39 +0000
Subject: [PATCH 090/683] Trying to resolve a strange crash in
 LLUUID::isNull()... by avoiding it for now.

---
 indra/llprimitive/llprimitive.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index 59697d1ebdc..e67d4368879 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -286,7 +286,7 @@ class LLLightImageParams : public LLNetworkData
 
 	void setLightTexture(const LLUUID& id) { mLightTexture = id; }
 	LLUUID getLightTexture() const         { return mLightTexture; }
-	bool isLightSpotlight() const         { return !mLightTexture.isNull(); }
+	bool isLightSpotlight() const         { return mLightTexture.notNull(); }
 	void setParams(const LLVector3& params) { mParams = params; }
 	LLVector3 getParams() const			   { return mParams; }
 	
-- 
GitLab


From cc5920bed7790db49a062fb98ce54191f06ed98c Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 2 Feb 2010 22:45:30 +0000
Subject: [PATCH 091/683] Probably the real fix for isLightSpotlight() -
 PARAMS_LIGHT_IMAGE isn't guaranteed, duh.

---
 indra/newview/llvovolume.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index a6caa2362b9..be2744aeded 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2465,7 +2465,11 @@ void LLVOVolume::updateSpotLightPriority()
 bool LLVOVolume::isLightSpotlight() const
 {
 	LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
-	return params->isLightSpotlight();
+	if (params)
+	{
+		return params->isLightSpotlight();
+	}
+	return false;
 }
 
 
-- 
GitLab


From 84ffc72c01e53cbf4d2449d1753fd6556c5c9932 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 2 Feb 2010 22:45:30 +0000
Subject: [PATCH 092/683] Probably the real fix for isLightSpotlight() -
 PARAMS_LIGHT_IMAGE isn't guaranteed, duh.

---
 indra/newview/llvovolume.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 10160a42084..8a774613691 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2454,7 +2454,11 @@ void LLVOVolume::updateSpotLightPriority()
 bool LLVOVolume::isLightSpotlight() const
 {
 	LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
-	return params->isLightSpotlight();
+	if (params)
+	{
+		return params->isLightSpotlight();
+	}
+	return false;
 }
 
 
-- 
GitLab


From 011b0b0e5e72800d2b3f0fb08d820cc7e23fcb61 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 3 Feb 2010 17:00:33 +0000
Subject: [PATCH 093/683] Fix silent merge conflict.... AFAICT.

---
 .../default/xui/en/floater_inventory.xml      | 21 ------------------
 .../default/xui/en/menu_inventory_add.xml     | 22 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/indra/newview/skins/default/xui/en/floater_inventory.xml b/indra/newview/skins/default/xui/en/floater_inventory.xml
index 6d4620f9ab7..e187eabd3a2 100644
--- a/indra/newview/skins/default/xui/en/floater_inventory.xml
+++ b/indra/newview/skins/default/xui/en/floater_inventory.xml
@@ -41,25 +41,4 @@
 	 name="Inventory Panel"
 	 top="15"
 	 width="467" />
-              <menu_item_call
-                 label="Model (L$[COST])..."
-                 layout="topleft"
-                 name="Upload Model">
-                <menu_item_call.on_click
-                 function="File.UploadModel"
-                 parameter="" />
-                <menu_item_call.on_enable
-                 function="File.EnableUpload" />
-              </menu_item_call>
-              <menu_item_call
-                 label="Scene..."
-                 layout="topleft"
-                 name="Upload Scene">
-                <menu_item_call.on_click
-                 function="File.UploadScene"
-                 parameter="" />
-                <menu_item_call.on_enable
-                 function="File.EnableUpload" />
-              </menu_item_call>
-                <menu_item_call
 </floater>
diff --git a/indra/newview/skins/default/xui/en/menu_inventory_add.xml b/indra/newview/skins/default/xui/en/menu_inventory_add.xml
index 5ad099e2d9e..0d974075f56 100644
--- a/indra/newview/skins/default/xui/en/menu_inventory_add.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory_add.xml
@@ -42,6 +42,26 @@
                     <menu_item_call.on_enable
                      function="File.EnableUpload" />
                 </menu_item_call>
+		<menu_item_call
+                 label="Model (L$[COST])..."
+                 layout="topleft"
+                 name="Upload Model">
+                <menu_item_call.on_click
+                 function="File.UploadModel"
+                 parameter="" />
+                <menu_item_call.on_enable
+                 function="File.EnableUpload" />
+              </menu_item_call>
+              <menu_item_call
+                 label="Scene..."
+                 layout="topleft"
+                 name="Upload Scene">
+                <menu_item_call.on_click
+                 function="File.UploadScene"
+                 parameter="" />
+                <menu_item_call.on_enable
+                 function="File.EnableUpload" />
+              </menu_item_call>
                 <menu_item_call
                  label="Bulk (L$[COST] per file)..."
                  layout="topleft"
@@ -226,4 +246,4 @@
                      parameter="eyes" />
                 </menu_item_call>
             </menu>
-</menu>
\ No newline at end of file
+</menu>
-- 
GitLab


From 1805369b58d98677c726bb0bcb52618bd66e8fdd Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Wed, 3 Feb 2010 18:08:19 -0600
Subject: [PATCH 094/683] handle reflected geometry in scene import implement
 determinant for 4x4 matrices fix materials for collada <polygon>

---
 indra/llmath/m4math.cpp | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp
index 37001429824..5c112b52b2a 100644
--- a/indra/llmath/m4math.cpp
+++ b/indra/llmath/m4math.cpp
@@ -221,8 +221,33 @@ const LLMatrix4&	LLMatrix4::transpose()
 
 F32 LLMatrix4::determinant() const
 {
-	llerrs << "Not implemented!" << llendl;
-	return 0.f;
+	F32 value =
+	    mMatrix[0][3] * mMatrix[1][2] * mMatrix[2][1] * mMatrix[3][0] -
+	    mMatrix[0][2] * mMatrix[1][3] * mMatrix[2][1] * mMatrix[3][0] -
+	    mMatrix[0][3] * mMatrix[1][1] * mMatrix[2][2] * mMatrix[3][0] +
+	    mMatrix[0][1] * mMatrix[1][3] * mMatrix[2][2] * mMatrix[3][0] +
+	    mMatrix[0][2] * mMatrix[1][1] * mMatrix[2][3] * mMatrix[3][0] -
+	    mMatrix[0][1] * mMatrix[1][2] * mMatrix[2][3] * mMatrix[3][0] -
+	    mMatrix[0][3] * mMatrix[1][2] * mMatrix[2][0] * mMatrix[3][1] +
+	    mMatrix[0][2] * mMatrix[1][3] * mMatrix[2][0] * mMatrix[3][1] +
+	    mMatrix[0][3] * mMatrix[1][0] * mMatrix[2][2] * mMatrix[3][1] -
+	    mMatrix[0][0] * mMatrix[1][3] * mMatrix[2][2] * mMatrix[3][1] -
+	    mMatrix[0][2] * mMatrix[1][0] * mMatrix[2][3] * mMatrix[3][1] +
+	    mMatrix[0][0] * mMatrix[1][2] * mMatrix[2][3] * mMatrix[3][1] +
+	    mMatrix[0][3] * mMatrix[1][1] * mMatrix[2][0] * mMatrix[3][2] -
+	    mMatrix[0][1] * mMatrix[1][3] * mMatrix[2][0] * mMatrix[3][2] -
+	    mMatrix[0][3] * mMatrix[1][0] * mMatrix[2][1] * mMatrix[3][2] +
+	    mMatrix[0][0] * mMatrix[1][3] * mMatrix[2][1] * mMatrix[3][2] +
+	    mMatrix[0][1] * mMatrix[1][0] * mMatrix[2][3] * mMatrix[3][2] -
+	    mMatrix[0][0] * mMatrix[1][1] * mMatrix[2][3] * mMatrix[3][2] -
+	    mMatrix[0][2] * mMatrix[1][1] * mMatrix[2][0] * mMatrix[3][3] +
+	    mMatrix[0][1] * mMatrix[1][2] * mMatrix[2][0] * mMatrix[3][3] +
+	    mMatrix[0][2] * mMatrix[1][0] * mMatrix[2][1] * mMatrix[3][3] -
+	    mMatrix[0][0] * mMatrix[1][2] * mMatrix[2][1] * mMatrix[3][3] -
+	    mMatrix[0][1] * mMatrix[1][0] * mMatrix[2][2] * mMatrix[3][3] +
+		mMatrix[0][0] * mMatrix[1][1] * mMatrix[2][2] * mMatrix[3][3];
+
+	return value;
 }
 
 // Only works for pure orthonormal, homogeneous transform matrices.
-- 
GitLab


From 62f0f426532808755f6d97f34fd2d8c9e5d2fa6a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 5 Feb 2010 09:12:13 +0000
Subject: [PATCH 095/683] repair meshfu for inventory API change

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

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 6aecc4af4d2..366fb091e4b 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -5046,7 +5046,7 @@ void LLMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 	std::vector<std::string> items;
 	std::vector<std::string> disabled_items;
 
-	if(isInTrash())
+	if(isItemInTrash())
 	{
 		items.push_back(std::string("Purge Item"));
 		if (!isItemRemovable())
-- 
GitLab


From 095a5e84408b47ef3c5610e111aefe51d77633ca Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 6 Feb 2010 17:33:12 -0600
Subject: [PATCH 096/683] Draw prims using triangle strips instead of triangle
 lists.

---
 indra/llmath/llvolume.cpp               | 201 ++++++++++++++++++------
 indra/llmath/llvolume.h                 |   4 +-
 indra/newview/app_settings/settings.xml |  11 ++
 indra/newview/lldrawpool.cpp            |   4 +-
 indra/newview/lldrawpoolalpha.cpp       |   8 +-
 indra/newview/lldrawpoolbump.cpp        |   8 +-
 indra/newview/lldrawpooltree.cpp        |   4 +-
 indra/newview/llface.cpp                |  25 ++-
 indra/newview/llspatialpartition.cpp    |   3 +-
 indra/newview/llspatialpartition.h      |   1 +
 indra/newview/llviewercontrol.cpp       |   1 +
 indra/newview/llviewerjointmesh.cpp     |   2 +-
 indra/newview/llvotree.cpp              |   6 +-
 indra/newview/llvovolume.cpp            |  16 +-
 indra/newview/llvowlsky.cpp             |   2 +-
 indra/newview/pipeline.cpp              |  15 +-
 indra/newview/pipeline.h                |   4 +-
 17 files changed, 242 insertions(+), 73 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index df4c618ac10..cd7d7a12e3f 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4520,15 +4520,65 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
-		int idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
-		for(int gx = 0;gx<grid_size;gx++){
-			for(int gy = 0;gy<grid_size;gy++){
-				if (mTypeMask & TOP_MASK){
-					for(int i=5;i>=0;i--)mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
-				}else{
-					for(int i=0;i<6;i++)mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
+		mTriStrip.clear();
+		S32 idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
+		for(S32 gx = 0;gx<grid_size;gx++)
+		{
+			
+			for(S32 gy = 0;gy<grid_size;gy++)
+			{
+				if (mTypeMask & TOP_MASK)
+				{
+					for(S32 i=5;i>=0;i--)
+					{
+						mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
+					}
+					
+					if (gy == 0)
+					{
+						mTriStrip.push_back((gx+1)*(grid_size+1));
+						mTriStrip.push_back((gx+1)*(grid_size+1));
+						mTriStrip.push_back(gx*(grid_size+1));
+					}
+
+					mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1));
+					mTriStrip.push_back(gy+1+gx*(grid_size+1));
+					
+					
+					if (gy == grid_size-1)
+					{
+						mTriStrip.push_back(gy+1+gx*(grid_size+1));
+					}
+				}
+				else
+				{
+					for(S32 i=0;i<6;i++)
+					{
+						mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
+					}
+
+					if (gy == 0)
+					{
+						mTriStrip.push_back(gx*(grid_size+1));
+						mTriStrip.push_back(gx*(grid_size+1));
+						mTriStrip.push_back((gx+1)*(grid_size+1));
+					}
+
+					mTriStrip.push_back(gy+1+gx*(grid_size+1));
+					mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1));
+					
+					if (gy == grid_size-1)
+					{
+						mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1));
+					}
 				}
 			}
+			
+		}
+
+		if (mTriStrip.size()%2 == 1)
+		{
+			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 		}
 	}
 		
@@ -4770,6 +4820,8 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 					pt2--;
 				}
 			}
+
+			makeTriStrip();
 		}
 		else
 		{
@@ -4874,67 +4926,108 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 					pt2--;
 				}
 			}
+
+			makeTriStrip();
 		}
 	}
 	else
 	{
 		// Not hollow, generate the triangle fan.
+		U16 v1 = 2;
+		U16 v2 = 1;
+
 		if (mTypeMask & TOP_MASK)
 		{
-			if (mTypeMask & OPEN_MASK)
-			{
-				// SOLID OPEN TOP
-				// Generate indices
-				// This is a tri-fan, so we reuse the same first point for all triangles.
-				for (S32 i = 0; i < (num_vertices - 2); i++)
-				{
-					mIndices[3*i] = num_vertices - 1;
-					mIndices[3*i+1] = i;
-					mIndices[3*i+2] = i + 1;
-				}
-			}
-			else
-			{
-				// SOLID CLOSED TOP
-				for (S32 i = 0; i < (num_vertices - 2); i++)
-				{				
-					//MSMSM fix these caps but only for the un-cut case
-					mIndices[3*i] = num_vertices - 1;
-					mIndices[3*i+1] = i;
-					mIndices[3*i+2] = i + 1;
-				}
-			}
+			v1 = 1;
+			v2 = 2;
+		}
+
+		for (S32 i = 0; i < (num_vertices - 2); i++)
+		{
+			mIndices[3*i] = num_vertices - 1;
+			mIndices[3*i+v1] = i;
+			mIndices[3*i+v2] = i + 1;
+		}
+
+		//make tri strip
+		if (mTypeMask & OPEN_MASK)
+		{
+			makeTriStrip();
 		}
 		else
 		{
-			if (mTypeMask & OPEN_MASK)
+			S32 j = num_vertices-2;
+			if (mTypeMask & TOP_MASK)
 			{
-				// SOLID OPEN BOTTOM
-				// Generate indices
-				// This is a tri-fan, so we reuse the same first point for all triangles.
-				for (S32 i = 0; i < (num_vertices - 2); i++)
+				mTriStrip.push_back(0);
+				for (S32 i = 1; i <= j; ++i)
 				{
-					mIndices[3*i] = num_vertices - 1;
-					mIndices[3*i+1] = i + 1;
-					mIndices[3*i+2] = i;
+					mTriStrip.push_back(i);
+					if (i != j)
+					{
+						mTriStrip.push_back(j);
+					}
+					--j;
 				}
 			}
 			else
 			{
-				// SOLID CLOSED BOTTOM
-				for (S32 i = 0; i < (num_vertices - 2); i++)
+				mTriStrip.push_back(j);
+				for (S32 i = 1; i <= j; ++i)
 				{
-					//MSMSM fix these caps but only for the un-cut case
-					mIndices[3*i] = num_vertices - 1;
-					mIndices[3*i+1] = i + 1;
-					mIndices[3*i+2] = i;
+					if (i != j)
+					{
+						mTriStrip.push_back(j);
+					}
+					mTriStrip.push_back(i);
+					--j;
 				}
 			}
+			
+			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
+
+			if (mTriStrip.size()%2 == 1)
+			{
+				mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
+			}
 		}
 	}
+		
 	return TRUE;
 }
 
+void LLVolumeFace::makeTriStrip()
+{
+	for (U32 i = 0; i < mIndices.size(); i+=3)
+	{
+		U16 i0 = mIndices[i];
+		U16 i1 = mIndices[i+1];
+		U16 i2 = mIndices[i+2];
+
+		if ((i/3)%2 == 1)
+		{
+			mTriStrip.push_back(i0);
+			mTriStrip.push_back(i0);
+			mTriStrip.push_back(i1);
+			mTriStrip.push_back(i2);
+			mTriStrip.push_back(i2);
+		}
+		else
+		{
+			mTriStrip.push_back(i2);
+			mTriStrip.push_back(i2);
+			mTriStrip.push_back(i1);
+			mTriStrip.push_back(i0);
+			mTriStrip.push_back(i0);
+		}
+	}
+
+	if (mTriStrip.size()%2 == 1)
+	{
+		mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
+	}
+}
+
 void LLVolumeFace::createBinormals()
 {
 	LLMemType m1(LLMemType::MTYPE_VOLUME);
@@ -5135,9 +5228,14 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
+		mTriStrip.clear();
+
 		// Now we generate the indices.
 		for (t = 0; t < (mNumT-1); t++)
 		{
+			//prepend terminating index to strip
+			mTriStrip.push_back(mNumS*t);
+
 			for (s = 0; s < (mNumS-1); s++)
 			{	
 				mIndices[cur_index++] = s   + mNumS*t;			//bottom left
@@ -5147,6 +5245,14 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				mIndices[cur_index++] = s+1 + mNumS*t;			//bottom right
 				mIndices[cur_index++] = s+1 + mNumS*(t+1);		//top right
 
+				if (s == 0)
+				{
+					mTriStrip.push_back(s+mNumS*t);
+					mTriStrip.push_back(s+mNumS*(t+1));
+				}
+				mTriStrip.push_back(s+1+mNumS*t);
+				mTriStrip.push_back(s+1+mNumS*(t+1));
+				
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1;						//bottom left/top right neighbor face 
 				if (t < mNumT-2) {												//top right/top left neighbor face 
 					mEdge[cur_edge++] = (mNumS-1)*2*(t+1)+s*2+1;
@@ -5187,6 +5293,13 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				}
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2;							//top right/bottom left neighbor face	
 			}
+			//append terminating vertex to strip
+			mTriStrip.push_back(mNumS-1+mNumS*(t+1));
+		}
+
+		if (mTriStrip.size()%2 == 1)
+		{
+			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 		}
 	}
 
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 871b3344521..d9f80f0e30e 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -798,7 +798,8 @@ class LLVolumeFace
 
 	BOOL create(LLVolume* volume, BOOL partial_build = FALSE);
 	void createBinormals();
-
+	void makeTriStrip();
+	
 	class VertexData
 	{
 	public:
@@ -839,6 +840,7 @@ class LLVolumeFace
 
 	std::vector<VertexData> mVertices;
 	std::vector<U16>	mIndices;
+	std::vector<U16>	mTriStrip;
 	std::vector<S32>	mEdge;
 
 private:
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 8a447502b08..ce19dda9a54 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7386,6 +7386,17 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
+  <key>RenderUseTriStrips</key>
+  <map>
+    <key>Comment</key>
+    <string>Use triangle strips for rendering prims.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>1</integer>
+  </map>
     <key>RenderUseFarClip</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index 95ddacb722a..ef946ac49e5 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -496,8 +496,8 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
 			params.mGroup->rebuildMesh();
 		}
 		params.mVertexBuffer->setBuffer(mask);
-		params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
-		gPipeline.addTrianglesDrawn(params.mCount/3);
+		params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+		gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
 	}
 
 	if (params.mTextureMatrix && texture && params.mTexture.notNull())
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 6d773614149..0e02bc4b01c 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -250,8 +250,8 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask)
 					params.mGroup->rebuildMesh();
 				}
 				params.mVertexBuffer->setBuffer(mask);
-				params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
-				gPipeline.addTrianglesDrawn(params.mCount/3);
+				params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+				gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
 			}
 		}
 	}
@@ -380,8 +380,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 				}
 
 				params.mVertexBuffer->setBuffer(mask);
-				params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
-				gPipeline.addTrianglesDrawn(params.mCount/3);
+				params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+				gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
 
 				if (params.mTextureMatrix && params.mTexture.notNull())
 				{
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 03a8b108e29..d09d4a412fa 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -560,8 +560,8 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL
 			params.mGroup->rebuildMesh();
 		}
 		params.mVertexBuffer->setBuffer(mask);
-		params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
-		gPipeline.addTrianglesDrawn(params.mCount/3);
+		params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+		gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
 	}
 }
 
@@ -1231,8 +1231,8 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
 		params.mGroup->rebuildMesh();
 	}
 	params.mVertexBuffer->setBuffer(mask);
-	params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
-	gPipeline.addTrianglesDrawn(params.mCount/3);
+	params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+	gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
 	if (params.mTextureMatrix)
 	{
 		if (mShiny)
diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp
index 5521fb05a82..1a5d55d793b 100644
--- a/indra/newview/lldrawpooltree.cpp
+++ b/indra/newview/lldrawpooltree.cpp
@@ -115,7 +115,7 @@ void LLDrawPoolTree::render(S32 pass)
 			LLFace *face = *iter;
 			face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
 			face->mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, face->mVertexBuffer->getRequestedVerts()-1, face->mVertexBuffer->getRequestedIndices(), 0); 
-			gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices()/3);
+			gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices());
 		}
 	}
 }
@@ -237,7 +237,7 @@ void LLDrawPoolTree::renderForSelect()
 				
 				face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
 				face->mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, face->mVertexBuffer->getRequestedVerts()-1, face->mVertexBuffer->getRequestedIndices(), 0); 
-				gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices()/3);
+				gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices());
 			}
 		}
 	}
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 965ac1cad0b..93840e077c6 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -868,7 +868,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	llpushcallstacks ;
 	const LLVolumeFace &vf = volume.getVolumeFace(f);
 	S32 num_vertices = (S32)vf.mVertices.size();
-	S32 num_indices = (S32)vf.mIndices.size();
+	S32 num_indices = LLPipeline::sUseTriStrips ? (S32)vf.mTriStrip.size() : (S32) vf.mIndices.size();
 	
 	if (mVertexBuffer.notNull())
 	{
@@ -1058,9 +1058,19 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	if (full_rebuild)
 	{
 		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
-		for (U16 i = 0; i < num_indices; i++)
+		if (LLPipeline::sUseTriStrips)
 		{
-			*indicesp++ = vf.mIndices[i] + index_offset;
+			for (U16 i = 0; i < num_indices; i++)
+			{
+				*indicesp++ = vf.mTriStrip[i] + index_offset;
+			}
+		}
+		else
+		{
+			for (U16 i = 0; i < num_indices; i++)
+			{
+				*indicesp++ = vf.mIndices[i] + index_offset;
+			}
 		}
 	}
 	
@@ -1572,8 +1582,13 @@ S32 LLFace::pushVertices(const U16* index_array) const
 {
 	if (mIndicesCount)
 	{
-		mVertexBuffer->drawRange(LLRender::TRIANGLES, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex);
-		gPipeline.addTrianglesDrawn(mIndicesCount/3);
+		U32 render_type = LLRender::TRIANGLES;
+		if (mDrawInfo)
+		{
+			render_type = mDrawInfo->mDrawMode;
+		}
+		mVertexBuffer->drawRange(render_type, mGeomIndex, mGeomIndex+mGeomCount-1, mIndicesCount, mIndicesIndex);
+		gPipeline.addTrianglesDrawn(mIndicesCount, render_type);
 	}
 
 	return mIndicesCount;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 2a57d48f16b..d6e9256feea 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -3380,7 +3380,8 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset,
 	mVSize(0.f),
 	mGroup(NULL),
 	mFace(NULL),
-	mDistance(0.f)
+	mDistance(0.f),
+	mDrawMode(LLRender::TRIANGLES)
 {
 	mDebugColor = (rand() << 16) + rand();
 	if (mStart >= mVertexBuffer->getRequestedVerts() ||
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 64c2a9acbc7..7896488379e 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -93,6 +93,7 @@ class LLDrawInfo : public LLRefCount
 	LLFace* mFace; //associated face
 	F32 mDistance;
 	LLVector3 mExtents[2];
+	U32 mDrawMode;
 
 	struct CompareTexture
 	{
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 827d34138fe..0b7f6900ed8 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -510,6 +510,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("FirstPersonAvatarVisible")->getSignal()->connect(boost::bind(&handleRenderAvatarMouselookChanged, _2));
 	gSavedSettings.getControl("RenderFarClip")->getSignal()->connect(boost::bind(&handleRenderFarClipChanged, _2));
 	gSavedSettings.getControl("RenderTerrainDetail")->getSignal()->connect(boost::bind(&handleTerrainDetailChanged, _2));
+	gSavedSettings.getControl("RenderUseTriStrips")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 1a67fc09664..7225aa15238 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -626,7 +626,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
 		mFace->mVertexBuffer->drawRange(LLRender::TRIANGLES, start, end, count, offset);
 		glPopMatrix();
 	}
-	gPipeline.addTrianglesDrawn(count/3);
+	gPipeline.addTrianglesDrawn(count);
 
 	triangle_count += count;
 	
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 24f1c4bd246..55e2c58a520 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -1141,7 +1141,7 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
 
 				glLoadMatrixf((F32*) scale_mat.mMatrix);
  				glDrawElements(GL_TRIANGLES, sLODIndexCount[trunk_LOD], GL_UNSIGNED_SHORT, indicesp + sLODIndexOffset[trunk_LOD]);
-				gPipeline.addTrianglesDrawn(LEAF_INDICES/3);
+				gPipeline.addTrianglesDrawn(LEAF_INDICES);
 				stop_glerror();
 				ret += sLODIndexCount[trunk_LOD];
 			}
@@ -1191,7 +1191,7 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
 			
 				glLoadMatrixf((F32*) scale_mat.mMatrix);
 				glDrawElements(GL_TRIANGLES, LEAF_INDICES, GL_UNSIGNED_SHORT, indicesp);
-				gPipeline.addTrianglesDrawn(LEAF_INDICES/3);							
+				gPipeline.addTrianglesDrawn(LEAF_INDICES);							
 				stop_glerror();
 				ret += LEAF_INDICES;
 			}
@@ -1216,7 +1216,7 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
 					
 		glLoadMatrixf((F32*) scale_mat.mMatrix);
 		glDrawElements(GL_TRIANGLES, LEAF_INDICES, GL_UNSIGNED_SHORT, indicesp);
-		gPipeline.addTrianglesDrawn(LEAF_INDICES/3);
+		gPipeline.addTrianglesDrawn(LEAF_INDICES);
 		stop_glerror();
 		ret += LEAF_INDICES;
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 25ed931fb50..b87ad7fc478 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1514,7 +1514,14 @@ void LLVOVolume::updateFaceSize(S32 idx)
 	else
 	{
 		const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx);
-		facep->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
+		if (LLPipeline::sUseTriStrips)
+		{
+			facep->setSize(vol_face.mVertices.size(), vol_face.mTriStrip.size());
+		}
+		else
+		{
+			facep->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
+		}
 	}
 }
 
@@ -3264,6 +3271,11 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 		draw_info->mExtents[0] = facep->mExtents[0];
 		draw_info->mExtents[1] = facep->mExtents[1];
 		validate_draw_info(*draw_info);
+
+		if (LLPipeline::sUseTriStrips)
+		{
+			draw_info->mDrawMode = LLRender::TRIANGLE_STRIP;
+		}
 	}
 }
 
@@ -3348,7 +3360,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 			drawablep->updateFaceSize(i);
 			LLFace* facep = drawablep->getFace(i);
 
-			if (cur_total > max_total)
+			if (cur_total > max_total || facep->getIndicesCount() <= 0 || facep->getGeomCount() <= 0)
 			{
 				facep->mVertexBuffer = NULL;
 				facep->mLastVertexBuffer = NULL;
diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp
index 0272a2ab342..1749ccef94b 100644
--- a/indra/newview/llvowlsky.cpp
+++ b/indra/newview/llvowlsky.cpp
@@ -519,7 +519,7 @@ void LLVOWLSky::drawDome(void)
 			LLRender::TRIANGLE_STRIP, 
 			0, strips_segment->getRequestedVerts()-1, strips_segment->getRequestedIndices(), 
 			0);
-		gPipeline.addTrianglesDrawn(strips_segment->getRequestedIndices() - 2);
+		gPipeline.addTrianglesDrawn(strips_segment->getRequestedIndices(), LLRender::TRIANGLE_STRIP);
 	}
 
 #else
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index d5f87b73fe2..91da9e39e07 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -270,6 +270,7 @@ BOOL	LLPipeline::sDelayVBUpdate = TRUE;
 BOOL	LLPipeline::sFastAlpha = TRUE;
 BOOL	LLPipeline::sDisableShaders = FALSE;
 BOOL	LLPipeline::sRenderBump = TRUE;
+BOOL	LLPipeline::sUseTriStrips = TRUE;
 BOOL	LLPipeline::sUseFarClip = TRUE;
 BOOL	LLPipeline::sShadowRender = FALSE;
 BOOL	LLPipeline::sWaterReflections = FALSE;
@@ -358,6 +359,7 @@ void LLPipeline::init()
 
 	sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
+	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
 	sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights");
 	sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles");
 
@@ -3495,9 +3497,19 @@ void LLPipeline::renderGeomShadow(LLCamera& camera)
 }
 
 
-void LLPipeline::addTrianglesDrawn(S32 count)
+void LLPipeline::addTrianglesDrawn(S32 index_count, U32 render_type)
 {
 	assertInitialized();
+	S32 count = 0;
+	if (render_type == LLRender::TRIANGLE_STRIP)
+	{
+		count = index_count-2;
+	}
+	else
+	{
+		count = index_count/3;
+	}
+
 	mTrianglesDrawn += count;
 	mBatchCount++;
 	mMaxBatchSize = llmax(mMaxBatchSize, count);
@@ -5349,6 +5361,7 @@ void LLPipeline::resetVertexBuffers(LLDrawable* drawable)
 void LLPipeline::resetVertexBuffers()
 {
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
+	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
 
 	for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
 			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index c5285943e84..1bf2ee941b4 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -277,7 +277,7 @@ class LLPipeline
 	LLCullResult::sg_list_t::iterator beginAlphaGroups();
 	LLCullResult::sg_list_t::iterator endAlphaGroups();
 	
-	void addTrianglesDrawn(S32 count);
+	void addTrianglesDrawn(S32 index_count, U32 render_type = LLRender::TRIANGLES);
 	BOOL hasRenderType(const U32 type) const				{ return (type && (mRenderTypeMask & (1<<type))) ? TRUE : FALSE; }
 	BOOL hasRenderDebugFeatureMask(const U32 mask) const	{ return (mRenderDebugFeatureMask & mask) ? TRUE : FALSE; }
 	BOOL hasRenderDebugMask(const U32 mask) const			{ return (mRenderDebugMask & mask) ? TRUE : FALSE; }
@@ -447,7 +447,7 @@ class LLPipeline
 	static BOOL				sFastAlpha;
 	static BOOL				sDisableShaders; // if TRUE, rendering will be done without shaders
 	static BOOL				sRenderBump;
-	static BOOL				sUseFBO;
+	static BOOL				sUseTriStrips;
 	static BOOL				sUseFarClip;
 	static BOOL				sShadowRender;
 	static BOOL				sWaterReflections;
-- 
GitLab


From ce504224de16776ade2a01adfbd5410fae6942cc Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 6 Feb 2010 20:50:49 -0600
Subject: [PATCH 097/683] Fix for bad GL blend function caching.

---
 indra/llrender/llrender.cpp   | 33 ++++++++++++++++-----------------
 indra/llrender/llrender.h     |  3 ++-
 indra/newview/llselectmgr.cpp | 19 +++++++++++++------
 3 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index d2dc1104a85..c11675fa48c 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -763,7 +763,8 @@ LLRender::LLRender()
 
 	mCurrAlphaFunc = CF_DEFAULT;
 	mCurrAlphaFuncVal = 0.01f;
-	mCurrSceneBlendType = BT_ALPHA;
+	mCurrBlendSFactor = BF_SOURCE_ALPHA;
+	mCurrBlendDFactor = BF_ONE_MINUS_SOURCE_ALPHA;
 }
 
 LLRender::~LLRender()
@@ -922,40 +923,33 @@ void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB
 
 void LLRender::setSceneBlendType(eBlendType type)
 {
-	if (mCurrSceneBlendType == type)
-	{
-		return;
-	}
-
-	flush();
 	switch (type) 
 	{
 		case BT_ALPHA:
-			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+			blendFunc(BF_SOURCE_ALPHA, BF_ONE_MINUS_SOURCE_ALPHA);
 			break;
 		case BT_ADD:
-			glBlendFunc(GL_ONE, GL_ONE);
+			blendFunc(BF_ONE, BF_ONE);
 			break;
 		case BT_ADD_WITH_ALPHA:
-			glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+			blendFunc(BF_SOURCE_ALPHA, BF_ONE);
 			break;
 		case BT_MULT:
-			glBlendFunc(GL_DST_COLOR, GL_ZERO);
+			blendFunc(BF_DEST_COLOR, BF_ZERO);
 			break;
 		case BT_MULT_ALPHA:
-			glBlendFunc(GL_DST_ALPHA, GL_ZERO);
+			blendFunc(BF_DEST_ALPHA, BF_ZERO);
 			break;
 		case BT_MULT_X2:
-			glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
+			blendFunc(BF_DEST_COLOR, BF_SOURCE_COLOR);
 			break;
 		case BT_REPLACE:
-			glBlendFunc(GL_ONE, GL_ZERO);
+			blendFunc(BF_ONE, BF_ZERO);
 			break;
 		default:
 			llerrs << "Unknown Scene Blend Type: " << type << llendl;
 			break;
 	}
-	mCurrSceneBlendType = type;
 }
 
 void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
@@ -976,8 +970,13 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
 
 void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor)
 {
-	flush();
-	glBlendFunc(sGLBlendFactor[sfactor], sGLBlendFactor[dfactor]);
+	if (mCurrBlendSFactor != sfactor || mCurrBlendDFactor != dfactor)
+	{
+		mCurrBlendSFactor = sfactor;
+		mCurrBlendDFactor = dfactor;
+		flush();
+		glBlendFunc(sGLBlendFactor[sfactor], sGLBlendFactor[dfactor]);
+	}
 }
 
 LLTexUnit* LLRender::getTexUnit(U32 index)
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 6e38fac67b2..a70ccf4d805 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -360,7 +360,8 @@ class LLRender
 	std::vector<LLTexUnit*>		mTexUnits;
 	LLTexUnit*			mDummyTexUnit;
 
-	U32				mCurrSceneBlendType;
+	U32				mCurrBlendSFactor;
+	U32				mCurrBlendDFactor;
 
 	F32				mMaxAnisotropy;
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 95408946468..d733574a9df 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -4919,13 +4919,15 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud)
 
 		// set up transform to encompass bounding box of HUD
 		glMatrixMode(GL_PROJECTION);
-		glPushMatrix();
+		gGL.pushMatrix();
 		glLoadIdentity();
 		F32 depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
 		glOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, depth);
 
 		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
+		gGL.pushMatrix();
+		gGL.pushUIMatrix();
+		gGL.loadUIIdentity();
 		glLoadIdentity();
 		glLoadMatrixf(OGL_TO_CFR_ROTATION);		// Load Cory's favorite reference frame
 		glTranslatef(-hud_bbox.getCenterLocal().mV[VX] + (depth *0.5f), 0.f, 0.f);
@@ -5022,10 +5024,11 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud)
 	if (for_hud && avatar)
 	{
 		glMatrixMode(GL_PROJECTION);
-		glPopMatrix();
+		gGL.popMatrix();
 
 		glMatrixMode(GL_MODELVIEW);
-		glPopMatrix();
+		gGL.popMatrix();
+		gGL.popUIMatrix();
 		stop_glerror();
 	}
 
@@ -5374,7 +5377,10 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
 	}
 
 	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
+	gGL.pushMatrix();
+	gGL.pushUIMatrix();
+	gGL.loadUIIdentity();
+
 	if (!is_hud_object)
 	{
 		glLoadIdentity();
@@ -5493,7 +5499,8 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
 		gGL.end();
 		gGL.flush();
 	}
-	glPopMatrix();
+	gGL.popMatrix();
+	gGL.popUIMatrix();
 }
 
 //
-- 
GitLab


From 4d9bcc2c8f303464c3664a0a7304a1bc2d658e2e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 8 Feb 2010 13:47:14 +0000
Subject: [PATCH 098/683] Fix a crash in the LLModelPreview floater.  This is
 just some sloppy generosity in data acceptance - the probable 'real' fix has
 been sent to qarl+davep for comment.

---
 indra/llui/llview.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index f1b08c380b5..63e627ceb5a 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -1720,6 +1720,7 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
 	for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
 	{
 		LLView* childp = *child_it;
+		llassert(childp);
 		if (childp->getName() == name)
 		{
 			return childp;
@@ -1731,6 +1732,7 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
 		for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
 		{
 			LLView* childp = *child_it;
+			llassert(childp);
 			LLView* viewp = childp->findChildView(name, recurse);
 			if ( viewp )
 			{
-- 
GitLab


From 42df75bafeab49b408f23d79feb4f2213d2560eb Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 8 Feb 2010 10:14:11 -0600
Subject: [PATCH 099/683] Enable FBO multisampling for OSX. Fix bad triangle in
 prim caps.

---
 indra/llmath/llvolume.cpp         |  4 ++--
 indra/llrender/llrendertarget.cpp | 11 -----------
 indra/newview/llviewerdisplay.cpp |  4 ++++
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index cd7d7a12e3f..ae5c9bc8cf0 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4960,7 +4960,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 			if (mTypeMask & TOP_MASK)
 			{
 				mTriStrip.push_back(0);
-				for (S32 i = 1; i <= j; ++i)
+				for (S32 i = 0; i <= j; ++i)
 				{
 					mTriStrip.push_back(i);
 					if (i != j)
@@ -4973,7 +4973,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 			else
 			{
 				mTriStrip.push_back(j);
-				for (S32 i = 1; i <= j; ++i)
+				for (S32 i = 0; i <= j; ++i)
 				{
 					if (i != j)
 					{
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index d9520b3bf63..3f2558f1f5e 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -390,8 +390,6 @@ void LLRenderTarget::flush(BOOL fetch_depth)
 	}
 	else
 	{
-#if !LL_DARWIN
-
 		stop_glerror();
 
 		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
@@ -435,7 +433,6 @@ void LLRenderTarget::flush(BOOL fetch_depth)
 				}
 			}
 		}
-#endif
 
 		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 	}
@@ -444,7 +441,6 @@ void LLRenderTarget::flush(BOOL fetch_depth)
 void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, S32 srcX1, S32 srcY1,
 						S32 dstX0, S32 dstY0, S32 dstX1, S32 dstY1, U32 mask, U32 filter)
 {
-#if !LL_DARWIN
 	gGL.flush();
 	if (!source.mFBO || !mFBO)
 	{
@@ -483,14 +479,12 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0,
 			stop_glerror();
 		}
 	}
-#endif
 }
 
 //static
 void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0, S32 srcY0, S32 srcX1, S32 srcY1,
 						S32 dstX0, S32 dstY0, S32 dstX1, S32 dstY1, U32 mask, U32 filter)
 {
-#if !LL_DARWIN
 	if (!source.mFBO)
 	{
 		llerrs << "Cannot copy framebuffer contents for non FBO render targets." << llendl;
@@ -507,7 +501,6 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0
 		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 		stop_glerror();
 	}
-#endif
 }
 
 BOOL LLRenderTarget::isComplete() const
@@ -652,7 +645,6 @@ void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth
 
 void LLMultisampleBuffer::addColorAttachment(U32 color_fmt)
 {
-#if !LL_DARWIN
 	if (color_fmt == 0)
 	{
 		return;
@@ -693,12 +685,10 @@ void LLMultisampleBuffer::addColorAttachment(U32 color_fmt)
 	}
 
 	mTex.push_back(tex);
-#endif
 }
 
 void LLMultisampleBuffer::allocateDepth()
 {
-#if !LL_DARWIN
 	glGenRenderbuffersEXT(1, (GLuint* ) &mDepth);
 	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepth);
 	if (mStencil)
@@ -709,6 +699,5 @@ void LLMultisampleBuffer::allocateDepth()
 	{
 		glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, mSamples, GL_DEPTH_COMPONENT16_ARB, mResX, mResY);	
 	}
-#endif
 }
 
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index ba256d70e80..64b3bccd4c4 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -862,10 +862,14 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender)
 			{
 				gPipeline.mDeferredScreen.flush();
+				LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(),
+									0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
 			}
 			else
 			{
 				gPipeline.mScreen.flush();
+				LLRenderTarget::copyContentsToFramebuffer(gPipeline.mScreen, 0, 0, gPipeline.mScreen.getWidth(), gPipeline.mScreen.getHeight(),
+									0, 0, gPipeline.mScreen.getWidth(), gPipeline.mScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
 			}
 		}
 
-- 
GitLab


From e0c9ee3275e19decfa8c5179da5e9335bbd70fc7 Mon Sep 17 00:00:00 2001
From: Palmer Truelson <palmer@lindenlab.com>
Date: Mon, 8 Feb 2010 16:11:16 -0800
Subject: [PATCH 100/683] Fix to build dave's changes on mac. Reviewed by davep

---
 indra/llui/llui.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 852a19660a0..22d3af3e6b8 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -710,19 +710,19 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 
 			v = LLVector3(offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2f(v.mV[0], v.mV[1] );
 
 			v = LLVector3(-offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2f(v.mV[0], v.mV[1] );
 
 			v = LLVector3(-offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2f(v.mV[0], v.mV[1] );
 
 			v = LLVector3(offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2f(v.mV[0], v.mV[1] );
 		}
 		gGL.end();
 		gGL.popUIMatrix();
-- 
GitLab


From cf9972b97151422f80746dec2ebc57aa758228c3 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 8 Feb 2010 19:15:43 -0600
Subject: [PATCH 101/683] Fix for blend func being screwed up at init. Fix for
 avatar appearance editor drawing hair in the background.

---
 indra/llrender/llrender.cpp             |  4 ++--
 indra/llui/llui.cpp                     |  8 ++++----
 indra/newview/app_settings/settings.xml |  2 +-
 indra/newview/llfloaterimagepreview.cpp |  5 +++++
 indra/newview/lltoolmorph.cpp           | 12 ++++++++----
 5 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index c11675fa48c..55c5b4531b5 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -763,8 +763,8 @@ LLRender::LLRender()
 
 	mCurrAlphaFunc = CF_DEFAULT;
 	mCurrAlphaFuncVal = 0.01f;
-	mCurrBlendSFactor = BF_SOURCE_ALPHA;
-	mCurrBlendDFactor = BF_ONE_MINUS_SOURCE_ALPHA;
+	mCurrBlendSFactor = BF_ONE;
+	mCurrBlendDFactor = BF_ZERO;
 }
 
 LLRender::~LLRender()
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 852a19660a0..22d3af3e6b8 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -710,19 +710,19 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 
 			v = LLVector3(offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2f(v.mV[0], v.mV[1] );
 
 			v = LLVector3(-offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2f(v.mV[0], v.mV[1] );
 
 			v = LLVector3(-offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2f(v.mV[0], v.mV[1] );
 
 			v = LLVector3(offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2f(v.mV[0], v.mV[1] );
 		}
 		gGL.end();
 		gGL.popUIMatrix();
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 5e5917add9d..93165cf5eda 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7395,7 +7395,7 @@
     <key>Type</key>
     <string>Boolean</string>
     <key>Value</key>
-    <integer>1</integer>
+    <integer>0</integer>
   </map>
     <key>RenderUseFarClip</key>
     <map>
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index 61568df12e0..9917593c91c 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -688,6 +688,9 @@ BOOL LLImagePreviewAvatar::render()
 	mNeedsUpdate = FALSE;
 	LLVOAvatar* avatarp = mDummyAvatar;
 
+	gGL.pushUIMatrix();
+	gGL.loadUIIdentity();
+
 	glMatrixMode(GL_PROJECTION);
 	gGL.pushMatrix();
 	glLoadIdentity();
@@ -696,6 +699,7 @@ BOOL LLImagePreviewAvatar::render()
 	glMatrixMode(GL_MODELVIEW);
 	gGL.pushMatrix();
 	glLoadIdentity();
+	
 
 	LLGLSUIDefault def;
 	gGL.color4f(0.15f, 0.2f, 0.3f, 1.f);
@@ -741,6 +745,7 @@ BOOL LLImagePreviewAvatar::render()
 		avatarPoolp->renderAvatars(avatarp);  // renders only one avatar
 	}
 
+	gGL.popUIMatrix();
 	gGL.color4f(1,1,1,1);
 	return TRUE;
 }
diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp
index 4fb75f7a49f..5f825b461ed 100644
--- a/indra/newview/lltoolmorph.cpp
+++ b/indra/newview/lltoolmorph.cpp
@@ -167,13 +167,16 @@ BOOL LLVisualParamHint::render()
 	LLVisualParamReset::sDirty = TRUE;
 	LLVOAvatar* avatarp = gAgent.getAvatarObject();
 
+	gGL.pushUIMatrix();
+	gGL.loadUIIdentity();
+
 	glMatrixMode(GL_PROJECTION);
-	glPushMatrix();
+	gGL.pushMatrix();
 	glLoadIdentity();
 	glOrtho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f);
 
 	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
+	gGL.pushMatrix();
 	glLoadIdentity();
 
 	LLGLSUIDefault gls_ui;
@@ -181,10 +184,10 @@ BOOL LLVisualParamHint::render()
 	mBackgroundp->draw(0, 0, mFullWidth, mFullHeight);
 
 	glMatrixMode(GL_PROJECTION);
-	glPopMatrix();
+	gGL.popMatrix();
 
 	glMatrixMode(GL_MODELVIEW);
-	glPopMatrix();
+	gGL.popMatrix();
 
 	mNeedsUpdate = FALSE;
 	mIsVisible = TRUE;
@@ -247,6 +250,7 @@ BOOL LLVisualParamHint::render()
 	mVisualParam->setWeight(mLastParamWeight, FALSE);
 	gGL.color4f(1,1,1,1);
 	mGLTexturep->setGLTextureCreated(true);
+	gGL.popUIMatrix();
 	return TRUE;
 }
 
-- 
GitLab


From bc7f2e41fd268895774f9ddffd45be318662dcaa Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 8 Feb 2010 20:03:02 -0600
Subject: [PATCH 102/683] Switching to 10.5 SDK

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

diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index db0b44eb8f0..9b1f7024bfd 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -79,7 +79,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   # NOTE: wont have a distributable build unless you add this on the configure line with:
   # -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc'
   #set(CMAKE_OSX_ARCHITECTURES i386;ppc)
-  set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk)
+  set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
   if (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
     set(ARCH universal)
   else (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
-- 
GitLab


From 17f709abcde85fd073bd0ef8b1525cf4a021ccb7 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 14:40:15 +0100
Subject: [PATCH 103/683] ssreflections: reflect sunlight direction for
 reflection.  dunno how I feel about this yet.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 155f03fdcf9..51d737f10b4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -310,8 +310,11 @@ void main()
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
-		// get appropriate light strength for guess-point
-		float reflit = max(dot(refn, lightnorm.xyz), 0.0);
+		// get appropriate light strength for guess-point.
+		// reflect light direction to increase the illusion that
+		// these are reflections.
+		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
+		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		vec3 ssshiny = (refprod * spec.a);
-- 
GitLab


From cf3c8e6af85a06fe40eb8d37129945573029d178 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 14:50:24 +0100
Subject: [PATCH 104/683] ssreflections: use the minimum of the lighting dp and
 the appropriateness.  not the product.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl      | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 51d737f10b4..8b2b983ba45 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -317,6 +317,8 @@ void main()
 		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		float refmod = min(refapprop, reflit);
+		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 
 		// add the two types of shiny together
-- 
GitLab


From b41902d533f8064a9c185d28bfd28e2c9b078dcd Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 15:20:35 +0100
Subject: [PATCH 105/683] ssreflections: water reflections strongly imply that
 the non-perspective reflection from eye is the right one.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 8b2b983ba45..25733e80d12 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -282,7 +282,8 @@ void main()
 	{
 		// the old infinite-sky shiny reflection
 		//
-		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
+		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
+		//vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnorm, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
-- 
GitLab


From 1a4645b7fea37bb6e272b0a41cbf0f600f7a506a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 15:46:47 +0100
Subject: [PATCH 106/683] ssreflections: perspective reflection for sunlight,
 planar reflection for ssreflection

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 25733e80d12..d00d3ed4121 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -282,13 +282,13 @@ void main()
 	{
 		// the old infinite-sky shiny reflection
 		//
-		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
-		//vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(refnorm, vary_light.xyz);
+		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
 		// screen-space cheap fakey reflection map
 		//
+		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
-- 
GitLab


From 02d301e612bcbc626fa14be8b0b5193e19129f37 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 15:59:11 +0100
Subject: [PATCH 107/683] clean-up transplant

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl       | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index d00d3ed4121..503c7d0b838 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -317,7 +317,6 @@ void main()
 		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
 		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
-		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
-- 
GitLab


From ac2db4d1db16a425231ee7788c172da3b8700eaf Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 16:03:20 +0100
Subject: [PATCH 108/683] apply ssreflection changes to class2 and class3 too.

---
 .../shaders/class2/deferred/softenLightF.glsl     | 13 +++++++++----
 .../shaders/class3/deferred/softenLightF.glsl     | 15 ++++++++++-----
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 922a07c3066..d6fbae7b22b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -281,12 +281,13 @@ void main()
 	{
 		// the old infinite-sky shiny reflection
 		//
-		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(refnorm, vary_light.xyz);
+		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
 		// screen-space cheap fakey reflection map
 		//
+		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
@@ -311,9 +312,13 @@ void main()
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
 		// get appropriate light strength for guess-point
-		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad);
+		// reflect light direction to increase the illusion that
+		// these are reflections.
+		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
+		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
-		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		float refmod = min(refapprop, reflit);
+		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 
 		// add the two types of shiny together
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index ddd69befc36..ecfd9bef52b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -284,12 +284,13 @@ void main()
 	{
 		// the old infinite-sky shiny reflection
 		//
-		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(refnorm, vary_light.xyz);
+		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
 		// screen-space cheap fakey reflection map
 		//
+		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
@@ -313,10 +314,14 @@ void main()
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
-		// get appropriate light strength for guess-point
-		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad);
+		// get appropriate light strength for guess-point.
+		// reflect light direction to increase the illusion that
+		// these are reflections.
+		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
+		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
-		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		float refmod = min(refapprop, reflit);
+		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 
 		// add the two types of shiny together
-- 
GitLab


From 286572ec90558015bfec8a7f738502b63465be3e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 16:09:31 +0100
Subject: [PATCH 109/683] ssreflection: restore the shadow factor I
 accidentally removed with the last update.

---
 .../app_settings/shaders/class2/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index d6fbae7b22b..00a6a9dcb5e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -315,7 +315,7 @@ void main()
 		// reflect light direction to increase the illusion that
 		// these are reflections.
 		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
-		float reflit = max(dot(refn, reflight.xyz), 0.0);
+		float reflit = min(max(dot(refn, reflight.xyz), 0.0), refshad);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index ecfd9bef52b..aaa74eb7df4 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -318,7 +318,7 @@ void main()
 		// reflect light direction to increase the illusion that
 		// these are reflections.
 		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
-		float reflit = max(dot(refn, reflight.xyz), 0.0);
+		float reflit = min(max(dot(refn, reflight.xyz), 0.0), refshad);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
-- 
GitLab


From 958bbdd4f5d38bb07914f35896edf188b1437355 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 6 Apr 2010 22:24:57 +0100
Subject: [PATCH 110/683] extra diffuse sample in ssreflection to decrease
 aliasing.

---
 .../shaders/class1/deferred/softenLightF.glsl            | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 503c7d0b838..3f4425a0b27 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -298,13 +298,18 @@ void main()
 		// of the diffuse map.  LOD would be better in that regard.
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
+		// ---------------------
+		//     ^   ^ ^ ^   ^
+		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
+				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
-- 
GitLab


From 33b6d5d74f5a24a9a6ff6a21810d804493f50b61 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 7 Apr 2010 09:45:20 +0100
Subject: [PATCH 111/683] tidy up ssreflections comments and structure a bit.

---
 .../shaders/class1/deferred/softenLightF.glsl      | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 3f4425a0b27..158eef9319e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -298,18 +298,20 @@ void main()
 		// of the diffuse map.  LOD would be better in that regard.
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
-		// ---------------------
-		//     ^   ^ ^ ^   ^
-		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
 		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
 		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
-		// get attributes from the 2D guess point
-		float refdepth = texture2DRect(depthMap, ref2d).a;
-		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
+		// Get attributes from the 2D guess point.
+		// We average two samples of diffuse (not of anything else) per
+		// pixel to try to reduce aliasing some more.
+		// ---------------------
+		//     ^   ^ ^ ^   ^
+		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
 		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
 				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
+		float refdepth = texture2DRect(depthMap, ref2d).a;
+		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
-- 
GitLab


From 51ab9ae63c3c2a1d7f188fb73af1b7074331eae4 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 7 Apr 2010 10:31:56 +0100
Subject: [PATCH 112/683] apply latest ssreflections tweaks to class2 and
 class3.

---
 .../shaders/class2/deferred/softenLightF.glsl       | 13 ++++++++++---
 .../shaders/class3/deferred/softenLightF.glsl       | 13 ++++++++++---
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 00a6a9dcb5e..dbccb7fb8bc 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -298,12 +298,19 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
-		// get attributes from the 2D guess point
+		// Get attributes from the 2D guess point.
+		// We average two samples of diffuse (not of anything else) per
+		// pixel to try to reduce aliasing some more.
+		// ---------------------
+		//     ^   ^ ^ ^   ^
+		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
+				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
 		float refshad = texture2DRect(lightMap, ref2d).r;
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
 		// figure out how appropriate our guess actually was
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index aaa74eb7df4..ef81ed13089 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -301,12 +301,19 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
-		// get attributes from the 2D guess point
+		// Get attributes from the 2D guess point.
+		// We average two samples of diffuse (not of anything else) per
+		// pixel to try to reduce aliasing some more.
+		// ---------------------
+		//     ^   ^ ^ ^   ^
+		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
+				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
 		float refshad = texture2DRect(lightMap, ref2d).r;
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
 		// figure out how appropriate our guess actually was
-- 
GitLab


From 1cb8c584911e02d0daa9ce1ed44fd801885d9773 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 7 Apr 2010 16:06:13 +0100
Subject: [PATCH 113/683] merge fix.

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 21052775bd9..efb99061ab7 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3420,7 +3420,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
 		glLoadMatrixd(gGLModelView);
 		doOcclusion(camera);
 		gGLLastMatrix = NULL;
-		glLoadMatrix(gGLModelView);
+		glLoadMatrixd(gGLModelView);
 	}
 }
 
-- 
GitLab


From 0d65b34649bcbd2201f7c85949328a2e6423ae6b Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 8 Feb 2010 20:03:02 -0600
Subject: [PATCH 114/683] Switching to 10.5 SDK

---
 indra/cmake/Variables.cmake | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index bfaf3f4f26f..9b1f7024bfd 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -75,33 +75,11 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 
 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   set(DARWIN 1)
-
-  # NOTE: If specifying a different SDK with CMAKE_OSX_SYSROOT at configure
-  # time you should also specify CMAKE_OSX_DEPLOYMENT_TARGET explicitly,
-  # otherwise CMAKE_OSX_SYSROOT will be overridden here. We can't just check
-  # for it being unset, as it gets set to the system default :(
-
-  # Default to building against the 10.4 SDK if no deployment target is
-  # specified.
-  if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
-    # NOTE: setting -isysroot is NOT adequate: http://lists.apple.com/archives/Xcode-users/2007/Oct/msg00696.html
-    # see http://public.kitware.com/Bug/view.php?id=9959 + poppy
-    set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk)
-    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.4)
-  endif (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
-
-  # GCC 4.2 is incompatible with the MacOSX 10.4 SDK
-  if (${CMAKE_OSX_SYSROOT} MATCHES "10.4u")
-    set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "4.0")
-  endif (${CMAKE_OSX_SYSROOT} MATCHES "10.4u")
-
-  # NOTE: To attempt an i386/PPC Universal build, add this on the configure line:
+  # set this dynamically from the build system now -
+  # NOTE: wont have a distributable build unless you add this on the configure line with:
   # -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc'
-  # Build only for i386 by default, system default on MacOSX 10.6 is x86_64
-  if (NOT CMAKE_OSX_ARCHITECTURES)
-    set(CMAKE_OSX_ARCHITECTURES i386)
-  endif (NOT CMAKE_OSX_ARCHITECTURES)
-
+  #set(CMAKE_OSX_ARCHITECTURES i386;ppc)
+  set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
   if (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
     set(ARCH universal)
   else (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
@@ -111,7 +89,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
       set(ARCH i386)
     endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
   endif (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
-
   set(LL_ARCH ${ARCH}_darwin)
   set(LL_ARCH_DIR universal-darwin)
   set(WORD_SIZE 32)
-- 
GitLab


From 2cb5b0b66ec9633d4c6563acf5ff9d0f7bc7cbf7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 9 Feb 2010 12:26:09 -0600
Subject: [PATCH 115/683] consolidate button work in progress

---
 indra/llmath/llvolume.cpp | 19 +++++++++++++++++++
 indra/llmath/llvolume.h   |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index de32070da18..596c5fe2310 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5468,6 +5468,25 @@ void LLVolumeFace::createBinormals()
 	}
 }
 
+void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& transform, LLMatrix4& norm_transform)
+{
+	for (U32 i = 0; i < face.mVertices.size(); ++i)
+	{
+		VertexData v = face.mVertices[i];
+		v.mPosition *= mat;
+		v.mNormal *= norm_transform;
+
+
+		mVertices.push_back(v);
+	}
+
+	U16 offset = mIndices.size();
+	for (U32 i = 0; i < face.mIndices.size(); ++i)
+	{
+		mIndices.push_back(face.mIndices[i]+offset);
+	}
+}
+
 BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 {
 	LLMemType m1(LLMemType::MTYPE_VOLUME);
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index e3ab648fe33..1bf6fac3058 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -805,6 +805,8 @@ class LLVolumeFace
 	BOOL create(LLVolume* volume, BOOL partial_build = FALSE);
 	void createBinormals();
 	
+	void appendFace(const LLVolumeFace& face);
+
 	class VertexData
 	{
 	public:
-- 
GitLab


From 1f24e2795608ed90a108366b3332f57c375211cc Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 10 Feb 2010 14:47:53 -0600
Subject: [PATCH 116/683] Fix for U16 dumbness (can have > 64K indices)

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

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 0a9976f5111..4822c303bf1 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1081,14 +1081,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
 		if (LLPipeline::sUseTriStrips)
 		{
-			for (U16 i = 0; i < num_indices; i++)
+			for (U32 i = 0; i < num_indices; i++)
 			{
 				*indicesp++ = vf.mTriStrip[i] + index_offset;
 			}
 		}
 		else
 		{
-			for (U16 i = 0; i < num_indices; i++)
+			for (U32 i = 0; i < num_indices; i++)
 			{
 				*indicesp++ = vf.mIndices[i] + index_offset;
 			}
-- 
GitLab


From ffcbbf4aaabc652c2050ca6147a9388217cfcaa7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 11 Feb 2010 18:00:00 -0600
Subject: [PATCH 117/683] Multi-threaded asset uploading with proper ordering
 first draft.

---
 indra/llmath/llvolume.cpp        | 20 ++++++++++++++++----
 indra/llmath/llvolume.h          |  2 +-
 indra/llmessage/llcurl.cpp       | 28 ++++++++++++++++++++++++++++
 indra/llmessage/llcurl.h         |  3 +++
 indra/llmessage/llhttpclient.cpp |  1 +
 indra/newview/llface.cpp         |  4 ++--
 indra/newview/llviewermenufile.h | 10 ++++++++++
 7 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index d1716e1407e..7e1517fba7c 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5614,19 +5614,31 @@ void LLVolumeFace::createBinormals()
 	}
 }
 
-void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& transform, LLMatrix4& norm_transform)
+void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat, LLMatrix4& norm_mat)
 {
+	U16 offset = mVertices.size();
+
+	
 	for (U32 i = 0; i < face.mVertices.size(); ++i)
 	{
 		VertexData v = face.mVertices[i];
-		v.mPosition *= mat;
-		v.mNormal *= norm_transform;
+		v.mPosition = v.mPosition*mat;
+		v.mNormal = v.mNormal * norm_mat;
 
 
 		mVertices.push_back(v);
+
+		if (offset == 0 && i == 0)
+		{
+			mExtents[0] = mExtents[1] = v.mPosition;
+		}
+		else
+		{
+			update_min_max(mExtents[0], mExtents[1], v.mPosition);
+		}
 	}
 
-	U16 offset = mIndices.size();
+	
 	for (U32 i = 0; i < face.mIndices.size(); ++i)
 	{
 		mIndices.push_back(face.mIndices[i]+offset);
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 1059c295662..36811785dc2 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -805,7 +805,7 @@ class LLVolumeFace
 	void createBinormals();
 	void makeTriStrip();
 	
-	void appendFace(const LLVolumeFace& face);
+	void appendFace(const LLVolumeFace& face, LLMatrix4& transform, LLMatrix4& normal_tranform);
 
 	class VertexData
 	{
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 024e17a7779..b93b94cd251 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -55,6 +55,7 @@
 #include "llstl.h"
 #include "llsdserialize.h"
 #include "llthread.h"
+#include "llvfile.h"
 
 //////////////////////////////////////////////////////////////////////////////
 /*
@@ -801,7 +802,34 @@ bool LLCurlRequest::post(const std::string& url,
 	bool res = addEasy(easy);
 	return res;
 }
+
+bool LLCurlRequest::post(const std::string& url,
+						 const headers_t& headers,
+						 const std::string& data,
+						 LLCurl::ResponderPtr responder)
+{
+	LLCurl::Easy* easy = allocEasy();
+	if (!easy)
+	{
+		return false;
+	}
+	easy->prepRequest(url, headers, responder);
+
+	easy->getInput().write(data.data(), data.size());
+	S32 bytes = easy->getInput().str().length();
 	
+	easy->setopt(CURLOPT_POST, 1);
+	easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL);
+	easy->setopt(CURLOPT_POSTFIELDSIZE, bytes);
+
+	easy->slist_append("Content-Type: application/octet-stream");
+	easy->setHeaders();
+
+	lldebugs << "POSTING: " << bytes << " bytes." << llendl;
+	bool res = addEasy(easy);
+	return res;
+}
+
 // Note: call once per frame
 S32 LLCurlRequest::process()
 {
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index caf02cccd90..4302c19113d 100644
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -44,6 +44,7 @@
 #include <boost/intrusive_ptr.hpp>
 #include <curl/curl.h> // TODO: remove dependency
 
+#include "llassettype.h"
 #include "llbuffer.h"
 #include "lliopipe.h"
 #include "llsd.h"
@@ -213,6 +214,8 @@ class LLCurlRequest
 	void get(const std::string& url, LLCurl::ResponderPtr responder);
 	bool getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, LLCurl::ResponderPtr responder);
 	bool post(const std::string& url, const headers_t& headers, const LLSD& data, LLCurl::ResponderPtr responder);
+	bool post(const std::string& url, const headers_t& headers, const std::string& data, LLCurl::ResponderPtr responder);
+
 	S32  process();
 	S32  getQueued();
 
diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp
index dd56e18caf8..46952fa4345 100644
--- a/indra/llmessage/llhttpclient.cpp
+++ b/indra/llmessage/llhttpclient.cpp
@@ -194,6 +194,7 @@ namespace
 			fileBuffer = new U8 [fileSize];
             vfile.read(fileBuffer, fileSize);
             ostream.write((char*)fileBuffer, fileSize);
+			delete [] fileBuffer;
 			eos = true;
 			return STATUS_DONE;
 		}
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 0a9976f5111..4822c303bf1 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1081,14 +1081,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
 		if (LLPipeline::sUseTriStrips)
 		{
-			for (U16 i = 0; i < num_indices; i++)
+			for (U32 i = 0; i < num_indices; i++)
 			{
 				*indicesp++ = vf.mTriStrip[i] + index_offset;
 			}
 		}
 		else
 		{
-			for (U16 i = 0; i < num_indices; i++)
+			for (U32 i = 0; i < num_indices; i++)
 			{
 				*indicesp++ = vf.mIndices[i] + index_offset;
 			}
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 71679033119..7ffa5d5e574 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -100,4 +100,14 @@ void assign_defaults_and_show_upload_message(
 	const std::string& display_name,
 	std::string& description);
 
+LLSD generate_new_resource_upload_capability_body(
+	LLAssetType::EType asset_type,
+	const std::string& name,
+	const std::string& desc,
+	LLFolderType::EType destination_folder_type,
+	LLInventoryType::EType inv_type,
+	U32 next_owner_perms,
+	U32 group_perms,
+	U32 everyone_perms);
+
 #endif
-- 
GitLab


From 827c1adc917d832b577b37e37b0eb3f26705c29d Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 12:48:42 +0000
Subject: [PATCH 118/683] Backed out changeset d89b00b44ab6

---
 indra/newview/llagent.cpp            |   3 +
 indra/newview/llappviewer.cpp        |   8 +-
 indra/newview/lldrawable.cpp         |   3 -
 indra/newview/llflexibleobject.cpp   |  15 ++-
 indra/newview/llglsandbox.cpp        |  24 ++--
 indra/newview/llviewerobject.cpp     |   3 +
 indra/newview/llviewerobjectlist.cpp | 171 ++++++++++++++-------------
 indra/newview/llviewerobjectlist.h   |  31 ++---
 indra/newview/llviewerwindow.cpp     |   4 +-
 indra/newview/llvoclouds.cpp         |   4 +-
 indra/newview/llvotextbubble.cpp     |   3 +
 indra/newview/llvovolume.cpp         |  17 ++-
 indra/newview/llworld.cpp            |   3 +
 indra/newview/pipeline.cpp           |  64 +++-------
 indra/newview/pipeline.h             |   5 +-
 15 files changed, 185 insertions(+), 173 deletions(-)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 2354323a66d..9f2186f7f7c 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -3017,6 +3017,9 @@ void LLAgent::endAnimationUpdateUI()
 //-----------------------------------------------------------------------------
 void LLAgent::updateCamera()
 {
+	static LLFastTimer::DeclareTimer ftm("Camera");
+	LLFastTimer t(ftm);
+
 	//Ventrella - changed camera_skyward to the new global "mCameraUpVector"
 	mCameraUpVector = LLVector3::z_axis;
 	//LLVector3	camera_skyward(0.f, 0.f, 1.f);
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 2d694eefd35..9eb793783bf 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -3599,13 +3599,15 @@ void LLAppViewer::idle()
 
 	{
 		// Handle pending gesture processing
+		static LLFastTimer::DeclareTimer ftm("Agent Position");
+		LLFastTimer t(ftm);
 		LLGestureManager::instance().update();
 
 		gAgent.updateAgentPosition(gFrameDTClamped, yaw, current_mouse.mX, current_mouse.mY);
 	}
 
 	{
-		LLFastTimer t(FTM_OBJECTLIST_UPDATE); // Actually "object update"
+		LLFastTimer t(FTM_OBJECTLIST_UPDATE); 
 		
         if (!(logoutRequestSent() && hasSavedFinalSnapshot()))
 		{
@@ -3639,6 +3641,8 @@ void LLAppViewer::idle()
 	//
 
 	{
+		static LLFastTimer::DeclareTimer ftm("HUD Effects");
+		LLFastTimer t(ftm);
 		LLSelectMgr::getInstance()->updateEffects();
 		LLHUDManager::getInstance()->cleanupEffects();
 		LLHUDManager::getInstance()->sendEffects();
@@ -3895,7 +3899,7 @@ void LLAppViewer::sendLogoutRequest()
 static F32 CheckMessagesMaxTime = CHECK_MESSAGES_DEFAULT_MAX_TIME;
 #endif
 
-static LLFastTimer::DeclareTimer FTM_IDLE_NETWORK("Network");
+static LLFastTimer::DeclareTimer FTM_IDLE_NETWORK("Idle Network");
 
 void LLAppViewer::idleNetwork()
 {
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index d60330024af..244fed791f3 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -386,8 +386,6 @@ void LLDrawable::makeActive()
 			mParent->makeActive();
 		}
 
-		gPipeline.setActive(this, TRUE);
-
 		//all child objects must also be active
 		llassert_always(mVObjp);
 		
@@ -434,7 +432,6 @@ void LLDrawable::makeStatic(BOOL warning_enabled)
 	if (isState(ACTIVE))
 	{
 		clearState(ACTIVE);
-		gPipeline.setActive(this, FALSE);
 
 		if (mParent.notNull() && mParent->isActive() && warning_enabled)
 		{
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index aea2de8e92f..561965d0214 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -51,6 +51,9 @@
 
 /*static*/ F32 LLVolumeImplFlexible::sUpdateFactor = 1.0f;
 
+static LLFastTimer::DeclareTimer FTM_FLEXIBLE_REBUILD("Rebuild");
+static LLFastTimer::DeclareTimer FTM_DO_FLEXIBLE_UPDATE("Update");
+
 // LLFlexibleObjectData::pack/unpack now in llprimitive.cpp
 
 //-----------------------------------------------
@@ -194,7 +197,6 @@ void LLVolumeImplFlexible::remapSections(LLFlexibleObjectSection *source, S32 so
 	}
 }
 
-
 //-----------------------------------------------------------------------------
 void LLVolumeImplFlexible::setAttributesOfAllSections(LLVector3* inScale)
 {
@@ -363,6 +365,7 @@ inline S32 log2(S32 x)
 
 void LLVolumeImplFlexible::doFlexibleUpdate()
 {
+	LLFastTimer ftm(FTM_DO_FLEXIBLE_UPDATE);
 	LLVolume* volume = mVO->getVolume();
 	LLPath *path = &volume->getPath();
 	if (mSimulateRes == 0)
@@ -693,7 +696,10 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable)
 	}
 
 	volume->updateRelativeXform();
-	doFlexibleUpdate();
+	{
+		LLFastTimer t(FTM_DO_FLEXIBLE_UPDATE);
+		doFlexibleUpdate();
+	}
 	
 	// Object may have been rotated, which means it needs a rebuild.  See SL-47220
 	BOOL	rotated = FALSE;
@@ -710,7 +716,10 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable)
 		volume->regenFaces();
 		volume->mDrawable->setState(LLDrawable::REBUILD_VOLUME);
 		volume->dirtySpatialGroup();
-		doFlexibleRebuild();
+		{
+			LLFastTimer t(FTM_FLEXIBLE_REBUILD);
+			doFlexibleRebuild();
+		}
 		volume->genBBoxes(isVolumeGlobal());
 	}
 	else if (!mUpdated || rotated)
diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index 750a9d478fe..8569e208eb9 100644
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -897,19 +897,21 @@ void LLViewerObjectList::renderObjectBeacons()
 		S32 last_line_width = -1;
 		// gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width)
 		
-		for (S32 i = 0; i < mDebugBeacons.count(); i++)
+		BOOL flush = FALSE;
+		for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
 		{
-			const LLDebugBeacon &debug_beacon = mDebugBeacons[i];
+			const LLDebugBeacon &debug_beacon = *iter;
 			LLColor4 color = debug_beacon.mColor;
 			color.mV[3] *= 0.25f;
 			S32 line_width = debug_beacon.mLineWidth;
 			if (line_width != last_line_width)
 			{
-				if (i > 0)
+				if (flush)
 				{
 					gGL.end();
-					gGL.flush();
 				}
+				flush = TRUE;
+				gGL.flush();
 				glLineWidth( (F32)line_width );
 				last_line_width = line_width;
 				gGL.begin(LLRender::LINES);
@@ -936,18 +938,20 @@ void LLViewerObjectList::renderObjectBeacons()
 		S32 last_line_width = -1;
 		// gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width)
 		
-		for (S32 i = 0; i < mDebugBeacons.count(); i++)
+		BOOL flush = FALSE;
+		for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
 		{
-			const LLDebugBeacon &debug_beacon = mDebugBeacons[i];
+			const LLDebugBeacon &debug_beacon = *iter;
 
 			S32 line_width = debug_beacon.mLineWidth;
 			if (line_width != last_line_width)
 			{
-				if (i > 0)
+				if (flush)
 				{
 					gGL.end();
-					gGL.flush();
 				}
+				flush = TRUE;
+				gGL.flush();
 				glLineWidth( (F32)line_width );
 				last_line_width = line_width;
 				gGL.begin(LLRender::LINES);
@@ -969,9 +973,9 @@ void LLViewerObjectList::renderObjectBeacons()
 		gGL.flush();
 		glLineWidth(1.f);
 
-		for (S32 i = 0; i < mDebugBeacons.count(); i++)
+		for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
 		{
-			LLDebugBeacon &debug_beacon = mDebugBeacons[i];
+			LLDebugBeacon &debug_beacon = *iter;
 			if (debug_beacon.mString == "")
 			{
 				continue;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 886f1d9ef54..4fdfc37d6cd 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2001,6 +2001,9 @@ BOOL LLViewerObject::isActive() const
 
 BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
+	static LLFastTimer::DeclareTimer ftm("Viewer Object");
+	LLFastTimer t(ftm);
+
 	if (mDead)
 	{
 		// It's dead.  Don't update it.
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 96828ee1b60..6347090f716 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -93,7 +93,7 @@ extern LLPipeline	gPipeline;
 
 // Statics for object lookup tables.
 U32						LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check.
-LLMap<U64, U32>			LLViewerObjectList::sIPAndPortToIndex;
+std::map<U64, U32>			LLViewerObjectList::sIPAndPortToIndex;
 std::map<U64, LLUUID>	LLViewerObjectList::sIndexAndLocalIDToUUID;
 
 LLViewerObjectList::LLViewerObjectList()
@@ -571,10 +571,9 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys,
 
 void LLViewerObjectList::dirtyAllObjectInventory()
 {
-	S32 count = mObjects.count();
-	for(S32 i = 0; i < count; ++i)
+	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 	{
-		mObjects[i]->dirtyInventory();
+		(*iter)->dirtyInventory();
 	}
 }
 
@@ -587,14 +586,14 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
 	S32 num_updates, max_value;
 	if (NUM_BINS - 1 == mCurBin)
 	{
-		num_updates = mObjects.count() - mCurLazyUpdateIndex;
-		max_value = mObjects.count();
+		num_updates = (S32) mObjects.size() - mCurLazyUpdateIndex;
+		max_value = (S32) mObjects.size();
 		gTextureList.setUpdateStats(TRUE);
 	}
 	else
 	{
-		num_updates = (mObjects.count() / NUM_BINS) + 1;
-		max_value = llmin(mObjects.count(), mCurLazyUpdateIndex + num_updates);
+		num_updates = ((S32) mObjects.size() / NUM_BINS) + 1;
+		max_value = llmin((S32) mObjects.size(), mCurLazyUpdateIndex + num_updates);
 	}
 
 
@@ -647,7 +646,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
 	}
 
 	mCurLazyUpdateIndex = max_value;
-	if (mCurLazyUpdateIndex == mObjects.count())
+	if (mCurLazyUpdateIndex == mObjects.size())
 	{
 		mCurLazyUpdateIndex = 0;
 	}
@@ -694,20 +693,26 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	
 	// Make a copy of the list in case something in idleUpdate() messes with it
 	std::vector<LLViewerObject*> idle_list;
-	idle_list.reserve( mActiveObjects.size() );
+	
+	static LLFastTimer::DeclareTimer idle_copy("Idle Copy");
 
- 	for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
-		active_iter != mActiveObjects.end(); active_iter++)
 	{
-		objectp = *active_iter;
-		if (objectp)
+		LLFastTimer t(idle_copy);
+		idle_list.reserve( mActiveObjects.size() );
+
+ 		for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
+			active_iter != mActiveObjects.end(); active_iter++)
 		{
-			idle_list.push_back( objectp );
-		}
-		else
-		{	// There shouldn't be any NULL pointers in the list, but they have caused
-			// crashes before.  This may be idleUpdate() messing with the list.
-			llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl;
+			objectp = *active_iter;
+			if (objectp)
+			{
+				idle_list.push_back( objectp );
+			}
+			else
+			{	// There shouldn't be any NULL pointers in the list, but they have caused
+				// crashes before.  This may be idleUpdate() messing with the list.
+				llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl;
+			}
 		}
 	}
 
@@ -807,7 +812,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	}
 	*/
 
-	LLViewerStats::getInstance()->mNumObjectsStat.addValue(mObjects.count());
+	LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size());
 	LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(num_active_objects);
 	LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled);
 	LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled);
@@ -815,9 +820,9 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 
 void LLViewerObjectList::clearDebugText()
 {
-	for (S32 i = 0; i < mObjects.count(); i++)
+	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 	{
-		mObjects[i]->setDebugText("");
+		(*iter)->setDebugText("");
 	}
 }
 
@@ -856,7 +861,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 
 	if (objectp->isOnMap())
 	{
-		mMapObjects.removeObj(objectp);
+		removeFromMap(objectp);
 	}
 
 	// Don't clean up mObject references, these will be cleaned up more efficiently later!
@@ -913,10 +918,10 @@ void LLViewerObjectList::killObjects(LLViewerRegion *regionp)
 {
 	LLViewerObject *objectp;
 
-	S32 i;
-	for (i = 0; i < mObjects.count(); i++)
+	
+	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 	{
-		objectp = mObjects[i];
+		objectp = *iter;
 		
 		if (objectp->mRegionp == regionp)
 		{
@@ -933,10 +938,9 @@ void LLViewerObjectList::killAllObjects()
 	// Used only on global destruction.
 	LLViewerObject *objectp;
 
-	for (S32 i = 0; i < mObjects.count(); i++)
+	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 	{
-		objectp = mObjects[i];
-		
+		objectp = *iter;
 		killObject(objectp);
 		llassert(objectp->isDead());
 	}
@@ -945,7 +949,7 @@ void LLViewerObjectList::killAllObjects()
 
 	if(!mObjects.empty())
 	{
-		llwarns << "LLViewerObjectList::killAllObjects still has entries in mObjects: " << mObjects.count() << llendl;
+		llwarns << "LLViewerObjectList::killAllObjects still has entries in mObjects: " << mObjects.size() << llendl;
 		mObjects.clear();
 	}
 
@@ -970,16 +974,15 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer)
 		return;
 	}
 
-	S32 i = 0;
 	S32 num_removed = 0;
 	LLViewerObject *objectp;
-	while (i < mObjects.count())
+	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); )
 	{
 		// Scan for all of the dead objects and remove any "global" references to them.
-		objectp = mObjects[i];
+		objectp = *iter;
 		if (objectp->isDead())
 		{
-			mObjects.remove(i);
+			iter = mObjects.erase(iter);
 			num_removed++;
 
 			if (num_removed == mNumDeadObjects)
@@ -990,8 +993,7 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer)
 		}
 		else
 		{
-			// iterate, this isn't a dead object.
-			i++;
+			++iter;
 		}
 	}
 
@@ -1041,12 +1043,11 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 	}
 
 	LLViewerObject *objectp;
-	S32 i;
-	for (i = 0; i < mObjects.count(); i++)
+	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 	{
-		objectp = getObject(i);
+		objectp = *iter;
 		// There could be dead objects on the object list, so don't update stuff if the object is dead.
-		if (objectp)
+		if (!objectp->isDead())
 		{
 			objectp->updatePositionCaches();
 
@@ -1076,9 +1077,9 @@ void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap)
 
 	F32 max_radius = gSavedSettings.getF32("MiniMapPrimMaxRadius");
 
-	for (S32 i = 0; i < mMapObjects.count(); i++)
+	for (vobj_list_t::iterator iter = mMapObjects.begin(); iter != mMapObjects.end(); ++iter)
 	{
-		LLViewerObject* objectp = mMapObjects[i];
+		LLViewerObject* objectp = *iter;
 		if (!objectp->getRegion() || objectp->isOrphaned() || objectp->isAttachment())
 		{
 			continue;
@@ -1144,21 +1145,14 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 &center)
 {
 }
 
-void LLViewerObjectList::renderObjectsForSelect(LLCamera &camera, const LLRect& screen_rect, BOOL pick_parcel_wall, BOOL render_transparent)
-{
-	generatePickList(camera);
-	renderPickList(screen_rect, pick_parcel_wall, render_transparent);
-}
-
 void LLViewerObjectList::generatePickList(LLCamera &camera)
 {
 		LLViewerObject *objectp;
 		S32 i;
 		// Reset all of the GL names to zero.
-		for (i = 0; i < mObjects.count(); i++)
+		for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 		{
-			objectp = mObjects[i];
-			objectp->mGLName = 0;
+			(*iter)->mGLName = 0;
 		}
 
 		mSelectPickList.clear();
@@ -1321,17 +1315,19 @@ void LLViewerObjectList::addDebugBeacon(const LLVector3 &pos_agent,
 										const LLColor4 &text_color,
 										S32 line_width)
 {
-	LLDebugBeacon *beaconp = mDebugBeacons.reserve_block(1);
-	beaconp->mPositionAgent = pos_agent;
-	beaconp->mString = string;
-	beaconp->mColor = color;
-	beaconp->mTextColor = text_color;
-	beaconp->mLineWidth = line_width;
+	LLDebugBeacon beacon;
+	beacon.mPositionAgent = pos_agent;
+	beacon.mString = string;
+	beacon.mColor = color;
+	beacon.mTextColor = text_color;
+	beacon.mLineWidth = line_width;
+
+	mDebugBeacons.push_back(beacon);
 }
 
 void LLViewerObjectList::resetObjectBeacons()
 {
-	mDebugBeacons.reset();
+	mDebugBeacons.clear();
 }
 
 LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp)
@@ -1349,7 +1345,7 @@ LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLVi
 
 	mUUIDObjectMap[fullid] = objectp;
 
-	mObjects.put(objectp);
+	mObjects.push_back(objectp);
 
 	updateActive(objectp);
 
@@ -1388,7 +1384,7 @@ LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRe
 					gMessageSystem->getSenderIP(),
 					gMessageSystem->getSenderPort());
 
-	mObjects.put(objectp);
+	mObjects.push_back(objectp);
 
 	updateActive(objectp);
 
@@ -1411,11 +1407,11 @@ LLViewerObject *LLViewerObjectList::replaceObject(const LLUUID &id, const LLPCod
 S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const
 {
 	LLViewerObject *objectp;
-	S32 i;
 	S32 num_refs = 0;
-	for (i = 0; i < mObjects.count(); i++)
+	
+	for (vobj_list_t::const_iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
 	{
-		objectp = mObjects[i];
+		objectp = *iter;
 		if (objectp->mDrawable.notNull())
 		{
 			num_refs += objectp->mDrawable->findReferences(drawablep);
@@ -1460,15 +1456,15 @@ void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip
 	// Unknown parent, add to orpaned child list
 	U64 parent_info = getIndex(parent_id, ip, port);
 
-	if (-1 == mOrphanParents.find(parent_info))
+	if (std::find(mOrphanParents.begin(), mOrphanParents.end(), parent_info) == mOrphanParents.end())
 	{
-		mOrphanParents.put(parent_info);
+		mOrphanParents.push_back(parent_info);
 	}
 
 	LLViewerObjectList::OrphanInfo oi(parent_info, childp->mID);
-	if (-1 == mOrphanChildren.find(oi))
+	if (std::find(mOrphanChildren.begin(), mOrphanChildren.end(), oi) == mOrphanChildren.end())
 	{
-		mOrphanChildren.put(oi);
+		mOrphanChildren.push_back(oi);
 		mNumOrphans++;
 	}
 }
@@ -1491,28 +1487,29 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
 	// See if we are a parent of an orphan.
 	// Note:  This code is fairly inefficient but it should happen very rarely.
 	// It can be sped up if this is somehow a performance issue...
-	if (0 == mOrphanParents.count())
+	if (mOrphanParents.empty())
 	{
 		// no known orphan parents
 		return;
 	}
-	if (-1 == mOrphanParents.find(getIndex(objectp->mLocalID, ip, port)))
+	if (std::find(mOrphanParents.begin(), mOrphanParents.end(), getIndex(objectp->mLocalID, ip, port)) == mOrphanParents.end())
 	{
 		// did not find objectp in OrphanParent list
 		return;
 	}
 
-	S32 i;
 	U64 parent_info = getIndex(objectp->mLocalID, ip, port);
 	BOOL orphans_found = FALSE;
 	// Iterate through the orphan list, and set parents of matching children.
-	for (i = 0; i < mOrphanChildren.count(); i++)
-	{
-		if (mOrphanChildren[i].mParentInfo != parent_info)
+
+	for (std::vector<OrphanInfo>::iterator iter = mOrphanChildren.begin(); iter != mOrphanChildren.end(); )
+	{	
+		if (iter->mParentInfo != parent_info)
 		{
+			++iter;
 			continue;
 		}
-		LLViewerObject *childp = findObject(mOrphanChildren[i].mChildInfo);
+		LLViewerObject *childp = findObject(iter->mChildInfo);
 		if (childp)
 		{
 			if (childp == objectp)
@@ -1546,29 +1543,35 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
 
 			objectp->addChild(childp);
 			orphans_found = TRUE;
+			++iter;
 		}
 		else
 		{
 			llinfos << "Missing orphan child, removing from list" << llendl;
-			mOrphanChildren.remove(i);
-			i--;
+
+			iter = mOrphanChildren.erase(iter);
 		}
 	}
 
 	// Remove orphan parent and children from lists now that they've been found
-	mOrphanParents.remove(mOrphanParents.find(parent_info));
-
-	i = 0;
-	while (i < mOrphanChildren.count())
 	{
-		if (mOrphanChildren[i].mParentInfo == parent_info)
+		std::vector<U64>::iterator iter = std::find(mOrphanParents.begin(), mOrphanParents.end(), parent_info);
+		if (iter != mOrphanParents.end())
+		{
+			mOrphanParents.erase(iter);
+		}
+	}
+	
+	for (std::vector<OrphanInfo>::iterator iter = mOrphanChildren.begin(); iter != mOrphanChildren.end(); )
+	{
+		if (iter->mParentInfo == parent_info)
 		{
-			mOrphanChildren.remove(i);
+			iter = mOrphanChildren.erase(iter);
 			mNumOrphans--;
 		}
 		else
 		{
-			i++;
+			++iter;
 		}
 	}
 
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index ace5c5038e7..8d3d2c4b44a 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -38,8 +38,6 @@
 
 // common includes
 #include "llstat.h"
-#include "lldarrayptr.h"
-#include "llmap.h"			// *TODO: switch to std::map
 #include "llstring.h"
 
 // project includes
@@ -50,7 +48,7 @@ class LLNetMap;
 class LLDebugBeacon;
 
 const U32 CLOSE_BIN_SIZE = 10;
-const U32 NUM_BINS = 16;
+const U32 NUM_BINS = 128;
 
 // GL name = position in object list + GL_NAME_INDEX_OFFSET so that
 // we can have special numbers like zero.
@@ -111,13 +109,12 @@ class LLViewerObjectList
 	void updateAvatarVisibility();
 
 	// Selection related stuff
-	void renderObjectsForSelect(LLCamera &camera, const LLRect& screen_rect, BOOL pick_parcel_wall = FALSE, BOOL render_transparent = TRUE);
 	void generatePickList(LLCamera &camera);
 	void renderPickList(const LLRect& screen_rect, BOOL pick_parcel_wall, BOOL render_transparent);
 
 	LLViewerObject *getSelectedObject(const U32 object_id);
 
-	inline S32 getNumObjects() { return mObjects.count(); }
+	inline S32 getNumObjects() { return (S32) mObjects.size(); }
 
 	void addToMap(LLViewerObject *objectp);
 	void removeFromMap(LLViewerObject *objectp);
@@ -131,7 +128,7 @@ class LLViewerObjectList
 
 	S32 findReferences(LLDrawable *drawablep) const; // Find references to drawable in all objects, and return value.
 
-	S32 getOrphanParentCount() const { return mOrphanParents.count(); }
+	S32 getOrphanParentCount() const { return (S32) mOrphanParents.size(); }
 	S32 getOrphanCount() const { return mNumOrphans; }
 	void orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port);
 	void findOrphans(LLViewerObject* objectp, U32 ip, U32 port);
@@ -179,26 +176,28 @@ class LLViewerObjectList
 	S32 mNumUnknownKills;
 	S32 mNumDeadObjects;
 protected:
-	LLDynamicArray<U64>	mOrphanParents;	// LocalID/ip,port of orphaned objects
-	LLDynamicArray<OrphanInfo> mOrphanChildren;	// UUID's of orphaned objects
+	std::vector<U64>	mOrphanParents;	// LocalID/ip,port of orphaned objects
+	std::vector<OrphanInfo> mOrphanChildren;	// UUID's of orphaned objects
 	S32 mNumOrphans;
 
-	LLDynamicArrayPtr<LLPointer<LLViewerObject>, 256> mObjects;
+	typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
+
+	vobj_list_t mObjects;
 	std::set<LLPointer<LLViewerObject> > mActiveObjects;
 
-	LLDynamicArrayPtr<LLPointer<LLViewerObject> > mMapObjects;
+	vobj_list_t mMapObjects;
 
 	typedef std::map<LLUUID, LLPointer<LLViewerObject> > vo_map;
 	vo_map mDeadObjects;	// Need to keep multiple entries per UUID
 
 	std::map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap;
 
-	LLDynamicArray<LLDebugBeacon> mDebugBeacons;
+	std::vector<LLDebugBeacon> mDebugBeacons;
 
 	S32 mCurLazyUpdateIndex;
 
 	static U32 sSimulatorMachineIndex;
-	static LLMap<U64, U32> sIPAndPortToIndex;
+	static std::map<U64, U32> sIPAndPortToIndex;
 
 	static std::map<U64, LLUUID> sIndexAndLocalIDToUUID;
 
@@ -260,12 +259,16 @@ inline LLViewerObject *LLViewerObjectList::getObject(const S32 index)
 
 inline void LLViewerObjectList::addToMap(LLViewerObject *objectp)
 {
-	mMapObjects.put(objectp);
+	mMapObjects.push_back(objectp);
 }
 
 inline void LLViewerObjectList::removeFromMap(LLViewerObject *objectp)
 {
-	mMapObjects.removeObj(objectp);
+	std::vector<LLPointer<LLViewerObject> >::iterator iter = std::find(mMapObjects.begin(), mMapObjects.end(), objectp);
+	if (iter != mMapObjects.end())
+	{
+		mMapObjects.erase(iter);
+	}
 }
 
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index cd6b9e2c502..de4317b2de0 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2316,6 +2316,9 @@ void append_xui_tooltip(LLView* viewp, LLToolTip::Params& params)
 // event processing.
 void LLViewerWindow::updateUI()
 {
+	static LLFastTimer::DeclareTimer ftm("Update UI");
+	LLFastTimer t(ftm);
+
 	static std::string last_handle_msg;
 
 	// animate layout stacks so we have up to date rect for world view
@@ -2895,7 +2898,6 @@ void LLViewerWindow::saveLastMouse(const LLCoordGL &point)
 // Must be called after displayObjects is called, which sets the mGLName parameter
 // NOTE: This function gets called 3 times:
 //  render_ui_3d: 			FALSE, FALSE, TRUE
-//  renderObjectsForSelect:	TRUE, pick_parcel_wall, FALSE
 //  render_hud_elements:	FALSE, FALSE, FALSE
 void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, BOOL for_hud )
 {
diff --git a/indra/newview/llvoclouds.cpp b/indra/newview/llvoclouds.cpp
index 177cb16c508..5153cef7094 100644
--- a/indra/newview/llvoclouds.cpp
+++ b/indra/newview/llvoclouds.cpp
@@ -77,9 +77,11 @@ BOOL LLVOClouds::isActive() const
 	return TRUE;
 }
 
-
 BOOL LLVOClouds::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
+	static LLFastTimer::DeclareTimer ftm("Idle Clouds");
+	LLFastTimer t(ftm);
+
 	if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS)))
 	{
 		return TRUE;
diff --git a/indra/newview/llvotextbubble.cpp b/indra/newview/llvotextbubble.cpp
index 75beab519e0..428ef200064 100644
--- a/indra/newview/llvotextbubble.cpp
+++ b/indra/newview/llvotextbubble.cpp
@@ -84,6 +84,9 @@ BOOL LLVOTextBubble::isActive() const
 
 BOOL LLVOTextBubble::idleUpdate(LLAgent &agent, LLWorld	&world, const F64 &time)
 {
+	static LLFastTimer::DeclareTimer ftm("Text Bubble");
+	LLFastTimer t(ftm);
+
 	F32 dt = mUpdateTimer.getElapsedTimeF32();
 	// Die after a few seconds.
 	if (dt > 1.5f)
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index bfe38c14ba9..3cdf485d7d8 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -597,6 +597,9 @@ BOOL LLVOVolume::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
 	LLViewerObject::idleUpdate(agent, world, time);
 
+	static LLFastTimer::DeclareTimer ftm("Volume");
+	LLFastTimer t(ftm);
+
 	if (mDead || mDrawable.isNull())
 	{
 		return TRUE;
@@ -618,6 +621,18 @@ BOOL LLVOVolume::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 		mVolumeImpl->doIdleUpdate(agent, world, time);
 	}
 
+	const S32 MAX_ACTIVE_OBJECT_QUIET_FRAMES = 40;
+
+	if (mDrawable->isActive())
+	{
+		if (mDrawable->isRoot() && 
+			mDrawable->mQuietCount++ > MAX_ACTIVE_OBJECT_QUIET_FRAMES && 
+			(!mDrawable->getParent() || !mDrawable->getParent()->isActive()))
+		{
+			mDrawable->makeStatic();
+		}
+	}
+
 	return TRUE;
 }
 
@@ -1035,7 +1050,7 @@ BOOL LLVOVolume::calcLOD()
 	S32 cur_detail = 0;
 	
 	F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length();
-	F32 distance = llmin(mDrawable->mDistanceWRTCamera, MAX_LOD_DISTANCE);
+	F32 distance = mDrawable->mDistanceWRTCamera; //llmin(mDrawable->mDistanceWRTCamera, MAX_LOD_DISTANCE);
 	distance *= sDistanceFactor;
 			
 	F32 rampDist = LLVOVolume::sLODFactor * 2;
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 118d7f8d08d..d7e5b464a65 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -657,6 +657,9 @@ void LLWorld::updateParticles()
 
 void LLWorld::updateClouds(const F32 dt)
 {
+	static LLFastTimer::DeclareTimer ftm("World Clouds");
+	LLFastTimer t(ftm);
+
 	if (gSavedSettings.getBOOL("FreezeTime") ||
 		!gSavedSettings.getBOOL("SkyUseClassicClouds"))
 	{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 4f4fc838191..d5f87b73fe2 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -116,7 +116,6 @@ const F32 BACKLIGHT_DAY_MAGNITUDE_AVATAR = 0.2f;
 const F32 BACKLIGHT_NIGHT_MAGNITUDE_AVATAR = 0.1f;
 const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
 const F32 BACKLIGHT_NIGHT_MAGNITUDE_OBJECT = 0.08f;
-const S32 MAX_ACTIVE_OBJECT_QUIET_FRAMES = 40;
 const S32 MAX_OFFSCREEN_GEOMETRY_CHANGES_PER_FRAME = 10;
 const U32 REFLECTION_MAP_RES = 128;
 
@@ -1411,38 +1410,26 @@ void LLPipeline::updateMove()
 
 	assertInitialized();
 
-	for (LLDrawable::drawable_set_t::iterator iter = mRetexturedList.begin();
-		 iter != mRetexturedList.end(); ++iter)
 	{
-		LLDrawable* drawablep = *iter;
-		if (drawablep && !drawablep->isDead())
-		{
-			drawablep->updateTexture();
-		}
-	}
-	mRetexturedList.clear();
+		static LLFastTimer::DeclareTimer ftm("Retexture");
+		LLFastTimer t(ftm);
 
-	updateMovedList(mMovedList);
-
-	for (LLDrawable::drawable_set_t::iterator iter = mActiveQ.begin();
-		 iter != mActiveQ.end(); )
-	{
-		LLDrawable::drawable_set_t::iterator curiter = iter++;
-		LLDrawable* drawablep = *curiter;
-		if (drawablep && !drawablep->isDead()) 
+		for (LLDrawable::drawable_set_t::iterator iter = mRetexturedList.begin();
+			 iter != mRetexturedList.end(); ++iter)
 		{
-			if (drawablep->isRoot() && 
-				drawablep->mQuietCount++ > MAX_ACTIVE_OBJECT_QUIET_FRAMES && 
-				(!drawablep->getParent() || !drawablep->getParent()->isActive()))
+			LLDrawable* drawablep = *iter;
+			if (drawablep && !drawablep->isDead())
 			{
-				drawablep->makeStatic(); // removes drawable and its children from mActiveQ
-				iter = mActiveQ.upper_bound(drawablep); // next valid entry
+				drawablep->updateTexture();
 			}
 		}
-		else
-		{
-			mActiveQ.erase(curiter);
-		}
+		mRetexturedList.clear();
+	}
+
+	{
+		static LLFastTimer::DeclareTimer ftm("Moved List");
+		LLFastTimer t(ftm);
+		updateMovedList(mMovedList);
 	}
 
 	//balance octrees
@@ -3058,12 +3045,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 		}
 	}
 
-	if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PICKING))
-	{
-		LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderForSelect");
-		gObjectList.renderObjectsForSelect(camera, gViewerWindow->getWindowRectScaled());
-	}
-	else
 	{
 		LLFastTimer t(FTM_POOLS);
 		
@@ -4797,10 +4778,6 @@ void LLPipeline::findReferences(LLDrawable *drawablep)
 		llinfos << "In mRetexturedList" << llendl;
 	}
 	
-	if (mActiveQ.find(drawablep) != mActiveQ.end())
-	{
-		llinfos << "In mActiveQ" << llendl;
-	}
 	if (std::find(mBuildQ1.begin(), mBuildQ1.end(), drawablep) != mBuildQ1.end())
 	{
 		llinfos << "In mBuildQ1" << llendl;
@@ -4957,19 +4934,6 @@ void LLPipeline::setLight(LLDrawable *drawablep, BOOL is_light)
 	}
 }
 
-void LLPipeline::setActive(LLDrawable *drawablep, BOOL active)
-{
-	assertInitialized();
-	if (active)
-	{
-		mActiveQ.insert(drawablep);
-	}
-	else
-	{
-		mActiveQ.erase(drawablep);
-	}
-}
-
 //static
 void LLPipeline::toggleRenderType(U32 type)
 {
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 67004a5f2d9..c5285943e84 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -270,8 +270,7 @@ class LLPipeline
 	void shiftObjects(const LLVector3 &offset);
 
 	void setLight(LLDrawable *drawablep, BOOL is_light);
-	void setActive(LLDrawable *drawablep, BOOL active);
-
+	
 	BOOL hasRenderBatches(const U32 type) const;
 	LLCullResult::drawinfo_list_t::iterator beginRenderMap(U32 type);
 	LLCullResult::drawinfo_list_t::iterator endRenderMap(U32 type);
@@ -589,8 +588,6 @@ class LLPipeline
 
 	LLViewerObject::vobj_list_t		mCreateQ;
 		
-	LLDrawable::drawable_set_t		mActiveQ;
-	
 	LLDrawable::drawable_set_t		mRetexturedList;
 
 	class HighlightItem
-- 
GitLab


From f5572abb5eb0c202c96e044f99e47bccfb97ef4a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 12:49:54 +0000
Subject: [PATCH 119/683] Backed out changeset 6c161782dba3

---
 indra/llrender/llfontgl.cpp      |  30 +++------
 indra/llrender/llrender.cpp      | 106 ++++++++++++++++++++++++++++-
 indra/llrender/llrender.h        |  18 ++++-
 indra/llui/lltabcontainer.cpp    |  12 ++--
 indra/llui/llui.cpp              | 112 ++++++++++++++++++++-----------
 indra/llui/llviewborder.cpp      |  58 ----------------
 indra/llui/llviewborder.h        |   3 +-
 indra/newview/llhudrender.cpp    |  12 ++--
 indra/newview/llhudtext.cpp      |   2 +-
 indra/newview/llmediactrl.cpp    |   8 +--
 indra/newview/llnetmap.cpp       |  15 +++++
 indra/newview/llviewerwindow.cpp |  14 +++-
 12 files changed, 249 insertions(+), 141 deletions(-)

diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 1de1d6ded4a..129f3e79994 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -151,14 +151,16 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 		}
 	}
 
-	gGL.pushMatrix();
-	glLoadIdentity();
-	gGL.translatef(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
+	gGL.pushUIMatrix();
+
+	gGL.loadUIIdentity();
+	
+	gGL.translateUI(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
 
 	// this code snaps the text origin to a pixel grid to start with
 	F32 pixel_offset_x = llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
 	F32 pixel_offset_y = llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
-	gGL.translatef(-pixel_offset_x, -pixel_offset_y, 0.f);
+	gGL.translateUI(-pixel_offset_x, -pixel_offset_y, 0.f);
 
 	LLFastTimer t(FTM_RENDER_FONTS);
 
@@ -246,9 +248,6 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 	}
 
 
-	// Remember last-used texture to avoid unnecesssary bind calls.
-	LLImageGL *last_bound_texture = NULL;
-
 	for (i = begin_offset; i < begin_offset + length; i++)
 	{
 		llwchar wch = wstr[i];
@@ -261,12 +260,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 		}
 		// Per-glyph bitmap texture.
 		LLImageGL *image_gl = mFontFreetype->getFontBitmapCache()->getImageGL(fgi->mBitmapNum);
-		if (last_bound_texture != image_gl)
-		{
-			gGL.getTexUnit(0)->bind(image_gl);
-			last_bound_texture = image_gl;
-		}
-
+		gGL.getTexUnit(0)->bind(image_gl);
+	
 		if ((start_x + scaled_max_pixels) < (cur_x + fgi->mXBearing + fgi->mWidth))
 		{
 			// Not enough room for this character.
@@ -330,10 +325,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 		
 		// recursively render ellipses at end of string
 		// we've already reserved enough room
-		gGL.pushMatrix();
-		//glLoadIdentity();
-		//gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f);
-		//glScalef(sScaleX, sScaleY, 1.f);
+		gGL.pushUIMatrix();
 		renderUTF8(std::string("..."), 
 				0,
 				cur_x / sScaleX, (F32)y,
@@ -344,10 +336,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 				S32_MAX, max_pixels,
 				right_x,
 				FALSE); 
-		gGL.popMatrix();
+		gGL.popUIMatrix();
 	}
 
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 
 	return chars_drawn;
 }
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index f97d81126ec..cde60b7e259 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -49,6 +49,9 @@ F64 gGLLastProjection[16];
 F64 gGLProjection[16];
 S32	gGLViewport[4];
 
+U32 LLRender::sUICalls = 0;
+U32 LLRender::sUIVerts = 0;
+
 static const U32 LL_NUM_TEXTURE_LAYERS = 16; 
 
 static GLenum sGLTextureType[] =
@@ -255,10 +258,9 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind)
 		return false ;
 	}
 
-	gGL.flush();
-
 	if ((mCurrTexture != texture->getTexName()) || forceBind)
 	{
+		gGL.flush();
 		activate();
 		enable(texture->getTarget());
 		mCurrTexture = texture->getTexName();
@@ -445,6 +447,8 @@ void LLTexUnit::setTextureBlendType(eTextureBlendType type)
 		return;
 	}
 
+	gGL.flush();
+
 	activate();
 	mCurrBlendType = type;
 	S32 scale_amount = 1;
@@ -756,6 +760,7 @@ LLRender::LLRender()
 
 	mCurrAlphaFunc = CF_DEFAULT;
 	mCurrAlphaFuncVal = 0.01f;
+	mCurrSceneBlendType = BT_ALPHA;
 }
 
 LLRender::~LLRender()
@@ -818,6 +823,80 @@ void LLRender::popMatrix()
 	glPopMatrix();
 }
 
+void LLRender::translateUI(F32 x, F32 y, F32 z)
+{
+	if (mUIOffset.empty())
+	{
+		llerrs << "Need to push a UI translation frame before offsetting" << llendl;
+	}
+
+	mUIOffset.front().mV[0] += x;
+	mUIOffset.front().mV[1] += y;
+	mUIOffset.front().mV[2] += z;
+}
+
+void LLRender::scaleUI(F32 x, F32 y, F32 z)
+{
+	if (mUIScale.empty())
+	{
+		llerrs << "Need to push a UI transformation frame before scaling." << llendl;
+	}
+
+	mUIScale.front().scaleVec(LLVector3(x,y,z));
+}
+
+void LLRender::pushUIMatrix()
+{
+	mUIOffset.push_front(mUIOffset.front());
+	if (mUIScale.empty())
+	{
+		mUIScale.push_front(LLVector3(1,1,1));
+	}
+	else
+	{
+		mUIScale.push_front(mUIScale.front());
+	}
+}
+
+void LLRender::popUIMatrix()
+{
+	if (mUIOffset.empty())
+	{
+		llerrs << "UI offset stack blown." << llendl;
+	}
+	mUIOffset.pop_front();
+	mUIScale.pop_front();
+}
+
+LLVector3 LLRender::getUITranslation()
+{
+	if (mUIOffset.empty())
+	{
+		llerrs << "UI offset stack empty." << llendl;
+	}
+	return mUIOffset.front();
+}
+
+LLVector3 LLRender::getUIScale()
+{
+	if (mUIScale.empty())
+	{
+		llerrs << "UI scale stack empty." << llendl;
+	}
+	return mUIScale.front();
+}
+
+
+void LLRender::loadUIIdentity()
+{
+	if (mUIOffset.empty())
+	{
+		llerrs << "Need to push UI translation frame before clearing offset." << llendl;
+	}
+	mUIOffset.front().setVec(0,0,0);
+	mUIScale.front().setVec(1,1,1);
+}
+
 void LLRender::setColorMask(bool writeColor, bool writeAlpha)
 {
 	setColorMask(writeColor, writeColor, writeColor, writeAlpha);
@@ -840,6 +919,11 @@ void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB
 
 void LLRender::setSceneBlendType(eBlendType type)
 {
+	if (mCurrSceneBlendType == type)
+	{
+		return;
+	}
+
 	flush();
 	switch (type) 
 	{
@@ -868,6 +952,7 @@ void LLRender::setSceneBlendType(eBlendType type)
 			llerrs << "Unknown Scene Blend Type: " << type << llendl;
 			break;
 	}
+	mCurrSceneBlendType = type;
 }
 
 void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
@@ -1009,6 +1094,12 @@ void LLRender::flush()
 		}
 #endif
 				
+		if (!mUIOffset.empty())
+		{
+			sUICalls++;
+			sUIVerts += mCount;
+		}
+
 		mBuffer->setBuffer(immediate_mask);
 		mBuffer->drawArrays(mMode, 0, mCount);
 		
@@ -1028,7 +1119,16 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
 		return;
 	}
 
-	mVerticesp[mCount] = LLVector3(x,y,z);
+	if (mUIOffset.empty())
+	{
+		mVerticesp[mCount] = LLVector3(x,y,z);
+	}
+	else
+	{
+		LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.front()).scaledVec(mUIScale.front());
+		mVerticesp[mCount] = vert;
+	}
+
 	mCount++;
 	if (mCount < 4096)
 	{
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 0121a190ee5..6e38fac67b2 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -286,6 +286,14 @@ class LLRender
 	void pushMatrix();
 	void popMatrix();
 
+	void translateUI(F32 x, F32 y, F32 z);
+	void scaleUI(F32 x, F32 y, F32 z);
+	void pushUIMatrix();
+	void popUIMatrix();
+	void loadUIIdentity();
+	LLVector3 getUITranslation();
+	LLVector3 getUIScale();
+
 	void flush();
 
 	void begin(const GLuint& mode);
@@ -333,7 +341,9 @@ class LLRender
 	};
 
 public:
-
+	static U32 sUICalls;
+	static U32 sUIVerts;
+	
 private:
 	bool				mDirty;
 	U32				mCount;
@@ -350,7 +360,13 @@ class LLRender
 	std::vector<LLTexUnit*>		mTexUnits;
 	LLTexUnit*			mDummyTexUnit;
 
+	U32				mCurrSceneBlendType;
+
 	F32				mMaxAnisotropy;
+
+	std::list<LLVector3> mUIOffset;
+	std::list<LLVector3> mUIScale;
+
 };
 
 extern F64 gGLModelView[16];
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 6be76605fdf..f11bc2173c5 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -402,15 +402,15 @@ void LLTabContainer::draw()
 		if( mIsVertical && has_scroll_arrows )
 		{
 			// Redraw the arrows so that they appears on top.
-			gGL.pushMatrix();
-			gGL.translatef((F32)mPrevArrowBtn->getRect().mLeft, (F32)mPrevArrowBtn->getRect().mBottom, 0.f);
+			gGL.pushUIMatrix();
+			gGL.translateUI((F32)mPrevArrowBtn->getRect().mLeft, (F32)mPrevArrowBtn->getRect().mBottom, 0.f);
 			mPrevArrowBtn->draw();
-			gGL.popMatrix();
+			gGL.popUIMatrix();
 
-			gGL.pushMatrix();
-			gGL.translatef((F32)mNextArrowBtn->getRect().mLeft, (F32)mNextArrowBtn->getRect().mBottom, 0.f);
+			gGL.pushUIMatrix();
+			gGL.translateUI((F32)mNextArrowBtn->getRect().mLeft, (F32)mNextArrowBtn->getRect().mBottom, 0.f);
 			mNextArrowBtn->draw();
-			gGL.popMatrix();
+			gGL.popUIMatrix();
 		}
 	}
 
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index d0ed3b6fcae..0e2e8bf8ed0 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -39,6 +39,7 @@
 
 // Linden library includes
 #include "v2math.h"
+#include "m3math.h"
 #include "v4color.h"
 #include "llrender.h"
 #include "llrect.h"
@@ -180,19 +181,19 @@ void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, const LL
 
 void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, S32 pixel_offset, BOOL filled)
 {
-	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 	left += LLFontGL::sCurOrigin.mX;
 	right += LLFontGL::sCurOrigin.mX;
 	bottom += LLFontGL::sCurOrigin.mY;
 	top += LLFontGL::sCurOrigin.mY;
 
-	glLoadIdentity();
+	gGL.loadUIIdentity();
 	gl_rect_2d(llfloor((F32)left * LLUI::sGLScaleFactor.mV[VX]) - pixel_offset,
 				llfloor((F32)top * LLUI::sGLScaleFactor.mV[VY]) + pixel_offset,
 				llfloor((F32)right * LLUI::sGLScaleFactor.mV[VX]) + pixel_offset,
 				llfloor((F32)bottom * LLUI::sGLScaleFactor.mV[VY]) - pixel_offset,
 				filled);
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 }
 
 
@@ -508,9 +509,9 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
 		gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA);
 	}
 
-	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 	{
-		gGL.translatef((F32)x, (F32)y, 0.f);
+		gGL.translateUI((F32)x, (F32)y, 0.f);
 
 		gGL.getTexUnit(0)->bind(image);
 
@@ -637,7 +638,7 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
 		}
 		gGL.end();
 	}
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 
 	if (solid_color)
 	{
@@ -660,39 +661,72 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 
 	LLGLSUIDefault gls_ui;
 
-	gGL.pushMatrix();
+
+	gGL.getTexUnit(0)->bind(image);
+
+	gGL.color4fv(color.mV);
+
+	if (degrees == 0.f)
 	{
-		gGL.translatef((F32)x, (F32)y, 0.f);
-		if( degrees )
+		gGL.pushUIMatrix();
+		gGL.translateUI((F32)x, (F32)y, 0.f);
+			
+		gGL.begin(LLRender::QUADS);
 		{
-			F32 offset_x = F32(width/2);
-			F32 offset_y = F32(height/2);
-			gGL.translatef( offset_x, offset_y, 0.f);
-			glRotatef( degrees, 0.f, 0.f, 1.f );
-			gGL.translatef( -offset_x, -offset_y, 0.f );
+			gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
+			gGL.vertex2i(width, height );
+
+			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
+			gGL.vertex2i(0, height );
+
+			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
+			gGL.vertex2i(0, 0);
+
+			gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
+			gGL.vertex2i(width, 0);
 		}
+		gGL.end();
+		gGL.popUIMatrix();
+	}
+	else
+	{
+		gGL.pushUIMatrix();
+		gGL.translateUI((F32)x, (F32)y, 0.f);
+	
+		F32 offset_x = F32(width/2);
+		F32 offset_y = F32(height/2);
+
+		gGL.translateUI(offset_x, offset_y, 0.f);
 
+		LLMatrix3 quat(0.f, 0.f, degrees*DEG_TO_RAD);
+		
 		gGL.getTexUnit(0)->bind(image);
 
 		gGL.color4fv(color.mV);
 		
 		gGL.begin(LLRender::QUADS);
 		{
+			LLVector3 v;
+
+			v = LLVector3(offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
-			gGL.vertex2i(width, height );
+			gGL.vertex2i(v.mV[0], v.mV[1] );
 
+			v = LLVector3(-offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
-			gGL.vertex2i(0, height );
+			gGL.vertex2i(v.mV[0], v.mV[1] );
 
+			v = LLVector3(-offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
-			gGL.vertex2i(0, 0);
+			gGL.vertex2i(v.mV[0], v.mV[1] );
 
+			v = LLVector3(offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
-			gGL.vertex2i(width, 0);
+			gGL.vertex2i(v.mV[0], v.mV[1] );
 		}
 		gGL.end();
+		gGL.popUIMatrix();
 	}
-	gGL.popMatrix();
 }
 
 
@@ -747,9 +781,9 @@ void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F
 		end_angle += F_TWO_PI;
 	}
 
-	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 	{
-		gGL.translatef(center_x, center_y, 0.f);
+		gGL.translateUI(center_x, center_y, 0.f);
 
 		// Inexact, but reasonably fast.
 		F32 delta = (end_angle - start_angle) / steps;
@@ -780,15 +814,15 @@ void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F
 		}
 		gGL.end();
 	}
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 }
 
 void gl_circle_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled)
 {
-	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 	{
 		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-		gGL.translatef(center_x, center_y, 0.f);
+		gGL.translateUI(center_x, center_y, 0.f);
 
 		// Inexact, but reasonably fast.
 		F32 delta = F_TWO_PI / steps;
@@ -819,7 +853,7 @@ void gl_circle_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled
 		}
 		gGL.end();
 	}
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 }
 
 // Renders a ring with sides (tube shape)
@@ -846,9 +880,9 @@ void gl_deep_circle( F32 radius, F32 depth, S32 steps )
 
 void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor4& side_color, S32 steps, BOOL render_center )
 {
-	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 	{
-		gGL.translatef(0.f, 0.f, -width / 2);
+		gGL.translateUI(0.f, 0.f, -width / 2);
 		if( render_center )
 		{
 			gGL.color4fv(center_color.mV);
@@ -857,11 +891,11 @@ void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor
 		else
 		{
 			gl_washer_2d(radius, radius - width, steps, side_color, side_color);
-			gGL.translatef(0.f, 0.f, width);
+			gGL.translateUI(0.f, 0.f, width);
 			gl_washer_2d(radius - width, radius, steps, side_color, side_color);
 		}
 	}
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 }
 
 // Draw gray and white checkerboard with black border
@@ -1050,9 +1084,9 @@ void gl_segmented_rect_2d_tex(const S32 left,
 	S32 width = llabs(right - left);
 	S32 height = llabs(top - bottom);
 
-	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 
-	gGL.translatef((F32)left, (F32)bottom, 0.f);
+	gGL.translateUI((F32)left, (F32)bottom, 0.f);
 	LLVector2 border_uv_scale((F32)border_size / (F32)texture_width, (F32)border_size / (F32)texture_height);
 
 	if (border_uv_scale.mV[VX] > 0.5f)
@@ -1193,7 +1227,7 @@ void gl_segmented_rect_2d_tex(const S32 left,
 	}
 	gGL.end();
 
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 }
 
 void gl_segmented_rect_2d_fragment_tex(const S32 left, 
@@ -1210,9 +1244,9 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left,
 	S32 width = llabs(right - left);
 	S32 height = llabs(top - bottom);
 
-	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 
-	gGL.translatef((F32)left, (F32)bottom, 0.f);
+	gGL.translateUI((F32)left, (F32)bottom, 0.f);
 	LLVector2 border_uv_scale((F32)border_size / (F32)texture_width, (F32)border_size / (F32)texture_height);
 
 	if (border_uv_scale.mV[VX] > 0.5f)
@@ -1383,7 +1417,7 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left,
 	}
 	gGL.end();
 
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 }
 
 void gl_segmented_rect_3d_tex(const LLVector2& border_scale, const LLVector3& border_width, 
@@ -1591,7 +1625,7 @@ void LLUI::dirtyRect(LLRect rect)
 //static
 void LLUI::translate(F32 x, F32 y, F32 z)
 {
-	gGL.translatef(x,y,z);
+	gGL.translateUI(x,y,z);
 	LLFontGL::sCurOrigin.mX += (S32) x;
 	LLFontGL::sCurOrigin.mY += (S32) y;
 	LLFontGL::sCurOrigin.mZ += z;
@@ -1600,14 +1634,14 @@ void LLUI::translate(F32 x, F32 y, F32 z)
 //static
 void LLUI::pushMatrix()
 {
-	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 	LLFontGL::sOriginStack.push_back(LLFontGL::sCurOrigin);
 }
 
 //static
 void LLUI::popMatrix()
 {
-	gGL.popMatrix();
+	gGL.popUIMatrix();
 	LLFontGL::sCurOrigin = *LLFontGL::sOriginStack.rbegin();
 	LLFontGL::sOriginStack.pop_back();
 }
@@ -1615,7 +1649,7 @@ void LLUI::popMatrix()
 //static 
 void LLUI::loadIdentity()
 {
-	glLoadIdentity();
+	gGL.loadUIIdentity(); 
 	LLFontGL::sCurOrigin.mX = 0;
 	LLFontGL::sCurOrigin.mY = 0;
 	LLFontGL::sCurOrigin.mZ = 0;
diff --git a/indra/llui/llviewborder.cpp b/indra/llui/llviewborder.cpp
index 30717f87def..bd9c43c97f0 100644
--- a/indra/llui/llviewborder.cpp
+++ b/indra/llui/llviewborder.cpp
@@ -125,14 +125,6 @@ void LLViewBorder::draw()
 			llassert( FALSE );  // not implemented
 		}
 	}
-	else
-	if( STYLE_TEXTURE == mStyle )
-	{
-		if( mTexture )
-		{
-			drawTextures();
-		}
-	}
 
 	LLView::draw();
 }
@@ -255,56 +247,6 @@ void LLViewBorder::drawTwoPixelLines()
 	gl_line_2d(left+1, bottom+1, right-1, bottom+1);
 }
 
-void LLViewBorder::drawTextures()
-{
-	//LLGLSUIDefault gls_ui;
-
-	//llassert( FALSE );  // TODO: finish implementing
-
-	//gGL.color4fv(UI_VERTEX_COLOR.mV);
-
-	//gGL.getTexUnit(0)->bind(mTexture);
-	//gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP);
-
-	//drawTextureTrapezoid(   0.f, mBorderWidth, getRect().getWidth(),  0,					0 );
-	//drawTextureTrapezoid(  90.f, mBorderWidth, getRect().getHeight(), (F32)getRect().getWidth(),0 );
-	//drawTextureTrapezoid( 180.f, mBorderWidth, getRect().getWidth(),  (F32)getRect().getWidth(),(F32)getRect().getHeight() );
-	//drawTextureTrapezoid( 270.f, mBorderWidth, getRect().getHeight(), 0,					(F32)getRect().getHeight() );
-}
-
-
-void LLViewBorder::drawTextureTrapezoid( F32 degrees, S32 width, S32 length, F32 start_x, F32 start_y )
-{
-	gGL.pushMatrix();
-	{
-		gGL.translatef(start_x, start_y, 0.f);
-		glRotatef( degrees, 0, 0, 1 );
-
-		gGL.begin(LLRender::QUADS);
-		{
-			//      width, width   /---------\ length-width, width		//
-			//	   			      /           \							//
-			//				     /			   \						//
-			//				    /---------------\						//
-			//    			0,0					  length, 0				//
-
-			gGL.texCoord2f( 0, 0 );
-			gGL.vertex2i( 0, 0 );
-
-			gGL.texCoord2f( (GLfloat)length, 0 );
-			gGL.vertex2i( length, 0 );
-
-			gGL.texCoord2f( (GLfloat)(length - width), (GLfloat)width );
-			gGL.vertex2i( length - width, width );
-
-			gGL.texCoord2f( (GLfloat)width, (GLfloat)width );
-			gGL.vertex2i( width, width );
-		}
-		gGL.end();
-	}
-	gGL.popMatrix();
-}
-
 BOOL LLViewBorder::getBevelFromAttribute(LLXMLNodePtr node, LLViewBorder::EBevel& bevel_style)
 {
 	if (node->hasAttribute("bevel_style"))
diff --git a/indra/llui/llviewborder.h b/indra/llui/llviewborder.h
index 92fd5693250..342e84fd93e 100644
--- a/indra/llui/llviewborder.h
+++ b/indra/llui/llviewborder.h
@@ -99,8 +99,7 @@ class LLViewBorder : public LLView
 	void		drawOnePixelLines();
 	void		drawTwoPixelLines();
 	void		drawTextures();
-	void		drawTextureTrapezoid( F32 degrees, S32 width, S32 length, F32 start_x, F32 start_y );
-
+	
 	EBevel		mBevel;
 	EStyle		mStyle;
 	LLUIColor	mHighlightLight;
diff --git a/indra/newview/llhudrender.cpp b/indra/newview/llhudrender.cpp
index a02dc3355b1..325c9c260ca 100644
--- a/indra/newview/llhudrender.cpp
+++ b/indra/newview/llhudrender.cpp
@@ -121,24 +121,24 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent,
 	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
 	glMatrixMode(GL_MODELVIEW);
-	
+	gGL.pushMatrix();
 	LLUI::pushMatrix();
 		
 	gl_state_for_2d(world_view_rect.getWidth(), world_view_rect.getHeight());
 	gViewerWindow->setup3DViewport();
-	//gViewerWindow->setup2DRender();
-
+	
 	winX -= world_view_rect.mLeft;
 	winY -= world_view_rect.mBottom;
 	LLUI::loadIdentity();
+	glLoadIdentity();
 	LLUI::translate((F32) winX*1.0f/LLFontGL::sScaleX, (F32) winY*1.0f/(LLFontGL::sScaleY), -(((F32) winZ*2.f)-1.f));
-	//glRotatef(angle * RAD_TO_DEG, axis.mV[VX], axis.mV[VY], axis.mV[VZ]);
-	//glScalef(right_scale, up_scale, 1.f);
 	F32 right_x;
 	
 	font.render(wstr, 0, 0, 0, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, shadow, wstr.length(), 1000, &right_x);
+
 	LLUI::popMatrix();
-	
+	gGL.popMatrix();
+
 	glMatrixMode(GL_PROJECTION);
 	glPopMatrix();
 	glMatrixMode(GL_MODELVIEW);
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 8ad94b957d7..8d1d27444b9 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -555,7 +555,7 @@ void LLHUDText::renderText(BOOL for_select)
 		}
 	}
 	/// Reset the default color to white.  The renderer expects this to be the default. 
-	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+	gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f);
 	if (for_select)
 	{
 		gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index d464862eedc..6fd6958d2e5 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -724,14 +724,14 @@ void LLMediaCtrl::draw()
 		LLGLSUIDefault gls_ui;
 		LLGLDisable gls_alphaTest( GL_ALPHA_TEST );
 
-		gGL.pushMatrix();
+		gGL.pushUIMatrix();
 		{
 			if (mIgnoreUIScale)
 			{
-				glLoadIdentity();
+				gGL.loadUIIdentity();
 				// font system stores true screen origin, need to scale this by UI scale factor
 				// to get render origin for this view (with unit scale)
-				gGL.translatef(floorf(LLFontGL::sCurOrigin.mX * LLUI::sGLScaleFactor.mV[VX]), 
+				gGL.translateUI(floorf(LLFontGL::sCurOrigin.mX * LLUI::sGLScaleFactor.mV[VX]), 
 							floorf(LLFontGL::sCurOrigin.mY * LLUI::sGLScaleFactor.mV[VY]), 
 							LLFontGL::sCurOrigin.mZ);
 			}
@@ -825,7 +825,7 @@ void LLMediaCtrl::draw()
 			gGL.end();
 			gGL.setSceneBlendType(LLRender::BT_ALPHA);
 		}
-		gGL.popMatrix();
+		gGL.popUIMatrix();
 	
 	}
 	else
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index 234fe13217f..05623198ab6 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -153,6 +153,18 @@ void LLNetMap::draw()
 	// Prepare a scissor region
 	F32 rotation = 0;
 
+	gGL.pushMatrix();
+	gGL.pushUIMatrix();
+	
+	LLVector3 offset = gGL.getUITranslation();
+	LLVector3 scale = gGL.getUIScale();
+
+	glLoadIdentity();
+	gGL.loadUIIdentity();
+
+	glScalef(scale.mV[0], scale.mV[1], scale.mV[2]);
+	gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]);
+	
 	{
 		LLLocalClipRect clip(getLocalRect());
 		{
@@ -435,6 +447,9 @@ void LLNetMap::draw()
 		}
 	}
 	
+	gGL.popMatrix();
+	gGL.popUIMatrix();
+
 	LLUICtrl::draw();
 }
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index de4317b2de0..f6227c2dd6f 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -476,6 +476,10 @@ class LLDebugText
 			}
             ypos += y_inc;
 
+			addText(xpos, ypos, llformat("UI Verts/Calls: %d/%d", LLRender::sUIVerts, LLRender::sUICalls));
+			LLRender::sUICalls = LLRender::sUIVerts = 0;
+			ypos += y_inc;
+
 			addText(xpos,ypos, llformat("%d/%d Nodes visible", gPipeline.mNumVisibleNodes, LLSpatialGroup::sNodeCount));
 			
 			ypos += y_inc;
@@ -1843,12 +1847,15 @@ void LLViewerWindow::drawDebugText()
 {
 	gGL.color4f(1,1,1,1);
 	gGL.pushMatrix();
+	gGL.pushUIMatrix();
 	{
 		// scale view by UI global scale factor and aspect ratio correction factor
-		glScalef(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f);
+		gGL.scaleUI(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f);
 		mDebugText->draw();
 	}
+	gGL.popUIMatrix();
 	gGL.popMatrix();
+
 	gGL.flush();
 }
 
@@ -1896,9 +1903,11 @@ void LLViewerWindow::draw()
 	// No translation needed, this view is glued to 0,0
 
 	gGL.pushMatrix();
+	LLUI::pushMatrix();
 	{
+		
 		// scale view by UI global scale factor and aspect ratio correction factor
-		glScalef(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f);
+		gGL.scaleUI(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f);
 
 		LLVector2 old_scale_factor = LLUI::sGLScaleFactor;
 		// apply camera zoom transform (for high res screenshots)
@@ -1964,6 +1973,7 @@ void LLViewerWindow::draw()
 
 		LLUI::sGLScaleFactor = old_scale_factor;
 	}
+	LLUI::popMatrix();
 	gGL.popMatrix();
 
 #if LL_DEBUG
-- 
GitLab


From 30b2d01a3698fa18876db3638c7393809bee8688 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 12:50:28 +0000
Subject: [PATCH 120/683] Backed out changeset f196197a816a

---
 indra/newview/app_settings/settings.xml |  2 +-
 indra/newview/llviewercontrol.cpp       |  1 +
 indra/newview/llviewerwindow.cpp        | 13 +++++++------
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c7300fcee29..8a447502b08 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7384,7 +7384,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>0</integer>
+      <integer>1</integer>
     </map>
     <key>RenderUseFarClip</key>
     <map>
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 64eabe65cfe..827d34138fe 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -514,6 +514,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderUIBuffer")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderFSAASamples")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderShadowResolutionScale")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 77e46634330..3e1306ae3cd 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1362,7 +1362,7 @@ LLViewerWindow::LLViewerWindow(
 		gSavedSettings.getBOOL("DisableVerticalSync"),
 		!gNoRender,
 		ignore_pixel_depth,
-		gSavedSettings.getU32("RenderFSAASamples"));
+		0); //gSavedSettings.getU32("RenderFSAASamples"));
 
 	if (!LLAppViewer::instance()->restoreErrorTrap())
 	{
@@ -4713,8 +4713,9 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
 		return TRUE;
 	}
 
-	U32 fsaa = gSavedSettings.getU32("RenderFSAASamples");
-	U32 old_fsaa = mWindow->getFSAASamples();
+	//U32 fsaa = gSavedSettings.getU32("RenderFSAASamples");
+	//U32 old_fsaa = mWindow->getFSAASamples();
+
 	// going from windowed to windowed
 	if (!old_fullscreen && !fullscreen)
 	{
@@ -4724,7 +4725,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
 			mWindow->setSize(size);
 		}
 
-		if (fsaa == old_fsaa)
+		//if (fsaa == old_fsaa)
 		{
 			return TRUE;
 		}
@@ -4753,13 +4754,13 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
 		gSavedSettings.setS32("WindowY", old_pos.mY);
 	}
 	
-	mWindow->setFSAASamples(fsaa);
+	//mWindow->setFSAASamples(fsaa);
 
 	result_first_try = mWindow->switchContext(fullscreen, size, disable_vsync);
 	if (!result_first_try)
 	{
 		// try to switch back
-		mWindow->setFSAASamples(old_fsaa);
+		//mWindow->setFSAASamples(old_fsaa);
 		result_second_try = mWindow->switchContext(old_fullscreen, old_size, disable_vsync);
 
 		if (!result_second_try)
-- 
GitLab


From 95e9e569bfaf713eb71f3dba7206aceae06f74f6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 12:50:28 +0000
Subject: [PATCH 121/683] Backed out changeset f196197a816a

---
 indra/newview/app_settings/settings.xml |  2 +-
 indra/newview/llviewercontrol.cpp       |  1 +
 indra/newview/llviewerwindow.cpp        | 13 +++++++------
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c570578e639..ef1a7b670f2 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7430,7 +7430,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>0</integer>
+      <integer>1</integer>
     </map>
     <key>RenderUIBuffer</key>
     <map>
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 0a1108c3c30..d14b8595eb8 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -512,6 +512,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderUIBuffer")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderFSAASamples")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderShadowResolutionScale")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 96d9f2713e0..35632a745e4 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1377,7 +1377,7 @@ LLViewerWindow::LLViewerWindow(
 		gSavedSettings.getBOOL("DisableVerticalSync"),
 		!gNoRender,
 		ignore_pixel_depth,
-		gSavedSettings.getU32("RenderFSAASamples"));
+		0); //gSavedSettings.getU32("RenderFSAASamples"));
 
 	if (!LLAppViewer::instance()->restoreErrorTrap())
 	{
@@ -4594,8 +4594,9 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
 		return TRUE;
 	}
 
-	U32 fsaa = gSavedSettings.getU32("RenderFSAASamples");
-	U32 old_fsaa = mWindow->getFSAASamples();
+	//U32 fsaa = gSavedSettings.getU32("RenderFSAASamples");
+	//U32 old_fsaa = mWindow->getFSAASamples();
+
 	// going from windowed to windowed
 	if (!old_fullscreen && !fullscreen)
 	{
@@ -4605,7 +4606,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
 			mWindow->setSize(size);
 		}
 
-		if (fsaa == old_fsaa)
+		//if (fsaa == old_fsaa)
 		{
 			return TRUE;
 		}
@@ -4634,13 +4635,13 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
 		gSavedSettings.setS32("WindowY", old_pos.mY);
 	}
 	
-	mWindow->setFSAASamples(fsaa);
+	//mWindow->setFSAASamples(fsaa);
 
 	result_first_try = mWindow->switchContext(fullscreen, size, disable_vsync);
 	if (!result_first_try)
 	{
 		// try to switch back
-		mWindow->setFSAASamples(old_fsaa);
+		//mWindow->setFSAASamples(old_fsaa);
 		result_second_try = mWindow->switchContext(old_fullscreen, old_size, disable_vsync);
 
 		if (!result_second_try)
-- 
GitLab


From 420df10263103f64f366e9a0d2b704f83448a180 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 12:51:11 +0000
Subject: [PATCH 122/683] Backed out changeset ac249fda538f

---
 indra/llui/llui.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 852a19660a0..44a57a0989d 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -710,19 +710,19 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 
 			v = LLVector3(offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2i((GLint)v.mV[0], (GLint)v.mV[1] );
 
 			v = LLVector3(-offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2i((GLint)v.mV[0], (GLint)v.mV[1] );
 
 			v = LLVector3(-offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2i((GLint)v.mV[0], (GLint)v.mV[1] );
 
 			v = LLVector3(offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
-			gGL.vertex2i(v.mV[0], v.mV[1] );
+			gGL.vertex2i((GLint)v.mV[0], (GLint)v.mV[1] );
 		}
 		gGL.end();
 		gGL.popUIMatrix();
-- 
GitLab


From e0f95c5929aee8fc28fd360c796c5787b0f95ef5 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 12:52:11 +0000
Subject: [PATCH 123/683] restore casting fix.

---
 indra/llui/llui.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 44a57a0989d..c4a529f0821 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -710,19 +710,19 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 
 			v = LLVector3(offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
-			gGL.vertex2i((GLint)v.mV[0], (GLint)v.mV[1] );
+			gGL.vertex2f((GLint)v.mV[0], (GLint)v.mV[1] );
 
 			v = LLVector3(-offset_x, offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
-			gGL.vertex2i((GLint)v.mV[0], (GLint)v.mV[1] );
+			gGL.vertex2f((GLint)v.mV[0], (GLint)v.mV[1] );
 
 			v = LLVector3(-offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
-			gGL.vertex2i((GLint)v.mV[0], (GLint)v.mV[1] );
+			gGL.vertex2f((GLint)v.mV[0], (GLint)v.mV[1] );
 
 			v = LLVector3(offset_x, -offset_y, 0.f) * quat;
 			gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
-			gGL.vertex2i((GLint)v.mV[0], (GLint)v.mV[1] );
+			gGL.vertex2f((GLint)v.mV[0], (GLint)v.mV[1] );
 		}
 		gGL.end();
 		gGL.popUIMatrix();
-- 
GitLab


From 257347b8f8b3a11c79128a190e923f15fcfebccb Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 12:54:24 +0000
Subject: [PATCH 124/683] restore blend factor init fix.

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

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index fb153a6e3b6..0a1053abc28 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -764,6 +764,9 @@ LLRender::LLRender()
 	mCurrAlphaFunc = CF_DEFAULT;
 	mCurrAlphaFuncVal = 0.01f;
 	mCurrSceneBlendType = BT_ALPHA;
+
+	mCurrBlendSFactor = BF_ONE;
+	mCurrBlendDFactor = BF_ZERO;
 }
 
 LLRender::~LLRender()
-- 
GitLab


From b55c9b9db6ef1e548ebb77d5e24d2ddc6eb5324e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 13:05:22 +0000
Subject: [PATCH 125/683] sigh, fix another backout-backout problem.

---
 indra/llrender/llrender.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 6e38fac67b2..ef18b556e6e 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -364,6 +364,9 @@ class LLRender
 
 	F32				mMaxAnisotropy;
 
+	U32 mCurrBlendSFactor;
+	U32 mCurrBlendDFactor;
+
 	std::list<LLVector3> mUIOffset;
 	std::list<LLVector3> mUIScale;
 
-- 
GitLab


From 848f0ad183180ef5860038b1b709a3fdaa31aa3e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 13:55:41 +0000
Subject: [PATCH 126/683] a better fix for the blend-factor init problem.  I
 think.

---
 indra/llrender/llrender.cpp | 10 +++++++---
 indra/llrender/llrender.h   |  8 +++++---
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 0a1053abc28..e701b96a1ed 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -93,7 +93,9 @@ static GLenum sGLBlendFactor[] =
 	GL_DST_ALPHA,
 	GL_SRC_ALPHA,
 	GL_ONE_MINUS_DST_ALPHA,
-	GL_ONE_MINUS_SRC_ALPHA
+	GL_ONE_MINUS_SRC_ALPHA,
+
+	GL_ZERO // 'BF_UNDEF'
 };
 
 LLTexUnit::LLTexUnit(S32 index)
@@ -765,8 +767,8 @@ LLRender::LLRender()
 	mCurrAlphaFuncVal = 0.01f;
 	mCurrSceneBlendType = BT_ALPHA;
 
-	mCurrBlendSFactor = BF_ONE;
-	mCurrBlendDFactor = BF_ZERO;
+	mCurrBlendSFactor = BF_UNDEF;
+	mCurrBlendDFactor = BF_UNDEF;
 }
 
 LLRender::~LLRender()
@@ -979,6 +981,8 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
 
 void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor)
 {
+	llassert(sfactor < BF_UNDEF);
+	llassert(dfactor < BF_UNDEF);
 	if (mCurrBlendSFactor != sfactor || mCurrBlendDFactor != dfactor)
 	{
 		mCurrBlendSFactor = sfactor;
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index ef18b556e6e..e9ffba9efe2 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -270,7 +270,9 @@ class LLRender
 		BF_DEST_ALPHA,
 		BF_SOURCE_ALPHA,
 		BF_ONE_MINUS_DEST_ALPHA,
-		BF_ONE_MINUS_SOURCE_ALPHA
+		BF_ONE_MINUS_SOURCE_ALPHA,
+
+		BF_UNDEF
 	} eBlendFactor;
 
 	LLRender();
@@ -364,8 +366,8 @@ class LLRender
 
 	F32				mMaxAnisotropy;
 
-	U32 mCurrBlendSFactor;
-	U32 mCurrBlendDFactor;
+	eBlendFactor mCurrBlendSFactor;
+	eBlendFactor mCurrBlendDFactor;
 
 	std::list<LLVector3> mUIOffset;
 	std::list<LLVector3> mUIScale;
-- 
GitLab


From 2aab1d33e125502913075d38d126936d7c2a4a2e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 13 Feb 2010 14:45:34 +0000
Subject: [PATCH 127/683] gah, more blending fixing.

---
 indra/llrender/llrender.cpp | 8 --------
 indra/llrender/llrender.h   | 2 --
 2 files changed, 10 deletions(-)

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index e701b96a1ed..57e7dbe77d6 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -765,7 +765,6 @@ LLRender::LLRender()
 
 	mCurrAlphaFunc = CF_DEFAULT;
 	mCurrAlphaFuncVal = 0.01f;
-	mCurrSceneBlendType = BT_ALPHA;
 
 	mCurrBlendSFactor = BF_UNDEF;
 	mCurrBlendDFactor = BF_UNDEF;
@@ -927,12 +926,6 @@ void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB
 
 void LLRender::setSceneBlendType(eBlendType type)
 {
-	if (mCurrSceneBlendType == type)
-	{
-		return;
-	}
-
-	flush();
 	switch (type) 
 	{
 		case BT_ALPHA:
@@ -960,7 +953,6 @@ void LLRender::setSceneBlendType(eBlendType type)
 			llerrs << "Unknown Scene Blend Type: " << type << llendl;
 			break;
 	}
-	mCurrSceneBlendType = type;
 }
 
 void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index e9ffba9efe2..df24c985bd4 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -362,8 +362,6 @@ class LLRender
 	std::vector<LLTexUnit*>		mTexUnits;
 	LLTexUnit*			mDummyTexUnit;
 
-	U32				mCurrSceneBlendType;
-
 	F32				mMaxAnisotropy;
 
 	eBlendFactor mCurrBlendSFactor;
-- 
GitLab


From de88d6ced487fd55fa6f6bb860849979f031a363 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 17 Feb 2010 11:29:16 -0600
Subject: [PATCH 128/683] Switched program database on windows to edit and
 continue for non-release builds. Adding a debug watch to LLCurlRequest to
 avoid invalidating iterator on processing posts. Mesh bulk uploading rewrite
 work in progress. 404 icons for mesh assets.

---
 indra/cmake/00-Common.cmake  |  6 +++---
 indra/llmessage/llcurl.cpp   |  9 +++++++++
 indra/llmessage/llcurl.h     |  3 ++-
 indra/newview/llvovolume.cpp | 15 ++++++++++++---
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 49a1ec7f2ce..2219311fc72 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -35,13 +35,13 @@ if (WINDOWS)
   # Don't build DLLs.
   set(BUILD_SHARED_LIBS OFF)
 
-  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /MDd /MP"
+  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /ZI /MDd /MP"
       CACHE STRING "C++ compiler debug options" FORCE)
   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO 
-      "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Zi /MD /MP"
+      "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /ZI /MD /MP"
       CACHE STRING "C++ compiler release-with-debug options" FORCE)
   set(CMAKE_CXX_FLAGS_RELEASE
-      "${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /MD /MP"
+      "${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /MD /MP"
       CACHE STRING "C++ compiler release options" FORCE)
 
   set(CMAKE_CXX_STANDARD_LIBRARIES "")
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index b93b94cd251..5212ba1eca7 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -711,6 +711,7 @@ LLCurlRequest::LLCurlRequest() :
 	mActiveRequestCount(0)
 {
 	mThreadID = LLThread::currentID();
+	mProcessing = FALSE;
 }
 
 LLCurlRequest::~LLCurlRequest()
@@ -745,6 +746,11 @@ LLCurl::Easy* LLCurlRequest::allocEasy()
 bool LLCurlRequest::addEasy(LLCurl::Easy* easy)
 {
 	llassert_always(mActiveMulti);
+	
+	if (mProcessing)
+	{
+		llerrs << "Posting to a LLCurlRequest instance from within a responder is not allowed (causes DNS timeouts)." << llendl;
+	}
 	bool res = mActiveMulti->addEasy(easy);
 	return res;
 }
@@ -835,6 +841,8 @@ S32 LLCurlRequest::process()
 {
 	llassert_always(mThreadID == LLThread::currentID());
 	S32 res = 0;
+
+	mProcessing = TRUE;
 	for (curlmulti_set_t::iterator iter = mMultiSet.begin();
 		 iter != mMultiSet.end(); )
 	{
@@ -848,6 +856,7 @@ S32 LLCurlRequest::process()
 			delete multi;
 		}
 	}
+	mProcessing = FALSE;
 	return res;
 }
 
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index 4302c19113d..5367643289d 100644
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -215,7 +215,7 @@ class LLCurlRequest
 	bool getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, LLCurl::ResponderPtr responder);
 	bool post(const std::string& url, const headers_t& headers, const LLSD& data, LLCurl::ResponderPtr responder);
 	bool post(const std::string& url, const headers_t& headers, const std::string& data, LLCurl::ResponderPtr responder);
-
+	
 	S32  process();
 	S32  getQueued();
 
@@ -229,6 +229,7 @@ class LLCurlRequest
 	curlmulti_set_t mMultiSet;
 	LLCurl::Multi* mActiveMulti;
 	S32 mActiveRequestCount;
+	BOOL mProcessing;
 	U32 mThreadID; // debug
 };
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index fb28b78dafd..cb678905151 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -920,6 +920,8 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 
 	S32 lod = mLOD;
 
+	BOOL is404 = FALSE;
+
 	if (isSculpted())
 	{
 		// if it's a mesh
@@ -932,6 +934,11 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 			volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
 
 			lod = gMeshRepo.getActualMeshLOD(volume_params, lod);
+			if (lod == -1)
+			{
+				is404 = TRUE;
+				lod = 0;
+			}
 		}
 	}
 
@@ -962,7 +969,10 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 		}
 	}
 	
-	
+	if (is404)
+	{
+		setIcon(LLViewerTextureManager::getFetchedTextureFromFile("icons/Inv_Mesh.png", TRUE, LLViewerTexture::BOOST_UI));
+	}
 
 	if ((LLPrimitive::setVolume(volume_params, lod, (mVolumeImpl && mVolumeImpl->isVolumeUnique()))) || mSculptChanged)
 	{
@@ -995,10 +1005,9 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 			}
 			else // otherwise is sculptie
 			{
-
 				if (mSculptTexture.notNull())
 				{
-				sculpt();
+					sculpt();
 				}
 			}
 		}
-- 
GitLab


From 74621ff8a8a141d50a3c92430afbe53a9e00edb5 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 17 Feb 2010 15:50:50 -0600
Subject: [PATCH 129/683] Post-review cleanup.

---
 indra/cmake/00-Common.cmake | 2 +-
 indra/llmessage/llcurl.cpp  | 1 -
 indra/llmessage/llcurl.h    | 1 -
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 2219311fc72..113e21a7155 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -41,7 +41,7 @@ if (WINDOWS)
       "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /ZI /MD /MP"
       CACHE STRING "C++ compiler release-with-debug options" FORCE)
   set(CMAKE_CXX_FLAGS_RELEASE
-      "${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /MD /MP"
+      "${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /MD /MP"
       CACHE STRING "C++ compiler release options" FORCE)
 
   set(CMAKE_CXX_STANDARD_LIBRARIES "")
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 5212ba1eca7..0c919011ac3 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -55,7 +55,6 @@
 #include "llstl.h"
 #include "llsdserialize.h"
 #include "llthread.h"
-#include "llvfile.h"
 
 //////////////////////////////////////////////////////////////////////////////
 /*
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index 5367643289d..6ec0a5d8a79 100644
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -44,7 +44,6 @@
 #include <boost/intrusive_ptr.hpp>
 #include <curl/curl.h> // TODO: remove dependency
 
-#include "llassettype.h"
 #include "llbuffer.h"
 #include "lliopipe.h"
 #include "llsd.h"
-- 
GitLab


From ee8036712847315141c78d37646d629796442d09 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 17 Feb 2010 18:08:00 -0600
Subject: [PATCH 130/683] 16-bit limit awareness when consolidating models.

---
 indra/llmath/llvolume.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 7c98536e72b..33a00b80ca5 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5619,6 +5619,10 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat, LLMatrix
 {
 	U16 offset = mVertices.size();
 
+	if (face.mVertices.size() + mVertices.size() > 65536)
+	{
+		llerrs << "Cannot append face -- 16-bit overflow will occur." << llendl;
+	}
 	
 	for (U32 i = 0; i < face.mVertices.size(); ++i)
 	{
-- 
GitLab


From e09822153e135e8fc89f6fdb3338bb9e8e5b6132 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 18 Feb 2010 15:52:49 +0000
Subject: [PATCH 131/683] EXT-5389 Unreadable resident names with glow.

An alternative fix just for render-pipeline.
This is here instead of the trunk because it's cosmetically less good, and codewise a little weirder, and slightly (unmeasurably?) less performant.

But its advantage over the trunk fix is, it's still Z-buffered when FBOs are turned on.  Which we really care about on render-pipeline.
---
 indra/newview/lldrawpoolsimple.cpp | 6 +++++-
 indra/newview/llhudtext.cpp        | 2 +-
 indra/newview/pipeline.cpp         | 9 +++++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index ca7a1b47c2c..0a94e1f45a0 100644
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -71,7 +71,11 @@ void LLDrawPoolGlow::render(S32 pass)
 	LLGLDepthTest depth(GL_TRUE, GL_FALSE);
 	gGL.setColorMask(false, true);
 	renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask());
-	
+
+	// Render name tags invisibly, zero-ing glow (alpha) where they exist (EXT-5389)
+	gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ZERO); // LLHUDText::renderText(true) might clobber this, but right now it doesn't.
+	LLHUDObject::renderAllForSelect(); // we slightly abuse renderForSelect() because it happens to do the right thing for our needs
+
 	gGL.setColorMask(true, false);
 	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 	
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 9ed5d13831c..b49e14bc7d3 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -374,7 +374,7 @@ void LLHUDText::renderText(BOOL for_select)
 			{
 				gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 				S32 name = mSourceObject->mGLName;
-				LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name);
+				LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name, 0);
 				gGL.color4ubv(coloru.mV);
 				gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec);
 				LLUI::popMatrix();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 559ae831829..3a37ce8fbb1 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2794,9 +2794,6 @@ void render_hud_elements()
 		LLWorld::getInstance()->renderPropertyLines();
 		LLViewerParcelMgr::getInstance()->render();
 		LLViewerParcelMgr::getInstance()->renderParcelCollision();
-	
-		// Render name tags.
-		LLHUDObject::renderAll();
 	}
 	else if (gForceRenderLandFence)
 	{
@@ -3200,8 +3197,10 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 	if (!LLPipeline::sReflectionRender && !LLPipeline::sRenderDeferred && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
 	{
 		// Render debugging beacons.
-		gObjectList.renderObjectBeacons();
+		gObjectList.renderObjectBeacons();	
 		gObjectList.resetObjectBeacons();
+		// Render name tags
+		LLHUDObject::renderAll();
 	}
 
 	LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomEnd");
@@ -6923,6 +6922,8 @@ void LLPipeline::renderDeferredLighting()
 			// Render debugging beacons.
 			gObjectList.renderObjectBeacons();
 			gObjectList.resetObjectBeacons();
+			// Render name tags
+			LLHUDObject::renderAll();
 		}
 	}
 
-- 
GitLab


From dc7db357ac4e50f2d1e0d47fd50fd712f67dffe6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 18 Feb 2010 16:49:45 +0000
Subject: [PATCH 132/683] Backed out changeset 83d7019fda75

backing-out render-pipeline-specific version of EXT-5389 fix because it just doesn't reliably work right.
---
 indra/newview/lldrawpoolsimple.cpp | 6 +-----
 indra/newview/llhudtext.cpp        | 2 +-
 indra/newview/pipeline.cpp         | 9 ++++-----
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index 0a94e1f45a0..ca7a1b47c2c 100644
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -71,11 +71,7 @@ void LLDrawPoolGlow::render(S32 pass)
 	LLGLDepthTest depth(GL_TRUE, GL_FALSE);
 	gGL.setColorMask(false, true);
 	renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask());
-
-	// Render name tags invisibly, zero-ing glow (alpha) where they exist (EXT-5389)
-	gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ZERO); // LLHUDText::renderText(true) might clobber this, but right now it doesn't.
-	LLHUDObject::renderAllForSelect(); // we slightly abuse renderForSelect() because it happens to do the right thing for our needs
-
+	
 	gGL.setColorMask(true, false);
 	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 	
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index b49e14bc7d3..9ed5d13831c 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -374,7 +374,7 @@ void LLHUDText::renderText(BOOL for_select)
 			{
 				gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 				S32 name = mSourceObject->mGLName;
-				LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name, 0);
+				LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name);
 				gGL.color4ubv(coloru.mV);
 				gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec);
 				LLUI::popMatrix();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 3a37ce8fbb1..559ae831829 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2794,6 +2794,9 @@ void render_hud_elements()
 		LLWorld::getInstance()->renderPropertyLines();
 		LLViewerParcelMgr::getInstance()->render();
 		LLViewerParcelMgr::getInstance()->renderParcelCollision();
+	
+		// Render name tags.
+		LLHUDObject::renderAll();
 	}
 	else if (gForceRenderLandFence)
 	{
@@ -3197,10 +3200,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 	if (!LLPipeline::sReflectionRender && !LLPipeline::sRenderDeferred && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
 	{
 		// Render debugging beacons.
-		gObjectList.renderObjectBeacons();	
+		gObjectList.renderObjectBeacons();
 		gObjectList.resetObjectBeacons();
-		// Render name tags
-		LLHUDObject::renderAll();
 	}
 
 	LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomEnd");
@@ -6922,8 +6923,6 @@ void LLPipeline::renderDeferredLighting()
 			// Render debugging beacons.
 			gObjectList.renderObjectBeacons();
 			gObjectList.resetObjectBeacons();
-			// Render name tags
-			LLHUDObject::renderAll();
 		}
 	}
 
-- 
GitLab


From 38158f0e14663ac73c7ed79723ba6e34a1253e2a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 18 Feb 2010 23:04:16 -0600
Subject: [PATCH 133/683] Model preview now loads materials.

---
 indra/newview/llviewerjointmesh.cpp | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 7225aa15238..92029d10f69 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -561,12 +561,6 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
 		}
 		else
 		{
-			// This warning will always trigger if you've hacked the avatar to show as incomplete.
-			// Ignore the warning if that's the case.
-			if (!gSavedSettings.getBOOL("RenderUnloadedAvatar"))
-			{
-				//llwarns << "Layerset without composite" << llendl;
-			}
 			gGL.getTexUnit(0)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT));
 		}
 	}
-- 
GitLab


From 8bafcc0491d0131a53226365f18b3ba68648a742 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 19 Feb 2010 09:45:30 +0000
Subject: [PATCH 134/683] EXT-5553 improve alpha mask ('fast alpha') heuristic
 rev'd by davep

---
 indra/llrender/llimagegl.cpp | 62 +++++++++++++++++++++++++++++-------
 indra/llrender/llimagegl.h   |  2 +-
 2 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 36ac3ff119a..42513925466 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1639,7 +1639,7 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
 	}
 }
 
-void LLImageGL::analyzeAlpha(const void* data_in, S32 w, S32 h)
+void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 {
 	if(!mNeedsAlphaAndPickMask)
 	{
@@ -1647,24 +1647,64 @@ void LLImageGL::analyzeAlpha(const void* data_in, S32 w, S32 h)
 	}
 
 	U32 length = w * h;
-	const GLubyte* current = ((const GLubyte*) data_in) + mAlphaOffset ;
 	
-	S32 sample[16];
-	memset(sample, 0, sizeof(S32)*16);
-
-	for (U32 i = 0; i < length; i++)
+	U32 sample[16];
+	memset(sample, 0, sizeof(U32)*16);
+
+	// generate histogram of quantized alpha.
+	// also add-in the histogram of a 2x2 box-sampled version.  The idea is
+	// this will mid-skew the data (and thus increase the chances of not
+	// being used as a mask) from high-frequency alpha maps which
+	// suffer the worst from aliasing when used as alpha masks.
+	if (w >= 2 && h >= 2)
+	{
+		llassert(w%2 == 0);
+		llassert(h%2 == 0);
+		const GLubyte* rowstart = ((const GLubyte*) data_in) + mAlphaOffset;
+		for (U32 y = 0; y < h; y+=2)
+		{
+			const GLubyte* current = rowstart;
+			for (U32 x = 0; x < w; x+=2)
+			{
+				U32 s1 = current[0];
+				U32 s2 = current[w * mAlphaStride];
+				current += mAlphaStride;
+				U32 s3 = current[0];
+				U32 s4 = current[w * mAlphaStride];
+				current += mAlphaStride;
+
+				++sample[s1/16];
+				++sample[s2/16];
+				++sample[s3/16];
+				++sample[s4/16];
+
+				sample[(s1+s2+s3+s4)/(16 * 4)] += 4;
+			}
+			
+			rowstart += 2 * w * mAlphaStride;
+		}
+		length += length;
+	}
+	else
 	{
-		++sample[*current/16];
-		current += mAlphaStride ;
+		const GLubyte* current = ((const GLubyte*) data_in) + mAlphaOffset;
+		for (U32 i = 0; i < length; i++)
+		{
+			++sample[*current/16];
+			current += mAlphaStride;
+		}
 	}
+	
+	// if more than 1/16th of alpha samples are mid-range, this
+	// shouldn't be treated as a 1-bit mask
 
-	U32 total = 0;
+	U32 midrangetotal = 0;
 	for (U32 i = 4; i < 11; i++)
 	{
-		total += sample[i];
+		midrangetotal += sample[i];
 	}
 
-	if (total > length/16)
+	if (midrangetotal > length/16)
 	{
 		mIsMask = FALSE;
 	}
diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h
index f0870c3fc45..1b303307f63 100644
--- a/indra/llrender/llimagegl.h
+++ b/indra/llrender/llimagegl.h
@@ -91,7 +91,7 @@ class LLImageGL : public LLRefCount
 protected:
 	virtual ~LLImageGL();
 
-	void analyzeAlpha(const void* data_in, S32 w, S32 h);
+	void analyzeAlpha(const void* data_in, U32 w, U32 h);
 	void calcAlphaChannelOffsetAndStride();
 
 public:
-- 
GitLab


From 45529e8cadd8eeaae3dda4efe75a14b9f6b253ba Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 19 Feb 2010 09:45:30 +0000
Subject: [PATCH 135/683] EXT-5553 improve alpha mask ('fast alpha') heuristic
 rev'd by davep

---
 indra/llrender/llimagegl.cpp | 141 ++++++++++++++++++++---------------
 indra/llrender/llimagegl.h   |  40 +++++-----
 2 files changed, 103 insertions(+), 78 deletions(-)

diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 7860b32f343..2ab6e327b7e 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -2,25 +2,31 @@
  * @file llimagegl.cpp
  * @brief Generic GL image handler
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -99,24 +105,15 @@ void check_all_images()
 	}
 }
 
-void LLImageGL::checkTexSize(bool forced) const
+void LLImageGL::checkTexSize() const
 {
-	if ((forced || gDebugGL) && mTarget == GL_TEXTURE_2D)
+	if (gDebugGL && mTarget == GL_TEXTURE_2D)
 	{
-		{
-			//check viewport
-			GLint vp[4] ;
-			glGetIntegerv(GL_VIEWPORT, vp) ;
-			llcallstacks << "viewport: " << vp[0] << " : " << vp[1] << " : " << vp[2] << " : " << vp[3] << llcallstacksendl ;
-		}
-
 		GLint texname;
 		glGetIntegerv(GL_TEXTURE_BINDING_2D, &texname);
 		BOOL error = FALSE;
 		if (texname != mTexName)
 		{
-			llinfos << "Bound: " << texname << " Should bind: " << mTexName << " Default: " << LLImageGL::sDefaultGLTexture->getTexName() << llendl;
-
 			error = TRUE;
 			if (gDebugSession)
 			{
@@ -132,8 +129,6 @@ void LLImageGL::checkTexSize(bool forced) const
 		glGetTexLevelParameteriv(mTarget, 0, GL_TEXTURE_WIDTH, (GLint*)&x);
 		glGetTexLevelParameteriv(mTarget, 0, GL_TEXTURE_HEIGHT, (GLint*)&y) ;
 		stop_glerror() ;
-		llcallstacks << "w: " << x << " h: " << y << llcallstacksendl ;
-
 		if(!x || !y)
 		{
 			return ;
@@ -143,13 +138,11 @@ void LLImageGL::checkTexSize(bool forced) const
 			error = TRUE;
 			if (gDebugSession)
 			{
-				gFailLog << "wrong texture size and discard level!" << 
-					mWidth << " Height: " << mHeight << " Current Level: " << mCurrentDiscardLevel << std::endl;
+				gFailLog << "wrong texture size and discard level!" << std::endl;
 			}
 			else
 			{
-				llerrs << "wrong texture size and discard level: width: " << 
-					mWidth << " Height: " << mHeight << " Current Level: " << mCurrentDiscardLevel << llendl ;
+				llerrs << "wrong texture size and discard level!" << llendl ;
 			}
 		}
 
@@ -1051,9 +1044,7 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_
 {
 	if (gGL.getTexUnit(0)->bind(this, false, true))
 	{
-		checkTexSize(true) ;
-		llcallstacks << fb_x << " : " << fb_y << " : " << x_pos << " : " << y_pos << " : " << width << " : " << height << llcallstacksendl ;
-
+		//checkTexSize() ;
 		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height);
 		mGLTextureCreated = true;
 		stop_glerror();
@@ -1648,7 +1639,7 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
 	}
 }
 
-void LLImageGL::analyzeAlpha(const void* data_in, S32 w, S32 h)
+void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 {
 	if(!mNeedsAlphaAndPickMask)
 	{
@@ -1656,24 +1647,64 @@ void LLImageGL::analyzeAlpha(const void* data_in, S32 w, S32 h)
 	}
 
 	U32 length = w * h;
-	const GLubyte* current = ((const GLubyte*) data_in) + mAlphaOffset ;
 	
-	S32 sample[16];
-	memset(sample, 0, sizeof(S32)*16);
-
-	for (U32 i = 0; i < length; i++)
+	U32 sample[16];
+	memset(sample, 0, sizeof(U32)*16);
+
+	// generate histogram of quantized alpha.
+	// also add-in the histogram of a 2x2 box-sampled version.  The idea is
+	// this will mid-skew the data (and thus increase the chances of not
+	// being used as a mask) from high-frequency alpha maps which
+	// suffer the worst from aliasing when used as alpha masks.
+	if (w >= 2 && h >= 2)
+	{
+		llassert(w%2 == 0);
+		llassert(h%2 == 0);
+		const GLubyte* rowstart = ((const GLubyte*) data_in) + mAlphaOffset;
+		for (U32 y = 0; y < h; y+=2)
+		{
+			const GLubyte* current = rowstart;
+			for (U32 x = 0; x < w; x+=2)
+			{
+				U32 s1 = current[0];
+				U32 s2 = current[w * mAlphaStride];
+				current += mAlphaStride;
+				U32 s3 = current[0];
+				U32 s4 = current[w * mAlphaStride];
+				current += mAlphaStride;
+
+				++sample[s1/16];
+				++sample[s2/16];
+				++sample[s3/16];
+				++sample[s4/16];
+
+				sample[(s1+s2+s3+s4)/(16 * 4)] += 4;
+			}
+			
+			rowstart += 2 * w * mAlphaStride;
+		}
+		length += length;
+	}
+	else
 	{
-		++sample[*current/16];
-		current += mAlphaStride ;
+		const GLubyte* current = ((const GLubyte*) data_in) + mAlphaOffset;
+		for (U32 i = 0; i < length; i++)
+		{
+			++sample[*current/16];
+			current += mAlphaStride;
+		}
 	}
+	
+	// if more than 1/16th of alpha samples are mid-range, this
+	// shouldn't be treated as a 1-bit mask
 
-	U32 total = 0;
+	U32 midrangetotal = 0;
 	for (U32 i = 4; i < 11; i++)
 	{
-		total += sample[i];
+		midrangetotal += sample[i];
 	}
 
-	if (total > length/16)
+	if (midrangetotal > length/16)
 	{
 		mIsMask = FALSE;
 	}
@@ -1741,27 +1772,15 @@ BOOL LLImageGL::getMask(const LLVector2 &tc)
 
 	if (mPickMask)
 	{
-		F32 u,v;
-		if (LL_LIKELY(tc.isFinite()))
-		{
-			u = tc.mV[0] - floorf(tc.mV[0]);
-			v = tc.mV[1] - floorf(tc.mV[1]);
-		}
-		else
-		{
-			LL_WARNS_ONCE("render") << "Ugh, non-finite u/v in mask pick" << LL_ENDL;
-			u = v = 0.f;
-			// removing assert per EXT-4388
-			// llassert(false);
-		}
+		F32 u = tc.mV[0] - floorf(tc.mV[0]);
+		F32 v = tc.mV[1] - floorf(tc.mV[1]);
 
 		if (LL_UNLIKELY(u < 0.f || u > 1.f ||
 				v < 0.f || v > 1.f))
 		{
 			LL_WARNS_ONCE("render") << "Ugh, u/v out of range in image mask pick" << LL_ENDL;
 			u = v = 0.f;
-			// removing assert per EXT-4388
-			// llassert(false);
+			llassert(false);
 		}
 
 		S32 x = llfloor(u * mPickMaskWidth);
diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h
index 95379298ef6..1b303307f63 100644
--- a/indra/llrender/llimagegl.h
+++ b/indra/llrender/llimagegl.h
@@ -2,25 +2,31 @@
  * @file llimagegl.h
  * @brief Object for managing images and their textures
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -85,7 +91,7 @@ class LLImageGL : public LLRefCount
 protected:
 	virtual ~LLImageGL();
 
-	void analyzeAlpha(const void* data_in, S32 w, S32 h);
+	void analyzeAlpha(const void* data_in, U32 w, U32 h);
 	void calcAlphaChannelOffsetAndStride();
 
 public:
@@ -151,7 +157,7 @@ class LLImageGL : public LLRefCount
 	void updatePickMask(S32 width, S32 height, const U8* data_in);
 	BOOL getMask(const LLVector2 &tc);
 
-	void checkTexSize(bool forced = false) const ;
+	void checkTexSize() const ;
 	
 	// Sets the addressing mode used to sample the texture 
 	//  (such as wrapping, mirrored wrapping, and clamp)
-- 
GitLab


From afd30a8bb02863cb9325a8863e8069f88355db57 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 19 Feb 2010 13:56:44 +0000
Subject: [PATCH 136/683] fix warning introduced from trunk merge.

---
 indra/llrender/llfontgl.cpp | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 32ebbd1e3ba..867d14c855b 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -247,10 +247,6 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 		}
 	}
 
-
-	// Remember last-used texture to avoid unnecesssary bind calls.
-	LLImageGL *last_bound_texture = NULL;
-
 	const LLFontGlyphInfo* next_glyph = NULL;
 
 	for (i = begin_offset; i < begin_offset + length; i++)
-- 
GitLab


From 237f1a1ba362aa2dfd9bb386e431713bdfcad2dc Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Feb 2010 12:41:08 -0600
Subject: [PATCH 137/683] Consolidate now preserves materials.

---
 indra/llmath/v4color.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h
index d6fbdec61e1..6b63b976b02 100644
--- a/indra/llmath/v4color.h
+++ b/indra/llmath/v4color.h
@@ -114,6 +114,7 @@ class LLColor4
 	
 	    const LLColor4& operator=(const LLColor3 &a);	// Assigns vec3 to vec4 and returns vec4
 		
+		bool operator<(const LLColor4& rhs) const;
 		friend std::ostream&	 operator<<(std::ostream& s, const LLColor4 &a);		// Print a
 		friend LLColor4 operator+(const LLColor4 &a, const LLColor4 &b);	// Return vector a + b
 		friend LLColor4 operator-(const LLColor4 &a, const LLColor4 &b);	// Return vector a minus b
@@ -595,6 +596,23 @@ inline LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u)
 		a.mV[VW] + (b.mV[VW] - a.mV[VW]) * u);
 }
 
+inline bool LLColor4::operator<(const LLColor4& rhs) const
+{
+	if (mV[0] != rhs.mV[0])
+	{
+		return mV[0] < rhs.mV[0];
+	}
+	if (mV[1] != rhs.mV[1])
+	{
+		return mV[1] < rhs.mV[1];
+	}
+	if (mV[2] != rhs.mV[2])
+	{
+		return mV[2] < rhs.mV[2];
+	}
+
+	return mV[3] < rhs.mV[3];
+}
 
 void LLColor4::clamp()
 {
-- 
GitLab


From ca12b3d971db20559cb242417dc6c3f64d63c1d6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 20 Feb 2010 17:50:18 +0000
Subject: [PATCH 138/683] raise RenderDeferredSSAOMaxScale from 60 to 200. 
 This is fine.

---
 indra/newview/app_settings/settings.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 7dc4308893e..5d5a6ca58c2 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6061,7 +6061,7 @@
     <key>Type</key>
     <string>U32</string>
     <key>Value</key>
-    <integer>60</integer>
+    <integer>200</integer>
   </map>
   <key>RenderSSAOFactor</key>
   <map>
-- 
GitLab


From 6fb93cdfbfcde3e0ca671bc476af50a5c727b107 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 20 Feb 2010 17:50:18 +0000
Subject: [PATCH 139/683] raise RenderDeferredSSAOMaxScale from 60 to 200. 
 This is fine.

---
 indra/newview/app_settings/settings.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 8b66cce8a3e..6bfa42785f5 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6094,7 +6094,7 @@
     <key>Type</key>
     <string>U32</string>
     <key>Value</key>
-    <integer>60</integer>
+    <integer>200</integer>
   </map>
   <key>RenderSSAOFactor</key>
   <map>
-- 
GitLab


From 066f9de07ecfcf142103f646695e5be63a22a667 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 23 Feb 2010 16:57:06 -0600
Subject: [PATCH 140/683] Fix for normals getting squished on consolidation.
 Replaced some magic numbers with constants. Switched up throttling of mesh
 upload HTTP posts to prevent overloading one capability at a time. Added some
 feedback on upload progress via debug text. Made debug text move with side
 panel (keep debug text from rendering on top of side panel).

---
 indra/llmath/llvolume.cpp        |  1 +
 indra/newview/llviewerwindow.cpp | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 33a00b80ca5..704308f20f1 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5630,6 +5630,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat, LLMatrix
 		v.mPosition = v.mPosition*mat;
 		v.mNormal = v.mNormal * norm_mat;
 
+		v.mNormal.normalize();
 
 		mVertices.push_back(v);
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index fd59ea41b2d..5c039c9f943 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -31,7 +31,6 @@
  */
 
 #include "llviewerprecompiledheaders.h"
-
 #include "llviewerwindow.h"
 
 #if LL_WINDOWS
@@ -45,6 +44,7 @@
 #include <algorithm>
 
 #include "llfloaterreg.h"
+#include "llmeshrepository.h"
 #include "llpanellogin.h"
 #include "llviewerkeyboard.h"
 #include "llviewermenu.h"
@@ -318,7 +318,7 @@ class LLDebugText
 		mTextColor = LLColor4( 0.86f, 0.86f, 0.86f, 1.f );
 
 		// Draw stuff growing up from right lower corner of screen
-		U32 xpos = mWindow->getWindowWidthScaled() - 350;
+		U32 xpos = mWindow->getWorldViewWidthScaled() - 350;
 		U32 ypos = 64;
 		const U32 y_inc = 20;
 
@@ -583,6 +583,22 @@ class LLDebugText
 				ypos += y_inc;
 			}
 		}
+
+		//temporary hack to give feedback on mesh upload progress
+		if (!gMeshRepo.mUploads.empty())
+		{
+			for (std::vector<LLMeshUploadThread*>::iterator iter = gMeshRepo.mUploads.begin(); 
+				iter != gMeshRepo.mUploads.end(); ++iter)
+			{
+				LLMeshUploadThread* thread = *iter;
+
+				addText(xpos, ypos, llformat("Mesh Upload -- price quote: %d:%d | upload: %d:%d | create: %d", 
+								thread->mPendingConfirmations, thread->mUploadQ.size(),
+								thread->mPendingUploads, thread->mConfirmedQ.size(),
+								thread->mCompletedQ.size()));
+				ypos += y_inc;
+			}
+		}
 	}
 
 	void draw()
-- 
GitLab


From 469af6771d757dd951daaed3e2b1d59ee2127c0e Mon Sep 17 00:00:00 2001
From: Palmer Truelson <palmer@lindenlab.com>
Date: Tue, 23 Feb 2010 22:32:17 -0800
Subject: [PATCH 141/683] D'oh. Merge bork.

---
 indra/llrender/llrender.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 73c628d4b5c..a73a128368c 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -366,9 +366,6 @@ class LLRender
 	eBlendFactor mCurrBlendDFactor;
 	F32				mMaxAnisotropy;
 
-	eBlendFactor mCurrBlendSFactor;
-	eBlendFactor mCurrBlendDFactor;
-
 	std::list<LLVector3> mUIOffset;
 	std::list<LLVector3> mUIScale;
 
-- 
GitLab


From 2063bc2a3a5848d0290c97ce7661fc8d8f224976 Mon Sep 17 00:00:00 2001
From: Palmer Truelson <palmer@lindenlab.com>
Date: Wed, 24 Feb 2010 12:18:13 -0800
Subject: [PATCH 142/683] Allow for turning off of FBOs

---
 indra/newview/llviewerdisplay.cpp | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index fdf20606868..0a927cd5ead 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -861,14 +861,26 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender)
 			{
 				gPipeline.mDeferredScreen.flush();
-				LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(),
-									0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+				if(LLRenderTarget::sUseFBO)
+				{
+					LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), 
+															  gPipeline.mDeferredScreen.getHeight(), 0, 0, 
+															  gPipeline.mDeferredScreen.getWidth(), 
+															  gPipeline.mDeferredScreen.getHeight(), 
+															  GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+				}
 			}
 			else
 			{
 				gPipeline.mScreen.flush();
-				LLRenderTarget::copyContentsToFramebuffer(gPipeline.mScreen, 0, 0, gPipeline.mScreen.getWidth(), gPipeline.mScreen.getHeight(),
-									0, 0, gPipeline.mScreen.getWidth(), gPipeline.mScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+				if(LLRenderTarget::sUseFBO)
+				{				
+					LLRenderTarget::copyContentsToFramebuffer(gPipeline.mScreen, 0, 0, gPipeline.mScreen.getWidth(), 
+															  gPipeline.mScreen.getHeight(), 0, 0, 
+															  gPipeline.mScreen.getWidth(), 
+															  gPipeline.mScreen.getHeight(), 
+															  GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+				}
 			}
 		}
 
-- 
GitLab


From 4de18937025f92a0340277c3215fc43cac2f6688 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 24 Feb 2010 19:53:22 -0600
Subject: [PATCH 143/683] Added lower level pool to curl easy handles to speed
 up HTTP requests (from 40 ms per request to < 1 ms per request).

---
 indra/llmessage/llcurl.cpp | 87 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 84 insertions(+), 3 deletions(-)

diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 0c919011ac3..c640e176ee9 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -55,6 +55,7 @@
 #include "llstl.h"
 #include "llsdserialize.h"
 #include "llthread.h"
+#include "lltimer.h"
 
 //////////////////////////////////////////////////////////////////////////////
 /*
@@ -256,7 +257,12 @@ class LLCurl::Easy
 	
 	void resetState();
 
+	static CURL* allocEasyHandle();
+	static void releaseEasyHandle(CURL* handle);
+
 private:	
+	friend class LLCurl;
+
 	CURL*				mCurlEasyHandle;
 	struct curl_slist*	mHeaders;
 	
@@ -271,8 +277,62 @@ class LLCurl::Easy
 	std::vector<char*>	mStrings;
 	
 	ResponderPtr		mResponder;
+
+	static std::set<CURL*> sFreeHandles;
+	static std::set<CURL*> sActiveHandles;
+	static LLMutex* sHandleMutex;
 };
 
+std::set<CURL*> LLCurl::Easy::sFreeHandles;
+std::set<CURL*> LLCurl::Easy::sActiveHandles;
+LLMutex* LLCurl::Easy::sHandleMutex = NULL;
+
+
+//static
+CURL* LLCurl::Easy::allocEasyHandle()
+{
+	CURL* ret = NULL;
+	LLMutexLock lock(sHandleMutex);
+	if (sFreeHandles.empty())
+	{
+		ret = curl_easy_init();
+	}
+	else
+	{
+		ret = *(sFreeHandles.begin());
+		sFreeHandles.erase(ret);
+		curl_easy_reset(ret);
+	}
+
+	if (ret)
+	{
+		sActiveHandles.insert(ret);
+	}
+
+	return ret;
+}
+
+//static
+void LLCurl::Easy::releaseEasyHandle(CURL* handle)
+{
+	if (!handle)
+	{
+		llerrs << "handle cannot be NULL!" << llendl;
+	}
+
+	LLMutexLock lock(sHandleMutex);
+	
+	if (sActiveHandles.find(handle) != sActiveHandles.end())
+	{
+		sActiveHandles.erase(handle);
+		sFreeHandles.insert(handle);
+	}
+	else
+	{
+		llerrs << "Invalid handle." << llendl;
+	}
+}
+
 LLCurl::Easy::Easy()
 	: mHeaders(NULL),
 	  mCurlEasyHandle(NULL)
@@ -283,11 +343,12 @@ LLCurl::Easy::Easy()
 LLCurl::Easy* LLCurl::Easy::getEasy()
 {
 	Easy* easy = new Easy();
-	easy->mCurlEasyHandle = curl_easy_init();
+	easy->mCurlEasyHandle = allocEasyHandle(); 
+	
 	if (!easy->mCurlEasyHandle)
 	{
 		// this can happen if we have too many open files (fails in c-ares/ares_init.c)
-		llwarns << "curl_multi_init() returned NULL! Easy handles: " << gCurlEasyCount << " Multi handles: " << gCurlMultiCount << llendl;
+		llwarns << "allocEasyHandle() returned NULL! Easy handles: " << gCurlEasyCount << " Multi handles: " << gCurlMultiCount << llendl;
 		delete easy;
 		return NULL;
 	}
@@ -301,7 +362,7 @@ LLCurl::Easy* LLCurl::Easy::getEasy()
 
 LLCurl::Easy::~Easy()
 {
-	curl_easy_cleanup(mCurlEasyHandle);
+	releaseEasyHandle(mCurlEasyHandle);
 	--gCurlEasyCount;
 	curl_slist_free_all(mHeaders);
 	for_each(mStrings.begin(), mStrings.end(), DeletePointerArray());
@@ -543,6 +604,7 @@ LLCurl::Multi::Multi()
 	  mErrorCount(0)
 {
 	mCurlMultiHandle = curl_multi_init();
+	
 	if (!mCurlMultiHandle)
 	{
 		llwarns << "curl_multi_init() returned NULL! Easy handles: " << gCurlEasyCount << " Multi handles: " << gCurlMultiCount << llendl;
@@ -1078,6 +1140,8 @@ void LLCurl::initClass()
 	// - http://curl.haxx.se/libcurl/c/curl_global_init.html
 	curl_global_init(CURL_GLOBAL_ALL);
 	
+	Easy::sHandleMutex = new LLMutex(NULL);
+
 #if SAFE_SSL
 	S32 mutex_count = CRYPTO_num_locks();
 	for (S32 i=0; i<mutex_count; i++)
@@ -1095,5 +1159,22 @@ void LLCurl::cleanupClass()
 	CRYPTO_set_locking_callback(NULL);
 	for_each(sSSLMutex.begin(), sSSLMutex.end(), DeletePointer());
 #endif
+
+	delete Easy::sHandleMutex;
+	Easy::sHandleMutex = NULL;
+
+	for (std::set<CURL*>::iterator iter = Easy::sFreeHandles.begin(); iter != Easy::sFreeHandles.end(); ++iter)
+	{
+		CURL* curl = *iter;
+		curl_easy_cleanup(curl);
+	}
+
+	Easy::sFreeHandles.clear();
+
+	if (!Easy::sActiveHandles.empty())
+	{
+		llerrs << "CURL easy handles not cleaned up on shutdown!" << llendl;
+	}
+
 	curl_global_cleanup();
 }
-- 
GitLab


From 3c78771acee787e087bd2e2391397794d4d98f6d Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 24 Feb 2010 22:02:01 -0600
Subject: [PATCH 144/683] Removed scale from model importer. Removed support
 for scale entry in mesh assets. Fixed MeshMaxConcurrentRequests being
 ignored. Added mesh download queue debug text.

---
 indra/llmath/llvolume.cpp        |  4 ----
 indra/newview/llviewerwindow.cpp | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 704308f20f1..904786079f4 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2098,8 +2098,6 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 			min_tc.setValue(mdl[i]["TexCoord0Domain"]["Min"]);
 			max_tc.setValue(mdl[i]["TexCoord0Domain"]["Max"]);
 
-			F32 scale = llclamp((F32) mdl[i]["Scale"].asReal(), 1.f, 10.f);
-
 			LLVector3 pos_range = max_pos - min_pos;
 			LLVector2 tc_range = max_tc - min_tc;
 
@@ -2117,8 +2115,6 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 					(F32) v[1] / 65535.f * pos_range.mV[1] + min_pos.mV[1],
 					(F32) v[2] / 65535.f * pos_range.mV[2] + min_pos.mV[2]);
 
-				face.mVertices[j].mPosition *= scale;
-
 				if (j == 0)
 				{
 					min = max = face.mVertices[j].mPosition;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 6bdb322c091..f554acf1dff 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -599,6 +599,20 @@ class LLDebugText
 				ypos += y_inc;
 			}
 		}
+
+		S32 pending = (S32) gMeshRepo.mPendingRequests.size();
+		S32 header = (S32) gMeshRepo.mThread->mHeaderReqQ.size();
+		S32 lod = (S32) gMeshRepo.mThread->mLODReqQ.size();
+
+		if (pending + header + lod + LLMeshRepoThread::sActiveHeaderRequests + LLMeshRepoThread::sActiveLODRequests != 0)
+		{
+			addText(xpos, ypos, llformat ("Mesh Queue - %d pending (%d:%d header | %d:%d LOD)", 
+												pending,
+												LLMeshRepoThread::sActiveHeaderRequests, header,
+												LLMeshRepoThread::sActiveLODRequests, lod));
+
+			ypos += y_inc;
+		}
 	}
 
 	void draw()
-- 
GitLab


From 56c0d25ec88df661a15bd1401efd4a9f67b86328 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 24 Feb 2010 23:36:55 -0600
Subject: [PATCH 145/683] Fix for attempting to load mesh as texture. Fix for
 failing to retry when mesh uploads fail. Fix for race condition deadlocking
 mesh fetching thread.

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

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 562c733a3ed..726673013b0 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1021,7 +1021,7 @@ void LLVOVolume::updateSculptTexture()
 {
 	LLPointer<LLViewerFetchedTexture> old_sculpt = mSculptTexture;
 
-	if (isSculpted())
+	if (isSculpted() && !isMesh())
 	{
 		LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
 		LLUUID id =  sculpt_params->getSculptTexture(); 
-- 
GitLab


From 64d83571c9596900f32d0af63c2dd9968badb82f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 24 Feb 2010 23:40:46 -0600
Subject: [PATCH 146/683] Merge ?

---
 indra/llui/lllayoutstack.cpp | 38 +++++++++++++++++++++++++++++++-----
 indra/llui/lllayoutstack.h   | 10 +++++++++-
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index dc79550eb47..45120913714 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -49,9 +49,11 @@ static LLDefaultChildRegistry::Register<LLLayoutStack> register_layout_stack("la
 //
 struct LLLayoutStack::LayoutPanel
 {
-	LayoutPanel(LLPanel* panelp, ELayoutOrientation orientation, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize)	:	mPanel(panelp), 
+	LayoutPanel(LLPanel* panelp, ELayoutOrientation orientation, S32 min_width, S32 min_height, S32 max_width, S32 max_height, BOOL auto_resize, BOOL user_resize)	:	mPanel(panelp), 
 		mMinWidth(min_width), 
 		mMinHeight(min_height),
+		mMaxWidth(max_width), 
+		mMaxHeight(max_height),
 		mAutoResize(auto_resize),
 		mUserResize(user_resize),
 		mOrientation(orientation),
@@ -112,6 +114,11 @@ struct LLLayoutStack::LayoutPanel
 	LLPanel* mPanel;
 	S32 mMinWidth;
 	S32 mMinHeight;
+
+	// mMaxWidth & mMaxHeight are added to make configurable max width of the nearby chat bar. EXT-5589
+	// they are not processed by LLLayoutStack but they can be if necessary
+	S32 mMaxWidth;
+	S32 mMaxHeight;
 	BOOL mAutoResize;
 	BOOL mUserResize;
 	BOOL mCollapsed;
@@ -261,10 +268,14 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
 	{
 		const S32 DEFAULT_MIN_WIDTH = 0;
 		const S32 DEFAULT_MIN_HEIGHT = 0;
+		const S32 DEFAULT_MAX_WIDTH = S32_MAX;
+		const S32 DEFAULT_MAX_HEIGHT = S32_MAX;
 		const BOOL DEFAULT_AUTO_RESIZE = TRUE;
 
 		S32 min_width = DEFAULT_MIN_WIDTH;
 		S32 min_height = DEFAULT_MIN_HEIGHT;
+		S32 max_width = DEFAULT_MAX_WIDTH;
+		S32 max_height = DEFAULT_MAX_HEIGHT;
 		BOOL auto_resize = DEFAULT_AUTO_RESIZE;
 
 		LLXMLNodePtr output_child;
@@ -281,6 +292,10 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
 			DEFAULT_MIN_WIDTH, output_child);
 		get_attribute_s32_and_write(child_node, "min_height", &min_height,
 			DEFAULT_MIN_HEIGHT, output_child);
+		get_attribute_s32_and_write(child_node, "max_width", &max_width,
+			DEFAULT_MAX_WIDTH, output_child);
+		get_attribute_s32_and_write(child_node, "max_height", &max_height,
+			DEFAULT_MAX_HEIGHT, output_child);
 		get_attribute_bool_and_write(child_node, "auto_resize", &auto_resize,
 			DEFAULT_AUTO_RESIZE, output_child);
 
@@ -293,7 +308,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
 			if (panelp)
 			{
 				panelp->setFollowsNone();
-				layout_stackp->addPanel(panelp, min_width, min_height, auto_resize, user_resize);
+				layout_stackp->addPanel(panelp, min_width, min_height, max_width, max_height, auto_resize, user_resize);
 			}
 		}
 		else
@@ -309,7 +324,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
 			if (new_child)
 			{
 				// put child in new embedded panel
-				layout_stackp->addPanel(panelp, min_width, min_height, auto_resize, user_resize);
+				layout_stackp->addPanel(panelp, min_width, min_height, max_width, max_height, auto_resize, user_resize);
 				// resize panel to contain widget and move widget to be contained in panel
 				panelp->setRect(new_child->getRect());
 				new_child->setOrigin(0, 0);
@@ -359,14 +374,14 @@ S32 LLLayoutStack::getDefaultWidth(S32 cur_width)
 	return cur_width;
 }
 
-void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, EAnimate animate, S32 index)
+void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, S32 max_width, S32 max_height, BOOL auto_resize, BOOL user_resize, EAnimate animate, S32 index)
 {
 	// panel starts off invisible (collapsed)
 	if (animate == ANIMATE)
 	{
 		panel->setVisible(FALSE);
 	}
-	LayoutPanel* embedded_panel = new LayoutPanel(panel, mOrientation, min_width, min_height, auto_resize, user_resize);
+	LayoutPanel* embedded_panel = new LayoutPanel(panel, mOrientation, min_width, min_height, max_width, max_height, auto_resize, user_resize);
 	
 	mPanels.insert(mPanels.begin() + llclamp(index, 0, (S32)mPanels.size()), embedded_panel);
 	
@@ -437,6 +452,19 @@ bool LLLayoutStack::getPanelMinSize(const std::string& panel_name, S32* min_widt
 	return NULL != panel;
 }
 
+bool LLLayoutStack::getPanelMaxSize(const std::string& panel_name, S32* max_widthp, S32* max_heightp)
+{
+	LayoutPanel* panel = findEmbeddedPanelByName(panel_name);
+
+	if (panel)
+	{
+		if (max_widthp) *max_widthp = panel->mMaxWidth;
+		if (max_heightp) *max_heightp = panel->mMaxHeight;
+	}
+
+	return NULL != panel;
+}
+
 static LLFastTimer::DeclareTimer FTM_UPDATE_LAYOUT("Update LayoutStacks");
 void LLLayoutStack::updateLayout(BOOL force_resize)
 {
diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h
index c4f10038f86..e454454fe2b 100644
--- a/indra/llui/lllayoutstack.h
+++ b/indra/llui/lllayoutstack.h
@@ -74,7 +74,7 @@ class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack>
 		ANIMATE
 	} EAnimate;
 
-	void addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, EAnimate animate = NO_ANIMATE, S32 index = S32_MAX);
+	void addPanel(LLPanel* panel, S32 min_width, S32 min_height, S32 max_width, S32 max_height, BOOL auto_resize, BOOL user_resize, EAnimate animate = NO_ANIMATE, S32 index = S32_MAX);
 	void removePanel(LLPanel* panel);
 	void collapsePanel(LLPanel* panel, BOOL collapsed = TRUE);
 	S32 getNumPanels() { return mPanels.size(); }
@@ -89,6 +89,14 @@ class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack>
 	 * @returns true if specified by panel_name internal panel exists, false otherwise.
 	 */
 	bool getPanelMinSize(const std::string& panel_name, S32* min_widthp, S32* min_heightp);
+
+	/**
+	 * Gets maximal width and/or height of the specified by name panel.
+	 *
+	 * If it is necessary to get only the one dimension pass NULL for another one.
+	 * @returns true if specified by panel_name internal panel exists, false otherwise.
+	 */
+	bool getPanelMaxSize(const std::string& panel_name, S32* max_width, S32* max_height);
 	
 	void updateLayout(BOOL force_resize = FALSE);
 	
-- 
GitLab


From 1ceceecf7501076fa92fa7c9eb5cdf1aa8d5191e Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 25 Feb 2010 15:19:44 -0600
Subject: [PATCH 147/683] LOD tweaking (sort of) works again in importer. Got
 rid of another spot that was loading meshes as textures.

---
 indra/newview/llviewerobject.cpp | 2 +-
 indra/newview/llviewerobject.h   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index b5642d07a52..8dea60cc874 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2932,7 +2932,7 @@ void LLViewerObject::boostTexturePriority(BOOL boost_children /* = TRUE */)
  		getTEImage(i)->setBoostLevel(LLViewerTexture::BOOST_SELECTED);
 	}
 
-	if (isSculpted())
+	if (isSculpted() && !isMesh())
 	{
 		LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
 		LLUUID sculpt_id = sculpt_params->getSculptTexture();
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 266c40d4935..bf5e0b66563 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -229,6 +229,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	virtual BOOL isFlexible() const					{ return FALSE; }
 	virtual BOOL isSculpted() const 				{ return FALSE; }
+	virtual BOOL isMesh() const						{ return FALSE; }
 	virtual BOOL hasLightTexture() const			{ return FALSE; }
 
 	// This method returns true if the object is over land owned by
-- 
GitLab


From 26a0c18e95d8d542016d89cc78b948438bc335cb Mon Sep 17 00:00:00 2001
From: Palmer Truelson <palmer@lindenlab.com>
Date: Thu, 25 Feb 2010 16:02:23 -0800
Subject: [PATCH 148/683] Turn of FBOs on x1600 on mac

---
 indra/newview/featuretable_mac.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt
index 12d47a904c0..db0252d2e70 100644
--- a/indra/newview/featuretable_mac.txt
+++ b/indra/newview/featuretable_mac.txt
@@ -366,6 +366,7 @@ list ATI_Radeon_X1500
 Disregard128DefaultDrawDistance	1	0
 list ATI_Radeon_X1600 
 Disregard128DefaultDrawDistance	1	0
+RenderUseFBO 					0	0
 list ATI_Radeon_X1700 
 Disregard128DefaultDrawDistance	1	0
 list ATI_Mobility_Radeon_X1xxx
-- 
GitLab


From 4b58bc323dca517ae7253a6dfa2019ed68c768ea Mon Sep 17 00:00:00 2001
From: Palmer Truelson <palmer@lindenlab.com>
Date: Thu, 25 Feb 2010 16:02:23 -0800
Subject: [PATCH 149/683] Turn of FBOs on x1600 on mac

---
 indra/newview/featuretable_mac.txt | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt
index e89b0cc49d5..db0252d2e70 100644
--- a/indra/newview/featuretable_mac.txt
+++ b/indra/newview/featuretable_mac.txt
@@ -26,7 +26,6 @@ list all
 RenderAnisotropic				1	0
 RenderAvatarCloth				0	0
 RenderAvatarLODFactor			1	1.0
-RenderAvatarMaxVisible          1   12
 RenderAvatarVP					1	0
 RenderCubeMap					1	1
 RenderDelayVBUpdate				1	0
@@ -58,8 +57,6 @@ Disregard96DefaultDrawDistance	1	1
 RenderTextureMemoryMultiple		1	0.5
 Disregard128DefaultDrawDistance	1	1
 Disregard96DefaultDrawDistance	1	1
-SkyUseClassicClouds			1	1
-WatchdogDisabled				1	1
 
 //
 // Low Graphics Settings
@@ -67,26 +64,24 @@ WatchdogDisabled				1	1
 list Low
 RenderAnisotropic			1	0
 RenderAvatarCloth			1	0
-RenderAvatarLODFactor		1	0
-RenderAvatarMaxVisible      1   3
+RenderAvatarLODFactor		1	0.5
 RenderAvatarVP				1	0
 RenderFarClip				1	64
-RenderFlexTimeFactor		1	0
+RenderFlexTimeFactor		1	0.5
 RenderGlowResolutionPow		1	8
 RenderLightingDetail		1	0
-RenderMaxPartCount			1	0
+RenderMaxPartCount			1	1024
 RenderObjectBump			1	0
 RenderReflectionDetail		1	0
 RenderTerrainDetail			1	0
 RenderTerrainLODFactor		1	1
-RenderTreeLODFactor			1	0
+RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
-RenderVolumeLODFactor		1	0
+RenderVolumeLODFactor		1	1.125
 RenderWaterReflections		1	0
 VertexShaderEnable			1	0
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
-SkyUseClassicClouds			1	0
 
 //
 // Mid Graphics Settings
@@ -371,6 +366,7 @@ list ATI_Radeon_X1500
 Disregard128DefaultDrawDistance	1	0
 list ATI_Radeon_X1600 
 Disregard128DefaultDrawDistance	1	0
+RenderUseFBO 					0	0
 list ATI_Radeon_X1700 
 Disregard128DefaultDrawDistance	1	0
 list ATI_Mobility_Radeon_X1xxx
-- 
GitLab


From b414b5067e3e47da7d9baf490d94534b4c65a8eb Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sun, 28 Feb 2010 16:40:30 -0600
Subject: [PATCH 150/683] Remove some dead code. Add LH transform to LLVector3
 Add DebugShowUploadCost Make LOD generation on model preview less finnicky.
 Remove error level based LOD generation. Better framing of model before
 upload. Better error handling for model uploader. Remove [COST] argument from
 model upload menu item. Remove L$ check from model upload menu item being
 enabled.

---
 indra/llmath/m4math.cpp                       | 31 ----------
 indra/llmath/m4math.h                         |  5 +-
 indra/llmath/v3math.cpp                       | 22 +++++++
 indra/llmath/v3math.h                         |  3 +
 indra/llrender/llvertexbuffer.cpp             |  6 ++
 indra/newview/app_settings/settings.xml       | 13 ++++-
 indra/newview/llviewermenu.cpp                |  3 +-
 indra/newview/llviewermenufile.cpp            | 10 ++++
 indra/newview/llviewermessage.cpp             |  1 -
 indra/newview/llviewerwindow.cpp              | 14 +++++
 indra/newview/pipeline.cpp                    | 57 +++++++++++++++++++
 indra/newview/pipeline.h                      |  4 ++
 .../default/xui/en/menu_inventory_add.xml     |  4 +-
 .../skins/default/xui/en/menu_viewer.xml      | 11 ++++
 .../default/xui/en/panel_main_inventory.xml   |  4 +-
 15 files changed, 145 insertions(+), 43 deletions(-)

diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp
index 5c112b52b2a..ce5428f0e17 100644
--- a/indra/llmath/m4math.cpp
+++ b/indra/llmath/m4math.cpp
@@ -684,37 +684,6 @@ const LLMatrix4&  	LLMatrix4::initMatrix(const LLMatrix3 &mat, const LLVector4 &
 
 // LLMatrix4 Operators
 
-
-/* Not implemented to help enforce code consistency with the syntax of
-   row-major notation.  This is a Good Thing.
-LLVector4 operator*(const LLMatrix4 &a, const LLVector4 &b)
-{
-	// Operate "to the right" on column-vector b
-	LLVector4	vec;
-	vec.mV[VX] = a.mMatrix[VX][VX] * b.mV[VX] + 
-				 a.mMatrix[VY][VX] * b.mV[VY] + 
- 				 a.mMatrix[VZ][VX] * b.mV[VZ] +
-				 a.mMatrix[VW][VX] * b.mV[VW];
-
-	vec.mV[VY] = a.mMatrix[VX][VY] * b.mV[VX] + 
-				 a.mMatrix[VY][VY] * b.mV[VY] + 
-				 a.mMatrix[VZ][VY] * b.mV[VZ] +
-				 a.mMatrix[VW][VY] * b.mV[VW];
-
-	vec.mV[VZ] = a.mMatrix[VX][VZ] * b.mV[VX] + 
-			  	 a.mMatrix[VY][VZ] * b.mV[VY] + 
-				 a.mMatrix[VZ][VZ] * b.mV[VZ] +
-				 a.mMatrix[VW][VZ] * b.mV[VW];
-
-	vec.mV[VW] = a.mMatrix[VX][VW] * b.mV[VX] + 
-				 a.mMatrix[VY][VW] * b.mV[VY] + 
-				 a.mMatrix[VZ][VW] * b.mV[VZ] +
-				 a.mMatrix[VW][VW] * b.mV[VW];
-	return vec;
-}
-*/
-
-
 LLVector4 operator*(const LLVector4 &a, const LLMatrix4 &b)
 {
 	// Operate "to the left" on row-vector a
diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h
index 6007b96bd9a..40599a08865 100644
--- a/indra/llmath/m4math.h
+++ b/indra/llmath/m4math.h
@@ -226,10 +226,7 @@ class LLMatrix4
 	// Operators
 	//
 
-// Not implemented to enforce code that agrees with symbolic syntax
-//		friend LLVector4 operator*(const LLMatrix4 &a, const LLVector4 &b);		// Apply rotation a to vector b
-
-//	friend inline LLMatrix4 operator*(const LLMatrix4 &a, const LLMatrix4 &b);		// Return a * b
+	//	friend inline LLMatrix4 operator*(const LLMatrix4 &a, const LLMatrix4 &b);		// Return a * b
 	friend LLVector4 operator*(const LLVector4 &a, const LLMatrix4 &b);		// Return transform of vector a by matrix b
 	friend const LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b);		// Return full transform of a by matrix b
 	friend LLVector4 rotate_vector(const LLVector4 &a, const LLMatrix4 &b);	// Rotates a but does not translate
diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp
index 63683ed4962..82aad6550b0 100644
--- a/indra/llmath/v3math.cpp
+++ b/indra/llmath/v3math.cpp
@@ -197,6 +197,28 @@ const LLVector3&	LLVector3::rotVec(const LLQuaternion &q)
 	return *this;
 }
 
+const LLVector3& LLVector3::transVec(const LLMatrix4& mat)
+{
+	setVec(
+			mV[VX] * mat.mMatrix[VX][VX] + 
+			mV[VY] * mat.mMatrix[VX][VY] + 
+			mV[VZ] * mat.mMatrix[VX][VZ] +
+			mat.mMatrix[VX][VW],
+			 
+			mV[VX] * mat.mMatrix[VY][VX] + 
+			mV[VY] * mat.mMatrix[VY][VY] + 
+			mV[VZ] * mat.mMatrix[VY][VZ] +
+			mat.mMatrix[VY][VW],
+
+			mV[VX] * mat.mMatrix[VZ][VX] + 
+			mV[VY] * mat.mMatrix[VZ][VY] + 
+			mV[VZ] * mat.mMatrix[VZ][VZ] +
+			mat.mMatrix[VZ][VW]);
+
+	return *this;
+}
+
+
 const LLVector3&	LLVector3::rotVec(F32 angle, const LLVector3 &vec)
 {
 	if ( !vec.isExactlyZero() && angle )
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index 73738cffd25..76dd938887c 100644
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -36,10 +36,12 @@
 #include "llerror.h"
 #include "llmath.h"
 
+
 #include "llsd.h"
 class LLVector2;
 class LLVector4;
 class LLMatrix3;
+class LLMatrix4;
 class LLVector3d;
 class LLQuaternion;
 
@@ -115,6 +117,7 @@ class LLVector3
 		const LLVector3&	rotVec(F32 angle, F32 x, F32 y, F32 z);		// Rotates about x,y,z by angle radians
 		const LLVector3&	rotVec(const LLMatrix3 &mat);				// Rotates by LLMatrix4 mat
 		const LLVector3&	rotVec(const LLQuaternion &q);				// Rotates by LLQuaternion q
+		const LLVector3&	transVec(const LLMatrix4& mat);				// Transforms by LLMatrix4 mat (mat * v)
 
 		const LLVector3&	scaleVec(const LLVector3& vec);				// scales per component by vec
 		LLVector3			scaledVec(const LLVector3& vec) const;			// get a copy of this vector scaled by vec
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 116e2659140..415d2f603b2 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -668,6 +668,12 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
 {
 	LLMemType mt2(LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER);
 		
+	if (nverts < 0 || nindices < 0 ||
+		nverts > 65536)
+	{
+		llerrs << "Bad vertex buffer allocation: " << nverts << " : " << nindices << llendl;
+	}
+
 	updateNumVerts(nverts);
 	updateNumIndices(nindices);
 	
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index bb90aeb91a5..cb30147925e 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1687,7 +1687,7 @@
     <key>DebugShowRenderInfo</key>
     <map>
       <key>Comment</key>
-      <string>Show depth buffer contents</string>
+      <string>Show stats about current scene</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -1695,6 +1695,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+  <key>DebugShowUploadCost</key>
+  <map>
+    <key>Comment</key>
+    <string>Show what it would cost to upload assets in current scene</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>0</integer>
+  </map>
   <key>DebugShowRenderMatrices</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index b25d622d171..9404d7ce6b6 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -445,8 +445,7 @@ void init_menus()
 	gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost);
 	gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost);
 	gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", upload_cost);
-	gMenuHolder->childSetLabelArg("Upload Model", "[COST]", upload_cost);
-
+	
 	gAFKMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Away", TRUE);
 	gBusyMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Busy", TRUE);
 	gAttachSubMenu = gMenuBarView->findChildMenuByName("Attach Object", TRUE);
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 0f26975149b..53688f12109 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -92,6 +92,15 @@ class LLFileEnableUpload : public view_listener_t
 	}
 };
 
+class LLFileEnableUploadModel : public view_listener_t
+{
+	bool handleEvent(const LLSD& userdata)
+	{
+		bool new_value = gAgent.getRegion() && !gAgent.getRegion()->getCapability("NewFileAgentInventoryVariablePrice").empty();
+		return new_value;
+	}
+};
+
 //============================================================================
 
 #if LL_WINDOWS
@@ -1283,6 +1292,7 @@ void init_menu_file()
 	view_listener_t::addCommit(new LLFileQuit(), "File.Quit");
 
 	view_listener_t::addEnable(new LLFileEnableUpload(), "File.EnableUpload");
+	view_listener_t::addEnable(new LLFileEnableUploadModel(), "File.EnableUploadModel");
 	
 	// "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled.
 }
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 6a9e6f090fa..a8702b2c6ba 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4842,7 +4842,6 @@ void process_economy_data(LLMessageSystem *msg, void** /*user_data*/)
 
 	gMenuHolder->childSetLabelArg("Upload Image", "[COST]", llformat("%d", upload_cost));
 	gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", llformat("%d", upload_cost));
-	gMenuHolder->childSetLabelArg("Upload Model", "[COST]", llformat("%d", upload_cost));
 	gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", llformat("%d", upload_cost));
 	gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", llformat("%d", upload_cost));
 }
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index f554acf1dff..5b21e13bf10 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -584,6 +584,20 @@ class LLDebugText
 			}
 		}
 
+
+		if (gSavedSettings.getBOOL("DebugShowUploadCost"))
+		{
+			addText(xpos, ypos, llformat("       Meshes: L$%d", gPipeline.mDebugMeshUploadCost));
+			ypos += y_inc/2.f;
+			addText(xpos, ypos, llformat("    Sculpties: L$%d", gPipeline.mDebugSculptUploadCost));
+			ypos += y_inc/2.f;
+			addText(xpos, ypos, llformat("     Textures: L$%d", gPipeline.mDebugTextureUploadCost));
+			ypos += y_inc/2.f;
+			addText(xpos, ypos, "Upload Cost: ");
+						
+			ypos += y_inc;
+		}
+
 		//temporary hack to give feedback on mesh upload progress
 		if (!gMeshRepo.mUploads.empty())
 		{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 559ae831829..43b21041358 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3553,6 +3553,63 @@ void LLPipeline::renderDebug()
 		}
 	}
 
+	if (gSavedSettings.getBOOL("DebugShowUploadCost"))
+	{
+		std::set<LLUUID> textures;
+		std::set<LLUUID> sculpts;
+		std::set<LLUUID> meshes;
+		
+		BOOL selected = TRUE;
+		if (LLSelectMgr::getInstance()->getSelection()->isEmpty())
+		{
+			selected = FALSE;
+		}
+			
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		{
+			LLSpatialGroup* group = *iter;
+			LLSpatialGroup::OctreeNode* node = group->mOctreeNode;
+			for (LLSpatialGroup::OctreeNode::element_iter elem = node->getData().begin(); elem != node->getData().end(); ++elem)
+			{
+				LLDrawable* drawable = *elem;
+				LLVOVolume* volume = drawable->getVOVolume();
+				if (volume && volume->isSelected() == selected)
+				{
+					for (U32 i = 0; i < volume->getNumTEs(); ++i)
+					{
+						LLTextureEntry* te = volume->getTE(i);
+						textures.insert(te->getID());
+					}
+
+					if (volume->isSculpted())
+					{
+						LLUUID sculpt_id = volume->getVolume()->getParams().getSculptID();
+						if (volume->isMesh())
+						{
+							meshes.insert(sculpt_id);
+						}
+						else
+						{
+							sculpts.insert(sculpt_id);
+						}
+					}
+				}
+			}
+		}
+
+		gPipeline.mDebugTextureUploadCost = textures.size() * 10;
+		gPipeline.mDebugSculptUploadCost = sculpts.size()*10;
+		
+		U32 mesh_cost = 0;
+
+		for (std::set<LLUUID>::iterator iter = meshes.begin(); iter != meshes.end(); ++iter)
+		{
+			mesh_cost += gMeshRepo.getResourceCost(*iter)*10;
+		}
+
+		gPipeline.mDebugMeshUploadCost = mesh_cost;
+	}
+
 	for (LLCullResult::bridge_list_t::const_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
 	{
 		LLSpatialBridge* bridge = *i;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 33c18c1b86b..814c54326a7 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -435,6 +435,10 @@ class LLPipeline
 	S32						 mNumVisibleNodes;
 	S32						 mVerticesRelit;
 
+	S32						 mDebugTextureUploadCost;
+	S32						 mDebugSculptUploadCost;
+	S32						 mDebugMeshUploadCost;
+
 	S32						 mLightingChanges;
 	S32						 mGeometryChanges;
 
diff --git a/indra/newview/skins/default/xui/en/menu_inventory_add.xml b/indra/newview/skins/default/xui/en/menu_inventory_add.xml
index 0d974075f56..05a4e60de79 100644
--- a/indra/newview/skins/default/xui/en/menu_inventory_add.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory_add.xml
@@ -43,14 +43,14 @@
                      function="File.EnableUpload" />
                 </menu_item_call>
 		<menu_item_call
-                 label="Model (L$[COST])..."
+                 label="Model..."
                  layout="topleft"
                  name="Upload Model">
                 <menu_item_call.on_click
                  function="File.UploadModel"
                  parameter="" />
                 <menu_item_call.on_enable
-                 function="File.EnableUpload" />
+                 function="File.EnableUploadModel" />
               </menu_item_call>
               <menu_item_call
                  label="Scene..."
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 158e764eaed..5c75a95c16b 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2061,6 +2061,17 @@
                  function="ToggleControl"
                  parameter="DebugShowTime" />
             </menu_item_check>
+          <menu_item_check
+             label="Show Upload Cost"
+             layout="topleft"
+             name="Show Upload Cost">
+            <menu_item_check.on_check
+             function="CheckControl"
+             parameter="DebugShowUploadCost" />
+            <menu_item_check.on_click
+             function="ToggleControl"
+             parameter="DebugShowUploadCost" />
+          </menu_item_check>
             <menu_item_check
              label="Show Render Info"
              layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_main_inventory.xml b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
index 5cd5d0dfea6..afd098ba21c 100644
--- a/indra/newview/skins/default/xui/en/panel_main_inventory.xml
+++ b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
@@ -80,14 +80,14 @@
                      function="File.EnableUpload" />
                 </menu_item_call>
                 <menu_item_call
-                 label="Model (L$[COST])..."
+                 label="Model..."
                  layout="topleft"
                  name="Upload Model">
                     <menu_item_call.on_click
                      function="File.UploadModel"
                      parameter="" />
                     <menu_item_call.on_enable
-                     function="File.EnableUpload" />
+                     function="File.EnableUploadModel" />
                 </menu_item_call>
                 <menu_item_call
                  label="Scene..."
-- 
GitLab


From dc01f8db212a09c9745e72e7f01c61ba648b3355 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 1 Mar 2010 19:36:10 -0600
Subject: [PATCH 151/683] "Model..." upload button always enabled now. Default
 fast alpha to on.

---
 indra/newview/app_settings/settings.xml | 4 ++--
 indra/newview/llviewermenufile.cpp      | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 26ed763b0a4..0238fab5af7 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6910,13 +6910,13 @@
     <key>RenderFastAlpha</key>
     <map>
       <key>Comment</key>
-      <string>Use lossy alpha rendering optimization (opaque/nonexistent small alpha faces).</string>
+      <string>Use alpha masks where appropriate.</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>0</integer>
+      <integer>1</integer>
     </map>
     <key>RenderFastUI</key>
     <map>
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 53688f12109..e2602204930 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -96,8 +96,7 @@ class LLFileEnableUploadModel : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
-		bool new_value = gAgent.getRegion() && !gAgent.getRegion()->getCapability("NewFileAgentInventoryVariablePrice").empty();
-		return new_value;
+		return true;
 	}
 };
 
-- 
GitLab


From 21586ca40f661ec0c5bcce37dc681b3b37ee5a08 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 1 Mar 2010 20:27:07 -0600
Subject: [PATCH 152/683] Fix for gcc compiler error ? Fix for cropping of
 models in model preview window. Fix for prim count and upload cost always
 being 0.

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

diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 5b21e13bf10..d682e85b7ec 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -588,11 +588,11 @@ class LLDebugText
 		if (gSavedSettings.getBOOL("DebugShowUploadCost"))
 		{
 			addText(xpos, ypos, llformat("       Meshes: L$%d", gPipeline.mDebugMeshUploadCost));
-			ypos += y_inc/2.f;
+			ypos += y_inc/2;
 			addText(xpos, ypos, llformat("    Sculpties: L$%d", gPipeline.mDebugSculptUploadCost));
-			ypos += y_inc/2.f;
+			ypos += y_inc/2;
 			addText(xpos, ypos, llformat("     Textures: L$%d", gPipeline.mDebugTextureUploadCost));
-			ypos += y_inc/2.f;
+			ypos += y_inc/2;
 			addText(xpos, ypos, "Upload Cost: ");
 						
 			ypos += y_inc;
-- 
GitLab


From e9d926385f4d8933d10bb4a3168628e0a6f0ad2a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 2 Mar 2010 12:03:00 -0600
Subject: [PATCH 153/683] Curl tweaks to get rid of various types of timeouts.
 - Scrub host names from capability ips (requires disabling SSL host name
 verification) - Reset connections that have received a timeout (avoids
 cascading timeouts from reusing a cached bad connection)

---
 indra/llmessage/llcurl.cpp       | 11 ++++++++---
 indra/newview/llviewerregion.cpp | 15 ++++++++++++++-
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index c640e176ee9..637110ba0fc 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -353,9 +353,10 @@ LLCurl::Easy* LLCurl::Easy::getEasy()
 		return NULL;
 	}
 	
-	// set no DMS caching as default for all easy handles. This prevents them adopting a
+	// set no DNS caching as default for all easy handles. This prevents them adopting a
 	// multi handles cache if they are added to one.
 	curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_DNS_CACHE_TIMEOUT, 0);
+
 	++gCurlEasyCount;
 	return easy;
 }
@@ -440,6 +441,7 @@ U32 LLCurl::Easy::report(CURLcode code)
 	{
 		responseCode = 499;
 		responseReason = strerror(code) + " : " + mErrorBuffer;
+		setopt(CURLOPT_FRESH_CONNECT, TRUE);
 	}
 		
 	if (mResponder)
@@ -526,7 +528,7 @@ void LLCurl::Easy::prepRequest(const std::string& url,
 	
 	if (post) setoptString(CURLOPT_ENCODING, "");
 
-//	setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
+	//setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
 	setopt(CURLOPT_NOSIGNAL, 1);
 
 	mOutput.reset(new LLBufferArray);
@@ -543,9 +545,12 @@ void LLCurl::Easy::prepRequest(const std::string& url,
 	setCA();
 
 	setopt(CURLOPT_SSL_VERIFYPEER, LLCurl::getSSLVerify());
-	setopt(CURLOPT_SSL_VERIFYHOST, LLCurl::getSSLVerify()? 2 : 0);
+	//setopt(CURLOPT_SSL_VERIFYHOST, LLCurl::getSSLVerify()? 2 : 0);
+	setopt(CURLOPT_SSL_VERIFYHOST, 0);
 	setopt(CURLOPT_TIMEOUT, CURL_REQUEST_TIMEOUT);
 
+	setopt(CURLOPT_FORBID_REUSE, TRUE);
+
 	setoptString(CURLOPT_URL, url);
 
 	mResponder = responder;
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 6737b113afb..be7fb042063 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1552,7 +1552,20 @@ std::string LLViewerRegion::getCapability(const std::string& name) const
 	{
 		return "";
 	}
-	return iter->second;
+
+	std::string http_url = iter->second;
+
+	std::string ip_string = mHost.getIPString();
+	std::string host_string = mHost.getHostName();
+
+	std::string::size_type idx = http_url.find(host_string);
+
+	if (!ip_string.empty() && !host_string.empty() && idx != std::string::npos)
+	{
+		http_url.replace(idx, host_string.length(), ip_string);
+	}
+
+	return http_url;
 }
 
 void LLViewerRegion::logActiveCapabilities() const
-- 
GitLab


From e38adc5baf0bf4090168088fc4b9a71a5b231aa4 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 2 Mar 2010 12:35:19 -0600
Subject: [PATCH 154/683] cleanup from review

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

diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 637110ba0fc..f8a7eb04170 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -546,11 +546,11 @@ void LLCurl::Easy::prepRequest(const std::string& url,
 
 	setopt(CURLOPT_SSL_VERIFYPEER, LLCurl::getSSLVerify());
 	//setopt(CURLOPT_SSL_VERIFYHOST, LLCurl::getSSLVerify()? 2 : 0);
+	
+	//don't verify host name so urls with scrubbed host names will work (improves DNS performance)
 	setopt(CURLOPT_SSL_VERIFYHOST, 0);
 	setopt(CURLOPT_TIMEOUT, CURL_REQUEST_TIMEOUT);
 
-	setopt(CURLOPT_FORBID_REUSE, TRUE);
-
 	setoptString(CURLOPT_URL, url);
 
 	mResponder = responder;
-- 
GitLab


From 5f9591535138d782f0f9666b39534149de0562a1 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 2 Mar 2010 17:06:08 -0600
Subject: [PATCH 155/683] Can upload textures from model preview now. Fix for
 bad region crossing.

---
 indra/newview/llviewerregion.cpp  | 14 +-------------
 indra/newview/llviewertexture.cpp | 11 +++++++++--
 indra/newview/llviewerwindow.cpp  |  4 ++--
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index be7fb042063..dc1dfeb82b9 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1553,19 +1553,7 @@ std::string LLViewerRegion::getCapability(const std::string& name) const
 		return "";
 	}
 
-	std::string http_url = iter->second;
-
-	std::string ip_string = mHost.getIPString();
-	std::string host_string = mHost.getHostName();
-
-	std::string::size_type idx = http_url.find(host_string);
-
-	if (!ip_string.empty() && !host_string.empty() && idx != std::string::npos)
-	{
-		http_url.replace(idx, host_string.length(), ip_string);
-	}
-
-	return http_url;
+	return iter->second;
 }
 
 void LLViewerRegion::logActiveCapabilities() const
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 0f0fd5da301..d0c3768b34f 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1367,8 +1367,15 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
 			mOrigWidth = mRawImage->getWidth();
 			mOrigHeight = mRawImage->getHeight();
 
-			// leave black border, do not scale image content
-			mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, FALSE);
+			
+			if (mBoostLevel == BOOST_PREVIEW)
+			{ 
+				mRawImage->biasedScaleToPowerOfTwo(1024);
+			}
+			else
+			{ // leave black border, do not scale image content
+				mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, FALSE);
+			}
 			
 			mFullWidth = mRawImage->getWidth();
 			mFullHeight = mRawImage->getHeight();
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index d682e85b7ec..1f19c23a6f1 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -607,8 +607,8 @@ class LLDebugText
 				LLMeshUploadThread* thread = *iter;
 
 				addText(xpos, ypos, llformat("Mesh Upload -- price quote: %d:%d | upload: %d:%d | create: %d", 
-								thread->mPendingConfirmations, thread->mUploadQ.size(),
-								thread->mPendingUploads, thread->mConfirmedQ.size(),
+								thread->mPendingConfirmations, thread->mUploadQ.size()+thread->mTextureQ.size(),
+								thread->mPendingUploads, thread->mConfirmedQ.size()+thread->mConfirmedTextureQ.size(),
 								thread->mCompletedQ.size()));
 				ypos += y_inc;
 			}
-- 
GitLab


From ac2dc19029d0b17292beadc834fdf41330eb88d8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 2 Mar 2010 19:04:13 -0600
Subject: [PATCH 156/683] Fix for bad handling of creating mesh prim instances.

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

diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 1f19c23a6f1..0bdac6eff40 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -609,7 +609,7 @@ class LLDebugText
 				addText(xpos, ypos, llformat("Mesh Upload -- price quote: %d:%d | upload: %d:%d | create: %d", 
 								thread->mPendingConfirmations, thread->mUploadQ.size()+thread->mTextureQ.size(),
 								thread->mPendingUploads, thread->mConfirmedQ.size()+thread->mConfirmedTextureQ.size(),
-								thread->mCompletedQ.size()));
+								thread->mInstanceQ.size()));
 				ypos += y_inc;
 			}
 		}
-- 
GitLab


From ea6397fe4990b73e190391d61781c609fbd1f8c1 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 4 Mar 2010 15:30:15 -0600
Subject: [PATCH 157/683] Optimiziation pass. Added RenderUseStreamVBO to
 enable/disable usage of VBO's for streaming buffers. Faster traversal of
 LLCullResult members. Removal of llpushcallstacks from inner loops.
 Sprinkling in fast timers.

---
 indra/llrender/llglslshader.cpp         |   6 ++
 indra/llrender/llvertexbuffer.cpp       |   6 ++
 indra/llrender/llvertexbuffer.h         |   2 +
 indra/newview/app_settings/settings.xml |  11 ++
 indra/newview/lldrawable.cpp            |   7 ++
 indra/newview/lldrawpool.cpp            |   2 +-
 indra/newview/lldrawpoolalpha.cpp       | 132 ++++++++++++------------
 indra/newview/lldrawpoolbump.cpp        |   4 +-
 indra/newview/llface.cpp                |   4 +-
 indra/newview/llspatialpartition.cpp    |  36 +++++--
 indra/newview/llspatialpartition.h      |   7 ++
 indra/newview/llviewercontrol.cpp       |   1 +
 indra/newview/llvovolume.cpp            |   6 +-
 indra/newview/pipeline.cpp              |  21 +++-
 14 files changed, 160 insertions(+), 85 deletions(-)

diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index ca92cb6580f..2b3179116d7 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -343,8 +343,11 @@ BOOL LLGLSLShader::link(BOOL suppress_errors)
 	return LLShaderMgr::instance()->linkProgramObject(mProgramObject, suppress_errors);
 }
 
+static LLFastTimer::DeclareTimer FTM_BIND_SHADER("Bind Shader");
+
 void LLGLSLShader::bind()
 {
+	LLFastTimer ftm(FTM_BIND_SHADER);
 	if (gGLManager.mHasShaderObjects)
 	{
 		glUseProgramObjectARB(mProgramObject);
@@ -357,8 +360,11 @@ void LLGLSLShader::bind()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_UNBIND_SHADER("Unbind Shader");
+
 void LLGLSLShader::unbind()
 {
+	LLFastTimer ftm(FTM_UNBIND_SHADER);
 	if (gGLManager.mHasShaderObjects)
 	{
 		stop_glerror();
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 415d2f603b2..4064e688e83 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -61,6 +61,7 @@ BOOL LLVertexBuffer::sVBOActive = FALSE;
 BOOL LLVertexBuffer::sIBOActive = FALSE;
 U32 LLVertexBuffer::sAllocatedBytes = 0;
 BOOL LLVertexBuffer::sMapped = FALSE;
+BOOL LLVertexBuffer::sUseStreamDraw = TRUE;
 
 std::vector<U32> LLVertexBuffer::sDeleteList;
 
@@ -381,6 +382,11 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
 	{
 		mUsage = 0 ; 
 	}
+
+	if (mUsage == GL_STREAM_DRAW_ARB && !sUseStreamDraw)
+	{
+		mUsage = 0;
+	}
 	
 	S32 stride = calcStride(typemask, mOffsets);
 
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index b785a229769..e2fecdffef9 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -83,6 +83,8 @@ class LLVertexBuffer : public LLRefCount
 	static LLVBOPool sDynamicVBOPool;
 	static LLVBOPool sStreamIBOPool;
 	static LLVBOPool sDynamicIBOPool;
+	
+	static BOOL	sUseStreamDraw;
 
 	static void initClass(bool use_vbo);
 	static void cleanupClass();
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 0238fab5af7..e234af699b6 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7531,6 +7531,17 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
+  <key>RenderUseStreamVBO</key>
+  <map>
+    <key>Comment</key>
+    <string>Use VBO's for stream buffers</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>1</integer>
+  </map>
     <key>RenderVolumeLODFactor</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 390e950d758..fd9cb18a42a 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -683,8 +683,11 @@ BOOL LLDrawable::updateMoveDamped()
 	return done_moving;
 }
 
+static LLFastTimer::DeclareTimer FTM_UPDATE_DISTANCE("Update Distance");
+
 void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 {
+	LLFastTimer t(FTM_UPDATE_DISTANCE);
 	if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
 		llerrs << "WTF?" << llendl;
@@ -1317,8 +1320,12 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_BRIDGE_DISTANCE_UPDATE("Bridge Distance");
+
 void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 {
+	LLFastTimer t(FTM_BRIDGE_DISTANCE_UPDATE);
+
 	if (mDrawable == NULL)
 	{
 		markDead();
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index ef946ac49e5..ae30af36478 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -442,7 +442,6 @@ void LLRenderPass::renderTexture(U32 type, U32 mask)
 
 void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture)
 {
-	llpushcallstacks ;
 	for (LLCullResult::drawinfo_list_t::iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i)	
 	{
 		LLDrawInfo* pparams = *i;
@@ -475,6 +474,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
 	{
 		if (params.mTexture.notNull())
 		{
+			params.mTexture->addTextureStats(params.mVSize);
 			gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ;
 			if (params.mTextureMatrix)
 			{
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 875c9ac6a9d..75973cfa54b 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -294,96 +294,98 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 
 				LLRenderPass::applyModelMatrix(params);
 
-				if (params.mFullbright)
 				{
-					// Turn off lighting if it hasn't already been so.
-					if (light_enabled || !initialized_lighting)
+					if (params.mFullbright)
+					{
+						// Turn off lighting if it hasn't already been so.
+						if (light_enabled || !initialized_lighting)
+						{
+							initialized_lighting = TRUE;
+							if (use_shaders) 
+							{
+								target_shader = fullbright_shader;
+							}
+							else
+							{
+								gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
+							}
+							light_enabled = FALSE;
+						}
+					}
+					// Turn on lighting if it isn't already.
+					else if (!light_enabled || !initialized_lighting)
 					{
 						initialized_lighting = TRUE;
 						if (use_shaders) 
 						{
-							target_shader = fullbright_shader;
+							target_shader = simple_shader;
 						}
 						else
 						{
-							gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
+							gPipeline.enableLightsDynamic();
 						}
-						light_enabled = FALSE;
+						light_enabled = TRUE;
 					}
-				}
-				// Turn on lighting if it isn't already.
-				else if (!light_enabled || !initialized_lighting)
-				{
-					initialized_lighting = TRUE;
-					if (use_shaders) 
-					{
-						target_shader = simple_shader;
-					}
-					else
-					{
-						gPipeline.enableLightsDynamic();
-					}
-					light_enabled = TRUE;
-				}
 
-				// If we need shaders, and we're not ALREADY using the proper shader, then bind it
-				// (this way we won't rebind shaders unnecessarily).
-				if(use_shaders && (current_shader != target_shader))
-				{
-					llassert(target_shader != NULL);
-					if (deferred_render && current_shader != NULL)
-					{
-						gPipeline.unbindDeferredShader(*current_shader);
-						diffuse_channel = 0;
-					}
-					current_shader = target_shader;
-					if (deferred_render)
-					{
-						gPipeline.bindDeferredShader(*current_shader);
-						diffuse_channel = current_shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
-					}
-					else
+					// If we need shaders, and we're not ALREADY using the proper shader, then bind it
+					// (this way we won't rebind shaders unnecessarily).
+					if(use_shaders && (current_shader != target_shader))
 					{
-						current_shader->bind();
+						llassert(target_shader != NULL);
+						if (deferred_render && current_shader != NULL)
+						{
+							gPipeline.unbindDeferredShader(*current_shader);
+							diffuse_channel = 0;
+						}
+						current_shader = target_shader;
+						if (deferred_render)
+						{
+							gPipeline.bindDeferredShader(*current_shader);
+							diffuse_channel = current_shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
+						}
+						else
+						{
+							current_shader->bind();
+						}
 					}
-				}
-				else if (!use_shaders && current_shader != NULL)
-				{
-					if (deferred_render)
+					else if (!use_shaders && current_shader != NULL)
 					{
-						gPipeline.unbindDeferredShader(*current_shader);
-						diffuse_channel = 0;
+						if (deferred_render)
+						{
+							gPipeline.unbindDeferredShader(*current_shader);
+							diffuse_channel = 0;
+						}
+						LLGLSLShader::bindNoShader();
+						current_shader = NULL;
 					}
-					LLGLSLShader::bindNoShader();
-					current_shader = NULL;
-				}
-
-				if (params.mGroup)
-				{
-					params.mGroup->rebuildMesh();
-				}
 
-				
-				if (params.mTexture.notNull())
-				{
-					gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get());
-					if(params.mTexture.notNull())
+					if (params.mGroup)
 					{
-						params.mTexture->addTextureStats(params.mVSize);
+						params.mGroup->rebuildMesh();
 					}
-					if (params.mTextureMatrix)
+
+					
+					if (params.mTexture.notNull())
 					{
-						gGL.getTexUnit(0)->activate();
-						glMatrixMode(GL_TEXTURE);
-						glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
-						gPipeline.mTextureMatrixOps++;
+						gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get());
+						if(params.mTexture.notNull())
+						{
+							params.mTexture->addTextureStats(params.mVSize);
+						}
+						if (params.mTextureMatrix)
+						{
+							gGL.getTexUnit(0)->activate();
+							glMatrixMode(GL_TEXTURE);
+							glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
+							gPipeline.mTextureMatrixOps++;
+						}
 					}
 				}
 
 				params.mVertexBuffer->setBuffer(mask);
 				params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
 				gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
-
+			
 				if (params.mTextureMatrix && params.mTexture.notNull())
 				{
 					gGL.getTexUnit(0)->activate();
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index a4a8dc80b5b..8f3e775976c 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -837,7 +837,6 @@ void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32
 
 void LLBumpImageList::updateImages()
 {	
-	llpushcallstacks ;
 	for (bump_image_map_t::iterator iter = mBrightnessEntries.begin(); iter != mBrightnessEntries.end(); )
 	{
 		bump_image_map_t::iterator curiter = iter++;
@@ -864,7 +863,7 @@ void LLBumpImageList::updateImages()
 			}
 		}
 	}
-	llpushcallstacks ;
+	
 	for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); )
 	{
 		bump_image_map_t::iterator curiter = iter++;
@@ -891,7 +890,6 @@ void LLBumpImageList::updateImages()
 			}
 		}
 	}
-	llpushcallstacks ;
 }
 
 
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 770811b5875..53330e4d985 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -883,12 +883,14 @@ void LLFace::updateRebuildFlags()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_FACE_GET_GEOM("Face Geom");
+
 BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 							   const S32 &f,
 								const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
 								const U16 &index_offset)
 {
-	llpushcallstacks ;
+	LLFastTimer t(FTM_FACE_GET_GEOM);
 	const LLVolumeFace &vf = volume.getVolumeFace(f);
 	S32 num_vertices = (S32)vf.mVertices.size();
 	S32 num_indices = LLPipeline::sUseTriStrips ? (S32)vf.mTriStrip.size() : (S32) vf.mIndices.size();
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 19bf40b56ab..3742f70df52 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1513,6 +1513,7 @@ void LLSpatialGroup::checkOcclusion()
 {
 	if (LLPipeline::sUseOcclusion > 1)
 	{
+		LLFastTimer t(FTM_OCCLUSION_READBACK);
 		LLSpatialGroup* parent = getParent();
 		if (parent && parent->isOcclusionState(LLSpatialGroup::OCCLUDED))
 		{	//if the parent has been marked as occluded, the child is implicitly occluded
@@ -1520,7 +1521,6 @@ void LLSpatialGroup::checkOcclusion()
 		}
 		else if (isOcclusionState(QUERY_PENDING))
 		{	//otherwise, if a query is pending, read it back
-			LLFastTimer t(FTM_OCCLUSION_READBACK);
 			GLuint res = 1;
 			if (!isOcclusionState(DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID])
 			{
@@ -3422,11 +3422,23 @@ LLCullResult::LLCullResult()
 void LLCullResult::clear()
 {
 	mVisibleGroupsSize = 0;
+	mVisibleGroupsEnd = mVisibleGroups.begin();
+
 	mAlphaGroupsSize = 0;
+	mAlphaGroupsEnd = mAlphaGroups.begin();
+
 	mOcclusionGroupsSize = 0;
+	mOcclusionGroupsEnd = mOcclusionGroups.begin();
+
 	mDrawableGroupsSize = 0;
+	mDrawableGroupsEnd = mDrawableGroups.begin();
+
 	mVisibleListSize = 0;
+	mVisibleListEnd = mVisibleList.begin();
+
 	mVisibleBridgeSize = 0;
+	mVisibleBridgeEnd = mVisibleBridge.begin();
+
 
 	for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
 	{
@@ -3435,6 +3447,7 @@ void LLCullResult::clear()
 			mRenderMap[i][j] = 0;
 		}
 		mRenderMapSize[i] = 0;
+		mRenderMapEnd[i] = mRenderMap[i].begin();
 	}
 }
 
@@ -3445,7 +3458,7 @@ LLCullResult::sg_list_t::iterator LLCullResult::beginVisibleGroups()
 
 LLCullResult::sg_list_t::iterator LLCullResult::endVisibleGroups()
 {
-	return mVisibleGroups.begin() + mVisibleGroupsSize;
+	return mVisibleGroupsEnd;
 }
 
 LLCullResult::sg_list_t::iterator LLCullResult::beginAlphaGroups()
@@ -3455,7 +3468,7 @@ LLCullResult::sg_list_t::iterator LLCullResult::beginAlphaGroups()
 
 LLCullResult::sg_list_t::iterator LLCullResult::endAlphaGroups()
 {
-	return mAlphaGroups.begin() + mAlphaGroupsSize;
+	return mAlphaGroupsEnd;
 }
 
 LLCullResult::sg_list_t::iterator LLCullResult::beginOcclusionGroups()
@@ -3465,7 +3478,7 @@ LLCullResult::sg_list_t::iterator LLCullResult::beginOcclusionGroups()
 
 LLCullResult::sg_list_t::iterator LLCullResult::endOcclusionGroups()
 {
-	return mOcclusionGroups.begin() + mOcclusionGroupsSize;
+	return mOcclusionGroupsEnd;
 }
 
 LLCullResult::sg_list_t::iterator LLCullResult::beginDrawableGroups()
@@ -3475,7 +3488,7 @@ LLCullResult::sg_list_t::iterator LLCullResult::beginDrawableGroups()
 
 LLCullResult::sg_list_t::iterator LLCullResult::endDrawableGroups()
 {
-	return mDrawableGroups.begin() + mDrawableGroupsSize;
+	return mDrawableGroupsEnd;
 }
 
 LLCullResult::drawable_list_t::iterator LLCullResult::beginVisibleList()
@@ -3485,7 +3498,7 @@ LLCullResult::drawable_list_t::iterator LLCullResult::beginVisibleList()
 
 LLCullResult::drawable_list_t::iterator LLCullResult::endVisibleList()
 {
-	return mVisibleList.begin() + mVisibleListSize;
+	return mVisibleListEnd;
 }
 
 LLCullResult::bridge_list_t::iterator LLCullResult::beginVisibleBridge()
@@ -3495,7 +3508,7 @@ LLCullResult::bridge_list_t::iterator LLCullResult::beginVisibleBridge()
 
 LLCullResult::bridge_list_t::iterator LLCullResult::endVisibleBridge()
 {
-	return mVisibleBridge.begin() + mVisibleBridgeSize;
+	return mVisibleBridgeEnd;
 }
 
 LLCullResult::drawinfo_list_t::iterator LLCullResult::beginRenderMap(U32 type)
@@ -3505,7 +3518,7 @@ LLCullResult::drawinfo_list_t::iterator LLCullResult::beginRenderMap(U32 type)
 
 LLCullResult::drawinfo_list_t::iterator LLCullResult::endRenderMap(U32 type)
 {
-	return mRenderMap[type].begin() + mRenderMapSize[type];
+	return mRenderMapEnd[type];
 }
 
 void LLCullResult::pushVisibleGroup(LLSpatialGroup* group)
@@ -3519,6 +3532,7 @@ void LLCullResult::pushVisibleGroup(LLSpatialGroup* group)
 		mVisibleGroups.push_back(group);
 	}
 	++mVisibleGroupsSize;
+	mVisibleGroupsEnd = mVisibleGroups.begin()+mVisibleGroupsSize;
 }
 
 void LLCullResult::pushAlphaGroup(LLSpatialGroup* group)
@@ -3532,6 +3546,7 @@ void LLCullResult::pushAlphaGroup(LLSpatialGroup* group)
 		mAlphaGroups.push_back(group);
 	}
 	++mAlphaGroupsSize;
+	mAlphaGroupsEnd = mAlphaGroups.begin()+mAlphaGroupsSize;
 }
 
 void LLCullResult::pushOcclusionGroup(LLSpatialGroup* group)
@@ -3545,6 +3560,7 @@ void LLCullResult::pushOcclusionGroup(LLSpatialGroup* group)
 		mOcclusionGroups.push_back(group);
 	}
 	++mOcclusionGroupsSize;
+	mOcclusionGroupsEnd = mOcclusionGroups.begin()+mOcclusionGroupsSize;
 }
 
 void LLCullResult::pushDrawableGroup(LLSpatialGroup* group)
@@ -3558,6 +3574,7 @@ void LLCullResult::pushDrawableGroup(LLSpatialGroup* group)
 		mDrawableGroups.push_back(group);
 	}
 	++mDrawableGroupsSize;
+	mDrawableGroupsEnd = mDrawableGroups.begin()+mDrawableGroupsSize;
 }
 
 void LLCullResult::pushDrawable(LLDrawable* drawable)
@@ -3571,6 +3588,7 @@ void LLCullResult::pushDrawable(LLDrawable* drawable)
 		mVisibleList.push_back(drawable);
 	}
 	++mVisibleListSize;
+	mVisibleListEnd = mVisibleList.begin()+mVisibleListSize;
 }
 
 void LLCullResult::pushBridge(LLSpatialBridge* bridge)
@@ -3584,6 +3602,7 @@ void LLCullResult::pushBridge(LLSpatialBridge* bridge)
 		mVisibleBridge.push_back(bridge);
 	}
 	++mVisibleBridgeSize;
+	mVisibleBridgeEnd = mVisibleBridge.begin()+mVisibleBridgeSize;
 }
 
 void LLCullResult::pushDrawInfo(U32 type, LLDrawInfo* draw_info)
@@ -3597,6 +3616,7 @@ void LLCullResult::pushDrawInfo(U32 type, LLDrawInfo* draw_info)
 		mRenderMap[type].push_back(draw_info);
 	}
 	++mRenderMapSize[type];
+	mRenderMapEnd[type] = mRenderMap[type].begin() + mRenderMapSize[type];
 }
 
 
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index c5719bebcc8..ef6b915e5cd 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -535,12 +535,19 @@ class LLCullResult
 	U32					mRenderMapSize[LLRenderPass::NUM_RENDER_TYPES];
 
 	sg_list_t			mVisibleGroups;
+	sg_list_t::iterator mVisibleGroupsEnd;
 	sg_list_t			mAlphaGroups;
+	sg_list_t::iterator mAlphaGroupsEnd;
 	sg_list_t			mOcclusionGroups;
+	sg_list_t::iterator	mOcclusionGroupsEnd;
 	sg_list_t			mDrawableGroups;
+	sg_list_t::iterator mDrawableGroupsEnd;
 	drawable_list_t		mVisibleList;
+	drawable_list_t::iterator mVisibleListEnd;
 	bridge_list_t		mVisibleBridge;
+	bridge_list_t::iterator mVisibleBridgeEnd;
 	drawinfo_list_t		mRenderMap[LLRenderPass::NUM_RENDER_TYPES];
+	drawinfo_list_t::iterator mRenderMapEnd[LLRenderPass::NUM_RENDER_TYPES];
 };
 
 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 0b7f6900ed8..1d99be9960e 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -571,6 +571,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("MuteAmbient")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
 	gSavedSettings.getControl("MuteUI")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
 	gSavedSettings.getControl("RenderVBOEnable")->getSignal()->connect(boost::bind(&handleRenderUseVBOChanged, _2));
+	gSavedSettings.getControl("RenderUseStreamVBO")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("WLSkyDetail")->getSignal()->connect(boost::bind(&handleWLSkyDetailChanged, _2));
 	gSavedSettings.getControl("RenderLightingDetail")->getSignal()->connect(boost::bind(&handleRenderLightingDetailChanged, _2));
 	gSavedSettings.getControl("NumpadControl")->getSignal()->connect(boost::bind(&handleNumpadControlChanged, _2));
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index eb2e6e3d768..39db6196a30 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3422,7 +3422,6 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
-	llpushcallstacks ;
 	if (group->changeLOD())
 	{
 		group->mLastUpdateDistance = group->mDistance;
@@ -3651,9 +3650,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 }
 
 static LLFastTimer::DeclareTimer FTM_VOLUME_GEOM("Volume Geometry");
+static LLFastTimer::DeclareTimer FTM_VOLUME_GEOM_PARTIAL("Terse Rebuild");
+
 void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 {
-	llpushcallstacks ;
 	llassert(group);
 	if (group && group->isState(LLSpatialGroup::MESH_DIRTY) && !group->isState(LLSpatialGroup::GEOM_DIRTY))
 	{
@@ -3664,6 +3664,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 		
 		for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
 		{
+			LLFastTimer t(FTM_VOLUME_GEOM_PARTIAL);
 			LLDrawable* drawablep = *drawable_iter;
 
 			if (drawablep->isDead() || drawablep->isState(LLDrawable::FORCE_INVISIBLE) )
@@ -3750,7 +3751,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 
 void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort)
 {
-	llpushcallstacks ;
 	//calculate maximum number of vertices to store in a single buffer
 	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcStride(group->mSpatialPartition->mVertexDataMask);
 	max_vertices = llmin(max_vertices, (U32) 65535);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 43b21041358..eb3ad955861 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -362,6 +362,7 @@ void LLPipeline::init()
 	sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
 	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
+	LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");
 	sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights");
 	sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles");
 
@@ -1739,8 +1740,12 @@ void LLPipeline::markOccluder(LLSpatialGroup* group)
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_DO_OCCLUSION("Do Occlusion");
+
 void LLPipeline::doOcclusion(LLCamera& camera)
 {
+	LLFastTimer t(FTM_DO_OCCLUSION);
+
 	LLVertexBuffer::unbind();
 
 	if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION))
@@ -1816,7 +1821,6 @@ void LLPipeline::rebuildPriorityGroups()
 		
 void LLPipeline::rebuildGroups()
 {
-	llpushcallstacks ;
 	// Iterate through some drawables on the non-priority build queue
 	S32 size = (S32) mGroupQ2.size();
 	S32 min_count = llclamp((S32) ((F32) (size * size)/4096*0.25f), 1, size);
@@ -1961,9 +1965,13 @@ void LLPipeline::updateGeom(F32 max_dtime)
 	updateMovedList(mMovedBridge);
 }
 
+static LLFastTimer::DeclareTimer FTM_MARK_VISIBLE("Mark Visible");
+
 void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE);
+	LLFastTimer t(FTM_MARK_VISIBLE);
+
 	if(!drawablep || drawablep->isDead())
 	{
 		return;
@@ -4704,8 +4712,12 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 	mLightMask = 0;
 }
 
+static LLFastTimer::DeclareTimer FTM_ENABLE_LIGHTS("Enable Lights");
+
 void LLPipeline::enableLights(U32 mask)
 {
+	LLFastTimer ftm(FTM_ENABLE_LIGHTS);
+
 	assertInitialized();
 
 	if (mLightingDetail == 0)
@@ -4813,16 +4825,16 @@ void LLPipeline::enableLightsFullbright(const LLColor4& color)
 	enableLights(mask);
 
 	glLightModelfv(GL_LIGHT_MODEL_AMBIENT,color.mV);
-	if (mLightingDetail >= 2)
+	/*if (mLightingDetail >= 2)
 	{
 		glColor4f(0.f, 0.f, 0.f, 1.f); // no local lighting by default
-	}
+	}*/
 }
 
 void LLPipeline::disableLights()
 {
 	enableLights(0); // no lighting (full bright)
-	glColor4f(1.f, 1.f, 1.f, 1.f); // lighting color = white by default
+	//glColor4f(1.f, 1.f, 1.f, 1.f); // lighting color = white by default
 }
 
 //============================================================================
@@ -5425,6 +5437,7 @@ void LLPipeline::resetVertexBuffers()
 {
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
 	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
+	LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");
 
 	for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
 			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
-- 
GitLab


From 4ffac619945cafc9c7da357bf56c9bc92e318b1b Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 4 Mar 2010 15:30:15 -0600
Subject: [PATCH 158/683] Optimiziation pass. Added RenderUseStreamVBO to
 enable/disable usage of VBO's for streaming buffers. Faster traversal of
 LLCullResult members. Removal of llpushcallstacks from inner loops.
 Sprinkling in fast timers.

---
 indra/llrender/llglslshader.cpp         |  42 +++---
 indra/llrender/llvertexbuffer.cpp       |  46 ++++---
 indra/llrender/llvertexbuffer.h         |  38 +++---
 indra/newview/app_settings/settings.xml |  11 ++
 indra/newview/lldrawable.cpp            |  50 ++++---
 indra/newview/lldrawpool.cpp            |  37 +++---
 indra/newview/lldrawpoolalpha.cpp       | 168 +++++++++++++-----------
 indra/newview/lldrawpoolbump.cpp        |   4 +-
 indra/newview/llface.cpp                |  53 ++++----
 indra/newview/llspatialpartition.cpp    |  73 ++++++----
 indra/newview/llspatialpartition.h      |  45 ++++---
 indra/newview/llviewercontrol.cpp       |   1 +
 indra/newview/llvovolume.cpp            |   6 +-
 indra/newview/pipeline.cpp              |  21 ++-
 14 files changed, 353 insertions(+), 242 deletions(-)

diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 16534fa9a5e..2b3179116d7 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -2,25 +2,31 @@
  * @file llglslshader.cpp
  * @brief GLSL helper functions and state.
  *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2005&license=viewergpl$
+ * 
+ * Copyright (c) 2005-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -337,8 +343,11 @@ BOOL LLGLSLShader::link(BOOL suppress_errors)
 	return LLShaderMgr::instance()->linkProgramObject(mProgramObject, suppress_errors);
 }
 
+static LLFastTimer::DeclareTimer FTM_BIND_SHADER("Bind Shader");
+
 void LLGLSLShader::bind()
 {
+	LLFastTimer ftm(FTM_BIND_SHADER);
 	if (gGLManager.mHasShaderObjects)
 	{
 		glUseProgramObjectARB(mProgramObject);
@@ -351,8 +360,11 @@ void LLGLSLShader::bind()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_UNBIND_SHADER("Unbind Shader");
+
 void LLGLSLShader::unbind()
 {
+	LLFastTimer ftm(FTM_UNBIND_SHADER);
 	if (gGLManager.mHasShaderObjects)
 	{
 		stop_glerror();
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 0f41e278b60..ae43915a9d0 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -2,25 +2,31 @@
  * @file llvertexbuffer.cpp
  * @brief LLVertexBuffer implementation
  *
- * $LicenseInfo:firstyear=2003&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2003&license=viewergpl$
+ * 
+ * Copyright (c) 2003-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -376,12 +382,12 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
 	{
 		mUsage = 0 ; 
 	}
-	
+
 	if (mUsage == GL_STREAM_DRAW_ARB && !sUseStreamDraw)
 	{
 		mUsage = 0;
 	}
-
+	
 	S32 stride = calcStride(typemask, mOffsets);
 
 	mTypeMask = typemask;
@@ -813,7 +819,7 @@ BOOL LLVertexBuffer::useVBOs() const
 		return FALSE;
 	}
 #endif
-	return TRUE;
+	return sEnableVBOs;
 }
 
 //----------------------------------------------------------------------------
@@ -1177,7 +1183,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 	{		
 		if (mGLBuffer)
 		{
-			if (sVBOActive)
+			if (sEnableVBOs && sVBOActive)
 			{
 				glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
 				sBindCount++;
@@ -1189,7 +1195,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 				setup = TRUE; // ... or a client memory pointer changed
 			}
 		}
-		if (mGLIndices && sIBOActive)
+		if (sEnableVBOs && mGLIndices && sIBOActive)
 		{
 			/*if (sMapped)
 			{
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 94fa7909574..e2fecdffef9 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -2,25 +2,31 @@
  * @file llvertexbuffer.h
  * @brief LLVertexBuffer wrapper for OpengGL vertex buffer objects
  *
- * $LicenseInfo:firstyear=2003&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2003&license=viewergpl$
+ * 
+ * Copyright (c) 2003-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -77,7 +83,7 @@ class LLVertexBuffer : public LLRefCount
 	static LLVBOPool sDynamicVBOPool;
 	static LLVBOPool sStreamIBOPool;
 	static LLVBOPool sDynamicIBOPool;
-
+	
 	static BOOL	sUseStreamDraw;
 
 	static void initClass(bool use_vbo);
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 6bfa42785f5..1dc90280a20 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7542,6 +7542,17 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
+  <key>RenderUseStreamVBO</key>
+  <map>
+    <key>Comment</key>
+    <string>Use VBO's for stream buffers</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>1</integer>
+  </map>
     <key>RenderVolumeLODFactor</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 0447b06fccd..013577261ce 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -2,25 +2,31 @@
  * @file lldrawable.cpp
  * @brief LLDrawable class implementation
  *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -667,8 +673,11 @@ BOOL LLDrawable::updateMoveDamped()
 	return done_moving;
 }
 
+static LLFastTimer::DeclareTimer FTM_UPDATE_DISTANCE("Update Distance");
+
 void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 {
+	LLFastTimer t(FTM_UPDATE_DISTANCE);
 	if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
 		llerrs << "WTF?" << llendl;
@@ -1301,8 +1310,12 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_BRIDGE_DISTANCE_UPDATE("Bridge Distance");
+
 void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 {
+	LLFastTimer t(FTM_BRIDGE_DISTANCE_UPDATE);
+
 	if (mDrawable == NULL)
 	{
 		markDead();
@@ -1360,11 +1373,10 @@ void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL imm
 
 BOOL LLSpatialBridge::updateMove()
 {
-	llassert_always(mDrawable);
-	llassert_always(mDrawable->mVObjp);
-	llassert_always(mDrawable->getRegion());
+	llassert(mDrawable);
+	llassert(mDrawable->getRegion());
 	LLSpatialPartition* part = mDrawable->getRegion()->getSpatialPartition(mPartitionType);
-	llassert_always(part);
+	llassert(part);
 
 	mOctree->balance();
 	if (part)
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index 6d8344f4e85..ae30af36478 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -2,25 +2,31 @@
  * @file lldrawpool.cpp
  * @brief LLDrawPool class implementation
  *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -468,6 +474,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
 	{
 		if (params.mTexture.notNull())
 		{
+			params.mTexture->addTextureStats(params.mVSize);
 			gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ;
 			if (params.mTextureMatrix)
 			{
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 5d1a0ee9de4..75973cfa54b 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -2,25 +2,31 @@
  * @file lldrawpoolalpha.cpp
  * @brief LLDrawPoolAlpha class implementation
  *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -288,96 +294,98 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 
 				LLRenderPass::applyModelMatrix(params);
 
-				if (params.mFullbright)
 				{
-					// Turn off lighting if it hasn't already been so.
-					if (light_enabled || !initialized_lighting)
+					if (params.mFullbright)
+					{
+						// Turn off lighting if it hasn't already been so.
+						if (light_enabled || !initialized_lighting)
+						{
+							initialized_lighting = TRUE;
+							if (use_shaders) 
+							{
+								target_shader = fullbright_shader;
+							}
+							else
+							{
+								gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
+							}
+							light_enabled = FALSE;
+						}
+					}
+					// Turn on lighting if it isn't already.
+					else if (!light_enabled || !initialized_lighting)
 					{
 						initialized_lighting = TRUE;
 						if (use_shaders) 
 						{
-							target_shader = fullbright_shader;
+							target_shader = simple_shader;
 						}
 						else
 						{
-							gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
+							gPipeline.enableLightsDynamic();
 						}
-						light_enabled = FALSE;
-					}
-				}
-				// Turn on lighting if it isn't already.
-				else if (!light_enabled || !initialized_lighting)
-				{
-					initialized_lighting = TRUE;
-					if (use_shaders) 
-					{
-						target_shader = simple_shader;
+						light_enabled = TRUE;
 					}
-					else
-					{
-						gPipeline.enableLightsDynamic();
-					}
-					light_enabled = TRUE;
-				}
 
-				// If we need shaders, and we're not ALREADY using the proper shader, then bind it
-				// (this way we won't rebind shaders unnecessarily).
-				if(use_shaders && (current_shader != target_shader))
-				{
-					llassert(target_shader != NULL);
-					if (deferred_render && current_shader != NULL)
-					{
-						gPipeline.unbindDeferredShader(*current_shader);
-						diffuse_channel = 0;
-					}
-					current_shader = target_shader;
-					if (deferred_render)
+					// If we need shaders, and we're not ALREADY using the proper shader, then bind it
+					// (this way we won't rebind shaders unnecessarily).
+					if(use_shaders && (current_shader != target_shader))
 					{
-						gPipeline.bindDeferredShader(*current_shader);
-						diffuse_channel = current_shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
-					}
-					else
-					{
-						current_shader->bind();
+						llassert(target_shader != NULL);
+						if (deferred_render && current_shader != NULL)
+						{
+							gPipeline.unbindDeferredShader(*current_shader);
+							diffuse_channel = 0;
+						}
+						current_shader = target_shader;
+						if (deferred_render)
+						{
+							gPipeline.bindDeferredShader(*current_shader);
+							diffuse_channel = current_shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
+						}
+						else
+						{
+							current_shader->bind();
+						}
 					}
-				}
-				else if (!use_shaders && current_shader != NULL)
-				{
-					if (deferred_render)
+					else if (!use_shaders && current_shader != NULL)
 					{
-						gPipeline.unbindDeferredShader(*current_shader);
-						diffuse_channel = 0;
+						if (deferred_render)
+						{
+							gPipeline.unbindDeferredShader(*current_shader);
+							diffuse_channel = 0;
+						}
+						LLGLSLShader::bindNoShader();
+						current_shader = NULL;
 					}
-					LLGLSLShader::bindNoShader();
-					current_shader = NULL;
-				}
-
-				if (params.mGroup)
-				{
-					params.mGroup->rebuildMesh();
-				}
 
-				
-				if (params.mTexture.notNull())
-				{
-					gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get());
-					if(params.mTexture.notNull())
+					if (params.mGroup)
 					{
-						params.mTexture->addTextureStats(params.mVSize);
+						params.mGroup->rebuildMesh();
 					}
-					if (params.mTextureMatrix)
+
+					
+					if (params.mTexture.notNull())
 					{
-						gGL.getTexUnit(0)->activate();
-						glMatrixMode(GL_TEXTURE);
-						glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
-						gPipeline.mTextureMatrixOps++;
+						gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get());
+						if(params.mTexture.notNull())
+						{
+							params.mTexture->addTextureStats(params.mVSize);
+						}
+						if (params.mTextureMatrix)
+						{
+							gGL.getTexUnit(0)->activate();
+							glMatrixMode(GL_TEXTURE);
+							glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
+							gPipeline.mTextureMatrixOps++;
+						}
 					}
 				}
 
 				params.mVertexBuffer->setBuffer(mask);
 				params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
 				gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
-
+			
 				if (params.mTextureMatrix && params.mTexture.notNull())
 				{
 					gGL.getTexUnit(0)->activate();
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index a4a8dc80b5b..8f3e775976c 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -837,7 +837,6 @@ void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32
 
 void LLBumpImageList::updateImages()
 {	
-	llpushcallstacks ;
 	for (bump_image_map_t::iterator iter = mBrightnessEntries.begin(); iter != mBrightnessEntries.end(); )
 	{
 		bump_image_map_t::iterator curiter = iter++;
@@ -864,7 +863,7 @@ void LLBumpImageList::updateImages()
 			}
 		}
 	}
-	llpushcallstacks ;
+	
 	for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); )
 	{
 		bump_image_map_t::iterator curiter = iter++;
@@ -891,7 +890,6 @@ void LLBumpImageList::updateImages()
 			}
 		}
 	}
-	llpushcallstacks ;
 }
 
 
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index e0e7fb46479..8d86070bdf9 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -2,25 +2,31 @@
  * @file llface.cpp
  * @brief LLFace class implementation
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -1358,7 +1364,7 @@ F32 LLFace::getTextureVirtualSize()
 	F32 cos_angle_to_view_dir;	
 	BOOL in_frustum = calcPixelArea(cos_angle_to_view_dir, radius);
 
-	if (mPixelArea < F_ALMOST_ZERO || !in_frustum)
+	if (mPixelArea < 0.0001f || !in_frustum)
 	{
 		setVirtualSize(0.f) ;
 		return 0.f;
@@ -1373,18 +1379,9 @@ F32 LLFace::getTextureVirtualSize()
 		texel_area = 1.f;
 	}
 
-	F32 face_area;
-	if (mVObjp->isSculpted() && texel_area > 1.f)
-	{
-		//sculpts can break assumptions about texel area
-		face_area = mPixelArea;
-	}
-	else
-	{
-		//apply texel area to face area to get accurate ratio
-		//face_area /= llclamp(texel_area, 1.f/64.f, 16.f);
-		face_area =  mPixelArea / llclamp(texel_area, 0.015625f, 128.f);
-	}
+	//apply texel area to face area to get accurate ratio
+	//face_area /= llclamp(texel_area, 1.f/64.f, 16.f);
+	F32 face_area = mPixelArea / llclamp(texel_area, 0.015625f, 128.f);
 
 	if(face_area > LLViewerTexture::sMaxSmallImageSize)
 	{
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 317b597a111..cf1e3bf1862 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2,25 +2,31 @@
  * @file llspatialpartition.cpp
  * @brief LLSpatialGroup class implementation and supporting functions
  *
- * $LicenseInfo:firstyear=2003&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2003&license=viewergpl$
+ * 
+ * Copyright (c) 2003-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -294,7 +300,6 @@ LLSpatialGroup::~LLSpatialGroup()
 	}
 
 	delete [] mOcclusionVerts;
-	mOcclusionVerts = NULL;
 
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	clearDrawMap();
@@ -1508,6 +1513,7 @@ void LLSpatialGroup::checkOcclusion()
 {
 	if (LLPipeline::sUseOcclusion > 1)
 	{
+		LLFastTimer t(FTM_OCCLUSION_READBACK);
 		LLSpatialGroup* parent = getParent();
 		if (parent && parent->isOcclusionState(LLSpatialGroup::OCCLUDED))
 		{	//if the parent has been marked as occluded, the child is implicitly occluded
@@ -1515,7 +1521,6 @@ void LLSpatialGroup::checkOcclusion()
 		}
 		else if (isOcclusionState(QUERY_PENDING))
 		{	//otherwise, if a query is pending, read it back
-			LLFastTimer t(FTM_OCCLUSION_READBACK);
 			GLuint res = 1;
 			if (!isOcclusionState(DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID])
 			{
@@ -3418,11 +3423,23 @@ LLCullResult::LLCullResult()
 void LLCullResult::clear()
 {
 	mVisibleGroupsSize = 0;
+	mVisibleGroupsEnd = mVisibleGroups.begin();
+
 	mAlphaGroupsSize = 0;
+	mAlphaGroupsEnd = mAlphaGroups.begin();
+
 	mOcclusionGroupsSize = 0;
+	mOcclusionGroupsEnd = mOcclusionGroups.begin();
+
 	mDrawableGroupsSize = 0;
+	mDrawableGroupsEnd = mDrawableGroups.begin();
+
 	mVisibleListSize = 0;
+	mVisibleListEnd = mVisibleList.begin();
+
 	mVisibleBridgeSize = 0;
+	mVisibleBridgeEnd = mVisibleBridge.begin();
+
 
 	for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
 	{
@@ -3431,6 +3448,7 @@ void LLCullResult::clear()
 			mRenderMap[i][j] = 0;
 		}
 		mRenderMapSize[i] = 0;
+		mRenderMapEnd[i] = mRenderMap[i].begin();
 	}
 }
 
@@ -3441,7 +3459,7 @@ LLCullResult::sg_list_t::iterator LLCullResult::beginVisibleGroups()
 
 LLCullResult::sg_list_t::iterator LLCullResult::endVisibleGroups()
 {
-	return mVisibleGroups.begin() + mVisibleGroupsSize;
+	return mVisibleGroupsEnd;
 }
 
 LLCullResult::sg_list_t::iterator LLCullResult::beginAlphaGroups()
@@ -3451,7 +3469,7 @@ LLCullResult::sg_list_t::iterator LLCullResult::beginAlphaGroups()
 
 LLCullResult::sg_list_t::iterator LLCullResult::endAlphaGroups()
 {
-	return mAlphaGroups.begin() + mAlphaGroupsSize;
+	return mAlphaGroupsEnd;
 }
 
 LLCullResult::sg_list_t::iterator LLCullResult::beginOcclusionGroups()
@@ -3461,7 +3479,7 @@ LLCullResult::sg_list_t::iterator LLCullResult::beginOcclusionGroups()
 
 LLCullResult::sg_list_t::iterator LLCullResult::endOcclusionGroups()
 {
-	return mOcclusionGroups.begin() + mOcclusionGroupsSize;
+	return mOcclusionGroupsEnd;
 }
 
 LLCullResult::sg_list_t::iterator LLCullResult::beginDrawableGroups()
@@ -3471,7 +3489,7 @@ LLCullResult::sg_list_t::iterator LLCullResult::beginDrawableGroups()
 
 LLCullResult::sg_list_t::iterator LLCullResult::endDrawableGroups()
 {
-	return mDrawableGroups.begin() + mDrawableGroupsSize;
+	return mDrawableGroupsEnd;
 }
 
 LLCullResult::drawable_list_t::iterator LLCullResult::beginVisibleList()
@@ -3481,7 +3499,7 @@ LLCullResult::drawable_list_t::iterator LLCullResult::beginVisibleList()
 
 LLCullResult::drawable_list_t::iterator LLCullResult::endVisibleList()
 {
-	return mVisibleList.begin() + mVisibleListSize;
+	return mVisibleListEnd;
 }
 
 LLCullResult::bridge_list_t::iterator LLCullResult::beginVisibleBridge()
@@ -3491,7 +3509,7 @@ LLCullResult::bridge_list_t::iterator LLCullResult::beginVisibleBridge()
 
 LLCullResult::bridge_list_t::iterator LLCullResult::endVisibleBridge()
 {
-	return mVisibleBridge.begin() + mVisibleBridgeSize;
+	return mVisibleBridgeEnd;
 }
 
 LLCullResult::drawinfo_list_t::iterator LLCullResult::beginRenderMap(U32 type)
@@ -3501,7 +3519,7 @@ LLCullResult::drawinfo_list_t::iterator LLCullResult::beginRenderMap(U32 type)
 
 LLCullResult::drawinfo_list_t::iterator LLCullResult::endRenderMap(U32 type)
 {
-	return mRenderMap[type].begin() + mRenderMapSize[type];
+	return mRenderMapEnd[type];
 }
 
 void LLCullResult::pushVisibleGroup(LLSpatialGroup* group)
@@ -3515,6 +3533,7 @@ void LLCullResult::pushVisibleGroup(LLSpatialGroup* group)
 		mVisibleGroups.push_back(group);
 	}
 	++mVisibleGroupsSize;
+	mVisibleGroupsEnd = mVisibleGroups.begin()+mVisibleGroupsSize;
 }
 
 void LLCullResult::pushAlphaGroup(LLSpatialGroup* group)
@@ -3528,6 +3547,7 @@ void LLCullResult::pushAlphaGroup(LLSpatialGroup* group)
 		mAlphaGroups.push_back(group);
 	}
 	++mAlphaGroupsSize;
+	mAlphaGroupsEnd = mAlphaGroups.begin()+mAlphaGroupsSize;
 }
 
 void LLCullResult::pushOcclusionGroup(LLSpatialGroup* group)
@@ -3541,6 +3561,7 @@ void LLCullResult::pushOcclusionGroup(LLSpatialGroup* group)
 		mOcclusionGroups.push_back(group);
 	}
 	++mOcclusionGroupsSize;
+	mOcclusionGroupsEnd = mOcclusionGroups.begin()+mOcclusionGroupsSize;
 }
 
 void LLCullResult::pushDrawableGroup(LLSpatialGroup* group)
@@ -3554,6 +3575,7 @@ void LLCullResult::pushDrawableGroup(LLSpatialGroup* group)
 		mDrawableGroups.push_back(group);
 	}
 	++mDrawableGroupsSize;
+	mDrawableGroupsEnd = mDrawableGroups.begin()+mDrawableGroupsSize;
 }
 
 void LLCullResult::pushDrawable(LLDrawable* drawable)
@@ -3567,6 +3589,7 @@ void LLCullResult::pushDrawable(LLDrawable* drawable)
 		mVisibleList.push_back(drawable);
 	}
 	++mVisibleListSize;
+	mVisibleListEnd = mVisibleList.begin()+mVisibleListSize;
 }
 
 void LLCullResult::pushBridge(LLSpatialBridge* bridge)
@@ -3580,6 +3603,7 @@ void LLCullResult::pushBridge(LLSpatialBridge* bridge)
 		mVisibleBridge.push_back(bridge);
 	}
 	++mVisibleBridgeSize;
+	mVisibleBridgeEnd = mVisibleBridge.begin()+mVisibleBridgeSize;
 }
 
 void LLCullResult::pushDrawInfo(U32 type, LLDrawInfo* draw_info)
@@ -3593,6 +3617,7 @@ void LLCullResult::pushDrawInfo(U32 type, LLDrawInfo* draw_info)
 		mRenderMap[type].push_back(draw_info);
 	}
 	++mRenderMapSize[type];
+	mRenderMapEnd[type] = mRenderMap[type].begin() + mRenderMapSize[type];
 }
 
 
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index cc634b784c7..de3745a1a3d 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -2,25 +2,31 @@
  * @file llspatialpartition.h
  * @brief LLSpatialGroup header file including definitions for supporting functions
  *
- * $LicenseInfo:firstyear=2003&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2003&license=viewergpl$
+ * 
+ * Copyright (c) 2003-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -158,6 +164,8 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	static BOOL sNoDelete; //deletion of spatial groups and draw info not allowed if TRUE
 
 	typedef std::vector<LLPointer<LLSpatialGroup> > sg_vector_t;
+	typedef std::set<LLPointer<LLSpatialGroup> > sg_set_t;
+	typedef std::list<LLPointer<LLSpatialGroup> > sg_list_t;
 	typedef std::vector<LLPointer<LLSpatialBridge> > bridge_list_t;
 	typedef std::vector<LLPointer<LLDrawInfo> > drawmap_elem_t; 
 	typedef std::map<U32, drawmap_elem_t > draw_map_t;	
@@ -526,12 +534,19 @@ class LLCullResult
 	U32					mRenderMapSize[LLRenderPass::NUM_RENDER_TYPES];
 
 	sg_list_t			mVisibleGroups;
+	sg_list_t::iterator mVisibleGroupsEnd;
 	sg_list_t			mAlphaGroups;
+	sg_list_t::iterator mAlphaGroupsEnd;
 	sg_list_t			mOcclusionGroups;
+	sg_list_t::iterator	mOcclusionGroupsEnd;
 	sg_list_t			mDrawableGroups;
+	sg_list_t::iterator mDrawableGroupsEnd;
 	drawable_list_t		mVisibleList;
+	drawable_list_t::iterator mVisibleListEnd;
 	bridge_list_t		mVisibleBridge;
+	bridge_list_t::iterator mVisibleBridgeEnd;
 	drawinfo_list_t		mRenderMap[LLRenderPass::NUM_RENDER_TYPES];
+	drawinfo_list_t::iterator mRenderMapEnd[LLRenderPass::NUM_RENDER_TYPES];
 };
 
 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 6f037177fab..51a1ae901e9 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -576,6 +576,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("MuteAmbient")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
 	gSavedSettings.getControl("MuteUI")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
 	gSavedSettings.getControl("RenderVBOEnable")->getSignal()->connect(boost::bind(&handleRenderUseVBOChanged, _2));
+	gSavedSettings.getControl("RenderUseStreamVBO")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("WLSkyDetail")->getSignal()->connect(boost::bind(&handleWLSkyDetailChanged, _2));
 	gSavedSettings.getControl("RenderLightingDetail")->getSignal()->connect(boost::bind(&handleRenderLightingDetailChanged, _2));
 	gSavedSettings.getControl("NumpadControl")->getSignal()->connect(boost::bind(&handleNumpadControlChanged, _2));
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 8a774613691..073d7c2b91c 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3304,7 +3304,6 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
-	llpushcallstacks ;
 	if (group->changeLOD())
 	{
 		group->mLastUpdateDistance = group->mDistance;
@@ -3533,9 +3532,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 }
 
 static LLFastTimer::DeclareTimer FTM_VOLUME_GEOM("Volume Geometry");
+static LLFastTimer::DeclareTimer FTM_VOLUME_GEOM_PARTIAL("Terse Rebuild");
+
 void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 {
-	llpushcallstacks ;
 	llassert(group);
 	if (group && group->isState(LLSpatialGroup::MESH_DIRTY) && !group->isState(LLSpatialGroup::GEOM_DIRTY))
 	{
@@ -3546,6 +3546,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 		
 		for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
 		{
+			LLFastTimer t(FTM_VOLUME_GEOM_PARTIAL);
 			LLDrawable* drawablep = *drawable_iter;
 
 			if (drawablep->isDead() || drawablep->isState(LLDrawable::FORCE_INVISIBLE) )
@@ -3627,7 +3628,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 
 void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort)
 {
-	llpushcallstacks ;
 	//calculate maximum number of vertices to store in a single buffer
 	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcStride(group->mSpatialPartition->mVertexDataMask);
 	max_vertices = llmin(max_vertices, (U32) 65535);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 3d700abd014..1ae8bc5481c 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -361,6 +361,7 @@ void LLPipeline::init()
 	sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
 	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
+	LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");
 	sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights");
 	sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles");
 
@@ -1725,8 +1726,12 @@ void LLPipeline::markOccluder(LLSpatialGroup* group)
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_DO_OCCLUSION("Do Occlusion");
+
 void LLPipeline::doOcclusion(LLCamera& camera)
 {
+	LLFastTimer t(FTM_DO_OCCLUSION);
+
 	LLVertexBuffer::unbind();
 
 	if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION))
@@ -1799,7 +1804,6 @@ void LLPipeline::rebuildPriorityGroups()
 		
 void LLPipeline::rebuildGroups()
 {
-	llpushcallstacks ;
 	// Iterate through some drawables on the non-priority build queue
 	S32 size = (S32) mGroupQ2.size();
 	S32 min_count = llclamp((S32) ((F32) (size * size)/4096*0.25f), 1, size);
@@ -1944,9 +1948,13 @@ void LLPipeline::updateGeom(F32 max_dtime)
 	updateMovedList(mMovedBridge);
 }
 
+static LLFastTimer::DeclareTimer FTM_MARK_VISIBLE("Mark Visible");
+
 void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE);
+	LLFastTimer t(FTM_MARK_VISIBLE);
+
 	if(!drawablep || drawablep->isDead())
 	{
 		return;
@@ -4630,8 +4638,12 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 	mLightMask = 0;
 }
 
+static LLFastTimer::DeclareTimer FTM_ENABLE_LIGHTS("Enable Lights");
+
 void LLPipeline::enableLights(U32 mask)
 {
+	LLFastTimer ftm(FTM_ENABLE_LIGHTS);
+
 	assertInitialized();
 
 	if (mLightingDetail == 0)
@@ -4737,16 +4749,16 @@ void LLPipeline::enableLightsFullbright(const LLColor4& color)
 	enableLights(mask);
 
 	glLightModelfv(GL_LIGHT_MODEL_AMBIENT,color.mV);
-	if (mLightingDetail >= 2)
+	/*if (mLightingDetail >= 2)
 	{
 		glColor4f(0.f, 0.f, 0.f, 1.f); // no local lighting by default
-	}
+	}*/
 }
 
 void LLPipeline::disableLights()
 {
 	enableLights(0); // no lighting (full bright)
-	glColor4f(1.f, 1.f, 1.f, 1.f); // lighting color = white by default
+	//glColor4f(1.f, 1.f, 1.f, 1.f); // lighting color = white by default
 }
 
 //============================================================================
@@ -5349,6 +5361,7 @@ void LLPipeline::resetVertexBuffers()
 {
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
 	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
+	LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");
 
 	for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
 			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
-- 
GitLab


From 643bbdae728e01a0855accf3b5e614026dc56f9f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 10:48:25 -0600
Subject: [PATCH 159/683] Tweak LLDynamicArrayIndexed to not abuse its
 std::vector.

---
 indra/llcommon/lldarray.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llcommon/lldarray.h b/indra/llcommon/lldarray.h
index 0e56a11d530..af647c7e7af 100644
--- a/indra/llcommon/lldarray.h
+++ b/indra/llcommon/lldarray.h
@@ -202,7 +202,7 @@ class LLDynamicArrayIndexed
 		{
 			U32 n = mVector.size();
 			mIndexMap[k] = n;
-			mVector.resize(n+1);
+			mVector.push_back(Type());
 			llassert(mVector.size() == mIndexMap.size());
 			return mVector[n];
 		}
-- 
GitLab


From 16ce2652e4c88e2150dc6fcf48f02a6718dc6787 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 10:48:25 -0600
Subject: [PATCH 160/683] Tweak LLDynamicArrayIndexed to not abuse its
 std::vector.

---
 indra/llcommon/lldarray.h | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/indra/llcommon/lldarray.h b/indra/llcommon/lldarray.h
index 95c57de1895..af647c7e7af 100644
--- a/indra/llcommon/lldarray.h
+++ b/indra/llcommon/lldarray.h
@@ -2,25 +2,31 @@
  * @file lldarray.h
  * @brief Wrapped std::vector for backward compatibility.
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -196,7 +202,7 @@ class LLDynamicArrayIndexed
 		{
 			U32 n = mVector.size();
 			mIndexMap[k] = n;
-			mVector.resize(n+1);
+			mVector.push_back(Type());
 			llassert(mVector.size() == mIndexMap.size());
 			return mVector[n];
 		}
-- 
GitLab


From 3ea01fb66e75ec6da1cee994da37ef461af66a48 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 10:49:05 -0600
Subject: [PATCH 161/683] Remove some fast timers that were being futzy.

---
 indra/llrender/llglslshader.cpp |  6 ------
 indra/newview/lldrawable.cpp    |  7 -------
 indra/newview/pipeline.cpp      | 13 ++-----------
 3 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 2b3179116d7..ca92cb6580f 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -343,11 +343,8 @@ BOOL LLGLSLShader::link(BOOL suppress_errors)
 	return LLShaderMgr::instance()->linkProgramObject(mProgramObject, suppress_errors);
 }
 
-static LLFastTimer::DeclareTimer FTM_BIND_SHADER("Bind Shader");
-
 void LLGLSLShader::bind()
 {
-	LLFastTimer ftm(FTM_BIND_SHADER);
 	if (gGLManager.mHasShaderObjects)
 	{
 		glUseProgramObjectARB(mProgramObject);
@@ -360,11 +357,8 @@ void LLGLSLShader::bind()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_UNBIND_SHADER("Unbind Shader");
-
 void LLGLSLShader::unbind()
 {
-	LLFastTimer ftm(FTM_UNBIND_SHADER);
 	if (gGLManager.mHasShaderObjects)
 	{
 		stop_glerror();
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index fd9cb18a42a..390e950d758 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -683,11 +683,8 @@ BOOL LLDrawable::updateMoveDamped()
 	return done_moving;
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_DISTANCE("Update Distance");
-
 void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 {
-	LLFastTimer t(FTM_UPDATE_DISTANCE);
 	if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
 		llerrs << "WTF?" << llendl;
@@ -1320,12 +1317,8 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_BRIDGE_DISTANCE_UPDATE("Bridge Distance");
-
 void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 {
-	LLFastTimer t(FTM_BRIDGE_DISTANCE_UPDATE);
-
 	if (mDrawable == NULL)
 	{
 		markDead();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index eb3ad955861..e65c8b9af8b 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -511,6 +511,7 @@ void LLPipeline::destroyGL()
 }
 
 static LLFastTimer::DeclareTimer FTM_RESIZE_SCREEN_TEXTURE("Resize Screen Texture");
+
 void LLPipeline::resizeScreenTexture()
 {
 	LLFastTimer ft(FTM_RESIZE_SCREEN_TEXTURE);
@@ -1740,12 +1741,8 @@ void LLPipeline::markOccluder(LLSpatialGroup* group)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_DO_OCCLUSION("Do Occlusion");
-
 void LLPipeline::doOcclusion(LLCamera& camera)
 {
-	LLFastTimer t(FTM_DO_OCCLUSION);
-
 	LLVertexBuffer::unbind();
 
 	if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION))
@@ -1965,12 +1962,9 @@ void LLPipeline::updateGeom(F32 max_dtime)
 	updateMovedList(mMovedBridge);
 }
 
-static LLFastTimer::DeclareTimer FTM_MARK_VISIBLE("Mark Visible");
-
 void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE);
-	LLFastTimer t(FTM_MARK_VISIBLE);
 
 	if(!drawablep || drawablep->isDead())
 	{
@@ -4712,12 +4706,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 	mLightMask = 0;
 }
 
-static LLFastTimer::DeclareTimer FTM_ENABLE_LIGHTS("Enable Lights");
-
 void LLPipeline::enableLights(U32 mask)
 {
-	LLFastTimer ftm(FTM_ENABLE_LIGHTS);
-
 	assertInitialized();
 
 	if (mLightingDetail == 0)
@@ -5573,6 +5563,7 @@ void LLPipeline::bindScreenToTexture()
 }
 
 static LLFastTimer::DeclareTimer FTM_RENDER_BLOOM("Bloom");
+
 void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 {
 	LLMemType mt_ru(LLMemType::MTYPE_PIPELINE_RENDER_BLOOM);
-- 
GitLab


From 60dde53d72e72b2f66390e93d9d44ca589b9b465 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 10:49:05 -0600
Subject: [PATCH 162/683] Remove some fast timers that were being futzy.

---
 indra/llrender/llglslshader.cpp |  6 ------
 indra/newview/lldrawable.cpp    |  7 -------
 indra/newview/pipeline.cpp      | 13 ++-----------
 3 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 2b3179116d7..ca92cb6580f 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -343,11 +343,8 @@ BOOL LLGLSLShader::link(BOOL suppress_errors)
 	return LLShaderMgr::instance()->linkProgramObject(mProgramObject, suppress_errors);
 }
 
-static LLFastTimer::DeclareTimer FTM_BIND_SHADER("Bind Shader");
-
 void LLGLSLShader::bind()
 {
-	LLFastTimer ftm(FTM_BIND_SHADER);
 	if (gGLManager.mHasShaderObjects)
 	{
 		glUseProgramObjectARB(mProgramObject);
@@ -360,11 +357,8 @@ void LLGLSLShader::bind()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_UNBIND_SHADER("Unbind Shader");
-
 void LLGLSLShader::unbind()
 {
-	LLFastTimer ftm(FTM_UNBIND_SHADER);
 	if (gGLManager.mHasShaderObjects)
 	{
 		stop_glerror();
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 013577261ce..38eda5bd2e0 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -673,11 +673,8 @@ BOOL LLDrawable::updateMoveDamped()
 	return done_moving;
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_DISTANCE("Update Distance");
-
 void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 {
-	LLFastTimer t(FTM_UPDATE_DISTANCE);
 	if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
 		llerrs << "WTF?" << llendl;
@@ -1310,12 +1307,8 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_BRIDGE_DISTANCE_UPDATE("Bridge Distance");
-
 void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 {
-	LLFastTimer t(FTM_BRIDGE_DISTANCE_UPDATE);
-
 	if (mDrawable == NULL)
 	{
 		markDead();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1ae8bc5481c..2f4314f7e53 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -510,6 +510,7 @@ void LLPipeline::destroyGL()
 }
 
 static LLFastTimer::DeclareTimer FTM_RESIZE_SCREEN_TEXTURE("Resize Screen Texture");
+
 void LLPipeline::resizeScreenTexture()
 {
 	LLFastTimer ft(FTM_RESIZE_SCREEN_TEXTURE);
@@ -1726,12 +1727,8 @@ void LLPipeline::markOccluder(LLSpatialGroup* group)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_DO_OCCLUSION("Do Occlusion");
-
 void LLPipeline::doOcclusion(LLCamera& camera)
 {
-	LLFastTimer t(FTM_DO_OCCLUSION);
-
 	LLVertexBuffer::unbind();
 
 	if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION))
@@ -1948,12 +1945,9 @@ void LLPipeline::updateGeom(F32 max_dtime)
 	updateMovedList(mMovedBridge);
 }
 
-static LLFastTimer::DeclareTimer FTM_MARK_VISIBLE("Mark Visible");
-
 void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE);
-	LLFastTimer t(FTM_MARK_VISIBLE);
 
 	if(!drawablep || drawablep->isDead())
 	{
@@ -4638,12 +4632,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 	mLightMask = 0;
 }
 
-static LLFastTimer::DeclareTimer FTM_ENABLE_LIGHTS("Enable Lights");
-
 void LLPipeline::enableLights(U32 mask)
 {
-	LLFastTimer ftm(FTM_ENABLE_LIGHTS);
-
 	assertInitialized();
 
 	if (mLightingDetail == 0)
@@ -5497,6 +5487,7 @@ void LLPipeline::bindScreenToTexture()
 }
 
 static LLFastTimer::DeclareTimer FTM_RENDER_BLOOM("Bloom");
+
 void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 {
 	LLMemType mt_ru(LLMemType::MTYPE_PIPELINE_RENDER_BLOOM);
-- 
GitLab


From 372212ae764a32bf667d3cb4cf5b99e6c6147b0f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 10:49:52 -0600
Subject: [PATCH 163/683] Fix for sun specular highlights showing up in shadow
 when diffuse ambiance greater than 0.

---
 .../app_settings/shaders/class2/deferred/softenLightF.glsl      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 531f7376a37..249ac7ef9b9 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -275,7 +275,7 @@ void main()
 	{
 		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
 	}
 	
 	col = atmosLighting(col);
-- 
GitLab


From f2e6f26e209ca84f88fa04fba8b316e3aafcd127 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 10:49:52 -0600
Subject: [PATCH 164/683] Fix for sun specular highlights showing up in shadow
 when diffuse ambiance greater than 0.

---
 .../app_settings/shaders/class2/deferred/softenLightF.glsl      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 531f7376a37..249ac7ef9b9 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -275,7 +275,7 @@ void main()
 	{
 		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
 	}
 	
 	col = atmosLighting(col);
-- 
GitLab


From 988520f3a7d5d5e817326945d8b9c3808c4eb5f7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 10:50:29 -0600
Subject: [PATCH 165/683] Fix for avatar eyes not showing up when deferred
 rendering enabled.

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

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 546b60f2867..012e41383fb 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -157,6 +157,8 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
 {
 	LLFastTimer t(FTM_RENDER_CHARACTERS);
 	
+	sSkipTransparent = TRUE;
+
 	if (LLPipeline::sImpostorRender)
 	{
 		beginDeferredSkinned();
@@ -181,6 +183,8 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass)
 {
 	LLFastTimer t(FTM_RENDER_CHARACTERS);
 
+	sSkipTransparent = FALSE;
+
 	if (LLPipeline::sImpostorRender)
 	{
 		endDeferredSkinned();
@@ -564,7 +568,6 @@ void LLDrawPoolAvatar::endSkinned()
 
 void LLDrawPoolAvatar::beginDeferredSkinned()
 {
-	sSkipTransparent = TRUE;
 	sShaderLevel = mVertexShaderLevel;
 	sVertexProgram = &gDeferredAvatarProgram;
 
@@ -579,7 +582,6 @@ void LLDrawPoolAvatar::beginDeferredSkinned()
 
 void LLDrawPoolAvatar::endDeferredSkinned()
 {
-	sSkipTransparent = FALSE;
 	// if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done
 	sRenderingSkinned = FALSE;
 	disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
-- 
GitLab


From aa07c778192ffe59234c09bfa366c831db20337f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 10:50:29 -0600
Subject: [PATCH 166/683] Fix for avatar eyes not showing up when deferred
 rendering enabled.

---
 indra/newview/lldrawpoolavatar.cpp | 50 +++++++++++++++++-------------
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 600ffa492ea..012e41383fb 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -2,25 +2,31 @@
  * @file lldrawpoolavatar.cpp
  * @brief LLDrawPoolAvatar class implementation
  *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -151,6 +157,8 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
 {
 	LLFastTimer t(FTM_RENDER_CHARACTERS);
 	
+	sSkipTransparent = TRUE;
+
 	if (LLPipeline::sImpostorRender)
 	{
 		beginDeferredSkinned();
@@ -175,6 +183,8 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass)
 {
 	LLFastTimer t(FTM_RENDER_CHARACTERS);
 
+	sSkipTransparent = FALSE;
+
 	if (LLPipeline::sImpostorRender)
 	{
 		endDeferredSkinned();
@@ -558,7 +568,6 @@ void LLDrawPoolAvatar::endSkinned()
 
 void LLDrawPoolAvatar::beginDeferredSkinned()
 {
-	sSkipTransparent = TRUE;
 	sShaderLevel = mVertexShaderLevel;
 	sVertexProgram = &gDeferredAvatarProgram;
 
@@ -573,7 +582,6 @@ void LLDrawPoolAvatar::beginDeferredSkinned()
 
 void LLDrawPoolAvatar::endDeferredSkinned()
 {
-	sSkipTransparent = FALSE;
 	// if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done
 	sRenderingSkinned = FALSE;
 	disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
@@ -628,7 +636,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 
 	if (!single_avatar && !avatarp->isFullyLoaded() )
 	{
-		if (pass==0 && (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) || LLViewerPartSim::getMaxPartCount() <= 0))
+		if (pass==1 && (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) || LLViewerPartSim::getMaxPartCount() <= 0))
 		{
 			// debug code to draw a sphere in place of avatar
 			gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep);
@@ -640,10 +648,8 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 			gGL.translatef((F32)(pos.mV[VX]),	 
 						   (F32)(pos.mV[VY]),	 
 							(F32)(pos.mV[VZ]));	 
-			 gGL.scalef(0.15f, 0.15f, 0.3f);
-
-			 gSphere.renderGGL();
-				 
+			 gGL.scalef(0.15f, 0.15f, 0.3f);	 
+			 gSphere.render();	 
 			 gGL.popMatrix();
 			 gGL.setColorMask(true, false);
 		}
-- 
GitLab


From 16a30929f9b12359658d0f462b6bac25ed9a36fb Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 13:17:31 -0600
Subject: [PATCH 167/683] Inventory now updates appropriately when using model
 uploader.

---
 indra/newview/llassetuploadresponders.cpp | 16 +---------------
 indra/newview/llviewermenufile.h          | 11 +++++++++++
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index a0be6efdc25..9a66bae2473 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -73,7 +73,7 @@ static const S32 FILE_COUNT_DISPLAY_THRESHOLD = 5;
 
 void dialog_refresh_all();
 
-static void on_new_single_inventory_upload_complete(
+void on_new_single_inventory_upload_complete(
 	LLAssetType::EType asset_type,
 	LLInventoryType::EType inventory_type,
 	const std::string inventory_type_string,
@@ -94,11 +94,6 @@ static void on_new_single_inventory_upload_complete(
 		LLNotificationsUtil::add("UploadPayment", args);
 	}
 
-	// Actually add the upload to viewer inventory
-	llinfos << "Adding " << server_response["new_inventory_item"].asUUID()
-			<< " " << server_response["new_asset"].asUUID()
-			<< " to inventory." << llendl;
-
 	if( item_folder_id.notNull() )
 	{
 		U32 everyone_perms = PERM_NONE;
@@ -165,15 +160,6 @@ static void on_new_single_inventory_upload_complete(
 				server_response["new_inventory_item"].asUUID(),
 				TAKE_FOCUS_NO);
 
-			if(
-				(LLAssetType::AT_TEXTURE == asset_type ||
-				 LLAssetType::AT_SOUND == asset_type) &&
-				(LLFilePicker::instance().getFileCount() <=
-				 FILE_COUNT_DISPLAY_THRESHOLD) )
-			{
-				panel->openSelected();
-			}
-
 			// restore keyboard focus
 			gFocusMgr.setKeyboardFocus(focus);
 		}
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 7ffa5d5e574..e700b0565ee 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -110,4 +110,15 @@ LLSD generate_new_resource_upload_capability_body(
 	U32 group_perms,
 	U32 everyone_perms);
 
+void on_new_single_inventory_upload_complete(
+	LLAssetType::EType asset_type,
+	LLInventoryType::EType inventory_type,
+	const std::string inventory_type_string,
+	const LLUUID& item_folder_id,
+	const std::string& item_name,
+	const std::string& item_description,
+	const LLSD& server_response,
+	S32 upload_price);
+
+
 #endif
-- 
GitLab


From b43441d9024db6e2ff46e53aace14f1fb6c1bbe6 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 14:33:14 -0600
Subject: [PATCH 168/683] COMMENTS!

---
 indra/newview/llspatialpartition.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index ef6b915e5cd..88fab01ea4c 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -347,11 +347,11 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	F32 mBuilt;
 	OctreeNode* mOctreeNode;
 	LLSpatialPartition* mSpatialPartition;
-	LLVector3 mBounds[2];
-	LLVector3 mExtents[2];
+	LLVector3 mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LLVector3 mExtents[2]; // extents (min, max) of this node and all its children
 	
-	LLVector3 mObjectExtents[2];
-	LLVector3 mObjectBounds[2];
+	LLVector3 mObjectExtents[2]; // extents (min, max) of objects in this node
+	LLVector3 mObjectBounds[2]; // bounding box (center, size) of objects in this node
 
 	LLPointer<LLVertexBuffer> mVertexBuffer;
 	F32*					mOcclusionVerts;
-- 
GitLab


From c6a2960a2d721cfbeaf41c48e80a8d1359bd6b7c Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 5 Mar 2010 14:33:14 -0600
Subject: [PATCH 169/683] COMMENTS!

---
 indra/newview/llspatialpartition.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index de3745a1a3d..929f2adc1aa 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -346,11 +346,11 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	F32 mBuilt;
 	OctreeNode* mOctreeNode;
 	LLSpatialPartition* mSpatialPartition;
-	LLVector3 mBounds[2];
-	LLVector3 mExtents[2];
+	LLVector3 mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LLVector3 mExtents[2]; // extents (min, max) of this node and all its children
 	
-	LLVector3 mObjectExtents[2];
-	LLVector3 mObjectBounds[2];
+	LLVector3 mObjectExtents[2]; // extents (min, max) of objects in this node
+	LLVector3 mObjectBounds[2]; // bounding box (center, size) of objects in this node
 
 	LLPointer<LLVertexBuffer> mVertexBuffer;
 	F32*					mOcclusionVerts;
-- 
GitLab


From 1889d02569a58d08b6c452e609819a1961bf64e8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 6 Mar 2010 00:42:39 -0600
Subject: [PATCH 170/683] Better bounding boxes for meshes.

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

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 39db6196a30..1d3d943b06c 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1329,7 +1329,7 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
 
 	BOOL rebuild = mDrawable->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION);
 
-	for (S32 i = 0; i < getVolume()->getNumFaces(); i++)
+	for (S32 i = 0; i < getVolume()->getNumVolumeFaces(); i++)
 	{
 		LLFace *face = mDrawable->getFace(i);
 		if (!face)
-- 
GitLab


From 665567e2f97f8ec4de2810fb63d6b845e67833e2 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 09:40:11 +0000
Subject: [PATCH 171/683] Remove the class2/class3 water shaders, which aren't
 materially different from class1 except for some minor const tweaks (I've
 migrated class3's tweaks into class1 on the assumption that this was what
 davep sees all the time)

---
 .../app_settings/shaders/class1/deferred/waterF.glsl        | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index d21575119dd..5cb8bbba0f7 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -131,11 +131,11 @@ void main()
 	//color.rgb = scaleSoftClip(color.rgb);
 	//color.a = spec * sunAngle2;
 
-	//wavef.z = -0.25f;
+	//wavef.z *= 0.1f;
 	wavef = normalize(wavef);
 	wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
-	gl_FragData[0] = vec4(color.rgb, 0.75);
-	gl_FragData[1] = vec4(1,1,1, 0.8);
+	gl_FragData[0] = vec4(color.rgb, 0.5);
+	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95);
 	gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0);
 }
-- 
GitLab


From 181b0a4edec814ef53ee243371c9935cf72704e8 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 09:40:11 +0000
Subject: [PATCH 172/683] Remove the class2/class3 water shaders, which aren't
 materially different from class1 except for some minor const tweaks (I've
 migrated class3's tweaks into class1 on the assumption that this was what
 davep sees all the time)

---
 .../app_settings/shaders/class1/deferred/waterF.glsl        | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index d21575119dd..5cb8bbba0f7 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -131,11 +131,11 @@ void main()
 	//color.rgb = scaleSoftClip(color.rgb);
 	//color.a = spec * sunAngle2;
 
-	//wavef.z = -0.25f;
+	//wavef.z *= 0.1f;
 	wavef = normalize(wavef);
 	wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
-	gl_FragData[0] = vec4(color.rgb, 0.75);
-	gl_FragData[1] = vec4(1,1,1, 0.8);
+	gl_FragData[0] = vec4(color.rgb, 0.5);
+	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95);
 	gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0);
 }
-- 
GitLab


From bd884d89e9d278454f0c9f27d5083a9d6500d582 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 09:41:47 +0000
Subject: [PATCH 173/683] Remove an extraneous normalize() from the water
 fragment shader - the last thing we did to this vector was normalize it
 anyway.

---
 indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 5cb8bbba0f7..411c4bc1c37 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -132,7 +132,7 @@ void main()
 	//color.a = spec * sunAngle2;
 
 	//wavef.z *= 0.1f;
-	wavef = normalize(wavef);
+	//wavef = normalize(wavef);
 	wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
 	gl_FragData[0] = vec4(color.rgb, 0.5);
-- 
GitLab


From a6c5980978c95ba8a4e4dd8822c644e9fe8a2e69 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 09:41:47 +0000
Subject: [PATCH 174/683] Remove an extraneous normalize() from the water
 fragment shader - the last thing we did to this vector was normalize it
 anyway.

---
 indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 5cb8bbba0f7..411c4bc1c37 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -132,7 +132,7 @@ void main()
 	//color.a = spec * sunAngle2;
 
 	//wavef.z *= 0.1f;
-	wavef = normalize(wavef);
+	//wavef = normalize(wavef);
 	wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
 	gl_FragData[0] = vec4(color.rgb, 0.5);
-- 
GitLab


From ead28366c6f33ca2794043ffbced28a950e6e334 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 10:09:06 +0000
Subject: [PATCH 175/683] trivial comment typo fix.

---
 indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 411c4bc1c37..1fc58113826 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -115,7 +115,7 @@ void main()
 	vec4 fb = texture2D(screenTex, distort2);
 	
 	//mix with reflection
-	// Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug
+	// Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug
 	color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999);
 	
 	float shadow = 1.0;
-- 
GitLab


From 12d6214f0fbeb02ef3c8469020147723be339615 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 10:09:06 +0000
Subject: [PATCH 176/683] trivial comment typo fix.

---
 indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 411c4bc1c37..1fc58113826 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -115,7 +115,7 @@ void main()
 	vec4 fb = texture2D(screenTex, distort2);
 	
 	//mix with reflection
-	// Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug
+	// Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug
 	color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999);
 	
 	float shadow = 1.0;
-- 
GitLab


From 88a1b6676ed825345f0615050b9870b325fb6ef1 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 10:15:07 +0000
Subject: [PATCH 177/683] Some extra comments to help me get things straight.

---
 .../app_settings/shaders/class1/deferred/waterF.glsl        | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 1fc58113826..55c893d73bb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -135,7 +135,7 @@ void main()
 	//wavef = normalize(wavef);
 	wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
-	gl_FragData[0] = vec4(color.rgb, 0.5);
-	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95);
-	gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0);
+	gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse
+	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
+	gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0); // normal
 }
-- 
GitLab


From 23f03d9f6cc64d960d8eb05c8fb2cb10f6a4ec6b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 10:15:07 +0000
Subject: [PATCH 178/683] Some extra comments to help me get things straight.

---
 .../app_settings/shaders/class1/deferred/waterF.glsl        | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 1fc58113826..55c893d73bb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -135,7 +135,7 @@ void main()
 	//wavef = normalize(wavef);
 	wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
-	gl_FragData[0] = vec4(color.rgb, 0.5);
-	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95);
-	gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0);
+	gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse
+	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
+	gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0); // normal
 }
-- 
GitLab


From 64797175a14785ac740ae27e647a5b0241700577 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 11:34:31 +0000
Subject: [PATCH 179/683] Add a touch of fakey ripple to shadows on the surface
 of water, as if the water has depth.  Using 4th component of the normal map
 to encode a position displacement (along the normal) in the class2 shadow
 lookup.

---
 .../app_settings/shaders/class1/deferred/waterF.glsl      | 4 ++--
 .../app_settings/shaders/class2/deferred/sunLightF.glsl   | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 55c893d73bb..ceb7e0fb56e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -133,9 +133,9 @@ void main()
 
 	//wavef.z *= 0.1f;
 	//wavef = normalize(wavef);
-	wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
+	vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
 	gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse
 	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
-	gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0); // normal
+	gl_FragData[2] = vec4(screenspacewavef*0.5+0.5, screenspacewavef.z*0.5); // normal, displace
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 74a948f584e..50502dbdadc 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -159,7 +159,9 @@ void main()
 	
 	vec4 pos = getPosition(pos_screen);
 	
-    vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+	vec4 nmap4 = texture2DRect(normalMap, pos_screen);
+	float displace = nmap4.w;
+	vec3 norm = nmap4.xyz*2.0-1.0;
 	
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
 	{
@@ -168,9 +170,9 @@ void main()
 	}*/
 	
 	float shadow = 1.0;
-    float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
+	float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
 
-	vec4 spos = vec4(pos.xyz + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+	vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
 	
 	if (spos.z > -shadow_clip.w)
 	{	
-- 
GitLab


From 550922aa84634594c277bd51d2839256f5963ac7 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 11:34:31 +0000
Subject: [PATCH 180/683] Add a touch of fakey ripple to shadows on the surface
 of water, as if the water has depth.  Using 4th component of the normal map
 to encode a position displacement (along the normal) in the class2 shadow
 lookup.

---
 .../app_settings/shaders/class1/deferred/waterF.glsl      | 4 ++--
 .../app_settings/shaders/class2/deferred/sunLightF.glsl   | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 55c893d73bb..ceb7e0fb56e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -133,9 +133,9 @@ void main()
 
 	//wavef.z *= 0.1f;
 	//wavef = normalize(wavef);
-	wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
+	vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
 	gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse
 	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
-	gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0); // normal
+	gl_FragData[2] = vec4(screenspacewavef*0.5+0.5, screenspacewavef.z*0.5); // normal, displace
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 74a948f584e..50502dbdadc 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -159,7 +159,9 @@ void main()
 	
 	vec4 pos = getPosition(pos_screen);
 	
-    vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+	vec4 nmap4 = texture2DRect(normalMap, pos_screen);
+	float displace = nmap4.w;
+	vec3 norm = nmap4.xyz*2.0-1.0;
 	
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
 	{
@@ -168,9 +170,9 @@ void main()
 	}*/
 	
 	float shadow = 1.0;
-    float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
+	float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
 
-	vec4 spos = vec4(pos.xyz + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+	vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
 	
 	if (spos.z > -shadow_clip.w)
 	{	
-- 
GitLab


From 80ab668f4494601b6968748e227208f5b95a63bf Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 18:31:32 +0000
Subject: [PATCH 181/683] Add support for glBlendFuncSeparate(). I want it to
 fix glow-through-alpha, but this checkin doesn't includes any of those
 changes.

---
 indra/llrender/llgl.cpp      | 28 +++++++++++++++++++++++-
 indra/llrender/llgl.h        |  1 +
 indra/llrender/llglheaders.h | 22 ++++++++++++++++++-
 indra/llrender/llrender.cpp  | 41 +++++++++++++++++++++++++++++++-----
 indra/llrender/llrender.h    | 10 +++++++--
 5 files changed, 93 insertions(+), 9 deletions(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index a3f7a946ecd..4c256f4b060 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -185,6 +185,9 @@ PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT =
 // GL_EXT_framebuffer_blit
 PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT = NULL;
 
+// GL_EXT_blend_func_separate
+PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT = NULL;
+
 // GL_ARB_draw_buffers
 PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB = NULL;
 
@@ -324,6 +327,7 @@ LLGLManager::LLGLManager() :
 	mHasCompressedTextures(FALSE),
 	mHasFramebufferObject(FALSE),
 	mHasFramebufferMultisample(FALSE),
+	mHasBlendFuncSeparate(FALSE),
 
 	mHasVertexBufferObject(FALSE),
 	mHasPBuffer(FALSE),
@@ -632,6 +636,12 @@ void LLGLManager::initExtensions()
 	mHasDrawBuffers = TRUE;
 #else
 	mHasDrawBuffers = FALSE;
+# endif
+# if GL_EXT_blend_func_separate
+	mHasBlendFuncSeparate = TRUE;
+#else
+#error XXXXXX
+	mHasBlendFuncSeparate = FALSE;
 # endif
 	mHasMipMapGeneration = FALSE;
 	mHasSeparateSpecularColor = FALSE;
@@ -659,6 +669,7 @@ void LLGLManager::initExtensions()
 		&& ExtensionExists("GL_EXT_packed_depth_stencil", gGLHExts.mSysExts);
 	mHasFramebufferMultisample = mHasFramebufferObject && ExtensionExists("GL_EXT_framebuffer_multisample", gGLHExts.mSysExts);
 	mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts);
+	mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts);
 	mHasTextureRectangle = ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts);
 #if !LL_DARWIN
 	mHasPointParameters = !mIsATI && ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts);
@@ -682,6 +693,7 @@ void LLGLManager::initExtensions()
 		mHasFramebufferObject = FALSE;
 		mHasFramebufferMultisample = FALSE;
 		mHasDrawBuffers = FALSE;
+		mHasBlendFuncSeparate = FALSE;
 		mHasMipMapGeneration = FALSE;
 		mHasSeparateSpecularColor = FALSE;
 		mHasAnisotropic = FALSE;
@@ -706,6 +718,7 @@ void LLGLManager::initExtensions()
 		mHasShaderObjects = FALSE;
 		mHasVertexShader = FALSE;
 		mHasFragmentShader = FALSE;
+		mHasBlendFuncSeparate = FALSE;
 		LL_WARNS("RenderInit") << "GL extension support forced to SIMPLE level via LL_GL_BASICEXT" << LL_ENDL;
 	}
 	if (getenv("LL_GL_BLACKLIST"))	/* Flawfinder: ignore */
@@ -734,7 +747,8 @@ void LLGLManager::initExtensions()
 		if (strchr(blacklist,'r')) mHasDrawBuffers = FALSE;//S
 		if (strchr(blacklist,'s')) mHasFramebufferMultisample = FALSE;
 		if (strchr(blacklist,'t')) mHasTextureRectangle = FALSE;
-
+		if (strchr(blacklist,'u')) mHasBlendFuncSeparate = FALSE;//S
+		
 	}
 #endif // LL_LINUX || LL_SOLARIS
 	
@@ -782,6 +796,14 @@ void LLGLManager::initExtensions()
 	{
 		LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_fragment_shader" << LL_ENDL;
 	}
+	if (!mHasBlendFuncSeparate)
+	{
+		LL_INFOS("RenderInit") << "Couldn't initialize GL_EXT_blend_func_separate" << LL_ENDL;
+	}
+	if (!mHasDrawBuffers)
+	{
+		LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_draw_buffers" << LL_ENDL;
+	}
 
 	// Disable certain things due to known bugs
 	if (mIsIntel && mHasMipMapGeneration)
@@ -852,6 +874,10 @@ void LLGLManager::initExtensions()
 	{
 		glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDrawBuffersARB");
 	}
+	if (mHasBlendFuncSeparate)
+	{
+		glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlendFuncSeparateEXT");
+	}
 #if (!LL_LINUX && !LL_SOLARIS) || LL_LINUX_NV_GL_HEADERS
 	// This is expected to be a static symbol on Linux GL implementations, except if we use the nvidia headers - bah
 	glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)GLH_EXT_GET_PROC_ADDRESS("glDrawRangeElements");
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 91421f3c954..0c2da7dd089 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -87,6 +87,7 @@ class LLGLManager
 	BOOL mHasCompressedTextures;
 	BOOL mHasFramebufferObject;
 	BOOL mHasFramebufferMultisample;
+	BOOL mHasBlendFuncSeparate;
 	
 	// ARB Extensions
 	BOOL mHasVertexBufferObject;
diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h
index f33ae7d8f02..f6d35bc7669 100644
--- a/indra/llrender/llglheaders.h
+++ b/indra/llrender/llglheaders.h
@@ -216,6 +216,9 @@ extern PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB;
 
 extern PFNGLCOLORTABLEEXTPROC glColorTableEXT;
 
+//GL_EXT_blend_func_separate
+extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
+
 //GL_EXT_framebuffer_object
 extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
 extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
@@ -249,7 +252,10 @@ extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
 # include "GL/glh_extensions.h"
 # undef __APPLE__
 
-#elif LL_LINUX 
+#elif LL_LINUX
+//----------------------------------------------------------------------------
+// LL_LINUX
+
 //----------------------------------------------------------------------------
 // Linux, MESA headers, but not necessarily assuming MESA runtime.
 // quotes so we get libraries/.../GL/ version
@@ -285,6 +291,7 @@ extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
 # define LL_LINUX_NV_GL_HEADERS 0
 #endif // LL_LINUX && defined(WINGDIAPI)
 
+
 #if LL_LINUX_NV_GL_HEADERS
 // Missing functions when using nvidia headers:
 extern PFNGLACTIVETEXTUREARBPROC	glActiveTextureARB;
@@ -445,6 +452,9 @@ extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
 extern PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB;
 extern PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB;
 
+//GL_EXT_blend_func_separate
+extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
+
 //GL_EXT_framebuffer_object
 extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
 extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
@@ -473,7 +483,10 @@ extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
 //GL_ARB_draw_buffers
 extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB;
 
+
 #elif LL_WINDOWS
+//----------------------------------------------------------------------------
+// LL_WINDOWS
 
 // windows gl headers depend on things like APIENTRY, so include windows.
 #define WIN32_LEAN_AND_MEAN
@@ -641,6 +654,9 @@ extern PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocationARB;
 extern PFNGLGETACTIVEATTRIBARBPROC glGetActiveAttribARB;
 extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
 
+//GL_EXT_blend_func_separate
+extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
+
 //GL_EXT_framebuffer_object
 extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
 extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
@@ -669,6 +685,7 @@ extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
 //GL_ARB_draw_buffers
 extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB;
 
+
 #elif LL_DARWIN
 //----------------------------------------------------------------------------
 // LL_DARWIN
@@ -685,6 +702,9 @@ extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB;
 // Note that they also must not be called on 10.3.9.  This should be taken care of by a runtime check for the existence of the GL extension.
 #include <AvailabilityMacros.h>
 
+//GL_EXT_blend_func_separate
+extern void glBlendFuncSeparateEXT(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
 // GL_EXT_framebuffer_object
 extern GLboolean glIsRenderbufferEXT(GLuint renderbuffer) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
 extern void glBindRenderbufferEXT(GLenum target, GLuint renderbuffer) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 57e7dbe77d6..6622178196e 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -766,8 +766,10 @@ LLRender::LLRender()
 	mCurrAlphaFunc = CF_DEFAULT;
 	mCurrAlphaFuncVal = 0.01f;
 
-	mCurrBlendSFactor = BF_UNDEF;
-	mCurrBlendDFactor = BF_UNDEF;
+	mCurrBlendColorSFactor = BF_UNDEF;
+	mCurrBlendAlphaSFactor = BF_UNDEF;
+	mCurrBlendColorDFactor = BF_UNDEF;
+	mCurrBlendAlphaDFactor = BF_UNDEF;
 }
 
 LLRender::~LLRender()
@@ -975,15 +977,44 @@ void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor)
 {
 	llassert(sfactor < BF_UNDEF);
 	llassert(dfactor < BF_UNDEF);
-	if (mCurrBlendSFactor != sfactor || mCurrBlendDFactor != dfactor)
+	if (mCurrBlendColorSFactor != sfactor || mCurrBlendColorDFactor != dfactor ||
+	    mCurrBlendAlphaSFactor != sfactor || mCurrBlendAlphaDFactor != dfactor)
 	{
-		mCurrBlendSFactor = sfactor;
-		mCurrBlendDFactor = dfactor;
+		mCurrBlendColorSFactor = sfactor;
+		mCurrBlendAlphaSFactor = sfactor;
+		mCurrBlendColorDFactor = dfactor;
+		mCurrBlendAlphaDFactor = dfactor;
 		flush();
 		glBlendFunc(sGLBlendFactor[sfactor], sGLBlendFactor[dfactor]);
 	}
 }
 
+void LLRender::blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor,
+			 eBlendFactor alpha_sfactor, eBlendFactor alpha_dfactor)
+{
+	llassert(color_sfactor < BF_UNDEF);
+	llassert(color_dfactor < BF_UNDEF);
+	llassert(alpha_sfactor < BF_UNDEF);
+	llassert(alpha_dfactor < BF_UNDEF);
+	if (!gGLManager.mHasBlendFuncSeparate)
+	{
+		LL_WARNS_ONCE("render") << "no glBlendFuncSeparateEXT(), using color-only blend func" << llendl;
+		blendFunc(color_sfactor, color_dfactor);
+		return;
+	}
+	if (mCurrBlendColorSFactor != color_sfactor || mCurrBlendColorDFactor != color_dfactor ||
+	    mCurrBlendAlphaSFactor != alpha_sfactor || mCurrBlendAlphaDFactor != alpha_dfactor)
+	{
+		mCurrBlendColorSFactor = color_sfactor;
+		mCurrBlendAlphaSFactor = alpha_sfactor;
+		mCurrBlendColorDFactor = color_dfactor;
+		mCurrBlendAlphaDFactor = alpha_dfactor;
+		flush();
+		glBlendFuncSeparateEXT(sGLBlendFactor[color_sfactor], sGLBlendFactor[color_dfactor],
+				       sGLBlendFactor[alpha_sfactor], sGLBlendFactor[alpha_dfactor]);
+	}
+}
+
 LLTexUnit* LLRender::getTexUnit(U32 index)
 {
 	if (index < mTexUnits.size())
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index a73a128368c..3cda4b57700 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -323,7 +323,11 @@ class LLRender
 
 	void setAlphaRejectSettings(eCompareFunc func, F32 value = 0.01f);
 
+	// applies blend func to both color and alpha
 	void blendFunc(eBlendFactor sfactor, eBlendFactor dfactor);
+	// applies separate blend functions to color and alpha
+	void blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor,
+		       eBlendFactor alpha_sfactor, eBlendFactor alpha_dfactor);
 
 	LLTexUnit* getTexUnit(U32 index);
 
@@ -362,8 +366,10 @@ class LLRender
 	std::vector<LLTexUnit*>		mTexUnits;
 	LLTexUnit*			mDummyTexUnit;
 
-	eBlendFactor mCurrBlendSFactor;
-	eBlendFactor mCurrBlendDFactor;
+	eBlendFactor mCurrBlendColorSFactor;
+	eBlendFactor mCurrBlendColorDFactor;
+	eBlendFactor mCurrBlendAlphaSFactor;
+	eBlendFactor mCurrBlendAlphaDFactor;
 	F32				mMaxAnisotropy;
 
 	std::list<LLVector3> mUIOffset;
-- 
GitLab


From b307d020a8e3039f93796b8203e65905850c7fbf Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 7 Mar 2010 18:31:32 +0000
Subject: [PATCH 182/683] Add support for glBlendFuncSeparate(). I want it to
 fix glow-through-alpha, but this checkin doesn't includes any of those
 changes.

---
 indra/llrender/llgl.cpp      | 64 ++++++++++++++++++++++--------
 indra/llrender/llgl.h        | 37 ++++++++++-------
 indra/llrender/llglheaders.h | 58 +++++++++++++++++++--------
 indra/llrender/llrender.cpp  | 77 ++++++++++++++++++++++++++----------
 indra/llrender/llrender.h    | 46 +++++++++++++--------
 5 files changed, 198 insertions(+), 84 deletions(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index ec1bd353cba..4c256f4b060 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -2,25 +2,31 @@
  * @file llgl.cpp
  * @brief LLGL implementation
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -179,6 +185,9 @@ PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT =
 // GL_EXT_framebuffer_blit
 PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT = NULL;
 
+// GL_EXT_blend_func_separate
+PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT = NULL;
+
 // GL_ARB_draw_buffers
 PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB = NULL;
 
@@ -318,6 +327,7 @@ LLGLManager::LLGLManager() :
 	mHasCompressedTextures(FALSE),
 	mHasFramebufferObject(FALSE),
 	mHasFramebufferMultisample(FALSE),
+	mHasBlendFuncSeparate(FALSE),
 
 	mHasVertexBufferObject(FALSE),
 	mHasPBuffer(FALSE),
@@ -626,6 +636,12 @@ void LLGLManager::initExtensions()
 	mHasDrawBuffers = TRUE;
 #else
 	mHasDrawBuffers = FALSE;
+# endif
+# if GL_EXT_blend_func_separate
+	mHasBlendFuncSeparate = TRUE;
+#else
+#error XXXXXX
+	mHasBlendFuncSeparate = FALSE;
 # endif
 	mHasMipMapGeneration = FALSE;
 	mHasSeparateSpecularColor = FALSE;
@@ -653,6 +669,7 @@ void LLGLManager::initExtensions()
 		&& ExtensionExists("GL_EXT_packed_depth_stencil", gGLHExts.mSysExts);
 	mHasFramebufferMultisample = mHasFramebufferObject && ExtensionExists("GL_EXT_framebuffer_multisample", gGLHExts.mSysExts);
 	mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts);
+	mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts);
 	mHasTextureRectangle = ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts);
 #if !LL_DARWIN
 	mHasPointParameters = !mIsATI && ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts);
@@ -676,6 +693,7 @@ void LLGLManager::initExtensions()
 		mHasFramebufferObject = FALSE;
 		mHasFramebufferMultisample = FALSE;
 		mHasDrawBuffers = FALSE;
+		mHasBlendFuncSeparate = FALSE;
 		mHasMipMapGeneration = FALSE;
 		mHasSeparateSpecularColor = FALSE;
 		mHasAnisotropic = FALSE;
@@ -700,6 +718,7 @@ void LLGLManager::initExtensions()
 		mHasShaderObjects = FALSE;
 		mHasVertexShader = FALSE;
 		mHasFragmentShader = FALSE;
+		mHasBlendFuncSeparate = FALSE;
 		LL_WARNS("RenderInit") << "GL extension support forced to SIMPLE level via LL_GL_BASICEXT" << LL_ENDL;
 	}
 	if (getenv("LL_GL_BLACKLIST"))	/* Flawfinder: ignore */
@@ -728,7 +747,8 @@ void LLGLManager::initExtensions()
 		if (strchr(blacklist,'r')) mHasDrawBuffers = FALSE;//S
 		if (strchr(blacklist,'s')) mHasFramebufferMultisample = FALSE;
 		if (strchr(blacklist,'t')) mHasTextureRectangle = FALSE;
-
+		if (strchr(blacklist,'u')) mHasBlendFuncSeparate = FALSE;//S
+		
 	}
 #endif // LL_LINUX || LL_SOLARIS
 	
@@ -776,6 +796,14 @@ void LLGLManager::initExtensions()
 	{
 		LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_fragment_shader" << LL_ENDL;
 	}
+	if (!mHasBlendFuncSeparate)
+	{
+		LL_INFOS("RenderInit") << "Couldn't initialize GL_EXT_blend_func_separate" << LL_ENDL;
+	}
+	if (!mHasDrawBuffers)
+	{
+		LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_draw_buffers" << LL_ENDL;
+	}
 
 	// Disable certain things due to known bugs
 	if (mIsIntel && mHasMipMapGeneration)
@@ -846,6 +874,10 @@ void LLGLManager::initExtensions()
 	{
 		glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDrawBuffersARB");
 	}
+	if (mHasBlendFuncSeparate)
+	{
+		glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlendFuncSeparateEXT");
+	}
 #if (!LL_LINUX && !LL_SOLARIS) || LL_LINUX_NV_GL_HEADERS
 	// This is expected to be a static symbol on Linux GL implementations, except if we use the nvidia headers - bah
 	glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)GLH_EXT_GET_PROC_ADDRESS("glDrawRangeElements");
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 46c57c75854..0c2da7dd089 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -2,25 +2,31 @@
  * @file llgl.h
  * @brief LLGL definition
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -81,6 +87,7 @@ class LLGLManager
 	BOOL mHasCompressedTextures;
 	BOOL mHasFramebufferObject;
 	BOOL mHasFramebufferMultisample;
+	BOOL mHasBlendFuncSeparate;
 	
 	// ARB Extensions
 	BOOL mHasVertexBufferObject;
diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h
index 436c861ab4b..f6d35bc7669 100644
--- a/indra/llrender/llglheaders.h
+++ b/indra/llrender/llglheaders.h
@@ -2,25 +2,31 @@
  * @file llglheaders.h
  * @brief LLGL definitions
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -210,6 +216,9 @@ extern PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB;
 
 extern PFNGLCOLORTABLEEXTPROC glColorTableEXT;
 
+//GL_EXT_blend_func_separate
+extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
+
 //GL_EXT_framebuffer_object
 extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
 extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
@@ -243,7 +252,10 @@ extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
 # include "GL/glh_extensions.h"
 # undef __APPLE__
 
-#elif LL_LINUX 
+#elif LL_LINUX
+//----------------------------------------------------------------------------
+// LL_LINUX
+
 //----------------------------------------------------------------------------
 // Linux, MESA headers, but not necessarily assuming MESA runtime.
 // quotes so we get libraries/.../GL/ version
@@ -279,6 +291,7 @@ extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
 # define LL_LINUX_NV_GL_HEADERS 0
 #endif // LL_LINUX && defined(WINGDIAPI)
 
+
 #if LL_LINUX_NV_GL_HEADERS
 // Missing functions when using nvidia headers:
 extern PFNGLACTIVETEXTUREARBPROC	glActiveTextureARB;
@@ -439,6 +452,9 @@ extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
 extern PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB;
 extern PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB;
 
+//GL_EXT_blend_func_separate
+extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
+
 //GL_EXT_framebuffer_object
 extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
 extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
@@ -467,7 +483,10 @@ extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
 //GL_ARB_draw_buffers
 extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB;
 
+
 #elif LL_WINDOWS
+//----------------------------------------------------------------------------
+// LL_WINDOWS
 
 // windows gl headers depend on things like APIENTRY, so include windows.
 #define WIN32_LEAN_AND_MEAN
@@ -635,6 +654,9 @@ extern PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocationARB;
 extern PFNGLGETACTIVEATTRIBARBPROC glGetActiveAttribARB;
 extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
 
+//GL_EXT_blend_func_separate
+extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
+
 //GL_EXT_framebuffer_object
 extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
 extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
@@ -663,6 +685,7 @@ extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
 //GL_ARB_draw_buffers
 extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB;
 
+
 #elif LL_DARWIN
 //----------------------------------------------------------------------------
 // LL_DARWIN
@@ -679,6 +702,9 @@ extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB;
 // Note that they also must not be called on 10.3.9.  This should be taken care of by a runtime check for the existence of the GL extension.
 #include <AvailabilityMacros.h>
 
+//GL_EXT_blend_func_separate
+extern void glBlendFuncSeparateEXT(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
 // GL_EXT_framebuffer_object
 extern GLboolean glIsRenderbufferEXT(GLuint renderbuffer) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
 extern void glBindRenderbufferEXT(GLenum target, GLuint renderbuffer) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index a829616df28..5597b23c69f 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -2,25 +2,31 @@
  * @file llrender.cpp
  * @brief LLRender implementation
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -772,8 +778,10 @@ LLRender::LLRender()
 
 	mCurrAlphaFunc = CF_DEFAULT;
 	mCurrAlphaFuncVal = 0.01f;
-	mCurrBlendSFactor = BF_UNDEF;
-	mCurrBlendDFactor = BF_UNDEF;
+	mCurrBlendColorSFactor = BF_UNDEF;
+	mCurrBlendAlphaSFactor = BF_UNDEF;
+	mCurrBlendColorDFactor = BF_UNDEF;
+	mCurrBlendAlphaDFactor = BF_UNDEF;
 }
 
 LLRender::~LLRender()
@@ -989,15 +997,44 @@ void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor)
 {
 	llassert(sfactor < BF_UNDEF);
 	llassert(dfactor < BF_UNDEF);
-	if (mCurrBlendSFactor != sfactor || mCurrBlendDFactor != dfactor)
+	if (mCurrBlendColorSFactor != sfactor || mCurrBlendColorDFactor != dfactor ||
+	    mCurrBlendAlphaSFactor != sfactor || mCurrBlendAlphaDFactor != dfactor)
 	{
-		mCurrBlendSFactor = sfactor;
-		mCurrBlendDFactor = dfactor;
+		mCurrBlendColorSFactor = sfactor;
+		mCurrBlendAlphaSFactor = sfactor;
+		mCurrBlendColorDFactor = dfactor;
+		mCurrBlendAlphaDFactor = dfactor;
 		flush();
 		glBlendFunc(sGLBlendFactor[sfactor], sGLBlendFactor[dfactor]);
 	}
 }
 
+void LLRender::blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor,
+			 eBlendFactor alpha_sfactor, eBlendFactor alpha_dfactor)
+{
+	llassert(color_sfactor < BF_UNDEF);
+	llassert(color_dfactor < BF_UNDEF);
+	llassert(alpha_sfactor < BF_UNDEF);
+	llassert(alpha_dfactor < BF_UNDEF);
+	if (!gGLManager.mHasBlendFuncSeparate)
+	{
+		LL_WARNS_ONCE("render") << "no glBlendFuncSeparateEXT(), using color-only blend func" << llendl;
+		blendFunc(color_sfactor, color_dfactor);
+		return;
+	}
+	if (mCurrBlendColorSFactor != color_sfactor || mCurrBlendColorDFactor != color_dfactor ||
+	    mCurrBlendAlphaSFactor != alpha_sfactor || mCurrBlendAlphaDFactor != alpha_dfactor)
+	{
+		mCurrBlendColorSFactor = color_sfactor;
+		mCurrBlendAlphaSFactor = alpha_sfactor;
+		mCurrBlendColorDFactor = color_dfactor;
+		mCurrBlendAlphaDFactor = alpha_dfactor;
+		flush();
+		glBlendFuncSeparateEXT(sGLBlendFactor[color_sfactor], sGLBlendFactor[color_dfactor],
+				       sGLBlendFactor[alpha_sfactor], sGLBlendFactor[alpha_dfactor]);
+	}
+}
+
 LLTexUnit* LLRender::getTexUnit(U32 index)
 {
 	if (index < mTexUnits.size())
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index fb3a4d214d2..f6c87aa1dbc 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -7,25 +7,31 @@
  *	code, to define an interface for a multiple rendering API abstraction of the UI
  *	rendering, and to abstract out direct rendering calls in a way that is cleaner and easier to maintain.
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -317,7 +323,11 @@ class LLRender
 
 	void setAlphaRejectSettings(eCompareFunc func, F32 value = 0.01f);
 
+	// applies blend func to both color and alpha
 	void blendFunc(eBlendFactor sfactor, eBlendFactor dfactor);
+	// applies separate blend functions to color and alpha
+	void blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor,
+		       eBlendFactor alpha_sfactor, eBlendFactor alpha_dfactor);
 
 	LLTexUnit* getTexUnit(U32 index);
 
@@ -356,8 +366,10 @@ class LLRender
 	std::vector<LLTexUnit*>		mTexUnits;
 	LLTexUnit*			mDummyTexUnit;
 
-	eBlendFactor mCurrBlendSFactor;
-	eBlendFactor mCurrBlendDFactor;
+	eBlendFactor mCurrBlendColorSFactor;
+	eBlendFactor mCurrBlendColorDFactor;
+	eBlendFactor mCurrBlendAlphaSFactor;
+	eBlendFactor mCurrBlendAlphaDFactor;
 
 	F32				mMaxAnisotropy;
 
-- 
GitLab


From 9beeb33f091083d10be3169930b9c205efc2821b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 8 Mar 2010 12:28:33 +0000
Subject: [PATCH 183/683] fixes VWR-4214 Glow effect passes through alpha
 textures where alpha is actually "solid" and its many many dupes.

In summary this does the following:
* When laying down alpha, uses the new separated color-and-alpha blend func support to suppress existing glow in proportion to the opacity of the incoming fragments
* Moves glowing-alpha support from the glow pool to the alpha pool, ensures that the glow pass for a vertex buffer happens after the alpha pass for the vertex buffer so that it doesn't suppress its *own* glow.

Tested with all shader modes, FBO on/off, and deferred rendering.  Tested with every permutation of alpha/non-alpha/glow/non-glow/fullbright/waterglow/particle interaction I could contrive so far. :)
---
 indra/newview/lldrawpoolalpha.cpp | 37 ++++++++++++++++++++++++++++++-
 indra/newview/llvovolume.cpp      | 16 +++++--------
 2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 75973cfa54b..9a778a063dd 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -204,7 +204,12 @@ void LLDrawPoolAlpha::render(S32 pass)
 	}
 
 	LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE);
+
+	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);
 	renderAlpha(getVertexDataMask());
+	gGL.setColorMask(true, false);
 
 	if (deferred_render && current_shader != NULL)
 	{
@@ -283,9 +288,18 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 	for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
+		llassert(group);
+		llassert(group->mSpatialPartition);
+
 		if (group->mSpatialPartition->mRenderByGroup &&
-			!group->isDead())
+		    !group->isDead())
 		{
+			bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow.
+				// All particle systems seem to come off the wire with texture entries which claim that they glow.  This is probably a bug in the data.  Suppress.
+				group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_PARTICLE &&
+				group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_CLOUD &&
+				group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD_PARTICLE;
+
 			LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA];
 
 			for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k)	
@@ -385,6 +399,27 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 				params.mVertexBuffer->setBuffer(mask);
 				params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
 				gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
+				
+				// If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow).  Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha.
+				if (draw_glow_for_this_partition &&
+				    params.mGlowColor.mV[3] > 0)
+				{
+					// install glow-accumulating blend mode
+					gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE, // don't touch color
+						      LLRender::BF_ONE, LLRender::BF_ONE); // add to alpha (glow)
+
+					// glow doesn't use vertex colors from the mesh data
+					params.mVertexBuffer->setBuffer(mask & ~LLVertexBuffer::MAP_COLOR);
+					glColor4ubv(params.mGlowColor.mV);
+
+					// do the actual drawing, again
+					params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+					gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
+
+					// restore our alpha blend mode
+					gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
+						      LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
+				}
 			
 				if (params.mTextureMatrix && params.mTexture.notNull())
 				{
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 1d3d943b06c..91aa994eab0 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3317,11 +3317,10 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 
 	S32 idx = draw_vec.size()-1;
 
-
 	BOOL fullbright = (type == LLRenderPass::PASS_FULLBRIGHT) ||
-					  (type == LLRenderPass::PASS_INVISIBLE) ||
-					  (type == LLRenderPass::PASS_ALPHA ? facep->isState(LLFace::FULLBRIGHT) : FALSE);
-
+		(type == LLRenderPass::PASS_INVISIBLE) ||
+		(type == LLRenderPass::PASS_ALPHA ? facep->isState(LLFace::FULLBRIGHT) : FALSE);
+	
 	if (!fullbright && type != LLRenderPass::PASS_GLOW && !facep->mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL))
 	{
 		llwarns << "Non fullbright face has no normals!" << llendl;
@@ -3350,12 +3349,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 	
 	LLViewerTexture* tex = facep->getTexture();
 
-	U8 glow = 0;
-		
-	if (type == LLRenderPass::PASS_GLOW)
-	{
-		glow = (U8) (facep->getTextureEntry()->getGlow() * 255);
-	}
+	U8 glow = (U8) (facep->getTextureEntry()->getGlow() * 255);
 
 	if (facep->mVertexBuffer.isNull())
 	{
@@ -4001,7 +3995,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				}
 			}
 
-			if (LLPipeline::sRenderGlow && te->getGlow() > 0.f)
+			if (!is_alpha && LLPipeline::sRenderGlow && te->getGlow() > 0.f)
 			{
 				registerFace(group, facep, LLRenderPass::PASS_GLOW);
 			}
-- 
GitLab


From 5461959d33f2cccfcacfe7887622d68e1c94ad12 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 8 Mar 2010 12:28:33 +0000
Subject: [PATCH 184/683] fixes VWR-4214 Glow effect passes through alpha
 textures where alpha is actually "solid" and its many many dupes.

In summary this does the following:
* When laying down alpha, uses the new separated color-and-alpha blend func support to suppress existing glow in proportion to the opacity of the incoming fragments
* Moves glowing-alpha support from the glow pool to the alpha pool, ensures that the glow pass for a vertex buffer happens after the alpha pass for the vertex buffer so that it doesn't suppress its *own* glow.

Tested with all shader modes, FBO on/off, and deferred rendering.  Tested with every permutation of alpha/non-alpha/glow/non-glow/fullbright/waterglow/particle interaction I could contrive so far. :)
---
 indra/newview/lldrawpoolalpha.cpp | 37 ++++++++++++++++++++++++++++++-
 indra/newview/llvovolume.cpp      | 16 +++++--------
 2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 75973cfa54b..9a778a063dd 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -204,7 +204,12 @@ void LLDrawPoolAlpha::render(S32 pass)
 	}
 
 	LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE);
+
+	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);
 	renderAlpha(getVertexDataMask());
+	gGL.setColorMask(true, false);
 
 	if (deferred_render && current_shader != NULL)
 	{
@@ -283,9 +288,18 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 	for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
+		llassert(group);
+		llassert(group->mSpatialPartition);
+
 		if (group->mSpatialPartition->mRenderByGroup &&
-			!group->isDead())
+		    !group->isDead())
 		{
+			bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow.
+				// All particle systems seem to come off the wire with texture entries which claim that they glow.  This is probably a bug in the data.  Suppress.
+				group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_PARTICLE &&
+				group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_CLOUD &&
+				group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD_PARTICLE;
+
 			LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA];
 
 			for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k)	
@@ -385,6 +399,27 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 				params.mVertexBuffer->setBuffer(mask);
 				params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
 				gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
+				
+				// If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow).  Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha.
+				if (draw_glow_for_this_partition &&
+				    params.mGlowColor.mV[3] > 0)
+				{
+					// install glow-accumulating blend mode
+					gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE, // don't touch color
+						      LLRender::BF_ONE, LLRender::BF_ONE); // add to alpha (glow)
+
+					// glow doesn't use vertex colors from the mesh data
+					params.mVertexBuffer->setBuffer(mask & ~LLVertexBuffer::MAP_COLOR);
+					glColor4ubv(params.mGlowColor.mV);
+
+					// do the actual drawing, again
+					params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+					gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
+
+					// restore our alpha blend mode
+					gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
+						      LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
+				}
 			
 				if (params.mTextureMatrix && params.mTexture.notNull())
 				{
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 073d7c2b91c..c92af140dab 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3199,11 +3199,10 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 
 	S32 idx = draw_vec.size()-1;
 
-
 	BOOL fullbright = (type == LLRenderPass::PASS_FULLBRIGHT) ||
-					  (type == LLRenderPass::PASS_INVISIBLE) ||
-					  (type == LLRenderPass::PASS_ALPHA ? facep->isState(LLFace::FULLBRIGHT) : FALSE);
-
+		(type == LLRenderPass::PASS_INVISIBLE) ||
+		(type == LLRenderPass::PASS_ALPHA ? facep->isState(LLFace::FULLBRIGHT) : FALSE);
+	
 	if (!fullbright && type != LLRenderPass::PASS_GLOW && !facep->mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL))
 	{
 		llwarns << "Non fullbright face has no normals!" << llendl;
@@ -3232,12 +3231,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 	
 	LLViewerTexture* tex = facep->getTexture();
 
-	U8 glow = 0;
-		
-	if (type == LLRenderPass::PASS_GLOW)
-	{
-		glow = (U8) (facep->getTextureEntry()->getGlow() * 255);
-	}
+	U8 glow = (U8) (facep->getTextureEntry()->getGlow() * 255);
 
 	if (facep->mVertexBuffer.isNull())
 	{
@@ -3878,7 +3872,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				}
 			}
 
-			if (LLPipeline::sRenderGlow && te->getGlow() > 0.f)
+			if (!is_alpha && LLPipeline::sRenderGlow && te->getGlow() > 0.f)
 			{
 				registerFace(group, facep, LLRenderPass::PASS_GLOW);
 			}
-- 
GitLab


From fa29257c8fa82cd7b04663868744b06ea58294f0 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 8 Mar 2010 14:51:27 +0000
Subject: [PATCH 185/683] VWR-4214 followup Make the fix work for alpha masks
 ('fast alpha') too - ironically this hasn't ever worked either AFAICT.

---
 indra/newview/lldrawpoolalpha.cpp | 26 +++++++++++++++++++-------
 indra/newview/lldrawpoolalpha.h   |  7 +++++++
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 9a778a063dd..7fd7cd3910b 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -60,7 +60,9 @@ static BOOL deferred_render = FALSE;
 
 LLDrawPoolAlpha::LLDrawPoolAlpha(U32 type) :
 		LLRenderPass(type), current_shader(NULL), target_shader(NULL),
-		simple_shader(NULL), fullbright_shader(NULL)
+		simple_shader(NULL), fullbright_shader(NULL),
+		mColorSFactor(LLRender::BF_UNDEF), mColorDFactor(LLRender::BF_UNDEF),
+		mAlphaSFactor(LLRender::BF_UNDEF), mAlphaDFactor(LLRender::BF_UNDEF)
 {
 
 }
@@ -178,9 +180,16 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 	LLGLSPipelineAlpha gls_pipeline_alpha;
 
+	gGL.setColorMask(true, true);
+
 	if (LLPipeline::sFastAlpha && !deferred_render)
 	{
-		LLGLDisable blend_disable(GL_BLEND);
+		mColorSFactor = LLRender::BF_ONE;  // }
+		mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow
+		mAlphaSFactor = LLRender::BF_ZERO;
+		mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds
+		gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
+
 		gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f);
 		if (mVertexShaderLevel > 0)
 		{
@@ -205,10 +214,14 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 	LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE);
 
-	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);
+	mColorSFactor = LLRender::BF_SOURCE_ALPHA;           // } regular alpha blend
+	mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // }
+	mAlphaSFactor = LLRender::BF_ZERO;                         // } glow suppression
+	mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA;       // }
+	gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
+
 	renderAlpha(getVertexDataMask());
+
 	gGL.setColorMask(true, false);
 
 	if (deferred_render && current_shader != NULL)
@@ -417,8 +430,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 					gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
 
 					// restore our alpha blend mode
-					gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
-						      LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
+					gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
 				}
 			
 				if (params.mTextureMatrix && params.mTexture.notNull())
diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h
index 3aa752f72c5..61f73d0b311 100644
--- a/indra/newview/lldrawpoolalpha.h
+++ b/indra/newview/lldrawpoolalpha.h
@@ -34,6 +34,7 @@
 #define LL_LLDRAWPOOLALPHA_H
 
 #include "lldrawpool.h"
+#include "llrender.h"
 #include "llframetimer.h"
 
 class LLFace;
@@ -83,6 +84,12 @@ class LLDrawPoolAlpha: public LLRenderPass
 	LLGLSLShader* target_shader;
 	LLGLSLShader* simple_shader;
 	LLGLSLShader* fullbright_shader;	
+
+	// our 'normal' alpha blend function for this pass
+	LLRender::eBlendFactor mColorSFactor;
+	LLRender::eBlendFactor mColorDFactor;	
+	LLRender::eBlendFactor mAlphaSFactor;
+	LLRender::eBlendFactor mAlphaDFactor;
 };
 
 class LLDrawPoolAlphaPostWater : public LLDrawPoolAlpha
-- 
GitLab


From 6de84031ee5c786b1a773d9d35f499c7c7a5ec20 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 8 Mar 2010 14:51:27 +0000
Subject: [PATCH 186/683] VWR-4214 followup Make the fix work for alpha masks
 ('fast alpha') too - ironically this hasn't ever worked either AFAICT.

---
 indra/newview/lldrawpoolalpha.cpp | 26 ++++++++++++++-----
 indra/newview/lldrawpoolalpha.h   | 43 ++++++++++++++++++++-----------
 2 files changed, 47 insertions(+), 22 deletions(-)

diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 9a778a063dd..7fd7cd3910b 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -60,7 +60,9 @@ static BOOL deferred_render = FALSE;
 
 LLDrawPoolAlpha::LLDrawPoolAlpha(U32 type) :
 		LLRenderPass(type), current_shader(NULL), target_shader(NULL),
-		simple_shader(NULL), fullbright_shader(NULL)
+		simple_shader(NULL), fullbright_shader(NULL),
+		mColorSFactor(LLRender::BF_UNDEF), mColorDFactor(LLRender::BF_UNDEF),
+		mAlphaSFactor(LLRender::BF_UNDEF), mAlphaDFactor(LLRender::BF_UNDEF)
 {
 
 }
@@ -178,9 +180,16 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 	LLGLSPipelineAlpha gls_pipeline_alpha;
 
+	gGL.setColorMask(true, true);
+
 	if (LLPipeline::sFastAlpha && !deferred_render)
 	{
-		LLGLDisable blend_disable(GL_BLEND);
+		mColorSFactor = LLRender::BF_ONE;  // }
+		mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow
+		mAlphaSFactor = LLRender::BF_ZERO;
+		mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds
+		gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
+
 		gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f);
 		if (mVertexShaderLevel > 0)
 		{
@@ -205,10 +214,14 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 	LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE);
 
-	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);
+	mColorSFactor = LLRender::BF_SOURCE_ALPHA;           // } regular alpha blend
+	mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // }
+	mAlphaSFactor = LLRender::BF_ZERO;                         // } glow suppression
+	mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA;       // }
+	gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
+
 	renderAlpha(getVertexDataMask());
+
 	gGL.setColorMask(true, false);
 
 	if (deferred_render && current_shader != NULL)
@@ -417,8 +430,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 					gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
 
 					// restore our alpha blend mode
-					gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA,
-						      LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
+					gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
 				}
 			
 				if (params.mTextureMatrix && params.mTexture.notNull())
diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h
index 0477093afab..61f73d0b311 100644
--- a/indra/newview/lldrawpoolalpha.h
+++ b/indra/newview/lldrawpoolalpha.h
@@ -2,25 +2,31 @@
  * @file lldrawpoolalpha.h
  * @brief LLDrawPoolAlpha class definition
  *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -28,6 +34,7 @@
 #define LL_LLDRAWPOOLALPHA_H
 
 #include "lldrawpool.h"
+#include "llrender.h"
 #include "llframetimer.h"
 
 class LLFace;
@@ -77,6 +84,12 @@ class LLDrawPoolAlpha: public LLRenderPass
 	LLGLSLShader* target_shader;
 	LLGLSLShader* simple_shader;
 	LLGLSLShader* fullbright_shader;	
+
+	// our 'normal' alpha blend function for this pass
+	LLRender::eBlendFactor mColorSFactor;
+	LLRender::eBlendFactor mColorDFactor;	
+	LLRender::eBlendFactor mAlphaSFactor;
+	LLRender::eBlendFactor mAlphaDFactor;
 };
 
 class LLDrawPoolAlphaPostWater : public LLDrawPoolAlpha
-- 
GitLab


From b9a2c6eafacdaa4838cd62672b3255c3e9c0ee16 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 8 Mar 2010 15:48:27 +0000
Subject: [PATCH 187/683] Remove a '#error XXX' I was using to test ifdef-hell.

---
 indra/llrender/llgl.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 4c256f4b060..97019d48c48 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -640,7 +640,6 @@ void LLGLManager::initExtensions()
 # if GL_EXT_blend_func_separate
 	mHasBlendFuncSeparate = TRUE;
 #else
-#error XXXXXX
 	mHasBlendFuncSeparate = FALSE;
 # endif
 	mHasMipMapGeneration = FALSE;
-- 
GitLab


From d429a4787f7c09a188e3c03904d2695bf1f0108e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 8 Mar 2010 15:48:27 +0000
Subject: [PATCH 188/683] Remove a '#error XXX' I was using to test ifdef-hell.

---
 indra/llrender/llgl.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 4c256f4b060..97019d48c48 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -640,7 +640,6 @@ void LLGLManager::initExtensions()
 # if GL_EXT_blend_func_separate
 	mHasBlendFuncSeparate = TRUE;
 #else
-#error XXXXXX
 	mHasBlendFuncSeparate = FALSE;
 # endif
 	mHasMipMapGeneration = FALSE;
-- 
GitLab


From 38334e22e3dbbf7ddc735e8f64a8dc39691d1701 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 8 Mar 2010 21:33:19 -0600
Subject: [PATCH 189/683] Multi-threaded file dialog

---
 indra/newview/llappviewer.cpp      |  7 ++++
 indra/newview/llfilepicker.cpp     | 19 +++++++----
 indra/newview/llfilepicker.h       |  2 +-
 indra/newview/llviewermenufile.cpp | 53 +++++++++++++++++++++++++++++-
 indra/newview/llviewermenufile.h   | 26 +++++++++++++++
 5 files changed, 99 insertions(+), 8 deletions(-)

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 33ab12c623a..e3bfb823d09 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -78,6 +78,7 @@
 #include "llteleporthistory.h"
 #include "lllocationhistory.h"
 #include "llfasttimerview.h"
+#include "llviewermenufile.h"
 #include "llvoicechannel.h"
 #include "llsidetray.h"
 
@@ -1567,6 +1568,8 @@ bool LLAppViewer::cleanup()
 	sTextureFetch->shutDownTextureCacheThread() ;
 	sTextureFetch->shutDownImageDecodeThread() ;
 
+	LLFilePickerThread::cleanupClass();
+
 	delete sTextureCache;
     sTextureCache = NULL;
 	delete sTextureFetch;
@@ -1717,6 +1720,8 @@ bool LLAppViewer::initThreads()
 	// Mesh streaming and caching
 	gMeshRepo.init();
 
+	LLFilePickerThread::initClass();
+
 	// *FIX: no error handling here!
 	return true;
 }
@@ -3461,6 +3466,8 @@ void LLAppViewer::idle()
 	LLEventTimer::updateClass();
 	LLCriticalDamp::updateInterpolants();
 	LLMortician::updateClass();
+	LLFilePickerThread::clearDead();  //calls LLFilePickerThread::notify()
+
 	F32 dt_raw = idle_timer.getElapsedTimeAndResetF32();
 
 	// Cap out-of-control frame times
diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index 6a502e8d8c5..868d0b67c8e 100644
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -211,7 +211,7 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)
 	return res;
 }
 
-BOOL LLFilePicker::getOpenFile(ELoadFilter filter)
+BOOL LLFilePicker::getOpenFile(ELoadFilter filter, BOOL blocking)
 {
 	if( mLocked )
 	{
@@ -230,8 +230,11 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter)
 
 	setupFilter(filter);
 	
-	// Modal, so pause agent
-	send_agent_pause();
+	if (blocking)
+	{
+		// Modal, so pause agent
+		send_agent_pause();
+	}
 
 	reset();
 	
@@ -242,10 +245,14 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter)
 		std::string filename = utf16str_to_utf8str(llutf16string(mFilesW));
 		mFiles.push_back(filename);
 	}
-	send_agent_resume();
 
-	// Account for the fact that the app has been stalled.
-	LLFrameTimer::updateFrameTime();
+	if (blocking)
+	{
+		send_agent_resume();
+		// Account for the fact that the app has been stalled.
+		LLFrameTimer::updateFrameTime();
+	}
+	
 	return success;
 }
 
diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h
index 98dc36c296e..b96f9576731 100644
--- a/indra/newview/llfilepicker.h
+++ b/indra/newview/llfilepicker.h
@@ -113,7 +113,7 @@ class LLFilePicker
 
 	// open the dialog. This is a modal operation
 	BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const std::string& filename = LLStringUtil::null );
-	BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL );
+	BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL, BOOL blocking = TRUE  );
 	BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL );
 
 	// Get the filename(s) found. getFirstFile() sets the pointer to
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index e2602204930..8b537512751 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -100,6 +100,57 @@ class LLFileEnableUploadModel : public view_listener_t
 	}
 };
 
+LLMutex* LLFilePickerThread::sMutex = NULL;
+std::queue<LLFilePickerThread*> LLFilePickerThread::sDeadQ;
+
+//virtual 
+void LLFilePickerThread::run()
+{
+	LLFilePicker picker;
+	if (picker.getOpenFile(mFilter, FALSE))
+	{
+		mFile = picker.getFirstFile();
+	}
+	
+	{
+		LLMutexLock lock(sMutex);
+		sDeadQ.push(this);
+	}
+
+}
+
+//static
+void LLFilePickerThread::initClass()
+{
+	sMutex = new LLMutex(NULL);
+}
+
+//static
+void LLFilePickerThread::cleanupClass()
+{
+	clearDead();
+	
+	delete sMutex;
+	sMutex = NULL;
+}
+
+//static
+void LLFilePickerThread::clearDead()
+{
+	if (!sDeadQ.empty())
+	{
+		LLMutexLock lock(sMutex);
+		while (!sDeadQ.empty())
+		{
+			LLFilePickerThread* thread = sDeadQ.front();
+			thread->notify(thread->mFile);
+			delete thread;
+			sDeadQ.pop();
+		}
+	}
+}
+
+
 //============================================================================
 
 #if LL_WINDOWS
@@ -290,7 +341,7 @@ class LLFileUploadModel : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
-		LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) LLFloaterReg::showInstance("upload_model");
+		LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) LLFloaterReg::getInstance("upload_model");
 		if (fmp)
 		{
 			fmp->loadModel(3);
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index e700b0565ee..8936b5cdb4c 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -36,6 +36,7 @@
 #include "llfoldertype.h"
 #include "llassetstorage.h"
 #include "llinventorytype.h"
+#include "llfilepicker.h"
 
 class LLTransactionID;
 
@@ -120,5 +121,30 @@ void on_new_single_inventory_upload_complete(
 	const LLSD& server_response,
 	S32 upload_price);
 
+class LLFilePickerThread : public LLThread
+{ //multi-threaded file picker (runs system specific file picker in background and calls "notify" from main thread)
+public:
+
+	static std::queue<LLFilePickerThread*> sDeadQ;
+	static LLMutex* sMutex;
+
+	static void initClass();
+	static void cleanupClass();
+	static void clearDead();
+
+	std::string mFile; 
+
+	LLFilePicker::ELoadFilter mFilter;
+
+	LLFilePickerThread(LLFilePicker::ELoadFilter filter)
+		: LLThread("file picker"), mFilter(filter)
+	{
+
+	}
+	virtual void run();
+
+	virtual void notify(const std::string& filename) = 0;
+};
+
 
 #endif
-- 
GitLab


From b26d5803468c029bba735acf2ae57ea50b542dee Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 8 Mar 2010 21:50:24 -0600
Subject: [PATCH 190/683] little bool

---
 indra/newview/llfilepicker.cpp     | 2 +-
 indra/newview/llfilepicker.h       | 2 +-
 indra/newview/llviewermenufile.cpp | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index 868d0b67c8e..fe30556234a 100644
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -211,7 +211,7 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)
 	return res;
 }
 
-BOOL LLFilePicker::getOpenFile(ELoadFilter filter, BOOL blocking)
+BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking)
 {
 	if( mLocked )
 	{
diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h
index b96f9576731..10fb30af9f0 100644
--- a/indra/newview/llfilepicker.h
+++ b/indra/newview/llfilepicker.h
@@ -113,7 +113,7 @@ class LLFilePicker
 
 	// open the dialog. This is a modal operation
 	BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const std::string& filename = LLStringUtil::null );
-	BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL, BOOL blocking = TRUE  );
+	BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL, bool blocking = true  );
 	BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL );
 
 	// Get the filename(s) found. getFirstFile() sets the pointer to
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 8b537512751..b22a74080fb 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -107,7 +107,7 @@ std::queue<LLFilePickerThread*> LLFilePickerThread::sDeadQ;
 void LLFilePickerThread::run()
 {
 	LLFilePicker picker;
-	if (picker.getOpenFile(mFilter, FALSE))
+	if (picker.getOpenFile(mFilter, false))
 	{
 		mFile = picker.getFirstFile();
 	}
-- 
GitLab


From 68991a2cce21932137a2d678f4258dad83ee27d6 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 8 Mar 2010 22:16:08 -0600
Subject: [PATCH 191/683] Mac and linux fix?

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

diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index fe30556234a..324d99937ed 100644
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -834,7 +834,7 @@ OSStatus	LLFilePicker::doNavSaveDialog(ESaveFilter filter, const std::string& fi
 	return error;
 }
 
-BOOL LLFilePicker::getOpenFile(ELoadFilter filter)
+BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking)
 {
 	if( mLocked )
 		return FALSE;
@@ -853,20 +853,29 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter)
 		mNavOptions.optionFlags |= kNavSupportPackages;
 	}
 	
-	// Modal, so pause agent
-	send_agent_pause();
+	if (blocking)
+	{
+		// Modal, so pause agent
+		send_agent_pause();
+	}
+
 	{
 		error = doNavChooseDialog(filter);
 	}
-	send_agent_resume();
+	
 	if (error == noErr)
 	{
 		if (getFileCount())
 			success = true;
 	}
 
-	// Account for the fact that the app has been stalled.
-	LLFrameTimer::updateFrameTime();
+	if (blocking)
+	{
+		send_agent_resume();
+		// Account for the fact that the app has been stalled.
+		LLFrameTimer::updateFrameTime();
+	}
+
 	return success;
 }
 
@@ -1223,7 +1232,7 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename
 	return rtn;
 }
 
-BOOL LLFilePicker::getOpenFile( ELoadFilter filter )
+BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking )
 {
 	BOOL rtn = FALSE;
 
-- 
GitLab


From 4c022455685598bfd3ab90c4611e053fad72345d Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 9 Mar 2010 13:28:23 +0000
Subject: [PATCH 192/683] Disable alpha-masking for glowing surfaces.  It seems
 beyond my ability to get right.

Refactor some replicated and/or strangely-expressed logic.
---
 indra/newview/llspatialpartition.h |  5 +++--
 indra/newview/llvovolume.cpp       | 24 ++++++++++++++----------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 88fab01ea4c..d74216de2d1 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -614,14 +614,15 @@ class LLCloudPartition : public LLParticlePartition
 //class for wrangling geometry out of volumes (implemented in LLVOVolume.cpp)
 class LLVolumeGeometryManager: public LLGeometryManager
 {
-public:
+ public:
 	virtual ~LLVolumeGeometryManager() { }
 	virtual void rebuildGeom(LLSpatialGroup* group);
 	virtual void rebuildMesh(LLSpatialGroup* group);
 	virtual void getGeometry(LLSpatialGroup* group);
 	void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort = FALSE);
 	void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type);
-
+ private:
+	bool canRenderAsMask(LLFace* facep); // logic helper
 };
 
 //spatial partition that uses volume geometry manager (implemented in LLVOVolume.cpp)
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 91aa994eab0..90a06a966df 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3319,7 +3319,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 
 	BOOL fullbright = (type == LLRenderPass::PASS_FULLBRIGHT) ||
 		(type == LLRenderPass::PASS_INVISIBLE) ||
-		(type == LLRenderPass::PASS_ALPHA ? facep->isState(LLFace::FULLBRIGHT) : FALSE);
+		(type == LLRenderPass::PASS_ALPHA && facep->isState(LLFace::FULLBRIGHT));
 	
 	if (!fullbright && type != LLRenderPass::PASS_GLOW && !facep->mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL))
 	{
@@ -3414,6 +3414,16 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_VB("Volume");
 static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
+bool LLVolumeGeometryManager::canRenderAsMask(LLFace* facep)
+{
+	const LLTextureEntry* te = facep->getTextureEntry();
+	return (LLPipeline::sFastAlpha &&
+		(te->getColor().mV[3] == 1.0f) &&
+		(!te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible, need to figure out why - for now, avoid
+		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
+		facep->getTexture()->getIsAlphaMask());
+}
+
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
 	if (group->changeLOD())
@@ -3539,10 +3549,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 				if (type == LLDrawPool::POOL_ALPHA)
 				{
-					if (LLPipeline::sFastAlpha &&
-					    (te->getColor().mV[VW] == 1.0f) &&
-					    (!te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible, need to figure out why - for now, avoid
-					    facep->getTexture()->getIsAlphaMask())
+					if (canRenderAsMask(facep))
 					{ //can be treated as alpha mask
 						simple_faces.push_back(facep);
 					}
@@ -3891,15 +3898,12 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 
 			const LLTextureEntry* te = facep->getTextureEntry();
 
-			BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE;
+			BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) ? TRUE : FALSE;
 		
 			if (is_alpha)
 			{
 				// can we safely treat this as an alpha mask?
-				if (LLPipeline::sFastAlpha &&
-				    (te->getColor().mV[VW] == 1.0f) &&
-				    (!te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible, need to figure out why - for now, avoid
-				    facep->getTexture()->getIsAlphaMask())
+				if (canRenderAsMask(facep))
 				{
 					if (te->getFullbright())
 					{
-- 
GitLab


From 43c425db2467fa91d2df40b5dd708a738003131e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 9 Mar 2010 13:28:23 +0000
Subject: [PATCH 193/683] Disable alpha-masking for glowing surfaces.  It seems
 beyond my ability to get right.

Refactor some replicated and/or strangely-expressed logic.
---
 indra/newview/llspatialpartition.h |  5 +++--
 indra/newview/llvovolume.cpp       | 24 ++++++++++++++----------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 929f2adc1aa..2c09a25e040 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -613,14 +613,15 @@ class LLCloudPartition : public LLParticlePartition
 //class for wrangling geometry out of volumes (implemented in LLVOVolume.cpp)
 class LLVolumeGeometryManager: public LLGeometryManager
 {
-public:
+ public:
 	virtual ~LLVolumeGeometryManager() { }
 	virtual void rebuildGeom(LLSpatialGroup* group);
 	virtual void rebuildMesh(LLSpatialGroup* group);
 	virtual void getGeometry(LLSpatialGroup* group);
 	void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort = FALSE);
 	void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type);
-
+ private:
+	bool canRenderAsMask(LLFace* facep); // logic helper
 };
 
 //spatial partition that uses volume geometry manager (implemented in LLVOVolume.cpp)
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index c92af140dab..ea493d47980 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3201,7 +3201,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 
 	BOOL fullbright = (type == LLRenderPass::PASS_FULLBRIGHT) ||
 		(type == LLRenderPass::PASS_INVISIBLE) ||
-		(type == LLRenderPass::PASS_ALPHA ? facep->isState(LLFace::FULLBRIGHT) : FALSE);
+		(type == LLRenderPass::PASS_ALPHA && facep->isState(LLFace::FULLBRIGHT));
 	
 	if (!fullbright && type != LLRenderPass::PASS_GLOW && !facep->mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL))
 	{
@@ -3296,6 +3296,16 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_VB("Volume");
 static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
+bool LLVolumeGeometryManager::canRenderAsMask(LLFace* facep)
+{
+	const LLTextureEntry* te = facep->getTextureEntry();
+	return (LLPipeline::sFastAlpha &&
+		(te->getColor().mV[3] == 1.0f) &&
+		(!te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible, need to figure out why - for now, avoid
+		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
+		facep->getTexture()->getIsAlphaMask());
+}
+
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
 	if (group->changeLOD())
@@ -3421,10 +3431,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 				if (type == LLDrawPool::POOL_ALPHA)
 				{
-					if (LLPipeline::sFastAlpha &&
-					    (te->getColor().mV[VW] == 1.0f) &&
-					    (!te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible, need to figure out why - for now, avoid
-					    facep->getTexture()->getIsAlphaMask())
+					if (canRenderAsMask(facep))
 					{ //can be treated as alpha mask
 						simple_faces.push_back(facep);
 					}
@@ -3768,15 +3775,12 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 
 			const LLTextureEntry* te = facep->getTextureEntry();
 
-			BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE;
+			BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) ? TRUE : FALSE;
 		
 			if (is_alpha)
 			{
 				// can we safely treat this as an alpha mask?
-				if (LLPipeline::sFastAlpha &&
-				    (te->getColor().mV[VW] == 1.0f) &&
-				    (!te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible, need to figure out why - for now, avoid
-				    facep->getTexture()->getIsAlphaMask())
+				if (canRenderAsMask(facep))
 				{
 					if (te->getFullbright())
 					{
-- 
GitLab


From 8da956d60926cb9c62c15e6766ea542049690777 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 9 Mar 2010 13:45:53 +0000
Subject: [PATCH 194/683] We can enable alpha masking for fullbright faces as
 long as we're not in deferred mode.  Deferred masked fullbrights are still
 broken (we fall back to blending instead of masking as a workaround), but
 they always have been. :/

---
 indra/newview/llvovolume.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 90a06a966df..1725879b7f6 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3417,11 +3417,15 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 bool LLVolumeGeometryManager::canRenderAsMask(LLFace* facep)
 {
 	const LLTextureEntry* te = facep->getTextureEntry();
-	return (LLPipeline::sFastAlpha &&
-		(te->getColor().mV[3] == 1.0f) &&
-		(!te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible, need to figure out why - for now, avoid
+	return (
+		LLPipeline::sFastAlpha && // do we want masks at all?
+
+		(te->getColor().mV[3] == 1.0f) && // can't treat as mask if we have face alpha
+		!(LLPipeline::sRenderDeferred && te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible in deferred rendering mode, need to figure out why - for now, avoid
 		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
-		facep->getTexture()->getIsAlphaMask());
+
+		facep->getTexture()->getIsAlphaMask() // texture actually qualifies for masking (lazily calculated but expensive)
+		);
 }
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
-- 
GitLab


From 6b08cc3a2da882982f80be477c159c2d2e4d89d0 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 9 Mar 2010 13:45:53 +0000
Subject: [PATCH 195/683] We can enable alpha masking for fullbright faces as
 long as we're not in deferred mode.  Deferred masked fullbrights are still
 broken (we fall back to blending instead of masking as a workaround), but
 they always have been. :/

---
 indra/newview/llvovolume.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index ea493d47980..49c0c4d4e02 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3299,11 +3299,15 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 bool LLVolumeGeometryManager::canRenderAsMask(LLFace* facep)
 {
 	const LLTextureEntry* te = facep->getTextureEntry();
-	return (LLPipeline::sFastAlpha &&
-		(te->getColor().mV[3] == 1.0f) &&
-		(!te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible, need to figure out why - for now, avoid
+	return (
+		LLPipeline::sFastAlpha && // do we want masks at all?
+
+		(te->getColor().mV[3] == 1.0f) && // can't treat as mask if we have face alpha
+		!(LLPipeline::sRenderDeferred && te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible in deferred rendering mode, need to figure out why - for now, avoid
 		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
-		facep->getTexture()->getIsAlphaMask());
+
+		facep->getTexture()->getIsAlphaMask() // texture actually qualifies for masking (lazily calculated but expensive)
+		);
 }
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
-- 
GitLab


From d60f5e937f2ed264f3e01eec7e32b9260e3d772f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 9 Mar 2010 14:28:06 -0600
Subject: [PATCH 196/683] Tool tips for model preview.  Rename "Impostor" to
 "Lowest"

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

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 904786079f4..d85c56046fc 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1918,7 +1918,7 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 	
 	std::string nm[] = 
 	{
-		"impostor",
+		"lowest_lod",
 		"low_lod",
 		"medium_lod",
 		"high_lod"
-- 
GitLab


From 4c0e2f79219913b57424bfe136b75a6a58fb8639 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 11 Mar 2010 12:02:37 -0600
Subject: [PATCH 197/683] "Generate Normals" is less busted now.

---
 indra/llmath/llvolume.cpp | 67 +++++++++++++++++++++++++++++++++++++--
 indra/llmath/llvolume.h   | 33 +++++++++++++++++++
 2 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index d85c56046fc..9ea3912a885 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1882,9 +1882,15 @@ bool LLVolumeFace::VertexData::compareNormal(const LLVolumeFace::VertexData& rhs
 	bool retval = false;
 	if (rhs.mPosition == mPosition && rhs.mTexCoord == mTexCoord)
 	{
-		F32 cur_angle = rhs.mNormal*mNormal;
-		
-		retval = cur_angle > angle_cutoff;
+		if (angle_cutoff > 1.f)
+		{
+			retval = (mNormal == rhs.mNormal);
+		}
+		else
+		{
+			F32 cur_angle = rhs.mNormal*mNormal;
+			retval = cur_angle > angle_cutoff;
+		}
 	}
 
 	return retval;
@@ -4953,6 +4959,61 @@ BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
 	}
 }
 
+void LLVolumeFace::optimize(F32 angle_cutoff)
+{
+	LLVolumeFace new_face;
+
+	VertexMapData::PointMap point_map;
+
+	//remove redundant vertices
+	for (U32 i = 0; i < mIndices.size(); ++i)
+	{
+		U16 index = mIndices[i];
+
+		LLVolumeFace::VertexData cv = mVertices[index];
+
+		BOOL found = FALSE;
+		VertexMapData::PointMap::iterator point_iter = point_map.find(cv.mPosition);
+		if (point_iter != point_map.end())
+		{ //duplicate point might exist
+			for (U32 j = 0; j < point_iter->second.size(); ++j)
+			{
+				LLVolumeFace::VertexData& tv = (point_iter->second)[j];
+				if (tv.compareNormal(cv, angle_cutoff))
+				{
+					found = TRUE;
+					new_face.mIndices.push_back((point_iter->second)[j].mIndex);
+					break;
+				}
+			}
+		}
+
+		if (!found)
+		{
+			new_face.mVertices.push_back(cv);
+			U16 index = (U16) new_face.mVertices.size()-1;
+			new_face.mIndices.push_back(index);
+
+			VertexMapData d;
+			d.mPosition = cv.mPosition;
+			d.mTexCoord = cv.mTexCoord;
+			d.mNormal = cv.mNormal;
+			d.mIndex = index;
+			if (point_iter != point_map.end())
+			{
+				point_iter->second.push_back(d);
+			}
+			else
+			{
+				point_map[d.mPosition].push_back(d);
+			}
+		}
+	}
+
+	mVertices = new_face.mVertices;
+	mIndices = new_face.mIndices;
+}
+
 void	LerpPlanarVertex(LLVolumeFace::VertexData& v0,
 				   LLVolumeFace::VertexData& v1,
 				   LLVolumeFace::VertexData& v2,
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 36811785dc2..f1c1fdcebab 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -820,6 +820,39 @@ class LLVolumeFace
 		bool compareNormal(const VertexData& rhs, F32 angle_cutoff) const;
 	};
 
+	class VertexMapData : public LLVolumeFace::VertexData
+	{
+	public:
+		U16 mIndex;
+
+		bool operator==(const LLVolumeFace::VertexData& rhs) const
+		{
+			return mPosition == rhs.mPosition &&
+				mTexCoord == rhs.mTexCoord &&
+				mNormal == rhs.mNormal;
+		}
+
+		struct ComparePosition
+		{
+			bool operator()(const LLVector3& a, const LLVector3& b) const
+			{
+				if (a.mV[0] != b.mV[0])
+				{
+					return a.mV[0] < b.mV[0];
+				}
+				if (a.mV[1] != b.mV[1])
+				{
+					return a.mV[1] < b.mV[1];
+				}
+				return a.mV[2] < b.mV[2];
+			}
+		};
+
+		typedef std::map<LLVector3, std::vector<VertexMapData>, VertexMapData::ComparePosition > PointMap;
+	};
+
+	void optimize(F32 angle_cutoff = 2.f);
+	
 	enum
 	{
 		SINGLE_MASK =	0x0001,
-- 
GitLab


From 294e7036e48b7efc17b2d48ebc050045bb0c5d14 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 12 Mar 2010 17:24:57 -0600
Subject: [PATCH 198/683] Fix for file dialog crashing on mac and linux when
 uploading meshes.

---
 indra/newview/llviewermenufile.cpp | 18 +++++++++++++++++-
 indra/newview/llviewermenufile.h   |  3 +++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index b22a74080fb..1026ff86a5b 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -103,15 +103,31 @@ class LLFileEnableUploadModel : public view_listener_t
 LLMutex* LLFilePickerThread::sMutex = NULL;
 std::queue<LLFilePickerThread*> LLFilePickerThread::sDeadQ;
 
+void LLFilePickerThread::getFile()
+{
+#if LL_WINDOWS
+	start();
+#else
+	run();
+#endif
+}
+
 //virtual 
 void LLFilePickerThread::run()
 {
 	LLFilePicker picker;
+#if LL_WINDOWS
 	if (picker.getOpenFile(mFilter, false))
 	{
 		mFile = picker.getFirstFile();
 	}
-	
+#else
+	if (picker.getOpenFile(mFilter, true))
+	{
+		mFile = picker.getFirstFile();
+	}
+#endif
+
 	{
 		LLMutexLock lock(sMutex);
 		sDeadQ.push(this);
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 8936b5cdb4c..08444551a9f 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -141,6 +141,9 @@ class LLFilePickerThread : public LLThread
 	{
 
 	}
+
+	void getFile();
+
 	virtual void run();
 
 	virtual void notify(const std::string& filename) = 0;
-- 
GitLab


From 71d11af31083ced30da7b67a2a63e624c93b44a3 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 13 Mar 2010 17:39:32 -0600
Subject: [PATCH 199/683] Mesh cache.  Has a bug.

---
 indra/llmath/llvolume.cpp | 28 ++++++++++++++--------------
 indra/llmath/llvolume.h   |  2 +-
 indra/llvfs/llvfile.cpp   |  2 +-
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 9ea3912a885..52a3fb21955 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1962,7 +1962,7 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 	return unpackVolumeFaces(is, header[nm[lod]]["size"].asInteger());
 }
 
-BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
+bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 {
 	U8* result = NULL;
 	U32 cur_size = 0;
@@ -2002,7 +2002,7 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 				inflateEnd(&strm);
 				free(result);
 				delete [] in;
-				return FALSE;
+				return false;
 			}
 			
 			switch (ret)
@@ -2014,7 +2014,7 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 				inflateEnd(&strm);
 				free(result);
 				delete [] in;
-				return FALSE;
+				return false;
 				break;
 			}
 
@@ -2032,7 +2032,7 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 		if (ret != Z_STREAM_END)
 		{
 			free(result);
-			return FALSE;
+			return false;
 		}
 	}
 
@@ -2047,7 +2047,7 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 		if (!LLSDSerialize::deserialize(mdl, istr, cur_size))
 		{
 			llwarns << "not a valid mesh asset!" << llendl;
-			return FALSE;
+			return false;
 		}
 	}
 
@@ -2074,7 +2074,7 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 			LLVolumeFace& face = mVolumeFaces[i];
 
-			face.mHasBinormals = FALSE;
+			face.mHasBinormals = false;
 
 			//copy out indices
 			face.mIndices.resize(idx.size()/2);
@@ -2146,24 +2146,24 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 			
 			// modifier flags?
-			BOOL do_mirror = (mParams.getSculptType() & LL_SCULPT_FLAG_MIRROR);
-			BOOL do_invert = (mParams.getSculptType() &LL_SCULPT_FLAG_INVERT);
+			bool do_mirror = (mParams.getSculptType() & LL_SCULPT_FLAG_MIRROR);
+			bool do_invert = (mParams.getSculptType() &LL_SCULPT_FLAG_INVERT);
 			
 			
 			// translate to actions:
-			BOOL do_reflect_x = FALSE;
-			BOOL do_reverse_triangles = FALSE;
-			BOOL do_invert_normals = FALSE;
+			bool do_reflect_x = false;
+			bool do_reverse_triangles = false;
+			bool do_invert_normals = false;
 			
 			if (do_mirror)
 			{
-				do_reflect_x = TRUE;
+				do_reflect_x = true;
 				do_reverse_triangles = !do_reverse_triangles;
 			}
 			
 			if (do_invert)
 			{
-				do_invert_normals = TRUE;
+				do_invert_normals = true;
 				do_reverse_triangles = !do_reverse_triangles;
 			}
 			
@@ -2201,7 +2201,7 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 	}
 
 	mSculptLevel = 0;  // success!
-	return TRUE;
+	return true;
 }
 
 void tetrahedron_set_normal(LLVolumeFace::VertexData* cv)
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index f1c1fdcebab..60c1569e550 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -1009,7 +1009,7 @@ class LLVolume : public LLRefCount
 public:
 	virtual BOOL createVolumeFacesFromFile(const std::string& file_name);
 	virtual BOOL createVolumeFacesFromStream(std::istream& is);
-	virtual BOOL unpackVolumeFaces(std::istream& is, S32 size);
+	virtual bool unpackVolumeFaces(std::istream& is, S32 size);
 
 	virtual void makeTetrahedron();
 	virtual BOOL isTetrahedron();
diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp
index e0e282d7afa..6751f3eb939 100644
--- a/indra/llvfs/llvfile.cpp
+++ b/indra/llvfs/llvfile.cpp
@@ -320,7 +320,7 @@ BOOL LLVFile::setMaxSize(S32 size)
 
 	if (!mVFS->checkAvailable(size))
 	{
-		LLFastTimer t(FTM_VFILE_WAIT);
+		//LLFastTimer t(FTM_VFILE_WAIT);
 		S32 count = 0;
 		while (sVFSThread->getPending() > 1000)
 		{
-- 
GitLab


From 80eeff0297be277c79683c293ab46eda2a5e7fb0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 16 Mar 2010 14:08:11 -0500
Subject: [PATCH 200/683] Alert dialog when mesh upload fails.

---
 indra/newview/skins/default/xui/en/notifications.xml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index a3abe36db4e..f204b8082a3 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -5905,6 +5905,12 @@ Selected button can not be shown right now.
 The button will be shown when there is enough space for it.
   </notification>
 
+  <notification
+    name="MeshUploadError"
+    icon="alert.tga"
+    type="alert">
+    [LABEL] failed to upload: [MESSAGE] [IDENTIFIER] [INVALIDITY_IDENTIFIER]
+  </notification>
 
   <global name="UnsupportedCPU">
 - Your CPU speed does not meet the minimum requirements.
-- 
GitLab


From 4f46c4ef41298a58c165288511b1e919acbff6b8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 17 Mar 2010 15:36:52 -0500
Subject: [PATCH 201/683] Disable fast alpha by default.  Pull scene importer
 option from upload menu.

---
 indra/newview/app_settings/settings.xml            |  2 +-
 .../skins/default/xui/en/menu_inventory_add.xml    | 14 ++------------
 .../skins/default/xui/en/panel_main_inventory.xml  | 10 ----------
 3 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 2fb3f526922..8d6a1790f16 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6916,7 +6916,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>1</integer>
+      <integer>0</integer>
     </map>
     <key>RenderFastUI</key>
     <map>
diff --git a/indra/newview/skins/default/xui/en/menu_inventory_add.xml b/indra/newview/skins/default/xui/en/menu_inventory_add.xml
index 05a4e60de79..4e178eef964 100644
--- a/indra/newview/skins/default/xui/en/menu_inventory_add.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory_add.xml
@@ -42,7 +42,7 @@
                     <menu_item_call.on_enable
                      function="File.EnableUpload" />
                 </menu_item_call>
-		<menu_item_call
+		            <menu_item_call
                  label="Model..."
                  layout="topleft"
                  name="Upload Model">
@@ -51,17 +51,7 @@
                  parameter="" />
                 <menu_item_call.on_enable
                  function="File.EnableUploadModel" />
-              </menu_item_call>
-              <menu_item_call
-                 label="Scene..."
-                 layout="topleft"
-                 name="Upload Scene">
-                <menu_item_call.on_click
-                 function="File.UploadScene"
-                 parameter="" />
-                <menu_item_call.on_enable
-                 function="File.EnableUpload" />
-              </menu_item_call>
+                </menu_item_call>
                 <menu_item_call
                  label="Bulk (L$[COST] per file)..."
                  layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_main_inventory.xml b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
index cbe36626fe9..65da20ae8cf 100644
--- a/indra/newview/skins/default/xui/en/panel_main_inventory.xml
+++ b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
@@ -89,16 +89,6 @@
                     <menu_item_call.on_enable
                      function="File.EnableUploadModel" />
                 </menu_item_call>
-                <menu_item_call
-                 label="Scene..."
-                 layout="topleft"
-                 name="Upload Scene">
-                    <menu_item_call.on_click
-                     function="File.UploadScene"
-                     parameter="" />
-                    <menu_item_call.on_enable
-                     function="File.EnableUpload" />
-                </menu_item_call>
                 <menu_item_call
                  label="Bulk (L$[COST] per file)..."
                  layout="topleft"
-- 
GitLab


From 39a08368bb916a08da626c58908e40cf4f817f9a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 17 Mar 2010 21:17:01 -0500
Subject: [PATCH 202/683] Fix for impostors being fullbright when deferred
 rendering enabled.

---
 .../app_settings/shaders/class1/deferred/impostorF.glsl        | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index 8c140a7b4f0..508bbf415ea 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -11,7 +11,8 @@ uniform sampler2D specularMap;
 
 void main() 
 {
-	gl_FragData[0] = texture2D(diffuseMap, gl_TexCoord[0].xy);
+	vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
+	gl_FragData[0] = vec4(col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
 	gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy);
 	gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, 0.0);
 }
-- 
GitLab


From 7c3bc40df78398b446a74b313b9068fc59db4756 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 17 Mar 2010 21:17:01 -0500
Subject: [PATCH 203/683] Fix for impostors being fullbright when deferred
 rendering enabled.

---
 .../app_settings/shaders/class1/deferred/impostorF.glsl        | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index 8c140a7b4f0..508bbf415ea 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -11,7 +11,8 @@ uniform sampler2D specularMap;
 
 void main() 
 {
-	gl_FragData[0] = texture2D(diffuseMap, gl_TexCoord[0].xy);
+	vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
+	gl_FragData[0] = vec4(col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
 	gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy);
 	gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, 0.0);
 }
-- 
GitLab


From 16bbd7bf08b7b1abec0ba6b97bc4a34f753b5875 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 17 Mar 2010 22:22:02 -0500
Subject: [PATCH 204/683] CTS-110 Remove soft alpha in deferred pipeline
 (breaks some content).  Will revisit soft alpha in materials project.

---
 .../app_settings/shaders/class1/deferred/alphaF.glsl  | 11 -----------
 .../shaders/class1/deferred/fullbrightF.glsl          | 11 -----------
 .../app_settings/shaders/class2/deferred/alphaF.glsl  | 11 -----------
 indra/newview/pipeline.cpp                            |  1 -
 4 files changed, 34 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 4fb109d6870..fea2e160908 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -24,8 +24,6 @@ varying vec3 vary_fragcoord;
 varying vec3 vary_position;
 varying vec3 vary_light;
 
-uniform float alpha_soften;
-
 uniform mat4 inv_proj;
 
 vec4 getPosition(vec2 pos_screen)
@@ -57,15 +55,6 @@ void main()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	if (samp_pos.z != 0.0 && gl_Color.a < 1.0)
-	{
-		float dist_factor = alpha_soften;
-		float a = gl_Color.a;
-		a *= a;
-		dist_factor *= 1.0/(1.0-a);
-		color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
-	}
-	
 	//gl_FragColor = gl_Color;
 	gl_FragColor = color;
 	//gl_FragColor = vec4(1,0,1,1);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index e518bddb984..0db9586a88d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -23,8 +23,6 @@ varying vec4 vary_position;
 varying vec3 vary_normal;
 varying vec3 vary_fragcoord;
 
-uniform float alpha_soften;
-
 uniform mat4 inv_proj;
 
 vec4 getPosition(vec2 pos_screen)
@@ -56,15 +54,6 @@ void main()
 
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 
-	if (samp_pos.z != 0.0 && color.a < 1.0)
-	{
-		float dist_factor = alpha_soften;
-		float a = color.a;
-		a *= a;
-		dist_factor *= 1.0/(1.0-a);
-		color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
-	}
-
 	//gl_FragColor = gl_Color;
 	gl_FragColor = color;
 	//gl_FragColor = vec4(1,0,1,1);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index ad16de6d816..665fe16b439 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -29,8 +29,6 @@ varying vec3 vary_fragcoord;
 varying vec3 vary_position;
 varying vec3 vary_light;
 
-uniform float alpha_soften;
-
 uniform float shadow_bias;
 
 uniform mat4 inv_proj;
@@ -115,15 +113,6 @@ void main()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	if (samp_pos.z != 0.0 && gl_Color.a < 1.0)
-	{
-		float dist_factor = alpha_soften;
-		float a = gl_Color.a;
-		a *= a;
-		dist_factor *= 1.0/(1.0-a);
-		color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
-	}
-	
 	//gl_FragColor = gl_Color;
 	gl_FragColor = color;
 	//gl_FragColor = vec4(1,0,1,1)*shadow;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2f4314f7e53..674f2fe58ca 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6173,7 +6173,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
 
 	shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight());
 	shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f);
-	shader.uniform1f("alpha_soften", gSavedSettings.getF32("RenderDeferredAlphaSoften"));
 	shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset"));
 	shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias"));
 	shader.uniform1f("lum_scale", gSavedSettings.getF32("RenderLuminanceScale"));
-- 
GitLab


From 0afe2491ab6a05bf62a2fce438dfdbbaf0b191df Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 17 Mar 2010 22:22:02 -0500
Subject: [PATCH 205/683] CTS-110 Remove soft alpha in deferred pipeline
 (breaks some content).  Will revisit soft alpha in materials project.

---
 .../app_settings/shaders/class1/deferred/alphaF.glsl  | 11 -----------
 .../shaders/class1/deferred/fullbrightF.glsl          | 11 -----------
 .../app_settings/shaders/class2/deferred/alphaF.glsl  | 11 -----------
 indra/newview/pipeline.cpp                            |  1 -
 4 files changed, 34 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 4fb109d6870..fea2e160908 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -24,8 +24,6 @@ varying vec3 vary_fragcoord;
 varying vec3 vary_position;
 varying vec3 vary_light;
 
-uniform float alpha_soften;
-
 uniform mat4 inv_proj;
 
 vec4 getPosition(vec2 pos_screen)
@@ -57,15 +55,6 @@ void main()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	if (samp_pos.z != 0.0 && gl_Color.a < 1.0)
-	{
-		float dist_factor = alpha_soften;
-		float a = gl_Color.a;
-		a *= a;
-		dist_factor *= 1.0/(1.0-a);
-		color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
-	}
-	
 	//gl_FragColor = gl_Color;
 	gl_FragColor = color;
 	//gl_FragColor = vec4(1,0,1,1);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index e518bddb984..0db9586a88d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -23,8 +23,6 @@ varying vec4 vary_position;
 varying vec3 vary_normal;
 varying vec3 vary_fragcoord;
 
-uniform float alpha_soften;
-
 uniform mat4 inv_proj;
 
 vec4 getPosition(vec2 pos_screen)
@@ -56,15 +54,6 @@ void main()
 
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 
-	if (samp_pos.z != 0.0 && color.a < 1.0)
-	{
-		float dist_factor = alpha_soften;
-		float a = color.a;
-		a *= a;
-		dist_factor *= 1.0/(1.0-a);
-		color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
-	}
-
 	//gl_FragColor = gl_Color;
 	gl_FragColor = color;
 	//gl_FragColor = vec4(1,0,1,1);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index ad16de6d816..665fe16b439 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -29,8 +29,6 @@ varying vec3 vary_fragcoord;
 varying vec3 vary_position;
 varying vec3 vary_light;
 
-uniform float alpha_soften;
-
 uniform float shadow_bias;
 
 uniform mat4 inv_proj;
@@ -115,15 +113,6 @@ void main()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	if (samp_pos.z != 0.0 && gl_Color.a < 1.0)
-	{
-		float dist_factor = alpha_soften;
-		float a = gl_Color.a;
-		a *= a;
-		dist_factor *= 1.0/(1.0-a);
-		color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
-	}
-	
 	//gl_FragColor = gl_Color;
 	gl_FragColor = color;
 	//gl_FragColor = vec4(1,0,1,1)*shadow;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e65c8b9af8b..ee5ed32a830 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6249,7 +6249,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
 
 	shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight());
 	shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f);
-	shader.uniform1f("alpha_soften", gSavedSettings.getF32("RenderDeferredAlphaSoften"));
 	shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset"));
 	shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias"));
 	shader.uniform1f("lum_scale", gSavedSettings.getF32("RenderLuminanceScale"));
-- 
GitLab


From 97d13488d6213b9413f010e751e5032193d74904 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 18 Mar 2010 15:43:37 -0500
Subject: [PATCH 206/683] XML changes for new graphics preferences

---
 indra/newview/app_settings/settings.xml       |  26 +-
 .../xui/en/panel_preferences_graphics1.xml    | 285 +++++++++---------
 2 files changed, 163 insertions(+), 148 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 1dc90280a20..c8a6db89edc 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6679,6 +6679,18 @@
     <integer>1</integer>
   </map>
 
+  <key>RenderDeferredSSAO</key>
+  <map>
+    <key>Comment</key>
+    <string>Execute screen space ambient occlusion shader in deferred renderer.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>1</integer>
+  </map>
+
   <key>RenderDeferredBlurLight</key>
   <map>
     <key>Comment</key>
@@ -7311,7 +7323,19 @@
       <key>Value</key>
       <integer>2</integer>
     </map>
-    <key>RenderReflectionRes</key>
+    <key>RenderShadowDetail</key>
+    <map>
+      <key>Comment</key>
+      <string>Detail of shadows.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>S32</string>
+      <key>Value</key>
+      <integer>2</integer>
+    </map>
+
+  <key>RenderReflectionRes</key>
     <map>
       <key>Comment</key>
       <string>Reflection map resolution.</string>
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 44c44f5f59c..8d43adb5453 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -155,12 +155,12 @@
 	 visiblity_control="ShowAdvancedGraphicsSettings"
      border="false"
 	 follows="top|left"
-     height="260"
+     height="283"
      label="CustomGraphics"
      layout="topleft"
      left="5"
      name="CustomGraphics Panel"
-     top="124"
+     top="101"
      width="485">
 		<text
 		type="string"
@@ -211,119 +211,105 @@
 			<check_box.commit_callback
 			function="Pref.VertexShaderEnable" />
 		</check_box>
-		<check_box
-		control_name="RenderWaterReflections"
-		height="16"
-		initial_value="true"
-		label="Water reflections"
-		layout="topleft"
-		left_delta="0"
-		name="Reflections"
-		top_pad="1"
-		width="256">
-			<check_box.commit_callback
-			function="Pref.VertexShaderEnable" />
-		</check_box>
-		<text
-		type="string"
-		length="1"
-		follows="left|top"
-		height="12"
-		layout="topleft"
-		left_delta="0"
-		name="ReflectionDetailText"
-		top_pad="7"
-		width="128">
-			Reflection detail:
-		</text>
-		<radio_group
-		control_name="RenderReflectionDetail"
-		draw_border="false"
-		height="70"
-		layout="topleft"
-		left_delta="-2"
-		name="ReflectionDetailRadio"
-		top_pad="3"
-		width="321">
-			<radio_item
-			height="16"
-			label="Terrain and trees"
-			layout="topleft"
-			left="3"
-			name="0"
-			top="3"
-			width="315" />
-			<radio_item
-			height="16"
-			label="All static objects"
-			layout="topleft"
-			left_delta="0"
-			name="1"
-			top_delta="16"
-			width="315" />
-			<radio_item
-			height="16"
-			label="All avatars and objects"
-			layout="topleft"
-			left_delta="0"
-			name="2"
-			top_delta="16"
-			width="315" />
-			<radio_item
-			height="16"
-			label="Everything"
-			layout="topleft"
-			left_delta="0"
-			name="3"
-			top_delta="16"
-			width="315" />
-		</radio_group>
-		<text
-		type="string"
-		length="1"
-		follows="left|top"
-		height="12"
-		layout="topleft"
-		left_delta="2"
-		name="AvatarRenderingText"
-		top_pad="5"
-		width="128">
-			Avatar rendering:
-		</text>
-		<check_box
-		control_name="RenderUseImpostors"
-		height="16"
-		initial_value="true"
-		label="Avatar impostors"
-		layout="topleft"
-		left_delta="0"
-		name="AvatarImpostors"
-		top_pad="7"
-		width="256" />
-		<check_box
-		control_name="RenderAvatarVP"
+    <check_box
+		control_name="RenderDeferred"
 		height="16"
 		initial_value="true"
-		label="Hardware skinning"
+		label="Lighting Shaders"
 		layout="topleft"
 		left_delta="0"
-		name="AvatarVertexProgram"
+		name="UseLightShaders"
 		top_pad="1"
-		width="256">
-			<check_box.commit_callback
-			function="Pref.VertexShaderEnable" />
-		</check_box>
-		<check_box
-		control_name="RenderAvatarCloth"
+		width="256"/>
+    <check_box
+		control_name="RenderDeferredSSAO"
 		height="16"
 		initial_value="true"
-		label="Avatar cloth"
+		label="Ambient Occlusion"
 		layout="topleft"
 		left_delta="0"
-		name="AvatarCloth"
+		name="UseSSAO"
 		top_pad="1"
-		width="256" />
+		width="256"/>
 
+      <text
+    type="string"
+    length="1"
+    top_pad="8"
+    follows="top|left"
+    height="23"
+    width="110"
+    word_wrap="true"
+    layout="topleft"
+    left="10"
+    name="reflection_label">
+        Water Reflections:
+      </text>
+      <combo_box
+      control_name="RenderReflectionDetail"
+      height="23"
+      layout="topleft"
+      left_="10"
+      top_pad ="0" 
+      name="ReflectionDetailRadio"
+      width="150">
+        <combo_box.item
+        label="None"
+        name="0"
+        value="0"/>
+        <combo_box.item
+        label="Terrain and trees"
+        name="1"
+        value="1"/>
+        <combo_box.item
+        label="All static objects"
+        name="2"
+        value="2"/>
+        <combo_box.item
+        label="All avatars and objects"
+        name="3"
+        value="3"/>
+        <combo_box.item
+        label="Everything"
+        name="4"
+        value="4"/>
+      </combo_box>
+
+      <text
+    type="string"
+    length="1"
+    top_pad="8"
+    follows="top|left"
+    height="23"
+    width="110"
+    word_wrap="true"
+    layout="topleft"
+    left="10"
+    name="shadows_label">
+        Shadows:
+      </text>
+      <combo_box
+      control_name="RenderShadowDetail"
+      height="23"
+      layout="topleft"
+      left="10"
+      top_pad="0" 
+      name="ShadowDetailRadio"
+      width="150">
+        <combo_box.item
+        label="None"
+        name="0"
+        value="0"/>
+        <combo_box.item
+        label="Sun/Moon"
+        name="1"
+        value="1"/>
+        <combo_box.item
+        label="Sun/Moon + Projectors"
+        name="2"
+        value="2"/>
+      </combo_box>
+    
 		<slider
 		control_name="RenderFarClip"
 		decimal_digits="0"
@@ -522,7 +508,7 @@
         layout="topleft"
         left="444"
         name="PostProcessText"
-        top="305"
+        top="328"
         width="128">
            Low
         </text>
@@ -599,46 +585,51 @@
         width="128">
            Low
         </text>
-        <text
-        type="string"
-        length="1"
-        follows="left|top"
-        height="12"
-        layout="topleft"
-        left_delta="-230"
-        name="LightingDetailText"
-        top_pad="8"
-        width="140">
-           Lighting detail:
-        </text>
-        <radio_group
-        control_name="RenderLightingDetail"
-        draw_border="false"
-        height="38"
-        layout="topleft"
-        left_delta="0"
-        name="LightingDetailRadio"
-        top_pad="5"
-        width="321">
-           <radio_item
-            height="16"
-            label="Sun and moon only"
-            layout="topleft"
-            left="3"
-            name="SunMoon"
-            value="0"
-            top="3"
-            width="156" />
-           <radio_item
-            height="16"
-            label="Nearby local lights"
-            layout="topleft"
-            left_delta="0"
-            name="LocalLights"
-            value="1"
-            top_delta="16"
-            width="156" />
-        </radio_group>
+      <text
+      type="string"
+      length="1"
+      follows="left|top"
+      height="12"
+      layout="topleft"
+      left_delta="-230"
+      name="AvatarRenderingText"
+      top_pad="8"
+      width="128">
+        Avatar rendering:
+      </text>
+      <check_box
+      control_name="RenderUseImpostors"
+      height="16"
+      initial_value="true"
+      label="Avatar impostors"
+      layout="topleft"
+      left_delta="0"
+      name="AvatarImpostors"
+      top_pad="7"
+      width="256" />
+      <check_box
+      control_name="RenderAvatarVP"
+      height="16"
+      initial_value="true"
+      label="Hardware skinning"
+      layout="topleft"
+      left_delta="0"
+      name="AvatarVertexProgram"
+      top_pad="1"
+      width="256">
+        <check_box.commit_callback
+        function="Pref.VertexShaderEnable" />
+      </check_box>
+      <check_box
+      control_name="RenderAvatarCloth"
+      height="16"
+      initial_value="true"
+      label="Avatar cloth"
+      layout="topleft"
+      left_delta="0"
+      name="AvatarCloth"
+      top_pad="1"
+      width="256" />
         <text
         type="string"
         length="1"
@@ -647,7 +638,7 @@
         layout="topleft"
         left="358"
         name="TerrainDetailText"
-        top="465"
+        top="488"
         width="155">
            Terrain detail:
         </text>
@@ -676,7 +667,7 @@
             name="2"
             top_delta="16"
             width="315" />
-        </radio_group>
+        </radio_group> -->
 	</panel>
 	
         <button
-- 
GitLab


From 4a12ace4f58c7cc432dcefe408c72285e9e81d12 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 18 Mar 2010 15:43:37 -0500
Subject: [PATCH 207/683] XML changes for new graphics preferences

---
 indra/newview/app_settings/settings.xml       |  26 +-
 .../xui/en/panel_preferences_graphics1.xml    | 285 +++++++++---------
 2 files changed, 163 insertions(+), 148 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 8d6a1790f16..38d0df9a174 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6657,6 +6657,18 @@
     <integer>1</integer>
   </map>
 
+  <key>RenderDeferredSSAO</key>
+  <map>
+    <key>Comment</key>
+    <string>Execute screen space ambient occlusion shader in deferred renderer.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>1</integer>
+  </map>
+
   <key>RenderDeferredBlurLight</key>
   <map>
     <key>Comment</key>
@@ -7289,7 +7301,19 @@
       <key>Value</key>
       <integer>2</integer>
     </map>
-    <key>RenderReflectionRes</key>
+    <key>RenderShadowDetail</key>
+    <map>
+      <key>Comment</key>
+      <string>Detail of shadows.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>S32</string>
+      <key>Value</key>
+      <integer>2</integer>
+    </map>
+
+  <key>RenderReflectionRes</key>
     <map>
       <key>Comment</key>
       <string>Reflection map resolution.</string>
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index c74de043e92..3a37486e861 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -182,12 +182,12 @@
 	 visiblity_control="ShowAdvancedGraphicsSettings"
      border="false"
 	 follows="top|left"
-     height="260"
+     height="283"
      label="CustomGraphics"
      layout="topleft"
      left="5"
      name="CustomGraphics Panel"
-     top="124"
+     top="101"
      width="485">
 		<text
 		type="string"
@@ -238,119 +238,105 @@
 			<check_box.commit_callback
 			function="Pref.VertexShaderEnable" />
 		</check_box>
-		<check_box
-		control_name="RenderWaterReflections"
-		height="16"
-		initial_value="true"
-		label="Water reflections"
-		layout="topleft"
-		left_delta="0"
-		name="Reflections"
-		top_pad="1"
-		width="256">
-			<check_box.commit_callback
-			function="Pref.VertexShaderEnable" />
-		</check_box>
-		<text
-		type="string"
-		length="1"
-		follows="left|top"
-		height="12"
-		layout="topleft"
-		left_delta="0"
-		name="ReflectionDetailText"
-		top_pad="7"
-		width="128">
-			Reflection detail:
-		</text>
-		<radio_group
-		control_name="RenderReflectionDetail"
-		draw_border="false"
-		height="70"
-		layout="topleft"
-		left_delta="-2"
-		name="ReflectionDetailRadio"
-		top_pad="3"
-		width="321">
-			<radio_item
-			height="16"
-			label="Terrain and trees"
-			layout="topleft"
-			left="3"
-			name="0"
-			top="3"
-			width="315" />
-			<radio_item
-			height="16"
-			label="All static objects"
-			layout="topleft"
-			left_delta="0"
-			name="1"
-			top_delta="16"
-			width="315" />
-			<radio_item
-			height="16"
-			label="All avatars and objects"
-			layout="topleft"
-			left_delta="0"
-			name="2"
-			top_delta="16"
-			width="315" />
-			<radio_item
-			height="16"
-			label="Everything"
-			layout="topleft"
-			left_delta="0"
-			name="3"
-			top_delta="16"
-			width="315" />
-		</radio_group>
-		<text
-		type="string"
-		length="1"
-		follows="left|top"
-		height="12"
-		layout="topleft"
-		left_delta="2"
-		name="AvatarRenderingText"
-		top_pad="5"
-		width="128">
-			Avatar rendering:
-		</text>
-		<check_box
-		control_name="RenderUseImpostors"
-		height="16"
-		initial_value="true"
-		label="Avatar impostors"
-		layout="topleft"
-		left_delta="0"
-		name="AvatarImpostors"
-		top_pad="7"
-		width="256" />
-		<check_box
-		control_name="RenderAvatarVP"
+    <check_box
+		control_name="RenderDeferred"
 		height="16"
 		initial_value="true"
-		label="Hardware skinning"
+		label="Lighting Shaders"
 		layout="topleft"
 		left_delta="0"
-		name="AvatarVertexProgram"
+		name="UseLightShaders"
 		top_pad="1"
-		width="256">
-			<check_box.commit_callback
-			function="Pref.VertexShaderEnable" />
-		</check_box>
-		<check_box
-		control_name="RenderAvatarCloth"
+		width="256"/>
+    <check_box
+		control_name="RenderDeferredSSAO"
 		height="16"
 		initial_value="true"
-		label="Avatar cloth"
+		label="Ambient Occlusion"
 		layout="topleft"
 		left_delta="0"
-		name="AvatarCloth"
+		name="UseSSAO"
 		top_pad="1"
-		width="256" />
+		width="256"/>
 
+      <text
+    type="string"
+    length="1"
+    top_pad="8"
+    follows="top|left"
+    height="23"
+    width="110"
+    word_wrap="true"
+    layout="topleft"
+    left="10"
+    name="reflection_label">
+        Water Reflections:
+      </text>
+      <combo_box
+      control_name="RenderReflectionDetail"
+      height="23"
+      layout="topleft"
+      left_="10"
+      top_pad ="0" 
+      name="ReflectionDetailRadio"
+      width="150">
+        <combo_box.item
+        label="None"
+        name="0"
+        value="0"/>
+        <combo_box.item
+        label="Terrain and trees"
+        name="1"
+        value="1"/>
+        <combo_box.item
+        label="All static objects"
+        name="2"
+        value="2"/>
+        <combo_box.item
+        label="All avatars and objects"
+        name="3"
+        value="3"/>
+        <combo_box.item
+        label="Everything"
+        name="4"
+        value="4"/>
+      </combo_box>
+
+      <text
+    type="string"
+    length="1"
+    top_pad="8"
+    follows="top|left"
+    height="23"
+    width="110"
+    word_wrap="true"
+    layout="topleft"
+    left="10"
+    name="shadows_label">
+        Shadows:
+      </text>
+      <combo_box
+      control_name="RenderShadowDetail"
+      height="23"
+      layout="topleft"
+      left="10"
+      top_pad="0" 
+      name="ShadowDetailRadio"
+      width="150">
+        <combo_box.item
+        label="None"
+        name="0"
+        value="0"/>
+        <combo_box.item
+        label="Sun/Moon"
+        name="1"
+        value="1"/>
+        <combo_box.item
+        label="Sun/Moon + Projectors"
+        name="2"
+        value="2"/>
+      </combo_box>
+    
 		<slider
 		control_name="RenderFarClip"
 		decimal_digits="0"
@@ -549,7 +535,7 @@
         layout="topleft"
         left="444"
         name="PostProcessText"
-        top="305"
+        top="328"
         width="128">
            Low
         </text>
@@ -626,46 +612,51 @@
         width="128">
            Low
         </text>
-        <text
-        type="string"
-        length="1"
-        follows="left|top"
-        height="12"
-        layout="topleft"
-        left_delta="-230"
-        name="LightingDetailText"
-        top_pad="8"
-        width="140">
-           Lighting detail:
-        </text>
-        <radio_group
-        control_name="RenderLightingDetail"
-        draw_border="false"
-        height="38"
-        layout="topleft"
-        left_delta="0"
-        name="LightingDetailRadio"
-        top_pad="5"
-        width="321">
-           <radio_item
-            height="16"
-            label="Sun and moon only"
-            layout="topleft"
-            left="3"
-            name="SunMoon"
-            value="0"
-            top="3"
-            width="156" />
-           <radio_item
-            height="16"
-            label="Nearby local lights"
-            layout="topleft"
-            left_delta="0"
-            name="LocalLights"
-            value="1"
-            top_delta="16"
-            width="156" />
-        </radio_group>
+      <text
+      type="string"
+      length="1"
+      follows="left|top"
+      height="12"
+      layout="topleft"
+      left_delta="-230"
+      name="AvatarRenderingText"
+      top_pad="8"
+      width="128">
+        Avatar rendering:
+      </text>
+      <check_box
+      control_name="RenderUseImpostors"
+      height="16"
+      initial_value="true"
+      label="Avatar impostors"
+      layout="topleft"
+      left_delta="0"
+      name="AvatarImpostors"
+      top_pad="7"
+      width="256" />
+      <check_box
+      control_name="RenderAvatarVP"
+      height="16"
+      initial_value="true"
+      label="Hardware skinning"
+      layout="topleft"
+      left_delta="0"
+      name="AvatarVertexProgram"
+      top_pad="1"
+      width="256">
+        <check_box.commit_callback
+        function="Pref.VertexShaderEnable" />
+      </check_box>
+      <check_box
+      control_name="RenderAvatarCloth"
+      height="16"
+      initial_value="true"
+      label="Avatar cloth"
+      layout="topleft"
+      left_delta="0"
+      name="AvatarCloth"
+      top_pad="1"
+      width="256" />
         <text
         type="string"
         length="1"
@@ -674,7 +665,7 @@
         layout="topleft"
         left="358"
         name="TerrainDetailText"
-        top="465"
+        top="488"
         width="155">
            Terrain detail:
         </text>
@@ -703,7 +694,7 @@
             name="2"
             top_delta="16"
             width="315" />
-        </radio_group>
+        </radio_group> -->
 	</panel>
 	
         <button
-- 
GitLab


From bee8774886a6258cc20f7a065e62d099ab7098ca Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 14:34:49 -0500
Subject: [PATCH 208/683] Replace usage of RenderWaterReflections with
 RenderReflectionDetail.

---
 indra/newview/app_settings/high_graphics.xml  |  2 -
 indra/newview/app_settings/low_graphics.xml   |  6 +--
 indra/newview/app_settings/mid_graphics.xml   |  4 +-
 indra/newview/app_settings/settings.xml       | 11 -----
 indra/newview/app_settings/ultra_graphics.xml |  4 +-
 indra/newview/featuretable.txt                | 44 +++++++------------
 indra/newview/llfloaterpreference.cpp         |  4 +-
 indra/newview/pipeline.cpp                    | 13 +++---
 .../xui/en/panel_preferences_graphics1.xml    |  2 +-
 9 files changed, 31 insertions(+), 59 deletions(-)

diff --git a/indra/newview/app_settings/high_graphics.xml b/indra/newview/app_settings/high_graphics.xml
index 6368f7099e7..c3fa2ab75ea 100644
--- a/indra/newview/app_settings/high_graphics.xml
+++ b/indra/newview/app_settings/high_graphics.xml
@@ -31,8 +31,6 @@
 	<!--Default for now-->
 	<RenderVolumeLODFactor value="1.125"/>
 	<!--NO SHADERS-->
-	<RenderWaterReflections value="FALSE"/>
-	<!--NO SHADERS-->
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index d02a13a6713..cff5bb0dfe2 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -4,8 +4,6 @@
 	<RenderAvatarCloth value="FALSE"/>
 	<!--Default for now-->
 	<RenderAvatarLODFactor value="0.5"/>
-  <!--Default for now-->
-  <RenderAvatarMaxVisible value="3"/>
 	<!--NO SHADERS-->
 	<RenderAvatarVP value="FALSE"/>
 	<!--Short Range-->
@@ -33,8 +31,8 @@
 	<!--Default for now-->
 	<RenderVolumeLODFactor value="1.125"/>
 	<!--NO SHADERS-->
-	<RenderWaterReflections value="FALSE"/>
-	<!--NO SHADERS-->
+  <RenderReflectionDetail value="0"/>
+  <!--NO SHADERS-->
 	<VertexShaderEnable value="FALSE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="FALSE"/>
diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml
index 12da77da400..6f919f153d0 100644
--- a/indra/newview/app_settings/mid_graphics.xml
+++ b/indra/newview/app_settings/mid_graphics.xml
@@ -31,8 +31,8 @@
 	<!--Default for now-->
 	<RenderVolumeLODFactor value="1.125"/>
 	<!--NO SHADERS-->
-	<RenderWaterReflections value="FALSE"/>
-	<!--NO SHADERS-->
+  <RenderReflectionDetail value="0"/>
+  <!--NO SHADERS-->
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="FALSE"/>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c8a6db89edc..f9de77fae8c 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7621,17 +7621,6 @@
       <key>Value</key>
       <integer>512</integer>
     </map>
-    <key>RenderWaterReflections</key>
-    <map>
-      <key>Comment</key>
-      <string>Reflect the environment in the water.</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
     <key>RotateRight</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/app_settings/ultra_graphics.xml b/indra/newview/app_settings/ultra_graphics.xml
index f16ec6c30f2..149aa320005 100644
--- a/indra/newview/app_settings/ultra_graphics.xml
+++ b/indra/newview/app_settings/ultra_graphics.xml
@@ -19,7 +19,7 @@
 	<!--bump okay-->
 	<RenderObjectBump value="TRUE"/>
 	<!--NO SHADERS-->
-	<RenderReflectionDetail value="3"/>
+	<RenderReflectionDetail value="4"/>
 	<!--Simple-->
 	<RenderTerrainDetail value="1"/>
 	<!--Default for now-->
@@ -31,8 +31,6 @@
 	<!--Default for now-->
 	<RenderVolumeLODFactor value="2.0"/>
 	<!--NO SHADERS-->
-	<RenderWaterReflections value="TRUE"/>
-	<!--NO SHADERS-->
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index ccdb109d95d..7f13240e601 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -1,4 +1,4 @@
-version 22
+version 21
 
 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences
 // Should be combined into one table
@@ -23,10 +23,9 @@ version 22
 // NOTE: All settings are set to the MIN of applied values, including 'all'!
 //
 list all
-RenderAnisotropic			1	0
+RenderAnisotropic			1	1
 RenderAvatarCloth			1	1
 RenderAvatarLODFactor		1	1.0
-RenderAvatarMaxVisible      1   12
 RenderAvatarVP				1	1
 RenderCubeMap				1	1
 RenderDelayVBUpdate			1	0
@@ -40,14 +39,13 @@ RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderNightBrightness		1	1.0
 RenderObjectBump			1	1
-RenderReflectionDetail		1	3
+RenderReflectionDetail		1	4
 RenderTerrainDetail			1	1
 RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	1.0
 RenderUseImpostors			1	1
 RenderVBOEnable				1	1
 RenderVolumeLODFactor		1	2.0
-RenderWaterReflections		1	1
 UseStartScreen				1	1
 UseOcclusion				1	1
 VertexShaderEnable			1	1
@@ -57,9 +55,6 @@ Disregard128DefaultDrawDistance	1	1
 Disregard96DefaultDrawDistance	1	1
 RenderTextureMemoryMultiple		1	1.0
 RenderShaderLightingMaxLevel	1	3
-SkyUseClassicClouds			1	1
-WatchdogDisabled				1	1
-RenderUseStreamVBO			1	1
 
 
 //
@@ -68,26 +63,23 @@ RenderUseStreamVBO			1	1
 list Low
 RenderAnisotropic			1	0
 RenderAvatarCloth			1	0
-RenderAvatarLODFactor		1	0
-RenderAvatarMaxVisible      1   3
+RenderAvatarLODFactor		1	0.5
 RenderAvatarVP				1	0
 RenderFarClip				1	64
-RenderFlexTimeFactor		1	0
+RenderFlexTimeFactor		1	0.5
 RenderGlowResolutionPow		1	8
 RenderLightingDetail		1	0
-RenderMaxPartCount			1	0
+RenderMaxPartCount			1	1024
 RenderObjectBump			1	0
 RenderReflectionDetail		1	0
 RenderTerrainDetail			1	0
 RenderTerrainLODFactor		1	1
-RenderTreeLODFactor			1	0
+RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
-RenderVolumeLODFactor		1	0
-RenderWaterReflections		1	0
+RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	0
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
-SkyUseClassicClouds			1	0
 
 //
 // Mid Graphics Settings
@@ -109,7 +101,6 @@ RenderTerrainLODFactor		1	1.0
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
@@ -134,7 +125,6 @@ RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
@@ -153,13 +143,12 @@ RenderGlowResolutionPow		1	9
 RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderObjectBump			1	1
-RenderReflectionDetail		1	3
+RenderReflectionDetail		1	4
 RenderTerrainDetail			1	1
 RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	1.0
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	2.0
-RenderWaterReflections		1	1
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
@@ -200,7 +189,7 @@ RenderVBOEnable				1	1
 list NoPixelShaders
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
 
@@ -210,7 +199,7 @@ WindLightUseAtmosShaders	0	0
 list NoVertexShaders
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
 
@@ -226,7 +215,7 @@ RenderMaxPartCount			1	1024
 RenderTerrainDetail 		1	0
 RenderUseImpostors			0	0
 RenderVBOEnable				1	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 WindLightUseAtmosShaders	0	0
 
 //
@@ -302,23 +291,28 @@ RenderUseImpostors			0	0
 list Intel_945GM			
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	0
+RenderUseImpostors			0	0
 
 list Intel_945G
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	0
+RenderUseImpostors			0	0
 
 list Intel_950
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	0
+RenderUseImpostors			0	0
 
 list Intel_965
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	0
 UseOcclusion				0	0
+RenderUseImpostors			0	0
 
 list Intel_G33
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	0
+RenderUseImpostors			0	0
 
 list Intel_G45
 WindLightUseAtmosShaders		0	0
@@ -432,10 +426,6 @@ list ATIOldDriver
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
 
-// ATI cards generally perform better when not using VBOs for streaming data
-
-list ATI
-RenderUseStreamVBO			1	0
 
 /// Tweaked NVIDIA
 
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 60ce16aafb3..281bfca188a 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -866,7 +866,7 @@ void LLFloaterPreference::refreshEnabledState()
 
 void LLFloaterPreference::disableUnavailableSettings()
 {	
-	LLCheckBoxCtrl* ctrl_reflections   = getChild<LLCheckBoxCtrl>("Reflections");
+	LLComboBox* ctrl_reflections   = getChild<LLComboBox>("Reflections");
 	LLCheckBoxCtrl* ctrl_avatar_vp     = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
 	LLCheckBoxCtrl* ctrl_avatar_cloth  = getChild<LLCheckBoxCtrl>("AvatarCloth");
 	LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
@@ -900,7 +900,7 @@ void LLFloaterPreference::disableUnavailableSettings()
 	}
 	
 	// disabled reflections
-	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderWaterReflections"))
+	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
 	{
 		ctrl_reflections->setEnabled(FALSE);
 		ctrl_reflections->setValue(FALSE);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 674f2fe58ca..8b9f33e88e8 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -7238,17 +7238,16 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 									  (1<<LLPipeline::RENDER_TYPE_SKY) |
 									  (1<<LLPipeline::RENDER_TYPE_CLOUDS));	
 
-				if (gSavedSettings.getBOOL("RenderWaterReflections"))
+				S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
+				if (detail > 0)
 				{ //mask out selected geometry based on reflection detail
-
-					S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
-					if (detail < 3)
+					if (detail < 4)
 					{
 						mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_PARTICLES);
-						if (detail < 2)
+						if (detail < 3)
 						{
 							mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_AVATAR);
-							if (detail < 1)
+							if (detail < 2)
 							{
 								mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_VOLUME);
 							}
@@ -7268,7 +7267,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 			if (LLDrawPoolWater::sNeedsDistortionUpdate)
 			{
 				mRenderTypeMask = ref_mask;
-				if (gSavedSettings.getBOOL("RenderWaterReflections"))
+				if (gSavedSettings.getS32("RenderReflectionDetail") > 0)
 				{
 					gPipeline.grabReferences(ref_result);
 					LLGLUserClipPlane clip_plane(plane, mat, projection);
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 8d43adb5453..96083bd5fa8 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -251,7 +251,7 @@
       layout="topleft"
       left_="10"
       top_pad ="0" 
-      name="ReflectionDetailRadio"
+      name="Reflections"
       width="150">
         <combo_box.item
         label="None"
-- 
GitLab


From 16b5db66419fdad8a8f958fd4e542c96429965ae Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 14:34:49 -0500
Subject: [PATCH 209/683] Replace usage of RenderWaterReflections with
 RenderReflectionDetail.

---
 indra/newview/app_settings/high_graphics.xml    |  2 --
 indra/newview/app_settings/low_graphics.xml     |  4 ++--
 indra/newview/app_settings/mid_graphics.xml     |  4 ++--
 indra/newview/app_settings/settings.xml         | 11 -----------
 indra/newview/app_settings/ultra_graphics.xml   |  4 +---
 indra/newview/featuretable.txt                  | 17 ++++++-----------
 indra/newview/llfloaterpreference.cpp           |  4 ++--
 indra/newview/pipeline.cpp                      | 13 ++++++-------
 .../xui/en/panel_preferences_graphics1.xml      |  2 +-
 9 files changed, 20 insertions(+), 41 deletions(-)

diff --git a/indra/newview/app_settings/high_graphics.xml b/indra/newview/app_settings/high_graphics.xml
index 6368f7099e7..c3fa2ab75ea 100644
--- a/indra/newview/app_settings/high_graphics.xml
+++ b/indra/newview/app_settings/high_graphics.xml
@@ -31,8 +31,6 @@
 	<!--Default for now-->
 	<RenderVolumeLODFactor value="1.125"/>
 	<!--NO SHADERS-->
-	<RenderWaterReflections value="FALSE"/>
-	<!--NO SHADERS-->
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index 3f67a70d7ac..cff5bb0dfe2 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -31,8 +31,8 @@
 	<!--Default for now-->
 	<RenderVolumeLODFactor value="1.125"/>
 	<!--NO SHADERS-->
-	<RenderWaterReflections value="FALSE"/>
-	<!--NO SHADERS-->
+  <RenderReflectionDetail value="0"/>
+  <!--NO SHADERS-->
 	<VertexShaderEnable value="FALSE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="FALSE"/>
diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml
index 12da77da400..6f919f153d0 100644
--- a/indra/newview/app_settings/mid_graphics.xml
+++ b/indra/newview/app_settings/mid_graphics.xml
@@ -31,8 +31,8 @@
 	<!--Default for now-->
 	<RenderVolumeLODFactor value="1.125"/>
 	<!--NO SHADERS-->
-	<RenderWaterReflections value="FALSE"/>
-	<!--NO SHADERS-->
+  <RenderReflectionDetail value="0"/>
+  <!--NO SHADERS-->
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="FALSE"/>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 38d0df9a174..900ae6259e5 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7610,17 +7610,6 @@
       <key>Value</key>
       <integer>512</integer>
     </map>
-    <key>RenderWaterReflections</key>
-    <map>
-      <key>Comment</key>
-      <string>Reflect the environment in the water.</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
     <key>RotateRight</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/app_settings/ultra_graphics.xml b/indra/newview/app_settings/ultra_graphics.xml
index f16ec6c30f2..149aa320005 100644
--- a/indra/newview/app_settings/ultra_graphics.xml
+++ b/indra/newview/app_settings/ultra_graphics.xml
@@ -19,7 +19,7 @@
 	<!--bump okay-->
 	<RenderObjectBump value="TRUE"/>
 	<!--NO SHADERS-->
-	<RenderReflectionDetail value="3"/>
+	<RenderReflectionDetail value="4"/>
 	<!--Simple-->
 	<RenderTerrainDetail value="1"/>
 	<!--Default for now-->
@@ -31,8 +31,6 @@
 	<!--Default for now-->
 	<RenderVolumeLODFactor value="2.0"/>
 	<!--NO SHADERS-->
-	<RenderWaterReflections value="TRUE"/>
-	<!--NO SHADERS-->
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 4029bf95a0d..7f13240e601 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -23,7 +23,7 @@ version 21
 // NOTE: All settings are set to the MIN of applied values, including 'all'!
 //
 list all
-RenderAnisotropic			1	0
+RenderAnisotropic			1	1
 RenderAvatarCloth			1	1
 RenderAvatarLODFactor		1	1.0
 RenderAvatarVP				1	1
@@ -39,14 +39,13 @@ RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderNightBrightness		1	1.0
 RenderObjectBump			1	1
-RenderReflectionDetail		1	3
+RenderReflectionDetail		1	4
 RenderTerrainDetail			1	1
 RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	1.0
 RenderUseImpostors			1	1
 RenderVBOEnable				1	1
 RenderVolumeLODFactor		1	2.0
-RenderWaterReflections		1	1
 UseStartScreen				1	1
 UseOcclusion				1	1
 VertexShaderEnable			1	1
@@ -78,7 +77,6 @@ RenderTerrainLODFactor		1	1
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	0
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
@@ -103,7 +101,6 @@ RenderTerrainLODFactor		1	1.0
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
@@ -128,7 +125,6 @@ RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
@@ -147,13 +143,12 @@ RenderGlowResolutionPow		1	9
 RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderObjectBump			1	1
-RenderReflectionDetail		1	3
+RenderReflectionDetail		1	4
 RenderTerrainDetail			1	1
 RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	1.0
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	2.0
-RenderWaterReflections		1	1
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
@@ -194,7 +189,7 @@ RenderVBOEnable				1	1
 list NoPixelShaders
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
 
@@ -204,7 +199,7 @@ WindLightUseAtmosShaders	0	0
 list NoVertexShaders
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
 
@@ -220,7 +215,7 @@ RenderMaxPartCount			1	1024
 RenderTerrainDetail 		1	0
 RenderUseImpostors			0	0
 RenderVBOEnable				1	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 WindLightUseAtmosShaders	0	0
 
 //
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 8bffe9bf57a..f19683304f1 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -884,7 +884,7 @@ void LLFloaterPreference::refreshEnabledState()
 
 void LLFloaterPreference::disableUnavailableSettings()
 {	
-	LLCheckBoxCtrl* ctrl_reflections   = getChild<LLCheckBoxCtrl>("Reflections");
+	LLComboBox* ctrl_reflections   = getChild<LLComboBox>("Reflections");
 	LLCheckBoxCtrl* ctrl_avatar_vp     = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
 	LLCheckBoxCtrl* ctrl_avatar_cloth  = getChild<LLCheckBoxCtrl>("AvatarCloth");
 	LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
@@ -918,7 +918,7 @@ void LLFloaterPreference::disableUnavailableSettings()
 	}
 	
 	// disabled reflections
-	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderWaterReflections"))
+	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
 	{
 		ctrl_reflections->setEnabled(FALSE);
 		ctrl_reflections->setValue(FALSE);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index ee5ed32a830..e61dff139eb 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -7313,17 +7313,16 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 									  (1<<LLPipeline::RENDER_TYPE_SKY) |
 									  (1<<LLPipeline::RENDER_TYPE_CLOUDS));	
 
-				if (gSavedSettings.getBOOL("RenderWaterReflections"))
+				S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
+				if (detail > 0)
 				{ //mask out selected geometry based on reflection detail
-
-					S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
-					if (detail < 3)
+					if (detail < 4)
 					{
 						mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_PARTICLES);
-						if (detail < 2)
+						if (detail < 3)
 						{
 							mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_AVATAR);
-							if (detail < 1)
+							if (detail < 2)
 							{
 								mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_VOLUME);
 							}
@@ -7343,7 +7342,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 			if (LLDrawPoolWater::sNeedsDistortionUpdate)
 			{
 				mRenderTypeMask = ref_mask;
-				if (gSavedSettings.getBOOL("RenderWaterReflections"))
+				if (gSavedSettings.getS32("RenderReflectionDetail") > 0)
 				{
 					gPipeline.grabReferences(ref_result);
 					LLGLUserClipPlane clip_plane(plane, mat, projection);
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 3a37486e861..e38ad01ff98 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -278,7 +278,7 @@
       layout="topleft"
       left_="10"
       top_pad ="0" 
-      name="ReflectionDetailRadio"
+      name="Reflections"
       width="150">
         <combo_box.item
         label="None"
-- 
GitLab


From 1dc978cad714c7e2acd2661a4b2c3c714e53c904 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 15:25:04 -0500
Subject: [PATCH 210/683] Cleanup of RenderReflectionDetail getting duplicated
 in low/mid_graphics.xml

---
 indra/newview/app_settings/low_graphics.xml | 76 ++++++++++-----------
 indra/newview/app_settings/mid_graphics.xml | 76 ++++++++++-----------
 2 files changed, 74 insertions(+), 78 deletions(-)

diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index cff5bb0dfe2..72cbb2808b2 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -1,39 +1,37 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<settings version = "101">
-	<!--NO SHADERS-->
-	<RenderAvatarCloth value="FALSE"/>
-	<!--Default for now-->
-	<RenderAvatarLODFactor value="0.5"/>
-	<!--NO SHADERS-->
-	<RenderAvatarVP value="FALSE"/>
-	<!--Short Range-->
-	<RenderFarClip value="64"/>
-	<!--Default for now-->
-	<RenderFlexTimeFactor value="0.5"/>
-	<!--256... but they don't use this-->
-	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="0"/>
-	<!--Low number-->
-	<RenderMaxPartCount value="1024"/>
-	<!--bump okay-->
-	<RenderObjectBump value="FALSE"/>
-	<!--NO SHADERS-->
-	<RenderReflectionDetail value="0"/>
-	<!--Simple-->
-	<RenderTerrainDetail value="0"/>
-	<!--Default for now-->
-	<RenderTerrainLODFactor value="1.0"/>
-	<!--Default for now-->
-	<RenderTreeLODFactor value="0.5"/>
-	<!--Try Impostors-->
-	<RenderUseImpostors value="TRUE"/>
-	<!--Default for now-->
-	<RenderVolumeLODFactor value="1.125"/>
-	<!--NO SHADERS-->
-  <RenderReflectionDetail value="0"/>
-  <!--NO SHADERS-->
-	<VertexShaderEnable value="FALSE"/>
-	<!--NO SHADERS-->
-	<WindLightUseAtmosShaders value="FALSE"/>
-</settings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings version = "101">
+	<!--NO SHADERS-->
+	<RenderAvatarCloth value="FALSE"/>
+	<!--Default for now-->
+	<RenderAvatarLODFactor value="0.5"/>
+	<!--NO SHADERS-->
+	<RenderAvatarVP value="FALSE"/>
+	<!--Short Range-->
+	<RenderFarClip value="64"/>
+	<!--Default for now-->
+	<RenderFlexTimeFactor value="0.5"/>
+	<!--256... but they don't use this-->
+	<RenderGlowResolutionPow value="8"/>
+	<!--Sun/Moon only-->
+	<RenderLightingDetail value="0"/>
+	<!--Low number-->
+	<RenderMaxPartCount value="1024"/>
+	<!--bump okay-->
+	<RenderObjectBump value="FALSE"/>
+	<!--NO SHADERS-->
+	<RenderReflectionDetail value="0"/>
+	<!--Simple-->
+	<RenderTerrainDetail value="0"/>
+	<!--Default for now-->
+	<RenderTerrainLODFactor value="1.0"/>
+	<!--Default for now-->
+	<RenderTreeLODFactor value="0.5"/>
+	<!--Try Impostors-->
+	<RenderUseImpostors value="TRUE"/>
+	<!--Default for now-->
+	<RenderVolumeLODFactor value="1.125"/>
+	<!--NO SHADERS-->
+	<VertexShaderEnable value="FALSE"/>
+	<!--NO SHADERS-->
+	<WindLightUseAtmosShaders value="FALSE"/>
+</settings>
diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml
index 6f919f153d0..743dfa418ce 100644
--- a/indra/newview/app_settings/mid_graphics.xml
+++ b/indra/newview/app_settings/mid_graphics.xml
@@ -1,39 +1,37 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<settings version = "101">
-	<!--NO SHADERS-->
-	<RenderAvatarCloth value="FALSE"/>
-	<!--Default for now-->
-	<RenderAvatarLODFactor value="0.5"/>
-	<!--NO SHADERS-->
-	<RenderAvatarVP value="TRUE"/>
-	<!--Short Range-->
-	<RenderFarClip value="96"/>
-	<!--Default for now-->
-	<RenderFlexTimeFactor value="1"/>
-	<!--256... but they don't use this-->
-	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
-	<!--Low number-->
-	<RenderMaxPartCount value="2048"/>
-	<!--bump okay-->
-	<RenderObjectBump value="TRUE"/>
-	<!--NO SHADERS-->
-	<RenderReflectionDetail value="0"/>
-	<!--Simple-->
-	<RenderTerrainDetail value="1"/>
-	<!--Default for now-->
-	<RenderTerrainLODFactor value="1.0"/>
-	<!--Default for now-->
-	<RenderTreeLODFactor value="0.5"/>
-	<!--Try Impostors-->
-	<RenderUseImpostors value="TRUE"/>
-	<!--Default for now-->
-	<RenderVolumeLODFactor value="1.125"/>
-	<!--NO SHADERS-->
-  <RenderReflectionDetail value="0"/>
-  <!--NO SHADERS-->
-	<VertexShaderEnable value="TRUE"/>
-	<!--NO SHADERS-->
-	<WindLightUseAtmosShaders value="FALSE"/>
-</settings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings version = "101">
+	<!--NO SHADERS-->
+	<RenderAvatarCloth value="FALSE"/>
+	<!--Default for now-->
+	<RenderAvatarLODFactor value="0.5"/>
+	<!--NO SHADERS-->
+	<RenderAvatarVP value="TRUE"/>
+	<!--Short Range-->
+	<RenderFarClip value="96"/>
+	<!--Default for now-->
+	<RenderFlexTimeFactor value="1"/>
+	<!--256... but they don't use this-->
+	<RenderGlowResolutionPow value="8"/>
+	<!--Sun/Moon only-->
+	<RenderLightingDetail value="1"/>
+	<!--Low number-->
+	<RenderMaxPartCount value="2048"/>
+	<!--bump okay-->
+	<RenderObjectBump value="TRUE"/>
+	<!--NO SHADERS-->
+	<RenderReflectionDetail value="0"/>
+	<!--Simple-->
+	<RenderTerrainDetail value="1"/>
+	<!--Default for now-->
+	<RenderTerrainLODFactor value="1.0"/>
+	<!--Default for now-->
+	<RenderTreeLODFactor value="0.5"/>
+	<!--Try Impostors-->
+	<RenderUseImpostors value="TRUE"/>
+	<!--Default for now-->
+	<RenderVolumeLODFactor value="1.125"/>
+	<!--NO SHADERS-->
+	<VertexShaderEnable value="TRUE"/>
+	<!--NO SHADERS-->
+	<WindLightUseAtmosShaders value="FALSE"/>
+</settings>
-- 
GitLab


From 964d9953c6bc77749fc1083d32daf494232e1a65 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 15:25:04 -0500
Subject: [PATCH 211/683] Cleanup of RenderReflectionDetail getting duplicated
 in low/mid_graphics.xml

---
 indra/newview/app_settings/low_graphics.xml | 76 ++++++++++-----------
 indra/newview/app_settings/mid_graphics.xml | 76 ++++++++++-----------
 2 files changed, 74 insertions(+), 78 deletions(-)

diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index cff5bb0dfe2..72cbb2808b2 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -1,39 +1,37 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<settings version = "101">
-	<!--NO SHADERS-->
-	<RenderAvatarCloth value="FALSE"/>
-	<!--Default for now-->
-	<RenderAvatarLODFactor value="0.5"/>
-	<!--NO SHADERS-->
-	<RenderAvatarVP value="FALSE"/>
-	<!--Short Range-->
-	<RenderFarClip value="64"/>
-	<!--Default for now-->
-	<RenderFlexTimeFactor value="0.5"/>
-	<!--256... but they don't use this-->
-	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="0"/>
-	<!--Low number-->
-	<RenderMaxPartCount value="1024"/>
-	<!--bump okay-->
-	<RenderObjectBump value="FALSE"/>
-	<!--NO SHADERS-->
-	<RenderReflectionDetail value="0"/>
-	<!--Simple-->
-	<RenderTerrainDetail value="0"/>
-	<!--Default for now-->
-	<RenderTerrainLODFactor value="1.0"/>
-	<!--Default for now-->
-	<RenderTreeLODFactor value="0.5"/>
-	<!--Try Impostors-->
-	<RenderUseImpostors value="TRUE"/>
-	<!--Default for now-->
-	<RenderVolumeLODFactor value="1.125"/>
-	<!--NO SHADERS-->
-  <RenderReflectionDetail value="0"/>
-  <!--NO SHADERS-->
-	<VertexShaderEnable value="FALSE"/>
-	<!--NO SHADERS-->
-	<WindLightUseAtmosShaders value="FALSE"/>
-</settings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings version = "101">
+	<!--NO SHADERS-->
+	<RenderAvatarCloth value="FALSE"/>
+	<!--Default for now-->
+	<RenderAvatarLODFactor value="0.5"/>
+	<!--NO SHADERS-->
+	<RenderAvatarVP value="FALSE"/>
+	<!--Short Range-->
+	<RenderFarClip value="64"/>
+	<!--Default for now-->
+	<RenderFlexTimeFactor value="0.5"/>
+	<!--256... but they don't use this-->
+	<RenderGlowResolutionPow value="8"/>
+	<!--Sun/Moon only-->
+	<RenderLightingDetail value="0"/>
+	<!--Low number-->
+	<RenderMaxPartCount value="1024"/>
+	<!--bump okay-->
+	<RenderObjectBump value="FALSE"/>
+	<!--NO SHADERS-->
+	<RenderReflectionDetail value="0"/>
+	<!--Simple-->
+	<RenderTerrainDetail value="0"/>
+	<!--Default for now-->
+	<RenderTerrainLODFactor value="1.0"/>
+	<!--Default for now-->
+	<RenderTreeLODFactor value="0.5"/>
+	<!--Try Impostors-->
+	<RenderUseImpostors value="TRUE"/>
+	<!--Default for now-->
+	<RenderVolumeLODFactor value="1.125"/>
+	<!--NO SHADERS-->
+	<VertexShaderEnable value="FALSE"/>
+	<!--NO SHADERS-->
+	<WindLightUseAtmosShaders value="FALSE"/>
+</settings>
diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml
index 6f919f153d0..743dfa418ce 100644
--- a/indra/newview/app_settings/mid_graphics.xml
+++ b/indra/newview/app_settings/mid_graphics.xml
@@ -1,39 +1,37 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<settings version = "101">
-	<!--NO SHADERS-->
-	<RenderAvatarCloth value="FALSE"/>
-	<!--Default for now-->
-	<RenderAvatarLODFactor value="0.5"/>
-	<!--NO SHADERS-->
-	<RenderAvatarVP value="TRUE"/>
-	<!--Short Range-->
-	<RenderFarClip value="96"/>
-	<!--Default for now-->
-	<RenderFlexTimeFactor value="1"/>
-	<!--256... but they don't use this-->
-	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
-	<!--Low number-->
-	<RenderMaxPartCount value="2048"/>
-	<!--bump okay-->
-	<RenderObjectBump value="TRUE"/>
-	<!--NO SHADERS-->
-	<RenderReflectionDetail value="0"/>
-	<!--Simple-->
-	<RenderTerrainDetail value="1"/>
-	<!--Default for now-->
-	<RenderTerrainLODFactor value="1.0"/>
-	<!--Default for now-->
-	<RenderTreeLODFactor value="0.5"/>
-	<!--Try Impostors-->
-	<RenderUseImpostors value="TRUE"/>
-	<!--Default for now-->
-	<RenderVolumeLODFactor value="1.125"/>
-	<!--NO SHADERS-->
-  <RenderReflectionDetail value="0"/>
-  <!--NO SHADERS-->
-	<VertexShaderEnable value="TRUE"/>
-	<!--NO SHADERS-->
-	<WindLightUseAtmosShaders value="FALSE"/>
-</settings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings version = "101">
+	<!--NO SHADERS-->
+	<RenderAvatarCloth value="FALSE"/>
+	<!--Default for now-->
+	<RenderAvatarLODFactor value="0.5"/>
+	<!--NO SHADERS-->
+	<RenderAvatarVP value="TRUE"/>
+	<!--Short Range-->
+	<RenderFarClip value="96"/>
+	<!--Default for now-->
+	<RenderFlexTimeFactor value="1"/>
+	<!--256... but they don't use this-->
+	<RenderGlowResolutionPow value="8"/>
+	<!--Sun/Moon only-->
+	<RenderLightingDetail value="1"/>
+	<!--Low number-->
+	<RenderMaxPartCount value="2048"/>
+	<!--bump okay-->
+	<RenderObjectBump value="TRUE"/>
+	<!--NO SHADERS-->
+	<RenderReflectionDetail value="0"/>
+	<!--Simple-->
+	<RenderTerrainDetail value="1"/>
+	<!--Default for now-->
+	<RenderTerrainLODFactor value="1.0"/>
+	<!--Default for now-->
+	<RenderTreeLODFactor value="0.5"/>
+	<!--Try Impostors-->
+	<RenderUseImpostors value="TRUE"/>
+	<!--Default for now-->
+	<RenderVolumeLODFactor value="1.125"/>
+	<!--NO SHADERS-->
+	<VertexShaderEnable value="TRUE"/>
+	<!--NO SHADERS-->
+	<WindLightUseAtmosShaders value="FALSE"/>
+</settings>
-- 
GitLab


From 38205c1efbac48ce6ee220087b981ba9cbfd4484 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 15:25:35 -0500
Subject: [PATCH 212/683] Replace RenderDeferredShadow/RenderDeferredSunShadow
 with RenderShadowDetail

---
 indra/newview/app_settings/settings.xml |  26 +--
 indra/newview/llviewercontrol.cpp       |   2 +-
 indra/newview/llviewershadermgr.cpp     |  38 ++--
 indra/newview/pipeline.cpp              | 237 ++++++++++++------------
 4 files changed, 143 insertions(+), 160 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index f9de77fae8c..9c1d710551b 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6618,19 +6618,7 @@
     <key>Value</key>
     <integer>0</integer>
   </map>
-
-  <key>RenderDeferredShadow</key>
-  <map>
-    <key>Comment</key>
-    <string>Enable shadows in deferred renderer.</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>Boolean</string>
-    <key>Value</key>
-    <integer>1</integer>
-  </map>
-
+  
   <key>RenderDeferredGI</key>
   <map>
     <key>Comment</key>
@@ -6643,18 +6631,6 @@
     <integer>0</integer>
   </map>
 
-  <key>RenderDeferredSunShadow</key>
-  <map>
-    <key>Comment</key>
-    <string>Generate shadows from the sun.</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>Boolean</string>
-    <key>Value</key>
-    <integer>1</integer>
-  </map>
-
   <key>RenderDeferredSun</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 51a1ae901e9..d071baf72c8 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -551,7 +551,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderDebugPipeline")->getSignal()->connect(boost::bind(&handleRenderDebugPipelineChanged, _2));
 	gSavedSettings.getControl("RenderResolutionDivisor")->getSignal()->connect(boost::bind(&handleRenderResolutionDivisorChanged, _2));
 	gSavedSettings.getControl("RenderDeferred")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
-	gSavedSettings.getControl("RenderDeferredShadow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
+	gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderDeferredGI")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("TextureMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2));
 	gSavedSettings.getControl("AuditTexture")->getSignal()->connect(boost::bind(&handleAuditTextureChanged, _2));
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 4c2ea272537..5b7b464e910 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -2,25 +2,31 @@
  * @file llviewershadermgr.cpp
  * @brief Viewer shader manager implementation.
  *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2005&license=viewergpl$
+ * 
+ * Copyright (c) 2005-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -372,7 +378,7 @@ void LLViewerShaderMgr::setShaders()
 
 		if (LLPipeline::sRenderDeferred)
 		{
-			if (gSavedSettings.getBOOL("RenderDeferredShadow"))
+			if (gSavedSettings.getS32("RenderShadowDetail") > 0)
 			{
 				if (gSavedSettings.getBOOL("RenderDeferredGI"))
 				{ //shadows + gi
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 8b9f33e88e8..e378fb4d080 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6268,7 +6268,7 @@ void LLPipeline::renderDeferredLighting()
 			glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0);
 		}
 
-		if (gSavedSettings.getBOOL("RenderDeferredShadow"))
+		if (gSavedSettings.getS32("RenderShadowDetail") > 0)
 		{
 			glPushMatrix();
 			glLoadIdentity();
@@ -7905,30 +7905,11 @@ void LLPipeline::generateHighlight(LLCamera& camera)
 
 void LLPipeline::generateSunShadow(LLCamera& camera)
 {
-	if (!sRenderDeferred || !gSavedSettings.getBOOL("RenderDeferredShadow"))
+	if (!sRenderDeferred || gSavedSettings.getS32("RenderShadowDetail") <= 0)
 	{
 		return;
 	}
 
-	//temporary hack to disable shadows but keep local lights
-	static BOOL clear = TRUE;
-	BOOL gen_shadow = gSavedSettings.getBOOL("RenderDeferredSunShadow");
-	if (!gen_shadow)
-	{
-		if (clear)
-		{
-			clear = FALSE;
-			for (U32 i = 0; i < 6; i++)
-			{
-				mShadow[i].bindTarget();
-				mShadow[i].clear();
-				mShadow[i].flush();
-			}
-		}
-		return;
-	}
-	clear = TRUE;
-
 	F64 last_modelview[16];
 	F64 last_projection[16];
 	for (U32 i = 0; i < 16; i++)
@@ -8444,135 +8425,155 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		}
 	}
 
-	
-
-	F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
 
-	//update shadow targets
-	for (U32 i = 0; i < 2; i++)
-	{ //for each current shadow
-		LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i;
+	//hack to disable projector shadows 
+	static bool clear = true;
+	bool gen_shadow = gSavedSettings.getS32("RenderShadowDetail") > 1;
+	
+	if (gen_shadow)
+	{
+		clear = true;
+		F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
 
-		if (mShadowSpotLight[i].notNull() && 
-			(mShadowSpotLight[i] == mTargetShadowSpotLight[0] ||
-			mShadowSpotLight[i] == mTargetShadowSpotLight[1]))
-		{ //keep this spotlight
-			mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f);
-		}
-		else
-		{ //fade out this light
-			mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f);
-			
-			if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull())
-			{ //faded out, grab one of the pending spots (whichever one isn't already taken)
-				if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2])
-				{
-					mShadowSpotLight[i] = mTargetShadowSpotLight[0];
-				}
-				else
-				{
-					mShadowSpotLight[i] = mTargetShadowSpotLight[1];
+		//update shadow targets
+		for (U32 i = 0; i < 2; i++)
+		{ //for each current shadow
+			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i;
+
+			if (mShadowSpotLight[i].notNull() && 
+				(mShadowSpotLight[i] == mTargetShadowSpotLight[0] ||
+				mShadowSpotLight[i] == mTargetShadowSpotLight[1]))
+			{ //keep this spotlight
+				mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f);
+			}
+			else
+			{ //fade out this light
+				mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f);
+				
+				if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull())
+				{ //faded out, grab one of the pending spots (whichever one isn't already taken)
+					if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2])
+					{
+						mShadowSpotLight[i] = mTargetShadowSpotLight[0];
+					}
+					else
+					{
+						mShadowSpotLight[i] = mTargetShadowSpotLight[1];
+					}
 				}
 			}
 		}
-	}
-
-	for (S32 i = 0; i < 2; i++)
-	{
-		glh_set_current_modelview(saved_view);
-		glh_set_current_projection(saved_proj);
-
-		if (mShadowSpotLight[i].isNull())
+		
+		for (S32 i = 0; i < 2; i++)
 		{
-			continue;
-		}
+			glh_set_current_modelview(saved_view);
+			glh_set_current_projection(saved_proj);
 
-		LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume();
+			if (mShadowSpotLight[i].isNull())
+			{
+				continue;
+			}
 
-		if (!volume)
-		{
-			mShadowSpotLight[i] = NULL;
-			continue;
-		}
+			LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume();
 
-		LLDrawable* drawable = mShadowSpotLight[i];
+			if (!volume)
+			{
+				mShadowSpotLight[i] = NULL;
+				continue;
+			}
 
-		LLVector3 params = volume->getSpotLightParams();
-		F32 fov = params.mV[0];
+			LLDrawable* drawable = mShadowSpotLight[i];
 
-		//get agent->light space matrix (modelview)
-		LLVector3 center = drawable->getPositionAgent();
-		LLQuaternion quat = volume->getRenderRotation();
+			LLVector3 params = volume->getSpotLightParams();
+			F32 fov = params.mV[0];
 
-		//get near clip plane
-		LLVector3 scale = volume->getScale();
-		LLVector3 at_axis(0,0,-scale.mV[2]*0.5f);
-		at_axis *= quat;
+			//get agent->light space matrix (modelview)
+			LLVector3 center = drawable->getPositionAgent();
+			LLQuaternion quat = volume->getRenderRotation();
 
-		LLVector3 np = center+at_axis;
-		at_axis.normVec();
+			//get near clip plane
+			LLVector3 scale = volume->getScale();
+			LLVector3 at_axis(0,0,-scale.mV[2]*0.5f);
+			at_axis *= quat;
 
-		//get origin that has given fov for plane np, at_axis, and given scale
-		F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f);
+			LLVector3 np = center+at_axis;
+			at_axis.normVec();
 
-		LLVector3 origin = np - at_axis*dist;
+			//get origin that has given fov for plane np, at_axis, and given scale
+			F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f);
 
-		LLMatrix4 mat(quat, LLVector4(origin, 1.f));
+			LLVector3 origin = np - at_axis*dist;
 
-		view[i+4] = glh::matrix4f((F32*) mat.mMatrix);
+			LLMatrix4 mat(quat, LLVector4(origin, 1.f));
 
-		view[i+4] = view[i+4].inverse();
+			view[i+4] = glh::matrix4f((F32*) mat.mMatrix);
 
-		//get perspective matrix
-		F32 near_clip = dist+0.01f;
-		F32 width = scale.mV[VX];
-		F32 height = scale.mV[VY];
-		F32 far_clip = dist+volume->getLightRadius()*1.5f;
+			view[i+4] = view[i+4].inverse();
 
-		F32 fovy = fov * RAD_TO_DEG;
-		F32 aspect = width/height;
-		
-		proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip);
+			//get perspective matrix
+			F32 near_clip = dist+0.01f;
+			F32 width = scale.mV[VX];
+			F32 height = scale.mV[VY];
+			F32 far_clip = dist+volume->getLightRadius()*1.5f;
 
-		//translate and scale to from [-1, 1] to [0, 1]
-		glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f,
-						0.f, 0.5f, 0.f, 0.5f,
-						0.f, 0.f, 0.5f, 0.5f,
-						0.f, 0.f, 0.f, 1.f);
+			F32 fovy = fov * RAD_TO_DEG;
+			F32 aspect = width/height;
+			
+			proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip);
 
-		glh_set_current_modelview(view[i+4]);
-		glh_set_current_projection(proj[i+4]);
+			//translate and scale to from [-1, 1] to [0, 1]
+			glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f,
+							0.f, 0.5f, 0.f, 0.5f,
+							0.f, 0.f, 0.5f, 0.5f,
+							0.f, 0.f, 0.f, 1.f);
 
-		mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view;
-		
-		for (U32 j = 0; j < 16; j++)
-		{
-			gGLLastModelView[j] = mShadowModelview[i+4].m[j];
-			gGLLastProjection[j] = mShadowProjection[i+4].m[j];
-		}
+			glh_set_current_modelview(view[i+4]);
+			glh_set_current_projection(proj[i+4]);
 
-		mShadowModelview[i+4] = view[i+4];
-		mShadowProjection[i+4] = proj[i+4];
+			mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view;
+			
+			for (U32 j = 0; j < 16; j++)
+			{
+				gGLLastModelView[j] = mShadowModelview[i+4].m[j];
+				gGLLastProjection[j] = mShadowProjection[i+4].m[j];
+			}
 
-		LLCamera shadow_cam = camera;
-		shadow_cam.setFar(far_clip);
-		shadow_cam.setOrigin(origin);
+			mShadowModelview[i+4] = view[i+4];
+			mShadowProjection[i+4] = proj[i+4];
 
-		LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
+			LLCamera shadow_cam = camera;
+			shadow_cam.setFar(far_clip);
+			shadow_cam.setOrigin(origin);
 
-		stop_glerror();
+			LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
+
+			stop_glerror();
 
-		mShadow[i+4].bindTarget();
-		mShadow[i+4].getViewport(gGLViewport);
+			mShadow[i+4].bindTarget();
+			mShadow[i+4].getViewport(gGLViewport);
 
-		static LLCullResult result[2];
+			static LLCullResult result[2];
 
-		LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4;
+			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4;
 
-		renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE);
+			renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE);
 
-		mShadow[i+4].flush();
- 	}
+			mShadow[i+4].flush();
+ 		}
+	}
+	else
+	{
+		if (clear)
+		{
+			clear = false;
+			for (U32 i = 4; i < 6; i++)
+			{
+				mShadow[i].bindTarget();
+				mShadow[i].clear();
+				mShadow[i].flush();
+			}
+		}
+	}
 
 	if (!gSavedSettings.getBOOL("CameraOffset"))
 	{
-- 
GitLab


From d4699a1b0e922258682d9b6e164a5bcc6bbd7238 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 15:25:35 -0500
Subject: [PATCH 213/683] Replace RenderDeferredShadow/RenderDeferredSunShadow
 with RenderShadowDetail

---
 indra/newview/app_settings/settings.xml |  26 +--
 indra/newview/llviewercontrol.cpp       |   2 +-
 indra/newview/llviewershadermgr.cpp     |   2 +-
 indra/newview/pipeline.cpp              | 237 ++++++++++++------------
 4 files changed, 122 insertions(+), 145 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 900ae6259e5..68d759019d6 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6596,19 +6596,7 @@
     <key>Value</key>
     <integer>0</integer>
   </map>
-
-  <key>RenderDeferredShadow</key>
-  <map>
-    <key>Comment</key>
-    <string>Enable shadows in deferred renderer.</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>Boolean</string>
-    <key>Value</key>
-    <integer>1</integer>
-  </map>
-
+  
   <key>RenderDeferredGI</key>
   <map>
     <key>Comment</key>
@@ -6621,18 +6609,6 @@
     <integer>0</integer>
   </map>
 
-  <key>RenderDeferredSunShadow</key>
-  <map>
-    <key>Comment</key>
-    <string>Generate shadows from the sun.</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>Boolean</string>
-    <key>Value</key>
-    <integer>1</integer>
-  </map>
-
   <key>RenderDeferredSun</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 1d99be9960e..8051fcbcfa1 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -546,7 +546,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderDebugPipeline")->getSignal()->connect(boost::bind(&handleRenderDebugPipelineChanged, _2));
 	gSavedSettings.getControl("RenderResolutionDivisor")->getSignal()->connect(boost::bind(&handleRenderResolutionDivisorChanged, _2));
 	gSavedSettings.getControl("RenderDeferred")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
-	gSavedSettings.getControl("RenderDeferredShadow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
+	gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderDeferredGI")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("TextureMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2));
 	gSavedSettings.getControl("AuditTexture")->getSignal()->connect(boost::bind(&handleAuditTextureChanged, _2));
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 86b1a8c9100..5b7b464e910 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -378,7 +378,7 @@ void LLViewerShaderMgr::setShaders()
 
 		if (LLPipeline::sRenderDeferred)
 		{
-			if (gSavedSettings.getBOOL("RenderDeferredShadow"))
+			if (gSavedSettings.getS32("RenderShadowDetail") > 0)
 			{
 				if (gSavedSettings.getBOOL("RenderDeferredGI"))
 				{ //shadows + gi
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e61dff139eb..04118ad767f 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6344,7 +6344,7 @@ void LLPipeline::renderDeferredLighting()
 			glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0);
 		}
 
-		if (gSavedSettings.getBOOL("RenderDeferredShadow"))
+		if (gSavedSettings.getS32("RenderShadowDetail") > 0)
 		{
 			glPushMatrix();
 			glLoadIdentity();
@@ -7980,30 +7980,11 @@ void LLPipeline::generateHighlight(LLCamera& camera)
 
 void LLPipeline::generateSunShadow(LLCamera& camera)
 {
-	if (!sRenderDeferred || !gSavedSettings.getBOOL("RenderDeferredShadow"))
+	if (!sRenderDeferred || gSavedSettings.getS32("RenderShadowDetail") <= 0)
 	{
 		return;
 	}
 
-	//temporary hack to disable shadows but keep local lights
-	static BOOL clear = TRUE;
-	BOOL gen_shadow = gSavedSettings.getBOOL("RenderDeferredSunShadow");
-	if (!gen_shadow)
-	{
-		if (clear)
-		{
-			clear = FALSE;
-			for (U32 i = 0; i < 6; i++)
-			{
-				mShadow[i].bindTarget();
-				mShadow[i].clear();
-				mShadow[i].flush();
-			}
-		}
-		return;
-	}
-	clear = TRUE;
-
 	F64 last_modelview[16];
 	F64 last_projection[16];
 	for (U32 i = 0; i < 16; i++)
@@ -8519,135 +8500,155 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		}
 	}
 
-	
-
-	F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
 
-	//update shadow targets
-	for (U32 i = 0; i < 2; i++)
-	{ //for each current shadow
-		LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i;
+	//hack to disable projector shadows 
+	static bool clear = true;
+	bool gen_shadow = gSavedSettings.getS32("RenderShadowDetail") > 1;
+	
+	if (gen_shadow)
+	{
+		clear = true;
+		F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
 
-		if (mShadowSpotLight[i].notNull() && 
-			(mShadowSpotLight[i] == mTargetShadowSpotLight[0] ||
-			mShadowSpotLight[i] == mTargetShadowSpotLight[1]))
-		{ //keep this spotlight
-			mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f);
-		}
-		else
-		{ //fade out this light
-			mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f);
-			
-			if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull())
-			{ //faded out, grab one of the pending spots (whichever one isn't already taken)
-				if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2])
-				{
-					mShadowSpotLight[i] = mTargetShadowSpotLight[0];
-				}
-				else
-				{
-					mShadowSpotLight[i] = mTargetShadowSpotLight[1];
+		//update shadow targets
+		for (U32 i = 0; i < 2; i++)
+		{ //for each current shadow
+			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i;
+
+			if (mShadowSpotLight[i].notNull() && 
+				(mShadowSpotLight[i] == mTargetShadowSpotLight[0] ||
+				mShadowSpotLight[i] == mTargetShadowSpotLight[1]))
+			{ //keep this spotlight
+				mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f);
+			}
+			else
+			{ //fade out this light
+				mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f);
+				
+				if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull())
+				{ //faded out, grab one of the pending spots (whichever one isn't already taken)
+					if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2])
+					{
+						mShadowSpotLight[i] = mTargetShadowSpotLight[0];
+					}
+					else
+					{
+						mShadowSpotLight[i] = mTargetShadowSpotLight[1];
+					}
 				}
 			}
 		}
-	}
-
-	for (S32 i = 0; i < 2; i++)
-	{
-		glh_set_current_modelview(saved_view);
-		glh_set_current_projection(saved_proj);
-
-		if (mShadowSpotLight[i].isNull())
+		
+		for (S32 i = 0; i < 2; i++)
 		{
-			continue;
-		}
+			glh_set_current_modelview(saved_view);
+			glh_set_current_projection(saved_proj);
 
-		LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume();
+			if (mShadowSpotLight[i].isNull())
+			{
+				continue;
+			}
 
-		if (!volume)
-		{
-			mShadowSpotLight[i] = NULL;
-			continue;
-		}
+			LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume();
 
-		LLDrawable* drawable = mShadowSpotLight[i];
+			if (!volume)
+			{
+				mShadowSpotLight[i] = NULL;
+				continue;
+			}
 
-		LLVector3 params = volume->getSpotLightParams();
-		F32 fov = params.mV[0];
+			LLDrawable* drawable = mShadowSpotLight[i];
 
-		//get agent->light space matrix (modelview)
-		LLVector3 center = drawable->getPositionAgent();
-		LLQuaternion quat = volume->getRenderRotation();
+			LLVector3 params = volume->getSpotLightParams();
+			F32 fov = params.mV[0];
 
-		//get near clip plane
-		LLVector3 scale = volume->getScale();
-		LLVector3 at_axis(0,0,-scale.mV[2]*0.5f);
-		at_axis *= quat;
+			//get agent->light space matrix (modelview)
+			LLVector3 center = drawable->getPositionAgent();
+			LLQuaternion quat = volume->getRenderRotation();
 
-		LLVector3 np = center+at_axis;
-		at_axis.normVec();
+			//get near clip plane
+			LLVector3 scale = volume->getScale();
+			LLVector3 at_axis(0,0,-scale.mV[2]*0.5f);
+			at_axis *= quat;
 
-		//get origin that has given fov for plane np, at_axis, and given scale
-		F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f);
+			LLVector3 np = center+at_axis;
+			at_axis.normVec();
 
-		LLVector3 origin = np - at_axis*dist;
+			//get origin that has given fov for plane np, at_axis, and given scale
+			F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f);
 
-		LLMatrix4 mat(quat, LLVector4(origin, 1.f));
+			LLVector3 origin = np - at_axis*dist;
 
-		view[i+4] = glh::matrix4f((F32*) mat.mMatrix);
+			LLMatrix4 mat(quat, LLVector4(origin, 1.f));
 
-		view[i+4] = view[i+4].inverse();
+			view[i+4] = glh::matrix4f((F32*) mat.mMatrix);
 
-		//get perspective matrix
-		F32 near_clip = dist+0.01f;
-		F32 width = scale.mV[VX];
-		F32 height = scale.mV[VY];
-		F32 far_clip = dist+volume->getLightRadius()*1.5f;
+			view[i+4] = view[i+4].inverse();
 
-		F32 fovy = fov * RAD_TO_DEG;
-		F32 aspect = width/height;
-		
-		proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip);
+			//get perspective matrix
+			F32 near_clip = dist+0.01f;
+			F32 width = scale.mV[VX];
+			F32 height = scale.mV[VY];
+			F32 far_clip = dist+volume->getLightRadius()*1.5f;
 
-		//translate and scale to from [-1, 1] to [0, 1]
-		glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f,
-						0.f, 0.5f, 0.f, 0.5f,
-						0.f, 0.f, 0.5f, 0.5f,
-						0.f, 0.f, 0.f, 1.f);
+			F32 fovy = fov * RAD_TO_DEG;
+			F32 aspect = width/height;
+			
+			proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip);
 
-		glh_set_current_modelview(view[i+4]);
-		glh_set_current_projection(proj[i+4]);
+			//translate and scale to from [-1, 1] to [0, 1]
+			glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f,
+							0.f, 0.5f, 0.f, 0.5f,
+							0.f, 0.f, 0.5f, 0.5f,
+							0.f, 0.f, 0.f, 1.f);
 
-		mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view;
-		
-		for (U32 j = 0; j < 16; j++)
-		{
-			gGLLastModelView[j] = mShadowModelview[i+4].m[j];
-			gGLLastProjection[j] = mShadowProjection[i+4].m[j];
-		}
+			glh_set_current_modelview(view[i+4]);
+			glh_set_current_projection(proj[i+4]);
 
-		mShadowModelview[i+4] = view[i+4];
-		mShadowProjection[i+4] = proj[i+4];
+			mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view;
+			
+			for (U32 j = 0; j < 16; j++)
+			{
+				gGLLastModelView[j] = mShadowModelview[i+4].m[j];
+				gGLLastProjection[j] = mShadowProjection[i+4].m[j];
+			}
 
-		LLCamera shadow_cam = camera;
-		shadow_cam.setFar(far_clip);
-		shadow_cam.setOrigin(origin);
+			mShadowModelview[i+4] = view[i+4];
+			mShadowProjection[i+4] = proj[i+4];
 
-		LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
+			LLCamera shadow_cam = camera;
+			shadow_cam.setFar(far_clip);
+			shadow_cam.setOrigin(origin);
 
-		stop_glerror();
+			LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
+
+			stop_glerror();
 
-		mShadow[i+4].bindTarget();
-		mShadow[i+4].getViewport(gGLViewport);
+			mShadow[i+4].bindTarget();
+			mShadow[i+4].getViewport(gGLViewport);
 
-		static LLCullResult result[2];
+			static LLCullResult result[2];
 
-		LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4;
+			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4;
 
-		renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE);
+			renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE);
 
-		mShadow[i+4].flush();
- 	}
+			mShadow[i+4].flush();
+ 		}
+	}
+	else
+	{
+		if (clear)
+		{
+			clear = false;
+			for (U32 i = 4; i < 6; i++)
+			{
+				mShadow[i].bindTarget();
+				mShadow[i].clear();
+				mShadow[i].flush();
+			}
+		}
+	}
 
 	if (!gSavedSettings.getBOOL("CameraOffset"))
 	{
-- 
GitLab


From 3793360167fc118e21ba28074ad2feac42093de4 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 18:14:17 -0500
Subject: [PATCH 214/683] RenderDeferredSSAO works as an independent setting --
 decoupled shadows from SSAO.

---
 .../shaders/class1/deferred/blurLightF.glsl   |  20 +-
 .../class1/deferred/multiSpotLightF.glsl      |   3 +-
 .../shaders/class1/deferred/softenLightF.glsl |  27 ++-
 .../shaders/class1/deferred/spotLightF.glsl   |  11 -
 .../shaders/class1/deferred/sunLightF.glsl    | 201 +-----------------
 .../class2/deferred/multiSpotLightF.glsl      |   3 -
 .../shaders/class2/deferred/softenLightF.glsl |  10 +-
 .../shaders/class2/deferred/spotLightF.glsl   |   4 -
 .../shaders/class2/deferred/sunLightF.glsl    |  64 +-----
 indra/newview/llviewercontrol.cpp             |   1 +
 indra/newview/llviewershadermgr.cpp           |  14 +-
 indra/newview/pipeline.cpp                    | 156 +++++++-------
 12 files changed, 138 insertions(+), 376 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index bd5e9dd7580..0fad5b4b50b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -10,13 +10,11 @@
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform sampler2DRect lightMap;
-uniform sampler2DRect giLightMap;
 
 uniform float dist_factor;
 uniform float blur_size;
 uniform vec2 delta;
-uniform vec3 kern[32];
-uniform int kern_length;
+uniform vec3 kern[4];
 uniform float kern_scale;
 
 varying vec2 vary_fragcoord;
@@ -50,7 +48,7 @@ void main()
 	vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
 	vec4 col = defined_weight.xyxx * ccol;
 	
-	for (int i = 1; i < kern_length; i++)
+	for (int i = 1; i < 4; i++)
 	{
 		vec2 tc = vary_fragcoord.xy + kern[i].z*dlt;
 	        vec3 samppos = getPosition(tc).xyz; 
@@ -61,12 +59,22 @@ void main()
 			defined_weight += kern[i].xy;
 		}
 	}
+	for (int i = 1; i < 4; i++)
+	{
+		vec2 tc = vary_fragcoord.xy - kern[i].z*dlt;
+	        vec3 samppos = getPosition(tc).xyz; 
+		float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
+		if (d*d <= 0.003)
+		{
+			col += texture2DRect(lightMap, tc)*kern[i].xyxx;
+			defined_weight += kern[i].xy;
+		}
+	}
 
 
 
 	col /= defined_weight.xyxx;
 	
 	gl_FragColor = col;
-	
-	//gl_FragColor = ccol;
 }
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 2c8d90d1a6e..82e9450e684 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -7,6 +7,8 @@
 
 #version 120
 
+//class 1 -- no shadows
+
 #extension GL_ARB_texture_rectangle : enable
 
 uniform sampler2DRect diffuseRect;
@@ -14,7 +16,6 @@ uniform sampler2DRect specularRect;
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform samplerCube environmentMap;
-uniform sampler2DRect lightMap;
 uniform sampler2D noiseMap;
 uniform sampler2D lightFunc;
 uniform sampler2D projectionMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index b4b0d0ce9de..9cf60aad489 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -11,6 +11,7 @@ uniform sampler2DRect diffuseRect;
 uniform sampler2DRect specularRect;
 uniform sampler2DRect positionMap;
 uniform sampler2DRect normalMap;
+uniform sampler2DRect lightMap;
 uniform sampler2DRect depthMap;
 uniform sampler2D	  noiseMap;
 uniform samplerCube environmentMap;
@@ -40,7 +41,7 @@ uniform float scene_light_strength;
 uniform vec3 env_mat[3];
 //uniform mat4 shadow_matrix[3];
 //uniform vec4 shadow_clip;
-//uniform mat3 ssao_effect_mat;
+uniform mat3 ssao_effect_mat;
 
 varying vec4 vary_light;
 varying vec2 vary_fragcoord;
@@ -178,7 +179,17 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
 	temp2.x += .25;
 	
 	//increase ambient when there are more clouds
-	vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;	
+	vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;
+	
+	/*  decrease value and saturation (that in HSV, not HSL) for occluded areas
+	 * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html
+	 * // The following line of code performs the equivalent of:
+	 * float ambAlpha = tmpAmbient.a;
+	 * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis
+	 * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue);
+	 * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha);
+	 */
+	tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
 
 	//haze color
 	setAdditiveColor(
@@ -250,10 +261,14 @@ void main()
 	vec4 diffuse = texture2DRect(diffuseRect, tc);
 	vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
 	
-	calcAtmospherics(pos.xyz, 0.0);
+	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
+	float scol = max(scol_ambocc.r, diffuse.a); 
+	float ambocc = scol_ambocc.g;
+	
+	calcAtmospherics(pos.xyz, ambocc);
 	
 	vec3 col = atmosAmbient(vec3(0));
-	col += atmosAffectDirectionalLight(clamp(da, diffuse.a, 1.0));
+	col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a));
 	
 	col *= diffuse.rgb;
 	
@@ -261,12 +276,12 @@ void main()
 	{
 		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
 	}
 	
 	col = atmosLighting(col);
 	col = scaleSoftClip(col);
-	
+		
 	gl_FragColor.rgb = col;
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 2a7234fd83b..f320dbb4001 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -161,17 +161,6 @@ void main()
 		}
 	}
 	
-	/*if (spec.a > 0.0)
-	{
-		//vec3 ref = reflect(normalize(pos), norm);
-		float sa = dot(normalize(lv-normalize(pos)),norm);;
-		//sa = max(sa, 0.0);
-		//sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
-		sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
-		sa *= noise;
-		col += da*sa*lcol*spec.rgb;
-	}*/
-	
 	gl_FragColor.rgb = col;	
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
index fafc2ae3cc0..56e4055c02c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -5,206 +5,11 @@
  * $License$
  */
 
-#extension GL_ARB_texture_rectangle : enable
-
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRectShadow shadowMap0;
-uniform sampler2DRectShadow shadowMap1;
-uniform sampler2DRectShadow shadowMap2;
-uniform sampler2DRectShadow shadowMap3;
-uniform sampler2DRectShadow shadowMap4;
-uniform sampler2DRectShadow shadowMap5;
-uniform sampler2D noiseMap;
-
-uniform sampler2D		lightFunc;
-
-
-// Inputs
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
-uniform float ssao_radius;
-uniform float ssao_max_radius;
-uniform float ssao_factor;
-uniform float ssao_factor_inv;
-
-varying vec2 vary_fragcoord;
-varying vec4 vary_light;
-
-uniform mat4 inv_proj;
-uniform vec2 screen_res;
-
-uniform float shadow_bias;
-uniform float shadow_offset;
-
-vec4 getPosition(vec2 pos_screen)
-{
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
-	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
-	sc -= vec2(1.0,1.0);
-	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
-	vec4 pos = inv_proj * ndc;
-	pos /= pos.w;
-	pos.w = 1.0;
-	return pos;
-}
+//class 1, no shadow, no SSAO, should never be called
 
-//calculate decreases in ambient lighting when crowded out (SSAO)
-float calcAmbientOcclusion(vec4 pos, vec3 norm)
-{
-	float ret = 1.0;
-	
-	float dist = dot(pos.xyz,pos.xyz);
-	
-	if (dist < 64.0*64.0)
-	{
-		vec2 kern[8];
-		// exponentially (^2) distant occlusion samples spread around origin
-		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
-		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
-		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
-		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
-		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
-		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
-		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
-		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
-		vec2 pos_screen = vary_fragcoord.xy;
-		vec3 pos_world = pos.xyz;
-		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-		
-		float angle_hidden = 0.0;
-		int points = 0;
-		
-		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-		
-		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
-		for (int i = 0; i < 8; i++)
-		{
-			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
-			vec3 samppos_world = getPosition(samppos_screen).xyz; 
-			
-			vec3 diff = pos_world - samppos_world;
-			float dist2 = dot(diff, diff);
-			
-			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
-			// --> solid angle shrinking by the square of distance
-			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
-			//(k should vary inversely with # of samples, but this is taken care of later)
-			
-			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
-			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
-			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
-			
-			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
-			points = points + int(diff.z > -1.0);
-		}
-		
-		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-		
-		ret = (1.0 - (float(points != 0) * angle_hidden));
-		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
-	}
-	
-	return min(ret, 1.0);
-}
+#extension GL_ARB_texture_rectangle : enable
 
 void main() 
 {
-	vec2 pos_screen = vary_fragcoord.xy;
-	
-	//try doing an unproject here
-	
-	vec4 pos = getPosition(pos_screen);
-	
-    vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
-	
-	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
-	{
-		gl_FragColor = vec4(0.0); // doesn't matter
-		return;
-	}*/
-	
-	float shadow = 1.0;
-    float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
-
-	vec4 spos = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0);
-	
-	//vec3 debug = vec3(0,0,0);
-	
-	if (dp_directional_light == 0.0)
-	{
-		// if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup
-		shadow = 0.0;
-	}
-	else if (spos.z > -shadow_clip.w)
-	{	
-		vec4 lpos;
-		
-		if (spos.z < -shadow_clip.z)
-		{
-			lpos = shadow_matrix[3]*spos;
-			lpos.xy *= screen_res;
-			shadow = shadow2DRectProj(shadowMap3, lpos).x;
-			shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
-		}
-		else if (spos.z < -shadow_clip.y)
-		{
-			lpos = shadow_matrix[2]*spos;
-			lpos.xy *= screen_res;
-			shadow = shadow2DRectProj(shadowMap2, lpos).x;
-		}
-		else if (spos.z < -shadow_clip.x)
-		{
-			lpos = shadow_matrix[1]*spos;
-			lpos.xy *= screen_res;
-			shadow = shadow2DRectProj(shadowMap1, lpos).x;
-		}
-		else
-		{
-			lpos = shadow_matrix[0]*spos;
-			lpos.xy *= screen_res;
-			shadow = shadow2DRectProj(shadowMap0, lpos).x;
-		}
-
-		// take the most-shadowed value out of these two:
-		//  * the blurred sun shadow in the light (shadow) map
-		//  * an unblurred dot product between the sun and this norm
-		// the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting
-		shadow = min(shadow, dp_directional_light);
-		
-		/*debug.r = lpos.y / (lpos.w*screen_res.y);
-		
-		lpos.xy /= lpos.w*32.0;
-		if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1)
-		{
-			debug.gb = vec2(0.5, 0.5);
-		}
-		
-		debug += (1.0-shadow)*0.5;*/
-		
-	}
-	else
-	{
-		// more distant than the shadow map covers - just use directional shading as shadow
-		shadow = dp_directional_light;
-	}
-	
-	gl_FragColor[0] = shadow;
-	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
-	
-	//spotlight shadow 1
-	vec4 lpos = shadow_matrix[4]*spos;
-	lpos.xy *= screen_res;
-	gl_FragColor[2] = shadow2DRectProj(shadowMap4, lpos).x; 
-	
-	//spotlight shadow 2
-	lpos = shadow_matrix[5]*spos;
-	lpos.xy *= screen_res;
-	gl_FragColor[3] = shadow2DRectProj(shadowMap5, lpos).x; 
-
-	//gl_FragColor.rgb = pos.xyz;
-	//gl_FragColor.b = shadow;
-	//gl_FragColor.rgb = debug;
+	gl_FragColor = vec4(0,0,0,0);
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 3e29c684e8b..5308e5bb1e1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -230,9 +230,6 @@ void main()
 		}
 	}
 	
-	//attenuate point light contribution by SSAO component
-	col *= texture2DRect(lightMap, frag.xy).g;
-	
 	gl_FragColor.rgb = col;	
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 249ac7ef9b9..589a2927515 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -11,6 +11,7 @@ uniform sampler2DRect diffuseRect;
 uniform sampler2DRect specularRect;
 uniform sampler2DRect normalMap;
 uniform sampler2DRect lightMap;
+uniform sampler2DRect depthMap;
 uniform sampler2D	  noiseMap;
 uniform samplerCube environmentMap;
 uniform sampler2D	  lightFunc;
@@ -41,7 +42,6 @@ uniform vec3 env_mat[3];
 uniform vec4 shadow_clip;
 uniform mat3 ssao_effect_mat;
 
-uniform sampler2DRect depthMap;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
@@ -282,13 +282,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	
-	//gl_FragColor.rgb = gi_col.rgb;
 	gl_FragColor.a = 0.0;
-	
-	//gl_FragColor.rg = scol_ambocc.rg;
-	//gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb;
-	//gl_FragColor.rgb = norm.rgb*0.5+0.5;
-	//gl_FragColor.rgb = vec3(ambocc);
-	//gl_FragColor.rgb = vec3(scol);
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 6617e33c0d8..eeaecc157ff 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -179,10 +179,6 @@ void main()
 		}
 	}
 	
-	//attenuate point light contribution by SSAO component
-	col *= texture2DRect(lightMap, frag.xy).g;
-	
-
 	gl_FragColor.rgb = col;	
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 50502dbdadc..04c9a4d19aa 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -7,6 +7,8 @@
 
 #extension GL_ARB_texture_rectangle : enable
 
+//class 2, shadows, no SSAO
+
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform sampler2DRectShadow shadowMap0;
@@ -52,66 +54,6 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
-//calculate decreases in ambient lighting when crowded out (SSAO)
-float calcAmbientOcclusion(vec4 pos, vec3 norm)
-{
-	float ret = 1.0;
-	
-	float dist = dot(pos.xyz,pos.xyz);
-	
-	if (dist < 64.0*64.0)
-	{
-		vec2 kern[8];
-		// exponentially (^2) distant occlusion samples spread around origin
-		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
-		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
-		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
-		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
-		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
-		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
-		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
-		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
-		vec2 pos_screen = vary_fragcoord.xy;
-		vec3 pos_world = pos.xyz;
-		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-		
-		float angle_hidden = 0.0;
-		int points = 0;
-		
-		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-		
-		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
-		for (int i = 0; i < 8; i++)
-		{
-			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
-			vec3 samppos_world = getPosition(samppos_screen).xyz; 
-			
-			vec3 diff = pos_world - samppos_world;
-			float dist2 = dot(diff, diff);
-			
-			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
-			// --> solid angle shrinking by the square of distance
-			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
-			//(k should vary inversely with # of samples, but this is taken care of later)
-			
-			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
-			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
-			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
-			
-			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
-			points = points + int(diff.z > -1.0);
-		}
-		
-		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-		
-		ret = (1.0 - (float(points != 0) * angle_hidden));
-		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
-	}
-	
-	return min(ret, 1.0);
-}
-
 float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 {
 	stc.xyz /= stc.w;
@@ -232,7 +174,7 @@ void main()
 	}
 	
 	gl_FragColor[0] = shadow;
-	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
+	gl_FragColor[1] = 1.0;
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index d071baf72c8..b773b959177 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -552,6 +552,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderResolutionDivisor")->getSignal()->connect(boost::bind(&handleRenderResolutionDivisorChanged, _2));
 	gSavedSettings.getControl("RenderDeferred")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
+	gSavedSettings.getControl("RenderDeferredSSAO")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderDeferredGI")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("TextureMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2));
 	gSavedSettings.getControl("AuditTexture")->getSignal()->connect(boost::bind(&handleAuditTextureChanged, _2));
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 5b7b464e910..50e55221749 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -973,10 +973,22 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 
 	if (success)
 	{
+		S32 level = 0;
+		std::string fragment;
+
+		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
+		{
+			fragment = "deferred/sunLightSSAOF.glsl";
+		}
+		else
+		{
+			fragment = "deferred/sunLightF.glsl";
+		}
+
 		gDeferredSunProgram.mName = "Deferred Sun Shader";
 		gDeferredSunProgram.mShaderFiles.clear();
 		gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
 		gDeferredSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 		success = gDeferredSunProgram.createShader(NULL, NULL);
 	}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e378fb4d080..fc81241080f 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6268,16 +6268,16 @@ void LLPipeline::renderDeferredLighting()
 			glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0);
 		}
 
-		if (gSavedSettings.getS32("RenderShadowDetail") > 0)
-		{
-			glPushMatrix();
-			glLoadIdentity();
-			glMatrixMode(GL_PROJECTION);
-			glPushMatrix();
-			glLoadIdentity();
+		glPushMatrix();
+		glLoadIdentity();
+		glMatrixMode(GL_PROJECTION);
+		glPushMatrix();
+		glLoadIdentity();
 
-			mDeferredLight[0].bindTarget();
-			if (gSavedSettings.getBOOL("RenderDeferredSun"))
+		mDeferredLight[0].bindTarget();
+
+		if (gSavedSettings.getBOOL("RenderDeferredSSAO") || gSavedSettings.getS32("RenderShadowDetail") > 0)
+		{
 			{ //paint shadow/SSAO light map (direct lighting lightmap)
 				LLFastTimer ftm(FTM_SUN_SHADOW);
 				bindDeferredShader(gDeferredSunProgram, 0);
@@ -6318,18 +6318,22 @@ void LLPipeline::renderDeferredLighting()
 				
 				unbindDeferredShader(gDeferredSunProgram);
 			}
-			else
-			{
-				mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT);
-			}
+		}
+		else
+		{
+			glClearColor(1,1,1,1);
+			mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT);
+			glClearColor(0,0,0,0);
+		}
 
-			mDeferredLight[0].flush();
+		mDeferredLight[0].flush();
 
+		{ //global illumination specific block (still experimental)
 			if (gSavedSettings.getBOOL("RenderDeferredBlurLight") &&
-			    gSavedSettings.getBOOL("RenderDeferredGI"))
-			{
+				gSavedSettings.getBOOL("RenderDeferredGI"))
+			{ 
 				LLFastTimer ftm(FTM_EDGE_DETECTION);
-				//get edge map
+				//generate edge map
 				LLGLDisable blend(GL_BLEND);
 				LLGLDisable test(GL_ALPHA_TEST);
 				LLGLDepthTest depth(GL_FALSE);
@@ -6426,79 +6430,79 @@ void LLPipeline::renderDeferredLighting()
 					unbindDeferredShader(gDeferredPostGIProgram);
 				}
 			}
+		}
 
-			if (gSavedSettings.getBOOL("RenderDeferredBlurLight"))
-			{ //soften direct lighting lightmap
-				LLFastTimer ftm(FTM_SOFTEN_SHADOW);
-				//blur lightmap
-				mDeferredLight[1].bindTarget();
+		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
+		{ //soften direct lighting lightmap
+			LLFastTimer ftm(FTM_SOFTEN_SHADOW);
+			//blur lightmap
+			mDeferredLight[1].bindTarget();
 
-				glClearColor(1,1,1,1);
-				mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
-				glClearColor(0,0,0,0);
-				
-				bindDeferredShader(gDeferredBlurLightProgram);
+			glClearColor(1,1,1,1);
+			mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
+			glClearColor(0,0,0,0);
+			
+			bindDeferredShader(gDeferredBlurLightProgram);
 
-				LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian");
-				const U32 kern_length = 4;
-				F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize");
-				F32 dist_factor = gSavedSettings.getF32("RenderShadowBlurDistFactor");
+			LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian");
+			const U32 kern_length = 4;
+			F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize");
+			F32 dist_factor = gSavedSettings.getF32("RenderShadowBlurDistFactor");
 
-				// sample symmetrically with the middle sample falling exactly on 0.0
-				F32 x = 0.f;
+			// sample symmetrically with the middle sample falling exactly on 0.0
+			F32 x = 0.f;
 
-				LLVector3 gauss[32]; // xweight, yweight, offset
+			LLVector3 gauss[32]; // xweight, yweight, offset
 
-				for (U32 i = 0; i < kern_length; i++)
-				{
-					gauss[i].mV[0] = llgaussian(x, go.mV[0]);
-					gauss[i].mV[1] = llgaussian(x, go.mV[1]);
-					gauss[i].mV[2] = x;
-					x += 1.f;
-				}
+			for (U32 i = 0; i < kern_length; i++)
+			{
+				gauss[i].mV[0] = llgaussian(x, go.mV[0]);
+				gauss[i].mV[1] = llgaussian(x, go.mV[1]);
+				gauss[i].mV[2] = x;
+				x += 1.f;
+			}
 
-				gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f);
-				gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor);
-				gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV);
-				gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV);
-				gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f));
+			gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f);
+			gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor);
+			gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV);
+			gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV);
+			gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f));
+		
+			{
+				LLGLDisable blend(GL_BLEND);
+				LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+				stop_glerror();
+				glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+				stop_glerror();
+			}
 			
-				{
-					LLGLDisable blend(GL_BLEND);
-					LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-					stop_glerror();
-					glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
-					stop_glerror();
-				}
-				
-				mDeferredLight[1].flush();
-				unbindDeferredShader(gDeferredBlurLightProgram);
+			mDeferredLight[1].flush();
+			unbindDeferredShader(gDeferredBlurLightProgram);
 
-				bindDeferredShader(gDeferredBlurLightProgram, 1);
-				mDeferredLight[0].bindTarget();
+			bindDeferredShader(gDeferredBlurLightProgram, 1);
+			mDeferredLight[0].bindTarget();
 
-				gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f);
+			gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f);
 
-				{
-					LLGLDisable blend(GL_BLEND);
-					LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-					stop_glerror();
-					glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
-					stop_glerror();
-				}
-				mDeferredLight[0].flush();
-				unbindDeferredShader(gDeferredBlurLightProgram);
+			{
+				LLGLDisable blend(GL_BLEND);
+				LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+				stop_glerror();
+				glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+				stop_glerror();
 			}
-
-			stop_glerror();
-			glPopMatrix();
-			stop_glerror();
-			glMatrixMode(GL_MODELVIEW);
-			stop_glerror();
-			glPopMatrix();
-			stop_glerror();
+			mDeferredLight[0].flush();
+			unbindDeferredShader(gDeferredBlurLightProgram);
 		}
 
+		stop_glerror();
+		glPopMatrix();
+		stop_glerror();
+		glMatrixMode(GL_MODELVIEW);
+		stop_glerror();
+		glPopMatrix();
+		stop_glerror();
+
 		//copy depth and stencil from deferred screen
 		//mScreen.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(),
 		//					0, 0, mScreen.getWidth(), mScreen.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
-- 
GitLab


From bbfacbd50d6e8beac36fd8de1dc51ceb109a4a7d Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 18:14:17 -0500
Subject: [PATCH 215/683] RenderDeferredSSAO works as an independent setting --
 decoupled shadows from SSAO.

---
 .../shaders/class1/deferred/blurLightF.glsl   |  20 +-
 .../class1/deferred/multiSpotLightF.glsl      |   3 +-
 .../shaders/class1/deferred/softenLightF.glsl |  27 ++-
 .../shaders/class1/deferred/spotLightF.glsl   |  11 -
 .../shaders/class1/deferred/sunLightF.glsl    | 201 +-----------------
 .../class2/deferred/multiSpotLightF.glsl      |   3 -
 .../shaders/class2/deferred/softenLightF.glsl |  10 +-
 .../shaders/class2/deferred/spotLightF.glsl   |   4 -
 .../shaders/class2/deferred/sunLightF.glsl    |  64 +-----
 indra/newview/llviewercontrol.cpp             |   1 +
 indra/newview/llviewershadermgr.cpp           |  14 +-
 indra/newview/pipeline.cpp                    | 156 +++++++-------
 12 files changed, 138 insertions(+), 376 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index bd5e9dd7580..0fad5b4b50b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -10,13 +10,11 @@
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform sampler2DRect lightMap;
-uniform sampler2DRect giLightMap;
 
 uniform float dist_factor;
 uniform float blur_size;
 uniform vec2 delta;
-uniform vec3 kern[32];
-uniform int kern_length;
+uniform vec3 kern[4];
 uniform float kern_scale;
 
 varying vec2 vary_fragcoord;
@@ -50,7 +48,7 @@ void main()
 	vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
 	vec4 col = defined_weight.xyxx * ccol;
 	
-	for (int i = 1; i < kern_length; i++)
+	for (int i = 1; i < 4; i++)
 	{
 		vec2 tc = vary_fragcoord.xy + kern[i].z*dlt;
 	        vec3 samppos = getPosition(tc).xyz; 
@@ -61,12 +59,22 @@ void main()
 			defined_weight += kern[i].xy;
 		}
 	}
+	for (int i = 1; i < 4; i++)
+	{
+		vec2 tc = vary_fragcoord.xy - kern[i].z*dlt;
+	        vec3 samppos = getPosition(tc).xyz; 
+		float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
+		if (d*d <= 0.003)
+		{
+			col += texture2DRect(lightMap, tc)*kern[i].xyxx;
+			defined_weight += kern[i].xy;
+		}
+	}
 
 
 
 	col /= defined_weight.xyxx;
 	
 	gl_FragColor = col;
-	
-	//gl_FragColor = ccol;
 }
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 2c8d90d1a6e..82e9450e684 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -7,6 +7,8 @@
 
 #version 120
 
+//class 1 -- no shadows
+
 #extension GL_ARB_texture_rectangle : enable
 
 uniform sampler2DRect diffuseRect;
@@ -14,7 +16,6 @@ uniform sampler2DRect specularRect;
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform samplerCube environmentMap;
-uniform sampler2DRect lightMap;
 uniform sampler2D noiseMap;
 uniform sampler2D lightFunc;
 uniform sampler2D projectionMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index b4b0d0ce9de..9cf60aad489 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -11,6 +11,7 @@ uniform sampler2DRect diffuseRect;
 uniform sampler2DRect specularRect;
 uniform sampler2DRect positionMap;
 uniform sampler2DRect normalMap;
+uniform sampler2DRect lightMap;
 uniform sampler2DRect depthMap;
 uniform sampler2D	  noiseMap;
 uniform samplerCube environmentMap;
@@ -40,7 +41,7 @@ uniform float scene_light_strength;
 uniform vec3 env_mat[3];
 //uniform mat4 shadow_matrix[3];
 //uniform vec4 shadow_clip;
-//uniform mat3 ssao_effect_mat;
+uniform mat3 ssao_effect_mat;
 
 varying vec4 vary_light;
 varying vec2 vary_fragcoord;
@@ -178,7 +179,17 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
 	temp2.x += .25;
 	
 	//increase ambient when there are more clouds
-	vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;	
+	vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;
+	
+	/*  decrease value and saturation (that in HSV, not HSL) for occluded areas
+	 * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html
+	 * // The following line of code performs the equivalent of:
+	 * float ambAlpha = tmpAmbient.a;
+	 * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis
+	 * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue);
+	 * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha);
+	 */
+	tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
 
 	//haze color
 	setAdditiveColor(
@@ -250,10 +261,14 @@ void main()
 	vec4 diffuse = texture2DRect(diffuseRect, tc);
 	vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
 	
-	calcAtmospherics(pos.xyz, 0.0);
+	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
+	float scol = max(scol_ambocc.r, diffuse.a); 
+	float ambocc = scol_ambocc.g;
+	
+	calcAtmospherics(pos.xyz, ambocc);
 	
 	vec3 col = atmosAmbient(vec3(0));
-	col += atmosAffectDirectionalLight(clamp(da, diffuse.a, 1.0));
+	col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a));
 	
 	col *= diffuse.rgb;
 	
@@ -261,12 +276,12 @@ void main()
 	{
 		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
 	}
 	
 	col = atmosLighting(col);
 	col = scaleSoftClip(col);
-	
+		
 	gl_FragColor.rgb = col;
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 2a7234fd83b..f320dbb4001 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -161,17 +161,6 @@ void main()
 		}
 	}
 	
-	/*if (spec.a > 0.0)
-	{
-		//vec3 ref = reflect(normalize(pos), norm);
-		float sa = dot(normalize(lv-normalize(pos)),norm);;
-		//sa = max(sa, 0.0);
-		//sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
-		sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
-		sa *= noise;
-		col += da*sa*lcol*spec.rgb;
-	}*/
-	
 	gl_FragColor.rgb = col;	
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
index fafc2ae3cc0..56e4055c02c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -5,206 +5,11 @@
  * $License$
  */
 
-#extension GL_ARB_texture_rectangle : enable
-
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRectShadow shadowMap0;
-uniform sampler2DRectShadow shadowMap1;
-uniform sampler2DRectShadow shadowMap2;
-uniform sampler2DRectShadow shadowMap3;
-uniform sampler2DRectShadow shadowMap4;
-uniform sampler2DRectShadow shadowMap5;
-uniform sampler2D noiseMap;
-
-uniform sampler2D		lightFunc;
-
-
-// Inputs
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
-uniform float ssao_radius;
-uniform float ssao_max_radius;
-uniform float ssao_factor;
-uniform float ssao_factor_inv;
-
-varying vec2 vary_fragcoord;
-varying vec4 vary_light;
-
-uniform mat4 inv_proj;
-uniform vec2 screen_res;
-
-uniform float shadow_bias;
-uniform float shadow_offset;
-
-vec4 getPosition(vec2 pos_screen)
-{
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
-	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
-	sc -= vec2(1.0,1.0);
-	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
-	vec4 pos = inv_proj * ndc;
-	pos /= pos.w;
-	pos.w = 1.0;
-	return pos;
-}
+//class 1, no shadow, no SSAO, should never be called
 
-//calculate decreases in ambient lighting when crowded out (SSAO)
-float calcAmbientOcclusion(vec4 pos, vec3 norm)
-{
-	float ret = 1.0;
-	
-	float dist = dot(pos.xyz,pos.xyz);
-	
-	if (dist < 64.0*64.0)
-	{
-		vec2 kern[8];
-		// exponentially (^2) distant occlusion samples spread around origin
-		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
-		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
-		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
-		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
-		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
-		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
-		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
-		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
-		vec2 pos_screen = vary_fragcoord.xy;
-		vec3 pos_world = pos.xyz;
-		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-		
-		float angle_hidden = 0.0;
-		int points = 0;
-		
-		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-		
-		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
-		for (int i = 0; i < 8; i++)
-		{
-			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
-			vec3 samppos_world = getPosition(samppos_screen).xyz; 
-			
-			vec3 diff = pos_world - samppos_world;
-			float dist2 = dot(diff, diff);
-			
-			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
-			// --> solid angle shrinking by the square of distance
-			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
-			//(k should vary inversely with # of samples, but this is taken care of later)
-			
-			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
-			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
-			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
-			
-			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
-			points = points + int(diff.z > -1.0);
-		}
-		
-		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-		
-		ret = (1.0 - (float(points != 0) * angle_hidden));
-		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
-	}
-	
-	return min(ret, 1.0);
-}
+#extension GL_ARB_texture_rectangle : enable
 
 void main() 
 {
-	vec2 pos_screen = vary_fragcoord.xy;
-	
-	//try doing an unproject here
-	
-	vec4 pos = getPosition(pos_screen);
-	
-    vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
-	
-	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
-	{
-		gl_FragColor = vec4(0.0); // doesn't matter
-		return;
-	}*/
-	
-	float shadow = 1.0;
-    float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
-
-	vec4 spos = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0);
-	
-	//vec3 debug = vec3(0,0,0);
-	
-	if (dp_directional_light == 0.0)
-	{
-		// if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup
-		shadow = 0.0;
-	}
-	else if (spos.z > -shadow_clip.w)
-	{	
-		vec4 lpos;
-		
-		if (spos.z < -shadow_clip.z)
-		{
-			lpos = shadow_matrix[3]*spos;
-			lpos.xy *= screen_res;
-			shadow = shadow2DRectProj(shadowMap3, lpos).x;
-			shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
-		}
-		else if (spos.z < -shadow_clip.y)
-		{
-			lpos = shadow_matrix[2]*spos;
-			lpos.xy *= screen_res;
-			shadow = shadow2DRectProj(shadowMap2, lpos).x;
-		}
-		else if (spos.z < -shadow_clip.x)
-		{
-			lpos = shadow_matrix[1]*spos;
-			lpos.xy *= screen_res;
-			shadow = shadow2DRectProj(shadowMap1, lpos).x;
-		}
-		else
-		{
-			lpos = shadow_matrix[0]*spos;
-			lpos.xy *= screen_res;
-			shadow = shadow2DRectProj(shadowMap0, lpos).x;
-		}
-
-		// take the most-shadowed value out of these two:
-		//  * the blurred sun shadow in the light (shadow) map
-		//  * an unblurred dot product between the sun and this norm
-		// the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting
-		shadow = min(shadow, dp_directional_light);
-		
-		/*debug.r = lpos.y / (lpos.w*screen_res.y);
-		
-		lpos.xy /= lpos.w*32.0;
-		if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1)
-		{
-			debug.gb = vec2(0.5, 0.5);
-		}
-		
-		debug += (1.0-shadow)*0.5;*/
-		
-	}
-	else
-	{
-		// more distant than the shadow map covers - just use directional shading as shadow
-		shadow = dp_directional_light;
-	}
-	
-	gl_FragColor[0] = shadow;
-	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
-	
-	//spotlight shadow 1
-	vec4 lpos = shadow_matrix[4]*spos;
-	lpos.xy *= screen_res;
-	gl_FragColor[2] = shadow2DRectProj(shadowMap4, lpos).x; 
-	
-	//spotlight shadow 2
-	lpos = shadow_matrix[5]*spos;
-	lpos.xy *= screen_res;
-	gl_FragColor[3] = shadow2DRectProj(shadowMap5, lpos).x; 
-
-	//gl_FragColor.rgb = pos.xyz;
-	//gl_FragColor.b = shadow;
-	//gl_FragColor.rgb = debug;
+	gl_FragColor = vec4(0,0,0,0);
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 3e29c684e8b..5308e5bb1e1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -230,9 +230,6 @@ void main()
 		}
 	}
 	
-	//attenuate point light contribution by SSAO component
-	col *= texture2DRect(lightMap, frag.xy).g;
-	
 	gl_FragColor.rgb = col;	
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 249ac7ef9b9..589a2927515 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -11,6 +11,7 @@ uniform sampler2DRect diffuseRect;
 uniform sampler2DRect specularRect;
 uniform sampler2DRect normalMap;
 uniform sampler2DRect lightMap;
+uniform sampler2DRect depthMap;
 uniform sampler2D	  noiseMap;
 uniform samplerCube environmentMap;
 uniform sampler2D	  lightFunc;
@@ -41,7 +42,6 @@ uniform vec3 env_mat[3];
 uniform vec4 shadow_clip;
 uniform mat3 ssao_effect_mat;
 
-uniform sampler2DRect depthMap;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
@@ -282,13 +282,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	
-	//gl_FragColor.rgb = gi_col.rgb;
 	gl_FragColor.a = 0.0;
-	
-	//gl_FragColor.rg = scol_ambocc.rg;
-	//gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb;
-	//gl_FragColor.rgb = norm.rgb*0.5+0.5;
-	//gl_FragColor.rgb = vec3(ambocc);
-	//gl_FragColor.rgb = vec3(scol);
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 6617e33c0d8..eeaecc157ff 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -179,10 +179,6 @@ void main()
 		}
 	}
 	
-	//attenuate point light contribution by SSAO component
-	col *= texture2DRect(lightMap, frag.xy).g;
-	
-
 	gl_FragColor.rgb = col;	
 	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 50502dbdadc..04c9a4d19aa 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -7,6 +7,8 @@
 
 #extension GL_ARB_texture_rectangle : enable
 
+//class 2, shadows, no SSAO
+
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform sampler2DRectShadow shadowMap0;
@@ -52,66 +54,6 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
-//calculate decreases in ambient lighting when crowded out (SSAO)
-float calcAmbientOcclusion(vec4 pos, vec3 norm)
-{
-	float ret = 1.0;
-	
-	float dist = dot(pos.xyz,pos.xyz);
-	
-	if (dist < 64.0*64.0)
-	{
-		vec2 kern[8];
-		// exponentially (^2) distant occlusion samples spread around origin
-		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
-		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
-		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
-		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
-		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
-		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
-		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
-		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
-
-		vec2 pos_screen = vary_fragcoord.xy;
-		vec3 pos_world = pos.xyz;
-		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
-		
-		float angle_hidden = 0.0;
-		int points = 0;
-		
-		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
-		
-		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
-		for (int i = 0; i < 8; i++)
-		{
-			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
-			vec3 samppos_world = getPosition(samppos_screen).xyz; 
-			
-			vec3 diff = pos_world - samppos_world;
-			float dist2 = dot(diff, diff);
-			
-			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
-			// --> solid angle shrinking by the square of distance
-			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
-			//(k should vary inversely with # of samples, but this is taken care of later)
-			
-			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
-			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
-			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
-			
-			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
-			points = points + int(diff.z > -1.0);
-		}
-		
-		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
-		
-		ret = (1.0 - (float(points != 0) * angle_hidden));
-		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
-	}
-	
-	return min(ret, 1.0);
-}
-
 float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 {
 	stc.xyz /= stc.w;
@@ -232,7 +174,7 @@ void main()
 	}
 	
 	gl_FragColor[0] = shadow;
-	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
+	gl_FragColor[1] = 1.0;
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 8051fcbcfa1..862e1de6851 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -547,6 +547,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderResolutionDivisor")->getSignal()->connect(boost::bind(&handleRenderResolutionDivisorChanged, _2));
 	gSavedSettings.getControl("RenderDeferred")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
+	gSavedSettings.getControl("RenderDeferredSSAO")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderDeferredGI")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("TextureMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2));
 	gSavedSettings.getControl("AuditTexture")->getSignal()->connect(boost::bind(&handleAuditTextureChanged, _2));
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 5b7b464e910..50e55221749 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -973,10 +973,22 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 
 	if (success)
 	{
+		S32 level = 0;
+		std::string fragment;
+
+		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
+		{
+			fragment = "deferred/sunLightSSAOF.glsl";
+		}
+		else
+		{
+			fragment = "deferred/sunLightF.glsl";
+		}
+
 		gDeferredSunProgram.mName = "Deferred Sun Shader";
 		gDeferredSunProgram.mShaderFiles.clear();
 		gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
 		gDeferredSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 		success = gDeferredSunProgram.createShader(NULL, NULL);
 	}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 04118ad767f..5cfd6c3d38f 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6344,16 +6344,16 @@ void LLPipeline::renderDeferredLighting()
 			glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0);
 		}
 
-		if (gSavedSettings.getS32("RenderShadowDetail") > 0)
-		{
-			glPushMatrix();
-			glLoadIdentity();
-			glMatrixMode(GL_PROJECTION);
-			glPushMatrix();
-			glLoadIdentity();
+		glPushMatrix();
+		glLoadIdentity();
+		glMatrixMode(GL_PROJECTION);
+		glPushMatrix();
+		glLoadIdentity();
 
-			mDeferredLight[0].bindTarget();
-			if (gSavedSettings.getBOOL("RenderDeferredSun"))
+		mDeferredLight[0].bindTarget();
+
+		if (gSavedSettings.getBOOL("RenderDeferredSSAO") || gSavedSettings.getS32("RenderShadowDetail") > 0)
+		{
 			{ //paint shadow/SSAO light map (direct lighting lightmap)
 				LLFastTimer ftm(FTM_SUN_SHADOW);
 				bindDeferredShader(gDeferredSunProgram, 0);
@@ -6394,18 +6394,22 @@ void LLPipeline::renderDeferredLighting()
 				
 				unbindDeferredShader(gDeferredSunProgram);
 			}
-			else
-			{
-				mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT);
-			}
+		}
+		else
+		{
+			glClearColor(1,1,1,1);
+			mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT);
+			glClearColor(0,0,0,0);
+		}
 
-			mDeferredLight[0].flush();
+		mDeferredLight[0].flush();
 
+		{ //global illumination specific block (still experimental)
 			if (gSavedSettings.getBOOL("RenderDeferredBlurLight") &&
-			    gSavedSettings.getBOOL("RenderDeferredGI"))
-			{
+				gSavedSettings.getBOOL("RenderDeferredGI"))
+			{ 
 				LLFastTimer ftm(FTM_EDGE_DETECTION);
-				//get edge map
+				//generate edge map
 				LLGLDisable blend(GL_BLEND);
 				LLGLDisable test(GL_ALPHA_TEST);
 				LLGLDepthTest depth(GL_FALSE);
@@ -6502,79 +6506,79 @@ void LLPipeline::renderDeferredLighting()
 					unbindDeferredShader(gDeferredPostGIProgram);
 				}
 			}
+		}
 
-			if (gSavedSettings.getBOOL("RenderDeferredBlurLight"))
-			{ //soften direct lighting lightmap
-				LLFastTimer ftm(FTM_SOFTEN_SHADOW);
-				//blur lightmap
-				mDeferredLight[1].bindTarget();
+		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
+		{ //soften direct lighting lightmap
+			LLFastTimer ftm(FTM_SOFTEN_SHADOW);
+			//blur lightmap
+			mDeferredLight[1].bindTarget();
 
-				glClearColor(1,1,1,1);
-				mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
-				glClearColor(0,0,0,0);
-				
-				bindDeferredShader(gDeferredBlurLightProgram);
+			glClearColor(1,1,1,1);
+			mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
+			glClearColor(0,0,0,0);
+			
+			bindDeferredShader(gDeferredBlurLightProgram);
 
-				LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian");
-				const U32 kern_length = 4;
-				F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize");
-				F32 dist_factor = gSavedSettings.getF32("RenderShadowBlurDistFactor");
+			LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian");
+			const U32 kern_length = 4;
+			F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize");
+			F32 dist_factor = gSavedSettings.getF32("RenderShadowBlurDistFactor");
 
-				// sample symmetrically with the middle sample falling exactly on 0.0
-				F32 x = 0.f;
+			// sample symmetrically with the middle sample falling exactly on 0.0
+			F32 x = 0.f;
 
-				LLVector3 gauss[32]; // xweight, yweight, offset
+			LLVector3 gauss[32]; // xweight, yweight, offset
 
-				for (U32 i = 0; i < kern_length; i++)
-				{
-					gauss[i].mV[0] = llgaussian(x, go.mV[0]);
-					gauss[i].mV[1] = llgaussian(x, go.mV[1]);
-					gauss[i].mV[2] = x;
-					x += 1.f;
-				}
+			for (U32 i = 0; i < kern_length; i++)
+			{
+				gauss[i].mV[0] = llgaussian(x, go.mV[0]);
+				gauss[i].mV[1] = llgaussian(x, go.mV[1]);
+				gauss[i].mV[2] = x;
+				x += 1.f;
+			}
 
-				gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f);
-				gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor);
-				gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV);
-				gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV);
-				gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f));
+			gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f);
+			gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor);
+			gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV);
+			gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV);
+			gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f));
+		
+			{
+				LLGLDisable blend(GL_BLEND);
+				LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+				stop_glerror();
+				glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+				stop_glerror();
+			}
 			
-				{
-					LLGLDisable blend(GL_BLEND);
-					LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-					stop_glerror();
-					glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
-					stop_glerror();
-				}
-				
-				mDeferredLight[1].flush();
-				unbindDeferredShader(gDeferredBlurLightProgram);
+			mDeferredLight[1].flush();
+			unbindDeferredShader(gDeferredBlurLightProgram);
 
-				bindDeferredShader(gDeferredBlurLightProgram, 1);
-				mDeferredLight[0].bindTarget();
+			bindDeferredShader(gDeferredBlurLightProgram, 1);
+			mDeferredLight[0].bindTarget();
 
-				gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f);
+			gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f);
 
-				{
-					LLGLDisable blend(GL_BLEND);
-					LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-					stop_glerror();
-					glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
-					stop_glerror();
-				}
-				mDeferredLight[0].flush();
-				unbindDeferredShader(gDeferredBlurLightProgram);
+			{
+				LLGLDisable blend(GL_BLEND);
+				LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+				stop_glerror();
+				glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+				stop_glerror();
 			}
-
-			stop_glerror();
-			glPopMatrix();
-			stop_glerror();
-			glMatrixMode(GL_MODELVIEW);
-			stop_glerror();
-			glPopMatrix();
-			stop_glerror();
+			mDeferredLight[0].flush();
+			unbindDeferredShader(gDeferredBlurLightProgram);
 		}
 
+		stop_glerror();
+		glPopMatrix();
+		stop_glerror();
+		glMatrixMode(GL_MODELVIEW);
+		stop_glerror();
+		glPopMatrix();
+		stop_glerror();
+
 		//copy depth and stencil from deferred screen
 		//mScreen.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(),
 		//					0, 0, mScreen.getWidth(), mScreen.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
-- 
GitLab


From 64b38f3eac7ddd611a62249e27dc205db9d56e4e Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 18:19:18 -0500
Subject: [PATCH 216/683] Line ending fix.

---
 indra/newview/app_settings/low_graphics.xml | 74 ++++++++++-----------
 indra/newview/app_settings/mid_graphics.xml | 74 ++++++++++-----------
 2 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index 72cbb2808b2..54320117fca 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -1,37 +1,37 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<settings version = "101">
-	<!--NO SHADERS-->
-	<RenderAvatarCloth value="FALSE"/>
-	<!--Default for now-->
-	<RenderAvatarLODFactor value="0.5"/>
-	<!--NO SHADERS-->
-	<RenderAvatarVP value="FALSE"/>
-	<!--Short Range-->
-	<RenderFarClip value="64"/>
-	<!--Default for now-->
-	<RenderFlexTimeFactor value="0.5"/>
-	<!--256... but they don't use this-->
-	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="0"/>
-	<!--Low number-->
-	<RenderMaxPartCount value="1024"/>
-	<!--bump okay-->
-	<RenderObjectBump value="FALSE"/>
-	<!--NO SHADERS-->
-	<RenderReflectionDetail value="0"/>
-	<!--Simple-->
-	<RenderTerrainDetail value="0"/>
-	<!--Default for now-->
-	<RenderTerrainLODFactor value="1.0"/>
-	<!--Default for now-->
-	<RenderTreeLODFactor value="0.5"/>
-	<!--Try Impostors-->
-	<RenderUseImpostors value="TRUE"/>
-	<!--Default for now-->
-	<RenderVolumeLODFactor value="1.125"/>
-	<!--NO SHADERS-->
-	<VertexShaderEnable value="FALSE"/>
-	<!--NO SHADERS-->
-	<WindLightUseAtmosShaders value="FALSE"/>
-</settings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings version = "101">
+	<!--NO SHADERS-->
+	<RenderAvatarCloth value="FALSE"/>
+	<!--Default for now-->
+	<RenderAvatarLODFactor value="0.5"/>
+	<!--NO SHADERS-->
+	<RenderAvatarVP value="FALSE"/>
+	<!--Short Range-->
+	<RenderFarClip value="64"/>
+	<!--Default for now-->
+	<RenderFlexTimeFactor value="0.5"/>
+	<!--256... but they don't use this-->
+	<RenderGlowResolutionPow value="8"/>
+	<!--Sun/Moon only-->
+	<RenderLightingDetail value="0"/>
+	<!--Low number-->
+	<RenderMaxPartCount value="1024"/>
+	<!--bump okay-->
+	<RenderObjectBump value="FALSE"/>
+	<!--NO SHADERS-->
+	<RenderReflectionDetail value="0"/>
+	<!--Simple-->
+	<RenderTerrainDetail value="0"/>
+	<!--Default for now-->
+	<RenderTerrainLODFactor value="1.0"/>
+	<!--Default for now-->
+	<RenderTreeLODFactor value="0.5"/>
+	<!--Try Impostors-->
+	<RenderUseImpostors value="TRUE"/>
+	<!--Default for now-->
+	<RenderVolumeLODFactor value="1.125"/>
+	<!--NO SHADERS-->
+	<VertexShaderEnable value="FALSE"/>
+	<!--NO SHADERS-->
+	<WindLightUseAtmosShaders value="FALSE"/>
+</settings>
diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml
index 743dfa418ce..422988498df 100644
--- a/indra/newview/app_settings/mid_graphics.xml
+++ b/indra/newview/app_settings/mid_graphics.xml
@@ -1,37 +1,37 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<settings version = "101">
-	<!--NO SHADERS-->
-	<RenderAvatarCloth value="FALSE"/>
-	<!--Default for now-->
-	<RenderAvatarLODFactor value="0.5"/>
-	<!--NO SHADERS-->
-	<RenderAvatarVP value="TRUE"/>
-	<!--Short Range-->
-	<RenderFarClip value="96"/>
-	<!--Default for now-->
-	<RenderFlexTimeFactor value="1"/>
-	<!--256... but they don't use this-->
-	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
-	<!--Low number-->
-	<RenderMaxPartCount value="2048"/>
-	<!--bump okay-->
-	<RenderObjectBump value="TRUE"/>
-	<!--NO SHADERS-->
-	<RenderReflectionDetail value="0"/>
-	<!--Simple-->
-	<RenderTerrainDetail value="1"/>
-	<!--Default for now-->
-	<RenderTerrainLODFactor value="1.0"/>
-	<!--Default for now-->
-	<RenderTreeLODFactor value="0.5"/>
-	<!--Try Impostors-->
-	<RenderUseImpostors value="TRUE"/>
-	<!--Default for now-->
-	<RenderVolumeLODFactor value="1.125"/>
-	<!--NO SHADERS-->
-	<VertexShaderEnable value="TRUE"/>
-	<!--NO SHADERS-->
-	<WindLightUseAtmosShaders value="FALSE"/>
-</settings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings version = "101">
+	<!--NO SHADERS-->
+	<RenderAvatarCloth value="FALSE"/>
+	<!--Default for now-->
+	<RenderAvatarLODFactor value="0.5"/>
+	<!--NO SHADERS-->
+	<RenderAvatarVP value="TRUE"/>
+	<!--Short Range-->
+	<RenderFarClip value="96"/>
+	<!--Default for now-->
+	<RenderFlexTimeFactor value="1"/>
+	<!--256... but they don't use this-->
+	<RenderGlowResolutionPow value="8"/>
+	<!--Sun/Moon only-->
+	<RenderLightingDetail value="1"/>
+	<!--Low number-->
+	<RenderMaxPartCount value="2048"/>
+	<!--bump okay-->
+	<RenderObjectBump value="TRUE"/>
+	<!--NO SHADERS-->
+	<RenderReflectionDetail value="0"/>
+	<!--Simple-->
+	<RenderTerrainDetail value="1"/>
+	<!--Default for now-->
+	<RenderTerrainLODFactor value="1.0"/>
+	<!--Default for now-->
+	<RenderTreeLODFactor value="0.5"/>
+	<!--Try Impostors-->
+	<RenderUseImpostors value="TRUE"/>
+	<!--Default for now-->
+	<RenderVolumeLODFactor value="1.125"/>
+	<!--NO SHADERS-->
+	<VertexShaderEnable value="TRUE"/>
+	<!--NO SHADERS-->
+	<WindLightUseAtmosShaders value="FALSE"/>
+</settings>
-- 
GitLab


From 09dd7e1967835020e985baf3069faa1d4cc42382 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 18:19:18 -0500
Subject: [PATCH 217/683] Line ending fix.

---
 indra/newview/app_settings/low_graphics.xml | 74 ++++++++++-----------
 indra/newview/app_settings/mid_graphics.xml | 74 ++++++++++-----------
 2 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index 72cbb2808b2..54320117fca 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -1,37 +1,37 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<settings version = "101">
-	<!--NO SHADERS-->
-	<RenderAvatarCloth value="FALSE"/>
-	<!--Default for now-->
-	<RenderAvatarLODFactor value="0.5"/>
-	<!--NO SHADERS-->
-	<RenderAvatarVP value="FALSE"/>
-	<!--Short Range-->
-	<RenderFarClip value="64"/>
-	<!--Default for now-->
-	<RenderFlexTimeFactor value="0.5"/>
-	<!--256... but they don't use this-->
-	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="0"/>
-	<!--Low number-->
-	<RenderMaxPartCount value="1024"/>
-	<!--bump okay-->
-	<RenderObjectBump value="FALSE"/>
-	<!--NO SHADERS-->
-	<RenderReflectionDetail value="0"/>
-	<!--Simple-->
-	<RenderTerrainDetail value="0"/>
-	<!--Default for now-->
-	<RenderTerrainLODFactor value="1.0"/>
-	<!--Default for now-->
-	<RenderTreeLODFactor value="0.5"/>
-	<!--Try Impostors-->
-	<RenderUseImpostors value="TRUE"/>
-	<!--Default for now-->
-	<RenderVolumeLODFactor value="1.125"/>
-	<!--NO SHADERS-->
-	<VertexShaderEnable value="FALSE"/>
-	<!--NO SHADERS-->
-	<WindLightUseAtmosShaders value="FALSE"/>
-</settings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings version = "101">
+	<!--NO SHADERS-->
+	<RenderAvatarCloth value="FALSE"/>
+	<!--Default for now-->
+	<RenderAvatarLODFactor value="0.5"/>
+	<!--NO SHADERS-->
+	<RenderAvatarVP value="FALSE"/>
+	<!--Short Range-->
+	<RenderFarClip value="64"/>
+	<!--Default for now-->
+	<RenderFlexTimeFactor value="0.5"/>
+	<!--256... but they don't use this-->
+	<RenderGlowResolutionPow value="8"/>
+	<!--Sun/Moon only-->
+	<RenderLightingDetail value="0"/>
+	<!--Low number-->
+	<RenderMaxPartCount value="1024"/>
+	<!--bump okay-->
+	<RenderObjectBump value="FALSE"/>
+	<!--NO SHADERS-->
+	<RenderReflectionDetail value="0"/>
+	<!--Simple-->
+	<RenderTerrainDetail value="0"/>
+	<!--Default for now-->
+	<RenderTerrainLODFactor value="1.0"/>
+	<!--Default for now-->
+	<RenderTreeLODFactor value="0.5"/>
+	<!--Try Impostors-->
+	<RenderUseImpostors value="TRUE"/>
+	<!--Default for now-->
+	<RenderVolumeLODFactor value="1.125"/>
+	<!--NO SHADERS-->
+	<VertexShaderEnable value="FALSE"/>
+	<!--NO SHADERS-->
+	<WindLightUseAtmosShaders value="FALSE"/>
+</settings>
diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml
index 743dfa418ce..422988498df 100644
--- a/indra/newview/app_settings/mid_graphics.xml
+++ b/indra/newview/app_settings/mid_graphics.xml
@@ -1,37 +1,37 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<settings version = "101">
-	<!--NO SHADERS-->
-	<RenderAvatarCloth value="FALSE"/>
-	<!--Default for now-->
-	<RenderAvatarLODFactor value="0.5"/>
-	<!--NO SHADERS-->
-	<RenderAvatarVP value="TRUE"/>
-	<!--Short Range-->
-	<RenderFarClip value="96"/>
-	<!--Default for now-->
-	<RenderFlexTimeFactor value="1"/>
-	<!--256... but they don't use this-->
-	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
-	<!--Low number-->
-	<RenderMaxPartCount value="2048"/>
-	<!--bump okay-->
-	<RenderObjectBump value="TRUE"/>
-	<!--NO SHADERS-->
-	<RenderReflectionDetail value="0"/>
-	<!--Simple-->
-	<RenderTerrainDetail value="1"/>
-	<!--Default for now-->
-	<RenderTerrainLODFactor value="1.0"/>
-	<!--Default for now-->
-	<RenderTreeLODFactor value="0.5"/>
-	<!--Try Impostors-->
-	<RenderUseImpostors value="TRUE"/>
-	<!--Default for now-->
-	<RenderVolumeLODFactor value="1.125"/>
-	<!--NO SHADERS-->
-	<VertexShaderEnable value="TRUE"/>
-	<!--NO SHADERS-->
-	<WindLightUseAtmosShaders value="FALSE"/>
-</settings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings version = "101">
+	<!--NO SHADERS-->
+	<RenderAvatarCloth value="FALSE"/>
+	<!--Default for now-->
+	<RenderAvatarLODFactor value="0.5"/>
+	<!--NO SHADERS-->
+	<RenderAvatarVP value="TRUE"/>
+	<!--Short Range-->
+	<RenderFarClip value="96"/>
+	<!--Default for now-->
+	<RenderFlexTimeFactor value="1"/>
+	<!--256... but they don't use this-->
+	<RenderGlowResolutionPow value="8"/>
+	<!--Sun/Moon only-->
+	<RenderLightingDetail value="1"/>
+	<!--Low number-->
+	<RenderMaxPartCount value="2048"/>
+	<!--bump okay-->
+	<RenderObjectBump value="TRUE"/>
+	<!--NO SHADERS-->
+	<RenderReflectionDetail value="0"/>
+	<!--Simple-->
+	<RenderTerrainDetail value="1"/>
+	<!--Default for now-->
+	<RenderTerrainLODFactor value="1.0"/>
+	<!--Default for now-->
+	<RenderTreeLODFactor value="0.5"/>
+	<!--Try Impostors-->
+	<RenderUseImpostors value="TRUE"/>
+	<!--Default for now-->
+	<RenderVolumeLODFactor value="1.125"/>
+	<!--NO SHADERS-->
+	<VertexShaderEnable value="TRUE"/>
+	<!--NO SHADERS-->
+	<WindLightUseAtmosShaders value="FALSE"/>
+</settings>
-- 
GitLab


From a40bbd868c16e0375938f3e5837fba4035125910 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 21:25:43 -0500
Subject: [PATCH 218/683] Make gcc happy

---
 indra/newview/llviewershadermgr.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 50e55221749..c15f93d9aa5 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -973,7 +973,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 
 	if (success)
 	{
-		S32 level = 0;
 		std::string fragment;
 
 		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
-- 
GitLab


From 97d6eef1d3b808d0a5f09fd0bb3c725a49e94ea5 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 19 Mar 2010 21:25:43 -0500
Subject: [PATCH 219/683] Make gcc happy

---
 indra/newview/llviewershadermgr.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 50e55221749..c15f93d9aa5 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -973,7 +973,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 
 	if (success)
 	{
-		S32 level = 0;
 		std::string fragment;
 
 		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
-- 
GitLab


From 8f9fae7815f24ca59e2a7e180b7baab3bc75e2e7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 20 Mar 2010 14:15:13 -0500
Subject: [PATCH 220/683] SSAO version of sunLight shaders.

---
 .../class1/deferred/sunLightSSAOF.glsl        | 123 +++++++++
 .../class2/deferred/sunLightSSAOF.glsl        | 248 ++++++++++++++++++
 2 files changed, 371 insertions(+)
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
 create mode 100644 indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl

diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
new file mode 100644
index 00000000000..7450817ea7a
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -0,0 +1,123 @@
+/** 
+ * @file sunLightSSAOF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+//class 1 -- no shadow, SSAO only
+
+uniform sampler2DRect depthMap;
+uniform sampler2DRect normalMap;
+uniform sampler2D noiseMap;
+
+uniform sampler2D		lightFunc;
+
+
+// Inputs
+uniform mat4 shadow_matrix[6];
+uniform vec4 shadow_clip;
+uniform float ssao_radius;
+uniform float ssao_max_radius;
+uniform float ssao_factor;
+uniform float ssao_factor_inv;
+
+varying vec2 vary_fragcoord;
+varying vec4 vary_light;
+
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+
+uniform float shadow_bias;
+uniform float shadow_offset;
+
+vec4 getPosition(vec2 pos_screen)
+{
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	vec2 sc = pos_screen.xy*2.0;
+	sc /= screen_res;
+	sc -= vec2(1.0,1.0);
+	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+	vec4 pos = inv_proj * ndc;
+	pos /= pos.w;
+	pos.w = 1.0;
+	return pos;
+}
+
+//calculate decreases in ambient lighting when crowded out (SSAO)
+float calcAmbientOcclusion(vec4 pos, vec3 norm)
+{
+	float ret = 1.0;
+	
+	float dist = dot(pos.xyz,pos.xyz);
+	
+	if (dist < 64.0*64.0)
+	{
+		vec2 kern[8];
+		// exponentially (^2) distant occlusion samples spread around origin
+		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+		vec2 pos_screen = vary_fragcoord.xy;
+		vec3 pos_world = pos.xyz;
+		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
+		
+		float angle_hidden = 0.0;
+		int points = 0;
+		
+		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
+		
+		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+		for (int i = 0; i < 8; i++)
+		{
+			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+			vec3 samppos_world = getPosition(samppos_screen).xyz; 
+			
+			vec3 diff = pos_world - samppos_world;
+			float dist2 = dot(diff, diff);
+			
+			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+			// --> solid angle shrinking by the square of distance
+			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+			//(k should vary inversely with # of samples, but this is taken care of later)
+			
+			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
+			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
+			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+			
+			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
+			points = points + int(diff.z > -1.0);
+		}
+		
+		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+		
+		ret = (1.0 - (float(points != 0) * angle_hidden));
+		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
+	}
+	
+	return min(ret, 1.0);
+}
+
+void main() 
+{
+	vec2 pos_screen = vary_fragcoord.xy;
+	
+	//try doing an unproject here
+	
+	vec4 pos = getPosition(pos_screen);
+	
+    vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+		
+	gl_FragColor[0] = 1.0;
+	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
+	gl_FragColor[2] = 1.0; 
+	gl_FragColor[3] = 1.0;
+}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
new file mode 100644
index 00000000000..d77d17942a6
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -0,0 +1,248 @@
+/** 
+ * @file sunLightSSAOF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+//class 2 -- shadows and SSAO
+
+uniform sampler2DRect depthMap;
+uniform sampler2DRect normalMap;
+uniform sampler2DRectShadow shadowMap0;
+uniform sampler2DRectShadow shadowMap1;
+uniform sampler2DRectShadow shadowMap2;
+uniform sampler2DRectShadow shadowMap3;
+uniform sampler2DShadow shadowMap4;
+uniform sampler2DShadow shadowMap5;
+uniform sampler2D noiseMap;
+
+uniform sampler2D		lightFunc;
+
+// Inputs
+uniform mat4 shadow_matrix[6];
+uniform vec4 shadow_clip;
+uniform float ssao_radius;
+uniform float ssao_max_radius;
+uniform float ssao_factor;
+uniform float ssao_factor_inv;
+
+varying vec2 vary_fragcoord;
+varying vec4 vary_light;
+
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+uniform vec2 shadow_res;
+uniform vec2 proj_shadow_res;
+
+uniform float shadow_bias;
+uniform float shadow_offset;
+
+vec4 getPosition(vec2 pos_screen)
+{
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	vec2 sc = pos_screen.xy*2.0;
+	sc /= screen_res;
+	sc -= vec2(1.0,1.0);
+	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+	vec4 pos = inv_proj * ndc;
+	pos /= pos.w;
+	pos.w = 1.0;
+	return pos;
+}
+
+//calculate decreases in ambient lighting when crowded out (SSAO)
+float calcAmbientOcclusion(vec4 pos, vec3 norm)
+{
+	float ret = 1.0;
+	
+	float dist = dot(pos.xyz,pos.xyz);
+	
+	if (dist < 64.0*64.0)
+	{
+		vec2 kern[8];
+		// exponentially (^2) distant occlusion samples spread around origin
+		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+		vec2 pos_screen = vary_fragcoord.xy;
+		vec3 pos_world = pos.xyz;
+		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
+		
+		float angle_hidden = 0.0;
+		int points = 0;
+		
+		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
+		
+		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+		for (int i = 0; i < 8; i++)
+		{
+			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+			vec3 samppos_world = getPosition(samppos_screen).xyz; 
+			
+			vec3 diff = pos_world - samppos_world;
+			float dist2 = dot(diff, diff);
+			
+			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+			// --> solid angle shrinking by the square of distance
+			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+			//(k should vary inversely with # of samples, but this is taken care of later)
+			
+			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
+			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
+			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+			
+			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
+			points = points + int(diff.z > -1.0);
+		}
+		
+		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+		
+		ret = (1.0 - (float(points != 0) * angle_hidden));
+		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
+	}
+	
+	return min(ret, 1.0);
+}
+
+float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
+{
+	stc.xyz /= stc.w;
+	stc.z += shadow_bias*scl;
+	
+	float cs = shadow2DRect(shadowMap, stc.xyz).x;
+	float shadow = cs;
+
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, 1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, -1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, 1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, -1.5, 0.0)).x, cs);
+			
+	return shadow/5.0;
+	
+	//return shadow;
+}
+
+float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
+{
+	stc.xyz /= stc.w;
+	stc.z += shadow_bias*scl;
+	
+	float cs = shadow2D(shadowMap, stc.xyz).x;
+	float shadow = cs;
+
+	vec2 off = 1.5/proj_shadow_res;
+	
+	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(off.x, off.y, 0.0)).x, cs);
+	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x, cs);
+	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x, cs);
+	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(-off.x, -off.y, 0.0)).x, cs);
+	
+			
+	return shadow/5.0;
+	
+	//return shadow;
+}
+
+void main() 
+{
+	vec2 pos_screen = vary_fragcoord.xy;
+	
+	//try doing an unproject here
+	
+	vec4 pos = getPosition(pos_screen);
+	
+	vec4 nmap4 = texture2DRect(normalMap, pos_screen);
+	float displace = nmap4.w;
+	vec3 norm = nmap4.xyz*2.0-1.0;
+	
+	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
+	{
+		gl_FragColor = vec4(0.0); // doesn't matter
+		return;
+	}*/
+	
+	float shadow = 1.0;
+	float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
+
+	vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+	
+	if (spos.z > -shadow_clip.w)
+	{	
+		if (dp_directional_light == 0.0)
+		{
+			// if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup
+			shadow = 0.0;
+		}
+		else
+		{
+			vec4 lpos;
+			
+			if (spos.z < -shadow_clip.z)
+			{
+				lpos = shadow_matrix[3]*spos;
+				lpos.xy *= shadow_res;
+				shadow = pcfShadow(shadowMap3, lpos, 0.25);
+				shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
+			}
+			else if (spos.z < -shadow_clip.y)
+			{
+				lpos = shadow_matrix[2]*spos;
+				lpos.xy *= shadow_res;
+				shadow = pcfShadow(shadowMap2, lpos, 0.5);
+			}
+			else if (spos.z < -shadow_clip.x)
+			{
+				lpos = shadow_matrix[1]*spos;
+				lpos.xy *= shadow_res;
+				shadow = pcfShadow(shadowMap1, lpos, 0.75);
+			}
+			else
+			{
+				lpos = shadow_matrix[0]*spos;
+				lpos.xy *= shadow_res;
+				shadow = pcfShadow(shadowMap0, lpos, 1.0);
+			}
+		
+			// take the most-shadowed value out of these two:
+			//  * the blurred sun shadow in the light (shadow) map
+			//  * an unblurred dot product between the sun and this norm
+			// the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting
+			shadow = min(shadow, dp_directional_light);
+			
+			//lpos.xy /= lpos.w*32.0;
+			//if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1)
+			//{
+			//	shadow = 0.0;
+			//}
+			
+		}
+	}
+	else
+	{
+		// more distant than the shadow map covers
+		shadow = 1.0;
+	}
+	
+	gl_FragColor[0] = shadow;
+	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
+	
+	//spotlight shadow 1
+	vec4 lpos = shadow_matrix[4]*spos;
+	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x; 
+	
+	//spotlight shadow 2
+	lpos = shadow_matrix[5]*spos;
+	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x; 
+
+	//gl_FragColor.rgb = pos.xyz;
+	//gl_FragColor.b = shadow;
+}
-- 
GitLab


From 5add36d898262b6dc41e1b4151465405c1d364a4 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 20 Mar 2010 14:15:13 -0500
Subject: [PATCH 221/683] SSAO version of sunLight shaders.

---
 .../class1/deferred/sunLightSSAOF.glsl        | 123 +++++++++
 .../class2/deferred/sunLightSSAOF.glsl        | 248 ++++++++++++++++++
 2 files changed, 371 insertions(+)
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
 create mode 100644 indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl

diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
new file mode 100644
index 00000000000..7450817ea7a
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -0,0 +1,123 @@
+/** 
+ * @file sunLightSSAOF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+//class 1 -- no shadow, SSAO only
+
+uniform sampler2DRect depthMap;
+uniform sampler2DRect normalMap;
+uniform sampler2D noiseMap;
+
+uniform sampler2D		lightFunc;
+
+
+// Inputs
+uniform mat4 shadow_matrix[6];
+uniform vec4 shadow_clip;
+uniform float ssao_radius;
+uniform float ssao_max_radius;
+uniform float ssao_factor;
+uniform float ssao_factor_inv;
+
+varying vec2 vary_fragcoord;
+varying vec4 vary_light;
+
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+
+uniform float shadow_bias;
+uniform float shadow_offset;
+
+vec4 getPosition(vec2 pos_screen)
+{
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	vec2 sc = pos_screen.xy*2.0;
+	sc /= screen_res;
+	sc -= vec2(1.0,1.0);
+	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+	vec4 pos = inv_proj * ndc;
+	pos /= pos.w;
+	pos.w = 1.0;
+	return pos;
+}
+
+//calculate decreases in ambient lighting when crowded out (SSAO)
+float calcAmbientOcclusion(vec4 pos, vec3 norm)
+{
+	float ret = 1.0;
+	
+	float dist = dot(pos.xyz,pos.xyz);
+	
+	if (dist < 64.0*64.0)
+	{
+		vec2 kern[8];
+		// exponentially (^2) distant occlusion samples spread around origin
+		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+		vec2 pos_screen = vary_fragcoord.xy;
+		vec3 pos_world = pos.xyz;
+		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
+		
+		float angle_hidden = 0.0;
+		int points = 0;
+		
+		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
+		
+		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+		for (int i = 0; i < 8; i++)
+		{
+			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+			vec3 samppos_world = getPosition(samppos_screen).xyz; 
+			
+			vec3 diff = pos_world - samppos_world;
+			float dist2 = dot(diff, diff);
+			
+			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+			// --> solid angle shrinking by the square of distance
+			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+			//(k should vary inversely with # of samples, but this is taken care of later)
+			
+			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
+			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
+			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+			
+			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
+			points = points + int(diff.z > -1.0);
+		}
+		
+		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+		
+		ret = (1.0 - (float(points != 0) * angle_hidden));
+		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
+	}
+	
+	return min(ret, 1.0);
+}
+
+void main() 
+{
+	vec2 pos_screen = vary_fragcoord.xy;
+	
+	//try doing an unproject here
+	
+	vec4 pos = getPosition(pos_screen);
+	
+    vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+		
+	gl_FragColor[0] = 1.0;
+	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
+	gl_FragColor[2] = 1.0; 
+	gl_FragColor[3] = 1.0;
+}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
new file mode 100644
index 00000000000..d77d17942a6
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -0,0 +1,248 @@
+/** 
+ * @file sunLightSSAOF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+//class 2 -- shadows and SSAO
+
+uniform sampler2DRect depthMap;
+uniform sampler2DRect normalMap;
+uniform sampler2DRectShadow shadowMap0;
+uniform sampler2DRectShadow shadowMap1;
+uniform sampler2DRectShadow shadowMap2;
+uniform sampler2DRectShadow shadowMap3;
+uniform sampler2DShadow shadowMap4;
+uniform sampler2DShadow shadowMap5;
+uniform sampler2D noiseMap;
+
+uniform sampler2D		lightFunc;
+
+// Inputs
+uniform mat4 shadow_matrix[6];
+uniform vec4 shadow_clip;
+uniform float ssao_radius;
+uniform float ssao_max_radius;
+uniform float ssao_factor;
+uniform float ssao_factor_inv;
+
+varying vec2 vary_fragcoord;
+varying vec4 vary_light;
+
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+uniform vec2 shadow_res;
+uniform vec2 proj_shadow_res;
+
+uniform float shadow_bias;
+uniform float shadow_offset;
+
+vec4 getPosition(vec2 pos_screen)
+{
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	vec2 sc = pos_screen.xy*2.0;
+	sc /= screen_res;
+	sc -= vec2(1.0,1.0);
+	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+	vec4 pos = inv_proj * ndc;
+	pos /= pos.w;
+	pos.w = 1.0;
+	return pos;
+}
+
+//calculate decreases in ambient lighting when crowded out (SSAO)
+float calcAmbientOcclusion(vec4 pos, vec3 norm)
+{
+	float ret = 1.0;
+	
+	float dist = dot(pos.xyz,pos.xyz);
+	
+	if (dist < 64.0*64.0)
+	{
+		vec2 kern[8];
+		// exponentially (^2) distant occlusion samples spread around origin
+		kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+		kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+		kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+		kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+		kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+		kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+		kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+		kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+		vec2 pos_screen = vary_fragcoord.xy;
+		vec3 pos_world = pos.xyz;
+		vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
+		
+		float angle_hidden = 0.0;
+		int points = 0;
+		
+		float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
+		
+		// it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+		for (int i = 0; i < 8; i++)
+		{
+			vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+			vec3 samppos_world = getPosition(samppos_screen).xyz; 
+			
+			vec3 diff = pos_world - samppos_world;
+			float dist2 = dot(diff, diff);
+			
+			// assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+			// --> solid angle shrinking by the square of distance
+			//radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+			//(k should vary inversely with # of samples, but this is taken care of later)
+			
+			//if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0)  // -0.05*norm to shift sample point back slightly for flat surfaces
+			//	angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional.  max of 1.0 (= ssao_factor_inv * ssao_factor)
+			angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+			
+			// 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" 
+			points = points + int(diff.z > -1.0);
+		}
+		
+		angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+		
+		ret = (1.0 - (float(points != 0) * angle_hidden));
+		ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
+	}
+	
+	return min(ret, 1.0);
+}
+
+float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
+{
+	stc.xyz /= stc.w;
+	stc.z += shadow_bias*scl;
+	
+	float cs = shadow2DRect(shadowMap, stc.xyz).x;
+	float shadow = cs;
+
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, 1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, -1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, 1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, -1.5, 0.0)).x, cs);
+			
+	return shadow/5.0;
+	
+	//return shadow;
+}
+
+float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
+{
+	stc.xyz /= stc.w;
+	stc.z += shadow_bias*scl;
+	
+	float cs = shadow2D(shadowMap, stc.xyz).x;
+	float shadow = cs;
+
+	vec2 off = 1.5/proj_shadow_res;
+	
+	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(off.x, off.y, 0.0)).x, cs);
+	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x, cs);
+	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x, cs);
+	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(-off.x, -off.y, 0.0)).x, cs);
+	
+			
+	return shadow/5.0;
+	
+	//return shadow;
+}
+
+void main() 
+{
+	vec2 pos_screen = vary_fragcoord.xy;
+	
+	//try doing an unproject here
+	
+	vec4 pos = getPosition(pos_screen);
+	
+	vec4 nmap4 = texture2DRect(normalMap, pos_screen);
+	float displace = nmap4.w;
+	vec3 norm = nmap4.xyz*2.0-1.0;
+	
+	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
+	{
+		gl_FragColor = vec4(0.0); // doesn't matter
+		return;
+	}*/
+	
+	float shadow = 1.0;
+	float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
+
+	vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+	
+	if (spos.z > -shadow_clip.w)
+	{	
+		if (dp_directional_light == 0.0)
+		{
+			// if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup
+			shadow = 0.0;
+		}
+		else
+		{
+			vec4 lpos;
+			
+			if (spos.z < -shadow_clip.z)
+			{
+				lpos = shadow_matrix[3]*spos;
+				lpos.xy *= shadow_res;
+				shadow = pcfShadow(shadowMap3, lpos, 0.25);
+				shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
+			}
+			else if (spos.z < -shadow_clip.y)
+			{
+				lpos = shadow_matrix[2]*spos;
+				lpos.xy *= shadow_res;
+				shadow = pcfShadow(shadowMap2, lpos, 0.5);
+			}
+			else if (spos.z < -shadow_clip.x)
+			{
+				lpos = shadow_matrix[1]*spos;
+				lpos.xy *= shadow_res;
+				shadow = pcfShadow(shadowMap1, lpos, 0.75);
+			}
+			else
+			{
+				lpos = shadow_matrix[0]*spos;
+				lpos.xy *= shadow_res;
+				shadow = pcfShadow(shadowMap0, lpos, 1.0);
+			}
+		
+			// take the most-shadowed value out of these two:
+			//  * the blurred sun shadow in the light (shadow) map
+			//  * an unblurred dot product between the sun and this norm
+			// the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting
+			shadow = min(shadow, dp_directional_light);
+			
+			//lpos.xy /= lpos.w*32.0;
+			//if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1)
+			//{
+			//	shadow = 0.0;
+			//}
+			
+		}
+	}
+	else
+	{
+		// more distant than the shadow map covers
+		shadow = 1.0;
+	}
+	
+	gl_FragColor[0] = shadow;
+	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
+	
+	//spotlight shadow 1
+	vec4 lpos = shadow_matrix[4]*spos;
+	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x; 
+	
+	//spotlight shadow 2
+	lpos = shadow_matrix[5]*spos;
+	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x; 
+
+	//gl_FragColor.rgb = pos.xyz;
+	//gl_FragColor.b = shadow;
+}
-- 
GitLab


From 06e3d288e40e46204d84aed9c548a6ca529e78d8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 20 Mar 2010 16:56:36 -0500
Subject: [PATCH 222/683] Tweak detail settings and make graphics preferences
 widget enabling respect requirements.

---
 indra/newview/app_settings/high_graphics.xml  |  9 ++-
 indra/newview/app_settings/low_graphics.xml   |  9 ++-
 indra/newview/app_settings/mid_graphics.xml   |  9 ++-
 indra/newview/app_settings/settings.xml       | 11 ---
 indra/newview/app_settings/ultra_graphics.xml |  9 ++-
 indra/newview/featuretable.txt                | 38 +++++++--
 indra/newview/llfloaterpreference.cpp         | 60 +++++++++++++-
 indra/newview/llviewercontrol.cpp             | 10 ---
 indra/newview/llviewershadermgr.cpp           | 39 ++++++---
 indra/newview/llviewerstats.cpp               |  2 +-
 indra/newview/pipeline.cpp                    | 13 ++-
 .../xui/en/panel_preferences_graphics1.xml    | 80 ++++++++++---------
 12 files changed, 198 insertions(+), 91 deletions(-)

diff --git a/indra/newview/app_settings/high_graphics.xml b/indra/newview/app_settings/high_graphics.xml
index c3fa2ab75ea..93d39c84144 100644
--- a/indra/newview/app_settings/high_graphics.xml
+++ b/indra/newview/app_settings/high_graphics.xml
@@ -12,8 +12,6 @@
 	<RenderFlexTimeFactor value="1"/>
 	<!--256... but they don't use this-->
 	<RenderGlowResolutionPow value="9"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
 	<!--Low number-->
 	<RenderMaxPartCount value="4096"/>
 	<!--bump okay-->
@@ -34,4 +32,11 @@
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
+  <!--Deferred Shading-->
+  <RenderDeferred value="TRUE"/>
+  <!--SSAO Disabled-->
+  <RenderDeferredSSAO value="FALSE"/>
+  <!--Sun Shadows-->
+  <RenderShadowDetail value="1"/>
+
 </settings>
diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index 54320117fca..a300c8646c4 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -12,8 +12,6 @@
 	<RenderFlexTimeFactor value="0.5"/>
 	<!--256... but they don't use this-->
 	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="0"/>
 	<!--Low number-->
 	<RenderMaxPartCount value="1024"/>
 	<!--bump okay-->
@@ -34,4 +32,11 @@
 	<VertexShaderEnable value="FALSE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="FALSE"/>
+  <!--No Deferred Shading-->
+  <RenderDeferred value="FALSE"/>
+  <!--SSAO Disabled-->
+  <RenderDeferredSSAO value="FALSE"/>
+  <!--No Shadows-->
+  <RenderShadowDetail value="0"/>
+
 </settings>
diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml
index 422988498df..a1430a58f98 100644
--- a/indra/newview/app_settings/mid_graphics.xml
+++ b/indra/newview/app_settings/mid_graphics.xml
@@ -12,8 +12,6 @@
 	<RenderFlexTimeFactor value="1"/>
 	<!--256... but they don't use this-->
 	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
 	<!--Low number-->
 	<RenderMaxPartCount value="2048"/>
 	<!--bump okay-->
@@ -34,4 +32,11 @@
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="FALSE"/>
+  <!--No Deferred Shading-->
+  <RenderDeferred value="FALSE"/>
+  <!--SSAO Disabled-->
+  <RenderDeferredSSAO value="FALSE"/>
+  <!--No Shadows-->
+  <RenderShadowDetail value="0"/>
+
 </settings>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 68d759019d6..520cbae15b4 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7167,17 +7167,6 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>RenderLightingDetail</key>
-    <map>
-      <key>Comment</key>
-      <string>Amount of detail for lighting objects/avatars/terrain (0=sun/moon only, 1=enable local lights)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <integer>1</integer>
-    </map>
     <key>RenderMaxPartCount</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/app_settings/ultra_graphics.xml b/indra/newview/app_settings/ultra_graphics.xml
index 149aa320005..f741089ca2b 100644
--- a/indra/newview/app_settings/ultra_graphics.xml
+++ b/indra/newview/app_settings/ultra_graphics.xml
@@ -12,8 +12,6 @@
 	<RenderFlexTimeFactor value="1"/>
 	<!--256... but they don't use this-->
 	<RenderGlowResolutionPow value="9"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
 	<!--Low number-->
 	<RenderMaxPartCount value="4096"/>
 	<!--bump okay-->
@@ -34,4 +32,11 @@
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
+  <!--Deferred Shading-->
+  <RenderDeferred value="TRUE"/>
+  <!--SSAO Enabled-->
+  <RenderDeferredSSAO value="TRUE"/>
+  <!--Full Shadows-->
+  <RenderShadowDetail value="2"/>
+
 </settings>
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 7f13240e601..1913f52499b 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -35,7 +35,6 @@ RenderFogRatio				1	4.0
 RenderGamma					1	0
 RenderGlowResolutionPow		1	9
 RenderGround				1	1
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderNightBrightness		1	1.0
 RenderObjectBump			1	1
@@ -55,6 +54,9 @@ Disregard128DefaultDrawDistance	1	1
 Disregard96DefaultDrawDistance	1	1
 RenderTextureMemoryMultiple		1	1.0
 RenderShaderLightingMaxLevel	1	3
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
+RenderShadowDetail			1	2
 
 
 //
@@ -68,7 +70,6 @@ RenderAvatarVP				1	0
 RenderFarClip				1	64
 RenderFlexTimeFactor		1	0.5
 RenderGlowResolutionPow		1	8
-RenderLightingDetail		1	0
 RenderMaxPartCount			1	1024
 RenderObjectBump			1	0
 RenderReflectionDetail		1	0
@@ -80,6 +81,10 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	0
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
+
 
 //
 // Mid Graphics Settings
@@ -92,7 +97,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	96
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	8
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	2048
 RenderObjectBump			1	1
 RenderReflectionDetail		1	0
@@ -104,6 +108,10 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
+
 
 //
 // High Graphics Settings (purty)
@@ -116,7 +124,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	128
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	9
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	4096
 RenderObjectBump			1	1
 RenderReflectionDetail		1	2
@@ -128,6 +135,10 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
+RenderDeferred				1	1
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	1
+
 
 //
 // Ultra graphics (REALLY PURTY!)
@@ -140,7 +151,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	256
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	9
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderObjectBump			1	1
 RenderReflectionDetail		1	4
@@ -152,6 +162,10 @@ RenderVolumeLODFactor		1	2.0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
+RenderShadowDetail			1	2
+
 
 //
 // Class Unknown Hardware (unknown)
@@ -192,6 +206,9 @@ RenderAvatarCloth			0	0
 RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
 
 //
 // No Vertex Shaders available
@@ -202,6 +219,10 @@ RenderAvatarCloth			0	0
 RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
+
 
 // "Default" setups for safe, low, medium, high
 //
@@ -209,7 +230,6 @@ list safe
 RenderAnisotropic			1	0
 RenderAvatarCloth			0	0
 RenderAvatarVP				0	0
-RenderLightingDetail		1	0
 RenderObjectBump			0	0
 RenderMaxPartCount			1	1024
 RenderTerrainDetail 		1	0
@@ -217,6 +237,10 @@ RenderUseImpostors			0	0
 RenderVBOEnable				1	0
 RenderReflectionDetail		0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
+
 
 //
 // CPU based feature masks
@@ -240,11 +264,9 @@ RenderVBOEnable				1	0
 
 list Intel
 RenderAnisotropic			1	0
-RenderLightingDetail		1	0
 
 list GeForce2
 RenderAnisotropic			1	0
-RenderLightingDetail		1	0
 RenderMaxPartCount			1	2048
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	1
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index f19683304f1..2d23f848af6 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -819,7 +819,7 @@ void LLFloaterPreference::buildPopupLists()
 
 void LLFloaterPreference::refreshEnabledState()
 {	
-	LLCheckBoxCtrl* ctrl_reflections = getChild<LLCheckBoxCtrl>("Reflections");
+	LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
 	LLRadioGroup* radio_reflection_detail = getChild<LLRadioGroup>("ReflectionDetailRadio");
 	
 	// Reflections
@@ -832,7 +832,7 @@ void LLFloaterPreference::refreshEnabledState()
 	bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
 	getChild<LLCheckBoxCtrl>("BumpShiny")->setEnabled(bumpshiny ? TRUE : FALSE);
 	
-	radio_reflection_detail->setEnabled(ctrl_reflections->get() && reflections);
+	radio_reflection_detail->setEnabled(reflections);
 	
 	// Avatar Mode
 	// Enable Avatar Shaders
@@ -878,6 +878,26 @@ void LLFloaterPreference::refreshEnabledState()
 	// *HACK just checks to see if we can use shaders... 
 	// maybe some cards that use shaders, but don't support windlight
 	ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders);
+
+	//Deferred/SSAO/Shadows
+	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+	if (LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseFBO") &&
+		shaders)
+	{
+		BOOL enabled = ctrl_wind_light->get() ? TRUE : FALSE;
+
+		ctrl_deferred->setEnabled(enabled);
+	
+		LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
+		LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
+
+		enabled = enabled && (ctrl_deferred->get() ? TRUE : FALSE);
+		
+		ctrl_ssao->setEnabled(enabled);
+		ctrl_shadow->setEnabled(enabled);
+	}
+
+
 	// now turn off any features that are unavailable
 	disableUnavailableSettings();
 }
@@ -890,6 +910,9 @@ void LLFloaterPreference::disableUnavailableSettings()
 	LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
 	LLCheckBoxCtrl* ctrl_wind_light    = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
 	LLCheckBoxCtrl* ctrl_avatar_impostors = getChild<LLCheckBoxCtrl>("AvatarImpostors");
+	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+	LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail");
+	LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
 
 	// if vertex shaders off, disable all shader related products
 	if(!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"))
@@ -901,13 +924,22 @@ void LLFloaterPreference::disableUnavailableSettings()
 		ctrl_wind_light->setValue(FALSE);
 		
 		ctrl_reflections->setEnabled(FALSE);
-		ctrl_reflections->setValue(FALSE);
+		ctrl_reflections->setValue(0);
 		
 		ctrl_avatar_vp->setEnabled(FALSE);
 		ctrl_avatar_vp->setValue(FALSE);
 		
 		ctrl_avatar_cloth->setEnabled(FALSE);
 		ctrl_avatar_cloth->setValue(FALSE);
+
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
 	}
 	
 	// disabled windlight
@@ -915,6 +947,16 @@ void LLFloaterPreference::disableUnavailableSettings()
 	{
 		ctrl_wind_light->setEnabled(FALSE);
 		ctrl_wind_light->setValue(FALSE);
+
+		//deferred needs windlight, disable deferred
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
 	}
 	
 	// disabled reflections
@@ -932,13 +974,25 @@ void LLFloaterPreference::disableUnavailableSettings()
 		
 		ctrl_avatar_cloth->setEnabled(FALSE);
 		ctrl_avatar_cloth->setValue(FALSE);
+
+		//deferred needs AvatarVP, disable deferred
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
 	}
+
 	// disabled cloth
 	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
 	{
 		ctrl_avatar_cloth->setEnabled(FALSE);
 		ctrl_avatar_cloth->setValue(FALSE);
 	}
+
 	// disabled impostors
 	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseImpostors"))
 	{
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 862e1de6851..e13411442d9 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -297,15 +297,6 @@ static bool handleWLSkyDetailChanged(const LLSD&)
 	return true;
 }
 
-static bool handleRenderLightingDetailChanged(const LLSD& newvalue)
-{
-	if (gPipeline.isInit())
-	{
-		gPipeline.setLightingDetail(newvalue.asInteger());
-	}
-	return true;
-}
-
 static bool handleResetVertexBuffersChanged(const LLSD&)
 {
 	if (gPipeline.isInit())
@@ -574,7 +565,6 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderVBOEnable")->getSignal()->connect(boost::bind(&handleRenderUseVBOChanged, _2));
 	gSavedSettings.getControl("RenderUseStreamVBO")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("WLSkyDetail")->getSignal()->connect(boost::bind(&handleWLSkyDetailChanged, _2));
-	gSavedSettings.getControl("RenderLightingDetail")->getSignal()->connect(boost::bind(&handleRenderLightingDetailChanged, _2));
 	gSavedSettings.getControl("NumpadControl")->getSignal()->connect(boost::bind(&handleNumpadControlChanged, _2));
 	gSavedSettings.getControl("JoystickAxis0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
 	gSavedSettings.getControl("JoystickAxis1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index c15f93d9aa5..a0d0b9d4904 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -317,10 +317,16 @@ S32 LLViewerShaderMgr::getVertexShaderLevel(S32 type)
 
 void LLViewerShaderMgr::setShaders()
 {
-	if (!gPipeline.mInitialized || !sInitialized)
+	//setShaders might be called redundantly by gSavedSettings, so return on reentrance
+	static bool reentrance = false;
+	
+	if (!gPipeline.mInitialized || !sInitialized || reentrance)
 	{
 		return;
 	}
+
+	reentrance = true;
+
 	// Make sure the compiled shader map is cleared before we recompile shaders.
 	mShaderObjects.clear();
 	
@@ -368,15 +374,8 @@ void LLViewerShaderMgr::setShaders()
 		S32 wl_class = 2;
 		S32 water_class = 2;
 		S32 deferred_class = 0;
-		if (!(LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")
-			  && gSavedSettings.getBOOL("WindLightUseAtmosShaders")))
-		{
-			// user has disabled WindLight in their settings, downgrade
-			// windlight shaders to stub versions.
-			wl_class = 1;
-		}
-
-		if (LLPipeline::sRenderDeferred)
+		
+		if (gSavedSettings.getBOOL("RenderDeferred"))
 		{
 			if (gSavedSettings.getS32("RenderShadowDetail") > 0)
 			{
@@ -393,6 +392,24 @@ void LLViewerShaderMgr::setShaders()
 			{ //no shadows
 				deferred_class = 1;
 			}
+
+			//make sure framebuffer objects are enabled
+			gSavedSettings.setBOOL("RenderUseFBO", TRUE);
+
+			//make sure hardware skinning is enabled
+			gSavedSettings.setBOOL("RenderAvatarVP", TRUE);
+			
+			//make sure atmospheric shaders are enabled
+			gSavedSettings.setBOOL("WindLightUseAtmosShaders", TRUE);
+		}
+
+
+		if (!(LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")
+			  && gSavedSettings.getBOOL("WindLightUseAtmosShaders")))
+		{
+			// user has disabled WindLight in their settings, downgrade
+			// windlight shaders to stub versions.
+			wl_class = 1;
 		}
 
 		if(!gSavedSettings.getBOOL("EnableRippleWater"))
@@ -517,6 +534,8 @@ void LLViewerShaderMgr::setShaders()
 		gViewerWindow->setCursor(UI_CURSOR_ARROW);
 	}
 	gPipeline.createGLBuffers();
+
+	reentrance = false;
 }
 
 void LLViewerShaderMgr::unloadShaders()
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 8059f866ba5..045a5485ef2 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -591,7 +591,7 @@ void update_statistics(U32 frame_count)
 		}
 	}
 	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
-	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gSavedSettings.getS32("RenderLightingDetail"));
+	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
 	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip"));
 	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
 #if 0 // 1.9.2
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 5cfd6c3d38f..26670351c6a 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -409,6 +409,8 @@ void LLPipeline::init()
 	{
 		mSpotLightFade[i] = 1.f;
 	}
+
+	setLightingDetail(-1);
 }
 
 LLPipeline::~LLPipeline()
@@ -905,13 +907,18 @@ S32 LLPipeline::setLightingDetail(S32 level)
 
 	if (level < 0)
 	{
-		level = gSavedSettings.getS32("RenderLightingDetail");
+		if (gSavedSettings.getBOOL("VertexShaderEnable"))
+		{
+			level = 1;
+		}
+		else
+		{
+			level = 0;
+		}
 	}
 	level = llclamp(level, 0, getMaxLightingDetail());
 	if (level != mLightingDetail)
 	{
-		gSavedSettings.setS32("RenderLightingDetail", level);
-		
 		mLightingDetail = level;
 
 		if (mVertexShadersLoaded == 1)
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index e38ad01ff98..e6e70948473 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -242,12 +242,15 @@
 		control_name="RenderDeferred"
 		height="16"
 		initial_value="true"
-		label="Lighting Shaders"
+		label="Lighting and Shadows"
 		layout="topleft"
 		left_delta="0"
 		name="UseLightShaders"
 		top_pad="1"
-		width="256"/>
+		width="256">
+      <check_box.commit_callback
+			function="Pref.VertexShaderEnable" />
+    </check_box>
     <check_box
 		control_name="RenderDeferredSSAO"
 		height="16"
@@ -257,9 +260,12 @@
 		left_delta="0"
 		name="UseSSAO"
 		top_pad="1"
-		width="256"/>
+		width="256">
+      <check_box.commit_callback
+			function="Pref.VertexShaderEnable" />
+    </check_box>
 
-      <text
+     <text
     type="string"
     length="1"
     top_pad="8"
@@ -269,72 +275,72 @@
     word_wrap="true"
     layout="topleft"
     left="10"
-    name="reflection_label">
-        Water Reflections:
+    name="shadows_label">
+        Shadows:
       </text>
       <combo_box
-      control_name="RenderReflectionDetail"
+      control_name="RenderShadowDetail"
       height="23"
       layout="topleft"
-      left_="10"
-      top_pad ="0" 
-      name="Reflections"
+      left="10"
+      top_pad="0" 
+      name="ShadowDetail"
       width="150">
         <combo_box.item
         label="None"
         name="0"
         value="0"/>
         <combo_box.item
-        label="Terrain and trees"
+        label="Sun/Moon"
         name="1"
         value="1"/>
         <combo_box.item
-        label="All static objects"
+        label="Sun/Moon + Projectors"
         name="2"
         value="2"/>
-        <combo_box.item
-        label="All avatars and objects"
-        name="3"
-        value="3"/>
-        <combo_box.item
-        label="Everything"
-        name="4"
-        value="4"/>
       </combo_box>
 
       <text
-    type="string"
-    length="1"
-    top_pad="8"
-    follows="top|left"
-    height="23"
-    width="110"
-    word_wrap="true"
-    layout="topleft"
-    left="10"
-    name="shadows_label">
-        Shadows:
+  type="string"
+  length="1"
+  top_pad="8"
+  follows="top|left"
+  height="23"
+  width="110"
+  word_wrap="true"
+  layout="topleft"
+  left="10"
+  name="reflection_label">
+        Water Reflections:
       </text>
       <combo_box
-      control_name="RenderShadowDetail"
+      control_name="RenderReflectionDetail"
       height="23"
       layout="topleft"
-      left="10"
-      top_pad="0" 
-      name="ShadowDetailRadio"
+      left_="10"
+      top_pad ="0"
+      name="Reflections"
       width="150">
         <combo_box.item
         label="None"
         name="0"
         value="0"/>
         <combo_box.item
-        label="Sun/Moon"
+        label="Terrain and trees"
         name="1"
         value="1"/>
         <combo_box.item
-        label="Sun/Moon + Projectors"
+        label="All static objects"
         name="2"
         value="2"/>
+        <combo_box.item
+        label="All avatars and objects"
+        name="3"
+        value="3"/>
+        <combo_box.item
+        label="Everything"
+        name="4"
+        value="4"/>
       </combo_box>
     
 		<slider
-- 
GitLab


From b767f2a5d5c61e01b0eb270f951fb2e6c98dbdd4 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 20 Mar 2010 16:56:36 -0500
Subject: [PATCH 223/683] Tweak detail settings and make graphics preferences
 widget enabling respect requirements.

---
 indra/newview/app_settings/high_graphics.xml  |  9 ++-
 indra/newview/app_settings/low_graphics.xml   |  9 ++-
 indra/newview/app_settings/mid_graphics.xml   |  9 ++-
 indra/newview/app_settings/settings.xml       | 11 ---
 indra/newview/app_settings/ultra_graphics.xml |  9 ++-
 indra/newview/featuretable.txt                | 38 +++++++--
 indra/newview/llfloaterpreference.cpp         | 60 +++++++++++++-
 indra/newview/llviewercontrol.cpp             | 10 ---
 indra/newview/llviewershadermgr.cpp           | 39 ++++++---
 indra/newview/llviewerstats.cpp               |  2 +-
 indra/newview/pipeline.cpp                    | 13 ++-
 .../xui/en/panel_preferences_graphics1.xml    | 80 ++++++++++---------
 12 files changed, 198 insertions(+), 91 deletions(-)

diff --git a/indra/newview/app_settings/high_graphics.xml b/indra/newview/app_settings/high_graphics.xml
index c3fa2ab75ea..93d39c84144 100644
--- a/indra/newview/app_settings/high_graphics.xml
+++ b/indra/newview/app_settings/high_graphics.xml
@@ -12,8 +12,6 @@
 	<RenderFlexTimeFactor value="1"/>
 	<!--256... but they don't use this-->
 	<RenderGlowResolutionPow value="9"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
 	<!--Low number-->
 	<RenderMaxPartCount value="4096"/>
 	<!--bump okay-->
@@ -34,4 +32,11 @@
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
+  <!--Deferred Shading-->
+  <RenderDeferred value="TRUE"/>
+  <!--SSAO Disabled-->
+  <RenderDeferredSSAO value="FALSE"/>
+  <!--Sun Shadows-->
+  <RenderShadowDetail value="1"/>
+
 </settings>
diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index 54320117fca..a300c8646c4 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -12,8 +12,6 @@
 	<RenderFlexTimeFactor value="0.5"/>
 	<!--256... but they don't use this-->
 	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="0"/>
 	<!--Low number-->
 	<RenderMaxPartCount value="1024"/>
 	<!--bump okay-->
@@ -34,4 +32,11 @@
 	<VertexShaderEnable value="FALSE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="FALSE"/>
+  <!--No Deferred Shading-->
+  <RenderDeferred value="FALSE"/>
+  <!--SSAO Disabled-->
+  <RenderDeferredSSAO value="FALSE"/>
+  <!--No Shadows-->
+  <RenderShadowDetail value="0"/>
+
 </settings>
diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml
index 422988498df..a1430a58f98 100644
--- a/indra/newview/app_settings/mid_graphics.xml
+++ b/indra/newview/app_settings/mid_graphics.xml
@@ -12,8 +12,6 @@
 	<RenderFlexTimeFactor value="1"/>
 	<!--256... but they don't use this-->
 	<RenderGlowResolutionPow value="8"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
 	<!--Low number-->
 	<RenderMaxPartCount value="2048"/>
 	<!--bump okay-->
@@ -34,4 +32,11 @@
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="FALSE"/>
+  <!--No Deferred Shading-->
+  <RenderDeferred value="FALSE"/>
+  <!--SSAO Disabled-->
+  <RenderDeferredSSAO value="FALSE"/>
+  <!--No Shadows-->
+  <RenderShadowDetail value="0"/>
+
 </settings>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 9c1d710551b..c570578e639 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7189,17 +7189,6 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>RenderLightingDetail</key>
-    <map>
-      <key>Comment</key>
-      <string>Amount of detail for lighting objects/avatars/terrain (0=sun/moon only, 1=enable local lights)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <integer>1</integer>
-    </map>
     <key>RenderMaxPartCount</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/app_settings/ultra_graphics.xml b/indra/newview/app_settings/ultra_graphics.xml
index 149aa320005..f741089ca2b 100644
--- a/indra/newview/app_settings/ultra_graphics.xml
+++ b/indra/newview/app_settings/ultra_graphics.xml
@@ -12,8 +12,6 @@
 	<RenderFlexTimeFactor value="1"/>
 	<!--256... but they don't use this-->
 	<RenderGlowResolutionPow value="9"/>
-	<!--Sun/Moon only-->
-	<RenderLightingDetail value="1"/>
 	<!--Low number-->
 	<RenderMaxPartCount value="4096"/>
 	<!--bump okay-->
@@ -34,4 +32,11 @@
 	<VertexShaderEnable value="TRUE"/>
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
+  <!--Deferred Shading-->
+  <RenderDeferred value="TRUE"/>
+  <!--SSAO Enabled-->
+  <RenderDeferredSSAO value="TRUE"/>
+  <!--Full Shadows-->
+  <RenderShadowDetail value="2"/>
+
 </settings>
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 7f13240e601..1913f52499b 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -35,7 +35,6 @@ RenderFogRatio				1	4.0
 RenderGamma					1	0
 RenderGlowResolutionPow		1	9
 RenderGround				1	1
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderNightBrightness		1	1.0
 RenderObjectBump			1	1
@@ -55,6 +54,9 @@ Disregard128DefaultDrawDistance	1	1
 Disregard96DefaultDrawDistance	1	1
 RenderTextureMemoryMultiple		1	1.0
 RenderShaderLightingMaxLevel	1	3
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
+RenderShadowDetail			1	2
 
 
 //
@@ -68,7 +70,6 @@ RenderAvatarVP				1	0
 RenderFarClip				1	64
 RenderFlexTimeFactor		1	0.5
 RenderGlowResolutionPow		1	8
-RenderLightingDetail		1	0
 RenderMaxPartCount			1	1024
 RenderObjectBump			1	0
 RenderReflectionDetail		1	0
@@ -80,6 +81,10 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	0
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
+
 
 //
 // Mid Graphics Settings
@@ -92,7 +97,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	96
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	8
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	2048
 RenderObjectBump			1	1
 RenderReflectionDetail		1	0
@@ -104,6 +108,10 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
+
 
 //
 // High Graphics Settings (purty)
@@ -116,7 +124,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	128
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	9
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	4096
 RenderObjectBump			1	1
 RenderReflectionDetail		1	2
@@ -128,6 +135,10 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
+RenderDeferred				1	1
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	1
+
 
 //
 // Ultra graphics (REALLY PURTY!)
@@ -140,7 +151,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	256
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	9
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderObjectBump			1	1
 RenderReflectionDetail		1	4
@@ -152,6 +162,10 @@ RenderVolumeLODFactor		1	2.0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
+RenderShadowDetail			1	2
+
 
 //
 // Class Unknown Hardware (unknown)
@@ -192,6 +206,9 @@ RenderAvatarCloth			0	0
 RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
 
 //
 // No Vertex Shaders available
@@ -202,6 +219,10 @@ RenderAvatarCloth			0	0
 RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
+
 
 // "Default" setups for safe, low, medium, high
 //
@@ -209,7 +230,6 @@ list safe
 RenderAnisotropic			1	0
 RenderAvatarCloth			0	0
 RenderAvatarVP				0	0
-RenderLightingDetail		1	0
 RenderObjectBump			0	0
 RenderMaxPartCount			1	1024
 RenderTerrainDetail 		1	0
@@ -217,6 +237,10 @@ RenderUseImpostors			0	0
 RenderVBOEnable				1	0
 RenderReflectionDetail		0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
+
 
 //
 // CPU based feature masks
@@ -240,11 +264,9 @@ RenderVBOEnable				1	0
 
 list Intel
 RenderAnisotropic			1	0
-RenderLightingDetail		1	0
 
 list GeForce2
 RenderAnisotropic			1	0
-RenderLightingDetail		1	0
 RenderMaxPartCount			1	2048
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	1
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 281bfca188a..551884d5a2e 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -799,7 +799,7 @@ void LLFloaterPreference::buildPopupLists()
 
 void LLFloaterPreference::refreshEnabledState()
 {	
-	LLCheckBoxCtrl* ctrl_reflections = getChild<LLCheckBoxCtrl>("Reflections");
+	LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
 	LLRadioGroup* radio_reflection_detail = getChild<LLRadioGroup>("ReflectionDetailRadio");
 	
 	// Reflections
@@ -812,7 +812,7 @@ void LLFloaterPreference::refreshEnabledState()
 	bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
 	getChild<LLCheckBoxCtrl>("BumpShiny")->setEnabled(bumpshiny ? TRUE : FALSE);
 	
-	radio_reflection_detail->setEnabled(ctrl_reflections->get() && reflections);
+	radio_reflection_detail->setEnabled(reflections);
 	
 	// Avatar Mode
 	// Enable Avatar Shaders
@@ -858,6 +858,26 @@ void LLFloaterPreference::refreshEnabledState()
 	// *HACK just checks to see if we can use shaders... 
 	// maybe some cards that use shaders, but don't support windlight
 	ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders);
+
+	//Deferred/SSAO/Shadows
+	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+	if (LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseFBO") &&
+		shaders)
+	{
+		BOOL enabled = ctrl_wind_light->get() ? TRUE : FALSE;
+
+		ctrl_deferred->setEnabled(enabled);
+	
+		LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
+		LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
+
+		enabled = enabled && (ctrl_deferred->get() ? TRUE : FALSE);
+		
+		ctrl_ssao->setEnabled(enabled);
+		ctrl_shadow->setEnabled(enabled);
+	}
+
+
 	// now turn off any features that are unavailable
 	disableUnavailableSettings();
 
@@ -872,6 +892,9 @@ void LLFloaterPreference::disableUnavailableSettings()
 	LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
 	LLCheckBoxCtrl* ctrl_wind_light    = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
 	LLCheckBoxCtrl* ctrl_avatar_impostors = getChild<LLCheckBoxCtrl>("AvatarImpostors");
+	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+	LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail");
+	LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
 
 	// if vertex shaders off, disable all shader related products
 	if(!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"))
@@ -883,13 +906,22 @@ void LLFloaterPreference::disableUnavailableSettings()
 		ctrl_wind_light->setValue(FALSE);
 		
 		ctrl_reflections->setEnabled(FALSE);
-		ctrl_reflections->setValue(FALSE);
+		ctrl_reflections->setValue(0);
 		
 		ctrl_avatar_vp->setEnabled(FALSE);
 		ctrl_avatar_vp->setValue(FALSE);
 		
 		ctrl_avatar_cloth->setEnabled(FALSE);
 		ctrl_avatar_cloth->setValue(FALSE);
+
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
 	}
 	
 	// disabled windlight
@@ -897,6 +929,16 @@ void LLFloaterPreference::disableUnavailableSettings()
 	{
 		ctrl_wind_light->setEnabled(FALSE);
 		ctrl_wind_light->setValue(FALSE);
+
+		//deferred needs windlight, disable deferred
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
 	}
 	
 	// disabled reflections
@@ -914,13 +956,25 @@ void LLFloaterPreference::disableUnavailableSettings()
 		
 		ctrl_avatar_cloth->setEnabled(FALSE);
 		ctrl_avatar_cloth->setValue(FALSE);
+
+		//deferred needs AvatarVP, disable deferred
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
 	}
+
 	// disabled cloth
 	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
 	{
 		ctrl_avatar_cloth->setEnabled(FALSE);
 		ctrl_avatar_cloth->setValue(FALSE);
 	}
+
 	// disabled impostors
 	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseImpostors"))
 	{
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index b773b959177..0a1108c3c30 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -299,15 +299,6 @@ static bool handleWLSkyDetailChanged(const LLSD&)
 	return true;
 }
 
-static bool handleRenderLightingDetailChanged(const LLSD& newvalue)
-{
-	if (gPipeline.isInit())
-	{
-		gPipeline.setLightingDetail(newvalue.asInteger());
-	}
-	return true;
-}
-
 static bool handleResetVertexBuffersChanged(const LLSD&)
 {
 	if (gPipeline.isInit())
@@ -579,7 +570,6 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderVBOEnable")->getSignal()->connect(boost::bind(&handleRenderUseVBOChanged, _2));
 	gSavedSettings.getControl("RenderUseStreamVBO")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("WLSkyDetail")->getSignal()->connect(boost::bind(&handleWLSkyDetailChanged, _2));
-	gSavedSettings.getControl("RenderLightingDetail")->getSignal()->connect(boost::bind(&handleRenderLightingDetailChanged, _2));
 	gSavedSettings.getControl("NumpadControl")->getSignal()->connect(boost::bind(&handleNumpadControlChanged, _2));
 	gSavedSettings.getControl("JoystickAxis0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
 	gSavedSettings.getControl("JoystickAxis1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index c15f93d9aa5..a0d0b9d4904 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -317,10 +317,16 @@ S32 LLViewerShaderMgr::getVertexShaderLevel(S32 type)
 
 void LLViewerShaderMgr::setShaders()
 {
-	if (!gPipeline.mInitialized || !sInitialized)
+	//setShaders might be called redundantly by gSavedSettings, so return on reentrance
+	static bool reentrance = false;
+	
+	if (!gPipeline.mInitialized || !sInitialized || reentrance)
 	{
 		return;
 	}
+
+	reentrance = true;
+
 	// Make sure the compiled shader map is cleared before we recompile shaders.
 	mShaderObjects.clear();
 	
@@ -368,15 +374,8 @@ void LLViewerShaderMgr::setShaders()
 		S32 wl_class = 2;
 		S32 water_class = 2;
 		S32 deferred_class = 0;
-		if (!(LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")
-			  && gSavedSettings.getBOOL("WindLightUseAtmosShaders")))
-		{
-			// user has disabled WindLight in their settings, downgrade
-			// windlight shaders to stub versions.
-			wl_class = 1;
-		}
-
-		if (LLPipeline::sRenderDeferred)
+		
+		if (gSavedSettings.getBOOL("RenderDeferred"))
 		{
 			if (gSavedSettings.getS32("RenderShadowDetail") > 0)
 			{
@@ -393,6 +392,24 @@ void LLViewerShaderMgr::setShaders()
 			{ //no shadows
 				deferred_class = 1;
 			}
+
+			//make sure framebuffer objects are enabled
+			gSavedSettings.setBOOL("RenderUseFBO", TRUE);
+
+			//make sure hardware skinning is enabled
+			gSavedSettings.setBOOL("RenderAvatarVP", TRUE);
+			
+			//make sure atmospheric shaders are enabled
+			gSavedSettings.setBOOL("WindLightUseAtmosShaders", TRUE);
+		}
+
+
+		if (!(LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")
+			  && gSavedSettings.getBOOL("WindLightUseAtmosShaders")))
+		{
+			// user has disabled WindLight in their settings, downgrade
+			// windlight shaders to stub versions.
+			wl_class = 1;
 		}
 
 		if(!gSavedSettings.getBOOL("EnableRippleWater"))
@@ -517,6 +534,8 @@ void LLViewerShaderMgr::setShaders()
 		gViewerWindow->setCursor(UI_CURSOR_ARROW);
 	}
 	gPipeline.createGLBuffers();
+
+	reentrance = false;
 }
 
 void LLViewerShaderMgr::unloadShaders()
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index b7c265be597..b0c4b6fc8a0 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -592,7 +592,7 @@ void update_statistics(U32 frame_count)
 		}
 	}
 	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
-	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gSavedSettings.getS32("RenderLightingDetail"));
+	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
 	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip"));
 	LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
 #if 0 // 1.9.2
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index fc81241080f..21052775bd9 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -408,6 +408,8 @@ void LLPipeline::init()
 	{
 		mSpotLightFade[i] = 1.f;
 	}
+
+	setLightingDetail(-1);
 }
 
 LLPipeline::~LLPipeline()
@@ -904,13 +906,18 @@ S32 LLPipeline::setLightingDetail(S32 level)
 
 	if (level < 0)
 	{
-		level = gSavedSettings.getS32("RenderLightingDetail");
+		if (gSavedSettings.getBOOL("VertexShaderEnable"))
+		{
+			level = 1;
+		}
+		else
+		{
+			level = 0;
+		}
 	}
 	level = llclamp(level, 0, getMaxLightingDetail());
 	if (level != mLightingDetail)
 	{
-		gSavedSettings.setS32("RenderLightingDetail", level);
-		
 		mLightingDetail = level;
 
 		if (mVertexShadersLoaded == 1)
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 96083bd5fa8..87502537d32 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -215,12 +215,15 @@
 		control_name="RenderDeferred"
 		height="16"
 		initial_value="true"
-		label="Lighting Shaders"
+		label="Lighting and Shadows"
 		layout="topleft"
 		left_delta="0"
 		name="UseLightShaders"
 		top_pad="1"
-		width="256"/>
+		width="256">
+      <check_box.commit_callback
+			function="Pref.VertexShaderEnable" />
+    </check_box>
     <check_box
 		control_name="RenderDeferredSSAO"
 		height="16"
@@ -230,9 +233,12 @@
 		left_delta="0"
 		name="UseSSAO"
 		top_pad="1"
-		width="256"/>
+		width="256">
+      <check_box.commit_callback
+			function="Pref.VertexShaderEnable" />
+    </check_box>
 
-      <text
+     <text
     type="string"
     length="1"
     top_pad="8"
@@ -242,72 +248,72 @@
     word_wrap="true"
     layout="topleft"
     left="10"
-    name="reflection_label">
-        Water Reflections:
+    name="shadows_label">
+        Shadows:
       </text>
       <combo_box
-      control_name="RenderReflectionDetail"
+      control_name="RenderShadowDetail"
       height="23"
       layout="topleft"
-      left_="10"
-      top_pad ="0" 
-      name="Reflections"
+      left="10"
+      top_pad="0" 
+      name="ShadowDetail"
       width="150">
         <combo_box.item
         label="None"
         name="0"
         value="0"/>
         <combo_box.item
-        label="Terrain and trees"
+        label="Sun/Moon"
         name="1"
         value="1"/>
         <combo_box.item
-        label="All static objects"
+        label="Sun/Moon + Projectors"
         name="2"
         value="2"/>
-        <combo_box.item
-        label="All avatars and objects"
-        name="3"
-        value="3"/>
-        <combo_box.item
-        label="Everything"
-        name="4"
-        value="4"/>
       </combo_box>
 
       <text
-    type="string"
-    length="1"
-    top_pad="8"
-    follows="top|left"
-    height="23"
-    width="110"
-    word_wrap="true"
-    layout="topleft"
-    left="10"
-    name="shadows_label">
-        Shadows:
+  type="string"
+  length="1"
+  top_pad="8"
+  follows="top|left"
+  height="23"
+  width="110"
+  word_wrap="true"
+  layout="topleft"
+  left="10"
+  name="reflection_label">
+        Water Reflections:
       </text>
       <combo_box
-      control_name="RenderShadowDetail"
+      control_name="RenderReflectionDetail"
       height="23"
       layout="topleft"
-      left="10"
-      top_pad="0" 
-      name="ShadowDetailRadio"
+      left_="10"
+      top_pad ="0"
+      name="Reflections"
       width="150">
         <combo_box.item
         label="None"
         name="0"
         value="0"/>
         <combo_box.item
-        label="Sun/Moon"
+        label="Terrain and trees"
         name="1"
         value="1"/>
         <combo_box.item
-        label="Sun/Moon + Projectors"
+        label="All static objects"
         name="2"
         value="2"/>
+        <combo_box.item
+        label="All avatars and objects"
+        name="3"
+        value="3"/>
+        <combo_box.item
+        label="Everything"
+        name="4"
+        value="4"/>
       </combo_box>
     
 		<slider
-- 
GitLab


From fc3ae43f70d68865de6b8e2f353b867ddbb8371a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 21 Mar 2010 18:59:44 +0000
Subject: [PATCH 224/683] indra/llcommon/llthread.h : dos2unix

---
 indra/llcommon/llthread.h | 570 +++++++++++++++++++-------------------
 1 file changed, 285 insertions(+), 285 deletions(-)

diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index 5d5ecd62fc3..4b6c3df1055 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -1,285 +1,285 @@
-/** 
- * @file llthread.h
- * @brief Base classes for thread, mutex and condition handling.
- *
- * $LicenseInfo:firstyear=2004&license=viewergpl$
- * 
- * Copyright (c) 2004-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLTHREAD_H
-#define LL_LLTHREAD_H
-
-#include "llapp.h"
-#include "llapr.h"
-#include "apr_thread_cond.h"
-
-class LLThread;
-class LLMutex;
-class LLCondition;
-
-#if LL_WINDOWS
-#define ll_thread_local __declspec(thread)
-#else
-#define ll_thread_local __thread
-#endif
-
-class LL_COMMON_API LLThread
-{
-private:
-	static U32 sIDIter;
-
-public:
-	typedef enum e_thread_status
-	{
-		STOPPED = 0,	// The thread is not running.  Not started, or has exited its run function
-		RUNNING = 1,	// The thread is currently running
-		QUITTING= 2 	// Someone wants this thread to quit
-	} EThreadStatus;
-
-	LLThread(const std::string& name, apr_pool_t *poolp = NULL);
-	virtual ~LLThread(); // Warning!  You almost NEVER want to destroy a thread unless it's in the STOPPED state.
-	virtual void shutdown(); // stops the thread
-	
-	bool isQuitting() const { return (QUITTING == mStatus); }
-	bool isStopped() const { return (STOPPED == mStatus); }
-	
-	static U32 currentID(); // Return ID of current thread
-	static void yield(); // Static because it can be called by the main thread, which doesn't have an LLThread data structure.
-	
-public:
-	// PAUSE / RESUME functionality. See source code for important usage notes.
-	// Called from MAIN THREAD.
-	void pause();
-	void unpause();
-	bool isPaused() { return isStopped() || mPaused == TRUE; }
-	
-	// Cause the thread to wake up and check its condition
-	void wake();
-
-	// Same as above, but to be used when the condition is already locked.
-	void wakeLocked();
-
-	// Called from run() (CHILD THREAD). Pause the thread if requested until unpaused.
-	void checkPause();
-
-	// this kicks off the apr thread
-	void start(void);
-
-	apr_pool_t *getAPRPool() { return mAPRPoolp; }
-	LLVolatileAPRPool* getLocalAPRFilePool() { return mLocalAPRFilePoolp ; }
-
-	U32 getID() const { return mID; }
-
-private:
-	BOOL				mPaused;
-	
-	// static function passed to APR thread creation routine
-	static void *APR_THREAD_FUNC staticRun(apr_thread_t *apr_threadp, void *datap);
-
-protected:
-	std::string			mName;
-	LLCondition*		mRunCondition;
-
-	apr_thread_t		*mAPRThreadp;
-	apr_pool_t			*mAPRPoolp;
-	BOOL				mIsLocalPool;
-	EThreadStatus		mStatus;
-	U32					mID;
-
-	//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
-	//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
-	//      otherwise it will cause severe memory leaking!!! --bao
-	LLVolatileAPRPool  *mLocalAPRFilePoolp ; 
-
-	void setQuitting();
-	
-	// virtual function overridden by subclass -- this will be called when the thread runs
-	virtual void run(void) = 0; 
-	
-	// virtual predicate function -- returns true if the thread should wake up, false if it should sleep.
-	virtual bool runCondition(void);
-
-	// Lock/Unlock Run Condition -- use around modification of any variable used in runCondition()
-	inline void lockData();
-	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
-	// 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();
-	// if(!shouldSleep())
-	//     mRunCondition->signal();
-	// mRunCondition->unlock();
-};
-
-//============================================================================
-
-#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO)
-
-class LL_COMMON_API LLMutex
-{
-public:
-	typedef enum
-	{
-		NO_THREAD = 0xFFFFFFFF
-	} e_locking_thread;
-
-	LLMutex(apr_pool_t *apr_poolp); // NULL pool constructs a new pool for the mutex
-	~LLMutex();
-	
-	void lock();		// blocks
-	void unlock();
-	bool isLocked(); 	// non-blocking, but does do a lock/unlock so not free
-	U32 lockingThread() const; //get ID of locking thread
-	
-protected:
-	apr_thread_mutex_t *mAPRMutexp;
-	mutable U32			mCount;
-	mutable U32			mLockingThread;
-	
-	apr_pool_t			*mAPRPoolp;
-	BOOL				mIsLocalPool;
-	
-#if MUTEX_DEBUG
-	std::map<U32, BOOL> mIsLocked;
-#endif
-};
-
-// Actually a condition/mutex pair (since each condition needs to be associated with a mutex).
-class LL_COMMON_API LLCondition : public LLMutex
-{
-public:
-	LLCondition(apr_pool_t *apr_poolp); // Defaults to global pool, could use the thread pool as well.
-	~LLCondition();
-	
-	void wait();		// blocks
-	void signal();
-	void broadcast();
-	
-protected:
-	apr_thread_cond_t *mAPRCondp;
-};
-
-class LLMutexLock
-{
-public:
-	LLMutexLock(LLMutex* mutex)
-	{
-		mMutex = mutex;
-		mMutex->lock();
-	}
-	~LLMutexLock()
-	{
-		mMutex->unlock();
-	}
-private:
-	LLMutex* mMutex;
-};
-
-//============================================================================
-
-void LLThread::lockData()
-{
-	mRunCondition->lock();
-}
-
-void LLThread::unlockData()
-{
-	mRunCondition->unlock();
-}
-
-
-//============================================================================
-
-// see llmemory.h for LLPointer<> definition
-
-class LL_COMMON_API LLThreadSafeRefCount
-{
-public:
-	static void initThreadSafeRefCount(); // creates sMutex
-	static void cleanupThreadSafeRefCount(); // destroys sMutex
-	
-private:
-	static LLMutex* sMutex;
-
-private:
-	LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented
-	LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented
-
-protected:
-	virtual ~LLThreadSafeRefCount(); // use unref()
-	
-public:
-	LLThreadSafeRefCount();
-	
-	void ref()
-	{
-		if (sMutex) sMutex->lock();
-		mRef++; 
-		if (sMutex) sMutex->unlock();
-	} 
-
-	S32 unref()
-	{
-		llassert(mRef >= 1);
-		if (sMutex) sMutex->lock();
-		S32 res = --mRef;
-		if (sMutex) sMutex->unlock();
-		if (0 == res) 
-		{
-			delete this; 
-			return 0;
-		}
-		return res;
-	}	
-	S32 getNumRefs() const
-	{
-		return mRef;
-	}
-
-private: 
-	S32	mRef; 
-};
-
-//============================================================================
-
-// Simple responder for self destructing callbacks
-// Pure virtual class
-class LL_COMMON_API LLResponder : public LLThreadSafeRefCount
-{
-protected:
-	virtual ~LLResponder();
-public:
-	virtual void completed(bool success) = 0;
-};
-
-//============================================================================
-
-#endif // LL_LLTHREAD_H
+/** 
+ * @file llthread.h
+ * @brief Base classes for thread, mutex and condition handling.
+ *
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLTHREAD_H
+#define LL_LLTHREAD_H
+
+#include "llapp.h"
+#include "llapr.h"
+#include "apr_thread_cond.h"
+
+class LLThread;
+class LLMutex;
+class LLCondition;
+
+#if LL_WINDOWS
+#define ll_thread_local __declspec(thread)
+#else
+#define ll_thread_local __thread
+#endif
+
+class LL_COMMON_API LLThread
+{
+private:
+	static U32 sIDIter;
+
+public:
+	typedef enum e_thread_status
+	{
+		STOPPED = 0,	// The thread is not running.  Not started, or has exited its run function
+		RUNNING = 1,	// The thread is currently running
+		QUITTING= 2 	// Someone wants this thread to quit
+	} EThreadStatus;
+
+	LLThread(const std::string& name, apr_pool_t *poolp = NULL);
+	virtual ~LLThread(); // Warning!  You almost NEVER want to destroy a thread unless it's in the STOPPED state.
+	virtual void shutdown(); // stops the thread
+	
+	bool isQuitting() const { return (QUITTING == mStatus); }
+	bool isStopped() const { return (STOPPED == mStatus); }
+	
+	static U32 currentID(); // Return ID of current thread
+	static void yield(); // Static because it can be called by the main thread, which doesn't have an LLThread data structure.
+	
+public:
+	// PAUSE / RESUME functionality. See source code for important usage notes.
+	// Called from MAIN THREAD.
+	void pause();
+	void unpause();
+	bool isPaused() { return isStopped() || mPaused == TRUE; }
+	
+	// Cause the thread to wake up and check its condition
+	void wake();
+
+	// Same as above, but to be used when the condition is already locked.
+	void wakeLocked();
+
+	// Called from run() (CHILD THREAD). Pause the thread if requested until unpaused.
+	void checkPause();
+
+	// this kicks off the apr thread
+	void start(void);
+
+	apr_pool_t *getAPRPool() { return mAPRPoolp; }
+	LLVolatileAPRPool* getLocalAPRFilePool() { return mLocalAPRFilePoolp ; }
+
+	U32 getID() const { return mID; }
+
+private:
+	BOOL				mPaused;
+	
+	// static function passed to APR thread creation routine
+	static void *APR_THREAD_FUNC staticRun(apr_thread_t *apr_threadp, void *datap);
+
+protected:
+	std::string			mName;
+	LLCondition*		mRunCondition;
+
+	apr_thread_t		*mAPRThreadp;
+	apr_pool_t			*mAPRPoolp;
+	BOOL				mIsLocalPool;
+	EThreadStatus		mStatus;
+	U32					mID;
+
+	//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
+	//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
+	//      otherwise it will cause severe memory leaking!!! --bao
+	LLVolatileAPRPool  *mLocalAPRFilePoolp ; 
+
+	void setQuitting();
+	
+	// virtual function overridden by subclass -- this will be called when the thread runs
+	virtual void run(void) = 0; 
+	
+	// virtual predicate function -- returns true if the thread should wake up, false if it should sleep.
+	virtual bool runCondition(void);
+
+	// Lock/Unlock Run Condition -- use around modification of any variable used in runCondition()
+	inline void lockData();
+	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
+	// 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();
+	// if(!shouldSleep())
+	//     mRunCondition->signal();
+	// mRunCondition->unlock();
+};
+
+//============================================================================
+
+#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO)
+
+class LL_COMMON_API LLMutex
+{
+public:
+	typedef enum
+	{
+		NO_THREAD = 0xFFFFFFFF
+	} e_locking_thread;
+
+	LLMutex(apr_pool_t *apr_poolp); // NULL pool constructs a new pool for the mutex
+	~LLMutex();
+	
+	void lock();		// blocks
+	void unlock();
+	bool isLocked(); 	// non-blocking, but does do a lock/unlock so not free
+	U32 lockingThread() const; //get ID of locking thread
+	
+protected:
+	apr_thread_mutex_t *mAPRMutexp;
+	mutable U32			mCount;
+	mutable U32			mLockingThread;
+	
+	apr_pool_t			*mAPRPoolp;
+	BOOL				mIsLocalPool;
+	
+#if MUTEX_DEBUG
+	std::map<U32, BOOL> mIsLocked;
+#endif
+};
+
+// Actually a condition/mutex pair (since each condition needs to be associated with a mutex).
+class LL_COMMON_API LLCondition : public LLMutex
+{
+public:
+	LLCondition(apr_pool_t *apr_poolp); // Defaults to global pool, could use the thread pool as well.
+	~LLCondition();
+	
+	void wait();		// blocks
+	void signal();
+	void broadcast();
+	
+protected:
+	apr_thread_cond_t *mAPRCondp;
+};
+
+class LLMutexLock
+{
+public:
+	LLMutexLock(LLMutex* mutex)
+	{
+		mMutex = mutex;
+		mMutex->lock();
+	}
+	~LLMutexLock()
+	{
+		mMutex->unlock();
+	}
+private:
+	LLMutex* mMutex;
+};
+
+//============================================================================
+
+void LLThread::lockData()
+{
+	mRunCondition->lock();
+}
+
+void LLThread::unlockData()
+{
+	mRunCondition->unlock();
+}
+
+
+//============================================================================
+
+// see llmemory.h for LLPointer<> definition
+
+class LL_COMMON_API LLThreadSafeRefCount
+{
+public:
+	static void initThreadSafeRefCount(); // creates sMutex
+	static void cleanupThreadSafeRefCount(); // destroys sMutex
+	
+private:
+	static LLMutex* sMutex;
+
+private:
+	LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented
+	LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented
+
+protected:
+	virtual ~LLThreadSafeRefCount(); // use unref()
+	
+public:
+	LLThreadSafeRefCount();
+	
+	void ref()
+	{
+		if (sMutex) sMutex->lock();
+		mRef++; 
+		if (sMutex) sMutex->unlock();
+	} 
+
+	S32 unref()
+	{
+		llassert(mRef >= 1);
+		if (sMutex) sMutex->lock();
+		S32 res = --mRef;
+		if (sMutex) sMutex->unlock();
+		if (0 == res) 
+		{
+			delete this; 
+			return 0;
+		}
+		return res;
+	}	
+	S32 getNumRefs() const
+	{
+		return mRef;
+	}
+
+private: 
+	S32	mRef; 
+};
+
+//============================================================================
+
+// Simple responder for self destructing callbacks
+// Pure virtual class
+class LL_COMMON_API LLResponder : public LLThreadSafeRefCount
+{
+protected:
+	virtual ~LLResponder();
+public:
+	virtual void completed(bool success) = 0;
+};
+
+//============================================================================
+
+#endif // LL_LLTHREAD_H
-- 
GitLab


From eb3206fb93187efdef3dce389862ed31be516963 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 22 Mar 2010 16:10:34 +0000
Subject: [PATCH 225/683] screen-space reflections mk4.  generally subtle. 
 very cheap.

---
 .../shaders/class1/deferred/softenLightF.glsl | 47 ++++++++++++++----
 .../shaders/class2/deferred/softenLightF.glsl | 48 +++++++++++++++----
 .../shaders/class3/deferred/softenLightF.glsl | 48 +++++++++++++++----
 3 files changed, 119 insertions(+), 24 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 9cf60aad489..7d57eaa13d9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -56,9 +56,8 @@ vec3 vary_AtmosAttenuation;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+vec4 getPosition_d(vec2 pos_screen, float depth)
+{
 	vec2 sc = pos_screen.xy*2.0;
 	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
@@ -69,6 +68,12 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
+vec4 getPosition(vec2 pos_screen)
+{ //get position in screen space (world units) given window coordinate and depth map
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	return getPosition_d(pos_screen, depth);
+}
+
 vec3 getPositionEye()
 {
 	return vary_PositionEye;
@@ -252,7 +257,8 @@ vec3 scaleSoftClip(vec3 light)
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
-	vec3 pos = getPosition(tc).xyz;
+	float depth = texture2DRect(depthMap, tc.xy).a;
+	vec3 pos = getPosition_d(tc, depth).xyz;
 	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
@@ -272,11 +278,36 @@ void main()
 	
 	col *= diffuse.rgb;
 	
-	if (spec.a > 0.0)
+	if (spec.a > 0.0) // specular reflection
 	{
-		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		// the old infinite-sky shiny reflection
+		//
+		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnorm, vary_light.xyz);
+		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
+
+		// screen-space cheap fakey reflection map
+		//
+		// first figure out where we'll make our 2D guess from
+		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// get attributes from the 2D guess point
+		float refdepth = texture2DRect(depthMap, ref2d).a;
+		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
+		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
+		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		// figure out how appropriate our guess actually was
+		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
+		// darken reflections from points which face away from the reflected ray - our guess was a back-face
+		//refapprop *= step(dot(refnorm, refn), 0.0);
+		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
+		// get appropriate light strength for guess-point
+		float reflit = max(dot(refn, vary_light.xyz), 0.0);
+		// apply sun color to guess-point, dampen according to inappropriateness of guess
+		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		vec3 ssshiny = (refprod * spec.a);
+
+		// add the two types of shiny together
+		col += (ssshiny + dumbshiny) * spec.rgb;
 	}
 	
 	col = atmosLighting(col);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 589a2927515..c5530c5f594 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -55,9 +55,8 @@ vec3 vary_AmblitColor;
 vec3 vary_AdditiveColor;
 vec3 vary_AtmosAttenuation;
 
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+vec4 getPosition_d(vec2 pos_screen, float depth)
+{
 	vec2 sc = pos_screen.xy*2.0;
 	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
@@ -68,6 +67,12 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
+vec4 getPosition(vec2 pos_screen)
+{ //get position in screen space (world units) given window coordinate and depth map
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	return getPosition_d(pos_screen, depth);
+}
+
 vec3 getPositionEye()
 {
 	return vary_PositionEye;
@@ -251,7 +256,8 @@ vec3 scaleSoftClip(vec3 light)
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
-	vec3 pos = getPosition(tc).xyz;
+	float depth = texture2DRect(depthMap, tc.xy).a;
+	vec3 pos = getPosition_d(tc, depth).xyz;
 	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
@@ -271,11 +277,37 @@ void main()
 	
 	col *= diffuse.rgb;
 	
-	if (spec.a > 0.0)
+	if (spec.a > 0.0) // specular reflection
 	{
-		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		// the old infinite-sky shiny reflection
+		//
+		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnorm, vary_light.xyz);
+		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
+
+		// screen-space cheap fakey reflection map
+		//
+		// first figure out where we'll make our 2D guess from
+		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// get attributes from the 2D guess point
+		float refdepth = texture2DRect(depthMap, ref2d).a;
+		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
+		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
+		float refshad = texture2DRect(lightMap, ref2d).r;
+		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		// figure out how appropriate our guess actually was
+		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
+		// darken reflections from points which face away from the reflected ray - our guess was a back-face
+		//refapprop *= step(dot(refnorm, refn), 0.0);
+		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
+		// get appropriate light strength for guess-point
+		float reflit = min(max(dot(refn, vary_light.xyz), 0.0), refshad);
+		// apply sun color to guess-point, dampen according to inappropriateness of guess
+		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		vec3 ssshiny = (refprod * spec.a);
+
+		// add the two types of shiny together
+		col += (ssshiny + dumbshiny) * spec.rgb;
 	}
 	
 	col = atmosLighting(col);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 96a083b5221..265fb437ec5 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -56,9 +56,8 @@ vec3 vary_AdditiveColor;
 vec3 vary_AtmosAttenuation;
 uniform float gi_ambiance;
 
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+vec4 getPosition_d(vec2 pos_screen, float depth)
+{
 	vec2 sc = pos_screen.xy*2.0;
 	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
@@ -69,6 +68,12 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
+vec4 getPosition(vec2 pos_screen)
+{ //get position in screen space (world units) given window coordinate and depth map
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	return getPosition_d(pos_screen, depth);
+}
+
 vec3 getPositionEye()
 {
 	return vary_PositionEye;
@@ -252,7 +257,8 @@ vec3 scaleSoftClip(vec3 light)
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
-	vec3 pos = getPosition(tc).xyz;
+	float depth = texture2DRect(depthMap, tc.xy).a;
+	vec3 pos = getPosition_d(tc, depth).xyz;
 	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
@@ -274,11 +280,37 @@ void main()
 	
 	col *= diffuse.rgb;
 	
-	if (spec.a > 0.0)
+	if (spec.a > 0.0) // specular reflection
 	{
-		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		// the old infinite-sky shiny reflection
+		//
+		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnorm, vary_light.xyz);
+		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
+
+		// screen-space cheap fakey reflection map
+		//
+		// first figure out where we'll make our 2D guess from
+		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// get attributes from the 2D guess point
+		float refdepth = texture2DRect(depthMap, ref2d).a;
+		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
+		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
+		float refshad = texture2DRect(lightMap, ref2d).r;
+		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		// figure out how appropriate our guess actually was
+		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
+		// darken reflections from points which face away from the reflected ray - our guess was a back-face
+		//refapprop *= step(dot(refnorm, refn), 0.0);
+		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
+		// get appropriate light strength for guess-point
+		float reflit = min(max(dot(refn, vary_light.xyz), 0.0), refshad);
+		// apply sun color to guess-point, dampen according to inappropriateness of guess
+		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		vec3 ssshiny = (refprod * spec.a);
+
+		// add the two types of shiny together
+		col += (ssshiny + dumbshiny) * spec.rgb;
 	}
 	
 	col = atmosLighting(col);
-- 
GitLab


From 28618d0d3bf93790cc70da247c2a723df0778b05 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 22 Mar 2010 16:10:34 +0000
Subject: [PATCH 226/683] screen-space reflections mk4.  generally subtle. 
 very cheap.

---
 .../shaders/class1/deferred/softenLightF.glsl | 47 ++++++++++++++----
 .../shaders/class2/deferred/softenLightF.glsl | 48 +++++++++++++++----
 .../shaders/class3/deferred/softenLightF.glsl | 48 +++++++++++++++----
 3 files changed, 119 insertions(+), 24 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 9cf60aad489..7d57eaa13d9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -56,9 +56,8 @@ vec3 vary_AtmosAttenuation;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+vec4 getPosition_d(vec2 pos_screen, float depth)
+{
 	vec2 sc = pos_screen.xy*2.0;
 	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
@@ -69,6 +68,12 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
+vec4 getPosition(vec2 pos_screen)
+{ //get position in screen space (world units) given window coordinate and depth map
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	return getPosition_d(pos_screen, depth);
+}
+
 vec3 getPositionEye()
 {
 	return vary_PositionEye;
@@ -252,7 +257,8 @@ vec3 scaleSoftClip(vec3 light)
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
-	vec3 pos = getPosition(tc).xyz;
+	float depth = texture2DRect(depthMap, tc.xy).a;
+	vec3 pos = getPosition_d(tc, depth).xyz;
 	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
@@ -272,11 +278,36 @@ void main()
 	
 	col *= diffuse.rgb;
 	
-	if (spec.a > 0.0)
+	if (spec.a > 0.0) // specular reflection
 	{
-		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		// the old infinite-sky shiny reflection
+		//
+		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnorm, vary_light.xyz);
+		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
+
+		// screen-space cheap fakey reflection map
+		//
+		// first figure out where we'll make our 2D guess from
+		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// get attributes from the 2D guess point
+		float refdepth = texture2DRect(depthMap, ref2d).a;
+		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
+		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
+		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		// figure out how appropriate our guess actually was
+		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
+		// darken reflections from points which face away from the reflected ray - our guess was a back-face
+		//refapprop *= step(dot(refnorm, refn), 0.0);
+		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
+		// get appropriate light strength for guess-point
+		float reflit = max(dot(refn, vary_light.xyz), 0.0);
+		// apply sun color to guess-point, dampen according to inappropriateness of guess
+		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		vec3 ssshiny = (refprod * spec.a);
+
+		// add the two types of shiny together
+		col += (ssshiny + dumbshiny) * spec.rgb;
 	}
 	
 	col = atmosLighting(col);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 589a2927515..c5530c5f594 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -55,9 +55,8 @@ vec3 vary_AmblitColor;
 vec3 vary_AdditiveColor;
 vec3 vary_AtmosAttenuation;
 
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+vec4 getPosition_d(vec2 pos_screen, float depth)
+{
 	vec2 sc = pos_screen.xy*2.0;
 	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
@@ -68,6 +67,12 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
+vec4 getPosition(vec2 pos_screen)
+{ //get position in screen space (world units) given window coordinate and depth map
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	return getPosition_d(pos_screen, depth);
+}
+
 vec3 getPositionEye()
 {
 	return vary_PositionEye;
@@ -251,7 +256,8 @@ vec3 scaleSoftClip(vec3 light)
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
-	vec3 pos = getPosition(tc).xyz;
+	float depth = texture2DRect(depthMap, tc.xy).a;
+	vec3 pos = getPosition_d(tc, depth).xyz;
 	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
@@ -271,11 +277,37 @@ void main()
 	
 	col *= diffuse.rgb;
 	
-	if (spec.a > 0.0)
+	if (spec.a > 0.0) // specular reflection
 	{
-		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		// the old infinite-sky shiny reflection
+		//
+		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnorm, vary_light.xyz);
+		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
+
+		// screen-space cheap fakey reflection map
+		//
+		// first figure out where we'll make our 2D guess from
+		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// get attributes from the 2D guess point
+		float refdepth = texture2DRect(depthMap, ref2d).a;
+		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
+		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
+		float refshad = texture2DRect(lightMap, ref2d).r;
+		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		// figure out how appropriate our guess actually was
+		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
+		// darken reflections from points which face away from the reflected ray - our guess was a back-face
+		//refapprop *= step(dot(refnorm, refn), 0.0);
+		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
+		// get appropriate light strength for guess-point
+		float reflit = min(max(dot(refn, vary_light.xyz), 0.0), refshad);
+		// apply sun color to guess-point, dampen according to inappropriateness of guess
+		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		vec3 ssshiny = (refprod * spec.a);
+
+		// add the two types of shiny together
+		col += (ssshiny + dumbshiny) * spec.rgb;
 	}
 	
 	col = atmosLighting(col);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 96a083b5221..265fb437ec5 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -56,9 +56,8 @@ vec3 vary_AdditiveColor;
 vec3 vary_AtmosAttenuation;
 uniform float gi_ambiance;
 
-vec4 getPosition(vec2 pos_screen)
-{ //get position in screen space (world units) given window coordinate and depth map
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+vec4 getPosition_d(vec2 pos_screen, float depth)
+{
 	vec2 sc = pos_screen.xy*2.0;
 	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
@@ -69,6 +68,12 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
+vec4 getPosition(vec2 pos_screen)
+{ //get position in screen space (world units) given window coordinate and depth map
+	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	return getPosition_d(pos_screen, depth);
+}
+
 vec3 getPositionEye()
 {
 	return vary_PositionEye;
@@ -252,7 +257,8 @@ vec3 scaleSoftClip(vec3 light)
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
-	vec3 pos = getPosition(tc).xyz;
+	float depth = texture2DRect(depthMap, tc.xy).a;
+	vec3 pos = getPosition_d(tc, depth).xyz;
 	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
@@ -274,11 +280,37 @@ void main()
 	
 	col *= diffuse.rgb;
 	
-	if (spec.a > 0.0)
+	if (spec.a > 0.0) // specular reflection
 	{
-		vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(ref, vary_light.xyz);
-		col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		// the old infinite-sky shiny reflection
+		//
+		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnorm, vary_light.xyz);
+		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
+
+		// screen-space cheap fakey reflection map
+		//
+		// first figure out where we'll make our 2D guess from
+		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// get attributes from the 2D guess point
+		float refdepth = texture2DRect(depthMap, ref2d).a;
+		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
+		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
+		float refshad = texture2DRect(lightMap, ref2d).r;
+		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		// figure out how appropriate our guess actually was
+		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
+		// darken reflections from points which face away from the reflected ray - our guess was a back-face
+		//refapprop *= step(dot(refnorm, refn), 0.0);
+		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
+		// get appropriate light strength for guess-point
+		float reflit = min(max(dot(refn, vary_light.xyz), 0.0), refshad);
+		// apply sun color to guess-point, dampen according to inappropriateness of guess
+		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		vec3 ssshiny = (refprod * spec.a);
+
+		// add the two types of shiny together
+		col += (ssshiny + dumbshiny) * spec.rgb;
 	}
 	
 	col = atmosLighting(col);
-- 
GitLab


From 87c4bac9356ad7ac9d0328f5d83335f70600da3e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 22 Mar 2010 16:26:15 +0000
Subject: [PATCH 227/683] bring linux featuretable in line with recent win32
 featuretable changes.

---
 indra/newview/featuretable_linux.txt | 86 ++++++++++++++++++++++------
 1 file changed, 67 insertions(+), 19 deletions(-)

diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt
index 61a8e51c50e..254b9c4ce4f 100644
--- a/indra/newview/featuretable_linux.txt
+++ b/indra/newview/featuretable_linux.txt
@@ -23,7 +23,7 @@ version 21
 // NOTE: All settings are set to the MIN of applied values, including 'all'!
 //
 list all
-RenderAnisotropic			1	0
+RenderAnisotropic			1	1
 RenderAvatarCloth			1	1
 RenderAvatarLODFactor		1	1.0
 RenderAvatarVP				1	1
@@ -35,18 +35,16 @@ RenderFogRatio				1	4.0
 RenderGamma					1	0
 RenderGlowResolutionPow		1	9
 RenderGround				1	1
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderNightBrightness		1	1.0
 RenderObjectBump			1	1
-RenderReflectionDetail		1	3
+RenderReflectionDetail		1	4
 RenderTerrainDetail			1	1
 RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	1.0
 RenderUseImpostors			1	1
 RenderVBOEnable				1	1
 RenderVolumeLODFactor		1	2.0
-RenderWaterReflections		1	1
 UseStartScreen				1	1
 UseOcclusion				1	1
 VertexShaderEnable			1	1
@@ -55,6 +53,10 @@ WLSkyDetail					1	128
 Disregard128DefaultDrawDistance	1	1
 Disregard96DefaultDrawDistance	1	1
 RenderTextureMemoryMultiple		1	1.0
+RenderShaderLightingMaxLevel		1	3
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
+RenderShadowDetail			1	2
 
 //
 // Low Graphics Settings
@@ -67,7 +69,6 @@ RenderAvatarVP				1	0
 RenderFarClip				1	64
 RenderFlexTimeFactor		1	0.5
 RenderGlowResolutionPow		1	8
-RenderLightingDetail		1	0
 RenderMaxPartCount			1	1024
 RenderObjectBump			1	0
 RenderReflectionDetail		1	0
@@ -76,10 +77,13 @@ RenderTerrainLODFactor		1	1
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	0
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
+
 
 //
 // Mid Graphics Settings
@@ -92,7 +96,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	96
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	8
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	2048
 RenderObjectBump			1	1
 RenderReflectionDetail		1	0
@@ -101,10 +104,13 @@ RenderTerrainLODFactor		1	1.0
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
+
 
 //
 // High Graphics Settings (purty)
@@ -117,7 +123,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	128
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	9
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	4096
 RenderObjectBump			1	1
 RenderReflectionDetail		1	2
@@ -126,10 +131,13 @@ RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
+RenderDeferred				1	1
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	1
+
 
 //
 // Ultra graphics (REALLY PURTY!)
@@ -142,19 +150,21 @@ RenderAvatarVP				1	1
 RenderFarClip				1	256
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	9
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderObjectBump			1	1
-RenderReflectionDetail		1	3
+RenderReflectionDetail		1	4
 RenderTerrainDetail			1	1
 RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	1.0
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	2.0
-RenderWaterReflections		1	1
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
+RenderShadowDetail			1	2
+
 
 //
 // Class Unknown Hardware (unknown)
@@ -192,9 +202,12 @@ RenderVBOEnable				1	1
 list NoPixelShaders
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
 
 //
 // No Vertex Shaders available
@@ -202,9 +215,13 @@ WindLightUseAtmosShaders	0	0
 list NoVertexShaders
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
+
 
 // "Default" setups for safe, low, medium, high
 //
@@ -212,14 +229,17 @@ list safe
 RenderAnisotropic			1	0
 RenderAvatarCloth			0	0
 RenderAvatarVP				0	0
-RenderLightingDetail		1	0
 RenderObjectBump			0	0
 RenderMaxPartCount			1	1024
 RenderTerrainDetail 		1	0
 RenderUseImpostors			0	0
 RenderVBOEnable				1	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
+
 
 //
 // CPU based feature masks
@@ -243,13 +263,11 @@ RenderVBOEnable				1	0
 
 list Intel
 RenderAnisotropic			1	0
-RenderLightingDetail		1	0
 // Avoid some Intel crashes on Linux
 RenderCubeMap				0	0
 
 list GeForce2
 RenderAnisotropic			1	0
-RenderLightingDetail		1	0
 RenderMaxPartCount			1	2048
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	1
@@ -461,17 +479,47 @@ list NVIDIA_GeForce_Go_6
 RenderVBOEnable				1	0
 Disregard128DefaultDrawDistance	1	0
 
+list NVIDIA_GeForce_7000
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7100
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_7200
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_7300
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_7400
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7500
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7600
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7700
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7800
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7900
+RenderShaderLightingMaxLevel	1	2
 
 list NVIDIA_GeForce_Go_7200
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_Go_7300
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7300_LE
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_Go_7400
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7600
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7700
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7800
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7900
+RenderShaderLightingMaxLevel	1	2
 
-- 
GitLab


From c409abdb95aa571c953083bbbe91fb600bd41c21 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 22 Mar 2010 16:26:15 +0000
Subject: [PATCH 228/683] bring linux featuretable in line with recent win32
 featuretable changes.

---
 indra/newview/featuretable_linux.txt | 101 +++++++++++++++++++--------
 1 file changed, 72 insertions(+), 29 deletions(-)

diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt
index 45de51f3cf1..254b9c4ce4f 100644
--- a/indra/newview/featuretable_linux.txt
+++ b/indra/newview/featuretable_linux.txt
@@ -23,10 +23,9 @@ version 21
 // NOTE: All settings are set to the MIN of applied values, including 'all'!
 //
 list all
-RenderAnisotropic			1	0
+RenderAnisotropic			1	1
 RenderAvatarCloth			1	1
 RenderAvatarLODFactor		1	1.0
-RenderAvatarMaxVisible      1   12
 RenderAvatarVP				1	1
 RenderCubeMap				1	1
 RenderDelayVBUpdate			1	0
@@ -36,18 +35,16 @@ RenderFogRatio				1	4.0
 RenderGamma					1	0
 RenderGlowResolutionPow		1	9
 RenderGround				1	1
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderNightBrightness		1	1.0
 RenderObjectBump			1	1
-RenderReflectionDetail		1	3
+RenderReflectionDetail		1	4
 RenderTerrainDetail			1	1
 RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	1.0
 RenderUseImpostors			1	1
 RenderVBOEnable				1	1
 RenderVolumeLODFactor		1	2.0
-RenderWaterReflections		1	1
 UseStartScreen				1	1
 UseOcclusion				1	1
 VertexShaderEnable			1	1
@@ -56,8 +53,10 @@ WLSkyDetail					1	128
 Disregard128DefaultDrawDistance	1	1
 Disregard96DefaultDrawDistance	1	1
 RenderTextureMemoryMultiple		1	1.0
-SkyUseClassicClouds			1	1
-WatchdogDisabled				1	1
+RenderShaderLightingMaxLevel		1	3
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
+RenderShadowDetail			1	2
 
 //
 // Low Graphics Settings
@@ -65,26 +64,26 @@ WatchdogDisabled				1	1
 list Low
 RenderAnisotropic			1	0
 RenderAvatarCloth			1	0
-RenderAvatarLODFactor		1	0
-RenderAvatarMaxVisible      1   3
+RenderAvatarLODFactor		1	0.5
 RenderAvatarVP				1	0
 RenderFarClip				1	64
-RenderFlexTimeFactor		1	0
+RenderFlexTimeFactor		1	0.5
 RenderGlowResolutionPow		1	8
-RenderLightingDetail		1	0
-RenderMaxPartCount			1	0
+RenderMaxPartCount			1	1024
 RenderObjectBump			1	0
 RenderReflectionDetail		1	0
 RenderTerrainDetail			1	0
 RenderTerrainLODFactor		1	1
-RenderTreeLODFactor			1	0
+RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
-RenderVolumeLODFactor		1	0
-RenderWaterReflections		1	0
+RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	0
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
-SkyUseClassicClouds			1	0
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
+
 
 //
 // Mid Graphics Settings
@@ -97,7 +96,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	96
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	8
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	2048
 RenderObjectBump			1	1
 RenderReflectionDetail		1	0
@@ -106,10 +104,13 @@ RenderTerrainLODFactor		1	1.0
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	0
 WLSkyDetail					1	48
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
+
 
 //
 // High Graphics Settings (purty)
@@ -122,7 +123,6 @@ RenderAvatarVP				1	1
 RenderFarClip				1	128
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	9
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	4096
 RenderObjectBump			1	1
 RenderReflectionDetail		1	2
@@ -131,10 +131,13 @@ RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	0.5
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	1.125
-RenderWaterReflections		1	0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
+RenderDeferred				1	1
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	1
+
 
 //
 // Ultra graphics (REALLY PURTY!)
@@ -147,19 +150,21 @@ RenderAvatarVP				1	1
 RenderFarClip				1	256
 RenderFlexTimeFactor		1	1.0
 RenderGlowResolutionPow		1	9
-RenderLightingDetail		1	1
 RenderMaxPartCount			1	8192
 RenderObjectBump			1	1
-RenderReflectionDetail		1	3
+RenderReflectionDetail		1	4
 RenderTerrainDetail			1	1
 RenderTerrainLODFactor		1	2.0
 RenderTreeLODFactor			1	1.0
 RenderUseImpostors			1	1
 RenderVolumeLODFactor		1	2.0
-RenderWaterReflections		1	1
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
+RenderShadowDetail			1	2
+
 
 //
 // Class Unknown Hardware (unknown)
@@ -197,9 +202,12 @@ RenderVBOEnable				1	1
 list NoPixelShaders
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
 
 //
 // No Vertex Shaders available
@@ -207,9 +215,13 @@ WindLightUseAtmosShaders	0	0
 list NoVertexShaders
 RenderAvatarVP				0	0
 RenderAvatarCloth			0	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 VertexShaderEnable			0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
+
 
 // "Default" setups for safe, low, medium, high
 //
@@ -217,14 +229,17 @@ list safe
 RenderAnisotropic			1	0
 RenderAvatarCloth			0	0
 RenderAvatarVP				0	0
-RenderLightingDetail		1	0
 RenderObjectBump			0	0
 RenderMaxPartCount			1	1024
 RenderTerrainDetail 		1	0
 RenderUseImpostors			0	0
 RenderVBOEnable				1	0
-RenderWaterReflections		0	0
+RenderReflectionDetail		0	0
 WindLightUseAtmosShaders	0	0
+RenderDeferred				0	0
+RenderDeferredSSAO			0	0
+RenderShadowDetail			0	0
+
 
 //
 // CPU based feature masks
@@ -248,13 +263,11 @@ RenderVBOEnable				1	0
 
 list Intel
 RenderAnisotropic			1	0
-RenderLightingDetail		1	0
 // Avoid some Intel crashes on Linux
 RenderCubeMap				0	0
 
 list GeForce2
 RenderAnisotropic			1	0
-RenderLightingDetail		1	0
 RenderMaxPartCount			1	2048
 RenderTerrainDetail			1	0
 RenderVBOEnable				1	1
@@ -466,17 +479,47 @@ list NVIDIA_GeForce_Go_6
 RenderVBOEnable				1	0
 Disregard128DefaultDrawDistance	1	0
 
+list NVIDIA_GeForce_7000
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7100
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_7200
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_7300
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_7400
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7500
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7600
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7700
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7800
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_7900
+RenderShaderLightingMaxLevel	1	2
 
 list NVIDIA_GeForce_Go_7200
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_Go_7300
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7300_LE
+RenderShaderLightingMaxLevel	1	2
 list NVIDIA_GeForce_Go_7400
 Disregard128DefaultDrawDistance	1	0
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7600
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7700
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7800
+RenderShaderLightingMaxLevel	1	2
+list NVIDIA_GeForce_Go_7900
+RenderShaderLightingMaxLevel	1	2
 
-- 
GitLab


From 500d1ec0ccbad710392c323e9b1f46b2241f7f90 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 22 Mar 2010 16:28:01 +0000
Subject: [PATCH 229/683] lowest water reflection level label 'none' changed to
 a more accurate 'minimal'

---
 .../skins/default/xui/en/panel_preferences_graphics1.xml        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index e6e70948473..66eae5f5163 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -322,7 +322,7 @@
       name="Reflections"
       width="150">
         <combo_box.item
-        label="None"
+        label="Minimal"
         name="0"
         value="0"/>
         <combo_box.item
-- 
GitLab


From 6397be73673d886680705b9f88ca9b9978dd457f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 22 Mar 2010 16:28:01 +0000
Subject: [PATCH 230/683] lowest water reflection level label 'none' changed to
 a more accurate 'minimal'

---
 .../skins/default/xui/en/panel_preferences_graphics1.xml        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 87502537d32..9e48f11de55 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -295,7 +295,7 @@
       name="Reflections"
       width="150">
         <combo_box.item
-        label="None"
+        label="Minimal"
         name="0"
         value="0"/>
         <combo_box.item
-- 
GitLab


From ebea9eed4d30376e8914c0e778250ecc45f9dd22 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Tue, 23 Mar 2010 13:29:40 -0700
Subject: [PATCH 231/683] Fix for crash logger crashing. bleh!

Reviewed by DaveP
---
 indra/llcrashlogger/llcrashlogger.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp
index c1022c1195e..4bda00ed868 100755
--- a/indra/llcrashlogger/llcrashlogger.cpp
+++ b/indra/llcrashlogger/llcrashlogger.cpp
@@ -370,6 +370,8 @@ void LLCrashLogger::updateApplication(const std::string& message)
 
 bool LLCrashLogger::init()
 {
+	LLCurl::initClass();
+
 	// We assume that all the logs we're looking for reside on the current drive
 	gDirUtilp->initAppDirs("SecondLife");
 
-- 
GitLab


From d1eb1310793f20eda065fe788fdb4b833c057823 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Tue, 23 Mar 2010 13:29:40 -0700
Subject: [PATCH 232/683] Fix for crash logger crashing. bleh!

Reviewed by DaveP
---
 indra/llcrashlogger/llcrashlogger.cpp | 93 ++++++++++++++-------------
 1 file changed, 48 insertions(+), 45 deletions(-)
 mode change 100644 => 100755 indra/llcrashlogger/llcrashlogger.cpp

diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp
old mode 100644
new mode 100755
index 2152feaf801..4bda00ed868
--- a/indra/llcrashlogger/llcrashlogger.cpp
+++ b/indra/llcrashlogger/llcrashlogger.cpp
@@ -2,25 +2,31 @@
 * @file llcrashlogger.cpp
 * @brief Crash logger implementation
 *
-* $LicenseInfo:firstyear=2003&license=viewerlgpl$
-* Second Life Viewer Source Code
-* Copyright (C) 2010, Linden Research, Inc.
+* $LicenseInfo:firstyear=2003&license=viewergpl$
+* 
+* Copyright (c) 2003-2009, Linden Research, Inc.
 * 
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation;
-* version 2.1 of the License only.
+* Second Life Viewer Source Code
+* The source code in this file ("Source Code") is provided by Linden Lab
+* to you under the terms of the GNU General Public License, version 2.0
+* ("GPL"), unless you have obtained a separate licensing agreement
+* ("Other License"), formally executed by you and Linden Lab.  Terms of
+* the GPL can be found in doc/GPL-license.txt in this distribution, or
+* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
 * 
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
+* There are special exceptions to the terms and conditions of the GPL as
+* it is applied to this Source Code. View the full text of the exception
+* in the file doc/FLOSS-exception.txt in this software distribution, or
+* online at
+* http://secondlifegrid.net/programs/open_source/licensing/flossexception
 * 
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+* By copying, modifying or distributing this software, you acknowledge
+* that you have read and understood your obligations described above,
+* and agree to abide by those obligations.
 * 
-* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+* COMPLETENESS OR PERFORMANCE.
 * $/LicenseInfo$
 */
 #include <cstdio>
@@ -149,6 +155,25 @@ std::string getStartupStateFromLog(std::string& sllog)
 
 void LLCrashLogger::gatherFiles()
 {
+
+	/*
+	//TODO:This function needs to be reimplemented somewhere in here...
+	if(!previous_crash && is_crash_log)
+	{
+		// Make sure the file isn't too old.
+		double age = difftime(gLaunchTime, stat_data.st_mtimespec.tv_sec);
+		
+		//			llinfos << "age is " << age << llendl;
+		
+		if(age > 60.0)
+		{
+				// The file was last modified more than 60 seconds before the crash reporter was launched.  Assume it's stale.
+			llwarns << "File " << mFilename << " is too old!" << llendl;
+			return;
+		}
+	}
+	*/
+
 	updateApplication("Gathering logs...");
 
 	// Figure out the filename of the debug log
@@ -184,9 +209,11 @@ void LLCrashLogger::gatherFiles()
 		mFileMap["SettingsXml"] = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,"settings.xml");
 	}
 
+#if !LL_DARWIN
 	if(mCrashInPreviousExec)
+#else
+#endif
 	{
-		// Restarting after freeze.
 		// Replace the log file ext with .old, since the 
 		// instance that launched this process has overwritten
 		// SecondLife.log
@@ -198,12 +225,7 @@ void LLCrashLogger::gatherFiles()
 	gatherPlatformSpecificFiles();
 
 	//Use the debug log to reconstruct the URL to send the crash report to
-	if(mDebugLog.has("CrashHostUrl"))
-	{
-		// Crash log receiver has been manually configured.
-		mCrashHost = mDebugLog["CrashHostUrl"].asString();
-	}
-	else if(mDebugLog.has("CurrentSimHost"))
+	if(mDebugLog.has("CurrentSimHost"))
 	{
 		mCrashHost = "https://";
 		mCrashHost += mDebugLog["CurrentSimHost"].asString();
@@ -225,6 +247,7 @@ void LLCrashLogger::gatherFiles()
 
 	mCrashInfo["DebugLog"] = mDebugLog;
 	mFileMap["StatsLog"] = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stats.log");
+	mFileMap["StackTrace"] = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log");
 	
 	updateApplication("Encoding files...");
 
@@ -249,30 +272,8 @@ void LLCrashLogger::gatherFiles()
 			trimSLLog(crash_info);
 		}
 
-		mCrashInfo[(*itr).first] = LLStringFn::strip_invalid_xml(rawstr_to_utf8(crash_info));
+		mCrashInfo[(*itr).first] = rawstr_to_utf8(crash_info);
 	}
-	
-	// Add minidump as binary.
-	std::string minidump_path = mDebugLog["MinidumpPath"];
-	if(minidump_path != "")
-	{
-		std::ifstream minidump_stream(minidump_path.c_str(), std::ios_base::in | std::ios_base::binary);
-		if(minidump_stream.is_open())
-		{
-			minidump_stream.seekg(0, std::ios::end);
-			size_t length = minidump_stream.tellg();
-			minidump_stream.seekg(0, std::ios::beg);
-			
-			LLSD::Binary data;
-			data.resize(length);
-			
-			minidump_stream.read(reinterpret_cast<char *>(&(data[0])),length);
-			minidump_stream.close();
-			
-			mCrashInfo["Minidump"] = data;
-		}
-	}
-	mCrashInfo["DebugLog"].erase("MinidumpPath");
 }
 
 LLSD LLCrashLogger::constructPostData()
@@ -369,6 +370,8 @@ void LLCrashLogger::updateApplication(const std::string& message)
 
 bool LLCrashLogger::init()
 {
+	LLCurl::initClass();
+
 	// We assume that all the logs we're looking for reside on the current drive
 	gDirUtilp->initAppDirs("SecondLife");
 
-- 
GitLab


From fc0bbcbc26aa4fdd8770b9777c58f10d651136e9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 25 Mar 2010 19:22:08 -0500
Subject: [PATCH 233/683] rigged attachments WIP

---
 indra/llrender/llvertexbuffer.cpp | 14 ++++++++++++++
 indra/llrender/llvertexbuffer.h   |  5 +++++
 2 files changed, 19 insertions(+)

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 4064e688e83..d5b00f27a7d 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -62,6 +62,7 @@ BOOL LLVertexBuffer::sIBOActive = FALSE;
 U32 LLVertexBuffer::sAllocatedBytes = 0;
 BOOL LLVertexBuffer::sMapped = FALSE;
 BOOL LLVertexBuffer::sUseStreamDraw = TRUE;
+S32	LLVertexBuffer::sWeight4Loc = -1;
 
 std::vector<U32> LLVertexBuffer::sDeleteList;
 
@@ -76,6 +77,7 @@ S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
 	sizeof(LLColor4U), // TYPE_COLOR,
 	sizeof(LLVector3), // TYPE_BINORMAL,
 	sizeof(F32),	   // TYPE_WEIGHT,
+	sizeof(LLVector4), // TYPE_WEIGHT4,
 	sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
 };
 
@@ -1015,6 +1017,12 @@ bool LLVertexBuffer::getWeightStrider(LLStrider<F32>& strider, S32 index)
 {
 	return VertexBufferStrider<F32,TYPE_WEIGHT>::get(*this, strider, index);
 }
+
+bool LLVertexBuffer::getWeight4Strider(LLStrider<LLVector4>& strider, S32 index)
+{
+	return VertexBufferStrider<LLVector4,TYPE_WEIGHT4>::get(*this, strider, index);
+}
+
 bool LLVertexBuffer::getClothWeightStrider(LLStrider<LLVector4>& strider, S32 index)
 {
 	return VertexBufferStrider<LLVector4,TYPE_CLOTHWEIGHT>::get(*this, strider, index);
@@ -1284,6 +1292,12 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
 	{
 		glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, stride, (void*)(base + mOffsets[TYPE_WEIGHT]));
 	}
+
+	if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
+	{
+		glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, stride, (void*)(base+mOffsets[TYPE_WEIGHT4]));
+	}
+
 	if (data_mask & MAP_CLOTHWEIGHT)
 	{
 		glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  stride, (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index e2fecdffef9..225237215cb 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -84,6 +84,8 @@ class LLVertexBuffer : public LLRefCount
 	static LLVBOPool sStreamIBOPool;
 	static LLVBOPool sDynamicIBOPool;
 	
+	static S32	sWeight4Loc;
+
 	static BOOL	sUseStreamDraw;
 
 	static void initClass(bool use_vbo);
@@ -109,6 +111,7 @@ class LLVertexBuffer : public LLRefCount
 		// These use VertexAttribPointer and should possibly be made generic
 		TYPE_BINORMAL,
 		TYPE_WEIGHT,
+		TYPE_WEIGHT4,
 		TYPE_CLOTHWEIGHT,
 		TYPE_MAX,
 		TYPE_INDEX,
@@ -124,6 +127,7 @@ class LLVertexBuffer : public LLRefCount
 		// These use VertexAttribPointer and should possibly be made generic
 		MAP_BINORMAL = (1<<TYPE_BINORMAL),
 		MAP_WEIGHT = (1<<TYPE_WEIGHT),
+		MAP_WEIGHT4 = (1<<TYPE_WEIGHT4),
 		MAP_CLOTHWEIGHT = (1<<TYPE_CLOTHWEIGHT),
 	};
 	
@@ -173,6 +177,7 @@ class LLVertexBuffer : public LLRefCount
 	bool getBinormalStrider(LLStrider<LLVector3>& strider, S32 index=0);
 	bool getColorStrider(LLStrider<LLColor4U>& strider, S32 index=0);
 	bool getWeightStrider(LLStrider<F32>& strider, S32 index=0);
+	bool getWeight4Strider(LLStrider<LLVector4>& strider, S32 index=0);
 	bool getClothWeightStrider(LLStrider<LLVector4>& strider, S32 index=0);
 	
 	BOOL isEmpty() const					{ return mEmpty; }
-- 
GitLab


From 783b0a72204f10b6d9e554bf17134e14ff90e756 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 26 Mar 2010 09:07:08 +0000
Subject: [PATCH 234/683] screen-space reflections: remember to unbias the
 value from the depth map.  don't use varying version of lightnorm for
 lighting the reflection-guess-point.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl     | 3 ++-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl     | 3 ++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl     | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 7d57eaa13d9..c78d7ece7e8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -288,6 +288,7 @@ void main()
 
 		// screen-space cheap fakey reflection map
 		//
+		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
@@ -301,7 +302,7 @@ void main()
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
 		// get appropriate light strength for guess-point
-		float reflit = max(dot(refn, vary_light.xyz), 0.0);
+		float reflit = max(dot(refn, lightnorm.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		vec3 ssshiny = (refprod * spec.a);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index c5530c5f594..9305d77ddb9 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -287,6 +287,7 @@ void main()
 
 		// screen-space cheap fakey reflection map
 		//
+		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
@@ -301,7 +302,7 @@ void main()
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
 		// get appropriate light strength for guess-point
-		float reflit = min(max(dot(refn, vary_light.xyz), 0.0), refshad);
+		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		vec3 ssshiny = (refprod * spec.a);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 265fb437ec5..262b34ede7f 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -290,6 +290,7 @@ void main()
 
 		// screen-space cheap fakey reflection map
 		//
+		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
@@ -304,7 +305,7 @@ void main()
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
 		// get appropriate light strength for guess-point
-		float reflit = min(max(dot(refn, vary_light.xyz), 0.0), refshad);
+		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		vec3 ssshiny = (refprod * spec.a);
-- 
GitLab


From 122308205b2958b27152b9dd5375554ef76dd084 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 26 Mar 2010 09:07:08 +0000
Subject: [PATCH 235/683] screen-space reflections: remember to unbias the
 value from the depth map.  don't use varying version of lightnorm for
 lighting the reflection-guess-point.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl     | 3 ++-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl     | 3 ++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl     | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 7d57eaa13d9..c78d7ece7e8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -288,6 +288,7 @@ void main()
 
 		// screen-space cheap fakey reflection map
 		//
+		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
@@ -301,7 +302,7 @@ void main()
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
 		// get appropriate light strength for guess-point
-		float reflit = max(dot(refn, vary_light.xyz), 0.0);
+		float reflit = max(dot(refn, lightnorm.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		vec3 ssshiny = (refprod * spec.a);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index c5530c5f594..9305d77ddb9 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -287,6 +287,7 @@ void main()
 
 		// screen-space cheap fakey reflection map
 		//
+		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
@@ -301,7 +302,7 @@ void main()
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
 		// get appropriate light strength for guess-point
-		float reflit = min(max(dot(refn, vary_light.xyz), 0.0), refshad);
+		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		vec3 ssshiny = (refprod * spec.a);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 265fb437ec5..262b34ede7f 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -290,6 +290,7 @@ void main()
 
 		// screen-space cheap fakey reflection map
 		//
+		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
@@ -304,7 +305,7 @@ void main()
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
 		// get appropriate light strength for guess-point
-		float reflit = min(max(dot(refn, vary_light.xyz), 0.0), refshad);
+		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		vec3 ssshiny = (refprod * spec.a);
-- 
GitLab


From 92257b55a405f3625cbbcf07357b3ca929a04882 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Fri, 26 Mar 2010 18:23:05 -0700
Subject: [PATCH 236/683] DEV-47845 Fix to work with TCP/LLSD message. This
 checkin is experimental, so if it breaks a build, just revert to the previous
 changeset.

---
 etc/message.xml                               |  7 +++
 indra/newview/llpanelobject.cpp               | 34 +++++++++++
 indra/newview/llpanelobject.h                 |  6 +-
 indra/newview/llselectmgr.cpp                 | 23 ++++++-
 indra/newview/llselectmgr.h                   |  1 +
 indra/newview/llviewerobject.cpp              | 60 +++++++++++++++++++
 indra/newview/llviewerobject.h                |  6 ++
 .../skins/default/xui/en/floater_tools.xml    | 33 ++++++++++
 scripts/messages/message_template.msg         |  4 ++
 9 files changed, 172 insertions(+), 2 deletions(-)

diff --git a/etc/message.xml b/etc/message.xml
index c17ae3656d0..7283d903b9a 100644
--- a/etc/message.xml
+++ b/etc/message.xml
@@ -572,6 +572,13 @@
 					<boolean>false</boolean>
 				</map>
 
+				<key>ObjectPhysicsProperties</key>
+				<map>
+					<key>flavor</key>
+					<string>llsd</string>
+					<key>trusted-sender</key>
+					<boolean>true</boolean>
+				</map>
 
 		  </map>
   	  	<key>capBans</key>
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 30221da12a8..991e97b767e 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -137,6 +137,10 @@ BOOL	LLPanelObject::postBuild()
 	// Phantom checkbox
 	mCheckPhantom = getChild<LLCheckBoxCtrl>("Phantom Checkbox Ctrl");
 	childSetCommitCallback("Phantom Checkbox Ctrl",onCommitPhantom,this);
+
+	// PhysicsRep combobox
+	mComboPhysicsRep = getChild<LLComboBox>("Physics Rep Combo Ctrl");
+	childSetCommitCallback("Physics Rep Combo Ctrl", onCommitPhysicsRep,this);
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -320,6 +324,7 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
+	mPhysicsRep(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -527,6 +532,10 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
+	mPhysicsRep = objectp->getPhysicsRep();
+	mComboPhysicsRep->setCurrentByIndex(mPhysicsRep);
+	mComboPhysicsRep->setEnabled(editable);
+
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
 	mCheckCastShadows->set( mCastShadows );
@@ -1232,6 +1241,22 @@ void LLPanelObject::sendIsPhantom()
 	}
 }
 
+void LLPanelObject::sendPhysicsRep()
+{
+	U8 value = (U8)mComboPhysicsRep->getCurrentIndex();
+	if (mPhysicsRep != value)
+	{
+		LLSelectMgr::getInstance()->selectionUpdatePhysicsRep(value);
+		mPhysicsRep = value;
+		
+		llinfos << "update physicsrep sent" << llendl;
+	}
+	else
+	{
+		llinfos << "update physicstep not changed" << llendl;
+	}
+}
+
 void LLPanelObject::sendCastShadows()
 {
 	BOOL value = mCheckCastShadows->get();
@@ -1905,6 +1930,8 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
+	mComboPhysicsRep->setCurrentByIndex(0);
+	mComboPhysicsRep->setEnabled(FALSE);
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
@@ -1999,6 +2026,13 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 	self->sendIsPhantom();
 }
 
+// static
+void LLPanelObject::onCommitPhysicsRep(LLUICtrl* ctrl, void* userdata )
+{
+	LLPanelObject* self = (LLPanelObject*) userdata;
+	self->sendPhysicsRep();
+}
+
 // static
 void LLPanelObject::onCommitCastShadows( LLUICtrl* ctrl, void* userdata )
 {
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index 58d9fe9b76e..fbc09021415 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -71,6 +71,7 @@ class LLPanelObject : public LLPanel
 	static void 	onCommitPhysics(		LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitTemporary(		LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitPhantom(		LLUICtrl* ctrl, void* userdata);
+	static void     onCommitPhysicsRep(     LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitCastShadows(	LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
@@ -93,6 +94,7 @@ class LLPanelObject : public LLPanel
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
+	void            sendPhysicsRep();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -165,8 +167,9 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
+	LLComboBox      *mComboPhysicsRep;
 	LLCheckBoxCtrl	*mCheckCastShadows;
-
+	
 	LLTextureCtrl   *mCtrlSculptTexture;
 	LLTextBox       *mLabelSculptType;
 	LLComboBox      *mCtrlSculptType;
@@ -177,6 +180,7 @@ class LLPanelObject : public LLPanel
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
 	BOOL			mIsTemporary;			// to avoid sending "temporary" when not changed
 	BOOL			mIsPhantom;				// to avoid sending "phantom" when not changed
+	U8              mPhysicsRep;			// to avoid sending "physics rep spec" when not changed
 	BOOL			mCastShadows;			// to avoid sending "cast shadows" when not changed
 	S32				mSelectedType;			// So we know what selected type we last were
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index f45abca246c..9d1893b68ae 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3930,6 +3930,28 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
+struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
+{
+	LLSelectMgrApplyPhysicsRep(U8 value) : mValue(value) {}
+	U8 mValue;
+	virtual bool apply(LLViewerObject* object)
+	{
+		if ( object->permModify() ) 	// preemptive permissions check
+		{
+			object->setPhysicsRep( mValue );
+			object->updateFlags();
+		}
+		return true;
+	}
+};
+
+
+void LLSelectMgr::selectionUpdatePhysicsRep(U8 rep)
+{
+	llwarns << "physics rep ->" << (U32)rep << llendl;
+	LLSelectMgrApplyPhysicsRep func(rep);
+	getSelection()->applyToObjects(&func);	
+}
 
 //----------------------------------------------------------------------
 // Helpful packing functions for sendObjectMessage()
@@ -4619,7 +4641,6 @@ void LLSelectMgr::processForceObjectSelect(LLMessageSystem* msg, void**)
 	LLSelectMgr::getInstance()->highlightObjectAndFamily(objects);
 }
 
-
 extern LLGLdouble	gGLModelView[16];
 
 void LLSelectMgr::updateSilhouettes()
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 60b151f1c63..f14136c275d 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -484,6 +484,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void selectionUpdatePhysics(BOOL use_physics);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
+	void selectionUpdatePhysicsRep(U8 rep);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 8dea60cc874..1ee30b49bf4 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -189,6 +189,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mGLName(0),
 	mbCanSelect(TRUE),
 	mFlags(0),
+	mPhysicsRep(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -4952,7 +4953,14 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("IsTemporary", flagTemporaryOnRez() );
 	gMessageSystem->addBOOL("IsPhantom", flagPhantom() );
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
+	gMessageSystem->nextBlock("ExtraPhysics");
+	gMessageSystem->addU8("PhysicsRep", getPhysicsRep() );
 	gMessageSystem->sendReliable( regionp->getHost() );
+
+	if (getPhysicsRep() != 0)
+	{
+		llwarns << "sent non default physics rep" << llendl;
+	}
 }
 
 BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
@@ -4984,6 +4992,12 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 	return setit;
 }
 
+void LLViewerObject::setPhysicsRep(U8 rep)
+{
+	mPhysicsRep = rep;
+	updateFlags();
+}
+
 void LLViewerObject::applyAngularVelocity(F32 dt)
 {
 	//do target omega here
@@ -5194,4 +5208,50 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
 
 	return ;
 }
+#include "../llcommon/llsdserialize.h"
+class ObjectPhysicsProperties : public LLHTTPNode
+{
+public:
+	virtual void post(
+		ResponsePtr responder,
+		const LLSD& context,
+		const LLSD& input) const
+	{
+		LLSD objectData = input["body"]["ObjectData"];
+		S32 numEntries = objectData.size();
+		
+		for ( S32 i = 0; i < numEntries; i++ )
+		{
+			U32 localID = objectData[i]["LocalID"].asInteger();
+
+			std::ostringstream string;
+			LLSDSerialize::serialize( input, string, LLSDSerialize::LLSD_XML, LLSDFormatter::OPTIONS_PRETTY);
+			llinfos << string.str() << llendl;
+
+			// Iterate through nodes at end, since it can be on both the regular AND hover list
+			struct f : public LLSelectedNodeFunctor
+			{
+				U32 mID;
+				f(const U32& id) : mID(id) {}
+				virtual bool apply(LLSelectNode* node)
+				{
+					return (node->getObject() && node->getObject()->mLocalID == mID );
+				}
+			} func(localID);
+
+			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
+
+			U8 physicsRepSpec = (U8)objectData[i]["PhysicsRepSpec"].asInteger();
+
+			if (node)
+			{
+				node->getObject()->setPhysicsRep(physicsRepSpec);
+			}	
+		}
+		
+	};
+};
+
+LLHTTPRegistration<ObjectPhysicsProperties>
+	gHTTPRegistrationObjectPhysicsProperties("/message/ObjectPhysicsProperties");
 
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index bf5e0b66563..da7e4002f5c 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -460,6 +460,8 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	inline BOOL		flagCameraDecoupled() const		{ return ((mFlags & FLAGS_CAMERA_DECOUPLED) != 0); }
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
+	inline U8       getPhysicsRep() const           { return mPhysicsRep; }
+	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
 
@@ -475,6 +477,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
+	void setPhysicsRep(U8 rep);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -554,6 +557,9 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	// Grabbed from UPDATE_FLAGS
 	U32				mFlags;
 
+	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
+	U8              mPhysicsRep;
+
 	// Pipeline classes
 	LLPointer<LLDrawable> mDrawable;
 
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index aec03b80536..26c08bdf7ce 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1419,6 +1419,39 @@ even though the user gets a free copy.
              text_enabled_color="1 1 1 1"
              top_pad="3"
              width="87" />
+            <text
+             type="string"
+             length="1"
+             follows="left|top"
+             height="10"
+             layout="topleft"
+             left_delta="0"
+             name="label physicsrep"
+             top_pad="10"
+             width="121">
+                Physics Rep:
+            </text>
+			<combo_box
+			   height="23"
+			   layout="topleft"
+			   follows="left|top"
+			   name="Physics Rep Combo Ctrl"
+			   tool_tip="Choose the physics representation"
+			   left_pad="0"
+			   width="108">
+			  <combo_box.item
+				 label="Default"
+				 name="Default"
+				 value="Default" />
+			  <combo_box.item
+				 label="No Shape"
+				 name="No Shape"
+				 value="No Shape" />
+			  <combo_box.item
+				 label="Convex Hull"
+				 name="Convex Hull"
+				 value="Convex Hull" />
+			</combo_box>
 
  <!--           <text
              type="string"
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index d4f791c202b..7813bfba833 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2061,6 +2061,10 @@ version 2.0
 		{	IsPhantom		BOOL	}
 		{	CastsShadows	BOOL	}
 	}
+    {
+		ExtraPhysics        Variable
+		{   PhysicsRep      U8      }
+	}
 }
 
 
-- 
GitLab


From d5c07e58c23a4c40507e4c033d502e7a5e9656a4 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 28 Mar 2010 21:45:32 +0100
Subject: [PATCH 237/683] ss reflections: make the guess less far from the
 source.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index c78d7ece7e8..e14869af9ec 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -290,7 +290,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 9305d77ddb9..78e4c179d70 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -289,7 +289,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 262b34ede7f..9ecb0a40ff0 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -292,7 +292,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-- 
GitLab


From e889511a0e3569620897f6ecae7727162dda5701 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 29 Mar 2010 11:30:08 +0100
Subject: [PATCH 238/683] ss reflections tweakage: +		// Offset the
 guess source a little according to a trivial +		// checkerboard dither
 function and spec.a. +		// This is meant to be similar to sampling a
 blurred version +		// of the diffuse map.  LOD would be better in
 that regard. +		// The goal of the blur is to soften reflections in
 surfaces +		// with low shinyness, and also to disguise our
 lameness.

---
 .../shaders/class1/deferred/softenLightF.glsl             | 8 ++++++++
 .../shaders/class2/deferred/softenLightF.glsl             | 8 ++++++++
 .../shaders/class3/deferred/softenLightF.glsl             | 8 ++++++++
 3 files changed, 24 insertions(+)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index e14869af9ec..4646bd4d404 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -291,6 +291,14 @@ void main()
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// Offset the guess source a little according to a trivial
+		// checkerboard dither function and spec.a.
+		// This is meant to be similar to sampling a blurred version
+		// of the diffuse map.  LOD would be better in that regard.
+		// The goal of the blur is to soften reflections in surfaces
+		// with low shinyness, and also to disguise our lameness.
+		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
+		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 78e4c179d70..5769288a367 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -290,6 +290,14 @@ void main()
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// Offset the guess source a little according to a trivial
+		// checkerboard dither function and spec.a.
+		// This is meant to be similar to sampling a blurred version
+		// of the diffuse map.  LOD would be better in that regard.
+		// The goal of the blur is to soften reflections in surfaces
+		// with low shinyness, and also to disguise our lameness.
+		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
+		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 9ecb0a40ff0..70a1c534565 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -293,6 +293,14 @@ void main()
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// Offset the guess source a little according to a trivial
+		// checkerboard dither function and spec.a.
+		// This is meant to be similar to sampling a blurred version
+		// of the diffuse map.  LOD would be better in that regard.
+		// The goal of the blur is to soften reflections in surfaces
+		// with low shinyness, and also to disguise our lameness.
+		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
+		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-- 
GitLab


From c5c62b3055325546ae51cfefada93490f76688da Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 31 Mar 2010 18:23:42 +0100
Subject: [PATCH 239/683] debug ssreflection blur direction.  minor.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 4646bd4d404..155f03fdcf9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -290,7 +290,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// Offset the guess source a little according to a trivial
 		// checkerboard dither function and spec.a.
 		// This is meant to be similar to sampling a blurred version
@@ -299,6 +299,7 @@ void main()
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
 		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += tc.xy; // use as offset from destination
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-- 
GitLab


From 7ee4c5e6ffef66df30c44fd9eb662632f1b4f709 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 31 Mar 2010 18:27:50 +0100
Subject: [PATCH 240/683] debug ssreflection blur direction.  minor.

---
 .../app_settings/shaders/class2/deferred/softenLightF.glsl     | 3 ++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl     | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 5769288a367..922a07c3066 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -289,7 +289,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// Offset the guess source a little according to a trivial
 		// checkerboard dither function and spec.a.
 		// This is meant to be similar to sampling a blurred version
@@ -298,6 +298,7 @@ void main()
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
 		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += tc.xy; // use as offset from destination
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 70a1c534565..ddd69befc36 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -292,7 +292,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// Offset the guess source a little according to a trivial
 		// checkerboard dither function and spec.a.
 		// This is meant to be similar to sampling a blurred version
@@ -301,6 +301,7 @@ void main()
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
 		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += tc.xy; // use as offset from destination
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-- 
GitLab


From 006e15495515e6e4c233412a4deed0f34e7b0f12 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Fri, 26 Mar 2010 18:23:05 -0700
Subject: [PATCH 241/683] DEV-47845 Fix to work with TCP/LLSD message. This
 checkin is experimental, so if it breaks a build, just revert to the previous
 changeset.

---
 etc/message.xml                               |  7 ++
 indra/newview/llpanelobject.cpp               | 77 +++++++++++++++----
 indra/newview/llpanelobject.h                 | 44 +++++++----
 indra/newview/llselectmgr.cpp                 | 23 +++++-
 indra/newview/llselectmgr.h                   |  1 +
 indra/newview/llviewerobject.cpp              | 60 +++++++++++++++
 indra/newview/llviewerobject.h                |  6 ++
 .../skins/default/xui/en/floater_tools.xml    | 33 ++++++++
 scripts/messages/message_template.msg         |  4 +
 9 files changed, 223 insertions(+), 32 deletions(-)

diff --git a/etc/message.xml b/etc/message.xml
index c17ae3656d0..7283d903b9a 100644
--- a/etc/message.xml
+++ b/etc/message.xml
@@ -572,6 +572,13 @@
 					<boolean>false</boolean>
 				</map>
 
+				<key>ObjectPhysicsProperties</key>
+				<map>
+					<key>flavor</key>
+					<string>llsd</string>
+					<key>trusted-sender</key>
+					<boolean>true</boolean>
+				</map>
 
 		  </map>
   	  	<key>capBans</key>
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index bc00d755339..991e97b767e 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -2,25 +2,31 @@
  * @file llpanelobject.cpp
  * @brief Object editing (position, scale, etc.) in the tools floater
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -131,6 +137,10 @@ BOOL	LLPanelObject::postBuild()
 	// Phantom checkbox
 	mCheckPhantom = getChild<LLCheckBoxCtrl>("Phantom Checkbox Ctrl");
 	childSetCommitCallback("Phantom Checkbox Ctrl",onCommitPhantom,this);
+
+	// PhysicsRep combobox
+	mComboPhysicsRep = getChild<LLComboBox>("Physics Rep Combo Ctrl");
+	childSetCommitCallback("Physics Rep Combo Ctrl", onCommitPhysicsRep,this);
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -166,6 +176,7 @@ BOOL	LLPanelObject::postBuild()
 	//--------------------------------------------------------
 		
 	// material type popup
+	mLabelMaterial = getChild<LLTextBox>("label material");
 	mComboMaterial = getChild<LLComboBox>("material");
 	childSetCommitCallback("material",onCommitMaterial,this);
 	mComboMaterial->removeall();
@@ -182,6 +193,7 @@ BOOL	LLPanelObject::postBuild()
 	mComboMaterialItemCount = mComboMaterial->getItemCount();
 
 	// Base Type
+	mLabelBaseType = getChild<LLTextBox>("label basetype");
 	mComboBaseType = getChild<LLComboBox>("comboBaseType");
 	childSetCommitCallback("comboBaseType",onCommitParametric,this);
 
@@ -312,6 +324,7 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
+	mPhysicsRep(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -519,6 +532,10 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
+	mPhysicsRep = objectp->getPhysicsRep();
+	mComboPhysicsRep->setCurrentByIndex(mPhysicsRep);
+	mComboPhysicsRep->setEnabled(editable);
+
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
 	mCheckCastShadows->set( mCastShadows );
@@ -540,6 +557,7 @@ void LLPanelObject::getState( )
 	if (editable && single_volume && material_same)
 	{
 		mComboMaterial->setEnabled( TRUE );
+		mLabelMaterial->setEnabled( TRUE );
 		if (material_code == LL_MCODE_LIGHT)
 		{
 			if (mComboMaterial->getItemCount() == mComboMaterialItemCount)
@@ -561,6 +579,7 @@ void LLPanelObject::getState( )
 	else
 	{
 		mComboMaterial->setEnabled( FALSE );
+		mLabelMaterial->setEnabled( FALSE );	
 	}
 	//----------------------------------------------------------------------------
 
@@ -969,6 +988,7 @@ void LLPanelObject::getState( )
 	}
 
 	// Update field enablement
+	mLabelBaseType	->setEnabled( enabled );
 	mComboBaseType	->setEnabled( enabled );
 
 	mLabelCut		->setEnabled( enabled );
@@ -1221,6 +1241,22 @@ void LLPanelObject::sendIsPhantom()
 	}
 }
 
+void LLPanelObject::sendPhysicsRep()
+{
+	U8 value = (U8)mComboPhysicsRep->getCurrentIndex();
+	if (mPhysicsRep != value)
+	{
+		LLSelectMgr::getInstance()->selectionUpdatePhysicsRep(value);
+		mPhysicsRep = value;
+		
+		llinfos << "update physicsrep sent" << llendl;
+	}
+	else
+	{
+		llinfos << "update physicstep not changed" << llendl;
+	}
+}
+
 void LLPanelObject::sendCastShadows()
 {
 	BOOL value = mCheckCastShadows->get();
@@ -1894,15 +1930,19 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
+	mComboPhysicsRep->setCurrentByIndex(0);
+	mComboPhysicsRep->setEnabled(FALSE);
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
 #endif
 	mComboMaterial	->setEnabled( FALSE );
+	mLabelMaterial	->setEnabled( FALSE );
 	// Disable text labels
 	mLabelPosition	->setEnabled( FALSE );
 	mLabelSize		->setEnabled( FALSE );
 	mLabelRotation	->setEnabled( FALSE );
+	mLabelBaseType	->setEnabled( FALSE );
 	mLabelCut		->setEnabled( FALSE );
 	mLabelHollow	->setEnabled( FALSE );
 	mLabelHoleType	->setEnabled( FALSE );
@@ -1986,6 +2026,13 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 	self->sendIsPhantom();
 }
 
+// static
+void LLPanelObject::onCommitPhysicsRep(LLUICtrl* ctrl, void* userdata )
+{
+	LLPanelObject* self = (LLPanelObject*) userdata;
+	self->sendPhysicsRep();
+}
+
 // static
 void LLPanelObject::onCommitCastShadows( LLUICtrl* ctrl, void* userdata )
 {
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index e07bf007ec1..fbc09021415 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -2,25 +2,31 @@
  * @file llpanelobject.h
  * @brief Object editing (position, scale, etc.) in the tools floater
  *
- * $LicenseInfo:firstyear=2004&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -65,6 +71,7 @@ class LLPanelObject : public LLPanel
 	static void 	onCommitPhysics(		LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitTemporary(		LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitPhantom(		LLUICtrl* ctrl, void* userdata);
+	static void     onCommitPhysicsRep(     LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitCastShadows(	LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
@@ -87,6 +94,7 @@ class LLPanelObject : public LLPanel
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
+	void            sendPhysicsRep();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -95,9 +103,11 @@ class LLPanelObject : public LLPanel
 protected:
 	S32				mComboMaterialItemCount;
 
+	LLTextBox*		mLabelMaterial;
 	LLComboBox*		mComboMaterial;
 	
 	// Per-object options
+	LLTextBox*		mLabelBaseType;
 	LLComboBox*		mComboBaseType;
 
 	LLTextBox*		mLabelCut;
@@ -157,8 +167,9 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
+	LLComboBox      *mComboPhysicsRep;
 	LLCheckBoxCtrl	*mCheckCastShadows;
-
+	
 	LLTextureCtrl   *mCtrlSculptTexture;
 	LLTextBox       *mLabelSculptType;
 	LLComboBox      *mCtrlSculptType;
@@ -169,6 +180,7 @@ class LLPanelObject : public LLPanel
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
 	BOOL			mIsTemporary;			// to avoid sending "temporary" when not changed
 	BOOL			mIsPhantom;				// to avoid sending "phantom" when not changed
+	U8              mPhysicsRep;			// to avoid sending "physics rep spec" when not changed
 	BOOL			mCastShadows;			// to avoid sending "cast shadows" when not changed
 	S32				mSelectedType;			// So we know what selected type we last were
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index d03a492cd10..d15017e0a19 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3931,6 +3931,28 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
+struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
+{
+	LLSelectMgrApplyPhysicsRep(U8 value) : mValue(value) {}
+	U8 mValue;
+	virtual bool apply(LLViewerObject* object)
+	{
+		if ( object->permModify() ) 	// preemptive permissions check
+		{
+			object->setPhysicsRep( mValue );
+			object->updateFlags();
+		}
+		return true;
+	}
+};
+
+
+void LLSelectMgr::selectionUpdatePhysicsRep(U8 rep)
+{
+	llwarns << "physics rep ->" << (U32)rep << llendl;
+	LLSelectMgrApplyPhysicsRep func(rep);
+	getSelection()->applyToObjects(&func);	
+}
 
 //----------------------------------------------------------------------
 // Helpful packing functions for sendObjectMessage()
@@ -4620,7 +4642,6 @@ void LLSelectMgr::processForceObjectSelect(LLMessageSystem* msg, void**)
 	LLSelectMgr::getInstance()->highlightObjectAndFamily(objects);
 }
 
-
 extern LLGLdouble	gGLModelView[16];
 
 void LLSelectMgr::updateSilhouettes()
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index d315f40ff3b..27e0c5dfa9d 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -483,6 +483,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void selectionUpdatePhysics(BOOL use_physics);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
+	void selectionUpdatePhysicsRep(U8 rep);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bb7933c10e8..f18fee3edec 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -199,6 +199,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mGLName(0),
 	mbCanSelect(TRUE),
 	mFlags(0),
+	mPhysicsRep(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -4961,7 +4962,14 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("IsTemporary", flagTemporaryOnRez() );
 	gMessageSystem->addBOOL("IsPhantom", flagPhantom() );
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
+	gMessageSystem->nextBlock("ExtraPhysics");
+	gMessageSystem->addU8("PhysicsRep", getPhysicsRep() );
 	gMessageSystem->sendReliable( regionp->getHost() );
+
+	if (getPhysicsRep() != 0)
+	{
+		llwarns << "sent non default physics rep" << llendl;
+	}
 }
 
 BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
@@ -4993,6 +5001,12 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 	return setit;
 }
 
+void LLViewerObject::setPhysicsRep(U8 rep)
+{
+	mPhysicsRep = rep;
+	updateFlags();
+}
+
 void LLViewerObject::applyAngularVelocity(F32 dt)
 {
 	//do target omega here
@@ -5203,4 +5217,50 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
 
 	return ;
 }
+#include "../llcommon/llsdserialize.h"
+class ObjectPhysicsProperties : public LLHTTPNode
+{
+public:
+	virtual void post(
+		ResponsePtr responder,
+		const LLSD& context,
+		const LLSD& input) const
+	{
+		LLSD objectData = input["body"]["ObjectData"];
+		S32 numEntries = objectData.size();
+		
+		for ( S32 i = 0; i < numEntries; i++ )
+		{
+			U32 localID = objectData[i]["LocalID"].asInteger();
+
+			std::ostringstream string;
+			LLSDSerialize::serialize( input, string, LLSDSerialize::LLSD_XML, LLSDFormatter::OPTIONS_PRETTY);
+			llinfos << string.str() << llendl;
+
+			// Iterate through nodes at end, since it can be on both the regular AND hover list
+			struct f : public LLSelectedNodeFunctor
+			{
+				U32 mID;
+				f(const U32& id) : mID(id) {}
+				virtual bool apply(LLSelectNode* node)
+				{
+					return (node->getObject() && node->getObject()->mLocalID == mID );
+				}
+			} func(localID);
+
+			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
+
+			U8 physicsRepSpec = (U8)objectData[i]["PhysicsRepSpec"].asInteger();
+
+			if (node)
+			{
+				node->getObject()->setPhysicsRep(physicsRepSpec);
+			}	
+		}
+		
+	};
+};
+
+LLHTTPRegistration<ObjectPhysicsProperties>
+	gHTTPRegistrationObjectPhysicsProperties("/message/ObjectPhysicsProperties");
 
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index be83fb7ef8a..49709d643a7 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -459,6 +459,8 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	inline BOOL		flagCameraDecoupled() const		{ return ((mFlags & FLAGS_CAMERA_DECOUPLED) != 0); }
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
+	inline U8       getPhysicsRep() const           { return mPhysicsRep; }
+	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
 
@@ -474,6 +476,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
+	void setPhysicsRep(U8 rep);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -553,6 +556,9 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	// Grabbed from UPDATE_FLAGS
 	U32				mFlags;
 
+	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
+	U8              mPhysicsRep;
+
 	// Pipeline classes
 	LLPointer<LLDrawable> mDrawable;
 
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index cc9e72cfb58..3bb8e9c0554 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1418,6 +1418,39 @@ even though the user gets a free copy.
              text_enabled_color="1 1 1 1"
              top_pad="3"
              width="87" />
+            <text
+             type="string"
+             length="1"
+             follows="left|top"
+             height="10"
+             layout="topleft"
+             left_delta="0"
+             name="label physicsrep"
+             top_pad="10"
+             width="121">
+                Physics Rep:
+            </text>
+			<combo_box
+			   height="23"
+			   layout="topleft"
+			   follows="left|top"
+			   name="Physics Rep Combo Ctrl"
+			   tool_tip="Choose the physics representation"
+			   left_pad="0"
+			   width="108">
+			  <combo_box.item
+				 label="Default"
+				 name="Default"
+				 value="Default" />
+			  <combo_box.item
+				 label="No Shape"
+				 name="No Shape"
+				 value="No Shape" />
+			  <combo_box.item
+				 label="Convex Hull"
+				 name="Convex Hull"
+				 value="Convex Hull" />
+			</combo_box>
 
  <!--           <text
              type="string"
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index d4f791c202b..7813bfba833 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2061,6 +2061,10 @@ version 2.0
 		{	IsPhantom		BOOL	}
 		{	CastsShadows	BOOL	}
 	}
+    {
+		ExtraPhysics        Variable
+		{   PhysicsRep      U8      }
+	}
 }
 
 
-- 
GitLab


From 79d2c59112213151060b928a2528c481cfde09fe Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 28 Mar 2010 21:45:32 +0100
Subject: [PATCH 242/683] ss reflections: make the guess less far from the
 source.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index c78d7ece7e8..e14869af9ec 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -290,7 +290,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 9305d77ddb9..78e4c179d70 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -289,7 +289,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 262b34ede7f..9ecb0a40ff0 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -292,7 +292,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-- 
GitLab


From ccd5b9e2f3f1139814a63d9db03c3671c249930c Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 29 Mar 2010 11:30:08 +0100
Subject: [PATCH 243/683] ss reflections tweakage: +		// Offset the
 guess source a little according to a trivial +		// checkerboard dither
 function and spec.a. +		// This is meant to be similar to sampling a
 blurred version +		// of the diffuse map.  LOD would be better in
 that regard. +		// The goal of the blur is to soften reflections in
 surfaces +		// with low shinyness, and also to disguise our
 lameness.

---
 .../shaders/class1/deferred/softenLightF.glsl             | 8 ++++++++
 .../shaders/class2/deferred/softenLightF.glsl             | 8 ++++++++
 .../shaders/class3/deferred/softenLightF.glsl             | 8 ++++++++
 3 files changed, 24 insertions(+)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index e14869af9ec..4646bd4d404 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -291,6 +291,14 @@ void main()
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// Offset the guess source a little according to a trivial
+		// checkerboard dither function and spec.a.
+		// This is meant to be similar to sampling a blurred version
+		// of the diffuse map.  LOD would be better in that regard.
+		// The goal of the blur is to soften reflections in surfaces
+		// with low shinyness, and also to disguise our lameness.
+		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
+		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 78e4c179d70..5769288a367 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -290,6 +290,14 @@ void main()
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// Offset the guess source a little according to a trivial
+		// checkerboard dither function and spec.a.
+		// This is meant to be similar to sampling a blurred version
+		// of the diffuse map.  LOD would be better in that regard.
+		// The goal of the blur is to soften reflections in surfaces
+		// with low shinyness, and also to disguise our lameness.
+		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
+		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 9ecb0a40ff0..70a1c534565 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -293,6 +293,14 @@ void main()
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		// Offset the guess source a little according to a trivial
+		// checkerboard dither function and spec.a.
+		// This is meant to be similar to sampling a blurred version
+		// of the diffuse map.  LOD would be better in that regard.
+		// The goal of the blur is to soften reflections in surfaces
+		// with low shinyness, and also to disguise our lameness.
+		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
+		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-- 
GitLab


From 784e83462b19c0fbea6656e2a845a1f3ab4b1e70 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 31 Mar 2010 18:23:42 +0100
Subject: [PATCH 244/683] debug ssreflection blur direction.  minor.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 4646bd4d404..155f03fdcf9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -290,7 +290,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// Offset the guess source a little according to a trivial
 		// checkerboard dither function and spec.a.
 		// This is meant to be similar to sampling a blurred version
@@ -299,6 +299,7 @@ void main()
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
 		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += tc.xy; // use as offset from destination
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-- 
GitLab


From e3c49e617edf6dfe61389e3e90c28082e5b678ce Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 31 Mar 2010 18:27:50 +0100
Subject: [PATCH 245/683] debug ssreflection blur direction.  minor.

---
 .../app_settings/shaders/class2/deferred/softenLightF.glsl     | 3 ++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl     | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 5769288a367..922a07c3066 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -289,7 +289,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// Offset the guess source a little according to a trivial
 		// checkerboard dither function and spec.a.
 		// This is meant to be similar to sampling a blurred version
@@ -298,6 +298,7 @@ void main()
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
 		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += tc.xy; // use as offset from destination
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 70a1c534565..ddd69befc36 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -292,7 +292,7 @@ void main()
 		//
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
-		vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
+		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
 		// Offset the guess source a little according to a trivial
 		// checkerboard dither function and spec.a.
 		// This is meant to be similar to sampling a blurred version
@@ -301,6 +301,7 @@ void main()
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
 		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += tc.xy; // use as offset from destination
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-- 
GitLab


From a503cb57465594bf693ed335d04715389725b3b0 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Wed, 31 Mar 2010 15:17:30 -0500
Subject: [PATCH 246/683] viewer side support for coalesced objects

---
 indra/newview/llviewerregion.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 524710f9e26..c6fe78eb748 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1511,6 +1511,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("UpdateNotecardTaskInventory");
 	capabilityNames.append("UpdateScriptTask");
 	capabilityNames.append("UploadBakedTexture");
+	capabilityNames.append("UploadObjectAsset");
 	capabilityNames.append("ViewerStartAuction");
 	capabilityNames.append("ViewerStats");
 	capabilityNames.append("WebFetchInventoryDescendents");
-- 
GitLab


From b2381a039de7e0edbd643d198b85ba8e00524b6b Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Wed, 31 Mar 2010 17:35:26 -0700
Subject: [PATCH 247/683] DEV-47845 Cleaned up names.

---
 indra/newview/llpanelobject.cpp               | 36 +++++++++----------
 indra/newview/llpanelobject.h                 | 22 ++++++------
 indra/newview/llselectmgr.cpp                 | 12 +++----
 indra/newview/llselectmgr.h                   |  2 +-
 indra/newview/llviewerobject.cpp              | 27 +++++++-------
 indra/newview/llviewerobject.h                |  6 ++--
 .../skins/default/xui/en/floater_tools.xml    | 18 +++++-----
 scripts/messages/message_template.msg         |  2 +-
 8 files changed, 62 insertions(+), 63 deletions(-)

diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 991e97b767e..669ff3ffd6c 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -138,9 +138,9 @@ BOOL	LLPanelObject::postBuild()
 	mCheckPhantom = getChild<LLCheckBoxCtrl>("Phantom Checkbox Ctrl");
 	childSetCommitCallback("Phantom Checkbox Ctrl",onCommitPhantom,this);
 
-	// PhysicsRep combobox
-	mComboPhysicsRep = getChild<LLComboBox>("Physics Rep Combo Ctrl");
-	childSetCommitCallback("Physics Rep Combo Ctrl", onCommitPhysicsRep,this);
+	// PhysicsShapeType combobox
+	mComboPhysicsShapeType = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
+	childSetCommitCallback("Physics Shape Type Combo Ctrl", onCommitPhysicsShapeType,this);
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -324,7 +324,7 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
-	mPhysicsRep(0),
+	mPhysicsShapeType(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -532,9 +532,9 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
-	mPhysicsRep = objectp->getPhysicsRep();
-	mComboPhysicsRep->setCurrentByIndex(mPhysicsRep);
-	mComboPhysicsRep->setEnabled(editable);
+	mPhysicsShapeType = objectp->getPhysicsShapeType();
+	mComboPhysicsShapeType->setCurrentByIndex(mPhysicsShapeType);
+	mComboPhysicsShapeType->setEnabled(editable);
 
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
@@ -1241,19 +1241,19 @@ void LLPanelObject::sendIsPhantom()
 	}
 }
 
-void LLPanelObject::sendPhysicsRep()
+void LLPanelObject::sendPhysicsShapeType()
 {
-	U8 value = (U8)mComboPhysicsRep->getCurrentIndex();
-	if (mPhysicsRep != value)
+	U8 value = (U8)mComboPhysicsShapeType->getCurrentIndex();
+	if (mPhysicsShapeType != value)
 	{
-		LLSelectMgr::getInstance()->selectionUpdatePhysicsRep(value);
-		mPhysicsRep = value;
+		LLSelectMgr::getInstance()->selectionUpdatePhysicsShapeType(value);
+		mPhysicsShapeType = value;
 		
-		llinfos << "update physicsrep sent" << llendl;
+		llinfos << "update physics shape type sent" << llendl;
 	}
 	else
 	{
-		llinfos << "update physicstep not changed" << llendl;
+		llinfos << "update physics shape type not changed" << llendl;
 	}
 }
 
@@ -1930,8 +1930,8 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
-	mComboPhysicsRep->setCurrentByIndex(0);
-	mComboPhysicsRep->setEnabled(FALSE);
+	mComboPhysicsShapeType->setCurrentByIndex(0);
+	mComboPhysicsShapeType->setEnabled(FALSE);
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
@@ -2027,10 +2027,10 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 }
 
 // static
-void LLPanelObject::onCommitPhysicsRep(LLUICtrl* ctrl, void* userdata )
+void LLPanelObject::onCommitPhysicsShapeType(LLUICtrl* ctrl, void* userdata )
 {
 	LLPanelObject* self = (LLPanelObject*) userdata;
-	self->sendPhysicsRep();
+	self->sendPhysicsShapeType();
 }
 
 // static
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index fbc09021415..7f368c38c70 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -65,14 +65,14 @@ class LLPanelObject : public LLPanel
 	static bool		precommitValidate(const LLSD& data);
 	
 	static void		onCommitLock(LLUICtrl *ctrl, void *data);
-	static void 	onCommitPosition(		LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitScale(			LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitRotation(		LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitPhysics(		LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitTemporary(		LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitPhantom(		LLUICtrl* ctrl, void* userdata);
-	static void     onCommitPhysicsRep(     LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitCastShadows(	LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPosition(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitScale(				LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitRotation(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPhysics(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitTemporary(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPhantom(			LLUICtrl* ctrl, void* userdata);
+	static void     onCommitPhysicsShapeType(   LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitCastShadows(		LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
 
@@ -94,7 +94,7 @@ class LLPanelObject : public LLPanel
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
-	void            sendPhysicsRep();
+	void            sendPhysicsShapeType();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -167,7 +167,7 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
-	LLComboBox      *mComboPhysicsRep;
+	LLComboBox      *mComboPhysicsShapeType;
 	LLCheckBoxCtrl	*mCheckCastShadows;
 	
 	LLTextureCtrl   *mCtrlSculptTexture;
@@ -180,7 +180,7 @@ class LLPanelObject : public LLPanel
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
 	BOOL			mIsTemporary;			// to avoid sending "temporary" when not changed
 	BOOL			mIsPhantom;				// to avoid sending "phantom" when not changed
-	U8              mPhysicsRep;			// to avoid sending "physics rep spec" when not changed
+	U8              mPhysicsShapeType;		// to avoid sending "physics shape type" when not changed
 	BOOL			mCastShadows;			// to avoid sending "cast shadows" when not changed
 	S32				mSelectedType;			// So we know what selected type we last were
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 9d1893b68ae..89fb6bf4df0 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3930,15 +3930,15 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
-struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
+struct LLSelectMgrApplyPhysicsShapeType : public LLSelectedObjectFunctor
 {
-	LLSelectMgrApplyPhysicsRep(U8 value) : mValue(value) {}
+	LLSelectMgrApplyPhysicsShapeType(U8 value) : mValue(value) {}
 	U8 mValue;
 	virtual bool apply(LLViewerObject* object)
 	{
 		if ( object->permModify() ) 	// preemptive permissions check
 		{
-			object->setPhysicsRep( mValue );
+			object->setPhysicsShapeType( mValue );
 			object->updateFlags();
 		}
 		return true;
@@ -3946,10 +3946,10 @@ struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
 };
 
 
-void LLSelectMgr::selectionUpdatePhysicsRep(U8 rep)
+void LLSelectMgr::selectionUpdatePhysicsShapeType(U8 type)
 {
-	llwarns << "physics rep ->" << (U32)rep << llendl;
-	LLSelectMgrApplyPhysicsRep func(rep);
+	llwarns << "physics shape type ->" << (U32)type << llendl;
+	LLSelectMgrApplyPhysicsShapeType func(type);
 	getSelection()->applyToObjects(&func);	
 }
 
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index f14136c275d..7db0adb31ea 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -484,7 +484,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void selectionUpdatePhysics(BOOL use_physics);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
-	void selectionUpdatePhysicsRep(U8 rep);
+	void selectionUpdatePhysicsShapeType(U8 type);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 1ee30b49bf4..fb48f3311b4 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -52,6 +52,7 @@
 #include "llprimitive.h"
 #include "llquantize.h"
 #include "llregionhandle.h"
+#include "llsdserialize.h"
 #include "lltree_common.h"
 #include "llxfermanager.h"
 #include "message.h"
@@ -189,7 +190,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mGLName(0),
 	mbCanSelect(TRUE),
 	mFlags(0),
-	mPhysicsRep(0),
+	mPhysicsShapeType(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -4954,10 +4955,10 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("IsPhantom", flagPhantom() );
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
 	gMessageSystem->nextBlock("ExtraPhysics");
-	gMessageSystem->addU8("PhysicsRep", getPhysicsRep() );
+	gMessageSystem->addU8("PhysicsShapeType", getPhysicsShapeType() );
 	gMessageSystem->sendReliable( regionp->getHost() );
 
-	if (getPhysicsRep() != 0)
+	if (getPhysicsShapeType() != 0)
 	{
 		llwarns << "sent non default physics rep" << llendl;
 	}
@@ -4992,9 +4993,9 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 	return setit;
 }
 
-void LLViewerObject::setPhysicsRep(U8 rep)
+void LLViewerObject::setPhysicsShapeType(U8 type)
 {
-	mPhysicsRep = rep;
+	mPhysicsShapeType = type;
 	updateFlags();
 }
 
@@ -5208,7 +5209,7 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
 
 	return ;
 }
-#include "../llcommon/llsdserialize.h"
+
 class ObjectPhysicsProperties : public LLHTTPNode
 {
 public:
@@ -5222,11 +5223,8 @@ class ObjectPhysicsProperties : public LLHTTPNode
 		
 		for ( S32 i = 0; i < numEntries; i++ )
 		{
-			U32 localID = objectData[i]["LocalID"].asInteger();
-
-			std::ostringstream string;
-			LLSDSerialize::serialize( input, string, LLSDSerialize::LLSD_XML, LLSDFormatter::OPTIONS_PRETTY);
-			llinfos << string.str() << llendl;
+			LLSD& currObjectData = objectData[i];
+			U32 localID = currObjectData["LocalID"].asInteger();
 
 			// Iterate through nodes at end, since it can be on both the regular AND hover list
 			struct f : public LLSelectedNodeFunctor
@@ -5241,11 +5239,12 @@ class ObjectPhysicsProperties : public LLHTTPNode
 
 			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
 
-			U8 physicsRepSpec = (U8)objectData[i]["PhysicsRepSpec"].asInteger();
-
 			if (node)
 			{
-				node->getObject()->setPhysicsRep(physicsRepSpec);
+				// The LLSD message builder doesn't know how to handle U8, so we need to send as S8 and cast
+				U8 physicsShapeType = (U8)currObjectData["PhysicsShapeType"].asInteger();
+
+				node->getObject()->setPhysicsShapeType(physicsShapeType);
 			}	
 		}
 		
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index da7e4002f5c..8b542af7738 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -460,7 +460,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	inline BOOL		flagCameraDecoupled() const		{ return ((mFlags & FLAGS_CAMERA_DECOUPLED) != 0); }
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
-	inline U8       getPhysicsRep() const           { return mPhysicsRep; }
+	inline U8       getPhysicsShapeType() const     { return mPhysicsShapeType; }
 	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
@@ -477,7 +477,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
-	void setPhysicsRep(U8 rep);
+	void setPhysicsShapeType(U8 type);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -558,7 +558,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	U32				mFlags;
 
 	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
-	U8              mPhysicsRep;
+	U8              mPhysicsShapeType;
 
 	// Pipeline classes
 	LLPointer<LLDrawable> mDrawable;
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index 26c08bdf7ce..fd6a5127d8d 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1426,7 +1426,7 @@ even though the user gets a free copy.
              height="10"
              layout="topleft"
              left_delta="0"
-             name="label physicsrep"
+             name="label physicsshapetype"
              top_pad="10"
              width="121">
                 Physics Rep:
@@ -1435,18 +1435,18 @@ even though the user gets a free copy.
 			   height="23"
 			   layout="topleft"
 			   follows="left|top"
-			   name="Physics Rep Combo Ctrl"
-			   tool_tip="Choose the physics representation"
+			   name="Physics Shape Type Combo Ctrl"
+			   tool_tip="Choose the physics shape type"
 			   left_pad="0"
 			   width="108">
 			  <combo_box.item
-				 label="Default"
-				 name="Default"
-				 value="Default" />
+				 label="Prim"
+				 name="Prim"
+				 value="Prim" />
 			  <combo_box.item
-				 label="No Shape"
-				 name="No Shape"
-				 value="No Shape" />
+				 label="None"
+				 name="None"
+				 value="None" />
 			  <combo_box.item
 				 label="Convex Hull"
 				 name="Convex Hull"
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 7813bfba833..6043542877a 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2063,7 +2063,7 @@ version 2.0
 	}
     {
 		ExtraPhysics        Variable
-		{   PhysicsRep      U8      }
+		{   PhysicsShapeType U8     }
 	}
 }
 
-- 
GitLab


From 779708b2293b1ab05574df0022493c7831503702 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Wed, 31 Mar 2010 17:35:26 -0700
Subject: [PATCH 248/683] DEV-47845 Cleaned up names.

---
 indra/newview/llpanelobject.cpp               | 36 +++++++++----------
 indra/newview/llpanelobject.h                 | 22 ++++++------
 indra/newview/llselectmgr.cpp                 | 12 +++----
 indra/newview/llselectmgr.h                   |  2 +-
 indra/newview/llviewerobject.cpp              | 27 +++++++-------
 indra/newview/llviewerobject.h                |  6 ++--
 .../skins/default/xui/en/floater_tools.xml    | 18 +++++-----
 scripts/messages/message_template.msg         |  2 +-
 8 files changed, 62 insertions(+), 63 deletions(-)

diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 991e97b767e..669ff3ffd6c 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -138,9 +138,9 @@ BOOL	LLPanelObject::postBuild()
 	mCheckPhantom = getChild<LLCheckBoxCtrl>("Phantom Checkbox Ctrl");
 	childSetCommitCallback("Phantom Checkbox Ctrl",onCommitPhantom,this);
 
-	// PhysicsRep combobox
-	mComboPhysicsRep = getChild<LLComboBox>("Physics Rep Combo Ctrl");
-	childSetCommitCallback("Physics Rep Combo Ctrl", onCommitPhysicsRep,this);
+	// PhysicsShapeType combobox
+	mComboPhysicsShapeType = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
+	childSetCommitCallback("Physics Shape Type Combo Ctrl", onCommitPhysicsShapeType,this);
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -324,7 +324,7 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
-	mPhysicsRep(0),
+	mPhysicsShapeType(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -532,9 +532,9 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
-	mPhysicsRep = objectp->getPhysicsRep();
-	mComboPhysicsRep->setCurrentByIndex(mPhysicsRep);
-	mComboPhysicsRep->setEnabled(editable);
+	mPhysicsShapeType = objectp->getPhysicsShapeType();
+	mComboPhysicsShapeType->setCurrentByIndex(mPhysicsShapeType);
+	mComboPhysicsShapeType->setEnabled(editable);
 
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
@@ -1241,19 +1241,19 @@ void LLPanelObject::sendIsPhantom()
 	}
 }
 
-void LLPanelObject::sendPhysicsRep()
+void LLPanelObject::sendPhysicsShapeType()
 {
-	U8 value = (U8)mComboPhysicsRep->getCurrentIndex();
-	if (mPhysicsRep != value)
+	U8 value = (U8)mComboPhysicsShapeType->getCurrentIndex();
+	if (mPhysicsShapeType != value)
 	{
-		LLSelectMgr::getInstance()->selectionUpdatePhysicsRep(value);
-		mPhysicsRep = value;
+		LLSelectMgr::getInstance()->selectionUpdatePhysicsShapeType(value);
+		mPhysicsShapeType = value;
 		
-		llinfos << "update physicsrep sent" << llendl;
+		llinfos << "update physics shape type sent" << llendl;
 	}
 	else
 	{
-		llinfos << "update physicstep not changed" << llendl;
+		llinfos << "update physics shape type not changed" << llendl;
 	}
 }
 
@@ -1930,8 +1930,8 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
-	mComboPhysicsRep->setCurrentByIndex(0);
-	mComboPhysicsRep->setEnabled(FALSE);
+	mComboPhysicsShapeType->setCurrentByIndex(0);
+	mComboPhysicsShapeType->setEnabled(FALSE);
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
@@ -2027,10 +2027,10 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 }
 
 // static
-void LLPanelObject::onCommitPhysicsRep(LLUICtrl* ctrl, void* userdata )
+void LLPanelObject::onCommitPhysicsShapeType(LLUICtrl* ctrl, void* userdata )
 {
 	LLPanelObject* self = (LLPanelObject*) userdata;
-	self->sendPhysicsRep();
+	self->sendPhysicsShapeType();
 }
 
 // static
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index fbc09021415..7f368c38c70 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -65,14 +65,14 @@ class LLPanelObject : public LLPanel
 	static bool		precommitValidate(const LLSD& data);
 	
 	static void		onCommitLock(LLUICtrl *ctrl, void *data);
-	static void 	onCommitPosition(		LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitScale(			LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitRotation(		LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitPhysics(		LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitTemporary(		LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitPhantom(		LLUICtrl* ctrl, void* userdata);
-	static void     onCommitPhysicsRep(     LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitCastShadows(	LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPosition(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitScale(				LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitRotation(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPhysics(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitTemporary(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPhantom(			LLUICtrl* ctrl, void* userdata);
+	static void     onCommitPhysicsShapeType(   LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitCastShadows(		LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
 
@@ -94,7 +94,7 @@ class LLPanelObject : public LLPanel
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
-	void            sendPhysicsRep();
+	void            sendPhysicsShapeType();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -167,7 +167,7 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
-	LLComboBox      *mComboPhysicsRep;
+	LLComboBox      *mComboPhysicsShapeType;
 	LLCheckBoxCtrl	*mCheckCastShadows;
 	
 	LLTextureCtrl   *mCtrlSculptTexture;
@@ -180,7 +180,7 @@ class LLPanelObject : public LLPanel
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
 	BOOL			mIsTemporary;			// to avoid sending "temporary" when not changed
 	BOOL			mIsPhantom;				// to avoid sending "phantom" when not changed
-	U8              mPhysicsRep;			// to avoid sending "physics rep spec" when not changed
+	U8              mPhysicsShapeType;		// to avoid sending "physics shape type" when not changed
 	BOOL			mCastShadows;			// to avoid sending "cast shadows" when not changed
 	S32				mSelectedType;			// So we know what selected type we last were
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index d15017e0a19..d47cc06ebce 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3931,15 +3931,15 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
-struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
+struct LLSelectMgrApplyPhysicsShapeType : public LLSelectedObjectFunctor
 {
-	LLSelectMgrApplyPhysicsRep(U8 value) : mValue(value) {}
+	LLSelectMgrApplyPhysicsShapeType(U8 value) : mValue(value) {}
 	U8 mValue;
 	virtual bool apply(LLViewerObject* object)
 	{
 		if ( object->permModify() ) 	// preemptive permissions check
 		{
-			object->setPhysicsRep( mValue );
+			object->setPhysicsShapeType( mValue );
 			object->updateFlags();
 		}
 		return true;
@@ -3947,10 +3947,10 @@ struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
 };
 
 
-void LLSelectMgr::selectionUpdatePhysicsRep(U8 rep)
+void LLSelectMgr::selectionUpdatePhysicsShapeType(U8 type)
 {
-	llwarns << "physics rep ->" << (U32)rep << llendl;
-	LLSelectMgrApplyPhysicsRep func(rep);
+	llwarns << "physics shape type ->" << (U32)type << llendl;
+	LLSelectMgrApplyPhysicsShapeType func(type);
 	getSelection()->applyToObjects(&func);	
 }
 
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 27e0c5dfa9d..544b1ff594e 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -483,7 +483,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void selectionUpdatePhysics(BOOL use_physics);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
-	void selectionUpdatePhysicsRep(U8 rep);
+	void selectionUpdatePhysicsShapeType(U8 type);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index f18fee3edec..7b94e49a2a2 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -53,6 +53,7 @@
 #include "llprimitive.h"
 #include "llquantize.h"
 #include "llregionhandle.h"
+#include "llsdserialize.h"
 #include "lltree_common.h"
 #include "llxfermanager.h"
 #include "message.h"
@@ -199,7 +200,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mGLName(0),
 	mbCanSelect(TRUE),
 	mFlags(0),
-	mPhysicsRep(0),
+	mPhysicsShapeType(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -4963,10 +4964,10 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("IsPhantom", flagPhantom() );
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
 	gMessageSystem->nextBlock("ExtraPhysics");
-	gMessageSystem->addU8("PhysicsRep", getPhysicsRep() );
+	gMessageSystem->addU8("PhysicsShapeType", getPhysicsShapeType() );
 	gMessageSystem->sendReliable( regionp->getHost() );
 
-	if (getPhysicsRep() != 0)
+	if (getPhysicsShapeType() != 0)
 	{
 		llwarns << "sent non default physics rep" << llendl;
 	}
@@ -5001,9 +5002,9 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 	return setit;
 }
 
-void LLViewerObject::setPhysicsRep(U8 rep)
+void LLViewerObject::setPhysicsShapeType(U8 type)
 {
-	mPhysicsRep = rep;
+	mPhysicsShapeType = type;
 	updateFlags();
 }
 
@@ -5217,7 +5218,7 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
 
 	return ;
 }
-#include "../llcommon/llsdserialize.h"
+
 class ObjectPhysicsProperties : public LLHTTPNode
 {
 public:
@@ -5231,11 +5232,8 @@ class ObjectPhysicsProperties : public LLHTTPNode
 		
 		for ( S32 i = 0; i < numEntries; i++ )
 		{
-			U32 localID = objectData[i]["LocalID"].asInteger();
-
-			std::ostringstream string;
-			LLSDSerialize::serialize( input, string, LLSDSerialize::LLSD_XML, LLSDFormatter::OPTIONS_PRETTY);
-			llinfos << string.str() << llendl;
+			LLSD& currObjectData = objectData[i];
+			U32 localID = currObjectData["LocalID"].asInteger();
 
 			// Iterate through nodes at end, since it can be on both the regular AND hover list
 			struct f : public LLSelectedNodeFunctor
@@ -5250,11 +5248,12 @@ class ObjectPhysicsProperties : public LLHTTPNode
 
 			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
 
-			U8 physicsRepSpec = (U8)objectData[i]["PhysicsRepSpec"].asInteger();
-
 			if (node)
 			{
-				node->getObject()->setPhysicsRep(physicsRepSpec);
+				// The LLSD message builder doesn't know how to handle U8, so we need to send as S8 and cast
+				U8 physicsShapeType = (U8)currObjectData["PhysicsShapeType"].asInteger();
+
+				node->getObject()->setPhysicsShapeType(physicsShapeType);
 			}	
 		}
 		
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 49709d643a7..de7bfc0e07b 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -459,7 +459,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	inline BOOL		flagCameraDecoupled() const		{ return ((mFlags & FLAGS_CAMERA_DECOUPLED) != 0); }
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
-	inline U8       getPhysicsRep() const           { return mPhysicsRep; }
+	inline U8       getPhysicsShapeType() const     { return mPhysicsShapeType; }
 	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
@@ -476,7 +476,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
-	void setPhysicsRep(U8 rep);
+	void setPhysicsShapeType(U8 type);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -557,7 +557,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	U32				mFlags;
 
 	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
-	U8              mPhysicsRep;
+	U8              mPhysicsShapeType;
 
 	// Pipeline classes
 	LLPointer<LLDrawable> mDrawable;
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index 3bb8e9c0554..b987cd91083 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1425,7 +1425,7 @@ even though the user gets a free copy.
              height="10"
              layout="topleft"
              left_delta="0"
-             name="label physicsrep"
+             name="label physicsshapetype"
              top_pad="10"
              width="121">
                 Physics Rep:
@@ -1434,18 +1434,18 @@ even though the user gets a free copy.
 			   height="23"
 			   layout="topleft"
 			   follows="left|top"
-			   name="Physics Rep Combo Ctrl"
-			   tool_tip="Choose the physics representation"
+			   name="Physics Shape Type Combo Ctrl"
+			   tool_tip="Choose the physics shape type"
 			   left_pad="0"
 			   width="108">
 			  <combo_box.item
-				 label="Default"
-				 name="Default"
-				 value="Default" />
+				 label="Prim"
+				 name="Prim"
+				 value="Prim" />
 			  <combo_box.item
-				 label="No Shape"
-				 name="No Shape"
-				 value="No Shape" />
+				 label="None"
+				 name="None"
+				 value="None" />
 			  <combo_box.item
 				 label="Convex Hull"
 				 name="Convex Hull"
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 7813bfba833..6043542877a 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2063,7 +2063,7 @@ version 2.0
 	}
     {
 		ExtraPhysics        Variable
-		{   PhysicsRep      U8      }
+		{   PhysicsShapeType U8     }
 	}
 }
 
-- 
GitLab


From 19c83c67c42305e41bff4b651975671d34a22b55 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Thu, 1 Apr 2010 11:30:43 -0700
Subject: [PATCH 249/683] DEV-47845 More cleanup. Fixed a bug where the physics
 shape type wouldn't get displayed properly until you re-selected an object.

---
 indra/newview/llviewerobject.cpp                     | 1 +
 indra/newview/skins/default/xui/en/floater_tools.xml | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index b7139b96479..5b778cc816e 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5249,6 +5249,7 @@ class ObjectPhysicsProperties : public LLHTTPNode
 			}	
 		}
 		
+		dialog_refresh_all();
 	};
 };
 
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index 4d608fb00a7..e851312d8e2 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1428,7 +1428,7 @@ even though the user gets a free copy.
              name="label physicsshapetype"
              top_pad="10"
              width="121">
-                Physics Rep:
+                Physics Shape Type:
             </text>
 			<combo_box
 			   height="23"
-- 
GitLab


From c2a0de46095315c778edf5c5c37c1de0bdfe82eb Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Thu, 1 Apr 2010 11:30:43 -0700
Subject: [PATCH 250/683] DEV-47845 More cleanup. Fixed a bug where the physics
 shape type wouldn't get displayed properly until you re-selected an object.

---
 indra/newview/llviewerobject.cpp                     | 1 +
 indra/newview/skins/default/xui/en/floater_tools.xml | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 7b94e49a2a2..bae84415d75 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5257,6 +5257,7 @@ class ObjectPhysicsProperties : public LLHTTPNode
 			}	
 		}
 		
+		dialog_refresh_all();
 	};
 };
 
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index b987cd91083..f5054cf2064 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1428,7 +1428,7 @@ even though the user gets a free copy.
              name="label physicsshapetype"
              top_pad="10"
              width="121">
-                Physics Rep:
+                Physics Shape Type:
             </text>
 			<combo_box
 			   height="23"
-- 
GitLab


From 17d5a40f8a6681151f0530c342174c5321d664eb Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Thu, 1 Apr 2010 11:34:05 -0700
Subject: [PATCH 251/683] Fixed line ending

---
 indra/newview/llviewerobject.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index a8212ade918..7532102378a 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5234,15 +5234,15 @@ class ObjectPhysicsProperties : public LLHTTPNode
 			LLSD& currObjectData = objectData[i];
 			U32 localID = currObjectData["LocalID"].asInteger();
 
-			// Iterate through nodes at end, since it can be on both the regular AND hover list
-			struct f : public LLSelectedNodeFunctor
-			{
-				U32 mID;
-				f(const U32& id) : mID(id) {}
-				virtual bool apply(LLSelectNode* node)
-				{
-					return (node->getObject() && node->getObject()->mLocalID == mID );
-				}
+			// Iterate through nodes at end, since it can be on both the regular AND hover list
+			struct f : public LLSelectedNodeFunctor
+			{
+				U32 mID;
+				f(const U32& id) : mID(id) {}
+				virtual bool apply(LLSelectNode* node)
+				{
+					return (node->getObject() && node->getObject()->mLocalID == mID );
+				}
 			} func(localID);
 
 			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
-- 
GitLab


From 725f0cfa6e85e1fd3a8cf1034e5b911a1803e1c2 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Thu, 1 Apr 2010 11:34:05 -0700
Subject: [PATCH 252/683] Fixed line ending

---
 indra/newview/llviewerobject.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bae84415d75..620e2701770 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5235,15 +5235,15 @@ class ObjectPhysicsProperties : public LLHTTPNode
 			LLSD& currObjectData = objectData[i];
 			U32 localID = currObjectData["LocalID"].asInteger();
 
-			// Iterate through nodes at end, since it can be on both the regular AND hover list
-			struct f : public LLSelectedNodeFunctor
-			{
-				U32 mID;
-				f(const U32& id) : mID(id) {}
-				virtual bool apply(LLSelectNode* node)
-				{
-					return (node->getObject() && node->getObject()->mLocalID == mID );
-				}
+			// Iterate through nodes at end, since it can be on both the regular AND hover list
+			struct f : public LLSelectedNodeFunctor
+			{
+				U32 mID;
+				f(const U32& id) : mID(id) {}
+				virtual bool apply(LLSelectNode* node)
+				{
+					return (node->getObject() && node->getObject()->mLocalID == mID );
+				}
 			} func(localID);
 
 			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
-- 
GitLab


From f17cfd952a274cc6c684e50db004d62373a49d1f Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Thu, 1 Apr 2010 17:03:51 -0700
Subject: [PATCH 253/683] DEV-47845: Finished fixing an update bug on the
 physics shape type and fixed the name of that combo box.

---
 indra/newview/app_settings/keywords.ini | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini
index 0805e94b10e..18edce42a44 100644
--- a/indra/newview/app_settings/keywords.ini
+++ b/indra/newview/app_settings/keywords.ini
@@ -353,6 +353,11 @@ PRIM_BUMP_SHINY		Followed by an integer face, one of PRIM_SHINY_NONE, PRIM_SHINY
 PRIM_FULLBRIGHT		Followed by an integer face, and TRUE or FALSE
 PRIM_TEXGEN			Followed by an integer face, and one of PRIM_TEXGEN_DEFAULT or PRIM_TEXGEN_PLANAR
 PRIM_GLOW			Followed by an integer face, and a float from 0.0 to 1.0 specifying glow amount
+PRIM_PHYSICS_SHAPE_TYPE Followed by one of PRIM_PHYSICS_SHAPE_PRIM (use prim as-is for physics), PRIM_PHYSICS_SHAPE_NONE (do not use prim for physics), PRIM_PHYSICS_SHAPE_CONVEX (use convex hull of prim for physics)
+
+PRIM_PHYSICS_SHAPE_PRIM     Sets the physics shape type to PRIM (i.e., use the prim as-is in the physics engine)
+PRIM_PHYSICS_SHAPE_NONE     Sets the physics shape type to NONE (i.e., the shape will not exist the physics engine)
+PRIM_PHYSICS_SHAPE_CONVEX   Sets the physics shape type to CONVEX (i.e., use the convex hull of the prim in the physics engine)
 
 PRIM_TYPE_BOX		Followed by integer hole shape, vector cut, float hollow, vector twist,:vector top size, and vector top shear
 PRIM_TYPE_CYLINDER	Followed by integer hole shape, vector cut, float hollow, vector twist,:vector top size, and vector top shear
-- 
GitLab


From dda40bd7823b05acb3aeb1729c7451713e084449 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Thu, 1 Apr 2010 17:03:51 -0700
Subject: [PATCH 254/683] DEV-47845: Finished fixing an update bug on the
 physics shape type and fixed the name of that combo box.

---
 indra/newview/app_settings/keywords.ini | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini
index 263b73ba23f..18edce42a44 100644
--- a/indra/newview/app_settings/keywords.ini
+++ b/indra/newview/app_settings/keywords.ini
@@ -353,6 +353,11 @@ PRIM_BUMP_SHINY		Followed by an integer face, one of PRIM_SHINY_NONE, PRIM_SHINY
 PRIM_FULLBRIGHT		Followed by an integer face, and TRUE or FALSE
 PRIM_TEXGEN			Followed by an integer face, and one of PRIM_TEXGEN_DEFAULT or PRIM_TEXGEN_PLANAR
 PRIM_GLOW			Followed by an integer face, and a float from 0.0 to 1.0 specifying glow amount
+PRIM_PHYSICS_SHAPE_TYPE Followed by one of PRIM_PHYSICS_SHAPE_PRIM (use prim as-is for physics), PRIM_PHYSICS_SHAPE_NONE (do not use prim for physics), PRIM_PHYSICS_SHAPE_CONVEX (use convex hull of prim for physics)
+
+PRIM_PHYSICS_SHAPE_PRIM     Sets the physics shape type to PRIM (i.e., use the prim as-is in the physics engine)
+PRIM_PHYSICS_SHAPE_NONE     Sets the physics shape type to NONE (i.e., the shape will not exist the physics engine)
+PRIM_PHYSICS_SHAPE_CONVEX   Sets the physics shape type to CONVEX (i.e., use the convex hull of the prim in the physics engine)
 
 PRIM_TYPE_BOX		Followed by integer hole shape, vector cut, float hollow, vector twist,:vector top size, and vector top shear
 PRIM_TYPE_CYLINDER	Followed by integer hole shape, vector cut, float hollow, vector twist,:vector top size, and vector top shear
@@ -497,7 +502,6 @@ PARCEL_DETAILS_DESC		Used with llGetParcelDetails to get the parcel description.
 PARCEL_DETAILS_OWNER	Used with llGetParcelDetails to get the parcel owner id.
 PARCEL_DETAILS_GROUP	Used with llGetParcelDetails to get the parcel group id.
 PARCEL_DETAILS_AREA		Used with llGetParcelDetails to get the parcel area in square meters.
-PARCEL_DETAILS_ID		Used with llGetParcelDetails to get the parcel id.
 
 STRING_TRIM_HEAD		Used with llStringTrim to trim leading spaces from a string.
 STRING_TRIM_TAIL		Used with llStringTrim to trim trailing spaces from a string.
-- 
GitLab


From 6fbe144e4cf578bb76c4e015c191300c17ac44fe Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 13:24:42 +0100
Subject: [PATCH 255/683] merge fix

---
 .../skins/default/xui/en/panel_main_inventory.xml      | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/indra/newview/skins/default/xui/en/panel_main_inventory.xml b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
index 0eea309d355..1b04d01abf4 100644
--- a/indra/newview/skins/default/xui/en/panel_main_inventory.xml
+++ b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
@@ -38,16 +38,6 @@
 		     width="300">
     Items:
   </text>
-                 label="Model..."
-                 layout="topleft"
-                 name="Upload Model">
-                    <menu_item_call.on_click
-                     function="File.UploadModel"
-                     parameter="" />
-                    <menu_item_call.on_enable
-                     function="File.EnableUploadModel" />
-                </menu_item_call>
-                <menu_item_call
   <filter_editor
    text_pad_left="10"
    follows="left|top|right"
-- 
GitLab


From 89ad33a53ef239adf332532fa1039ae6313f5ba9 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 14:40:15 +0100
Subject: [PATCH 256/683] ssreflections: reflect sunlight direction for
 reflection.  dunno how I feel about this yet.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 155f03fdcf9..51d737f10b4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -310,8 +310,11 @@ void main()
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
-		// get appropriate light strength for guess-point
-		float reflit = max(dot(refn, lightnorm.xyz), 0.0);
+		// get appropriate light strength for guess-point.
+		// reflect light direction to increase the illusion that
+		// these are reflections.
+		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
+		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		vec3 ssshiny = (refprod * spec.a);
-- 
GitLab


From cae24385d7a119d0ad634d252bd3bb1e4e68c57c Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 14:50:24 +0100
Subject: [PATCH 257/683] ssreflections: use the minimum of the lighting dp and
 the appropriateness.  not the product.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl      | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 51d737f10b4..8b2b983ba45 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -317,6 +317,8 @@ void main()
 		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		float refmod = min(refapprop, reflit);
+		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 
 		// add the two types of shiny together
-- 
GitLab


From 145ffe0da00f87ad16eb17dcec3c5a1a201fe32b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 15:20:35 +0100
Subject: [PATCH 258/683] ssreflections: water reflections strongly imply that
 the non-perspective reflection from eye is the right one.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 8b2b983ba45..25733e80d12 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -282,7 +282,8 @@ void main()
 	{
 		// the old infinite-sky shiny reflection
 		//
-		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
+		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
+		//vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnorm, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
-- 
GitLab


From 7261a23f39ce2dbfadf52427ce693896d9d24bf0 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 15:46:47 +0100
Subject: [PATCH 259/683] ssreflections: perspective reflection for sunlight,
 planar reflection for ssreflection

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 25733e80d12..d00d3ed4121 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -282,13 +282,13 @@ void main()
 	{
 		// the old infinite-sky shiny reflection
 		//
-		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
-		//vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(refnorm, vary_light.xyz);
+		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
 		// screen-space cheap fakey reflection map
 		//
+		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
-- 
GitLab


From 35d92b2db91a9da1ae240f14202195c36a2b40bf Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 15:59:11 +0100
Subject: [PATCH 260/683] clean-up transplant

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl       | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index d00d3ed4121..503c7d0b838 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -317,7 +317,6 @@ void main()
 		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
 		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
-		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
-- 
GitLab


From 33fd1e26beac37701301dfce3478a145720d73c9 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 16:03:20 +0100
Subject: [PATCH 261/683] apply ssreflection changes to class2 and class3 too.

---
 .../shaders/class2/deferred/softenLightF.glsl     | 13 +++++++++----
 .../shaders/class3/deferred/softenLightF.glsl     | 15 ++++++++++-----
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 922a07c3066..d6fbae7b22b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -281,12 +281,13 @@ void main()
 	{
 		// the old infinite-sky shiny reflection
 		//
-		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(refnorm, vary_light.xyz);
+		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
 		// screen-space cheap fakey reflection map
 		//
+		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
@@ -311,9 +312,13 @@ void main()
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
 		// get appropriate light strength for guess-point
-		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad);
+		// reflect light direction to increase the illusion that
+		// these are reflections.
+		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
+		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
-		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		float refmod = min(refapprop, reflit);
+		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 
 		// add the two types of shiny together
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index ddd69befc36..ecfd9bef52b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -284,12 +284,13 @@ void main()
 	{
 		// the old infinite-sky shiny reflection
 		//
-		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz));
-		float sa = dot(refnorm, vary_light.xyz);
+		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
 		// screen-space cheap fakey reflection map
 		//
+		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
 		depth -= 0.5; // unbias depth
 		// first figure out where we'll make our 2D guess from
 		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
@@ -313,10 +314,14 @@ void main()
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
 		//refapprop *= step(dot(refnorm, refn), 0.0);
 		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
-		// get appropriate light strength for guess-point
-		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad);
+		// get appropriate light strength for guess-point.
+		// reflect light direction to increase the illusion that
+		// these are reflections.
+		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
+		float reflit = max(dot(refn, reflight.xyz), 0.0);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
-		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop;
+		float refmod = min(refapprop, reflit);
+		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 
 		// add the two types of shiny together
-- 
GitLab


From a63c59be9e7df57143ddd04e44263c232f420a21 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 2 Apr 2010 16:09:31 +0100
Subject: [PATCH 262/683] ssreflection: restore the shadow factor I
 accidentally removed with the last update.

---
 .../app_settings/shaders/class2/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index d6fbae7b22b..00a6a9dcb5e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -315,7 +315,7 @@ void main()
 		// reflect light direction to increase the illusion that
 		// these are reflections.
 		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
-		float reflit = max(dot(refn, reflight.xyz), 0.0);
+		float reflit = min(max(dot(refn, reflight.xyz), 0.0), refshad);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index ecfd9bef52b..aaa74eb7df4 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -318,7 +318,7 @@ void main()
 		// reflect light direction to increase the illusion that
 		// these are reflections.
 		vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
-		float reflit = max(dot(refn, reflight.xyz), 0.0);
+		float reflit = min(max(dot(refn, reflight.xyz), 0.0), refshad);
 		// apply sun color to guess-point, dampen according to inappropriateness of guess
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
-- 
GitLab


From 807d835c2bfc5d794a74f9690d1fafbe55ff88cc Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 2 Apr 2010 14:43:05 -0500
Subject: [PATCH 263/683] First draft of skin weights in .mesh asset

---
 indra/llcommon/llsdserialize.cpp | 137 +++++++++++++++++++++++++++++++
 indra/llcommon/llsdserialize.h   |   4 +
 indra/llmath/llvolume.cpp        | 135 ++++++++++--------------------
 indra/llmath/llvolume.h          |   6 ++
 4 files changed, 192 insertions(+), 90 deletions(-)

diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index cf337be1615..c341b155399 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -39,6 +39,7 @@
 
 #include <iostream>
 #include "apr_base64.h"
+#include "zlib/zlib.h"  // for davep's dirty little zip functions
 
 #if !LL_WINDOWS
 #include <netinet/in.h> // htonl & ntohl
@@ -1989,3 +1990,139 @@ std::ostream& operator<<(std::ostream& s, const LLSD& llsd)
 	return s;
 }
 
+
+//dirty little zippers -- yell at davep if these are horrid
+
+//return a string containing gzipped bytes of binary serialized LLSD
+// VERY inefficient -- creates several copies of LLSD block in memory
+std::string zip_llsd(LLSD& data)
+{ 
+	std::stringstream llsd_strm;
+
+	LLSDSerialize::serialize(data, llsd_strm, LLSDSerialize::LLSD_BINARY);
+
+	z_stream strm;
+	strm.zalloc = Z_NULL;
+	strm.zfree = Z_NULL;
+	strm.opaque = Z_NULL;
+
+	S32 ret = deflateInit(&strm, Z_BEST_COMPRESSION);
+	if (ret != Z_OK)
+	{
+		llwarns << "Failed to compress LLSD block." << llendl;
+		return std::string();
+	}
+
+	std::string source = llsd_strm.str();
+
+	strm.avail_in = source.size();
+	strm.next_in = (U8*) source.data();
+	U8* output = new U8[strm.avail_in];
+	strm.avail_out = strm.avail_in;
+	strm.next_out = output;
+	ret = deflate(&strm, Z_FINISH);
+	if (ret != Z_STREAM_END)
+	{
+		delete [] output;
+		llwarns << "Failed to compress LLSD block." << llendl;
+	}
+
+	std::string::size_type size = source.size()-strm.avail_out;
+
+	std::string result((char*) output, size);
+	deflateEnd(&strm);
+	delete [] output;
+
+	return result;
+}
+
+//decompress a block of LLSD from provided istream
+// not very efficient -- creats a copy of decompressed LLSD block in memory
+// and deserializes from that copy using LLSDSerialize
+bool unzip_llsd(LLSD& data, std::istream& is, S32 size)
+{
+	U8* result = NULL;
+	U32 cur_size = 0;
+	z_stream strm;
+		
+	const U32 CHUNK = 65536;
+
+	U8 *in = new U8[size];
+	is.read((char*) in, size); 
+
+	U8 out[CHUNK];
+		
+	strm.zalloc = Z_NULL;
+	strm.zfree = Z_NULL;
+	strm.opaque = Z_NULL;
+	strm.avail_in = size;
+	strm.next_in = in;
+
+	S32 ret = inflateInit(&strm);
+
+	if (ret != Z_OK)
+	{
+		llerrs << "WTF?" << llendl;
+	}
+	
+	do
+	{
+		strm.avail_out = CHUNK;
+		strm.next_out = out;
+		ret = inflate(&strm, Z_NO_FLUSH);
+		if (ret == Z_STREAM_ERROR)
+		{
+			inflateEnd(&strm);
+			free(result);
+			delete [] in;
+			return false;
+		}
+		
+		switch (ret)
+		{
+		case Z_NEED_DICT:
+			ret = Z_DATA_ERROR;
+		case Z_DATA_ERROR:
+		case Z_MEM_ERROR:
+			inflateEnd(&strm);
+			free(result);
+			delete [] in;
+			return false;
+			break;
+		}
+
+		U32 have = CHUNK-strm.avail_out;
+
+		result = (U8*) realloc(result, cur_size + have);
+		memcpy(result+cur_size, out, have);
+		cur_size += have;
+
+	} while (strm.avail_out == 0);
+
+	inflateEnd(&strm);
+	delete [] in;
+
+	if (ret != Z_STREAM_END)
+	{
+		free(result);
+		return false;
+	}
+
+	//result now points to the decompressed LLSD block
+	{
+		std::string res_str((char*) result, cur_size);
+		std::istringstream istr(res_str);
+
+		if (!LLSDSerialize::deserialize(data, istr, cur_size))
+		{
+			llwarns << "Failed to unzip LLSD block" << llendl;
+			return false;
+		}
+	}
+
+	free(result);
+	return true;
+}
+
+
+
diff --git a/indra/llcommon/llsdserialize.h b/indra/llcommon/llsdserialize.h
index 2f2b292189b..390eaca7838 100644
--- a/indra/llcommon/llsdserialize.h
+++ b/indra/llcommon/llsdserialize.h
@@ -796,4 +796,8 @@ class LL_COMMON_API LLSDSerialize
 	}
 };
 
+//dirty little zip functions -- yell at davep
+LL_COMMON_API std::string zip_llsd(LLSD& data);
+LL_COMMON_API bool unzip_llsd(LLSD& data, std::istream& is, S32 size);
+
 #endif // LL_LLSDSERIALIZE_H
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 52a3fb21955..c563af592f1 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -47,8 +47,6 @@
 #include "llvolume.h"
 #include "llstl.h"
 #include "llsdserialize.h"
-#include "zlib/zlib.h"
-
 
 #define DEBUG_SILHOUETTE_BINORMALS 0
 #define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette
@@ -1964,97 +1962,15 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
 
 bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 {
-	U8* result = NULL;
-	U32 cur_size = 0;
-
-	{
-		//input stream is now pointing at a zlib compressed block of LLSD
-		//decompress block
-		z_stream strm;
-		
-		const U32 CHUNK = 65536;
-
-		U8 *in = new U8[size];
-		is.read((char*) in, size); 
-
-		U8 out[CHUNK];
-			
-		strm.zalloc = Z_NULL;
-		strm.zfree = Z_NULL;
-		strm.opaque = Z_NULL;
-		strm.avail_in = size;
-		strm.next_in = in;
-
-		S32 ret = inflateInit(&strm);
-
-		if (ret != Z_OK)
-		{
-			llerrs << "WTF?" << llendl;
-		}
-		
-		do
-		{
-			strm.avail_out = CHUNK;
-			strm.next_out = out;
-			ret = inflate(&strm, Z_NO_FLUSH);
-			if (ret == Z_STREAM_ERROR)
-			{
-				inflateEnd(&strm);
-				free(result);
-				delete [] in;
-				return false;
-			}
-			
-			switch (ret)
-			{
-			case Z_NEED_DICT:
-				ret = Z_DATA_ERROR;
-			case Z_DATA_ERROR:
-			case Z_MEM_ERROR:
-				inflateEnd(&strm);
-				free(result);
-				delete [] in;
-				return false;
-				break;
-			}
-
-			U32 have = CHUNK-strm.avail_out;
-
-			result = (U8*) realloc(result, cur_size + have);
-			memcpy(result+cur_size, out, have);
-			cur_size += have;
-
-		} while (strm.avail_out == 0);
-
-		inflateEnd(&strm);
-		delete [] in;
-
-		if (ret != Z_STREAM_END)
-		{
-			free(result);
-			return false;
-		}
-	}
-
-	//result now points to the decompressed LLSD block
-
+	//input stream is now pointing at a zlib compressed block of LLSD
+	//decompress block
 	LLSD mdl;
-
+	if (!unzip_llsd(mdl, is, size))
 	{
-		std::string res_str((char*) result, cur_size);
-		std::istringstream istr(res_str);
-
-		if (!LLSDSerialize::deserialize(mdl, istr, cur_size))
-		{
-			llwarns << "not a valid mesh asset!" << llendl;
-			return false;
-		}
+		llwarns << "not a valid mesh asset!" << llendl;
+		return false;
 	}
-
-
-	free(result);
-
-
+	
 	{
 		U32 face_count = mdl.size();
 
@@ -2094,11 +2010,50 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 			U32 num_verts = pos.size()/(3*2);
 			face.mVertices.resize(num_verts);
 
+			if (mdl[i].has("Weights"))
+			{
+				face.mWeights.resize(num_verts);
+				LLSD::Binary weights = mdl[i]["Weights"];
+
+				LLSD::Binary::iterator iter = weights.begin();
+
+				U32 cur_vertex = 0;
+				while (iter != weights.end())
+				{
+					const S32 END_INFLUENCES = 0xFF;
+					U8 joint = *(iter++);
+
+					U32 cur_influence = 0;
+					while (joint != END_INFLUENCES)
+					{
+						U16 influence = *(iter++);
+						influence = influence << 8;
+						influence |= *(iter++);
+
+						F32 w = llmin((F32) influence / 65535.f, 0.99999f);
+						face.mWeights[cur_vertex].mV[cur_influence++] = (F32) joint + w;
+
+						if (cur_influence >= 4)
+						{
+							joint = END_INFLUENCES;
+						}
+						else
+						{
+							joint = *(iter++);
+						}
+					}
+
+					cur_vertex++;
+					iter++;
+				}
+			}
+
 			LLVector3 min_pos;
 			LLVector3 max_pos;
 			LLVector2 min_tc; 
 			LLVector2 max_tc; 
 
+		
 			min_pos.setValue(mdl[i]["PositionDomain"]["Min"]);
 			max_pos.setValue(mdl[i]["PositionDomain"]["Max"]);
 			min_tc.setValue(mdl[i]["TexCoord0Domain"]["Min"]);
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 60c1569e550..c6a156ae379 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -49,6 +49,7 @@ class LLVolume;
 //#include "vmath.h"
 #include "v2math.h"
 #include "v3math.h"
+#include "v4math.h"
 #include "llquaternion.h"
 #include "llstrider.h"
 #include "v4coloru.h"
@@ -887,6 +888,11 @@ class LLVolumeFace
 	std::vector<U16>	mTriStrip;
 	std::vector<S32>	mEdge;
 
+	//list of skin weights for rigged volumes
+	// format is mWeights[vertex_index].mV[influence] = <joint_index>.<weight>
+	// mWeights.size() should be empty or match mVertices.size()  
+	std::vector<LLVector4> mWeights;
+
 private:
 	BOOL createUnCutCubeCap(LLVolume* volume, BOOL partial_build = FALSE);
 	BOOL createCap(LLVolume* volume, BOOL partial_build = FALSE);
-- 
GitLab


From 8f16be49dc86f0fca228b09ce0b788ad03482888 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 6 Apr 2010 15:09:18 +0100
Subject: [PATCH 264/683] some fixing from the viewer-trunk merge.

---
 indra/llmessage/llcurl.cpp        | 2 ++
 indra/newview/llinventorybridge.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 63a684ccc42..7c6660e28b9 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -1173,4 +1173,6 @@ void LLCurl::cleanupClass()
 	{
 		llerrs << "CURL easy handles not cleaned up on shutdown!" << llendl;
 	}
+}
+
 
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index e5abe02afdb..d5e4da41e45 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -46,7 +46,6 @@ class LLInventoryModel;
 class LLMenuGL;
 class LLCallingCardObserver;
 class LLViewerJointAttachment;
-	MESH_ICON_NAME,
 
 
 typedef std::vector<std::string> menuentry_vec_t;
@@ -219,6 +218,7 @@ enum EInventoryIcon
 	
 	ANIMATION_ICON_NAME,
 	GESTURE_ICON_NAME,
+	MESH_ICON_NAME,
 
 	LINKITEM_ICON_NAME,
 	LINKFOLDER_ICON_NAME,
-- 
GitLab


From 1de148608699e85a893e9e4e4ebf6e9c851d8f58 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 6 Apr 2010 15:12:22 +0100
Subject: [PATCH 265/683] more fixing from the viewer-trunk merge

---
 indra/newview/llinventorybridge.cpp | 2 +-
 indra/newview/llinventorybridge.h   | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 182629d2daa..5c0898407e0 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -997,7 +997,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 			{
 				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << safe_inv_type_lookup(inv_type) << " on uuid " << uuid << llendl;
 			}
-			new_listener = new LLMeshBridge(inventory, uuid);
+			new_listener = new LLMeshBridge(inventory, root, uuid);
 			break;
 
 		default:
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index d5e4da41e45..75b206f3b75 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -640,8 +640,10 @@ class LLMeshBridge : public LLItemBridge
 	virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
 
 protected:
-	LLMeshBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
-		LLItemBridge(inventory, uuid) {}
+	LLMeshBridge(LLInventoryPanel* inventory, 
+		     LLFolderView* root,
+		     const LLUUID& uuid) :
+                       LLItemBridge(inventory, root, uuid) {}
 };
 
 
-- 
GitLab


From 8f2f9e682b5cb42d0292d1f923777441b85d2feb Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 6 Apr 2010 15:13:15 +0100
Subject: [PATCH 266/683] wtf-fix for using \\ instead of // as a comment.

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

diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp
index f9f42cfc862..e0c7c83f4b5 100644
--- a/indra/newview/tests/llviewernetwork_test.cpp
+++ b/indra/newview/tests/llviewernetwork_test.cpp
@@ -216,10 +216,10 @@ namespace tut
 #ifndef LL_RELEASE_FOR_DOWNLOAD
 		ensure_equals("Agni grid label was not modified by grid file", 
 					  grid[GRID_LABEL_VALUE].asString(), std::string("Agni"));
-#else \\ LL_RELEASE_FOR_DOWNLOAD
+#else // LL_RELEASE_FOR_DOWNLOAD
 		ensure_equals("Agni grid label was not modified by grid file", 
 					  grid[GRID_LABEL_VALUE].asString(), std::string("Secondlife.com"));
-#endif \\ LL_RELEASE_FOR_DOWNLOAD
+#endif // LL_RELEASE_FOR_DOWNLOAD
 		
 		ensure_equals("Agni name wasn't modified by grid file",
 					  grid[GRID_VALUE].asString(), std::string("util.agni.lindenlab.com"));
-- 
GitLab


From 5de3e21a38f81559626cdca8a9e5b9e06f955063 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 6 Apr 2010 15:33:35 +0100
Subject: [PATCH 267/683] another conflict fix from viewer-trunk merge

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

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 5c0898407e0..2e690493cdb 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -995,7 +995,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 	        case LLAssetType::AT_MESH:
 			if(!(inv_type == LLInventoryType::IT_MESH))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << safe_inv_type_lookup(inv_type) << " on uuid " << uuid << llendl;
+				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
 			}
 			new_listener = new LLMeshBridge(inventory, root, uuid);
 			break;
-- 
GitLab


From c1b49a2142f04bde232d65038ac88765423fc7ad Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 6 Apr 2010 15:34:56 +0100
Subject: [PATCH 268/683] yet more conflict fixing from viewer-trunk merge

---
 indra/newview/llinventorybridge.cpp | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 2e690493cdb..7c156561b91 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -5107,7 +5107,6 @@ void LLLinkFolderBridge::performAction(LLInventoryModel* model, std::string acti
 		return;
 	}
 	LLItemBridge::performAction(model,action);
-		items.push_back(std::string("Restore Item"));
 }
 void LLLinkFolderBridge::gotoItem()
 {
@@ -5125,9 +5124,6 @@ void LLLinkFolderBridge::gotoItem()
 			mRoot->scrollToShowSelection();
 		}
 	}
-
-
-	hide_context_entries(menu, items, disabled_items);
 }
 const LLUUID &LLLinkFolderBridge::getFolderID() const
 {
@@ -5138,12 +5134,6 @@ const LLUUID &LLLinkFolderBridge::getFolderID() const
 			const LLUUID& cat_uuid = cat->getUUID();
 			return cat_uuid;
 		}
-	case LLAssetType::AT_MESH:
-		action = new LLMeshBridgeAction(uuid,model);
-		break;
-
-
-		
 	}
 	return LLUUID::null;
 }
-- 
GitLab


From cbf1ae105a980a439cff39026f9e2c05d4f13859 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 6 Apr 2010 15:45:54 +0100
Subject: [PATCH 269/683] sigghhhh, yet more conflict resolution from the
 viewer-trunk merge.  actually builds now.  let's see if it runs and works.

---
 indra/newview/llinventorybridge.cpp      | 13 +------------
 indra/newview/llpanelobjectinventory.cpp |  6 +++---
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 7c156561b91..83248e99911 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -5389,20 +5389,9 @@ class LLWearableBridgeAction: public LLInvFVBridgeAction
 				LLNotificationsUtil::add("CannotWearInfoNotComplete");
 			}
 		}
-	LLInvFVBridgeAction::doIt();
-}
-
-//virtual
-void	LLMeshBridgeAction::doIt() 
-{
-	LLViewerInventoryItem* item = getItem();
-	if(item)
-	{
-		// do it
-	}
-	
 		LLInvFVBridgeAction::doIt();
 	}
+
 	virtual ~LLWearableBridgeAction(){}
 protected:
 	LLWearableBridgeAction(const LLUUID& id,LLInventoryModel* model) : LLInvFVBridgeAction(id,model) {}
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index d6644e16c6b..76dee78f3dc 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -1418,7 +1418,7 @@ class LLTaskMeshBridge : public LLTaskInvFVBridge
 
 	virtual LLUIImagePtr getIcon() const;
 	virtual void openItem();
-	virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action);
+	virtual void performAction(LLInventoryModel* model, std::string action);
 	virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
 };
 
@@ -1442,7 +1442,7 @@ void LLTaskMeshBridge::openItem()
 
 
 // virtual
-void LLTaskMeshBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action)
+void LLTaskMeshBridge::performAction(LLInventoryModel* model, std::string action)
 {
 	if (action == "mesh action")
 	{
@@ -1452,7 +1452,7 @@ void LLTaskMeshBridge::performAction(LLFolderView* folder, LLInventoryModel* mod
 			// do action
 		}
 	}
-	LLTaskInvFVBridge::performAction(folder, model, action);
+	LLTaskInvFVBridge::performAction(model, action);
 }
 
 void LLTaskMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
-- 
GitLab


From 47ffcdb93d6e2ac1f9d497e43e0213c98d129254 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 6 Apr 2010 16:24:08 -0500
Subject: [PATCH 270/683] Rigged attachments (almost works).

---
 indra/llmath/llvolume.cpp           |  22 ++++--
 indra/llrender/llglslshader.cpp     |  14 +++-
 indra/llrender/llglslshader.h       |   3 +-
 indra/llrender/llshadermgr.cpp      |   8 ++
 indra/newview/lldrawpoolavatar.cpp  |  26 ++++++-
 indra/newview/lldrawpoolavatar.h    |   2 +
 indra/newview/llface.cpp            |  18 ++++-
 indra/newview/llface.h              |   4 +-
 indra/newview/llspatialpartition.h  |   7 ++
 indra/newview/llviewershadermgr.cpp |  25 +++++++
 indra/newview/llviewershadermgr.h   |   3 +
 indra/newview/llvoavatar.cpp        | 109 ++++++++++++++++++++++++++++
 indra/newview/llvoavatar.h          |   1 +
 indra/newview/llvovolume.cpp        |  20 +++++
 14 files changed, 247 insertions(+), 15 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index c563af592f1..fdd48b9e9ed 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2013,22 +2013,23 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 			if (mdl[i].has("Weights"))
 			{
 				face.mWeights.resize(num_verts);
+
 				LLSD::Binary weights = mdl[i]["Weights"];
 
-				LLSD::Binary::iterator iter = weights.begin();
+				U32 idx = 0;
 
 				U32 cur_vertex = 0;
-				while (iter != weights.end())
+				while (idx < weights.size() && cur_vertex < num_verts)
 				{
-					const S32 END_INFLUENCES = 0xFF;
-					U8 joint = *(iter++);
+					const U8 END_INFLUENCES = 0xFF;
+					U8 joint = weights[idx++];
 
 					U32 cur_influence = 0;
 					while (joint != END_INFLUENCES)
 					{
-						U16 influence = *(iter++);
+						U16 influence = weights[idx++];
 						influence = influence << 8;
-						influence |= *(iter++);
+						influence |= weights[idx++];
 
 						F32 w = llmin((F32) influence / 65535.f, 0.99999f);
 						face.mWeights[cur_vertex].mV[cur_influence++] = (F32) joint + w;
@@ -2039,13 +2040,18 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 						}
 						else
 						{
-							joint = *(iter++);
+							joint = weights[idx++];
 						}
 					}
 
 					cur_vertex++;
-					iter++;
 				}
+
+				if (cur_vertex != num_verts || idx != weights.size())
+				{
+					llwarns << "Vertex weight count does not match vertex count!" << llendl;
+				}
+					
 			}
 
 			LLVector3 min_pos;
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index ca92cb6580f..949057df049 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -61,7 +61,7 @@ BOOL shouldChange(const LLVector4& v1, const LLVector4& v2)
 
 LLShaderFeatures::LLShaderFeatures()
 : calculatesLighting(false), isShiny(false), isFullbright(false), hasWaterFog(false),
-hasTransport(false), hasSkinning(false), hasAtmospherics(false), isSpecular(false),
+hasTransport(false), hasSkinning(false), hasObjectSkinning(false), hasAtmospherics(false), isSpecular(false),
 hasGamma(false), hasLighting(false), calculatesAtmospherics(false)
 {
 }
@@ -717,6 +717,18 @@ GLint LLGLSLShader::getUniformLocation(const string& uniform)
 	return -1;
 }
 
+GLint LLGLSLShader::getAttribLocation(U32 attrib)
+{
+	if (attrib < mAttribute.size())
+	{
+		return mAttribute[attrib];
+	}
+	else
+	{
+		return -1;
+	}
+}
+
 void LLGLSLShader::uniform1i(const string& uniform, GLint v)
 {
 	GLint location = getUniformLocation(uniform);
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 166d4af04ca..dc493ba1629 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -48,6 +48,7 @@ class LLShaderFeatures
 	bool hasWaterFog; // implies no gamma
 	bool hasTransport; // implies no lighting (it's possible to have neither though)
 	bool hasSkinning;	
+	bool hasObjectSkinning;
 	bool hasAtmospherics;
 	bool hasGamma;
 
@@ -109,7 +110,7 @@ class LLGLSLShader
 	void vertexAttrib4fv(U32 index, GLfloat* v);
 	
 	GLint getUniformLocation(const std::string& uniform);
-	
+	GLint getAttribLocation(U32 attrib);
 	GLint mapUniformTextureChannel(GLint location, GLenum type);
 	
 
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 1286e91e49c..23b76351ebb 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -152,6 +152,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
 			return FALSE;
 		}
 	}
+
+	if (features->hasObjectSkinning)
+	{
+		if (!shader->attachObject("avatar/objectSkinV.glsl"))
+		{
+			return FALSE;
+		}
+	}
 	
 	///////////////////////////////////////
 	// Attach Fragment Shader Features Next
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 012e41383fb..9311a5f60ec 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -320,7 +320,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 
 S32 LLDrawPoolAvatar::getNumPasses()
 {
-	return LLPipeline::sImpostorRender ? 1 : 3;
+	return LLPipeline::sImpostorRender ? 1 : 4;
 }
 
 void LLDrawPoolAvatar::render(S32 pass)
@@ -357,6 +357,8 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 		break;
 	case 2:
 		beginSkinned();
+	case 3:
+		beginRigged();
 		break;
 	}
 }
@@ -381,6 +383,10 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 		break;
 	case 2:
 		endSkinned();
+		break;
+	case 3:
+		endRigged();
+		break;
 	}
 }
 
@@ -566,6 +572,18 @@ void LLDrawPoolAvatar::endSkinned()
 	gGL.getTexUnit(0)->activate();
 }
 
+void LLDrawPoolAvatar::beginRigged()
+{
+	gSkinnedObjectSimpleProgram.bind();
+	LLVertexBuffer::sWeight4Loc = gSkinnedObjectSimpleProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endRigged()
+{
+	gSkinnedObjectSimpleProgram.unbind();
+	LLVertexBuffer::sWeight4Loc = -1;
+}
+
 void LLDrawPoolAvatar::beginDeferredSkinned()
 {
 	sShaderLevel = mVertexShaderLevel;
@@ -711,6 +729,12 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		avatarp->renderRigid();
 		return;
 	}
+
+	if (pass == 3)
+	{
+		avatarp->renderSkinnedAttachments();
+		return;
+	}
 	
 	if (sShaderLevel > 0)
 	{
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index b9479436199..c43aa9b1e30 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -90,10 +90,12 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginRigid();
 	void beginFootShadow();
 	void beginSkinned();
+	void beginRigged();
 		
 	void endRigid();
 	void endFootShadow();
 	void endSkinned();
+	void endRigged();
 
 	void beginDeferredImpostor();
 	void beginDeferredRigid();
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 53330e4d985..bc3e04db183 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -888,7 +888,8 @@ static LLFastTimer::DeclareTimer FTM_FACE_GET_GEOM("Face Geom");
 BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 							   const S32 &f,
 								const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
-								const U16 &index_offset)
+								const U16 &index_offset,
+								bool force_rebuild)
 {
 	LLFastTimer t(FTM_FACE_GET_GEOM);
 	const LLVolumeFace &vf = volume.getVolumeFace(f);
@@ -925,8 +926,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	LLStrider<LLColor4U> colors;
 	LLStrider<LLVector3> binormals;
 	LLStrider<U16> indicesp;
+	LLStrider<LLVector4> weights;
 
-	BOOL full_rebuild = mDrawablep->isState(LLDrawable::REBUILD_VOLUME);
+	BOOL full_rebuild = force_rebuild || mDrawablep->isState(LLDrawable::REBUILD_VOLUME);
 	
 	BOOL global_volume = mDrawablep->getVOVolume()->isVolumeGlobal();
 	LLVector3 scale;
@@ -944,6 +946,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	BOOL rebuild_tcoord = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_TCOORD);
 	BOOL rebuild_normal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
 	BOOL rebuild_binormal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_BINORMAL);
+	bool rebuild_weights = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_WEIGHT4);
 
 	const LLTextureEntry *tep = mVObjp->getTE(f);
 	U8  bump_code = tep ? tep->getBumpmap() : 0;
@@ -960,7 +963,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	{
 		mVertexBuffer->getBinormalStrider(binormals, mGeomIndex);
 	}
-
+	if (rebuild_weights)
+	{
+		mVertexBuffer->getWeight4Strider(weights, mGeomIndex);
+	}
+	
 	F32 tcoord_xoffset = 0.f ;
 	F32 tcoord_yoffset = 0.f ;
 	F32 tcoord_xscale = 1.f ;
@@ -1338,6 +1345,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 			*binormals++ = binormal;
 		}
 		
+		if (rebuild_weights)
+		{
+			*weights++ = vf.mWeights[i];
+		}
+
 		if (rebuild_color)
 		{
 			*colors++ = color;		
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 67dd97e6f7a..06ec043c760 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -73,6 +73,7 @@ class LLFace
 		HUD_RENDER		= 0x0008,
 		USE_FACE_COLOR	= 0x0010,
 		TEXTURE_ANIM	= 0x0020, 
+		RIGGED			= 0x0040,
 	};
 
 	static void initClass();
@@ -145,7 +146,8 @@ class LLFace
 	BOOL getGeometryVolume(const LLVolume& volume,
 						const S32 &f,
 						const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
-						const U16 &index_offset);
+						const U16 &index_offset,
+						bool force_rebuild = false);
 
 	// For avatar
 	U16			 getGeometryAvatar(
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index d74216de2d1..b5e59673749 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -615,6 +615,13 @@ class LLCloudPartition : public LLParticlePartition
 class LLVolumeGeometryManager: public LLGeometryManager
 {
  public:
+	typedef enum
+	{
+		NONE = 0,
+		BATCH_SORT,
+		DISTANCE_SORT
+	} eSortType;
+
 	virtual ~LLVolumeGeometryManager() { }
 	virtual void rebuildGeom(LLSpatialGroup* group);
 	virtual void rebuildMesh(LLSpatialGroup* group);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index a0d0b9d4904..8a68dd6ea70 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -77,6 +77,9 @@ LLGLSLShader		gObjectFullbrightShinyProgram;
 LLGLSLShader		gObjectShinyProgram;
 LLGLSLShader		gObjectShinyWaterProgram;
 
+//object hardware skinning shaders
+LLGLSLShader		gSkinnedObjectSimpleProgram;
+
 //environment shaders
 LLGLSLShader		gTerrainProgram;
 LLGLSLShader		gTerrainWaterProgram;
@@ -148,6 +151,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gObjectSimpleProgram);
 	mShaderList.push_back(&gObjectFullbrightProgram);
 	mShaderList.push_back(&gObjectFullbrightShinyProgram);
+	mShaderList.push_back(&gSkinnedObjectSimpleProgram);
 	mShaderList.push_back(&gTerrainProgram);
 	mShaderList.push_back(&gTerrainWaterProgram);
 	mShaderList.push_back(&gObjectSimpleWaterProgram);
@@ -195,6 +199,7 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void)
 		mReservedAttribs.push_back("materialColor");
 		mReservedAttribs.push_back("specularColor");
 		mReservedAttribs.push_back("binormal");
+		mReservedAttribs.push_back("object_weight");
 
 		mAvatarAttribs.reserve(5);
 		mAvatarAttribs.push_back("weight");
@@ -548,6 +553,9 @@ void LLViewerShaderMgr::unloadShaders()
 	gObjectShinyProgram.unload();
 	gObjectFullbrightShinyProgram.unload();
 	gObjectShinyWaterProgram.unload();
+
+	gSkinnedObjectSimpleProgram.unload();
+
 	gWaterProgram.unload();
 	gUnderWaterProgram.unload();
 	gTerrainProgram.unload();
@@ -625,6 +633,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders()
 	shaders.push_back( make_pair( "lighting/lightSpecularV.glsl",			mVertexShaderLevel[SHADER_LIGHTING] ) );
 	shaders.push_back( make_pair( "windlight/atmosphericsV.glsl",			mVertexShaderLevel[SHADER_WINDLIGHT] ) );
 	shaders.push_back( make_pair( "avatar/avatarSkinV.glsl",				1 ) );
+	shaders.push_back( make_pair( "avatar/objectSkinV.glsl",				1 ) );
 
 	// We no longer have to bind the shaders to global glhandles, they are automatically added to a map now.
 	for (U32 i = 0; i < shaders.size(); i++)
@@ -1214,6 +1223,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		gObjectSimpleWaterProgram.unload();
 		gObjectFullbrightProgram.unload();
 		gObjectFullbrightWaterProgram.unload();
+		gSkinnedObjectSimpleProgram.unload();
 		return FALSE;
 	}
 
@@ -1323,6 +1333,21 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		success = gObjectFullbrightShinyProgram.createShader(NULL, &mShinyUniforms);
 	}
 
+	if (success)
+	{
+		gSkinnedObjectSimpleProgram.mName = "Skinned Simple Shader";
+		gSkinnedObjectSimpleProgram.mFeatures.calculatesLighting = true;
+		gSkinnedObjectSimpleProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectSimpleProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectSimpleProgram.mFeatures.hasAtmospherics = true;
+		gSkinnedObjectSimpleProgram.mFeatures.hasLighting = true;
+		gSkinnedObjectSimpleProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectSimpleProgram.mShaderFiles.clear();
+		gSkinnedObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectSimpleProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectSimpleProgram.createShader(NULL, NULL);
+	}
 
 	if( !success )
 	{
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index ac2b4624e02..83a650cdbc7 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -82,6 +82,7 @@ class LLViewerShaderMgr: public LLShaderMgr
 		MATERIAL_COLOR = 0,
 		SPECULAR_COLOR,
 		BINORMAL,
+		OBJECT_WEIGHT,
 		END_RESERVED_ATTRIBS
 	} eGLSLReservedAttribs;
 	
@@ -313,6 +314,8 @@ extern LLGLSLShader			gObjectFullbrightShinyProgram;
 extern LLGLSLShader			gObjectShinyProgram;
 extern LLGLSLShader			gObjectShinyWaterProgram;
 
+extern LLGLSLShader			gSkinnedObjectSimpleProgram;
+
 //environment shaders
 extern LLGLSLShader			gTerrainProgram;
 extern LLGLSLShader			gTerrainWaterProgram;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index c400e8510e6..535440692fd 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -64,6 +64,7 @@
 #include "llkeyframefallmotion.h"
 #include "llkeyframestandmotion.h"
 #include "llkeyframewalkmotion.h"
+#include "llmeshrepository.h"
 #include "llmutelist.h"
 #include "llmoveview.h"
 #include "llquantize.h"
@@ -79,6 +80,7 @@
 #include "llviewermenu.h"
 #include "llviewerobjectlist.h"
 #include "llviewerparcelmgr.h"
+#include "llviewershadermgr.h"
 #include "llviewerstats.h"
 #include "llvoavatarself.h"
 #include "llvovolume.h"
@@ -3644,6 +3646,113 @@ bool LLVOAvatar::shouldAlphaMask()
 
 }
 
+U32 LLVOAvatar::renderSkinnedAttachments()
+{
+	U32 num_indices = 0;
+	
+	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
+							LLVertexBuffer::MAP_NORMAL | 
+							LLVertexBuffer::MAP_TEXCOORD0 | 
+							LLVertexBuffer::MAP_WEIGHT4;
+
+	for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); 
+		 iter != 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)
+		{
+			const LLViewerObject* attached_object = (*attachment_iter);
+			if (attached_object && !attached_object->isHUDAttachment())
+			{
+				const LLDrawable* drawable = attached_object->mDrawable;
+				if (drawable)
+				{
+					for (S32 i = 0; i < drawable->getNumFaces(); ++i)
+					{
+						LLFace* face = drawable->getFace(i);
+						if (face->isState(LLFace::RIGGED))
+						{
+							LLVolume* volume = attached_object->getVolume();
+							const LLVolumeFace& vol_face = volume->getVolumeFace(i);
+
+							const LLMeshSkinInfo* skin = NULL;
+							LLVertexBuffer* buff = face->mVertexBuffer;
+
+							if (!buff || 
+								!buff->hasDataType(LLVertexBuffer::TYPE_WEIGHT4) ||
+								buff->getRequestedVerts() != vol_face.mVertices.size())
+							{
+								face->mVertexBuffer = NULL;
+								face->mLastVertexBuffer = NULL;
+								buff = NULL;
+
+								LLUUID mesh_id = volume->getParams().getSculptID();
+								if (mesh_id.notNull())
+								{
+									skin = gMeshRepo.getSkinInfo(mesh_id);
+									if (skin)
+									{
+										face->mVertexBuffer = new LLVertexBuffer(data_mask, 0);
+										face->mVertexBuffer->allocateBuffer(vol_face.mVertices.size(), vol_face.mIndices.size(), true);
+
+										face->setGeomIndex(0);
+										face->setIndicesIndex(0);
+										
+										U16 offset = 0;
+										
+										LLMatrix4 mat_vert = skin->mBindShapeMatrix;
+										LLMatrix3 mat_normal;
+
+										face->getGeometryVolume(*volume, i, mat_vert, mat_normal, offset, true);
+										buff = face->mVertexBuffer;
+									}
+								}
+							}								
+							
+							if (buff)
+							{
+								if (skin)
+								{
+									LLMatrix4 mat[64];
+
+									for (U32 i = 0; i < skin->mJointNames.size(); ++i)
+									{
+										LLJoint* joint = getJoint(skin->mJointNames[i]);
+										if (joint)
+										{
+											mat[i] = skin->mInvBindMatrix[i];
+											mat[i] *= joint->getWorldMatrix();
+										}
+									}
+									
+									gSkinnedObjectSimpleProgram.uniformMatrix4fv("matrixPalette", 
+										skin->mJointNames.size(),
+										FALSE,
+										(GLfloat*) mat[0].mMatrix);
+
+									buff->setBuffer(data_mask);
+
+									U16 start = face->getGeomStart();
+									U16 end = start + face->getGeomCount();
+									S32 offset = face->getIndicesStart();
+									U32 count = face->getIndicesCount();
+
+									buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+
+	return num_indices;
+}
+
 //-----------------------------------------------------------------------------
 // renderSkinned()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index d5485413f40..b0535a4a265 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -339,6 +339,7 @@ class LLVOAvatar :
 	U32 		renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
 	U32 		renderRigid();
 	U32 		renderSkinned(EAvatarRenderPass pass);
+	U32			renderSkinnedAttachments();
 	U32 		renderTransparent(BOOL first_pass);
 	void 		renderCollisionVolumes();
 	static void	deleteCachedImages(bool clearAll=true);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index bc83e11fd27..56fb42bb890 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3496,6 +3496,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 		drawablep->clearState(LLDrawable::HAS_ALPHA);
 
+		bool rigged = vobj->isAttachment() && 
+					vobj->isMesh() && 
+					gMeshRepo.getSkinInfo(vobj->getVolume()->getParams().getSculptID());
+
 		//for each face
 		for (S32 i = 0; i < drawablep->getNumFaces(); i++)
 		{
@@ -3503,6 +3507,22 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 			drawablep->updateFaceSize(i);
 			LLFace* facep = drawablep->getFace(i);
 
+			if (rigged) 
+			{
+				if (!facep->isState(LLFace::RIGGED))
+				{
+					facep->mVertexBuffer = NULL;
+					facep->mLastVertexBuffer = NULL;
+					facep->setState(LLFace::RIGGED);
+				}
+
+				continue;
+			}
+			else
+			{
+				facep->clearState(LLFace::RIGGED);
+			}
+
 			if (cur_total > max_total || facep->getIndicesCount() <= 0 || facep->getGeomCount() <= 0)
 			{
 				facep->mVertexBuffer = NULL;
-- 
GitLab


From 3f05cd7e7fdb7da83f27f798913a0b0b848a08a6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 6 Apr 2010 22:24:57 +0100
Subject: [PATCH 271/683] extra diffuse sample in ssreflection to decrease
 aliasing.

---
 .../shaders/class1/deferred/softenLightF.glsl            | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 503c7d0b838..3f4425a0b27 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -298,13 +298,18 @@ void main()
 		// of the diffuse map.  LOD would be better in that regard.
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
+		// ---------------------
+		//     ^   ^ ^ ^   ^
+		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
 		// get attributes from the 2D guess point
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
+				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
-- 
GitLab


From ecec1641ffe295c3bccbd0b4cb1bd2056b8a83e7 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Tue, 6 Apr 2010 16:41:41 -0500
Subject: [PATCH 272/683] fix model importer to create a single coalesced
 object.

---
 indra/newview/skins/default/xui/en/menu_viewer.xml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index c2e19501a68..dccffa67de4 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2874,6 +2874,16 @@
          shortcut="control|alt|shift|G">
             <menu_item_call.on_click
              function="Advanced.LeaveAdminStatus" />
+        </menu_item_call>
+		<menu_item_call
+           label="HACK Upload Model..."
+           layout="topleft"
+           name="Upload Model">
+          <menu_item_call.on_click
+             function="File.UploadModel"
+             parameter="" />
+          <menu_item_call.on_enable
+             function="File.EnableUploadModel" />
         </menu_item_call>
     </menu>
     <menu
-- 
GitLab


From de663d15df69aa6961f984f9f1c440f1fe2b3efb Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 6 Apr 2010 17:37:31 -0500
Subject: [PATCH 273/683] Cleanup from review.

---
 indra/llcommon/llsdserialize.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index c341b155399..fdeb93e27f2 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -2025,6 +2025,7 @@ std::string zip_llsd(LLSD& data)
 	{
 		delete [] output;
 		llwarns << "Failed to compress LLSD block." << llendl;
+		return std::string();
 	}
 
 	std::string::size_type size = source.size()-strm.avail_out;
@@ -2116,6 +2117,7 @@ bool unzip_llsd(LLSD& data, std::istream& is, S32 size)
 		if (!LLSDSerialize::deserialize(data, istr, cur_size))
 		{
 			llwarns << "Failed to unzip LLSD block" << llendl;
+			free(result);
 			return false;
 		}
 	}
-- 
GitLab


From 9454398cd93f1b9710ef027206180a605c374dbd Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 7 Apr 2010 09:45:20 +0100
Subject: [PATCH 274/683] tidy up ssreflections comments and structure a bit.

---
 .../shaders/class1/deferred/softenLightF.glsl      | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 3f4425a0b27..158eef9319e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -298,18 +298,20 @@ void main()
 		// of the diffuse map.  LOD would be better in that regard.
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
-		// ---------------------
-		//     ^   ^ ^ ^   ^
-		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
 		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
 		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
-		// get attributes from the 2D guess point
-		float refdepth = texture2DRect(depthMap, ref2d).a;
-		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
+		// Get attributes from the 2D guess point.
+		// We average two samples of diffuse (not of anything else) per
+		// pixel to try to reduce aliasing some more.
+		// ---------------------
+		//     ^   ^ ^ ^   ^
+		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
 		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
 				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
+		float refdepth = texture2DRect(depthMap, ref2d).a;
+		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
-- 
GitLab


From e07937ced233513bcae55b2365f9ba5a15108faa Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 7 Apr 2010 10:31:56 +0100
Subject: [PATCH 275/683] apply latest ssreflections tweaks to class2 and
 class3.

---
 .../shaders/class2/deferred/softenLightF.glsl       | 13 ++++++++++---
 .../shaders/class3/deferred/softenLightF.glsl       | 13 ++++++++++---
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 00a6a9dcb5e..dbccb7fb8bc 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -298,12 +298,19 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
-		// get attributes from the 2D guess point
+		// Get attributes from the 2D guess point.
+		// We average two samples of diffuse (not of anything else) per
+		// pixel to try to reduce aliasing some more.
+		// ---------------------
+		//     ^   ^ ^ ^   ^
+		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
+				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
 		float refshad = texture2DRect(lightMap, ref2d).r;
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
 		// figure out how appropriate our guess actually was
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index aaa74eb7df4..ef81ed13089 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -301,12 +301,19 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
-		// get attributes from the 2D guess point
+		// Get attributes from the 2D guess point.
+		// We average two samples of diffuse (not of anything else) per
+		// pixel to try to reduce aliasing some more.
+		// ---------------------
+		//     ^   ^ ^ ^   ^
+		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
+				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;
 		float refshad = texture2DRect(lightMap, ref2d).r;
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
 		// figure out how appropriate our guess actually was
-- 
GitLab


From 70aa3cf12405eb7c0deaedce4dd2ced81ca3e0c8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 7 Apr 2010 12:41:44 -0500
Subject: [PATCH 276/683] Shadow aliasing fix WIP

---
 indra/newview/app_settings/settings.xml       | 48 +++++++++++++++++++
 .../shaders/class2/deferred/sunLightF.glsl    | 32 +++++++++++--
 indra/newview/pipeline.cpp                    | 14 +++++-
 3 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index eef3725cd7d..b0c56aea7c8 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6537,6 +6537,54 @@
     <real>0.01</real>
   </map>
 
+  <key>RenderShadowBiasError</key>
+  <map>
+    <key>Comment</key>
+    <string>Error scale for shadow bias (based on altitude).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>0</real>
+  </map>
+  <key>RenderShadowOffsetError</key>
+  <map>
+    <key>Comment</key>
+    <string>Error scale for shadow offset (based on altitude).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>0</real>
+  </map>
+  
+  <key>RenderSpotShadowBias</key>
+  <map>
+    <key>Comment</key>
+    <string>Bias value for shadows (prevent shadow acne).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>-0.008</real>
+  </map>
+  <key>RenderSpotShadowOffset</key>
+  <map>
+    <key>Comment</key>
+    <string>Offset value for shadows (prevent shadow acne).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>0.01</real>
+  </map>
+
+  
+  
   <key>RenderShadowResolutionScale</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 04c9a4d19aa..4974bbef9e5 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -41,6 +41,9 @@ uniform vec2 proj_shadow_res;
 uniform float shadow_bias;
 uniform float shadow_offset;
 
+uniform float spot_shadow_bias;
+uniform float spot_shadow_offset;
+
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -72,6 +75,24 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 	//return shadow;
 }
 
+float pcfSpotShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
+{
+	stc.xyz /= stc.w;
+	stc.z += spot_shadow_bias*scl;
+	
+	float cs = shadow2DRect(shadowMap, stc.xyz).x;
+	float shadow = cs;
+
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, 1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, -1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, 1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, -1.5, 0.0)).x, cs);
+			
+	return shadow/5.0;
+	
+	//return shadow;
+}
+
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
 	stc.xyz /= stc.w;
@@ -114,7 +135,10 @@ void main()
 	float shadow = 1.0;
 	float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
 
-	vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+	vec3 shadow_pos = pos.xyz + displace*norm;
+	vec3 offset = vary_light.xyz * (1.0-dp_directional_light);
+	
+	vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0);
 	
 	if (spos.z > -shadow_clip.w)
 	{	
@@ -176,13 +200,15 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = 1.0;
 	
+	spos.xyz = shadow_pos*offset*spot_shadow_offset;
+	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x; 
+	gl_FragColor[2] = pcfSpotShadow(shadowMap4, lpos, 0.8).x; 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x; 
+	gl_FragColor[3] = pcfSpotShadow(shadowMap5, lpos, 0.8).x; 
 
 	//gl_FragColor.rgb = pos.xyz;
 	//gl_FragColor.b = shadow;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 3778cae201c..2aa0210a809 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -5922,8 +5922,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 }
 
+static LLFastTimer::DeclareTimer FTM_BIND_DEFERRED("Bind Deferred");
+
 void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRenderTarget* gi_source, LLRenderTarget* last_gi_post, U32 noise_map)
 {
+	LLFastTimer t(FTM_BIND_DEFERRED);
+
 	if (noise_map == 0xFFFFFFFF)
 	{
 		noise_map = mNoiseMap;
@@ -6261,10 +6265,16 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
 								matrix_nondiag, matrix_nondiag, matrix_diag};
 	shader.uniformMatrix3fv("ssao_effect_mat", 1, GL_FALSE, ssao_effect_mat);
 
+	F32 shadow_offset_error = 1.f + gSavedSettings.getF32("RenderShadowOffsetError") * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]);
+	F32 shadow_bias_error = 1.f + gSavedSettings.getF32("RenderShadowBiasError") * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]);
+
 	shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight());
 	shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f);
-	shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset"));
-	shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias"));
+	shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset")*shadow_offset_error);
+	shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias")*shadow_bias_error);
+	shader.uniform1f ("spot_shadow_offset", gSavedSettings.getF32("RenderSpotShadowOffset"));
+	shader.uniform1f("spot_shadow_bias", gSavedSettings.getF32("RenderSpotShadowBias"));	
+
 	shader.uniform1f("lum_scale", gSavedSettings.getF32("RenderLuminanceScale"));
 	shader.uniform1f("sun_lum_scale", gSavedSettings.getF32("RenderSunLuminanceScale"));
 	shader.uniform1f("sun_lum_offset", gSavedSettings.getF32("RenderSunLuminanceOffset"));
-- 
GitLab


From 07dc44e37ed88bf867a7cde6e1ecb56ceac61da2 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 7 Apr 2010 12:41:44 -0500
Subject: [PATCH 277/683] Shadow aliasing fix WIP

---
 indra/newview/app_settings/settings.xml       | 48 +++++++++++++++++++
 .../shaders/class2/deferred/sunLightF.glsl    | 32 +++++++++++--
 indra/newview/pipeline.cpp                    | 14 +++++-
 3 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ef1a7b670f2..c25fba8a1ce 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6469,6 +6469,54 @@
     <real>0.01</real>
   </map>
 
+  <key>RenderShadowBiasError</key>
+  <map>
+    <key>Comment</key>
+    <string>Error scale for shadow bias (based on altitude).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>0</real>
+  </map>
+  <key>RenderShadowOffsetError</key>
+  <map>
+    <key>Comment</key>
+    <string>Error scale for shadow offset (based on altitude).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>0</real>
+  </map>
+  
+  <key>RenderSpotShadowBias</key>
+  <map>
+    <key>Comment</key>
+    <string>Bias value for shadows (prevent shadow acne).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>-0.008</real>
+  </map>
+  <key>RenderSpotShadowOffset</key>
+  <map>
+    <key>Comment</key>
+    <string>Offset value for shadows (prevent shadow acne).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>0.01</real>
+  </map>
+
+  
+  
   <key>RenderShadowResolutionScale</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 04c9a4d19aa..4974bbef9e5 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -41,6 +41,9 @@ uniform vec2 proj_shadow_res;
 uniform float shadow_bias;
 uniform float shadow_offset;
 
+uniform float spot_shadow_bias;
+uniform float spot_shadow_offset;
+
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -72,6 +75,24 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 	//return shadow;
 }
 
+float pcfSpotShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
+{
+	stc.xyz /= stc.w;
+	stc.z += spot_shadow_bias*scl;
+	
+	float cs = shadow2DRect(shadowMap, stc.xyz).x;
+	float shadow = cs;
+
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, 1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, -1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, 1.5, 0.0)).x, cs);
+	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, -1.5, 0.0)).x, cs);
+			
+	return shadow/5.0;
+	
+	//return shadow;
+}
+
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
 	stc.xyz /= stc.w;
@@ -114,7 +135,10 @@ void main()
 	float shadow = 1.0;
 	float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
 
-	vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+	vec3 shadow_pos = pos.xyz + displace*norm;
+	vec3 offset = vary_light.xyz * (1.0-dp_directional_light);
+	
+	vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0);
 	
 	if (spos.z > -shadow_clip.w)
 	{	
@@ -176,13 +200,15 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = 1.0;
 	
+	spos.xyz = shadow_pos*offset*spot_shadow_offset;
+	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x; 
+	gl_FragColor[2] = pcfSpotShadow(shadowMap4, lpos, 0.8).x; 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x; 
+	gl_FragColor[3] = pcfSpotShadow(shadowMap5, lpos, 0.8).x; 
 
 	//gl_FragColor.rgb = pos.xyz;
 	//gl_FragColor.b = shadow;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index efb99061ab7..432b0c86b26 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -5839,8 +5839,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 }
 
+static LLFastTimer::DeclareTimer FTM_BIND_DEFERRED("Bind Deferred");
+
 void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRenderTarget* gi_source, LLRenderTarget* last_gi_post, U32 noise_map)
 {
+	LLFastTimer t(FTM_BIND_DEFERRED);
+
 	if (noise_map == 0xFFFFFFFF)
 	{
 		noise_map = mNoiseMap;
@@ -6178,10 +6182,16 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
 								matrix_nondiag, matrix_nondiag, matrix_diag};
 	shader.uniformMatrix3fv("ssao_effect_mat", 1, GL_FALSE, ssao_effect_mat);
 
+	F32 shadow_offset_error = 1.f + gSavedSettings.getF32("RenderShadowOffsetError") * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]);
+	F32 shadow_bias_error = 1.f + gSavedSettings.getF32("RenderShadowBiasError") * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]);
+
 	shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight());
 	shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f);
-	shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset"));
-	shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias"));
+	shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset")*shadow_offset_error);
+	shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias")*shadow_bias_error);
+	shader.uniform1f ("spot_shadow_offset", gSavedSettings.getF32("RenderSpotShadowOffset"));
+	shader.uniform1f("spot_shadow_bias", gSavedSettings.getF32("RenderSpotShadowBias"));	
+
 	shader.uniform1f("lum_scale", gSavedSettings.getF32("RenderLuminanceScale"));
 	shader.uniform1f("sun_lum_scale", gSavedSettings.getF32("RenderSunLuminanceScale"));
 	shader.uniform1f("sun_lum_offset", gSavedSettings.getF32("RenderSunLuminanceOffset"));
-- 
GitLab


From e24f360c5e2c2745673e25133e7171aa71298eb0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 7 Apr 2010 13:52:52 -0500
Subject: [PATCH 278/683] Whitespace trimming.

---
 indra/newview/app_settings/settings.xml | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 8a3018340ed..b9647d01487 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6538,8 +6538,6 @@
     <real>0.01</real>
   </map>
 
-  
-  
   <key>RenderShadowResolutionScale</key>
   <map>
     <key>Comment</key>
@@ -6552,8 +6550,6 @@
     <real>1.0</real>
   </map>
 
-
-
   <key>RenderDeferredTreeShadowBias</key>
   <map>
     <key>Comment</key>
-- 
GitLab


From 4b86b20cd442db3fb684717223a12d5f27d29f69 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 7 Apr 2010 13:52:52 -0500
Subject: [PATCH 279/683] Whitespace trimming.

---
 indra/newview/app_settings/settings.xml | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c25fba8a1ce..1ff0ed4d87c 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6515,8 +6515,6 @@
     <real>0.01</real>
   </map>
 
-  
-  
   <key>RenderShadowResolutionScale</key>
   <map>
     <key>Comment</key>
@@ -6529,8 +6527,6 @@
     <real>1.0</real>
   </map>
 
-
-
   <key>RenderDeferredTreeShadowBias</key>
   <map>
     <key>Comment</key>
-- 
GitLab


From 711bcaf2ad43bc287b0af97c9e016b3d9a2abd77 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 7 Apr 2010 15:26:43 -0500
Subject: [PATCH 280/683] Fix for build failing.

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

diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 659ce4a47b9..99dfc07cd55 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -276,8 +276,12 @@ def construct(self):
             self.disable_manifest_check()
 
             # Mesh 3rd party libs needed for auto LOD and collada reading
-            self.path("libcollada14dom21.dll")
-            self.path("glod.dll")
+            try:
+                self.path("libcollada14dom21.dll")
+                self.path("glod.dll")
+            except RuntimeError, err:
+                print err.message
+                print "Skipping COLLADA and GLOD libraries (assumming linked statically)"
 
             # For textures
             if self.args['configuration'].lower() == 'debug':
-- 
GitLab


From f5c9196b365eee1032ead18a36320384deffc81a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 8 Apr 2010 12:42:10 -0500
Subject: [PATCH 281/683] Fix for shadows going crazy at high altitudes.

---
 indra/newview/pipeline.cpp | 76 +++++++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 29 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2aa0210a809..e3463574a75 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -193,6 +193,7 @@ std::string gPoolNames[] =
 };
 
 void drawBox(const LLVector3& c, const LLVector3& r);
+void drawBoxOutline(const LLVector3& pos, const LLVector3& size);
 
 U32 nhpo2(U32 v) 
 {
@@ -1531,8 +1532,10 @@ BOOL LLPipeline::visibleObjectsInFrustum(LLCamera& camera)
 
 BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& max)
 {
-	min = LLVector3(F32_MAX, F32_MAX, F32_MAX);
-	max = LLVector3(-F32_MAX, -F32_MAX, -F32_MAX);
+	const F32 X = 65536.f;
+
+	min = LLVector3(X,X,X);
+	max = LLVector3(-X,-X,-X);
 
 	U32 saved_camera_id = LLViewerCamera::sCurCameraID;
 	LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
@@ -3667,12 +3670,12 @@ void LLPipeline::renderDebug()
 
 		for (U32 i = 0; i < 8; i++)
 		{
+			LLVector3* frust = mShadowCamera[i].mAgentFrustum;
+
 			if (i > 3)
-			{
+			{ //render shadow frusta as volumes
 				gGL.color4fv(col+(i-4)*4);	
 			
-				LLVector3* frust = mShadowCamera[i].mAgentFrustum;
-
 				gGL.begin(LLRender::TRIANGLE_STRIP);
 				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
 				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
@@ -3700,31 +3703,46 @@ void LLPipeline::renderDebug()
 	
 			if (i < 4)
 			{
-				gGL.begin(LLRender::LINES);
-				
+
+				//render visible point cloud
+				gGL.flush();
+				glPointSize(8.f);
+				gGL.begin(LLRender::POINTS);
+
 				F32* c = col+i*4;
+				gGL.color3fv(c);
+
 				for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
-				{
+				{	
+					gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
 					
-					gGL.color3fv(c);
+				}
+				gGL.end();
 
-					for (U32 k = 0; k < mShadowFrustPoints[i].size(); ++k)
-					{
-						if (j != k)
-						{
-							gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
-							gGL.vertex3fv(mShadowFrustPoints[i][k].mV);
-						}
-					}
+				gGL.flush();
+				glPointSize(1.f);
 
-					if (!mShadowFrustOrigin[i].isExactlyZero())
-					{
-						gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
-						gGL.color4f(1,1,1,1);
-						gGL.vertex3fv(mShadowFrustOrigin[i].mV);
-					}
-				}
+				LLVector3* ext = mShadowExtents[i]; 
+				LLVector3 pos = (ext[0]+ext[1])*0.5f;
+				LLVector3 size = (ext[1]-ext[0])*0.5f;
+				drawBoxOutline(pos, size);
+
+				//render camera frustum splits as outlines
+				gGL.begin(LLRender::LINES);
+				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[1].mV);
+				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[2].mV);
+				gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[3].mV);
+				gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[0].mV);
+				gGL.vertex3fv(frust[4].mV); gGL.vertex3fv(frust[5].mV);
+				gGL.vertex3fv(frust[5].mV); gGL.vertex3fv(frust[6].mV);
+				gGL.vertex3fv(frust[6].mV); gGL.vertex3fv(frust[7].mV);
+				gGL.vertex3fv(frust[7].mV); gGL.vertex3fv(frust[4].mV);
+				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
+				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
+				gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV);
+				gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV);
 				gGL.end();
+
 			}
 
 			/*for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
@@ -7721,14 +7739,14 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 				//get point of intersection of 3 planes "p"
 				LLVector3 p = (-d1*(n2%n3)-d2*(n3%n1)-d3*(n1%n2))/(n1*(n2%n3));
 				
-				if (llround(p*n1+d1, 0.0001f) == 0.f &&
-					llround(p*n2+d2, 0.0001f) == 0.f &&
-					llround(p*n3+d3, 0.0001f) == 0.f)
+				if (llround(p*n1+d1, 0.1f) == 0.f &&
+					llround(p*n2+d2, 0.1f) == 0.f &&
+					llround(p*n3+d3, 0.1f) == 0.f)
 				{ //point is on all three planes
 					BOOL found = TRUE;
 					for (U32 l = 0; l < ps.size() && found; ++l)
 					{
-						if (llround(ps[l].dist(p), 0.0001f) > 0.0f)
+						if (llround(ps[l].dist(p), 0.1f) > 0.0f)
 						{ //point is above some plane, not contained
 							found = FALSE;	
 						}
@@ -8173,7 +8191,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		shadow_cam = camera;
 		shadow_cam.setFar(16.f);
 	
-		LLViewerCamera::updateFrustumPlanes(shadow_cam);
+		LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
 
 		LLVector3* frust = shadow_cam.mAgentFrustum;
 
-- 
GitLab


From 4cea9a726e1569a05201d1b4557f664d42501c60 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 8 Apr 2010 12:42:10 -0500
Subject: [PATCH 282/683] Fix for shadows going crazy at high altitudes.

---
 indra/newview/pipeline.cpp | 76 +++++++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 29 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 432b0c86b26..210aba893c6 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -191,6 +191,7 @@ std::string gPoolNames[] =
 };
 
 void drawBox(const LLVector3& c, const LLVector3& r);
+void drawBoxOutline(const LLVector3& pos, const LLVector3& size);
 
 U32 nhpo2(U32 v) 
 {
@@ -1521,8 +1522,10 @@ BOOL LLPipeline::visibleObjectsInFrustum(LLCamera& camera)
 
 BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& max)
 {
-	min = LLVector3(F32_MAX, F32_MAX, F32_MAX);
-	max = LLVector3(-F32_MAX, -F32_MAX, -F32_MAX);
+	const F32 X = 65536.f;
+
+	min = LLVector3(X,X,X);
+	max = LLVector3(-X,-X,-X);
 
 	U32 saved_camera_id = LLViewerCamera::sCurCameraID;
 	LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
@@ -3583,12 +3586,12 @@ void LLPipeline::renderDebug()
 
 		for (U32 i = 0; i < 8; i++)
 		{
+			LLVector3* frust = mShadowCamera[i].mAgentFrustum;
+
 			if (i > 3)
-			{
+			{ //render shadow frusta as volumes
 				gGL.color4fv(col+(i-4)*4);	
 			
-				LLVector3* frust = mShadowCamera[i].mAgentFrustum;
-
 				gGL.begin(LLRender::TRIANGLE_STRIP);
 				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
 				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
@@ -3616,31 +3619,46 @@ void LLPipeline::renderDebug()
 	
 			if (i < 4)
 			{
-				gGL.begin(LLRender::LINES);
-				
+
+				//render visible point cloud
+				gGL.flush();
+				glPointSize(8.f);
+				gGL.begin(LLRender::POINTS);
+
 				F32* c = col+i*4;
+				gGL.color3fv(c);
+
 				for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
-				{
+				{	
+					gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
 					
-					gGL.color3fv(c);
+				}
+				gGL.end();
 
-					for (U32 k = 0; k < mShadowFrustPoints[i].size(); ++k)
-					{
-						if (j != k)
-						{
-							gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
-							gGL.vertex3fv(mShadowFrustPoints[i][k].mV);
-						}
-					}
+				gGL.flush();
+				glPointSize(1.f);
 
-					if (!mShadowFrustOrigin[i].isExactlyZero())
-					{
-						gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
-						gGL.color4f(1,1,1,1);
-						gGL.vertex3fv(mShadowFrustOrigin[i].mV);
-					}
-				}
+				LLVector3* ext = mShadowExtents[i]; 
+				LLVector3 pos = (ext[0]+ext[1])*0.5f;
+				LLVector3 size = (ext[1]-ext[0])*0.5f;
+				drawBoxOutline(pos, size);
+
+				//render camera frustum splits as outlines
+				gGL.begin(LLRender::LINES);
+				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[1].mV);
+				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[2].mV);
+				gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[3].mV);
+				gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[0].mV);
+				gGL.vertex3fv(frust[4].mV); gGL.vertex3fv(frust[5].mV);
+				gGL.vertex3fv(frust[5].mV); gGL.vertex3fv(frust[6].mV);
+				gGL.vertex3fv(frust[6].mV); gGL.vertex3fv(frust[7].mV);
+				gGL.vertex3fv(frust[7].mV); gGL.vertex3fv(frust[4].mV);
+				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
+				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
+				gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV);
+				gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV);
 				gGL.end();
+
 			}
 
 			/*for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
@@ -7639,14 +7657,14 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 				//get point of intersection of 3 planes "p"
 				LLVector3 p = (-d1*(n2%n3)-d2*(n3%n1)-d3*(n1%n2))/(n1*(n2%n3));
 				
-				if (llround(p*n1+d1, 0.0001f) == 0.f &&
-					llround(p*n2+d2, 0.0001f) == 0.f &&
-					llround(p*n3+d3, 0.0001f) == 0.f)
+				if (llround(p*n1+d1, 0.1f) == 0.f &&
+					llround(p*n2+d2, 0.1f) == 0.f &&
+					llround(p*n3+d3, 0.1f) == 0.f)
 				{ //point is on all three planes
 					BOOL found = TRUE;
 					for (U32 l = 0; l < ps.size() && found; ++l)
 					{
-						if (llround(ps[l].dist(p), 0.0001f) > 0.0f)
+						if (llround(ps[l].dist(p), 0.1f) > 0.0f)
 						{ //point is above some plane, not contained
 							found = FALSE;	
 						}
@@ -8091,7 +8109,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		shadow_cam = camera;
 		shadow_cam.setFar(16.f);
 	
-		LLViewerCamera::updateFrustumPlanes(shadow_cam);
+		LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
 
 		LLVector3* frust = shadow_cam.mAgentFrustum;
 
-- 
GitLab


From 1df3e85d2d73820a3129ebeb1a3e4c88338e5a93 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 8 Apr 2010 20:42:55 -0500
Subject: [PATCH 283/683] Total fix for shadows going wonky at altitude.

---
 indra/newview/llspatialpartition.cpp |  7 +-
 indra/newview/pipeline.cpp           | 95 +++++++++++++++++-----------
 2 files changed, 61 insertions(+), 41 deletions(-)

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 3742f70df52..77c38798d12 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1924,11 +1924,8 @@ class LLOctreeCullVisExtents: public LLOctreeCullShadow
 			return;
 		}
 		
-		if (mRes == 2)
-		{
-			//fully in, don't traverse further (won't effect extents
-		}
-		else if (mRes && group->isState(LLSpatialGroup::SKIP_FRUSTUM_CHECK))
+		if ((mRes && group->isState(LLSpatialGroup::SKIP_FRUSTUM_CHECK)) ||
+			mRes == 2)
 		{	//don't need to do frustum check
 			LLSpatialGroup::OctreeTraveler::traverse(n);
 		}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e3463574a75..fd1445b33e6 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3674,6 +3674,11 @@ void LLPipeline::renderDebug()
 
 			if (i > 3)
 			{ //render shadow frusta as volumes
+				if (mShadowFrustPoints[i-4].empty())
+				{
+					continue;
+				}
+
 				gGL.color4fv(col+(i-4)*4);	
 			
 				gGL.begin(LLRender::TRIANGLE_STRIP);
@@ -3704,44 +3709,47 @@ void LLPipeline::renderDebug()
 			if (i < 4)
 			{
 
-				//render visible point cloud
-				gGL.flush();
-				glPointSize(8.f);
-				gGL.begin(LLRender::POINTS);
+				if (i == 0 || !mShadowFrustPoints[i].empty())
+				{
+					//render visible point cloud
+					gGL.flush();
+					glPointSize(8.f);
+					gGL.begin(LLRender::POINTS);
 
-				F32* c = col+i*4;
-				gGL.color3fv(c);
+					F32* c = col+i*4;
+					gGL.color3fv(c);
 
-				for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
-				{	
-					gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
-					
+					for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
+					{	
+						gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
+						
+					}
+					gGL.end();
+
+					gGL.flush();
+					glPointSize(1.f);
+
+					LLVector3* ext = mShadowExtents[i]; 
+					LLVector3 pos = (ext[0]+ext[1])*0.5f;
+					LLVector3 size = (ext[1]-ext[0])*0.5f;
+					drawBoxOutline(pos, size);
+
+					//render camera frustum splits as outlines
+					gGL.begin(LLRender::LINES);
+					gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[1].mV);
+					gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[2].mV);
+					gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[3].mV);
+					gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[0].mV);
+					gGL.vertex3fv(frust[4].mV); gGL.vertex3fv(frust[5].mV);
+					gGL.vertex3fv(frust[5].mV); gGL.vertex3fv(frust[6].mV);
+					gGL.vertex3fv(frust[6].mV); gGL.vertex3fv(frust[7].mV);
+					gGL.vertex3fv(frust[7].mV); gGL.vertex3fv(frust[4].mV);
+					gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
+					gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
+					gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV);
+					gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV);
+					gGL.end();
 				}
-				gGL.end();
-
-				gGL.flush();
-				glPointSize(1.f);
-
-				LLVector3* ext = mShadowExtents[i]; 
-				LLVector3 pos = (ext[0]+ext[1])*0.5f;
-				LLVector3 size = (ext[1]-ext[0])*0.5f;
-				drawBoxOutline(pos, size);
-
-				//render camera frustum splits as outlines
-				gGL.begin(LLRender::LINES);
-				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[1].mV);
-				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[2].mV);
-				gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[3].mV);
-				gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[0].mV);
-				gGL.vertex3fv(frust[4].mV); gGL.vertex3fv(frust[5].mV);
-				gGL.vertex3fv(frust[5].mV); gGL.vertex3fv(frust[6].mV);
-				gGL.vertex3fv(frust[6].mV); gGL.vertex3fv(frust[7].mV);
-				gGL.vertex3fv(frust[7].mV); gGL.vertex3fv(frust[4].mV);
-				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
-				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
-				gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV);
-				gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV);
-				gGL.end();
 
 			}
 
@@ -8107,16 +8115,31 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 	at.normVec();
 	
 	
+	LLCamera main_camera = camera;
+	
 	F32 near_clip = 0.f;
 	{
 		//get visible point cloud
 		std::vector<LLVector3> fp;
 
+		main_camera.calcAgentFrustumPlanes(main_camera.mAgentFrustum);
+		
 		LLVector3 min,max;
-		getVisiblePointCloud(camera,min,max,fp);
+		getVisiblePointCloud(main_camera,min,max,fp);
 
 		if (fp.empty())
 		{
+			if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA))
+			{
+				mShadowCamera[0] = main_camera;
+				mShadowExtents[0][0] = min;
+				mShadowExtents[0][1] = max;
+
+				mShadowFrustPoints[0].clear();
+				mShadowFrustPoints[1].clear();
+				mShadowFrustPoints[2].clear();
+				mShadowFrustPoints[3].clear();
+			}
 			mRenderTypeMask = type_mask;
 			return;
 		}
-- 
GitLab


From 53e791b299d51df3891a177b52dc5e1dc5dc5825 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 8 Apr 2010 20:42:55 -0500
Subject: [PATCH 284/683] Total fix for shadows going wonky at altitude.

---
 indra/newview/llspatialpartition.cpp |  7 +-
 indra/newview/pipeline.cpp           | 95 +++++++++++++++++-----------
 2 files changed, 61 insertions(+), 41 deletions(-)

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index cf1e3bf1862..c229657ded1 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1924,11 +1924,8 @@ class LLOctreeCullVisExtents: public LLOctreeCullShadow
 			return;
 		}
 		
-		if (mRes == 2)
-		{
-			//fully in, don't traverse further (won't effect extents
-		}
-		else if (mRes && group->isState(LLSpatialGroup::SKIP_FRUSTUM_CHECK))
+		if ((mRes && group->isState(LLSpatialGroup::SKIP_FRUSTUM_CHECK)) ||
+			mRes == 2)
 		{	//don't need to do frustum check
 			LLSpatialGroup::OctreeTraveler::traverse(n);
 		}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 210aba893c6..c56b3731386 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3590,6 +3590,11 @@ void LLPipeline::renderDebug()
 
 			if (i > 3)
 			{ //render shadow frusta as volumes
+				if (mShadowFrustPoints[i-4].empty())
+				{
+					continue;
+				}
+
 				gGL.color4fv(col+(i-4)*4);	
 			
 				gGL.begin(LLRender::TRIANGLE_STRIP);
@@ -3620,44 +3625,47 @@ void LLPipeline::renderDebug()
 			if (i < 4)
 			{
 
-				//render visible point cloud
-				gGL.flush();
-				glPointSize(8.f);
-				gGL.begin(LLRender::POINTS);
+				if (i == 0 || !mShadowFrustPoints[i].empty())
+				{
+					//render visible point cloud
+					gGL.flush();
+					glPointSize(8.f);
+					gGL.begin(LLRender::POINTS);
 
-				F32* c = col+i*4;
-				gGL.color3fv(c);
+					F32* c = col+i*4;
+					gGL.color3fv(c);
 
-				for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
-				{	
-					gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
-					
+					for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
+					{	
+						gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
+						
+					}
+					gGL.end();
+
+					gGL.flush();
+					glPointSize(1.f);
+
+					LLVector3* ext = mShadowExtents[i]; 
+					LLVector3 pos = (ext[0]+ext[1])*0.5f;
+					LLVector3 size = (ext[1]-ext[0])*0.5f;
+					drawBoxOutline(pos, size);
+
+					//render camera frustum splits as outlines
+					gGL.begin(LLRender::LINES);
+					gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[1].mV);
+					gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[2].mV);
+					gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[3].mV);
+					gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[0].mV);
+					gGL.vertex3fv(frust[4].mV); gGL.vertex3fv(frust[5].mV);
+					gGL.vertex3fv(frust[5].mV); gGL.vertex3fv(frust[6].mV);
+					gGL.vertex3fv(frust[6].mV); gGL.vertex3fv(frust[7].mV);
+					gGL.vertex3fv(frust[7].mV); gGL.vertex3fv(frust[4].mV);
+					gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
+					gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
+					gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV);
+					gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV);
+					gGL.end();
 				}
-				gGL.end();
-
-				gGL.flush();
-				glPointSize(1.f);
-
-				LLVector3* ext = mShadowExtents[i]; 
-				LLVector3 pos = (ext[0]+ext[1])*0.5f;
-				LLVector3 size = (ext[1]-ext[0])*0.5f;
-				drawBoxOutline(pos, size);
-
-				//render camera frustum splits as outlines
-				gGL.begin(LLRender::LINES);
-				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[1].mV);
-				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[2].mV);
-				gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[3].mV);
-				gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[0].mV);
-				gGL.vertex3fv(frust[4].mV); gGL.vertex3fv(frust[5].mV);
-				gGL.vertex3fv(frust[5].mV); gGL.vertex3fv(frust[6].mV);
-				gGL.vertex3fv(frust[6].mV); gGL.vertex3fv(frust[7].mV);
-				gGL.vertex3fv(frust[7].mV); gGL.vertex3fv(frust[4].mV);
-				gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
-				gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
-				gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV);
-				gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV);
-				gGL.end();
 
 			}
 
@@ -8025,16 +8033,31 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 	at.normVec();
 	
 	
+	LLCamera main_camera = camera;
+	
 	F32 near_clip = 0.f;
 	{
 		//get visible point cloud
 		std::vector<LLVector3> fp;
 
+		main_camera.calcAgentFrustumPlanes(main_camera.mAgentFrustum);
+		
 		LLVector3 min,max;
-		getVisiblePointCloud(camera,min,max,fp);
+		getVisiblePointCloud(main_camera,min,max,fp);
 
 		if (fp.empty())
 		{
+			if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA))
+			{
+				mShadowCamera[0] = main_camera;
+				mShadowExtents[0][0] = min;
+				mShadowExtents[0][1] = max;
+
+				mShadowFrustPoints[0].clear();
+				mShadowFrustPoints[1].clear();
+				mShadowFrustPoints[2].clear();
+				mShadowFrustPoints[3].clear();
+			}
 			mRenderTypeMask = type_mask;
 			return;
 		}
-- 
GitLab


From c566195ca82ddd9c5a3aef1c4b19e0094ef918c7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 9 Apr 2010 01:42:50 -0500
Subject: [PATCH 285/683] Tweak bias on projectors.  Fix some silly shader
 mistakes.

---
 indra/newview/app_settings/settings.xml       |  2 +-
 .../shaders/class2/deferred/sunLightF.glsl    | 29 ++++---------------
 .../class2/deferred/sunLightSSAOF.glsl        | 16 +++++++---
 indra/newview/lldrawpoolavatar.cpp            |  5 ++++
 4 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 1ff0ed4d87c..21801b503c6 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6501,7 +6501,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>-0.008</real>
+    <real>-0.0005</real>
   </map>
   <key>RenderSpotShadowOffset</key>
   <map>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 4974bbef9e5..46db3c990cf 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -75,28 +75,10 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 	//return shadow;
 }
 
-float pcfSpotShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
-{
-	stc.xyz /= stc.w;
-	stc.z += spot_shadow_bias*scl;
-	
-	float cs = shadow2DRect(shadowMap, stc.xyz).x;
-	float shadow = cs;
-
-	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, 1.5, 0.0)).x, cs);
-	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, -1.5, 0.0)).x, cs);
-	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, 1.5, 0.0)).x, cs);
-	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, -1.5, 0.0)).x, cs);
-			
-	return shadow/5.0;
-	
-	//return shadow;
-}
-
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
 	stc.xyz /= stc.w;
-	stc.z += shadow_bias*scl;
+	stc.z += spot_shadow_bias*scl;
 	
 	float cs = shadow2D(shadowMap, stc.xyz).x;
 	float shadow = cs;
@@ -107,8 +89,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x, cs);
 	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x, cs);
 	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(-off.x, -off.y, 0.0)).x, cs);
-	
-			
+				
 	return shadow/5.0;
 	
 	//return shadow;
@@ -200,15 +181,15 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = 1.0;
 	
-	spos.xyz = shadow_pos*offset*spot_shadow_offset;
+	spos.xyz = shadow_pos+offset*spot_shadow_offset;
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfSpotShadow(shadowMap4, lpos, 0.8).x; 
+	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8); 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfSpotShadow(shadowMap5, lpos, 0.8).x; 
+	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8); 
 
 	//gl_FragColor.rgb = pos.xyz;
 	//gl_FragColor.b = shadow;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index d77d17942a6..a0dfc96f14e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -40,6 +40,9 @@ uniform vec2 proj_shadow_res;
 uniform float shadow_bias;
 uniform float shadow_offset;
 
+uniform float spot_shadow_bias;
+uniform float spot_shadow_offset;
+
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -134,7 +137,7 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
 	stc.xyz /= stc.w;
-	stc.z += shadow_bias*scl;
+	stc.z += spot_shadow_bias*scl;
 	
 	float cs = shadow2D(shadowMap, stc.xyz).x;
 	float shadow = cs;
@@ -173,7 +176,10 @@ void main()
 	float shadow = 1.0;
 	float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
 
-	vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+	vec3 shadow_pos = pos.xyz + displace*norm;
+	vec3 offset = vary_light.xyz * (1.0-dp_directional_light);
+	
+	vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0);
 	
 	if (spos.z > -shadow_clip.w)
 	{	
@@ -235,13 +241,15 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
 	
+	spos.xyz = shadow_pos+offset*spot_shadow_offset;
+	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x; 
+	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8); 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x; 
+	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8); 
 
 	//gl_FragColor.rgb = pos.xyz;
 	//gl_FragColor.b = shadow;
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 012e41383fb..692f75b4a56 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -314,6 +314,11 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 		return;
 	}
 	
+	if (sShaderLevel > 0)
+	{
+		gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
+	}
+
 	avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
 
 }
-- 
GitLab


From b13af3b8baa05d20ae9f33046f100596182f6be0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 9 Apr 2010 01:42:50 -0500
Subject: [PATCH 286/683] Tweak bias on projectors.  Fix some silly shader
 mistakes.

---
 indra/newview/app_settings/settings.xml       |  2 +-
 .../shaders/class2/deferred/sunLightF.glsl    | 29 ++++---------------
 .../class2/deferred/sunLightSSAOF.glsl        | 16 +++++++---
 indra/newview/lldrawpoolavatar.cpp            |  5 ++++
 4 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index b9647d01487..fa8dccd659e 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6524,7 +6524,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>-0.008</real>
+    <real>-0.0005</real>
   </map>
   <key>RenderSpotShadowOffset</key>
   <map>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 4974bbef9e5..46db3c990cf 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -75,28 +75,10 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 	//return shadow;
 }
 
-float pcfSpotShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
-{
-	stc.xyz /= stc.w;
-	stc.z += spot_shadow_bias*scl;
-	
-	float cs = shadow2DRect(shadowMap, stc.xyz).x;
-	float shadow = cs;
-
-	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, 1.5, 0.0)).x, cs);
-	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, -1.5, 0.0)).x, cs);
-	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, 1.5, 0.0)).x, cs);
-	shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, -1.5, 0.0)).x, cs);
-			
-	return shadow/5.0;
-	
-	//return shadow;
-}
-
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
 	stc.xyz /= stc.w;
-	stc.z += shadow_bias*scl;
+	stc.z += spot_shadow_bias*scl;
 	
 	float cs = shadow2D(shadowMap, stc.xyz).x;
 	float shadow = cs;
@@ -107,8 +89,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x, cs);
 	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x, cs);
 	shadow += max(shadow2D(shadowMap, stc.xyz+vec3(-off.x, -off.y, 0.0)).x, cs);
-	
-			
+				
 	return shadow/5.0;
 	
 	//return shadow;
@@ -200,15 +181,15 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = 1.0;
 	
-	spos.xyz = shadow_pos*offset*spot_shadow_offset;
+	spos.xyz = shadow_pos+offset*spot_shadow_offset;
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfSpotShadow(shadowMap4, lpos, 0.8).x; 
+	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8); 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfSpotShadow(shadowMap5, lpos, 0.8).x; 
+	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8); 
 
 	//gl_FragColor.rgb = pos.xyz;
 	//gl_FragColor.b = shadow;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index d77d17942a6..a0dfc96f14e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -40,6 +40,9 @@ uniform vec2 proj_shadow_res;
 uniform float shadow_bias;
 uniform float shadow_offset;
 
+uniform float spot_shadow_bias;
+uniform float spot_shadow_offset;
+
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -134,7 +137,7 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
 	stc.xyz /= stc.w;
-	stc.z += shadow_bias*scl;
+	stc.z += spot_shadow_bias*scl;
 	
 	float cs = shadow2D(shadowMap, stc.xyz).x;
 	float shadow = cs;
@@ -173,7 +176,10 @@ void main()
 	float shadow = 1.0;
 	float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
 
-	vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+	vec3 shadow_pos = pos.xyz + displace*norm;
+	vec3 offset = vary_light.xyz * (1.0-dp_directional_light);
+	
+	vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0);
 	
 	if (spos.z > -shadow_clip.w)
 	{	
@@ -235,13 +241,15 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
 	
+	spos.xyz = shadow_pos+offset*spot_shadow_offset;
+	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x; 
+	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8); 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x; 
+	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8); 
 
 	//gl_FragColor.rgb = pos.xyz;
 	//gl_FragColor.b = shadow;
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 9311a5f60ec..23211d70904 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -314,6 +314,11 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 		return;
 	}
 	
+	if (sShaderLevel > 0)
+	{
+		gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
+	}
+
 	avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
 
 }
-- 
GitLab


From fb04904336b77b480f2ebd6bf9219f85c356d36f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 12 Apr 2010 11:11:23 -0500
Subject: [PATCH 287/683] Fix for avatars not rendering in non-deferred mode.

---
 indra/newview/lldrawpoolavatar.cpp |  5 ++++-
 indra/newview/llvoavatar.cpp       | 22 +++++++++++++++++-----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 9311a5f60ec..a07be305655 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -320,7 +320,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 
 S32 LLDrawPoolAvatar::getNumPasses()
 {
-	return LLPipeline::sImpostorRender ? 1 : 4;
+	return LLPipeline::sImpostorRender ? 1 : 3;
 }
 
 void LLDrawPoolAvatar::render(S32 pass)
@@ -357,6 +357,7 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 		break;
 	case 2:
 		beginSkinned();
+		break;
 	case 3:
 		beginRigged();
 		break;
@@ -574,12 +575,14 @@ void LLDrawPoolAvatar::endSkinned()
 
 void LLDrawPoolAvatar::beginRigged()
 {
+	sVertexProgram = NULL;
 	gSkinnedObjectSimpleProgram.bind();
 	LLVertexBuffer::sWeight4Loc = gSkinnedObjectSimpleProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
 void LLDrawPoolAvatar::endRigged()
 {
+	sVertexProgram = NULL;
 	gSkinnedObjectSimpleProgram.unbind();
 	LLVertexBuffer::sWeight4Loc = -1;
 }
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 6c2eb37971d..201c4ce1d52 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3645,7 +3645,8 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 	
 	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
 							LLVertexBuffer::MAP_NORMAL | 
-							LLVertexBuffer::MAP_TEXCOORD0 | 
+							LLVertexBuffer::MAP_TEXCOORD0 |
+							LLVertexBuffer::MAP_COLOR |
 							LLVertexBuffer::MAP_WEIGHT4;
 
 	for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); 
@@ -3669,10 +3670,16 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 						if (face->isState(LLFace::RIGGED))
 						{
 							LLVolume* volume = attached_object->getVolume();
+							if (!volume || volume->getNumVolumeFaces() <= i)
+							{
+								continue;
+							}
+
 							const LLVolumeFace& vol_face = volume->getVolumeFace(i);
 
 							const LLMeshSkinInfo* skin = NULL;
 							LLVertexBuffer* buff = face->mVertexBuffer;
+							LLUUID mesh_id = volume->getParams().getSculptID();;
 
 							if (!buff || 
 								!buff->hasDataType(LLVertexBuffer::TYPE_WEIGHT4) ||
@@ -3682,7 +3689,6 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 								face->mLastVertexBuffer = NULL;
 								buff = NULL;
 
-								LLUUID mesh_id = volume->getParams().getSculptID();
 								if (mesh_id.notNull())
 								{
 									skin = gMeshRepo.getSkinInfo(mesh_id);
@@ -3693,7 +3699,8 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 
 										face->setGeomIndex(0);
 										face->setIndicesIndex(0);
-										
+										face->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
+
 										U16 offset = 0;
 										
 										LLMatrix4 mat_vert = skin->mBindShapeMatrix;
@@ -3705,8 +3712,13 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 								}
 							}								
 							
-							if (buff)
+							if (buff && mesh_id.notNull())
 							{
+								if (!skin)
+								{
+									skin = gMeshRepo.getSkinInfo(mesh_id);
+								}
+
 								if (skin)
 								{
 									LLMatrix4 mat[64];
@@ -3729,7 +3741,7 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 									buff->setBuffer(data_mask);
 
 									U16 start = face->getGeomStart();
-									U16 end = start + face->getGeomCount();
+									U16 end = start + face->getGeomCount()-1;
 									S32 offset = face->getIndicesStart();
 									U32 count = face->getIndicesCount();
 
-- 
GitLab


From 6b72149cf7ad90c0036d9b037594b0a8e86dc483 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 12 Apr 2010 23:15:42 -0500
Subject: [PATCH 288/683] Tracking down ATI deferred bugs WIP

---
 .../app_settings/shaders/class1/deferred/avatarShadowF.glsl   | 4 ++--
 indra/newview/lldrawpoolavatar.cpp                            | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
index 00083eb6b39..085ffddeece 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
@@ -10,7 +10,7 @@ uniform sampler2D diffuseMap;
 
 void main() 
 {
-	gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a);
-	//gl_FragColor = vec4(1,1,1,1);
+	//gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a);
+	gl_FragColor = vec4(1,1,1,1);
 }
 
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 23211d70904..5a67e1753ab 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -254,7 +254,7 @@ S32 LLDrawPoolAvatar::getNumShadowPasses()
 void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-	
+	sSkipTransparent = TRUE;
 	sVertexProgram = &gDeferredAvatarShadowProgram;
 	if (sShaderLevel > 0)
 	{
@@ -276,7 +276,7 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 void LLDrawPoolAvatar::endShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-
+	sSkipTransparent = FALSE;
 	if (sShaderLevel > 0)
 	{
 		sRenderingSkinned = FALSE;
-- 
GitLab


From 11ab373c5d4ea5476330f0140f60bec0280d3e84 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 12 Apr 2010 23:15:42 -0500
Subject: [PATCH 289/683] Tracking down ATI deferred bugs WIP (transplanted
 from 76dacfb89b155fd1e6698d7affc81fb13ee4fb33)

---
 .../app_settings/shaders/class1/deferred/avatarShadowF.glsl   | 4 ++--
 indra/newview/lldrawpoolavatar.cpp                            | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
index 00083eb6b39..085ffddeece 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
@@ -10,7 +10,7 @@ uniform sampler2D diffuseMap;
 
 void main() 
 {
-	gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a);
-	//gl_FragColor = vec4(1,1,1,1);
+	//gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a);
+	gl_FragColor = vec4(1,1,1,1);
 }
 
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 692f75b4a56..c1a57305b95 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -254,7 +254,7 @@ S32 LLDrawPoolAvatar::getNumShadowPasses()
 void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-	
+	sSkipTransparent = TRUE;
 	sVertexProgram = &gDeferredAvatarShadowProgram;
 	if (sShaderLevel > 0)
 	{
@@ -276,7 +276,7 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 void LLDrawPoolAvatar::endShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-
+	sSkipTransparent = FALSE;
 	if (sShaderLevel > 0)
 	{
 		sRenderingSkinned = FALSE;
-- 
GitLab


From e0bfefbd63449c0fe5ef7964677948f012d51506 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Tue, 13 Apr 2010 17:31:56 -0700
Subject: [PATCH 290/683] Add SimulatorFeatures to the seed capabilities
 requested by the viewer.

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

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index c6fe78eb748..53ca32d1b0a 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -174,7 +174,7 @@ class BaseCapabilitiesComplete : public LLHTTPClient::Responder
 				mRegion->showReleaseNotes();
 			}
 		}
-		
+
 		if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
 		{
 			LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED );
@@ -1493,6 +1493,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("ProvisionVoiceAccountRequest");
 	capabilityNames.append("RemoteParcelRequest");
 	capabilityNames.append("RequestTextureDownload");
+	capabilityNames.append("SimulatorFeatures");
 	capabilityNames.append("SearchStatRequest");
 	capabilityNames.append("SearchStatTracking");
 	capabilityNames.append("SendPostcard");
-- 
GitLab


From 145ec3dfe366c913c0fde1c2ea41ad06041715b4 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Tue, 13 Apr 2010 17:31:56 -0700
Subject: [PATCH 291/683] Add SimulatorFeatures to the seed capabilities
 requested by the viewer. (transplanted from
 17d7f73d189a8f6cf55b55b8147c91646c786573)

---
 indra/newview/llviewerregion.cpp | 96 +++++++++++---------------------
 1 file changed, 33 insertions(+), 63 deletions(-)

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index a86efa215b1..2267db770c0 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2,25 +2,31 @@
  * @file llviewerregion.cpp
  * @brief Implementation of the LLViewerRegion class.
  *
- * $LicenseInfo:firstyear=2000&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2000&license=viewergpl$
+ * 
+ * Copyright (c) 2000-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -73,8 +79,6 @@
 // format changes. JC
 const U32 INDRA_OBJECT_CACHE_VERSION = 14;
 
-// Format string used to construct filename for the object cache
-static const char OBJECT_CACHE_FILENAME[] = "objects_%d_%d.slc";
 
 extern BOOL gNoRender;
 
@@ -170,7 +174,7 @@ class BaseCapabilitiesComplete : public LLHTTPClient::Responder
 				mRegion->showReleaseNotes();
 			}
 		}
-		
+
 		if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
 		{
 			LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED );
@@ -212,7 +216,6 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
 	mColoName("unknown"),
 	mProductSKU("unknown"),
 	mProductName("unknown"),
-	mHttpUrl(""),
 	mCacheLoaded(FALSE),
 	mCacheEntriesCount(0),
 	mCacheID(),
@@ -319,25 +322,13 @@ LLViewerRegion::~LLViewerRegion()
 	delete mEventPoll;
 	LLHTTPSender::clearSender(mHost);
 	
-	saveObjectCache();
+	saveCache();
 
 	std::for_each(mObjectPartition.begin(), mObjectPartition.end(), DeletePointer());
 }
 
 
-const std::string LLViewerRegion::getObjectCacheFilename(U64 mHandle) const
-{
-	std::string filename;
-	U32 region_x, region_y;
-
-	grid_from_region_handle(mHandle, &region_x, &region_y);
-	filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,
-			   llformat(OBJECT_CACHE_FILENAME, region_x, region_y));
-
-	return filename;
-}
-
-void LLViewerRegion::loadObjectCache()
+void LLViewerRegion::loadCache()
 {
 	if (mCacheLoaded)
 	{
@@ -349,8 +340,9 @@ void LLViewerRegion::loadObjectCache()
 
 	LLVOCacheEntry *entry;
 
-	std::string filename = getObjectCacheFilename(mHandle);
-	LL_DEBUGS("ObjectCache") << filename << LL_ENDL;
+	std::string filename;
+	filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"") + gDirUtilp->getDirDelimiter() +
+		llformat("objects_%d_%d.slc",U32(mHandle>>32)/REGION_WIDTH_UNITS, U32(mHandle)/REGION_WIDTH_UNITS );
 
 	LLFILE* fp = LLFile::fopen(filename, "rb");		/* Flawfinder: ignore */
 	if (!fp)
@@ -421,7 +413,7 @@ void LLViewerRegion::loadObjectCache()
 }
 
 
-void LLViewerRegion::saveObjectCache()
+void LLViewerRegion::saveCache()
 {
 	if (!mCacheLoaded)
 	{
@@ -434,8 +426,9 @@ void LLViewerRegion::saveObjectCache()
 		return;
 	}
 
-	std::string filename = getObjectCacheFilename(mHandle);
-	LL_DEBUGS("ObjectCache") << filename << LL_ENDL;
+	std::string filename;
+	filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"") + gDirUtilp->getDirDelimiter() +
+		llformat("sobjects_%d_%d.slc", U32(mHandle>>32)/REGION_WIDTH_UNITS, U32(mHandle)/REGION_WIDTH_UNITS );
 
 	LLFILE* fp = LLFile::fopen(filename, "wb");		/* Flawfinder: ignore */
 	if (!fp)
@@ -633,26 +626,6 @@ std::string LLViewerRegion::accessToString(U8 sim_access)
 	}
 }
 
-// static
-std::string LLViewerRegion::getAccessIcon(U8 sim_access)
-{
-	switch(sim_access)
-	{
-	case SIM_ACCESS_MATURE:
-		return "Parcel_M_Dark";
-
-	case SIM_ACCESS_ADULT:
-		return "Parcel_R_Light";
-
-	case SIM_ACCESS_PG:
-		return "Parcel_PG_Light";
-
-	case SIM_ACCESS_MIN:
-	default:
-		return "";
-	}
-}
-
 // static
 std::string LLViewerRegion::accessToShortString(U8 sim_access)
 {
@@ -1460,7 +1433,7 @@ void LLViewerRegion::unpackRegionHandshake()
 
 	// Now that we have the name, we can load the cache file
 	// off disk.
-	loadObjectCache();
+	loadCache();
 
 	// After loading cache, signal that simulator can start
 	// sending data.
@@ -1517,6 +1490,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("ProvisionVoiceAccountRequest");
 	capabilityNames.append("RemoteParcelRequest");
 	capabilityNames.append("RequestTextureDownload");
+	capabilityNames.append("SimulatorFeatures");
 	capabilityNames.append("SearchStatRequest");
 	capabilityNames.append("SearchStatTracking");
 	capabilityNames.append("SendPostcard");
@@ -1562,10 +1536,6 @@ void LLViewerRegion::setCapability(const std::string& name, const std::string& u
 	else
 	{
 		mCapabilities[name] = url;
-		if(name == "GetTexture")
-		{
-			mHttpUrl = url ;
-		}
 	}
 }
 
-- 
GitLab


From d3d180f5db0350d6a8b930227b17d5001e673295 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 14 Apr 2010 16:18:13 -0500
Subject: [PATCH 292/683] Hack to fix ATI depth shadows screwing up alpha
 masking.

---
 indra/newview/lldrawpoolavatar.cpp | 2 --
 indra/newview/pipeline.cpp         | 9 +++++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 588a77a6204..2cd9fef9f51 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -254,7 +254,6 @@ S32 LLDrawPoolAvatar::getNumShadowPasses()
 void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-	sSkipTransparent = TRUE;
 	sVertexProgram = &gDeferredAvatarShadowProgram;
 	if (sShaderLevel > 0)
 	{
@@ -276,7 +275,6 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 void LLDrawPoolAvatar::endShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-	sSkipTransparent = FALSE;
 	if (sShaderLevel > 0)
 	{
 		sRenderingSkinned = FALSE;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index bd210b33761..02dc013ca4e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -572,9 +572,12 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 
 		F32 scale = gSavedSettings.getF32("RenderShadowResolutionScale");
 
+		//HACK: make alpha masking work on ATI depth shadows (work around for ATI driver bug)
+		U32 shadow_fmt = gGLManager.mIsATI ? GL_ALPHA : 0;
+
 		for (U32 i = 0; i < 4; i++)
 		{
-			mShadow[i].allocate(U32(resX*scale),U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
+			mShadow[i].allocate(U32(resX*scale),U32(resY*scale), shadow_fmt, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
 		}
 
 
@@ -583,11 +586,9 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 
 		for (U32 i = 4; i < 6; i++)
 		{
-			mShadow[i].allocate(width, height, 0, TRUE, FALSE);
+			mShadow[i].allocate(width, height, shadow_fmt, TRUE, FALSE);
 		}
 
-
-
 		width = nhpo2(resX)/2;
 		height = nhpo2(resY)/2;
 		mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE);
-- 
GitLab


From 91d4289bd868a58a989539a43cfae69261a4fe47 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 14 Apr 2010 16:18:13 -0500
Subject: [PATCH 293/683] Hack to fix ATI depth shadows screwing up alpha
 masking. (transplanted from 730a62c9a717c9aeb730e01632f259601acc1ece)

---
 indra/newview/lldrawpoolavatar.cpp | 2 --
 indra/newview/pipeline.cpp         | 9 +++++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index c1a57305b95..ac02d62a9e6 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -254,7 +254,6 @@ S32 LLDrawPoolAvatar::getNumShadowPasses()
 void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-	sSkipTransparent = TRUE;
 	sVertexProgram = &gDeferredAvatarShadowProgram;
 	if (sShaderLevel > 0)
 	{
@@ -276,7 +275,6 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 void LLDrawPoolAvatar::endShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-	sSkipTransparent = FALSE;
 	if (sShaderLevel > 0)
 	{
 		sRenderingSkinned = FALSE;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 8508b20689e..a45f41a7dda 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -570,9 +570,12 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 
 		F32 scale = gSavedSettings.getF32("RenderShadowResolutionScale");
 
+		//HACK: make alpha masking work on ATI depth shadows (work around for ATI driver bug)
+		U32 shadow_fmt = gGLManager.mIsATI ? GL_ALPHA : 0;
+
 		for (U32 i = 0; i < 4; i++)
 		{
-			mShadow[i].allocate(U32(resX*scale),U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
+			mShadow[i].allocate(U32(resX*scale),U32(resY*scale), shadow_fmt, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
 		}
 
 
@@ -581,11 +584,9 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 
 		for (U32 i = 4; i < 6; i++)
 		{
-			mShadow[i].allocate(width, height, 0, TRUE, FALSE);
+			mShadow[i].allocate(width, height, shadow_fmt, TRUE, FALSE);
 		}
 
-
-
 		width = nhpo2(resX)/2;
 		height = nhpo2(resY)/2;
 		mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE);
-- 
GitLab


From 54dd30cc426e16aa99b4f7eea080bbeae0656843 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 15 Apr 2010 00:04:17 -0500
Subject: [PATCH 294/683] More rigged attachments work.

---
 indra/llrender/llshadermgr.cpp     | 33 +++++++++++++++++++-----------
 indra/llrender/llvertexbuffer.cpp  | 21 +++++++++++++++++++
 indra/newview/lldrawpoolavatar.cpp |  3 ++-
 indra/newview/llvoavatar.cpp       | 12 ++++++++---
 4 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 23b76351ebb..8fc7163b83f 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -322,10 +322,13 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns)
 GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type)
 {
 	GLenum error;
-	error = glGetError();
-	if (error != GL_NO_ERROR)
+	if (gDebugGL)
 	{
-		LL_WARNS("ShaderLoading") << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL;
+		error = glGetError();
+		if (error != GL_NO_ERROR)
+		{
+			LL_WARNS("ShaderLoading") << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL;
+		}
 	}
 	
 	LL_DEBUGS("ShaderLoading") << "Loading shader file: " << filename << " class " << shader_level << LL_ENDL;
@@ -380,10 +383,13 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 
 	//create shader object
 	GLhandleARB ret = glCreateShaderObjectARB(type);
-	error = glGetError();
-	if (error != GL_NO_ERROR)
+	if (gDebugGL)
 	{
-		LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << LL_ENDL;
+		error = glGetError();
+		if (error != GL_NO_ERROR)
+		{
+			LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << LL_ENDL;
+		}
 	}
 	else
 	{
@@ -415,13 +421,16 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		//check for errors
 		GLint success = GL_TRUE;
 		glGetObjectParameterivARB(ret, GL_OBJECT_COMPILE_STATUS_ARB, &success);
-		error = glGetError();
-		if (error != GL_NO_ERROR || success == GL_FALSE) 
+		if (gDebugGL)
 		{
-			//an error occured, print log
-			LL_WARNS("ShaderLoading") << "GLSL Compilation Error: (" << error << ") in " << filename << LL_ENDL;
-			dumpObjectLog(ret);
-			ret = 0;
+			error = glGetError();
+			if (error != GL_NO_ERROR || success == GL_FALSE) 
+			{
+				//an error occured, print log
+				LL_WARNS("ShaderLoading") << "GLSL Compilation Error: (" << error << ") in " << filename << LL_ENDL;
+				dumpObjectLog(ret);
+				ret = 0;
+			}
 		}
 	}
 	else
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index d5b00f27a7d..668e9e55f9d 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -212,6 +212,27 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
 			glClientActiveTextureARB(GL_TEXTURE0_ARB);
 		}
 	
+		if (sLastMask & MAP_WEIGHT4)
+		{
+			if (sWeight4Loc < 0)
+			{
+				llerrs << "Weighting disabled but vertex buffer still bound!" << llendl;
+			}
+
+			if (!(data_mask & MAP_WEIGHT4))
+			{ //disable 4-component skin weight			
+				glDisableVertexAttribArrayARB(sWeight4Loc);
+			}
+		}
+		else if (data_mask & MAP_WEIGHT4)
+		{
+			if (sWeight4Loc >= 0)
+			{ //enable 4-component skin weight
+				glEnableVertexAttribArrayARB(sWeight4Loc);
+			}
+		}
+				
+
 		sLastMask = data_mask;
 	}
 }
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index de9b71a9b8b..1a2558ac5f5 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -325,7 +325,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 
 S32 LLDrawPoolAvatar::getNumPasses()
 {
-	return LLPipeline::sImpostorRender ? 1 : 3;
+	return LLPipeline::sImpostorRender ? 1 : 4;
 }
 
 void LLDrawPoolAvatar::render(S32 pass)
@@ -588,6 +588,7 @@ void LLDrawPoolAvatar::beginRigged()
 void LLDrawPoolAvatar::endRigged()
 {
 	sVertexProgram = NULL;
+	LLVertexBuffer::unbind();
 	gSkinnedObjectSimpleProgram.unbind();
 	LLVertexBuffer::sWeight4Loc = -1;
 }
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 201c4ce1d52..8bf4c0ab963 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3728,8 +3728,8 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 										LLJoint* joint = getJoint(skin->mJointNames[i]);
 										if (joint)
 										{
-											mat[i] = skin->mInvBindMatrix[i];
-											mat[i] *= joint->getWorldMatrix();
+											mat[i*2+0] = skin->mInvBindMatrix[i];
+											mat[i*2+1] = joint->getWorldMatrix();
 										}
 									}
 									
@@ -3737,6 +3737,10 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 										skin->mJointNames.size(),
 										FALSE,
 										(GLfloat*) mat[0].mMatrix);
+									gSkinnedObjectSimpleProgram.uniformMatrix4fv("matrixPalette[0]", 
+										skin->mJointNames.size(),
+										FALSE,
+										(GLfloat*) mat[0].mMatrix);
 
 									buff->setBuffer(data_mask);
 
@@ -3745,7 +3749,9 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 									S32 offset = face->getIndicesStart();
 									U32 count = face->getIndicesCount();
 
-									buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);
+									glPointSize(8.f);
+									buff->drawRange(LLRender::POINTS, start, end, count, offset);
+									glPointSize(1.f);
 								}
 							}
 						}
-- 
GitLab


From b0554832e2cffac344590bf49897119e72d142cb Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 15 Apr 2010 00:06:53 -0500
Subject: [PATCH 295/683] Quick port of fix for avatar mesh rebuilding bug from
 viewer-hotfix.

---
 indra/newview/llvoavatarself.cpp | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index c15dbeb8c60..8b87254f819 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -697,15 +697,6 @@ BOOL LLVOAvatarSelf::setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL
 /*virtual*/ 
 void LLVOAvatarSelf::updateVisualParams()
 {
-	for (U32 type = 0; type < WT_COUNT; type++)
-	{
-		LLWearable *wearable = gAgentWearables.getTopWearable((EWearableType)type);
-		if (wearable)
-		{
-			wearable->writeToAvatar();
-		}
-	}
-
 	LLVOAvatar::updateVisualParams();
 }
 
@@ -716,7 +707,14 @@ void LLVOAvatarSelf::idleUpdateAppearanceAnimation()
 	gAgentWearables.animateAllWearableParams(calcMorphAmount(), FALSE);
 
 	// apply wearable visual params to avatar
-	updateVisualParams();
+	for (U32 type = 0; type < WT_COUNT; type++)
+	{
+		LLWearable *wearable = gAgentWearables.getTopWearable((EWearableType)type);
+		if (wearable)
+		{
+			wearable->writeToAvatar();
+		}
+	}
 
 	//allow avatar to process updates
 	LLVOAvatar::idleUpdateAppearanceAnimation();
-- 
GitLab


From 186224ab91e53c712537887f3d08293520338250 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 16 Apr 2010 12:19:30 +0100
Subject: [PATCH 296/683] strengthen the fakey blur in the fakey ssreflections.
 (transplanted from 940e02cbe4fa2f996d11500392e71f3a00e1cfed) (transplanted
 from 1ee9eaf155ed897a5a7b86369c1f5160455094f0)

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 158eef9319e..5fb86dd92d5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -299,7 +299,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
 		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index dbccb7fb8bc..1fd54b56071 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -298,7 +298,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
 		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index ef81ed13089..45d921d8618 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -301,7 +301,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
 		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
-- 
GitLab


From 14f3b77b9c4103f324d24625bd30dd106ab1817f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 16 Apr 2010 12:19:30 +0100
Subject: [PATCH 297/683] strengthen the fakey blur in the fakey ssreflections.
 (transplanted from 940e02cbe4fa2f996d11500392e71f3a00e1cfed)

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl      | 2 +-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 158eef9319e..5fb86dd92d5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -299,7 +299,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
 		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index dbccb7fb8bc..1fd54b56071 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -298,7 +298,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
 		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index ef81ed13089..45d921d8618 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -301,7 +301,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5);
+		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
 		ref2d += checkoffset;
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
-- 
GitLab


From 71b0a63c8df29d5d69b777306dcf6280fd98886a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 16 Apr 2010 13:00:01 -0500
Subject: [PATCH 298/683] Optimize LLViewerJointMesh::updateFaceData

---
 indra/llcommon/llstrider.h          |  2 +-
 indra/newview/lldrawpoolavatar.cpp  |  2 +-
 indra/newview/llviewerjointmesh.cpp | 88 ++++++++++++++++++++++-------
 3 files changed, 71 insertions(+), 21 deletions(-)

diff --git a/indra/llcommon/llstrider.h b/indra/llcommon/llstrider.h
index 369b06b48a9..44ea80a36b3 100644
--- a/indra/llcommon/llstrider.h
+++ b/indra/llcommon/llstrider.h
@@ -51,7 +51,7 @@ template <class Object> class LLStrider
 	void setStride (S32 skipBytes)	{ mSkip = (skipBytes ? skipBytes : sizeof(Object));}
 
 	void skip(const U32 index)     { mBytep += mSkip*index;}
-
+	U32 getSkip() const			   { return mSkip; }
 	Object* get()                  { return mObjectp; }
 	Object* operator->()           { return mObjectp; }
 	Object& operator *()           { return *mObjectp; }
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 7ab85ae3e4b..b509b363b73 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -123,7 +123,7 @@ void LLDrawPoolAvatar::prerender()
 	
 	if (sShaderLevel > 0)
 	{
-		sBufferUsage = GL_STATIC_DRAW_ARB;
+		sBufferUsage = GL_DYNAMIC_DRAW_ARB;
 	}
 	else
 	{
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 92029d10f69..90a5a29bb4a 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -661,6 +661,8 @@ void LLViewerJointMesh::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32
 //-----------------------------------------------------------------------------
 // updateFaceData()
 //-----------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_AVATAR_FACE("Avatar Face");
+
 void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind)
 {
 	mFace = face;
@@ -670,6 +672,8 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 		return;
 	}
 
+	LLFastTimer t(FTM_AVATAR_FACE);
+
 	LLStrider<LLVector3> verticesp;
 	LLStrider<LLVector3> normalsp;
 	LLStrider<LLVector2> tex_coordsp;
@@ -688,30 +692,76 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 			face->mVertexBuffer->getIndexStrider(indicesp);
 			stop_glerror();
 
-			for (U16 i = 0; i < mMesh->getNumVertices(); i++)
+			verticesp += mMesh->mFaceVertexOffset;
+			tex_coordsp += mMesh->mFaceVertexOffset;
+			normalsp += mMesh->mFaceVertexOffset;
+			vertex_weightsp += mMesh->mFaceVertexOffset;
+			clothing_weightsp += mMesh->mFaceVertexOffset;
+
+			U32* __restrict v = (U32*) verticesp.get();
+			const U32 vert_skip = verticesp.getSkip()/sizeof(U32);
+
+			U32* __restrict tc = (U32*) tex_coordsp.get();
+			const U32 tc_skip = tex_coordsp.getSkip()/sizeof(U32);
+
+			U32* __restrict n = (U32*) normalsp.get();
+			const U32 n_skip = normalsp.getSkip()/sizeof(U32);
+			
+			U32* __restrict vw = (U32*) vertex_weightsp.get();
+			const U32 vw_skip = vertex_weightsp.getSkip()/sizeof(U32);
+
+
+			U32* __restrict cw = (U32*) clothing_weightsp.get();
+			const U32 cw_skip = vertex_weightsp.getSkip()/sizeof(U32);
+
+			const U32* __restrict coords = (U32*) mMesh->getCoords();
+			const U32* __restrict tex_coords = (U32*) mMesh->getTexCoords();
+			const U32* __restrict normals = (U32*) mMesh->getNormals();
+			const U32* __restrict weights = (U32*) mMesh->getWeights();
+			const U32* __restrict cloth_weights = (U32*) mMesh->getClothingWeights();
+
+			const U32 num_verts = mMesh->getNumVertices();
+
+			U32 i = 0;
+			do
 			{
-				verticesp[mMesh->mFaceVertexOffset + i] = *(mMesh->getCoords() + i);
-				tex_coordsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getTexCoords() + i);
-				normalsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getNormals() + i);
-				vertex_weightsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getWeights() + i);
-				if (damp_wind)
-				{
-					clothing_weightsp[mMesh->mFaceVertexOffset + i] = LLVector4(0,0,0,0);
-				}
-				else
-				{
-					clothing_weightsp[mMesh->mFaceVertexOffset + i] = (*(mMesh->getClothingWeights() + i));
-				}
+				v[0] = *(coords++); 
+				v[1] = *(coords++); 
+				v[2] = *(coords++);
+				v += vert_skip;
+
+				tc[0] = *(tex_coords++); 
+				tc[1] = *(tex_coords++);
+				tc += tc_skip;
+
+				n[0] = *(normals++); 
+				n[1] = *(normals++);
+				n[2] = *(normals++);
+				n += n_skip;
+
+				vw[0] = *(weights++);
+				vw += vw_skip;
+
+				cw[0] = *(cloth_weights++);
+				cw[1] = *(cloth_weights++);
+				cw[2] = *(cloth_weights++);
+				cw[3] = *(cloth_weights++);
+				cw += cw_skip;
 			}
+			while (++i < num_verts);
+
+			const U32 idx_count = mMesh->getNumFaces()*3;
 
-			for (S32 i = 0; i < mMesh->getNumFaces(); i++)
+			U16* __restrict idx = indicesp.get();
+			S32* __restrict src_idx = (S32*) mMesh->getFaces();
+
+			i = 0;
+
+			do
 			{
-				for (U32 j = 0; j < 3; j++)
-				{
-					U32 k = i*3+j+mMesh->mFaceIndexOffset;
-					indicesp[k] = mMesh->getFaces()[i][j] + mMesh->mFaceVertexOffset;
-				}
+				*(idx++) = *(src_idx++);
 			}
+			while (++i < idx_count);
 		}
 	}
 }
-- 
GitLab


From 36d942b30c32aeffaf734bd084bd407e5efa4102 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 16 Apr 2010 13:00:01 -0500
Subject: [PATCH 299/683] Optimize LLViewerJointMesh::updateFaceData
 (transplanted from 365d7fdcd6a16d2b2cc4cbb0d721b4011487f33b)

---
 indra/llcommon/llstrider.h          |  38 +++++----
 indra/newview/lldrawpoolavatar.cpp  |   2 +-
 indra/newview/llviewerjointmesh.cpp | 124 ++++++++++++++++++++--------
 3 files changed, 113 insertions(+), 51 deletions(-)

diff --git a/indra/llcommon/llstrider.h b/indra/llcommon/llstrider.h
index 488b8d0f35a..44ea80a36b3 100644
--- a/indra/llcommon/llstrider.h
+++ b/indra/llcommon/llstrider.h
@@ -1,25 +1,31 @@
 /** 
  * @file llstrider.h
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -45,7 +51,7 @@ template <class Object> class LLStrider
 	void setStride (S32 skipBytes)	{ mSkip = (skipBytes ? skipBytes : sizeof(Object));}
 
 	void skip(const U32 index)     { mBytep += mSkip*index;}
-
+	U32 getSkip() const			   { return mSkip; }
 	Object* get()                  { return mObjectp; }
 	Object* operator->()           { return mObjectp; }
 	Object& operator *()           { return *mObjectp; }
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index ac02d62a9e6..03e66231d10 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -123,7 +123,7 @@ void LLDrawPoolAvatar::prerender()
 	
 	if (sShaderLevel > 0)
 	{
-		sBufferUsage = GL_STATIC_DRAW_ARB;
+		sBufferUsage = GL_DYNAMIC_DRAW_ARB;
 	}
 	else
 	{
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index d2c29adf27b..b125c79f61e 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -2,25 +2,31 @@
  * @file llviewerjointmesh.cpp
  * @brief Implementation of LLViewerJointMesh class
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -661,6 +667,8 @@ void LLViewerJointMesh::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32
 //-----------------------------------------------------------------------------
 // updateFaceData()
 //-----------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_AVATAR_FACE("Avatar Face");
+
 void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind)
 {
 	mFace = face;
@@ -670,6 +678,8 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 		return;
 	}
 
+	LLFastTimer t(FTM_AVATAR_FACE);
+
 	LLStrider<LLVector3> verticesp;
 	LLStrider<LLVector3> normalsp;
 	LLStrider<LLVector2> tex_coordsp;
@@ -688,30 +698,76 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 			face->mVertexBuffer->getIndexStrider(indicesp);
 			stop_glerror();
 
-			for (U16 i = 0; i < mMesh->getNumVertices(); i++)
+			verticesp += mMesh->mFaceVertexOffset;
+			tex_coordsp += mMesh->mFaceVertexOffset;
+			normalsp += mMesh->mFaceVertexOffset;
+			vertex_weightsp += mMesh->mFaceVertexOffset;
+			clothing_weightsp += mMesh->mFaceVertexOffset;
+
+			U32* __restrict v = (U32*) verticesp.get();
+			const U32 vert_skip = verticesp.getSkip()/sizeof(U32);
+
+			U32* __restrict tc = (U32*) tex_coordsp.get();
+			const U32 tc_skip = tex_coordsp.getSkip()/sizeof(U32);
+
+			U32* __restrict n = (U32*) normalsp.get();
+			const U32 n_skip = normalsp.getSkip()/sizeof(U32);
+			
+			U32* __restrict vw = (U32*) vertex_weightsp.get();
+			const U32 vw_skip = vertex_weightsp.getSkip()/sizeof(U32);
+
+
+			U32* __restrict cw = (U32*) clothing_weightsp.get();
+			const U32 cw_skip = vertex_weightsp.getSkip()/sizeof(U32);
+
+			const U32* __restrict coords = (U32*) mMesh->getCoords();
+			const U32* __restrict tex_coords = (U32*) mMesh->getTexCoords();
+			const U32* __restrict normals = (U32*) mMesh->getNormals();
+			const U32* __restrict weights = (U32*) mMesh->getWeights();
+			const U32* __restrict cloth_weights = (U32*) mMesh->getClothingWeights();
+
+			const U32 num_verts = mMesh->getNumVertices();
+
+			U32 i = 0;
+			do
 			{
-				verticesp[mMesh->mFaceVertexOffset + i] = *(mMesh->getCoords() + i);
-				tex_coordsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getTexCoords() + i);
-				normalsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getNormals() + i);
-				vertex_weightsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getWeights() + i);
-				if (damp_wind)
-				{
-					clothing_weightsp[mMesh->mFaceVertexOffset + i] = LLVector4(0,0,0,0);
-				}
-				else
-				{
-					clothing_weightsp[mMesh->mFaceVertexOffset + i] = (*(mMesh->getClothingWeights() + i));
-				}
+				v[0] = *(coords++); 
+				v[1] = *(coords++); 
+				v[2] = *(coords++);
+				v += vert_skip;
+
+				tc[0] = *(tex_coords++); 
+				tc[1] = *(tex_coords++);
+				tc += tc_skip;
+
+				n[0] = *(normals++); 
+				n[1] = *(normals++);
+				n[2] = *(normals++);
+				n += n_skip;
+
+				vw[0] = *(weights++);
+				vw += vw_skip;
+
+				cw[0] = *(cloth_weights++);
+				cw[1] = *(cloth_weights++);
+				cw[2] = *(cloth_weights++);
+				cw[3] = *(cloth_weights++);
+				cw += cw_skip;
 			}
+			while (++i < num_verts);
 
-			for (S32 i = 0; i < mMesh->getNumFaces(); i++)
+			const U32 idx_count = mMesh->getNumFaces()*3;
+
+			U16* __restrict idx = indicesp.get();
+			S32* __restrict src_idx = (S32*) mMesh->getFaces();
+
+			i = 0;
+
+			do
 			{
-				for (U32 j = 0; j < 3; j++)
-				{
-					U32 k = i*3+j+mMesh->mFaceIndexOffset;
-					indicesp[k] = mMesh->getFaces()[i][j] + mMesh->mFaceVertexOffset;
-				}
+				*(idx++) = *(src_idx++);
 			}
+			while (++i < idx_count);
 		}
 	}
 }
-- 
GitLab


From 12499cebcba81175ae5d92926f5ec89632f00926 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 16 Apr 2010 15:53:26 -0500
Subject: [PATCH 300/683] Fix for busted optimizations.

---
 indra/newview/lldrawpoolavatar.cpp  | 4 +---
 indra/newview/llviewerjointmesh.cpp | 6 +++++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index b509b363b73..b3942d559a9 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -881,9 +881,7 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const
 
 LLVertexBufferAvatar::LLVertexBufferAvatar()
 : LLVertexBuffer(sDataMask, 
-	LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) > 0 ?	
-	GL_DYNAMIC_DRAW_ARB : 
-	GL_STREAM_DRAW_ARB)
+	GL_STREAM_DRAW_ARB) //avatars are always stream draw due to morph targets
 {
 
 }
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 90a5a29bb4a..db2279d9257 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -752,14 +752,18 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 
 			const U32 idx_count = mMesh->getNumFaces()*3;
 
+			indicesp += mMesh->mFaceIndexOffset;
+
 			U16* __restrict idx = indicesp.get();
 			S32* __restrict src_idx = (S32*) mMesh->getFaces();
 
 			i = 0;
 
+			const S32 offset = (S32) mMesh->mFaceVertexOffset;
+
 			do
 			{
-				*(idx++) = *(src_idx++);
+				*(idx++) = *(src_idx++)+offset;
 			}
 			while (++i < idx_count);
 		}
-- 
GitLab


From a20546a5dd82d16410b2c8d88c3f38d0833b6d3e Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 16 Apr 2010 15:53:26 -0500
Subject: [PATCH 301/683] Fix for busted optimizations. (transplanted from
 6fae1a167f287f23a0cdc5dac8dfa2b74444efcf)

---
 indra/newview/lldrawpoolavatar.cpp  | 4 +---
 indra/newview/llviewerjointmesh.cpp | 6 +++++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 03e66231d10..c94b0c3fa76 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -853,9 +853,7 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const
 
 LLVertexBufferAvatar::LLVertexBufferAvatar()
 : LLVertexBuffer(sDataMask, 
-	LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) > 0 ?	
-	GL_DYNAMIC_DRAW_ARB : 
-	GL_STREAM_DRAW_ARB)
+	GL_STREAM_DRAW_ARB) //avatars are always stream draw due to morph targets
 {
 
 }
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index b125c79f61e..c65946a5747 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -758,14 +758,18 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 
 			const U32 idx_count = mMesh->getNumFaces()*3;
 
+			indicesp += mMesh->mFaceIndexOffset;
+
 			U16* __restrict idx = indicesp.get();
 			S32* __restrict src_idx = (S32*) mMesh->getFaces();
 
 			i = 0;
 
+			const S32 offset = (S32) mMesh->mFaceVertexOffset;
+
 			do
 			{
-				*(idx++) = *(src_idx++);
+				*(idx++) = *(src_idx++)+offset;
 			}
 			while (++i < idx_count);
 		}
-- 
GitLab


From 8b88b093b9b59ba530e5e716609390fd00015efa Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 19 Apr 2010 23:31:38 -0500
Subject: [PATCH 302/683] Fix for ridiculous bug that causes all sitting
 avatars to rebuild their geometry every frame.

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

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 390e950d758..03eee12707b 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -533,7 +533,7 @@ F32 LLDrawable::updateXform(BOOL undamped)
 		{
 			// snap to final position
 			dist_squared = 0.0f;
-			if (!isRoot())
+			if (getVOVolume() && !isRoot())
 			{ //child prim snapping to some position, needs a rebuild
 				gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE);
 			}
-- 
GitLab


From 1f4a4d62555836147ef5f5f94df725aa7fb49369 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 19 Apr 2010 23:31:38 -0500
Subject: [PATCH 303/683] Fix for ridiculous bug that causes all sitting
 avatars to rebuild their geometry every frame. (transplanted from
 dd9dfa0c1629b21268f91ae0e46a51ca9d29f861)

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

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 38eda5bd2e0..ed6a791e7fd 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -523,7 +523,7 @@ F32 LLDrawable::updateXform(BOOL undamped)
 		{
 			// snap to final position
 			dist_squared = 0.0f;
-			if (!isRoot())
+			if (getVOVolume() && !isRoot())
 			{ //child prim snapping to some position, needs a rebuild
 				gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE);
 			}
-- 
GitLab


From 1651dd9c5b98923716a80ea476ec47360748f343 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 19 Apr 2010 23:32:27 -0500
Subject: [PATCH 304/683] Remove foot shadows, renaming foot shadow pass to
 impostor pass.

---
 indra/newview/lldrawpoolavatar.cpp | 12 ++++--------
 indra/newview/lldrawpoolavatar.h   |  4 ++--
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index b3942d559a9..c4581b2c788 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -353,7 +353,7 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 	switch (pass)
 	{
 	case 0:
-		beginFootShadow();
+		beginImpostor();
 		break;
 	case 1:
 		beginRigid();
@@ -380,7 +380,7 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 	switch (pass)
 	{
 	case 0:
-		endFootShadow();
+		endImpostor();
 		break;
 	case 1:
 		endRigid();
@@ -394,7 +394,7 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 	}
 }
 
-void LLDrawPoolAvatar::beginFootShadow()
+void LLDrawPoolAvatar::beginImpostor()
 {
 	if (!LLPipeline::sReflectionRender)
 	{
@@ -406,7 +406,7 @@ void LLDrawPoolAvatar::beginFootShadow()
 	diffuse_channel = 0;
 }
 
-void LLDrawPoolAvatar::endFootShadow()
+void LLDrawPoolAvatar::endImpostor()
 {
 	gPipeline.enableLightsDynamic();
 }
@@ -718,10 +718,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 			}
 			avatarp->renderImpostor(LLColor4U(255,255,255,255), diffuse_channel);
 		}
-		else if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS) && !LLPipeline::sRenderDeferred)
-		{
-			avatarp->renderFootShadows();	
-		}
 		return;
 	}
 
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index c43aa9b1e30..45f694ccd99 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -88,12 +88,12 @@ class LLDrawPoolAvatar : public LLFacePool
 	/*virtual*/ void renderShadow(S32 pass);
 
 	void beginRigid();
-	void beginFootShadow();
+	void beginImpostor();
 	void beginSkinned();
 	void beginRigged();
 		
 	void endRigid();
-	void endFootShadow();
+	void endImpostor();
 	void endSkinned();
 	void endRigged();
 
-- 
GitLab


From f647020bb125eb88461ea5887c08d5bcc53e8464 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 19 Apr 2010 23:32:27 -0500
Subject: [PATCH 305/683] Remove foot shadows, renaming foot shadow pass to
 impostor pass. (transplanted from 9b6ce276fa8d72109208e84c65890b0d06dba5db)

---
 indra/newview/lldrawpoolavatar.cpp | 12 +++------
 indra/newview/lldrawpoolavatar.h   | 40 +++++++++++++++++-------------
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index c94b0c3fa76..c58fbbdcd09 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -353,7 +353,7 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 	switch (pass)
 	{
 	case 0:
-		beginFootShadow();
+		beginImpostor();
 		break;
 	case 1:
 		beginRigid();
@@ -377,7 +377,7 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 	switch (pass)
 	{
 	case 0:
-		endFootShadow();
+		endImpostor();
 		break;
 	case 1:
 		endRigid();
@@ -387,7 +387,7 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 	}
 }
 
-void LLDrawPoolAvatar::beginFootShadow()
+void LLDrawPoolAvatar::beginImpostor()
 {
 	if (!LLPipeline::sReflectionRender)
 	{
@@ -399,7 +399,7 @@ void LLDrawPoolAvatar::beginFootShadow()
 	diffuse_channel = 0;
 }
 
-void LLDrawPoolAvatar::endFootShadow()
+void LLDrawPoolAvatar::endImpostor()
 {
 	gPipeline.enableLightsDynamic();
 }
@@ -696,10 +696,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 			}
 			avatarp->renderImpostor(LLColor4U(255,255,255,255), diffuse_channel);
 		}
-		else if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS) && !LLPipeline::sRenderDeferred)
-		{
-			avatarp->renderFootShadows();	
-		}
 		return;
 	}
 
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index 171152b72da..d247260527d 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -2,25 +2,31 @@
  * @file lldrawpoolavatar.h
  * @brief LLDrawPoolAvatar class definition
  *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -82,11 +88,11 @@ class LLDrawPoolAvatar : public LLFacePool
 	/*virtual*/ void renderShadow(S32 pass);
 
 	void beginRigid();
-	void beginFootShadow();
+	void beginImpostor();
 	void beginSkinned();
 		
 	void endRigid();
-	void endFootShadow();
+	void endImpostor();
 	void endSkinned();
 
 	void beginDeferredImpostor();
-- 
GitLab


From e994b9dcee82b510dc881e2b14d053a27fe35472 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 19 Apr 2010 23:33:34 -0500
Subject: [PATCH 306/683] Remove foot shadows from llvoavatar and add terse
 update to LLViewerJointMesh::updateFaceData.

---
 indra/newview/llviewerjoint.cpp     |   4 +-
 indra/newview/llviewerjoint.h       |   2 +-
 indra/newview/llviewerjointmesh.cpp | 121 +++++++++------
 indra/newview/llviewerjointmesh.h   |   2 +-
 indra/newview/llvoavatar.cpp        | 231 ++++------------------------
 indra/newview/llvoavatar.h          |   5 +-
 6 files changed, 110 insertions(+), 255 deletions(-)

diff --git a/indra/newview/llviewerjoint.cpp b/indra/newview/llviewerjoint.cpp
index 95f05b5f5f9..8f2006b4319 100644
--- a/indra/newview/llviewerjoint.cpp
+++ b/indra/newview/llviewerjoint.cpp
@@ -440,13 +440,13 @@ void LLViewerJoint::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pix
 	}
 }
 
-void LLViewerJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind)
+void LLViewerJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
 {
 	for (child_list_t::iterator iter = mChildren.begin();
 		 iter != mChildren.end(); ++iter)
 	{
 		LLViewerJoint* joint = (LLViewerJoint*)(*iter);
-		joint->updateFaceData(face, pixel_area, damp_wind);
+		joint->updateFaceData(face, pixel_area, damp_wind, terse_update);
 	}
 }
 
diff --git a/indra/newview/llviewerjoint.h b/indra/newview/llviewerjoint.h
index 0d3092a0447..67bd7786c3d 100644
--- a/indra/newview/llviewerjoint.h
+++ b/indra/newview/llviewerjoint.h
@@ -126,7 +126,7 @@ class LLViewerJoint :
 	PickName getPickName() { return mPickName; }
 
 	virtual void updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area);
-	virtual void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE);
+	virtual void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE, bool terse_update = false);
 	virtual BOOL updateLOD(F32 pixel_area, BOOL activate);
 	virtual void updateJointGeometry();
 	virtual void dump();
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index db2279d9257..fb6cc8d7908 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -663,7 +663,7 @@ void LLViewerJointMesh::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32
 //-----------------------------------------------------------------------------
 static LLFastTimer::DeclareTimer FTM_AVATAR_FACE("Avatar Face");
 
-void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind)
+void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
 {
 	mFace = face;
 
@@ -698,22 +698,6 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 			vertex_weightsp += mMesh->mFaceVertexOffset;
 			clothing_weightsp += mMesh->mFaceVertexOffset;
 
-			U32* __restrict v = (U32*) verticesp.get();
-			const U32 vert_skip = verticesp.getSkip()/sizeof(U32);
-
-			U32* __restrict tc = (U32*) tex_coordsp.get();
-			const U32 tc_skip = tex_coordsp.getSkip()/sizeof(U32);
-
-			U32* __restrict n = (U32*) normalsp.get();
-			const U32 n_skip = normalsp.getSkip()/sizeof(U32);
-			
-			U32* __restrict vw = (U32*) vertex_weightsp.get();
-			const U32 vw_skip = vertex_weightsp.getSkip()/sizeof(U32);
-
-
-			U32* __restrict cw = (U32*) clothing_weightsp.get();
-			const U32 cw_skip = vertex_weightsp.getSkip()/sizeof(U32);
-
 			const U32* __restrict coords = (U32*) mMesh->getCoords();
 			const U32* __restrict tex_coords = (U32*) mMesh->getTexCoords();
 			const U32* __restrict normals = (U32*) mMesh->getNormals();
@@ -723,49 +707,84 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 			const U32 num_verts = mMesh->getNumVertices();
 
 			U32 i = 0;
-			do
+
+			const U32 skip = verticesp.getSkip()/sizeof(U32);
+
+			U32* __restrict v = (U32*) verticesp.get();
+			U32* __restrict n = (U32*) normalsp.get();
+			
+			if (terse_update)
 			{
-				v[0] = *(coords++); 
-				v[1] = *(coords++); 
-				v[2] = *(coords++);
-				v += vert_skip;
-
-				tc[0] = *(tex_coords++); 
-				tc[1] = *(tex_coords++);
-				tc += tc_skip;
-
-				n[0] = *(normals++); 
-				n[1] = *(normals++);
-				n[2] = *(normals++);
-				n += n_skip;
-
-				vw[0] = *(weights++);
-				vw += vw_skip;
-
-				cw[0] = *(cloth_weights++);
-				cw[1] = *(cloth_weights++);
-				cw[2] = *(cloth_weights++);
-				cw[3] = *(cloth_weights++);
-				cw += cw_skip;
+				for (S32 i = num_verts; i > 0; --i)
+				{
+					//morph target application only, only update positions and normals
+					v[0] = coords[0]; 
+					v[1] = coords[1]; 
+					v[2] = coords[2];		
+					coords += 3;
+					v += skip;
+				}
+
+				for (S32 i = num_verts; i > 0; --i)
+				{
+					n[0] = normals[0]; 
+					n[1] = normals[1];
+					n[2] = normals[2];
+					normals += 3;
+					n += skip;
+				}
 			}
-			while (++i < num_verts);
+			else
+				{
 
-			const U32 idx_count = mMesh->getNumFaces()*3;
+				U32* __restrict tc = (U32*) tex_coordsp.get();
+				U32* __restrict vw = (U32*) vertex_weightsp.get();
+				U32* __restrict cw = (U32*) clothing_weightsp.get();
+				
+				do
+				{
+					v[0] = *(coords++); 
+					v[1] = *(coords++); 
+					v[2] = *(coords++);
+					v += skip;
+
+					tc[0] = *(tex_coords++); 
+					tc[1] = *(tex_coords++);
+					tc += skip;
+
+					n[0] = *(normals++); 
+					n[1] = *(normals++);
+					n[2] = *(normals++);
+					n += skip;
+
+					vw[0] = *(weights++);
+					vw += skip;
+
+					cw[0] = *(cloth_weights++);
+					cw[1] = *(cloth_weights++);
+					cw[2] = *(cloth_weights++);
+					cw[3] = *(cloth_weights++);
+					cw += skip;
+				}
+				while (++i < num_verts);
 
-			indicesp += mMesh->mFaceIndexOffset;
+				const U32 idx_count = mMesh->getNumFaces()*3;
 
-			U16* __restrict idx = indicesp.get();
-			S32* __restrict src_idx = (S32*) mMesh->getFaces();
+				indicesp += mMesh->mFaceIndexOffset;
 
-			i = 0;
+				U16* __restrict idx = indicesp.get();
+				S32* __restrict src_idx = (S32*) mMesh->getFaces();
 
-			const S32 offset = (S32) mMesh->mFaceVertexOffset;
+				i = 0;
 
-			do
-			{
-				*(idx++) = *(src_idx++)+offset;
+				const S32 offset = (S32) mMesh->mFaceVertexOffset;
+
+				do
+				{
+					*(idx++) = *(src_idx++)+offset;
+				}
+				while (++i < idx_count);
 			}
-			while (++i < idx_count);
 		}
 	}
 }
diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h
index d62b0ada850..3b8d9c82b80 100644
--- a/indra/newview/llviewerjointmesh.h
+++ b/indra/newview/llviewerjointmesh.h
@@ -140,7 +140,7 @@ class LLViewerJointMesh : public LLViewerJoint
 	/*virtual*/ U32 drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy );
 
 	/*virtual*/ void updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area);
-	/*virtual*/ void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE);
+	/*virtual*/ void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE, bool terse_update = false);
 	/*virtual*/ BOOL updateLOD(F32 pixel_area, BOOL activate);
 	/*virtual*/ void updateJointGeometry();
 	/*virtual*/ void dump();
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 33ea0199b6e..e30a2111852 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -693,10 +693,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 		mBakedTextureDatas[i].mTextureIndex = LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)i);
 	}
 
-	mDirtyMesh = TRUE;	// Dirty geometry, need to regenerate.
+	mDirtyMesh = 2;	// Dirty geometry, need to regenerate.
 	mMeshTexturesDirty = FALSE;
-	mShadow0Facep = NULL;
-	mShadow1Facep = NULL;
 	mHeadp = NULL;
 
 	mIsBuilt = FALSE;
@@ -732,12 +730,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 
 	mRippleTimeLast = 0.f;
 
-	mShadowImagep = LLViewerTextureManager::getFetchedTextureFromFile("foot_shadow.j2c");
-	
-	// GL NOT ACTIVE HERE
-	//gGL.getTexUnit(0)->bind(mShadowImagep.get());
-	//mShadowImagep->setAddressMode(LLTexUnit::TAM_CLAMP);
-	
 	mInAir = FALSE;
 
 	mStepOnLand = TRUE;
@@ -1923,7 +1915,7 @@ void LLVOAvatar::updateMeshData()
 			}
 			if(num_vertices < 1)//skip empty meshes
 			{
-				break ;
+				continue ;
 			}
 			if(last_v_num > 0)//put the last inserted part into next vertex buffer.
 			{
@@ -1945,6 +1937,8 @@ void LLVOAvatar::updateMeshData()
 			// resize immediately
 			facep->setSize(num_vertices, num_indices);
 
+			bool terse_update = false;
+
 			if(facep->mVertexBuffer.isNull())
 			{
 				facep->mVertexBuffer = new LLVertexBufferAvatar();
@@ -1952,7 +1946,15 @@ void LLVOAvatar::updateMeshData()
 			}
 			else
 			{
-				facep->mVertexBuffer->resizeBuffer(num_vertices, num_indices) ;
+				if (facep->mVertexBuffer->getRequestedIndices() == num_indices &&
+					facep->mVertexBuffer->getRequestedVerts() == num_vertices)
+				{
+					terse_update = true;
+				}
+				else
+				{
+					facep->mVertexBuffer->resizeBuffer(num_vertices, num_indices) ;
+				}
 			}
 		
 			facep->setGeomIndex(0);
@@ -1967,7 +1969,7 @@ void LLVOAvatar::updateMeshData()
 
 			for(S32 k = j ; k < part_index ; k++)
 			{
-				mMeshLOD[k]->updateFaceData(facep, mAdjustedPixelArea, k == MESH_ID_HAIR);
+				mMeshLOD[k]->updateFaceData(facep, mAdjustedPixelArea, k == MESH_ID_HAIR, terse_update);
 			}
 
 			stop_glerror();
@@ -2320,12 +2322,6 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 	LLJoint::sNumUpdates = 0;
 	LLJoint::sNumTouches = 0;
 
-	// *NOTE: this is necessary for the floating name text above your head.
-	if (mDrawable.notNull())
-	{
-		gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_SHADOW, TRUE);
-	}
-
 	BOOL visible = isVisible() || mNeedsAnimUpdate;
 
 	// update attachments positions
@@ -3778,12 +3774,19 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 		return num_indices;
 	}
 
-	if (mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
+	LLFace* face = mDrawable->getFace(0);
+
+	bool needs_rebuild = !face || face->mVertexBuffer.isNull();
+
+	if (needs_rebuild || mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
-		updateMeshData();
-		mDirtyMesh = FALSE;
-		mNeedsSkin = TRUE;
-		mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
+		if (needs_rebuild || mDirtyMesh >= 2 || mVisibilityRank <= 4)
+		{
+			updateMeshData();
+			mDirtyMesh = 0;
+			mNeedsSkin = TRUE;
+			mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
+		}
 	}
 
 	if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0)
@@ -4031,54 +4034,6 @@ U32 LLVOAvatar::renderRigid()
 	return num_indices;
 }
 
-U32 LLVOAvatar::renderFootShadows()
-{
-	U32 num_indices = 0;
-
-	if (!mIsBuilt)
-	{
-		return 0;
-	}
-
-	if (isSelf() && (!gAgent.needsRenderAvatar() || !gAgent.needsRenderHead()))
-	{
-		return 0;
-	}
-	
-	if (!mIsBuilt)
-	{
-		return 0;
-	}
-	
-	// Don't render foot shadows if your lower body is completely invisible.
-	// (non-humanoid avatars rule!)
-	if (!isTextureVisible(TEX_LOWER_BAKED))
-	{
-		return 0;
-	}
-
-	// Update the shadow, tractor, and text label geometry.
-	if (mDrawable->isState(LLDrawable::REBUILD_SHADOW) && !isImpostor())
-	{
-		updateShadowFaces();
-		mDrawable->clearState(LLDrawable::REBUILD_SHADOW);
-	}
-
-	U32 foot_mask = LLVertexBuffer::MAP_VERTEX |
-					LLVertexBuffer::MAP_TEXCOORD0;
-
-	LLGLDepthTest test(GL_TRUE, GL_FALSE);
-	//render foot shadows
-	LLGLEnable blend(GL_BLEND);
-	gGL.getTexUnit(0)->bind(mShadowImagep, TRUE);
-	glColor4fv(mShadow0Facep->getRenderColor().mV);
-	mShadow0Facep->renderIndexed(foot_mask);
-	glColor4fv(mShadow1Facep->getRenderColor().mV);
-	mShadow1Facep->renderIndexed(foot_mask);
-	
-	return num_indices;
-}
-
 U32 LLVOAvatar::renderImpostor(LLColor4U color, S32 diffuse_channel)
 {
 	if (!mImpostor.isComplete())
@@ -4199,11 +4154,6 @@ void LLVOAvatar::updateTextures()
 	{
 		setDebugText(llformat("%4.0f:%4.0f", fsqrtf(mMinPixelArea),fsqrtf(mMaxPixelArea)));
 	}	
-	
-	if( render_avatar )
-	{
-		mShadowImagep->addTextureStats(mPixelArea);
-	}
 }
 
 
@@ -5347,7 +5297,7 @@ BOOL LLVOAvatar::updateJointLODs()
  		if (res)
 		{
 			sNumLODChangesThisFrame++;
-			dirtyMesh();
+			dirtyMesh(2);
 			return TRUE;
 		}
 	}
@@ -5371,18 +5321,9 @@ LLDrawable *LLVOAvatar::createDrawable(LLPipeline *pipeline)
 	mDrawable->addFace(poolp, NULL);
 	mDrawable->setRenderType(LLPipeline::RENDER_TYPE_AVATAR);
 	
-	LLFace *facep;
-
-	// Add faces for the foot shadows
-	facep = mDrawable->addFace((LLFacePool*) NULL, mShadowImagep);
-	mShadow0Facep = facep;
-
-	facep = mDrawable->addFace((LLFacePool*) NULL, mShadowImagep);
-	mShadow1Facep = facep;
-
 	mNumInitFaces = mDrawable->getNumFaces() ;
 
-	dirtyMesh();
+	dirtyMesh(2);
 	return mDrawable;
 }
 
@@ -5421,107 +5362,6 @@ BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable)
 	return TRUE;
 }
 
-//-----------------------------------------------------------------------------
-// updateShadowFaces()
-//-----------------------------------------------------------------------------
-void LLVOAvatar::updateShadowFaces()
-{
-	LLFace *face0p = mShadow0Facep;
-	LLFace *face1p = mShadow1Facep;
-
-	//
-	// render avatar shadows
-	//
-	if (mInAir || mUpdatePeriod >= IMPOSTOR_PERIOD)
-	{
-		face0p->setSize(0, 0);
-		face1p->setSize(0, 0);
-		return;
-	}
-
-	LLSprite sprite(mShadowImagep.notNull() ? mShadowImagep->getID() : LLUUID::null);
-	sprite.setFollow(FALSE);
-	const F32 cos_angle = gSky.getSunDirection().mV[2];
-	F32 cos_elev = sqrt(1 - cos_angle * cos_angle);
-	if (cos_angle < 0) cos_elev = -cos_elev;
-	sprite.setSize(0.4f + cos_elev * 0.8f, 0.3f);
-	LLVector3 sun_vec = gSky.mVOSkyp ? gSky.mVOSkyp->getToSun() : LLVector3(0.f, 0.f, 0.f);
-
-	if (mShadowImagep->hasGLTexture())
-	{
-		LLVector3 normal;
-		LLVector3d shadow_pos;
-		LLVector3 shadow_pos_agent;
-		F32 foot_height;
-
-		if (mFootLeftp)
-		{
-			LLVector3 joint_world_pos = mFootLeftp->getWorldPosition();
-			// this only does a ray straight down from the foot, as our client-side ray-tracing is very limited now
-			// but we make an explicit ray trace call in expectation of future improvements
-			resolveRayCollisionAgent(gAgent.getPosGlobalFromAgent(joint_world_pos), 
-									 gAgent.getPosGlobalFromAgent(gSky.getSunDirection() + joint_world_pos), shadow_pos, normal);
-			shadow_pos_agent = gAgent.getPosAgentFromGlobal(shadow_pos);
-			foot_height = joint_world_pos.mV[VZ] - shadow_pos_agent.mV[VZ];
-
-			// Pull sprite in direction of surface normal
-			shadow_pos_agent += normal * SHADOW_OFFSET_AMT;
-
-			// Render sprite
-			sprite.setNormal(normal);
-			if (isSelf() && gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
-			{
-				sprite.setColor(0.f, 0.f, 0.f, 0.f);
-			}
-			else
-			{
-				sprite.setColor(0.f, 0.f, 0.f, clamp_rescale(foot_height, MIN_SHADOW_HEIGHT, MAX_SHADOW_HEIGHT, 0.5f, 0.f));
-			}
-			sprite.setPosition(shadow_pos_agent);
-
-			LLVector3 foot_to_knee = mKneeLeftp->getWorldPosition() - joint_world_pos;
-			//foot_to_knee.normalize();
-			foot_to_knee -= projected_vec(foot_to_knee, sun_vec);
-			sprite.setYaw(azimuth(sun_vec - foot_to_knee));
-		
-			sprite.updateFace(*face0p);
-		}
-
-		if (mFootRightp)
-		{
-			LLVector3 joint_world_pos = mFootRightp->getWorldPosition();
-			// this only does a ray straight down from the foot, as our client-side ray-tracing is very limited now
-			// but we make an explicit ray trace call in expectation of future improvements
-			resolveRayCollisionAgent(gAgent.getPosGlobalFromAgent(joint_world_pos), 
-									 gAgent.getPosGlobalFromAgent(gSky.getSunDirection() + joint_world_pos), shadow_pos, normal);
-			shadow_pos_agent = gAgent.getPosAgentFromGlobal(shadow_pos);
-			foot_height = joint_world_pos.mV[VZ] - shadow_pos_agent.mV[VZ];
-
-			// Pull sprite in direction of surface normal
-			shadow_pos_agent += normal * SHADOW_OFFSET_AMT;
-
-			// Render sprite
-			sprite.setNormal(normal);
-			if (isSelf() && gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
-			{
-				sprite.setColor(0.f, 0.f, 0.f, 0.f);
-			}
-			else
-			{
-				sprite.setColor(0.f, 0.f, 0.f, clamp_rescale(foot_height, MIN_SHADOW_HEIGHT, MAX_SHADOW_HEIGHT, 0.5f, 0.f));
-			}
-			sprite.setPosition(shadow_pos_agent);
-
-			LLVector3 foot_to_knee = mKneeRightp->getWorldPosition() - joint_world_pos;
-			//foot_to_knee.normalize();
-			foot_to_knee -= projected_vec(foot_to_knee, sun_vec);
-			sprite.setYaw(azimuth(sun_vec - foot_to_knee));
-	
-			sprite.updateFace(*face1p);
-		}
-	}
-}
-
 //-----------------------------------------------------------------------------
 // updateSexDependentLayerSets()
 //-----------------------------------------------------------------------------
@@ -5535,9 +5375,9 @@ void LLVOAvatar::updateSexDependentLayerSets( BOOL upload_bake )
 //-----------------------------------------------------------------------------
 // dirtyMesh()
 //-----------------------------------------------------------------------------
-void LLVOAvatar::dirtyMesh()
+void LLVOAvatar::dirtyMesh(S32 priority)
 {
-	mDirtyMesh = TRUE;
+	mDirtyMesh = llmax(mDirtyMesh, priority);
 }
 
 //-----------------------------------------------------------------------------
@@ -7696,18 +7536,15 @@ BOOL LLVOAvatar::updateLOD()
 	BOOL res = updateJointLODs();
 
 	LLFace* facep = mDrawable->getFace(0);
-	if (facep->mVertexBuffer.isNull() ||
-		(LLVertexBuffer::sEnableVBOs &&
-		((facep->mVertexBuffer->getUsage() == GL_STATIC_DRAW ? TRUE : FALSE) !=
-		 (facep->getPool()->getVertexShaderLevel() > 0 ? TRUE : FALSE))))
+	if (facep->mVertexBuffer.isNull())
 	{
-		mDirtyMesh = TRUE;
+		dirtyMesh(2);
 	}
 
-	if (mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
+	if (mDirtyMesh >= 2 || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
 		updateMeshData();
-		mDirtyMesh = FALSE;
+		mDirtyMesh = 0;
 		mNeedsSkin = TRUE;
 		mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
 	}
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index d0ad2b727bf..19e2c23ddd9 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -336,7 +336,6 @@ class LLVOAvatar :
  **/
 
 public:
-	U32 		renderFootShadows();
 	U32 		renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
 	U32 		renderRigid();
 	U32 		renderSkinned(EAvatarRenderPass pass);
@@ -565,13 +564,13 @@ class LLVOAvatar :
 public:
 	void 			updateMeshTextures();
 	void 			updateSexDependentLayerSets(BOOL upload_bake);
-	void 			dirtyMesh(); // Dirty the avatar mesh
+	void 			dirtyMesh(S32 priority = 1); // Dirty the avatar mesh
 	void 			updateMeshData();
 protected:
 	void 			releaseMeshData();
 	virtual void restoreMeshData();
 private:
-	BOOL 			mDirtyMesh;
+	S32 			mDirtyMesh; // 0 -- not dirty, 1 -- morphed, 2 -- LOD
 	BOOL			mMeshTexturesDirty;
 
 	typedef std::multimap<std::string, LLPolyMesh*> polymesh_map_t;
-- 
GitLab


From e9da44aa093305de76417e62319119e7e478c726 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 19 Apr 2010 23:33:34 -0500
Subject: [PATCH 307/683] Remove foot shadows from llvoavatar and add terse
 update to LLViewerJointMesh::updateFaceData. (transplanted from
 14545d24820e032279c81cb386dd043eeee625f7)

---
 indra/newview/llviewerjoint.cpp     |  40 +++--
 indra/newview/llviewerjoint.h       |  38 +++--
 indra/newview/llviewerjointmesh.cpp | 121 +++++++++------
 indra/newview/llviewerjointmesh.h   |  38 +++--
 indra/newview/llvoavatar.cpp        | 231 ++++------------------------
 indra/newview/llvoavatar.h          |   5 +-
 6 files changed, 173 insertions(+), 300 deletions(-)

diff --git a/indra/newview/llviewerjoint.cpp b/indra/newview/llviewerjoint.cpp
index dada3ee3b99..8f2006b4319 100644
--- a/indra/newview/llviewerjoint.cpp
+++ b/indra/newview/llviewerjoint.cpp
@@ -2,25 +2,31 @@
  * @file llviewerjoint.cpp
  * @brief Implementation of LLViewerJoint class
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -434,13 +440,13 @@ void LLViewerJoint::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pix
 	}
 }
 
-void LLViewerJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind)
+void LLViewerJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
 {
 	for (child_list_t::iterator iter = mChildren.begin();
 		 iter != mChildren.end(); ++iter)
 	{
 		LLViewerJoint* joint = (LLViewerJoint*)(*iter);
-		joint->updateFaceData(face, pixel_area, damp_wind);
+		joint->updateFaceData(face, pixel_area, damp_wind, terse_update);
 	}
 }
 
diff --git a/indra/newview/llviewerjoint.h b/indra/newview/llviewerjoint.h
index 4a5ebf20818..67bd7786c3d 100644
--- a/indra/newview/llviewerjoint.h
+++ b/indra/newview/llviewerjoint.h
@@ -2,25 +2,31 @@
  * @file llviewerjoint.h
  * @brief Implementation of LLViewerJoint class
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -120,7 +126,7 @@ class LLViewerJoint :
 	PickName getPickName() { return mPickName; }
 
 	virtual void updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area);
-	virtual void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE);
+	virtual void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE, bool terse_update = false);
 	virtual BOOL updateLOD(F32 pixel_area, BOOL activate);
 	virtual void updateJointGeometry();
 	virtual void dump();
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index c65946a5747..6be7c442eff 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -669,7 +669,7 @@ void LLViewerJointMesh::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32
 //-----------------------------------------------------------------------------
 static LLFastTimer::DeclareTimer FTM_AVATAR_FACE("Avatar Face");
 
-void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind)
+void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
 {
 	mFace = face;
 
@@ -704,22 +704,6 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 			vertex_weightsp += mMesh->mFaceVertexOffset;
 			clothing_weightsp += mMesh->mFaceVertexOffset;
 
-			U32* __restrict v = (U32*) verticesp.get();
-			const U32 vert_skip = verticesp.getSkip()/sizeof(U32);
-
-			U32* __restrict tc = (U32*) tex_coordsp.get();
-			const U32 tc_skip = tex_coordsp.getSkip()/sizeof(U32);
-
-			U32* __restrict n = (U32*) normalsp.get();
-			const U32 n_skip = normalsp.getSkip()/sizeof(U32);
-			
-			U32* __restrict vw = (U32*) vertex_weightsp.get();
-			const U32 vw_skip = vertex_weightsp.getSkip()/sizeof(U32);
-
-
-			U32* __restrict cw = (U32*) clothing_weightsp.get();
-			const U32 cw_skip = vertex_weightsp.getSkip()/sizeof(U32);
-
 			const U32* __restrict coords = (U32*) mMesh->getCoords();
 			const U32* __restrict tex_coords = (U32*) mMesh->getTexCoords();
 			const U32* __restrict normals = (U32*) mMesh->getNormals();
@@ -729,49 +713,84 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 			const U32 num_verts = mMesh->getNumVertices();
 
 			U32 i = 0;
-			do
+
+			const U32 skip = verticesp.getSkip()/sizeof(U32);
+
+			U32* __restrict v = (U32*) verticesp.get();
+			U32* __restrict n = (U32*) normalsp.get();
+			
+			if (terse_update)
 			{
-				v[0] = *(coords++); 
-				v[1] = *(coords++); 
-				v[2] = *(coords++);
-				v += vert_skip;
-
-				tc[0] = *(tex_coords++); 
-				tc[1] = *(tex_coords++);
-				tc += tc_skip;
-
-				n[0] = *(normals++); 
-				n[1] = *(normals++);
-				n[2] = *(normals++);
-				n += n_skip;
-
-				vw[0] = *(weights++);
-				vw += vw_skip;
-
-				cw[0] = *(cloth_weights++);
-				cw[1] = *(cloth_weights++);
-				cw[2] = *(cloth_weights++);
-				cw[3] = *(cloth_weights++);
-				cw += cw_skip;
+				for (S32 i = num_verts; i > 0; --i)
+				{
+					//morph target application only, only update positions and normals
+					v[0] = coords[0]; 
+					v[1] = coords[1]; 
+					v[2] = coords[2];		
+					coords += 3;
+					v += skip;
+				}
+
+				for (S32 i = num_verts; i > 0; --i)
+				{
+					n[0] = normals[0]; 
+					n[1] = normals[1];
+					n[2] = normals[2];
+					normals += 3;
+					n += skip;
+				}
 			}
-			while (++i < num_verts);
+			else
+				{
 
-			const U32 idx_count = mMesh->getNumFaces()*3;
+				U32* __restrict tc = (U32*) tex_coordsp.get();
+				U32* __restrict vw = (U32*) vertex_weightsp.get();
+				U32* __restrict cw = (U32*) clothing_weightsp.get();
+				
+				do
+				{
+					v[0] = *(coords++); 
+					v[1] = *(coords++); 
+					v[2] = *(coords++);
+					v += skip;
+
+					tc[0] = *(tex_coords++); 
+					tc[1] = *(tex_coords++);
+					tc += skip;
+
+					n[0] = *(normals++); 
+					n[1] = *(normals++);
+					n[2] = *(normals++);
+					n += skip;
+
+					vw[0] = *(weights++);
+					vw += skip;
+
+					cw[0] = *(cloth_weights++);
+					cw[1] = *(cloth_weights++);
+					cw[2] = *(cloth_weights++);
+					cw[3] = *(cloth_weights++);
+					cw += skip;
+				}
+				while (++i < num_verts);
 
-			indicesp += mMesh->mFaceIndexOffset;
+				const U32 idx_count = mMesh->getNumFaces()*3;
 
-			U16* __restrict idx = indicesp.get();
-			S32* __restrict src_idx = (S32*) mMesh->getFaces();
+				indicesp += mMesh->mFaceIndexOffset;
 
-			i = 0;
+				U16* __restrict idx = indicesp.get();
+				S32* __restrict src_idx = (S32*) mMesh->getFaces();
 
-			const S32 offset = (S32) mMesh->mFaceVertexOffset;
+				i = 0;
 
-			do
-			{
-				*(idx++) = *(src_idx++)+offset;
+				const S32 offset = (S32) mMesh->mFaceVertexOffset;
+
+				do
+				{
+					*(idx++) = *(src_idx++)+offset;
+				}
+				while (++i < idx_count);
 			}
-			while (++i < idx_count);
 		}
 	}
 }
diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h
index 1320bd03f96..3b8d9c82b80 100644
--- a/indra/newview/llviewerjointmesh.h
+++ b/indra/newview/llviewerjointmesh.h
@@ -2,25 +2,31 @@
  * @file llviewerjointmesh.h
  * @brief Implementation of LLViewerJointMesh class
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -134,7 +140,7 @@ class LLViewerJointMesh : public LLViewerJoint
 	/*virtual*/ U32 drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy );
 
 	/*virtual*/ void updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area);
-	/*virtual*/ void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE);
+	/*virtual*/ void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE, bool terse_update = false);
 	/*virtual*/ BOOL updateLOD(F32 pixel_area, BOOL activate);
 	/*virtual*/ void updateJointGeometry();
 	/*virtual*/ void dump();
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 5100f4e59a1..f89139dcd8d 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -694,10 +694,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 		mBakedTextureDatas[i].mTextureIndex = LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)i);
 	}
 
-	mDirtyMesh = TRUE;	// Dirty geometry, need to regenerate.
+	mDirtyMesh = 2;	// Dirty geometry, need to regenerate.
 	mMeshTexturesDirty = FALSE;
-	mShadow0Facep = NULL;
-	mShadow1Facep = NULL;
 	mHeadp = NULL;
 
 	mIsBuilt = FALSE;
@@ -733,12 +731,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 
 	mRippleTimeLast = 0.f;
 
-	mShadowImagep = LLViewerTextureManager::getFetchedTextureFromFile("foot_shadow.j2c");
-	
-	// GL NOT ACTIVE HERE
-	//gGL.getTexUnit(0)->bind(mShadowImagep.get());
-	//mShadowImagep->setAddressMode(LLTexUnit::TAM_CLAMP);
-	
 	mInAir = FALSE;
 
 	mStepOnLand = TRUE;
@@ -1924,7 +1916,7 @@ void LLVOAvatar::updateMeshData()
 			}
 			if(num_vertices < 1)//skip empty meshes
 			{
-				break ;
+				continue ;
 			}
 			if(last_v_num > 0)//put the last inserted part into next vertex buffer.
 			{
@@ -1946,6 +1938,8 @@ void LLVOAvatar::updateMeshData()
 			// resize immediately
 			facep->setSize(num_vertices, num_indices);
 
+			bool terse_update = false;
+
 			if(facep->mVertexBuffer.isNull())
 			{
 				facep->mVertexBuffer = new LLVertexBufferAvatar();
@@ -1953,7 +1947,15 @@ void LLVOAvatar::updateMeshData()
 			}
 			else
 			{
-				facep->mVertexBuffer->resizeBuffer(num_vertices, num_indices) ;
+				if (facep->mVertexBuffer->getRequestedIndices() == num_indices &&
+					facep->mVertexBuffer->getRequestedVerts() == num_vertices)
+				{
+					terse_update = true;
+				}
+				else
+				{
+					facep->mVertexBuffer->resizeBuffer(num_vertices, num_indices) ;
+				}
 			}
 		
 			facep->setGeomIndex(0);
@@ -1968,7 +1970,7 @@ void LLVOAvatar::updateMeshData()
 
 			for(S32 k = j ; k < part_index ; k++)
 			{
-				mMeshLOD[k]->updateFaceData(facep, mAdjustedPixelArea, k == MESH_ID_HAIR);
+				mMeshLOD[k]->updateFaceData(facep, mAdjustedPixelArea, k == MESH_ID_HAIR, terse_update);
 			}
 
 			stop_glerror();
@@ -2321,12 +2323,6 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 	LLJoint::sNumUpdates = 0;
 	LLJoint::sNumTouches = 0;
 
-	// *NOTE: this is necessary for the floating name text above your head.
-	if (mDrawable.notNull())
-	{
-		gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_SHADOW, TRUE);
-	}
-
 	BOOL visible = isVisible() || mNeedsAnimUpdate;
 
 	// update attachments positions
@@ -3654,12 +3650,19 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 		return num_indices;
 	}
 
-	if (mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
+	LLFace* face = mDrawable->getFace(0);
+
+	bool needs_rebuild = !face || face->mVertexBuffer.isNull();
+
+	if (needs_rebuild || mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
-		updateMeshData();
-		mDirtyMesh = FALSE;
-		mNeedsSkin = TRUE;
-		mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
+		if (needs_rebuild || mDirtyMesh >= 2 || mVisibilityRank <= 4)
+		{
+			updateMeshData();
+			mDirtyMesh = 0;
+			mNeedsSkin = TRUE;
+			mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
+		}
 	}
 
 	if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0)
@@ -3907,54 +3910,6 @@ U32 LLVOAvatar::renderRigid()
 	return num_indices;
 }
 
-U32 LLVOAvatar::renderFootShadows()
-{
-	U32 num_indices = 0;
-
-	if (!mIsBuilt)
-	{
-		return 0;
-	}
-
-	if (isSelf() && (!gAgent.needsRenderAvatar() || !gAgent.needsRenderHead()))
-	{
-		return 0;
-	}
-	
-	if (!mIsBuilt)
-	{
-		return 0;
-	}
-	
-	// Don't render foot shadows if your lower body is completely invisible.
-	// (non-humanoid avatars rule!)
-	if (!isTextureVisible(TEX_LOWER_BAKED))
-	{
-		return 0;
-	}
-
-	// Update the shadow, tractor, and text label geometry.
-	if (mDrawable->isState(LLDrawable::REBUILD_SHADOW) && !isImpostor())
-	{
-		updateShadowFaces();
-		mDrawable->clearState(LLDrawable::REBUILD_SHADOW);
-	}
-
-	U32 foot_mask = LLVertexBuffer::MAP_VERTEX |
-					LLVertexBuffer::MAP_TEXCOORD0;
-
-	LLGLDepthTest test(GL_TRUE, GL_FALSE);
-	//render foot shadows
-	LLGLEnable blend(GL_BLEND);
-	gGL.getTexUnit(0)->bind(mShadowImagep, TRUE);
-	glColor4fv(mShadow0Facep->getRenderColor().mV);
-	mShadow0Facep->renderIndexed(foot_mask);
-	glColor4fv(mShadow1Facep->getRenderColor().mV);
-	mShadow1Facep->renderIndexed(foot_mask);
-	
-	return num_indices;
-}
-
 U32 LLVOAvatar::renderImpostor(LLColor4U color, S32 diffuse_channel)
 {
 	if (!mImpostor.isComplete())
@@ -4075,11 +4030,6 @@ void LLVOAvatar::updateTextures()
 	{
 		setDebugText(llformat("%4.0f:%4.0f", fsqrtf(mMinPixelArea),fsqrtf(mMaxPixelArea)));
 	}	
-	
-	if( render_avatar )
-	{
-		mShadowImagep->addTextureStats(mPixelArea);
-	}
 }
 
 
@@ -5223,7 +5173,7 @@ BOOL LLVOAvatar::updateJointLODs()
  		if (res)
 		{
 			sNumLODChangesThisFrame++;
-			dirtyMesh();
+			dirtyMesh(2);
 			return TRUE;
 		}
 	}
@@ -5247,18 +5197,9 @@ LLDrawable *LLVOAvatar::createDrawable(LLPipeline *pipeline)
 	mDrawable->addFace(poolp, NULL);
 	mDrawable->setRenderType(LLPipeline::RENDER_TYPE_AVATAR);
 	
-	LLFace *facep;
-
-	// Add faces for the foot shadows
-	facep = mDrawable->addFace((LLFacePool*) NULL, mShadowImagep);
-	mShadow0Facep = facep;
-
-	facep = mDrawable->addFace((LLFacePool*) NULL, mShadowImagep);
-	mShadow1Facep = facep;
-
 	mNumInitFaces = mDrawable->getNumFaces() ;
 
-	dirtyMesh();
+	dirtyMesh(2);
 	return mDrawable;
 }
 
@@ -5297,107 +5238,6 @@ BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable)
 	return TRUE;
 }
 
-//-----------------------------------------------------------------------------
-// updateShadowFaces()
-//-----------------------------------------------------------------------------
-void LLVOAvatar::updateShadowFaces()
-{
-	LLFace *face0p = mShadow0Facep;
-	LLFace *face1p = mShadow1Facep;
-
-	//
-	// render avatar shadows
-	//
-	if (mInAir || mUpdatePeriod >= IMPOSTOR_PERIOD)
-	{
-		face0p->setSize(0, 0);
-		face1p->setSize(0, 0);
-		return;
-	}
-
-	LLSprite sprite(mShadowImagep.notNull() ? mShadowImagep->getID() : LLUUID::null);
-	sprite.setFollow(FALSE);
-	const F32 cos_angle = gSky.getSunDirection().mV[2];
-	F32 cos_elev = sqrt(1 - cos_angle * cos_angle);
-	if (cos_angle < 0) cos_elev = -cos_elev;
-	sprite.setSize(0.4f + cos_elev * 0.8f, 0.3f);
-	LLVector3 sun_vec = gSky.mVOSkyp ? gSky.mVOSkyp->getToSun() : LLVector3(0.f, 0.f, 0.f);
-
-	if (mShadowImagep->hasGLTexture())
-	{
-		LLVector3 normal;
-		LLVector3d shadow_pos;
-		LLVector3 shadow_pos_agent;
-		F32 foot_height;
-
-		if (mFootLeftp)
-		{
-			LLVector3 joint_world_pos = mFootLeftp->getWorldPosition();
-			// this only does a ray straight down from the foot, as our client-side ray-tracing is very limited now
-			// but we make an explicit ray trace call in expectation of future improvements
-			resolveRayCollisionAgent(gAgent.getPosGlobalFromAgent(joint_world_pos), 
-									 gAgent.getPosGlobalFromAgent(gSky.getSunDirection() + joint_world_pos), shadow_pos, normal);
-			shadow_pos_agent = gAgent.getPosAgentFromGlobal(shadow_pos);
-			foot_height = joint_world_pos.mV[VZ] - shadow_pos_agent.mV[VZ];
-
-			// Pull sprite in direction of surface normal
-			shadow_pos_agent += normal * SHADOW_OFFSET_AMT;
-
-			// Render sprite
-			sprite.setNormal(normal);
-			if (isSelf() && gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
-			{
-				sprite.setColor(0.f, 0.f, 0.f, 0.f);
-			}
-			else
-			{
-				sprite.setColor(0.f, 0.f, 0.f, clamp_rescale(foot_height, MIN_SHADOW_HEIGHT, MAX_SHADOW_HEIGHT, 0.5f, 0.f));
-			}
-			sprite.setPosition(shadow_pos_agent);
-
-			LLVector3 foot_to_knee = mKneeLeftp->getWorldPosition() - joint_world_pos;
-			//foot_to_knee.normalize();
-			foot_to_knee -= projected_vec(foot_to_knee, sun_vec);
-			sprite.setYaw(azimuth(sun_vec - foot_to_knee));
-		
-			sprite.updateFace(*face0p);
-		}
-
-		if (mFootRightp)
-		{
-			LLVector3 joint_world_pos = mFootRightp->getWorldPosition();
-			// this only does a ray straight down from the foot, as our client-side ray-tracing is very limited now
-			// but we make an explicit ray trace call in expectation of future improvements
-			resolveRayCollisionAgent(gAgent.getPosGlobalFromAgent(joint_world_pos), 
-									 gAgent.getPosGlobalFromAgent(gSky.getSunDirection() + joint_world_pos), shadow_pos, normal);
-			shadow_pos_agent = gAgent.getPosAgentFromGlobal(shadow_pos);
-			foot_height = joint_world_pos.mV[VZ] - shadow_pos_agent.mV[VZ];
-
-			// Pull sprite in direction of surface normal
-			shadow_pos_agent += normal * SHADOW_OFFSET_AMT;
-
-			// Render sprite
-			sprite.setNormal(normal);
-			if (isSelf() && gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
-			{
-				sprite.setColor(0.f, 0.f, 0.f, 0.f);
-			}
-			else
-			{
-				sprite.setColor(0.f, 0.f, 0.f, clamp_rescale(foot_height, MIN_SHADOW_HEIGHT, MAX_SHADOW_HEIGHT, 0.5f, 0.f));
-			}
-			sprite.setPosition(shadow_pos_agent);
-
-			LLVector3 foot_to_knee = mKneeRightp->getWorldPosition() - joint_world_pos;
-			//foot_to_knee.normalize();
-			foot_to_knee -= projected_vec(foot_to_knee, sun_vec);
-			sprite.setYaw(azimuth(sun_vec - foot_to_knee));
-	
-			sprite.updateFace(*face1p);
-		}
-	}
-}
-
 //-----------------------------------------------------------------------------
 // updateSexDependentLayerSets()
 //-----------------------------------------------------------------------------
@@ -5411,9 +5251,9 @@ void LLVOAvatar::updateSexDependentLayerSets( BOOL upload_bake )
 //-----------------------------------------------------------------------------
 // dirtyMesh()
 //-----------------------------------------------------------------------------
-void LLVOAvatar::dirtyMesh()
+void LLVOAvatar::dirtyMesh(S32 priority)
 {
-	mDirtyMesh = TRUE;
+	mDirtyMesh = llmax(mDirtyMesh, priority);
 }
 
 //-----------------------------------------------------------------------------
@@ -7584,18 +7424,15 @@ BOOL LLVOAvatar::updateLOD()
 	BOOL res = updateJointLODs();
 
 	LLFace* facep = mDrawable->getFace(0);
-	if (facep->mVertexBuffer.isNull() ||
-		(LLVertexBuffer::sEnableVBOs &&
-		((facep->mVertexBuffer->getUsage() == GL_STATIC_DRAW ? TRUE : FALSE) !=
-		 (facep->getPool()->getVertexShaderLevel() > 0 ? TRUE : FALSE))))
+	if (facep->mVertexBuffer.isNull())
 	{
-		mDirtyMesh = TRUE;
+		dirtyMesh(2);
 	}
 
-	if (mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
+	if (mDirtyMesh >= 2 || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
 		updateMeshData();
-		mDirtyMesh = FALSE;
+		mDirtyMesh = 0;
 		mNeedsSkin = TRUE;
 		mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
 	}
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 8da4c226edd..445bb032748 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -337,7 +337,6 @@ class LLVOAvatar :
  **/
 
 public:
-	U32 		renderFootShadows();
 	U32 		renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
 	U32 		renderRigid();
 	U32 		renderSkinned(EAvatarRenderPass pass);
@@ -565,13 +564,13 @@ class LLVOAvatar :
 public:
 	void 			updateMeshTextures();
 	void 			updateSexDependentLayerSets(BOOL upload_bake);
-	void 			dirtyMesh(); // Dirty the avatar mesh
+	void 			dirtyMesh(S32 priority = 1); // Dirty the avatar mesh
 	void 			updateMeshData();
 protected:
 	void 			releaseMeshData();
 	virtual void restoreMeshData();
 private:
-	BOOL 			mDirtyMesh;
+	S32 			mDirtyMesh; // 0 -- not dirty, 1 -- morphed, 2 -- LOD
 	BOOL			mMeshTexturesDirty;
 
 	typedef std::multimap<std::string, LLPolyMesh*> polymesh_map_t;
-- 
GitLab


From 9fd6531dda19bda12ba7dc16a5b5020550711a97 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 20 Apr 2010 13:41:19 +0100
Subject: [PATCH 308/683] Try to fix a (correct) gcc whine about the child
 hiding the parent's dirtyMesh() method. What I can't figure out is why gcc
 doesn't complain in render-pipeline, where the problem is the same.

---
 indra/newview/llvoavatar.cpp | 5 ++++-
 indra/newview/llvoavatar.h   | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index f89139dcd8d..2ad09beb587 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -5251,11 +5251,14 @@ void LLVOAvatar::updateSexDependentLayerSets( BOOL upload_bake )
 //-----------------------------------------------------------------------------
 // dirtyMesh()
 //-----------------------------------------------------------------------------
+void LLVOAvatar::dirtyMesh()
+{
+	dirtyMesh(1);
+}
 void LLVOAvatar::dirtyMesh(S32 priority)
 {
 	mDirtyMesh = llmax(mDirtyMesh, priority);
 }
-
 //-----------------------------------------------------------------------------
 // hideSkirt()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 445bb032748..0b0ef269705 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -564,12 +564,13 @@ class LLVOAvatar :
 public:
 	void 			updateMeshTextures();
 	void 			updateSexDependentLayerSets(BOOL upload_bake);
-	void 			dirtyMesh(S32 priority = 1); // Dirty the avatar mesh
+	void 			dirtyMesh(); // Dirty the avatar mesh
 	void 			updateMeshData();
 protected:
 	void 			releaseMeshData();
 	virtual void restoreMeshData();
 private:
+	void 			dirtyMesh(S32 priority); // Dirty the avatar mesh, with priority
 	S32 			mDirtyMesh; // 0 -- not dirty, 1 -- morphed, 2 -- LOD
 	BOOL			mMeshTexturesDirty;
 
-- 
GitLab


From a0cff3f011cd2c55ab63d5104169953f741a85f0 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 20 Apr 2010 13:41:19 +0100
Subject: [PATCH 309/683] Try to fix a (correct) gcc whine about the child
 hiding the parent's dirtyMesh() method. What I can't figure out is why gcc
 doesn't complain in render-pipeline, where the problem is the same.
 (transplanted from cba9bf2cf5194da14105cc28e792f908ef672864)

---
 indra/newview/llvoavatar.cpp | 5 ++++-
 indra/newview/llvoavatar.h   | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 52b32e07c6a..8c1546d47f5 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -5378,11 +5378,14 @@ void LLVOAvatar::updateSexDependentLayerSets( BOOL upload_bake )
 //-----------------------------------------------------------------------------
 // dirtyMesh()
 //-----------------------------------------------------------------------------
+void LLVOAvatar::dirtyMesh()
+{
+	dirtyMesh(1);
+}
 void LLVOAvatar::dirtyMesh(S32 priority)
 {
 	mDirtyMesh = llmax(mDirtyMesh, priority);
 }
-
 //-----------------------------------------------------------------------------
 // hideSkirt()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index b81725f106b..a851b7a1501 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -565,12 +565,13 @@ class LLVOAvatar :
 public:
 	void 			updateMeshTextures();
 	void 			updateSexDependentLayerSets(BOOL upload_bake);
-	void 			dirtyMesh(S32 priority = 1); // Dirty the avatar mesh
+	void 			dirtyMesh(); // Dirty the avatar mesh
 	void 			updateMeshData();
 protected:
 	void 			releaseMeshData();
 	virtual void restoreMeshData();
 private:
+	void 			dirtyMesh(S32 priority); // Dirty the avatar mesh, with priority
 	S32 			mDirtyMesh; // 0 -- not dirty, 1 -- morphed, 2 -- LOD
 	BOOL			mMeshTexturesDirty;
 
-- 
GitLab


From a49b1f5e00ae1a03469de5fae4b36233a0442b54 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 20 Apr 2010 11:38:07 -0500
Subject: [PATCH 310/683] Make assert_glerror not a hotspot.

---
 indra/llrender/llgl.cpp | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 97019d48c48..2ee7b16cf37 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -1039,23 +1039,8 @@ void flush_glerror()
 	glGetError();
 }
 
-void assert_glerror()
+void do_assert_glerror()
 {
-	if (!gGLActive)
-	{
-		//llwarns << "GL used while not active!" << llendl;
-
-		if (gDebugSession)
-		{
-			//ll_fail("GL used while not active");
-		}
-	}
-
-	if (gNoRender || !gDebugGL) 
-	{
-		return;
-	}
-	
 	if (!gGLManager.mInited)
 	{
 		LL_ERRS("RenderInit") << "GL not initialized" << LL_ENDL;
@@ -1107,6 +1092,25 @@ void assert_glerror()
 	}
 }
 
+void assert_glerror()
+{
+	if (!gGLActive)
+	{
+		//llwarns << "GL used while not active!" << llendl;
+
+		if (gDebugSession)
+		{
+			//ll_fail("GL used while not active");
+		}
+	}
+
+	if (!gNoRender && gDebugGL) 
+	{
+		do_assert_glerror();
+	}
+}
+	
+
 void clear_glerror()
 {
 	//  Create or update texture to be used with this data 
-- 
GitLab


From 9eb4dc94d58a6cb7fe247f30bde08c126f99d820 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 20 Apr 2010 11:38:07 -0500
Subject: [PATCH 311/683] Make assert_glerror not a hotspot. (transplanted from
 8476304a30a3c387a722b33743ef3385e85f85a0)

---
 indra/llrender/llgl.cpp | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 97019d48c48..2ee7b16cf37 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -1039,23 +1039,8 @@ void flush_glerror()
 	glGetError();
 }
 
-void assert_glerror()
+void do_assert_glerror()
 {
-	if (!gGLActive)
-	{
-		//llwarns << "GL used while not active!" << llendl;
-
-		if (gDebugSession)
-		{
-			//ll_fail("GL used while not active");
-		}
-	}
-
-	if (gNoRender || !gDebugGL) 
-	{
-		return;
-	}
-	
 	if (!gGLManager.mInited)
 	{
 		LL_ERRS("RenderInit") << "GL not initialized" << LL_ENDL;
@@ -1107,6 +1092,25 @@ void assert_glerror()
 	}
 }
 
+void assert_glerror()
+{
+	if (!gGLActive)
+	{
+		//llwarns << "GL used while not active!" << llendl;
+
+		if (gDebugSession)
+		{
+			//ll_fail("GL used while not active");
+		}
+	}
+
+	if (!gNoRender && gDebugGL) 
+	{
+		do_assert_glerror();
+	}
+}
+	
+
 void clear_glerror()
 {
 	//  Create or update texture to be used with this data 
-- 
GitLab


From d40b29345118ee9e80baf132fc68dc3e367e4c07 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 20 Apr 2010 11:38:38 -0500
Subject: [PATCH 312/683] Better branch prediction for markVisible.

---
 indra/newview/pipeline.cpp | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 02dc013ca4e..cb656b4fbc7 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1973,31 +1973,29 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE);
 
-	if(!drawablep || drawablep->isDead())
+	if(drawablep && !drawablep->isDead())
 	{
-		return;
-	}
-	
-	if (drawablep->isSpatialBridge())
-	{
-		LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
-
-		if (root && root->getParent() && root->getVObj() && root->getVObj()->isAttachment())
+		if (drawablep->isSpatialBridge())
 		{
-			LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
-			if (av && av->isImpostor())
+			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
+
+			if (root->getVObj()->isAttachment())
 			{
-				return;
+				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
+				if (av && av->isImpostor())
+				{
+					return;
+				}
 			}
+			sCull->pushBridge((LLSpatialBridge*) drawablep);
+		}
+		else
+		{
+			sCull->pushDrawable(drawablep);
 		}
-		sCull->pushBridge((LLSpatialBridge*) drawablep);
-	}
-	else
-	{
-		sCull->pushDrawable(drawablep);
-	}
 
-	drawablep->setVisible(camera);
+		drawablep->setVisible(camera);
+	}
 }
 
 void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion)
-- 
GitLab


From a1a23b3e00929dc7df62abff43e1486d402727d3 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 20 Apr 2010 11:38:38 -0500
Subject: [PATCH 313/683] Better branch prediction for markVisible.
 (transplanted from 5b6c80049d6e6c0df2396099b865729f21200de8)

---
 indra/newview/pipeline.cpp | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index a45f41a7dda..620f34ae534 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1960,31 +1960,29 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 {
 	LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE);
 
-	if(!drawablep || drawablep->isDead())
+	if(drawablep && !drawablep->isDead())
 	{
-		return;
-	}
-	
-	if (drawablep->isSpatialBridge())
-	{
-		LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
-
-		if (root && root->getParent() && root->getVObj() && root->getVObj()->isAttachment())
+		if (drawablep->isSpatialBridge())
 		{
-			LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
-			if (av && av->isImpostor())
+			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
+
+			if (root->getVObj()->isAttachment())
 			{
-				return;
+				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
+				if (av && av->isImpostor())
+				{
+					return;
+				}
 			}
+			sCull->pushBridge((LLSpatialBridge*) drawablep);
+		}
+		else
+		{
+			sCull->pushDrawable(drawablep);
 		}
-		sCull->pushBridge((LLSpatialBridge*) drawablep);
-	}
-	else
-	{
-		sCull->pushDrawable(drawablep);
-	}
 
-	drawablep->setVisible(camera);
+		drawablep->setVisible(camera);
+	}
 }
 
 void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion)
-- 
GitLab


From 707fca6abad1eb322fd0204d895d465f720fba13 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 20 Apr 2010 11:49:20 -0500
Subject: [PATCH 314/683] Fix for bad if on calling updateMeshData

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

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 09b9da444fb..9c14f1aa352 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3779,9 +3779,9 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 
 	LLFace* face = mDrawable->getFace(0);
 
-	bool needs_rebuild = !face || face->mVertexBuffer.isNull();
+	bool needs_rebuild = !face || face->mVertexBuffer.isNull() || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY);
 
-	if (needs_rebuild || mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
+	if (needs_rebuild || mDirtyMesh)
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
 		if (needs_rebuild || mDirtyMesh >= 2 || mVisibilityRank <= 4)
 		{
-- 
GitLab


From 6a6207871961cb61cc5a147d2bd7e28b87fe5069 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 20 Apr 2010 11:49:20 -0500
Subject: [PATCH 315/683] Fix for bad if on calling updateMeshData
 (transplanted from 06e897a5e9a67c675844993564d006de08501c72)

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

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 6c026ba34c3..bef1d63fcf7 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3652,9 +3652,9 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 
 	LLFace* face = mDrawable->getFace(0);
 
-	bool needs_rebuild = !face || face->mVertexBuffer.isNull();
+	bool needs_rebuild = !face || face->mVertexBuffer.isNull() || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY);
 
-	if (needs_rebuild || mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
+	if (needs_rebuild || mDirtyMesh)
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
 		if (needs_rebuild || mDirtyMesh >= 2 || mVisibilityRank <= 4)
 		{
-- 
GitLab


From 50b4783ad317b82791273c2d3b6e4260f7a5e77e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 20 Apr 2010 19:12:52 +0100
Subject: [PATCH 316/683] follow-up fix to ede2c9f28dd5 optimization.  for all
 I know, this fix nerfs the delicate branch optimization, BUT there was a real
 crash there. :/ (transplanted from e13b292907c5c208e0c96de73b80e203412c5c33)

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 620f34ae534..17c4830a32f 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1966,7 +1966,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 		{
 			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
 
-			if (root->getVObj()->isAttachment())
+			if (root && root->getVObj()->isAttachment())
 			{
 				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
 				if (av && av->isImpostor())
-- 
GitLab


From c4fd211cd85febb80158a8540e4ac625387aa515 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 20 Apr 2010 19:12:52 +0100
Subject: [PATCH 317/683] follow-up fix to ede2c9f28dd5 optimization.  for all
 I know, this fix nerfs the delicate branch optimization, BUT there was a real
 crash there. :/

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index cb656b4fbc7..f54b72ec32c 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1979,7 +1979,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 		{
 			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
 
-			if (root->getVObj()->isAttachment())
+			if (root && root->getVObj()->isAttachment())
 			{
 				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
 				if (av && av->isImpostor())
-- 
GitLab


From fbc8ee0abe1448e52d8b0f8a06f4ddacbc05fbcd Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 20 Apr 2010 22:47:32 +0100
Subject: [PATCH 318/683] Backed out changeset e13b292907c5 This didn't help. 
 I'll try another approach. (transplanted from
 ecd9ac6b5a41ab5c816fff8d993b03616076b82a)

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 17c4830a32f..620f34ae534 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1966,7 +1966,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 		{
 			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
 
-			if (root && root->getVObj()->isAttachment())
+			if (root->getVObj()->isAttachment())
 			{
 				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
 				if (av && av->isImpostor())
-- 
GitLab


From 5344d4b2fd89893288243c9a76413a19f90d6f56 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 20 Apr 2010 22:47:32 +0100
Subject: [PATCH 319/683] Backed out changeset e13b292907c5 This didn't help. 
 I'll try another approach.

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index f54b72ec32c..cb656b4fbc7 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1979,7 +1979,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 		{
 			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
 
-			if (root && root->getVObj()->isAttachment())
+			if (root->getVObj()->isAttachment())
 			{
 				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
 				if (av && av->isImpostor())
-- 
GitLab


From 879fc70f35107d17ef0e3fa6f8df48527f644d4d Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 20 Apr 2010 22:50:58 +0100
Subject: [PATCH 320/683] Another try at finding the new markVisible() crasher
 without de-optimizing it too badly.  Sprinkle it with asserts for the sanity
 checks we've started to skip, see which one (ones?) fires. (transplanted from
 09164f83f03cfa62d0fd8296c810d3e3794cb365)

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 620f34ae534..82954906779 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1965,9 +1965,11 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 		if (drawablep->isSpatialBridge())
 		{
 			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
-
+			llassert(root);
 			if (root->getVObj()->isAttachment())
 			{
+				llassert(root->getParent());
+				llassert(root->getParent()->getVObj());
 				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
 				if (av && av->isImpostor())
 				{
-- 
GitLab


From cb1ece05ddb71218de4c35df520937ffdda83434 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 20 Apr 2010 22:50:58 +0100
Subject: [PATCH 321/683] Another try at finding the new markVisible() crasher
 without de-optimizing it too badly.  Sprinkle it with asserts for the sanity
 checks we've started to skip, see which one (ones?) fires.

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index cb656b4fbc7..368e78dc434 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1978,9 +1978,11 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 		if (drawablep->isSpatialBridge())
 		{
 			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
-
+			llassert(root);
 			if (root->getVObj()->isAttachment())
 			{
+				llassert(root->getParent());
+				llassert(root->getParent()->getVObj());
 				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
 				if (av && av->isImpostor())
 				{
-- 
GitLab


From db73037c2882af70a09ac768ddb3748d811c767a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 21 Apr 2010 11:24:16 +0100
Subject: [PATCH 322/683] Make markVisible as safe as it was, but hopefully not
 as slow as it was. This is also sprinkled with asserts so we can see which of
 the NULL tests are - or aren't - needed, if it's really so important to skip
 them.

---
 indra/newview/pipeline.cpp | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 368e78dc434..318d5d5ca1f 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1977,16 +1977,25 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 	{
 		if (drawablep->isSpatialBridge())
 		{
-			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
-			llassert(root);
-			if (root->getVObj()->isAttachment())
+			const LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
+			llassert(root); // trying to catch a bad assumption
+			if (root && //  // this test may not be needed, see above
+			    root->getVObj()->isAttachment())
 			{
-				llassert(root->getParent());
-				llassert(root->getParent()->getVObj());
-				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
-				if (av && av->isImpostor())
+				LLDrawable* rootparent = root->getParent();
+				llassert(rootparent); // trying to catch a bad assumption
+				if (rootparent) // this test may not be needed, see above
 				{
-					return;
+					LLViewerObject *vobj = rootparent->getVObj();
+					llassert(vobj); // trying to catch a bad assumption
+					if (vobj) // this test may not be needed, see above
+					{
+						const LLVOAvatar* av = vobj->asAvatar();
+						if (av && av->isImpostor())
+						{
+							return;
+						}
+					}
 				}
 			}
 			sCull->pushBridge((LLSpatialBridge*) drawablep);
-- 
GitLab


From f066ff8c607d5c0db8cea8d9cb88eec546df1089 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 21 Apr 2010 11:24:16 +0100
Subject: [PATCH 323/683] Make markVisible as safe as it was, but hopefully not
 as slow as it was. This is also sprinkled with asserts so we can see which of
 the NULL tests are - or aren't - needed, if it's really so important to skip
 them. (transplanted from 66851d9c86b7ec5155b6c3950e2971d0d7375826)

---
 indra/newview/pipeline.cpp | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 82954906779..37ab95f0e8e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1964,16 +1964,25 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 	{
 		if (drawablep->isSpatialBridge())
 		{
-			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
-			llassert(root);
-			if (root->getVObj()->isAttachment())
+			const LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
+			llassert(root); // trying to catch a bad assumption
+			if (root && //  // this test may not be needed, see above
+			    root->getVObj()->isAttachment())
 			{
-				llassert(root->getParent());
-				llassert(root->getParent()->getVObj());
-				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
-				if (av && av->isImpostor())
+				LLDrawable* rootparent = root->getParent();
+				llassert(rootparent); // trying to catch a bad assumption
+				if (rootparent) // this test may not be needed, see above
 				{
-					return;
+					LLViewerObject *vobj = rootparent->getVObj();
+					llassert(vobj); // trying to catch a bad assumption
+					if (vobj) // this test may not be needed, see above
+					{
+						const LLVOAvatar* av = vobj->asAvatar();
+						if (av && av->isImpostor())
+						{
+							return;
+						}
+					}
 				}
 			}
 			sCull->pushBridge((LLSpatialBridge*) drawablep);
-- 
GitLab


From 0cd4106ba6e3d74a9f41dac12fe6e1b504b007f9 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 21 Apr 2010 14:24:44 +0100
Subject: [PATCH 324/683] ssreflections: if we're going to (pretend to) take 4
 diffuse samples, then take them in a diamond pattern instead of all in a
 line.  this also slightly simplifies(?) the shader. (transplanted from
 7b334c22ece4e98565c5d182690ab9ca4c2526c6)

---
 .../shaders/class1/deferred/softenLightF.glsl         | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 5fb86dd92d5..01d18cdcde6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -299,17 +299,14 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
-		ref2d += checkoffset;
+		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
 		// We average two samples of diffuse (not of anything else) per
 		// pixel to try to reduce aliasing some more.
-		// ---------------------
-		//     ^   ^ ^ ^   ^
-		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
-		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
-				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb +
+				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
-- 
GitLab


From ba294e9ad95e8db491ea19c8a370e88a31814c9d Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 21 Apr 2010 14:24:44 +0100
Subject: [PATCH 325/683] ssreflections: if we're going to (pretend to) take 4
 diffuse samples, then take them in a diamond pattern instead of all in a
 line.  this also slightly simplifies(?) the shader. (transplanted from
 7b334c22ece4e98565c5d182690ab9ca4c2526c6)

---
 .../shaders/class1/deferred/softenLightF.glsl         | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 5fb86dd92d5..01d18cdcde6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -299,17 +299,14 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
-		ref2d += checkoffset;
+		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
 		// We average two samples of diffuse (not of anything else) per
 		// pixel to try to reduce aliasing some more.
-		// ---------------------
-		//     ^   ^ ^ ^   ^
-		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
-		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
-				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb +
+				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
-- 
GitLab


From aff0a1bf84db8d77b06c5ab4e44e9d461bc77b7a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 21 Apr 2010 14:27:54 +0100
Subject: [PATCH 326/683] port class1 ssreflections tweaks to class2 and class3
 (transplanted from 19036fc277d88c364e957019a66b4cdf4cce8b53)

---
 .../shaders/class2/deferred/softenLightF.glsl         | 11 ++++-------
 .../shaders/class3/deferred/softenLightF.glsl         | 11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 1fd54b56071..2982cd3e09c 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -298,17 +298,14 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
-		ref2d += checkoffset;
+		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
 		// We average two samples of diffuse (not of anything else) per
 		// pixel to try to reduce aliasing some more.
-		// ---------------------
-		//     ^   ^ ^ ^   ^
-		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
-		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
-				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb +
+				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		float refshad = texture2DRect(lightMap, ref2d).r;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 45d921d8618..e1e035411bd 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -301,17 +301,14 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
-		ref2d += checkoffset;
+		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
 		// We average two samples of diffuse (not of anything else) per
 		// pixel to try to reduce aliasing some more.
-		// ---------------------
-		//     ^   ^ ^ ^   ^
-		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
-		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
-				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb +
+				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		float refshad = texture2DRect(lightMap, ref2d).r;
-- 
GitLab


From e188693f126455ac1e74fbab42ddc76b63bc167b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 21 Apr 2010 14:27:54 +0100
Subject: [PATCH 327/683] port class1 ssreflections tweaks to class2 and class3
 (transplanted from 19036fc277d88c364e957019a66b4cdf4cce8b53)

---
 .../shaders/class2/deferred/softenLightF.glsl         | 11 ++++-------
 .../shaders/class3/deferred/softenLightF.glsl         | 11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 1fd54b56071..2982cd3e09c 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -298,17 +298,14 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
-		ref2d += checkoffset;
+		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
 		// We average two samples of diffuse (not of anything else) per
 		// pixel to try to reduce aliasing some more.
-		// ---------------------
-		//     ^   ^ ^ ^   ^
-		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
-		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
-				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb +
+				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		float refshad = texture2DRect(lightMap, ref2d).r;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 45d921d8618..e1e035411bd 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -301,17 +301,14 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5);
-		ref2d += checkoffset;
+		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
 		// We average two samples of diffuse (not of anything else) per
 		// pixel to try to reduce aliasing some more.
-		// ---------------------
-		//     ^   ^ ^ ^   ^
-		//     a . b o c . d    check=0:avg(a,b) check=1:avg(c,d)
-		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb +
-				     texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb);
+		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb +
+				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		float refshad = texture2DRect(lightMap, ref2d).r;
-- 
GitLab


From 2f695e1e24f804ee77a3a3b2533914eff40a9e19 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 21 Apr 2010 15:40:13 +0100
Subject: [PATCH 328/683] tidy-up the graphics prefs panel a bit, after the
 merge from viewer-trunk disrupted it. (transplanted from
 3f69c628cd87e2a0a7e6e3c9f51df2020a81b917)

---
 .../skins/default/xui/en/panel_preferences_graphics1.xml       | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index ab5e4ef5cdd..68a0db3b893 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -597,7 +597,7 @@
       follows="left|top"
       height="12"
       layout="topleft"
-      left_delta="-230"
+      left_delta="-260"
       name="AvatarRenderingText"
       top_pad="8"
       width="128">
@@ -642,6 +642,7 @@
         follows="left|top"
         height="12"
         layout="topleft"
+        left="358"
         left_pad="-30"
         name="TerrainDetailText"
         top="488"
-- 
GitLab


From 4d204d4903fdf8f4ea083f752a27d185dad63ce6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 21 Apr 2010 15:40:13 +0100
Subject: [PATCH 329/683] tidy-up the graphics prefs panel a bit, after the
 merge from viewer-trunk disrupted it.

---
 .../skins/default/xui/en/panel_preferences_graphics1.xml       | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index ab5e4ef5cdd..68a0db3b893 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -597,7 +597,7 @@
       follows="left|top"
       height="12"
       layout="topleft"
-      left_delta="-230"
+      left_delta="-260"
       name="AvatarRenderingText"
       top_pad="8"
       width="128">
@@ -642,6 +642,7 @@
         follows="left|top"
         height="12"
         layout="topleft"
+        left="358"
         left_pad="-30"
         name="TerrainDetailText"
         top="488"
-- 
GitLab


From 8dda4d48f9b51976eede5e1777d753cf6dfb8586 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 21 Apr 2010 16:50:00 -0500
Subject: [PATCH 330/683] Rigged attachments FTW!

---
 indra/newview/llvoavatar.cpp | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 51a78fc1252..e2650d22b01 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3705,7 +3705,15 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 										U16 offset = 0;
 										
 										LLMatrix4 mat_vert = skin->mBindShapeMatrix;
-										LLMatrix3 mat_normal;
+										glh::matrix4f m((F32*) mat_vert.mMatrix);
+										m = m.inverse().transpose();
+										
+										F32 mat3[] = 
+										{ m.m[0], m.m[1], m.m[2],
+										  m.m[4], m.m[5], m.m[6],
+										  m.m[8], m.m[9], m.m[10] };
+
+										LLMatrix3 mat_normal(mat3);				
 
 										face->getGeometryVolume(*volume, i, mat_vert, mat_normal, offset, true);
 										buff = face->mVertexBuffer;
@@ -3729,8 +3737,8 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 										LLJoint* joint = getJoint(skin->mJointNames[i]);
 										if (joint)
 										{
-											mat[i*2+0] = skin->mInvBindMatrix[i];
-											mat[i*2+1] = joint->getWorldMatrix();
+											mat[i] = skin->mInvBindMatrix[i];
+											mat[i] *= joint->getWorldMatrix();
 										}
 									}
 									
@@ -3750,9 +3758,9 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 									S32 offset = face->getIndicesStart();
 									U32 count = face->getIndicesCount();
 
-									glPointSize(8.f);
-									buff->drawRange(LLRender::POINTS, start, end, count, offset);
-									glPointSize(1.f);
+									gGL.getTexUnit(0)->bind(face->getTexture());
+									buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);
+									
 								}
 							}
 						}
-- 
GitLab


From 07856a0640ba5c881571952f6c67d40fe5651ebb Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 21 Apr 2010 16:50:15 -0500
Subject: [PATCH 331/683] Make attached lights not render when disabled in
 deferred rendering.

---
 indra/newview/pipeline.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index cb656b4fbc7..d80f749e569 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1979,7 +1979,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 		{
 			LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
 
-			if (root->getVObj()->isAttachment())
+			if (root && root->getVObj() && root->getVObj()->isAttachment())
 			{
 				LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
 				if (av && av->isImpostor())
@@ -6736,6 +6736,15 @@ void LLPipeline::renderDeferredLighting()
 						continue;
 					}
 
+					if (volume->isAttachment())
+					{
+						if (!sRenderAttachedLights)
+						{
+							continue;
+						}
+					}
+
+
 					LLVector3 center = drawablep->getPositionAgent();
 					F32* c = center.mV;
 					F32 s = volume->getLightRadius()*1.5f;
-- 
GitLab


From d9b624e5c2bf43a6ce1635f4a2d1a6ba355d8040 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 21 Apr 2010 16:50:15 -0500
Subject: [PATCH 332/683] Make attached lights not render when disabled in
 deferred rendering. (transplanted from
 4be49811a590ad3107af3f546475ee6d33928120)

---
 indra/newview/pipeline.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 37ab95f0e8e..af0aa41ca59 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6664,6 +6664,15 @@ void LLPipeline::renderDeferredLighting()
 						continue;
 					}
 
+					if (volume->isAttachment())
+					{
+						if (!sRenderAttachedLights)
+						{
+							continue;
+						}
+					}
+
+
 					LLVector3 center = drawablep->getPositionAgent();
 					F32* c = center.mV;
 					F32 s = volume->getLightRadius()*1.5f;
-- 
GitLab


From bf8bcfe4f76f1805a908af0368e334261b764591 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 22 Apr 2010 00:14:06 -0500
Subject: [PATCH 333/683] Deferred shading for rigged attachments.

---
 indra/newview/lldrawpoolavatar.cpp  | 98 +++++++++++++++++++++--------
 indra/newview/lldrawpoolavatar.h    |  4 ++
 indra/newview/llviewershadermgr.cpp | 27 ++++++++
 indra/newview/llviewershadermgr.h   |  2 +
 indra/newview/llvoavatar.cpp        |  4 +-
 5 files changed, 106 insertions(+), 29 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index c4581b2c788..4b7de971017 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -53,8 +53,9 @@
 static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK;
 static U32 sBufferUsage = GL_STREAM_DRAW_ARB;
 static U32 sShaderLevel = 0;
-static LLGLSLShader* sVertexProgram = NULL;
 
+
+LLGLSLShader* LLDrawPoolAvatar::sVertexProgram = NULL;
 BOOL	LLDrawPoolAvatar::sSkipOpaque = FALSE;
 BOOL	LLDrawPoolAvatar::sSkipTransparent = FALSE;
 
@@ -176,6 +177,9 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
 	case 2:
 		beginDeferredSkinned();
 		break;
+	case 3:
+		beginDeferredRigged();
+		break;
 	}
 }
 
@@ -202,6 +206,8 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass)
 	case 2:
 		endDeferredSkinned();
 		break;
+	case 3:
+		endDeferredRigged();
 	}
 }
 
@@ -248,41 +254,58 @@ void LLDrawPoolAvatar::renderPostDeferred(S32 pass)
 
 S32 LLDrawPoolAvatar::getNumShadowPasses()
 {
-	return 1;
+	return 2;
 }
 
 void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-	sVertexProgram = &gDeferredAvatarShadowProgram;
-	if (sShaderLevel > 0)
+
+	if (pass == 0)
 	{
-		gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
-	}
-	gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f);
-	
-	glColor4f(1,1,1,1);
+		sVertexProgram = &gDeferredAvatarShadowProgram;
+		if (sShaderLevel > 0)
+		{
+			gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
+		}
+		gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f);
+		
+		glColor4f(1,1,1,1);
 
-	if ((sShaderLevel > 0))  // for hardware blending
+		if ((sShaderLevel > 0))  // for hardware blending
+		{
+			sRenderingSkinned = TRUE;
+			sVertexProgram->bind();
+			enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
+		}
+	}
+	else
 	{
-		sRenderingSkinned = TRUE;
+		sVertexProgram = &gDeferredAttachmentShadowProgram;
 		sVertexProgram->bind();
-		enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
+		LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 	}
-
 }
 
 void LLDrawPoolAvatar::endShadowPass(S32 pass)
 {
 	LLFastTimer t(FTM_SHADOW_AVATAR);
-	if (sShaderLevel > 0)
+	if (pass == 0)
 	{
-		sRenderingSkinned = FALSE;
+		if (sShaderLevel > 0)
+		{
+			sRenderingSkinned = FALSE;
+			sVertexProgram->unbind();
+			disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
+		}
+	}
+	else
+	{
+		LLVertexBuffer::unbind();
 		sVertexProgram->unbind();
-		disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
+		LLVertexBuffer::sWeight4Loc = -1;
+		sVertexProgram = NULL;
 	}
-
-	gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
 }
 
 void LLDrawPoolAvatar::renderShadow(S32 pass)
@@ -312,13 +335,19 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 		return;
 	}
 	
-	if (sShaderLevel > 0)
+	if (pass == 0)
 	{
-		gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
-	}
-
-	avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
+		if (sShaderLevel > 0)
+		{
+			gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
+		}
 
+		avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
+	}
+	else
+	{
+		avatarp->renderSkinnedAttachments();
+	}
 }
 
 S32 LLDrawPoolAvatar::getNumPasses()
@@ -578,7 +607,7 @@ void LLDrawPoolAvatar::endSkinned()
 
 void LLDrawPoolAvatar::beginRigged()
 {
-	sVertexProgram = NULL;
+	sVertexProgram = &gSkinnedObjectSimpleProgram;
 	gSkinnedObjectSimpleProgram.bind();
 	LLVertexBuffer::sWeight4Loc = gSkinnedObjectSimpleProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
@@ -591,6 +620,21 @@ void LLDrawPoolAvatar::endRigged()
 	LLVertexBuffer::sWeight4Loc = -1;
 }
 
+void LLDrawPoolAvatar::beginDeferredRigged()
+{
+	sVertexProgram = &gDeferredSkinnedDiffuseProgram;
+	sVertexProgram->bind();
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endDeferredRigged()
+{
+	LLVertexBuffer::unbind();
+	sVertexProgram->unbind();
+	LLVertexBuffer::sWeight4Loc = -1;
+	sVertexProgram = NULL;
+}
+
 void LLDrawPoolAvatar::beginDeferredSkinned()
 {
 	sShaderLevel = mVertexShaderLevel;
@@ -893,16 +937,16 @@ void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
 		glNormalPointer(GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_NORMAL]));
 		glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD0]));
 		
-		set_vertex_weights(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT]));
+		set_vertex_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT]));
 
 		if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_BUMP)
 		{
-			set_binormals(sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL]));
+			set_binormals(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL]));
 		}
 	
 		if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)
 		{
-			set_vertex_clothing_weights(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
+			set_vertex_clothing_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
 		}
 	}
 	else
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index 45f694ccd99..b42cc54622c 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -36,6 +36,7 @@
 #include "lldrawpool.h"
 
 class LLVOAvatar;
+class LLGLSLShader;
 
 class LLDrawPoolAvatar : public LLFacePool
 {
@@ -100,10 +101,12 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginDeferredImpostor();
 	void beginDeferredRigid();
 	void beginDeferredSkinned();
+	void beginDeferredRigged();
 	
 	void endDeferredImpostor();
 	void endDeferredRigid();
 	void endDeferredSkinned();
+	void endDeferredRigged();
 		
 	/*virtual*/ LLViewerTexture *getDebugTexture();
 	/*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display
@@ -112,6 +115,7 @@ class LLDrawPoolAvatar : public LLFacePool
 
 	static BOOL sSkipOpaque;
 	static BOOL sSkipTransparent;
+	static LLGLSLShader* sVertexProgram;
 };
 
 class LLVertexBufferAvatar : public LLVertexBuffer
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 8a68dd6ea70..d978e856a60 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -110,6 +110,7 @@ LLGLSLShader			gDeferredImpostorProgram;
 LLGLSLShader			gDeferredEdgeProgram;
 LLGLSLShader			gDeferredWaterProgram;
 LLGLSLShader			gDeferredDiffuseProgram;
+LLGLSLShader			gDeferredSkinnedDiffuseProgram;
 LLGLSLShader			gDeferredBumpProgram;
 LLGLSLShader			gDeferredTerrainProgram;
 LLGLSLShader			gDeferredTreeProgram;
@@ -124,6 +125,7 @@ LLGLSLShader			gDeferredBlurLightProgram;
 LLGLSLShader			gDeferredSoftenProgram;
 LLGLSLShader			gDeferredShadowProgram;
 LLGLSLShader			gDeferredAvatarShadowProgram;
+LLGLSLShader			gDeferredAttachmentShadowProgram;
 LLGLSLShader			gDeferredAlphaProgram;
 LLGLSLShader			gDeferredFullbrightProgram;
 LLGLSLShader			gDeferredGIProgram;
@@ -575,6 +577,7 @@ void LLViewerShaderMgr::unloadShaders()
 	gPostNightVisionProgram.unload();
 
 	gDeferredDiffuseProgram.unload();
+	gDeferredSkinnedDiffuseProgram.unload();
 
 	mVertexShaderLevel[SHADER_LIGHTING] = 0;
 	mVertexShaderLevel[SHADER_OBJECT] = 0;
@@ -889,6 +892,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gDeferredTreeProgram.unload();
 		gDeferredDiffuseProgram.unload();
+		gDeferredSkinnedDiffuseProgram.unload();
 		gDeferredBumpProgram.unload();
 		gDeferredImpostorProgram.unload();
 		gDeferredTerrainProgram.unload();
@@ -901,6 +905,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredSoftenProgram.unload();
 		gDeferredShadowProgram.unload();
 		gDeferredAvatarShadowProgram.unload();
+		gDeferredAttachmentShadowProgram.unload();
 		gDeferredAvatarProgram.unload();
 		gDeferredAvatarAlphaProgram.unload();
 		gDeferredAlphaProgram.unload();
@@ -929,6 +934,17 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		success = gDeferredDiffuseProgram.createShader(NULL, NULL);
 	}
 
+	if (success)
+	{
+		gDeferredSkinnedDiffuseProgram.mName = "Deferred Skinned Diffuse Shader";
+		gDeferredSkinnedDiffuseProgram.mFeatures.hasObjectSkinning = true;
+		gDeferredSkinnedDiffuseProgram.mShaderFiles.clear();
+		gDeferredSkinnedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredSkinnedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gDeferredSkinnedDiffuseProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+		success = gDeferredSkinnedDiffuseProgram.createShader(NULL, NULL);
+	}
+
 	if (success)
 	{
 		gDeferredBumpProgram.mName = "Deferred Bump Shader";
@@ -1104,6 +1120,17 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		success = gDeferredAvatarShadowProgram.createShader(&mAvatarAttribs, &mAvatarUniforms);
 	}
 
+	if (success)
+	{
+		gDeferredAttachmentShadowProgram.mName = "Deferred Attachment Shadow Shader";
+		gDeferredAttachmentShadowProgram.mFeatures.hasObjectSkinning = true;
+		gDeferredAttachmentShadowProgram.mShaderFiles.clear();
+		gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gDeferredAttachmentShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+		success = gDeferredAttachmentShadowProgram.createShader(NULL, NULL);
+	}
+
 	if (success)
 	{
 		gTerrainProgram.mName = "Deferred Terrain Shader";
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index 83a650cdbc7..b279a59777b 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -346,6 +346,7 @@ extern LLGLSLShader			gDeferredImpostorProgram;
 extern LLGLSLShader			gDeferredEdgeProgram;
 extern LLGLSLShader			gDeferredWaterProgram;
 extern LLGLSLShader			gDeferredDiffuseProgram;
+extern LLGLSLShader			gDeferredSkinnedDiffuseProgram;
 extern LLGLSLShader			gDeferredBumpProgram;
 extern LLGLSLShader			gDeferredTerrainProgram;
 extern LLGLSLShader			gDeferredTreeProgram;
@@ -363,6 +364,7 @@ extern LLGLSLShader			gDeferredShadowProgram;
 extern LLGLSLShader			gDeferredPostGIProgram;
 extern LLGLSLShader			gDeferredPostProgram;
 extern LLGLSLShader			gDeferredAvatarShadowProgram;
+extern LLGLSLShader			gDeferredAttachmentShadowProgram;
 extern LLGLSLShader			gDeferredAlphaProgram;
 extern LLGLSLShader			gDeferredFullbrightProgram;
 extern LLGLSLShader			gDeferredAvatarAlphaProgram;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index e2650d22b01..7cdbebf4d1c 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3742,11 +3742,11 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 										}
 									}
 									
-									gSkinnedObjectSimpleProgram.uniformMatrix4fv("matrixPalette", 
+									LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", 
 										skin->mJointNames.size(),
 										FALSE,
 										(GLfloat*) mat[0].mMatrix);
-									gSkinnedObjectSimpleProgram.uniformMatrix4fv("matrixPalette[0]", 
+									LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette[0]", 
 										skin->mJointNames.size(),
 										FALSE,
 										(GLfloat*) mat[0].mMatrix);
-- 
GitLab


From 04d2f64aa7eb679975fc672d932af1472b7feb8f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 14:52:02 +0100
Subject: [PATCH 334/683] Stop asserting one of the markDirty paths which
 really happens in the wild. (transplanted from
 fe2be2242fe59806989f9784a3797e2d5f69442f)

---
 indra/newview/pipeline.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index af0aa41ca59..7a9a47feab7 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1970,8 +1970,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 			    root->getVObj()->isAttachment())
 			{
 				LLDrawable* rootparent = root->getParent();
-				llassert(rootparent); // trying to catch a bad assumption
-				if (rootparent) // this test may not be needed, see above
+				if (rootparent) // this IS sometimes NULL
 				{
 					LLViewerObject *vobj = rootparent->getVObj();
 					llassert(vobj); // trying to catch a bad assumption
-- 
GitLab


From 2c07b128520ccbd748a8bf3d9dcdbbf3a7099ee3 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 14:52:02 +0100
Subject: [PATCH 335/683] Stop asserting one of the markDirty paths which
 really happens in the wild.

---
 indra/newview/pipeline.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 44c95a4fd69..a36f6831c36 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1983,8 +1983,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 			    root->getVObj()->isAttachment())
 			{
 				LLDrawable* rootparent = root->getParent();
-				llassert(rootparent); // trying to catch a bad assumption
-				if (rootparent) // this test may not be needed, see above
+				if (rootparent) // this IS sometimes NULL
 				{
 					LLViewerObject *vobj = rootparent->getVObj();
 					llassert(vobj); // trying to catch a bad assumption
-- 
GitLab


From 02d9320afd91713a28b0b40a249feee064bd4ad2 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 16:28:33 +0100
Subject: [PATCH 336/683] Let GL errors be caught on Linux - don't know why
 this was disabled. (transplanted from
 a149524a63039870704a498952d9bb3aa599b472)

---
 indra/llrender/llgl.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 2ee7b16cf37..7ff68fe34b2 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -1041,7 +1041,7 @@ void flush_glerror()
 
 void do_assert_glerror()
 {
-	if (!gGLManager.mInited)
+	if (LL_UNLIKELY(!gGLManager.mInited))
 	{
 		LL_ERRS("RenderInit") << "GL not initialized" << LL_ENDL;
 	}
@@ -1049,10 +1049,9 @@ void do_assert_glerror()
 	GLenum error;
 	error = glGetError();
 	BOOL quit = FALSE;
-	while (error)
+	while (LL_UNLIKELY(error))
 	{
 		quit = TRUE;
-#ifndef LL_LINUX // *FIX: !  This should be an error for linux as well.
 		GLubyte const * gl_error_msg = gluErrorString(error);
 		if (NULL != gl_error_msg)
 		{
@@ -1076,7 +1075,6 @@ void do_assert_glerror()
 			}
 		}
 		error = glGetError();
-#endif
 	}
 
 	if (quit)
-- 
GitLab


From 8496f2673971d0b3ba0f22623d7007cd163f8b02 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 16:28:33 +0100
Subject: [PATCH 337/683] Let GL errors be caught on Linux - don't know why
 this was disabled.

---
 indra/llrender/llgl.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 2ee7b16cf37..7ff68fe34b2 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -1041,7 +1041,7 @@ void flush_glerror()
 
 void do_assert_glerror()
 {
-	if (!gGLManager.mInited)
+	if (LL_UNLIKELY(!gGLManager.mInited))
 	{
 		LL_ERRS("RenderInit") << "GL not initialized" << LL_ENDL;
 	}
@@ -1049,10 +1049,9 @@ void do_assert_glerror()
 	GLenum error;
 	error = glGetError();
 	BOOL quit = FALSE;
-	while (error)
+	while (LL_UNLIKELY(error))
 	{
 		quit = TRUE;
-#ifndef LL_LINUX // *FIX: !  This should be an error for linux as well.
 		GLubyte const * gl_error_msg = gluErrorString(error);
 		if (NULL != gl_error_msg)
 		{
@@ -1076,7 +1075,6 @@ void do_assert_glerror()
 			}
 		}
 		error = glGetError();
-#endif
 	}
 
 	if (quit)
-- 
GitLab


From c074404d9dbaa7ccdbd863e4a9e7e3eff97e7816 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 22 Apr 2010 14:44:34 -0500
Subject: [PATCH 338/683] Que?

---
 indra/llrender/llvertexbuffer.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 668e9e55f9d..7fa47cd171b 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -271,9 +271,22 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
 		return;
 	}
 
+	U16* idx = ((U16*) getIndicesPointer())+indices_offset;
+
+	if (gDebugGL && !useVBOs())
+	{
+		for (U32 i = 0; i < count; ++i)
+		{
+			if (idx[i] < start || idx[i] > end)
+			{
+				llerrs << "Index out of range: " << idx[i] << " not in [" << start << ", " << end << "]" << llendl;
+			}
+		}
+	}
+
 	stop_glerror();
 	glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, 
-		((U16*) getIndicesPointer()) + indices_offset);
+		idx);
 	stop_glerror();
 }
 
-- 
GitLab


From 12e0a745dd97b7bd5a10ee01dec3e5d3055b515c Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 21:33:10 +0100
Subject: [PATCH 339/683] ssreflections: dampen/blur ssreflections rather more.

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl    | 3 ++-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl    | 3 ++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl    | 4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 01d18cdcde6..bf5dd4155c2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -299,7 +299,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5);
 		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
@@ -324,6 +324,7 @@ void main()
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
+		ssshiny *= 0.3; // dampen it even more
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 2982cd3e09c..28cfc6322e0 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -298,7 +298,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5);
 		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
@@ -324,6 +324,7 @@ void main()
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
+		ssshiny *= 0.3; // dampen it even more
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index e1e035411bd..9f94b9e8eaa 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -301,7 +301,8 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5);
+
 		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
@@ -327,6 +328,7 @@ void main()
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
+		ssshiny *= 0.3; // dampen it even more
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
-- 
GitLab


From 782438843c1fcd8b2f933b22de0da190b20a867a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 21:39:09 +0100
Subject: [PATCH 340/683] Backed out changeset 491edf15255a

---
 indra/newview/llviewerregion.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 2267db770c0..07d4ac664f4 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -174,7 +174,7 @@ class BaseCapabilitiesComplete : public LLHTTPClient::Responder
 				mRegion->showReleaseNotes();
 			}
 		}
-
+		
 		if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
 		{
 			LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED );
@@ -1490,7 +1490,6 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("ProvisionVoiceAccountRequest");
 	capabilityNames.append("RemoteParcelRequest");
 	capabilityNames.append("RequestTextureDownload");
-	capabilityNames.append("SimulatorFeatures");
 	capabilityNames.append("SearchStatRequest");
 	capabilityNames.append("SearchStatTracking");
 	capabilityNames.append("SendPostcard");
-- 
GitLab


From bc98e01c4a389948b1a6c0f5e53cc8b8b21a0bec Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 21:39:37 +0100
Subject: [PATCH 341/683] Backed out changeset 24ced5703710

---
 indra/newview/app_settings/keywords.ini | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini
index 18edce42a44..0805e94b10e 100644
--- a/indra/newview/app_settings/keywords.ini
+++ b/indra/newview/app_settings/keywords.ini
@@ -353,11 +353,6 @@ PRIM_BUMP_SHINY		Followed by an integer face, one of PRIM_SHINY_NONE, PRIM_SHINY
 PRIM_FULLBRIGHT		Followed by an integer face, and TRUE or FALSE
 PRIM_TEXGEN			Followed by an integer face, and one of PRIM_TEXGEN_DEFAULT or PRIM_TEXGEN_PLANAR
 PRIM_GLOW			Followed by an integer face, and a float from 0.0 to 1.0 specifying glow amount
-PRIM_PHYSICS_SHAPE_TYPE Followed by one of PRIM_PHYSICS_SHAPE_PRIM (use prim as-is for physics), PRIM_PHYSICS_SHAPE_NONE (do not use prim for physics), PRIM_PHYSICS_SHAPE_CONVEX (use convex hull of prim for physics)
-
-PRIM_PHYSICS_SHAPE_PRIM     Sets the physics shape type to PRIM (i.e., use the prim as-is in the physics engine)
-PRIM_PHYSICS_SHAPE_NONE     Sets the physics shape type to NONE (i.e., the shape will not exist the physics engine)
-PRIM_PHYSICS_SHAPE_CONVEX   Sets the physics shape type to CONVEX (i.e., use the convex hull of the prim in the physics engine)
 
 PRIM_TYPE_BOX		Followed by integer hole shape, vector cut, float hollow, vector twist,:vector top size, and vector top shear
 PRIM_TYPE_CYLINDER	Followed by integer hole shape, vector cut, float hollow, vector twist,:vector top size, and vector top shear
-- 
GitLab


From f15dc04e3884cf389c27ff8897ff67cdb2721d88 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 21:39:49 +0100
Subject: [PATCH 342/683] Backed out changeset 8d006f07bf22

---
 indra/newview/llviewerobject.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 620e2701770..bae84415d75 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5235,15 +5235,15 @@ class ObjectPhysicsProperties : public LLHTTPNode
 			LLSD& currObjectData = objectData[i];
 			U32 localID = currObjectData["LocalID"].asInteger();
 
-			// Iterate through nodes at end, since it can be on both the regular AND hover list
-			struct f : public LLSelectedNodeFunctor
-			{
-				U32 mID;
-				f(const U32& id) : mID(id) {}
-				virtual bool apply(LLSelectNode* node)
-				{
-					return (node->getObject() && node->getObject()->mLocalID == mID );
-				}
+			// Iterate through nodes at end, since it can be on both the regular AND hover list
+			struct f : public LLSelectedNodeFunctor
+			{
+				U32 mID;
+				f(const U32& id) : mID(id) {}
+				virtual bool apply(LLSelectNode* node)
+				{
+					return (node->getObject() && node->getObject()->mLocalID == mID );
+				}
 			} func(localID);
 
 			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
-- 
GitLab


From 4ef74e89c7677dcc84e412ce1c5648848d3577e5 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 21:40:04 +0100
Subject: [PATCH 343/683] Backed out changeset 5d5e820de3ef

---
 indra/newview/llviewerobject.cpp                     | 1 -
 indra/newview/skins/default/xui/en/floater_tools.xml | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bae84415d75..7b94e49a2a2 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5257,7 +5257,6 @@ class ObjectPhysicsProperties : public LLHTTPNode
 			}	
 		}
 		
-		dialog_refresh_all();
 	};
 };
 
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index f5054cf2064..b987cd91083 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1428,7 +1428,7 @@ even though the user gets a free copy.
              name="label physicsshapetype"
              top_pad="10"
              width="121">
-                Physics Shape Type:
+                Physics Rep:
             </text>
 			<combo_box
 			   height="23"
-- 
GitLab


From 91587ab74f80bc95ebb2a06826950468b6b3a460 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 21:40:23 +0100
Subject: [PATCH 344/683] Backed out changeset 4e01b259fdd4

---
 indra/newview/llpanelobject.cpp               | 36 +++++++++----------
 indra/newview/llpanelobject.h                 | 22 ++++++------
 indra/newview/llselectmgr.cpp                 | 12 +++----
 indra/newview/llselectmgr.h                   |  2 +-
 indra/newview/llviewerobject.cpp              | 27 +++++++-------
 indra/newview/llviewerobject.h                |  6 ++--
 .../skins/default/xui/en/floater_tools.xml    | 18 +++++-----
 scripts/messages/message_template.msg         |  2 +-
 8 files changed, 63 insertions(+), 62 deletions(-)

diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 669ff3ffd6c..991e97b767e 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -138,9 +138,9 @@ BOOL	LLPanelObject::postBuild()
 	mCheckPhantom = getChild<LLCheckBoxCtrl>("Phantom Checkbox Ctrl");
 	childSetCommitCallback("Phantom Checkbox Ctrl",onCommitPhantom,this);
 
-	// PhysicsShapeType combobox
-	mComboPhysicsShapeType = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
-	childSetCommitCallback("Physics Shape Type Combo Ctrl", onCommitPhysicsShapeType,this);
+	// PhysicsRep combobox
+	mComboPhysicsRep = getChild<LLComboBox>("Physics Rep Combo Ctrl");
+	childSetCommitCallback("Physics Rep Combo Ctrl", onCommitPhysicsRep,this);
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -324,7 +324,7 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
-	mPhysicsShapeType(0),
+	mPhysicsRep(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -532,9 +532,9 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
-	mPhysicsShapeType = objectp->getPhysicsShapeType();
-	mComboPhysicsShapeType->setCurrentByIndex(mPhysicsShapeType);
-	mComboPhysicsShapeType->setEnabled(editable);
+	mPhysicsRep = objectp->getPhysicsRep();
+	mComboPhysicsRep->setCurrentByIndex(mPhysicsRep);
+	mComboPhysicsRep->setEnabled(editable);
 
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
@@ -1241,19 +1241,19 @@ void LLPanelObject::sendIsPhantom()
 	}
 }
 
-void LLPanelObject::sendPhysicsShapeType()
+void LLPanelObject::sendPhysicsRep()
 {
-	U8 value = (U8)mComboPhysicsShapeType->getCurrentIndex();
-	if (mPhysicsShapeType != value)
+	U8 value = (U8)mComboPhysicsRep->getCurrentIndex();
+	if (mPhysicsRep != value)
 	{
-		LLSelectMgr::getInstance()->selectionUpdatePhysicsShapeType(value);
-		mPhysicsShapeType = value;
+		LLSelectMgr::getInstance()->selectionUpdatePhysicsRep(value);
+		mPhysicsRep = value;
 		
-		llinfos << "update physics shape type sent" << llendl;
+		llinfos << "update physicsrep sent" << llendl;
 	}
 	else
 	{
-		llinfos << "update physics shape type not changed" << llendl;
+		llinfos << "update physicstep not changed" << llendl;
 	}
 }
 
@@ -1930,8 +1930,8 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
-	mComboPhysicsShapeType->setCurrentByIndex(0);
-	mComboPhysicsShapeType->setEnabled(FALSE);
+	mComboPhysicsRep->setCurrentByIndex(0);
+	mComboPhysicsRep->setEnabled(FALSE);
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
@@ -2027,10 +2027,10 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 }
 
 // static
-void LLPanelObject::onCommitPhysicsShapeType(LLUICtrl* ctrl, void* userdata )
+void LLPanelObject::onCommitPhysicsRep(LLUICtrl* ctrl, void* userdata )
 {
 	LLPanelObject* self = (LLPanelObject*) userdata;
-	self->sendPhysicsShapeType();
+	self->sendPhysicsRep();
 }
 
 // static
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index 7f368c38c70..fbc09021415 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -65,14 +65,14 @@ class LLPanelObject : public LLPanel
 	static bool		precommitValidate(const LLSD& data);
 	
 	static void		onCommitLock(LLUICtrl *ctrl, void *data);
-	static void 	onCommitPosition(			LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitScale(				LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitRotation(			LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitPhysics(			LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitTemporary(			LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitPhantom(			LLUICtrl* ctrl, void* userdata);
-	static void     onCommitPhysicsShapeType(   LLUICtrl* ctrl, void* userdata);
-	static void 	onCommitCastShadows(		LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPosition(		LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitScale(			LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitRotation(		LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPhysics(		LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitTemporary(		LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitPhantom(		LLUICtrl* ctrl, void* userdata);
+	static void     onCommitPhysicsRep(     LLUICtrl* ctrl, void* userdata);
+	static void 	onCommitCastShadows(	LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
 
@@ -94,7 +94,7 @@ class LLPanelObject : public LLPanel
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
-	void            sendPhysicsShapeType();
+	void            sendPhysicsRep();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -167,7 +167,7 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
-	LLComboBox      *mComboPhysicsShapeType;
+	LLComboBox      *mComboPhysicsRep;
 	LLCheckBoxCtrl	*mCheckCastShadows;
 	
 	LLTextureCtrl   *mCtrlSculptTexture;
@@ -180,7 +180,7 @@ class LLPanelObject : public LLPanel
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
 	BOOL			mIsTemporary;			// to avoid sending "temporary" when not changed
 	BOOL			mIsPhantom;				// to avoid sending "phantom" when not changed
-	U8              mPhysicsShapeType;		// to avoid sending "physics shape type" when not changed
+	U8              mPhysicsRep;			// to avoid sending "physics rep spec" when not changed
 	BOOL			mCastShadows;			// to avoid sending "cast shadows" when not changed
 	S32				mSelectedType;			// So we know what selected type we last were
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index d47cc06ebce..d15017e0a19 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3931,15 +3931,15 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
-struct LLSelectMgrApplyPhysicsShapeType : public LLSelectedObjectFunctor
+struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
 {
-	LLSelectMgrApplyPhysicsShapeType(U8 value) : mValue(value) {}
+	LLSelectMgrApplyPhysicsRep(U8 value) : mValue(value) {}
 	U8 mValue;
 	virtual bool apply(LLViewerObject* object)
 	{
 		if ( object->permModify() ) 	// preemptive permissions check
 		{
-			object->setPhysicsShapeType( mValue );
+			object->setPhysicsRep( mValue );
 			object->updateFlags();
 		}
 		return true;
@@ -3947,10 +3947,10 @@ struct LLSelectMgrApplyPhysicsShapeType : public LLSelectedObjectFunctor
 };
 
 
-void LLSelectMgr::selectionUpdatePhysicsShapeType(U8 type)
+void LLSelectMgr::selectionUpdatePhysicsRep(U8 rep)
 {
-	llwarns << "physics shape type ->" << (U32)type << llendl;
-	LLSelectMgrApplyPhysicsShapeType func(type);
+	llwarns << "physics rep ->" << (U32)rep << llendl;
+	LLSelectMgrApplyPhysicsRep func(rep);
 	getSelection()->applyToObjects(&func);	
 }
 
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 544b1ff594e..27e0c5dfa9d 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -483,7 +483,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void selectionUpdatePhysics(BOOL use_physics);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
-	void selectionUpdatePhysicsShapeType(U8 type);
+	void selectionUpdatePhysicsRep(U8 rep);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 7b94e49a2a2..f18fee3edec 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -53,7 +53,6 @@
 #include "llprimitive.h"
 #include "llquantize.h"
 #include "llregionhandle.h"
-#include "llsdserialize.h"
 #include "lltree_common.h"
 #include "llxfermanager.h"
 #include "message.h"
@@ -200,7 +199,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mGLName(0),
 	mbCanSelect(TRUE),
 	mFlags(0),
-	mPhysicsShapeType(0),
+	mPhysicsRep(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -4964,10 +4963,10 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("IsPhantom", flagPhantom() );
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
 	gMessageSystem->nextBlock("ExtraPhysics");
-	gMessageSystem->addU8("PhysicsShapeType", getPhysicsShapeType() );
+	gMessageSystem->addU8("PhysicsRep", getPhysicsRep() );
 	gMessageSystem->sendReliable( regionp->getHost() );
 
-	if (getPhysicsShapeType() != 0)
+	if (getPhysicsRep() != 0)
 	{
 		llwarns << "sent non default physics rep" << llendl;
 	}
@@ -5002,9 +5001,9 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 	return setit;
 }
 
-void LLViewerObject::setPhysicsShapeType(U8 type)
+void LLViewerObject::setPhysicsRep(U8 rep)
 {
-	mPhysicsShapeType = type;
+	mPhysicsRep = rep;
 	updateFlags();
 }
 
@@ -5218,7 +5217,7 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
 
 	return ;
 }
-
+#include "../llcommon/llsdserialize.h"
 class ObjectPhysicsProperties : public LLHTTPNode
 {
 public:
@@ -5232,8 +5231,11 @@ class ObjectPhysicsProperties : public LLHTTPNode
 		
 		for ( S32 i = 0; i < numEntries; i++ )
 		{
-			LLSD& currObjectData = objectData[i];
-			U32 localID = currObjectData["LocalID"].asInteger();
+			U32 localID = objectData[i]["LocalID"].asInteger();
+
+			std::ostringstream string;
+			LLSDSerialize::serialize( input, string, LLSDSerialize::LLSD_XML, LLSDFormatter::OPTIONS_PRETTY);
+			llinfos << string.str() << llendl;
 
 			// Iterate through nodes at end, since it can be on both the regular AND hover list
 			struct f : public LLSelectedNodeFunctor
@@ -5248,12 +5250,11 @@ class ObjectPhysicsProperties : public LLHTTPNode
 
 			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
 
+			U8 physicsRepSpec = (U8)objectData[i]["PhysicsRepSpec"].asInteger();
+
 			if (node)
 			{
-				// The LLSD message builder doesn't know how to handle U8, so we need to send as S8 and cast
-				U8 physicsShapeType = (U8)currObjectData["PhysicsShapeType"].asInteger();
-
-				node->getObject()->setPhysicsShapeType(physicsShapeType);
+				node->getObject()->setPhysicsRep(physicsRepSpec);
 			}	
 		}
 		
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index de7bfc0e07b..49709d643a7 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -459,7 +459,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	inline BOOL		flagCameraDecoupled() const		{ return ((mFlags & FLAGS_CAMERA_DECOUPLED) != 0); }
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
-	inline U8       getPhysicsShapeType() const     { return mPhysicsShapeType; }
+	inline U8       getPhysicsRep() const           { return mPhysicsRep; }
 	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
@@ -476,7 +476,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
-	void setPhysicsShapeType(U8 type);
+	void setPhysicsRep(U8 rep);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -557,7 +557,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	U32				mFlags;
 
 	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
-	U8              mPhysicsShapeType;
+	U8              mPhysicsRep;
 
 	// Pipeline classes
 	LLPointer<LLDrawable> mDrawable;
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index b987cd91083..3bb8e9c0554 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1425,7 +1425,7 @@ even though the user gets a free copy.
              height="10"
              layout="topleft"
              left_delta="0"
-             name="label physicsshapetype"
+             name="label physicsrep"
              top_pad="10"
              width="121">
                 Physics Rep:
@@ -1434,18 +1434,18 @@ even though the user gets a free copy.
 			   height="23"
 			   layout="topleft"
 			   follows="left|top"
-			   name="Physics Shape Type Combo Ctrl"
-			   tool_tip="Choose the physics shape type"
+			   name="Physics Rep Combo Ctrl"
+			   tool_tip="Choose the physics representation"
 			   left_pad="0"
 			   width="108">
 			  <combo_box.item
-				 label="Prim"
-				 name="Prim"
-				 value="Prim" />
+				 label="Default"
+				 name="Default"
+				 value="Default" />
 			  <combo_box.item
-				 label="None"
-				 name="None"
-				 value="None" />
+				 label="No Shape"
+				 name="No Shape"
+				 value="No Shape" />
 			  <combo_box.item
 				 label="Convex Hull"
 				 name="Convex Hull"
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 6043542877a..7813bfba833 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2063,7 +2063,7 @@ version 2.0
 	}
     {
 		ExtraPhysics        Variable
-		{   PhysicsShapeType U8     }
+		{   PhysicsRep      U8      }
 	}
 }
 
-- 
GitLab


From 9226d42d12b9edb792d65b28254c633d0dc64edc Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 21:40:38 +0100
Subject: [PATCH 345/683] Backed out changeset 78dddb3a1dd3

---
 etc/message.xml                               |  7 ---
 indra/newview/llpanelobject.cpp               | 34 -----------
 indra/newview/llpanelobject.h                 |  6 +-
 indra/newview/llselectmgr.cpp                 | 23 +------
 indra/newview/llselectmgr.h                   |  1 -
 indra/newview/llviewerobject.cpp              | 60 -------------------
 indra/newview/llviewerobject.h                |  6 --
 .../skins/default/xui/en/floater_tools.xml    | 33 ----------
 scripts/messages/message_template.msg         |  4 --
 9 files changed, 2 insertions(+), 172 deletions(-)

diff --git a/etc/message.xml b/etc/message.xml
index 7283d903b9a..c17ae3656d0 100644
--- a/etc/message.xml
+++ b/etc/message.xml
@@ -572,13 +572,6 @@
 					<boolean>false</boolean>
 				</map>
 
-				<key>ObjectPhysicsProperties</key>
-				<map>
-					<key>flavor</key>
-					<string>llsd</string>
-					<key>trusted-sender</key>
-					<boolean>true</boolean>
-				</map>
 
 		  </map>
   	  	<key>capBans</key>
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 991e97b767e..30221da12a8 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -137,10 +137,6 @@ BOOL	LLPanelObject::postBuild()
 	// Phantom checkbox
 	mCheckPhantom = getChild<LLCheckBoxCtrl>("Phantom Checkbox Ctrl");
 	childSetCommitCallback("Phantom Checkbox Ctrl",onCommitPhantom,this);
-
-	// PhysicsRep combobox
-	mComboPhysicsRep = getChild<LLComboBox>("Physics Rep Combo Ctrl");
-	childSetCommitCallback("Physics Rep Combo Ctrl", onCommitPhysicsRep,this);
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -324,7 +320,6 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
-	mPhysicsRep(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -532,10 +527,6 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
-	mPhysicsRep = objectp->getPhysicsRep();
-	mComboPhysicsRep->setCurrentByIndex(mPhysicsRep);
-	mComboPhysicsRep->setEnabled(editable);
-
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
 	mCheckCastShadows->set( mCastShadows );
@@ -1241,22 +1232,6 @@ void LLPanelObject::sendIsPhantom()
 	}
 }
 
-void LLPanelObject::sendPhysicsRep()
-{
-	U8 value = (U8)mComboPhysicsRep->getCurrentIndex();
-	if (mPhysicsRep != value)
-	{
-		LLSelectMgr::getInstance()->selectionUpdatePhysicsRep(value);
-		mPhysicsRep = value;
-		
-		llinfos << "update physicsrep sent" << llendl;
-	}
-	else
-	{
-		llinfos << "update physicstep not changed" << llendl;
-	}
-}
-
 void LLPanelObject::sendCastShadows()
 {
 	BOOL value = mCheckCastShadows->get();
@@ -1930,8 +1905,6 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
-	mComboPhysicsRep->setCurrentByIndex(0);
-	mComboPhysicsRep->setEnabled(FALSE);
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
@@ -2026,13 +1999,6 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 	self->sendIsPhantom();
 }
 
-// static
-void LLPanelObject::onCommitPhysicsRep(LLUICtrl* ctrl, void* userdata )
-{
-	LLPanelObject* self = (LLPanelObject*) userdata;
-	self->sendPhysicsRep();
-}
-
 // static
 void LLPanelObject::onCommitCastShadows( LLUICtrl* ctrl, void* userdata )
 {
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index fbc09021415..58d9fe9b76e 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -71,7 +71,6 @@ class LLPanelObject : public LLPanel
 	static void 	onCommitPhysics(		LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitTemporary(		LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitPhantom(		LLUICtrl* ctrl, void* userdata);
-	static void     onCommitPhysicsRep(     LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitCastShadows(	LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
@@ -94,7 +93,6 @@ class LLPanelObject : public LLPanel
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
-	void            sendPhysicsRep();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -167,9 +165,8 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
-	LLComboBox      *mComboPhysicsRep;
 	LLCheckBoxCtrl	*mCheckCastShadows;
-	
+
 	LLTextureCtrl   *mCtrlSculptTexture;
 	LLTextBox       *mLabelSculptType;
 	LLComboBox      *mCtrlSculptType;
@@ -180,7 +177,6 @@ class LLPanelObject : public LLPanel
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
 	BOOL			mIsTemporary;			// to avoid sending "temporary" when not changed
 	BOOL			mIsPhantom;				// to avoid sending "phantom" when not changed
-	U8              mPhysicsRep;			// to avoid sending "physics rep spec" when not changed
 	BOOL			mCastShadows;			// to avoid sending "cast shadows" when not changed
 	S32				mSelectedType;			// So we know what selected type we last were
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index d15017e0a19..d03a492cd10 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3931,28 +3931,6 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
-struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
-{
-	LLSelectMgrApplyPhysicsRep(U8 value) : mValue(value) {}
-	U8 mValue;
-	virtual bool apply(LLViewerObject* object)
-	{
-		if ( object->permModify() ) 	// preemptive permissions check
-		{
-			object->setPhysicsRep( mValue );
-			object->updateFlags();
-		}
-		return true;
-	}
-};
-
-
-void LLSelectMgr::selectionUpdatePhysicsRep(U8 rep)
-{
-	llwarns << "physics rep ->" << (U32)rep << llendl;
-	LLSelectMgrApplyPhysicsRep func(rep);
-	getSelection()->applyToObjects(&func);	
-}
 
 //----------------------------------------------------------------------
 // Helpful packing functions for sendObjectMessage()
@@ -4642,6 +4620,7 @@ void LLSelectMgr::processForceObjectSelect(LLMessageSystem* msg, void**)
 	LLSelectMgr::getInstance()->highlightObjectAndFamily(objects);
 }
 
+
 extern LLGLdouble	gGLModelView[16];
 
 void LLSelectMgr::updateSilhouettes()
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 27e0c5dfa9d..d315f40ff3b 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -483,7 +483,6 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void selectionUpdatePhysics(BOOL use_physics);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
-	void selectionUpdatePhysicsRep(U8 rep);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index f18fee3edec..bb7933c10e8 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -199,7 +199,6 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mGLName(0),
 	mbCanSelect(TRUE),
 	mFlags(0),
-	mPhysicsRep(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -4962,14 +4961,7 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("IsTemporary", flagTemporaryOnRez() );
 	gMessageSystem->addBOOL("IsPhantom", flagPhantom() );
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
-	gMessageSystem->nextBlock("ExtraPhysics");
-	gMessageSystem->addU8("PhysicsRep", getPhysicsRep() );
 	gMessageSystem->sendReliable( regionp->getHost() );
-
-	if (getPhysicsRep() != 0)
-	{
-		llwarns << "sent non default physics rep" << llendl;
-	}
 }
 
 BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
@@ -5001,12 +4993,6 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 	return setit;
 }
 
-void LLViewerObject::setPhysicsRep(U8 rep)
-{
-	mPhysicsRep = rep;
-	updateFlags();
-}
-
 void LLViewerObject::applyAngularVelocity(F32 dt)
 {
 	//do target omega here
@@ -5217,50 +5203,4 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
 
 	return ;
 }
-#include "../llcommon/llsdserialize.h"
-class ObjectPhysicsProperties : public LLHTTPNode
-{
-public:
-	virtual void post(
-		ResponsePtr responder,
-		const LLSD& context,
-		const LLSD& input) const
-	{
-		LLSD objectData = input["body"]["ObjectData"];
-		S32 numEntries = objectData.size();
-		
-		for ( S32 i = 0; i < numEntries; i++ )
-		{
-			U32 localID = objectData[i]["LocalID"].asInteger();
-
-			std::ostringstream string;
-			LLSDSerialize::serialize( input, string, LLSDSerialize::LLSD_XML, LLSDFormatter::OPTIONS_PRETTY);
-			llinfos << string.str() << llendl;
-
-			// Iterate through nodes at end, since it can be on both the regular AND hover list
-			struct f : public LLSelectedNodeFunctor
-			{
-				U32 mID;
-				f(const U32& id) : mID(id) {}
-				virtual bool apply(LLSelectNode* node)
-				{
-					return (node->getObject() && node->getObject()->mLocalID == mID );
-				}
-			} func(localID);
-
-			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
-
-			U8 physicsRepSpec = (U8)objectData[i]["PhysicsRepSpec"].asInteger();
-
-			if (node)
-			{
-				node->getObject()->setPhysicsRep(physicsRepSpec);
-			}	
-		}
-		
-	};
-};
-
-LLHTTPRegistration<ObjectPhysicsProperties>
-	gHTTPRegistrationObjectPhysicsProperties("/message/ObjectPhysicsProperties");
 
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 49709d643a7..be83fb7ef8a 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -459,8 +459,6 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	inline BOOL		flagCameraDecoupled() const		{ return ((mFlags & FLAGS_CAMERA_DECOUPLED) != 0); }
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
-	inline U8       getPhysicsRep() const           { return mPhysicsRep; }
-	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
 
@@ -476,7 +474,6 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
-	void setPhysicsRep(U8 rep);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -556,9 +553,6 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	// Grabbed from UPDATE_FLAGS
 	U32				mFlags;
 
-	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
-	U8              mPhysicsRep;
-
 	// Pipeline classes
 	LLPointer<LLDrawable> mDrawable;
 
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index 3bb8e9c0554..cc9e72cfb58 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1418,39 +1418,6 @@ even though the user gets a free copy.
              text_enabled_color="1 1 1 1"
              top_pad="3"
              width="87" />
-            <text
-             type="string"
-             length="1"
-             follows="left|top"
-             height="10"
-             layout="topleft"
-             left_delta="0"
-             name="label physicsrep"
-             top_pad="10"
-             width="121">
-                Physics Rep:
-            </text>
-			<combo_box
-			   height="23"
-			   layout="topleft"
-			   follows="left|top"
-			   name="Physics Rep Combo Ctrl"
-			   tool_tip="Choose the physics representation"
-			   left_pad="0"
-			   width="108">
-			  <combo_box.item
-				 label="Default"
-				 name="Default"
-				 value="Default" />
-			  <combo_box.item
-				 label="No Shape"
-				 name="No Shape"
-				 value="No Shape" />
-			  <combo_box.item
-				 label="Convex Hull"
-				 name="Convex Hull"
-				 value="Convex Hull" />
-			</combo_box>
 
  <!--           <text
              type="string"
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 7813bfba833..d4f791c202b 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2061,10 +2061,6 @@ version 2.0
 		{	IsPhantom		BOOL	}
 		{	CastsShadows	BOOL	}
 	}
-    {
-		ExtraPhysics        Variable
-		{   PhysicsRep      U8      }
-	}
 }
 
 
-- 
GitLab


From 473df1559015de6d72a18cb12958e68fb438f2ac Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 22 Apr 2010 21:33:10 +0100
Subject: [PATCH 346/683] ssreflections: dampen/blur ssreflections rather more.
 (transplanted from 4c4ae8d8f0795244fda258c157177e2778bfc444)

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl    | 3 ++-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl    | 3 ++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl    | 4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 01d18cdcde6..bf5dd4155c2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -299,7 +299,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5);
 		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
@@ -324,6 +324,7 @@ void main()
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
+		ssshiny *= 0.3; // dampen it even more
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 2982cd3e09c..28cfc6322e0 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -298,7 +298,7 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5);
 		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
@@ -324,6 +324,7 @@ void main()
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
+		ssshiny *= 0.3; // dampen it even more
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index e1e035411bd..9f94b9e8eaa 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -301,7 +301,8 @@ void main()
 		// The goal of the blur is to soften reflections in surfaces
 		// with low shinyness, and also to disguise our lameness.
 		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
-		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5);
+		float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5);
+
 		ref2d += vec2(checkoffset, checkoffset);
 		ref2d += tc.xy; // use as offset from destination
 		// Get attributes from the 2D guess point.
@@ -327,6 +328,7 @@ void main()
 		float refmod = min(refapprop, reflit);
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
+		ssshiny *= 0.3; // dampen it even more
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
-- 
GitLab


From bd216c96498585ca01e1634877d4b184f20fa45f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 22 Apr 2010 16:52:05 -0500
Subject: [PATCH 347/683] Fix for shadows from skyboxes hitting the ground.

---
 indra/llmath/llcamera.h    |  2 +-
 indra/newview/pipeline.cpp | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
index 0c81067919a..d6c5f7bbb14 100644
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -143,7 +143,7 @@ class LLCamera
 public:
 	LLVector3 mAgentFrustum[8];  //8 corners of 6-plane frustum
 	F32	mFrustumCornerDist;		//distance to corner of frustum against far clip plane
-	LLPlane getAgentPlane(U32 idx) { return mAgentPlanes[idx].p; }
+	LLPlane& getAgentPlane(U32 idx) { return mAgentPlanes[idx].p; }
 
 public:
 	LLCamera();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index a36f6831c36..5a173d8460f 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8118,6 +8118,14 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 	LLVector3 n = gSavedSettings.getVector3("RenderShadowNearDist");
 	//F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] };
 
+	//put together a universal "near clip" plane for shadow frusta
+	LLPlane shadow_near_clip;
+	{
+		LLVector3 p = gAgent.getPositionAgent();
+		p += mSunDir * gSavedSettings.getF32("RenderFarClip")*2.f;
+		shadow_near_clip.setVec(p, mSunDir);
+	}
+
 	LLVector3 lightDir = -mSunDir;
 	lightDir.normVec();
 
@@ -8551,7 +8559,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 
 		LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
 
-		shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR);
+		//shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR);
+		shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_clip);
 
 		//translate and scale to from [-1, 1] to [0, 1]
 		glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f,
-- 
GitLab


From 5715a9269b66de59ee59637fbb09e9430bfb244f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 22 Apr 2010 23:16:39 -0500
Subject: [PATCH 348/683] Fix for broken shader loading behavior when Debug GL
 enabled.

---
 indra/llrender/llshadermgr.cpp     | 29 +++++++++++++++++------------
 indra/newview/lldrawpoolavatar.cpp | 13 ++++++++++++-
 2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 8fc7163b83f..17fc7fe1204 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -391,26 +391,31 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 			LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << LL_ENDL;
 		}
 	}
-	else
+	
+	//load source
+	glShaderSourceARB(ret, count, (const GLcharARB**) text, NULL);
+
+	if (gDebugGL)
 	{
-		//load source
-		glShaderSourceARB(ret, count, (const GLcharARB**) text, NULL);
 		error = glGetError();
 		if (error != GL_NO_ERROR)
 		{
 			LL_WARNS("ShaderLoading") << "GL ERROR in glShaderSourceARB: " << error << LL_ENDL;
 		}
-		else
+	}
+
+	//compile source
+	glCompileShaderARB(ret);
+
+	if (gDebugGL)
+	{
+		error = glGetError();
+		if (error != GL_NO_ERROR)
 		{
-			//compile source
-			glCompileShaderARB(ret);
-			error = glGetError();
-			if (error != GL_NO_ERROR)
-			{
-				LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShaderARB: " << error << LL_ENDL;
-			}
+			LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShaderARB: " << error << LL_ENDL;
 		}
 	}
+		
 	//free memory
 	for (GLuint i = 0; i < count; i++)
 	{
@@ -421,7 +426,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		//check for errors
 		GLint success = GL_TRUE;
 		glGetObjectParameterivARB(ret, GL_OBJECT_COMPILE_STATUS_ARB, &success);
-		if (gDebugGL)
+		if (gDebugGL || success == GL_FALSE)
 		{
 			error = glGetError();
 			if (error != GL_NO_ERROR || success == GL_FALSE) 
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 4b7de971017..62226383a4b 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -352,7 +352,18 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 
 S32 LLDrawPoolAvatar::getNumPasses()
 {
-	return LLPipeline::sImpostorRender ? 1 : 4;
+	if (LLPipeline::sImpostorRender)
+	{
+		return 1;
+	}
+	else if (getVertexShaderLevel() > 0)
+	{
+		return 4;
+	}
+	else
+	{
+		return 3;
+	}
 }
 
 void LLDrawPoolAvatar::render(S32 pass)
-- 
GitLab


From 95ca4315e3791fd9748edb5fe0d76719de6854ae Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 23 Apr 2010 00:38:10 -0500
Subject: [PATCH 349/683] Fix for stupid shader loading mistake.

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

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 17fc7fe1204..0f54ebeb690 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -321,7 +321,7 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns)
 
 GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type)
 {
-	GLenum error;
+	GLenum error = GL_NO_ERROR;
 	if (gDebugGL)
 	{
 		error = glGetError();
-- 
GitLab


From 77155500ede52d09ef69dbf6c8d3e505d02485f7 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 23 Apr 2010 13:37:03 +0100
Subject: [PATCH 350/683] Restore a bit of the non-deferred renderer's sun/moon
 waterglow in deferred rendering.  This also adds a slight pinch of glow to
 shiny sun-spots.  So be it. (transplanted from
 5a0d9e5b5cfb2ecd96685f0275ab8e999ab86263) (transplanted from
 90f0ce75b2d7bb9fc03e84245db27a16508cde63)

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl    | 4 +++-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl    | 4 +++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl    | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index bf5dd4155c2..65540ad6fe9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -270,6 +270,7 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
+	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -285,6 +286,7 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -334,5 +336,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	gl_FragColor.a = 0.0;
+	gl_FragColor.a = glowresult;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 28cfc6322e0..67ef3d52807 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -269,6 +269,7 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
+	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -284,6 +285,7 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -334,5 +336,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	gl_FragColor.a = 0.0;
+	gl_FragColor.a = glowresult;
 }
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 9f94b9e8eaa..b5c6693d3b6 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -272,6 +272,7 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
+	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -287,6 +288,7 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -340,7 +342,7 @@ void main()
 	gl_FragColor.rgb = col;
 	
 	//gl_FragColor.rgb = gi_col.rgb;
-	gl_FragColor.a = 0.0;
+	gl_FragColor.a = glowresult;
 	
 	//gl_FragColor.rg = scol_ambocc.rg;
 	//gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb;
-- 
GitLab


From f972cc4be952abc943f9d289533c9951ce4dc839 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 23 Apr 2010 13:37:03 +0100
Subject: [PATCH 351/683] Restore a bit of the non-deferred renderer's sun/moon
 waterglow in deferred rendering.  This also adds a slight pinch of glow to
 shiny sun-spots.  So be it. (transplanted from
 5a0d9e5b5cfb2ecd96685f0275ab8e999ab86263)

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl    | 4 +++-
 .../app_settings/shaders/class2/deferred/softenLightF.glsl    | 4 +++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl    | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index bf5dd4155c2..65540ad6fe9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -270,6 +270,7 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
+	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -285,6 +286,7 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -334,5 +336,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	gl_FragColor.a = 0.0;
+	gl_FragColor.a = glowresult;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 28cfc6322e0..67ef3d52807 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -269,6 +269,7 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
+	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -284,6 +285,7 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -334,5 +336,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	gl_FragColor.a = 0.0;
+	gl_FragColor.a = glowresult;
 }
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 9f94b9e8eaa..b5c6693d3b6 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -272,6 +272,7 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
+	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -287,6 +288,7 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
+		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -340,7 +342,7 @@ void main()
 	gl_FragColor.rgb = col;
 	
 	//gl_FragColor.rgb = gi_col.rgb;
-	gl_FragColor.a = 0.0;
+	gl_FragColor.a = glowresult;
 	
 	//gl_FragColor.rg = scol_ambocc.rg;
 	//gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb;
-- 
GitLab


From ef925261ae69b71189b0df759e6f155a38a3a8f7 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 23 Apr 2010 17:35:26 +0100
Subject: [PATCH 352/683] Backed out changeset b379d162769e

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl    | 4 +---
 .../app_settings/shaders/class2/deferred/softenLightF.glsl    | 4 +---
 .../app_settings/shaders/class3/deferred/softenLightF.glsl    | 4 +---
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 65540ad6fe9..bf5dd4155c2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -270,7 +270,6 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
-	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -286,7 +285,6 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
-		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -336,5 +334,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	gl_FragColor.a = glowresult;
+	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 67ef3d52807..28cfc6322e0 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -269,7 +269,6 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
-	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -285,7 +284,6 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
-		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -336,5 +334,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	gl_FragColor.a = glowresult;
+	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index b5c6693d3b6..9f94b9e8eaa 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -272,7 +272,6 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
-	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -288,7 +287,6 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
-		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -342,7 +340,7 @@ void main()
 	gl_FragColor.rgb = col;
 	
 	//gl_FragColor.rgb = gi_col.rgb;
-	gl_FragColor.a = glowresult;
+	gl_FragColor.a = 0.0;
 	
 	//gl_FragColor.rg = scol_ambocc.rg;
 	//gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb;
-- 
GitLab


From f313196363085de2eb8f3a4fd33abeb5617204c4 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 23 Apr 2010 17:35:32 +0100
Subject: [PATCH 353/683] Backed out changeset 90f0ce75b2d7

---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl    | 4 +---
 .../app_settings/shaders/class2/deferred/softenLightF.glsl    | 4 +---
 .../app_settings/shaders/class3/deferred/softenLightF.glsl    | 4 +---
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 65540ad6fe9..bf5dd4155c2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -270,7 +270,6 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
-	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -286,7 +285,6 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
-		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -336,5 +334,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	gl_FragColor.a = glowresult;
+	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 67ef3d52807..28cfc6322e0 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -269,7 +269,6 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
-	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -285,7 +284,6 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
-		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -336,5 +334,5 @@ void main()
 	col = scaleSoftClip(col);
 		
 	gl_FragColor.rgb = col;
-	gl_FragColor.a = glowresult;
+	gl_FragColor.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index b5c6693d3b6..9f94b9e8eaa 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -272,7 +272,6 @@ void main()
 	vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 	float scol = max(scol_ambocc.r, diffuse.a); 
 	float ambocc = scol_ambocc.g;
-	float glowresult = 0.0;
 	
 	calcAtmospherics(pos.xyz, ambocc);
 	
@@ -288,7 +287,6 @@ void main()
 		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
-		glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb);
 
 		// screen-space cheap fakey reflection map
 		//
@@ -342,7 +340,7 @@ void main()
 	gl_FragColor.rgb = col;
 	
 	//gl_FragColor.rgb = gi_col.rgb;
-	gl_FragColor.a = glowresult;
+	gl_FragColor.a = 0.0;
 	
 	//gl_FragColor.rg = scol_ambocc.rg;
 	//gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb;
-- 
GitLab


From d6acc0f0c69195c2ac51d12145a180a42f8c69bb Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 23 Apr 2010 17:40:10 +0100
Subject: [PATCH 354/683] Backed out changeset 211aeed4e8f4 backing out
 "Switching to 10.5 SDK"

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

diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index 9b1f7024bfd..db0b44eb8f0 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -79,7 +79,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   # NOTE: wont have a distributable build unless you add this on the configure line with:
   # -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc'
   #set(CMAKE_OSX_ARCHITECTURES i386;ppc)
-  set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
+  set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk)
   if (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
     set(ARCH universal)
   else (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
-- 
GitLab


From 0655104fa2339fd0b8e5a0385e5a1d8141834a88 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 26 Apr 2010 14:42:06 +0100
Subject: [PATCH 355/683] EXT-7060 default auto alpha masking to ON for
 deferred rendering (only deferred rendering) (transplanted from
 050ae2c9451a6b89374c5a10403f373e2475f23b)

---
 indra/newview/app_settings/settings.xml       | 15 ++++++-
 indra/newview/lldrawpoolalpha.cpp             |  2 +-
 indra/newview/llface.cpp                      | 20 ++++++++++
 indra/newview/llface.h                        | 40 +++++++++++--------
 indra/newview/llspatialpartition.h            |  2 -
 indra/newview/llviewercontrol.cpp             |  3 +-
 indra/newview/llviewerdisplay.cpp             |  3 +-
 indra/newview/llvovolume.cpp                  | 21 ++--------
 indra/newview/pipeline.cpp                    |  3 +-
 indra/newview/pipeline.h                      |  3 +-
 .../skins/default/xui/en/menu_viewer.xml      | 18 +++++++--
 11 files changed, 82 insertions(+), 48 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 43e7f1c06c9..5014ba33499 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6973,10 +6973,10 @@
       <key>Value</key>
       <real>256.0</real>
     </map>
-    <key>RenderFastAlpha</key>
+    <key>RenderAutoMaskAlphaNonDeferred</key>
     <map>
       <key>Comment</key>
-      <string>Use lossy alpha rendering optimization (opaque/nonexistent small alpha faces).</string>
+      <string>Use alpha masks where appropriate, in the non-deferred (non-'Lighting and Shadows') graphics mode</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -6984,6 +6984,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>RenderAutoMaskAlphaDeferred</key>
+    <map>
+      <key>Comment</key>
+      <string>Use alpha masks where appropriate, in the deferred ('Lighting and Shadows') graphics mode</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>1</integer>
+    </map>
     <key>RenderFastUI</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 7fd7cd3910b..def463cb416 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -182,7 +182,7 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 	gGL.setColorMask(true, true);
 
-	if (LLPipeline::sFastAlpha && !deferred_render)
+	if (LLPipeline::sAutoMaskAlphaNonDeferred && !deferred_render)
 	{
 		mColorSFactor = LLRender::BF_ONE;  // }
 		mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 8d86070bdf9..f6932b0e680 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -862,6 +862,26 @@ void LLFace::updateRebuildFlags()
 	}
 }
 
+
+bool LLFace::canRenderAsMask()
+{
+	const LLTextureEntry* te = getTextureEntry();
+	return (
+		(
+		 (LLPipeline::sRenderDeferred && LLPipeline::sAutoMaskAlphaDeferred) ||
+		 
+		 (!LLPipeline::sRenderDeferred && LLPipeline::sAutoMaskAlphaNonDeferred)		 
+		 ) // do we want masks at all?
+		&&
+		(te->getColor().mV[3] == 1.0f) && // can't treat as mask if we have face alpha
+		!(LLPipeline::sRenderDeferred && te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible in deferred rendering mode, need to figure out why - for now, avoid
+		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
+
+		getTexture()->getIsAlphaMask() // texture actually qualifies for masking (lazily recalculated but expensive)
+		);
+}
+
+
 static LLFastTimer::DeclareTimer FTM_FACE_GET_GEOM("Face Geom");
 
 BOOL LLFace::getGeometryVolume(const LLVolume& volume,
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 351d48a6719..02cc2af4336 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -2,25 +2,31 @@
  * @file llface.h
  * @brief LLFace class definition
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -132,10 +138,10 @@ class LLFace
 	void			unsetFaceColor(); // switch back to material color
 	const LLColor4&	getFaceColor() const { return mFaceColor; } 
 	const LLColor4& getRenderColor() const;
-	
 
 	//for volumes
 	void updateRebuildFlags();
+	bool canRenderAsMask(); // logic helper
 	BOOL getGeometryVolume(const LLVolume& volume,
 						const S32 &f,
 						const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
@@ -273,7 +279,7 @@ class LLFace
 	{
 		bool operator()(const LLFace* const& lhs, const LLFace* const& rhs)
 		{
-			return !lhs || (rhs && (lhs->mDistance > rhs->mDistance)); // farthest = first
+			return lhs->mDistance > rhs->mDistance; // farthest = first
 		}
 	};
 	
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 2c09a25e040..19af6a0c38e 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -620,8 +620,6 @@ class LLVolumeGeometryManager: public LLGeometryManager
 	virtual void getGeometry(LLSpatialGroup* group);
 	void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort = FALSE);
 	void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type);
- private:
-	bool canRenderAsMask(LLFace* facep); // logic helper
 };
 
 //spatial partition that uses volume geometry manager (implemented in LLVOVolume.cpp)
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 3fa6b0c8c2c..33fb3d0f0f1 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -532,7 +532,8 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderMaxPartCount")->getSignal()->connect(boost::bind(&handleMaxPartCountChanged, _2));
 	gSavedSettings.getControl("RenderDynamicLOD")->getSignal()->connect(boost::bind(&handleRenderDynamicLODChanged, _2));
 	gSavedSettings.getControl("RenderDebugTextureBind")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
-	gSavedSettings.getControl("RenderFastAlpha")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
+	gSavedSettings.getControl("RenderAutoMaskAlphaDeferred")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
+	gSavedSettings.getControl("RenderAutoMaskAlphaNonDeferred")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderObjectBump")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderMaxVBOSize")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderUseFBO")->getSignal()->connect(boost::bind(&handleRenderUseFBOChanged, _2));
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 8e2e2283bf1..ede5950ecc7 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -596,7 +596,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			LLPipeline::sUseOcclusion = 3;
 		}
 
-		LLPipeline::sFastAlpha = gSavedSettings.getBOOL("RenderFastAlpha");
+		LLPipeline::sAutoMaskAlphaDeferred = gSavedSettings.getBOOL("RenderAutoMaskAlphaDeferred");
+		LLPipeline::sAutoMaskAlphaNonDeferred = gSavedSettings.getBOOL("RenderAutoMaskAlphaNonDeferred");
 		LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip");
 		LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible");
 		LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate");
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 49c0c4d4e02..aa22dc7f5df 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2921,9 +2921,7 @@ F32 LLVOVolume::getBinRadius()
 		{
 			LLFace* face = mDrawable->getFace(i);
 			if (face->getPoolType() == LLDrawPool::POOL_ALPHA &&
-				(!LLPipeline::sFastAlpha || 
-				face->getFaceColor().mV[3] != 1.f ||
-				!face->getTexture()->getIsAlphaMask()))
+			    !face->canRenderAsMask())
 			{
 				alpha_wrap = TRUE;
 				break;
@@ -3296,19 +3294,6 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_VB("Volume");
 static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
-bool LLVolumeGeometryManager::canRenderAsMask(LLFace* facep)
-{
-	const LLTextureEntry* te = facep->getTextureEntry();
-	return (
-		LLPipeline::sFastAlpha && // do we want masks at all?
-
-		(te->getColor().mV[3] == 1.0f) && // can't treat as mask if we have face alpha
-		!(LLPipeline::sRenderDeferred && te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible in deferred rendering mode, need to figure out why - for now, avoid
-		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
-
-		facep->getTexture()->getIsAlphaMask() // texture actually qualifies for masking (lazily calculated but expensive)
-		);
-}
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
@@ -3435,7 +3420,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 				if (type == LLDrawPool::POOL_ALPHA)
 				{
-					if (canRenderAsMask(facep))
+					if (facep->canRenderAsMask())
 					{ //can be treated as alpha mask
 						simple_faces.push_back(facep);
 					}
@@ -3784,7 +3769,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 			if (is_alpha)
 			{
 				// can we safely treat this as an alpha mask?
-				if (canRenderAsMask(facep))
+				if (facep->canRenderAsMask())
 				{
 					if (te->getFullbright())
 					{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 7a9a47feab7..e6b4c5f3ed1 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -269,7 +269,8 @@ BOOL	LLPipeline::sRenderHighlight = TRUE;
 BOOL	LLPipeline::sForceOldBakedUpload = FALSE;
 S32		LLPipeline::sUseOcclusion = 0;
 BOOL	LLPipeline::sDelayVBUpdate = TRUE;
-BOOL	LLPipeline::sFastAlpha = TRUE;
+BOOL	LLPipeline::sAutoMaskAlphaDeferred = TRUE;
+BOOL	LLPipeline::sAutoMaskAlphaNonDeferred = FALSE;
 BOOL	LLPipeline::sDisableShaders = FALSE;
 BOOL	LLPipeline::sRenderBump = TRUE;
 BOOL	LLPipeline::sUseTriStrips = TRUE;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 60e0b0ae8c0..a096a887b08 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -444,7 +444,8 @@ class LLPipeline
 	static BOOL				sForceOldBakedUpload; // If true will not use capabilities to upload baked textures.
 	static S32				sUseOcclusion;  // 0 = no occlusion, 1 = read only, 2 = read/write
 	static BOOL				sDelayVBUpdate;
-	static BOOL				sFastAlpha;
+	static BOOL				sAutoMaskAlphaDeferred;
+	static BOOL				sAutoMaskAlphaNonDeferred;
 	static BOOL				sDisableShaders; // if TRUE, rendering will be done without shaders
 	static BOOL				sRenderBump;
 	static BOOL				sUseTriStrips;
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 3af80f63fe2..cc16194c2da 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2137,14 +2137,24 @@
                  parameter="RenderDebugPipeline" />
             </menu_item_check>
             <menu_item_check
-             label="Fast Alpha"
-             name="Fast Alpha">
+             label="Automatic Alpha Masks (deferred)"
+             name="Automatic Alpha Masks (deferred)">
                 <menu_item_check.on_check
                  function="CheckControl"
-                 parameter="RenderFastAlpha" />
+                 parameter="RenderAutoMaskAlphaDeferred" />
                 <menu_item_check.on_click
                  function="ToggleControl"
-                 parameter="RenderFastAlpha" />
+                 parameter="RenderAutoMaskAlphaDeferred" />
+            </menu_item_check>
+            <menu_item_check
+             label="Automatic Alpha Masks (non-deferred)"
+             name="Automatic Alpha Masks (non-deferred)">
+                <menu_item_check.on_check
+                 function="CheckControl"
+                 parameter="RenderAutoMaskAlphaNonDeferred" />
+                <menu_item_check.on_click
+                 function="ToggleControl"
+                 parameter="RenderAutoMaskAlphaNonDeferred" />
             </menu_item_check>
             <menu_item_check
              label="Animation Textures"
-- 
GitLab


From 64112134be2a4b46c7ade1483e3d968ea1e3e81f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 26 Apr 2010 14:42:06 +0100
Subject: [PATCH 356/683] EXT-7060 default auto alpha masking to ON for
 deferred rendering (only deferred rendering)

---
 indra/newview/app_settings/settings.xml       | 15 +++++++++++--
 indra/newview/lldrawpoolalpha.cpp             |  2 +-
 indra/newview/llface.cpp                      | 20 ++++++++++++++++++
 indra/newview/llface.h                        |  2 +-
 indra/newview/llspatialpartition.h            |  2 --
 indra/newview/llviewercontrol.cpp             |  3 ++-
 indra/newview/llviewerdisplay.cpp             |  3 ++-
 indra/newview/llvovolume.cpp                  | 21 +++----------------
 indra/newview/pipeline.cpp                    |  3 ++-
 indra/newview/pipeline.h                      |  3 ++-
 .../skins/default/xui/en/menu_viewer.xml      | 18 ++++++++++++----
 11 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 8abb0f7106c..a820d82f6ff 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6996,10 +6996,10 @@
       <key>Value</key>
       <real>256.0</real>
     </map>
-    <key>RenderFastAlpha</key>
+    <key>RenderAutoMaskAlphaNonDeferred</key>
     <map>
       <key>Comment</key>
-      <string>Use alpha masks where appropriate.</string>
+      <string>Use alpha masks where appropriate, in the non-deferred (non-'Lighting and Shadows') graphics mode</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -7007,6 +7007,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>RenderAutoMaskAlphaDeferred</key>
+    <map>
+      <key>Comment</key>
+      <string>Use alpha masks where appropriate, in the deferred ('Lighting and Shadows') graphics mode</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>1</integer>
+    </map>
     <key>RenderFastUI</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 7fd7cd3910b..def463cb416 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -182,7 +182,7 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 	gGL.setColorMask(true, true);
 
-	if (LLPipeline::sFastAlpha && !deferred_render)
+	if (LLPipeline::sAutoMaskAlphaNonDeferred && !deferred_render)
 	{
 		mColorSFactor = LLRender::BF_ONE;  // }
 		mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index bc3e04db183..7816418dc26 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -883,6 +883,26 @@ void LLFace::updateRebuildFlags()
 	}
 }
 
+
+bool LLFace::canRenderAsMask()
+{
+	const LLTextureEntry* te = getTextureEntry();
+	return (
+		(
+		 (LLPipeline::sRenderDeferred && LLPipeline::sAutoMaskAlphaDeferred) ||
+		 
+		 (!LLPipeline::sRenderDeferred && LLPipeline::sAutoMaskAlphaNonDeferred)		 
+		 ) // do we want masks at all?
+		&&
+		(te->getColor().mV[3] == 1.0f) && // can't treat as mask if we have face alpha
+		!(LLPipeline::sRenderDeferred && te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible in deferred rendering mode, need to figure out why - for now, avoid
+		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
+
+		getTexture()->getIsAlphaMask() // texture actually qualifies for masking (lazily recalculated but expensive)
+		);
+}
+
+
 static LLFastTimer::DeclareTimer FTM_FACE_GET_GEOM("Face Geom");
 
 BOOL LLFace::getGeometryVolume(const LLVolume& volume,
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 06ec043c760..bbf8de04bc9 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -139,10 +139,10 @@ class LLFace
 	void			unsetFaceColor(); // switch back to material color
 	const LLColor4&	getFaceColor() const { return mFaceColor; } 
 	const LLColor4& getRenderColor() const;
-	
 
 	//for volumes
 	void updateRebuildFlags();
+	bool canRenderAsMask(); // logic helper
 	BOOL getGeometryVolume(const LLVolume& volume,
 						const S32 &f,
 						const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index b5e59673749..67c33d5b0f7 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -628,8 +628,6 @@ class LLVolumeGeometryManager: public LLGeometryManager
 	virtual void getGeometry(LLSpatialGroup* group);
 	void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort = FALSE);
 	void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type);
- private:
-	bool canRenderAsMask(LLFace* facep); // logic helper
 };
 
 //spatial partition that uses volume geometry manager (implemented in LLVOVolume.cpp)
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 3fa6b0c8c2c..33fb3d0f0f1 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -532,7 +532,8 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderMaxPartCount")->getSignal()->connect(boost::bind(&handleMaxPartCountChanged, _2));
 	gSavedSettings.getControl("RenderDynamicLOD")->getSignal()->connect(boost::bind(&handleRenderDynamicLODChanged, _2));
 	gSavedSettings.getControl("RenderDebugTextureBind")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
-	gSavedSettings.getControl("RenderFastAlpha")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
+	gSavedSettings.getControl("RenderAutoMaskAlphaDeferred")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
+	gSavedSettings.getControl("RenderAutoMaskAlphaNonDeferred")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderObjectBump")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderMaxVBOSize")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderUseFBO")->getSignal()->connect(boost::bind(&handleRenderUseFBOChanged, _2));
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 5be5dc04447..18558425ac3 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -596,7 +596,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			LLPipeline::sUseOcclusion = 3;
 		}
 
-		LLPipeline::sFastAlpha = gSavedSettings.getBOOL("RenderFastAlpha");
+		LLPipeline::sAutoMaskAlphaDeferred = gSavedSettings.getBOOL("RenderAutoMaskAlphaDeferred");
+		LLPipeline::sAutoMaskAlphaNonDeferred = gSavedSettings.getBOOL("RenderAutoMaskAlphaNonDeferred");
 		LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip");
 		LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible");
 		LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate");
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 56fb42bb890..96f69b36761 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3042,9 +3042,7 @@ F32 LLVOVolume::getBinRadius()
 		{
 			LLFace* face = mDrawable->getFace(i);
 			if (face->getPoolType() == LLDrawPool::POOL_ALPHA &&
-				(!LLPipeline::sFastAlpha || 
-				face->getFaceColor().mV[3] != 1.f ||
-				!face->getTexture()->getIsAlphaMask()))
+			    !face->canRenderAsMask())
 			{
 				alpha_wrap = TRUE;
 				break;
@@ -3417,19 +3415,6 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_VB("Volume");
 static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
-bool LLVolumeGeometryManager::canRenderAsMask(LLFace* facep)
-{
-	const LLTextureEntry* te = facep->getTextureEntry();
-	return (
-		LLPipeline::sFastAlpha && // do we want masks at all?
-
-		(te->getColor().mV[3] == 1.0f) && // can't treat as mask if we have face alpha
-		!(LLPipeline::sRenderDeferred && te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible in deferred rendering mode, need to figure out why - for now, avoid
-		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
-
-		facep->getTexture()->getIsAlphaMask() // texture actually qualifies for masking (lazily calculated but expensive)
-		);
-}
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
@@ -3576,7 +3561,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 				if (type == LLDrawPool::POOL_ALPHA)
 				{
-					if (canRenderAsMask(facep))
+					if (facep->canRenderAsMask())
 					{ //can be treated as alpha mask
 						simple_faces.push_back(facep);
 					}
@@ -3930,7 +3915,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 			if (is_alpha)
 			{
 				// can we safely treat this as an alpha mask?
-				if (canRenderAsMask(facep))
+				if (facep->canRenderAsMask())
 				{
 					if (te->getFullbright())
 					{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 5a173d8460f..3df9a119bf6 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -271,7 +271,8 @@ BOOL	LLPipeline::sRenderHighlight = TRUE;
 BOOL	LLPipeline::sForceOldBakedUpload = FALSE;
 S32		LLPipeline::sUseOcclusion = 0;
 BOOL	LLPipeline::sDelayVBUpdate = TRUE;
-BOOL	LLPipeline::sFastAlpha = TRUE;
+BOOL	LLPipeline::sAutoMaskAlphaDeferred = TRUE;
+BOOL	LLPipeline::sAutoMaskAlphaNonDeferred = FALSE;
 BOOL	LLPipeline::sDisableShaders = FALSE;
 BOOL	LLPipeline::sRenderBump = TRUE;
 BOOL	LLPipeline::sUseTriStrips = TRUE;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 8bdc635d056..be878ae6677 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -450,7 +450,8 @@ class LLPipeline
 	static BOOL				sForceOldBakedUpload; // If true will not use capabilities to upload baked textures.
 	static S32				sUseOcclusion;  // 0 = no occlusion, 1 = read only, 2 = read/write
 	static BOOL				sDelayVBUpdate;
-	static BOOL				sFastAlpha;
+	static BOOL				sAutoMaskAlphaDeferred;
+	static BOOL				sAutoMaskAlphaNonDeferred;
 	static BOOL				sDisableShaders; // if TRUE, rendering will be done without shaders
 	static BOOL				sRenderBump;
 	static BOOL				sUseTriStrips;
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index bb57464741c..6a5f9ed8f87 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2148,14 +2148,24 @@
                  parameter="RenderDebugPipeline" />
             </menu_item_check>
             <menu_item_check
-             label="Fast Alpha"
-             name="Fast Alpha">
+             label="Automatic Alpha Masks (deferred)"
+             name="Automatic Alpha Masks (deferred)">
                 <menu_item_check.on_check
                  function="CheckControl"
-                 parameter="RenderFastAlpha" />
+                 parameter="RenderAutoMaskAlphaDeferred" />
                 <menu_item_check.on_click
                  function="ToggleControl"
-                 parameter="RenderFastAlpha" />
+                 parameter="RenderAutoMaskAlphaDeferred" />
+            </menu_item_check>
+            <menu_item_check
+             label="Automatic Alpha Masks (non-deferred)"
+             name="Automatic Alpha Masks (non-deferred)">
+                <menu_item_check.on_check
+                 function="CheckControl"
+                 parameter="RenderAutoMaskAlphaNonDeferred" />
+                <menu_item_check.on_click
+                 function="ToggleControl"
+                 parameter="RenderAutoMaskAlphaNonDeferred" />
             </menu_item_check>
             <menu_item_check
              label="Animation Textures"
-- 
GitLab


From 79f38a961dff09451fb1eac5f4ead1c2f36727a8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 26 Apr 2010 11:55:48 -0500
Subject: [PATCH 357/683] Make LLPipeline::getVisiblePointCloud not a hot spot.

Reviewed by Palmer.
---
 indra/newview/pipeline.cpp | 217 +++++++++++++++++++++++--------------
 1 file changed, 137 insertions(+), 80 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 5a173d8460f..1369956eab9 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -7686,115 +7686,172 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
 	LLPipeline::sShadowRender = FALSE;
 }
 
-
+static LLFastTimer::DeclareTimer FTM_VISIBLE_CLOUD("Visible Cloud");
 BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir)
 {
+	LLFastTimer t(FTM_VISIBLE_CLOUD);
 	//get point cloud of intersection of frust and min, max
 
-	//get set of planes
-	std::vector<LLPlane> ps;
-	
 	if (getVisibleExtents(camera, min, max))
 	{
 		return FALSE;
 	}
 
-	ps.push_back(LLPlane(min, LLVector3(-1,0,0)));
-	ps.push_back(LLPlane(min, LLVector3(0,-1,0)));
-	ps.push_back(LLPlane(min, LLVector3(0,0,-1)));
-	ps.push_back(LLPlane(max, LLVector3(1,0,0)));
-	ps.push_back(LLPlane(max, LLVector3(0,1,0)));
-	ps.push_back(LLPlane(max, LLVector3(0,0,1)));
+	//get set of planes on bounding box
+	std::vector<LLPlane> bp;
+		
+	bp.push_back(LLPlane(min, LLVector3(-1,0,0)));
+	bp.push_back(LLPlane(min, LLVector3(0,-1,0)));
+	bp.push_back(LLPlane(min, LLVector3(0,0,-1)));
+	bp.push_back(LLPlane(max, LLVector3(1,0,0)));
+	bp.push_back(LLPlane(max, LLVector3(0,1,0)));
+	bp.push_back(LLPlane(max, LLVector3(0,0,1)));
+	
+	//potential points
+	std::vector<LLVector3> pp;
+
+	//add corners of AABB
+	pp.push_back(LLVector3(min.mV[0], min.mV[1], min.mV[2]));
+	pp.push_back(LLVector3(max.mV[0], min.mV[1], min.mV[2]));
+	pp.push_back(LLVector3(min.mV[0], max.mV[1], min.mV[2]));
+	pp.push_back(LLVector3(max.mV[0], max.mV[1], min.mV[2]));
+	pp.push_back(LLVector3(min.mV[0], min.mV[1], max.mV[2]));
+	pp.push_back(LLVector3(max.mV[0], min.mV[1], max.mV[2]));
+	pp.push_back(LLVector3(min.mV[0], max.mV[1], max.mV[2]));
+	pp.push_back(LLVector3(max.mV[0], max.mV[1], max.mV[2]));
 
-	/*if (!light_dir.isExactlyZero())
+	//add corners of camera frustum
+	for (U32 i = 0; i < 8; i++)
 	{
-		LLPlane ucp;
-		LLPlane mcp;
+		pp.push_back(camera.mAgentFrustum[i]);
+	}
 
-		F32 maxd = -1.f;
-		F32 mind = 1.f;
 
-		for (U32 i = 0; i < ps.size(); ++i)
-		{  //pick the plane most aligned to lightDir for user clip plane
-			LLVector3 n(ps[i].mV);
-			F32 da = n*light_dir;
-			if (da > maxd)
-			{
-				maxd = da;
-				ucp = ps[i];
-			}
+	//bounding box line segments
+	U32 bs[] = 
+	{
+		0,1,
+		1,3,
+		3,2,
+		2,0,
+
+		4,5,
+		5,7,
+		7,6,
+		6,4,
+
+		0,4,
+		1,5,
+		3,7,
+		2,6
+	};
+
+	for (U32 i = 0; i < 12; i++)
+	{ //for each line segment in bounding box
+		for (U32 j = 0; j < 6; j++) 
+		{ //for each plane in camera frustum
+			const LLPlane& cp = camera.getAgentPlane(j);
+			const LLVector3& v1 = pp[bs[i*2+0]];
+			const LLVector3& v2 = pp[bs[i*2+1]];
+			const LLVector3 n(cp.mV);
+
+			LLVector3 line = v1-v2;
+
+			F32 d1 = line*n;
+			F32 d2 = -cp.dist(v2);
+
+			F32 t = d2/d1;
 
-			if (da < mind)
+			if (t > 0.f && t < 1.f)
 			{
-				mind = da;
-				mcp = ps[i];
+				LLVector3 intersect = v2+line*t;
+				pp.push_back(intersect);
 			}
 		}
-			
-		camera.setUserClipPlane(ucp);
+	}
 
-		ps.clear();
-		ps.push_back(ucp);
-		ps.push_back(mcp);
-	}*/
-	
-	for (U32 i = 0; i < 6; i++)
+	//camera frustum line segments
+	const U32 fs[] =
 	{
-		ps.push_back(camera.getAgentPlane(i));
-	}
+		0,1,
+		1,2,
+		2,3,
+		3,1,
 
-	//get set of points where planes intersect and points are not above any plane
-	fp.clear();
-	
-	for (U32 i = 0; i < ps.size(); ++i)
+		4,5,
+		5,6,
+		6,7,
+		7,4,
+
+		0,4,
+		1,5,
+		2,6,
+		3,7	
+	};
+
+	LLVector3 center = (max+min)*0.5f;
+	LLVector3 size = (max-min)*0.5f;
+
+	for (U32 i = 0; i < 12; i++)
 	{
-		for (U32 j = 0; j < ps.size(); ++j)
+		for (U32 j = 0; j < 6; ++j)
 		{
-			for (U32 k = 0; k < ps.size(); ++k)
-			{
-				if (i == j ||
-					i == k ||
-					k == j)
-				{
-					continue;
-				}
+			const LLVector3& v1 = pp[fs[i*2+0]+8];
+			const LLVector3& v2 = pp[fs[i*2+1]+8];
+			const LLPlane& cp = bp[j];
+			const LLVector3 n(cp.mV);
 
-				LLVector3 n1,n2,n3;
-				F32 d1,d2,d3;
+			LLVector3 line = v1-v2;
 
-				n1.setVec(ps[i].mV);
-				n2.setVec(ps[j].mV);
-				n3.setVec(ps[k].mV);
+			F32 d1 = line*n;
+			F32 d2 = -cp.dist(v2);
 
-				d1 = ps[i].mV[3];
-				d2 = ps[j].mV[3];
-				d3 = ps[k].mV[3];
-			
-				//get point of intersection of 3 planes "p"
-				LLVector3 p = (-d1*(n2%n3)-d2*(n3%n1)-d3*(n1%n2))/(n1*(n2%n3));
-				
-				if (llround(p*n1+d1, 0.1f) == 0.f &&
-					llround(p*n2+d2, 0.1f) == 0.f &&
-					llround(p*n3+d3, 0.1f) == 0.f)
-				{ //point is on all three planes
-					BOOL found = TRUE;
-					for (U32 l = 0; l < ps.size() && found; ++l)
-					{
-						if (llround(ps[l].dist(p), 0.1f) > 0.0f)
-						{ //point is above some plane, not contained
-							found = FALSE;	
-						}
-					}
+			F32 t = d2/d1;
 
-					if (found)
-					{
-						fp.push_back(p);
-					}
-				}
-			}
+			if (t > 0.f && t < 1.f)
+			{
+				LLVector3 intersect = v2+line*t;
+				pp.push_back(intersect);
+			}	
 		}
 	}
 	
+	LLVector3 ext[] = { min-LLVector3(0.05f,0.05f,0.05f),
+		max+LLVector3(0.05f,0.05f,0.05f) };
+
+	for (U32 i = 0; i < pp.size(); ++i)
+	{
+		bool found = true;
+		
+		const F32* p = pp[i].mV;
+
+		for (U32 j = 0; j < 3; ++j)
+		{
+			if (p[j] < ext[0].mV[j] ||
+				p[j] > ext[1].mV[j])
+			{
+				found = false;
+				break;
+			}
+		}
+			
+		for (U32 j = 0; j < 6; ++j)
+		{
+			const LLPlane& cp = camera.getAgentPlane(j);
+			F32 dist = cp.dist(pp[i]);
+			if (dist > 0.05f) //point is above some plane, not contained
+			{
+				found = false;
+				break;
+			}
+		}
+
+		if (found)
+		{
+			fp.push_back(pp[i]);
+		}
+	}
+
 	if (fp.empty())
 	{
 		return FALSE;
-- 
GitLab


From 66ff7e5d049d34126996bc93e25e4f40c42c0155 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 26 Apr 2010 11:55:48 -0500
Subject: [PATCH 358/683] Make LLPipeline::getVisiblePointCloud not a hot spot.

Reviewed by Palmer.
(transplanted from 996892f8a9ac2bd17456340fbd427704340b3553)
---
 indra/newview/pipeline.cpp | 217 +++++++++++++++++++++++--------------
 1 file changed, 137 insertions(+), 80 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e6b4c5f3ed1..e35c1a1c9cb 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -7605,115 +7605,172 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
 	LLPipeline::sShadowRender = FALSE;
 }
 
-
+static LLFastTimer::DeclareTimer FTM_VISIBLE_CLOUD("Visible Cloud");
 BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir)
 {
+	LLFastTimer t(FTM_VISIBLE_CLOUD);
 	//get point cloud of intersection of frust and min, max
 
-	//get set of planes
-	std::vector<LLPlane> ps;
-	
 	if (getVisibleExtents(camera, min, max))
 	{
 		return FALSE;
 	}
 
-	ps.push_back(LLPlane(min, LLVector3(-1,0,0)));
-	ps.push_back(LLPlane(min, LLVector3(0,-1,0)));
-	ps.push_back(LLPlane(min, LLVector3(0,0,-1)));
-	ps.push_back(LLPlane(max, LLVector3(1,0,0)));
-	ps.push_back(LLPlane(max, LLVector3(0,1,0)));
-	ps.push_back(LLPlane(max, LLVector3(0,0,1)));
+	//get set of planes on bounding box
+	std::vector<LLPlane> bp;
+		
+	bp.push_back(LLPlane(min, LLVector3(-1,0,0)));
+	bp.push_back(LLPlane(min, LLVector3(0,-1,0)));
+	bp.push_back(LLPlane(min, LLVector3(0,0,-1)));
+	bp.push_back(LLPlane(max, LLVector3(1,0,0)));
+	bp.push_back(LLPlane(max, LLVector3(0,1,0)));
+	bp.push_back(LLPlane(max, LLVector3(0,0,1)));
+	
+	//potential points
+	std::vector<LLVector3> pp;
+
+	//add corners of AABB
+	pp.push_back(LLVector3(min.mV[0], min.mV[1], min.mV[2]));
+	pp.push_back(LLVector3(max.mV[0], min.mV[1], min.mV[2]));
+	pp.push_back(LLVector3(min.mV[0], max.mV[1], min.mV[2]));
+	pp.push_back(LLVector3(max.mV[0], max.mV[1], min.mV[2]));
+	pp.push_back(LLVector3(min.mV[0], min.mV[1], max.mV[2]));
+	pp.push_back(LLVector3(max.mV[0], min.mV[1], max.mV[2]));
+	pp.push_back(LLVector3(min.mV[0], max.mV[1], max.mV[2]));
+	pp.push_back(LLVector3(max.mV[0], max.mV[1], max.mV[2]));
 
-	/*if (!light_dir.isExactlyZero())
+	//add corners of camera frustum
+	for (U32 i = 0; i < 8; i++)
 	{
-		LLPlane ucp;
-		LLPlane mcp;
+		pp.push_back(camera.mAgentFrustum[i]);
+	}
 
-		F32 maxd = -1.f;
-		F32 mind = 1.f;
 
-		for (U32 i = 0; i < ps.size(); ++i)
-		{  //pick the plane most aligned to lightDir for user clip plane
-			LLVector3 n(ps[i].mV);
-			F32 da = n*light_dir;
-			if (da > maxd)
-			{
-				maxd = da;
-				ucp = ps[i];
-			}
+	//bounding box line segments
+	U32 bs[] = 
+	{
+		0,1,
+		1,3,
+		3,2,
+		2,0,
+
+		4,5,
+		5,7,
+		7,6,
+		6,4,
+
+		0,4,
+		1,5,
+		3,7,
+		2,6
+	};
+
+	for (U32 i = 0; i < 12; i++)
+	{ //for each line segment in bounding box
+		for (U32 j = 0; j < 6; j++) 
+		{ //for each plane in camera frustum
+			const LLPlane& cp = camera.getAgentPlane(j);
+			const LLVector3& v1 = pp[bs[i*2+0]];
+			const LLVector3& v2 = pp[bs[i*2+1]];
+			const LLVector3 n(cp.mV);
+
+			LLVector3 line = v1-v2;
+
+			F32 d1 = line*n;
+			F32 d2 = -cp.dist(v2);
+
+			F32 t = d2/d1;
 
-			if (da < mind)
+			if (t > 0.f && t < 1.f)
 			{
-				mind = da;
-				mcp = ps[i];
+				LLVector3 intersect = v2+line*t;
+				pp.push_back(intersect);
 			}
 		}
-			
-		camera.setUserClipPlane(ucp);
+	}
 
-		ps.clear();
-		ps.push_back(ucp);
-		ps.push_back(mcp);
-	}*/
-	
-	for (U32 i = 0; i < 6; i++)
+	//camera frustum line segments
+	const U32 fs[] =
 	{
-		ps.push_back(camera.getAgentPlane(i));
-	}
+		0,1,
+		1,2,
+		2,3,
+		3,1,
 
-	//get set of points where planes intersect and points are not above any plane
-	fp.clear();
-	
-	for (U32 i = 0; i < ps.size(); ++i)
+		4,5,
+		5,6,
+		6,7,
+		7,4,
+
+		0,4,
+		1,5,
+		2,6,
+		3,7	
+	};
+
+	LLVector3 center = (max+min)*0.5f;
+	LLVector3 size = (max-min)*0.5f;
+
+	for (U32 i = 0; i < 12; i++)
 	{
-		for (U32 j = 0; j < ps.size(); ++j)
+		for (U32 j = 0; j < 6; ++j)
 		{
-			for (U32 k = 0; k < ps.size(); ++k)
-			{
-				if (i == j ||
-					i == k ||
-					k == j)
-				{
-					continue;
-				}
+			const LLVector3& v1 = pp[fs[i*2+0]+8];
+			const LLVector3& v2 = pp[fs[i*2+1]+8];
+			const LLPlane& cp = bp[j];
+			const LLVector3 n(cp.mV);
 
-				LLVector3 n1,n2,n3;
-				F32 d1,d2,d3;
+			LLVector3 line = v1-v2;
 
-				n1.setVec(ps[i].mV);
-				n2.setVec(ps[j].mV);
-				n3.setVec(ps[k].mV);
+			F32 d1 = line*n;
+			F32 d2 = -cp.dist(v2);
 
-				d1 = ps[i].mV[3];
-				d2 = ps[j].mV[3];
-				d3 = ps[k].mV[3];
-			
-				//get point of intersection of 3 planes "p"
-				LLVector3 p = (-d1*(n2%n3)-d2*(n3%n1)-d3*(n1%n2))/(n1*(n2%n3));
-				
-				if (llround(p*n1+d1, 0.1f) == 0.f &&
-					llround(p*n2+d2, 0.1f) == 0.f &&
-					llround(p*n3+d3, 0.1f) == 0.f)
-				{ //point is on all three planes
-					BOOL found = TRUE;
-					for (U32 l = 0; l < ps.size() && found; ++l)
-					{
-						if (llround(ps[l].dist(p), 0.1f) > 0.0f)
-						{ //point is above some plane, not contained
-							found = FALSE;	
-						}
-					}
+			F32 t = d2/d1;
 
-					if (found)
-					{
-						fp.push_back(p);
-					}
-				}
-			}
+			if (t > 0.f && t < 1.f)
+			{
+				LLVector3 intersect = v2+line*t;
+				pp.push_back(intersect);
+			}	
 		}
 	}
 	
+	LLVector3 ext[] = { min-LLVector3(0.05f,0.05f,0.05f),
+		max+LLVector3(0.05f,0.05f,0.05f) };
+
+	for (U32 i = 0; i < pp.size(); ++i)
+	{
+		bool found = true;
+		
+		const F32* p = pp[i].mV;
+
+		for (U32 j = 0; j < 3; ++j)
+		{
+			if (p[j] < ext[0].mV[j] ||
+				p[j] > ext[1].mV[j])
+			{
+				found = false;
+				break;
+			}
+		}
+			
+		for (U32 j = 0; j < 6; ++j)
+		{
+			const LLPlane& cp = camera.getAgentPlane(j);
+			F32 dist = cp.dist(pp[i]);
+			if (dist > 0.05f) //point is above some plane, not contained
+			{
+				found = false;
+				break;
+			}
+		}
+
+		if (found)
+		{
+			fp.push_back(pp[i]);
+		}
+	}
+
 	if (fp.empty())
 	{
 		return FALSE;
-- 
GitLab


From 809b6879e1d89ff3bc565f3144e4cb625ccdd185 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 26 Apr 2010 17:35:52 -0500
Subject: [PATCH 359/683] Use 10.5 sdk

---
 indra/cmake/Variables.cmake | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index bfaf3f4f26f..f181e5b6fd5 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -81,13 +81,13 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   # otherwise CMAKE_OSX_SYSROOT will be overridden here. We can't just check
   # for it being unset, as it gets set to the system default :(
 
-  # Default to building against the 10.4 SDK if no deployment target is
+  # Default to building against the 10.5 SDK if no deployment target is
   # specified.
   if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
     # NOTE: setting -isysroot is NOT adequate: http://lists.apple.com/archives/Xcode-users/2007/Oct/msg00696.html
     # see http://public.kitware.com/Bug/view.php?id=9959 + poppy
-    set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk)
-    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.4)
+    set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
+    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
   endif (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
 
   # GCC 4.2 is incompatible with the MacOSX 10.4 SDK
-- 
GitLab


From c0a2a44a44c5d6db39cfa5fdb5630578d4c2d267 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 26 Apr 2010 21:33:18 -0500
Subject: [PATCH 360/683] Fix for mac build.

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

diff --git a/indra/llplugin/slplugin/slplugin.cpp b/indra/llplugin/slplugin/slplugin.cpp
index 7d6dde1a58e..b989e321f1c 100644
--- a/indra/llplugin/slplugin/slplugin.cpp
+++ b/indra/llplugin/slplugin/slplugin.cpp
@@ -273,7 +273,7 @@ int main(int argc, char **argv)
 			}
 			
 			// Check for a change in this process's frontmost window.
-			if(FrontWindow() != front_window)
+			if(ActiveNonFloatingWindow() != front_window)
 			{
 				ProcessSerialNumber self = { 0, kCurrentProcess };
 				ProcessSerialNumber parent = { 0, kNoProcess };
@@ -299,7 +299,7 @@ int main(int argc, char **argv)
 					}
 				}
 								
-				if((FrontWindow() != NULL) && (front_window == NULL))
+				if((ActiveNonFloatingWindow() != NULL) && (front_window == NULL))
 				{
 					// Opening the first window
 					
@@ -311,7 +311,7 @@ int main(int argc, char **argv)
 
 					if(layer_group)
 					{
-						SetWindowGroup(FrontWindow(), layer_group);
+						SetWindowGroup(ActiveNonFloatingWindow(), layer_group);
 					}
 					
 					if(parent_is_front_process)
@@ -320,9 +320,9 @@ int main(int argc, char **argv)
 						(void) SetFrontProcess( &self );
 					}
 
-					ActivateWindow(FrontWindow(), true);					
+					ActivateWindow(ActiveNonFloatingWindow(), true);					
 				}
-				else if((FrontWindow() == NULL) && (front_window != NULL))
+				else if((ActiveNonFloatingWindow() == NULL) && (front_window != NULL))
 				{
 					// Closing the last window
 					
@@ -342,7 +342,7 @@ int main(int argc, char **argv)
 					window_hack_state = 2;
 				}
 
-				front_window = FrontWindow();
+				front_window = ActiveNonFloatingWindow();
 
 			}
 		}
-- 
GitLab


From 9d88673a29cd5b6ae3cadb442ff1fa850ce606bc Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 27 Apr 2010 00:13:51 -0500
Subject: [PATCH 361/683] Stop z-fighting in glow pass.

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

diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index ca7a1b47c2c..c8e6f95ab6d 100644
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -55,6 +55,10 @@ void LLDrawPoolGlow::render(S32 pass)
 	LLFastTimer t(FTM_RENDER_GLOW);
 	LLGLEnable blend(GL_BLEND);
 	LLGLDisable test(GL_ALPHA_TEST);
+	gGL.flush();
+	/// Get rid of z-fighting with non-glow pass.
+	LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
+	glPolygonOffset(-1.0f, -1.0f);
 	gGL.setSceneBlendType(LLRender::BT_ADD);
 	
 	U32 shader_level = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
-- 
GitLab


From 8f5db6da1420e5e28e1144f69382f6571f94696b Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 27 Apr 2010 00:13:51 -0500
Subject: [PATCH 362/683] Stop z-fighting in glow pass. (transplanted from
 a1ec712ffcf5a8b21d2d441b348022fa8e4a44c2)

---
 indra/newview/lldrawpoolsimple.cpp | 40 +++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index 2c1430b8340..c8e6f95ab6d 100644
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -2,25 +2,31 @@
  * @file lldrawpoolsimple.cpp
  * @brief LLDrawPoolSimple class implementation
  *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -49,6 +55,10 @@ void LLDrawPoolGlow::render(S32 pass)
 	LLFastTimer t(FTM_RENDER_GLOW);
 	LLGLEnable blend(GL_BLEND);
 	LLGLDisable test(GL_ALPHA_TEST);
+	gGL.flush();
+	/// Get rid of z-fighting with non-glow pass.
+	LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
+	glPolygonOffset(-1.0f, -1.0f);
 	gGL.setSceneBlendType(LLRender::BT_ADD);
 	
 	U32 shader_level = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
-- 
GitLab


From 07c0389f50ccef13ad2699e149dc4b87de3dbd70 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 27 Apr 2010 01:50:06 -0500
Subject: [PATCH 363/683] Proper byte ordering when decoding skin weights.

---
 indra/llmath/llvolume.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index fdd48b9e9ed..9d2d157c767 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2028,8 +2028,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 					while (joint != END_INFLUENCES)
 					{
 						U16 influence = weights[idx++];
-						influence = influence << 8;
-						influence |= weights[idx++];
+						influence |= ((U16) weights[idx++] << 8);
 
 						F32 w = llmin((F32) influence / 65535.f, 0.99999f);
 						face.mWeights[cur_vertex].mV[cur_influence++] = (F32) joint + w;
-- 
GitLab


From 31a358ac1dd059f62547aa0a0f7b708333045d58 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 27 Apr 2010 02:53:50 -0500
Subject: [PATCH 364/683] Fix for crash when logging in next to folks wearing
 rigged attachments.

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

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 7816418dc26..7866e49bae4 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1365,7 +1365,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 			*binormals++ = binormal;
 		}
 		
-		if (rebuild_weights)
+		if (rebuild_weights && vf.mWeights.size() > i)
 		{
 			*weights++ = vf.mWeights[i];
 		}
-- 
GitLab


From 4a501bb437f86175f6e8e2d015969595f55fa705 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 28 Apr 2010 02:53:12 -0500
Subject: [PATCH 365/683] Make LLVolume::createSide a little faster.
 (transplanted from 4d43e3b83ccffd725ec6cb234ddcfa0833f17a9f)

---
 indra/llmath/llvolume.cpp | 129 ++++++++++++++++++++++----------------
 1 file changed, 76 insertions(+), 53 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 39b7453ffc4..3c3356f41d3 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1,25 +1,31 @@
 /** 
  * @file llvolume.cpp
  *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -80,6 +86,8 @@ const F32 SKEW_MAX	=  0.95f;
 const F32 SCULPT_MIN_AREA = 0.002f;
 const S32 SCULPT_MIN_AREA_DETAIL = 1;
 
+#define GEN_TRI_STRIP 0
+
 BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
 {    
 	LLVector3 test = (pt2-pt1)%(pt3-pt2);
@@ -1682,7 +1690,7 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
 	mGenerateSingleFace = generate_single_face;
 
 	generate();
-	if (mParams.getSculptID().isNull())
+	if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
 	{
 		createVolumeFaces();
 	}
@@ -1858,6 +1866,11 @@ void LLVolume::createVolumeFaces()
 			LLProfile::Face& face = mProfilep->mFaces[i];
 			vf.mBeginS = face.mIndex;
 			vf.mNumS = face.mCount;
+			if (vf.mNumS < 0)
+			{
+				llerrs << "Volume face corruption detected." << llendl;
+			}
+
 			vf.mBeginT = 0;
 			vf.mNumT= getPath().mPath.size();
 			vf.mID = i;
@@ -1901,6 +1914,10 @@ void LLVolume::createVolumeFaces()
 					if (face.mFlat && vf.mNumS > 2)
 					{ //flat inner faces have to copy vert normals
 						vf.mNumS = vf.mNumS*2;
+						if (vf.mNumS < 0)
+						{
+							llerrs << "Volume face corruption detected." << llendl;
+						}
 					}
 				}
 				else
@@ -4515,7 +4532,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
+#if GEN_TRI_STRIP
 		mTriStrip.clear();
+#endif
 		S32 idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
 		for(S32 gx = 0;gx<grid_size;gx++)
 		{
@@ -4529,6 +4548,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 						mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
 					}
 					
+#if GEN_TRI_STRIP
 					if (gy == 0)
 					{
 						mTriStrip.push_back((gx+1)*(grid_size+1));
@@ -4544,6 +4564,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 					{
 						mTriStrip.push_back(gy+1+gx*(grid_size+1));
 					}
+#endif
 				}
 				else
 				{
@@ -4552,6 +4573,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 						mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
 					}
 
+#if GEN_TRI_STRIP
 					if (gy == 0)
 					{
 						mTriStrip.push_back(gx*(grid_size+1));
@@ -4566,15 +4588,18 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 					{
 						mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1));
 					}
+#endif
 				}
 			}
 			
 		}
 
+#if GEN_TRI_STRIP
 		if (mTriStrip.size()%2 == 1)
 		{
 			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 		}
+#endif
 	}
 		
 	return TRUE;
@@ -4944,6 +4969,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 			mIndices[3*i+v2] = i + 1;
 		}
 
+#if GEN_TRI_STRIP
 		//make tri strip
 		if (mTypeMask & OPEN_MASK)
 		{
@@ -4986,6 +5012,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 				mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 			}
 		}
+#endif
 	}
 		
 	return TRUE;
@@ -4993,6 +5020,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 
 void LLVolumeFace::makeTriStrip()
 {
+#if GEN_TRI_STRIP
 	for (U32 i = 0; i < mIndices.size(); i+=3)
 	{
 		U16 i0 = mIndices[i];
@@ -5021,6 +5049,7 @@ void LLVolumeFace::makeTriStrip()
 	{
 		mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 	}
+#endif
 }
 
 void LLVolumeFace::createBinormals()
@@ -5106,12 +5135,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 		mHasBinormals = FALSE;
 	}
 
-
-	LLVector3& face_min = mExtents[0];
-	LLVector3& face_max = mExtents[1];
-
-	mCenter.clearVec();
-
 	S32 begin_stex = llfloor( profile[mBeginS].mV[2] );
 	S32 num_s = ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2) ? mNumS/2 : mNumS;
 
@@ -5167,15 +5190,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 		
 			mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
 			mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
-			
-			if (cur_vertex == 0)
-			{
-				face_min = face_max = mesh[i].mPos;
-			}
-			else
-			{
-				update_min_max(face_min, face_max, mesh[i].mPos);
-			}
 
 			cur_vertex++;
 
@@ -5209,12 +5223,22 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 			mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
 			mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
 
-			update_min_max(face_min,face_max,mesh[i].mPos);
-
 			cur_vertex++;
 		}
 	}
 	
+
+	//get bounding box for this side
+	LLVector3& face_min = mExtents[0];
+	LLVector3& face_max = mExtents[1];
+	mCenter.clearVec();
+
+	face_min = face_max = mVertices[0].mPosition;
+	for (U32 i = 1; i < mVertices.size(); ++i)
+	{
+		update_min_max(face_min, face_max, mVertices[i].mPosition);
+	}
+
 	mCenter = (face_min + face_max) * 0.5f;
 
 	S32 cur_index = 0;
@@ -5223,13 +5247,17 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
+#if GEN_TRI_STRIP
 		mTriStrip.clear();
+#endif
 
 		// Now we generate the indices.
 		for (t = 0; t < (mNumT-1); t++)
 		{
+#if GEN_TRI_STRIP
 			//prepend terminating index to strip
 			mTriStrip.push_back(mNumS*t);
+#endif
 
 			for (s = 0; s < (mNumS-1); s++)
 			{	
@@ -5240,6 +5268,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				mIndices[cur_index++] = s+1 + mNumS*t;			//bottom right
 				mIndices[cur_index++] = s+1 + mNumS*(t+1);		//top right
 
+#if GEN_TRI_STRIP
 				if (s == 0)
 				{
 					mTriStrip.push_back(s+mNumS*t);
@@ -5247,6 +5276,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				}
 				mTriStrip.push_back(s+1+mNumS*t);
 				mTriStrip.push_back(s+1+mNumS*(t+1));
+#endif
 				
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1;						//bottom left/top right neighbor face 
 				if (t < mNumT-2) {												//top right/top left neighbor face 
@@ -5288,44 +5318,37 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				}
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2;							//top right/bottom left neighbor face	
 			}
+#if GEN_TRI_STRIP
 			//append terminating vertex to strip
 			mTriStrip.push_back(mNumS-1+mNumS*(t+1));
+#endif
 		}
 
+#if GEN_TRI_STRIP
 		if (mTriStrip.size()%2 == 1)
 		{
 			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 		}
+#endif
 	}
 
 	//generate normals 
 	for (U32 i = 0; i < mIndices.size()/3; i++) //for each triangle
 	{
-		const S32 i0 = mIndices[i*3+0];
-		const S32 i1 = mIndices[i*3+1];
-		const S32 i2 = mIndices[i*3+2];
-		const VertexData& v0 = mVertices[i0];
-		const VertexData& v1 = mVertices[i1];
-		const VertexData& v2 = mVertices[i2];
+		const U16* idx = &(mIndices[i*3]);
+			
+		VertexData* v[] = 
+		{	&mVertices[idx[0]], &mVertices[idx[1]], &mVertices[idx[2]] };
 					
 		//calculate triangle normal
-		LLVector3 norm = (v0.mPosition-v1.mPosition) % (v0.mPosition-v2.mPosition);
+		LLVector3 norm = (v[0]->mPosition-v[1]->mPosition) % (v[0]->mPosition-v[2]->mPosition);
 
-		for (U32 j = 0; j < 3; j++) 
-		{ //add triangle normal to vertices
-			const S32 idx = mIndices[i*3+j];
-			mVertices[idx].mNormal += norm; // * (weight_sum - d[j])/weight_sum;
-		}
+		v[0]->mNormal += norm;
+		v[1]->mNormal += norm;
+		v[2]->mNormal += norm;
 
 		//even out quad contributions
-		if ((i & 1) == 0) 
-		{
-			mVertices[i2].mNormal += norm;
-		}
-		else 
-		{
-			mVertices[i1].mNormal += norm;
-		}
+		v[i%2+1]->mNormal += norm;
 	}
 	
 	// adjust normals based on wrapping and stitching
-- 
GitLab


From d71716aa6dde434b6356cfe85e3a8fce376056dd Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 28 Apr 2010 02:53:12 -0500
Subject: [PATCH 366/683] Make LLVolume::createSide a little faster.

---
 indra/llmath/llvolume.cpp | 82 +++++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 37 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 9d2d157c767..5ffc61ce9cc 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -87,6 +87,8 @@ const F32 SKEW_MAX	=  0.95f;
 const F32 SCULPT_MIN_AREA = 0.002f;
 const S32 SCULPT_MIN_AREA_DETAIL = 1;
 
+#define GEN_TRI_STRIP 0
+
 BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
 {    
 	LLVector3 test = (pt2-pt1)%(pt3-pt2);
@@ -5079,7 +5081,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
+#if GEN_TRI_STRIP
 		mTriStrip.clear();
+#endif
 		S32 idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
 		for(S32 gx = 0;gx<grid_size;gx++)
 		{
@@ -5093,6 +5097,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 						mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
 					}
 					
+#if GEN_TRI_STRIP
 					if (gy == 0)
 					{
 						mTriStrip.push_back((gx+1)*(grid_size+1));
@@ -5108,6 +5113,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 					{
 						mTriStrip.push_back(gy+1+gx*(grid_size+1));
 					}
+#endif
 				}
 				else
 				{
@@ -5116,6 +5122,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 						mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
 					}
 
+#if GEN_TRI_STRIP
 					if (gy == 0)
 					{
 						mTriStrip.push_back(gx*(grid_size+1));
@@ -5130,15 +5137,18 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 					{
 						mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1));
 					}
+#endif
 				}
 			}
 			
 		}
 
+#if GEN_TRI_STRIP
 		if (mTriStrip.size()%2 == 1)
 		{
 			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 		}
+#endif
 	}
 		
 	return TRUE;
@@ -5508,6 +5518,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 			mIndices[3*i+v2] = i + 1;
 		}
 
+#if GEN_TRI_STRIP
 		//make tri strip
 		if (mTypeMask & OPEN_MASK)
 		{
@@ -5550,6 +5561,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 				mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 			}
 		}
+#endif
 	}
 		
 	return TRUE;
@@ -5557,6 +5569,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 
 void LLVolumeFace::makeTriStrip()
 {
+#if GEN_TRI_STRIP
 	for (U32 i = 0; i < mIndices.size(); i+=3)
 	{
 		U16 i0 = mIndices[i];
@@ -5585,6 +5598,7 @@ void LLVolumeFace::makeTriStrip()
 	{
 		mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 	}
+#endif
 }
 
 void LLVolumeFace::createBinormals()
@@ -5710,12 +5724,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 		mHasBinormals = FALSE;
 	}
 
-
-	LLVector3& face_min = mExtents[0];
-	LLVector3& face_max = mExtents[1];
-
-	mCenter.clearVec();
-
 	S32 begin_stex = llfloor( profile[mBeginS].mV[2] );
 	S32 num_s = ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2) ? mNumS/2 : mNumS;
 
@@ -5771,15 +5779,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 		
 			mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
 			mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
-			
-			if (cur_vertex == 0)
-			{
-				face_min = face_max = mesh[i].mPos;
-			}
-			else
-			{
-				update_min_max(face_min, face_max, mesh[i].mPos);
-			}
 
 			cur_vertex++;
 
@@ -5813,12 +5812,22 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 			mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
 			mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
 
-			update_min_max(face_min,face_max,mesh[i].mPos);
-
 			cur_vertex++;
 		}
 	}
 	
+
+	//get bounding box for this side
+	LLVector3& face_min = mExtents[0];
+	LLVector3& face_max = mExtents[1];
+	mCenter.clearVec();
+
+	face_min = face_max = mVertices[0].mPosition;
+	for (U32 i = 1; i < mVertices.size(); ++i)
+	{
+		update_min_max(face_min, face_max, mVertices[i].mPosition);
+	}
+
 	mCenter = (face_min + face_max) * 0.5f;
 
 	S32 cur_index = 0;
@@ -5827,13 +5836,17 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
+#if GEN_TRI_STRIP
 		mTriStrip.clear();
+#endif
 
 		// Now we generate the indices.
 		for (t = 0; t < (mNumT-1); t++)
 		{
+#if GEN_TRI_STRIP
 			//prepend terminating index to strip
 			mTriStrip.push_back(mNumS*t);
+#endif
 
 			for (s = 0; s < (mNumS-1); s++)
 			{	
@@ -5844,6 +5857,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				mIndices[cur_index++] = s+1 + mNumS*t;			//bottom right
 				mIndices[cur_index++] = s+1 + mNumS*(t+1);		//top right
 
+#if GEN_TRI_STRIP
 				if (s == 0)
 				{
 					mTriStrip.push_back(s+mNumS*t);
@@ -5851,6 +5865,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				}
 				mTriStrip.push_back(s+1+mNumS*t);
 				mTriStrip.push_back(s+1+mNumS*(t+1));
+#endif
 				
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1;						//bottom left/top right neighbor face 
 				if (t < mNumT-2) {												//top right/top left neighbor face 
@@ -5892,44 +5907,37 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				}
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2;							//top right/bottom left neighbor face	
 			}
+#if GEN_TRI_STRIP
 			//append terminating vertex to strip
 			mTriStrip.push_back(mNumS-1+mNumS*(t+1));
+#endif
 		}
 
+#if GEN_TRI_STRIP
 		if (mTriStrip.size()%2 == 1)
 		{
 			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 		}
+#endif
 	}
 
 	//generate normals 
 	for (U32 i = 0; i < mIndices.size()/3; i++) //for each triangle
 	{
-		const S32 i0 = mIndices[i*3+0];
-		const S32 i1 = mIndices[i*3+1];
-		const S32 i2 = mIndices[i*3+2];
-		const VertexData& v0 = mVertices[i0];
-		const VertexData& v1 = mVertices[i1];
-		const VertexData& v2 = mVertices[i2];
+		const U16* idx = &(mIndices[i*3]);
+			
+		VertexData* v[] = 
+		{	&mVertices[idx[0]], &mVertices[idx[1]], &mVertices[idx[2]] };
 					
 		//calculate triangle normal
-		LLVector3 norm = (v0.mPosition-v1.mPosition) % (v0.mPosition-v2.mPosition);
+		LLVector3 norm = (v[0]->mPosition-v[1]->mPosition) % (v[0]->mPosition-v[2]->mPosition);
 
-		for (U32 j = 0; j < 3; j++) 
-		{ //add triangle normal to vertices
-			const S32 idx = mIndices[i*3+j];
-			mVertices[idx].mNormal += norm; // * (weight_sum - d[j])/weight_sum;
-		}
+		v[0]->mNormal += norm;
+		v[1]->mNormal += norm;
+		v[2]->mNormal += norm;
 
 		//even out quad contributions
-		if ((i & 1) == 0) 
-		{
-			mVertices[i2].mNormal += norm;
-		}
-		else 
-		{
-			mVertices[i1].mNormal += norm;
-		}
+		v[i%2+1]->mNormal += norm;
 	}
 	
 	// adjust normals based on wrapping and stitching
-- 
GitLab


From 4f46e777a501ff0bfedaf657ac6decdeba8acbe5 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Apr 2010 09:45:44 +0100
Subject: [PATCH 367/683] EXT-7149 objects with white color and varied texture
 do not appear shiny with deferred rendering (transplanted from
 778a5a83ef4e5e70652fbc00f2e1f8375e587afc)

---
 .../app_settings/shaders/class1/deferred/diffuseF.glsl     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 5895ebda84c..59b1720578f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -11,8 +11,9 @@ varying vec3 vary_normal;
 
 void main() 
 {
-	vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
-	gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0);
-	gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a);
+	vec3 col = gl_Color.rgb * texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
+	gl_FragData[0] = vec4(col, 0.0);
+	gl_FragData[1] = vec4(gl_Color.aaa*1.5, gl_Color.a); // spec
+	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
 	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
 }
-- 
GitLab


From 94067a94c170fc2530d6868979318fa5adf8014e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Apr 2010 09:45:44 +0100
Subject: [PATCH 368/683] EXT-7149 objects with white color and varied texture
 do not appear shiny with deferred rendering

---
 .../app_settings/shaders/class1/deferred/diffuseF.glsl     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 5895ebda84c..59b1720578f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -11,8 +11,9 @@ varying vec3 vary_normal;
 
 void main() 
 {
-	vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
-	gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0);
-	gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a);
+	vec3 col = gl_Color.rgb * texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
+	gl_FragData[0] = vec4(col, 0.0);
+	gl_FragData[1] = vec4(gl_Color.aaa*1.5, gl_Color.a); // spec
+	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
 	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
 }
-- 
GitLab


From 41afe80984ee6d0363032193ea4a5d3eb867b3b1 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Apr 2010 10:40:27 +0100
Subject: [PATCH 369/683] more tweakery for EXT-7149 objects with white color
 and varied texture do not appear shiny with deferred rendering (transplanted
 from 36680184ec50ecf5fff92ee33db711b7512d923a)

---
 .../newview/app_settings/shaders/class1/deferred/diffuseF.glsl  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 59b1720578f..112103956da 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -13,7 +13,7 @@ void main()
 {
 	vec3 col = gl_Color.rgb * texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
 	gl_FragData[0] = vec4(col, 0.0);
-	gl_FragData[1] = vec4(gl_Color.aaa*1.5, gl_Color.a); // spec
+	gl_FragData[1] = gl_Color.aaaa; // spec
 	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
 	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
 }
-- 
GitLab


From f2233f0a24b8b826cb6e7dca064b42296997d1fa Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Apr 2010 10:40:27 +0100
Subject: [PATCH 370/683] more tweakery for EXT-7149 objects with white color
 and varied texture do not appear shiny with deferred rendering

---
 .../newview/app_settings/shaders/class1/deferred/diffuseF.glsl  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 59b1720578f..112103956da 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -13,7 +13,7 @@ void main()
 {
 	vec3 col = gl_Color.rgb * texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
 	gl_FragData[0] = vec4(col, 0.0);
-	gl_FragData[1] = vec4(gl_Color.aaa*1.5, gl_Color.a); // spec
+	gl_FragData[1] = gl_Color.aaaa; // spec
 	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
 	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
 }
-- 
GitLab


From cf258fa9defe5559678aa8417233f0e7882b7c32 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Apr 2010 11:58:45 +0100
Subject: [PATCH 371/683] expand EXT-7149 fix to include bumpyshiny.
 (transplanted from 57e136beedee9122dbbf46a1d91f6514f058b829)

---
 .../app_settings/shaders/class1/deferred/bumpF.glsl   | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 1c29dae5f7c..6e38caf5ef8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -14,14 +14,15 @@ varying vec3 vary_mat2;
 
 void main() 
 {
-	vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
+	vec3 col = gl_Color.rgb * texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
 	vec3 norm = texture2D(bumpMap, gl_TexCoord[0].xy).rgb * 2.0 - 1.0;
 
 	vec3 tnorm = vec3(dot(norm,vary_mat0),
-					  dot(norm,vary_mat1),
-					  dot(norm,vary_mat2));
+			  dot(norm,vary_mat1),
+			  dot(norm,vary_mat2));
 						
-	gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0);
-	gl_FragData[1] = vec4(col*gl_Color.a, gl_Color.a);
+	gl_FragData[0] = vec4(col, 0.0);
+	gl_FragData[1] = gl_Color.aaaa; // spec
+	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
 	gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0);
 }
-- 
GitLab


From dece522f171d2b1a33de829e6709d1b799e6edc2 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Apr 2010 11:58:45 +0100
Subject: [PATCH 372/683] expand EXT-7149 fix to include bumpyshiny.

---
 .../app_settings/shaders/class1/deferred/bumpF.glsl   | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 1c29dae5f7c..6e38caf5ef8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -14,14 +14,15 @@ varying vec3 vary_mat2;
 
 void main() 
 {
-	vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
+	vec3 col = gl_Color.rgb * texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
 	vec3 norm = texture2D(bumpMap, gl_TexCoord[0].xy).rgb * 2.0 - 1.0;
 
 	vec3 tnorm = vec3(dot(norm,vary_mat0),
-					  dot(norm,vary_mat1),
-					  dot(norm,vary_mat2));
+			  dot(norm,vary_mat1),
+			  dot(norm,vary_mat2));
 						
-	gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0);
-	gl_FragData[1] = vec4(col*gl_Color.a, gl_Color.a);
+	gl_FragData[0] = vec4(col, 0.0);
+	gl_FragData[1] = gl_Color.aaaa; // spec
+	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
 	gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0);
 }
-- 
GitLab


From b0fa1e011f14356b3634f39d32f43e244b6f1298 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Apr 2010 13:50:59 +0100
Subject: [PATCH 373/683] EXT-7162 90% transparent textures are invisible when
 Lighting and Shadows are enabled (transplanted from
 0aaf4b4676f27560cc436d0ff74b7d812a1e6662)

---
 indra/llrender/llimagegl.cpp | 43 ++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 00f0fd5b9a9..2f02ccf30b5 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1653,6 +1653,7 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 	}
 
 	U32 length = w * h;
+	U32 alphatotal = 0;
 	
 	U32 sample[16];
 	memset(sample, 0, sizeof(U32)*16);
@@ -1672,11 +1673,15 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 			const GLubyte* current = rowstart;
 			for (U32 x = 0; x < w; x+=2)
 			{
-				U32 s1 = current[0];
-				U32 s2 = current[w * mAlphaStride];
+				const U32 s1 = current[0];
+				alphatotal += s1;
+				const U32 s2 = current[w * mAlphaStride];
+				alphatotal += s2;
 				current += mAlphaStride;
-				U32 s3 = current[0];
-				U32 s4 = current[w * mAlphaStride];
+				const U32 s3 = current[0];
+				alphatotal += s3;
+				const U32 s4 = current[w * mAlphaStride];
+				alphatotal += s4;
 				current += mAlphaStride;
 
 				++sample[s1/16];
@@ -1684,19 +1689,23 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 				++sample[s3/16];
 				++sample[s4/16];
 
-				sample[(s1+s2+s3+s4)/(16 * 4)] += 4;
+				const U32 asum = (s1+s2+s3+s4);
+				alphatotal += asum;
+				sample[asum/(16*4)] += 4;
 			}
 			
 			rowstart += 2 * w * mAlphaStride;
 		}
-		length += length;
+		length *= 2; // we sampled everything twice, essentially
 	}
 	else
 	{
 		const GLubyte* current = ((const GLubyte*) data_in) + mAlphaOffset;
 		for (U32 i = 0; i < length; i++)
 		{
-			++sample[*current/16];
+			const U32 s1 = *current;
+			alphatotal += s1;
+			++sample[s1/16];
 			current += mAlphaStride;
 		}
 	}
@@ -1704,15 +1713,31 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 	// if more than 1/16th of alpha samples are mid-range, this
 	// shouldn't be treated as a 1-bit mask
 
+	// also, if all of the alpha samples are clumped on one half
+	// of the range (but not at an absolute extreme), then consider
+	// this to be an intentional effect and don't treat as a mask.
+
 	U32 midrangetotal = 0;
 	for (U32 i = 4; i < 11; i++)
 	{
 		midrangetotal += sample[i];
 	}
+	U32 lowerhalftotal = 0;
+	for (U32 i = 0; i < 8; i++)
+	{
+		lowerhalftotal += sample[i];
+	}
+	U32 upperhalftotal = 0;
+	for (U32 i = 8; i < 16; i++)
+	{
+		upperhalftotal += sample[i];
+	}
 
-	if (midrangetotal > length/16)
+	if (midrangetotal > length/16 || // lots of midrange, or
+	    (lowerhalftotal == length && alphatotal != 0) || // all close to transparent but not all totally transparent, or
+	    (upperhalftotal == length && alphatotal != 255*length)) // all close to opaque but not all totally opaque
 	{
-		mIsMask = FALSE;
+		mIsMask = FALSE; // not suitable for masking
 	}
 	else
 	{
-- 
GitLab


From 5ab2d0755578b4129b532f67a78d780be039fed0 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Apr 2010 13:50:59 +0100
Subject: [PATCH 374/683] EXT-7162 90% transparent textures are invisible when
 Lighting and Shadows are enabled

---
 indra/llrender/llimagegl.cpp | 43 ++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 00f0fd5b9a9..2f02ccf30b5 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1653,6 +1653,7 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 	}
 
 	U32 length = w * h;
+	U32 alphatotal = 0;
 	
 	U32 sample[16];
 	memset(sample, 0, sizeof(U32)*16);
@@ -1672,11 +1673,15 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 			const GLubyte* current = rowstart;
 			for (U32 x = 0; x < w; x+=2)
 			{
-				U32 s1 = current[0];
-				U32 s2 = current[w * mAlphaStride];
+				const U32 s1 = current[0];
+				alphatotal += s1;
+				const U32 s2 = current[w * mAlphaStride];
+				alphatotal += s2;
 				current += mAlphaStride;
-				U32 s3 = current[0];
-				U32 s4 = current[w * mAlphaStride];
+				const U32 s3 = current[0];
+				alphatotal += s3;
+				const U32 s4 = current[w * mAlphaStride];
+				alphatotal += s4;
 				current += mAlphaStride;
 
 				++sample[s1/16];
@@ -1684,19 +1689,23 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 				++sample[s3/16];
 				++sample[s4/16];
 
-				sample[(s1+s2+s3+s4)/(16 * 4)] += 4;
+				const U32 asum = (s1+s2+s3+s4);
+				alphatotal += asum;
+				sample[asum/(16*4)] += 4;
 			}
 			
 			rowstart += 2 * w * mAlphaStride;
 		}
-		length += length;
+		length *= 2; // we sampled everything twice, essentially
 	}
 	else
 	{
 		const GLubyte* current = ((const GLubyte*) data_in) + mAlphaOffset;
 		for (U32 i = 0; i < length; i++)
 		{
-			++sample[*current/16];
+			const U32 s1 = *current;
+			alphatotal += s1;
+			++sample[s1/16];
 			current += mAlphaStride;
 		}
 	}
@@ -1704,15 +1713,31 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 	// if more than 1/16th of alpha samples are mid-range, this
 	// shouldn't be treated as a 1-bit mask
 
+	// also, if all of the alpha samples are clumped on one half
+	// of the range (but not at an absolute extreme), then consider
+	// this to be an intentional effect and don't treat as a mask.
+
 	U32 midrangetotal = 0;
 	for (U32 i = 4; i < 11; i++)
 	{
 		midrangetotal += sample[i];
 	}
+	U32 lowerhalftotal = 0;
+	for (U32 i = 0; i < 8; i++)
+	{
+		lowerhalftotal += sample[i];
+	}
+	U32 upperhalftotal = 0;
+	for (U32 i = 8; i < 16; i++)
+	{
+		upperhalftotal += sample[i];
+	}
 
-	if (midrangetotal > length/16)
+	if (midrangetotal > length/16 || // lots of midrange, or
+	    (lowerhalftotal == length && alphatotal != 0) || // all close to transparent but not all totally transparent, or
+	    (upperhalftotal == length && alphatotal != 255*length)) // all close to opaque but not all totally opaque
 	{
-		mIsMask = FALSE;
+		mIsMask = FALSE; // not suitable for masking
 	}
 	else
 	{
-- 
GitLab


From f324787a70b8fccc7a8ea202805bf726fba765a7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 1 May 2010 00:45:44 -0500
Subject: [PATCH 375/683] Rigged attachment integration WIP.

---
 indra/llrender/llglslshader.cpp               |   2 +-
 .../shaders/class1/deferred/diffuseV.glsl     |   2 +-
 indra/newview/lldrawpool.cpp                  |   5 -
 indra/newview/lldrawpool.h                    |   2 -
 indra/newview/lldrawpoolavatar.cpp            | 244 +++++++++++++++++-
 indra/newview/lldrawpoolavatar.h              |  42 ++-
 indra/newview/lldrawpoolbump.cpp              |  54 ++--
 indra/newview/lldrawpoolbump.h                |   4 +
 indra/newview/llface.cpp                      |   5 +
 indra/newview/llface.h                        |   1 +
 indra/newview/llviewerobject.cpp              |  19 ++
 indra/newview/llviewerobject.h                |   1 +
 indra/newview/llviewershadermgr.cpp           |  27 +-
 indra/newview/llviewershadermgr.h             |   1 +
 indra/newview/llvoavatar.cpp                  |  99 +------
 indra/newview/llvovolume.cpp                  |  66 ++++-
 16 files changed, 440 insertions(+), 134 deletions(-)

diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 949057df049..9256e3959cd 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -124,7 +124,7 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
 	{
 		GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second);
 		LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL;
-		if (mShaderLevel > 0)
+		if (shaderhandle > 0)
 		{
 			attachObject(shaderhandle);
 		}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
index 44468cdfa29..b4588426572 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
@@ -13,7 +13,7 @@ void main()
 	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 
 	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
 	
-	vary_normal = normalize(gl_NormalMatrix * gl_Normal);
+	vary_nomral = normalize(gl_NormalMatrix * gl_Normal);
 
 	gl_FrontColor = gl_Color;
 }
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index ae30af36478..a99b80d6185 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -248,11 +248,6 @@ void LLFacePool::dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures
 {
 }
 
-BOOL LLFacePool::moveFace(LLFace *face, LLDrawPool *poolp, BOOL copy_data)
-{
-	return TRUE;
-}
-
 // static
 S32 LLFacePool::drawLoop(face_array_t& face_list)
 {
diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index 67870c10e93..e46d503db32 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -187,8 +187,6 @@ class LLFacePool : public LLDrawPool
 	virtual void resetDrawOrders();
 	void resetAll();
 
-	BOOL moveFace(LLFace *face, LLDrawPool *poolp, BOOL copy_data = FALSE);
-
 	void destroy();
 
 	void buildEdges();
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 62226383a4b..02c7e3bb6f6 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -39,13 +39,17 @@
 #include "m3math.h"
 
 #include "lldrawable.h"
+#include "lldrawpoolbump.h"
 #include "llface.h"
+#include "llmeshrepository.h"
 #include "llsky.h"
 #include "llviewercamera.h"
 #include "llviewerregion.h"
 #include "noise.h"
 #include "pipeline.h"
 #include "llviewershadermgr.h"
+#include "llvovolume.h"
+#include "llvolume.h"
 #include "llappviewer.h"
 #include "llrendersphere.h"
 #include "llviewerpartsim.h"
@@ -94,6 +98,8 @@ static BOOL sRenderingSkinned = FALSE;
 S32 normal_channel = -1;
 S32 specular_channel = -1;
 S32 diffuse_channel = -1;
+S32 cube_channel = -1;
+
 
 static LLFastTimer::DeclareTimer FTM_SHADOW_AVATAR("Avatar Shadow");
 
@@ -358,7 +364,7 @@ S32 LLDrawPoolAvatar::getNumPasses()
 	}
 	else if (getVertexShaderLevel() > 0)
 	{
-		return 4;
+		return 5;
 	}
 	else
 	{
@@ -402,7 +408,10 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 		beginSkinned();
 		break;
 	case 3:
-		beginRigged();
+		beginRiggedSimple();
+		break;
+	case 4:
+		beginRiggedShinySimple();
 		break;
 	}
 }
@@ -429,7 +438,10 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 		endSkinned();
 		break;
 	case 3:
-		endRigged();
+		endRiggedSimple();
+		break;
+	case 4:
+		endRiggedShinySimple();
 		break;
 	}
 }
@@ -616,14 +628,15 @@ void LLDrawPoolAvatar::endSkinned()
 	gGL.getTexUnit(0)->activate();
 }
 
-void LLDrawPoolAvatar::beginRigged()
+void LLDrawPoolAvatar::beginRiggedSimple()
 {
 	sVertexProgram = &gSkinnedObjectSimpleProgram;
+	diffuse_channel = 0;
 	gSkinnedObjectSimpleProgram.bind();
 	LLVertexBuffer::sWeight4Loc = gSkinnedObjectSimpleProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
-void LLDrawPoolAvatar::endRigged()
+void LLDrawPoolAvatar::endRiggedSimple()
 {
 	sVertexProgram = NULL;
 	LLVertexBuffer::unbind();
@@ -631,6 +644,23 @@ void LLDrawPoolAvatar::endRigged()
 	LLVertexBuffer::sWeight4Loc = -1;
 }
 
+void LLDrawPoolAvatar::beginRiggedShinySimple()
+{
+	sVertexProgram = &gSkinnedObjectShinySimpleProgram;
+	sVertexProgram->bind();
+	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, diffuse_channel, cube_channel, false);
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endRiggedShinySimple()
+{
+	LLVertexBuffer::unbind();
+	LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, diffuse_channel, cube_channel, false);
+	sVertexProgram->unbind();
+	sVertexProgram = NULL;
+	LLVertexBuffer::sWeight4Loc = -1;
+}
+
 void LLDrawPoolAvatar::beginDeferredRigged()
 {
 	sVertexProgram = &gDeferredSkinnedDiffuseProgram;
@@ -790,9 +820,16 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 
 	if (pass == 3)
 	{
-		avatarp->renderSkinnedAttachments();
+		renderRiggedSimple(avatarp);
+		return;
+	}
+
+	if (pass == 4)
+	{
+		renderRiggedShinySimple(avatarp);
 		return;
 	}
+
 	
 	if (sShaderLevel > 0)
 	{
@@ -830,13 +867,146 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 	}
 }
 
+void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face, U32 data_mask)
+{
+	LLVertexBuffer* buff = face->mVertexBuffer;
+
+	if (!buff || 
+		!buff->hasDataType(LLVertexBuffer::TYPE_WEIGHT4) ||
+		buff->getRequestedVerts() != vol_face.mVertices.size())
+	{
+		face->setGeomIndex(0);
+		face->setIndicesIndex(0);
+		face->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
+
+		face->mVertexBuffer = new LLVertexBuffer(data_mask, 0);
+		face->mVertexBuffer->allocateBuffer(vol_face.mVertices.size(), vol_face.mIndices.size(), true);
+
+		U16 offset = 0;
+		
+		LLMatrix4 mat_vert = skin->mBindShapeMatrix;
+		glh::matrix4f m((F32*) mat_vert.mMatrix);
+		m = m.inverse().transpose();
+		
+		F32 mat3[] = 
+		{ m.m[0], m.m[1], m.m[2],
+		  m.m[4], m.m[5], m.m[6],
+		  m.m[8], m.m[9], m.m[10] };
+
+		LLMatrix3 mat_normal(mat3);				
+
+		face->getGeometryVolume(*volume, face->getTEOffset(), mat_vert, mat_normal, offset, true);
+		buff = face->mVertexBuffer;
+	}
+}
+
+void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask)
+{
+	for (U32 i = 0; i < mRiggedFace[type].size(); ++i)
+	{
+		LLFace* face = mRiggedFace[type][i];
+		LLDrawable* drawable = face->getDrawable();
+		if (!drawable)
+		{
+			continue;
+		}
+
+		LLVOVolume* vobj = drawable->getVOVolume();
+
+		if (!vobj)
+		{
+			continue;
+		}
+
+		LLVolume* volume = vobj->getVolume();
+		S32 te = face->getTEOffset();
+
+		if (!volume || volume->getNumVolumeFaces() <= te)
+		{
+			continue;
+		}
+
+		LLUUID mesh_id = volume->getParams().getSculptID();
+		if (mesh_id.isNull())
+		{
+			continue;
+		}
+
+		const LLMeshSkinInfo* skin = gMeshRepo.getSkinInfo(mesh_id);
+		if (!skin)
+		{
+			continue;
+		}
+
+		const LLVolumeFace& vol_face = volume->getVolumeFace(te);
+		updateRiggedFaceVertexBuffer(face, skin, volume, vol_face, data_mask);
+		
+		LLVertexBuffer* buff = face->mVertexBuffer;
+
+		if (buff)
+		{
+			LLMatrix4 mat[64];
+
+			for (U32 i = 0; i < skin->mJointNames.size(); ++i)
+			{
+				LLJoint* joint = avatar->getJoint(skin->mJointNames[i]);
+				if (joint)
+				{
+					mat[i] = skin->mInvBindMatrix[i];
+					mat[i] *= joint->getWorldMatrix();
+				}
+			}
+			
+			LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", 
+				skin->mJointNames.size(),
+				FALSE,
+				(GLfloat*) mat[0].mMatrix);
+			LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette[0]", 
+				skin->mJointNames.size(),
+				FALSE,
+				(GLfloat*) mat[0].mMatrix);
+
+			buff->setBuffer(data_mask);
+
+			U16 start = face->getGeomStart();
+			U16 end = start + face->getGeomCount()-1;
+			S32 offset = face->getIndicesStart();
+			U32 count = face->getIndicesCount();
+
+			gGL.getTexUnit(0)->bind(face->getTexture());
+			buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);		
+		}
+	}
+}
+
+void LLDrawPoolAvatar::renderRiggedSimple(LLVOAvatar* avatar)
+{
+	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
+							LLVertexBuffer::MAP_NORMAL | 
+							LLVertexBuffer::MAP_TEXCOORD0 |
+							LLVertexBuffer::MAP_COLOR |
+							LLVertexBuffer::MAP_WEIGHT4;
+
+	renderRigged(avatar, RIGGED_SIMPLE, data_mask);
+}
+
+	
+void LLDrawPoolAvatar::renderRiggedShinySimple(LLVOAvatar* avatar)
+{
+	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
+							LLVertexBuffer::MAP_NORMAL | 
+							LLVertexBuffer::MAP_TEXCOORD0 |
+							LLVertexBuffer::MAP_COLOR |
+							LLVertexBuffer::MAP_WEIGHT4;
+
+	renderRigged(avatar, RIGGED_SHINY_SIMPLE, data_mask);
+}
+
 //-----------------------------------------------------------------------------
 // renderForSelect()
 //-----------------------------------------------------------------------------
 void LLDrawPoolAvatar::renderForSelect()
 {
-
-
 	if (mDrawFace.empty())
 	{
 		return;
@@ -930,6 +1100,64 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const
 	return LLColor3(0.f, 1.f, 0.f);
 }
 
+void LLDrawPoolAvatar::addRiggedFace(LLFace* facep, U32 type)
+{
+	if (facep->getReferenceIndex() != -1)
+	{
+		llerrs << "Tried to add a rigged face that's referenced elsewhere." << llendl;
+	}	
+
+	if (type >= NUM_RIGGED_PASSES)
+	{
+		llerrs << "Invalid rigged face type." << llendl;
+	}
+
+	facep->setReferenceIndex(mRiggedFace[type].size());
+	facep->mDrawPoolp = this;
+	mRiggedFace[type].push_back(facep);
+}
+
+void LLDrawPoolAvatar::removeRiggedFace(LLFace* facep, U32 type)
+{
+	S32 index = facep->getReferenceIndex();
+	if (index == -1)
+	{
+		llerrs << "Tried to remove rigged face with invalid index." << llendl;
+	}
+
+	if (type > RIGGED_UNKNOWN)
+	{
+		llerrs << "Invalid rigged face type." << llendl;
+	}
+
+	facep->setReferenceIndex(-1);
+	facep->mDrawPoolp = NULL;
+
+	if (type == RIGGED_UNKNOWN)
+	{
+		for (U32 i = 0; i < NUM_RIGGED_PASSES; ++i)
+		{
+			if (mRiggedFace[i].size() > index && mRiggedFace[i][index] == facep)
+			{
+				type = i;
+				break;
+			}
+		}
+	}
+
+	if (type >= NUM_RIGGED_PASSES)
+	{
+		llerrs << "Could not find face for removal from current drawpool." << llendl;
+	}
+
+	mRiggedFace[type].erase(mRiggedFace[type].begin()+index);
+
+	for (S32 i = index; i < mRiggedFace[type].size(); ++i)
+	{ //bump indexes of currently held faces down after removal
+		mRiggedFace[type][i]->setReferenceIndex(i);
+	}
+}
+
 LLVertexBufferAvatar::LLVertexBufferAvatar()
 : LLVertexBuffer(sDataMask, 
 	GL_STREAM_DRAW_ARB) //avatars are always stream draw due to morph targets
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index b42cc54622c..0ebb035f2a4 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -37,6 +37,11 @@
 
 class LLVOAvatar;
 class LLGLSLShader;
+class LLFace;
+class LLMeshSkinInfo;
+class LLVolume;
+class LLVolumeFace;
+
 
 class LLDrawPoolAvatar : public LLFacePool
 {
@@ -91,12 +96,14 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginRigid();
 	void beginImpostor();
 	void beginSkinned();
-	void beginRigged();
-		
+	void beginRiggedSimple();
+	void beginRiggedShinySimple();
+
 	void endRigid();
 	void endImpostor();
 	void endSkinned();
-	void endRigged();
+	void endRiggedSimple();
+	void endRiggedShinySimple();
 
 	void beginDeferredImpostor();
 	void beginDeferredRigid();
@@ -108,11 +115,40 @@ class LLDrawPoolAvatar : public LLFacePool
 	void endDeferredSkinned();
 	void endDeferredRigged();
 		
+	void updateRiggedFaceVertexBuffer(LLFace* facep, 
+									  const LLMeshSkinInfo* skin, 
+									  LLVolume* volume,
+									  const LLVolumeFace& vol_face, 
+									  U32 data_mask);
+
+	void renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask);
+	void renderRiggedSimple(LLVOAvatar* avatar);
+	void renderRiggedShinySimple(LLVOAvatar* avatar);
+
 	/*virtual*/ LLViewerTexture *getDebugTexture();
 	/*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display
 
 	void renderAvatars(LLVOAvatar *single_avatar, S32 pass = -1); // renders only one avatar if single_avatar is not null.
 
+	typedef enum
+	{
+		RIGGED_SIMPLE = 0,
+		RIGGED_SHINY_SIMPLE,
+		RIGGED_SHINY_FULLBRIGHT,
+		RIGGED_SHINY_BUMP,
+		RIGGED_BUMP,
+		RIGGED_FULLBRIGHT,
+		RIGGED_ALPHA,
+		NUM_RIGGED_PASSES,
+		RIGGED_UNKNOWN,
+	} eRiggedPass;
+
+	
+	void addRiggedFace(LLFace* facep, U32 type);
+	void removeRiggedFace(LLFace* facep, U32 type = RIGGED_UNKNOWN); 
+
+	std::vector<LLFace*> mRiggedFace[NUM_RIGGED_PASSES];
+
 	static BOOL sSkipOpaque;
 	static BOOL sSkipTransparent;
 	static LLGLSLShader* sVertexProgram;
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 8f3e775976c..2f449fa42f5 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -323,30 +323,43 @@ void LLDrawPoolBump::beginShiny(bool invisible)
 		sVertexMask = VERTEX_MASK_SHINY | LLVertexBuffer::MAP_TEXCOORD0;
 	}
 	
-	if (LLPipeline::sUnderWaterRender)
+	if (getVertexShaderLevel() > 0)
 	{
-		shader = &gObjectShinyWaterProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			shader = &gObjectShinyWaterProgram;
+		}
+		else
+		{
+			shader = &gObjectShinyProgram;
+		}
+		shader->bind();
 	}
 	else
 	{
-		shader = &gObjectShinyProgram;
+		shader = NULL;
 	}
 
+	bindCubeMap(shader, mVertexShaderLevel, diffuse_channel, cube_channel, invisible);
+}
+
+//static
+void LLDrawPoolBump::bindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible)
+{
 	LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL;
 	if( cube_map )
 	{
-		if (!invisible && LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0 )
+		if (!invisible && shader )
 		{
 			LLMatrix4 mat;
 			mat.initRows(LLVector4(gGLModelView+0),
 						 LLVector4(gGLModelView+4),
 						 LLVector4(gGLModelView+8),
 						 LLVector4(gGLModelView+12));
-			shader->bind();
 			LLVector3 vec = LLVector3(gShinyOrigin) * mat;
 			LLVector4 vec4(vec, gShinyOrigin.mV[3]);
 			shader->uniform4fv(LLViewerShaderMgr::SHINY_ORIGIN, 1, vec4.mV);			
-			if (mVertexShaderLevel > 1)
+			if (shader_level > 1)
 			{
 				cube_map->setMatrix(1);
 				// Make sure that texture coord generation happens for tex unit 1, as that's the one we use for 
@@ -408,22 +421,16 @@ void LLDrawPoolBump::renderShiny(bool invisible)
 	}
 }
 
-void LLDrawPoolBump::endShiny(bool invisible)
+//static
+void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible)
 {
-	LLFastTimer t(FTM_RENDER_SHINY);
-	if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))|| 
-		(invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)))
-	{
-		return;
-	}
-
 	LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL;
 	if( cube_map )
 	{
 		cube_map->disable();
 		cube_map->restoreMatrix();
 
-		if (!invisible && mVertexShaderLevel > 1)
+		if (!invisible && shader_level > 1)
 		{
 			shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
 					
@@ -434,7 +441,6 @@ void LLDrawPoolBump::endShiny(bool invisible)
 					shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 				}
 			}
-			shader->unbind();
 		}
 	}
 	gGL.getTexUnit(diffuse_channel)->disable();
@@ -442,6 +448,22 @@ void LLDrawPoolBump::endShiny(bool invisible)
 
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+}
+
+void LLDrawPoolBump::endShiny(bool invisible)
+{
+	LLFastTimer t(FTM_RENDER_SHINY);
+	if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))|| 
+		(invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)))
+	{
+		return;
+	}
+
+	unbindCubeMap(shader, mVertexShaderLevel, diffuse_channel, cube_channel, invisible);
+	if (shader)
+	{
+		shader->unbind();
+	}
 
 	diffuse_channel = -1;
 	cube_channel = 0;
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index 2019f1df269..89bbefe7785 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -41,6 +41,7 @@
 class LLImageRaw;
 class LLSpatialGroup;
 class LLDrawInfo;
+class LLGLSLShader;
 class LLViewerFetchedTexture;
 
 class LLDrawPoolBump : public LLRenderPass
@@ -79,6 +80,9 @@ protected :
 	void renderBump();
 	void endBump();
 
+	static void bindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible);
+	static void unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible);
+
 	virtual S32 getNumDeferredPasses();
 	/*virtual*/ void beginDeferredPass(S32 pass);
 	/*virtual*/ void endDeferredPass(S32 pass);
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 7866e49bae4..0e0b8447caf 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -205,7 +205,12 @@ void LLFace::destroy()
 	if (mDrawPoolp)
 	{
 		LLFastTimer t(FTM_DESTROY_DRAWPOOL);
+
+		if (this->isState(LLFace::RIGGED) && mDrawPoolp->getType() == LLDrawPool::POOL_AVATAR)
 		mDrawPoolp->removeFace(this);
+
+		
+		
 		mDrawPoolp = NULL;
 	}
 
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index bbf8de04bc9..2b8fdf2e582 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -234,6 +234,7 @@ class LLFace
 private:
 	friend class LLGeometryManager;
 	friend class LLVolumeGeometryManager;
+	friend class LLDrawPoolAvatar;
 
 	U32			mState;
 	LLFacePool*	mDrawPoolp;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 6bd3ceb8a85..3aecd0175d2 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5219,6 +5219,25 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
 	return ;
 }
 
+//virtual
+LLVOAvatar* LLViewerObject::getAvatar() const
+{
+	if (isAttachment())
+	{
+		LLViewerObject* vobj = (LLViewerObject*) getParent();
+
+		while (vobj && !vobj->asAvatar())
+		{
+			vobj = (LLViewerObject*) vobj->getParent();
+		}
+
+		return (LLVOAvatar*) vobj;
+	}
+
+	return NULL;
+}
+
+
 class ObjectPhysicsProperties : public LLHTTPNode
 {
 public:
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 594d7a08278..0fd0cbfa604 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -181,6 +181,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	void			setOnActiveList(BOOL on_active)		{ mOnActiveList = on_active; }
 
 	virtual BOOL	isAttachment() const { return FALSE; }
+	virtual LLVOAvatar* getAvatar() const;  //get the avatar this object is attached to, or NULL if object is not an attachment
 	virtual BOOL	isHUDAttachment() const { return FALSE; }
 	virtual void 	updateRadius() {};
 	virtual F32 	getVObjRadius() const; // default implemenation is mDrawable->getRadius()
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index d978e856a60..fe68d6eaa4c 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -79,6 +79,7 @@ LLGLSLShader		gObjectShinyWaterProgram;
 
 //object hardware skinning shaders
 LLGLSLShader		gSkinnedObjectSimpleProgram;
+LLGLSLShader		gSkinnedObjectShinySimpleProgram;
 
 //environment shaders
 LLGLSLShader		gTerrainProgram;
@@ -154,6 +155,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gObjectFullbrightProgram);
 	mShaderList.push_back(&gObjectFullbrightShinyProgram);
 	mShaderList.push_back(&gSkinnedObjectSimpleProgram);
+	mShaderList.push_back(&gSkinnedObjectShinySimpleProgram);
 	mShaderList.push_back(&gTerrainProgram);
 	mShaderList.push_back(&gTerrainWaterProgram);
 	mShaderList.push_back(&gObjectSimpleWaterProgram);
@@ -505,6 +507,9 @@ void LLViewerShaderMgr::setShaders()
 			if (!loadShadersDeferred())
 			{
 				gSavedSettings.setBOOL("RenderDeferred", FALSE);
+				reentrance = false;
+				setShaders();
+				return;
 			}
 #endif
 		}
@@ -557,6 +562,8 @@ void LLViewerShaderMgr::unloadShaders()
 	gObjectShinyWaterProgram.unload();
 
 	gSkinnedObjectSimpleProgram.unload();
+	gSkinnedObjectShinySimpleProgram.unload();
+	
 
 	gWaterProgram.unload();
 	gUnderWaterProgram.unload();
@@ -917,7 +924,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredGIProgram.unload();
 		gDeferredGIFinalProgram.unload();
 		gDeferredWaterProgram.unload();
-		return FALSE;
+		return TRUE;
 	}
 
 	mVertexShaderLevel[SHADER_AVATAR] = 1;
@@ -1251,6 +1258,8 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		gObjectFullbrightProgram.unload();
 		gObjectFullbrightWaterProgram.unload();
 		gSkinnedObjectSimpleProgram.unload();
+		gSkinnedObjectShinySimpleProgram.unload();
+	
 		return FALSE;
 	}
 
@@ -1376,6 +1385,22 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		success = gSkinnedObjectSimpleProgram.createShader(NULL, NULL);
 	}
 
+	if (success)
+	{
+		gSkinnedObjectShinySimpleProgram.mName = "Skinned Shiny Simple Shader";
+		gSkinnedObjectShinySimpleProgram.mFeatures.calculatesLighting = true;
+		gSkinnedObjectShinySimpleProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectShinySimpleProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectShinySimpleProgram.mFeatures.hasAtmospherics = true;
+		gSkinnedObjectShinySimpleProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectShinySimpleProgram.mFeatures.isShiny = true;
+		gSkinnedObjectShinySimpleProgram.mShaderFiles.clear();
+		gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectShinySimpleProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectShinySimpleProgram.createShader(NULL, &mShinyUniforms);
+	}
+
 	if( !success )
 	{
 		mVertexShaderLevel[SHADER_OBJECT] = 0;
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index b279a59777b..beac5462e2d 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -315,6 +315,7 @@ extern LLGLSLShader			gObjectShinyProgram;
 extern LLGLSLShader			gObjectShinyWaterProgram;
 
 extern LLGLSLShader			gSkinnedObjectSimpleProgram;
+extern LLGLSLShader			gSkinnedObjectShinySimpleProgram;
 
 //environment shaders
 extern LLGLSLShader			gTerrainProgram;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 7cdbebf4d1c..c51a7d9cbb7 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3642,7 +3642,7 @@ bool LLVOAvatar::shouldAlphaMask()
 
 U32 LLVOAvatar::renderSkinnedAttachments()
 {
-	U32 num_indices = 0;
+	/*U32 num_indices = 0;
 	
 	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
 							LLVertexBuffer::MAP_NORMAL | 
@@ -3670,107 +3670,14 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 						LLFace* face = drawable->getFace(i);
 						if (face->isState(LLFace::RIGGED))
 						{
-							LLVolume* volume = attached_object->getVolume();
-							if (!volume || volume->getNumVolumeFaces() <= i)
-							{
-								continue;
-							}
-
-							const LLVolumeFace& vol_face = volume->getVolumeFace(i);
-
-							const LLMeshSkinInfo* skin = NULL;
-							LLVertexBuffer* buff = face->mVertexBuffer;
-							LLUUID mesh_id = volume->getParams().getSculptID();;
-
-							if (!buff || 
-								!buff->hasDataType(LLVertexBuffer::TYPE_WEIGHT4) ||
-								buff->getRequestedVerts() != vol_face.mVertices.size())
-							{
-								face->mVertexBuffer = NULL;
-								face->mLastVertexBuffer = NULL;
-								buff = NULL;
-
-								if (mesh_id.notNull())
-								{
-									skin = gMeshRepo.getSkinInfo(mesh_id);
-									if (skin)
-									{
-										face->mVertexBuffer = new LLVertexBuffer(data_mask, 0);
-										face->mVertexBuffer->allocateBuffer(vol_face.mVertices.size(), vol_face.mIndices.size(), true);
-
-										face->setGeomIndex(0);
-										face->setIndicesIndex(0);
-										face->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
-
-										U16 offset = 0;
-										
-										LLMatrix4 mat_vert = skin->mBindShapeMatrix;
-										glh::matrix4f m((F32*) mat_vert.mMatrix);
-										m = m.inverse().transpose();
-										
-										F32 mat3[] = 
-										{ m.m[0], m.m[1], m.m[2],
-										  m.m[4], m.m[5], m.m[6],
-										  m.m[8], m.m[9], m.m[10] };
-
-										LLMatrix3 mat_normal(mat3);				
-
-										face->getGeometryVolume(*volume, i, mat_vert, mat_normal, offset, true);
-										buff = face->mVertexBuffer;
-									}
-								}
-							}								
 							
-							if (buff && mesh_id.notNull())
-							{
-								if (!skin)
-								{
-									skin = gMeshRepo.getSkinInfo(mesh_id);
-								}
-
-								if (skin)
-								{
-									LLMatrix4 mat[64];
-
-									for (U32 i = 0; i < skin->mJointNames.size(); ++i)
-									{
-										LLJoint* joint = getJoint(skin->mJointNames[i]);
-										if (joint)
-										{
-											mat[i] = skin->mInvBindMatrix[i];
-											mat[i] *= joint->getWorldMatrix();
-										}
-									}
-									
-									LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", 
-										skin->mJointNames.size(),
-										FALSE,
-										(GLfloat*) mat[0].mMatrix);
-									LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette[0]", 
-										skin->mJointNames.size(),
-										FALSE,
-										(GLfloat*) mat[0].mMatrix);
-
-									buff->setBuffer(data_mask);
-
-									U16 start = face->getGeomStart();
-									U16 end = start + face->getGeomCount()-1;
-									S32 offset = face->getIndicesStart();
-									U32 count = face->getIndicesCount();
-
-									gGL.getTexUnit(0)->bind(face->getTexture());
-									buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);
-									
-								}
-							}
-						}
-					}
 				}
 			}
 		}
 	}
 
-	return num_indices;
+	return num_indices;*/
+	return 0;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 96f69b36761..e49b33bd80d 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -52,6 +52,7 @@
 #include "object_flags.h"
 #include "llagentconstants.h"
 #include "lldrawable.h"
+#include "lldrawpoolavatar.h"
 #include "lldrawpoolbump.h"
 #include "llface.h"
 #include "llspatialpartition.h"
@@ -73,6 +74,8 @@
 #include "llmeshrepository.h"
 #include "llagent.h"
 #include "llviewermediafocus.h"
+#include "llvoavatar.h"
+
 
 const S32 MIN_QUIET_FRAMES_COALESCE = 30;
 const F32 FORCE_SIMPLE_RENDER_AREA = 512.f;
@@ -3415,6 +3418,33 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_VB("Volume");
 static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
+LLDrawPoolAvatar* get_avatar_drawpool(LLViewerObject* vobj)
+{
+	LLVOAvatar* avatar = vobj->getAvatar();
+					
+	if (avatar)
+	{
+		LLDrawable* drawable = avatar->mDrawable;
+		if (drawable && drawable->getNumFaces() > 0)
+		{
+			LLFace* face = drawable->getFace(0);
+			if (face)
+			{
+				LLDrawPool* drawpool = face->getPool();
+				if (drawpool)
+				{
+					if (drawpool->getType() == LLDrawPool::POOL_AVATAR)
+					{
+						return (LLDrawPoolAvatar*) drawpool;
+					}
+				}
+			}
+		}
+	}
+
+	return NULL;
+}
+		
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
@@ -3499,13 +3529,47 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 					facep->mVertexBuffer = NULL;
 					facep->mLastVertexBuffer = NULL;
 					facep->setState(LLFace::RIGGED);
+					
+					//get drawpool of avatar with rigged face
+					LLDrawPoolAvatar* pool = get_avatar_drawpool(vobj);
+					
+					if (pool)
+					{
+						const LLTextureEntry* te = facep->getTextureEntry();
+
+						//remove face from old pool if it exists
+						LLDrawPool* old_pool = facep->getPool();
+						if (old_pool && old_pool->getType() == LLDrawPool::POOL_AVATAR)
+						{
+							((LLDrawPoolAvatar*) old_pool)->removeRiggedFace(facep);
+						}
+
+						//add face to new pool
+						if (te->getShiny())
+						{
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SHINY_SIMPLE);
+						}
+						else
+						{
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SIMPLE);
+						}
+					}
+
 				}
 
 				continue;
 			}
 			else
 			{
-				facep->clearState(LLFace::RIGGED);
+				if (facep->isState(LLFace::RIGGED))
+				{ //face is not rigged but used to be, remove from rigged face pool
+					LLDrawPoolAvatar* pool = (LLDrawPoolAvatar*) facep->getPool();
+					if (pool)
+					{
+						pool->removeRiggedFace(facep);
+					}
+					facep->clearState(LLFace::RIGGED);
+				}
 			}
 
 			if (cur_total > max_total || facep->getIndicesCount() <= 0 || facep->getGeomCount() <= 0)
-- 
GitLab


From 2f95a549a365ca2bedf7824014a687b3af88e20f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 1 May 2010 01:55:21 -0500
Subject: [PATCH 376/683] Fullbrigt skinned and fix for silly crash from not
 removing face references.

---
 .../shaders/class1/objects/shinyV.glsl        |  2 +-
 indra/newview/lldrawpoolavatar.cpp            | 40 ++++++++++++++++++-
 indra/newview/lldrawpoolavatar.h              |  5 ++-
 indra/newview/llface.cpp                      | 13 ++++--
 indra/newview/llviewershadermgr.cpp           | 19 +++++++++
 indra/newview/llviewershadermgr.h             |  1 +
 indra/newview/llvovolume.cpp                  |  9 ++++-
 7 files changed, 81 insertions(+), 8 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl b/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
index c2e1ddf734f..101458c438d 100644
--- a/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
@@ -12,7 +12,7 @@ uniform vec4 origin;
 void main()
 {
 	//transform vertex
-	gl_Position = ftransform(); //gl_ModelViewProjectionMatrix * gl_Vertex;
+	gl_Position = ftransform();
 	
 	vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
 	vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 02c7e3bb6f6..9463be6059f 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -364,7 +364,7 @@ S32 LLDrawPoolAvatar::getNumPasses()
 	}
 	else if (getVertexShaderLevel() > 0)
 	{
-		return 5;
+		return 6;
 	}
 	else
 	{
@@ -411,6 +411,9 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 		beginRiggedSimple();
 		break;
 	case 4:
+		beginRiggedFullbright();
+		break;
+	case 5:
 		beginRiggedShinySimple();
 		break;
 	}
@@ -441,6 +444,9 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 		endRiggedSimple();
 		break;
 	case 4:
+		endRiggedFullbright();
+		break;
+	case 5:
 		endRiggedShinySimple();
 		break;
 	}
@@ -644,6 +650,22 @@ void LLDrawPoolAvatar::endRiggedSimple()
 	LLVertexBuffer::sWeight4Loc = -1;
 }
 
+void LLDrawPoolAvatar::beginRiggedFullbright()
+{
+	sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	diffuse_channel = 0;
+	gSkinnedObjectFullbrightProgram.bind();
+	LLVertexBuffer::sWeight4Loc = gSkinnedObjectFullbrightProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endRiggedFullbright()
+{
+	sVertexProgram = NULL;
+	LLVertexBuffer::unbind();
+	gSkinnedObjectFullbrightProgram.unbind();
+	LLVertexBuffer::sWeight4Loc = -1;
+}
+
 void LLDrawPoolAvatar::beginRiggedShinySimple()
 {
 	sVertexProgram = &gSkinnedObjectShinySimpleProgram;
@@ -825,6 +847,12 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 	}
 
 	if (pass == 4)
+	{
+		renderRiggedFullbright(avatarp);
+		return;
+	}
+
+	if (pass == 5)
 	{
 		renderRiggedShinySimple(avatarp);
 		return;
@@ -990,6 +1018,16 @@ void LLDrawPoolAvatar::renderRiggedSimple(LLVOAvatar* avatar)
 	renderRigged(avatar, RIGGED_SIMPLE, data_mask);
 }
 
+void LLDrawPoolAvatar::renderRiggedFullbright(LLVOAvatar* avatar)
+{
+	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
+							LLVertexBuffer::MAP_TEXCOORD0 |
+							LLVertexBuffer::MAP_COLOR |
+							LLVertexBuffer::MAP_WEIGHT4;
+
+	renderRigged(avatar, RIGGED_FULLBRIGHT, data_mask);
+}
+
 	
 void LLDrawPoolAvatar::renderRiggedShinySimple(LLVOAvatar* avatar)
 {
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index 0ebb035f2a4..84430693768 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -97,12 +97,14 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginImpostor();
 	void beginSkinned();
 	void beginRiggedSimple();
+	void beginRiggedFullbright();
 	void beginRiggedShinySimple();
 
 	void endRigid();
 	void endImpostor();
 	void endSkinned();
 	void endRiggedSimple();
+	void endRiggedFullbright();
 	void endRiggedShinySimple();
 
 	void beginDeferredImpostor();
@@ -123,6 +125,7 @@ class LLDrawPoolAvatar : public LLFacePool
 
 	void renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask);
 	void renderRiggedSimple(LLVOAvatar* avatar);
+	void renderRiggedFullbright(LLVOAvatar* avatar);
 	void renderRiggedShinySimple(LLVOAvatar* avatar);
 
 	/*virtual*/ LLViewerTexture *getDebugTexture();
@@ -133,11 +136,11 @@ class LLDrawPoolAvatar : public LLFacePool
 	typedef enum
 	{
 		RIGGED_SIMPLE = 0,
+		RIGGED_FULLBRIGHT,
 		RIGGED_SHINY_SIMPLE,
 		RIGGED_SHINY_FULLBRIGHT,
 		RIGGED_SHINY_BUMP,
 		RIGGED_BUMP,
-		RIGGED_FULLBRIGHT,
 		RIGGED_ALPHA,
 		NUM_RIGGED_PASSES,
 		RIGGED_UNKNOWN,
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 0e0b8447caf..9df692e787e 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -41,6 +41,7 @@
 #include "m3math.h"
 #include "v3color.h"
 
+#include "lldrawpoolavatar.h"
 #include "lldrawpoolbump.h"
 #include "llgl.h"
 #include "llrender.h"
@@ -207,10 +208,14 @@ void LLFace::destroy()
 		LLFastTimer t(FTM_DESTROY_DRAWPOOL);
 
 		if (this->isState(LLFace::RIGGED) && mDrawPoolp->getType() == LLDrawPool::POOL_AVATAR)
-		mDrawPoolp->removeFace(this);
-
-		
-		
+		{
+			((LLDrawPoolAvatar*) mDrawPoolp)->removeRiggedFace(this);
+		}
+		else
+		{
+			mDrawPoolp->removeFace(this);
+		}
+	
 		mDrawPoolp = NULL;
 	}
 
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index fe68d6eaa4c..3cc5b4357ac 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -79,6 +79,7 @@ LLGLSLShader		gObjectShinyWaterProgram;
 
 //object hardware skinning shaders
 LLGLSLShader		gSkinnedObjectSimpleProgram;
+LLGLSLShader		gSkinnedObjectFullbrightProgram;
 LLGLSLShader		gSkinnedObjectShinySimpleProgram;
 
 //environment shaders
@@ -155,6 +156,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gObjectFullbrightProgram);
 	mShaderList.push_back(&gObjectFullbrightShinyProgram);
 	mShaderList.push_back(&gSkinnedObjectSimpleProgram);
+	mShaderList.push_back(&gSkinnedObjectFullbrightProgram);
 	mShaderList.push_back(&gSkinnedObjectShinySimpleProgram);
 	mShaderList.push_back(&gTerrainProgram);
 	mShaderList.push_back(&gTerrainWaterProgram);
@@ -562,6 +564,7 @@ void LLViewerShaderMgr::unloadShaders()
 	gObjectShinyWaterProgram.unload();
 
 	gSkinnedObjectSimpleProgram.unload();
+	gSkinnedObjectFullbrightProgram.unload();
 	gSkinnedObjectShinySimpleProgram.unload();
 	
 
@@ -1258,6 +1261,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		gObjectFullbrightProgram.unload();
 		gObjectFullbrightWaterProgram.unload();
 		gSkinnedObjectSimpleProgram.unload();
+		gSkinnedObjectFullbrightProgram.unload();
 		gSkinnedObjectShinySimpleProgram.unload();
 	
 		return FALSE;
@@ -1385,6 +1389,21 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		success = gSkinnedObjectSimpleProgram.createShader(NULL, NULL);
 	}
 
+	if (success)
+	{
+		gSkinnedObjectFullbrightProgram.mName = "Skinned Fullbright Shader";
+		gSkinnedObjectFullbrightProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectFullbrightProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectFullbrightProgram.mFeatures.hasTransport = true;
+		gSkinnedObjectFullbrightProgram.mFeatures.isFullbright = true;
+		gSkinnedObjectFullbrightProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectFullbrightProgram.mShaderFiles.clear();
+		gSkinnedObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectFullbrightProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectFullbrightProgram.createShader(NULL, NULL);
+	}
+
 	if (success)
 	{
 		gSkinnedObjectShinySimpleProgram.mName = "Skinned Shiny Simple Shader";
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index beac5462e2d..b4fc336bf31 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -315,6 +315,7 @@ extern LLGLSLShader			gObjectShinyProgram;
 extern LLGLSLShader			gObjectShinyWaterProgram;
 
 extern LLGLSLShader			gSkinnedObjectSimpleProgram;
+extern LLGLSLShader			gSkinnedObjectFullbrightProgram;
 extern LLGLSLShader			gSkinnedObjectShinySimpleProgram;
 
 //environment shaders
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index e49b33bd80d..3449c05be8e 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3551,7 +3551,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 						}
 						else
 						{
-							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SIMPLE);
+							if (te->getFullbright())
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT);
+							}
+							else
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SIMPLE);
+							}
 						}
 					}
 
-- 
GitLab


From dc15fc5ba0fcf9907d834b523e6622d800d7ed4e Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 1 May 2010 02:56:23 -0500
Subject: [PATCH 377/683] Fullbright shiny skinned.

---
 indra/newview/lldrawpoolavatar.cpp  | 45 +++++++++++++++++++++++++++--
 indra/newview/lldrawpoolavatar.h    | 11 ++++---
 indra/newview/llviewershadermgr.cpp | 20 +++++++++++++
 indra/newview/llviewershadermgr.h   |  1 +
 indra/newview/llvovolume.cpp        |  9 +++++-
 5 files changed, 79 insertions(+), 7 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 9463be6059f..8227e8ede24 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -364,7 +364,7 @@ S32 LLDrawPoolAvatar::getNumPasses()
 	}
 	else if (getVertexShaderLevel() > 0)
 	{
-		return 6;
+		return 7;
 	}
 	else
 	{
@@ -416,6 +416,9 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 	case 5:
 		beginRiggedShinySimple();
 		break;
+	case 6:
+		beginRiggedFullbrightShiny();
+		break;
 	}
 }
 
@@ -449,6 +452,9 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 	case 5:
 		endRiggedShinySimple();
 		break;
+	case 6:
+		endRiggedFullbrightShiny();
+		break;
 	}
 }
 
@@ -683,6 +689,24 @@ void LLDrawPoolAvatar::endRiggedShinySimple()
 	LLVertexBuffer::sWeight4Loc = -1;
 }
 
+void LLDrawPoolAvatar::beginRiggedFullbrightShiny()
+{
+	sVertexProgram = &gSkinnedObjectFullbrightShinyProgram;
+	sVertexProgram->bind();
+	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, diffuse_channel, cube_channel, false);
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endRiggedFullbrightShiny()
+{
+	LLVertexBuffer::unbind();
+	LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, diffuse_channel, cube_channel, false);
+	sVertexProgram->unbind();
+	sVertexProgram = NULL;
+	LLVertexBuffer::sWeight4Loc = -1;
+}
+
+
 void LLDrawPoolAvatar::beginDeferredRigged()
 {
 	sVertexProgram = &gDeferredSkinnedDiffuseProgram;
@@ -858,6 +882,12 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		return;
 	}
 
+	if (pass == 6)
+	{
+		renderRiggedFullbrightShiny(avatarp);
+		return;
+	}
+
 	
 	if (sShaderLevel > 0)
 	{
@@ -1037,7 +1067,18 @@ void LLDrawPoolAvatar::renderRiggedShinySimple(LLVOAvatar* avatar)
 							LLVertexBuffer::MAP_COLOR |
 							LLVertexBuffer::MAP_WEIGHT4;
 
-	renderRigged(avatar, RIGGED_SHINY_SIMPLE, data_mask);
+	renderRigged(avatar, RIGGED_SHINY, data_mask);
+}
+
+void LLDrawPoolAvatar::renderRiggedFullbrightShiny(LLVOAvatar* avatar)
+{
+	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
+							LLVertexBuffer::MAP_NORMAL | 
+							LLVertexBuffer::MAP_TEXCOORD0 |
+							LLVertexBuffer::MAP_COLOR |
+							LLVertexBuffer::MAP_WEIGHT4;
+
+	renderRigged(avatar, RIGGED_FULLBRIGHT_SHINY, data_mask);
 }
 
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index 84430693768..d758bb07f0a 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -98,6 +98,7 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginSkinned();
 	void beginRiggedSimple();
 	void beginRiggedFullbright();
+	void beginRiggedFullbrightShiny();
 	void beginRiggedShinySimple();
 
 	void endRigid();
@@ -105,6 +106,7 @@ class LLDrawPoolAvatar : public LLFacePool
 	void endSkinned();
 	void endRiggedSimple();
 	void endRiggedFullbright();
+	void endRiggedFullbrightShiny();
 	void endRiggedShinySimple();
 
 	void beginDeferredImpostor();
@@ -127,6 +129,7 @@ class LLDrawPoolAvatar : public LLFacePool
 	void renderRiggedSimple(LLVOAvatar* avatar);
 	void renderRiggedFullbright(LLVOAvatar* avatar);
 	void renderRiggedShinySimple(LLVOAvatar* avatar);
+	void renderRiggedFullbrightShiny(LLVOAvatar* avatar);
 
 	/*virtual*/ LLViewerTexture *getDebugTexture();
 	/*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display
@@ -137,11 +140,11 @@ class LLDrawPoolAvatar : public LLFacePool
 	{
 		RIGGED_SIMPLE = 0,
 		RIGGED_FULLBRIGHT,
-		RIGGED_SHINY_SIMPLE,
-		RIGGED_SHINY_FULLBRIGHT,
-		RIGGED_SHINY_BUMP,
-		RIGGED_BUMP,
+		RIGGED_SHINY,
+		RIGGED_FULLBRIGHT_SHINY,
+		RIGGED_GLOW,
 		RIGGED_ALPHA,
+		RIGGED_FULLBRIGHT_ALPHA,
 		NUM_RIGGED_PASSES,
 		RIGGED_UNKNOWN,
 	} eRiggedPass;
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 3cc5b4357ac..eafc52748e9 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -80,6 +80,7 @@ LLGLSLShader		gObjectShinyWaterProgram;
 //object hardware skinning shaders
 LLGLSLShader		gSkinnedObjectSimpleProgram;
 LLGLSLShader		gSkinnedObjectFullbrightProgram;
+LLGLSLShader		gSkinnedObjectFullbrightShinyProgram;
 LLGLSLShader		gSkinnedObjectShinySimpleProgram;
 
 //environment shaders
@@ -157,6 +158,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gObjectFullbrightShinyProgram);
 	mShaderList.push_back(&gSkinnedObjectSimpleProgram);
 	mShaderList.push_back(&gSkinnedObjectFullbrightProgram);
+	mShaderList.push_back(&gSkinnedObjectFullbrightShinyProgram);
 	mShaderList.push_back(&gSkinnedObjectShinySimpleProgram);
 	mShaderList.push_back(&gTerrainProgram);
 	mShaderList.push_back(&gTerrainWaterProgram);
@@ -565,6 +567,7 @@ void LLViewerShaderMgr::unloadShaders()
 
 	gSkinnedObjectSimpleProgram.unload();
 	gSkinnedObjectFullbrightProgram.unload();
+	gSkinnedObjectFullbrightShinyProgram.unload();
 	gSkinnedObjectShinySimpleProgram.unload();
 	
 
@@ -1262,6 +1265,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		gObjectFullbrightWaterProgram.unload();
 		gSkinnedObjectSimpleProgram.unload();
 		gSkinnedObjectFullbrightProgram.unload();
+		gSkinnedObjectFullbrightShinyProgram.unload();
 		gSkinnedObjectShinySimpleProgram.unload();
 	
 		return FALSE;
@@ -1404,6 +1408,22 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		success = gSkinnedObjectFullbrightProgram.createShader(NULL, NULL);
 	}
 
+	if (success)
+	{
+		gSkinnedObjectFullbrightShinyProgram.mName = "Skinned Fullbright Shiny Shader";
+		gSkinnedObjectFullbrightShinyProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectFullbrightShinyProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectFullbrightShinyProgram.mFeatures.hasTransport = true;
+		gSkinnedObjectFullbrightShinyProgram.mFeatures.isShiny = true;
+		gSkinnedObjectFullbrightShinyProgram.mFeatures.isFullbright = true;
+		gSkinnedObjectFullbrightShinyProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectFullbrightShinyProgram.mShaderFiles.clear();
+		gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectFullbrightShinyProgram.createShader(NULL, &mShinyUniforms);
+	}
+
 	if (success)
 	{
 		gSkinnedObjectShinySimpleProgram.mName = "Skinned Shiny Simple Shader";
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index b4fc336bf31..bb28cd7ec20 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -316,6 +316,7 @@ extern LLGLSLShader			gObjectShinyWaterProgram;
 
 extern LLGLSLShader			gSkinnedObjectSimpleProgram;
 extern LLGLSLShader			gSkinnedObjectFullbrightProgram;
+extern LLGLSLShader			gSkinnedObjectFullbrightShinyProgram;
 extern LLGLSLShader			gSkinnedObjectShinySimpleProgram;
 
 //environment shaders
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 3449c05be8e..43252c553c1 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3547,7 +3547,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 						//add face to new pool
 						if (te->getShiny())
 						{
-							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SHINY_SIMPLE);
+							if (te->getFullbright())
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_SHINY);
+							}
+							else
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SHINY);
+							}
 						}
 						else
 						{
-- 
GitLab


From 58defe76b0eed6f773b961e8ba5cd3aeb856467a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sun, 2 May 2010 00:28:30 -0500
Subject: [PATCH 378/683] Rigged glow.

---
 indra/newview/lldrawpoolavatar.cpp | 214 ++++++++++++++++++++++++-----
 indra/newview/lldrawpoolavatar.h   |  13 +-
 indra/newview/llface.h             |   2 +
 indra/newview/llvovolume.cpp       |  21 ++-
 4 files changed, 212 insertions(+), 38 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 8227e8ede24..866aea42c4d 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -364,7 +364,7 @@ S32 LLDrawPoolAvatar::getNumPasses()
 	}
 	else if (getVertexShaderLevel() > 0)
 	{
-		return 7;
+		return 10;
 	}
 	else
 	{
@@ -419,6 +419,15 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 	case 6:
 		beginRiggedFullbrightShiny();
 		break;
+	case 7:
+		beginRiggedAlpha();
+		break;
+	case 8:
+		beginRiggedFullbrightAlpha();
+		break;
+	case 9:
+		beginRiggedGlow();
+		break;
 	}
 }
 
@@ -455,6 +464,15 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 	case 6:
 		endRiggedFullbrightShiny();
 		break;
+	case 7:
+		endRiggedAlpha();
+		break;
+	case 8:
+		endRiggedFullbrightAlpha();
+		break;
+	case 9:
+		endRiggedGlow();
+		break;
 	}
 }
 
@@ -656,6 +674,55 @@ void LLDrawPoolAvatar::endRiggedSimple()
 	LLVertexBuffer::sWeight4Loc = -1;
 }
 
+void LLDrawPoolAvatar::beginRiggedAlpha()
+{
+	sVertexProgram = &gSkinnedObjectSimpleProgram;
+	diffuse_channel = 0;
+	sVertexProgram->bind();
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endRiggedAlpha()
+{
+	sVertexProgram->unbind();
+	sVertexProgram = NULL;
+	LLVertexBuffer::unbind();
+	LLVertexBuffer::sWeight4Loc = -1;
+}
+
+
+void LLDrawPoolAvatar::beginRiggedFullbrightAlpha()
+{
+	sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	diffuse_channel = 0;
+	sVertexProgram->bind();
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endRiggedFullbrightAlpha()
+{
+	sVertexProgram->unbind();
+	sVertexProgram = NULL;
+	LLVertexBuffer::unbind();
+	LLVertexBuffer::sWeight4Loc = -1;
+}
+
+void LLDrawPoolAvatar::beginRiggedGlow()
+{
+	sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	diffuse_channel = 0;
+	sVertexProgram->bind();
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endRiggedGlow()
+{
+	sVertexProgram->unbind();
+	sVertexProgram = NULL;
+	LLVertexBuffer::unbind();
+	LLVertexBuffer::sWeight4Loc = -1;
+}
+
 void LLDrawPoolAvatar::beginRiggedFullbright()
 {
 	sVertexProgram = &gSkinnedObjectFullbrightProgram;
@@ -888,6 +955,48 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		return;
 	}
 
+	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);
+			return;
+		}
+
+		if (pass == 8)
+		{
+			renderRiggedFullbrightAlpha(avatarp);
+			return;
+		}
+	}
+
+	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);
+	}
+
 	
 	if (sShaderLevel > 0)
 	{
@@ -958,7 +1067,7 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSk
 	}
 }
 
-void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask)
+void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask, bool glow)
 {
 	for (U32 i = 0; i < mRiggedFace[type].size(); ++i)
 	{
@@ -1031,6 +1140,11 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, const U32 data
 			S32 offset = face->getIndicesStart();
 			U32 count = face->getIndicesCount();
 
+			if (glow)
+			{
+				glColor4f(0,0,0,face->getTextureEntry()->getGlow());
+			}
+
 			gGL.getTexUnit(0)->bind(face->getTexture());
 			buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);		
 		}
@@ -1081,6 +1195,39 @@ void LLDrawPoolAvatar::renderRiggedFullbrightShiny(LLVOAvatar* avatar)
 	renderRigged(avatar, RIGGED_FULLBRIGHT_SHINY, data_mask);
 }
 
+void LLDrawPoolAvatar::renderRiggedAlpha(LLVOAvatar* avatar)
+{
+	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
+							LLVertexBuffer::MAP_NORMAL | 
+							LLVertexBuffer::MAP_TEXCOORD0 |
+							LLVertexBuffer::MAP_COLOR |
+							LLVertexBuffer::MAP_WEIGHT4;
+
+	renderRigged(avatar, RIGGED_ALPHA, data_mask);
+}
+
+void LLDrawPoolAvatar::renderRiggedFullbrightAlpha(LLVOAvatar* avatar)
+{
+	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
+							LLVertexBuffer::MAP_TEXCOORD0 |
+							LLVertexBuffer::MAP_COLOR |
+							LLVertexBuffer::MAP_WEIGHT4;
+
+	renderRigged(avatar, RIGGED_FULLBRIGHT_ALPHA, data_mask);
+}
+
+void LLDrawPoolAvatar::renderRiggedGlow(LLVOAvatar* avatar)
+{
+	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
+							LLVertexBuffer::MAP_TEXCOORD0 |
+							LLVertexBuffer::MAP_WEIGHT4;
+
+	renderRigged(avatar, RIGGED_GLOW, data_mask, true);
+}
+
+
+
+
 //-----------------------------------------------------------------------------
 // renderForSelect()
 //-----------------------------------------------------------------------------
@@ -1181,60 +1328,57 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const
 
 void LLDrawPoolAvatar::addRiggedFace(LLFace* facep, U32 type)
 {
-	if (facep->getReferenceIndex() != -1)
+	if (facep->mRiggedIndex.empty())
 	{
-		llerrs << "Tried to add a rigged face that's referenced elsewhere." << llendl;
-	}	
+		facep->mRiggedIndex.resize(LLDrawPoolAvatar::NUM_RIGGED_PASSES);
+		for (U32 i = 0; i < facep->mRiggedIndex.size(); ++i)
+		{
+			facep->mRiggedIndex[i] = -1;
+		}
+	}
 
 	if (type >= NUM_RIGGED_PASSES)
 	{
 		llerrs << "Invalid rigged face type." << llendl;
 	}
 
-	facep->setReferenceIndex(mRiggedFace[type].size());
+	if (facep->mRiggedIndex[type] != -1)
+	{
+		llerrs << "Tried to add a rigged face that's referenced elsewhere." << llendl;
+	}	
+
+	
+	facep->mRiggedIndex[type] = mRiggedFace[type].size();
 	facep->mDrawPoolp = this;
 	mRiggedFace[type].push_back(facep);
 }
 
-void LLDrawPoolAvatar::removeRiggedFace(LLFace* facep, U32 type)
+void LLDrawPoolAvatar::removeRiggedFace(LLFace* facep)
 {
-	S32 index = facep->getReferenceIndex();
-	if (index == -1)
-	{
-		llerrs << "Tried to remove rigged face with invalid index." << llendl;
-	}
-
-	if (type > RIGGED_UNKNOWN)
-	{
-		llerrs << "Invalid rigged face type." << llendl;
-	}
-
-	facep->setReferenceIndex(-1);
+	
 	facep->mDrawPoolp = NULL;
 
-	if (type == RIGGED_UNKNOWN)
+	for (U32 i = 0; i < NUM_RIGGED_PASSES; ++i)
 	{
-		for (U32 i = 0; i < NUM_RIGGED_PASSES; ++i)
+		S32 index = facep->mRiggedIndex[i];
+		
+		if (index > -1)
 		{
 			if (mRiggedFace[i].size() > index && mRiggedFace[i][index] == facep)
 			{
-				type = i;
-				break;
+				facep->mRiggedIndex[i] = -1;
+				mRiggedFace[i].erase(mRiggedFace[i].begin()+index);
+				for (U32 j = index; j < mRiggedFace[i].size(); ++j)
+				{ //bump indexes down for faces referenced after erased face
+					mRiggedFace[i][j]->mRiggedIndex[i] = j;
+				}
+			}
+			else
+			{
+				llerrs << "Face reference data corrupt for rigged type " << i << llendl;
 			}
 		}
 	}
-
-	if (type >= NUM_RIGGED_PASSES)
-	{
-		llerrs << "Could not find face for removal from current drawpool." << llendl;
-	}
-
-	mRiggedFace[type].erase(mRiggedFace[type].begin()+index);
-
-	for (S32 i = index; i < mRiggedFace[type].size(); ++i)
-	{ //bump indexes of currently held faces down after removal
-		mRiggedFace[type][i]->setReferenceIndex(i);
-	}
 }
 
 LLVertexBufferAvatar::LLVertexBufferAvatar()
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index d758bb07f0a..59f9cf7ddb8 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -100,6 +100,9 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginRiggedFullbright();
 	void beginRiggedFullbrightShiny();
 	void beginRiggedShinySimple();
+	void beginRiggedAlpha();
+	void beginRiggedFullbrightAlpha();
+	void beginRiggedGlow();
 
 	void endRigid();
 	void endImpostor();
@@ -108,6 +111,9 @@ class LLDrawPoolAvatar : public LLFacePool
 	void endRiggedFullbright();
 	void endRiggedFullbrightShiny();
 	void endRiggedShinySimple();
+	void endRiggedAlpha();
+	void endRiggedFullbrightAlpha();
+	void endRiggedGlow();
 
 	void beginDeferredImpostor();
 	void beginDeferredRigid();
@@ -125,11 +131,14 @@ class LLDrawPoolAvatar : public LLFacePool
 									  const LLVolumeFace& vol_face, 
 									  U32 data_mask);
 
-	void renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask);
+	void renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask, bool glow = false);
 	void renderRiggedSimple(LLVOAvatar* avatar);
+	void renderRiggedAlpha(LLVOAvatar* avatar);
+	void renderRiggedFullbrightAlpha(LLVOAvatar* avatar);
 	void renderRiggedFullbright(LLVOAvatar* avatar);
 	void renderRiggedShinySimple(LLVOAvatar* avatar);
 	void renderRiggedFullbrightShiny(LLVOAvatar* avatar);
+	void renderRiggedGlow(LLVOAvatar* avatar);
 
 	/*virtual*/ LLViewerTexture *getDebugTexture();
 	/*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display
@@ -151,7 +160,7 @@ class LLDrawPoolAvatar : public LLFacePool
 
 	
 	void addRiggedFace(LLFace* facep, U32 type);
-	void removeRiggedFace(LLFace* facep, U32 type = RIGGED_UNKNOWN); 
+	void removeRiggedFace(LLFace* facep); 
 
 	std::vector<LLFace*> mRiggedFace[NUM_RIGGED_PASSES];
 
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 2b8fdf2e582..f9e9c3e0783 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -260,6 +260,8 @@ class LLFace
 	S32			mTEOffset;
 
 	S32			mReferenceIndex;
+	std::vector<S32> mRiggedIndex;
+	 
 	F32			mVSize;
 	F32			mPixelArea;
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 43252c553c1..e263f8d937f 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3545,7 +3545,21 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 						}
 
 						//add face to new pool
-						if (te->getShiny())
+						LLViewerTexture* tex = facep->getTexture();
+						U32 type = gPipeline.getPoolTypeFromTE(te, tex);
+
+						if (type == LLDrawPool::POOL_ALPHA)
+						{
+							if (te->getFullbright())
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA);
+							}
+							else
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_ALPHA);
+							}
+						}
+						else if (te->getShiny())
 						{
 							if (te->getFullbright())
 							{
@@ -3567,6 +3581,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SIMPLE);
 							}
 						}
+
+						if (te->getGlow())
+						{
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_GLOW);
+						}
 					}
 
 				}
-- 
GitLab


From eb283701afc7ecbe3009a9fb75be1dcb222a383b Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 4 May 2010 00:45:28 -0500
Subject: [PATCH 379/683] Deferred pipeline integration of rigged attachments
 and cleanup.

---
 indra/llrender/llvertexbuffer.h               |   2 +-
 .../shaders/class1/deferred/alphaF.glsl       |   5 +-
 .../shaders/class1/deferred/alphaV.glsl       |   2 +-
 .../shaders/class1/deferred/avatarAlphaV.glsl |   4 +-
 .../shaders/class1/deferred/diffuseV.glsl     |   2 +-
 .../shaders/class2/deferred/alphaF.glsl       |   2 +-
 indra/newview/lldrawpoolavatar.cpp            | 302 +++++++++++++-----
 indra/newview/lldrawpoolavatar.h              |  51 ++-
 indra/newview/lldrawpoolbump.cpp              |  27 +-
 indra/newview/lldrawpoolbump.h                |   7 +-
 indra/newview/llviewershadermgr.cpp           |  36 ++-
 indra/newview/llviewershadermgr.h             |   2 +
 indra/newview/llvovolume.cpp                  |  15 +
 13 files changed, 359 insertions(+), 98 deletions(-)

diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 225237215cb..d1700aa54ab 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -190,7 +190,7 @@ class LLVertexBuffer : public LLRefCount
 	U8* getIndicesPointer() const			{ return useVBOs() ? NULL : mMappedIndexData; }
 	U8* getVerticesPointer() const			{ return useVBOs() ? NULL : mMappedData; }
 	S32 getStride() const					{ return mStride; }
-	S32 getTypeMask() const					{ return mTypeMask; }
+	U32 getTypeMask() const					{ return mTypeMask; }
 	BOOL hasDataType(S32 type) const		{ return ((1 << type) & getTypeMask()) ? TRUE : FALSE; }
 	S32 getSize() const						{ return mNumVerts*mStride; }
 	S32 getIndicesSize() const				{ return mNumIndices * sizeof(U16); }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index fea2e160908..6f027de6a23 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -22,7 +22,6 @@ varying vec3 vary_ambient;
 varying vec3 vary_directional;
 varying vec3 vary_fragcoord;
 varying vec3 vary_position;
-varying vec3 vary_light;
 
 uniform mat4 inv_proj;
 
@@ -55,8 +54,8 @@ void main()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	//gl_FragColor = gl_Color;
-	gl_FragColor = color;
+	gl_FragColor = gl_Color;
+	//gl_FragColor = color;
 	//gl_FragColor = vec4(1,0,1,1);
 	//gl_FragColor = vec4(1,0,1,1)*shadow;
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 04e556c11ad..43200f1b075 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -36,7 +36,7 @@ void main()
 	vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
 	vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
 	
-	vary_position = pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias);
+	vary_position = pos.xyz;
 		
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index 650fbcc3f5c..da1dafda366 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -17,7 +17,7 @@ vec3 atmosAffectDirectionalLight(float lightIntensity);
 vec3 scaleDownLight(vec3 light);
 vec3 scaleUpLight(vec3 light);
 
-varying vec4 vary_position;
+varying vec3 vary_position;
 varying vec3 vary_ambient;
 varying vec3 vary_directional;
 varying vec3 vary_normal;
@@ -41,7 +41,7 @@ void main()
 	norm = normalize(norm);
 		
 	gl_Position = gl_ProjectionMatrix * pos;
-	vary_position = pos;
+	vary_position = pos.xyz;
 	vary_normal = norm;	
 	
 	calcAtmospherics(pos.xyz);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
index b4588426572..44468cdfa29 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
@@ -13,7 +13,7 @@ void main()
 	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 
 	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
 	
-	vary_nomral = normalize(gl_NormalMatrix * gl_Normal);
+	vary_normal = normalize(gl_NormalMatrix * gl_Normal);
 
 	gl_FrontColor = gl_Color;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index 665fe16b439..fa6b4e2afb1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -115,7 +115,7 @@ void main()
 
 	//gl_FragColor = gl_Color;
 	gl_FragColor = color;
-	//gl_FragColor = vec4(1,0,1,1)*shadow;
+	//gl_FragColor = vec4(1,shadow,1,1);
 	
 }
 
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 866aea42c4d..ac599caa5b7 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -63,6 +63,8 @@ LLGLSLShader* LLDrawPoolAvatar::sVertexProgram = NULL;
 BOOL	LLDrawPoolAvatar::sSkipOpaque = FALSE;
 BOOL	LLDrawPoolAvatar::sSkipTransparent = FALSE;
 
+static bool is_deferred_render = false;
+
 extern BOOL gUseGLPick;
 
 F32 CLOTHING_GRAVITY_EFFECT = 0.7f;
@@ -100,6 +102,18 @@ S32 specular_channel = -1;
 S32 diffuse_channel = -1;
 S32 cube_channel = -1;
 
+static const U32 rigged_data_mask[] = {
+	LLDrawPoolAvatar::RIGGED_SIMPLE_MASK,
+	LLDrawPoolAvatar::RIGGED_FULLBRIGHT_MASK,
+	LLDrawPoolAvatar::RIGGED_SHINY_MASK,
+	LLDrawPoolAvatar::RIGGED_FULLBRIGHT_SHINY_MASK,
+	LLDrawPoolAvatar::RIGGED_GLOW_MASK,
+	LLDrawPoolAvatar::RIGGED_ALPHA_MASK,
+	LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA_MASK,
+	LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP_MASK,						 
+	LLDrawPoolAvatar::RIGGED_DEFERRED_SIMPLE_MASK,
+};
+
 
 static LLFastTimer::DeclareTimer FTM_SHADOW_AVATAR("Avatar Shadow");
 
@@ -155,21 +169,17 @@ LLMatrix4& LLDrawPoolAvatar::getModelView()
 //-----------------------------------------------------------------------------
 
 
-S32 LLDrawPoolAvatar::getNumDeferredPasses()
-{
-	return getNumPasses();
-}
 
 void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
 {
 	LLFastTimer t(FTM_RENDER_CHARACTERS);
 	
 	sSkipTransparent = TRUE;
-
+	is_deferred_render = true;
+	
 	if (LLPipeline::sImpostorRender)
-	{
-		beginDeferredSkinned();
-		return;
+	{ //impostor pass does not have rigid or impostor rendering
+		pass += 2;
 	}
 
 	switch (pass)
@@ -184,7 +194,10 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
 		beginDeferredSkinned();
 		break;
 	case 3:
-		beginDeferredRigged();
+		beginDeferredRiggedSimple();
+		break;
+	case 4:
+		beginDeferredRiggedBump();
 		break;
 	}
 }
@@ -194,11 +207,11 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass)
 	LLFastTimer t(FTM_RENDER_CHARACTERS);
 
 	sSkipTransparent = FALSE;
+	is_deferred_render = false;
 
 	if (LLPipeline::sImpostorRender)
 	{
-		endDeferredSkinned();
-		return;
+		pass += 2;
 	}
 
 	switch (pass)
@@ -213,7 +226,11 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass)
 		endDeferredSkinned();
 		break;
 	case 3:
-		endDeferredRigged();
+		endDeferredRiggedSimple();
+		break;
+	case 4:
+		endDeferredRiggedBump();
+		break;
 	}
 }
 
@@ -224,10 +241,35 @@ void LLDrawPoolAvatar::renderDeferred(S32 pass)
 
 S32 LLDrawPoolAvatar::getNumPostDeferredPasses()
 {
-	return 1;
+	return 6;
 }
 
 void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass)
+{
+	switch (pass)
+	{
+	case 0:
+		beginPostDeferredAlpha();
+		break;
+	case 1:
+		beginRiggedFullbright();
+		break;
+	case 2:
+		beginRiggedFullbrightShiny();
+		break;
+	case 3:
+		beginDeferredRiggedAlpha();
+		break;
+	case 4:
+		beginRiggedFullbrightAlpha();
+		break;
+	case 5:
+		beginRiggedGlow();
+		break;
+	}
+}
+
+void LLDrawPoolAvatar::beginPostDeferredAlpha()
 {
 	sSkipOpaque = TRUE;
 	sShaderLevel = mVertexShaderLevel;
@@ -240,7 +282,49 @@ void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass)
 	enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
 }
 
+void LLDrawPoolAvatar::beginDeferredRiggedAlpha()
+{
+	sVertexProgram = &gDeferredSkinnedAlphaProgram;
+	gPipeline.bindDeferredShader(*sVertexProgram);
+	diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+	gPipeline.enableLightsDynamic();
+}
+
+void LLDrawPoolAvatar::endDeferredRiggedAlpha()
+{
+	LLVertexBuffer::unbind();
+	gPipeline.unbindDeferredShader(*sVertexProgram);
+	LLVertexBuffer::sWeight4Loc = -1;
+	sVertexProgram = NULL;
+}
+
 void LLDrawPoolAvatar::endPostDeferredPass(S32 pass)
+{
+	switch (pass)
+	{
+	case 0:
+		endPostDeferredAlpha();
+		break;
+	case 1:
+		endRiggedFullbright();
+		break;
+	case 2:
+		endRiggedFullbrightShiny();
+		break;
+	case 3:
+		endDeferredRiggedAlpha();
+		break;
+	case 4:
+		endRiggedFullbrightAlpha();
+		break;
+	case 5:
+		endRiggedGlow();
+		break;
+	}
+}
+
+void LLDrawPoolAvatar::endPostDeferredAlpha()
 {
 	// if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done
 	sRenderingSkinned = FALSE;
@@ -254,7 +338,17 @@ void LLDrawPoolAvatar::endPostDeferredPass(S32 pass)
 
 void LLDrawPoolAvatar::renderPostDeferred(S32 pass)
 {
-	render(2); //pass 2 = skinned
+	const S32 actual_pass[] =
+	{ //map post deferred pass numbers to what render() expects
+		2, //skinned
+		4, // rigged fullbright
+		6, //rigged fullbright shiny
+		7, //rigged alpha
+		8, //rigged fullbright alpha
+		9, //rigged glow
+	};
+
+	render(actual_pass[pass]);
 }
 
 
@@ -288,6 +382,7 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 	else
 	{
 		sVertexProgram = &gDeferredAttachmentShadowProgram;
+		diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 		sVertexProgram->bind();
 		LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 	}
@@ -352,7 +447,12 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 	}
 	else
 	{
-		avatarp->renderSkinnedAttachments();
+		renderRigged(avatarp, RIGGED_SIMPLE);
+		renderRigged(avatarp, RIGGED_ALPHA);
+		renderRigged(avatarp, RIGGED_FULLBRIGHT);
+		renderRigged(avatarp, RIGGED_FULLBRIGHT_SHINY);
+		renderRigged(avatarp, RIGGED_SHINY);
+		renderRigged(avatarp, RIGGED_FULLBRIGHT_ALPHA);
 	}
 }
 
@@ -360,7 +460,7 @@ S32 LLDrawPoolAvatar::getNumPasses()
 {
 	if (LLPipeline::sImpostorRender)
 	{
-		return 1;
+		return 8;
 	}
 	else if (getVertexShaderLevel() > 0)
 	{
@@ -372,6 +472,19 @@ S32 LLDrawPoolAvatar::getNumPasses()
 	}
 }
 
+S32 LLDrawPoolAvatar::getNumDeferredPasses()
+{
+	if (LLPipeline::sImpostorRender)
+	{
+		return 3;
+	}
+	else
+	{
+		return 5;
+	}
+}
+
+
 void LLDrawPoolAvatar::render(S32 pass)
 {
 	LLFastTimer t(FTM_RENDER_CHARACTERS);
@@ -391,9 +504,8 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 	LLVertexBuffer::unbind();
 
 	if (LLPipeline::sImpostorRender)
-	{
-		beginSkinned();
-		return;
+	{ //impostor render does not have impostors or rigid rendering
+		pass += 2;
 	}
 
 	switch (pass)
@@ -437,8 +549,7 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 
 	if (LLPipeline::sImpostorRender)
 	{
-		endSkinned();
-		return;
+		pass += 2;		
 	}
 
 	switch (pass)
@@ -536,8 +647,8 @@ void LLDrawPoolAvatar::beginDeferredImpostor()
 
 	sVertexProgram = &gDeferredImpostorProgram;
 
-	normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL);
 	specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP);
+	normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL);
 	diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 
 	sVertexProgram->bind();
@@ -774,18 +885,40 @@ void LLDrawPoolAvatar::endRiggedFullbrightShiny()
 }
 
 
-void LLDrawPoolAvatar::beginDeferredRigged()
+void LLDrawPoolAvatar::beginDeferredRiggedSimple()
 {
 	sVertexProgram = &gDeferredSkinnedDiffuseProgram;
+	diffuse_channel = 0;
+	sVertexProgram->bind();
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endDeferredRiggedSimple()
+{
+	LLVertexBuffer::unbind();
+	sVertexProgram->unbind();
+	LLVertexBuffer::sWeight4Loc = -1;
+	sVertexProgram = NULL;
+}
+
+void LLDrawPoolAvatar::beginDeferredRiggedBump()
+{
+	sVertexProgram = &gDeferredSkinnedBumpProgram;
 	sVertexProgram->bind();
+	normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP);
+	diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
-void LLDrawPoolAvatar::endDeferredRigged()
+void LLDrawPoolAvatar::endDeferredRiggedBump()
 {
 	LLVertexBuffer::unbind();
+	sVertexProgram->disableTexture(LLViewerShaderMgr::BUMP_MAP);
+	sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 	sVertexProgram->unbind();
 	LLVertexBuffer::sWeight4Loc = -1;
+	normal_channel = -1;
+	diffuse_channel = -1;
 	sVertexProgram = NULL;
 }
 
@@ -933,13 +1066,28 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 
 	if (pass == 3)
 	{
-		renderRiggedSimple(avatarp);
+		if (is_deferred_render)
+		{
+			renderDeferredRiggedSimple(avatarp);
+		}
+		else
+		{
+			renderRiggedSimple(avatarp);
+		}
 		return;
 	}
 
 	if (pass == 4)
 	{
-		renderRiggedFullbright(avatarp);
+		if (is_deferred_render)
+		{
+			renderDeferredRiggedBump(avatarp);
+		}
+		else
+		{
+			renderRiggedFullbright(avatarp);
+		}
+
 		return;
 	}
 
@@ -995,6 +1143,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		renderRiggedGlow(avatarp);
 		gGL.setColorMask(true, false);
 		gGL.setSceneBlendType(LLRender::BT_ALPHA);
+		return;
 	}
 
 	
@@ -1034,12 +1183,21 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 	}
 }
 
-void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face, U32 data_mask)
+void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face)
 {
+	U32 data_mask = 0;
+	for (U32 i = 0; i < face->mRiggedIndex.size(); ++i)
+	{
+		if (face->mRiggedIndex[i] > -1)
+		{
+			data_mask |= rigged_data_mask[i];
+		}
+	}
+
 	LLVertexBuffer* buff = face->mVertexBuffer;
 
 	if (!buff || 
-		!buff->hasDataType(LLVertexBuffer::TYPE_WEIGHT4) ||
+		buff->getTypeMask() != data_mask ||
 		buff->getRequestedVerts() != vol_face.mVertices.size())
 	{
 		face->setGeomIndex(0);
@@ -1067,7 +1225,7 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSk
 	}
 }
 
-void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask, bool glow)
+void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 {
 	for (U32 i = 0; i < mRiggedFace[type].size(); ++i)
 	{
@@ -1106,8 +1264,10 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, const U32 data
 		}
 
 		const LLVolumeFace& vol_face = volume->getVolumeFace(te);
-		updateRiggedFaceVertexBuffer(face, skin, volume, vol_face, data_mask);
+		updateRiggedFaceVertexBuffer(face, skin, volume, vol_face);
 		
+		U32 data_mask = rigged_data_mask[type];
+
 		LLVertexBuffer* buff = face->mVertexBuffer;
 
 		if (buff)
@@ -1145,84 +1305,72 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, const U32 data
 				glColor4f(0,0,0,face->getTextureEntry()->getGlow());
 			}
 
-			gGL.getTexUnit(0)->bind(face->getTexture());
-			buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);		
+			gGL.getTexUnit(diffuse_channel)->bind(face->getTexture());
+			if (normal_channel > -1)
+			{
+				LLDrawPoolBump::bindBumpMap(face, normal_channel);
+			}
+
+			if (face->mTextureMatrix)
+			{
+				glMatrixMode(GL_TEXTURE);
+				glLoadMatrixf((F32*) face->mTextureMatrix->mMatrix);
+				buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);
+				glLoadIdentity();
+				glMatrixMode(GL_MODELVIEW);
+			}
+			else
+			{
+				buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);		
+			}
 		}
 	}
 }
 
-void LLDrawPoolAvatar::renderRiggedSimple(LLVOAvatar* avatar)
+void LLDrawPoolAvatar::renderDeferredRiggedSimple(LLVOAvatar* avatar)
 {
-	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
-							LLVertexBuffer::MAP_NORMAL | 
-							LLVertexBuffer::MAP_TEXCOORD0 |
-							LLVertexBuffer::MAP_COLOR |
-							LLVertexBuffer::MAP_WEIGHT4;
+	renderRigged(avatar, RIGGED_DEFERRED_SIMPLE);
+}
 
-	renderRigged(avatar, RIGGED_SIMPLE, data_mask);
+void LLDrawPoolAvatar::renderDeferredRiggedBump(LLVOAvatar* avatar)
+{
+	renderRigged(avatar, RIGGED_DEFERRED_BUMP);
 }
 
-void LLDrawPoolAvatar::renderRiggedFullbright(LLVOAvatar* avatar)
+void LLDrawPoolAvatar::renderRiggedSimple(LLVOAvatar* avatar)
 {
-	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
-							LLVertexBuffer::MAP_TEXCOORD0 |
-							LLVertexBuffer::MAP_COLOR |
-							LLVertexBuffer::MAP_WEIGHT4;
+	renderRigged(avatar, RIGGED_SIMPLE);
+}
 
-	renderRigged(avatar, RIGGED_FULLBRIGHT, data_mask);
+void LLDrawPoolAvatar::renderRiggedFullbright(LLVOAvatar* avatar)
+{
+	renderRigged(avatar, RIGGED_FULLBRIGHT);
 }
 
 	
 void LLDrawPoolAvatar::renderRiggedShinySimple(LLVOAvatar* avatar)
 {
-	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
-							LLVertexBuffer::MAP_NORMAL | 
-							LLVertexBuffer::MAP_TEXCOORD0 |
-							LLVertexBuffer::MAP_COLOR |
-							LLVertexBuffer::MAP_WEIGHT4;
-
-	renderRigged(avatar, RIGGED_SHINY, data_mask);
+	renderRigged(avatar, RIGGED_SHINY);
 }
 
 void LLDrawPoolAvatar::renderRiggedFullbrightShiny(LLVOAvatar* avatar)
 {
-	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
-							LLVertexBuffer::MAP_NORMAL | 
-							LLVertexBuffer::MAP_TEXCOORD0 |
-							LLVertexBuffer::MAP_COLOR |
-							LLVertexBuffer::MAP_WEIGHT4;
-
-	renderRigged(avatar, RIGGED_FULLBRIGHT_SHINY, data_mask);
+	renderRigged(avatar, RIGGED_FULLBRIGHT_SHINY);
 }
 
 void LLDrawPoolAvatar::renderRiggedAlpha(LLVOAvatar* avatar)
 {
-	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
-							LLVertexBuffer::MAP_NORMAL | 
-							LLVertexBuffer::MAP_TEXCOORD0 |
-							LLVertexBuffer::MAP_COLOR |
-							LLVertexBuffer::MAP_WEIGHT4;
-
-	renderRigged(avatar, RIGGED_ALPHA, data_mask);
+	renderRigged(avatar, RIGGED_ALPHA);
 }
 
 void LLDrawPoolAvatar::renderRiggedFullbrightAlpha(LLVOAvatar* avatar)
 {
-	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
-							LLVertexBuffer::MAP_TEXCOORD0 |
-							LLVertexBuffer::MAP_COLOR |
-							LLVertexBuffer::MAP_WEIGHT4;
-
-	renderRigged(avatar, RIGGED_FULLBRIGHT_ALPHA, data_mask);
+	renderRigged(avatar, RIGGED_FULLBRIGHT_ALPHA);
 }
 
 void LLDrawPoolAvatar::renderRiggedGlow(LLVOAvatar* avatar)
 {
-	const U32 data_mask =	LLVertexBuffer::MAP_VERTEX | 
-							LLVertexBuffer::MAP_TEXCOORD0 |
-							LLVertexBuffer::MAP_WEIGHT4;
-
-	renderRigged(avatar, RIGGED_GLOW, data_mask, true);
+	renderRigged(avatar, RIGGED_GLOW, true);
 }
 
 
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index 59f9cf7ddb8..bab6f014807 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -103,6 +103,8 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginRiggedAlpha();
 	void beginRiggedFullbrightAlpha();
 	void beginRiggedGlow();
+	void beginPostDeferredAlpha();
+	void beginDeferredRiggedAlpha();
 
 	void endRigid();
 	void endImpostor();
@@ -114,24 +116,27 @@ class LLDrawPoolAvatar : public LLFacePool
 	void endRiggedAlpha();
 	void endRiggedFullbrightAlpha();
 	void endRiggedGlow();
+	void endPostDeferredAlpha();
+	void endDeferredRiggedAlpha();
 
 	void beginDeferredImpostor();
 	void beginDeferredRigid();
 	void beginDeferredSkinned();
-	void beginDeferredRigged();
+	void beginDeferredRiggedSimple();
+	void beginDeferredRiggedBump();
 	
 	void endDeferredImpostor();
 	void endDeferredRigid();
 	void endDeferredSkinned();
-	void endDeferredRigged();
+	void endDeferredRiggedSimple();
+	void endDeferredRiggedBump();
 		
 	void updateRiggedFaceVertexBuffer(LLFace* facep, 
 									  const LLMeshSkinInfo* skin, 
 									  LLVolume* volume,
-									  const LLVolumeFace& vol_face, 
-									  U32 data_mask);
+									  const LLVolumeFace& vol_face);
 
-	void renderRigged(LLVOAvatar* avatar, U32 type, const U32 data_mask, bool glow = false);
+	void renderRigged(LLVOAvatar* avatar, U32 type, bool glow = false);
 	void renderRiggedSimple(LLVOAvatar* avatar);
 	void renderRiggedAlpha(LLVOAvatar* avatar);
 	void renderRiggedFullbrightAlpha(LLVOAvatar* avatar);
@@ -139,6 +144,8 @@ class LLDrawPoolAvatar : public LLFacePool
 	void renderRiggedShinySimple(LLVOAvatar* avatar);
 	void renderRiggedFullbrightShiny(LLVOAvatar* avatar);
 	void renderRiggedGlow(LLVOAvatar* avatar);
+	void renderDeferredRiggedSimple(LLVOAvatar* avatar);
+	void renderDeferredRiggedBump(LLVOAvatar* avatar);
 
 	/*virtual*/ LLViewerTexture *getDebugTexture();
 	/*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display
@@ -154,11 +161,43 @@ class LLDrawPoolAvatar : public LLFacePool
 		RIGGED_GLOW,
 		RIGGED_ALPHA,
 		RIGGED_FULLBRIGHT_ALPHA,
+		RIGGED_DEFERRED_BUMP,
+		RIGGED_DEFERRED_SIMPLE,
 		NUM_RIGGED_PASSES,
 		RIGGED_UNKNOWN,
 	} eRiggedPass;
 
-	
+	typedef enum
+	{
+		RIGGED_SIMPLE_MASK = LLVertexBuffer::MAP_VERTEX | 
+							 LLVertexBuffer::MAP_NORMAL | 
+							 LLVertexBuffer::MAP_TEXCOORD0 |
+							 LLVertexBuffer::MAP_COLOR |
+							 LLVertexBuffer::MAP_WEIGHT4,
+		RIGGED_FULLBRIGHT_MASK = LLVertexBuffer::MAP_VERTEX | 
+							 LLVertexBuffer::MAP_TEXCOORD0 |
+							 LLVertexBuffer::MAP_COLOR |
+							 LLVertexBuffer::MAP_WEIGHT4,
+		RIGGED_SHINY_MASK = RIGGED_SIMPLE_MASK,
+		RIGGED_FULLBRIGHT_SHINY_MASK = RIGGED_SIMPLE_MASK,							 
+		RIGGED_GLOW_MASK = LLVertexBuffer::MAP_VERTEX | 
+							 LLVertexBuffer::MAP_TEXCOORD0 |
+							 LLVertexBuffer::MAP_WEIGHT4,
+		RIGGED_ALPHA_MASK = RIGGED_SIMPLE_MASK,
+		RIGGED_FULLBRIGHT_ALPHA_MASK = RIGGED_FULLBRIGHT_MASK,
+		RIGGED_DEFERRED_BUMP_MASK = LLVertexBuffer::MAP_VERTEX | 
+							 LLVertexBuffer::MAP_NORMAL | 
+							 LLVertexBuffer::MAP_TEXCOORD0 |
+							 LLVertexBuffer::MAP_BINORMAL |
+							 LLVertexBuffer::MAP_COLOR |
+							 LLVertexBuffer::MAP_WEIGHT4,
+		RIGGED_DEFERRED_SIMPLE_MASK = LLVertexBuffer::MAP_VERTEX | 
+							 LLVertexBuffer::MAP_NORMAL | 
+							 LLVertexBuffer::MAP_TEXCOORD0 |
+							 LLVertexBuffer::MAP_COLOR |
+							 LLVertexBuffer::MAP_WEIGHT4,
+	} eRiggedDataMask;
+
 	void addRiggedFace(LLFace* facep, U32 type);
 	void removeRiggedFace(LLFace* facep); 
 
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 2f449fa42f5..906615ade83 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -591,18 +591,37 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL
 // static
 BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel)
 {
-	LLViewerTexture* bump = NULL;
-
 	U8 bump_code = params.mBump;
 
+	return bindBumpMap(bump_code, params.mTexture, params.mVSize, channel);
+}
+
+//static
+BOOL LLDrawPoolBump::bindBumpMap(LLFace* face, S32 channel)
+{
+	const LLTextureEntry* te = face->getTextureEntry();
+	if (te)
+	{
+		U8 bump_code = te->getBumpmap();
+		return bindBumpMap(bump_code, face->getTexture(), face->getVirtualSize(), channel);
+	}
+
+	return FALSE;
+}
+
+//static
+BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, F32 vsize, S32 channel)
+{
 	//Note: texture atlas does not support bump texture now.
-	LLViewerFetchedTexture* tex = LLViewerTextureManager::staticCastToFetchedTexture(params.mTexture) ;
+	LLViewerFetchedTexture* tex = LLViewerTextureManager::staticCastToFetchedTexture(texture) ;
 	if(!tex)
 	{
 		//if the texture is not a fetched texture
 		return FALSE;
 	}
 
+	LLViewerTexture* bump = NULL;
+
 	switch( bump_code )
 	{
 	case BE_NO_BUMP:		
@@ -616,7 +635,7 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel)
 		if( bump_code < LLStandardBumpmap::sStandardBumpmapCount )
 		{
 			bump = gStandardBumpmapList[bump_code].mImage;
-			gBumpImageList.addTextureStats(bump_code, tex->getID(), params.mVSize);
+			gBumpImageList.addTextureStats(bump_code, tex->getID(), vsize);
 		}
 		break;
 	}
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index 89bbefe7785..127c9efe852 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -93,7 +93,12 @@ protected :
 	/*virtual*/ void endPostDeferredPass(S32 pass);
 	/*virtual*/ void renderPostDeferred(S32 pass);
 
-	BOOL bindBumpMap(LLDrawInfo& params, S32 channel = -2);
+	static BOOL bindBumpMap(LLDrawInfo& params, S32 channel = -2);
+	static BOOL bindBumpMap(LLFace* face, S32 channel = -2);
+
+private:
+	static BOOL bindBumpMap(U8 bump_code, LLViewerTexture* tex, F32 vsize, S32 channel);
+
 };
 
 enum EBumpEffect
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index eafc52748e9..e64fdfc0b41 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -114,6 +114,8 @@ LLGLSLShader			gDeferredEdgeProgram;
 LLGLSLShader			gDeferredWaterProgram;
 LLGLSLShader			gDeferredDiffuseProgram;
 LLGLSLShader			gDeferredSkinnedDiffuseProgram;
+LLGLSLShader			gDeferredSkinnedBumpProgram;
+LLGLSLShader			gDeferredSkinnedAlphaProgram;
 LLGLSLShader			gDeferredBumpProgram;
 LLGLSLShader			gDeferredTerrainProgram;
 LLGLSLShader			gDeferredTreeProgram;
@@ -173,6 +175,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gDeferredLightProgram);
 	mShaderList.push_back(&gDeferredMultiLightProgram);
 	mShaderList.push_back(&gDeferredAlphaProgram);
+	mShaderList.push_back(&gDeferredSkinnedAlphaProgram);
 	mShaderList.push_back(&gDeferredFullbrightProgram);
 	mShaderList.push_back(&gDeferredPostGIProgram);
 	mShaderList.push_back(&gDeferredEdgeProgram);
@@ -591,6 +594,8 @@ void LLViewerShaderMgr::unloadShaders()
 
 	gDeferredDiffuseProgram.unload();
 	gDeferredSkinnedDiffuseProgram.unload();
+	gDeferredSkinnedBumpProgram.unload();
+	gDeferredSkinnedAlphaProgram.unload();
 
 	mVertexShaderLevel[SHADER_LIGHTING] = 0;
 	mVertexShaderLevel[SHADER_OBJECT] = 0;
@@ -906,6 +911,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredTreeProgram.unload();
 		gDeferredDiffuseProgram.unload();
 		gDeferredSkinnedDiffuseProgram.unload();
+		gDeferredSkinnedBumpProgram.unload();
+		gDeferredSkinnedAlphaProgram.unload();
 		gDeferredBumpProgram.unload();
 		gDeferredImpostorProgram.unload();
 		gDeferredTerrainProgram.unload();
@@ -958,6 +965,33 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		success = gDeferredSkinnedDiffuseProgram.createShader(NULL, NULL);
 	}
 
+	if (success)
+	{
+		gDeferredSkinnedBumpProgram.mName = "Deferred Skinned Bump Shader";
+		gDeferredSkinnedBumpProgram.mFeatures.hasObjectSkinning = true;
+		gDeferredSkinnedBumpProgram.mShaderFiles.clear();
+		gDeferredSkinnedBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredSkinnedBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gDeferredSkinnedBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+		success = gDeferredSkinnedBumpProgram.createShader(NULL, NULL);
+	}
+
+	if (success)
+	{
+		gDeferredSkinnedAlphaProgram.mName = "Deferred Skinned Alpha Shader";
+		gDeferredSkinnedAlphaProgram.mFeatures.hasObjectSkinning = true;
+		gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = true;
+		gDeferredSkinnedAlphaProgram.mFeatures.calculatesAtmospherics = true;
+		gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true;
+		gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true;
+		gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = true;
+		gDeferredSkinnedAlphaProgram.mShaderFiles.clear();
+		gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gDeferredSkinnedAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+		success = gDeferredSkinnedAlphaProgram.createShader(NULL, NULL);
+	}
+
 	if (success)
 	{
 		gDeferredBumpProgram.mName = "Deferred Bump Shader";
@@ -1176,7 +1210,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true;
 		gDeferredAvatarAlphaProgram.mShaderFiles.clear();
 		gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 		success = gDeferredAvatarAlphaProgram.createShader(&mAvatarAttribs, &mAvatarUniforms);
 	}
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index bb28cd7ec20..da16a384279 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -350,6 +350,8 @@ extern LLGLSLShader			gDeferredEdgeProgram;
 extern LLGLSLShader			gDeferredWaterProgram;
 extern LLGLSLShader			gDeferredDiffuseProgram;
 extern LLGLSLShader			gDeferredSkinnedDiffuseProgram;
+extern LLGLSLShader			gDeferredSkinnedBumpProgram;
+extern LLGLSLShader			gDeferredSkinnedAlphaProgram;
 extern LLGLSLShader			gDeferredBumpProgram;
 extern LLGLSLShader			gDeferredTerrainProgram;
 extern LLGLSLShader			gDeferredTreeProgram;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index e263f8d937f..220634897e3 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3586,6 +3586,21 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 						{
 							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_GLOW);
 						}
+
+						if (LLPipeline::sRenderDeferred)
+						{
+							if (type != LLDrawPool::POOL_ALPHA && !te->getFullbright())
+							{
+								if (te->getBumpmap())
+								{
+									pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP);
+								}
+								else
+								{
+									pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_DEFERRED_SIMPLE);
+								}
+							}
+						}
 					}
 
 				}
-- 
GitLab


From fd0b287be34f0d90b02c332494c96769c6ebb912 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 4 May 2010 10:25:26 +0100
Subject: [PATCH 380/683] EXT-7168 Fix the tying of the deferred prefs UI to
 the featuretable. (transplanted from
 3196941d73f122f5dbe42aa0ffdc28a2470ea089)

---
 indra/newview/llfloaterpreference.cpp | 35 +++++++++++++++++++++++++--
 indra/newview/llviewershadermgr.cpp   |  3 ++-
 indra/newview/pipeline.cpp            |  9 ++++---
 3 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 00292eecb4a..de92b953fb3 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -862,18 +862,22 @@ void LLFloaterPreference::refreshEnabledState()
 	//Deferred/SSAO/Shadows
 	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
 	if (LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseFBO") &&
+	    LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
 		shaders)
 	{
-		BOOL enabled = ctrl_wind_light->get() ? TRUE : FALSE;
+		BOOL enabled = (ctrl_wind_light->get()) ? TRUE : FALSE;
 
 		ctrl_deferred->setEnabled(enabled);
 	
 		LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
 		LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
 
-		enabled = enabled && (ctrl_deferred->get() ? TRUE : FALSE);
+		enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE);
 		
 		ctrl_ssao->setEnabled(enabled);
+
+		enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail");
+
 		ctrl_shadow->setEnabled(enabled);
 	}
 
@@ -940,7 +944,34 @@ void LLFloaterPreference::disableUnavailableSettings()
 		ctrl_deferred->setEnabled(FALSE);
 		ctrl_deferred->setValue(FALSE);
 	}
+
+	// disabled deferred
+	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"))
+	{
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
+	}
+	
+	// disabled deferred SSAO
+	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO"))
+	{
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+	}
 	
+	// disabled deferred shadows
+	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"))
+	{
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+	}
+
 	// disabled reflections
 	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
 	{
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index e64fdfc0b41..49eeffe2289 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -391,7 +391,8 @@ void LLViewerShaderMgr::setShaders()
 		S32 water_class = 2;
 		S32 deferred_class = 0;
 		
-		if (gSavedSettings.getBOOL("RenderDeferred"))
+		if (LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
+		    gSavedSettings.getBOOL("RenderDeferred"))
 		{
 			if (gSavedSettings.getS32("RenderShadowDetail") > 0)
 			{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 6abe1041f7e..2e2b2c02c39 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -633,10 +633,11 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 void LLPipeline::updateRenderDeferred()
 {
 	BOOL deferred = (gSavedSettings.getBOOL("RenderDeferred") && 
-		LLRenderTarget::sUseFBO &&
-		gSavedSettings.getBOOL("VertexShaderEnable") && 
-		gSavedSettings.getBOOL("RenderAvatarVP") &&
-		gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE;
+			 LLRenderTarget::sUseFBO &&
+			 LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
+			 gSavedSettings.getBOOL("VertexShaderEnable") && 
+			 gSavedSettings.getBOOL("RenderAvatarVP") &&
+			 gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE;
 	
 	sRenderDeferred = deferred;			
 }
-- 
GitLab


From 399942954687bfa7836a021b7d6087c3c264f9d0 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 4 May 2010 10:25:26 +0100
Subject: [PATCH 381/683] EXT-7168 Fix the tying of the deferred prefs UI to
 the featuretable.

---
 indra/newview/llfloaterpreference.cpp | 35 +++++++++++++++++++++++++--
 indra/newview/llviewershadermgr.cpp   |  3 ++-
 indra/newview/pipeline.cpp            |  9 ++++---
 3 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 00292eecb4a..de92b953fb3 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -862,18 +862,22 @@ void LLFloaterPreference::refreshEnabledState()
 	//Deferred/SSAO/Shadows
 	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
 	if (LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseFBO") &&
+	    LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
 		shaders)
 	{
-		BOOL enabled = ctrl_wind_light->get() ? TRUE : FALSE;
+		BOOL enabled = (ctrl_wind_light->get()) ? TRUE : FALSE;
 
 		ctrl_deferred->setEnabled(enabled);
 	
 		LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
 		LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
 
-		enabled = enabled && (ctrl_deferred->get() ? TRUE : FALSE);
+		enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE);
 		
 		ctrl_ssao->setEnabled(enabled);
+
+		enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail");
+
 		ctrl_shadow->setEnabled(enabled);
 	}
 
@@ -940,7 +944,34 @@ void LLFloaterPreference::disableUnavailableSettings()
 		ctrl_deferred->setEnabled(FALSE);
 		ctrl_deferred->setValue(FALSE);
 	}
+
+	// disabled deferred
+	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"))
+	{
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
+	}
+	
+	// disabled deferred SSAO
+	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO"))
+	{
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+	}
 	
+	// disabled deferred shadows
+	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"))
+	{
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+	}
+
 	// disabled reflections
 	if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
 	{
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index a0d0b9d4904..0e298517787 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -375,7 +375,8 @@ void LLViewerShaderMgr::setShaders()
 		S32 water_class = 2;
 		S32 deferred_class = 0;
 		
-		if (gSavedSettings.getBOOL("RenderDeferred"))
+		if (LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
+		    gSavedSettings.getBOOL("RenderDeferred"))
 		{
 			if (gSavedSettings.getS32("RenderShadowDetail") > 0)
 			{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 7c618162a4d..4fbc6bb5da9 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -631,10 +631,11 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 void LLPipeline::updateRenderDeferred()
 {
 	BOOL deferred = (gSavedSettings.getBOOL("RenderDeferred") && 
-		LLRenderTarget::sUseFBO &&
-		gSavedSettings.getBOOL("VertexShaderEnable") && 
-		gSavedSettings.getBOOL("RenderAvatarVP") &&
-		gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE;
+			 LLRenderTarget::sUseFBO &&
+			 LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
+			 gSavedSettings.getBOOL("VertexShaderEnable") && 
+			 gSavedSettings.getBOOL("RenderAvatarVP") &&
+			 gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE;
 	
 	sRenderDeferred = deferred;			
 }
-- 
GitLab


From ddad6dd5ea88705a0b7db603e1785715593624de Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 4 May 2010 14:55:02 +0100
Subject: [PATCH 382/683] EXT-7161 Fullbright has no effect on shiny & bump
 mapped prim while Lighting and Shadows are enabled. (transplanted from
 6f25e5a4f0e0d7bbe1ed3e14e7da4d371e290c67)

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

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 220634897e3..f71c3ce4185 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4060,13 +4060,13 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				}
 				else if (LLPipeline::sRenderDeferred)
 				{
-					if (te->getBumpmap())
+					if (te->getFullbright())
 					{
-						registerFace(group, facep, LLRenderPass::PASS_BUMP);
+						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_SHINY);
 					}
-					else if (te->getFullbright())
+					else if (te->getBumpmap())
 					{
-						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_SHINY);
+						registerFace(group, facep, LLRenderPass::PASS_BUMP);
 					}
 					else
 					{
-- 
GitLab


From f07b8c194447be4753512716402993888b2ed98c Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 4 May 2010 14:55:02 +0100
Subject: [PATCH 383/683] EXT-7161 Fullbright has no effect on shiny & bump
 mapped prim while Lighting and Shadows are enabled.

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

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index aa22dc7f5df..34ae915a076 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3802,13 +3802,13 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				}
 				else if (LLPipeline::sRenderDeferred)
 				{
-					if (te->getBumpmap())
+					if (te->getFullbright())
 					{
-						registerFace(group, facep, LLRenderPass::PASS_BUMP);
+						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_SHINY);
 					}
-					else if (te->getFullbright())
+					else if (te->getBumpmap())
 					{
-						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_SHINY);
+						registerFace(group, facep, LLRenderPass::PASS_BUMP);
 					}
 					else
 					{
-- 
GitLab


From 744f2e4951fc6fc1a1f08e97fc446e909c1fe39e Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 4 May 2010 12:14:47 -0500
Subject: [PATCH 384/683] Cleanup from review.

---
 indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 3 +--
 indra/newview/lldrawpoolavatar.cpp                             | 2 +-
 indra/newview/llvovolume.cpp                                   | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 6f027de6a23..7d18ae50366 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -54,8 +54,7 @@ void main()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	gl_FragColor = gl_Color;
-	//gl_FragColor = color;
+	gl_FragColor = color;
 	//gl_FragColor = vec4(1,0,1,1);
 	//gl_FragColor = vec4(1,0,1,1)*shadow;
 	
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index ac599caa5b7..a49cf8781ea 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1103,7 +1103,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		return;
 	}
 
-	if (pass >= 7 && pass <= 9)
+	if (pass >= 7 && pass < 9)
 	{
 		LLGLEnable blend(GL_BLEND);
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 220634897e3..1ed8da85a8a 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3418,7 +3418,7 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_VB("Volume");
 static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
-LLDrawPoolAvatar* get_avatar_drawpool(LLViewerObject* vobj)
+static LLDrawPoolAvatar* get_avatar_drawpool(LLViewerObject* vobj)
 {
 	LLVOAvatar* avatar = vobj->getAvatar();
 					
-- 
GitLab


From b92e0c516d31d17965e0349ff436d6db4a9a3f9e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 6 May 2010 13:53:52 +0100
Subject: [PATCH 385/683] EXT-6912 FIXED Deferred Rendering - shiny objects
 look like a projection instead of a reflection

Disable screen-space shiny while I chew on it some more.
---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl     | 3 +++
 .../app_settings/shaders/class2/deferred/softenLightF.glsl     | 3 +++
 .../app_settings/shaders/class3/deferred/softenLightF.glsl     | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index bf5dd4155c2..ef614918260 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -286,6 +286,7 @@ void main()
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
+		/*
 		// screen-space cheap fakey reflection map
 		//
 		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
@@ -325,6 +326,8 @@ void main()
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 		ssshiny *= 0.3; // dampen it even more
+		*/
+		vec3 ssshiny = vec3(0,0,0);
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 28cfc6322e0..bc84720b86b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -285,6 +285,7 @@ void main()
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
+		/*
 		// screen-space cheap fakey reflection map
 		//
 		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
@@ -325,6 +326,8 @@ void main()
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 		ssshiny *= 0.3; // dampen it even more
+		*/
+		vec3 ssshiny = vec3(0,0,0);
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 9f94b9e8eaa..5298079af79 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -288,6 +288,7 @@ void main()
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
+		/*
 		// screen-space cheap fakey reflection map
 		//
 		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
@@ -329,6 +330,8 @@ void main()
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 		ssshiny *= 0.3; // dampen it even more
+		*/
+		vec3 ssshiny = vec3(0,0,0);
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
-- 
GitLab


From a295803279f250c1b75b8c5cae73dd25c0786413 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Fri, 7 May 2010 14:40:21 -0700
Subject: [PATCH 386/683] Simple adjustment to model preview UI and added text.

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

diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index 8a20712ea85..159e4b41cac 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -69,7 +69,7 @@ const S32 PREVIEW_BORDER_WIDTH = 2;
 const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
 const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
 const S32 PREF_BUTTON_HEIGHT = 16 + 7 + 16;
-const S32 PREVIEW_TEXTURE_HEIGHT = 300;
+const S32 PREVIEW_TEXTURE_HEIGHT = 320;
 
 //-----------------------------------------------------------------------------
 // LLFloaterImagePreview()
-- 
GitLab


From f3b6bc0d4c6361a62c49cb77b5a510326a3f3d93 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Fri, 7 May 2010 15:24:53 -0700
Subject: [PATCH 387/683] Turning off shadows and deferred by default

---
 indra/newview/app_settings/high_graphics.xml | 4 ++--
 indra/newview/featuretable.txt               | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/app_settings/high_graphics.xml b/indra/newview/app_settings/high_graphics.xml
index 93d39c84144..587b2f2a896 100644
--- a/indra/newview/app_settings/high_graphics.xml
+++ b/indra/newview/app_settings/high_graphics.xml
@@ -33,10 +33,10 @@
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
   <!--Deferred Shading-->
-  <RenderDeferred value="TRUE"/>
+  <RenderDeferred value="FALSE"/>
   <!--SSAO Disabled-->
   <RenderDeferredSSAO value="FALSE"/>
   <!--Sun Shadows-->
-  <RenderShadowDetail value="1"/>
+  <RenderShadowDetail value="0"/>
 
 </settings>
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 1913f52499b..cf280ae5f6c 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -135,9 +135,9 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
-RenderDeferred				1	1
+RenderDeferred				1	0
 RenderDeferredSSAO			1	0
-RenderShadowDetail			1	1
+RenderShadowDetail			1	0
 
 
 //
-- 
GitLab


From 45396901731dc7ecb8ade9e585a43e811f4e4f05 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Fri, 7 May 2010 17:43:12 -0500
Subject: [PATCH 388/683] revert mac build to 10.4u sdk.  remove FBO code from
 llrendertarget.cpp with #ifdefs.

---
 indra/cmake/Variables.cmake       |  6 +++---
 indra/llrender/llrendertarget.cpp | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index f181e5b6fd5..6b9fcbf5096 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -81,13 +81,13 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   # otherwise CMAKE_OSX_SYSROOT will be overridden here. We can't just check
   # for it being unset, as it gets set to the system default :(
 
-  # Default to building against the 10.5 SDK if no deployment target is
+  # Default to building against the 10.4u SDK if no deployment target is
   # specified.
   if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
     # NOTE: setting -isysroot is NOT adequate: http://lists.apple.com/archives/Xcode-users/2007/Oct/msg00696.html
     # see http://public.kitware.com/Bug/view.php?id=9959 + poppy
-    set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
-    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
+    set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk)
+    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.4u)
   endif (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
 
   # GCC 4.2 is incompatible with the MacOSX 10.4 SDK
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 3f2558f1f5e..d9520b3bf63 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -390,6 +390,8 @@ void LLRenderTarget::flush(BOOL fetch_depth)
 	}
 	else
 	{
+#if !LL_DARWIN
+
 		stop_glerror();
 
 		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
@@ -433,6 +435,7 @@ void LLRenderTarget::flush(BOOL fetch_depth)
 				}
 			}
 		}
+#endif
 
 		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 	}
@@ -441,6 +444,7 @@ void LLRenderTarget::flush(BOOL fetch_depth)
 void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, S32 srcX1, S32 srcY1,
 						S32 dstX0, S32 dstY0, S32 dstX1, S32 dstY1, U32 mask, U32 filter)
 {
+#if !LL_DARWIN
 	gGL.flush();
 	if (!source.mFBO || !mFBO)
 	{
@@ -479,12 +483,14 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0,
 			stop_glerror();
 		}
 	}
+#endif
 }
 
 //static
 void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0, S32 srcY0, S32 srcX1, S32 srcY1,
 						S32 dstX0, S32 dstY0, S32 dstX1, S32 dstY1, U32 mask, U32 filter)
 {
+#if !LL_DARWIN
 	if (!source.mFBO)
 	{
 		llerrs << "Cannot copy framebuffer contents for non FBO render targets." << llendl;
@@ -501,6 +507,7 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0
 		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 		stop_glerror();
 	}
+#endif
 }
 
 BOOL LLRenderTarget::isComplete() const
@@ -645,6 +652,7 @@ void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth
 
 void LLMultisampleBuffer::addColorAttachment(U32 color_fmt)
 {
+#if !LL_DARWIN
 	if (color_fmt == 0)
 	{
 		return;
@@ -685,10 +693,12 @@ void LLMultisampleBuffer::addColorAttachment(U32 color_fmt)
 	}
 
 	mTex.push_back(tex);
+#endif
 }
 
 void LLMultisampleBuffer::allocateDepth()
 {
+#if !LL_DARWIN
 	glGenRenderbuffersEXT(1, (GLuint* ) &mDepth);
 	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepth);
 	if (mStencil)
@@ -699,5 +709,6 @@ void LLMultisampleBuffer::allocateDepth()
 	{
 		glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, mSamples, GL_DEPTH_COMPONENT16_ARB, mResX, mResY);	
 	}
+#endif
 }
 
-- 
GitLab


From 761b346e8d6fcb9c052b5cfabc9a6be43b5775fe Mon Sep 17 00:00:00 2001
From: Palmer Truelson <palmer@lindenlab.com>
Date: Fri, 7 May 2010 16:32:29 -0700
Subject: [PATCH 389/683] Turning off universal builds

---
 indra/cmake/00-Common.cmake | 2 +-
 indra/cmake/Variables.cmake | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 113e21a7155..ef83f436356 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -208,7 +208,7 @@ if (LINUX OR DARWIN)
     set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
   endif (NOT GCC_DISABLE_FATAL_WARNINGS)
 
-  set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor")
+  set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor -Woverloaded-virtual")
 
   set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}")
   set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index 6b9fcbf5096..28feb523ea9 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -87,7 +87,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
     # NOTE: setting -isysroot is NOT adequate: http://lists.apple.com/archives/Xcode-users/2007/Oct/msg00696.html
     # see http://public.kitware.com/Bug/view.php?id=9959 + poppy
     set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk)
-    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.4u)
+    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.4)
   endif (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
 
   # GCC 4.2 is incompatible with the MacOSX 10.4 SDK
-- 
GitLab


From 33c4d124ce60b2999efb73fc17dc996cb3c2a103 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 6 May 2010 13:53:52 +0100
Subject: [PATCH 390/683] EXT-6912 FIXED Deferred Rendering - shiny objects
 look like a projection instead of a reflection

Disable screen-space shiny while I chew on it some more.
(transplanted from bde80560117295f6b3e61f9b47f3bdea826945ca)
---
 .../app_settings/shaders/class1/deferred/softenLightF.glsl     | 3 +++
 .../app_settings/shaders/class2/deferred/softenLightF.glsl     | 3 +++
 .../app_settings/shaders/class3/deferred/softenLightF.glsl     | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index bf5dd4155c2..ef614918260 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -286,6 +286,7 @@ void main()
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
+		/*
 		// screen-space cheap fakey reflection map
 		//
 		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
@@ -325,6 +326,8 @@ void main()
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 		ssshiny *= 0.3; // dampen it even more
+		*/
+		vec3 ssshiny = vec3(0,0,0);
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 28cfc6322e0..bc84720b86b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -285,6 +285,7 @@ void main()
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
+		/*
 		// screen-space cheap fakey reflection map
 		//
 		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
@@ -325,6 +326,8 @@ void main()
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 		ssshiny *= 0.3; // dampen it even more
+		*/
+		vec3 ssshiny = vec3(0,0,0);
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 9f94b9e8eaa..5298079af79 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -288,6 +288,7 @@ void main()
 		float sa = dot(refnormpersp, vary_light.xyz);
 		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;
 
+		/*
 		// screen-space cheap fakey reflection map
 		//
 		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
@@ -329,6 +330,8 @@ void main()
 		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
 		vec3 ssshiny = (refprod * spec.a);
 		ssshiny *= 0.3; // dampen it even more
+		*/
+		vec3 ssshiny = vec3(0,0,0);
 
 		// add the two types of shiny together
 		col += (ssshiny + dumbshiny) * spec.rgb;
-- 
GitLab


From 4462a906714a3783d22d421a3734974a204617e5 Mon Sep 17 00:00:00 2001
From: Palmer <palmer@lindenlab.com>
Date: Fri, 7 May 2010 15:24:53 -0700
Subject: [PATCH 391/683] Turning off shadows and deferred by default
 (transplanted from 2fa444675ca24b5b2a1bef8fd27fa52af1f6fcf8)

---
 indra/newview/app_settings/high_graphics.xml | 4 ++--
 indra/newview/featuretable.txt               | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/app_settings/high_graphics.xml b/indra/newview/app_settings/high_graphics.xml
index 93d39c84144..587b2f2a896 100644
--- a/indra/newview/app_settings/high_graphics.xml
+++ b/indra/newview/app_settings/high_graphics.xml
@@ -33,10 +33,10 @@
 	<!--NO SHADERS-->
 	<WindLightUseAtmosShaders value="TRUE"/>
   <!--Deferred Shading-->
-  <RenderDeferred value="TRUE"/>
+  <RenderDeferred value="FALSE"/>
   <!--SSAO Disabled-->
   <RenderDeferredSSAO value="FALSE"/>
   <!--Sun Shadows-->
-  <RenderShadowDetail value="1"/>
+  <RenderShadowDetail value="0"/>
 
 </settings>
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 1913f52499b..cf280ae5f6c 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -135,9 +135,9 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
-RenderDeferred				1	1
+RenderDeferred				1	0
 RenderDeferredSSAO			1	0
-RenderShadowDetail			1	1
+RenderShadowDetail			1	0
 
 
 //
-- 
GitLab


From 44e9e6d2310c598011d7af59ced43f32abbf68b0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 8 May 2010 16:10:05 -0500
Subject: [PATCH 392/683] Physics shape fetching.

---
 indra/newview/llspatialpartition.cpp          | 49 ++++++++++++++++++-
 indra/newview/llviewermenu.cpp                |  4 ++
 indra/newview/pipeline.h                      |  1 +
 .../skins/default/xui/en/menu_viewer.xml      | 10 ++++
 4 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 77c38798d12..6787018f5a0 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -44,6 +44,7 @@
 #include "llviewerregion.h"
 #include "llcamera.h"
 #include "pipeline.h"
+#include "llmeshrepository.h"
 #include "llrender.h"
 #include "lloctree.h"
 #include "llvoavatar.h"
@@ -2658,6 +2659,46 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE)
 	
 }
 
+void renderPhysicsShape(LLDrawable* drawable)
+{
+	LLVOVolume* volume = drawable->getVOVolume();
+	if (volume)
+	{
+		if (volume->isMesh())
+		{
+			LLUUID mesh_id = volume->getVolume()->getParams().getSculptID();
+			const LLMeshDecomposition* decomp = gMeshRepo.getDecomposition(mesh_id);
+			if (decomp)
+			{
+				gGL.pushMatrix();
+				glLoadMatrixd(gGLModelView);
+				gGL.flush();
+				glPointSize(4.f);
+				gGL.begin(LLRender::POINTS);
+				static std::vector<LLColor4U> color;
+
+				for (U32 i = 0; i < decomp->mHull.size(); ++i)
+				{
+					if (color.size() <= i)
+					{
+						color.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127));
+					}
+					gGL.color4ubv(color[i].mV);
+					for (U32 j = 0; j < decomp->mHull[i].size(); ++j)
+					{
+						LLVector3 v = volume->volumePositionToAgent(decomp->mHull[i][j]);
+						gGL.vertex3fv(v.mV);
+					}
+				}
+				gGL.end();
+				gGL.flush();
+				gGL.popMatrix();
+				glPointSize(1.f);
+			}
+		}
+	}
+}
+
 void renderTexturePriority(LLDrawable* drawable)
 {
 	for (int face=0; face<drawable->getNumFaces(); ++face)
@@ -2974,6 +3015,11 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 				renderBoundingBox(drawable);			
 			}
 			
+			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES))
+			{
+				renderPhysicsShape(drawable);
+			}
+
 			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BUILD_QUEUE))
 			{
 				if (drawable->isState(LLDrawable::IN_REBUILD_Q2))
@@ -3173,7 +3219,8 @@ void LLSpatialPartition::renderDebug()
 									  LLPipeline::RENDER_DEBUG_AVATAR_VOLUME |
 									  LLPipeline::RENDER_DEBUG_AGENT_TARGET |
 									  LLPipeline::RENDER_DEBUG_BUILD_QUEUE |
-									  LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) 
+									  LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA |
+									  LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) 
 	{
 		return;
 	}
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index b63ef921ac1..04c1c64f8ff 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -869,6 +869,10 @@ U32 info_display_from_string(std::string info_display)
 	{
 		return LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA;
 	}
+	else if ("physics shapes" == info_display)
+	{
+		return LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES;
+	}
 	else if ("occlusion" == info_display)
 	{
 		return LLPipeline::RENDER_DEBUG_OCCLUSION;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index be878ae6677..11c350000f8 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -413,6 +413,7 @@ class LLPipeline
 		RENDER_DEBUG_AVATAR_VOLUME      = 0x0100000,
 		RENDER_DEBUG_BUILD_QUEUE		= 0x0200000,
 		RENDER_DEBUG_AGENT_TARGET       = 0x0400000,
+		RENDER_DEBUG_PHYSICS_SHAPES     = 0x0800000,
 	};
 
 public:
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index bdc171ea529..b5406194312 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -1945,6 +1945,16 @@
            function="Advanced.ToggleInfoDisplay"
            parameter="shadow frusta" />
         </menu_item_check>
+        <menu_item_check
+         label="Physics Shapes"
+         name="Physics Shapes">
+          <menu_item_check.on_check
+           function="Advanced.CheckInfoDisplay"
+           parameter="physics shapes" />
+          <menu_item_check.on_click
+           function="Advanced.ToggleInfoDisplay"
+           parameter="physics shapes" />
+        </menu_item_check>
         <menu_item_check
          label="Occlusion"
          name="Occlusion">
-- 
GitLab


From 7539836bc960f9435d7712f71ae9a7d4b0df1c0b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 9 May 2010 12:35:32 +0100
Subject: [PATCH 393/683] EXT-7179 FIXED Wireframe mode is mostly useless in
 trunk (204029)

---
 indra/newview/pipeline.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 4fbc6bb5da9..05f14ff8f49 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -635,7 +635,8 @@ void LLPipeline::updateRenderDeferred()
 			 LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
 			 gSavedSettings.getBOOL("VertexShaderEnable") && 
 			 gSavedSettings.getBOOL("RenderAvatarVP") &&
-			 gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE;
+			 (gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE) &&
+		!gUseWireframe;
 	
 	sRenderDeferred = deferred;			
 }
@@ -6571,12 +6572,12 @@ void LLPipeline::renderDeferredLighting()
 		if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 2)
 		{
 			mDeferredLight[1].bindTarget();
-			mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
+			// clear color buffer here?  doesn't seem to matter.
 		}
 		else
 		{
 			mScreen.bindTarget();
-			mScreen.clear(GL_COLOR_BUFFER_BIT);
+			// clear color buffer here?  doesn't seem to matter.
 		}
 
 		if (gSavedSettings.getBOOL("RenderDeferredAtmospheric"))
-- 
GitLab


From 8f2ba1df9d93b723f64726c48a66b6ffe4228b08 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 9 May 2010 13:49:41 +0100
Subject: [PATCH 394/683] followup for glow glitch caused by EXT-7179 fix

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 05f14ff8f49..7b7a551fb32 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6577,7 +6577,9 @@ void LLPipeline::renderDeferredLighting()
 		else
 		{
 			mScreen.bindTarget();
-			// clear color buffer here?  doesn't seem to matter.
+			// clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky
+			glClearColor(0,0,0,0);
+			mScreen.clear(GL_COLOR_BUFFER_BIT);
 		}
 
 		if (gSavedSettings.getBOOL("RenderDeferredAtmospheric"))
-- 
GitLab


From ccc50f752223fb96ee97690e50725d204c003f55 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 9 May 2010 15:01:17 +0100
Subject: [PATCH 395/683] followup for glow glitch caused by EXT-7179 fix I
 knew I shouldn't have optimized those clears away!  sigh!

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

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 7b7a551fb32..91352ed4f3c 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6572,7 +6572,9 @@ void LLPipeline::renderDeferredLighting()
 		if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 2)
 		{
 			mDeferredLight[1].bindTarget();
-			// clear color buffer here?  doesn't seem to matter.
+			// clear color buffer here (GI) - zeroing alpha (glow) is important or it will accumulate against sky
+			glClearColor(0,0,0,0);
+			mScreen.clear(GL_COLOR_BUFFER_BIT);
 		}
 		else
 		{
-- 
GitLab


From 940bca8ebc03d963d8384f07b4bea7c5484691a3 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 9 May 2010 15:02:10 +0100
Subject: [PATCH 396/683] Rejig deferred normal-map packing a little, to double
 its accuracy for free.

---
 .../app_settings/shaders/class1/deferred/avatarF.glsl |  3 ++-
 .../shaders/class1/deferred/blurLightF.glsl           |  3 ++-
 .../app_settings/shaders/class1/deferred/bumpF.glsl   |  3 ++-
 .../shaders/class1/deferred/diffuseF.glsl             |  3 ++-
 .../app_settings/shaders/class1/deferred/giF.glsl     |  3 ++-
 .../shaders/class1/deferred/multiPointLightF.glsl     |  3 ++-
 .../shaders/class1/deferred/pointLightF.glsl          |  3 ++-
 .../app_settings/shaders/class1/deferred/postgiF.glsl |  9 +++++----
 .../shaders/class1/deferred/softenLightF.glsl         |  6 ++++--
 .../shaders/class1/deferred/spotLightF.glsl           |  3 ++-
 .../shaders/class1/deferred/sunLightSSAOF.glsl        |  3 ++-
 .../shaders/class1/deferred/terrainF.glsl             |  3 ++-
 .../app_settings/shaders/class1/deferred/treeF.glsl   |  3 ++-
 .../app_settings/shaders/class1/deferred/waterF.glsl  |  2 +-
 .../shaders/class2/deferred/blurLightF.glsl           |  3 ++-
 .../app_settings/shaders/class2/deferred/edgeF.glsl   | 11 ++++++++---
 .../shaders/class2/deferred/multiSpotLightF.glsl      |  3 ++-
 .../shaders/class2/deferred/softenLightF.glsl         |  7 +++++--
 .../shaders/class2/deferred/spotLightF.glsl           |  3 ++-
 .../shaders/class2/deferred/sunLightF.glsl            |  3 ++-
 .../shaders/class2/deferred/sunLightSSAOF.glsl        |  3 ++-
 .../shaders/class3/deferred/giDownsampleF.glsl        | 10 ++++++----
 .../app_settings/shaders/class3/deferred/giF.glsl     |  3 ++-
 .../shaders/class3/deferred/softenLightF.glsl         |  7 +++++--
 .../app_settings/shaders/class3/deferred/treeF.glsl   |  3 ++-
 25 files changed, 70 insertions(+), 36 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index 75df3889418..afbe08a5794 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -20,6 +20,7 @@ void main()
 	
 	gl_FragData[0] = vec4(diff.rgb, 0.0);
 	gl_FragData[1] = vec4(0,0,0,0);
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index 0fad5b4b50b..d1c5d7cb195 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -37,7 +37,8 @@ vec4 getPosition(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	vec3 pos = getPosition(vary_fragcoord.xy).xyz;
 	vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba;
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 6e38caf5ef8..2197744a372 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -24,5 +24,6 @@ void main()
 	gl_FragData[0] = vec4(col, 0.0);
 	gl_FragData[1] = gl_Color.aaaa; // spec
 	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
-	gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(tnorm);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 112103956da..3803119cda3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -15,5 +15,6 @@ void main()
 	gl_FragData[0] = vec4(col, 0.0);
 	gl_FragData[1] = gl_Color.aaaa; // spec
 	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
index b351eec6e54..d4b153c4af9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
@@ -159,7 +159,8 @@ void main()
 {
 	vec2 pos_screen = vary_fragcoord.xy;
 	vec4 pos = getPosition(pos_screen);
-	vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
 	gl_FragData[0].xyz = giAmbient(pos, norm);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 797b9e9f3bf..e1715eb4f98 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -53,7 +53,8 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz*2.0-1.0);
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	vec4 spec = texture2DRect(specularRect, frag.xy);
 	vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
 	float noise = texture2D(noiseMap, frag.xy/128.0).b;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index 78256e20cc6..3aecbc5f23c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -55,7 +55,8 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	float da = dot(norm, lv);
 	if (da < 0.0)
 	{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
index 9612aee4059..bd554c2d84c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
@@ -38,10 +38,10 @@ vec4 getPosition(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	vec3 pos = getPosition(vary_fragcoord.xy).xyz;
 	
-	
 	vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
 	vec2 dlt = kern_scale * delta/(1.0+norm.xy*norm.xy);
 	dlt /= max(-pos.z*dist_factor, 1.0);
@@ -51,9 +51,10 @@ void main()
 	for (int i = 0; i < kern_length; i++)
 	{
 		vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
-	    vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz*2.0-1.0;
+		vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz;
+		sampNorm = vec3((sampNorm.xy-0.5)*2.0,sampNorm.z); // unpack norm
 	    
-	    float d = dot(norm.xyz, sampNorm);
+		float d = dot(norm.xyz, sampNorm);
 		
 		if (d > 0.8)
 		{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index ef614918260..bef91e735dc 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -259,7 +259,8 @@ void main()
 	vec2 tc = vary_fragcoord.xy;
 	float depth = texture2DRect(depthMap, tc.xy).a;
 	vec3 pos = getPosition_d(tc, depth).xyz;
-	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, tc).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
 	float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
@@ -310,7 +311,8 @@ void main()
 				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		vec3 refn = texture2DRect(normalMap, ref2d).rgb;
+		refn = normalize(vec3((refn.xy-0.5)*2.0,refn.z)); // unpack norm
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index f320dbb4001..1b95b253c35 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -68,7 +68,8 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
 	norm = normalize(norm);
 	float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index 7450817ea7a..cdbed4b7917 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -114,7 +114,8 @@ void main()
 	
 	vec4 pos = getPosition(pos_screen);
 	
-    vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 		
 	gl_FragColor[0] = 1.0;
 	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 3cccfb72020..fa0a60c98d9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -29,6 +29,7 @@ void main()
 	
 	gl_FragData[0] = vec4(outColor.rgb, 0.0);
 	gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2);
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index 258acee08c1..5b33ea5bfe2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -14,5 +14,6 @@ void main()
 	vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
 	gl_FragData[0] = vec4(gl_Color.rgb*col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
 	gl_FragData[1] = vec4(0,0,0,0);
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index ceb7e0fb56e..361ae8dc843 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -137,5 +137,5 @@ void main()
 	
 	gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse
 	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
-	gl_FragData[2] = vec4(screenspacewavef*0.5+0.5, screenspacewavef.z*0.5); // normal, displace
+	gl_FragData[2] = vec4(screenspacewavef.xy*0.5+0.5, screenspacewavef.z, screenspacewavef.z*0.5); // normalxyz, displace
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
index 0fad5b4b50b..d1c5d7cb195 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
@@ -37,7 +37,8 @@ vec4 getPosition(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	vec3 pos = getPosition(vary_fragcoord.xy).xyz;
 	vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba;
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl b/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl
index 02beddd43b3..e32e9f4b326 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl
@@ -31,7 +31,8 @@ float getDepth(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	float depth = getDepth(vary_fragcoord.xy);
 	
 	vec2 tc = vary_fragcoord.xy;
@@ -46,8 +47,12 @@ void main()
 	de = step(depth_cutoff, de);
 	
 	vec2 ne;
-	ne.x = dot(texture2DRect(normalMap, tc+vec2(-sc,-sc)).rgb*2.0-1.0, norm);
-	ne.y = dot(texture2DRect(normalMap, tc+vec2(sc,sc)).rgb*2.0-1.0, norm);
+	vec3 nexnorm = texture2DRect(normalMap, tc+vec2(-sc,-sc)).rgb;
+	nexnorm = vec3((nexnorm.xy-0.5)*2.0,nexnorm.z); // unpack norm
+	ne.x = dot(nexnorm, norm);
+	vec3 neynorm = texture2DRect(normalMap, tc+vec2(sc,sc)).rgb;
+	neynorm = vec3((neynorm.xy-0.5)*2.0,neynorm.z); // unpack norm
+	ne.y = dot(neynorm, norm);
 	
 	ne = 1.0-ne;
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 5308e5bb1e1..22ffb58c635 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -129,7 +129,8 @@ void main()
 		shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
 	norm = normalize(norm);
 	float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index bc84720b86b..fd6ae2b9608 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -258,7 +258,8 @@ void main()
 	vec2 tc = vary_fragcoord.xy;
 	float depth = texture2DRect(depthMap, tc.xy).a;
 	vec3 pos = getPosition_d(tc, depth).xyz;
-	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, tc).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
 	float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
@@ -310,7 +311,9 @@ void main()
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		float refshad = texture2DRect(lightMap, ref2d).r;
-		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		vec3 refn = texture2DRect(normalMap, ref2d).rgb;
+		refn = vec3((refn.xy-0.5)*2.0,refn.z); // unpack norm
+		refn = normalize(refn);
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index eeaecc157ff..8a90199b7ca 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -82,7 +82,8 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
 	norm = normalize(norm);
 	float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 46db3c990cf..195a20e9dde 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -104,8 +104,9 @@ void main()
 	vec4 pos = getPosition(pos_screen);
 	
 	vec4 nmap4 = texture2DRect(normalMap, pos_screen);
+	nmap4 = vec4((nmap4.xy-0.5)*2.0,nmap4.z,nmap4.w); // unpack norm
 	float displace = nmap4.w;
-	vec3 norm = nmap4.xyz*2.0-1.0;
+	vec3 norm = nmap4.xyz;
 	
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
 	{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index a0dfc96f14e..4e33a1af450 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -164,8 +164,9 @@ void main()
 	vec4 pos = getPosition(pos_screen);
 	
 	vec4 nmap4 = texture2DRect(normalMap, pos_screen);
+	nmap4 = vec4((nmap4.xy-0.5)*2.0,nmap4.z,nmap4.w); // unpack norm
 	float displace = nmap4.w;
-	vec3 norm = nmap4.xyz*2.0-1.0;
+	vec3 norm = nmap4.xyz;
 	
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
 	{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl
index 7325825d6d4..66606233cdf 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl
@@ -44,7 +44,8 @@ float getDepth(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	float depth = getDepth(vary_fragcoord.xy);
 		
 	vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
@@ -56,9 +57,10 @@ void main()
 	for (int i = 0; i < kern_length; i++)
 	{
 		vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
-	    vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz*2.0-1.0;
-	    
-	   float d = dot(norm.xyz, sampNorm);
+		vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz;
+		sampNorm = vec3((sampNorm.xy-0.5)*2.0,sampNorm.z); // unpack norm
+		
+		float d = dot(norm.xyz, sampNorm);
 		
 		if (d > 0.5)
 		{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/giF.glsl b/indra/newview/app_settings/shaders/class3/deferred/giF.glsl
index 939710cb563..1b8354dbd10 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/giF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/giF.glsl
@@ -178,7 +178,8 @@ void main()
 	
 	float rad = gi_range*0.5;
 	
-	vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	float dist = max(length(pos.xyz)-rad, 0.0);
 	
 	float da = clamp(1.0-dist/rad, 0.0, 1.0);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 5298079af79..c88edd0a60b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -259,7 +259,8 @@ void main()
 	vec2 tc = vary_fragcoord.xy;
 	float depth = texture2DRect(depthMap, tc.xy).a;
 	vec3 pos = getPosition_d(tc, depth).xyz;
-	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, tc).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
 	float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
@@ -314,7 +315,9 @@ void main()
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		float refshad = texture2DRect(lightMap, ref2d).r;
-		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		vec3 refn = texture2DRect(normalMap, ref2d).rgb;
+		refn = vec3((refn.xy-0.5)*2.0,refn.z); // unpack norm
+		refn = normalize(refn);
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
diff --git a/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl
index 258acee08c1..5b33ea5bfe2 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl
@@ -14,5 +14,6 @@ void main()
 	vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
 	gl_FragData[0] = vec4(gl_Color.rgb*col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
 	gl_FragData[1] = vec4(0,0,0,0);
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
-- 
GitLab


From 49579bebdd274a88c2381c4cab3d09ecd393564d Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 10 May 2010 13:00:36 -0500
Subject: [PATCH 397/683] Fix for wierd triangle shadow bug and fix for ATI
 hating deferred rendering.

---
 indra/llrender/llrender.cpp                   |  1 +
 .../shaders/class2/deferred/avatarAlphaV.glsl |  3 +-
 indra/newview/featuretable.txt                |  1 +
 indra/newview/lldrawpoolavatar.cpp            | 43 ++++++++++---------
 indra/newview/lldrawpoolavatar.h              |  4 +-
 indra/newview/llviewerjointmesh.cpp           | 30 +++++++------
 indra/newview/pipeline.cpp                    |  2 +-
 7 files changed, 47 insertions(+), 37 deletions(-)

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 43662fbb5c3..2472339ec4c 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -165,6 +165,7 @@ void LLTexUnit::enable(eTextureType type)
 	if ( (mCurrTexType != type || gGL.mDirty) && (type != TT_NONE) )
 	{
 		activate();
+
 		if (mCurrTexType != TT_NONE && !gGL.mDirty)
 		{
 			disable(); // Force a disable of a previous texture type if it's enabled.
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index f8dd1b74314..de423ee22ac 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -21,6 +21,7 @@ varying vec3 vary_position;
 varying vec3 vary_ambient;
 varying vec3 vary_directional;
 varying vec3 vary_normal;
+varying vec3 vary_fragcoord;
 
 uniform float near_clip;
 uniform float shadow_offset;
@@ -77,7 +78,7 @@ void main()
 	gl_FrontColor = col;
 
 	gl_FogFragCoord = pos.z;
-
+	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
 }
 
 
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 1913f52499b..74d14c49b0c 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -57,6 +57,7 @@ RenderShaderLightingMaxLevel	1	3
 RenderDeferred				1	1
 RenderDeferredSSAO			1	1
 RenderShadowDetail			1	2
+RenderUseFBO				1	1
 
 
 //
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index a49cf8781ea..d1f4be71f55 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -62,6 +62,8 @@ static U32 sShaderLevel = 0;
 LLGLSLShader* LLDrawPoolAvatar::sVertexProgram = NULL;
 BOOL	LLDrawPoolAvatar::sSkipOpaque = FALSE;
 BOOL	LLDrawPoolAvatar::sSkipTransparent = FALSE;
+S32 LLDrawPoolAvatar::sDiffuseChannel = 0;
+
 
 static bool is_deferred_render = false;
 
@@ -99,7 +101,6 @@ BOOL gAvatarEmbossBumpMap = FALSE;
 static BOOL sRenderingSkinned = FALSE;
 S32 normal_channel = -1;
 S32 specular_channel = -1;
-S32 diffuse_channel = -1;
 S32 cube_channel = -1;
 
 static const U32 rigged_data_mask[] = {
@@ -279,6 +280,7 @@ void LLDrawPoolAvatar::beginPostDeferredAlpha()
 
 	gPipeline.bindDeferredShader(*sVertexProgram);
 	
+	sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 	enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
 }
 
@@ -286,7 +288,7 @@ void LLDrawPoolAvatar::beginDeferredRiggedAlpha()
 {
 	sVertexProgram = &gDeferredSkinnedAlphaProgram;
 	gPipeline.bindDeferredShader(*sVertexProgram);
-	diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
+	sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 	gPipeline.enableLightsDynamic();
 }
@@ -295,6 +297,7 @@ void LLDrawPoolAvatar::endDeferredRiggedAlpha()
 {
 	LLVertexBuffer::unbind();
 	gPipeline.unbindDeferredShader(*sVertexProgram);
+	sDiffuseChannel = 0;
 	LLVertexBuffer::sWeight4Loc = -1;
 	sVertexProgram = NULL;
 }
@@ -332,7 +335,7 @@ void LLDrawPoolAvatar::endPostDeferredAlpha()
 	disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
 	
 	gPipeline.unbindDeferredShader(*sVertexProgram);
-
+	sDiffuseChannel = 0;
 	sShaderLevel = mVertexShaderLevel;
 }
 
@@ -382,7 +385,7 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 	else
 	{
 		sVertexProgram = &gDeferredAttachmentShadowProgram;
-		diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
+		sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 		sVertexProgram->bind();
 		LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 	}
@@ -596,7 +599,7 @@ void LLDrawPoolAvatar::beginImpostor()
 	}
 
 	gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
-	diffuse_channel = 0;
+	sDiffuseChannel = 0;
 }
 
 void LLDrawPoolAvatar::endImpostor()
@@ -649,7 +652,7 @@ void LLDrawPoolAvatar::beginDeferredImpostor()
 
 	specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP);
 	normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL);
-	diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
+	sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 
 	sVertexProgram->bind();
 }
@@ -772,7 +775,7 @@ void LLDrawPoolAvatar::endSkinned()
 void LLDrawPoolAvatar::beginRiggedSimple()
 {
 	sVertexProgram = &gSkinnedObjectSimpleProgram;
-	diffuse_channel = 0;
+	sDiffuseChannel = 0;
 	gSkinnedObjectSimpleProgram.bind();
 	LLVertexBuffer::sWeight4Loc = gSkinnedObjectSimpleProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
@@ -788,7 +791,7 @@ void LLDrawPoolAvatar::endRiggedSimple()
 void LLDrawPoolAvatar::beginRiggedAlpha()
 {
 	sVertexProgram = &gSkinnedObjectSimpleProgram;
-	diffuse_channel = 0;
+	sDiffuseChannel = 0;
 	sVertexProgram->bind();
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
@@ -805,7 +808,7 @@ void LLDrawPoolAvatar::endRiggedAlpha()
 void LLDrawPoolAvatar::beginRiggedFullbrightAlpha()
 {
 	sVertexProgram = &gSkinnedObjectFullbrightProgram;
-	diffuse_channel = 0;
+	sDiffuseChannel = 0;
 	sVertexProgram->bind();
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
@@ -821,7 +824,7 @@ void LLDrawPoolAvatar::endRiggedFullbrightAlpha()
 void LLDrawPoolAvatar::beginRiggedGlow()
 {
 	sVertexProgram = &gSkinnedObjectFullbrightProgram;
-	diffuse_channel = 0;
+	sDiffuseChannel = 0;
 	sVertexProgram->bind();
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
@@ -837,7 +840,7 @@ void LLDrawPoolAvatar::endRiggedGlow()
 void LLDrawPoolAvatar::beginRiggedFullbright()
 {
 	sVertexProgram = &gSkinnedObjectFullbrightProgram;
-	diffuse_channel = 0;
+	sDiffuseChannel = 0;
 	gSkinnedObjectFullbrightProgram.bind();
 	LLVertexBuffer::sWeight4Loc = gSkinnedObjectFullbrightProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
@@ -854,14 +857,14 @@ void LLDrawPoolAvatar::beginRiggedShinySimple()
 {
 	sVertexProgram = &gSkinnedObjectShinySimpleProgram;
 	sVertexProgram->bind();
-	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, diffuse_channel, cube_channel, false);
+	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
 void LLDrawPoolAvatar::endRiggedShinySimple()
 {
 	LLVertexBuffer::unbind();
-	LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, diffuse_channel, cube_channel, false);
+	LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
 	sVertexProgram->unbind();
 	sVertexProgram = NULL;
 	LLVertexBuffer::sWeight4Loc = -1;
@@ -871,14 +874,14 @@ void LLDrawPoolAvatar::beginRiggedFullbrightShiny()
 {
 	sVertexProgram = &gSkinnedObjectFullbrightShinyProgram;
 	sVertexProgram->bind();
-	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, diffuse_channel, cube_channel, false);
+	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
 void LLDrawPoolAvatar::endRiggedFullbrightShiny()
 {
 	LLVertexBuffer::unbind();
-	LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, diffuse_channel, cube_channel, false);
+	LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
 	sVertexProgram->unbind();
 	sVertexProgram = NULL;
 	LLVertexBuffer::sWeight4Loc = -1;
@@ -888,7 +891,7 @@ void LLDrawPoolAvatar::endRiggedFullbrightShiny()
 void LLDrawPoolAvatar::beginDeferredRiggedSimple()
 {
 	sVertexProgram = &gDeferredSkinnedDiffuseProgram;
-	diffuse_channel = 0;
+	sDiffuseChannel = 0;
 	sVertexProgram->bind();
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
@@ -906,7 +909,7 @@ void LLDrawPoolAvatar::beginDeferredRiggedBump()
 	sVertexProgram = &gDeferredSkinnedBumpProgram;
 	sVertexProgram->bind();
 	normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP);
-	diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
+	sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
@@ -918,7 +921,7 @@ void LLDrawPoolAvatar::endDeferredRiggedBump()
 	sVertexProgram->unbind();
 	LLVertexBuffer::sWeight4Loc = -1;
 	normal_channel = -1;
-	diffuse_channel = -1;
+	sDiffuseChannel = 0;
 	sVertexProgram = NULL;
 }
 
@@ -1047,7 +1050,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 					avatarp->mImpostor.bindTexture(1, specular_channel);
 				}
 			}
-			avatarp->renderImpostor(LLColor4U(255,255,255,255), diffuse_channel);
+			avatarp->renderImpostor(LLColor4U(255,255,255,255), sDiffuseChannel);
 		}
 		return;
 	}
@@ -1305,7 +1308,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 				glColor4f(0,0,0,face->getTextureEntry()->getGlow());
 			}
 
-			gGL.getTexUnit(diffuse_channel)->bind(face->getTexture());
+			gGL.getTexUnit(sDiffuseChannel)->bind(face->getTexture());
 			if (normal_channel > -1)
 			{
 				LLDrawPoolBump::bindBumpMap(face, normal_channel);
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index bab6f014807..4a5b0094128 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -1,4 +1,4 @@
-/** 
+ /** 
  * @file lldrawpoolavatar.h
  * @brief LLDrawPoolAvatar class definition
  *
@@ -205,6 +205,8 @@ class LLDrawPoolAvatar : public LLFacePool
 
 	static BOOL sSkipOpaque;
 	static BOOL sSkipTransparent;
+	static S32 sDiffuseChannel;
+
 	static LLGLSLShader* sVertexProgram;
 };
 
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index fb6cc8d7908..deb3d8fd97e 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -516,6 +516,8 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
 
 	U32 triangle_count = 0;
 
+	S32 diffuse_channel = LLDrawPoolAvatar::sDiffuseChannel;
+
 	stop_glerror();
 	
 	//----------------------------------------------------------------
@@ -541,7 +543,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
 	LLTexUnit::eTextureAddressMode old_mode = LLTexUnit::TAM_WRAP;
 	if (mTestImageName)
 	{
-		gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTestImageName);
+		gGL.getTexUnit(diffuse_channel)->bindManual(LLTexUnit::TT_TEXTURE, mTestImageName);
 
 		if (mIsTransparent)
 		{
@@ -550,18 +552,18 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
 		else
 		{
 			glColor4f(0.7f, 0.6f, 0.3f, 1.f);
-			gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_LERP_TEX_ALPHA, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
+			gGL.getTexUnit(diffuse_channel)->setTextureColorBlend(LLTexUnit::TBO_LERP_TEX_ALPHA, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
 		}
 	}
 	else if( !is_dummy && mLayerSet )
 	{
 		if(	mLayerSet->hasComposite() )
 		{
-			gGL.getTexUnit(0)->bind(mLayerSet->getComposite());
+			gGL.getTexUnit(diffuse_channel)->bind(mLayerSet->getComposite());
 		}
 		else
 		{
-			gGL.getTexUnit(0)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT));
+			gGL.getTexUnit(diffuse_channel)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT));
 		}
 	}
 	else
@@ -571,25 +573,25 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
 		{
 			old_mode = mTexture->getAddressMode();
 		}
-		gGL.getTexUnit(0)->bind(mTexture.get());
-		gGL.getTexUnit(0)->bind(mTexture);
-		gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
+		gGL.getTexUnit(diffuse_channel)->bind(mTexture.get());
+		gGL.getTexUnit(diffuse_channel)->bind(mTexture);
+		gGL.getTexUnit(diffuse_channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
 	}
 	else
 	{
-		gGL.getTexUnit(0)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT));
+		gGL.getTexUnit(diffuse_channel)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT));
 	}
 	
 	if (gRenderForSelect)
 	{
 		if (isTransparent())
 		{
-			gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR);
-			gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_CONST_ALPHA);
+			gGL.getTexUnit(diffuse_channel)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR);
+			gGL.getTexUnit(diffuse_channel)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_CONST_ALPHA);
 		}
 		else
 		{
-			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+			gGL.getTexUnit(diffuse_channel)->unbind(LLTexUnit::TT_TEXTURE);
 		}
 	}
 	
@@ -626,13 +628,13 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
 	
 	if (mTestImageName)
 	{
-		gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+		gGL.getTexUnit(diffuse_channel)->setTextureBlendType(LLTexUnit::TB_MULT);
 	}
 
 	if (mTexture.notNull() && !is_dummy)
 	{
-		gGL.getTexUnit(0)->bind(mTexture);
-		gGL.getTexUnit(0)->setTextureAddressMode(old_mode);
+		gGL.getTexUnit(diffuse_channel)->bind(mTexture);
+		gGL.getTexUnit(diffuse_channel)->setTextureAddressMode(old_mode);
 	}
 
 	return triangle_count;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 9bcec9e13d3..da01ae44db4 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -7778,7 +7778,7 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 		0,1,
 		1,2,
 		2,3,
-		3,1,
+		3,0,
 
 		4,5,
 		5,6,
-- 
GitLab


From f6c03a46731ad0af301ae2c8505050d9e514a7d4 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Mon, 10 May 2010 13:01:18 -0500
Subject: [PATCH 398/683] turn off -Woverloaded-virtual - incompatible with
 colladadom

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

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index ef83f436356..113e21a7155 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -208,7 +208,7 @@ if (LINUX OR DARWIN)
     set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
   endif (NOT GCC_DISABLE_FATAL_WARNINGS)
 
-  set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor -Woverloaded-virtual")
+  set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor")
 
   set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}")
   set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
-- 
GitLab


From 606721f978090ed09d413c9a844fc7358349608c Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 10 May 2010 16:21:15 -0600
Subject: [PATCH 399/683] EXT-7294: FIXED: crash at LLTextureCache::updateEntry
 [secondlife-bin lltexturecache.cpp:1231] Also simply the writing flow of the
 texture cache. (transplanted from efd5ac0975be77e734147e366ba2bb4988dd27e6)

---
 indra/newview/lltexturecache.cpp | 177 ++++++++++++-------------------
 indra/newview/lltexturecache.h   |   7 +-
 2 files changed, 72 insertions(+), 112 deletions(-)

diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index df79725474b..9ad23227655 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -401,7 +401,8 @@ bool LLTextureCacheRemoteWorker::doRead()
 	// Second state / stage : identify the cache or not...
 	if (!done && (mState == CACHE))
 	{
-		idx = mCache->getHeaderCacheEntry(mID, mImageSize);
+		LLTextureCache::Entry entry ;
+		idx = mCache->getHeaderCacheEntry(mID, entry);
 		if (idx < 0)
 		{
 			// The texture is *not* cached. We're done here...
@@ -410,6 +411,7 @@ bool LLTextureCacheRemoteWorker::doRead()
 		}
 		else
 		{
+			mImageSize = entry.mImageSize ;
 			// If the read offset is bigger than the header cache, we read directly from the body
 			// Note that currently, we *never* read with offset from the cache, so the result is *always* HEADER
 			mState = mOffset < TEXTURE_CACHE_ENTRY_SIZE ? HEADER : BODY;
@@ -531,13 +533,14 @@ bool LLTextureCacheRemoteWorker::doRead()
 bool LLTextureCacheRemoteWorker::doWrite()
 {
 	bool done = false;
-	S32 idx = -1;
+	S32 idx = -1;	
 
 	// First state / stage : check that what we're trying to cache is in an OK shape
 	if (mState == INIT)
 	{
 		llassert_always(mOffset == 0);	// We currently do not support write offsets
 		llassert_always(mDataSize > 0); // Things will go badly wrong if mDataSize is nul or negative...
+		llassert_always(mImageSize >= mDataSize);
 		mState = CACHE;
 	}
 	
@@ -547,14 +550,19 @@ bool LLTextureCacheRemoteWorker::doWrite()
 	if (!done && (mState == CACHE))
 	{
 		bool alreadyCached = false;
-		S32 cur_imagesize = 0;
+		LLTextureCache::Entry entry ;
+
 		// Checks if this image is already in the entry list
-		idx = mCache->getHeaderCacheEntry(mID, cur_imagesize);
-		if (idx >= 0 && (cur_imagesize > 0))
+		idx = mCache->getHeaderCacheEntry(mID, entry);
+		if(idx < 0)
+		{
+			idx = mCache->setHeaderCacheEntry(mID, entry, mImageSize, mDataSize); // create the new entry.
+		}
+		else
 		{
-			alreadyCached = true;	// already there and non empty
+			alreadyCached = mCache->updateEntry(idx, entry, mImageSize, mDataSize); // update the existing entry.
 		}
-		idx = mCache->setHeaderCacheEntry(mID, mImageSize); // create or touch the entry
+
 		if (idx < 0)
 		{
 			llwarns << "LLTextureCacheWorker: "  << mID
@@ -564,10 +572,6 @@ bool LLTextureCacheRemoteWorker::doWrite()
 		}
 		else
 		{
-			if (cur_imagesize > 0 && (mImageSize != cur_imagesize))
-			{
-				alreadyCached = false; // re-write the header if the size changed in all cases
-			}
 			if (alreadyCached && (mDataSize <= TEXTURE_CACHE_ENTRY_SIZE))
 			{
 				// Small texture already cached case: we're done with writing
@@ -630,7 +634,7 @@ bool LLTextureCacheRemoteWorker::doWrite()
 	{
 		llassert(mDataSize > TEXTURE_CACHE_ENTRY_SIZE);	// wouldn't make sense to be here otherwise...
 		S32 file_size = mDataSize - TEXTURE_CACHE_ENTRY_SIZE;
-		if ((file_size > 0) && mCache->updateTextureEntryList(mID, file_size))
+		
 		{
 			// build the cache file name from the UUID
 			std::string filename = mCache->getTextureFileName(mID);			
@@ -648,10 +652,7 @@ bool LLTextureCacheRemoteWorker::doWrite()
 				done = true;
 			}
 		}
-		else
-		{
-			mDataSize = 0; // no data written
-		}
+		
 		// Nothing else to do at that point...
 		done = true;
 	}
@@ -825,53 +826,6 @@ std::string LLTextureCache::getTextureFileName(const LLUUID& id)
 	return filename;
 }
 
-bool LLTextureCache::updateTextureEntryList(const LLUUID& id, S32 bodysize)
-{
-	bool res = false;
-	bool purge = false;
-	{
-		LLMutexLock lock(&mHeaderMutex);
-		size_map_t::iterator iter1 = mTexturesSizeMap.find(id);
-		if (iter1 == mTexturesSizeMap.end() || iter1->second < bodysize)
-		{
-			llassert_always(bodysize > 0);
-
-			S32 oldbodysize = 0;
-			if (iter1 != mTexturesSizeMap.end())
-			{
-				oldbodysize = iter1->second;
-			}
-						
-			Entry entry;
-			S32 idx = openAndReadEntry(id, entry, false);
-			if (idx < 0)
-			{
-				llwarns << "Failed to open entry: " << id << llendl;
-				removeCachedTexture(id) ;
-				return false;
-			}			
-			else if (oldbodysize != entry.mBodySize)
-			{
-				// only happens to 64 bits systems, do not know why.
-				llwarns << "Entry mismatch in mTextureSizeMap / mHeaderIDMap"
-					   << " idx=" << idx << " oldsize=" << oldbodysize << " entrysize=" << entry.mBodySize << llendl;
-			}
-			updateEntry(idx, entry, entry.mImageSize, bodysize);			
-			
-			if (mTexturesSizeTotal > sCacheMaxTexturesSize)
-			{
-				purge = true;
-			}
-			res = true;
-		}
-	}
-	if (purge)
-	{
-		mDoPurge = TRUE;
-	}
-	return res;
-}
-
 //debug
 BOOL LLTextureCache::isInCache(const LLUUID& id) 
 {
@@ -1207,55 +1161,64 @@ void LLTextureCache::updateEntryTimeStamp(S32 idx, Entry& entry)
 	{
 		if (!mReadOnly)
 		{
-			llassert_always(entry.mImageSize > entry.mBodySize);
-
 			entry.mTime = time(NULL);			
 			mUpdatedEntryMap[idx] = entry ;
 		}
 	}
 }
 
-//mHeaderMutex is locked before calling this.
 //update an existing entry, write to header file immediately.
-void LLTextureCache::updateEntry(S32 idx, Entry& entry, S32 new_image_size, S32 new_body_size)
+bool LLTextureCache::updateEntry(S32 idx, Entry& entry, S32 new_image_size, S32 new_data_size)
 {
-	llassert_always(new_image_size > -1) ;
-
+	S32 new_body_size = llmax(0, new_data_size - TEXTURE_CACHE_ENTRY_SIZE) ;
+	
 	if(new_image_size == entry.mImageSize && new_body_size == entry.mBodySize)
 	{
-		updateEntryTimeStamp(idx, entry) ; //nothing changed.
+		return true ; //nothing changed.
 	}
-	else if (idx >= 0)
+	else 
 	{
-		if (!mReadOnly)
-		{
-			llassert_always(new_image_size > new_body_size) ;
+		bool purge = false ;
 
-			bool update_header = false ;
-			if(entry.mImageSize < 0) //is a brand-new entry
-			{
-				mHeaderIDMap[entry.mID] = idx;
-				mTexturesSizeMap[entry.mID] = new_body_size ;
-				mTexturesSizeTotal += new_body_size ;
-				
-				// Update Header
-				update_header = true ;
-			}				
-			else if (entry.mBodySize != new_body_size)
-			{
-				//already in mHeaderIDMap.
-				mTexturesSizeMap[entry.mID] = new_body_size ;
-				mTexturesSizeTotal -= entry.mBodySize ;
-				mTexturesSizeTotal += new_body_size ;
-			}
-			entry.mTime = time(NULL);
-			entry.mImageSize = new_image_size ; 
-			entry.mBodySize = new_body_size ;
+		lockHeaders() ;
+
+		bool update_header = false ;
+		if(entry.mImageSize < 0) //is a brand-new entry
+		{
+			mHeaderIDMap[entry.mID] = idx;
+			mTexturesSizeMap[entry.mID] = new_body_size ;
+			mTexturesSizeTotal += new_body_size ;
 			
-// 			llinfos << "Updating TE: " << idx << ": " << id << " Size: " << entry.mBodySize << " Time: " << entry.mTime << llendl;			
-			writeEntryToHeaderImmediately(idx, entry, update_header) ;
+			// Update Header
+			update_header = true ;
+		}				
+		else if (entry.mBodySize != new_body_size)
+		{
+			//already in mHeaderIDMap.
+			mTexturesSizeMap[entry.mID] = new_body_size ;
+			mTexturesSizeTotal -= entry.mBodySize ;
+			mTexturesSizeTotal += new_body_size ;
+		}
+		entry.mTime = time(NULL);
+		entry.mImageSize = new_image_size ; 
+		entry.mBodySize = new_body_size ;
+		
+		writeEntryToHeaderImmediately(idx, entry, update_header) ;
+	
+		if (mTexturesSizeTotal > sCacheMaxTexturesSize)
+		{
+			purge = true;
+		}
+		
+		unlockHeaders() ;
+
+		if (purge)
+		{
+			mDoPurge = TRUE;
 		}
 	}
+
+	return false ;
 }
 
 U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries)
@@ -1658,39 +1621,37 @@ LLTextureCacheWorker* LLTextureCache::getWriter(handle_t handle)
 // Called from work thread
 
 // Reads imagesize from the header, updates timestamp
-S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, S32& imagesize)
+S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, Entry& entry)
 {
-	LLMutexLock lock(&mHeaderMutex);
-	Entry entry;
+	LLMutexLock lock(&mHeaderMutex);	
 	S32 idx = openAndReadEntry(id, entry, false);
 	if (idx >= 0)
-	{
-		imagesize = entry.mImageSize;
+	{		
 		updateEntryTimeStamp(idx, entry); // updates time
 	}
 	return idx;
 }
 
 // Writes imagesize to the header, updates timestamp
-S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, S32 imagesize)
+S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, Entry& entry, S32 imagesize, S32 datasize)
 {
 	mHeaderMutex.lock();
-	llassert_always(imagesize >= 0);
-	Entry entry;
 	S32 idx = openAndReadEntry(id, entry, true);
+	mHeaderMutex.unlock();
+
 	if (idx >= 0)
 	{
-		updateEntry(idx, entry, imagesize, entry.mBodySize);
-		mHeaderMutex.unlock();
+		updateEntry(idx, entry, imagesize, datasize);				
 	}
 	else // retry
 	{
-		mHeaderMutex.unlock();
 		readHeaderCache(); // We couldn't write an entry, so refresh the LRU
+	
 		mHeaderMutex.lock();
 		llassert_always(!mLRU.empty() || mHeaderEntriesInfo.mEntries < sCacheMaxEntries);
 		mHeaderMutex.unlock();
-		idx = setHeaderCacheEntry(id, imagesize); // assert above ensures no inf. recursion
+
+		idx = setHeaderCacheEntry(id, entry, imagesize, datasize); // assert above ensures no inf. recursion
 	}
 	return idx;
 }
diff --git a/indra/newview/lltexturecache.h b/indra/newview/lltexturecache.h
index 5dc06ff4013..0fceee3011d 100644
--- a/indra/newview/lltexturecache.h
+++ b/indra/newview/lltexturecache.h
@@ -144,7 +144,6 @@ class LLTextureCache : public LLWorkerThread
 
 protected:
 	// Accessed by LLTextureCacheWorker
-	bool updateTextureEntryList(const LLUUID& id, S32 size);
 	std::string getLocalFileName(const LLUUID& id);
 	std::string getTextureFileName(const LLUUID& id);
 	void addCompleted(Responder* responder, bool success);
@@ -162,7 +161,7 @@ class LLTextureCache : public LLWorkerThread
 	void readEntriesHeader();
 	void writeEntriesHeader();
 	S32 openAndReadEntry(const LLUUID& id, Entry& entry, bool create);
-	void updateEntry(S32 idx, Entry& entry, S32 new_image_size, S32 new_body_size);
+	bool updateEntry(S32 idx, Entry& entry, S32 new_image_size, S32 new_body_size);
 	void updateEntryTimeStamp(S32 idx, Entry& entry) ;
 	U32 openAndReadEntries(std::vector<Entry>& entries);
 	void writeEntriesAndClose(const std::vector<Entry>& entries);
@@ -170,8 +169,8 @@ class LLTextureCache : public LLWorkerThread
 	void writeEntryToHeaderImmediately(S32 idx, Entry& entry, bool write_header = false) ;
 	void removeEntry(S32 idx, Entry& entry, std::string& filename);
 	void removeCachedTexture(const LLUUID& id) ;
-	S32 getHeaderCacheEntry(const LLUUID& id, S32& imagesize);
-	S32 setHeaderCacheEntry(const LLUUID& id, S32 imagesize);
+	S32 getHeaderCacheEntry(const LLUUID& id, Entry& entry);
+	S32 setHeaderCacheEntry(const LLUUID& id, Entry& entry, S32 imagesize, S32 datasize);
 	void writeUpdatedEntries() ;
 	void updatedHeaderEntriesFile() ;
 	void lockHeaders() { mHeaderMutex.lock(); }
-- 
GitLab


From 8d6fb2dbc6ad9566903f6cd2e539d0abb62d8391 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 11 May 2010 00:21:40 -0500
Subject: [PATCH 400/683] Hide mesh UI when MeshEnabled is set to false.

---
 indra/newview/app_settings/settings.xml             | 13 ++++++++++++-
 indra/newview/llviewermenufile.cpp                  | 11 ++++++++++-
 .../newview/skins/default/xui/en/floater_tools.xml  |  3 ---
 .../skins/default/xui/en/menu_inventory_add.xml     |  2 ++
 4 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 17b58eab47f..a2b88d17d4e 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4744,7 +4744,18 @@
       <key>Value</key>
       <real>0</real>
     </map>
-    <key>MigrateCacheDirectory</key>
+  <key>MeshEnabled</key>
+  <map>
+    <key>Comment</key>
+    <string>Expose UI for mesh functionality (may require restart to take effect).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <real>1</real>
+  </map>
+  <key>MigrateCacheDirectory</key>
     <map>
       <key>Comment</key>
       <string>Check for old version of disk cache to migrate to current location</string>
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index fb51344269b..aca0090d7de 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -101,6 +101,14 @@ class LLFileEnableUploadModel : public view_listener_t
 	}
 };
 
+class LLMeshEnabled : public view_listener_t
+{
+	bool handleEvent(const LLSD& userdata)
+	{
+		return gSavedSettings.getBOOL("MeshEnabled");
+	}
+};
+
 LLMutex* LLFilePickerThread::sMutex = NULL;
 std::queue<LLFilePickerThread*> LLFilePickerThread::sDeadQ;
 
@@ -1361,6 +1369,7 @@ void init_menu_file()
 
 	view_listener_t::addEnable(new LLFileEnableUpload(), "File.EnableUpload");
 	view_listener_t::addEnable(new LLFileEnableUploadModel(), "File.EnableUploadModel");
-	
+	view_listener_t::addMenu(new LLMeshEnabled(), "File.MeshEnabled");
+
 	// "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled.
 }
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index ce6fc48a3bf..f5054cf2064 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -2029,9 +2029,6 @@ even though the user gets a free copy.
                  label="Cylinder"
                  name="Cylinder"
                  value="Cylinder" />
-                <combo_box.item
-                 label="Mesh"
-                 value="Mesh" />
             </combo_box>
         </panel>
         <panel
diff --git a/indra/newview/skins/default/xui/en/menu_inventory_add.xml b/indra/newview/skins/default/xui/en/menu_inventory_add.xml
index 4e178eef964..936ef4e5394 100644
--- a/indra/newview/skins/default/xui/en/menu_inventory_add.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory_add.xml
@@ -51,6 +51,8 @@
                  parameter="" />
                 <menu_item_call.on_enable
                  function="File.EnableUploadModel" />
+                <menu_item_call.on_visible
+                function="File.MeshEnabled"/>
                 </menu_item_call>
                 <menu_item_call
                  label="Bulk (L$[COST] per file)..."
-- 
GitLab


From 45aa68fde1fd8c89fa5e7766e1f50b14a577638f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 11 May 2010 00:57:30 -0500
Subject: [PATCH 401/683] EXT-7225 Fix for busted projector shadows under
 certain settings.

---
 indra/newview/app_settings/settings.xml                        | 2 +-
 .../app_settings/shaders/class2/deferred/sunLightF.glsl        | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index a2b88d17d4e..623f0f3b01a 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6615,7 +6615,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>0.01</real>
+    <real>-0.01</real>
   </map>
 
   <key>RenderShadowResolutionScale</key>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 46db3c990cf..413835515ad 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -77,6 +77,7 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
+	stc.z += spot_shadow_offset;
 	stc.xyz /= stc.w;
 	stc.z += spot_shadow_bias*scl;
 	
@@ -181,7 +182,7 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = 1.0;
 	
-	spos.xyz = shadow_pos+offset*spot_shadow_offset;
+	spos = vec4(shadow_pos, 1.0);
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-- 
GitLab


From 9950c22a5568b55ff896734185e0e1181a93fcf0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 12 May 2010 03:59:01 -0500
Subject: [PATCH 402/683] Fix for fullbright bump not working in deferred
 render. Fix for shadow artifacts around split frusta. Tweak for shadow
 aliasing with projectors. Fix for crash on exit in mesh thread.

---
 indra/newview/app_settings/settings.xml       |   6 +-
 .../shaders/class2/deferred/sunLightF.glsl    |   3 +-
 indra/newview/lldrawpool.h                    |   1 +
 indra/newview/lldrawpoolbump.cpp              |  44 +-
 indra/newview/lldrawpoolbump.h                |   8 +-
 indra/newview/lldrawpoolsimple.cpp            |   3 +-
 indra/newview/llviewercontrol.cpp             |   3 +
 indra/newview/llviewerdisplay.cpp             |   8 +-
 indra/newview/llvovolume.cpp                  |  39 +-
 indra/newview/pipeline.cpp                    | 394 ++++++++++++------
 indra/newview/pipeline.h                      |  30 +-
 11 files changed, 364 insertions(+), 175 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 623f0f3b01a..4c72b03b2e2 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6604,7 +6604,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>-0.0005</real>
+    <real>0.0</real>
   </map>
   <key>RenderSpotShadowOffset</key>
   <map>
@@ -6615,7 +6615,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>-0.01</real>
+    <real>0.04</real>
   </map>
 
   <key>RenderShadowResolutionScale</key>
@@ -6751,7 +6751,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>1</real>
+    <real>8</real>
   </map>
 
   <key>RenderDeferred</key>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 413835515ad..794c4d27619 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -77,7 +77,6 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
-	stc.z += spot_shadow_offset;
 	stc.xyz /= stc.w;
 	stc.z += spot_shadow_bias*scl;
 	
@@ -182,7 +181,7 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = 1.0;
 	
-	spos = vec4(shadow_pos, 1.0);
+	spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index e46d503db32..ec870f59c6d 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -133,6 +133,7 @@ class LLRenderPass : public LLDrawPool
 		PASS_FULLBRIGHT_SHINY,
 		PASS_SHINY,
 		PASS_BUMP,
+		PASS_POST_BUMP,
 		PASS_GLOW,
 		PASS_ALPHA,
 		PASS_ALPHA_MASK,
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 906615ade83..967ce3fc5c8 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -659,9 +659,9 @@ BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, F32 vsi
 }
 
 //static
-void LLDrawPoolBump::beginBump()
+void LLDrawPoolBump::beginBump(U32 pass)
 {	
-	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+	if (!gPipeline.hasRenderBatches(pass))
 	{
 		return;
 	}
@@ -704,9 +704,9 @@ void LLDrawPoolBump::beginBump()
 }
 
 //static
-void LLDrawPoolBump::renderBump()
+void LLDrawPoolBump::renderBump(U32 pass)
 {
-	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+	if (!gPipeline.hasRenderBatches(pass))
 	{
 		return;
 	}
@@ -719,13 +719,13 @@ void LLDrawPoolBump::renderBump()
 	/// Get rid of z-fighting with non-bump pass.
 	LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
 	glPolygonOffset(-1.0f, -1.0f);
-	renderBump(LLRenderPass::PASS_BUMP, sVertexMask);
+	renderBump(pass, sVertexMask);
 }
 
 //static
-void LLDrawPoolBump::endBump()
+void LLDrawPoolBump::endBump(U32 pass)
 {
-	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+	if (!gPipeline.hasRenderBatches(pass))
 	{
 		return;
 	}
@@ -808,17 +808,41 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
 
 void LLDrawPoolBump::beginPostDeferredPass(S32 pass)
 {
-	beginFullbrightShiny();
+	switch (pass)
+	{
+	case 0:
+		beginFullbrightShiny();
+		break;
+	case 1:
+		beginBump(LLRenderPass::PASS_POST_BUMP);
+		break;
+	}
 }
 
 void LLDrawPoolBump::endPostDeferredPass(S32 pass)
 {
-	endFullbrightShiny();
+	switch (pass)
+	{
+	case 0:
+		endFullbrightShiny();
+		break;
+	case 1:
+		endBump(LLRenderPass::PASS_POST_BUMP);
+		break;
+	}
 }
 
 void LLDrawPoolBump::renderPostDeferred(S32 pass)
 {
-	renderFullbrightShiny();
+	switch (pass)
+	{
+	case 0:
+		renderFullbrightShiny();
+		break;
+	case 1:
+		renderBump(LLRenderPass::PASS_POST_BUMP);
+		break;
+	}
 }
 
 ////////////////////////////////////////////////////////////////
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index 127c9efe852..a75653e68e3 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -76,9 +76,9 @@ protected :
 	void renderFullbrightShiny();
 	void endFullbrightShiny();
 
-	void beginBump();
-	void renderBump();
-	void endBump();
+	void beginBump(U32 pass = LLRenderPass::PASS_BUMP);
+	void renderBump(U32 pass = LLRenderPass::PASS_BUMP);
+	void endBump(U32 pass = LLRenderPass::PASS_BUMP);
 
 	static void bindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible);
 	static void unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible);
@@ -88,7 +88,7 @@ protected :
 	/*virtual*/ void endDeferredPass(S32 pass);
 	/*virtual*/ void renderDeferred(S32 pass);
 
-	virtual S32 getNumPostDeferredPasses() { return 1; }
+	virtual S32 getNumPostDeferredPasses() { return 2; }
 	/*virtual*/ void beginPostDeferredPass(S32 pass);
 	/*virtual*/ void endPostDeferredPass(S32 pass);
 	/*virtual*/ void renderPostDeferred(S32 pass);
diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index c8e6f95ab6d..91191287cd9 100644
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -151,7 +151,8 @@ void LLDrawPoolSimple::render(S32 pass)
 		renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask());
 
 		if (LLPipeline::sRenderDeferred)
-		{
+		{ //if deferred rendering is enabled, bump faces aren't reigstered as simple
+			//render bump faces here as simple so bump faces will appear under water
 			renderTexture(LLRenderPass::PASS_BUMP, getVertexDataMask());
 		}
 	}
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index a8004f26edd..701df86de41 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -505,6 +505,9 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderUIBuffer")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderSpecularResX")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderSpecularResY")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderSpecularExponent")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderFSAASamples")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderShadowResolutionScale")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 360cee9f73a..3cd7af64339 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -946,9 +946,10 @@ void render_hud_attachments()
 		bool render_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) && gSavedSettings.getBOOL("RenderHUDParticles");
 		
 		//only render hud objects
-		U32 mask = gPipeline.getRenderTypeMask();
+		gPipeline.pushRenderTypeMask();
+		
 		// turn off everything
-		gPipeline.setRenderTypeMask(0);
+		gPipeline.andRenderTypeMask(LLPipeline::END_RENDER_TYPES);
 		// turn on HUD
 		gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
 		// turn on HUD particles
@@ -1002,7 +1003,8 @@ void render_hud_attachments()
 		render_hud_elements();
 
 		//restore type mask
-		gPipeline.setRenderTypeMask(mask);
+		gPipeline.popRenderTypeMask();
+
 		if (has_ui)
 		{
 			gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index aaa6e8007f4..b120f5abf32 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3349,7 +3349,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 		model_mat = &(drawable->getRegion()->mRenderMatrix);
 	}
 
-	U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0);
+
+	U8 bump = (type == LLRenderPass::PASS_BUMP || type == LLRenderPass::PASS_POST_BUMP) ? facep->getTextureEntry()->getBumpmap() : 0;
 	
 	LLViewerTexture* tex = facep->getTexture();
 
@@ -4052,66 +4053,76 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				&& group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD 
 				&& LLPipeline::sRenderBump 
 				&& te->getShiny())
-			{
+			{ //shiny
 				if (tex->getPrimaryFormat() == GL_ALPHA)
-				{
+				{ //invisiprim+shiny
 					registerFace(group, facep, LLRenderPass::PASS_INVISI_SHINY);
 					registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
 				}
 				else if (LLPipeline::sRenderDeferred)
-				{
+				{ //deferred rendering
 					if (te->getFullbright())
-					{
+					{ //register in post deferred fullbright shiny pass
 						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_SHINY);
+						if (te->getBumpmap())
+						{ //register in post deferred bump pass
+							registerFace(group, facep, LLRenderPass::PASS_POST_BUMP);
+						}
 					}
 					else if (te->getBumpmap())
-					{
+					{ //register in deferred bump pass
 						registerFace(group, facep, LLRenderPass::PASS_BUMP);
 					}
 					else
-					{
+					{ //register in deferred simple pass (deferred simple includes shiny)
 						llassert(mask & LLVertexBuffer::MAP_NORMAL);
 						registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
 					}
 				}
 				else if (fullbright)
-				{						
+				{	//not deferred, register in standard fullbright shiny pass					
 					registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_SHINY);
 				}
 				else
-				{
+				{ //not deferred or fullbright, register in standard shiny pass
 					registerFace(group, facep, LLRenderPass::PASS_SHINY);
 				}
 			}
 			else
-			{
+			{ //not alpha and not shiny
 				if (!is_alpha && tex->getPrimaryFormat() == GL_ALPHA)
-				{
+				{ //invisiprim
 					registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
 				}
 				else if (fullbright)
-				{
+				{ //fullbright
 					registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT);
+					if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap())
+					{ //if this is the deferred render and a bump map is present, register in post deferred bump
+						registerFace(group, facep, LLRenderPass::PASS_POST_BUMP);
+					}
 				}
 				else
 				{
 					if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap())
-					{
+					{ //non-shiny or fullbright deferred bump
 						registerFace(group, facep, LLRenderPass::PASS_BUMP);
 					}
 					else
-					{
+					{ //all around simple
 						llassert(mask & LLVertexBuffer::MAP_NORMAL);
 						registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
 					}
 				}
 				
+				//not sure why this is here -- shiny HUD attachments maybe?  -- davep 5/11/2010
 				if (!is_alpha && te->getShiny() && LLPipeline::sRenderBump)
 				{
 					registerFace(group, facep, LLRenderPass::PASS_SHINY);
 				}
 			}
 			
+			//not sure why this is here, and looks like it might cause bump mapped objects to get rendered redundantly -- davep 5/11/2010
 			if (!is_alpha && !LLPipeline::sRenderDeferred)
 			{
 				llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index da01ae44db4..a066b7fc0d9 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -331,7 +331,6 @@ LLPipeline::LLPipeline() :
 	mInitialized(FALSE),
 	mVertexShadersEnabled(FALSE),
 	mVertexShadersLoaded(0),
-	mRenderTypeMask(0),
 	mRenderDebugFeatureMask(0),
 	mRenderDebugMask(0),
 	mOldRenderDebugMask(0),
@@ -385,7 +384,11 @@ void LLPipeline::init()
 	LLViewerStats::getInstance()->mTrianglesDrawnStat.reset();
 	resetFrameStats();
 
-	mRenderTypeMask = 0xffffffff;	// All render types start on
+	for (U32 i = 0; i < NUM_RENDER_TYPES; ++i)
+	{
+		mRenderTypeEnabled[i] = TRUE; //all rendering types start enabled
+	}
+
 	mRenderDebugFeatureMask = 0xffffffff; // All debugging features on
 	mRenderDebugMask = 0;	// All debug starts off
 
@@ -2217,14 +2220,13 @@ static LLFastTimer::DeclareTimer FTM_RESET_DRAWORDER("Reset Draw Order");
 
 void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 {
-	const U32 face_mask = (1 << LLPipeline::RENDER_TYPE_AVATAR) |
-						  (1 << LLPipeline::RENDER_TYPE_GROUND) |
-						  (1 << LLPipeline::RENDER_TYPE_TERRAIN) |
-						  (1 << LLPipeline::RENDER_TYPE_TREE) |
-						  (1 << LLPipeline::RENDER_TYPE_SKY) |
-						  (1 << LLPipeline::RENDER_TYPE_WATER);
-
-	if (mRenderTypeMask & face_mask)
+	if (hasAnyRenderType(LLPipeline::RENDER_TYPE_AVATAR,
+					  LLPipeline::RENDER_TYPE_GROUND,
+					  LLPipeline::RENDER_TYPE_TERRAIN,
+					  LLPipeline::RENDER_TYPE_TREE,
+					  LLPipeline::RENDER_TYPE_SKY,
+					  LLPipeline::RENDER_TYPE_WATER,
+					  LLPipeline::END_RENDER_TYPES))
 	{
 		//clear faces from face pools
 		LLFastTimer t(FTM_RESET_DRAWORDER);
@@ -5072,8 +5074,7 @@ void LLPipeline::setLight(LLDrawable *drawablep, BOOL is_light)
 //static
 void LLPipeline::toggleRenderType(U32 type)
 {
-	U32 bit = (1<<type);
-	gPipeline.mRenderTypeMask ^= bit;
+	gPipeline.mRenderTypeEnabled[type] = !gPipeline.mRenderTypeEnabled[type];
 }
 
 //static
@@ -6695,15 +6696,16 @@ void LLPipeline::renderDeferredLighting()
 			LLGLDisable stencil(GL_STENCIL_TEST);
 			gGL.setSceneBlendType(LLRender::BT_ALPHA);
 
-			U32 render_mask = mRenderTypeMask;
-			mRenderTypeMask =	mRenderTypeMask & 
-								((1 << LLPipeline::RENDER_TYPE_SKY) |
-								(1 << LLPipeline::RENDER_TYPE_CLOUDS) |
-								(1 << LLPipeline::RENDER_TYPE_WL_SKY));
+			gPipeline.pushRenderTypeMask();
+			
+			gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
+										LLPipeline::RENDER_TYPE_CLOUDS,
+										LLPipeline::RENDER_TYPE_WL_SKY,
+										LLPipeline::END_RENDER_TYPES);
 								
 			
 			renderGeomPostDeferred(*LLViewerCamera::getInstance());
-			mRenderTypeMask = render_mask;
+			gPipeline.popRenderTypeMask();
 		}
 
 		BOOL render_local = gSavedSettings.getBOOL("RenderDeferredLocalLights");
@@ -7025,29 +7027,30 @@ void LLPipeline::renderDeferredLighting()
 		LLGLDisable blend(GL_BLEND);
 		LLGLDisable stencil(GL_STENCIL_TEST);
 
-		U32 render_mask = mRenderTypeMask;
-		mRenderTypeMask =	mRenderTypeMask & 
-							((1 << LLPipeline::RENDER_TYPE_ALPHA) |
-							(1 << LLPipeline::RENDER_TYPE_FULLBRIGHT) |
-							(1 << LLPipeline::RENDER_TYPE_VOLUME) |
-							(1 << LLPipeline::RENDER_TYPE_GLOW) |
-							(1 << LLPipeline::RENDER_TYPE_BUMP) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_ALPHA) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_GLOW) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_GRASS) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_INVISIBLE) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY) |
-							(1 << LLPipeline::RENDER_TYPE_AVATAR));
+		pushRenderTypeMask();
+		andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA,
+						 LLPipeline::RENDER_TYPE_FULLBRIGHT,
+						 LLPipeline::RENDER_TYPE_VOLUME,
+						 LLPipeline::RENDER_TYPE_GLOW,
+						 LLPipeline::RENDER_TYPE_BUMP,
+						 LLPipeline::RENDER_TYPE_PASS_SIMPLE,
+						 LLPipeline::RENDER_TYPE_PASS_ALPHA,
+						 LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK,
+						 LLPipeline::RENDER_TYPE_PASS_BUMP,
+						 LLPipeline::RENDER_TYPE_PASS_POST_BUMP,
+						 LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
+						 LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK,
+						 LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
+						 LLPipeline::RENDER_TYPE_PASS_GLOW,
+						 LLPipeline::RENDER_TYPE_PASS_GRASS,
+						 LLPipeline::RENDER_TYPE_PASS_SHINY,
+						 LLPipeline::RENDER_TYPE_PASS_INVISIBLE,
+						 LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY,
+						 LLPipeline::RENDER_TYPE_AVATAR,
+						 END_RENDER_TYPES);
 		
 		renderGeomPostDeferred(*LLViewerCamera::getInstance());
-		mRenderTypeMask = render_mask;
+		popRenderTypeMask();
 	}
 
 	{
@@ -7301,8 +7304,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 
 		LLPipeline::sUseOcclusion = llmin(occlusion, 1);
 		
-		U32 type_mask = gPipeline.mRenderTypeMask;
-
+		gPipeline.pushRenderTypeMask();
+		
 		glh::matrix4f projection = glh_get_current_projection();
 		glh::matrix4f mat;
 
@@ -7370,43 +7373,48 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 			glCullFace(GL_FRONT);
 
 			static LLCullResult ref_result;
-			U32 ref_mask = 0;
+		
 			if (LLDrawPoolWater::sNeedsDistortionUpdate)
 			{
 				//initial sky pass (no user clip plane)
 				{ //mask out everything but the sky
-					U32 tmp = mRenderTypeMask;
-					mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) |
-										(1 << LLPipeline::RENDER_TYPE_WL_SKY));
+					gPipeline.pushRenderTypeMask();
+					gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
+												LLPipeline::RENDER_TYPE_WL_SKY,
+												LLPipeline::END_RENDER_TYPES);
 					static LLCullResult result;
 					updateCull(camera, result);
 					llpushcallstacks ;
 					stateSort(camera, result);
-					mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) |
-										(1 << LLPipeline::RENDER_TYPE_CLOUDS) |
-										(1 << LLPipeline::RENDER_TYPE_WL_SKY));
+					andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
+										LLPipeline::RENDER_TYPE_CLOUDS,
+										LLPipeline::RENDER_TYPE_WL_SKY,
+										LLPipeline::END_RENDER_TYPES);
+
 					renderGeom(camera, TRUE);
-					mRenderTypeMask = tmp;
+					gPipeline.popRenderTypeMask();
 				}
 
-				U32 mask = mRenderTypeMask;
-				mRenderTypeMask &=	~((1<<LLPipeline::RENDER_TYPE_WATER) |
-									  (1<<LLPipeline::RENDER_TYPE_GROUND) |
-									  (1<<LLPipeline::RENDER_TYPE_SKY) |
-									  (1<<LLPipeline::RENDER_TYPE_CLOUDS));	
+				gPipeline.pushRenderTypeMask();
+				
+				clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
+									LLPipeline::RENDER_TYPE_GROUND,
+									LLPipeline::RENDER_TYPE_SKY,
+									LLPipeline::RENDER_TYPE_CLOUDS,
+									LLPipeline::END_RENDER_TYPES);	
 
 				S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
 				if (detail > 0)
 				{ //mask out selected geometry based on reflection detail
 					if (detail < 4)
 					{
-						mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_PARTICLES);
+						clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES);
 						if (detail < 3)
 						{
-							mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_AVATAR);
+							clearRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES);
 							if (detail < 2)
 							{
-								mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_VOLUME);
+								clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES);
 							}
 						}
 					}
@@ -7418,18 +7426,17 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 					stateSort(camera, ref_result);
 				}	
 				
-				ref_mask = mRenderTypeMask;
-				mRenderTypeMask = mask;
-			}
-			if (LLDrawPoolWater::sNeedsDistortionUpdate)
-			{
-				mRenderTypeMask = ref_mask;
-				if (gSavedSettings.getS32("RenderReflectionDetail") > 0)
+				if (LLDrawPoolWater::sNeedsDistortionUpdate)
 				{
-					gPipeline.grabReferences(ref_result);
-					LLGLUserClipPlane clip_plane(plane, mat, projection);
-					renderGeom(camera);
+					if (gSavedSettings.getS32("RenderReflectionDetail") > 0)
+					{
+						gPipeline.grabReferences(ref_result);
+						LLGLUserClipPlane clip_plane(plane, mat, projection);
+						renderGeom(camera);
+					}
 				}
+
+				gPipeline.popRenderTypeMask();
 			}	
 			glCullFace(GL_BACK);
 			glPopMatrix();
@@ -7443,18 +7450,20 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 		if (last_update)
 		{
 			camera.setFar(camera_in.getFar());
-			mRenderTypeMask = type_mask & (~(1<<LLPipeline::RENDER_TYPE_WATER) |
-											(1<<LLPipeline::RENDER_TYPE_GROUND));	
+			clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
+								LLPipeline::RENDER_TYPE_GROUND,
+								END_RENDER_TYPES);	
 			stop_glerror();
 
 			LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? FALSE : TRUE;
 
 			if (LLPipeline::sUnderWaterRender)
 			{
-				mRenderTypeMask &=	~((1<<LLPipeline::RENDER_TYPE_GROUND) |
-									  (1<<LLPipeline::RENDER_TYPE_SKY) |
-									  (1<<LLPipeline::RENDER_TYPE_CLOUDS) |
-									  (1<<LLPipeline::RENDER_TYPE_WL_SKY));		
+				clearRenderTypeMask(LLPipeline::RENDER_TYPE_GROUND,
+									LLPipeline::RENDER_TYPE_SKY,
+									LLPipeline::RENDER_TYPE_CLOUDS,
+									LLPipeline::RENDER_TYPE_WL_SKY,
+									END_RENDER_TYPES);		
 			}
 			LLViewerCamera::updateFrustumPlanes(camera);
 
@@ -7496,7 +7505,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 		}
 		glClearColor(0.f, 0.f, 0.f, 0.f);
 		gViewerWindow->setup3DViewport();
-		mRenderTypeMask = type_mask;
+		gPipeline.popRenderTypeMask();
 		LLDrawPoolWater::sNeedsReflectionUpdate = FALSE;
 		LLDrawPoolWater::sNeedsDistortionUpdate = FALSE;
 		LLViewerCamera::getInstance()->setUserClipPlane(LLPlane(-pnorm, -pd));
@@ -7951,21 +7960,22 @@ void LLPipeline::generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<L
 	sun_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR);
 	static LLCullResult result;
 
-	U32 type_mask = mRenderTypeMask;
+	pushRenderTypeMask();
 
-	mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) |
-								   (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
-								   (1<<LLPipeline::RENDER_TYPE_BUMP) |
-								   (1<<LLPipeline::RENDER_TYPE_VOLUME) |
-								   (1<<LLPipeline::RENDER_TYPE_TREE) | 
-								   (1<<LLPipeline::RENDER_TYPE_TERRAIN) |
-								   (1<<LLPipeline::RENDER_TYPE_WATER) |
-								   (1<<LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW) |
-								   (1<<LLPipeline::RENDER_TYPE_AVATAR) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
-									(1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
-									(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
-									(1 << LLPipeline::RENDER_TYPE_PASS_SHINY));
+	andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE,
+								 LLPipeline::RENDER_TYPE_FULLBRIGHT,
+								 LLPipeline::RENDER_TYPE_BUMP,
+								 LLPipeline::RENDER_TYPE_VOLUME,
+								 LLPipeline::RENDER_TYPE_TREE, 
+								 LLPipeline::RENDER_TYPE_TERRAIN,
+								 LLPipeline::RENDER_TYPE_WATER,
+								 LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW,
+								 LLPipeline::RENDER_TYPE_AVATAR,
+								 LLPipeline::RENDER_TYPE_PASS_SIMPLE,
+								 LLPipeline::RENDER_TYPE_PASS_BUMP,
+								 LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
+								 LLPipeline::RENDER_TYPE_PASS_SHINY,
+								 END_RENDER_TYPES);
 
 
 	
@@ -8034,7 +8044,7 @@ void LLPipeline::generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<L
 	LLPipeline::sShadowRender = FALSE;
 	sMinRenderSize = 0.f;
 
-	mRenderTypeMask = type_mask;
+	popRenderTypeMask();
 
 }
 
@@ -8131,23 +8141,24 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		last_projection[i] = gGLLastProjection[i];
 	}
 
-	U32 type_mask = mRenderTypeMask;
-	mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) |
-								   (1<<LLPipeline::RENDER_TYPE_ALPHA) |
-								   (1<<LLPipeline::RENDER_TYPE_GRASS) |
-								   (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
-								   (1<<LLPipeline::RENDER_TYPE_BUMP) |
-								   (1<<LLPipeline::RENDER_TYPE_VOLUME) |
-								   (1<<LLPipeline::RENDER_TYPE_AVATAR) |
-								   (1<<LLPipeline::RENDER_TYPE_TREE) | 
-								   (1<<LLPipeline::RENDER_TYPE_TERRAIN) |
-								   (1<<LLPipeline::RENDER_TYPE_WATER) |
-								   (1<<LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY));
+	pushRenderTypeMask();
+	andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE,
+					LLPipeline::RENDER_TYPE_ALPHA,
+					LLPipeline::RENDER_TYPE_GRASS,
+					LLPipeline::RENDER_TYPE_FULLBRIGHT,
+					LLPipeline::RENDER_TYPE_BUMP,
+					LLPipeline::RENDER_TYPE_VOLUME,
+					LLPipeline::RENDER_TYPE_AVATAR,
+					LLPipeline::RENDER_TYPE_TREE, 
+					LLPipeline::RENDER_TYPE_TERRAIN,
+					LLPipeline::RENDER_TYPE_WATER,
+					LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW,
+					LLPipeline::RENDER_TYPE_PASS_SIMPLE,
+					LLPipeline::RENDER_TYPE_PASS_BUMP,
+					LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
+					LLPipeline::RENDER_TYPE_PASS_SHINY,
+					LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
+					END_RENDER_TYPES);
 
 	gGL.setColorMask(false, false);
 
@@ -8232,7 +8243,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 				mShadowFrustPoints[2].clear();
 				mShadowFrustPoints[3].clear();
 			}
-			mRenderTypeMask = type_mask;
+			popRenderTypeMask();
 			return;
 		}
 
@@ -8318,10 +8329,11 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		for (U32 i = 0; i < 4; i++)
 		{
 			LLVector3 delta = frust[i+4]-eye;
+			delta += (frust[i+4]-frust[(i+2)%4+4])*0.05f;
 			delta.normVec();
 			F32 dp = delta*pn;
-			frust[i] = eye + (delta*dist[j])/dp;
-			frust[i+4] = eye + (delta*dist[j+1])/dp;
+			frust[i] = eye + (delta*dist[j]*0.95f)/dp;
+			frust[i+4] = eye + (delta*dist[j+1]*1.05f)/dp;
 		}
 						
 		shadow_cam.calcAgentFrustumPlanes(frust);
@@ -8834,7 +8846,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		gGLLastProjection[i] = last_projection[i];
 	}
 
-	mRenderTypeMask = type_mask;
+	popRenderTypeMask();
 }
 
 void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture)
@@ -8873,35 +8885,34 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	U32 mask;
 	BOOL muted = LLMuteList::getInstance()->isMuted(avatar->getID());
 
+	pushRenderTypeMask();
+	
 	if (muted)
 	{
-		mask  = 1 << LLPipeline::RENDER_TYPE_AVATAR;
+		andRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES);
 	}
 	else
 	{
-		mask  = (1<<LLPipeline::RENDER_TYPE_VOLUME) |
-				(1<<LLPipeline::RENDER_TYPE_AVATAR) |
-				(1<<LLPipeline::RENDER_TYPE_BUMP) |
-				(1<<LLPipeline::RENDER_TYPE_GRASS) |
-				(1<<LLPipeline::RENDER_TYPE_SIMPLE) |
-				(1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
-				(1<<LLPipeline::RENDER_TYPE_ALPHA) | 
-				(1<<LLPipeline::RENDER_TYPE_INVISIBLE) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_ALPHA) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_INVISIBLE) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY);
+		andRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME,
+						LLPipeline::RENDER_TYPE_AVATAR,
+						LLPipeline::RENDER_TYPE_BUMP,
+						LLPipeline::RENDER_TYPE_GRASS,
+						LLPipeline::RENDER_TYPE_SIMPLE,
+						LLPipeline::RENDER_TYPE_FULLBRIGHT,
+						LLPipeline::RENDER_TYPE_ALPHA, 
+						LLPipeline::RENDER_TYPE_INVISIBLE,
+						LLPipeline::RENDER_TYPE_PASS_SIMPLE,
+						LLPipeline::RENDER_TYPE_PASS_ALPHA,
+						LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK,
+						LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
+						LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK,
+						LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
+						LLPipeline::RENDER_TYPE_PASS_SHINY,
+						LLPipeline::RENDER_TYPE_PASS_INVISIBLE,
+						LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY,
+						END_RENDER_TYPES);
 	}
 	
-	mask = mask & gPipeline.getRenderTypeMask();
-	U32 saved_mask = gPipeline.mRenderTypeMask;
-	gPipeline.mRenderTypeMask = mask;
-
 	S32 occlusion = sUseOcclusion;
 	sUseOcclusion = 0;
 	sReflectionRender = sRenderDeferred ? FALSE : TRUE;
@@ -9075,7 +9086,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	sReflectionRender = FALSE;
 	sImpostorRender = FALSE;
 	sShadowRender = FALSE;
-	gPipeline.mRenderTypeMask = saved_mask;
+	popRenderTypeMask();
 
 	glMatrixMode(GL_PROJECTION);
 	glPopMatrix();
@@ -9116,4 +9127,121 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
 	return sCull->endAlphaGroups();
 }
 
+BOOL LLPipeline::hasRenderType(const U32 type) const
+{
+	return mRenderTypeEnabled[type];
+}
+
+void LLPipeline::setRenderTypeMask(U32 type, ...)
+{
+	va_list args;
+
+	va_start(args, type);
+	while (type < END_RENDER_TYPES)
+	{
+		mRenderTypeEnabled[type] = TRUE;
+		type = va_arg(args, U32);
+	}
+	va_end(args);
+
+	if (type > END_RENDER_TYPES)
+	{
+		llerrs << "Invalid render type." << llendl;
+	}
+}
+
+BOOL LLPipeline::hasAnyRenderType(U32 type, ...) const
+{
+	va_list args;
+
+	va_start(args, type);
+	while (type < END_RENDER_TYPES)
+	{
+		if (mRenderTypeEnabled[type])
+		{
+			return TRUE;
+		}
+		type = va_arg(args, U32);
+	}
+	va_end(args);
+
+	if (type > END_RENDER_TYPES)
+	{
+		llerrs << "Invalid render type." << llendl;
+	}
+
+	return FALSE;
+}
+
+void LLPipeline::pushRenderTypeMask()
+{
+	std::string cur_mask;
+	cur_mask.assign((const char*) mRenderTypeEnabled, sizeof(mRenderTypeEnabled));
+	mRenderTypeEnableStack.push(cur_mask);
+}
+
+void LLPipeline::popRenderTypeMask()
+{
+	if (mRenderTypeEnableStack.empty())
+	{
+		llerrs << "Depleted render type stack." << llendl;
+	}
+
+	memcpy(mRenderTypeEnabled, mRenderTypeEnableStack.top().data(), sizeof(mRenderTypeEnabled));
+	mRenderTypeEnableStack.pop();
+}
+
+void LLPipeline::andRenderTypeMask(U32 type, ...)
+{
+	va_list args;
+
+	BOOL tmp[NUM_RENDER_TYPES];
+	for (U32 i = 0; i < NUM_RENDER_TYPES; ++i)
+	{
+		tmp[i] = FALSE;
+	}
+
+	va_start(args, type);
+	while (type < END_RENDER_TYPES)
+	{
+		if (mRenderTypeEnabled[type]) 
+		{
+			tmp[type] = TRUE;
+		}
+
+		type = va_arg(args, U32);
+	}
+	va_end(args);
+
+	if (type > END_RENDER_TYPES)
+	{
+		llerrs << "Invalid render type." << llendl;
+	}
+
+	for (U32 i = 0; i < LLPipeline::NUM_RENDER_TYPES; ++i)
+	{
+		mRenderTypeEnabled[i] = tmp[i];
+	}
+
+}
+
+void LLPipeline::clearRenderTypeMask(U32 type, ...)
+{
+	va_list args;
+
+	va_start(args, type);
+	while (type < END_RENDER_TYPES)
+	{
+		mRenderTypeEnabled[type] = FALSE;
+		
+		type = va_arg(args, U32);
+	}
+	va_end(args);
+
+	if (type > END_RENDER_TYPES)
+	{
+		llerrs << "Invalid render type." << llendl;
+	}
+}
+
 
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index be878ae6677..2c14b948479 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -46,6 +46,8 @@
 #include "lldrawable.h"
 #include "llrendertarget.h"
 
+#include <stack>
+
 class LLViewerTexture;
 class LLEdge;
 class LLFace;
@@ -279,12 +281,25 @@ class LLPipeline
 	LLCullResult::sg_list_t::iterator beginAlphaGroups();
 	LLCullResult::sg_list_t::iterator endAlphaGroups();
 	
+
 	void addTrianglesDrawn(S32 index_count, U32 render_type = LLRender::TRIANGLES);
-	BOOL hasRenderType(const U32 type) const				{ return (type && (mRenderTypeMask & (1<<type))) ? TRUE : FALSE; }
+
 	BOOL hasRenderDebugFeatureMask(const U32 mask) const	{ return (mRenderDebugFeatureMask & mask) ? TRUE : FALSE; }
 	BOOL hasRenderDebugMask(const U32 mask) const			{ return (mRenderDebugMask & mask) ? TRUE : FALSE; }
-	void setRenderTypeMask(const U32 mask)					{ mRenderTypeMask = mask; }
-	U32  getRenderTypeMask() const							{ return mRenderTypeMask; }
+	
+
+
+	BOOL hasRenderType(const U32 type) const;
+	BOOL hasAnyRenderType(const U32 type, ...) const;
+
+	void setRenderTypeMask(U32 type, ...);
+	void orRenderTypeMask(U32 type, ...);
+	void andRenderTypeMask(U32 type, ...);
+	void clearRenderTypeMask(U32 type, ...);
+	
+	void pushRenderTypeMask();
+	void popRenderTypeMask();
+
 	static void toggleRenderType(U32 type);
 
 	// For UI control of render features
@@ -362,6 +377,7 @@ class LLPipeline
 		RENDER_TYPE_PASS_FULLBRIGHT_SHINY		= LLRenderPass::PASS_FULLBRIGHT_SHINY,
 		RENDER_TYPE_PASS_SHINY					= LLRenderPass::PASS_SHINY,
 		RENDER_TYPE_PASS_BUMP					= LLRenderPass::PASS_BUMP,
+		RENDER_TYPE_PASS_POST_BUMP				= LLRenderPass::PASS_POST_BUMP,
 		RENDER_TYPE_PASS_GLOW					= LLRenderPass::PASS_GLOW,
 		RENDER_TYPE_PASS_ALPHA					= LLRenderPass::PASS_ALPHA,
 		RENDER_TYPE_PASS_ALPHA_MASK				= LLRenderPass::PASS_ALPHA_MASK,
@@ -372,7 +388,9 @@ class LLPipeline
 		RENDER_TYPE_VOLUME,
 		RENDER_TYPE_PARTICLES,
 		RENDER_TYPE_CLOUDS,
-		RENDER_TYPE_HUD_PARTICLES
+		RENDER_TYPE_HUD_PARTICLES,
+		NUM_RENDER_TYPES,
+		END_RENDER_TYPES = NUM_RENDER_TYPES
 	};
 
 	enum LLRenderDebugFeatureMask
@@ -539,7 +557,9 @@ class LLPipeline
 	S32						mVertexShadersLoaded; // 0 = no, 1 = yes, -1 = failed
 
 protected:
-	U32						mRenderTypeMask;
+	BOOL					mRenderTypeEnabled[NUM_RENDER_TYPES];
+	std::stack<std::string> mRenderTypeEnableStack;
+
 	U32						mRenderDebugFeatureMask;
 	U32						mRenderDebugMask;
 
-- 
GitLab


From 6b26a7c330e83860b28ae051ddd4e88078921256 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 12 May 2010 11:26:44 +0100
Subject: [PATCH 403/683] remove unused var that was causing fatal gcc whining.

---
 indra/newview/pipeline.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index a066b7fc0d9..dbd7f864476 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8882,7 +8882,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 
 	assertInitialized();
 
-	U32 mask;
 	BOOL muted = LLMuteList::getInstance()->isMuted(avatar->getID());
 
 	pushRenderTypeMask();
-- 
GitLab


From 514186eee31c4bc44e7bc021bb9c526e4138cb07 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 9 May 2010 15:02:10 +0100
Subject: [PATCH 404/683] Rejig deferred normal-map packing a little, to double
 its accuracy for free. (transplanted from
 bf541483d9074c18c6d4f4bd19caf0de82013cbf)

---
 .../app_settings/shaders/class1/deferred/avatarF.glsl |  3 ++-
 .../shaders/class1/deferred/blurLightF.glsl           |  3 ++-
 .../app_settings/shaders/class1/deferred/bumpF.glsl   |  3 ++-
 .../shaders/class1/deferred/diffuseF.glsl             |  3 ++-
 .../app_settings/shaders/class1/deferred/giF.glsl     |  3 ++-
 .../shaders/class1/deferred/multiPointLightF.glsl     |  3 ++-
 .../shaders/class1/deferred/pointLightF.glsl          |  3 ++-
 .../app_settings/shaders/class1/deferred/postgiF.glsl |  9 +++++----
 .../shaders/class1/deferred/softenLightF.glsl         |  6 ++++--
 .../shaders/class1/deferred/spotLightF.glsl           |  3 ++-
 .../shaders/class1/deferred/sunLightSSAOF.glsl        |  3 ++-
 .../shaders/class1/deferred/terrainF.glsl             |  3 ++-
 .../app_settings/shaders/class1/deferred/treeF.glsl   |  3 ++-
 .../app_settings/shaders/class1/deferred/waterF.glsl  |  2 +-
 .../shaders/class2/deferred/blurLightF.glsl           |  3 ++-
 .../app_settings/shaders/class2/deferred/edgeF.glsl   | 11 ++++++++---
 .../shaders/class2/deferred/multiSpotLightF.glsl      |  3 ++-
 .../shaders/class2/deferred/softenLightF.glsl         |  7 +++++--
 .../shaders/class2/deferred/spotLightF.glsl           |  3 ++-
 .../shaders/class2/deferred/sunLightF.glsl            |  3 ++-
 .../shaders/class2/deferred/sunLightSSAOF.glsl        |  3 ++-
 .../shaders/class3/deferred/giDownsampleF.glsl        | 10 ++++++----
 .../app_settings/shaders/class3/deferred/giF.glsl     |  3 ++-
 .../shaders/class3/deferred/softenLightF.glsl         |  7 +++++--
 .../app_settings/shaders/class3/deferred/treeF.glsl   |  3 ++-
 25 files changed, 70 insertions(+), 36 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index 75df3889418..afbe08a5794 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -20,6 +20,7 @@ void main()
 	
 	gl_FragData[0] = vec4(diff.rgb, 0.0);
 	gl_FragData[1] = vec4(0,0,0,0);
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index 0fad5b4b50b..d1c5d7cb195 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -37,7 +37,8 @@ vec4 getPosition(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	vec3 pos = getPosition(vary_fragcoord.xy).xyz;
 	vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba;
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 6e38caf5ef8..2197744a372 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -24,5 +24,6 @@ void main()
 	gl_FragData[0] = vec4(col, 0.0);
 	gl_FragData[1] = gl_Color.aaaa; // spec
 	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
-	gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(tnorm);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 112103956da..3803119cda3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -15,5 +15,6 @@ void main()
 	gl_FragData[0] = vec4(col, 0.0);
 	gl_FragData[1] = gl_Color.aaaa; // spec
 	//gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
index b351eec6e54..d4b153c4af9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
@@ -159,7 +159,8 @@ void main()
 {
 	vec2 pos_screen = vary_fragcoord.xy;
 	vec4 pos = getPosition(pos_screen);
-	vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
 	gl_FragData[0].xyz = giAmbient(pos, norm);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 797b9e9f3bf..e1715eb4f98 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -53,7 +53,8 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz*2.0-1.0);
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	vec4 spec = texture2DRect(specularRect, frag.xy);
 	vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
 	float noise = texture2D(noiseMap, frag.xy/128.0).b;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index 78256e20cc6..3aecbc5f23c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -55,7 +55,8 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	float da = dot(norm, lv);
 	if (da < 0.0)
 	{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
index 9612aee4059..bd554c2d84c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
@@ -38,10 +38,10 @@ vec4 getPosition(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	vec3 pos = getPosition(vary_fragcoord.xy).xyz;
 	
-	
 	vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
 	vec2 dlt = kern_scale * delta/(1.0+norm.xy*norm.xy);
 	dlt /= max(-pos.z*dist_factor, 1.0);
@@ -51,9 +51,10 @@ void main()
 	for (int i = 0; i < kern_length; i++)
 	{
 		vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
-	    vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz*2.0-1.0;
+		vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz;
+		sampNorm = vec3((sampNorm.xy-0.5)*2.0,sampNorm.z); // unpack norm
 	    
-	    float d = dot(norm.xyz, sampNorm);
+		float d = dot(norm.xyz, sampNorm);
 		
 		if (d > 0.8)
 		{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index ef614918260..bef91e735dc 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -259,7 +259,8 @@ void main()
 	vec2 tc = vary_fragcoord.xy;
 	float depth = texture2DRect(depthMap, tc.xy).a;
 	vec3 pos = getPosition_d(tc, depth).xyz;
-	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, tc).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
 	float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
@@ -310,7 +311,8 @@ void main()
 				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
-		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		vec3 refn = texture2DRect(normalMap, ref2d).rgb;
+		refn = normalize(vec3((refn.xy-0.5)*2.0,refn.z)); // unpack norm
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index f320dbb4001..1b95b253c35 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -68,7 +68,8 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
 	norm = normalize(norm);
 	float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index 7450817ea7a..cdbed4b7917 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -114,7 +114,8 @@ void main()
 	
 	vec4 pos = getPosition(pos_screen);
 	
-    vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 		
 	gl_FragColor[0] = 1.0;
 	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 3cccfb72020..fa0a60c98d9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -29,6 +29,7 @@ void main()
 	
 	gl_FragData[0] = vec4(outColor.rgb, 0.0);
 	gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2);
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index 258acee08c1..5b33ea5bfe2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -14,5 +14,6 @@ void main()
 	vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
 	gl_FragData[0] = vec4(gl_Color.rgb*col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
 	gl_FragData[1] = vec4(0,0,0,0);
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index ceb7e0fb56e..361ae8dc843 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -137,5 +137,5 @@ void main()
 	
 	gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse
 	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
-	gl_FragData[2] = vec4(screenspacewavef*0.5+0.5, screenspacewavef.z*0.5); // normal, displace
+	gl_FragData[2] = vec4(screenspacewavef.xy*0.5+0.5, screenspacewavef.z, screenspacewavef.z*0.5); // normalxyz, displace
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
index 0fad5b4b50b..d1c5d7cb195 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
@@ -37,7 +37,8 @@ vec4 getPosition(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	vec3 pos = getPosition(vary_fragcoord.xy).xyz;
 	vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba;
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl b/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl
index 02beddd43b3..e32e9f4b326 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/edgeF.glsl
@@ -31,7 +31,8 @@ float getDepth(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	float depth = getDepth(vary_fragcoord.xy);
 	
 	vec2 tc = vary_fragcoord.xy;
@@ -46,8 +47,12 @@ void main()
 	de = step(depth_cutoff, de);
 	
 	vec2 ne;
-	ne.x = dot(texture2DRect(normalMap, tc+vec2(-sc,-sc)).rgb*2.0-1.0, norm);
-	ne.y = dot(texture2DRect(normalMap, tc+vec2(sc,sc)).rgb*2.0-1.0, norm);
+	vec3 nexnorm = texture2DRect(normalMap, tc+vec2(-sc,-sc)).rgb;
+	nexnorm = vec3((nexnorm.xy-0.5)*2.0,nexnorm.z); // unpack norm
+	ne.x = dot(nexnorm, norm);
+	vec3 neynorm = texture2DRect(normalMap, tc+vec2(sc,sc)).rgb;
+	neynorm = vec3((neynorm.xy-0.5)*2.0,neynorm.z); // unpack norm
+	ne.y = dot(neynorm, norm);
 	
 	ne = 1.0-ne;
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 5308e5bb1e1..22ffb58c635 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -129,7 +129,8 @@ void main()
 		shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
 	norm = normalize(norm);
 	float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index bc84720b86b..fd6ae2b9608 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -258,7 +258,8 @@ void main()
 	vec2 tc = vary_fragcoord.xy;
 	float depth = texture2DRect(depthMap, tc.xy).a;
 	vec3 pos = getPosition_d(tc, depth).xyz;
-	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, tc).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
 	float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
@@ -310,7 +311,9 @@ void main()
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		float refshad = texture2DRect(lightMap, ref2d).r;
-		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		vec3 refn = texture2DRect(normalMap, ref2d).rgb;
+		refn = vec3((refn.xy-0.5)*2.0,refn.z); // unpack norm
+		refn = normalize(refn);
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index eeaecc157ff..8a90199b7ca 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -82,7 +82,8 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
 	norm = normalize(norm);
 	float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 794c4d27619..7423347346b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -104,8 +104,9 @@ void main()
 	vec4 pos = getPosition(pos_screen);
 	
 	vec4 nmap4 = texture2DRect(normalMap, pos_screen);
+	nmap4 = vec4((nmap4.xy-0.5)*2.0,nmap4.z,nmap4.w); // unpack norm
 	float displace = nmap4.w;
-	vec3 norm = nmap4.xyz*2.0-1.0;
+	vec3 norm = nmap4.xyz;
 	
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
 	{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index a0dfc96f14e..4e33a1af450 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -164,8 +164,9 @@ void main()
 	vec4 pos = getPosition(pos_screen);
 	
 	vec4 nmap4 = texture2DRect(normalMap, pos_screen);
+	nmap4 = vec4((nmap4.xy-0.5)*2.0,nmap4.z,nmap4.w); // unpack norm
 	float displace = nmap4.w;
-	vec3 norm = nmap4.xyz*2.0-1.0;
+	vec3 norm = nmap4.xyz;
 	
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
 	{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl
index 7325825d6d4..66606233cdf 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl
@@ -44,7 +44,8 @@ float getDepth(vec2 pos_screen)
 
 void main() 
 {
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	float depth = getDepth(vary_fragcoord.xy);
 		
 	vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
@@ -56,9 +57,10 @@ void main()
 	for (int i = 0; i < kern_length; i++)
 	{
 		vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
-	    vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz*2.0-1.0;
-	    
-	   float d = dot(norm.xyz, sampNorm);
+		vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz;
+		sampNorm = vec3((sampNorm.xy-0.5)*2.0,sampNorm.z); // unpack norm
+		
+		float d = dot(norm.xyz, sampNorm);
 		
 		if (d > 0.5)
 		{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/giF.glsl b/indra/newview/app_settings/shaders/class3/deferred/giF.glsl
index 939710cb563..1b8354dbd10 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/giF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/giF.glsl
@@ -178,7 +178,8 @@ void main()
 	
 	float rad = gi_range*0.5;
 	
-	vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	float dist = max(length(pos.xyz)-rad, 0.0);
 	
 	float da = clamp(1.0-dist/rad, 0.0, 1.0);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 5298079af79..c88edd0a60b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -259,7 +259,8 @@ void main()
 	vec2 tc = vary_fragcoord.xy;
 	float depth = texture2DRect(depthMap, tc.xy).a;
 	vec3 pos = getPosition_d(tc, depth).xyz;
-	vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
+	vec3 norm = texture2DRect(normalMap, tc).xyz;
+	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
 	
 	float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
@@ -314,7 +315,9 @@ void main()
 		float refdepth = texture2DRect(depthMap, ref2d).a;
 		vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
 		float refshad = texture2DRect(lightMap, ref2d).r;
-		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);
+		vec3 refn = texture2DRect(normalMap, ref2d).rgb;
+		refn = vec3((refn.xy-0.5)*2.0,refn.z); // unpack norm
+		refn = normalize(refn);
 		// figure out how appropriate our guess actually was
 		float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
 		// darken reflections from points which face away from the reflected ray - our guess was a back-face
diff --git a/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl
index 258acee08c1..5b33ea5bfe2 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl
@@ -14,5 +14,6 @@ void main()
 	vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
 	gl_FragData[0] = vec4(gl_Color.rgb*col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
 	gl_FragData[1] = vec4(0,0,0,0);
-	gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
+	vec3 nvn = normalize(vary_normal);
+	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
-- 
GitLab


From d03f4c2a312b1a4d8f33cd171a958670f508da70 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 11 May 2010 00:57:30 -0500
Subject: [PATCH 405/683] EXT-7225 Fix for busted projector shadows under
 certain settings. (transplanted from
 63218c79aa5670331235d3fde25de4a595991460)

---
 indra/newview/app_settings/settings.xml                        | 2 +-
 .../app_settings/shaders/class2/deferred/sunLightF.glsl        | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index dee01387292..66a3fd9f433 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6603,7 +6603,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>0.01</real>
+    <real>-0.01</real>
   </map>
 
   <key>RenderShadowResolutionScale</key>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 195a20e9dde..70e241b53a2 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -77,6 +77,7 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
+	stc.z += spot_shadow_offset;
 	stc.xyz /= stc.w;
 	stc.z += spot_shadow_bias*scl;
 	
@@ -182,7 +183,7 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = 1.0;
 	
-	spos.xyz = shadow_pos+offset*spot_shadow_offset;
+	spos = vec4(shadow_pos, 1.0);
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-- 
GitLab


From 1928970c6b4e6fc12f54b8235e5022f0a729017e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 11 May 2010 20:39:43 +0100
Subject: [PATCH 406/683] add an accidentally-dropped normalize from the
 bf541483d907 / normpacking-rejig

---
 .../app_settings/shaders/class1/deferred/multiPointLightF.glsl   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index e1715eb4f98..b494b521cab 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -55,6 +55,7 @@ void main()
 	
 	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
 	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+	norm = normalize(norm);
 	vec4 spec = texture2DRect(specularRect, frag.xy);
 	vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
 	float noise = texture2D(noiseMap, frag.xy/128.0).b;
-- 
GitLab


From b14e52a5a3f29ad250b4e36ba8bcccf494ff43bc Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 11 May 2010 20:39:43 +0100
Subject: [PATCH 407/683] add an accidentally-dropped normalize from the
 bf541483d907 / normpacking-rejig (transplanted from
 9e23eb15550830b5efe1012c8169339931ec5f32)

---
 .../app_settings/shaders/class1/deferred/multiPointLightF.glsl   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index e1715eb4f98..b494b521cab 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -55,6 +55,7 @@ void main()
 	
 	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
 	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+	norm = normalize(norm);
 	vec4 spec = texture2DRect(specularRect, frag.xy);
 	vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
 	float noise = texture2D(noiseMap, frag.xy/128.0).b;
-- 
GitLab


From 6c086be01659a0d23a91bf6e3ea07bafd86c4dd7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 12 May 2010 03:59:01 -0500
Subject: [PATCH 408/683] Fix for fullbright bump not working in deferred
 render. Fix for shadow artifacts around split frusta. Tweak for shadow
 aliasing with projectors. Fix for crash on exit in mesh thread. (transplanted
 from 6dcf09cd3e524016c8130a0c8af3d9fc95f2d411)

---
 indra/newview/app_settings/settings.xml       |   6 +-
 .../shaders/class2/deferred/sunLightF.glsl    |   3 +-
 indra/newview/lldrawpool.h                    |   1 +
 indra/newview/lldrawpoolbump.cpp              |  44 +-
 indra/newview/lldrawpoolbump.h                |   8 +-
 indra/newview/lldrawpoolsimple.cpp            |   3 +-
 indra/newview/llviewercontrol.cpp             |   3 +
 indra/newview/llviewerdisplay.cpp             |   8 +-
 indra/newview/llvovolume.cpp                  |  39 +-
 indra/newview/pipeline.cpp                    | 395 ++++++++++++------
 indra/newview/pipeline.h                      |  30 +-
 11 files changed, 364 insertions(+), 176 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 66a3fd9f433..ef2e447c04c 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6592,7 +6592,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>-0.0005</real>
+    <real>0.0</real>
   </map>
   <key>RenderSpotShadowOffset</key>
   <map>
@@ -6603,7 +6603,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>-0.01</real>
+    <real>0.04</real>
   </map>
 
   <key>RenderShadowResolutionScale</key>
@@ -6739,7 +6739,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>1</real>
+    <real>8</real>
   </map>
 
   <key>RenderDeferred</key>
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 70e241b53a2..7423347346b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -77,7 +77,6 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
 
 float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
 {
-	stc.z += spot_shadow_offset;
 	stc.xyz /= stc.w;
 	stc.z += spot_shadow_bias*scl;
 	
@@ -183,7 +182,7 @@ void main()
 	gl_FragColor[0] = shadow;
 	gl_FragColor[1] = 1.0;
 	
-	spos = vec4(shadow_pos, 1.0);
+	spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index 67870c10e93..f85b46cfbac 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -133,6 +133,7 @@ class LLRenderPass : public LLDrawPool
 		PASS_FULLBRIGHT_SHINY,
 		PASS_SHINY,
 		PASS_BUMP,
+		PASS_POST_BUMP,
 		PASS_GLOW,
 		PASS_ALPHA,
 		PASS_ALPHA_MASK,
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 8f3e775976c..08c9f7fe159 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -618,9 +618,9 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel)
 }
 
 //static
-void LLDrawPoolBump::beginBump()
+void LLDrawPoolBump::beginBump(U32 pass)
 {	
-	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+	if (!gPipeline.hasRenderBatches(pass))
 	{
 		return;
 	}
@@ -663,9 +663,9 @@ void LLDrawPoolBump::beginBump()
 }
 
 //static
-void LLDrawPoolBump::renderBump()
+void LLDrawPoolBump::renderBump(U32 pass)
 {
-	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+	if (!gPipeline.hasRenderBatches(pass))
 	{
 		return;
 	}
@@ -678,13 +678,13 @@ void LLDrawPoolBump::renderBump()
 	/// Get rid of z-fighting with non-bump pass.
 	LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
 	glPolygonOffset(-1.0f, -1.0f);
-	renderBump(LLRenderPass::PASS_BUMP, sVertexMask);
+	renderBump(pass, sVertexMask);
 }
 
 //static
-void LLDrawPoolBump::endBump()
+void LLDrawPoolBump::endBump(U32 pass)
 {
-	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+	if (!gPipeline.hasRenderBatches(pass))
 	{
 		return;
 	}
@@ -767,17 +767,41 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
 
 void LLDrawPoolBump::beginPostDeferredPass(S32 pass)
 {
-	beginFullbrightShiny();
+	switch (pass)
+	{
+	case 0:
+		beginFullbrightShiny();
+		break;
+	case 1:
+		beginBump(LLRenderPass::PASS_POST_BUMP);
+		break;
+	}
 }
 
 void LLDrawPoolBump::endPostDeferredPass(S32 pass)
 {
-	endFullbrightShiny();
+	switch (pass)
+	{
+	case 0:
+		endFullbrightShiny();
+		break;
+	case 1:
+		endBump(LLRenderPass::PASS_POST_BUMP);
+		break;
+	}
 }
 
 void LLDrawPoolBump::renderPostDeferred(S32 pass)
 {
-	renderFullbrightShiny();
+	switch (pass)
+	{
+	case 0:
+		renderFullbrightShiny();
+		break;
+	case 1:
+		renderBump(LLRenderPass::PASS_POST_BUMP);
+		break;
+	}
 }
 
 ////////////////////////////////////////////////////////////////
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index 2019f1df269..e35598448d8 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -75,16 +75,16 @@ protected :
 	void renderFullbrightShiny();
 	void endFullbrightShiny();
 
-	void beginBump();
-	void renderBump();
-	void endBump();
+	void beginBump(U32 pass = LLRenderPass::PASS_BUMP);
+	void renderBump(U32 pass = LLRenderPass::PASS_BUMP);
+	void endBump(U32 pass = LLRenderPass::PASS_BUMP);
 
 	virtual S32 getNumDeferredPasses();
 	/*virtual*/ void beginDeferredPass(S32 pass);
 	/*virtual*/ void endDeferredPass(S32 pass);
 	/*virtual*/ void renderDeferred(S32 pass);
 
-	virtual S32 getNumPostDeferredPasses() { return 1; }
+	virtual S32 getNumPostDeferredPasses() { return 2; }
 	/*virtual*/ void beginPostDeferredPass(S32 pass);
 	/*virtual*/ void endPostDeferredPass(S32 pass);
 	/*virtual*/ void renderPostDeferred(S32 pass);
diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index c8e6f95ab6d..91191287cd9 100644
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -151,7 +151,8 @@ void LLDrawPoolSimple::render(S32 pass)
 		renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask());
 
 		if (LLPipeline::sRenderDeferred)
-		{
+		{ //if deferred rendering is enabled, bump faces aren't reigstered as simple
+			//render bump faces here as simple so bump faces will appear under water
 			renderTexture(LLRenderPass::PASS_BUMP, getVertexDataMask());
 		}
 	}
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index a8004f26edd..701df86de41 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -505,6 +505,9 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderUIBuffer")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderSpecularResX")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderSpecularResY")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderSpecularExponent")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderFSAASamples")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderShadowResolutionScale")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 235faba15aa..570dd1a1058 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -930,9 +930,10 @@ void render_hud_attachments()
 		bool render_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) && gSavedSettings.getBOOL("RenderHUDParticles");
 		
 		//only render hud objects
-		U32 mask = gPipeline.getRenderTypeMask();
+		gPipeline.pushRenderTypeMask();
+		
 		// turn off everything
-		gPipeline.setRenderTypeMask(0);
+		gPipeline.andRenderTypeMask(LLPipeline::END_RENDER_TYPES);
 		// turn on HUD
 		gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
 		// turn on HUD particles
@@ -986,7 +987,8 @@ void render_hud_attachments()
 		render_hud_elements();
 
 		//restore type mask
-		gPipeline.setRenderTypeMask(mask);
+		gPipeline.popRenderTypeMask();
+
 		if (has_ui)
 		{
 			gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 34ae915a076..15b04fa746e 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3225,7 +3225,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 		model_mat = &(drawable->getRegion()->mRenderMatrix);
 	}
 
-	U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0);
+
+	U8 bump = (type == LLRenderPass::PASS_BUMP || type == LLRenderPass::PASS_POST_BUMP) ? facep->getTextureEntry()->getBumpmap() : 0;
 	
 	LLViewerTexture* tex = facep->getTexture();
 
@@ -3794,66 +3795,76 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				&& group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD 
 				&& LLPipeline::sRenderBump 
 				&& te->getShiny())
-			{
+			{ //shiny
 				if (tex->getPrimaryFormat() == GL_ALPHA)
-				{
+				{ //invisiprim+shiny
 					registerFace(group, facep, LLRenderPass::PASS_INVISI_SHINY);
 					registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
 				}
 				else if (LLPipeline::sRenderDeferred)
-				{
+				{ //deferred rendering
 					if (te->getFullbright())
-					{
+					{ //register in post deferred fullbright shiny pass
 						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_SHINY);
+						if (te->getBumpmap())
+						{ //register in post deferred bump pass
+							registerFace(group, facep, LLRenderPass::PASS_POST_BUMP);
+						}
 					}
 					else if (te->getBumpmap())
-					{
+					{ //register in deferred bump pass
 						registerFace(group, facep, LLRenderPass::PASS_BUMP);
 					}
 					else
-					{
+					{ //register in deferred simple pass (deferred simple includes shiny)
 						llassert(mask & LLVertexBuffer::MAP_NORMAL);
 						registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
 					}
 				}
 				else if (fullbright)
-				{						
+				{	//not deferred, register in standard fullbright shiny pass					
 					registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_SHINY);
 				}
 				else
-				{
+				{ //not deferred or fullbright, register in standard shiny pass
 					registerFace(group, facep, LLRenderPass::PASS_SHINY);
 				}
 			}
 			else
-			{
+			{ //not alpha and not shiny
 				if (!is_alpha && tex->getPrimaryFormat() == GL_ALPHA)
-				{
+				{ //invisiprim
 					registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
 				}
 				else if (fullbright)
-				{
+				{ //fullbright
 					registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT);
+					if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap())
+					{ //if this is the deferred render and a bump map is present, register in post deferred bump
+						registerFace(group, facep, LLRenderPass::PASS_POST_BUMP);
+					}
 				}
 				else
 				{
 					if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap())
-					{
+					{ //non-shiny or fullbright deferred bump
 						registerFace(group, facep, LLRenderPass::PASS_BUMP);
 					}
 					else
-					{
+					{ //all around simple
 						llassert(mask & LLVertexBuffer::MAP_NORMAL);
 						registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
 					}
 				}
 				
+				//not sure why this is here -- shiny HUD attachments maybe?  -- davep 5/11/2010
 				if (!is_alpha && te->getShiny() && LLPipeline::sRenderBump)
 				{
 					registerFace(group, facep, LLRenderPass::PASS_SHINY);
 				}
 			}
 			
+			//not sure why this is here, and looks like it might cause bump mapped objects to get rendered redundantly -- davep 5/11/2010
 			if (!is_alpha && !LLPipeline::sRenderDeferred)
 			{
 				llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 91352ed4f3c..b027fae0336 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -329,7 +329,6 @@ LLPipeline::LLPipeline() :
 	mInitialized(FALSE),
 	mVertexShadersEnabled(FALSE),
 	mVertexShadersLoaded(0),
-	mRenderTypeMask(0),
 	mRenderDebugFeatureMask(0),
 	mRenderDebugMask(0),
 	mOldRenderDebugMask(0),
@@ -383,7 +382,11 @@ void LLPipeline::init()
 	LLViewerStats::getInstance()->mTrianglesDrawnStat.reset();
 	resetFrameStats();
 
-	mRenderTypeMask = 0xffffffff;	// All render types start on
+	for (U32 i = 0; i < NUM_RENDER_TYPES; ++i)
+	{
+		mRenderTypeEnabled[i] = TRUE; //all rendering types start enabled
+	}
+
 	mRenderDebugFeatureMask = 0xffffffff; // All debugging features on
 	mRenderDebugMask = 0;	// All debug starts off
 
@@ -2205,14 +2208,13 @@ static LLFastTimer::DeclareTimer FTM_RESET_DRAWORDER("Reset Draw Order");
 
 void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 {
-	const U32 face_mask = (1 << LLPipeline::RENDER_TYPE_AVATAR) |
-						  (1 << LLPipeline::RENDER_TYPE_GROUND) |
-						  (1 << LLPipeline::RENDER_TYPE_TERRAIN) |
-						  (1 << LLPipeline::RENDER_TYPE_TREE) |
-						  (1 << LLPipeline::RENDER_TYPE_SKY) |
-						  (1 << LLPipeline::RENDER_TYPE_WATER);
-
-	if (mRenderTypeMask & face_mask)
+	if (hasAnyRenderType(LLPipeline::RENDER_TYPE_AVATAR,
+					  LLPipeline::RENDER_TYPE_GROUND,
+					  LLPipeline::RENDER_TYPE_TERRAIN,
+					  LLPipeline::RENDER_TYPE_TREE,
+					  LLPipeline::RENDER_TYPE_SKY,
+					  LLPipeline::RENDER_TYPE_WATER,
+					  LLPipeline::END_RENDER_TYPES))
 	{
 		//clear faces from face pools
 		LLFastTimer t(FTM_RESET_DRAWORDER);
@@ -4990,8 +4992,7 @@ void LLPipeline::setLight(LLDrawable *drawablep, BOOL is_light)
 //static
 void LLPipeline::toggleRenderType(U32 type)
 {
-	U32 bit = (1<<type);
-	gPipeline.mRenderTypeMask ^= bit;
+	gPipeline.mRenderTypeEnabled[type] = !gPipeline.mRenderTypeEnabled[type];
 }
 
 //static
@@ -6617,15 +6618,16 @@ void LLPipeline::renderDeferredLighting()
 			LLGLDisable stencil(GL_STENCIL_TEST);
 			gGL.setSceneBlendType(LLRender::BT_ALPHA);
 
-			U32 render_mask = mRenderTypeMask;
-			mRenderTypeMask =	mRenderTypeMask & 
-								((1 << LLPipeline::RENDER_TYPE_SKY) |
-								(1 << LLPipeline::RENDER_TYPE_CLOUDS) |
-								(1 << LLPipeline::RENDER_TYPE_WL_SKY));
+			gPipeline.pushRenderTypeMask();
+			
+			gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
+										LLPipeline::RENDER_TYPE_CLOUDS,
+										LLPipeline::RENDER_TYPE_WL_SKY,
+										LLPipeline::END_RENDER_TYPES);
 								
 			
 			renderGeomPostDeferred(*LLViewerCamera::getInstance());
-			mRenderTypeMask = render_mask;
+			gPipeline.popRenderTypeMask();
 		}
 
 		BOOL render_local = gSavedSettings.getBOOL("RenderDeferredLocalLights");
@@ -6947,29 +6949,30 @@ void LLPipeline::renderDeferredLighting()
 		LLGLDisable blend(GL_BLEND);
 		LLGLDisable stencil(GL_STENCIL_TEST);
 
-		U32 render_mask = mRenderTypeMask;
-		mRenderTypeMask =	mRenderTypeMask & 
-							((1 << LLPipeline::RENDER_TYPE_ALPHA) |
-							(1 << LLPipeline::RENDER_TYPE_FULLBRIGHT) |
-							(1 << LLPipeline::RENDER_TYPE_VOLUME) |
-							(1 << LLPipeline::RENDER_TYPE_GLOW) |
-							(1 << LLPipeline::RENDER_TYPE_BUMP) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_ALPHA) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_GLOW) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_GRASS) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_INVISIBLE) |
-							(1 << LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY) |
-							(1 << LLPipeline::RENDER_TYPE_AVATAR));
+		pushRenderTypeMask();
+		andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA,
+						 LLPipeline::RENDER_TYPE_FULLBRIGHT,
+						 LLPipeline::RENDER_TYPE_VOLUME,
+						 LLPipeline::RENDER_TYPE_GLOW,
+						 LLPipeline::RENDER_TYPE_BUMP,
+						 LLPipeline::RENDER_TYPE_PASS_SIMPLE,
+						 LLPipeline::RENDER_TYPE_PASS_ALPHA,
+						 LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK,
+						 LLPipeline::RENDER_TYPE_PASS_BUMP,
+						 LLPipeline::RENDER_TYPE_PASS_POST_BUMP,
+						 LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
+						 LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK,
+						 LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
+						 LLPipeline::RENDER_TYPE_PASS_GLOW,
+						 LLPipeline::RENDER_TYPE_PASS_GRASS,
+						 LLPipeline::RENDER_TYPE_PASS_SHINY,
+						 LLPipeline::RENDER_TYPE_PASS_INVISIBLE,
+						 LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY,
+						 LLPipeline::RENDER_TYPE_AVATAR,
+						 END_RENDER_TYPES);
 		
 		renderGeomPostDeferred(*LLViewerCamera::getInstance());
-		mRenderTypeMask = render_mask;
+		popRenderTypeMask();
 	}
 
 	{
@@ -7224,8 +7227,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 
 		LLPipeline::sUseOcclusion = llmin(occlusion, 1);
 		
-		U32 type_mask = gPipeline.mRenderTypeMask;
-
+		gPipeline.pushRenderTypeMask();
+		
 		glh::matrix4f projection = glh_get_current_projection();
 		glh::matrix4f mat;
 
@@ -7293,43 +7296,48 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 			glCullFace(GL_FRONT);
 
 			static LLCullResult ref_result;
-			U32 ref_mask = 0;
+		
 			if (LLDrawPoolWater::sNeedsDistortionUpdate)
 			{
 				//initial sky pass (no user clip plane)
 				{ //mask out everything but the sky
-					U32 tmp = mRenderTypeMask;
-					mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) |
-										(1 << LLPipeline::RENDER_TYPE_WL_SKY));
+					gPipeline.pushRenderTypeMask();
+					gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
+												LLPipeline::RENDER_TYPE_WL_SKY,
+												LLPipeline::END_RENDER_TYPES);
 					static LLCullResult result;
 					updateCull(camera, result);
 					llpushcallstacks ;
 					stateSort(camera, result);
-					mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) |
-										(1 << LLPipeline::RENDER_TYPE_CLOUDS) |
-										(1 << LLPipeline::RENDER_TYPE_WL_SKY));
+					andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
+										LLPipeline::RENDER_TYPE_CLOUDS,
+										LLPipeline::RENDER_TYPE_WL_SKY,
+										LLPipeline::END_RENDER_TYPES);
+
 					renderGeom(camera, TRUE);
-					mRenderTypeMask = tmp;
+					gPipeline.popRenderTypeMask();
 				}
 
-				U32 mask = mRenderTypeMask;
-				mRenderTypeMask &=	~((1<<LLPipeline::RENDER_TYPE_WATER) |
-									  (1<<LLPipeline::RENDER_TYPE_GROUND) |
-									  (1<<LLPipeline::RENDER_TYPE_SKY) |
-									  (1<<LLPipeline::RENDER_TYPE_CLOUDS));	
+				gPipeline.pushRenderTypeMask();
+				
+				clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
+									LLPipeline::RENDER_TYPE_GROUND,
+									LLPipeline::RENDER_TYPE_SKY,
+									LLPipeline::RENDER_TYPE_CLOUDS,
+									LLPipeline::END_RENDER_TYPES);	
 
 				S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
 				if (detail > 0)
 				{ //mask out selected geometry based on reflection detail
 					if (detail < 4)
 					{
-						mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_PARTICLES);
+						clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES);
 						if (detail < 3)
 						{
-							mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_AVATAR);
+							clearRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES);
 							if (detail < 2)
 							{
-								mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_VOLUME);
+								clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES);
 							}
 						}
 					}
@@ -7341,18 +7349,17 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 					stateSort(camera, ref_result);
 				}
 				
-				ref_mask = mRenderTypeMask;
-				mRenderTypeMask = mask;
-			}
-			if (LLDrawPoolWater::sNeedsDistortionUpdate)
-			{
-				mRenderTypeMask = ref_mask;
-				if (gSavedSettings.getS32("RenderReflectionDetail") > 0)
+				if (LLDrawPoolWater::sNeedsDistortionUpdate)
 				{
-					gPipeline.grabReferences(ref_result);
-					LLGLUserClipPlane clip_plane(plane, mat, projection);
-					renderGeom(camera);
+					if (gSavedSettings.getS32("RenderReflectionDetail") > 0)
+					{
+						gPipeline.grabReferences(ref_result);
+						LLGLUserClipPlane clip_plane(plane, mat, projection);
+						renderGeom(camera);
+					}
 				}
+
+				gPipeline.popRenderTypeMask();
 			}	
 			glCullFace(GL_BACK);
 			glPopMatrix();
@@ -7366,18 +7373,20 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 		if (last_update)
 		{
 			camera.setFar(camera_in.getFar());
-			mRenderTypeMask = type_mask & (~(1<<LLPipeline::RENDER_TYPE_WATER) |
-											(1<<LLPipeline::RENDER_TYPE_GROUND));	
+			clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
+								LLPipeline::RENDER_TYPE_GROUND,
+								END_RENDER_TYPES);	
 			stop_glerror();
 
 			LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? FALSE : TRUE;
 
 			if (LLPipeline::sUnderWaterRender)
 			{
-				mRenderTypeMask &=	~((1<<LLPipeline::RENDER_TYPE_GROUND) |
-									  (1<<LLPipeline::RENDER_TYPE_SKY) |
-									  (1<<LLPipeline::RENDER_TYPE_CLOUDS) |
-									  (1<<LLPipeline::RENDER_TYPE_WL_SKY));		
+				clearRenderTypeMask(LLPipeline::RENDER_TYPE_GROUND,
+									LLPipeline::RENDER_TYPE_SKY,
+									LLPipeline::RENDER_TYPE_CLOUDS,
+									LLPipeline::RENDER_TYPE_WL_SKY,
+									END_RENDER_TYPES);		
 			}
 			LLViewerCamera::updateFrustumPlanes(camera);
 
@@ -7419,7 +7428,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 		}
 		glClearColor(0.f, 0.f, 0.f, 0.f);
 		gViewerWindow->setup3DViewport();
-		mRenderTypeMask = type_mask;
+		gPipeline.popRenderTypeMask();
 		LLDrawPoolWater::sNeedsReflectionUpdate = FALSE;
 		LLDrawPoolWater::sNeedsDistortionUpdate = FALSE;
 		LLViewerCamera::getInstance()->setUserClipPlane(LLPlane(-pnorm, -pd));
@@ -7874,21 +7883,22 @@ void LLPipeline::generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<L
 	sun_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR);
 	static LLCullResult result;
 
-	U32 type_mask = mRenderTypeMask;
+	pushRenderTypeMask();
 
-	mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) |
-								   (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
-								   (1<<LLPipeline::RENDER_TYPE_BUMP) |
-								   (1<<LLPipeline::RENDER_TYPE_VOLUME) |
-								   (1<<LLPipeline::RENDER_TYPE_TREE) | 
-								   (1<<LLPipeline::RENDER_TYPE_TERRAIN) |
-								   (1<<LLPipeline::RENDER_TYPE_WATER) |
-								   (1<<LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW) |
-								   (1<<LLPipeline::RENDER_TYPE_AVATAR) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
-									(1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
-									(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
-									(1 << LLPipeline::RENDER_TYPE_PASS_SHINY));
+	andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE,
+								 LLPipeline::RENDER_TYPE_FULLBRIGHT,
+								 LLPipeline::RENDER_TYPE_BUMP,
+								 LLPipeline::RENDER_TYPE_VOLUME,
+								 LLPipeline::RENDER_TYPE_TREE, 
+								 LLPipeline::RENDER_TYPE_TERRAIN,
+								 LLPipeline::RENDER_TYPE_WATER,
+								 LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW,
+								 LLPipeline::RENDER_TYPE_AVATAR,
+								 LLPipeline::RENDER_TYPE_PASS_SIMPLE,
+								 LLPipeline::RENDER_TYPE_PASS_BUMP,
+								 LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
+								 LLPipeline::RENDER_TYPE_PASS_SHINY,
+								 END_RENDER_TYPES);
 
 
 	
@@ -7957,7 +7967,7 @@ void LLPipeline::generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<L
 	LLPipeline::sShadowRender = FALSE;
 	sMinRenderSize = 0.f;
 
-	mRenderTypeMask = type_mask;
+	popRenderTypeMask();
 
 }
 
@@ -8054,23 +8064,24 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		last_projection[i] = gGLLastProjection[i];
 	}
 
-	U32 type_mask = mRenderTypeMask;
-	mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) |
-								   (1<<LLPipeline::RENDER_TYPE_ALPHA) |
-								   (1<<LLPipeline::RENDER_TYPE_GRASS) |
-								   (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
-								   (1<<LLPipeline::RENDER_TYPE_BUMP) |
-								   (1<<LLPipeline::RENDER_TYPE_VOLUME) |
-								   (1<<LLPipeline::RENDER_TYPE_AVATAR) |
-								   (1<<LLPipeline::RENDER_TYPE_TREE) | 
-								   (1<<LLPipeline::RENDER_TYPE_TERRAIN) |
-								   (1<<LLPipeline::RENDER_TYPE_WATER) |
-								   (1<<LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
-								   (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY));
+	pushRenderTypeMask();
+	andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE,
+					LLPipeline::RENDER_TYPE_ALPHA,
+					LLPipeline::RENDER_TYPE_GRASS,
+					LLPipeline::RENDER_TYPE_FULLBRIGHT,
+					LLPipeline::RENDER_TYPE_BUMP,
+					LLPipeline::RENDER_TYPE_VOLUME,
+					LLPipeline::RENDER_TYPE_AVATAR,
+					LLPipeline::RENDER_TYPE_TREE, 
+					LLPipeline::RENDER_TYPE_TERRAIN,
+					LLPipeline::RENDER_TYPE_WATER,
+					LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW,
+					LLPipeline::RENDER_TYPE_PASS_SIMPLE,
+					LLPipeline::RENDER_TYPE_PASS_BUMP,
+					LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
+					LLPipeline::RENDER_TYPE_PASS_SHINY,
+					LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
+					END_RENDER_TYPES);
 
 	gGL.setColorMask(false, false);
 
@@ -8147,7 +8158,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 				mShadowFrustPoints[2].clear();
 				mShadowFrustPoints[3].clear();
 			}
-			mRenderTypeMask = type_mask;
+			popRenderTypeMask();
 			return;
 		}
 
@@ -8233,10 +8244,11 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		for (U32 i = 0; i < 4; i++)
 		{
 			LLVector3 delta = frust[i+4]-eye;
+			delta += (frust[i+4]-frust[(i+2)%4+4])*0.05f;
 			delta.normVec();
 			F32 dp = delta*pn;
-			frust[i] = eye + (delta*dist[j])/dp;
-			frust[i+4] = eye + (delta*dist[j+1])/dp;
+			frust[i] = eye + (delta*dist[j]*0.95f)/dp;
+			frust[i+4] = eye + (delta*dist[j+1]*1.05f)/dp;
 		}
 						
 		shadow_cam.calcAgentFrustumPlanes(frust);
@@ -8748,7 +8760,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		gGLLastProjection[i] = last_projection[i];
 	}
 
-	mRenderTypeMask = type_mask;
+	popRenderTypeMask();
 }
 
 void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture)
@@ -8784,38 +8796,36 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 
 	assertInitialized();
 
-	U32 mask;
 	BOOL muted = LLMuteList::getInstance()->isMuted(avatar->getID());
 
+	pushRenderTypeMask();
+	
 	if (muted)
 	{
-		mask  = 1 << LLPipeline::RENDER_TYPE_AVATAR;
+		andRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES);
 	}
 	else
 	{
-		mask  = (1<<LLPipeline::RENDER_TYPE_VOLUME) |
-				(1<<LLPipeline::RENDER_TYPE_AVATAR) |
-				(1<<LLPipeline::RENDER_TYPE_BUMP) |
-				(1<<LLPipeline::RENDER_TYPE_GRASS) |
-				(1<<LLPipeline::RENDER_TYPE_SIMPLE) |
-				(1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
-				(1<<LLPipeline::RENDER_TYPE_ALPHA) | 
-				(1<<LLPipeline::RENDER_TYPE_INVISIBLE) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_ALPHA) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_INVISIBLE) |
-				(1 << LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY);
+		andRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME,
+						LLPipeline::RENDER_TYPE_AVATAR,
+						LLPipeline::RENDER_TYPE_BUMP,
+						LLPipeline::RENDER_TYPE_GRASS,
+						LLPipeline::RENDER_TYPE_SIMPLE,
+						LLPipeline::RENDER_TYPE_FULLBRIGHT,
+						LLPipeline::RENDER_TYPE_ALPHA, 
+						LLPipeline::RENDER_TYPE_INVISIBLE,
+						LLPipeline::RENDER_TYPE_PASS_SIMPLE,
+						LLPipeline::RENDER_TYPE_PASS_ALPHA,
+						LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK,
+						LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
+						LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK,
+						LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
+						LLPipeline::RENDER_TYPE_PASS_SHINY,
+						LLPipeline::RENDER_TYPE_PASS_INVISIBLE,
+						LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY,
+						END_RENDER_TYPES);
 	}
 	
-	mask = mask & gPipeline.getRenderTypeMask();
-	U32 saved_mask = gPipeline.mRenderTypeMask;
-	gPipeline.mRenderTypeMask = mask;
-
 	S32 occlusion = sUseOcclusion;
 	sUseOcclusion = 0;
 	sReflectionRender = sRenderDeferred ? FALSE : TRUE;
@@ -8989,7 +8999,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	sReflectionRender = FALSE;
 	sImpostorRender = FALSE;
 	sShadowRender = FALSE;
-	gPipeline.mRenderTypeMask = saved_mask;
+	popRenderTypeMask();
 
 	glMatrixMode(GL_PROJECTION);
 	glPopMatrix();
@@ -9030,4 +9040,121 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
 	return sCull->endAlphaGroups();
 }
 
+BOOL LLPipeline::hasRenderType(const U32 type) const
+{
+	return mRenderTypeEnabled[type];
+}
+
+void LLPipeline::setRenderTypeMask(U32 type, ...)
+{
+	va_list args;
+
+	va_start(args, type);
+	while (type < END_RENDER_TYPES)
+	{
+		mRenderTypeEnabled[type] = TRUE;
+		type = va_arg(args, U32);
+	}
+	va_end(args);
+
+	if (type > END_RENDER_TYPES)
+	{
+		llerrs << "Invalid render type." << llendl;
+	}
+}
+
+BOOL LLPipeline::hasAnyRenderType(U32 type, ...) const
+{
+	va_list args;
+
+	va_start(args, type);
+	while (type < END_RENDER_TYPES)
+	{
+		if (mRenderTypeEnabled[type])
+		{
+			return TRUE;
+		}
+		type = va_arg(args, U32);
+	}
+	va_end(args);
+
+	if (type > END_RENDER_TYPES)
+	{
+		llerrs << "Invalid render type." << llendl;
+	}
+
+	return FALSE;
+}
+
+void LLPipeline::pushRenderTypeMask()
+{
+	std::string cur_mask;
+	cur_mask.assign((const char*) mRenderTypeEnabled, sizeof(mRenderTypeEnabled));
+	mRenderTypeEnableStack.push(cur_mask);
+}
+
+void LLPipeline::popRenderTypeMask()
+{
+	if (mRenderTypeEnableStack.empty())
+	{
+		llerrs << "Depleted render type stack." << llendl;
+	}
+
+	memcpy(mRenderTypeEnabled, mRenderTypeEnableStack.top().data(), sizeof(mRenderTypeEnabled));
+	mRenderTypeEnableStack.pop();
+}
+
+void LLPipeline::andRenderTypeMask(U32 type, ...)
+{
+	va_list args;
+
+	BOOL tmp[NUM_RENDER_TYPES];
+	for (U32 i = 0; i < NUM_RENDER_TYPES; ++i)
+	{
+		tmp[i] = FALSE;
+	}
+
+	va_start(args, type);
+	while (type < END_RENDER_TYPES)
+	{
+		if (mRenderTypeEnabled[type]) 
+		{
+			tmp[type] = TRUE;
+		}
+
+		type = va_arg(args, U32);
+	}
+	va_end(args);
+
+	if (type > END_RENDER_TYPES)
+	{
+		llerrs << "Invalid render type." << llendl;
+	}
+
+	for (U32 i = 0; i < LLPipeline::NUM_RENDER_TYPES; ++i)
+	{
+		mRenderTypeEnabled[i] = tmp[i];
+	}
+
+}
+
+void LLPipeline::clearRenderTypeMask(U32 type, ...)
+{
+	va_list args;
+
+	va_start(args, type);
+	while (type < END_RENDER_TYPES)
+	{
+		mRenderTypeEnabled[type] = FALSE;
+		
+		type = va_arg(args, U32);
+	}
+	va_end(args);
+
+	if (type > END_RENDER_TYPES)
+	{
+		llerrs << "Invalid render type." << llendl;
+	}
+}
+
 
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index a096a887b08..9d25e6d189e 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -46,6 +46,8 @@
 #include "lldrawable.h"
 #include "llrendertarget.h"
 
+#include <stack>
+
 class LLViewerTexture;
 class LLEdge;
 class LLFace;
@@ -277,12 +279,25 @@ class LLPipeline
 	LLCullResult::sg_list_t::iterator beginAlphaGroups();
 	LLCullResult::sg_list_t::iterator endAlphaGroups();
 	
+
 	void addTrianglesDrawn(S32 index_count, U32 render_type = LLRender::TRIANGLES);
-	BOOL hasRenderType(const U32 type) const				{ return (type && (mRenderTypeMask & (1<<type))) ? TRUE : FALSE; }
+
 	BOOL hasRenderDebugFeatureMask(const U32 mask) const	{ return (mRenderDebugFeatureMask & mask) ? TRUE : FALSE; }
 	BOOL hasRenderDebugMask(const U32 mask) const			{ return (mRenderDebugMask & mask) ? TRUE : FALSE; }
-	void setRenderTypeMask(const U32 mask)					{ mRenderTypeMask = mask; }
-	U32  getRenderTypeMask() const							{ return mRenderTypeMask; }
+	
+
+
+	BOOL hasRenderType(const U32 type) const;
+	BOOL hasAnyRenderType(const U32 type, ...) const;
+
+	void setRenderTypeMask(U32 type, ...);
+	void orRenderTypeMask(U32 type, ...);
+	void andRenderTypeMask(U32 type, ...);
+	void clearRenderTypeMask(U32 type, ...);
+	
+	void pushRenderTypeMask();
+	void popRenderTypeMask();
+
 	static void toggleRenderType(U32 type);
 
 	// For UI control of render features
@@ -360,6 +375,7 @@ class LLPipeline
 		RENDER_TYPE_PASS_FULLBRIGHT_SHINY		= LLRenderPass::PASS_FULLBRIGHT_SHINY,
 		RENDER_TYPE_PASS_SHINY					= LLRenderPass::PASS_SHINY,
 		RENDER_TYPE_PASS_BUMP					= LLRenderPass::PASS_BUMP,
+		RENDER_TYPE_PASS_POST_BUMP				= LLRenderPass::PASS_POST_BUMP,
 		RENDER_TYPE_PASS_GLOW					= LLRenderPass::PASS_GLOW,
 		RENDER_TYPE_PASS_ALPHA					= LLRenderPass::PASS_ALPHA,
 		RENDER_TYPE_PASS_ALPHA_MASK				= LLRenderPass::PASS_ALPHA_MASK,
@@ -370,7 +386,9 @@ class LLPipeline
 		RENDER_TYPE_VOLUME,
 		RENDER_TYPE_PARTICLES,
 		RENDER_TYPE_CLOUDS,
-		RENDER_TYPE_HUD_PARTICLES
+		RENDER_TYPE_HUD_PARTICLES,
+		NUM_RENDER_TYPES,
+		END_RENDER_TYPES = NUM_RENDER_TYPES
 	};
 
 	enum LLRenderDebugFeatureMask
@@ -533,7 +551,9 @@ class LLPipeline
 	S32						mVertexShadersLoaded; // 0 = no, 1 = yes, -1 = failed
 
 protected:
-	U32						mRenderTypeMask;
+	BOOL					mRenderTypeEnabled[NUM_RENDER_TYPES];
+	std::stack<std::string> mRenderTypeEnableStack;
+
 	U32						mRenderDebugFeatureMask;
 	U32						mRenderDebugMask;
 
-- 
GitLab


From 7efb59f6b1f6484d094c8db588a54cd62b6ace7c Mon Sep 17 00:00:00 2001
From: "palmer@splinter" <palmer@splinter>
Date: Wed, 12 May 2010 10:20:22 -0700
Subject: [PATCH 409/683] Turning off deferred rendering on linux on high.  No
 code changed

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

diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt
index 254b9c4ce4f..f7896e31db4 100644
--- a/indra/newview/featuretable_linux.txt
+++ b/indra/newview/featuretable_linux.txt
@@ -134,9 +134,9 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
-RenderDeferred				1	1
+RenderDeferred				1	0
 RenderDeferredSSAO			1	0
-RenderShadowDetail			1	1
+RenderShadowDetail			1	0
 
 
 //
-- 
GitLab


From 379ca3c30830f6060637173147269dc0b2b58d27 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 12 May 2010 19:35:02 +0100
Subject: [PATCH 410/683] EXT-7154 : FIXED : darkness bumpmap looks like
 lightness bumpmap when deferred rendering is enabled

---
 indra/newview/lldrawpoolbump.cpp  | 31 +++++++++++++++++++------------
 indra/newview/lldrawpoolbump.h    |  1 +
 indra/newview/llviewercontrol.cpp |  4 ++++
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 08c9f7fe159..a3b236fcb9b 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -818,17 +818,22 @@ void LLBumpImageList::init()
 	LLStandardBumpmap::init();
 }
 
-void LLBumpImageList::shutdown()
+void LLBumpImageList::clear()
 {
+	// these will be re-populated on-demand
 	mBrightnessEntries.clear();
 	mDarknessEntries.clear();
+}
+
+void LLBumpImageList::shutdown()
+{
+	clear();
 	LLStandardBumpmap::shutdown();
 }
 
 void LLBumpImageList::destroyGL()
 {
-	mBrightnessEntries.clear();
-	mDarknessEntries.clear();
+	clear();
 	LLStandardBumpmap::destroyGL();
 }
 
@@ -1065,7 +1070,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 	{
 		bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries );
 		bump_image_map_t::iterator iter = entries_list.find(source_asset_id);
-		if (iter != entries_list.end())
+		if (iter != entries_list.end()) // bump not cached yet
 		{
 			LLPointer<LLImageRaw> dst_image = new LLImageRaw(src->getWidth(), src->getHeight(), 1);
 			U8* dst_data = dst_image->getData();
@@ -1150,8 +1155,11 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 				F32 twice_one_over_range = 2.f / (maximum - minimum);
 				S32 i;
 
-				const F32 ARTIFICIAL_SCALE = 2.f;  // Advantage: exagerates the effect in midrange.  Disadvantage: clamps at the extremes.
-				if( BE_DARKNESS == bump_code )
+				bool bump_polarity_negative = LLPipeline::sRenderDeferred ?
+					(BE_BRIGHTNESS == bump_code) : (BE_DARKNESS == bump_code); // deferred mode likes its normal map values inverted
+
+				const F32 ARTIFICIAL_SCALE = 2.f;  // Advantage: exaggerates the effect in midrange.  Disadvantage: clamps at the extremes.
+				if (bump_polarity_negative)
 				{
 					for( i = minimum; i <= maximum; i++ )
 					{
@@ -1161,7 +1169,6 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 				}
 				else
 				{
-					// BE_LIGHTNESS
 					for( i = minimum; i <= maximum; i++ )
 					{
 						F32 minus_one_to_one = F32(i - minimum) * twice_one_over_range - 1.f;
@@ -1176,9 +1183,9 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 			}
 
 			//---------------------------------------------------
-			//immediately assign bump to a global smart pointer in case some local smart pointer
-			//accidently releases it.
-			LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE);
+			// immediately assign bump to a global smart pointer in case some local smart pointer
+			// accidentally releases it.
+			LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE );
 			
 			if (!LLPipeline::sRenderDeferred)
 			{
@@ -1187,8 +1194,8 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 			}
 			else
 			{
-				LLPointer<LLImageRaw> nrm_image = new LLImageRaw(src->getWidth(), src->getHeight(), 4);
-				generateNormalMapFromAlpha(src, nrm_image);
+				LLPointer<LLImageRaw> nrm_image = new LLImageRaw(dst_image->getWidth(), dst_image->getHeight(), 4);
+				generateNormalMapFromAlpha(dst_image, nrm_image);
 				bump->setExplicitFormat(GL_RGBA, GL_RGBA);
 				bump->createGLTexture(0, nrm_image);
 			}
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index e35598448d8..219e2aac540 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -136,6 +136,7 @@ class LLBumpImageList
 
 	void		init();
 	void		shutdown();
+	void            clear();
 	void		destroyGL();
 	void		restoreGL();
 	void		updateImages();
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index ef3f09f251c..e856c18d707 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -43,6 +43,7 @@
 #include "llagent.h"
 #include "llagentcamera.h"
 #include "llconsole.h"
+#include "lldrawpoolbump.h"
 #include "lldrawpoolterrain.h"
 #include "llflexibleobject.h"
 #include "llfeaturemanager.h"
@@ -118,6 +119,9 @@ static bool handleTerrainDetailChanged(const LLSD& newvalue)
 
 static bool handleSetShaderChanged(const LLSD& newvalue)
 {
+	// changing shader level may invalidate existing cached ad-hoc bump maps, as the shader type determines the format of the bump map it expectes - clear the bump cache
+	gBumpImageList.clear();
+
 	LLViewerShaderMgr::instance()->setShaders();
 	return true;
 }
-- 
GitLab


From 3ad81349acccc9af2531121d5d6d89ad4e6ec0b2 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 12 May 2010 19:35:02 +0100
Subject: [PATCH 411/683] EXT-7154 : FIXED : darkness bumpmap looks like
 lightness bumpmap when deferred rendering is enabled (transplanted from
 569666ad2d30d83cab0eec1eb206f7e91e89d398)

---
 indra/newview/lldrawpoolbump.cpp  | 31 +++++++++++++++++++------------
 indra/newview/lldrawpoolbump.h    |  1 +
 indra/newview/llviewercontrol.cpp |  4 ++++
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 967ce3fc5c8..ac8bd4dc41c 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -859,17 +859,22 @@ void LLBumpImageList::init()
 	LLStandardBumpmap::init();
 }
 
-void LLBumpImageList::shutdown()
+void LLBumpImageList::clear()
 {
+	// these will be re-populated on-demand
 	mBrightnessEntries.clear();
 	mDarknessEntries.clear();
+}
+
+void LLBumpImageList::shutdown()
+{
+	clear();
 	LLStandardBumpmap::shutdown();
 }
 
 void LLBumpImageList::destroyGL()
 {
-	mBrightnessEntries.clear();
-	mDarknessEntries.clear();
+	clear();
 	LLStandardBumpmap::destroyGL();
 }
 
@@ -1106,7 +1111,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 	{
 		bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries );
 		bump_image_map_t::iterator iter = entries_list.find(source_asset_id);
-		if (iter != entries_list.end())
+		if (iter != entries_list.end()) // bump not cached yet
 		{
 			LLPointer<LLImageRaw> dst_image = new LLImageRaw(src->getWidth(), src->getHeight(), 1);
 			U8* dst_data = dst_image->getData();
@@ -1191,8 +1196,11 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 				F32 twice_one_over_range = 2.f / (maximum - minimum);
 				S32 i;
 
-				const F32 ARTIFICIAL_SCALE = 2.f;  // Advantage: exagerates the effect in midrange.  Disadvantage: clamps at the extremes.
-				if( BE_DARKNESS == bump_code )
+				bool bump_polarity_negative = LLPipeline::sRenderDeferred ?
+					(BE_BRIGHTNESS == bump_code) : (BE_DARKNESS == bump_code); // deferred mode likes its normal map values inverted
+
+				const F32 ARTIFICIAL_SCALE = 2.f;  // Advantage: exaggerates the effect in midrange.  Disadvantage: clamps at the extremes.
+				if (bump_polarity_negative)
 				{
 					for( i = minimum; i <= maximum; i++ )
 					{
@@ -1202,7 +1210,6 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 				}
 				else
 				{
-					// BE_LIGHTNESS
 					for( i = minimum; i <= maximum; i++ )
 					{
 						F32 minus_one_to_one = F32(i - minimum) * twice_one_over_range - 1.f;
@@ -1217,9 +1224,9 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 			}
 
 			//---------------------------------------------------
-			//immediately assign bump to a global smart pointer in case some local smart pointer
-			//accidently releases it.
-			LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE);
+			// immediately assign bump to a global smart pointer in case some local smart pointer
+			// accidentally releases it.
+			LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE );
 			
 			if (!LLPipeline::sRenderDeferred)
 			{
@@ -1228,8 +1235,8 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 			}
 			else
 			{
-				LLPointer<LLImageRaw> nrm_image = new LLImageRaw(src->getWidth(), src->getHeight(), 4);
-				generateNormalMapFromAlpha(src, nrm_image);
+				LLPointer<LLImageRaw> nrm_image = new LLImageRaw(dst_image->getWidth(), dst_image->getHeight(), 4);
+				generateNormalMapFromAlpha(dst_image, nrm_image);
 				bump->setExplicitFormat(GL_RGBA, GL_RGBA);
 				bump->createGLTexture(0, nrm_image);
 			}
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index a75653e68e3..ceb72309d80 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -145,6 +145,7 @@ class LLBumpImageList
 
 	void		init();
 	void		shutdown();
+	void            clear();
 	void		destroyGL();
 	void		restoreGL();
 	void		updateImages();
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 701df86de41..54323a4fadd 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -43,6 +43,7 @@
 #include "llagent.h"
 #include "llagentcamera.h"
 #include "llconsole.h"
+#include "lldrawpoolbump.h"
 #include "lldrawpoolterrain.h"
 #include "llflexibleobject.h"
 #include "llfeaturemanager.h"
@@ -118,6 +119,9 @@ static bool handleTerrainDetailChanged(const LLSD& newvalue)
 
 static bool handleSetShaderChanged(const LLSD& newvalue)
 {
+	// changing shader level may invalidate existing cached ad-hoc bump maps, as the shader type determines the format of the bump map it expectes - clear the bump cache
+	gBumpImageList.clear();
+
 	LLViewerShaderMgr::instance()->setShaders();
 	return true;
 }
-- 
GitLab


From b2906b594470ced996f102f4797eef7671ad009c Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 12 May 2010 17:17:39 -0500
Subject: [PATCH 412/683] Moved LLPhysicsDecomp to llmeshrepository. Better
 convex hull visualization.

---
 indra/newview/llspatialpartition.cpp | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 6787018f5a0..ed99f8648f6 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2671,10 +2671,8 @@ void renderPhysicsShape(LLDrawable* drawable)
 			if (decomp)
 			{
 				gGL.pushMatrix();
-				glLoadMatrixd(gGLModelView);
-				gGL.flush();
-				glPointSize(4.f);
-				gGL.begin(LLRender::POINTS);
+				glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+				glMultMatrixf((F32*) volume->getRelativeXform().mMatrix);
 				static std::vector<LLColor4U> color;
 
 				for (U32 i = 0; i < decomp->mHull.size(); ++i)
@@ -2683,17 +2681,15 @@ void renderPhysicsShape(LLDrawable* drawable)
 					{
 						color.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127));
 					}
-					gGL.color4ubv(color[i].mV);
-					for (U32 j = 0; j < decomp->mHull[i].size(); ++j)
-					{
-						LLVector3 v = volume->volumePositionToAgent(decomp->mHull[i][j]);
-						gGL.vertex3fv(v.mV);
-					}
+					glColor4ubv(color[i].mV);
+
+					LLVertexBuffer* buff = decomp->mMesh;
+
+					buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
+					buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
 				}
-				gGL.end();
-				gGL.flush();
+				glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 				gGL.popMatrix();
-				glPointSize(1.f);
 			}
 		}
 	}
-- 
GitLab


From de5b15b590770219927aa5bfb3911629d895fefe Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 12 May 2010 18:05:57 -0500
Subject: [PATCH 413/683] CTS-149 Get rid of camera minimum distance for meshes
 and when DisableCameraConstraints is TRUE.

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

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 9638d0e94f8..f838af61a9e 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -556,7 +556,9 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance)
 {
 	BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars)
 
-	if (!mFocusObject || mFocusObject->isDead())
+	if (!mFocusObject || mFocusObject->isDead() || 
+		mFocusObject->isMesh() ||
+		gSavedSettings.getBOOL("DisableCameraConstraints"))
 	{
 		obj_min_distance = 0.f;
 		return TRUE;
-- 
GitLab


From 65acaab16ffaa4cc6bed0934973ead659df20741 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 13 May 2010 01:31:45 -0500
Subject: [PATCH 414/683] working inworld vis

---
 indra/newview/llspatialpartition.cpp | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index ed99f8648f6..025c5084c31 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2671,24 +2671,36 @@ void renderPhysicsShape(LLDrawable* drawable)
 			if (decomp)
 			{
 				gGL.pushMatrix();
-				glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 				glMultMatrixf((F32*) volume->getRelativeXform().mMatrix);
 				static std::vector<LLColor4U> color;
 
+				gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
 				for (U32 i = 0; i < decomp->mHull.size(); ++i)
 				{
 					if (color.size() <= i)
 					{
-						color.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127));
+						color.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127, 255));
 					}
-					glColor4ubv(color[i].mV);
-
-					LLVertexBuffer* buff = decomp->mMesh;
+					
+					LLVertexBuffer* buff = decomp->mMesh[i];
 
 					buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
+
+					glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+					glColor4ubv(color[i].mV);
 					buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
+					glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+					{
+						LLGLEnable blend(GL_BLEND);
+						gGL.setSceneBlendType(LLRender::BT_ALPHA);
+						LLGLDepthTest depth(GL_TRUE, GL_FALSE);
+						glColor4ub(color[i].mV[0], color[i].mV[1], color[i].mV[2], 64);
+						buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
+					}
 				}
-				glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
 				gGL.popMatrix();
 			}
 		}
-- 
GitLab


From d334a9e645ab14c2822f35ee67d2c1e0f2a646a6 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 13 May 2010 14:54:56 -0500
Subject: [PATCH 415/683] Vis that works and first pass at fetching prim cost.

---
 indra/newview/llspatialpartition.cpp |  7 ++++-
 indra/newview/llviewerobject.cpp     |  1 +
 indra/newview/llviewerobject.h       |  4 +++
 indra/newview/llviewerobjectlist.cpp | 47 +++++++++++++++++++++++++++-
 indra/newview/llviewerobjectlist.h   |  6 ++++
 indra/newview/llviewerregion.cpp     |  1 +
 6 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 025c5084c31..f11195303e4 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2670,6 +2670,11 @@ void renderPhysicsShape(LLDrawable* drawable)
 			const LLMeshDecomposition* decomp = gMeshRepo.getDecomposition(mesh_id);
 			if (decomp)
 			{
+				if (volume->getObjectCost() == -1)
+				{
+					gObjectList.updateObjectCost(volume);
+				}
+
 				gGL.pushMatrix();
 				glMultMatrixf((F32*) volume->getRelativeXform().mMatrix);
 				static std::vector<LLColor4U> color;
@@ -2688,7 +2693,7 @@ void renderPhysicsShape(LLDrawable* drawable)
 					buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
 
 					glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-					glColor4ubv(color[i].mV);
+					glColor3ub(color[i].mV[0], color[i].mV[1], color[i].mV[2]);
 					buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
 					glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 3aecd0175d2..38a29ba4326 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -232,6 +232,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mState(0),
 	mMedia(NULL),
 	mClickAction(0),
+	mObjectCost(-1),
 	mAttachmentItemID(LLUUID::null)
 {
 	if (!is_global)
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 0fd0cbfa604..d2e465fe5a8 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -334,6 +334,9 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	
 	virtual void setScale(const LLVector3 &scale, BOOL damped = FALSE);
 
+	void setObjectCost(S32 cost) { mObjectCost = cost; }
+	S32 getObjectCost() { return mObjectCost; }
+
 	void sendShapeUpdate();
 
 	U8 getState()							{ return mState; }
@@ -668,6 +671,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	U8				mState;	// legacy
 	LLViewerObjectMedia* mMedia;	// NULL if no media associated
 	U8 mClickAction;
+	S32 mObjectCost; //resource cost of this object or -1 if unknown
 
 	static			U32			sNumZombieObjects;			// Objects which are dead, but not deleted
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 7ba28fef32a..047241fffba 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -656,6 +656,14 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
 	LLVOAvatar::cullAvatarsByPixelArea();
 }
 
+class LLObjectCostResponder : public LLCurl::Responder
+{
+public:
+	void result(const LLSD& content)
+	{
+		llinfos << content << llendl;
+	}
+};
 
 void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 {
@@ -753,6 +761,40 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 		}
 	}
 
+	//issue http request for stale object physics costs
+	if (!mStaleObjectCost.empty())
+	{
+		LLViewerRegion* regionp = gAgent.getRegion();
+
+		if (regionp)
+		{
+			std::string url; // = regionp->getCapability("GetObjectCost");
+
+			if (!url.empty())
+			{
+				LLSD id_list;
+				U32 idx = 0;
+				for (std::set<LLUUID>::iterator iter = mStaleObjectCost.begin(); iter != mStaleObjectCost.end(); ++iter)
+				{
+					if (mPendingObjectCost.find(*iter) == mPendingObjectCost.end())
+					{
+						mPendingObjectCost.insert(*iter);
+						id_list[idx++] = *iter;
+					}
+				}
+				mPendingObjectCost = mStaleObjectCost;
+				mStaleObjectCost.clear();
+
+				LLHTTPClient::post(url, id_list, new LLObjectCostResponder());
+			}
+			else
+			{
+				mStaleObjectCost.clear();
+				mPendingObjectCost.clear();
+			}
+		}
+	}
+
 	mNumSizeCulled = 0;
 	mNumVisCulled = 0;
 
@@ -1041,7 +1083,10 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
 	}
 }
 
-
+void LLViewerObjectList::updateObjectCost(LLViewerObject* object)
+{
+	mStaleObjectCost.insert(object->getID());
+}
 
 void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 {
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 706966deaef..ca228a64626 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -91,6 +91,8 @@ class LLViewerObjectList
 	void updateApparentAngles(LLAgent &agent);
 	void update(LLAgent &agent, LLWorld &world);
 
+	void updateObjectCost(LLViewerObject* object);
+
 	void shiftObjects(const LLVector3 &offset);
 
 	void renderObjectsForMap(LLNetMap &netmap);
@@ -192,6 +194,10 @@ class LLViewerObjectList
 
 	std::map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap;
 
+	//set of objects that need to update their cost
+	std::set<LLUUID> mStaleObjectCost;
+	std::set<LLUUID> mPendingObjectCost;
+
 	std::vector<LLDebugBeacon> mDebugBeacons;
 
 	S32 mCurLazyUpdateIndex;
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 4fdabd7ff05..59d419d67a1 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1497,6 +1497,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("FetchLibDescendents");
 	capabilityNames.append("GetTexture");
 	capabilityNames.append("GetMesh");
+	capabilityNames.append("GetObjectCost");
 	capabilityNames.append("GroupProposalBallot");
 	capabilityNames.append("HomeLocation");
 	capabilityNames.append("LandResources");
-- 
GitLab


From 963214f624c963ad9ce80e81db294d15a049b851 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 13 May 2010 14:40:48 -0600
Subject: [PATCH 416/683] EXT-7155: FIXED: bumpmaps failed to load reviewed by
 davep. (transplanted from fec2b449fbf9af842ee06e1be7198c4b2b879400)

---
 indra/newview/llviewerdisplay.cpp | 1 +
 indra/newview/pipeline.cpp        | 7 +++++++
 indra/newview/pipeline.h          | 1 +
 3 files changed, 9 insertions(+)

diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 3cd7af64339..1490f8153c1 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -732,6 +732,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		{
 			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
 			LLMemType mt_ss(LLMemType::MTYPE_DISPLAY_STATE_SORT);
+			gPipeline.sAllowRebuildPriorityGroup = TRUE ;
 			gPipeline.stateSort(*LLViewerCamera::getInstance(), result);
 			stop_glerror();
 				
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index dbd7f864476..ab41635b5ee 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -288,6 +288,7 @@ BOOL	LLPipeline::sRenderFrameTest = FALSE;
 BOOL	LLPipeline::sRenderAttachedLights = TRUE;
 BOOL	LLPipeline::sRenderAttachedParticles = TRUE;
 BOOL	LLPipeline::sRenderDeferred = FALSE;
+BOOL    LLPipeline::sAllowRebuildPriorityGroup = FALSE ;
 S32		LLPipeline::sVisibleLightCount = 0;
 F32		LLPipeline::sMinRenderSize = 0.f;
 
@@ -1808,6 +1809,12 @@ void LLPipeline::updateGL()
 
 void LLPipeline::rebuildPriorityGroups()
 {
+	if(!sAllowRebuildPriorityGroup)
+	{
+		return ;
+	}
+	sAllowRebuildPriorityGroup = FALSE ;
+
 	LLTimer update_timer;
 	LLMemType mt(LLMemType::MTYPE_PIPELINE);
 	
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 2c14b948479..f2e1d8eacb4 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -487,6 +487,7 @@ class LLPipeline
 	static BOOL				sRenderAttachedLights;
 	static BOOL				sRenderAttachedParticles;
 	static BOOL				sRenderDeferred;
+	static BOOL             sAllowRebuildPriorityGroup;
 	static S32				sVisibleLightCount;
 	static F32				sMinRenderSize;
 
-- 
GitLab


From 696249e731bcc78aa30624b478b5ea0581456c63 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 13 May 2010 14:43:24 -0600
Subject: [PATCH 417/683] EXT-7327: FIXED: viewer crash in
 LLVOVolume::syncMediaData on Meshopotamia 1 (transplanted from
 8be9afe40b24ddde1ad5f93e3a6554519acc7dc7)

---
 indra/newview/llvovolume.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index b120f5abf32..396d716ae2f 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1939,6 +1939,11 @@ void LLVOVolume::syncMediaData(S32 texture_index, const LLSD &media_data, bool m
 	}
 	
 	LLTextureEntry *te = getTE(texture_index);
+	if(!te)
+	{
+		return ;
+	}
+
 	LL_DEBUGS("MediaOnAPrim") << "BEFORE: texture_index = " << texture_index
 		<< " hasMedia = " << te->hasMedia() << " : " 
 		<< ((NULL == te->getMediaData()) ? "NULL MEDIA DATA" : ll_pretty_print_sd(te->getMediaData()->asLLSD())) << llendl;
-- 
GitLab


From ff7e83c3aa26bbaa380305a97dffbf22c0f7a747 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 14 May 2010 16:36:39 +0100
Subject: [PATCH 418/683] EXT-7154 FIXED revisted: darkness bumpmap looks like
 lightness bumpmap when deferred rendering is enabled

In addition to the previous bugs, the normal-map for *all* bumpmaps was also getting generated with its Y-gradient flipped, causing some odd and inconsistent results.
---
 indra/newview/lldrawpoolbump.cpp  | 23 ++++++++++++++++-------
 indra/newview/lldrawpoolbump.h    |  5 ++++-
 indra/newview/llviewercontrol.cpp |  4 +++-
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index a3b236fcb9b..3c268092598 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -93,6 +93,12 @@ void LLStandardBumpmap::shutdown()
 
 // static 
 void LLStandardBumpmap::restoreGL()
+{
+	addstandard();
+}
+
+// static
+void LLStandardBumpmap::addstandard()
 {
 	llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("None");		// BE_NO_BUMP
@@ -156,7 +162,7 @@ void LLStandardBumpmap::restoreGL()
 }
 
 // static
-void LLStandardBumpmap::destroyGL()
+void LLStandardBumpmap::clear()
 {
 	for( U32 i = 0; i < LLStandardBumpmap::sStandardBumpmapCount; i++ )
 	{
@@ -166,6 +172,12 @@ void LLStandardBumpmap::destroyGL()
 	sStandardBumpmapCount = 0;
 }
 
+// static
+void LLStandardBumpmap::destroyGL()
+{
+	clear();
+}
+
 
 
 ////////////////////////////////////////////////////////////////
@@ -1044,8 +1056,8 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr
 
 			LLVector3 right = LLVector3(norm_scale, 0, (F32) src_data[(j*resX+rX)*src_cmp+src_cmp-1]-cH);
 			LLVector3 left = LLVector3(-norm_scale, 0, (F32) src_data[(j*resX+lX)*src_cmp+src_cmp-1]-cH);
-			LLVector3 up = LLVector3(0, -norm_scale, (F32) src_data[(rY*resX+i)*src_cmp+src_cmp-1]-cH);
-			LLVector3 down = LLVector3(0, norm_scale, (F32) src_data[(lY*resX+i)*src_cmp+src_cmp-1]-cH);
+			LLVector3 up = LLVector3(0, -norm_scale, (F32) src_data[(lY*resX+i)*src_cmp+src_cmp-1]-cH);
+			LLVector3 down = LLVector3(0, norm_scale, (F32) src_data[(rY*resX+i)*src_cmp+src_cmp-1]-cH);
 
 			LLVector3 norm = right%down + down%left + left%up + up%right;
 		
@@ -1155,11 +1167,8 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 				F32 twice_one_over_range = 2.f / (maximum - minimum);
 				S32 i;
 
-				bool bump_polarity_negative = LLPipeline::sRenderDeferred ?
-					(BE_BRIGHTNESS == bump_code) : (BE_DARKNESS == bump_code); // deferred mode likes its normal map values inverted
-
 				const F32 ARTIFICIAL_SCALE = 2.f;  // Advantage: exaggerates the effect in midrange.  Disadvantage: clamps at the extremes.
-				if (bump_polarity_negative)
+				if (BE_DARKNESS == bump_code)
 				{
 					for( i = minimum; i <= maximum; i++ )
 					{
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index 219e2aac540..07846c28122 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -115,9 +115,12 @@ class LLStandardBumpmap
 
 	static	U32 sStandardBumpmapCount;  // Number of valid values in gStandardBumpmapList[]
 
+	static void clear();
+	static void addstandard();
+
 	static void init();
 	static void shutdown();
-	static void	restoreGL();
+	static void restoreGL();
 	static void destroyGL();
 };
 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index e856c18d707..d9f128b878c 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -119,8 +119,10 @@ static bool handleTerrainDetailChanged(const LLSD& newvalue)
 
 static bool handleSetShaderChanged(const LLSD& newvalue)
 {
-	// changing shader level may invalidate existing cached ad-hoc bump maps, as the shader type determines the format of the bump map it expectes - clear the bump cache
+	// changing shader level may invalidate existing cached bump maps, as the shader type determines the format of the bump map it expects - clear the bump cache
 	gBumpImageList.clear();
+	LLStandardBumpmap::clear();
+	LLStandardBumpmap::addstandard();
 
 	LLViewerShaderMgr::instance()->setShaders();
 	return true;
-- 
GitLab


From b27ed1f58e1d7d278a7110392b741bb98083381f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 14 May 2010 16:36:39 +0100
Subject: [PATCH 419/683] EXT-7154 FIXED revisted: darkness bumpmap looks like
 lightness bumpmap when deferred rendering is enabled

In addition to the previous bugs, the normal-map for *all* bumpmaps was also getting generated with its Y-gradient flipped, causing some odd and inconsistent results.
(transplanted from 3620b7690b1de428e8bada86124566157ea674a5)
---
 indra/newview/lldrawpoolbump.cpp  | 23 ++++++++++++++++-------
 indra/newview/lldrawpoolbump.h    |  5 ++++-
 indra/newview/llviewercontrol.cpp |  4 +++-
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index ac8bd4dc41c..1fae8e518c9 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -93,6 +93,12 @@ void LLStandardBumpmap::shutdown()
 
 // static 
 void LLStandardBumpmap::restoreGL()
+{
+	addstandard();
+}
+
+// static
+void LLStandardBumpmap::addstandard()
 {
 	llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("None");		// BE_NO_BUMP
@@ -156,7 +162,7 @@ void LLStandardBumpmap::restoreGL()
 }
 
 // static
-void LLStandardBumpmap::destroyGL()
+void LLStandardBumpmap::clear()
 {
 	for( U32 i = 0; i < LLStandardBumpmap::sStandardBumpmapCount; i++ )
 	{
@@ -166,6 +172,12 @@ void LLStandardBumpmap::destroyGL()
 	sStandardBumpmapCount = 0;
 }
 
+// static
+void LLStandardBumpmap::destroyGL()
+{
+	clear();
+}
+
 
 
 ////////////////////////////////////////////////////////////////
@@ -1085,8 +1097,8 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr
 
 			LLVector3 right = LLVector3(norm_scale, 0, (F32) src_data[(j*resX+rX)*src_cmp+src_cmp-1]-cH);
 			LLVector3 left = LLVector3(-norm_scale, 0, (F32) src_data[(j*resX+lX)*src_cmp+src_cmp-1]-cH);
-			LLVector3 up = LLVector3(0, -norm_scale, (F32) src_data[(rY*resX+i)*src_cmp+src_cmp-1]-cH);
-			LLVector3 down = LLVector3(0, norm_scale, (F32) src_data[(lY*resX+i)*src_cmp+src_cmp-1]-cH);
+			LLVector3 up = LLVector3(0, -norm_scale, (F32) src_data[(lY*resX+i)*src_cmp+src_cmp-1]-cH);
+			LLVector3 down = LLVector3(0, norm_scale, (F32) src_data[(rY*resX+i)*src_cmp+src_cmp-1]-cH);
 
 			LLVector3 norm = right%down + down%left + left%up + up%right;
 		
@@ -1196,11 +1208,8 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 				F32 twice_one_over_range = 2.f / (maximum - minimum);
 				S32 i;
 
-				bool bump_polarity_negative = LLPipeline::sRenderDeferred ?
-					(BE_BRIGHTNESS == bump_code) : (BE_DARKNESS == bump_code); // deferred mode likes its normal map values inverted
-
 				const F32 ARTIFICIAL_SCALE = 2.f;  // Advantage: exaggerates the effect in midrange.  Disadvantage: clamps at the extremes.
-				if (bump_polarity_negative)
+				if (BE_DARKNESS == bump_code)
 				{
 					for( i = minimum; i <= maximum; i++ )
 					{
diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h
index ceb72309d80..d634b7329e5 100644
--- a/indra/newview/lldrawpoolbump.h
+++ b/indra/newview/lldrawpoolbump.h
@@ -124,9 +124,12 @@ class LLStandardBumpmap
 
 	static	U32 sStandardBumpmapCount;  // Number of valid values in gStandardBumpmapList[]
 
+	static void clear();
+	static void addstandard();
+
 	static void init();
 	static void shutdown();
-	static void	restoreGL();
+	static void restoreGL();
 	static void destroyGL();
 };
 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 54323a4fadd..c985a9aa80b 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -119,8 +119,10 @@ static bool handleTerrainDetailChanged(const LLSD& newvalue)
 
 static bool handleSetShaderChanged(const LLSD& newvalue)
 {
-	// changing shader level may invalidate existing cached ad-hoc bump maps, as the shader type determines the format of the bump map it expectes - clear the bump cache
+	// changing shader level may invalidate existing cached bump maps, as the shader type determines the format of the bump map it expects - clear the bump cache
 	gBumpImageList.clear();
+	LLStandardBumpmap::clear();
+	LLStandardBumpmap::addstandard();
 
 	LLViewerShaderMgr::instance()->setShaders();
 	return true;
-- 
GitLab


From 8be6ad300a320b8a9debbd3abbf4b5c252db70a9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 14 May 2010 17:36:57 -0500
Subject: [PATCH 420/683] Actually update object cost based on result.

---
 indra/newview/llviewerobjectlist.cpp | 28 +++++++++++++++++++++++++---
 indra/newview/llviewerobjectlist.h   |  1 +
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 047241fffba..422ac4e84fe 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -60,6 +60,7 @@
 #include "llviewercamera.h"
 #include "llselectmgr.h"
 #include "llresmgr.h"
+#include "llsdutil.h"
 #include "llviewerregion.h"
 #include "llviewerstats.h"
 #include "llvoavatarself.h"
@@ -661,7 +662,14 @@ class LLObjectCostResponder : public LLCurl::Responder
 public:
 	void result(const LLSD& content)
 	{
-		llinfos << content << llendl;
+		for (LLSD::map_const_iterator iter = content.beginMap(); iter != content.endMap(); ++iter)
+		{
+			LLUUID object_id = LLUUID(iter->first);
+			S32 link_cost = iter->second["LinkResourceCost"].asInteger();
+			S32 prim_cost = iter->second["PrimResourceCost"].asInteger();
+
+			gObjectList.updateObjectCost(object_id, prim_cost, link_cost);
+		}
 	}
 };
 
@@ -768,7 +776,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 
 		if (regionp)
 		{
-			std::string url; // = regionp->getCapability("GetObjectCost");
+			std::string url = regionp->getCapability("GetObjectCost");
 
 			if (!url.empty())
 			{
@@ -785,7 +793,10 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 				mPendingObjectCost = mStaleObjectCost;
 				mStaleObjectCost.clear();
 
-				LLHTTPClient::post(url, id_list, new LLObjectCostResponder());
+				if (id_list.size() > 0)
+				{
+					LLHTTPClient::post(url, id_list, new LLObjectCostResponder());
+				}
 			}
 			else
 			{
@@ -1088,6 +1099,17 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object)
 	mStaleObjectCost.insert(object->getID());
 }
 
+void LLViewerObjectList::updateObjectCost(LLUUID object_id, S32 prim_cost, S32 link_cost)
+{
+	mPendingObjectCost.erase(object_id);
+
+	LLViewerObject* object = findObject(object_id);
+	if (object)
+	{
+		object->setObjectCost(prim_cost);
+	}
+}
+
 void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 {
 	// This is called when we shift our origin when we cross region boundaries...
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index ca228a64626..db9324bdbdd 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -92,6 +92,7 @@ class LLViewerObjectList
 	void update(LLAgent &agent, LLWorld &world);
 
 	void updateObjectCost(LLViewerObject* object);
+	void updateObjectCost(LLUUID object_id, S32 prim_cost, S32 link_cost);
 
 	void shiftObjects(const LLVector3 &offset);
 
-- 
GitLab


From 246dd9c168550bfe4b1b71bba75f5af9456e86dd Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 15 May 2010 02:45:58 -0500
Subject: [PATCH 421/683] Highlight for object cost and proper
 retrieval/display of prim object cost and linkset cost.

---
 indra/newview/app_settings/settings.xml | 44 +++++++++++++++++++++
 indra/newview/llfloatertools.cpp        | 12 +++---
 indra/newview/llselectmgr.cpp           | 47 +++++++++++++++++++++++
 indra/newview/llselectmgr.h             |  3 ++
 indra/newview/llspatialpartition.cpp    | 51 ++++++++++++++++---------
 indra/newview/llviewerobject.cpp        | 44 ++++++++++++++++++++-
 indra/newview/llviewerobject.h          | 11 ++++--
 indra/newview/llviewerobjectlist.cpp    |  7 ++--
 indra/newview/llviewerobjectlist.h      |  2 +-
 9 files changed, 189 insertions(+), 32 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4c72b03b2e2..107f98071cc 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -5418,6 +5418,50 @@
       <key>Value</key>
       <real>0.0</real>
     </map>
+  <key>ObjectCostHighThreshold</key>
+  <map>
+    <key>Comment</key>
+    <string>Threshold at which object cost is considered high (displayed in red).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>128.0</real>
+  </map>
+  <key>ObjectCostLowColor</key>
+  <map>
+    <key>Comment</key>
+    <string>Color for object with a low object cost.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Color4</string>
+    <key>Value</key>
+    <array>
+      <real>0.0</real>
+      <real>0.5</real>
+      <real>1.0</real>
+      <real>0.5</real>
+    </array>
+  </map>
+  <key>ObjectCostHighColor</key>
+  <map>
+    <key>Comment</key>
+    <string>Color for object a high object cost.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Color4</string>
+    <key>Value</key>
+    <array>
+      <real>1.0</real>
+      <real>0.0</real>
+      <real>0.0</real>
+      <real>0.75</real>
+    </array>
+  </map>
+  
     <key>ParcelMediaAutoPlayEnable</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp
index a8172bbfaef..30d2a02b5b9 100644
--- a/indra/newview/llfloatertools.cpp
+++ b/indra/newview/llfloatertools.cpp
@@ -419,12 +419,12 @@ void LLFloaterTools::refresh()
 
 	// Refresh object and prim count labels
 	LLLocale locale(LLLocale::USER_LOCALE);
-	std::string obj_count_string;
-	LLResMgr::getInstance()->getIntegerString(obj_count_string, LLSelectMgr::getInstance()->getSelection()->getRootObjectCount());
-	childSetTextArg("obj_count",  "[COUNT]", obj_count_string);	
-	std::string prim_count_string;
-	LLResMgr::getInstance()->getIntegerString(prim_count_string, LLSelectMgr::getInstance()->getSelection()->getObjectCount(TRUE));
-	childSetTextArg("prim_count", "[COUNT]", prim_count_string);
+	
+	F32 obj_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectCost();
+	F32 link_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedLinksetCost();
+
+	childSetTextArg("obj_count",  "[COUNT]", llformat("%.1f", obj_cost));	
+	childSetTextArg("prim_count", "[COUNT]", llformat("%.1f", link_cost));
 
 	// calculate selection rendering cost
 	if (sShowObjectCost)
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index e66be1023d1..5acbae0c770 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -6183,6 +6183,53 @@ S32 LLObjectSelection::getObjectCount(BOOL mesh_adjust)
 	return count;
 }
 
+F32 LLObjectSelection::getSelectedObjectCost()
+{
+	cleanupNodes();
+	F32 cost = 0.f;
+
+	for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+	{
+		LLSelectNode* node = *iter;
+		LLViewerObject* object = node->getObject();
+		
+		if (object)
+		{
+			cost += object->getObjectCost();
+		}
+	}
+
+	return cost;
+}
+
+F32 LLObjectSelection::getSelectedLinksetCost()
+{
+	cleanupNodes();
+	F32 cost = 0.f;
+
+	std::set<LLViewerObject*> me_roots;
+
+	for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+	{
+		LLSelectNode* node = *iter;
+		LLViewerObject* object = node->getObject();
+		
+		if (object)
+		{
+			LLViewerObject* root = static_cast<LLViewerObject*>(object->getRoot());
+			if (root)
+			{
+				if (me_roots.find(root) == me_roots.end())
+				{
+					me_roots.insert(root);
+					cost += root->getLinksetCost();
+				}
+			}
+		}
+	}
+
+	return cost;
+}
 
 //-----------------------------------------------------------------------------
 // getTECount()
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 34f2082b825..5302cfae683 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -292,6 +292,9 @@ class LLObjectSelection : public LLRefCount
 
 	// count members
 	S32 getObjectCount(BOOL mesh_adjust = FALSE);
+	F32 getSelectedObjectCost();
+	F32 getSelectedLinksetCost();
+
 	S32 getTECount();
 	S32 getRootObjectCount();
 
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index f11195303e4..1290e6b9a65 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2294,6 +2294,14 @@ void pushVerts(LLFace* face, U32 mask)
 	}
 }
 
+void pushVerts(LLDrawable* drawable, U32 mask)
+{
+	for (S32 i = 0; i < drawable->getNumFaces(); ++i)
+	{
+		pushVerts(drawable->getFace(i), mask);
+	}
+}
+
 void pushBufferVerts(LLVertexBuffer* buffer, U32 mask)
 {
 	if (buffer)
@@ -2664,36 +2672,35 @@ void renderPhysicsShape(LLDrawable* drawable)
 	LLVOVolume* volume = drawable->getVOVolume();
 	if (volume)
 	{
+		F32 threshold = gSavedSettings.getF32("ObjectCostHighThreshold");
+		F32 cost = volume->getObjectCost();
+
+		LLColor4 low = gSavedSettings.getColor4("ObjectCostLowColor");
+		LLColor4 high = gSavedSettings.getColor4("ObjectCostHighColor");
+
+		LLColor4 color = lerp(low, high, cost/threshold);
+
+		U32 data_mask = LLVertexBuffer::MAP_VERTEX;
+
 		if (volume->isMesh())
-		{
+		{			
 			LLUUID mesh_id = volume->getVolume()->getParams().getSculptID();
 			const LLMeshDecomposition* decomp = gMeshRepo.getDecomposition(mesh_id);
 			if (decomp)
 			{
-				if (volume->getObjectCost() == -1)
-				{
-					gObjectList.updateObjectCost(volume);
-				}
-
 				gGL.pushMatrix();
 				glMultMatrixf((F32*) volume->getRelativeXform().mMatrix);
-				static std::vector<LLColor4U> color;
-
+				
 				gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 
 				for (U32 i = 0; i < decomp->mHull.size(); ++i)
-				{
-					if (color.size() <= i)
-					{
-						color.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127, 255));
-					}
-					
+				{		
 					LLVertexBuffer* buff = decomp->mMesh[i];
 
-					buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
+					buff->setBuffer(data_mask);
 
 					glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-					glColor3ub(color[i].mV[0], color[i].mV[1], color[i].mV[2]);
+					glColor3fv(color.mV);
 					buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
 					glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 
@@ -2701,14 +2708,24 @@ void renderPhysicsShape(LLDrawable* drawable)
 						LLGLEnable blend(GL_BLEND);
 						gGL.setSceneBlendType(LLRender::BT_ALPHA);
 						LLGLDepthTest depth(GL_TRUE, GL_FALSE);
-						glColor4ub(color[i].mV[0], color[i].mV[1], color[i].mV[2], 64);
+						glColor4fv(color.mV);
 						buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
 					}
 				}
 
 				gGL.popMatrix();
+
+				return;
 			}
 		}
+
+		//push faces
+		glColor3fv(color.mV);
+		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+		pushVerts(drawable, data_mask);
+		glColor4fv(color.mV);
+		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+		pushVerts(drawable, data_mask);
 	}
 }
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 38a29ba4326..ff5d7e9c178 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -232,7 +232,9 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mState(0),
 	mMedia(NULL),
 	mClickAction(0),
-	mObjectCost(-1),
+	mObjectCost(0.f),
+	mLinksetCost(0.f),
+	mCostStale(true),
 	mAttachmentItemID(LLUUID::null)
 {
 	if (!is_global)
@@ -829,6 +831,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 #ifdef DEBUG_UPDATE_TYPE
 				llinfos << "Full:" << getID() << llendl;
 #endif
+				//clear cost and linkset cost
+				mCostStale = true;
+
 				LLUUID audio_uuid;
 				LLUUID owner_id;	// only valid if audio_uuid or particle system is not null
 				F32    gain;
@@ -1394,6 +1399,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 #ifdef DEBUG_UPDATE_TYPE
 				llinfos << "CompFull:" << getID() << llendl;
 #endif
+				mCostStale = true;
+
 				dp->unpackU32(crc, "CRC");
 				mTotalCRC = crc;
 				dp->unpackU8(material, "Material");
@@ -2864,6 +2871,39 @@ void LLViewerObject::setScale(const LLVector3 &scale, BOOL damped)
 	}
 }
 
+void LLViewerObject::setObjectCost(F32 cost)
+{
+	mObjectCost = cost;
+	mCostStale = false;
+}
+
+void LLViewerObject::setLinksetCost(F32 cost)
+{
+	mLinksetCost = cost;
+	mCostStale = false;
+}
+
+
+F32 LLViewerObject::getObjectCost()
+{
+	if (mCostStale)
+	{
+		gObjectList.updateObjectCost(this);
+	}
+	
+	return mObjectCost;
+}
+
+F32 LLViewerObject::getLinksetCost()
+{
+	if (mCostStale)
+	{
+		gObjectList.updateObjectCost(this);
+	}
+
+	return mLinksetCost;
+}
+
 void LLViewerObject::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax)
 {
 	LLVector3 center = getRenderPosition();
@@ -4970,7 +5010,7 @@ void LLViewerObject::updateFlags()
 
 	if (getPhysicsShapeType() != 0)
 	{
-		llwarns << "sent non default physics rep" << llendl;
+		llwarns << "sent non default physics rep " << (S32) getPhysicsShapeType() << llendl;
 	}
 }
 
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index d2e465fe5a8..15fabc9f821 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -334,8 +334,11 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	
 	virtual void setScale(const LLVector3 &scale, BOOL damped = FALSE);
 
-	void setObjectCost(S32 cost) { mObjectCost = cost; }
-	S32 getObjectCost() { return mObjectCost; }
+	void setObjectCost(F32 cost);
+	F32 getObjectCost();
+	void setLinksetCost(F32 cost);
+	F32 getLinksetCost();
+	
 
 	void sendShapeUpdate();
 
@@ -671,7 +674,9 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	U8				mState;	// legacy
 	LLViewerObjectMedia* mMedia;	// NULL if no media associated
 	U8 mClickAction;
-	S32 mObjectCost; //resource cost of this object or -1 if unknown
+	F32 mObjectCost; //resource cost of this object or -1 if unknown
+	F32 mLinksetCost;
+	bool mCostStale;
 
 	static			U32			sNumZombieObjects;			// Objects which are dead, but not deleted
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 422ac4e84fe..9d41e2a530d 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -665,8 +665,8 @@ class LLObjectCostResponder : public LLCurl::Responder
 		for (LLSD::map_const_iterator iter = content.beginMap(); iter != content.endMap(); ++iter)
 		{
 			LLUUID object_id = LLUUID(iter->first);
-			S32 link_cost = iter->second["LinkResourceCost"].asInteger();
-			S32 prim_cost = iter->second["PrimResourceCost"].asInteger();
+			F32 link_cost = iter->second["LinksetResourceCost"].asReal();
+			F32 prim_cost = iter->second["PrimResourceCost"].asReal();
 
 			gObjectList.updateObjectCost(object_id, prim_cost, link_cost);
 		}
@@ -1099,7 +1099,7 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object)
 	mStaleObjectCost.insert(object->getID());
 }
 
-void LLViewerObjectList::updateObjectCost(LLUUID object_id, S32 prim_cost, S32 link_cost)
+void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 prim_cost, F32 link_cost)
 {
 	mPendingObjectCost.erase(object_id);
 
@@ -1107,6 +1107,7 @@ void LLViewerObjectList::updateObjectCost(LLUUID object_id, S32 prim_cost, S32 l
 	if (object)
 	{
 		object->setObjectCost(prim_cost);
+		object->setLinksetCost(link_cost);
 	}
 }
 
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index db9324bdbdd..4064a68eb21 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -92,7 +92,7 @@ class LLViewerObjectList
 	void update(LLAgent &agent, LLWorld &world);
 
 	void updateObjectCost(LLViewerObject* object);
-	void updateObjectCost(LLUUID object_id, S32 prim_cost, S32 link_cost);
+	void updateObjectCost(LLUUID object_id, F32 prim_cost, F32 link_cost);
 
 	void shiftObjects(const LLVector3 &offset);
 
-- 
GitLab


From 1d92a950df91d7e6d3a34e925f445bc389a3fa93 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Tue, 18 May 2010 11:26:53 -0700
Subject: [PATCH 422/683] Modified color scheme for visualization of physics
 reps.

---
 indra/newview/app_settings/settings.xml | 18 +++++++++++++++++-
 indra/newview/llspatialpartition.cpp    | 13 ++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 107f98071cc..2e7ff939ee0 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -5427,7 +5427,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>128.0</real>
+    <real>50.0</real>
   </map>
   <key>ObjectCostLowColor</key>
   <map>
@@ -5445,6 +5445,22 @@
       <real>0.5</real>
     </array>
   </map>
+  <key>ObjectCostMidColor</key>
+  <map>
+    <key>Comment</key>
+    <string>Color for object with a medium object cost.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Color4</string>
+    <key>Value</key>
+    <array>
+      <real>1.0</real>
+      <real>0.75</real>
+      <real>0.0</real>
+      <real>0.65</real>
+    </array>
+  </map>
   <key>ObjectCostHighColor</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 1290e6b9a65..9bfc12c7abb 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2676,9 +2676,20 @@ void renderPhysicsShape(LLDrawable* drawable)
 		F32 cost = volume->getObjectCost();
 
 		LLColor4 low = gSavedSettings.getColor4("ObjectCostLowColor");
+		LLColor4 mid = gSavedSettings.getColor4("ObjectCostMidColor");
 		LLColor4 high = gSavedSettings.getColor4("ObjectCostHighColor");
 
-		LLColor4 color = lerp(low, high, cost/threshold);
+		F32 normalizedCost = 1.f - exp( -(cost / threshold) );
+
+		LLColor4 color;
+		if ( normalizedCost <= 0.5f )
+		{
+			color = lerp( low, mid, 2.f * normalizedCost );
+		}
+		else
+		{
+			color = lerp( mid, high, 2.f * ( normalizedCost - 0.5f ) );
+		}
 
 		U32 data_mask = LLVertexBuffer::MAP_VERTEX;
 
-- 
GitLab


From 387b7adbc4edea3f5c649b48b0714bf73d7af9da Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 18 May 2010 16:59:01 -0500
Subject: [PATCH 423/683] Take a stab at baked sunlight to help low end
 hardware.

---
 indra/newview/app_settings/settings.xml | 39 ++++++++++++++++++++++++-
 indra/newview/llface.cpp                | 23 ++++++++++++++-
 indra/newview/llviewercontrol.cpp       |  2 ++
 indra/newview/llvovolume.cpp            | 10 +++++--
 indra/newview/pipeline.cpp              |  4 +++
 indra/newview/pipeline.h                |  2 ++
 6 files changed, 75 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4c72b03b2e2..9b7cc041204 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6313,6 +6313,7 @@
     <key>Value</key>
     <integer>0</integer>
   </map>
+ 
   <key>RenderAnimateRes</key>
   <map>
     <key>Comment</key>
@@ -6324,7 +6325,31 @@
     <key>Value</key>
     <integer>0</integer>
   </map>
-  
+
+  <key>RenderBakeSunlight</key>
+  <map>
+    <key>Comment</key>
+    <string>Bake sunlight into vertex buffers for static objects.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>0</integer>
+  </map>
+
+  <key>RenderNoAlpha</key>
+  <map>
+    <key>Comment</key>
+    <string>Disable rendering of alpha objects (render all alpha objects as alpha masks).</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>0</integer>
+  </map>
+
   <key>RenderAnimateTrees</key>
   <map>
     <key>Comment</key>
@@ -6481,6 +6506,18 @@
     <real>16.0</real>
    </map>
 
+  <key>RenderMinimumLODTriangleCount</key>
+  <map>
+    <key>Comment</key>
+    <string>Triangle count threshold at which automatic LOD generation stops</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>U32</string>
+    <key>Value</key>
+    <real>16</real>
+  </map>
+
   <key>RenderEdgeDepthCutoff</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 9df692e787e..365f2fbe1ad 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -896,6 +896,11 @@ void LLFace::updateRebuildFlags()
 
 bool LLFace::canRenderAsMask()
 {
+	if (LLPipeline::sNoAlpha)
+	{
+		return true;
+	}
+
 	const LLTextureEntry* te = getTextureEntry();
 	return (
 		(
@@ -1205,6 +1210,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		mVObjp->getVolume()->genBinormals(f);
 	}
 
+	//if it's not fullbright and has no normals, bake sunlight based on face normal
+	bool bake_sunlight = !getTextureEntry()->getFullbright() &&
+		!mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
+
 	for (S32 i = 0; i < num_vertices; i++)
 	{
 		if (rebuild_tcoord)
@@ -1382,7 +1391,19 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_color)
 		{
-			*colors++ = color;		
+			if (bake_sunlight)
+			{
+				LLVector3 normal = vf.mVertices[i].mNormal * mat_normal;
+				normal.normVec();
+				
+				F32 da = normal * gPipeline.mSunDir;
+
+				*colors++ = LLColor4U(color.mV[0]*da, color.mV[1]*da, color.mV[2]*da, color.mV[3]);
+			}
+			else
+			{
+				*colors++ = color;		
+			}
 		}
 	}
 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 54323a4fadd..f76c53a77a9 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -506,6 +506,8 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderTerrainDetail")->getSignal()->connect(boost::bind(&handleTerrainDetailChanged, _2));
 	gSavedSettings.getControl("RenderUseTriStrips")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
+	gSavedSettings.getControl("RenderBakeSunlight")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
+	gSavedSettings.getControl("RenderNoAlpha")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
 	gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	gSavedSettings.getControl("RenderUIBuffer")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index b120f5abf32..c4700995940 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3516,6 +3516,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 					vobj->isMesh() && 
 					gMeshRepo.getSkinInfo(vobj->getVolume()->getParams().getSculptID());
 
+		bool bake_sunlight = LLPipeline::sBakeSunlight && drawablep->isStatic();
+
 		//for each face
 		for (S32 i = 0; i < drawablep->getNumFaces(); i++)
 		{
@@ -3715,7 +3717,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 							bump_faces.push_back(facep);
 						}
 						else if ((te->getShiny() && LLPipeline::sRenderBump) ||
-							!te->getFullbright())
+							!(te->getFullbright() || bake_sunlight))
 						{ //needs normal
 							simple_faces.push_back(facep);
 						}
@@ -3925,6 +3927,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 			buffer_index = 0;
 		}
 
+		bool bake_sunlight = LLPipeline::sBakeSunlight && facep->getDrawable()->isStatic(); 
+
 		U32 index_count = facep->getIndicesCount();
 		U32 geom_count = facep->getGeomCount();
 
@@ -4030,7 +4034,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				// can we safely treat this as an alpha mask?
 				if (facep->canRenderAsMask())
 				{
-					if (te->getFullbright())
+					if (te->getFullbright() || LLPipeline::sNoAlpha)
 					{
 						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK);
 					}
@@ -4094,7 +4098,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 				{ //invisiprim
 					registerFace(group, facep, LLRenderPass::PASS_INVISIBLE);
 				}
-				else if (fullbright)
+				else if (fullbright || bake_sunlight)
 				{ //fullbright
 					registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT);
 					if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap())
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index dbd7f864476..f54f29927ae 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -275,6 +275,8 @@ BOOL	LLPipeline::sAutoMaskAlphaDeferred = TRUE;
 BOOL	LLPipeline::sAutoMaskAlphaNonDeferred = FALSE;
 BOOL	LLPipeline::sDisableShaders = FALSE;
 BOOL	LLPipeline::sRenderBump = TRUE;
+BOOL	LLPipeline::sBakeSunlight = FALSE;
+BOOL	LLPipeline::sNoAlpha = FALSE;
 BOOL	LLPipeline::sUseTriStrips = TRUE;
 BOOL	LLPipeline::sUseFarClip = TRUE;
 BOOL	LLPipeline::sShadowRender = FALSE;
@@ -5487,6 +5489,8 @@ void LLPipeline::resetVertexBuffers()
 	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
 	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
 	LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");
+	sBakeSunlight = gSavedSettings.getBOOL("RenderBakeSunlight");
+	sNoAlpha = gSavedSettings.getBOOL("RenderNoAlpha");
 
 	for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
 			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 2c14b948479..d8bac8b6010 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -472,6 +472,8 @@ class LLPipeline
 	static BOOL				sAutoMaskAlphaNonDeferred;
 	static BOOL				sDisableShaders; // if TRUE, rendering will be done without shaders
 	static BOOL				sRenderBump;
+	static BOOL				sBakeSunlight;
+	static BOOL				sNoAlpha;
 	static BOOL				sUseTriStrips;
 	static BOOL				sUseFarClip;
 	static BOOL				sShadowRender;
-- 
GitLab


From d58ef90a029802370f4dd6246e522ca75cce9b0a Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 19 May 2010 10:26:33 +0100
Subject: [PATCH 424/683] explicit castfu for gcc.

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

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 365f2fbe1ad..53dc335c162 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1398,7 +1398,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 				
 				F32 da = normal * gPipeline.mSunDir;
 
-				*colors++ = LLColor4U(color.mV[0]*da, color.mV[1]*da, color.mV[2]*da, color.mV[3]);
+				*colors++ = LLColor4U(U8(color.mV[0]*da), U8(color.mV[1]*da), U8(color.mV[2]*da), color.mV[3]);
 			}
 			else
 			{
-- 
GitLab


From f14215689244a65064158e475e4f41eb149d85b0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 May 2010 02:22:26 -0500
Subject: [PATCH 425/683] Vectorized avatar vertex skinning.

---
 indra/newview/llpolymesh.cpp            |  26 +++--
 indra/newview/llpolymesh.h              |  12 +-
 indra/newview/llpolymorph.cpp           |  13 ++-
 indra/newview/llviewerjointmesh.cpp     | 145 ++++++++++++------------
 indra/newview/llviewerjointmesh_vec.cpp |   2 +
 5 files changed, 101 insertions(+), 97 deletions(-)

diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp
index d5a2d66bcfc..b8bdbfb2f81 100644
--- a/indra/newview/llpolymesh.cpp
+++ b/indra/newview/llpolymesh.cpp
@@ -708,15 +708,17 @@ LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_
 		mClothingWeights = reference_mesh->mClothingWeights;
 	}
 	else
-	{
+	{ 	 
 #if 1	// Allocate memory without initializing every vector
 		// NOTE: This makes asusmptions about the size of LLVector[234]
 		int nverts = mSharedData->mNumVertices;
-		int nfloats = nverts * (3*5 + 2 + 4);
-		mVertexData = new F32[nfloats];
+		int nfloats = nverts * (2*4 + 3*3 + 2 + 4);
+
+		//use aligned vertex data to make LLPolyMesh SSE friendly
+		mVertexData = (F32*) _mm_malloc(nfloats*4, 16);
 		int offset = 0;
-		mCoords = 				(LLVector3*)(mVertexData + offset); offset += 3*nverts;
-		mNormals = 				(LLVector3*)(mVertexData + offset); offset += 3*nverts;
+		mCoords = 				(LLVector4*)(mVertexData + offset); offset += 4*nverts;
+		mNormals = 				(LLVector4*)(mVertexData + offset); offset += 4*nverts;
 		mScaledNormals = 		(LLVector3*)(mVertexData + offset); offset += 3*nverts;
 		mBinormals = 			(LLVector3*)(mVertexData + offset); offset += 3*nverts;
 		mScaledBinormals = 		(LLVector3*)(mVertexData + offset); offset += 3*nverts;
@@ -757,7 +759,7 @@ LLPolyMesh::~LLPolyMesh()
 	delete [] mClothingWeights;
 	delete [] mTexCoords;
 #else
-	delete [] mVertexData;
+	_mm_free(mVertexData);
 #endif
 }
 
@@ -864,7 +866,7 @@ void LLPolyMesh::dumpDiagInfo()
 //-----------------------------------------------------------------------------
 // getWritableCoords()
 //-----------------------------------------------------------------------------
-LLVector3 *LLPolyMesh::getWritableCoords()
+LLVector4 *LLPolyMesh::getWritableCoords()
 {
 	return mCoords;
 }
@@ -872,7 +874,7 @@ LLVector3 *LLPolyMesh::getWritableCoords()
 //-----------------------------------------------------------------------------
 // getWritableNormals()
 //-----------------------------------------------------------------------------
-LLVector3 *LLPolyMesh::getWritableNormals()
+LLVector4 *LLPolyMesh::getWritableNormals()
 {
 	return mNormals;
 }
@@ -927,8 +929,12 @@ void LLPolyMesh::initializeForMorph()
 	if (!mSharedData)
 		return;
 
-	memcpy(mCoords, mSharedData->mBaseCoords, sizeof(LLVector3) * mSharedData->mNumVertices);	/*Flawfinder: ignore*/
-	memcpy(mNormals, mSharedData->mBaseNormals, sizeof(LLVector3) * mSharedData->mNumVertices);	/*Flawfinder: ignore*/
+	for (U32 i = 0; i < mSharedData->mNumVertices; ++i)
+	{
+		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*/
diff --git a/indra/newview/llpolymesh.h b/indra/newview/llpolymesh.h
index c2e5451dfe3..d86568a1ba7 100644
--- a/indra/newview/llpolymesh.h
+++ b/indra/newview/llpolymesh.h
@@ -223,15 +223,15 @@ class LLPolyMesh
 	}
 
 	// Get coords
-	const LLVector3	*getCoords() const{
+	const LLVector4	*getCoords() const{
 		return mCoords;
 	}
 
 	// non const version
-	LLVector3 *getWritableCoords();
+	LLVector4 *getWritableCoords();
 
 	// Get normals
-	const LLVector3	*getNormals() const{ 
+	const LLVector4	*getNormals() const{ 
 		return mNormals; 
 	}
 
@@ -253,7 +253,7 @@ class LLPolyMesh
 	}
 
 	// intermediate morphed normals and output normals
-	LLVector3 *getWritableNormals();
+	LLVector4 *getWritableNormals();
 	LLVector3 *getScaledNormals();
 
 	LLVector3 *getWritableBinormals();
@@ -347,11 +347,11 @@ class LLPolyMesh
 	// Single array of floats for allocation / deletion
 	F32						*mVertexData;
 	// deformed vertices (resulting from application of morph targets)
-	LLVector3				*mCoords;
+	LLVector4				*mCoords;
 	// deformed normals (resulting from application of morph targets)
 	LLVector3				*mScaledNormals;
 	// output normals (after normalization)
-	LLVector3				*mNormals;
+	LLVector4				*mNormals;
 	// deformed binormals (resulting from application of morph targets)
 	LLVector3				*mScaledBinormals;
 	// output binormals (after normalization)
diff --git a/indra/newview/llpolymorph.cpp b/indra/newview/llpolymorph.cpp
index 80983cad243..2058c351c4e 100644
--- a/indra/newview/llpolymorph.cpp
+++ b/indra/newview/llpolymorph.cpp
@@ -461,10 +461,10 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 	if (delta_weight != 0.f)
 	{
 		llassert(!mMesh->isLOD());
-		LLVector3 *coords = mMesh->getWritableCoords();
+		LLVector4 *coords = mMesh->getWritableCoords();
 
 		LLVector3 *scaled_normals = mMesh->getScaledNormals();
-		LLVector3 *normals = mMesh->getWritableNormals();
+		LLVector4 *normals = mMesh->getWritableNormals();
 
 		LLVector3 *scaled_binormals = mMesh->getScaledBinormals();
 		LLVector3 *binormals = mMesh->getWritableBinormals();
@@ -484,7 +484,8 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 				maskWeight = maskWeightArray[vert_index_morph];
 			}
 
-			coords[vert_index_mesh] += mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight;
+			coords[vert_index_mesh] += LLVector4(mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight);
+
 			if (getInfo()->mIsClothingMorph && clothing_weights)
 			{
 				LLVector3 clothing_offset = mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight;
@@ -499,7 +500,7 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 			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] = normalized_normal;
+			normals[vert_index_mesh] = LLVector4(normalized_normal);
 
 			// calculate new binormals
 			scaled_binormals[vert_index_mesh] += mMorphData->mBinormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR;
@@ -548,7 +549,7 @@ void	LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S3
 
 		if (maskWeights)
 		{
-			LLVector3 *coords = mMesh->getWritableCoords();
+			LLVector4 *coords = mMesh->getWritableCoords();
 			LLVector3 *scaled_normals = mMesh->getScaledNormals();
 			LLVector3 *scaled_binormals = mMesh->getScaledBinormals();
 			LLVector2 *tex_coords = mMesh->getWritableTexCoords();
@@ -559,7 +560,7 @@ void	LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S3
 				S32 out_vert = mMorphData->mVertexIndices[vert];
 
 				// remove effect of existing masked morph
-				coords[out_vert] -= mMorphData->mCoords[vert] * lastMaskWeight;
+				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;
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index deb3d8fd97e..294dfdcb555 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -61,6 +61,7 @@
 #include "v4math.h"
 #include "m3math.h"
 #include "m4math.h"
+#include "llmatrix4a.h"
 
 #if !LL_DARWIN && !LL_LINUX && !LL_SOLARIS
 extern PFNGLWEIGHTPOINTERARBPROC glWeightPointerARB;
@@ -382,6 +383,7 @@ const S32 NUM_AXES = 3;
 // pivot parent 0-n -- child = n+1
 
 static LLMatrix4	gJointMatUnaligned[32];
+static LLMatrix4a	gJointMatAligned[32];
 static LLMatrix3	gJointRotUnaligned[32];
 static LLVector4	gJointPivot[32];
 
@@ -467,6 +469,14 @@ void LLViewerJointMesh::uploadJointMatrices()
 		glUniform4fvARB(gAvatarMatrixParam, 45, mat);
 		stop_glerror();
 	}
+	else
+	{
+		//load gJointMatUnaligned into gJointMatAligned
+		for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.count(); ++joint_num)
+		{
+			gJointMatAligned[joint_num].loadu(gJointMatUnaligned[joint_num]);
+		}
+	}
 }
 
 //--------------------------------------------------------------------
@@ -723,7 +733,7 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 					v[0] = coords[0]; 
 					v[1] = coords[1]; 
 					v[2] = coords[2];		
-					coords += 3;
+					coords += 4;
 					v += skip;
 				}
 
@@ -732,12 +742,12 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 					n[0] = normals[0]; 
 					n[1] = normals[1];
 					n[2] = normals[2];
-					normals += 3;
+					normals += 4;
 					n += skip;
 				}
 			}
 			else
-				{
+			{
 
 				U32* __restrict tc = (U32*) tex_coordsp.get();
 				U32* __restrict vw = (U32*) vertex_weightsp.get();
@@ -745,18 +755,20 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 				
 				do
 				{
-					v[0] = *(coords++); 
-					v[1] = *(coords++); 
-					v[2] = *(coords++);
+					v[0] = coords[0]; 
+					v[1] = coords[1]; 
+					v[2] = coords[2];		
+					coords += 4;
 					v += skip;
 
 					tc[0] = *(tex_coords++); 
 					tc[1] = *(tex_coords++);
 					tc += skip;
 
-					n[0] = *(normals++); 
-					n[1] = *(normals++);
-					n[2] = *(normals++);
+					n[0] = normals[0]; 
+					n[1] = normals[1];
+					n[2] = normals[2];
+					normals += 4;
 					n += skip;
 
 					vw[0] = *(weights++);
@@ -808,17 +820,17 @@ void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh)
 	LLStrider<LLVector3> o_normals;
 
 	//get vertex and normal striders
-	LLVertexBuffer *buffer = mFace->mVertexBuffer;
+	LLVertexBuffer* buffer = mFace->mVertexBuffer;
 	buffer->getVertexStrider(o_vertices,  0);
 	buffer->getNormalStrider(o_normals,   0);
 
-	F32 last_weight = F32_MAX;
-	LLMatrix4 gBlendMat;
-	LLMatrix3 gBlendRotMat;
+	//F32 last_weight = F32_MAX;
+	LLMatrix4a gBlendMat;
+
+	__restrict const F32* weights = mMesh->getWeights();
+	__restrict const LLVector4* coords = mMesh->getCoords();
+	__restrict const LLVector4* normals = mMesh->getNormals();
 
-	const F32* weights = mMesh->getWeights();
-	const LLVector3* coords = mMesh->getCoords();
-	const LLVector3* normals = mMesh->getNormals();
 	for (U32 index = 0; index < mMesh->getNumVertices(); index++)
 	{
 		U32 bidx = index + mMesh->mFaceVertexOffset;
@@ -826,71 +838,54 @@ void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh)
 		// blend by first matrix
 		F32 w = weights[index]; 
 		
+		LLVector4a coord;
+		coord.load4a(coords[index].mV);
+
+		LLVector4a norm;
+		norm.load4a(normals[index].mV);
+
 		// Maybe we don't have to change gBlendMat.
 		// Profiles of a single-avatar scene on a Mac show this to be a very
 		// common case.  JC
-		if (w == last_weight)
+		//if (w != last_weight)
 		{
-			o_vertices[bidx] = coords[index] * gBlendMat;
-			o_normals[bidx] = normals[index] * gBlendRotMat;
-			continue;
-		}
-		
-		last_weight = w;
+			//last_weight = w;
 
-		S32 joint = llfloor(w);
-		w -= joint;
-		
-		// No lerp required in this case.
-		if (w == 1.0f)
-		{
-			gBlendMat = gJointMatUnaligned[joint+1];
-			o_vertices[bidx] = coords[index] * gBlendMat;
-			gBlendRotMat = gJointRotUnaligned[joint+1];
-			o_normals[bidx] = normals[index] * gBlendRotMat;
-			continue;
+			S32 joint = llfloor(w);
+			w -= joint;
+				
+			
+			if (w >= 0.f)
+			{
+				// Try to keep all the accesses to the matrix data as close
+				// together as possible.  This function is a hot spot on the
+				// Mac. JC
+				gBlendMat.setLerp(gJointMatAligned[joint+0],
+								  gJointMatAligned[joint+1], w);
+
+				LLVector4a res;
+				gBlendMat.affineTransform(coord, res);
+				o_vertices[bidx].setVec(res[0], res[1], res[2]);
+				gBlendMat.rotate(norm, res);
+				o_normals[bidx].setVec(res[0], res[1], res[2]);
+			}
+			else
+			{  // No lerp required in this case.
+				LLVector4a res;
+				gJointMatAligned[joint].affineTransform(coord, res);
+				o_vertices[bidx].setVec(res[0], res[1], res[2]);
+				gJointMatAligned[joint].rotate(norm, res);
+				o_normals[bidx].setVec(res[0], res[1], res[2]);
+			}
 		}
-		
-		// Try to keep all the accesses to the matrix data as close
-		// together as possible.  This function is a hot spot on the
-		// Mac. JC
-		LLMatrix4 &m0 = gJointMatUnaligned[joint+1];
-		LLMatrix4 &m1 = gJointMatUnaligned[joint+0];
-		
-		gBlendMat.mMatrix[VX][VX] = lerp(m1.mMatrix[VX][VX], m0.mMatrix[VX][VX], w);
-		gBlendMat.mMatrix[VX][VY] = lerp(m1.mMatrix[VX][VY], m0.mMatrix[VX][VY], w);
-		gBlendMat.mMatrix[VX][VZ] = lerp(m1.mMatrix[VX][VZ], m0.mMatrix[VX][VZ], w);
-
-		gBlendMat.mMatrix[VY][VX] = lerp(m1.mMatrix[VY][VX], m0.mMatrix[VY][VX], w);
-		gBlendMat.mMatrix[VY][VY] = lerp(m1.mMatrix[VY][VY], m0.mMatrix[VY][VY], w);
-		gBlendMat.mMatrix[VY][VZ] = lerp(m1.mMatrix[VY][VZ], m0.mMatrix[VY][VZ], w);
-
-		gBlendMat.mMatrix[VZ][VX] = lerp(m1.mMatrix[VZ][VX], m0.mMatrix[VZ][VX], w);
-		gBlendMat.mMatrix[VZ][VY] = lerp(m1.mMatrix[VZ][VY], m0.mMatrix[VZ][VY], w);
-		gBlendMat.mMatrix[VZ][VZ] = lerp(m1.mMatrix[VZ][VZ], m0.mMatrix[VZ][VZ], w);
-
-		gBlendMat.mMatrix[VW][VX] = lerp(m1.mMatrix[VW][VX], m0.mMatrix[VW][VX], w);
-		gBlendMat.mMatrix[VW][VY] = lerp(m1.mMatrix[VW][VY], m0.mMatrix[VW][VY], w);
-		gBlendMat.mMatrix[VW][VZ] = lerp(m1.mMatrix[VW][VZ], m0.mMatrix[VW][VZ], w);
-
-		o_vertices[bidx] = coords[index] * gBlendMat;
-		
-		LLMatrix3 &n0 = gJointRotUnaligned[joint+1];
-		LLMatrix3 &n1 = gJointRotUnaligned[joint+0];
-		
-		gBlendRotMat.mMatrix[VX][VX] = lerp(n1.mMatrix[VX][VX], n0.mMatrix[VX][VX], w);
-		gBlendRotMat.mMatrix[VX][VY] = lerp(n1.mMatrix[VX][VY], n0.mMatrix[VX][VY], w);
-		gBlendRotMat.mMatrix[VX][VZ] = lerp(n1.mMatrix[VX][VZ], n0.mMatrix[VX][VZ], w);
-
-		gBlendRotMat.mMatrix[VY][VX] = lerp(n1.mMatrix[VY][VX], n0.mMatrix[VY][VX], w);
-		gBlendRotMat.mMatrix[VY][VY] = lerp(n1.mMatrix[VY][VY], n0.mMatrix[VY][VY], w);
-		gBlendRotMat.mMatrix[VY][VZ] = lerp(n1.mMatrix[VY][VZ], n0.mMatrix[VY][VZ], w);
-
-		gBlendRotMat.mMatrix[VZ][VX] = lerp(n1.mMatrix[VZ][VX], n0.mMatrix[VZ][VX], w);
-		gBlendRotMat.mMatrix[VZ][VY] = lerp(n1.mMatrix[VZ][VY], n0.mMatrix[VZ][VY], w);
-		gBlendRotMat.mMatrix[VZ][VZ] = lerp(n1.mMatrix[VZ][VZ], n0.mMatrix[VZ][VZ], w);
-		
-		o_normals[bidx] = normals[index] * gBlendRotMat;
+		/*else
+		{ //weight didn't change
+			LLVector4a res;
+			gBlendMat.affineTransform(coord, res);
+			o_vertices[bidx].setVec(res[0], res[1], res[2]);
+			gBlendMat.rotate(norm, res);
+			o_normals[bidx].setVec(res[0], res[1], res[2]);
+		}*/
 	}
 
 	buffer->setBuffer(0);
diff --git a/indra/newview/llviewerjointmesh_vec.cpp b/indra/newview/llviewerjointmesh_vec.cpp
index 8fb9d1cf68f..a1225c9d1c9 100644
--- a/indra/newview/llviewerjointmesh_vec.cpp
+++ b/indra/newview/llviewerjointmesh_vec.cpp
@@ -52,6 +52,7 @@
 // static
 void LLViewerJointMesh::updateGeometryVectorized(LLFace *face, LLPolyMesh *mesh)
 {
+#if 0
 	static LLV4Matrix4	sJointMat[32];
 	LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData;
 	S32 j, joint_num, joint_end = joint_data.count();
@@ -98,4 +99,5 @@ void LLViewerJointMesh::updateGeometryVectorized(LLFace *face, LLPolyMesh *mesh)
 	}
 
 	buffer->setBuffer(0);
+#endif
 }
-- 
GitLab


From bf5f215fbc29102cfd8b5418f29ea0ed6edd14ee Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 20 May 2010 02:46:01 -0500
Subject: [PATCH 426/683] Cleanup from review.

---
 indra/newview/llviewerjointmesh.cpp | 69 +++++++++++------------------
 1 file changed, 26 insertions(+), 43 deletions(-)

diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 294dfdcb555..236ad98d686 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -827,9 +827,9 @@ void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh)
 	//F32 last_weight = F32_MAX;
 	LLMatrix4a gBlendMat;
 
-	__restrict const F32* weights = mMesh->getWeights();
-	__restrict const LLVector4* coords = mMesh->getCoords();
-	__restrict const LLVector4* normals = mMesh->getNormals();
+	const F32* __restrict weights = mMesh->getWeights();
+	const LLVector4a* __restrict coords = (LLVector4a*) mMesh->getCoords();
+	const LLVector4a* __restrict normals = (LLVector4a*) mMesh->getNormals();
 
 	for (U32 index = 0; index < mMesh->getNumVertices(); index++)
 	{
@@ -838,54 +838,37 @@ void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh)
 		// blend by first matrix
 		F32 w = weights[index]; 
 		
-		LLVector4a coord;
-		coord.load4a(coords[index].mV);
+		//LLVector4a coord;
+		//coord.load4a(coords[index].mV);
 
-		LLVector4a norm;
-		norm.load4a(normals[index].mV);
+		//LLVector4a norm;
+		//norm.load4a(normals[index].mV);
 
-		// Maybe we don't have to change gBlendMat.
-		// Profiles of a single-avatar scene on a Mac show this to be a very
-		// common case.  JC
-		//if (w != last_weight)
+		S32 joint = llfloor(w);
+		w -= joint;
+				
+		if (w > 0.f)
 		{
-			//last_weight = w;
+			// Try to keep all the accesses to the matrix data as close
+			// together as possible.  This function is a hot spot on the
+			// Mac. JC
+			gBlendMat.setLerp(gJointMatAligned[joint+0],
+							  gJointMatAligned[joint+1], w);
 
-			S32 joint = llfloor(w);
-			w -= joint;
-				
-			
-			if (w >= 0.f)
-			{
-				// Try to keep all the accesses to the matrix data as close
-				// together as possible.  This function is a hot spot on the
-				// Mac. JC
-				gBlendMat.setLerp(gJointMatAligned[joint+0],
-								  gJointMatAligned[joint+1], w);
-
-				LLVector4a res;
-				gBlendMat.affineTransform(coord, res);
-				o_vertices[bidx].setVec(res[0], res[1], res[2]);
-				gBlendMat.rotate(norm, res);
-				o_normals[bidx].setVec(res[0], res[1], res[2]);
-			}
-			else
-			{  // No lerp required in this case.
-				LLVector4a res;
-				gJointMatAligned[joint].affineTransform(coord, res);
-				o_vertices[bidx].setVec(res[0], res[1], res[2]);
-				gJointMatAligned[joint].rotate(norm, res);
-				o_normals[bidx].setVec(res[0], res[1], res[2]);
-			}
+			LLVector4a res;
+			gBlendMat.affineTransform(coords[index], res);
+			o_vertices[bidx].setVec(res[0], res[1], res[2]);
+			gBlendMat.rotate(normals[index], res);
+			o_normals[bidx].setVec(res[0], res[1], res[2]);
 		}
-		/*else
-		{ //weight didn't change
+		else
+		{  // No lerp required in this case.
 			LLVector4a res;
-			gBlendMat.affineTransform(coord, res);
+			gJointMatAligned[joint].affineTransform(coords[index], res);
 			o_vertices[bidx].setVec(res[0], res[1], res[2]);
-			gBlendMat.rotate(norm, res);
+			gJointMatAligned[joint].rotate(normals[index], res);
 			o_normals[bidx].setVec(res[0], res[1], res[2]);
-		}*/
+		}
 	}
 
 	buffer->setBuffer(0);
-- 
GitLab


From 05a23f8dbaa45c64bcf6c55dd09a468ba2b1f144 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 21 May 2010 04:49:12 -0500
Subject: [PATCH 427/683] Vectorized memcpy. 16-byte aligned vertex buffers.
 (almost) fully vectorized avatar vertex buffer updating --- index buffers
 still need to be vectorized

---
 indra/llrender/llvertexbuffer.cpp   | 195 +++++++++++++++++++++++++++-
 indra/llrender/llvertexbuffer.h     |   7 +-
 indra/newview/lldrawpoolavatar.cpp  |   4 +-
 indra/newview/llpolymesh.cpp        |  25 ++--
 indra/newview/llviewerjointmesh.cpp | 169 +++++++++---------------
 5 files changed, 273 insertions(+), 127 deletions(-)

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 7fa47cd171b..a50eb7211cf 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -39,6 +39,7 @@
 #include "llglheaders.h"
 #include "llmemtype.h"
 #include "llrender.h"
+#include "llvector4a.h"
 
 //============================================================================
 
@@ -66,6 +67,27 @@ S32	LLVertexBuffer::sWeight4Loc = -1;
 
 std::vector<U32> LLVertexBuffer::sDeleteList;
 
+#define LL_ALIGNED_VB 1
+
+#if LL_ALIGNED_VB
+
+S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
+{
+	sizeof(LLVector4), // TYPE_VERTEX,
+	sizeof(LLVector4), // TYPE_NORMAL,
+	sizeof(LLVector2), // TYPE_TEXCOORD0,
+	sizeof(LLVector2), // TYPE_TEXCOORD1,
+	sizeof(LLVector2), // TYPE_TEXCOORD2,
+	sizeof(LLVector2), // TYPE_TEXCOORD3,
+	sizeof(LLColor4U), // TYPE_COLOR,
+	sizeof(LLVector4), // TYPE_BINORMAL,
+	sizeof(F32),	   // TYPE_WEIGHT,
+	sizeof(LLVector4), // TYPE_WEIGHT4,
+	sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
+};
+
+#else
+
 S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
 {
 	sizeof(LLVector3), // TYPE_VERTEX,
@@ -81,6 +103,8 @@ S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
 	sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
 };
 
+#endif
+
 U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = 
 {
 	GL_TRIANGLES,
@@ -428,11 +452,41 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
 
 	mTypeMask = typemask;
 	mStride = stride;
+	mAlignedOffset = 0;
+
 	sCount++;
 }
 
+#if LL_ALIGNED_VB
+//static
+S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets, S32 num_vertices)
+{
+	S32 offset = 0;
+	for (S32 i=0; i<TYPE_MAX; i++)
+	{
+		U32 mask = 1<<i;
+		if (typemask & mask)
+		{
+			if (offsets)
+			{
+				offsets[i] = offset;
+				offset += LLVertexBuffer::sTypeOffsets[i]*num_vertices;
+				offset = (offset + 0xF) & ~0xF;
+			}
+		}
+	}
+
+	return offset+16;
+}
+
+S32 LLVertexBuffer::getSize() const
+{
+	return mStride;
+}
+
+#else
 //static
-S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets)
+S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets, S32 num_vertices)
 {
 	S32 stride = 0;
 	for (S32 i=0; i<TYPE_MAX; i++)
@@ -451,6 +505,12 @@ S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets)
 	return stride;
 }
 
+S32 LLVertexBuffer::getSize() const
+{ 
+	return mNumVerts*mStride; 
+}
+
+#endif
 // protected, use unref()
 //virtual
 LLVertexBuffer::~LLVertexBuffer()
@@ -560,7 +620,7 @@ void LLVertexBuffer::createGLBuffer()
 	{
 		static int gl_buffer_idx = 0;
 		mGLBuffer = ++gl_buffer_idx;
-		mMappedData = new U8[size];
+		mMappedData = (U8*) _mm_malloc(size, 16);
 		memset(mMappedData, 0, size);
 	}
 }
@@ -612,7 +672,7 @@ void LLVertexBuffer::destroyGLBuffer()
 		}
 		else
 		{
-			delete [] mMappedData;
+			_mm_free(mMappedData);
 			mMappedData = NULL;
 			mEmpty = TRUE;
 		}
@@ -664,7 +724,7 @@ void LLVertexBuffer::updateNumVerts(S32 nverts)
 	}
 
 	mRequestedNumVerts = nverts;
-	
+
 	if (!mDynamicSize)
 	{
 		mNumVerts = nverts;
@@ -679,6 +739,9 @@ void LLVertexBuffer::updateNumVerts(S32 nverts)
 		}
 		mNumVerts = nverts;
 	}
+#if LL_ALIGNED_VB
+	mStride = calcStride(mTypeMask, mOffsets, mNumVerts);
+#endif
 
 }
 
@@ -886,7 +949,11 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
 			setBuffer(0);
 			mLocked = TRUE;
 			stop_glerror();	
-			mMappedData = (U8*) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+
+			U8* src = (U8*) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+			mMappedData = LL_NEXT_ALIGNED_ADDRESS<U8>(src);
+			mAlignedOffset = mMappedData - src;
+			
 			stop_glerror();
 		}
 		{
@@ -975,6 +1042,45 @@ void LLVertexBuffer::unmapBuffer()
 
 //----------------------------------------------------------------------------
 
+#if LL_ALIGNED_VB
+
+template <class T,S32 type> struct VertexBufferStrider
+{
+	typedef LLStrider<T> strider_t;
+	static bool get(LLVertexBuffer& vbo, 
+					strider_t& strider, 
+					S32 index)
+	{
+		if (vbo.mapBuffer() == NULL)
+		{
+			llwarns << "mapBuffer failed!" << llendl;
+			return FALSE;
+		}
+
+		if (type == LLVertexBuffer::TYPE_INDEX)
+		{
+			S32 stride = sizeof(T);
+			strider = (T*)(vbo.getMappedIndices() + index*stride);
+			strider.setStride(0);
+			return TRUE;
+		}
+		else if (vbo.hasDataType(type))
+		{
+			S32 stride = LLVertexBuffer::sTypeOffsets[type];
+			strider = (T*)(vbo.getMappedData() + vbo.getOffset(type)+index*stride);
+			strider.setStride(stride);
+			return TRUE;
+		}
+		else
+		{
+			llerrs << "VertexBufferStrider could not find valid vertex data." << llendl;
+		}
+		return FALSE;
+	}
+};
+
+#else
+
 template <class T,S32 type> struct VertexBufferStrider
 {
 	typedef LLStrider<T> strider_t;
@@ -1010,6 +1116,7 @@ template <class T,S32 type> struct VertexBufferStrider
 	}
 };
 
+#endif
 
 bool LLVertexBuffer::getVertexStrider(LLStrider<LLVector3>& strider, S32 index)
 {
@@ -1272,6 +1379,82 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 	}
 }
 
+#if LL_ALIGNED_VB
+
+// virtual (default)
+void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
+{
+	LLMemType mt2(LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER);
+	stop_glerror();
+	U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData;
+
+	if ((data_mask & mTypeMask) != data_mask)
+	{
+		llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl;
+	}
+
+
+	if (data_mask & MAP_NORMAL)
+	{
+		glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
+	}
+	if (data_mask & MAP_TEXCOORD3)
+	{
+		glClientActiveTextureARB(GL_TEXTURE3_ARB);
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD3], (void*)(base + mOffsets[TYPE_TEXCOORD3]));
+		glClientActiveTextureARB(GL_TEXTURE0_ARB);
+	}
+	if (data_mask & MAP_TEXCOORD2)
+	{
+		glClientActiveTextureARB(GL_TEXTURE2_ARB);
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD2], (void*)(base + mOffsets[TYPE_TEXCOORD2]));
+		glClientActiveTextureARB(GL_TEXTURE0_ARB);
+	}
+	if (data_mask & MAP_TEXCOORD1)
+	{
+		glClientActiveTextureARB(GL_TEXTURE1_ARB);
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
+		glClientActiveTextureARB(GL_TEXTURE0_ARB);
+	}
+	if (data_mask & MAP_BINORMAL)
+	{
+		glClientActiveTextureARB(GL_TEXTURE2_ARB);
+		glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
+		glClientActiveTextureARB(GL_TEXTURE0_ARB);
+	}
+	if (data_mask & MAP_TEXCOORD0)
+	{
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+	}
+	if (data_mask & MAP_COLOR)
+	{
+		glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeOffsets[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
+	}
+	
+	if (data_mask & MAP_WEIGHT)
+	{
+		glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeOffsets[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT]));
+	}
+
+	if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
+	{
+		glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeOffsets[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4]));
+	}
+
+	if (data_mask & MAP_CLOTHWEIGHT)
+	{
+		glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  LLVertexBuffer::sTypeOffsets[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
+	}
+	if (data_mask & MAP_VERTEX)
+	{
+		glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_VERTEX], (void*)(base + 0));
+	}
+
+	llglassertok();
+}
+
+#else
+
 // virtual (default)
 void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
 {
@@ -1344,6 +1527,8 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
 	llglassertok();
 }
 
+#endif
+
 void LLVertexBuffer::markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count)
 {
 	// TODO: use GL_APPLE_flush_buffer_range here
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index d1700aa54ab..03799af9789 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -98,7 +98,7 @@ class LLVertexBuffer : public LLRefCount
 	//if offsets is not NULL, its contents will be filled
 	//with the offset of each vertex component in the buffer, 
 	// indexed by the following enum
-	static S32 calcStride(const U32& typemask, S32* offsets = NULL); 										
+	static S32 calcStride(const U32& typemask, S32* offsets = NULL, S32 num_vertices = 0); 										
 
 	enum {
 		TYPE_VERTEX,
@@ -192,7 +192,7 @@ class LLVertexBuffer : public LLRefCount
 	S32 getStride() const					{ return mStride; }
 	U32 getTypeMask() const					{ return mTypeMask; }
 	BOOL hasDataType(S32 type) const		{ return ((1 << type) & getTypeMask()) ? TRUE : FALSE; }
-	S32 getSize() const						{ return mNumVerts*mStride; }
+	S32 getSize() const;
 	S32 getIndicesSize() const				{ return mNumIndices * sizeof(U16); }
 	U8* getMappedData() const				{ return mMappedData; }
 	U8* getMappedIndices() const			{ return mMappedIndexData; }
@@ -213,6 +213,7 @@ class LLVertexBuffer : public LLRefCount
 	S32		mRequestedNumVerts;  // Number of vertices requested
 	S32		mRequestedNumIndices;  // Number of indices requested
 
+	ptrdiff_t mAlignedOffset;
 	S32		mStride;
 	U32		mTypeMask;
 	S32		mUsage;			// GL usage
@@ -227,7 +228,7 @@ class LLVertexBuffer : public LLRefCount
 	S32		mOffsets[TYPE_MAX];
 	BOOL	mResized;		// if TRUE, client buffer has been resized and GL buffer has not
 	BOOL	mDynamicSize;	// if TRUE, buffer has been resized at least once (and should be padded)
-
+	
 	class DirtyRegion
 	{
 	public:
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index d1f4be71f55..1e9053239d1 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1542,7 +1542,7 @@ LLVertexBufferAvatar::LLVertexBufferAvatar()
 
 void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
 {
-	if (sRenderingSkinned)
+/*	if (sRenderingSkinned)
 	{
 		U8* base = useVBOs() ? NULL : mMappedData;
 
@@ -1562,7 +1562,7 @@ void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
 			set_vertex_clothing_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
 		}
 	}
-	else
+	else*/
 	{
 		LLVertexBuffer::setupVertexBuffer(data_mask);
 	}
diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp
index b8bdbfb2f81..98c01913974 100644
--- a/indra/newview/llpolymesh.cpp
+++ b/indra/newview/llpolymesh.cpp
@@ -140,7 +140,7 @@ void LLPolyMeshSharedData::freeMeshData()
 		delete [] mDetailTexCoords;
 		mDetailTexCoords = NULL;
 
-		delete [] mWeights;
+		_mm_free(mWeights);
 		mWeights = NULL;
 	}
 
@@ -230,7 +230,7 @@ BOOL LLPolyMeshSharedData::allocateVertexData( U32 numVertices )
 	mBaseBinormals = new LLVector3[ numVertices ];
 	mTexCoords = new LLVector2[ numVertices ];
 	mDetailTexCoords = new LLVector2[ numVertices ];
-	mWeights = new F32[ numVertices ];
+	mWeights = (F32*) _mm_malloc((numVertices*sizeof(F32)+0xF) & ~0xF, 16);
 	for (i = 0; i < numVertices; i++)
 	{
 		mWeights[i] = 0.f;
@@ -717,13 +717,20 @@ LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_
 		//use aligned vertex data to make LLPolyMesh SSE friendly
 		mVertexData = (F32*) _mm_malloc(nfloats*4, 16);
 		int offset = 0;
-		mCoords = 				(LLVector4*)(mVertexData + offset); offset += 4*nverts;
-		mNormals = 				(LLVector4*)(mVertexData + offset); offset += 4*nverts;
-		mScaledNormals = 		(LLVector3*)(mVertexData + offset); offset += 3*nverts;
-		mBinormals = 			(LLVector3*)(mVertexData + offset); offset += 3*nverts;
-		mScaledBinormals = 		(LLVector3*)(mVertexData + offset); offset += 3*nverts;
-		mTexCoords = 			(LLVector2*)(mVertexData + offset); offset += 2*nverts;
-		mClothingWeights = 	(LLVector4*)(mVertexData + offset); offset += 4*nverts;
+
+		//all members must be 16-byte aligned except the last 3
+		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;
+		
+		
 #else
 		mCoords = new LLVector3[mSharedData->mNumVertices];
 		mNormals = new LLVector3[mSharedData->mNumVertices];
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 236ad98d686..a7e7bfadd69 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -655,6 +655,9 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
 //-----------------------------------------------------------------------------
 void LLViewerJointMesh::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area)
 {
+	//bump num_vertices to next multiple of 4
+	num_vertices = (num_vertices + 0x3) & ~0x3;
+
 	// Do a pre-alloc pass to determine sizes of data.
 	if (mMesh && mValid)
 	{
@@ -677,6 +680,8 @@ static LLFastTimer::DeclareTimer FTM_AVATAR_FACE("Avatar Face");
 
 void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
 {
+	//IF THIS FUNCTION BREAKS, SEE LLPOLYMESH CONSTRUCTOR AND CHECK ALIGNMENT OF INPUT ARRAYS
+
 	mFace = face;
 
 	if (mFace->mVertexBuffer.isNull())
@@ -684,6 +689,16 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 		return;
 	}
 
+	LLDrawPool *poolp = mFace->getPool();
+	BOOL hardware_skinning = (poolp && poolp->getVertexShaderLevel() > 0) ? TRUE : FALSE;
+
+	if (!hardware_skinning && terse_update)
+	{ //no need to do terse updates if we're doing software vertex skinning
+	 // since mMesh is being copied into mVertexBuffer every frame
+		return;
+	}
+
+
 	LLFastTimer t(FTM_AVATAR_FACE);
 
 	LLStrider<LLVector3> verticesp;
@@ -696,108 +711,52 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 	// Copy data into the faces from the polymesh data.
 	if (mMesh && mValid)
 	{
-		if (mMesh->getNumVertices())
+		const U32 num_verts = mMesh->getNumVertices();
+
+		if (num_verts)
 		{
-			stop_glerror();
 			face->getGeometryAvatar(verticesp, normalsp, tex_coordsp, vertex_weightsp, clothing_weightsp);
-			stop_glerror();
 			face->mVertexBuffer->getIndexStrider(indicesp);
-			stop_glerror();
 
 			verticesp += mMesh->mFaceVertexOffset;
-			tex_coordsp += mMesh->mFaceVertexOffset;
 			normalsp += mMesh->mFaceVertexOffset;
-			vertex_weightsp += mMesh->mFaceVertexOffset;
-			clothing_weightsp += mMesh->mFaceVertexOffset;
-
-			const U32* __restrict coords = (U32*) mMesh->getCoords();
-			const U32* __restrict tex_coords = (U32*) mMesh->getTexCoords();
-			const U32* __restrict normals = (U32*) mMesh->getNormals();
-			const U32* __restrict weights = (U32*) mMesh->getWeights();
-			const U32* __restrict cloth_weights = (U32*) mMesh->getClothingWeights();
-
-			const U32 num_verts = mMesh->getNumVertices();
-
-			U32 i = 0;
-
-			const U32 skip = verticesp.getSkip()/sizeof(U32);
+			
+			F32* v = (F32*) verticesp.get();
+			F32* n = (F32*) normalsp.get();
+			
+			U32 words = num_verts*4;
 
-			U32* __restrict v = (U32*) verticesp.get();
-			U32* __restrict n = (U32*) normalsp.get();
+			LLVector4a::memcpyNonAliased16(v, (F32*) mMesh->getCoords(), words);
+			LLVector4a::memcpyNonAliased16(n, (F32*) mMesh->getNormals(), words);
+						
 			
-			if (terse_update)
+			if (!terse_update)
 			{
-				for (S32 i = num_verts; i > 0; --i)
-				{
-					//morph target application only, only update positions and normals
-					v[0] = coords[0]; 
-					v[1] = coords[1]; 
-					v[2] = coords[2];		
-					coords += 4;
-					v += skip;
-				}
+				vertex_weightsp += mMesh->mFaceVertexOffset;
+				clothing_weightsp += mMesh->mFaceVertexOffset;
+				tex_coordsp += mMesh->mFaceVertexOffset;
+		
+				F32* tc = (F32*) tex_coordsp.get();
+				F32* vw = (F32*) vertex_weightsp.get();
+				F32* cw = (F32*) clothing_weightsp.get();	
 
-				for (S32 i = num_verts; i > 0; --i)
-				{
-					n[0] = normals[0]; 
-					n[1] = normals[1];
-					n[2] = normals[2];
-					normals += 4;
-					n += skip;
-				}
+				LLVector4a::memcpyNonAliased16(tc, (F32*) mMesh->getTexCoords(), num_verts*2);
+				LLVector4a::memcpyNonAliased16(vw, (F32*) mMesh->getWeights(), num_verts);	
+				LLVector4a::memcpyNonAliased16(cw, (F32*) mMesh->getClothingWeights(), num_verts*4);	
 			}
-			else
-			{
-
-				U32* __restrict tc = (U32*) tex_coordsp.get();
-				U32* __restrict vw = (U32*) vertex_weightsp.get();
-				U32* __restrict cw = (U32*) clothing_weightsp.get();
-				
-				do
-				{
-					v[0] = coords[0]; 
-					v[1] = coords[1]; 
-					v[2] = coords[2];		
-					coords += 4;
-					v += skip;
-
-					tc[0] = *(tex_coords++); 
-					tc[1] = *(tex_coords++);
-					tc += skip;
-
-					n[0] = normals[0]; 
-					n[1] = normals[1];
-					n[2] = normals[2];
-					normals += 4;
-					n += skip;
-
-					vw[0] = *(weights++);
-					vw += skip;
-
-					cw[0] = *(cloth_weights++);
-					cw[1] = *(cloth_weights++);
-					cw[2] = *(cloth_weights++);
-					cw[3] = *(cloth_weights++);
-					cw += skip;
-				}
-				while (++i < num_verts);
-
-				const U32 idx_count = mMesh->getNumFaces()*3;
 
-				indicesp += mMesh->mFaceIndexOffset;
+			const U32 idx_count = mMesh->getNumFaces()*3;
 
-				U16* __restrict idx = indicesp.get();
-				S32* __restrict src_idx = (S32*) mMesh->getFaces();
+			indicesp += mMesh->mFaceIndexOffset;
 
-				i = 0;
+			U16* __restrict idx = indicesp.get();
+			S32* __restrict src_idx = (S32*) mMesh->getFaces();	
 
-				const S32 offset = (S32) mMesh->mFaceVertexOffset;
+			const S32 offset = (S32) mMesh->mFaceVertexOffset;
 
-				do
-				{
-					*(idx++) = *(src_idx++)+offset;
-				}
-				while (++i < idx_count);
+			for (S32 i = 0; i < idx_count; ++i)
+			{
+				*(idx++) = *(src_idx++)+offset;
 			}
 		}
 	}
@@ -824,50 +783,44 @@ void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh)
 	buffer->getVertexStrider(o_vertices,  0);
 	buffer->getNormalStrider(o_normals,   0);
 
-	//F32 last_weight = F32_MAX;
-	LLMatrix4a gBlendMat;
+	F32* __restrict vert = o_vertices[0].mV;
+	F32* __restrict norm = o_normals[0].mV;
 
 	const F32* __restrict weights = mMesh->getWeights();
 	const LLVector4a* __restrict coords = (LLVector4a*) mMesh->getCoords();
 	const LLVector4a* __restrict normals = (LLVector4a*) mMesh->getNormals();
 
+	U32 offset = mMesh->mFaceVertexOffset*4;
+	vert += offset;
+	norm += offset;
+
 	for (U32 index = 0; index < mMesh->getNumVertices(); index++)
 	{
-		U32 bidx = index + mMesh->mFaceVertexOffset;
-		
-		// blend by first matrix
-		F32 w = weights[index]; 
-		
-		//LLVector4a coord;
-		//coord.load4a(coords[index].mV);
+		// equivalent to joint = floorf(weights[index]);
+		S32 joint = _mm_cvtt_ss2si(_mm_load_ss(weights+index));
+		F32 w = weights[index] - joint;		
 
-		//LLVector4a norm;
-		//norm.load4a(normals[index].mV);
+		LLMatrix4a gBlendMat;
 
-		S32 joint = llfloor(w);
-		w -= joint;
-				
-		if (w > 0.f)
+		if (w != 0.f)
 		{
-			// Try to keep all the accesses to the matrix data as close
-			// together as possible.  This function is a hot spot on the
-			// Mac. JC
+			// blend between matrices and apply
 			gBlendMat.setLerp(gJointMatAligned[joint+0],
 							  gJointMatAligned[joint+1], w);
 
 			LLVector4a res;
 			gBlendMat.affineTransform(coords[index], res);
-			o_vertices[bidx].setVec(res[0], res[1], res[2]);
+			res.store4a(vert+index*4);
 			gBlendMat.rotate(normals[index], res);
-			o_normals[bidx].setVec(res[0], res[1], res[2]);
+			res.store4a(norm+index*4);
 		}
 		else
 		{  // No lerp required in this case.
 			LLVector4a res;
 			gJointMatAligned[joint].affineTransform(coords[index], res);
-			o_vertices[bidx].setVec(res[0], res[1], res[2]);
+			res.store4a(vert+index*4);
 			gJointMatAligned[joint].rotate(normals[index], res);
-			o_normals[bidx].setVec(res[0], res[1], res[2]);
+			res.store4a(norm+index*4);
 		}
 	}
 
-- 
GitLab


From cd13bc0e044d5014a0d7e131ae9d47924e376997 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 21 May 2010 11:52:00 +0100
Subject: [PATCH 428/683] if we're serious about the SSE thing then we should
 add these compiler flags for linux.  though it's not quite enough, still.

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

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 113e21a7155..2cc8fa5e5fb 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -169,6 +169,7 @@ if (LINUX)
     add_definitions(-fvisibility=hidden)
     # don't catch SIGCHLD in our base application class for the viewer - some of our 3rd party libs may need their *own* SIGCHLD handler to work.  Sigh!  The viewer doesn't need to catch SIGCHLD anyway.
     add_definitions(-DLL_IGNORE_SIGCHLD)
+    add_definitions(-march=pentium3 -mfpmath=sse -ftree-vectorize)
     if (NOT STANDALONE)
       # this stops us requiring a really recent glibc at runtime
       add_definitions(-fno-stack-protector)
-- 
GitLab


From ab31e3bb217089e0cc28ca57bb5c4e46c06789dd Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 21 May 2010 15:11:16 +0100
Subject: [PATCH 429/683] Fix up the SSE stuff so it compiles on Linux.  Though
 I don't think it actually works properly.

---
 indra/llcommon/llmemory.cpp              | 19 ---------------
 indra/llcommon/llmemory.h                | 31 +++++++++++++++++++-----
 indra/newview/llpolymesh.cpp             |  9 ++++---
 indra/newview/llviewerjointmesh_sse.cpp  |  4 +--
 indra/newview/llviewerjointmesh_sse2.cpp |  4 +--
 5 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 2a8015e26d9..5c6ca30cdd0 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -73,25 +73,6 @@ void LLMemory::freeReserve()
 	reserveMem = NULL;
 }
 
-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;
-}
-
-void ll_release (void *p)
-{
-	free(p);
-}
 
 //----------------------------------------------------------------------------
 
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 1c6f64dd8bc..f0813fb4ee3 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -32,14 +32,33 @@
 #ifndef LLMEMORY_H
 #define LLMEMORY_H
 
+#include <stdlib.h>
 
+inline void* ll_aligned_malloc(size_t size, size_t alignment = 16) // alignment MUST be power-of-two multiple of sizeof(void*).   returned hunk MUST be freed with ll_aligned_free().
+{
+#if defined(LL_WINDOWS)
+	return _mm_malloc(size, alignment);
+#else
+	void *rtn;
+	if (LL_LIKELY(0 == posix_memalign(&rtn, alignment, size)))
+	{
+		return rtn;
+	}
+	else // bad alignment requested, or out of memory
+	{
+		return NULL;
+	}
+#endif
+}
 
-extern S32 gTotalDAlloc;
-extern S32 gTotalDAUse;
-extern S32 gDACount;
-
-extern void* ll_allocate (size_t size);
-extern void ll_release (void *p);
+inline void ll_aligned_free(void *p)
+{
+#if defined(LL_WINDOWS)
+	_mm_free(p);
+#else
+	free(p); // posix_memalign() is compatible with heap deallocator
+#endif
+}
 
 class LL_COMMON_API LLMemory
 {
diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp
index b8bdbfb2f81..af3c3e2b169 100644
--- a/indra/newview/llpolymesh.cpp
+++ b/indra/newview/llpolymesh.cpp
@@ -35,7 +35,8 @@
 //-----------------------------------------------------------------------------
 #include "llviewerprecompiledheaders.h"
 
-#include "llpolymesh.h"
+#include "llfasttimer.h"
+#include "llmemory.h"
 
 #include "llviewercontrol.h"
 #include "llxmltree.h"
@@ -45,7 +46,7 @@
 #include "llvolume.h"
 #include "llendianswizzle.h"
 
-#include "llfasttimer.h"
+#include "llpolymesh.h"
 
 #define HEADER_ASCII "Linden Mesh 1.0"
 #define HEADER_BINARY "Linden Binary Mesh 1.0"
@@ -715,7 +716,7 @@ LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_
 		int nfloats = nverts * (2*4 + 3*3 + 2 + 4);
 
 		//use aligned vertex data to make LLPolyMesh SSE friendly
-		mVertexData = (F32*) _mm_malloc(nfloats*4, 16);
+		mVertexData = (F32*) ll_aligned_malloc(nfloats*4, 16);
 		int offset = 0;
 		mCoords = 				(LLVector4*)(mVertexData + offset); offset += 4*nverts;
 		mNormals = 				(LLVector4*)(mVertexData + offset); offset += 4*nverts;
@@ -759,7 +760,7 @@ LLPolyMesh::~LLPolyMesh()
 	delete [] mClothingWeights;
 	delete [] mTexCoords;
 #else
-	_mm_free(mVertexData);
+	ll_aligned_free(mVertexData);
 #endif
 }
 
diff --git a/indra/newview/llviewerjointmesh_sse.cpp b/indra/newview/llviewerjointmesh_sse.cpp
index e586b910cd4..4fb5fafad12 100644
--- a/indra/newview/llviewerjointmesh_sse.cpp
+++ b/indra/newview/llviewerjointmesh_sse.cpp
@@ -94,8 +94,8 @@ void LLViewerJointMesh::updateGeometrySSE(LLFace *face, LLPolyMesh *mesh)
 	buffer->getNormalStrider(o_normals,   mesh->mFaceVertexOffset);
 
 	const F32*			weights			= mesh->getWeights();
-	const LLVector3*	coords			= mesh->getCoords();
-	const LLVector3*	normals			= mesh->getNormals();
+	const LLVector3*	coords			= (const LLVector3*)mesh->getCoords();
+	const LLVector3*	normals			= (const LLVector3*)mesh->getNormals();
 	for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index)
 	{
 		if( weight != weights[index])
diff --git a/indra/newview/llviewerjointmesh_sse2.cpp b/indra/newview/llviewerjointmesh_sse2.cpp
index 550044c321f..58cd75871d1 100644
--- a/indra/newview/llviewerjointmesh_sse2.cpp
+++ b/indra/newview/llviewerjointmesh_sse2.cpp
@@ -101,8 +101,8 @@ void LLViewerJointMesh::updateGeometrySSE2(LLFace *face, LLPolyMesh *mesh)
 	buffer->getNormalStrider(o_normals,   mesh->mFaceVertexOffset);
 
 	const F32*			weights			= mesh->getWeights();
-	const LLVector3*	coords			= mesh->getCoords();
-	const LLVector3*	normals			= mesh->getNormals();
+	const LLVector3*	coords			= (const LLVector3*)mesh->getCoords();
+	const LLVector3*	normals			= (const LLVector3*)mesh->getNormals();
 	for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index)
 	{
 		if( weight != weights[index])
-- 
GitLab


From c4d3682f07858a0ffada55e456357ff8192a7db1 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 21 May 2010 16:09:22 +0100
Subject: [PATCH 430/683] Avoid potentially loading the standard bumpmap list
 twice during startup.

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

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 1fae8e518c9..b7092f32a2f 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -82,7 +82,7 @@ static S32 bump_channel = -1;
 // static 
 void LLStandardBumpmap::init()
 {
-	LLStandardBumpmap::restoreGL();
+	// do nothing
 }
 
 // static 
@@ -876,6 +876,8 @@ void LLBumpImageList::clear()
 	// these will be re-populated on-demand
 	mBrightnessEntries.clear();
 	mDarknessEntries.clear();
+
+	LLStandardBumpmap::clear();
 }
 
 void LLBumpImageList::shutdown()
@@ -892,8 +894,8 @@ void LLBumpImageList::destroyGL()
 
 void LLBumpImageList::restoreGL()
 {
-	// Images will be recreated as they are needed.
 	LLStandardBumpmap::restoreGL();
+	// Images will be recreated as they are needed.
 }
 
 
-- 
GitLab


From 3008d5790d77af740847f1b39dedc117574cce60 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 21 May 2010 16:09:22 +0100
Subject: [PATCH 431/683] Avoid potentially loading the standard bumpmap list
 twice during startup. (transplanted from
 6dfc8d6ec39f6f3af4495c27546054f311b884af)

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

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 3c268092598..eefb93dc0cd 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -82,7 +82,7 @@ static S32 bump_channel = -1;
 // static 
 void LLStandardBumpmap::init()
 {
-	LLStandardBumpmap::restoreGL();
+	// do nothing
 }
 
 // static 
@@ -835,6 +835,8 @@ void LLBumpImageList::clear()
 	// these will be re-populated on-demand
 	mBrightnessEntries.clear();
 	mDarknessEntries.clear();
+
+	LLStandardBumpmap::clear();
 }
 
 void LLBumpImageList::shutdown()
@@ -851,8 +853,8 @@ void LLBumpImageList::destroyGL()
 
 void LLBumpImageList::restoreGL()
 {
-	// Images will be recreated as they are needed.
 	LLStandardBumpmap::restoreGL();
+	// Images will be recreated as they are needed.
 }
 
 
-- 
GitLab


From e90d2f88e5ce584b52b24315c85845a9e5113b50 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 21 May 2010 14:31:17 -0500
Subject: [PATCH 432/683] Aligned index buffers.

---
 indra/llrender/llvertexbuffer.cpp  | 56 +++++++++---------------------
 indra/llrender/llvertexbuffer.h    |  3 +-
 indra/newview/lldrawpoolavatar.cpp | 19 +++++-----
 3 files changed, 29 insertions(+), 49 deletions(-)

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index a50eb7211cf..0f3c900d2bd 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -453,6 +453,7 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
 	mTypeMask = typemask;
 	mStride = stride;
 	mAlignedOffset = 0;
+	mAlignedIndexOffset = 0;
 
 	sCount++;
 }
@@ -642,16 +643,20 @@ void LLVertexBuffer::createGLIndices()
 
 	mEmpty = TRUE;
 
+	//pad by 16 bytes for aligned copies
+	size += 16;
+
 	if (useVBOs())
 	{
+		//pad by another 16 bytes for VBO pointer adjustment
+		size += 16;
 		mMappedIndexData = NULL;
 		genIndices();
 		mResized = TRUE;
 	}
 	else
 	{
-		mMappedIndexData = new U8[size];
-		memset(mMappedIndexData, 0, size);
+		mMappedIndexData = (U8*) _mm_malloc(size, 16);
 		static int gl_buffer_idx = 0;
 		mGLIndices = ++gl_buffer_idx;
 	}
@@ -699,7 +704,7 @@ void LLVertexBuffer::destroyGLIndices()
 		}
 		else
 		{
-			delete [] mMappedIndexData;
+			_mm_free(mMappedIndexData);
 			mMappedIndexData = NULL;
 			mEmpty = TRUE;
 		}
@@ -836,26 +841,10 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
 			}
 			else
 			{
-				//delete old buffer, keep GL buffer for now
 				if (!useVBOs())
 				{
-					U8* old = mMappedData;
-					mMappedData = new U8[newsize];
-					if (old)
-					{	
-						memcpy(mMappedData, old, llmin(newsize, oldsize));
-						if (newsize > oldsize)
-						{
-							memset(mMappedData+oldsize, 0, newsize-oldsize);
-						}
-
-						delete [] old;
-					}
-					else
-					{
-						memset(mMappedData, 0, newsize);
-						mEmpty = TRUE;
-					}
+					_mm_free(mMappedData);
+					mMappedData = (U8*) _mm_malloc(newsize, 16);
 				}
 				mResized = TRUE;
 			}
@@ -875,24 +864,8 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
 			{
 				if (!useVBOs())
 				{
-					//delete old buffer, keep GL buffer for now
-					U8* old = mMappedIndexData;
-					mMappedIndexData = new U8[new_index_size];
-					
-					if (old)
-					{	
-						memcpy(mMappedIndexData, old, llmin(new_index_size, old_index_size));
-						if (new_index_size > old_index_size)
-						{
-							memset(mMappedIndexData+old_index_size, 0, new_index_size - old_index_size);
-						}
-						delete [] old;
-					}
-					else
-					{
-						memset(mMappedIndexData, 0, new_index_size);
-						mEmpty = TRUE;
-					}
+					_mm_free(mMappedIndexData);
+					mMappedIndexData = (U8*) _mm_malloc(new_index_size, 16);
 				}
 				mResized = TRUE;
 			}
@@ -958,7 +931,10 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
 		}
 		{
 			LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES);
-			mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+			U8* src = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+			mMappedIndexData = LL_NEXT_ALIGNED_ADDRESS<U8>(src);
+			mAlignedIndexOffset = mMappedIndexData - src;
+
 			stop_glerror();
 		}
 
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 03799af9789..c6fd0a9e3ca 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -187,7 +187,7 @@ class LLVertexBuffer : public LLRefCount
 	S32 getRequestedVerts() const			{ return mRequestedNumVerts; }
 	S32 getRequestedIndices() const			{ return mRequestedNumIndices; }
 
-	U8* getIndicesPointer() const			{ return useVBOs() ? NULL : mMappedIndexData; }
+	U8* getIndicesPointer() const			{ return useVBOs() ? (U8*) mAlignedIndexOffset : mMappedIndexData; }
 	U8* getVerticesPointer() const			{ return useVBOs() ? NULL : mMappedData; }
 	S32 getStride() const					{ return mStride; }
 	U32 getTypeMask() const					{ return mTypeMask; }
@@ -214,6 +214,7 @@ class LLVertexBuffer : public LLRefCount
 	S32		mRequestedNumIndices;  // Number of indices requested
 
 	ptrdiff_t mAlignedOffset;
+	ptrdiff_t mAlignedIndexOffset;
 	S32		mStride;
 	U32		mTypeMask;
 	S32		mUsage;			// GL usage
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 1e9053239d1..4fb8f5266eb 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1542,27 +1542,30 @@ LLVertexBufferAvatar::LLVertexBufferAvatar()
 
 void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
 {
-/*	if (sRenderingSkinned)
+	if (sRenderingSkinned)
 	{
 		U8* base = useVBOs() ? NULL : mMappedData;
 
-		glVertexPointer(3,GL_FLOAT, mStride, (void*)(base + 0));
-		glNormalPointer(GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_NORMAL]));
-		glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+		glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_VERTEX], (void*)(base + 0));
+		glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
 		
-		set_vertex_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT]));
+		set_vertex_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], 
+						LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_WEIGHT], (F32*)(base + mOffsets[TYPE_WEIGHT]));
 
 		if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_BUMP)
 		{
-			set_binormals(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL]));
+			set_binormals(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL],
+				LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_BINORMAL], (LLVector3*)(base + mOffsets[TYPE_BINORMAL]));
 		}
 	
 		if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)
 		{
-			set_vertex_clothing_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
+			set_vertex_clothing_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], 
+				LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_CLOTHWEIGHT], (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
 		}
 	}
-	else*/
+	else
 	{
 		LLVertexBuffer::setupVertexBuffer(data_mask);
 	}
-- 
GitLab


From 1ad56f84ef1102803986889cdd5b2a687adb557e Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 21 May 2010 14:33:05 -0500
Subject: [PATCH 433/683] Line endings fix.

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

diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index a7e7bfadd69..91605005e3f 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -797,7 +797,7 @@ void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh)
 	for (U32 index = 0; index < mMesh->getNumVertices(); index++)
 	{
 		// equivalent to joint = floorf(weights[index]);
-		S32 joint = _mm_cvtt_ss2si(_mm_load_ss(weights+index));
+		S32 joint = _mm_cvtt_ss2si(_mm_load_ss(weights+index));
 		F32 w = weights[index] - joint;		
 
 		LLMatrix4a gBlendMat;
-- 
GitLab


From 8919f4811a7dcaf47dc58159e0ba4ba042183325 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 21 May 2010 23:55:18 -0500
Subject: [PATCH 434/683] blah

---
 indra/llmath/llvolume.cpp     | 262 +++++++++++++++++++++++++---------
 indra/llmath/llvolume.h       |  27 +++-
 indra/llmath/v3math.h         |  15 ++
 indra/newview/llappviewer.cpp |   4 +
 4 files changed, 230 insertions(+), 78 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 5ffc61ce9cc..4e342b0b488 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -43,10 +43,12 @@
 #include "v4math.h"
 #include "m4math.h"
 #include "m3math.h"
+#include "llmatrix4a.h"
 #include "lldarray.h"
 #include "llvolume.h"
 #include "llstl.h"
 #include "llsdserialize.h"
+#include "llvector4a.h"
 
 #define DEBUG_SILHOUETTE_BINORMALS 0
 #define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette
@@ -1992,11 +1994,10 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 			LLVolumeFace& face = mVolumeFaces[i];
 
-			face.mHasBinormals = false;
-
 			//copy out indices
-			face.mIndices.resize(idx.size()/2);
-			if (idx.empty() || face.mIndices.size() < 3)
+			face.resizeIndices(idx.size()/2);
+			
+			if (idx.empty() || face.mNumIndices < 3)
 			{ //why is there an empty index list?
 				llerrs <<"WTF?" << llendl;
 				continue;
@@ -2010,7 +2011,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 			//copy out vertices
 			U32 num_verts = pos.size()/(3*2);
-			face.mVertices.resize(num_verts);
+			face.resizeVertices(num_verts);
 
 			if (mdl[i].has("Weights"))
 			{
@@ -2059,7 +2060,6 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 			LLVector3 max_pos;
 			LLVector2 min_tc; 
 			LLVector2 max_tc; 
-
 		
 			min_pos.setValue(mdl[i]["PositionDomain"]["Min"]);
 			max_pos.setValue(mdl[i]["PositionDomain"]["Max"]);
@@ -2074,36 +2074,44 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 			min = max = LLVector3(0,0,0);
 
+			F32* pos_out = face.mPositions;
+			F32* norm_out = face.mNormals;
+			F32* tc_out = face.mTexCoords;
+
 			for (U32 j = 0; j < num_verts; ++j)
 			{
 				U16* v = (U16*) &(pos[j*3*2]);
 
-				face.mVertices[j].mPosition.setVec(
-					(F32) v[0] / 65535.f * pos_range.mV[0] + min_pos.mV[0],
-					(F32) v[1] / 65535.f * pos_range.mV[1] + min_pos.mV[1],
-					(F32) v[2] / 65535.f * pos_range.mV[2] + min_pos.mV[2]);
+				pos_out[0] = (F32) v[0] / 65535.f * pos_range.mV[0] + min_pos.mV[0];
+				pos_out[1] = (F32) v[1] / 65535.f * pos_range.mV[1] + min_pos.mV[1];
+				pos_out[2] = (F32) v[2] / 65535.f * pos_range.mV[2] + min_pos.mV[2];
+			
 
 				if (j == 0)
 				{
-					min = max = face.mVertices[j].mPosition;
+					min = max = LLVector3(pos_out);
 				}
 				else
 				{
-					update_min_max(min,max,face.mVertices[j].mPosition);
+					update_min_max(min,max,pos_out);
 				}
 
+				pos_out += 4;
+
 				U16* n = (U16*) &(norm[j*3*2]);
 
-				face.mVertices[j].mNormal.setVec(
-					(F32) n[0] / 65535.f * 2.f - 1.f,
-					(F32) n[1] / 65535.f * 2.f - 1.f,
-					(F32) n[2] / 65535.f * 2.f - 1.f);
+				
+				norm_out[0] = (F32) n[0] / 65535.f * 2.f - 1.f;
+				norm_out[1] = (F32) n[1] / 65535.f * 2.f - 1.f;
+				norm_out[2] = (F32) n[2] / 65535.f * 2.f - 1.f;
+				norm_out += 4;
 
 				U16* t = (U16*) &(tc[j*2*2]);
 
-				face.mVertices[j].mTexCoord.setVec(
-					(F32) t[0] / 65535.f * tc_range.mV[0] + min_tc.mV[0],
-					(F32) t[1] / 65535.f * tc_range.mV[1] + min_tc.mV[1]);
+				tc_out[0] = (F32) t[0] / 65535.f * tc_range.mV[0] + min_tc.mV[0];
+				tc_out[1] =	(F32) t[1] / 65535.f * tc_range.mV[1] + min_tc.mV[1];
+
+				tc_out += 8;
 			}
 
 			
@@ -2133,24 +2141,29 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 			if (do_reflect_x)
 			{
-				for (S32 i = 0; i < face.mVertices.size(); i++)
+				LLVector4a* p = (LLVector4a*) face.mPositions;
+				LLVector4a* n = (LLVector4a*) face.mNormals;
+				
+				for (S32 i = 0; i < face.mNumVertices; i++)
 				{
-					face.mVertices[i].mPosition.mV[VX] *= -1.0f;
-					face.mVertices[i].mNormal.mV[VX] *= -1.0f;
+					p[i].mul(-1.0f);
+					n[i].mul(-1.0f);
 				}
 			}
 
 			if (do_invert_normals)
 			{
-				for (S32 i = 0; i < face.mVertices.size(); i++)
+				LLVector4a* n = (LLVector4a*) face.mNormals;
+				
+				for (S32 i = 0; i < face.mNumVertices; i++)
 				{
-					face.mVertices[i].mNormal *= -1.0f;
+					n[i].mul(-1.0f);
 				}
 			}
 
 			if (do_reverse_triangles)
 			{
-				for (U32 j = 0; j < face.mIndices.size(); j += 3)
+				for (U32 j = 0; j < face.mNumIndices; j += 3)
 				{
 					// swap the 2nd and 3rd index
 					S32 swap = face.mIndices[j+1];
@@ -2215,9 +2228,28 @@ void LLVolume::makeTetrahedron()
 
 	tetrahedron_set_normal(cv);
 
-	face.mVertices.push_back(cv[0]);
-	face.mVertices.push_back(cv[1]);
-	face.mVertices.push_back(cv[2]);
+	face.resizeVertices(12);
+	face.resizeIndices(12);
+
+	LLVector4a* v = (LLVector4a*) face.mPositions;
+	LLVector4a* n = (LLVector4a*) face.mNormals;
+	LLVector2* tc = (LLVector2*) face.mTexCoords;
+
+	v[0].load3(cv[0].mPosition.mV);
+	v[1].load3(cv[1].mPosition.mV);
+	v[2].load3(cv[2].mPosition.mV);
+	v += 3;
+
+	n[0].load3(cv[0].mNormal.mV);
+	n[1].load3(cv[1].mNormal.mV);
+	n[2].load3(cv[2].mNormal.mV);
+	n += 3;
+
+	tc[0] = cv[0].mTexCoord;
+	tc[1] = cv[1].mTexCoord;
+	tc[2] = cv[2].mTexCoord;
+	tc += 3;
+
 	
 	//side 2
 	cv[0].mPosition = p[3];
@@ -2226,9 +2258,20 @@ void LLVolume::makeTetrahedron()
 
 	tetrahedron_set_normal(cv);
 
-	face.mVertices.push_back(cv[0]);
-	face.mVertices.push_back(cv[1]);
-	face.mVertices.push_back(cv[2]);
+	v[0].load3(cv[0].mPosition.mV);
+	v[1].load3(cv[1].mPosition.mV);
+	v[2].load3(cv[2].mPosition.mV);
+	v += 3;
+
+	n[0].load3(cv[0].mNormal.mV);
+	n[1].load3(cv[1].mNormal.mV);
+	n[2].load3(cv[2].mNormal.mV);
+	n += 3;
+
+	tc[0] = cv[0].mTexCoord;
+	tc[1] = cv[1].mTexCoord;
+	tc[2] = cv[2].mTexCoord;
+	tc += 3;
 	
 	//side 3
 	cv[0].mPosition = p[3];
@@ -2237,9 +2280,20 @@ void LLVolume::makeTetrahedron()
 
 	tetrahedron_set_normal(cv);
 
-	face.mVertices.push_back(cv[0]);
-	face.mVertices.push_back(cv[1]);
-	face.mVertices.push_back(cv[2]);
+	v[0].load3(cv[0].mPosition.mV);
+	v[1].load3(cv[1].mPosition.mV);
+	v[2].load3(cv[2].mPosition.mV);
+	v += 3;
+
+	n[0].load3(cv[0].mNormal.mV);
+	n[1].load3(cv[1].mNormal.mV);
+	n[2].load3(cv[2].mNormal.mV);
+	n += 3;
+
+	tc[0] = cv[0].mTexCoord;
+	tc[1] = cv[1].mTexCoord;
+	tc[2] = cv[2].mTexCoord;
+	tc += 3;
 	
 	//side 4
 	cv[0].mPosition = p[2];
@@ -2248,14 +2302,25 @@ void LLVolume::makeTetrahedron()
 
 	tetrahedron_set_normal(cv);
 
-	face.mVertices.push_back(cv[0]);
-	face.mVertices.push_back(cv[1]);
-	face.mVertices.push_back(cv[2]);
+	v[0].load3(cv[0].mPosition.mV);
+	v[1].load3(cv[1].mPosition.mV);
+	v[2].load3(cv[2].mPosition.mV);
+	v += 3;
+
+	n[0].load3(cv[0].mNormal.mV);
+	n[1].load3(cv[1].mNormal.mV);
+	n[2].load3(cv[2].mNormal.mV);
+	n += 3;
+
+	tc[0] = cv[0].mTexCoord;
+	tc[1] = cv[1].mTexCoord;
+	tc[2] = cv[2].mTexCoord;
+	tc += 3;
 	
 	//set index buffer
-	for (U32 i = 0; i < 12; i++)
+	for (U16 i = 0; i < 12; i++)
 	{
-		face.mIndices.push_back(i);
+		face.mIndices[i] = i;
 	}
 	
 	mVolumeFaces.push_back(face);
@@ -3831,7 +3896,7 @@ S32 LLVolume::getNumTriangles() const
 
 	for (S32 i = 0; i < getNumVolumeFaces(); ++i)
 	{
-		triangle_count += getVolumeFace(i).mIndices.size()/3;
+		triangle_count += getVolumeFace(i).mNumIndices/3;
 	}
 
 	return triangle_count;
@@ -3844,13 +3909,22 @@ S32 LLVolume::getNumTriangles() const
 void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 										  std::vector<LLVector3> &normals,
 										  std::vector<S32> &segments,
-										  const LLVector3& obj_cam_vec,
-										  const LLMatrix4& mat,
-										  const LLMatrix3& norm_mat,
+										  const LLVector3& obj_cam_vec_in,
+										  const LLMatrix4& mat_in,
+										  const LLMatrix3& norm_mat_in,
 										  S32 face_mask)
 {
 	LLMemType m1(LLMemType::MTYPE_VOLUME);
 
+	LLMatrix4a mat;
+	mat.loadu(mat_in);
+
+	LLMatrix4a norm_mat;
+	norm_mat.loadu(norm_mat_in);
+		
+	LLVector4a obj_cam_vec;
+	obj_cam_vec.load3(obj_cam_vec_in.mV);
+
 	vertices.clear();
 	normals.clear();
 	segments.clear();
@@ -3868,7 +3942,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 		LLVolumeFace& face = *iter;
 	
 		if (!(face_mask & (0x1 << cur_index++)) ||
-		     face.mIndices.empty() || face.mEdge.empty())
+		     face.mNumIndices == 0 || face.mEdge.empty())
 		{
 			continue;
 		}
@@ -3885,7 +3959,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 #if DEBUG_SILHOUETTE_EDGE_MAP
 
 			//for each triangle
-			U32 count = face.mIndices.size();
+			U32 count = face.mNumIndices;
 			for (U32 j = 0; j < count/3; j++) {
 				//get vertices
 				S32 v1 = face.mIndices[j*3+0];
@@ -3938,7 +4012,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 #elif DEBUG_SILHOUETTE_NORMALS
 
 			//for each vertex
-			for (U32 j = 0; j < face.mVertices.size(); j++) {
+			for (U32 j = 0; j < face.mNumVertices; j++) {
 				vertices.push_back(face.mVertices[j].mPosition);
 				vertices.push_back(face.mVertices[j].mPosition + face.mVertices[j].mNormal*0.1f);
 				normals.push_back(LLVector3(0,0,1));
@@ -3964,26 +4038,36 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 
 			//for each triangle
 			std::vector<U8> fFacing;
-			vector_append(fFacing, face.mIndices.size()/3);
-			for (U32 j = 0; j < face.mIndices.size()/3; j++) 
+			vector_append(fFacing, face.mNumIndices/3);
+
+			LLVector4a* v = (LLVector4a*) face.mPositions;
+			LLVector4a* n = (LLVector4a*) face.mNormals;
+
+			for (U32 j = 0; j < face.mNumIndices/3; j++) 
 			{
 				//approximate normal
 				S32 v1 = face.mIndices[j*3+0];
 				S32 v2 = face.mIndices[j*3+1];
 				S32 v3 = face.mIndices[j*3+2];
 
-				LLVector3 norm = (face.mVertices[v1].mPosition - face.mVertices[v2].mPosition) % 
-					(face.mVertices[v2].mPosition - face.mVertices[v3].mPosition);
-				
-				if (norm.magVecSquared() < 0.00000001f) 
+				LLVector4a c1,c2;
+				c1.setSub(v[v1], v[v2]);
+				c2.setSub(v[v2], v[v3]);
+
+				LLVector4a norm;
+
+				norm.setCross3(c1, c2);
+
+				if (norm.dot3(norm) < 0.00000001f) 
 				{
 					fFacing[j] = AWAY | TOWARDS;
 				}
 				else 
 				{
 					//get view vector
-					LLVector3 view = (obj_cam_vec-face.mVertices[v1].mPosition);
-					bool away = view * norm > 0.0f; 
+					LLVector4a view;
+					view.setSub(obj_cam_vec, v[v1]);
+					bool away = view.dot3(norm) > 0.0f; 
 					if (away) 
 					{
 						fFacing[j] = AWAY;
@@ -3996,7 +4080,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 			}
 			
 			//for each triangle
-			for (U32 j = 0; j < face.mIndices.size()/3; j++) 
+			for (U32 j = 0; j < face.mNumIndices/3; j++) 
 			{
 				if (fFacing[j] == (AWAY | TOWARDS)) 
 				{ //this is a degenerate triangle
@@ -4029,9 +4113,14 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 						S32 v1 = face.mIndices[j*3+k];
 						S32 v2 = face.mIndices[j*3+((k+1)%3)];
 						
-						vertices.push_back(face.mVertices[v1].mPosition*mat);
-						LLVector3 norm1 = face.mVertices[v1].mNormal * norm_mat;
-						norm1.normVec();
+						LLVector4a t;
+						mat.affineTransform(v[v1], t);
+						vertices.push_back(LLVector3(t[0], t[1], t[2]));
+
+						norm_mat.rotate(n[v1], t);
+
+						t.normalize3Fast();
+						LLVector3 norm1 = LLVector3(t[0], t[1], t[2]);
 						normals.push_back(norm1);
 
 						vertices.push_back(face.mVertices[v2].mPosition*mat);
@@ -4088,7 +4177,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 				genBinormals(i);
 			}
 			
-			for (U32 tri = 0; tri < face.mIndices.size()/3; tri++) 
+			for (U32 tri = 0; tri < face.mNumIndices/3; tri++) 
 			{
 				S32 index1 = face.mIndices[tri*3+0];
 				S32 index2 = face.mIndices[tri*3+1];
@@ -4928,7 +5017,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 	VertexMapData::PointMap point_map;
 
 	//remove redundant vertices
-	for (U32 i = 0; i < mIndices.size(); ++i)
+	for (U32 i = 0; i < mNumIndices; ++i)
 	{
 		U16 index = mIndices[i];
 
@@ -4953,7 +5042,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 		if (!found)
 		{
 			new_face.mVertices.push_back(cv);
-			U16 index = (U16) new_face.mVertices.size()-1;
+			U16 index = (U16) new_face.mNumVertices-1;
 			new_face.mIndices.push_back(index);
 
 			VertexMapData d;
@@ -5053,7 +5142,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 		mVertices.clear();
 	}
 
-	S32	vtop = mVertices.size();
+	S32	vtop = mNumVertices;
 	for(int gx = 0;gx<grid_size+1;gx++){
 		for(int gy = 0;gy<grid_size+1;gy++){
 			VertexData newVert;
@@ -5570,7 +5659,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 void LLVolumeFace::makeTriStrip()
 {
 #if GEN_TRI_STRIP
-	for (U32 i = 0; i < mIndices.size(); i+=3)
+	for (U32 i = 0; i < mNumIndices; i+=3)
 	{
 		U16 i0 = mIndices[i];
 		U16 i1 = mIndices[i+1];
@@ -5608,7 +5697,7 @@ void LLVolumeFace::createBinormals()
 	if (!mHasBinormals)
 	{
 		//generate binormals
-		for (U32 i = 0; i < mIndices.size()/3; i++) 
+		for (U32 i = 0; i < mNumIndices/3; i++) 
 		{	//for each triangle
 			const VertexData& v0 = mVertices[mIndices[i*3+0]];
 			const VertexData& v1 = mVertices[mIndices[i*3+1]];
@@ -5636,7 +5725,7 @@ void LLVolumeFace::createBinormals()
 		}
 
 		//normalize binormals
-		for (U32 i = 0; i < mVertices.size(); i++) 
+		for (U32 i = 0; i < mNumVertices; i++) 
 		{
 			mVertices[i].mBinormal.normVec();
 			mVertices[i].mNormal.normVec();
@@ -5646,16 +5735,47 @@ void LLVolumeFace::createBinormals()
 	}
 }
 
+void LLVolumeFace::resizeVertices(S32 num_verts)
+{
+	_mm_free(mPositions);
+	_mm_free(mNormals);
+	_mm_free(mBinormals);
+	_mm_free(mTexCoords);
+
+	mBinormals = NULL;
+
+	mPositions = (F32*) _mm_malloc(num_verts*16, 16);
+	mNormals = (F32*) _mm_malloc(num_verts*16, 16);
+
+	//pad texture coordinate block end to allow for QWORD reads
+	S32 size = ((num_verts*8) + 0xF) & ~0xF;
+	mTexCoords = (F32*) _mm_malloc(size, 16);
+
+	mNumVertices = num_verts;
+}
+
+void LLVolumeFace::resizeIndices(S32 num_indices)
+{
+	_mm_free(mIndices);
+
+	//pad index block end to allow for QWORD reads
+	S32 size = ((num_indices*2) + 0xF) & ~0xF;
+	
+	mIndices = (U16*) _mm_malloc(size);	
+
+	mNumIndices = num_indices;
+}
+
 void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat, LLMatrix4& norm_mat)
 {
-	U16 offset = mVertices.size();
+	U16 offset = mNumVertices;
 
-	if (face.mVertices.size() + mVertices.size() > 65536)
+	if (face.mNumVertices + mNumVertices > 65536)
 	{
 		llerrs << "Cannot append face -- 16-bit overflow will occur." << llendl;
 	}
 	
-	for (U32 i = 0; i < face.mVertices.size(); ++i)
+	for (U32 i = 0; i < face.mNumVertices; ++i)
 	{
 		VertexData v = face.mVertices[i];
 		v.mPosition = v.mPosition*mat;
@@ -5676,7 +5796,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat, LLMatrix
 	}
 
 	
-	for (U32 i = 0; i < face.mIndices.size(); ++i)
+	for (U32 i = 0; i < face.mNumIndices; ++i)
 	{
 		mIndices.push_back(face.mIndices[i]+offset);
 	}
@@ -5823,7 +5943,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 	mCenter.clearVec();
 
 	face_min = face_max = mVertices[0].mPosition;
-	for (U32 i = 1; i < mVertices.size(); ++i)
+	for (U32 i = 1; i < mNumVertices; ++i)
 	{
 		update_min_max(face_min, face_max, mVertices[i].mPosition);
 	}
@@ -5922,7 +6042,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 	}
 
 	//generate normals 
-	for (U32 i = 0; i < mIndices.size()/3; i++) //for each triangle
+	for (U32 i = 0; i < mNumIndices/3; i++) //for each triangle
 	{
 		const U16* idx = &(mIndices[i*3]);
 			
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index c6a156ae379..17be642d4a2 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -794,20 +794,28 @@ class LLVolumeFace
 	LLVolumeFace() : 
 		mID(0),
 		mTypeMask(0),
-		mHasBinormals(FALSE),
 		mBeginS(0),
 		mBeginT(0),
 		mNumS(0),
-		mNumT(0)
+		mNumT(0),
+		mNumVertices(0),
+		mNumIndices(0),
+		mPositions(NULL),
+		mNormals(NULL),
+		mBinormals(NULL),
+		mTexCoords(NULL),
+		mIndices(NULL)
 	{
 	}
 
 	BOOL create(LLVolume* volume, BOOL partial_build = FALSE);
 	void createBinormals();
-	void makeTriStrip();
 	
 	void appendFace(const LLVolumeFace& face, LLMatrix4& transform, LLMatrix4& normal_tranform);
 
+	void resizeVertices(S32 num_verts);
+	void resizeIndices(S32 num_indices);
+
 	class VertexData
 	{
 	public:
@@ -873,7 +881,6 @@ class LLVolumeFace
 	S32 mID;
 	U32 mTypeMask;
 	LLVector3 mCenter;
-	BOOL mHasBinormals;
 
 	// Only used for INNER/OUTER faces
 	S32 mBeginS;
@@ -883,9 +890,15 @@ class LLVolumeFace
 
 	LLVector3 mExtents[2]; //minimum and maximum point of face
 
-	std::vector<VertexData> mVertices;
-	std::vector<U16>	mIndices;
-	std::vector<U16>	mTriStrip;
+	S32 mNumVertices;
+	S32 mNumIndices;
+
+	F32* mPositions;
+	F32* mNormals;
+	F32* mBinormals;
+	F32* mTexCoords;
+	U16* mIndices;
+
 	std::vector<S32>	mEdge;
 
 	//list of skin weights for rigged volumes
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index 76dd938887c..0e7d72e958b 100644
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -532,6 +532,21 @@ inline void update_min_max(LLVector3& min, LLVector3& max, const LLVector3& pos)
 	}
 }
 
+inline void update_min_max(LLVector3& min, LLVector3& max, const F32* pos)
+{
+	for (U32 i = 0; i < 3; i++)
+	{
+		if (min.mV[i] > pos[i])
+		{
+			min.mV[i] = pos[i];
+		}
+		if (max.mV[i] < pos[i])
+		{
+			max.mV[i] = pos[i];
+		}
+	}
+}
+
 inline F32 angle_between(const LLVector3& a, const LLVector3& b)
 {
 	LLVector3 an = a;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 6de34d94588..600e3294eba 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -79,6 +79,7 @@
 #include "llteleporthistory.h"
 #include "lllocationhistory.h"
 #include "llfasttimerview.h"
+#include "llvector4a.h"
 #include "llviewermenufile.h"
 #include "llvoicechannel.h"
 #include "llvoavatarself.h"
@@ -612,6 +613,9 @@ bool LLAppViewer::init()
 	//
 	LLFastTimer::reset();
 
+	// initialize SSE options
+	LLVector4a::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");
-- 
GitLab


From 4d57cb3c0975ff0bcea0d6fb3498f2d90962ff16 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 22 May 2010 04:35:02 -0500
Subject: [PATCH 435/683] Vectorize/memory align buffers in llvolumeface WIP

---
 indra/llmath/llvolume.cpp               | 720 ++++++++++++------------
 indra/llmath/llvolume.h                 |  35 +-
 indra/newview/lldrawpoolavatar.cpp      |   6 +-
 indra/newview/llface.cpp                |  55 +-
 indra/newview/llfloaterimagepreview.cpp |   6 +-
 indra/newview/llhudicon.cpp             |   2 +
 indra/newview/llhudtext.cpp             |   5 +
 indra/newview/llviewercamera.cpp        |   5 +-
 indra/newview/llvograss.cpp             |   2 +
 indra/newview/llvotextbubble.cpp        |  33 +-
 indra/newview/llvovolume.cpp            |  29 +-
 11 files changed, 474 insertions(+), 424 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 4e342b0b488..01fe2be3719 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1,4 +1,5 @@
 /** 
+
  * @file llvolume.cpp
  *
  * $LicenseInfo:firstyear=2002&license=viewergpl$
@@ -89,8 +90,6 @@ const F32 SKEW_MAX	=  0.95f;
 const F32 SCULPT_MIN_AREA = 0.002f;
 const S32 SCULPT_MIN_AREA_DETAIL = 1;
 
-#define GEN_TRI_STRIP 0
-
 BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
 {    
 	LLVector3 test = (pt2-pt1)%(pt3-pt2);
@@ -134,21 +133,25 @@ BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, con
 // and returns the intersection point along dir in intersection_t.
 
 // Moller-Trumbore algorithm
-BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
+BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
 							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided)
 {
 	F32 u, v, t;
 	
 	/* find vectors for two edges sharing vert0 */
-	LLVector3 edge1 = vert1 - vert0;
+	LLVector4a edge1;
+	edge1.setSub(vert1, vert0);
 	
-	LLVector3 edge2 = vert2 - vert0;;
+	
+	LLVector4a edge2;
+	edge2.setSub(vert2, vert0);
 
 	/* begin calculating determinant - also used to calculate U parameter */
-	LLVector3 pvec = dir % edge2;
-	
+	LLVector4a pvec;
+	pvec.setCross3(dir, edge2);
+
 	/* if determinant is near zero, ray lies in plane of triangle */
-	F32 det = edge1 * pvec;
+	F32 det = edge1.dot3(pvec);
 
 	if (!two_sided)
 	{
@@ -158,10 +161,11 @@ BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, cons
 		}
 
 		/* calculate distance from vert0 to ray origin */
-		LLVector3 tvec = orig - vert0;
+		LLVector4a tvec;
+		tvec.setSub(orig, vert0);
 
 		/* calculate U parameter and test bounds */
-		u = tvec * pvec;	
+		u = tvec.dot3(pvec);	
 
 		if (u < 0.f || u > det)
 		{
@@ -169,17 +173,18 @@ BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, cons
 		}
 	
 		/* prepare to test V parameter */
-		LLVector3 qvec = tvec % edge1;
+		LLVector4a qvec;
+		qvec.setCross3(tvec, edge1);
 		
 		/* calculate V parameter and test bounds */
-		v = dir * qvec;
+		v = dir.dot3(qvec);
 		if (v < 0.f || u + v > det)
 		{
 			return FALSE;
 		}
 
 		/* calculate t, scale parameters, ray intersects triangle */
-		t = edge2 * qvec;
+		t = edge2.dot3(qvec);
 		F32 inv_det = 1.0 / det;
 		t *= inv_det;
 		u *= inv_det;
@@ -195,20 +200,22 @@ BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, cons
 		F32 inv_det = 1.0 / det;
 
 		/* calculate distance from vert0 to ray origin */
-		LLVector3 tvec = orig - vert0;
+		LLVector4a tvec;
+		tvec.setSub(orig, vert0);
 		
 		/* calculate U parameter and test bounds */
-		u = (tvec * pvec) * inv_det;
+		u = (tvec.dot3(pvec)) * inv_det;
 		if (u < 0.f || u > 1.f)
 		{
 			return FALSE;
 			}
 
 		/* prepare to test V parameter */
-		LLVector3 qvec = tvec - edge1;
+		LLVector4a qvec;
+		qvec.setSub(tvec, edge1);
 		
 		/* calculate V parameter and test bounds */
-		v = (dir * qvec) * inv_det;
+		v = (dir.dot3(qvec)) * inv_det;
 		
 		if (v < 0.f || u + v > 1.f)
 		{
@@ -216,7 +223,7 @@ BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, cons
 		}
 
 		/* calculate t, ray intersects triangle */
-		t = (edge2 * qvec) * inv_det;
+		t = (edge2.dot3(qvec)) * inv_det;
 	}
 	
 	if (intersection_a != NULL)
@@ -4120,13 +4127,14 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 						norm_mat.rotate(n[v1], t);
 
 						t.normalize3Fast();
-						LLVector3 norm1 = LLVector3(t[0], t[1], t[2]);
-						normals.push_back(norm1);
+						normals.push_back(LLVector3(t[0], t[1], t[2]));
 
-						vertices.push_back(face.mVertices[v2].mPosition*mat);
-						LLVector3 norm2 = face.mVertices[v2].mNormal * norm_mat;
-						norm2.normVec();
-						normals.push_back(norm2);
+						mat.affineTransform(v[v2], t);
+						vertices.push_back(LLVector3(t[0], t[1], t[2]));
+						
+						norm_mat.rotate(n[v2], t);
+						t.normalize3Fast();
+						normals.push_back(LLVector3(t[0], t[1], t[2]));
 
 						segments.push_back(vertices.size());
 					}
@@ -4177,6 +4185,10 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 				genBinormals(i);
 			}
 			
+			LLVector4a starta, dira;
+
+			LLVector4a* p = (LLVector4a*) face.mPositions;
+
 			for (U32 tri = 0; tri < face.mNumIndices/3; tri++) 
 			{
 				S32 index1 = face.mIndices[tri*3+0];
@@ -4185,15 +4197,15 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 				F32 a, b, t;
 			
-				if (LLTriangleRayIntersect(face.mVertices[index1].mPosition,
-										   face.mVertices[index2].mPosition,
-										   face.mVertices[index3].mPosition,
-										   start, dir, &a, &b, &t, FALSE))
+				if (LLTriangleRayIntersect(p[index1],
+					p[index2],
+					p[index3],
+					starta, dira, &a, &b, &t, FALSE))
 				{
 					if ((t >= 0.f) &&      // if hit is after start
 						(t <= 1.f) &&      // and before end
 						(t < closest_t))   // and this hit is closer
-		{
+					{
 						closest_t = t;
 						hit_face = i;
 
@@ -4201,27 +4213,35 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 						{
 							*intersection = start + dir * closest_t;
 						}
-			
+
+
 						if (tex_coord != NULL)
-			{
-							*tex_coord = ((1.f - a - b)  * face.mVertices[index1].mTexCoord +
-										  a              * face.mVertices[index2].mTexCoord +
-										  b              * face.mVertices[index3].mTexCoord);
+						{
+							LLVector2* tc = (LLVector2*) face.mTexCoords;
+							*tex_coord = ((1.f - a - b)  * tc[index1] +
+								a              * tc[index2] +
+								b              * tc[index3]);
 
 						}
 
 						if (normal != NULL)
-				{
-							*normal    = ((1.f - a - b)  * face.mVertices[index1].mNormal + 
-										  a              * face.mVertices[index2].mNormal +
-										  b              * face.mVertices[index3].mNormal);
+						{
+							LLVector4* norm = (LLVector4*) face.mNormals;
+
+							*normal    = ((1.f - a - b)  * LLVector3(norm[index1]) + 
+								a              * LLVector3(norm[index2]) +
+								b              * LLVector3(norm[index3]));
 						}
 
 						if (bi_normal != NULL)
-					{
-							*bi_normal = ((1.f - a - b)  * face.mVertices[index1].mBinormal + 
-										  a              * face.mVertices[index2].mBinormal +
-										  b              * face.mVertices[index3].mBinormal);
+						{
+							LLVector4* binormal = (LLVector4*) face.mBinormals;
+							if (binormal)
+							{
+								*bi_normal = ((1.f - a - b)  * LLVector3(binormal[index1]) + 
+									a              * LLVector3(binormal[index2]) +
+									b              * LLVector3(binormal[index3]));
+							}
 						}
 
 					}
@@ -4992,6 +5012,14 @@ std::ostream& operator<<(std::ostream &s, const LLVolume *volumep)
 	return s;
 }
 
+LLVolumeFace::~LLVolumeFace()
+{
+	_mm_free(mPositions);
+	_mm_free(mNormals);
+	_mm_free(mTexCoords);
+	_mm_free(mIndices);
+	_mm_free(mBinormals);
+}
 
 BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
 {
@@ -5012,6 +5040,7 @@ BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
 
 void LLVolumeFace::optimize(F32 angle_cutoff)
 {
+#if 0 //disabling until a vectorized version is available
 	LLVolumeFace new_face;
 
 	VertexMapData::PointMap point_map;
@@ -5063,6 +5092,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 
 	mVertices = new_face.mVertices;
 	mIndices = new_face.mIndices;
+#endif 
 }
 
 void	LerpPlanarVertex(LLVolumeFace::VertexData& v0,
@@ -5127,20 +5157,22 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 		corners[1].mTexCoord=corners[2].mTexCoord;
 		corners[2].mTexCoord=swap;
 	}
-	baseVert.mBinormal = calc_binormal_from_triangle( 
+
+	LLVector4a binormal;
+	
+	calc_binormal_from_triangle( binormal,
 		corners[0].mPosition, corners[0].mTexCoord,
 		corners[1].mPosition, corners[1].mTexCoord,
 		corners[2].mPosition, corners[2].mTexCoord);
-	for(int t = 0; t < 4; t++){
-		corners[t].mBinormal = baseVert.mBinormal;
-		corners[t].mNormal = baseVert.mNormal;
-	}
-	mHasBinormals = TRUE;
 
-	if (partial_build)
-	{
-		mVertices.clear();
-	}
+	S32 size = (grid_size+1)*(grid_size+1);
+	resizeVertices(size);
+	allocateBinormals(size);
+
+	LLVector4a* pos = (LLVector4a*) mPositions;
+	LLVector4a* norm = (LLVector4a*) mNormals;
+	LLVector4a* binorm = (LLVector4a*) mBinormals;
+	LLVector2* tc = (LLVector2*) mTexCoords;
 
 	S32	vtop = mNumVertices;
 	for(int gx = 0;gx<grid_size+1;gx++){
@@ -5153,7 +5185,11 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 				newVert,
 				(F32)gx/(F32)grid_size,
 				(F32)gy/(F32)grid_size);
-			mVertices.push_back(newVert);
+
+			(*pos++).load3(newVert.mPosition.mV);
+			(*norm++).load3(baseVert.mNormal.mV);
+			(*tc++) = newVert.mTexCoord;
+			(*binorm++).load4a((F32*) &binormal.mQ);
 
 			if (gx == 0 && gy == 0)
 			{
@@ -5170,9 +5206,10 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
-#if GEN_TRI_STRIP
-		mTriStrip.clear();
-#endif
+		resizeIndices(grid_size*6);
+
+		U16* out = mIndices;
+
 		S32 idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
 		for(S32 gx = 0;gx<grid_size;gx++)
 		{
@@ -5183,61 +5220,19 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 				{
 					for(S32 i=5;i>=0;i--)
 					{
-						mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
-					}
-					
-#if GEN_TRI_STRIP
-					if (gy == 0)
-					{
-						mTriStrip.push_back((gx+1)*(grid_size+1));
-						mTriStrip.push_back((gx+1)*(grid_size+1));
-						mTriStrip.push_back(gx*(grid_size+1));
-					}
-
-					mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1));
-					mTriStrip.push_back(gy+1+gx*(grid_size+1));
-					
-					
-					if (gy == grid_size-1)
-					{
-						mTriStrip.push_back(gy+1+gx*(grid_size+1));
-					}
-#endif
+						*out++ = (vtop+(gy*(grid_size+1))+gx+idxs[i]);
+					}		
 				}
 				else
 				{
 					for(S32 i=0;i<6;i++)
 					{
-						mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
-					}
-
-#if GEN_TRI_STRIP
-					if (gy == 0)
-					{
-						mTriStrip.push_back(gx*(grid_size+1));
-						mTriStrip.push_back(gx*(grid_size+1));
-						mTriStrip.push_back((gx+1)*(grid_size+1));
+						*out++ = (vtop+(gy*(grid_size+1))+gx+idxs[i]);
 					}
-
-					mTriStrip.push_back(gy+1+gx*(grid_size+1));
-					mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1));
-					
-					if (gy == grid_size-1)
-					{
-						mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1));
-					}
-#endif
 				}
 			}
 			
 		}
-
-#if GEN_TRI_STRIP
-		if (mTriStrip.size()%2 == 1)
-		{
-			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
-		}
-#endif
 	}
 		
 	return TRUE;
@@ -5267,11 +5262,25 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	num_vertices = profile.size();
 	num_indices = (profile.size() - 2)*3;
 
-	mVertices.resize(num_vertices);
+	if (!(mTypeMask & HOLLOW_MASK) && !(mTypeMask & OPEN_MASK))
+	{
+		resizeVertices(num_vertices+1);
+		allocateBinormals(num_vertices+1);	
 
-	if (!partial_build)
+		if (!partial_build)
+		{
+			resizeIndices(num_indices+3);
+		}
+	}
+	else
 	{
-		mIndices.resize(num_indices);
+		resizeVertices(num_vertices);
+		allocateBinormals(num_vertices);
+
+		if (!partial_build)
+		{
+			resizeIndices(num_indices);
+		}
 	}
 
 	S32 max_s = volume->getProfile().getTotal();
@@ -5298,79 +5307,87 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	LLVector3& min = mExtents[0];
 	LLVector3& max = mExtents[1];
 
+	LLVector2* tc = (LLVector2*) mTexCoords;
+	LLVector4a* pos = (LLVector4a*) mPositions;
+	LLVector4a* norm = (LLVector4a*) mNormals;
+	LLVector4a* binorm = (LLVector4a*) mBinormals;
+
 	// Copy the vertices into the array
 	for (S32 i = 0; i < num_vertices; i++)
 	{
 		if (mTypeMask & TOP_MASK)
 		{
-			mVertices[i].mTexCoord.mV[0] = profile[i].mV[0]+0.5f;
-			mVertices[i].mTexCoord.mV[1] = profile[i].mV[1]+0.5f;
+			tc[i].mV[0] = profile[i].mV[0]+0.5f;
+			tc[i].mV[1] = profile[i].mV[1]+0.5f;
 		}
 		else
 		{
 			// Mirror for underside.
-			mVertices[i].mTexCoord.mV[0] = profile[i].mV[0]+0.5f;
-			mVertices[i].mTexCoord.mV[1] = 0.5f - profile[i].mV[1];
+			tc[i].mV[0] = profile[i].mV[0]+0.5f;
+			tc[i].mV[1] = 0.5f - profile[i].mV[1];
 		}
 
-		mVertices[i].mPosition = mesh[i + offset].mPos;
+		pos[i].load3(mesh[i + offset].mPos.mV);
 		
 		if (i == 0)
 		{
-			min = max = mVertices[i].mPosition;
-			min_uv = max_uv = mVertices[i].mTexCoord;
+			min = max = mesh[i+offset].mPos;
+			min_uv = max_uv = tc[i];
 		}
 		else
 		{
-			update_min_max(min,max, mVertices[i].mPosition);
-			update_min_max(min_uv, max_uv, mVertices[i].mTexCoord);
+			update_min_max(min,max, mesh[i+offset].mPos);
+			update_min_max(min_uv, max_uv, tc[i]);
 		}
 	}
 
 	mCenter = (min+max)*0.5f;
 	cuv = (min_uv + max_uv)*0.5f;
 
-	LLVector3 binormal = calc_binormal_from_triangle( 
+	LLVector4a binormal;
+	calc_binormal_from_triangle(binormal,
 		mCenter, cuv,
-		mVertices[0].mPosition, mVertices[0].mTexCoord,
-		mVertices[1].mPosition, mVertices[1].mTexCoord);
-	binormal.normVec();
+		mesh[0+offset].mPos, tc[0],
+		mesh[1+offset].mPos, tc[1]);
+	binormal.normalize3Fast();
+
+	LLVector4a normal;
+	LLVector4a d0, d1;
+	LLVector4a center;
+
+	center.load3(mCenter.mV);
 
-	LLVector3 d0;
-	LLVector3 d1;
-	LLVector3 normal;
+	d0.setSub(center, pos[0]);
+	d1.setSub(center, pos[1]);
 
-	d0 = mCenter-mVertices[0].mPosition;
-	d1 = mCenter-mVertices[1].mPosition;
+	if (mTypeMask & TOP_MASK)
+	{
+		normal.setCross3(d0, d1);
+	}
+	else
+	{
+		normal.setCross3(d1, d0);
+	}
 
-	normal = (mTypeMask & TOP_MASK) ? (d0%d1) : (d1%d0);
-	normal.normVec();
+	normal.normalize3Fast();
 
 	VertexData vd;
 	vd.mPosition = mCenter;
-	vd.mNormal = normal;
-	vd.mBinormal = binormal;
 	vd.mTexCoord = cuv;
 	
 	if (!(mTypeMask & HOLLOW_MASK) && !(mTypeMask & OPEN_MASK))
 	{
-		mVertices.push_back(vd);
+		pos[num_vertices].load4a((F32*) &center.mQ);
+		tc[num_vertices] = cuv;
 		num_vertices++;
-		if (!partial_build)
-		{
-			vector_append(mIndices, 3);
-		}
 	}
 		
-	
 	for (S32 i = 0; i < num_vertices; i++)
 	{
-		mVertices[i].mBinormal = binormal;
-		mVertices[i].mNormal = normal;
+		binorm[i].load4a((F32*) &binormal.mQ);
+		norm[i].load4a((F32*) &normal.mQ);
 	}
 
-	mHasBinormals = TRUE;
-
 	if (partial_build)
 	{
 		return TRUE;
@@ -5478,8 +5495,6 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 					pt2--;
 				}
 			}
-
-			makeTriStrip();
 		}
 		else
 		{
@@ -5584,8 +5599,6 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 					pt2--;
 				}
 			}
-
-			makeTriStrip();
 		}
 	}
 	else
@@ -5607,131 +5620,63 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 			mIndices[3*i+v2] = i + 1;
 		}
 
-#if GEN_TRI_STRIP
-		//make tri strip
-		if (mTypeMask & OPEN_MASK)
-		{
-			makeTriStrip();
-		}
-		else
-		{
-			S32 j = num_vertices-2;
-			if (mTypeMask & TOP_MASK)
-			{
-				mTriStrip.push_back(0);
-				for (S32 i = 0; i <= j; ++i)
-				{
-					mTriStrip.push_back(i);
-					if (i != j)
-					{
-						mTriStrip.push_back(j);
-					}
-					--j;
-				}
-			}
-			else
-			{
-				mTriStrip.push_back(j);
-				for (S32 i = 0; i <= j; ++i)
-				{
-					if (i != j)
-					{
-						mTriStrip.push_back(j);
-					}
-					mTriStrip.push_back(i);
-					--j;
-				}
-			}
-			
-			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
 
-			if (mTriStrip.size()%2 == 1)
-			{
-				mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
-			}
-		}
-#endif
 	}
 		
 	return TRUE;
 }
 
-void LLVolumeFace::makeTriStrip()
-{
-#if GEN_TRI_STRIP
-	for (U32 i = 0; i < mNumIndices; i+=3)
-	{
-		U16 i0 = mIndices[i];
-		U16 i1 = mIndices[i+1];
-		U16 i2 = mIndices[i+2];
-
-		if ((i/3)%2 == 1)
-		{
-			mTriStrip.push_back(i0);
-			mTriStrip.push_back(i0);
-			mTriStrip.push_back(i1);
-			mTriStrip.push_back(i2);
-			mTriStrip.push_back(i2);
-		}
-		else
-		{
-			mTriStrip.push_back(i2);
-			mTriStrip.push_back(i2);
-			mTriStrip.push_back(i1);
-			mTriStrip.push_back(i0);
-			mTriStrip.push_back(i0);
-		}
-	}
-
-	if (mTriStrip.size()%2 == 1)
-	{
-		mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
-	}
-#endif
-}
-
 void LLVolumeFace::createBinormals()
 {
 	LLMemType m1(LLMemType::MTYPE_VOLUME);
 	
-	if (!mHasBinormals)
+	if (!mBinormals)
 	{
+		allocateBinormals(mNumVertices);
+
 		//generate binormals
+		LLStrider<LLVector3> pos;
+		pos = (LLVector3*) mPositions;
+		pos.setStride(16);
+
+		LLVector2* tc = (LLVector2*) mTexCoords;
+		LLVector4a* binorm = (LLVector4a*) mBinormals;
+
 		for (U32 i = 0; i < mNumIndices/3; i++) 
 		{	//for each triangle
-			const VertexData& v0 = mVertices[mIndices[i*3+0]];
-			const VertexData& v1 = mVertices[mIndices[i*3+1]];
-			const VertexData& v2 = mVertices[mIndices[i*3+2]];
+			const U16& i0 = mIndices[i*3+0];
+			const U16& i1 = mIndices[i*3+1];
+			const U16& i2 = mIndices[i*3+2];
 						
 			//calculate binormal
-			LLVector3 binorm = calc_binormal_from_triangle(v0.mPosition, v0.mTexCoord,
-															v1.mPosition, v1.mTexCoord,
-															v2.mPosition, v2.mTexCoord);
+			LLVector4a binormal;
+			calc_binormal_from_triangle(binormal,
+										pos[i0], tc[i0],
+										pos[i1], tc[i1],
+										pos[i2], tc[i2]);
 
-			for (U32 j = 0; j < 3; j++) 
-			{ //add triangle normal to vertices
-				mVertices[mIndices[i*3+j]].mBinormal += binorm; // * (weight_sum - d[j])/weight_sum;
-			}
+
+			//add triangle normal to vertices
+			binorm[i0].add(binormal);
+			binorm[i1].add(binormal);
+			binorm[i2].add(binormal);
 
 			//even out quad contributions
 			if (i % 2 == 0) 
 			{
-				mVertices[mIndices[i*3+2]].mBinormal += binorm;
+				binorm[i2].add(binormal);
 			}
 			else 
 			{
-				mVertices[mIndices[i*3+1]].mBinormal += binorm;
+				binorm[i1].add(binormal);
 			}
 		}
 
 		//normalize binormals
 		for (U32 i = 0; i < mNumVertices; i++) 
 		{
-			mVertices[i].mBinormal.normVec();
-			mVertices[i].mNormal.normVec();
+			binorm[i].normalize3Fast();
 		}
-
-		mHasBinormals = TRUE;
 	}
 }
 
@@ -5754,6 +5699,13 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
 	mNumVertices = num_verts;
 }
 
+void LLVolumeFace::allocateBinormals(S32 num_verts)
+{
+	_mm_free(mBinormals);
+	mBinormals = (F32*) _mm_malloc(num_verts*16, 16);
+}
+
+
 void LLVolumeFace::resizeIndices(S32 num_indices)
 {
 	_mm_free(mIndices);
@@ -5761,44 +5713,107 @@ void LLVolumeFace::resizeIndices(S32 num_indices)
 	//pad index block end to allow for QWORD reads
 	S32 size = ((num_indices*2) + 0xF) & ~0xF;
 	
-	mIndices = (U16*) _mm_malloc(size);	
+	mIndices = (U16*) _mm_malloc(size,16);	
 
 	mNumIndices = num_indices;
 }
 
-void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat, LLMatrix4& norm_mat)
+void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx)
+{
+	resizeVertices(v.size());
+	resizeIndices(idx.size());
+
+	for (U32 i = 0; i < v.size(); ++i)
+	{
+		for (U32 j = 0; j < 3; ++j)
+		{
+			mPositions[i*4+j] = v[i].mPosition[j];
+			mNormals[i*4+j] = v[i].mNormal[j];
+		}
+
+		mTexCoords[i*2+0] = v[i].mTexCoord.mV[0];
+		mTexCoords[i*2+1] = v[i].mTexCoord.mV[1];
+	}
+
+	for (U32 i = 0; i < idx.size(); ++i)
+	{
+		mIndices[i] = idx[i];
+	}
+}
+
+void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMatrix4& norm_mat_in)
 {
 	U16 offset = mNumVertices;
 
-	if (face.mNumVertices + mNumVertices > 65536)
+	S32 new_count = face.mNumVertices + mNumVertices;
+
+	if (new_count > 65536)
 	{
 		llerrs << "Cannot append face -- 16-bit overflow will occur." << llendl;
 	}
 	
+	
+	F32* new_pos = (F32*) _mm_malloc(new_count*16, 16);
+	F32* new_norm = (F32*) _mm_malloc(new_count*16, 16);
+	F32* new_tc = (F32*) _mm_malloc((new_count*8+0xF) & ~0xF, 16);
+
+	LLVector4a::memcpyNonAliased16(new_pos, mPositions, new_count*4);
+	LLVector4a::memcpyNonAliased16(new_norm, mNormals, new_count*4);
+	LLVector4a::memcpyNonAliased16(new_tc, mTexCoords, new_count*2);
+
+	_mm_free(mPositions);
+	_mm_free(mNormals);
+	_mm_free(mTexCoords);
+
+	mPositions = new_pos;
+	mNormals = new_norm;
+	mTexCoords = new_tc;
+
+	mNumVertices = new_count;
+
+	LLVector4a* dst_pos = (LLVector4a*) mPositions+offset;
+	LLVector2* dst_tc = (LLVector2*) mTexCoords+offset;
+	LLVector4a* dst_norm = (LLVector4a*) mNormals+offset;
+
+	LLVector4a* src_pos = (LLVector4a*) face.mPositions;
+	LLVector2* src_tc = (LLVector2*) face.mTexCoords;
+	LLVector4a* src_norm = (LLVector4a*) face.mNormals;
+
+	LLMatrix4a mat, norm_mat;
+	mat.loadu(mat_in);
+	norm_mat.loadu(norm_mat_in);
+
 	for (U32 i = 0; i < face.mNumVertices; ++i)
 	{
-		VertexData v = face.mVertices[i];
-		v.mPosition = v.mPosition*mat;
-		v.mNormal = v.mNormal * norm_mat;
+		mat.affineTransform(src_pos[i], dst_pos[i]);
+		norm_mat.rotate(src_norm[i], dst_norm[i]);
+		dst_norm[i].normalize3Fast();
 
-		v.mNormal.normalize();
-
-		mVertices.push_back(v);
+		dst_tc[i] = src_tc[i];
 
 		if (offset == 0 && i == 0)
 		{
-			mExtents[0] = mExtents[1] = v.mPosition;
+			mExtents[0] = mExtents[1] = LLVector3((F32*) &(dst_pos[i].mQ));
 		}
 		else
 		{
-			update_min_max(mExtents[0], mExtents[1], v.mPosition);
+			update_min_max(mExtents[0], mExtents[1], (F32*) &(dst_pos[i].mQ));
 		}
 	}
 
-	
+
+	new_count = mNumIndices + face.mNumIndices;
+	U16* new_indices = (U16*) _mm_malloc((new_count*2+0xF) & ~0xF, 16);
+	LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, new_count/2);
+	_mm_free(mIndices);
+	mIndices = new_indices;
+	mNumIndices = new_count;
+
+	U16* dst_idx = mIndices+offset;
+
 	for (U32 i = 0; i < face.mNumIndices; ++i)
 	{
-		mIndices.push_back(face.mIndices[i]+offset);
+		dst_idx[i] = face.mIndices[i]+offset;
 	}
 }
 
@@ -5828,21 +5843,20 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 	num_vertices = mNumS*mNumT;
 	num_indices = (mNumS-1)*(mNumT-1)*6;
 
-	mVertices.resize(num_vertices);
-
 	if (!partial_build)
 	{
-		mIndices.resize(num_indices);
+		resizeVertices(num_vertices);
+		resizeIndices(num_indices);
 
 		if ((volume->getParams().getSculptType() & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH)
 		{
 			mEdge.resize(num_indices);
 		}
 	}
-	else
-	{
-		mHasBinormals = FALSE;
-	}
+
+	LLVector4a* pos = (LLVector4a*) mPositions;
+	LLVector4a* norm = (LLVector4a*) mNormals;
+	LLVector2* tc = (LLVector2*) mTexCoords;
 
 	S32 begin_stex = llfloor( profile[mBeginS].mV[2] );
 	S32 num_s = ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2) ? mNumS/2 : mNumS;
@@ -5894,21 +5908,21 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				i = mBeginS + s + max_s*t;
 			}
 
-			mVertices[cur_vertex].mPosition = mesh[i].mPos;
-			mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt);
+			pos[cur_vertex].load3(mesh[i].mPos.mV);
+			tc[cur_vertex] = LLVector2(ss,tt);
 		
-			mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
-			mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
+			norm[cur_vertex].clear();
 
 			cur_vertex++;
 
 			if ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2 && s > 0)
 			{
-				mVertices[cur_vertex].mPosition = mesh[i].mPos;
-				mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt);
+
+				pos[cur_vertex].load3(mesh[i].mPos.mV);
+				tc[cur_vertex] = LLVector2(ss,tt);
 			
-				mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
-				mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
+				norm[cur_vertex].clear();
+				
 				cur_vertex++;
 			}
 		}
@@ -5926,12 +5940,10 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 
 			i = mBeginS + s + max_s*t;
 			ss = profile[mBeginS + s].mV[2] - begin_stex;
-			mVertices[cur_vertex].mPosition = mesh[i].mPos;
-			mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt);
-		
-			mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
-			mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
-
+			pos[cur_vertex].load3(mesh[i].mPos.mV);
+			tc[cur_vertex] = LLVector2(ss,tt);
+			norm[cur_vertex].clear(); 
+			
 			cur_vertex++;
 		}
 	}
@@ -5942,10 +5954,11 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 	LLVector3& face_max = mExtents[1];
 	mCenter.clearVec();
 
-	face_min = face_max = mVertices[0].mPosition;
+	face_min = face_max = LLVector3((F32*) &(pos[i].mQ));
+
 	for (U32 i = 1; i < mNumVertices; ++i)
 	{
-		update_min_max(face_min, face_max, mVertices[i].mPosition);
+		update_min_max(face_min, face_max, (F32*) &(pos[i].mQ));
 	}
 
 	mCenter = (face_min + face_max) * 0.5f;
@@ -5956,18 +5969,9 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
-#if GEN_TRI_STRIP
-		mTriStrip.clear();
-#endif
-
 		// Now we generate the indices.
 		for (t = 0; t < (mNumT-1); t++)
 		{
-#if GEN_TRI_STRIP
-			//prepend terminating index to strip
-			mTriStrip.push_back(mNumS*t);
-#endif
-
 			for (s = 0; s < (mNumS-1); s++)
 			{	
 				mIndices[cur_index++] = s   + mNumS*t;			//bottom left
@@ -5977,16 +5981,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				mIndices[cur_index++] = s+1 + mNumS*t;			//bottom right
 				mIndices[cur_index++] = s+1 + mNumS*(t+1);		//top right
 
-#if GEN_TRI_STRIP
-				if (s == 0)
-				{
-					mTriStrip.push_back(s+mNumS*t);
-					mTriStrip.push_back(s+mNumS*(t+1));
-				}
-				mTriStrip.push_back(s+1+mNumS*t);
-				mTriStrip.push_back(s+1+mNumS*(t+1));
-#endif
-				
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1;						//bottom left/top right neighbor face 
 				if (t < mNumT-2) {												//top right/top left neighbor face 
 					mEdge[cur_edge++] = (mNumS-1)*2*(t+1)+s*2+1;
@@ -6027,52 +6021,55 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				}
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2;							//top right/bottom left neighbor face	
 			}
-#if GEN_TRI_STRIP
-			//append terminating vertex to strip
-			mTriStrip.push_back(mNumS-1+mNumS*(t+1));
-#endif
 		}
-
-#if GEN_TRI_STRIP
-		if (mTriStrip.size()%2 == 1)
-		{
-			mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]);
-		}
-#endif
 	}
 
 	//generate normals 
 	for (U32 i = 0; i < mNumIndices/3; i++) //for each triangle
 	{
 		const U16* idx = &(mIndices[i*3]);
-			
-		VertexData* v[] = 
-		{	&mVertices[idx[0]], &mVertices[idx[1]], &mVertices[idx[2]] };
-					
-		//calculate triangle normal
-		LLVector3 norm = (v[0]->mPosition-v[1]->mPosition) % (v[0]->mPosition-v[2]->mPosition);
+		
 
-		v[0]->mNormal += norm;
-		v[1]->mNormal += norm;
-		v[2]->mNormal += norm;
+		LLVector4a* v[] = 
+		{	pos+idx[0], pos+idx[1], pos+idx[2] };
+		
+		LLVector4a* n[] = 
+		{	norm+idx[0], norm+idx[1], norm+idx[2] };
+		
+		//calculate triangle normal
+		LLVector4a a, b, c;
+		
+		a.setSub(*v[0], *v[1]);
+		b.setSub(*v[0], *v[2]);
+		c.setCross3(a,b);
 
+		n[0]->add(c);
+		n[1]->add(c);
+		n[2]->add(c);
+		
 		//even out quad contributions
-		v[i%2+1]->mNormal += norm;
+		n[i%2+1]->add(c);
 	}
 	
 	// adjust normals based on wrapping and stitching
 	
-	BOOL s_bottom_converges = ((mVertices[0].mPosition - mVertices[mNumS*(mNumT-2)].mPosition).magVecSquared() < 0.000001f);
-	BOOL s_top_converges = ((mVertices[mNumS-1].mPosition - mVertices[mNumS*(mNumT-2)+mNumS-1].mPosition).magVecSquared() < 0.000001f);
+	LLVector4a top;
+	top.setSub(pos[0], pos[mNumS*(mNumT-2)]);
+	BOOL s_bottom_converges = (top.dot3(top) < 0.000001f);
+
+	top.setSub(pos[mNumS-1], pos[mNumS*(mNumT-2)+mNumS-1]);
+	BOOL s_top_converges = (top.dot3(top) < 0.000001f);
+
 	if (sculpt_stitching == LL_SCULPT_TYPE_NONE)  // logic for non-sculpt volumes
 	{
 		if (volume->getPath().isOpen() == FALSE)
 		{ //wrap normals on T
 			for (S32 i = 0; i < mNumS; i++)
 			{
-				LLVector3 norm = mVertices[i].mNormal + mVertices[mNumS*(mNumT-1)+i].mNormal;
-				mVertices[i].mNormal = norm;
-				mVertices[mNumS*(mNumT-1)+i].mNormal = norm;
+				LLVector4a n;
+				n.setAdd(norm[i], norm[mNumS*(mNumT-1)+i]);
+				norm[i] = n;
+				norm[mNumS*(mNumT-1)+i] = n;
 			}
 		}
 
@@ -6080,9 +6077,10 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 		{ //wrap normals on S
 			for (S32 i = 0; i < mNumT; i++)
 			{
-				LLVector3 norm = mVertices[mNumS*i].mNormal + mVertices[mNumS*i+mNumS-1].mNormal;
-				mVertices[mNumS * i].mNormal = norm;
-				mVertices[mNumS * i+mNumS-1].mNormal = norm;
+				LLVector4a n;
+				n.setAdd(norm[mNumS*i], norm[mNumS*i+mNumS-1]);
+				norm[mNumS * i] = n;
+				norm[mNumS * i+mNumS-1] = n;
 			}
 		}
 	
@@ -6093,7 +6091,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 			{ //all lower S have same normal
 				for (S32 i = 0; i < mNumT; i++)
 				{
-					mVertices[mNumS*i].mNormal = LLVector3(1,0,0);
+					norm[mNumS*i].set(1,0,0);
 				}
 			}
 
@@ -6101,7 +6099,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 			{ //all upper S have same normal
 				for (S32 i = 0; i < mNumT; i++)
 				{
-					mVertices[mNumS*i+mNumS-1].mNormal = LLVector3(-1,0,0);
+					norm[mNumS*i+mNumS-1].set(-1,0,0);
 				}
 			}
 		}
@@ -6129,30 +6127,33 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 		{
 			// average normals for north pole
 		
-			LLVector3 average(0.0, 0.0, 0.0);
+			LLVector4a average;
+			average.clear();
+
 			for (S32 i = 0; i < mNumS; i++)
 			{
-				average += mVertices[i].mNormal;
+				average.add(norm[i]);
 			}
 
 			// set average
 			for (S32 i = 0; i < mNumS; i++)
 			{
-				mVertices[i].mNormal = average;
+				norm[i] = average;
 			}
 
 			// average normals for south pole
 		
-			average = LLVector3(0.0, 0.0, 0.0);
+			average.clear();
+
 			for (S32 i = 0; i < mNumS; i++)
 			{
-				average += mVertices[i + mNumS * (mNumT - 1)].mNormal;
+				average.add(norm[i + mNumS * (mNumT - 1)]);
 			}
 
 			// set average
 			for (S32 i = 0; i < mNumS; i++)
 			{
-				mVertices[i + mNumS * (mNumT - 1)].mNormal = average;
+				norm[i + mNumS * (mNumT - 1)] = average;
 			}
 
 		}
@@ -6162,23 +6163,22 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 		{
 			for (S32 i = 0; i < mNumT; i++)
 			{
-				LLVector3 norm = mVertices[mNumS*i].mNormal + mVertices[mNumS*i+mNumS-1].mNormal;
-				mVertices[mNumS * i].mNormal = norm;
-				mVertices[mNumS * i+mNumS-1].mNormal = norm;
+				LLVector4a n;
+				n.setAdd(norm[mNumS*i], norm[mNumS*i+mNumS-1]);
+				norm[mNumS * i] = n;
+				norm[mNumS * i+mNumS-1] = n;
 			}
 		}
 
-
-		
 		if (wrap_t)
 		{
 			for (S32 i = 0; i < mNumS; i++)
 			{
-				LLVector3 norm = mVertices[i].mNormal + mVertices[mNumS*(mNumT-1)+i].mNormal;
-				mVertices[i].mNormal = norm;
-				mVertices[mNumS*(mNumT-1)+i].mNormal = norm;
+				LLVector4a n;
+				n.setAdd(norm[i], norm[mNumS*(mNumT-1)+i]);
+				norm[i] = n;
+				norm[mNumS*(mNumT-1)+i] = n;
 			}
-			
 		}
 
 	}
@@ -6188,7 +6188,8 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 
 // Finds binormal based on three vertices with texture coordinates.
 // Fills in dummy values if the triangle has degenerate texture coordinates.
-LLVector3 calc_binormal_from_triangle( 
+void calc_binormal_from_triangle(LLVector4a& binormal,
+
 	const LLVector3& pos0,
 	const LLVector2& tex0,
 	const LLVector3& pos1,
@@ -6196,33 +6197,42 @@ LLVector3 calc_binormal_from_triangle(
 	const LLVector3& pos2,
 	const LLVector2& tex2)
 {
-	LLVector3 rx0( pos0.mV[VX], tex0.mV[VX], tex0.mV[VY] );
-	LLVector3 rx1( pos1.mV[VX], tex1.mV[VX], tex1.mV[VY] );
-	LLVector3 rx2( pos2.mV[VX], tex2.mV[VX], tex2.mV[VY] );
+	LLVector4a rx0; rx0.set( pos0.mV[VX], tex0.mV[VX], tex0.mV[VY] );
+	LLVector4a rx1; rx1.set( pos1.mV[VX], tex1.mV[VX], tex1.mV[VY] );
+	LLVector4a rx2; rx2.set( pos2.mV[VX], tex2.mV[VX], tex2.mV[VY] );
 	
-	LLVector3 ry0( pos0.mV[VY], tex0.mV[VX], tex0.mV[VY] );
-	LLVector3 ry1( pos1.mV[VY], tex1.mV[VX], tex1.mV[VY] );
-	LLVector3 ry2( pos2.mV[VY], tex2.mV[VX], tex2.mV[VY] );
+	LLVector4a ry0; ry0.set( pos0.mV[VY], tex0.mV[VX], tex0.mV[VY] );
+	LLVector4a ry1; ry1.set( pos1.mV[VY], tex1.mV[VX], tex1.mV[VY] );
+	LLVector4a ry2; ry2.set( pos2.mV[VY], tex2.mV[VX], tex2.mV[VY] );
 
-	LLVector3 rz0( pos0.mV[VZ], tex0.mV[VX], tex0.mV[VY] );
-	LLVector3 rz1( pos1.mV[VZ], tex1.mV[VX], tex1.mV[VY] );
-	LLVector3 rz2( pos2.mV[VZ], tex2.mV[VX], tex2.mV[VY] );
+	LLVector4a rz0; rz0.set( pos0.mV[VZ], tex0.mV[VX], tex0.mV[VY] );
+	LLVector4a rz1; rz1.set( pos1.mV[VZ], tex1.mV[VX], tex1.mV[VY] );
+	LLVector4a rz2; rz2.set( pos2.mV[VZ], tex2.mV[VX], tex2.mV[VY] );
 	
-	LLVector3 r0 = (rx0 - rx1) % (rx0 - rx2);
-	LLVector3 r1 = (ry0 - ry1) % (ry0 - ry2);
-	LLVector3 r2 = (rz0 - rz1) % (rz0 - rz2);
+	LLVector4a lhs, rhs;
+
+	LLVector4a r0; 
+	lhs.setSub(rx0, rx1); rhs.setSub(rx0, rx2);
+	r0.setCross3(lhs, rhs);
+		
+	LLVector4a r1;
+	lhs.setSub(ry0, ry1); rhs.setSub(ry0, ry2);
+	r1.setCross3(lhs, rhs);
+
+	LLVector4a r2;
+	lhs.setSub(rz0, rz1); rhs.setSub(rz0, rz2);
+	r2.setCross3(lhs, rhs);
 
-	if( r0.mV[VX] && r1.mV[VX] && r2.mV[VX] )
+	if( r0[VX] && r1[VX] && r2[VX] )
 	{
-		LLVector3 binormal(
-				-r0.mV[VZ] / r0.mV[VX],
-				-r1.mV[VZ] / r1.mV[VX],
-				-r2.mV[VZ] / r2.mV[VX]);
+		binormal.set(
+				-r0[VZ] / r0[VX],
+				-r1[VZ] / r1[VX],
+				-r2[VZ] / r2[VX]);
 		// binormal.normVec();
-		return binormal;
 	}
 	else
 	{
-		return LLVector3( 0, 1 , 0 );
+		binormal.set( 0, 1 , 0 );
 	}
 }
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 17be642d4a2..911db6f94bb 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -40,6 +40,7 @@ class LLPathParams;
 class LLVolumeParams;
 class LLProfile;
 class LLPath;
+class LLVector4a;
 class LLVolumeFace;
 class LLVolume;
 
@@ -791,6 +792,19 @@ class LLDynamicPath : public LLPath
 class LLVolumeFace
 {
 public:
+	class VertexData
+	{
+	public:
+		LLVector3 mPosition;
+		LLVector3 mNormal;
+		LLVector3 mBinormal;
+		LLVector2 mTexCoord;
+
+		bool operator<(const VertexData& rhs) const;
+		bool operator==(const VertexData& rhs) const;
+		bool compareNormal(const VertexData& rhs, F32 angle_cutoff) const;
+	};
+
 	LLVolumeFace() : 
 		mID(0),
 		mTypeMask(0),
@@ -808,26 +822,18 @@ class LLVolumeFace
 	{
 	}
 
+	~LLVolumeFace();
+
 	BOOL create(LLVolume* volume, BOOL partial_build = FALSE);
 	void createBinormals();
 	
 	void appendFace(const LLVolumeFace& face, LLMatrix4& transform, LLMatrix4& normal_tranform);
 
 	void resizeVertices(S32 num_verts);
+	void allocateBinormals(S32 num_verts);
 	void resizeIndices(S32 num_indices);
+	void fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx);
 
-	class VertexData
-	{
-	public:
-		LLVector3 mPosition;
-		LLVector3 mNormal;
-		LLVector3 mBinormal;
-		LLVector2 mTexCoord;
-
-		bool operator<(const VertexData& rhs) const;
-		bool operator==(const VertexData& rhs) const;
-		bool compareNormal(const VertexData& rhs, F32 angle_cutoff) const;
-	};
 
 	class VertexMapData : public LLVolumeFace::VertexData
 	{
@@ -1051,7 +1057,8 @@ class LLVolume : public LLRefCount
 
 std::ostream& operator<<(std::ostream &s, const LLVolumeParams &volume_params);
 
-LLVector3 calc_binormal_from_triangle(
+void calc_binormal_from_triangle(
+		LLVector4a& binormal,
 		const LLVector3& pos0,
 		const LLVector2& tex0,
 		const LLVector3& pos1,
@@ -1060,7 +1067,7 @@ LLVector3 calc_binormal_from_triangle(
 		const LLVector2& tex2);
 
 BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size);
-BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
+BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
 							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided);
 	
 	
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 4fb8f5266eb..0fa0e80cb71 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1201,14 +1201,14 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSk
 
 	if (!buff || 
 		buff->getTypeMask() != data_mask ||
-		buff->getRequestedVerts() != vol_face.mVertices.size())
+		buff->getRequestedVerts() != vol_face.mNumVertices)
 	{
 		face->setGeomIndex(0);
 		face->setIndicesIndex(0);
-		face->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
+		face->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
 
 		face->mVertexBuffer = new LLVertexBuffer(data_mask, 0);
-		face->mVertexBuffer->allocateBuffer(vol_face.mVertices.size(), vol_face.mIndices.size(), true);
+		face->mVertexBuffer->allocateBuffer(vol_face.mNumVertices, vol_face.mNumIndices, true);
 
 		U16 offset = 0;
 		
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 53dc335c162..77e8a6fdf9b 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -928,8 +928,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 {
 	LLFastTimer t(FTM_FACE_GET_GEOM);
 	const LLVolumeFace &vf = volume.getVolumeFace(f);
-	S32 num_vertices = (S32)vf.mVertices.size();
-	S32 num_indices = LLPipeline::sUseTriStrips ? (S32)vf.mTriStrip.size() : (S32) vf.mIndices.size();
+	S32 num_vertices = (S32)vf.mNumVertices;
+	S32 num_indices = (S32) vf.mNumIndices;
 	
 	if (mVertexBuffer.notNull())
 	{
@@ -1128,19 +1128,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	if (full_rebuild)
 	{
 		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
-		if (LLPipeline::sUseTriStrips)
+		for (U32 i = 0; i < (U32) num_indices; i++)
 		{
-			for (U32 i = 0; i < (U32) num_indices; i++)
-			{
-				*indicesp++ = vf.mTriStrip[i] + index_offset;
-			}
-		}
-		else
-		{
-			for (U32 i = 0; i < (U32) num_indices; i++)
-			{
-				*indicesp++ = vf.mIndices[i] + index_offset;
-			}
+			*indicesp++ = vf.mIndices[i] + index_offset;
 		}
 	}
 	
@@ -1214,28 +1204,41 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	bool bake_sunlight = !getTextureEntry()->getFullbright() &&
 		!mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
 
+	//VECTORIZE THIS
 	for (S32 i = 0; i < num_vertices; i++)
 	{
+		LLVector3 vf_binormal;
+		if (vf.mBinormals)
+		{
+			vf_binormal.set(vf.mBinormals+i*4);
+		}
+
+		LLVector3 vf_normal;
+		vf_normal.set(vf.mNormals+i*4);
+
+		LLVector3 vf_position;
+		vf_position.set(vf.mPositions+i*4);
+
 		if (rebuild_tcoord)
 		{
-			LLVector2 tc = vf.mVertices[i].mTexCoord;
+			LLVector2 tc(vf.mTexCoords+i*2);
 		
 			if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
 			{
-				LLVector3 vec = vf.mVertices[i].mPosition; 
+				LLVector3 vec = vf_position;
 			
 				vec.scaleVec(scale);
 
 				switch (texgen)
 				{
 					case LLTextureEntry::TEX_GEN_PLANAR:
-						planarProjection(tc, vf.mVertices[i].mNormal, vf.mCenter, vec);
+						planarProjection(tc, vf_normal, vf.mCenter, vec);
 						break;
 					case LLTextureEntry::TEX_GEN_SPHERICAL:
-						sphericalProjection(tc, vf.mVertices[i].mNormal, vf.mCenter, vec);
+						sphericalProjection(tc, vf_normal, vf.mCenter, vec);
 						break;
 					case LLTextureEntry::TEX_GEN_CYLINDRICAL:
-						cylindricalProjection(tc, vf.mVertices[i].mNormal, vf.mCenter, vec);
+						cylindricalProjection(tc, vf_normal, vf.mCenter, vec);
 						break;
 					default:
 						break;
@@ -1345,10 +1348,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		
 			if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1))
 			{
-				LLVector3 tangent = vf.mVertices[i].mBinormal % vf.mVertices[i].mNormal;
+				LLVector3 tangent = vf_binormal % vf_normal;
 
 				LLMatrix3 tangent_to_object;
-				tangent_to_object.setRows(tangent, vf.mVertices[i].mBinormal, vf.mVertices[i].mNormal);
+				tangent_to_object.setRows(tangent, vf_binormal, vf_normal);
 				LLVector3 binormal = binormal_dir * tangent_to_object;
 				binormal = binormal * mat_normal;
 				
@@ -1366,12 +1369,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 			
 		if (rebuild_pos)
 		{
-			*vertices++ = vf.mVertices[i].mPosition * mat_vert;
+			*vertices++ = vf_position * mat_vert;
 		}
 		
 		if (rebuild_normal)
 		{
-			LLVector3 normal = vf.mVertices[i].mNormal * mat_normal;
+			LLVector3 normal = vf_normal * mat_normal;
 			normal.normVec();
 			
 			*normals++ = normal;
@@ -1379,21 +1382,21 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		
 		if (rebuild_binormal)
 		{
-			LLVector3 binormal = vf.mVertices[i].mBinormal * mat_normal;
+			LLVector3 binormal = vf_binormal * mat_normal;
 			binormal.normVec();
 			*binormals++ = binormal;
 		}
 		
 		if (rebuild_weights && vf.mWeights.size() > i)
 		{
-			*weights++ = vf.mWeights[i];
+			(*weights++) = vf.mWeights[i];
 		}
 
 		if (rebuild_color)
 		{
 			if (bake_sunlight)
 			{
-				LLVector3 normal = vf.mVertices[i].mNormal * mat_normal;
+				LLVector3 normal = vf_normal * mat_normal;
 				normal.normVec();
 				
 				F32 da = normal * gPipeline.mSunDir;
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index 159e4b41cac..dae301ae290 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -852,6 +852,7 @@ S8 LLImagePreviewSculpted::getType() const
 
 void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 { 
+#if 0 //VECTORIZE THIS
 	mCameraDistance = distance;
 	mCameraZoom = 1.f;
 	mCameraPitch = 0.f;
@@ -892,6 +893,7 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 	{
 		*(index_strider++) = vf.mIndices[i];
 	}
+#endif
 }
 
 
@@ -901,7 +903,7 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 BOOL LLImagePreviewSculpted::render()
 {
 	mNeedsUpdate = FALSE;
-
+#if 0 //VECTORIZE THIS
 	LLGLSUIDefault def;
 	LLGLDisable no_blend(GL_BLEND);
 	LLGLEnable cull(GL_CULL_FACE);
@@ -959,7 +961,7 @@ BOOL LLImagePreviewSculpted::render()
 	mVertexBuffer->draw(LLRender::TRIANGLES, num_indices, 0);
 
 	gGL.popMatrix();
-		
+#endif
 	return TRUE;
 }
 
diff --git a/indra/newview/llhudicon.cpp b/indra/newview/llhudicon.cpp
index 28b0e7356a1..c7ad0bde7e6 100644
--- a/indra/newview/llhudicon.cpp
+++ b/indra/newview/llhudicon.cpp
@@ -271,6 +271,7 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 	LLVector3 upper_left = icon_position - (x_scale * 0.5f) + y_scale;
 	LLVector3 upper_right = icon_position + (x_scale * 0.5f) + y_scale;
 
+#if 0 //VECTORIZE THIS
 	
 	F32 t = 0.f;
 	LLVector3 dir = end-start;
@@ -284,6 +285,7 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 		}
 		return TRUE;
 	}
+#endif
 
 	return FALSE;
 }
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 9ed5d13831c..64c01d09371 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -206,6 +206,8 @@ BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 			gGL.end();
 		}
 
+#if 0 //VECTORIZE THIS
+
 		LLVector3 dir = end-start;
 		F32 t = 0.f;
 
@@ -218,6 +220,9 @@ BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 				return TRUE;
 			}
 		}
+
+#endif
+
 	}
 
 	return FALSE;
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index aa82c216d91..7eca2763580 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -788,13 +788,14 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts)
 	LLMatrix4 render_mat(vo_volume->getRenderRotation(), LLVector4(vo_volume->getRenderPosition()));
 
 	num_faces = volume->getNumVolumeFaces();
+	//VECTORIZE THIS
 	for (i = 0; i < num_faces; i++)
 	{
 		const LLVolumeFace& face = volume->getVolumeFace(i);
 				
-		for (U32 v = 0; v < face.mVertices.size(); v++)
+		for (U32 v = 0; v < face.mNumVertices; v++)
 		{
-			LLVector4 vec = LLVector4(face.mVertices[v].mPosition) * mat;
+			LLVector4 vec = LLVector4(face.mPositions+v*4) * mat;
 
 			if (drawablep->isActive())
 			{
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index a82afbeb76d..edb97eef24f 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -640,6 +640,7 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 		position.mV[2] += blade_height;
 		v[3]    = v1 = position + mRegionp->getOriginAgent();
 	
+#if 0 //VECTORIZE THIS
 
 		F32 a,b,t;
 
@@ -703,6 +704,7 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 				}
 			}
 		}
+#endif
 	}
 
 	return ret;
diff --git a/indra/newview/llvotextbubble.cpp b/indra/newview/llvotextbubble.cpp
index 428ef200064..339da3c0bf9 100644
--- a/indra/newview/llvotextbubble.cpp
+++ b/indra/newview/llvotextbubble.cpp
@@ -45,6 +45,7 @@
 #include "llviewertexturelist.h"
 #include "llvolume.h"
 #include "pipeline.h"
+#include "llvector4a.h"
 #include "llviewerregion.h"
 
 LLVOTextBubble::LLVOTextBubble(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
@@ -217,7 +218,7 @@ void LLVOTextBubble::updateFaceSize(S32 idx)
 	else
 	{
 		const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx);
-		face->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
+		face->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
 	}
 }
 
@@ -235,19 +236,37 @@ void LLVOTextBubble::getGeometry(S32 idx,
 
 	const LLVolumeFace& face = getVolume()->getVolumeFace(idx);
 	
-	LLVector3 pos = getPositionAgent();
+	LLVector4a pos;
+	pos.load3(getPositionAgent().mV);
+
+	LLVector4a scale;
+	scale.load3(getScale().mV);
+
 	LLColor4U color = LLColor4U(getTE(idx)->getColor());
 	U32 offset = mDrawable->getFace(idx)->getGeomIndex();
 	
-	for (U32 i = 0; i < face.mVertices.size(); i++)
+	LLVector4a* dst_pos = (LLVector4a*) verticesp.get();
+	LLVector4a* src_pos = (LLVector4a*) face.mPositions;
+	
+	LLVector4a* dst_norm = (LLVector4a*) normalsp.get();
+	LLVector4a* src_norm  = (LLVector4a*) face.mNormals;
+	
+	LLVector2* dst_tc = (LLVector2*) texcoordsp.get();
+	LLVector2* src_tc = (LLVector2*) face.mTexCoords;
+
+	LLVector4a::memcpyNonAliased16((F32*) dst_norm, (F32*) src_norm, face.mNumVertices*4);
+	LLVector4a::memcpyNonAliased16((F32*) dst_tc, (F32*) src_tc, face.mNumVertices*2);
+	
+	
+	for (U32 i = 0; i < face.mNumVertices; i++)
 	{
-		*verticesp++ = face.mVertices[i].mPosition.scaledVec(getScale()) + pos;
-		*normalsp++ = face.mVertices[i].mNormal;
-		*texcoordsp++ = face.mVertices[i].mTexCoord;
+		LLVector4a t;
+		t.setMul(src_pos[i], scale);
+		dst_pos[i].setAdd(t, pos);
 		*colorsp++ = color;
 	}
 	
-	for (U32 i = 0; i < face.mIndices.size(); i++)
+	for (U32 i = 0; i < face.mNumIndices; i++)
 	{
 		*indicesp++ = face.mIndices[i] + offset;
 	}
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index cea964a100a..7d80a66041e 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -60,6 +60,7 @@
 #include "llflexibleobject.h"
 #include "llsky.h"
 #include "lltexturefetch.h"
+#include "llvector4a.h"
 #include "llviewercamera.h"
 #include "llviewertexturelist.h"
 #include "llviewerobjectlist.h"
@@ -1601,14 +1602,8 @@ void LLVOVolume::updateFaceSize(S32 idx)
 	else
 	{
 		const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx);
-		if (LLPipeline::sUseTriStrips)
-		{
-			facep->setSize(vol_face.mVertices.size(), vol_face.mTriStrip.size());
-		}
-		else
-		{
-			facep->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
-		}
+		facep->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
+		
 	}
 }
 
@@ -1863,21 +1858,25 @@ bool LLVOVolume::hasMedia() const
 LLVector3 LLVOVolume::getApproximateFaceNormal(U8 face_id)
 {
 	LLVolume* volume = getVolume();
-	LLVector3 result;
+	LLVector4a result;
+	result.clear();
+
+	LLVector3 ret;
 
 	if (volume && face_id < volume->getNumVolumeFaces())
 	{
 		const LLVolumeFace& face = volume->getVolumeFace(face_id);
-		for (S32 i = 0; i < (S32)face.mVertices.size(); ++i)
+		for (S32 i = 0; i < (S32)face.mNumVertices; ++i)
 		{
-			result += face.mVertices[i].mNormal;
+			result.add(*((LLVector4a*) face.mNormals+i*4));
 		}
 
-		result = volumeDirectionToAgent(result);
-		result.normVec();
+		LLVector3 ret((F32*) &result.mQ);
+		ret = volumeDirectionToAgent(ret);
+		ret.normVec();
 	}
 	
-	return result;
+	return ret;
 }
 
 void LLVOVolume::requestMediaDataUpdate(bool isNew)
@@ -3032,7 +3031,7 @@ F32 LLVOVolume::getBinRadius()
 			for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i)
 			{
 				const LLVolumeFace& face = volume->getVolumeFace(i);
-				vert_count += face.mVertices.size();
+				vert_count += face.mNumVertices;
 			}
 
 			scale = 1.f/llmax(vert_count/1024.f, 1.f);
-- 
GitLab


From d7cab99ba74b214c557d9b5e02a7800b6a25c109 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 22 May 2010 12:37:53 -0500
Subject: [PATCH 436/683] Fix for a couple dumb mistakes.

---
 indra/llmath/llvolume.cpp | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 01fe2be3719..88969af4bde 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5206,7 +5206,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
-		resizeIndices(grid_size*6);
+		resizeIndices(grid_size*grid_size*6);
 
 		U16* out = mIndices;
 
@@ -5689,12 +5689,21 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
 
 	mBinormals = NULL;
 
-	mPositions = (F32*) _mm_malloc(num_verts*16, 16);
-	mNormals = (F32*) _mm_malloc(num_verts*16, 16);
+	if (num_verts)
+	{
+		mPositions = (F32*) _mm_malloc(num_verts*16, 16);
+		mNormals = (F32*) _mm_malloc(num_verts*16, 16);
 
-	//pad texture coordinate block end to allow for QWORD reads
-	S32 size = ((num_verts*8) + 0xF) & ~0xF;
-	mTexCoords = (F32*) _mm_malloc(size, 16);
+		//pad texture coordinate block end to allow for QWORD reads
+		S32 size = ((num_verts*8) + 0xF) & ~0xF;
+		mTexCoords = (F32*) _mm_malloc(size, 16);
+	}
+	else
+	{
+		mPositions = NULL;
+		mNormals = NULL;
+		mTexCoords = NULL;
+	}
 
 	mNumVertices = num_verts;
 }
@@ -5710,10 +5719,17 @@ void LLVolumeFace::resizeIndices(S32 num_indices)
 {
 	_mm_free(mIndices);
 
-	//pad index block end to allow for QWORD reads
-	S32 size = ((num_indices*2) + 0xF) & ~0xF;
-	
-	mIndices = (U16*) _mm_malloc(size,16);	
+	if (num_indices)
+	{
+		//pad index block end to allow for QWORD reads
+		S32 size = ((num_indices*2) + 0xF) & ~0xF;
+		
+		mIndices = (U16*) _mm_malloc(size,16);	
+	}
+	else
+	{
+		mIndices = NULL;
+	}
 
 	mNumIndices = num_indices;
 }
@@ -5954,7 +5970,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 	LLVector3& face_max = mExtents[1];
 	mCenter.clearVec();
 
-	face_min = face_max = LLVector3((F32*) &(pos[i].mQ));
+	face_min = face_max = LLVector3((F32*) &(pos[0].mQ));
 
 	for (U32 i = 1; i < mNumVertices; ++i)
 	{
-- 
GitLab


From 98d72d1dd34c5553f1245c72f329c5d6b839c0ef Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 22 May 2010 12:49:32 -0500
Subject: [PATCH 437/683] Disabling some asserts for now so client is usable.

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

diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 2f02ccf30b5..2579bad0b69 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1813,7 +1813,7 @@ BOOL LLImageGL::getMask(const LLVector2 &tc)
 		{
 			LL_WARNS_ONCE("render") << "Ugh, non-finite u/v in mask pick" << LL_ENDL;
 			u = v = 0.f;
-			llassert(false);
+			//llassert(false);
 		}
 
 		if (LL_UNLIKELY(u < 0.f || u > 1.f ||
@@ -1821,7 +1821,7 @@ BOOL LLImageGL::getMask(const LLVector2 &tc)
 		{
 			LL_WARNS_ONCE("render") << "Ugh, u/v out of range in image mask pick" << LL_ENDL;
 			u = v = 0.f;
-			llassert(false);
+			//llassert(false);
 		}
 
 		S32 x = llfloor(u * mPickMaskWidth);
-- 
GitLab


From a3075d8837d61ed4a9604c948bd8726c60ac2694 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 24 May 2010 11:28:13 +0100
Subject: [PATCH 438/683] fix a tiny subset of the current build errors

---
 indra/llrender/llvertexbuffer.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 0f3c900d2bd..23303b6d5c5 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -822,9 +822,6 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
 	{
 		sAllocatedBytes -= getSize() + getIndicesSize();
 		
-		S32 oldsize = getSize();
-		S32 old_index_size = getIndicesSize();
-
 		updateNumVerts(newnverts);		
 		updateNumIndices(newnindices);
 		
-- 
GitLab


From 7eef5ed0789682e2e85f2d767c86bce6b9a6af18 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 24 May 2010 13:44:33 +0100
Subject: [PATCH 439/683] EXT-7461 move/remove deferred rendering UI from prefs

---
 indra/newview/llviewermenu.cpp                |  51 +++++++-
 .../skins/default/xui/en/menu_viewer.xml      | 114 +++++++++++++++++-
 .../xui/en/panel_preferences_graphics1.xml    |   3 +-
 3 files changed, 156 insertions(+), 12 deletions(-)

diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 10ceab26562..5ae64b25307 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2051,9 +2051,9 @@ class LLAdvancedEnableRenderDeferred: public view_listener_t
 };
 
 /////////////////////////////////////
-// Enable Global Illumination 	  ///
+// Enable Deferred Rendering sub-options
 /////////////////////////////////////
-class LLAdvancedEnableRenderDeferredGI: public view_listener_t
+class LLAdvancedEnableRenderDeferredOptions: public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
@@ -6543,7 +6543,7 @@ void handle_dump_attachments(void*)
 }
 
 
-// these are used in the gl menus to set control values.
+// these are used in the gl menus to set control values, generically.
 class LLToggleControl : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
@@ -6562,8 +6562,44 @@ class LLCheckControl : public view_listener_t
 		std::string callback_data = userdata.asString();
 		bool new_value = gSavedSettings.getBOOL(callback_data);
 		return new_value;
-}
+	}
+};
+
+// not so generic
 
+class LLAdvancedCheckRenderShadowOption: public view_listener_t
+{
+	bool handleEvent(const LLSD& userdata)
+	{
+		std::string control_name = userdata.asString();
+		S32 current_shadow_level = gSavedSettings.getS32(control_name);
+		if (current_shadow_level == 0) // is off
+		{
+			return false;
+		}
+		else // is on
+		{
+			return true;
+		}
+	}
+};
+
+class LLAdvancedClickRenderShadowOption: public view_listener_t
+{
+	bool handleEvent(const LLSD& userdata)
+	{
+		std::string control_name = userdata.asString();
+		S32 current_shadow_level = gSavedSettings.getS32(control_name);
+		if (current_shadow_level == 0) // upgrade to level 2
+		{
+			gSavedSettings.setS32(control_name, 2);
+		}
+		else // downgrade to level 0
+		{
+			gSavedSettings.setS32(control_name, 0);
+		}
+		return true;
+	}
 };
 
 void menu_toggle_attached_lights(void* user_data)
@@ -7821,7 +7857,7 @@ void initialize_menus()
 	// Help menu
 	// most items use the ShowFloater method
 
-	// Advance menu
+	// Advanced menu
 	view_listener_t::addMenu(new LLAdvancedToggleConsole(), "Advanced.ToggleConsole");
 	view_listener_t::addMenu(new LLAdvancedCheckConsole(), "Advanced.CheckConsole");
 	view_listener_t::addMenu(new LLAdvancedDumpInfoToConsole(), "Advanced.DumpInfoToConsole");
@@ -7848,12 +7884,13 @@ void initialize_menus()
 	view_listener_t::addMenu(new LLAdvancedSelectedTextureInfo(), "Advanced.SelectedTextureInfo");
 	view_listener_t::addMenu(new LLAdvancedToggleWireframe(), "Advanced.ToggleWireframe");
 	view_listener_t::addMenu(new LLAdvancedCheckWireframe(), "Advanced.CheckWireframe");
+	// Develop > Render
 	view_listener_t::addMenu(new LLAdvancedToggleTextureAtlas(), "Advanced.ToggleTextureAtlas");
 	view_listener_t::addMenu(new LLAdvancedCheckTextureAtlas(), "Advanced.CheckTextureAtlas");
 	view_listener_t::addMenu(new LLAdvancedEnableObjectObjectOcclusion(), "Advanced.EnableObjectObjectOcclusion");
 	view_listener_t::addMenu(new LLAdvancedEnableRenderFBO(), "Advanced.EnableRenderFBO");
 	view_listener_t::addMenu(new LLAdvancedEnableRenderDeferred(), "Advanced.EnableRenderDeferred");
-	view_listener_t::addMenu(new LLAdvancedEnableRenderDeferredGI(), "Advanced.EnableRenderDeferredGI");
+	view_listener_t::addMenu(new LLAdvancedEnableRenderDeferredOptions(), "Advanced.EnableRenderDeferredOptions");
 	view_listener_t::addMenu(new LLAdvancedToggleRandomizeFramerate(), "Advanced.ToggleRandomizeFramerate");
 	view_listener_t::addMenu(new LLAdvancedCheckRandomizeFramerate(), "Advanced.CheckRandomizeFramerate");
 	view_listener_t::addMenu(new LLAdvancedTogglePeriodicSlowFrame(), "Advanced.TogglePeriodicSlowFrame");
@@ -7862,6 +7899,8 @@ void initialize_menus()
 	view_listener_t::addMenu(new LLAdvancedToggleFrameTest(), "Advanced.ToggleFrameTest");
 	view_listener_t::addMenu(new LLAdvancedCheckFrameTest(), "Advanced.CheckFrameTest");
 	view_listener_t::addMenu(new LLAdvancedHandleAttachedLightParticles(), "Advanced.HandleAttachedLightParticles");
+	view_listener_t::addMenu(new LLAdvancedCheckRenderShadowOption(), "Advanced.CheckRenderShadowOption");
+	view_listener_t::addMenu(new LLAdvancedClickRenderShadowOption(), "Advanced.ClickRenderShadowOption");
 	
 
 	#ifdef TOGGLE_HACKED_GODLIKE_VIEWER
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index ef083865fdf..35960be57ff 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -29,7 +29,9 @@
             <menu_item_call.on_click
              function="BuyCurrency" />
         </menu_item_call>
+
         <menu_item_separator/>
+
         <menu_item_call
          label="My Profile"
          name="Profile">
@@ -113,7 +115,9 @@
             <menu_item_call.on_click
              function="Advanced.LeaveAdminStatus" />
         </menu_item_call>
+
         <menu_item_separator/>
+
         <menu_item_call
          label="Exit [APP_NAME]"
          name="Quit"
@@ -142,7 +146,9 @@
              function="SideTray.PanelPeopleTab"
              parameter="groups_panel" />
         </menu_item_call>
+
         <menu_item_separator/>
+
         <!--menu_item_call
          label="Chat"
          name="Chat">
@@ -240,7 +246,9 @@
              parameter="region_info" />
         </menu_item_call>
         </menu>
+
         <menu_item_separator/>
+
         <menu_item_call
              label="Buy This Land"
              name="Buy Land">
@@ -337,7 +345,9 @@
                control="NavBarShowParcelProperties" />
           </menu_item_check>
         </menu>
+
         <menu_item_separator/>
+
 	    <menu_item_call
 	     label="Teleport Home"
 	     name="Teleport Home"
@@ -376,7 +386,9 @@
              parameter="ShowNavbarFavoritesPanel" />
         </menu_item_check>
         <menu_item_separator/>-->
+
         <menu_item_separator/>
+
     <menu
          create_jump_keys="true"
          label="Sun"
@@ -419,7 +431,9 @@
                  function="World.EnvSettings"
                  parameter="default" />
             </menu_item_call>
+
             <menu_item_separator/>
+
             <menu_item_call
              label="Environment Editor"
              name="Environment Editor">
@@ -521,7 +535,9 @@
                 <menu_item_check.on_enable
                  function="Tools.EnableToolNotPie" />
             </menu_item_check>
+
         <menu_item_separator/>
+
         <menu_item_call
            label="Focus on Selection"
            name="Focus on Selection"
@@ -542,7 +558,9 @@
           <menu_item_call.on_enable
              function="Tools.SomethingSelectedNoHUD" />
         </menu_item_call>
+
         <menu_item_separator/>
+
         <menu
          create_jump_keys="true"
          label="Object"
@@ -644,7 +662,9 @@
                function="EditableSelected" />
           </menu_item_call>
         </menu>
+
         <menu_item_separator/>
+
         <menu
          create_jump_keys="true"
          label="Options"
@@ -667,7 +687,9 @@
 				 function="ToggleControl"
 				 parameter="DebugPermissions" />
 			</menu_item_check>
+
             <menu_item_separator/>
+
             <menu_item_check
                  label="Select Only My Objects"
                  name="Select Only My Objects">
@@ -694,7 +716,9 @@
                     <menu_item_check.on_click
                      function="Tools.SelectBySurrounding" />
             </menu_item_check>
+
           <menu_item_separator/>
+
                 <menu_item_check
                  label="Show Hidden Selection"
                  name="Show Hidden Selection">
@@ -720,7 +744,9 @@
                      function="ToggleControl"
                      parameter="ShowSelectionBeam" />
                 </menu_item_check>
+
         <menu_item_separator/>
+
                 <menu_item_check
                  label="Snap to Grid"
                  name="Snap to Grid"
@@ -828,7 +854,9 @@
              function="Floater.Show"
              parameter="hud" />
         </menu_item_call>-->
+
         <menu_item_separator/>
+
         <menu_item_call
              label="Report Abuse"
              name="Report Abuse">
@@ -842,7 +870,9 @@
                  function="ShowHelp"
                  parameter="report_bug" />
             </menu_item_call>
+
         <menu_item_separator/>
+
         <menu_item_call
          label="About [APP_NAME]"
          name="About Second Life">
@@ -893,7 +923,9 @@
            function="Floater.Show"
            parameter="window_size" />
         </menu_item_call>
+
         <menu_item_separator/>
+
         <menu_item_check
          label="Limit Select Distance"
          name="Limit Select Distance">
@@ -914,7 +946,9 @@
              function="ToggleControl"
              parameter="DisableCameraConstraints" />
         </menu_item_check>
+
         <menu_item_separator/>
+
         <menu_item_check
          label="High-res Snapshot"
          name="HighResSnapshot">
@@ -945,7 +979,9 @@
              function="ToggleControl"
              parameter="CompressSnapshotsToDisk" />
         </menu_item_check>
+
         <menu_item_separator/>
+
         <menu
          create_jump_keys="true"
          label="Performance Tools"
@@ -1058,7 +1094,9 @@
                 <menu_item_check.on_click
                  function="View.ShowHoverTips" />
             </menu_item_check>
+
             <menu_item_separator/>
+
             <menu_item_check
              label="Show Land Tooltips"
              name="Land Tips">
@@ -1365,7 +1403,9 @@
              function="ToggleControl"
              parameter="MouseSmooth" />
         </menu_item_check>
+
         <menu_item_separator/>
+
         <menu
          label="Shortcuts"
          name="Shortcuts"
@@ -1409,7 +1449,9 @@
                 <menu_item_call.on_click
                  function="View.DefaultUISize" />
             </menu_item_call>
+
             <menu_item_separator/>
+
             <menu_item_check
              label="Always Run"
              name="Always Run"
@@ -1430,7 +1472,9 @@
                 <menu_item_check.on_enable
                  function="Agent.enableFlying" />
             </menu_item_check>
+
             <menu_item_separator/>
+
             <menu_item_call
              label="Close Window"
              name="Close Window"
@@ -1449,7 +1493,9 @@
                 <menu_item_call.on_enable
                  function="File.EnableCloseAllWindows" />
             </menu_item_call>
+
             <menu_item_separator/>
+
             <menu_item_call
              label="Snapshot to Disk"
              name="Snapshot to Disk"
@@ -1458,7 +1504,9 @@
                 <menu_item_call.on_click
                  function="File.TakeSnapshotToDisk" />
             </menu_item_call>
+
             <menu_item_separator/>
+
             <menu_item_call
              label="Mouselook"
              name="Mouselook"
@@ -1495,7 +1543,9 @@
                 <menu_item_call.on_enable
                  function="View.EnableLastChatter" />
             </menu_item_call>
+
             <menu_item_separator/>
+
             <menu
              create_jump_keys="true"
              label="Select Build Tool"
@@ -1542,7 +1592,9 @@
                      parameter="land" />
                 </menu_item_call>
             </menu>
+
             <menu_item_separator/>
+
             <menu_item_call
              label="Zoom In"
              name="Zoom In"
@@ -1565,7 +1617,9 @@
                  function="View.ZoomOut" />
             </menu_item_call>
         </menu>
+
         <menu_item_separator/>
+
         <menu_item_call
          label="Show Debug Settings"
          name="Debug Settings">
@@ -1675,7 +1729,9 @@
                  function="Advanced.ToggleConsole"
                  parameter="memory view" />
             </menu_item_check>
+
             <menu_item_separator/>
+
             <menu_item_call
              label="Region Info to Debug Console"
              name="Region Info to Debug Console">
@@ -1697,7 +1753,9 @@
                  function="Advanced.DumpInfoToConsole"
                  parameter="capabilities" />
             </menu_item_call>
+
             <menu_item_separator/>
+
             <menu_item_check
              label="Camera"
              name="Camera">
@@ -1785,7 +1843,9 @@
                  function="ToggleControl"
                  parameter="DebugShowColor" />
             </menu_item_check>
+
             <menu_item_separator/>
+
             <menu_item_check
              label="Show Updates to Objects"
              name="Show Updates"
@@ -1797,7 +1857,9 @@
                  function="Advanced.ToggleShowObjectUpdates" />
             </menu_item_check>
         </menu>
+
         <menu_item_separator/>
+
         <menu
          create_jump_keys="true"
          label="Force an Error"
@@ -2091,9 +2153,12 @@
             <menu_item_check.on_enable
                  function="Advanced.EnableRenderFBO" />
            </menu_item_check>
+
+          <menu_item_separator />
+
           <menu_item_check
-                       label="Deferred Rendering"
-                       name="Deferred Rendering">
+                       label="Lighting and Shadows"
+                       name="Lighting and Shadows">
             <menu_item_check.on_check
              function="CheckControl"
              parameter="RenderDeferred" />
@@ -2104,7 +2169,31 @@
                  function="Advanced.EnableRenderDeferred" />
           </menu_item_check>
           <menu_item_check
-                   label="Global Illumination"
+                       label="   Shadows from Sun/Moon/Projectors"
+                       name="Shadows from Sun/Moon/Projectors">
+            <menu_item_check.on_check
+             function="Advanced.CheckRenderShadowOption"
+             parameter="RenderShadowDetail" />
+            <menu_item_check.on_click
+             function="Advanced.ClickRenderShadowOption"
+             parameter="RenderShadowDetail" />
+            <menu_item_check.on_enable
+                 function="Advanced.EnableRenderDeferredOptions" />
+          </menu_item_check>
+          <menu_item_check
+                   label="   SSAO and Shadow Smoothing"
+                   name="SSAO and Shadow Smoothing">
+            <menu_item_check.on_check
+             function="CheckControl"
+             parameter="RenderDeferredSSAO" />
+            <menu_item_check.on_click
+             function="ToggleControl"
+             parameter="RenderDeferredSSAO" />
+            <menu_item_check.on_enable
+                 function="Advanced.EnableRenderDeferredOptions" />
+          </menu_item_check>
+          <menu_item_check
+                   label="   Global Illumination (experimental)"
                    name="Global Illumination">
             <menu_item_check.on_check
              function="CheckControl"
@@ -2113,9 +2202,11 @@
              function="ToggleControl"
              parameter="RenderDeferredGI" />
             <menu_item_check.on_enable
-                 function="Advanced.EnableRenderDeferredGI" />
+                 function="Advanced.EnableRenderDeferredOptions" />
           </menu_item_check>
+
           <menu_item_separator />
+
           <menu_item_check
              label="Debug GL"
              name="Debug GL">
@@ -2197,7 +2288,7 @@
                parameter="AuditTexture" />
             </menu_item_check>
             <menu_item_check
-             label="Texture Atlas"
+             label="Texture Atlas (experimental)"
              name="Texture Atlas">
               <menu_item_check.on_check
                function="CheckControl"
@@ -2253,7 +2344,9 @@
                  function="ToggleControl"
                  parameter="AgentPause" />
             </menu_item_check>
+
             <menu_item_separator/>
+
             <menu_item_call
              label="Enable Message Log"
              name="Enable Message Log">
@@ -2266,7 +2359,9 @@
                 <menu_item_call.on_click
                  function="Advanced.DisableMessageLog" />
             </menu_item_call>
+
             <menu_item_separator/>
+
             <menu_item_check
              label="Velocity Interpolate Objects"
              name="Velocity Interpolate Objects">
@@ -2287,7 +2382,9 @@
                  function="ToggleControl"
                  parameter="PingInterpolate" />
             </menu_item_check>
+
             <menu_item_separator/>
+
             <menu_item_call
              label="Drop a Packet"
              name="Drop a Packet"
@@ -2475,6 +2572,7 @@
             </menu_item_check>
 
             <menu_item_separator />
+
             <menu_item_check
              label="Debug SelectMgr"
              name="Debug SelectMgr">
@@ -2820,7 +2918,9 @@
                  function="Advanced.DumpAvatarLocalTextures" />
             </menu_item_call>
         </menu>
+
         <menu_item_separator/>
+
         <menu_item_check
          label="HTTP Textures"
          name="HTTP Textures">
@@ -2857,7 +2957,9 @@
              function="ToggleControl"
              parameter="ShowConsoleWindow" />
         </menu_item_check>
+
         <menu_item_separator/>
+
         <menu_item_check
          label="Show Admin Menu"
          name="View Admin Options">
@@ -3192,7 +3294,9 @@
                      name="PublicIssueTrackerHelp_url"
                      parameter="WebLaunchPublicIssueHelp,http://wiki.secondlife.com/wiki/Issue_tracker" />
                 </menu_item_call>
+
                 <menu_item_separator/>
+
                 <menu_item_call
                  label="Bug Reporting 101"
                  name="Bug Reporing 101">
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 1881f85e8c1..ec6fef1a2b3 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -211,6 +211,7 @@
 			<check_box.commit_callback
 			function="Pref.VertexShaderEnable" />
 		</check_box>
+<!-- DISABLED UNTIL WE REALLY WANT TO SUPPORT THIS
     <check_box
 		control_name="RenderDeferred"
 		height="16"
@@ -272,7 +273,7 @@
         name="2"
         value="2"/>
       </combo_box>
-
+-->
       <text
   type="string"
   length="1"
-- 
GitLab


From cb20504bf09de1e6e7f2f1987b442dc3e67826b2 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 24 May 2010 14:14:18 +0100
Subject: [PATCH 440/683] EXT-7462 FIXED disable spotlight support by default

---
 indra/newview/app_settings/settings.xml | 12 ++++++++++++
 indra/newview/pipeline.cpp              |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 5fb146db1ce..335d5576203 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6672,6 +6672,18 @@
     <real>0</real>
   </map>
   
+  <key>RenderSpotLightsInNondeferred</key>
+  <map>
+    <key>Comment</key>
+    <string>Whether to support projectors as spotlights when Lighting and Shadows is disabled</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>0</integer>
+  </map>
+
   <key>RenderSpotShadowBias</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index a09cada12d8..e4b565b26bf 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4618,7 +4618,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			glLightf (gllight, GL_CONSTANT_ATTENUATION,   0.0f);
 			glLightf (gllight, GL_LINEAR_ATTENUATION,     linatten);
 			glLightf (gllight, GL_QUADRATIC_ATTENUATION,  0.0f);
-			if (light->isLightSpotlight()) // directional (spot-)light
+			if (light->isLightSpotlight() // directional (spot-)light
+			    && (LLPipeline::sRenderDeferred || gSavedSettings.getBOOL("RenderSpotLightsInNondeferred"))) // these are only rendered as GL spotlights if we're in deferred rendering mode *or* the setting forces them on
 			{
 				LLVector3 spotparams = light->getSpotLightParams();
 				LLQuaternion quat = light->getRenderRotation();
-- 
GitLab


From 1a227160d8516b31bd97d4646036c76c1e6579f0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 24 May 2010 11:29:31 -0500
Subject: [PATCH 441/683] Temprorary debugging settings tweak.

---
 indra/newview/app_settings/settings.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 9b7cc041204..b0a4c02a435 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6278,7 +6278,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>0</integer>
+      <integer>1</integer>
     </map>
     <key>RenderDebugPipeline</key>
     <map>
@@ -7735,7 +7735,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>1</integer>
+      <integer>0</integer>
     </map>
   <key>RenderUseStreamVBO</key>
   <map>
-- 
GitLab


From 7eba473723a260a1025b5a865715573b2369298e Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 24 May 2010 14:01:18 -0500
Subject: [PATCH 442/683] Fix for bad indexes on cube faces. Extra validation
 on vertex buffers.

---
 indra/llmath/llvolume.cpp            | 11 +++--
 indra/llrender/llvertexbuffer.cpp    | 34 ++++++++------
 indra/llrender/llvertexbuffer.h      |  5 +++
 indra/newview/llface.cpp             |  7 ++-
 indra/newview/llspatialpartition.cpp | 66 ++++------------------------
 indra/newview/llspatialpartition.h   |  4 +-
 indra/newview/llvovolume.cpp         |  5 ++-
 7 files changed, 51 insertions(+), 81 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 88969af4bde..31544016db1 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4173,7 +4173,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 	for (S32 i = start_face; i <= end_face; i++)
 	{
-		const LLVolumeFace &face = getVolumeFace((U32)i);
+		LLVolumeFace &face = mVolumeFaces[i];
 
 		LLVector3 box_center = (face.mExtents[0] + face.mExtents[1]) / 2.f;
 		LLVector3 box_size   = face.mExtents[1] - face.mExtents[0];
@@ -4235,6 +4235,10 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 						if (bi_normal != NULL)
 						{
+							if (!face.mBinormals)
+							{
+								face.createBinormals();
+							}
 							LLVector4* binormal = (LLVector4*) face.mBinormals;
 							if (binormal)
 							{
@@ -5174,7 +5178,6 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 	LLVector4a* binorm = (LLVector4a*) mBinormals;
 	LLVector2* tc = (LLVector2*) mTexCoords;
 
-	S32	vtop = mNumVertices;
 	for(int gx = 0;gx<grid_size+1;gx++){
 		for(int gy = 0;gy<grid_size+1;gy++){
 			VertexData newVert;
@@ -5220,14 +5223,14 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 				{
 					for(S32 i=5;i>=0;i--)
 					{
-						*out++ = (vtop+(gy*(grid_size+1))+gx+idxs[i]);
+						*out++ = ((gy*(grid_size+1))+gx+idxs[i]);
 					}		
 				}
 				else
 				{
 					for(S32 i=0;i<6;i++)
 					{
-						*out++ = (vtop+(gy*(grid_size+1))+gx+idxs[i]);
+						*out++ = ((gy*(grid_size+1))+gx+idxs[i]);
 					}
 				}
 			}
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 0f3c900d2bd..e6943cc5515 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -261,10 +261,8 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
 	}
 }
 
-void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const
+void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_offset) const
 {
-	llassert(mRequestedNumVerts >= 0);
-
 	if (start >= (U32) mRequestedNumVerts ||
 	    end >= (U32) mRequestedNumVerts)
 	{
@@ -279,6 +277,25 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
 		llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl;
 	}
 
+	if (gDebugGL && !useVBOs())
+	{
+		U16* idx = ((U16*) getIndicesPointer())+indices_offset;
+		for (U32 i = 0; i < count; ++i)
+		{
+			if (idx[i] < start || idx[i] > end)
+			{
+				llerrs << "Index out of range: " << idx[i] << " not in [" << start << ", " << end << "]" << llendl;
+			}
+		}
+	}
+}
+
+void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const
+{
+	validateRange(start, end, count, indices_offset);
+
+	llassert(mRequestedNumVerts >= 0);
+
 	if (mGLIndices != sGLRenderIndices)
 	{
 		llerrs << "Wrong index buffer bound." << llendl;
@@ -297,17 +314,6 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
 
 	U16* idx = ((U16*) getIndicesPointer())+indices_offset;
 
-	if (gDebugGL && !useVBOs())
-	{
-		for (U32 i = 0; i < count; ++i)
-		{
-			if (idx[i] < start || idx[i] > end)
-			{
-				llerrs << "Index out of range: " << idx[i] << " not in [" << start << ", " << end << "]" << llendl;
-			}
-		}
-	}
-
 	stop_glerror();
 	glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, 
 		idx);
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index c6fd0a9e3ca..47146a5ec4a 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -207,6 +207,11 @@ class LLVertexBuffer : public LLRefCount
 	void drawArrays(U32 mode, U32 offset, U32 count) const;
 	void drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const;
 
+	//for debugging, validate data in given range is valid
+	void validateRange(U32 start, U32 end, U32 count, U32 offset) const;
+
+	
+
 protected:	
 	S32		mNumVerts;		// Number of vertices allocated
 	S32		mNumIndices;	// Number of indices allocated
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 77e8a6fdf9b..a65ee52fa15 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -368,10 +368,13 @@ void LLFace::setDrawable(LLDrawable *drawable)
 
 void LLFace::setSize(const S32 num_vertices, const S32 num_indices)
 {
-	if (mGeomCount != num_vertices ||
+	//allocate vertices in blocks of 4 for alignment
+	S32 num_verts = (num_vertices + 0x3) & ~0x3;
+
+	if (mGeomCount != num_verts ||
 		mIndicesCount != num_indices)
 	{
-		mGeomCount    = num_vertices;
+		mGeomCount    = num_verts;
 		mIndicesCount = num_indices;
 		mVertexBuffer = NULL;
 		mLastVertexBuffer = NULL;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 77c38798d12..470c332b42b 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -512,50 +512,6 @@ void LLSpatialGroup::checkStates()
 #endif
 }
 
-void validate_draw_info(LLDrawInfo& params)
-{
-#if LL_OCTREE_PARANOIA_CHECK
-	if (params.mVertexBuffer.isNull())
-	{
-		llerrs << "Draw batch has no vertex buffer." << llendl;
-	}
-	
-	//bad range
-	if (params.mStart >= params.mEnd)
-	{
-		llerrs << "Draw batch has invalid range." << llendl;
-	}
-	
-	if (params.mEnd >= (U32) params.mVertexBuffer->getNumVerts())
-	{
-		llerrs << "Draw batch has buffer overrun error." << llendl;
-	}
-	
-	if (params.mOffset + params.mCount > (U32) params.mVertexBuffer->getNumIndices())
-	{
-		llerrs << "Draw batch has index buffer ovverrun error." << llendl;
-	}
-	
-	//bad indices
-	U16* indicesp = (U16*) params.mVertexBuffer->getIndicesPointer();
-	if (indicesp)
-	{
-		for (U32 i = params.mOffset; i < params.mOffset+params.mCount; i++)
-		{
-			if (indicesp[i] < (U16)params.mStart)
-			{
-				llerrs << "Draw batch has vertex buffer index out of range error (index too low)." << llendl;
-			}
-			
-			if (indicesp[i] > (U16)params.mEnd)
-			{
-				llerrs << "Draw batch has vertex buffer index out of range error (index too high)." << llendl;
-			}
-		}
-	}
-#endif
-}
-
 void LLSpatialGroup::validateDrawMap()
 {
 #if LL_OCTREE_PARANOIA_CHECK
@@ -565,8 +521,8 @@ void LLSpatialGroup::validateDrawMap()
 		for (drawmap_elem_t::iterator j = draw_vec.begin(); j != draw_vec.end(); ++j)
 		{
 			LLDrawInfo& params = **j;
-			
-			validate_draw_info(params);
+		
+			params.validate();
 		}
 	}
 #endif
@@ -3379,18 +3335,9 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset,
 	mDistance(0.f),
 	mDrawMode(LLRender::TRIANGLES)
 {
-	mDebugColor = (rand() << 16) + rand();
-	if (mStart >= mVertexBuffer->getRequestedVerts() ||
-		mEnd >= mVertexBuffer->getRequestedVerts())
-	{
-		llerrs << "Invalid draw info vertex range." << llendl;
-	}
+	mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset);
 
-	if (mOffset >= (U32) mVertexBuffer->getRequestedIndices() ||
-		mOffset + mCount > (U32) mVertexBuffer->getRequestedIndices())
-	{
-		llerrs << "Invalid draw info index range." << llendl;
-	}
+	mDebugColor = (rand() << 16) + rand();
 }
 
 LLDrawInfo::~LLDrawInfo()	
@@ -3406,6 +3353,11 @@ LLDrawInfo::~LLDrawInfo()
 	}
 }
 
+void LLDrawInfo::validate()
+{
+	mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset);
+}
+
 LLVertexBuffer* LLGeometryManager::createVertexBuffer(U32 type_mask, U32 usage)
 {
 	return new LLVertexBuffer(type_mask, usage);
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 67c33d5b0f7..9b252d10350 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -75,6 +75,8 @@ class LLDrawInfo : public LLRefCount
 				BOOL fullbright = FALSE, U8 bump = 0, BOOL particle = FALSE, F32 part_size = 0);
 	
 
+	void validate();
+
 	LLPointer<LLVertexBuffer> mVertexBuffer;
 	LLPointer<LLViewerTexture>     mTexture;
 	LLColor4U mGlowColor;
@@ -676,8 +678,6 @@ class LLHUDPartition : public LLBridgePartition
 	virtual void shift(const LLVector3 &offset);
 };
 
-void validate_draw_info(LLDrawInfo& params);
-
 extern const F32 SG_BOX_SIDE;
 extern const F32 SG_BOX_OFFSET;
 extern const F32 SG_BOX_RAD;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 7d80a66041e..d57a5350507 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3382,7 +3382,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 		draw_vec[idx]->mCount += facep->getIndicesCount();
 		draw_vec[idx]->mEnd += facep->getGeomCount();
 		draw_vec[idx]->mVSize = llmax(draw_vec[idx]->mVSize, facep->getVirtualSize());
-		validate_draw_info(*draw_vec[idx]);
+		draw_vec[idx]->validate();
 		update_min_max(draw_vec[idx]->mExtents[0], draw_vec[idx]->mExtents[1], facep->mExtents[0]);
 		update_min_max(draw_vec[idx]->mExtents[0], draw_vec[idx]->mExtents[1], facep->mExtents[1]);
 	}
@@ -3406,12 +3406,13 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 		}
 		draw_info->mExtents[0] = facep->mExtents[0];
 		draw_info->mExtents[1] = facep->mExtents[1];
-		validate_draw_info(*draw_info);
 
 		if (LLPipeline::sUseTriStrips)
 		{
 			draw_info->mDrawMode = LLRender::TRIANGLE_STRIP;
 		}
+
+		draw_info->validate();
 	}
 }
 
-- 
GitLab


From 8c32e3bf29337e330a313d0e4865ebd03ad9ca50 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 24 May 2010 14:03:10 -0500
Subject: [PATCH 443/683] Fix for bad indexes on cube faces. Extra validation
 on vertex buffers.

---
 indra/llmath/llvolume.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 88969af4bde..31544016db1 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4173,7 +4173,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 	for (S32 i = start_face; i <= end_face; i++)
 	{
-		const LLVolumeFace &face = getVolumeFace((U32)i);
+		LLVolumeFace &face = mVolumeFaces[i];
 
 		LLVector3 box_center = (face.mExtents[0] + face.mExtents[1]) / 2.f;
 		LLVector3 box_size   = face.mExtents[1] - face.mExtents[0];
@@ -4235,6 +4235,10 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 						if (bi_normal != NULL)
 						{
+							if (!face.mBinormals)
+							{
+								face.createBinormals();
+							}
 							LLVector4* binormal = (LLVector4*) face.mBinormals;
 							if (binormal)
 							{
@@ -5174,7 +5178,6 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 	LLVector4a* binorm = (LLVector4a*) mBinormals;
 	LLVector2* tc = (LLVector2*) mTexCoords;
 
-	S32	vtop = mNumVertices;
 	for(int gx = 0;gx<grid_size+1;gx++){
 		for(int gy = 0;gy<grid_size+1;gy++){
 			VertexData newVert;
@@ -5220,14 +5223,14 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 				{
 					for(S32 i=5;i>=0;i--)
 					{
-						*out++ = (vtop+(gy*(grid_size+1))+gx+idxs[i]);
+						*out++ = ((gy*(grid_size+1))+gx+idxs[i]);
 					}		
 				}
 				else
 				{
 					for(S32 i=0;i<6;i++)
 					{
-						*out++ = (vtop+(gy*(grid_size+1))+gx+idxs[i]);
+						*out++ = ((gy*(grid_size+1))+gx+idxs[i]);
 					}
 				}
 			}
-- 
GitLab


From a2eb86b00927439afcf27219e38e58eba421294f Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Mon, 24 May 2010 13:37:59 -0700
Subject: [PATCH 444/683] Ack. Fixed a bunch of stupid type mistakes in
 llvector4a.

---
 indra/llmath/CMakeLists.txt      |  2 ++
 indra/llmath/llvolume.cpp        | 12 ++++++------
 indra/newview/llpanelobject.cpp  | 17 +++++++++++++++++
 indra/newview/llviewerregion.cpp |  3 ++-
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt
index e93fe906505..367486eee73 100644
--- a/indra/llmath/CMakeLists.txt
+++ b/indra/llmath/CMakeLists.txt
@@ -62,6 +62,8 @@ set(llmath_HEADER_FILES
     llv4matrix3.h
     llv4matrix4.h
     llv4vector3.h
+    llvector4a.h
+    llmatrix4a.h
     llvolume.h
     llvolumemgr.h
     llsdutil_math.h
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 88969af4bde..d7d36d901de 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4126,14 +4126,14 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 
 						norm_mat.rotate(n[v1], t);
 
-						t.normalize3Fast();
+						t.normalize3fast();
 						normals.push_back(LLVector3(t[0], t[1], t[2]));
 
 						mat.affineTransform(v[v2], t);
 						vertices.push_back(LLVector3(t[0], t[1], t[2]));
 						
 						norm_mat.rotate(n[v2], t);
-						t.normalize3Fast();
+						t.normalize3fast();
 						normals.push_back(LLVector3(t[0], t[1], t[2]));
 
 						segments.push_back(vertices.size());
@@ -5349,7 +5349,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 		mCenter, cuv,
 		mesh[0+offset].mPos, tc[0],
 		mesh[1+offset].mPos, tc[1]);
-	binormal.normalize3Fast();
+	binormal.normalize3fast();
 
 	LLVector4a normal;
 	LLVector4a d0, d1;
@@ -5369,7 +5369,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 		normal.setCross3(d1, d0);
 	}
 
-	normal.normalize3Fast();
+	normal.normalize3fast();
 
 	VertexData vd;
 	vd.mPosition = mCenter;
@@ -5675,7 +5675,7 @@ void LLVolumeFace::createBinormals()
 		//normalize binormals
 		for (U32 i = 0; i < mNumVertices; i++) 
 		{
-			binorm[i].normalize3Fast();
+			binorm[i].normalize3fast();
 		}
 	}
 }
@@ -5803,7 +5803,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	{
 		mat.affineTransform(src_pos[i], dst_pos[i]);
 		norm_mat.rotate(src_norm[i], dst_norm[i]);
-		dst_norm[i].normalize3Fast();
+		dst_norm[i].normalize3fast();
 
 		dst_tc[i] = src_tc[i];
 
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 669ff3ffd6c..77f3984ecb3 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -1241,6 +1241,16 @@ void LLPanelObject::sendIsPhantom()
 	}
 }
 
+#include "llsdutil.h"
+class CostResponder : public LLHTTPClient::Responder
+{
+public:
+	CostResponder(U32 id) { mID = id; }
+	virtual void result(const LLSD& content) { llinfos << ll_pretty_print_sd(content) << llendl; }
+
+	U32 mID;
+};
+
 void LLPanelObject::sendPhysicsShapeType()
 {
 	U8 value = (U8)mComboPhysicsShapeType->getCurrentIndex();
@@ -1255,6 +1265,13 @@ void LLPanelObject::sendPhysicsShapeType()
 	{
 		llinfos << "update physics shape type not changed" << llendl;
 	}
+
+	std::string url = gAgent.getRegion()->getCapability("GetObjectCost");
+	LLSD body = LLSD::emptyArray();
+	
+	body.append(LLSelectMgr::getInstance()->getSelection()->getFirstObject()->getID());
+	
+	LLHTTPClient::post( url, body, new CostResponder(body[0].asInteger()) );
 }
 
 void LLPanelObject::sendCastShadows()
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 4fdabd7ff05..268e14674e0 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1497,6 +1497,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("FetchLibDescendents");
 	capabilityNames.append("GetTexture");
 	capabilityNames.append("GetMesh");
+	capabilityNames.append("GetObjectCost");
 	capabilityNames.append("GroupProposalBallot");
 	capabilityNames.append("HomeLocation");
 	capabilityNames.append("LandResources");
@@ -1513,13 +1514,13 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("ProvisionVoiceAccountRequest");
 	capabilityNames.append("RemoteParcelRequest");
 	capabilityNames.append("RequestTextureDownload");
-	capabilityNames.append("SimulatorFeatures");
 	capabilityNames.append("SearchStatRequest");
 	capabilityNames.append("SearchStatTracking");
 	capabilityNames.append("SendPostcard");
 	capabilityNames.append("SendUserReport");
 	capabilityNames.append("SendUserReportWithScreenshot");
 	capabilityNames.append("ServerReleaseNotes");
+	capabilityNames.append("SimulatorFeatures");
 	capabilityNames.append("StartGroupProposal");
 	capabilityNames.append("TextureStats");
 	capabilityNames.append("UntrustedSimulatorMessage");
-- 
GitLab


From 62059a05cfa2b4b08fde13122997bd2a7ebbbc67 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Mon, 24 May 2010 17:10:21 -0500
Subject: [PATCH 445/683] fix aligned malloc for osx.  reviewed by falcon.

---
 indra/llcommon/llmemory.h    | 12 ++++++++----
 indra/newview/llpolymesh.cpp |  8 ++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index f0813fb4ee3..071a122c953 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -34,13 +34,15 @@
 
 #include <stdlib.h>
 
-inline void* ll_aligned_malloc(size_t size, size_t alignment = 16) // alignment MUST be power-of-two multiple of sizeof(void*).   returned hunk MUST be freed with ll_aligned_free().
+inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free().
 {
 #if defined(LL_WINDOWS)
-	return _mm_malloc(size, alignment);
+	return _mm_malloc(size, 16);
+#elif defined(LL_DARWIN)
+	return malloc(size); // default osx malloc is 16 byte aligned.
 #else
 	void *rtn;
-	if (LL_LIKELY(0 == posix_memalign(&rtn, alignment, size)))
+	if (LL_LIKELY(0 == posix_memalign(&rtn, alignment, 16)))
 	{
 		return rtn;
 	}
@@ -51,10 +53,12 @@ inline void* ll_aligned_malloc(size_t size, size_t alignment = 16) // alignment
 #endif
 }
 
-inline void ll_aligned_free(void *p)
+inline void ll_aligned_free_16(void *p)
 {
 #if defined(LL_WINDOWS)
 	_mm_free(p);
+#elif defined(LL_DARWIN)
+	return free(p);
 #else
 	free(p); // posix_memalign() is compatible with heap deallocator
 #endif
diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp
index d0164c10338..d10e4fee3a0 100644
--- a/indra/newview/llpolymesh.cpp
+++ b/indra/newview/llpolymesh.cpp
@@ -141,7 +141,7 @@ void LLPolyMeshSharedData::freeMeshData()
 		delete [] mDetailTexCoords;
 		mDetailTexCoords = NULL;
 
-		_mm_free(mWeights);
+		ll_aligned_free_16(mWeights);
 		mWeights = NULL;
 	}
 
@@ -231,7 +231,7 @@ BOOL LLPolyMeshSharedData::allocateVertexData( U32 numVertices )
 	mBaseBinormals = new LLVector3[ numVertices ];
 	mTexCoords = new LLVector2[ numVertices ];
 	mDetailTexCoords = new LLVector2[ numVertices ];
-	mWeights = (F32*) _mm_malloc((numVertices*sizeof(F32)+0xF) & ~0xF, 16);
+	mWeights = (F32*) ll_aligned_malloc_16((numVertices*sizeof(F32)+0xF) & ~0xF);
 	for (i = 0; i < numVertices; i++)
 	{
 		mWeights[i] = 0.f;
@@ -716,7 +716,7 @@ LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_
 		int nfloats = nverts * (2*4 + 3*3 + 2 + 4);
 
 		//use aligned vertex data to make LLPolyMesh SSE friendly
-		mVertexData = (F32*) ll_aligned_malloc(nfloats*4, 16);
+		mVertexData = (F32*) ll_aligned_malloc_16(nfloats*4);
 		int offset = 0;
 
 		//all members must be 16-byte aligned except the last 3
@@ -767,7 +767,7 @@ LLPolyMesh::~LLPolyMesh()
 	delete [] mClothingWeights;
 	delete [] mTexCoords;
 #else
-	ll_aligned_free(mVertexData);
+	ll_aligned_free_16(mVertexData);
 #endif
 }
 
-- 
GitLab


From 9d72930328a3a7c193bd2e834d1d1ade91210e55 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Mon, 24 May 2010 17:19:07 -0500
Subject: [PATCH 446/683] fix osx build.

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

diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index edb97eef24f..b40e6af4968 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -596,7 +596,7 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 	LLVector3 v[4];
 	// LLVector3 n[4]; // unused!
 
-	F32 closest_t = 1.f;
+	// F32 closest_t = 1.f; // unused!
 
 	for (S32 i = 0;  i < mNumBlades; i++)
 	{
-- 
GitLab


From 0222829e93bf797c072057ec1dfe36188e052347 Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Mon, 24 May 2010 17:23:24 -0500
Subject: [PATCH 447/683] fix parameter mixup in linux posix_memalign.

---
 indra/llcommon/llmemory.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 071a122c953..117268cfe7b 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -42,7 +42,7 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi
 	return malloc(size); // default osx malloc is 16 byte aligned.
 #else
 	void *rtn;
-	if (LL_LIKELY(0 == posix_memalign(&rtn, alignment, 16)))
+	if (LL_LIKELY(0 == posix_memalign(&rtn, 16, size)))
 	{
 		return rtn;
 	}
-- 
GitLab


From c0b654dd4bee466a2ccbf050e532fb4a05acc549 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 24 May 2010 17:33:41 -0500
Subject: [PATCH 448/683] Fix for bad feeding of vectorized raycast.

---
 indra/llmath/llvolume.cpp | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 2ff1463b7cd..f05e6eb9d96 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4187,6 +4187,9 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 			
 			LLVector4a starta, dira;
 
+			starta.load3(start.mV);
+			dira.load3(dir.mV);
+
 			LLVector4a* p = (LLVector4a*) face.mPositions;
 
 			for (U32 tri = 0; tri < face.mNumIndices/3; tri++) 
@@ -4235,17 +4238,10 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 						if (bi_normal != NULL)
 						{
-							if (!face.mBinormals)
-							{
-								face.createBinormals();
-							}
 							LLVector4* binormal = (LLVector4*) face.mBinormals;
-							if (binormal)
-							{
-								*bi_normal = ((1.f - a - b)  * LLVector3(binormal[index1]) + 
+							*bi_normal = ((1.f - a - b)  * LLVector3(binormal[index1]) + 
 									a              * LLVector3(binormal[index2]) +
 									b              * LLVector3(binormal[index3]));
-							}
 						}
 
 					}
-- 
GitLab


From 051d55e9e417d1f70e4a0dcee0035f6e2a413792 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 24 May 2010 23:34:50 -0500
Subject: [PATCH 449/683] Terrain is no longer mutilated.

---
 indra/llrender/llvertexbuffer.cpp  |  1 -
 indra/newview/llface.cpp           | 13 ++++--
 indra/newview/llface.h             |  2 +-
 indra/newview/llvosurfacepatch.cpp | 74 +++++++++++++++++++++++++-----
 4 files changed, 71 insertions(+), 19 deletions(-)

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 18f7557da97..7f14a8d5ac8 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -1372,7 +1372,6 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
 		llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl;
 	}
 
-
 	if (data_mask & MAP_NORMAL)
 	{
 		glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index a65ee52fa15..679875e6bd2 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -366,15 +366,18 @@ void LLFace::setDrawable(LLDrawable *drawable)
 	mXform      = &drawable->mXform;
 }
 
-void LLFace::setSize(const S32 num_vertices, const S32 num_indices)
+void LLFace::setSize(S32 num_vertices, S32 num_indices, bool align)
 {
-	//allocate vertices in blocks of 4 for alignment
-	S32 num_verts = (num_vertices + 0x3) & ~0x3;
+	if (align)
+	{
+		//allocate vertices in blocks of 4 for alignment
+		S32 num_vertices = (num_vertices + 0x3) & ~0x3;
+	}
 
-	if (mGeomCount != num_verts ||
+	if (mGeomCount != num_vertices ||
 		mIndicesCount != num_indices)
 	{
-		mGeomCount    = num_verts;
+		mGeomCount    = num_vertices;
 		mIndicesCount = num_indices;
 		mVertexBuffer = NULL;
 		mLastVertexBuffer = NULL;
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index f9e9c3e0783..48909d7895e 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -166,7 +166,7 @@ class LLFace
 	S32 getColors(LLStrider<LLColor4U> &colors);
 	S32 getIndices(LLStrider<U16> &indices);
 
-	void		setSize(const S32 numVertices, const S32 num_indices = 0);
+	void		setSize(S32 numVertices, S32 num_indices = 0, bool align = false);
 	
 	BOOL		genVolumeBBoxes(const LLVolume &volume, S32 f,
 								   const LLMatrix4& mat, const LLMatrix3& inv_trans_mat, BOOL global_volume = FALSE);
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp
index ef7b1610036..eef62ddf1a1 100644
--- a/indra/newview/llvosurfacepatch.cpp
+++ b/indra/newview/llvosurfacepatch.cpp
@@ -60,27 +60,77 @@ class LLVertexBufferTerrain : public LLVertexBuffer
 		LLVertexBuffer(MAP_VERTEX | MAP_NORMAL | MAP_TEXCOORD0 | MAP_TEXCOORD1 | MAP_COLOR, GL_DYNAMIC_DRAW_ARB)
 	{
 		//texture coordinates 2 and 3 exist, but use the same data as texture coordinate 1
-		mOffsets[TYPE_TEXCOORD3] = mOffsets[TYPE_TEXCOORD2] = mOffsets[TYPE_TEXCOORD1];
-		mTypeMask |= MAP_TEXCOORD2 | MAP_TEXCOORD3;
 	};
 
-	/*// virtual
+	// virtual
 	void setupVertexBuffer(U32 data_mask) const
-	{		
-		if (LLDrawPoolTerrain::getDetailMode() == 0 || LLPipeline::sShadowRender)
+	{	
+		U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData;
+
+		//assume tex coords 2 and 3 are present
+		U32 type_mask = mTypeMask | MAP_TEXCOORD2 | MAP_TEXCOORD3;
+
+		if ((data_mask & type_mask) != data_mask)
+		{
+			llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl;
+		}
+
+		if (data_mask & MAP_NORMAL)
+		{
+			glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
+		}
+		if (data_mask & MAP_TEXCOORD3)
+		{ //substitute tex coord 0 for tex coord 3
+			glClientActiveTextureARB(GL_TEXTURE3_ARB);
+			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+			glClientActiveTextureARB(GL_TEXTURE0_ARB);
+		}
+		if (data_mask & MAP_TEXCOORD2)
+		{ //substitute tex coord 0 for tex coord 2
+			glClientActiveTextureARB(GL_TEXTURE2_ARB);
+			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+			glClientActiveTextureARB(GL_TEXTURE0_ARB);
+		}
+		if (data_mask & MAP_TEXCOORD1)
 		{
-			LLVertexBuffer::setupVertexBuffer(data_mask);
+			glClientActiveTextureARB(GL_TEXTURE1_ARB);
+			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
+			glClientActiveTextureARB(GL_TEXTURE0_ARB);
 		}
-		else if (data_mask & LLVertexBuffer::MAP_TEXCOORD1)
+		if (data_mask & MAP_BINORMAL)
 		{
-			LLVertexBuffer::setupVertexBuffer(data_mask);
+			glClientActiveTextureARB(GL_TEXTURE2_ARB);
+			glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
+			glClientActiveTextureARB(GL_TEXTURE0_ARB);
 		}
-		else
+		if (data_mask & MAP_TEXCOORD0)
 		{
-			LLVertexBuffer::setupVertexBuffer(data_mask);
+			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
 		}
-		llglassertok();		
-	}*/
+		if (data_mask & MAP_COLOR)
+		{
+			glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeOffsets[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
+		}
+		
+		if (data_mask & MAP_WEIGHT)
+		{
+			glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeOffsets[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT]));
+		}
+
+		if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
+		{
+			glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeOffsets[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4]));
+		}
+
+		if (data_mask & MAP_CLOTHWEIGHT)
+		{
+			glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  LLVertexBuffer::sTypeOffsets[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
+		}
+		if (data_mask & MAP_VERTEX)
+		{
+			glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_VERTEX], (void*)(base + 0));
+		}
+	}
 };
 
 //============================================================================
-- 
GitLab


From e6fe3b1f1aa888e4594c89154ef895b3cf5498e9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 25 May 2010 03:55:01 -0500
Subject: [PATCH 450/683] Better vectorization of various things.  Turn off
 debug gl by default.

---
 indra/llcommon/lldefs.h                 |   8 +
 indra/llmath/llvolume.cpp               | 383 +++++++++++++++---------
 indra/llmath/llvolume.h                 | 110 +++++--
 indra/newview/app_settings/settings.xml |   4 +-
 indra/newview/llface.cpp                |   8 +-
 indra/newview/llfloaterimagepreview.cpp |  20 +-
 indra/newview/llhudicon.cpp             |  43 ++-
 indra/newview/llhudtext.cpp             |   5 -
 indra/newview/llviewercamera.cpp        |  16 +-
 indra/newview/llvograss.cpp             |   7 +-
 indra/newview/llvovolume.cpp            |   2 +-
 11 files changed, 404 insertions(+), 202 deletions(-)

diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h
index f3b5ca361f8..10e6cb34bfa 100644
--- a/indra/llcommon/lldefs.h
+++ b/indra/llcommon/lldefs.h
@@ -242,5 +242,13 @@ inline LLDATATYPE llclampb(const LLDATATYPE& a)
 	return llmin(llmax(a, (LLDATATYPE)0), (LLDATATYPE)255);
 }
 
+template <class LLDATATYPE> 
+inline void llswap(LLDATATYPE& lhs, LLDATATYPE& rhs)
+{
+	LLDATATYPE tmp = lhs;
+	lhs = rhs;
+	rhs = tmp;
+}
+
 #endif // LL_LLDEFS_H
 
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index f05e6eb9d96..d8fbc081fa6 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -237,6 +237,21 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 	return TRUE;
 } 
 
+//helper for non-aligned vectors
+BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
+							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided)
+{
+	LLVector4a vert0a, vert1a, vert2a, origa, dira;
+	vert0a.load3(vert0.mV);
+	vert1a.load3(vert1.mV);
+	vert2a.load3(vert2.mV);
+	origa.load3(orig.mV);
+	dira.load3(dir.mV);
+
+	return LLTriangleRayIntersect(vert0a, vert1a, vert2a, origa, dira, 
+			intersection_a, intersection_b, intersection_t, two_sided);
+}
+
 
 //-------------------------------------------------------------------
 // statics
@@ -1889,15 +1904,15 @@ bool LLVolumeFace::VertexData::operator==(const LLVolumeFace::VertexData& rhs)co
 bool LLVolumeFace::VertexData::compareNormal(const LLVolumeFace::VertexData& rhs, F32 angle_cutoff) const
 {
 	bool retval = false;
-	if (rhs.mPosition == mPosition && rhs.mTexCoord == mTexCoord)
+	if (rhs.mData[POSITION].equal3(mData[POSITION]) && rhs.mTexCoord == mTexCoord)
 	{
 		if (angle_cutoff > 1.f)
 		{
-			retval = (mNormal == rhs.mNormal);
+			retval = (mData[NORMAL].equal3(rhs.mData[NORMAL]));
 		}
 		else
 		{
-			F32 cur_angle = rhs.mNormal*mNormal;
+			F32 cur_angle = rhs.mData[NORMAL].dot3(mData[NORMAL]);
 			retval = cur_angle > angle_cutoff;
 		}
 	}
@@ -2081,9 +2096,9 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 			min = max = LLVector3(0,0,0);
 
-			F32* pos_out = face.mPositions;
-			F32* norm_out = face.mNormals;
-			F32* tc_out = face.mTexCoords;
+			F32* pos_out = (F32*) face.mPositions;
+			F32* norm_out = (F32*) face.mNormals;
+			F32* tc_out = (F32*) face.mTexCoords;
 
 			for (U32 j = 0; j < num_verts; ++j)
 			{
@@ -2188,13 +2203,15 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 void tetrahedron_set_normal(LLVolumeFace::VertexData* cv)
 {
-	LLVector3 nrm = (cv[1].mPosition-cv[0].mPosition)%(cv[2].mPosition-cv[0].mPosition);
-
-	nrm.normVec();
-
-	cv[0].mNormal = nrm;
-	cv[1].mNormal = nrm;
-	cv[2].mNormal = nrm;
+	LLVector4a v0;
+	v0.setSub(cv[1].getPosition(), cv[0].getNormal());
+	LLVector4a v1;
+	v1.setSub(cv[2].getNormal(), cv[0].getPosition());
+	
+	cv[0].getNormal().setCross3(v0,v1);
+	cv[0].getNormal().normalize3fast();
+	cv[1].setNormal(cv[0].getNormal());
+	cv[2].setNormal(cv[1].getNormal());
 }
 
 BOOL LLVolume::isTetrahedron()
@@ -2209,12 +2226,12 @@ void LLVolume::makeTetrahedron()
 	LLVolumeFace face;
 
 	F32 x = 0.25f;
-	LLVector3 p[] = 
+	LLVector4a p[] = 
 	{ //unit tetrahedron corners
-		LLVector3(x,x,x),
-		LLVector3(-x,-x,x),
-		LLVector3(-x,x,-x),
-		LLVector3(x,-x,-x)
+		LLVector4a(x,x,x),
+		LLVector4a(-x,-x,x),
+		LLVector4a(-x,x,-x),
+		LLVector4a(x,-x,-x)
 	};
 
 	face.mExtents[0].setVec(-x,-x,-x);
@@ -2229,9 +2246,9 @@ void LLVolume::makeTetrahedron()
 
 
 	//side 1
-	cv[0].mPosition = p[1];
-	cv[1].mPosition = p[0];
-	cv[2].mPosition = p[2];
+	cv[0].setPosition(p[1]);
+	cv[1].setPosition(p[0]);
+	cv[2].setPosition(p[2]);
 
 	tetrahedron_set_normal(cv);
 
@@ -2242,14 +2259,14 @@ void LLVolume::makeTetrahedron()
 	LLVector4a* n = (LLVector4a*) face.mNormals;
 	LLVector2* tc = (LLVector2*) face.mTexCoords;
 
-	v[0].load3(cv[0].mPosition.mV);
-	v[1].load3(cv[1].mPosition.mV);
-	v[2].load3(cv[2].mPosition.mV);
+	v[0] = cv[0].getPosition();
+	v[1] = cv[1].getPosition();
+	v[2] = cv[2].getPosition();
 	v += 3;
 
-	n[0].load3(cv[0].mNormal.mV);
-	n[1].load3(cv[1].mNormal.mV);
-	n[2].load3(cv[2].mNormal.mV);
+	n[0] = cv[0].getNormal();
+	n[1] = cv[1].getNormal();
+	n[2] = cv[2].getNormal();
 	n += 3;
 
 	tc[0] = cv[0].mTexCoord;
@@ -2259,20 +2276,20 @@ void LLVolume::makeTetrahedron()
 
 	
 	//side 2
-	cv[0].mPosition = p[3];
-	cv[1].mPosition = p[0];
-	cv[2].mPosition = p[1];
+	cv[0].setPosition(p[3]);
+	cv[1].setPosition(p[0]);
+	cv[2].setPosition(p[1]);
 
 	tetrahedron_set_normal(cv);
 
-	v[0].load3(cv[0].mPosition.mV);
-	v[1].load3(cv[1].mPosition.mV);
-	v[2].load3(cv[2].mPosition.mV);
+	v[0] = cv[0].getPosition();
+	v[1] = cv[1].getPosition();
+	v[2] = cv[2].getPosition();
 	v += 3;
 
-	n[0].load3(cv[0].mNormal.mV);
-	n[1].load3(cv[1].mNormal.mV);
-	n[2].load3(cv[2].mNormal.mV);
+	n[0] = cv[0].getNormal();
+	n[1] = cv[1].getNormal();
+	n[2] = cv[2].getNormal();
 	n += 3;
 
 	tc[0] = cv[0].mTexCoord;
@@ -2281,20 +2298,20 @@ void LLVolume::makeTetrahedron()
 	tc += 3;
 	
 	//side 3
-	cv[0].mPosition = p[3];
-	cv[1].mPosition = p[1];
-	cv[2].mPosition = p[2];
+	cv[0].setPosition(p[3]);
+	cv[1].setPosition(p[1]);
+	cv[2].setPosition(p[2]);
 
 	tetrahedron_set_normal(cv);
 
-	v[0].load3(cv[0].mPosition.mV);
-	v[1].load3(cv[1].mPosition.mV);
-	v[2].load3(cv[2].mPosition.mV);
+	v[0] = cv[0].getPosition();
+	v[1] = cv[1].getPosition();
+	v[2] = cv[2].getPosition();
 	v += 3;
 
-	n[0].load3(cv[0].mNormal.mV);
-	n[1].load3(cv[1].mNormal.mV);
-	n[2].load3(cv[2].mNormal.mV);
+	n[0] = cv[0].getNormal();
+	n[1] = cv[1].getNormal();
+	n[2] = cv[2].getNormal();
 	n += 3;
 
 	tc[0] = cv[0].mTexCoord;
@@ -2303,20 +2320,20 @@ void LLVolume::makeTetrahedron()
 	tc += 3;
 	
 	//side 4
-	cv[0].mPosition = p[2];
-	cv[1].mPosition = p[0];
-	cv[2].mPosition = p[3];
+	cv[0].setPosition(p[2]);
+	cv[1].setPosition(p[0]);
+	cv[2].setPosition(p[3]);
 
 	tetrahedron_set_normal(cv);
 
-	v[0].load3(cv[0].mPosition.mV);
-	v[1].load3(cv[1].mPosition.mV);
-	v[2].load3(cv[2].mPosition.mV);
+	v[0] = cv[0].getPosition();
+	v[1] = cv[1].getPosition();
+	v[2] = cv[2].getPosition();
 	v += 3;
 
-	n[0].load3(cv[0].mNormal.mV);
-	n[1].load3(cv[1].mNormal.mV);
-	n[2].load3(cv[2].mNormal.mV);
+	n[0] = cv[0].getNormal();
+	n[1] = cv[1].getNormal();
+	n[2] = cv[2].getNormal();
 	n += 3;
 
 	tc[0] = cv[0].mTexCoord;
@@ -3974,9 +3991,9 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 				S32 v3 = face.mIndices[j*3+2];
 
 				//get current face center
-				LLVector3 cCenter = (face.mVertices[v1].mPosition + 
-									face.mVertices[v2].mPosition + 
-									face.mVertices[v3].mPosition) / 3.0f;
+				LLVector3 cCenter = (face.mVertices[v1].getPosition() + 
+									face.mVertices[v2].getPosition() + 
+									face.mVertices[v3].getPosition()) / 3.0f;
 
 				//for each edge
 				for (S32 k = 0; k < 3; k++) {
@@ -3994,9 +4011,9 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 					v3 = face.mIndices[nIndex*3+2];
 
 					//get neighbor face center
-					LLVector3 nCenter = (face.mVertices[v1].mPosition + 
-									face.mVertices[v2].mPosition + 
-									face.mVertices[v3].mPosition) / 3.0f;
+					LLVector3 nCenter = (face.mVertices[v1].getPosition() + 
+									face.mVertices[v2].getPosition() + 
+									face.mVertices[v3].getPosition()) / 3.0f;
 
 					//draw line
 					vertices.push_back(cCenter);
@@ -4020,14 +4037,14 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 
 			//for each vertex
 			for (U32 j = 0; j < face.mNumVertices; j++) {
-				vertices.push_back(face.mVertices[j].mPosition);
-				vertices.push_back(face.mVertices[j].mPosition + face.mVertices[j].mNormal*0.1f);
+				vertices.push_back(face.mVertices[j].getPosition());
+				vertices.push_back(face.mVertices[j].getPosition() + face.mVertices[j].getNormal()*0.1f);
 				normals.push_back(LLVector3(0,0,1));
 				normals.push_back(LLVector3(0,0,1));
 				segments.push_back(vertices.size());
 #if DEBUG_SILHOUETTE_BINORMALS
-				vertices.push_back(face.mVertices[j].mPosition);
-				vertices.push_back(face.mVertices[j].mPosition + face.mVertices[j].mBinormal*0.1f);
+				vertices.push_back(face.mVertices[j].getPosition());
+				vertices.push_back(face.mVertices[j].getPosition() + face.mVertices[j].mBinormal*0.1f);
 				normals.push_back(LLVector3(0,0,1));
 				normals.push_back(LLVector3(0,0,1));
 				segments.push_back(vertices.size());
@@ -5038,9 +5055,15 @@ BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
 	}
 }
 
+void LLVolumeFace::getVertexData(U16 index, LLVolumeFace::VertexData& cv)
+{
+	cv.setPosition(mPositions[index]);
+	cv.setNormal(mNormals[index]);
+	cv.mTexCoord = mTexCoords[index];
+}
+
 void LLVolumeFace::optimize(F32 angle_cutoff)
 {
-#if 0 //disabling until a vectorized version is available
 	LLVolumeFace new_face;
 
 	VertexMapData::PointMap point_map;
@@ -5050,10 +5073,11 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 	{
 		U16 index = mIndices[i];
 
-		LLVolumeFace::VertexData cv = mVertices[index];
-
+		LLVolumeFace::VertexData cv;
+		getVertexData(index, cv);
+		
 		BOOL found = FALSE;
-		VertexMapData::PointMap::iterator point_iter = point_map.find(cv.mPosition);
+		VertexMapData::PointMap::iterator point_iter = point_map.find(cv.getPosition());
 		if (point_iter != point_map.end())
 		{ //duplicate point might exist
 			for (U32 j = 0; j < point_iter->second.size(); ++j)
@@ -5062,7 +5086,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 				if (tv.compareNormal(cv, angle_cutoff))
 				{
 					found = TRUE;
-					new_face.mIndices.push_back((point_iter->second)[j].mIndex);
+					new_face.pushIndex((point_iter->second)[j].mIndex);
 					break;
 				}
 			}
@@ -5070,14 +5094,14 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 
 		if (!found)
 		{
-			new_face.mVertices.push_back(cv);
+			new_face.pushVertex(cv);
 			U16 index = (U16) new_face.mNumVertices-1;
-			new_face.mIndices.push_back(index);
+			new_face.pushIndex(index);
 
 			VertexMapData d;
-			d.mPosition = cv.mPosition;
+			d.setPosition(cv.getPosition());
 			d.mTexCoord = cv.mTexCoord;
-			d.mNormal = cv.mNormal;
+			d.setNormal(cv.getNormal());
 			d.mIndex = index;
 			if (point_iter != point_map.end())
 			{
@@ -5085,14 +5109,23 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 			}
 			else
 			{
-				point_map[d.mPosition].push_back(d);
+				point_map[d.getPosition()].push_back(d);
 			}
 		}
 	}
 
-	mVertices = new_face.mVertices;
-	mIndices = new_face.mIndices;
-#endif 
+	swapData(new_face);
+}
+
+void LLVolumeFace::swapData(LLVolumeFace& rhs)
+{
+	llswap(rhs.mPositions, mPositions);
+	llswap(rhs.mNormals, mNormals);
+	llswap(rhs.mBinormals, mBinormals);
+	llswap(rhs.mTexCoords, mTexCoords);
+	llswap(rhs.mIndices,mIndices);
+	llswap(rhs.mNumVertices, mNumVertices);
+	llswap(rhs.mNumIndices, mNumIndices);
 }
 
 void	LerpPlanarVertex(LLVolumeFace::VertexData& v0,
@@ -5102,10 +5135,21 @@ void	LerpPlanarVertex(LLVolumeFace::VertexData& v0,
 				   F32	coef01,
 				   F32	coef02)
 {
-	vout.mPosition = v0.mPosition + ((v1.mPosition-v0.mPosition)*coef01)+((v2.mPosition-v0.mPosition)*coef02);
+
+	LLVector4a lhs;
+	lhs.setSub(v1.getPosition(), v0.getPosition());
+	lhs.mul(coef01);
+	LLVector4a rhs;
+	rhs.setSub(v2.getPosition(), v0.getPosition());
+	rhs.mul(coef02);
+
+	rhs.add(lhs);
+	rhs.add(v0.getPosition());
+
+	vout.setPosition(rhs);
+		
 	vout.mTexCoord = v0.mTexCoord + ((v1.mTexCoord-v0.mTexCoord)*coef01)+((v2.mTexCoord-v0.mTexCoord)*coef02);
-	vout.mNormal = v0.mNormal;
-	vout.mBinormal = v0.mBinormal;
+	vout.setNormal(v0.getNormal());
 }
 
 BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
@@ -5137,16 +5181,22 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 	VertexData	corners[4];
 	VertexData baseVert;
 	for(int t = 0; t < 4; t++){
-		corners[t].mPosition = mesh[offset + (grid_size*t)].mPos;
+		corners[t].getPosition().load3( mesh[offset + (grid_size*t)].mPos.mV);
 		corners[t].mTexCoord.mV[0] = profile[grid_size*t].mV[0]+0.5f;
 		corners[t].mTexCoord.mV[1] = 0.5f - profile[grid_size*t].mV[1];
 	}
-	baseVert.mNormal = 
-		((corners[1].mPosition-corners[0].mPosition) % 
-		(corners[2].mPosition-corners[1].mPosition));
-	baseVert.mNormal.normVec();
+
+	{
+		LLVector4a lhs;
+		lhs.setSub(corners[1].getPosition(), corners[0].getPosition());
+		LLVector4a rhs;
+		rhs.setSub(corners[2].getPosition(), corners[1].getPosition());
+		baseVert.getNormal().setCross3(lhs, rhs); 
+		baseVert.getNormal().normalize3fast();
+	}
+
 	if(!(mTypeMask & TOP_MASK)){
-		baseVert.mNormal *= -1.0f;
+		baseVert.getNormal().mul(-1.0f);
 	}else{
 		//Swap the UVs on the U(X) axis for top face
 		LLVector2 swap;
@@ -5161,9 +5211,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 	LLVector4a binormal;
 	
 	calc_binormal_from_triangle( binormal,
-		corners[0].mPosition, corners[0].mTexCoord,
-		corners[1].mPosition, corners[1].mTexCoord,
-		corners[2].mPosition, corners[2].mTexCoord);
+		corners[0].getPosition(), corners[0].mTexCoord,
+		corners[1].getPosition(), corners[1].mTexCoord,
+		corners[2].getPosition(), corners[2].mTexCoord);
 
 	S32 size = (grid_size+1)*(grid_size+1);
 	resizeVertices(size);
@@ -5185,18 +5235,18 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 				(F32)gx/(F32)grid_size,
 				(F32)gy/(F32)grid_size);
 
-			(*pos++).load3(newVert.mPosition.mV);
-			(*norm++).load3(baseVert.mNormal.mV);
-			(*tc++) = newVert.mTexCoord;
-			(*binorm++).load4a((F32*) &binormal.mQ);
+			*pos++ = newVert.getPosition();
+			*norm++ = baseVert.getNormal();
+			*tc++ = newVert.mTexCoord;
+			*binorm++ = binormal;
 
 			if (gx == 0 && gy == 0)
 			{
-				min = max = newVert.mPosition;
+				min = max = LLVector3(newVert.getPosition().getF32());
 			}
 			else
 			{
-				update_min_max(min,max,newVert.mPosition);
+				update_min_max(min,max,newVert.getPosition().getF32());
 			}
 		}
 	}
@@ -5343,18 +5393,19 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	mCenter = (min+max)*0.5f;
 	cuv = (min_uv + max_uv)*0.5f;
 
+	LLVector4a center;
+	center.load3(mCenter.mV);
+
 	LLVector4a binormal;
 	calc_binormal_from_triangle(binormal,
-		mCenter, cuv,
-		mesh[0+offset].mPos, tc[0],
-		mesh[1+offset].mPos, tc[1]);
+		center, cuv,
+		pos[0], tc[0],
+		pos[1], tc[1]);
 	binormal.normalize3fast();
 
 	LLVector4a normal;
 	LLVector4a d0, d1;
-	LLVector4a center;
-
-	center.load3(mCenter.mV);
+	
 
 	d0.setSub(center, pos[0]);
 	d1.setSub(center, pos[1]);
@@ -5371,7 +5422,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	normal.normalize3fast();
 
 	VertexData vd;
-	vd.mPosition = mCenter;
+	vd.getPosition().load3(mCenter.mV);
 	vd.mTexCoord = cuv;
 	
 	if (!(mTypeMask & HOLLOW_MASK) && !(mTypeMask & OPEN_MASK))
@@ -5634,10 +5685,7 @@ void LLVolumeFace::createBinormals()
 		allocateBinormals(mNumVertices);
 
 		//generate binormals
-		LLStrider<LLVector3> pos;
-		pos = (LLVector3*) mPositions;
-		pos.setStride(16);
-
+		LLVector4a* pos = mPositions;
 		LLVector2* tc = (LLVector2*) mTexCoords;
 		LLVector4a* binorm = (LLVector4a*) mBinormals;
 
@@ -5690,12 +5738,12 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
 
 	if (num_verts)
 	{
-		mPositions = (F32*) _mm_malloc(num_verts*16, 16);
-		mNormals = (F32*) _mm_malloc(num_verts*16, 16);
+		mPositions = (LLVector4a*) _mm_malloc(num_verts*16, 16);
+		mNormals = (LLVector4a*) _mm_malloc(num_verts*16, 16);
 
 		//pad texture coordinate block end to allow for QWORD reads
 		S32 size = ((num_verts*8) + 0xF) & ~0xF;
-		mTexCoords = (F32*) _mm_malloc(size, 16);
+		mTexCoords = (LLVector2*) _mm_malloc(size, 16);
 	}
 	else
 	{
@@ -5707,10 +5755,61 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
 	mNumVertices = num_verts;
 }
 
+void LLVolumeFace::pushVertex(const LLVolumeFace::VertexData& cv)
+{
+	pushVertex(cv.getPosition(), cv.getNormal(), cv.mTexCoord);
+}
+
+void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, const LLVector2& tc)
+{
+	S32 new_verts = mNumVertices+1;
+	S32 new_size = new_verts*16;
+	
+	//positions
+	LLVector4a* dst = (LLVector4a*) _mm_malloc(new_size, 16);
+	if (mPositions)
+	{
+		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mPositions, new_size/4);
+		_mm_free(mPositions);
+	}
+	mPositions = dst;
+
+	//normals
+	dst = (LLVector4a*) _mm_malloc(new_size, 16);
+	if (mNormals)
+	{
+		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mNormals, new_size/4);
+		_mm_free(mNormals);
+	}
+	mNormals = dst;
+
+	//tex coords
+	new_size = ((new_verts*8)+0xF) & ~0xF;
+
+	{
+		LLVector2* dst = (LLVector2*) _mm_malloc(new_size, 16);
+		if (mTexCoords)
+		{
+			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mTexCoords, new_size/4);
+			_mm_free(mTexCoords);
+		}
+	}
+
+	//just clear binormals
+	_mm_free(mBinormals);
+	mBinormals = NULL;
+
+	mPositions[mNumVertices] = pos;
+	mNormals[mNumVertices] = norm;
+	mTexCoords[mNumVertices] = tc;
+
+	mNumVertices++;	
+}
+
 void LLVolumeFace::allocateBinormals(S32 num_verts)
 {
 	_mm_free(mBinormals);
-	mBinormals = (F32*) _mm_malloc(num_verts*16, 16);
+	mBinormals = (LLVector4a*) _mm_malloc(num_verts*16, 16);
 }
 
 
@@ -5733,6 +5832,23 @@ void LLVolumeFace::resizeIndices(S32 num_indices)
 	mNumIndices = num_indices;
 }
 
+void LLVolumeFace::pushIndex(const U16& idx)
+{
+	S32 new_count = mNumIndices + 1;
+	S32 new_size = ((new_count*2)+0xF) & ~0xF;
+
+	S32 old_size = (mNumIndices+0xF) & ~0xF;
+	if (new_size != old_size)
+	{
+		U16* dst = (U16*) _mm_malloc(new_size, 16);
+		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mIndices, new_size/4);
+		_mm_free(mIndices);
+		mIndices = dst;
+	}
+	
+	mIndices[mNumIndices++] = idx;
+}
+
 void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx)
 {
 	resizeVertices(v.size());
@@ -5740,14 +5856,9 @@ void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v,
 
 	for (U32 i = 0; i < v.size(); ++i)
 	{
-		for (U32 j = 0; j < 3; ++j)
-		{
-			mPositions[i*4+j] = v[i].mPosition[j];
-			mNormals[i*4+j] = v[i].mNormal[j];
-		}
-
-		mTexCoords[i*2+0] = v[i].mTexCoord.mV[0];
-		mTexCoords[i*2+1] = v[i].mTexCoord.mV[1];
+		mPositions[i] = v[i].getPosition();
+		mNormals[i] = v[i].getNormal();
+		mTexCoords[i] = v[i].mTexCoord;
 	}
 
 	for (U32 i = 0; i < idx.size(); ++i)
@@ -5768,13 +5879,13 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	}
 	
 	
-	F32* new_pos = (F32*) _mm_malloc(new_count*16, 16);
-	F32* new_norm = (F32*) _mm_malloc(new_count*16, 16);
-	F32* new_tc = (F32*) _mm_malloc((new_count*8+0xF) & ~0xF, 16);
+	LLVector4a* new_pos = (LLVector4a*) _mm_malloc(new_count*16, 16);
+	LLVector4a* new_norm = (LLVector4a*) _mm_malloc(new_count*16, 16);
+	LLVector2* new_tc = (LLVector2*) _mm_malloc((new_count*8+0xF) & ~0xF, 16);
 
-	LLVector4a::memcpyNonAliased16(new_pos, mPositions, new_count*4);
-	LLVector4a::memcpyNonAliased16(new_norm, mNormals, new_count*4);
-	LLVector4a::memcpyNonAliased16(new_tc, mTexCoords, new_count*2);
+	LLVector4a::memcpyNonAliased16((F32*) new_pos, (F32*) mPositions, new_count*4);
+	LLVector4a::memcpyNonAliased16((F32*) new_norm, (F32*) mNormals, new_count*4);
+	LLVector4a::memcpyNonAliased16((F32*) new_tc, (F32*) mTexCoords, new_count*2);
 
 	_mm_free(mPositions);
 	_mm_free(mNormals);
@@ -6205,24 +6316,24 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 // Fills in dummy values if the triangle has degenerate texture coordinates.
 void calc_binormal_from_triangle(LLVector4a& binormal,
 
-	const LLVector3& pos0,
+	const LLVector4a& pos0,
 	const LLVector2& tex0,
-	const LLVector3& pos1,
+	const LLVector4a& pos1,
 	const LLVector2& tex1,
-	const LLVector3& pos2,
+	const LLVector4a& pos2,
 	const LLVector2& tex2)
 {
-	LLVector4a rx0; rx0.set( pos0.mV[VX], tex0.mV[VX], tex0.mV[VY] );
-	LLVector4a rx1; rx1.set( pos1.mV[VX], tex1.mV[VX], tex1.mV[VY] );
-	LLVector4a rx2; rx2.set( pos2.mV[VX], tex2.mV[VX], tex2.mV[VY] );
+	LLVector4a rx0( pos0[VX], tex0.mV[VX], tex0.mV[VY] );
+	LLVector4a rx1( pos1[VX], tex1.mV[VX], tex1.mV[VY] );
+	LLVector4a rx2( pos2[VX], tex2.mV[VX], tex2.mV[VY] );
 	
-	LLVector4a ry0; ry0.set( pos0.mV[VY], tex0.mV[VX], tex0.mV[VY] );
-	LLVector4a ry1; ry1.set( pos1.mV[VY], tex1.mV[VX], tex1.mV[VY] );
-	LLVector4a ry2; ry2.set( pos2.mV[VY], tex2.mV[VX], tex2.mV[VY] );
+	LLVector4a ry0( pos0[VY], tex0.mV[VX], tex0.mV[VY] );
+	LLVector4a ry1( pos1[VY], tex1.mV[VX], tex1.mV[VY] );
+	LLVector4a ry2( pos2[VY], tex2.mV[VX], tex2.mV[VY] );
 
-	LLVector4a rz0; rz0.set( pos0.mV[VZ], tex0.mV[VX], tex0.mV[VY] );
-	LLVector4a rz1; rz1.set( pos1.mV[VZ], tex1.mV[VX], tex1.mV[VY] );
-	LLVector4a rz2; rz2.set( pos2.mV[VZ], tex2.mV[VX], tex2.mV[VY] );
+	LLVector4a rz0( pos0[VZ], tex0.mV[VX], tex0.mV[VY] );
+	LLVector4a rz1( pos1[VZ], tex1.mV[VX], tex1.mV[VY] );
+	LLVector4a rz2( pos2[VZ], tex2.mV[VX], tex2.mV[VY] );
 	
 	LLVector4a lhs, rhs;
 
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 911db6f94bb..aa58d6d1142 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -40,7 +40,6 @@ class LLPathParams;
 class LLVolumeParams;
 class LLProfile;
 class LLPath;
-class LLVector4a;
 class LLVolumeFace;
 class LLVolume;
 
@@ -56,6 +55,7 @@ class LLVolume;
 #include "v4coloru.h"
 #include "llrefcount.h"
 #include "llfile.h"
+#include "llvector4a.h"
 
 //============================================================================
 
@@ -794,15 +794,74 @@ class LLVolumeFace
 public:
 	class VertexData
 	{
+		enum 
+		{
+			POSITION = 0,
+			NORMAL = 1
+		};
+
+	private:
+		void init()
+		{
+			mData = (LLVector4a*) _mm_malloc(32, 16);
+		}
 	public:
-		LLVector3 mPosition;
-		LLVector3 mNormal;
-		LLVector3 mBinormal;
+		VertexData()
+		{
+			init();
+		}
+			
+		VertexData(const VertexData& rhs)
+		{
+			init();
+			LLVector4a::memcpyNonAliased16((F32*) mData, (F32*) rhs.mData, 8);
+			mTexCoord = rhs.mTexCoord;
+		}
+
+		~VertexData()
+		{
+			_mm_free(mData);
+		}
+
+		LLVector4a& getPosition()
+		{
+			return mData[POSITION];
+		}
+
+		LLVector4a& getNormal()
+		{
+			return mData[NORMAL];
+		}
+
+		const LLVector4a& getPosition() const
+		{
+			return mData[POSITION];
+		}
+
+		const LLVector4a& getNormal() const
+		{
+			return mData[NORMAL];
+		}
+		
+
+		void setPosition(const LLVector4a& pos)
+		{
+			mData[POSITION] = pos;
+		}
+
+		void setNormal(const LLVector4a& norm)
+		{
+			mData[NORMAL] = norm;
+		}
+
 		LLVector2 mTexCoord;
 
 		bool operator<(const VertexData& rhs) const;
 		bool operator==(const VertexData& rhs) const;
 		bool compareNormal(const VertexData& rhs, F32 angle_cutoff) const;
+
+	private:
+		LLVector4a* mData;
 	};
 
 	LLVolumeFace() : 
@@ -834,6 +893,13 @@ class LLVolumeFace
 	void resizeIndices(S32 num_indices);
 	void fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx);
 
+	void pushVertex(const VertexData& cv);
+	void pushVertex(const LLVector4a& pos, const LLVector4a& norm, const LLVector2& tc);
+	void pushIndex(const U16& idx);
+
+	void swapData(LLVolumeFace& rhs);
+
+	void getVertexData(U16 indx, LLVolumeFace::VertexData& cv);
 
 	class VertexMapData : public LLVolumeFace::VertexData
 	{
@@ -842,28 +908,20 @@ class LLVolumeFace
 
 		bool operator==(const LLVolumeFace::VertexData& rhs) const
 		{
-			return mPosition == rhs.mPosition &&
+			return getPosition().equal3(rhs.getPosition()) &&
 				mTexCoord == rhs.mTexCoord &&
-				mNormal == rhs.mNormal;
+				getNormal().equal3(rhs.getNormal());
 		}
 
 		struct ComparePosition
 		{
-			bool operator()(const LLVector3& a, const LLVector3& b) const
+			bool operator()(const LLVector4a& a, const LLVector4a& b) const
 			{
-				if (a.mV[0] != b.mV[0])
-				{
-					return a.mV[0] < b.mV[0];
-				}
-				if (a.mV[1] != b.mV[1])
-				{
-					return a.mV[1] < b.mV[1];
-				}
-				return a.mV[2] < b.mV[2];
+				return a.less3(b);			
 			}
 		};
 
-		typedef std::map<LLVector3, std::vector<VertexMapData>, VertexMapData::ComparePosition > PointMap;
+		typedef std::map<LLVector4a, std::vector<VertexMapData>, VertexMapData::ComparePosition > PointMap;
 	};
 
 	void optimize(F32 angle_cutoff = 2.f);
@@ -899,10 +957,10 @@ class LLVolumeFace
 	S32 mNumVertices;
 	S32 mNumIndices;
 
-	F32* mPositions;
-	F32* mNormals;
-	F32* mBinormals;
-	F32* mTexCoords;
+	LLVector4a* mPositions;
+	LLVector4a* mNormals;
+	LLVector4a* mBinormals;
+	LLVector2* mTexCoords;
 	U16* mIndices;
 
 	std::vector<S32>	mEdge;
@@ -1059,14 +1117,18 @@ std::ostream& operator<<(std::ostream &s, const LLVolumeParams &volume_params);
 
 void calc_binormal_from_triangle(
 		LLVector4a& binormal,
-		const LLVector3& pos0,
+		const LLVector4a& pos0,
 		const LLVector2& tex0,
-		const LLVector3& pos1,
+		const LLVector4a& pos1,
 		const LLVector2& tex1,
-		const LLVector3& pos2,
+		const LLVector4a& pos2,
 		const LLVector2& tex2);
 
 BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size);
+
+BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
+							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided);
+
 BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
 							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided);
 	
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index b0a4c02a435..9b7cc041204 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6278,7 +6278,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>1</integer>
+      <integer>0</integer>
     </map>
     <key>RenderDebugPipeline</key>
     <map>
@@ -7735,7 +7735,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>0</integer>
+      <integer>1</integer>
     </map>
   <key>RenderUseStreamVBO</key>
   <map>
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 679875e6bd2..db3c5cca33e 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1216,18 +1216,18 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		LLVector3 vf_binormal;
 		if (vf.mBinormals)
 		{
-			vf_binormal.set(vf.mBinormals+i*4);
+			vf_binormal.setVec(vf.mBinormals[i].getF32());
 		}
 
 		LLVector3 vf_normal;
-		vf_normal.set(vf.mNormals+i*4);
+		vf_normal.set(vf.mNormals[i].getF32());
 
 		LLVector3 vf_position;
-		vf_position.set(vf.mPositions+i*4);
+		vf_position.set(vf.mPositions[i].getF32());
 
 		if (rebuild_tcoord)
 		{
-			LLVector2 tc(vf.mTexCoords+i*2);
+			LLVector2 tc(vf.mTexCoords[i]);
 		
 			if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
 			{
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index dae301ae290..28fe2a14b77 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -852,7 +852,6 @@ S8 LLImagePreviewSculpted::getType() const
 
 void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 { 
-#if 0 //VECTORIZE THIS
 	mCameraDistance = distance;
 	mCameraZoom = 1.f;
 	mCameraPitch = 0.f;
@@ -865,8 +864,8 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 	}
 
 	const LLVolumeFace &vf = mVolume->getVolumeFace(0);
-	U32 num_indices = vf.mIndices.size();
-	U32 num_vertices = vf.mVertices.size();
+	U32 num_indices = vf.mNumIndices;
+	U32 num_vertices = vf.mNumVertices;
 
 	mVertexBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL, 0);
 	mVertexBuffer->allocateBuffer(num_vertices, num_indices, TRUE);
@@ -880,10 +879,16 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 	mVertexBuffer->getIndexStrider(index_strider);
 
 	// build vertices and normals
+	LLStrider<LLVector3> pos;
+	pos = (LLVector3*) vf.mPositions; pos.setStride(16);
+	LLStrider<LLVector3> norm;
+	norm = (LLVector3*) vf.mNormals; norm.setStride(16);
+		
+
 	for (U32 i = 0; i < num_vertices; i++)
 	{
-		*(vertex_strider++) = vf.mVertices[i].mPosition;
-		LLVector3 normal = vf.mVertices[i].mNormal;
+		*(vertex_strider++) = *pos++;
+		LLVector3 normal = *norm++;
 		normal.normalize();
 		*(normal_strider++) = normal;
 	}
@@ -893,7 +898,6 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 	{
 		*(index_strider++) = vf.mIndices[i];
 	}
-#endif
 }
 
 
@@ -903,7 +907,6 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 BOOL LLImagePreviewSculpted::render()
 {
 	mNeedsUpdate = FALSE;
-#if 0 //VECTORIZE THIS
 	LLGLSUIDefault def;
 	LLGLDisable no_blend(GL_BLEND);
 	LLGLEnable cull(GL_CULL_FACE);
@@ -948,7 +951,7 @@ BOOL LLImagePreviewSculpted::render()
 	LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE);
 
 	const LLVolumeFace &vf = mVolume->getVolumeFace(0);
-	U32 num_indices = vf.mIndices.size();
+	U32 num_indices = vf.mNumIndices;
 	
 	mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL);
 
@@ -961,7 +964,6 @@ BOOL LLImagePreviewSculpted::render()
 	mVertexBuffer->draw(LLRender::TRIANGLES, num_indices, 0);
 
 	gGL.popMatrix();
-#endif
 	return TRUE;
 }
 
diff --git a/indra/newview/llhudicon.cpp b/indra/newview/llhudicon.cpp
index c7ad0bde7e6..3c5a4de7f8a 100644
--- a/indra/newview/llhudicon.cpp
+++ b/indra/newview/llhudicon.cpp
@@ -39,6 +39,7 @@
 
 #include "llviewerobject.h"
 #include "lldrawable.h"
+#include "llvector4a.h"
 #include "llviewercamera.h"
 #include "llviewertexture.h"
 #include "llviewerwindow.h"
@@ -266,26 +267,44 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 	LLVector3 x_scale = image_aspect * (F32)gViewerWindow->getWindowHeightScaled() * mScale * scale_factor * x_pixel_vec;
 	LLVector3 y_scale = (F32)gViewerWindow->getWindowHeightScaled() * mScale * scale_factor * y_pixel_vec;
 
-	LLVector3 lower_left = icon_position - (x_scale * 0.5f);
-	LLVector3 lower_right = icon_position + (x_scale * 0.5f);
-	LLVector3 upper_left = icon_position - (x_scale * 0.5f) + y_scale;
-	LLVector3 upper_right = icon_position + (x_scale * 0.5f) + y_scale;
+	LLVector4a x_scalea;
+	LLVector4a icon_positiona;
+	LLVector4a y_scalea;
 
-#if 0 //VECTORIZE THIS
-	
-	F32 t = 0.f;
-	LLVector3 dir = end-start;
+	x_scalea.load3(x_scale.mV);
+	x_scalea.mul(0.5f);
+	y_scalea.load3(y_scale.mV);
+
+	icon_positiona.load3(icon_position.mV);
 
-	if (LLTriangleRayIntersect(upper_right, upper_left, lower_right, start, dir, NULL, NULL, &t, FALSE) ||
-		LLTriangleRayIntersect(upper_left, lower_left, lower_right, start, dir, NULL, NULL, &t, FALSE))
+	LLVector4a lower_left;
+	lower_left.setSub(icon_positiona, x_scalea);
+	LLVector4a lower_right;
+	lower_right.setAdd(icon_positiona, x_scalea);
+	LLVector4a upper_left;
+	upper_left.setAdd(lower_left, y_scalea);
+	LLVector4a upper_right;
+	upper_right.setAdd(lower_right, y_scalea);
+
+	F32 t = 0.f;
+	LLVector4a enda;
+	enda.load3(end.mV);
+	LLVector4a starta;
+	starta.load3(start.mV);
+	LLVector4a dir;
+	dir.setSub(enda, starta);
+
+	if (LLTriangleRayIntersect(upper_right, upper_left, lower_right, starta, dir, NULL, NULL, &t, FALSE) ||
+		LLTriangleRayIntersect(upper_left, lower_left, lower_right, starta, dir, NULL, NULL, &t, FALSE))
 	{
 		if (intersection)
 		{
-			*intersection = start + dir*t;
+			dir.mul(t);
+			starta.add(dir);
+			*intersection = LLVector3((F32*) &starta.mQ);
 		}
 		return TRUE;
 	}
-#endif
 
 	return FALSE;
 }
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 64c01d09371..9ed5d13831c 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -206,8 +206,6 @@ BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 			gGL.end();
 		}
 
-#if 0 //VECTORIZE THIS
-
 		LLVector3 dir = end-start;
 		F32 t = 0.f;
 
@@ -220,9 +218,6 @@ BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 				return TRUE;
 			}
 		}
-
-#endif
-
 	}
 
 	return FALSE;
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index 7eca2763580..cef7c4abbbf 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -38,6 +38,7 @@
 // Viewer includes
 #include "llagent.h"
 #include "llagentcamera.h"
+#include "llmatrix4a.h"
 #include "llviewercontrol.h"
 #include "llviewerobjectlist.h"
 #include "llviewerregion.h"
@@ -787,22 +788,29 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts)
 	
 	LLMatrix4 render_mat(vo_volume->getRenderRotation(), LLVector4(vo_volume->getRenderPosition()));
 
+	LLMatrix4a render_mata;
+	render_mata.loadu(render_mat);
+	LLMatrix4a mata;
+	mata.loadu(mat);
+
 	num_faces = volume->getNumVolumeFaces();
-	//VECTORIZE THIS
 	for (i = 0; i < num_faces; i++)
 	{
 		const LLVolumeFace& face = volume->getVolumeFace(i);
 				
 		for (U32 v = 0; v < face.mNumVertices; v++)
 		{
-			LLVector4 vec = LLVector4(face.mPositions+v*4) * mat;
+			const LLVector4a& src_vec = face.mPositions[v];
+			LLVector4a vec;
+			mata.affineTransform(src_vec, vec);
 
 			if (drawablep->isActive())
 			{
-				vec = vec * render_mat;	
+				LLVector4a t = vec;
+				render_mata.affineTransform(t, vec);
 			}
 
-			BOOL in_frustum = pointInFrustum(LLVector3(vec)) > 0;
+			BOOL in_frustum = pointInFrustum(LLVector3(vec.getF32())) > 0;
 
 			if (( !in_frustum && all_verts) ||
 				 (in_frustum && !all_verts))
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index b40e6af4968..d2842fd62ce 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -594,9 +594,9 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 
 	LLVector2 tc[4];
 	LLVector3 v[4];
-	// LLVector3 n[4]; // unused!
+	LLVector3 n[4];
 
-	// F32 closest_t = 1.f; // unused!
+	F32 closest_t = 1.f;
 
 	for (S32 i = 0;  i < mNumBlades; i++)
 	{
@@ -640,8 +640,6 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 		position.mV[2] += blade_height;
 		v[3]    = v1 = position + mRegionp->getOriginAgent();
 	
-#if 0 //VECTORIZE THIS
-
 		F32 a,b,t;
 
 		BOOL hit = FALSE;
@@ -704,7 +702,6 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 				}
 			}
 		}
-#endif
 	}
 
 	return ret;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index d57a5350507..8022f81f19e 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1868,7 +1868,7 @@ LLVector3 LLVOVolume::getApproximateFaceNormal(U8 face_id)
 		const LLVolumeFace& face = volume->getVolumeFace(face_id);
 		for (S32 i = 0; i < (S32)face.mNumVertices; ++i)
 		{
-			result.add(*((LLVector4a*) face.mNormals+i*4));
+			result.add(face.mNormals[i]);
 		}
 
 		LLVector3 ret((F32*) &result.mQ);
-- 
GitLab


From ccdefb25aca3c6e940a471b28146cc62a6018f01 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 25 May 2010 12:10:03 +0100
Subject: [PATCH 451/683] fix(?) another bug spotted by gcc.

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

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index db3c5cca33e..1571bab7de1 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -371,7 +371,7 @@ void LLFace::setSize(S32 num_vertices, S32 num_indices, bool align)
 	if (align)
 	{
 		//allocate vertices in blocks of 4 for alignment
-		S32 num_vertices = (num_vertices + 0x3) & ~0x3;
+		num_vertices = (num_vertices + 0x3) & ~0x3;
 	}
 
 	if (mGeomCount != num_vertices ||
-- 
GitLab


From 4c257db33b643a1bd662fd0ff8729fcf8aceb14b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 25 May 2010 12:17:33 +0100
Subject: [PATCH 452/683] fix another gcc whine.

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

diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index d2842fd62ce..91c9b762c57 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -594,7 +594,7 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 
 	LLVector2 tc[4];
 	LLVector3 v[4];
-	LLVector3 n[4];
+	//LLVector3 n[4];
 
 	F32 closest_t = 1.f;
 
-- 
GitLab


From 564a8433404ea97e5424fc12089958a2d753747f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 25 May 2010 13:27:17 +0100
Subject: [PATCH 453/683] VWR-13743 FIXED Change Request: Change double click
 action for inventory wearables DEV-33391 FIXED Change Request: Change double
 click action for inventory wearables

Pulled this from the AvP backlog and implemented it, as it's a pain point from Ben's usability findings.  And people loooove this in 3rd party viewers.
---
 indra/newview/llinventorybridge.cpp | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index ea43670da0c..10cc6fae32a 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3400,7 +3400,7 @@ openSoundPreview((void*)this);
 //send_uuid_sound_trigger(item->getAssetUUID(), 1.0);
 }
 */
-		}
+}
 
 void LLSoundBridge::previewItem()
 {
@@ -4187,21 +4187,9 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 
 void LLObjectBridge::openItem()
 {
-	LLViewerInventoryItem* item = getItem();
-
-	if (item)
-	{
-		LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel());
-	}
-
-	LLSD key;
-	key["id"] = mUUID;
-	LLSideTray::getInstance()->showPanel("sidepanel_inventory", key);
-
-	// Disable old properties floater; this is replaced by the sidepanel.
-	/*
-	  LLFloaterReg::showInstance("properties", mUUID);
-	*/
+	// object double-click action is to wear/unwear object
+	performAction(getInventoryModel(),
+		      get_is_item_worn(mUUID) ? "detach" : "attach");
 }
 
 LLFontGL::StyleFlags LLObjectBridge::getLabelStyle() const
-- 
GitLab


From 7f5cc148bf0c2b8c77205ae5cb6db9841c0654d9 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 25 May 2010 14:00:59 +0100
Subject: [PATCH 454/683] Autovectorization crashes GCC 3.1.  It's not very
 helpful anyway.  Turn it off.

---
 indra/cmake/00-Common.cmake | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 2cc8fa5e5fb..802db82091c 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -169,7 +169,8 @@ if (LINUX)
     add_definitions(-fvisibility=hidden)
     # don't catch SIGCHLD in our base application class for the viewer - some of our 3rd party libs may need their *own* SIGCHLD handler to work.  Sigh!  The viewer doesn't need to catch SIGCHLD anyway.
     add_definitions(-DLL_IGNORE_SIGCHLD)
-    add_definitions(-march=pentium3 -mfpmath=sse -ftree-vectorize)
+    add_definitions(-march=pentium3 -mfpmath=sse)
+    #add_definitions(-ftree-vectorize) # THIS CRASHES GCC 3.1-3.2
     if (NOT STANDALONE)
       # this stops us requiring a really recent glibc at runtime
       add_definitions(-fno-stack-protector)
-- 
GitLab


From c98b1b3fd9341834978aff0e841714e206d28c0a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 26 May 2010 03:29:19 -0500
Subject: [PATCH 455/683] Fully aligned llvolume

---
 indra/llmath/llvolume.cpp                  | 353 ++++++++++++++++-----
 indra/llmath/llvolume.h                    |  99 ++----
 indra/llmath/v3math.h                      |   1 -
 indra/newview/llface.cpp                   | 272 +++++++++-------
 indra/newview/llpanelprimmediacontrols.cpp |   4 +-
 indra/newview/llvovolume.cpp               |   3 +-
 6 files changed, 468 insertions(+), 264 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index d8fbc081fa6..9b6e2488e65 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -107,22 +107,27 @@ BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLV
 
 BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size)
 {
-	float fAWdU[3];
-	LLVector3 dir;
-	LLVector3 diff;
+	return LLLineSegmentBoxIntersect(start.mV, end.mV, center.mV, size.mV);
+}
+
+BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size)
+{
+	F32 fAWdU[3];
+	F32 dir[3];
+	F32 diff[3];
 
 	for (U32 i = 0; i < 3; i++)
 	{
-		dir.mV[i] = 0.5f * (end.mV[i] - start.mV[i]);
-		diff.mV[i] = (0.5f * (end.mV[i] + start.mV[i])) - center.mV[i];
-		fAWdU[i] = fabsf(dir.mV[i]);
-		if(fabsf(diff.mV[i])>size.mV[i] + fAWdU[i]) return false;
+		dir[i] = 0.5f * (end[i] - start[i]);
+		diff[i] = (0.5f * (end[i] + start[i])) - center[i];
+		fAWdU[i] = fabsf(dir[i]);
+		if(fabsf(diff[i])>size[i] + fAWdU[i]) return false;
 	}
 
 	float f;
-	f = dir.mV[1] * diff.mV[2] - dir.mV[2] * diff.mV[1];    if(fabsf(f)>size.mV[1]*fAWdU[2] + size.mV[2]*fAWdU[1])  return false;
-	f = dir.mV[2] * diff.mV[0] - dir.mV[0] * diff.mV[2];    if(fabsf(f)>size.mV[0]*fAWdU[2] + size.mV[2]*fAWdU[0])  return false;
-	f = dir.mV[0] * diff.mV[1] - dir.mV[1] * diff.mV[0];    if(fabsf(f)>size.mV[0]*fAWdU[1] + size.mV[1]*fAWdU[0])  return false;
+	f = dir[1] * diff[2] - dir[2] * diff[1];    if(fabsf(f)>size[1]*fAWdU[2] + size[2]*fAWdU[1])  return false;
+	f = dir[2] * diff[0] - dir[0] * diff[2];    if(fabsf(f)>size[0]*fAWdU[2] + size[2]*fAWdU[0])  return false;
+	f = dir[0] * diff[1] - dir[1] * diff[0];    if(fabsf(f)>size[0]*fAWdU[1] + size[1]*fAWdU[0])  return false;
 	
 	return true;
 }
@@ -1869,6 +1874,59 @@ BOOL LLVolume::generate()
 	return FALSE;
 }
 
+void LLVolumeFace::VertexData::init()
+{
+	mData = (LLVector4a*) _mm_malloc(32, 16);
+}
+
+LLVolumeFace::VertexData::VertexData()
+{
+	init();
+}
+	
+LLVolumeFace::VertexData::VertexData(const VertexData& rhs)
+{
+	init();
+	LLVector4a::memcpyNonAliased16((F32*) mData, (F32*) rhs.mData, 8);
+	mTexCoord = rhs.mTexCoord;
+}
+
+LLVolumeFace::VertexData::~VertexData()
+{
+	_mm_free(mData);
+}
+
+LLVector4a& LLVolumeFace::VertexData::getPosition()
+{
+	return mData[POSITION];
+}
+
+LLVector4a& LLVolumeFace::VertexData::getNormal()
+{
+	return mData[NORMAL];
+}
+
+const LLVector4a& LLVolumeFace::VertexData::getPosition() const
+{
+	return mData[POSITION];
+}
+
+const LLVector4a& LLVolumeFace::VertexData::getNormal() const
+{
+	return mData[NORMAL];
+}
+
+
+void LLVolumeFace::VertexData::setPosition(const LLVector4a& pos)
+{
+	mData[POSITION] = pos;
+}
+
+void LLVolumeFace::VertexData::setNormal(const LLVector4a& norm)
+{
+	mData[NORMAL] = norm;
+}
+
 bool LLVolumeFace::VertexData::operator<(const LLVolumeFace::VertexData& rhs)const
 {
 	const U8* l = (const U8*) this;
@@ -2037,7 +2095,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 
 			if (mdl[i].has("Weights"))
 			{
-				face.mWeights.resize(num_verts);
+				face.allocateWeights(num_verts);
 
 				LLSD::Binary weights = mdl[i]["Weights"];
 
@@ -2050,13 +2108,15 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 					U8 joint = weights[idx++];
 
 					U32 cur_influence = 0;
+					LLVector4 wght(0,0,0,0);
+
 					while (joint != END_INFLUENCES)
 					{
 						U16 influence = weights[idx++];
 						influence |= ((U16) weights[idx++] << 8);
 
 						F32 w = llmin((F32) influence / 65535.f, 0.99999f);
-						face.mWeights[cur_vertex].mV[cur_influence++] = (F32) joint + w;
+						wght.mV[cur_influence++] = (F32) joint + w;
 
 						if (cur_influence >= 4)
 						{
@@ -2068,6 +2128,8 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 						}
 					}
 
+					face.mWeights[cur_vertex].loadua(wght.mV);
+
 					cur_vertex++;
 				}
 
@@ -2078,62 +2140,70 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 					
 			}
 
-			LLVector3 min_pos;
-			LLVector3 max_pos;
+			LLVector3 minp;
+			LLVector3 maxp;
 			LLVector2 min_tc; 
 			LLVector2 max_tc; 
 		
-			min_pos.setValue(mdl[i]["PositionDomain"]["Min"]);
-			max_pos.setValue(mdl[i]["PositionDomain"]["Max"]);
+			minp.setValue(mdl[i]["PositionDomain"]["Min"]);
+			maxp.setValue(mdl[i]["PositionDomain"]["Max"]);
+			LLVector4a min_pos, max_pos;
+			min_pos.load3(minp.mV);
+			max_pos.load3(maxp.mV);
+
 			min_tc.setValue(mdl[i]["TexCoord0Domain"]["Min"]);
 			max_tc.setValue(mdl[i]["TexCoord0Domain"]["Max"]);
 
-			LLVector3 pos_range = max_pos - min_pos;
+			LLVector4a pos_range;
+			pos_range.setSub(max_pos, min_pos);
 			LLVector2 tc_range = max_tc - min_tc;
 
-			LLVector3& min = face.mExtents[0];
-			LLVector3& max = face.mExtents[1];
-
-			min = max = LLVector3(0,0,0);
+			LLVector4a& min = face.mExtents[0];
+			LLVector4a& max = face.mExtents[1];
 
-			F32* pos_out = (F32*) face.mPositions;
-			F32* norm_out = (F32*) face.mNormals;
-			F32* tc_out = (F32*) face.mTexCoords;
+			min.clear();
+			max.clear();
+			
+			LLVector4a* pos_out = face.mPositions;
+			LLVector4a* norm_out = face.mNormals;
+			LLVector2* tc_out = face.mTexCoords;
 
 			for (U32 j = 0; j < num_verts; ++j)
 			{
 				U16* v = (U16*) &(pos[j*3*2]);
 
-				pos_out[0] = (F32) v[0] / 65535.f * pos_range.mV[0] + min_pos.mV[0];
-				pos_out[1] = (F32) v[1] / 65535.f * pos_range.mV[1] + min_pos.mV[1];
-				pos_out[2] = (F32) v[2] / 65535.f * pos_range.mV[2] + min_pos.mV[2];
-			
+				pos_out->set((F32) v[0], (F32) v[1], (F32) v[2]);
+				pos_out->div(65535.f);
+				pos_out->mul(pos_range);
+				pos_out->add(min_pos);
 
 				if (j == 0)
 				{
-					min = max = LLVector3(pos_out);
+					min = *pos_out;
+					max = min;
 				}
 				else
 				{
-					update_min_max(min,max,pos_out);
+					min.setMin(*pos_out);
+					max.setMax(*pos_out);
 				}
 
-				pos_out += 4;
+				pos_out++;
 
 				U16* n = (U16*) &(norm[j*3*2]);
 
-				
-				norm_out[0] = (F32) n[0] / 65535.f * 2.f - 1.f;
-				norm_out[1] = (F32) n[1] / 65535.f * 2.f - 1.f;
-				norm_out[2] = (F32) n[2] / 65535.f * 2.f - 1.f;
-				norm_out += 4;
+				norm_out->set((F32) n[0], (F32) n[1], (F32) n[2]);
+				norm_out->div(65535.f);
+				norm_out->mul(2.f);
+				norm_out->sub(1.f);
+				norm_out++;
 
 				U16* t = (U16*) &(tc[j*2*2]);
 
-				tc_out[0] = (F32) t[0] / 65535.f * tc_range.mV[0] + min_tc.mV[0];
-				tc_out[1] =	(F32) t[1] / 65535.f * tc_range.mV[1] + min_tc.mV[1];
+				tc_out->mV[0] = (F32) t[0] / 65535.f * tc_range.mV[0] + min_tc.mV[0];
+				tc_out->mV[1] =	(F32) t[1] / 65535.f * tc_range.mV[1] + min_tc.mV[1];
 
-				tc_out += 8;
+				tc_out++;
 			}
 
 			
@@ -2234,8 +2304,8 @@ void LLVolume::makeTetrahedron()
 		LLVector4a(x,-x,-x)
 	};
 
-	face.mExtents[0].setVec(-x,-x,-x);
-	face.mExtents[1].setVec(x,x,x);
+	face.mExtents[0].splat(-x);
+	face.mExtents[1].splat(x);
 	
 	LLVolumeFace::VertexData cv[3];
 
@@ -4165,6 +4235,18 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, 
 								   S32 face,
 								   LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
+{
+	LLVector4a starta, enda;
+	starta.load3(start.mV);
+	enda.load3(end.mV);
+
+	return lineSegmentIntersect(starta, enda, face, intersection, tex_coord, normal, bi_normal);
+
+}
+
+S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, 
+								   S32 face,
+								   LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
 {
 	S32 hit_face = -1;
 	
@@ -4182,7 +4264,8 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 		end_face = face;
 	}
 
-	LLVector3 dir = end - start;
+	LLVector4a dir;
+	dir.setSub(end, start);
 
 	F32 closest_t = 2.f; // must be larger than 1
 	
@@ -4192,21 +4275,20 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 	{
 		LLVolumeFace &face = mVolumeFaces[i];
 
-		LLVector3 box_center = (face.mExtents[0] + face.mExtents[1]) / 2.f;
-		LLVector3 box_size   = face.mExtents[1] - face.mExtents[0];
+		LLVector4a box_center;
+		box_center.setAdd(face.mExtents[0], face.mExtents[1]);
+		box_center.mul(0.5f);
+
+		LLVector4a box_size;
+		box_size.setSub(face.mExtents[1], face.mExtents[0]);
 
-        if (LLLineSegmentBoxIntersect(start, end, box_center, box_size))
+        if (LLLineSegmentBoxIntersect(start.getF32(), end.getF32(), box_center.getF32(), box_size.getF32()))
 		{
 			if (bi_normal != NULL) // if the caller wants binormals, we may need to generate them
 			{
 				genBinormals(i);
 			}
 			
-			LLVector4a starta, dira;
-
-			starta.load3(start.mV);
-			dira.load3(dir.mV);
-
 			LLVector4a* p = (LLVector4a*) face.mPositions;
 
 			for (U32 tri = 0; tri < face.mNumIndices/3; tri++) 
@@ -4220,7 +4302,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 				if (LLTriangleRayIntersect(p[index1],
 					p[index2],
 					p[index3],
-					starta, dira, &a, &b, &t, FALSE))
+					start, dir, &a, &b, &t, FALSE))
 				{
 					if ((t >= 0.f) &&      // if hit is after start
 						(t <= 1.f) &&      // and before end
@@ -4231,7 +4313,10 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 						if (intersection != NULL)
 						{
-							*intersection = start + dir * closest_t;
+							LLVector4a intersect = dir;
+							intersect.mul(closest_t);
+							intersect.add(start);
+							intersection->set(intersect.getF32());
 						}
 
 
@@ -5029,6 +5114,107 @@ std::ostream& operator<<(std::ostream &s, const LLVolume *volumep)
 	return s;
 }
 
+LLVolumeFace::LLVolumeFace() : 
+	mID(0),
+	mTypeMask(0),
+	mBeginS(0),
+	mBeginT(0),
+	mNumS(0),
+	mNumT(0),
+	mNumVertices(0),
+	mNumIndices(0),
+	mPositions(NULL),
+	mNormals(NULL),
+	mBinormals(NULL),
+	mTexCoords(NULL),
+	mIndices(NULL),
+	mWeights(NULL)
+{
+	mExtents = (LLVector4a*) _mm_malloc(48, 16);
+	mCenter = mExtents+2;
+}
+
+LLVolumeFace::LLVolumeFace(const LLVolumeFace& src)
+{ 
+	mExtents = (LLVector4a*) _mm_malloc(48, 16);
+	mCenter = mExtents+2;
+	*this = src;
+}
+
+LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
+{
+	if (&src == this)
+	{ //self assignment, do nothing
+		return *this;
+	}
+
+	mID = src.mID;
+	mTypeMask = src.mTypeMask;
+	mBeginS = src.mBeginS;
+	mBeginT = src.mBeginT;
+	mNumS = src.mNumS;
+	mNumT = src.mNumT;
+
+	mNumVertices = 0;
+	mNumIndices = 0;
+	mPositions = NULL;
+	mNormals = NULL;
+	mBinormals = NULL;
+	mTexCoords = NULL;
+	mWeights = NULL;
+	mIndices = NULL;
+
+	LLVector4a::memcpyNonAliased16((F32*) mExtents, (F32*) src.mExtents, 12);
+
+	resizeVertices(src.mNumVertices);
+	resizeIndices(src.mNumIndices);
+
+	if (mNumVertices)
+	{
+		S32 vert_size = mNumVertices*4;
+		S32 tc_size = (mNumVertices*8+0xF) & ~0xF;
+		tc_size /= 4;
+			
+		LLVector4a::memcpyNonAliased16((F32*) mPositions, (F32*) src.mPositions, vert_size);
+		LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) src.mNormals, vert_size);
+		LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) src.mTexCoords, vert_size);
+
+		if (src.mBinormals)
+		{
+			allocateBinormals(src.mNumVertices);
+			LLVector4a::memcpyNonAliased16((F32*) mBinormals, (F32*) src.mBinormals, vert_size);
+		}
+		else
+		{
+			_mm_free(mBinormals);
+			mBinormals = NULL;
+		}
+
+		if (src.mWeights)
+		{
+			allocateWeights(src.mNumVertices);
+			LLVector4a::memcpyNonAliased16((F32*) mWeights, (F32*) src.mWeights, vert_size);
+		}
+		else
+		{
+			_mm_free(mWeights);
+			mWeights = NULL;
+		}
+	}
+
+	if (mNumIndices)
+	{
+		S32 idx_size = (mNumIndices*2+0xF) & ~0xF;
+		idx_size /= 4;
+
+		LLVector4a::memcpyNonAliased16((F32*) mIndices, (F32*) src.mIndices, idx_size);
+	}
+	
+
+	//delete 
+	return *this;
+}
+
 LLVolumeFace::~LLVolumeFace()
 {
 	_mm_free(mPositions);
@@ -5036,6 +5222,8 @@ LLVolumeFace::~LLVolumeFace()
 	_mm_free(mTexCoords);
 	_mm_free(mIndices);
 	_mm_free(mBinormals);
+	_mm_free(mWeights);
+	_mm_free(mExtents);
 }
 
 BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
@@ -5169,8 +5357,8 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 	num_vertices = (grid_size+1)*(grid_size+1);
 	num_indices = quad_count * 4;
 
-	LLVector3& min = mExtents[0];
-	LLVector3& max = mExtents[1];
+	LLVector4a& min = mExtents[0];
+	LLVector4a& max = mExtents[1];
 
 	S32 offset = 0;
 	if (mTypeMask & TOP_MASK)
@@ -5242,16 +5430,18 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 
 			if (gx == 0 && gy == 0)
 			{
-				min = max = LLVector3(newVert.getPosition().getF32());
+				min = max = newVert.getPosition();
 			}
 			else
 			{
-				update_min_max(min,max,newVert.getPosition().getF32());
+				min.setMin(newVert.getPosition());
+				max.setMax(newVert.getPosition());
 			}
 		}
 	}
 	
-	mCenter = (min + max) * 0.5f;
+	mCenter->setAdd(min, max);
+	mCenter->mul(0.5f); 
 
 	if (!partial_build)
 	{
@@ -5335,7 +5525,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	S32 max_s = volume->getProfile().getTotal();
 	S32 max_t = volume->getPath().mPath.size();
 
-	mCenter.clearVec();
+	mCenter->clear();
 
 	S32 offset = 0;
 	if (mTypeMask & TOP_MASK)
@@ -5353,8 +5543,8 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	LLVector2 cuv;
 	LLVector2 min_uv, max_uv;
 
-	LLVector3& min = mExtents[0];
-	LLVector3& max = mExtents[1];
+	LLVector4a& min = mExtents[0];
+	LLVector4a& max = mExtents[1];
 
 	LLVector2* tc = (LLVector2*) mTexCoords;
 	LLVector4a* pos = (LLVector4a*) mPositions;
@@ -5380,25 +5570,24 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 		
 		if (i == 0)
 		{
-			min = max = mesh[i+offset].mPos;
+			min = max = pos[i];
 			min_uv = max_uv = tc[i];
 		}
 		else
 		{
-			update_min_max(min,max, mesh[i+offset].mPos);
+			update_min_max(min,max,pos[i]);
 			update_min_max(min_uv, max_uv, tc[i]);
 		}
 	}
 
-	mCenter = (min+max)*0.5f;
-	cuv = (min_uv + max_uv)*0.5f;
+	mCenter->setAdd(min, max);
+	mCenter->mul(0.5f); 
 
-	LLVector4a center;
-	center.load3(mCenter.mV);
+	cuv = (min_uv + max_uv)*0.5f;
 
 	LLVector4a binormal;
 	calc_binormal_from_triangle(binormal,
-		center, cuv,
+		*mCenter, cuv,
 		pos[0], tc[0],
 		pos[1], tc[1]);
 	binormal.normalize3fast();
@@ -5407,8 +5596,8 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	LLVector4a d0, d1;
 	
 
-	d0.setSub(center, pos[0]);
-	d1.setSub(center, pos[1]);
+	d0.setSub(*mCenter, pos[0]);
+	d1.setSub(*mCenter, pos[1]);
 
 	if (mTypeMask & TOP_MASK)
 	{
@@ -5422,12 +5611,12 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	normal.normalize3fast();
 
 	VertexData vd;
-	vd.getPosition().load3(mCenter.mV);
+	vd.setPosition(*mCenter);
 	vd.mTexCoord = cuv;
 	
 	if (!(mTypeMask & HOLLOW_MASK) && !(mTypeMask & OPEN_MASK))
 	{
-		pos[num_vertices].load4a((F32*) &center.mQ);
+		pos[num_vertices] = *mCenter;
 		tc[num_vertices] = cuv;
 		num_vertices++;
 	}
@@ -5812,6 +6001,11 @@ void LLVolumeFace::allocateBinormals(S32 num_verts)
 	mBinormals = (LLVector4a*) _mm_malloc(num_verts*16, 16);
 }
 
+void LLVolumeFace::allocateWeights(S32 num_verts)
+{
+	_mm_free(mWeights);
+	mWeights = (LLVector4a*) _mm_malloc(num_verts*16, 16);
+}
 
 void LLVolumeFace::resizeIndices(S32 num_indices)
 {
@@ -5919,11 +6113,11 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 
 		if (offset == 0 && i == 0)
 		{
-			mExtents[0] = mExtents[1] = LLVector3((F32*) &(dst_pos[i].mQ));
+			mExtents[0] = mExtents[1] = dst_pos[i];
 		}
 		else
 		{
-			update_min_max(mExtents[0], mExtents[1], (F32*) &(dst_pos[i].mQ));
+			update_min_max(mExtents[0], mExtents[1], dst_pos[i]);
 		}
 	}
 
@@ -6076,18 +6270,19 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 	
 
 	//get bounding box for this side
-	LLVector3& face_min = mExtents[0];
-	LLVector3& face_max = mExtents[1];
-	mCenter.clearVec();
+	LLVector4a& face_min = mExtents[0];
+	LLVector4a& face_max = mExtents[1];
+	mCenter->clear();
 
-	face_min = face_max = LLVector3((F32*) &(pos[0].mQ));
+	face_min = face_max = pos[0];
 
 	for (U32 i = 1; i < mNumVertices; ++i)
 	{
-		update_min_max(face_min, face_max, (F32*) &(pos[i].mQ));
+		update_min_max(face_min, face_max, pos[i]);
 	}
 
-	mCenter = (face_min + face_max) * 0.5f;
+	mCenter->setAdd(face_min, face_max);
+	mCenter->mul(0.5f);
 
 	S32 cur_index = 0;
 	S32 cur_edge = 0;
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index aa58d6d1142..7c63266aab8 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -50,12 +50,13 @@ class LLVolume;
 #include "v2math.h"
 #include "v3math.h"
 #include "v4math.h"
+#include "llvector4a.h"
 #include "llquaternion.h"
 #include "llstrider.h"
 #include "v4coloru.h"
 #include "llrefcount.h"
 #include "llfile.h"
-#include "llvector4a.h"
+
 
 //============================================================================
 
@@ -801,59 +802,19 @@ class LLVolumeFace
 		};
 
 	private:
-		void init()
-		{
-			mData = (LLVector4a*) _mm_malloc(32, 16);
-		}
+		void init();
 	public:
-		VertexData()
-		{
-			init();
-		}
-			
-		VertexData(const VertexData& rhs)
-		{
-			init();
-			LLVector4a::memcpyNonAliased16((F32*) mData, (F32*) rhs.mData, 8);
-			mTexCoord = rhs.mTexCoord;
-		}
-
-		~VertexData()
-		{
-			_mm_free(mData);
-		}
-
-		LLVector4a& getPosition()
-		{
-			return mData[POSITION];
-		}
-
-		LLVector4a& getNormal()
-		{
-			return mData[NORMAL];
-		}
-
-		const LLVector4a& getPosition() const
-		{
-			return mData[POSITION];
-		}
-
-		const LLVector4a& getNormal() const
-		{
-			return mData[NORMAL];
-		}
+		VertexData();
+		VertexData(const VertexData& rhs);
+		~VertexData();
+		LLVector4a& getPosition();
+		LLVector4a& getNormal();
+		const LLVector4a& getPosition() const;
+		const LLVector4a& getNormal() const;
+		void setPosition(const LLVector4a& pos);
+		void setNormal(const LLVector4a& norm);
 		
 
-		void setPosition(const LLVector4a& pos)
-		{
-			mData[POSITION] = pos;
-		}
-
-		void setNormal(const LLVector4a& norm)
-		{
-			mData[NORMAL] = norm;
-		}
-
 		LLVector2 mTexCoord;
 
 		bool operator<(const VertexData& rhs) const;
@@ -864,22 +825,9 @@ class LLVolumeFace
 		LLVector4a* mData;
 	};
 
-	LLVolumeFace() : 
-		mID(0),
-		mTypeMask(0),
-		mBeginS(0),
-		mBeginT(0),
-		mNumS(0),
-		mNumT(0),
-		mNumVertices(0),
-		mNumIndices(0),
-		mPositions(NULL),
-		mNormals(NULL),
-		mBinormals(NULL),
-		mTexCoords(NULL),
-		mIndices(NULL)
-	{
-	}
+	LLVolumeFace();
+	LLVolumeFace(const LLVolumeFace& src);
+	LLVolumeFace& operator=(const LLVolumeFace& rhs);
 
 	~LLVolumeFace();
 
@@ -890,6 +838,7 @@ class LLVolumeFace
 
 	void resizeVertices(S32 num_verts);
 	void allocateBinormals(S32 num_verts);
+	void allocateWeights(S32 num_verts);
 	void resizeIndices(S32 num_indices);
 	void fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx);
 
@@ -944,15 +893,15 @@ class LLVolumeFace
 public:
 	S32 mID;
 	U32 mTypeMask;
-	LLVector3 mCenter;
-
+	
 	// Only used for INNER/OUTER faces
 	S32 mBeginS;
 	S32 mBeginT;
 	S32 mNumS;
 	S32 mNumT;
 
-	LLVector3 mExtents[2]; //minimum and maximum point of face
+	LLVector4a* mExtents; //minimum and maximum point of face
+	LLVector4a* mCenter;
 
 	S32 mNumVertices;
 	S32 mNumIndices;
@@ -968,7 +917,7 @@ class LLVolumeFace
 	//list of skin weights for rigged volumes
 	// format is mWeights[vertex_index].mV[influence] = <joint_index>.<weight>
 	// mWeights.size() should be empty or match mVertices.size()  
-	std::vector<LLVector4> mWeights;
+	LLVector4a* mWeights;
 
 private:
 	BOOL createUnCutCubeCap(LLVolume* volume, BOOL partial_build = FALSE);
@@ -1051,6 +1000,13 @@ class LLVolume : public LLRefCount
 							 LLVector3* normal = NULL,               // return the surface normal at the intersection point
 							 LLVector3* bi_normal = NULL             // return the surface bi-normal at the intersection point
 		);
+
+	S32 lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, 
+								   S32 face = 1,
+								   LLVector3* intersection = NULL,
+								   LLVector2* tex_coord = NULL,
+								   LLVector3* normal = NULL,
+								   LLVector3* bi_normal = NULL);
 	
 	// The following cleans up vertices and triangles,
 	// getting rid of degenerate triangles and duplicate vertices,
@@ -1124,6 +1080,7 @@ void calc_binormal_from_triangle(
 		const LLVector4a& pos2,
 		const LLVector2& tex2);
 
+BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size);
 BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size);
 
 BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index 0e7d72e958b..75c860a91eb 100644
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -36,7 +36,6 @@
 #include "llerror.h"
 #include "llmath.h"
 
-
 #include "llsd.h"
 class LLVector2;
 class LLVector4;
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index db3c5cca33e..5cdfdbacde0 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -39,6 +39,7 @@
 #include "llviewercontrol.h"
 #include "llvolume.h"
 #include "m3math.h"
+#include "llmatrix4a.h"
 #include "v3color.h"
 
 #include "lldrawpoolavatar.h"
@@ -74,35 +75,43 @@ The resulting texture coordinate <u,v> is:
 	u = 2(B dot P)
 	v = 2(T dot P)
 */
-void planarProjection(LLVector2 &tc, const LLVector3& normal,
-					  const LLVector3 &mCenter, const LLVector3& vec)
-{	//DONE!
-	LLVector3 binormal;
-	float d = normal * LLVector3(1,0,0);
+void planarProjection(LLVector2 &tc, const LLVector4a& normal,
+					  const LLVector4a &center, const LLVector4a& vec)
+{	
+	LLVector4a binormal;
+	F32 d = normal[0];
+
 	if (d >= 0.5f || d <= -0.5f)
 	{
-		binormal = LLVector3(0,1,0);
-		if (normal.mV[0] < 0)
+		if (d < 0)
 		{
-			binormal = -binormal;
+			binormal.set(0,-1,0);
+		}
+		else
+		{
+			binormal.set(0, 1, 0);
 		}
 	}
 	else
 	{
-        binormal = LLVector3(1,0,0);
-		if (normal.mV[1] > 0)
+        if (normal[1] > 0)
+		{
+			binormal.set(-1,0,0);
+		}
+		else
 		{
-			binormal = -binormal;
+			binormal.set(1,0,0);
 		}
 	}
-	LLVector3 tangent = binormal % normal;
+	LLVector4a tangent;
+	tangent.setCross3(binormal,normal);
 
-	tc.mV[1] = -((tangent*vec)*2 - 0.5f);
-	tc.mV[0] = 1.0f+((binormal*vec)*2 - 0.5f);
+	tc.mV[1] = -((tangent.dot3(vec))*2 - 0.5f);
+	tc.mV[0] = 1.0f+((binormal.dot3(vec))*2 - 0.5f);
 }
 
-void sphericalProjection(LLVector2 &tc, const LLVector3& normal,
-						 const LLVector3 &mCenter, const LLVector3& vec)
+void sphericalProjection(LLVector2 &tc, const LLVector4a& normal,
+						 const LLVector4a &mCenter, const LLVector4a& vec)
 {	//BROKEN
 	/*tc.mV[0] = acosf(vd.mNormal * LLVector3(1,0,0))/3.14159f;
 	
@@ -113,7 +122,7 @@ void sphericalProjection(LLVector2 &tc, const LLVector3& normal,
 	}*/
 }
 
-void cylindricalProjection(LLVector2 &tc, const LLVector3& normal, const LLVector3 &mCenter, const LLVector3& vec)
+void cylindricalProjection(LLVector2 &tc, const LLVector4a& normal, const LLVector4a &mCenter, const LLVector4a& vec)
 {	//BROKEN
 	/*LLVector3 binormal;
 	float d = vd.mNormal * LLVector3(1,0,0);
@@ -371,7 +380,14 @@ void LLFace::setSize(S32 num_vertices, S32 num_indices, bool align)
 	if (align)
 	{
 		//allocate vertices in blocks of 4 for alignment
-		S32 num_vertices = (num_vertices + 0x3) & ~0x3;
+		num_vertices = (num_vertices + 0x3) & ~0x3;
+	}
+	else
+	{
+		if (mDrawablep->getVOVolume())
+		{
+			llerrs << "WTF?" << llendl;
+		}
 	}
 
 	if (mGeomCount != num_vertices ||
@@ -722,6 +738,7 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
 		//	mLastVertexBuffer = NULL;
 		//}
 
+		//VECTORIZE THIS
 		LLVector3 min,max;
 	
 		if (f >= volume.getNumVolumeFaces())
@@ -732,8 +749,8 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
 		else
 		{
 			const LLVolumeFace &face = volume.getVolumeFace(f);
-			min = face.mExtents[0];
-			max = face.mExtents[1];
+			min.set(face.mExtents[0].getF32());
+			max.set(face.mExtents[1].getF32());
 		}
 
 		//min, max are in volume space, convert to drawable render space
@@ -824,18 +841,26 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position,
 		return surface_coord;
 	}
 
+	//VECTORIZE THIS
 	// see if we have a non-default mapping
     U8 texgen = getTextureEntry()->getTexGen();
 	if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
 	{
-		LLVector3 center = mDrawablep->getVOVolume()->getVolume()->getVolumeFace(mTEOffset).mCenter;
+		LLVector4a& center = *(mDrawablep->getVOVolume()->getVolume()->getVolumeFace(mTEOffset).mCenter);
 		
-		LLVector3 scale  = (mDrawablep->getVOVolume()->isVolumeGlobal()) ? LLVector3(1,1,1) : mVObjp->getScale();
-		LLVector3 volume_position = mDrawablep->getVOVolume()->agentPositionToVolume(position);
-		volume_position.scaleVec(scale);
+		LLVector4a volume_position;
+		volume_position.load3(mDrawablep->getVOVolume()->agentPositionToVolume(position).mV);
 		
-		LLVector3 volume_normal   = mDrawablep->getVOVolume()->agentDirectionToVolume(normal);
-		volume_normal.normalize();
+		if (!mDrawablep->getVOVolume()->isVolumeGlobal())
+		{
+			LLVector4a scale;
+			scale.load3(mVObjp->getScale().mV);
+			volume_position.mul(scale);
+		}
+		
+		LLVector4a volume_normal;
+		volume_normal.load3(mDrawablep->getVOVolume()->agentDirectionToVolume(normal).mV);
+		volume_normal.normalize3fast();
 		
 		switch (texgen)
 		{
@@ -928,7 +953,7 @@ static LLFastTimer::DeclareTimer FTM_FACE_GET_GEOM("Face Geom");
 
 BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 							   const S32 &f,
-								const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
+								const LLMatrix4& mat_vert_in, const LLMatrix3& mat_norm_in,
 								const U16 &index_offset,
 								bool force_rebuild)
 {
@@ -960,14 +985,18 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		}
 	}
 
-	LLStrider<LLVector3> vertices;
+	LLStrider<LLVector3> vert;
+	LLVector4a* vertices = NULL;
 	LLStrider<LLVector2> tex_coords;
 	LLStrider<LLVector2> tex_coords2;
-	LLStrider<LLVector3> normals;
+	LLVector4a* normals = NULL;
+	LLStrider<LLVector3> norm;
 	LLStrider<LLColor4U> colors;
-	LLStrider<LLVector3> binormals;
+	LLVector4a* binormals = NULL;
+	LLStrider<LLVector3> binorm;
 	LLStrider<U16> indicesp;
-	LLStrider<LLVector4> weights;
+	LLVector4a* weights = NULL;
+	LLStrider<LLVector4> wght;
 
 	BOOL full_rebuild = force_rebuild || mDrawablep->isState(LLDrawable::REBUILD_VOLUME);
 	
@@ -982,11 +1011,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		scale = mVObjp->getScale();
 	}
 	
-	BOOL rebuild_pos = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_POSITION);
-	BOOL rebuild_color = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_COLOR);
-	BOOL rebuild_tcoord = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_TCOORD);
-	BOOL rebuild_normal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
-	BOOL rebuild_binormal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_BINORMAL);
+	bool rebuild_pos = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_POSITION);
+	bool rebuild_color = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_COLOR);
+	bool rebuild_tcoord = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_TCOORD);
+	bool rebuild_normal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
+	bool rebuild_binormal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_BINORMAL);
 	bool rebuild_weights = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_WEIGHT4);
 
 	const LLTextureEntry *tep = mVObjp->getTE(f);
@@ -994,19 +1023,23 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 	if (rebuild_pos)
 	{
-		mVertexBuffer->getVertexStrider(vertices, mGeomIndex);
+		mVertexBuffer->getVertexStrider(vert, mGeomIndex);
+		vertices = (LLVector4a*) vert.get();
 	}
 	if (rebuild_normal)
 	{
-		mVertexBuffer->getNormalStrider(normals, mGeomIndex);
+		mVertexBuffer->getNormalStrider(norm, mGeomIndex);
+		normals = (LLVector4a*) norm.get();
 	}
 	if (rebuild_binormal)
 	{
-		mVertexBuffer->getBinormalStrider(binormals, mGeomIndex);
+		mVertexBuffer->getBinormalStrider(binorm, mGeomIndex);
+		binormals = (LLVector4a*) binorm.get();
 	}
 	if (rebuild_weights)
 	{
-		mVertexBuffer->getWeight4Strider(weights, mGeomIndex);
+		mVertexBuffer->getWeight4Strider(wght, mGeomIndex);
+		weights = (LLVector4a*) wght.get();
 	}
 	
 	F32 tcoord_xoffset = 0.f ;
@@ -1058,8 +1091,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 	LLVector2 tmin, tmax;
 	
-	
-
 	if (rebuild_tcoord)
 	{
 		if (tep)
@@ -1142,9 +1173,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	
 	
 	//bump setup
-	LLVector3 binormal_dir( -sin_ang, cos_ang, 0 );
-	LLVector3 bump_s_primary_light_ray;
-	LLVector3 bump_t_primary_light_ray;
+	LLVector4a binormal_dir( -sin_ang, cos_ang, 0 );
+	LLVector4a bump_s_primary_light_ray;
+	LLVector4a bump_t_primary_light_ray;
 
 	LLQuaternion bump_quat;
 	if (mDrawablep->isActive())
@@ -1196,8 +1227,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		LLVector3   moon_ray = gSky.getMoonDirection();
 		LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray;
 
-		bump_s_primary_light_ray = offset_multiple * s_scale * primary_light_ray;
-		bump_t_primary_light_ray = offset_multiple * t_scale * primary_light_ray;
+		bump_s_primary_light_ray;
+		bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV);
+		bump_t_primary_light_ray.load3((offset_multiple * t_scale * primary_light_ray).mV);
 	}
 		
 	U8 texgen = getTextureEntry()->getTexGen();
@@ -1206,45 +1238,47 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		mVObjp->getVolume()->genBinormals(f);
 	}
 
+	LLMatrix4a mat_normal;
+
+	if (rebuild_normal || rebuild_binormal || rebuild_tcoord)
+	{
+		mat_normal.loadu(mat_norm_in);
+	}
+	
 	//if it's not fullbright and has no normals, bake sunlight based on face normal
 	bool bake_sunlight = !getTextureEntry()->getFullbright() &&
 		!mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
 
-	//VECTORIZE THIS
-	for (S32 i = 0; i < num_vertices; i++)
+	if (rebuild_tcoord)
 	{
-		LLVector3 vf_binormal;
-		if (vf.mBinormals)
-		{
-			vf_binormal.setVec(vf.mBinormals[i].getF32());
-		}
+		LLVector4a scalea;
+		scalea.load3(scale.mV);
 
-		LLVector3 vf_normal;
-		vf_normal.set(vf.mNormals[i].getF32());
 
-		LLVector3 vf_position;
-		vf_position.set(vf.mPositions[i].getF32());
-
-		if (rebuild_tcoord)
-		{
+		for (S32 i = 0; i < num_vertices; i++)
+		{	
 			LLVector2 tc(vf.mTexCoords[i]);
 		
+			LLVector4a& norm = vf.mNormals[i];
+			
+			LLVector4a& center = *(vf.mCenter);
+
 			if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
 			{
-				LLVector3 vec = vf_position;
+				LLVector4a vec = vf.mPositions[i];
 			
-				vec.scaleVec(scale);
+				vec.mul(scalea);
 
 				switch (texgen)
 				{
 					case LLTextureEntry::TEX_GEN_PLANAR:
-						planarProjection(tc, vf_normal, vf.mCenter, vec);
+						planarProjection(tc, norm, center, vec);
 						break;
 					case LLTextureEntry::TEX_GEN_SPHERICAL:
-						sphericalProjection(tc, vf_normal, vf.mCenter, vec);
+						sphericalProjection(tc, norm, center, vec);
 						break;
 					case LLTextureEntry::TEX_GEN_CYLINDRICAL:
-						cylindricalProjection(tc, vf_normal, vf.mCenter, vec);
+						cylindricalProjection(tc, norm, center, vec);
 						break;
 					default:
 						break;
@@ -1351,68 +1385,84 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 			
 
 			*tex_coords++ = tc;
-		
+			
 			if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1))
 			{
-				LLVector3 tangent = vf_binormal % vf_normal;
-
-				LLMatrix3 tangent_to_object;
-				tangent_to_object.setRows(tangent, vf_binormal, vf_normal);
-				LLVector3 binormal = binormal_dir * tangent_to_object;
-				binormal = binormal * mat_normal;
-				
+				LLVector4a tangent;
+				tangent.setCross3(vf.mBinormals[i], vf.mNormals[i]);
+
+				LLMatrix4a tangent_to_object;
+				tangent_to_object.setRows(tangent, vf.mBinormals[i], vf.mNormals[i]);
+				LLVector4a t;
+				tangent_to_object.rotate(binormal_dir, t);
+				LLVector4a binormal;
+				mat_normal.rotate(t, binormal);
+					
+				//VECTORIZE THIS
 				if (mDrawablep->isActive())
 				{
-					binormal *= bump_quat;
+					LLVector3 t;
+					t.set(binormal.getF32());
+					t *= bump_quat;
+					binormal.load3(t.mV);
 				}
 
-				binormal.normVec();
-				tc += LLVector2( bump_s_primary_light_ray * tangent, bump_t_primary_light_ray * binormal );
+				binormal.normalize3fast();
+				tc += LLVector2( bump_s_primary_light_ray.dot3(tangent), bump_t_primary_light_ray.dot3(binormal) );
 				
 				*tex_coords2++ = tc;
 			}	
 		}
-			
-		if (rebuild_pos)
-		{
-			*vertices++ = vf_position * mat_vert;
-		}
-		
-		if (rebuild_normal)
-		{
-			LLVector3 normal = vf_normal * mat_normal;
-			normal.normVec();
-			
-			*normals++ = normal;
+	}
+
+	if (rebuild_pos)
+	{
+		LLMatrix4a mat_vert;
+		mat_vert.loadu(mat_vert_in);
+
+		for (S32 i = 0; i < num_vertices; i++)
+		{	
+			mat_vert.affineTransform(vf.mPositions[i], vertices[i]);
 		}
+	}
 		
-		if (rebuild_binormal)
-		{
-			LLVector3 binormal = vf_binormal * mat_normal;
-			binormal.normVec();
-			*binormals++ = binormal;
+	if (rebuild_normal)
+	{
+		for (S32 i = 0; i < num_vertices; i++)
+		{	
+			LLVector4a normal;
+			mat_normal.rotate(vf.mNormals[i], normal);
+			normal.normalize3fast();
+			normals[i] = normal;
 		}
+	}
 		
-		if (rebuild_weights && vf.mWeights.size() > i)
-		{
-			(*weights++) = vf.mWeights[i];
+	if (rebuild_binormal)
+	{
+		for (S32 i = 0; i < num_vertices; i++)
+		{	
+			LLVector4a binormal;
+			mat_normal.rotate(vf.mBinormals[i], binormal);
+			binormal.normalize3fast();
+			binormals[i] = binormal;
 		}
+	}
+	
+	if (rebuild_weights && vf.mWeights)
+	{
+		LLVector4a::memcpyNonAliased16((F32*) weights, (F32*) vf.mWeights, num_vertices/4);
+	}
 
-		if (rebuild_color)
-		{
-			if (bake_sunlight)
-			{
-				LLVector3 normal = vf_normal * mat_normal;
-				normal.normVec();
-				
-				F32 da = normal * gPipeline.mSunDir;
+	if (rebuild_color)
+	{
+		LLVector4a src;
 
-				*colors++ = LLColor4U(U8(color.mV[0]*da), U8(color.mV[1]*da), U8(color.mV[2]*da), color.mV[3]);
-			}
-			else
-			{
-				*colors++ = color;		
-			}
+		src.splat(reinterpret_cast<F32&>(color.mAll));
+
+		F32* dst = (F32*) colors.get();
+		for (S32 i = 0; i < num_vertices; i+=4)
+		{	
+			LLVector4a::copy4a(dst+i, (F32*) &src);
 		}
 	}
 
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index 0648d996851..a5804aa04e9 100644
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -574,7 +574,9 @@ void LLPanelPrimMediaControls::updateShape()
 		{
 			const LLVolumeFace& vf = volume->getVolumeFace(mTargetObjectFace);
 			
-			const LLVector3* ext = vf.mExtents;
+			LLVector3 ext[2];
+			ext[0].set(vf.mExtents[0].getF32());
+			ext[1].set(vf.mExtents[1].getF32());
 			
 			LLVector3 center = (ext[0]+ext[1])*0.5f;
 			LLVector3 size = (ext[1]-ext[0])*0.5f;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 8022f81f19e..c03ec67c796 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1602,7 +1602,8 @@ void LLVOVolume::updateFaceSize(S32 idx)
 	else
 	{
 		const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx);
-		facep->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
+		facep->setSize(vol_face.mNumVertices, vol_face.mNumIndices, 
+						true); // <--- volume faces should be padded for 16-byte alignment
 		
 	}
 }
-- 
GitLab


From 07a73b49f536ce72200b22f2626b407f249d4487 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 26 May 2010 16:46:55 +0100
Subject: [PATCH 456/683] EXT-7479 FIXED only bumpmaps of type Brightness or
 Darkness load on 2.0.2 (205107) (transplanted from
 372fb87d85f7d78c6ff285b4789bd868cb000c97)

---
 indra/newview/lldrawpoolbump.cpp  | 2 +-
 indra/newview/llviewercontrol.cpp | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index b7092f32a2f..711034a972a 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -82,7 +82,7 @@ static S32 bump_channel = -1;
 // static 
 void LLStandardBumpmap::init()
 {
-	// do nothing
+	LLStandardBumpmap::restoreGL();
 }
 
 // static 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 481c96dae3d..623950853e2 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -119,10 +119,9 @@ static bool handleTerrainDetailChanged(const LLSD& newvalue)
 
 static bool handleSetShaderChanged(const LLSD& newvalue)
 {
-	// changing shader level may invalidate existing cached bump maps, as the shader type determines the format of the bump map it expects - clear the bump cache
-	gBumpImageList.clear();
-	LLStandardBumpmap::clear();
-	LLStandardBumpmap::addstandard();
+	// changing shader level may invalidate existing cached bump maps, as the shader type determines the format of the bump map it expects - clear and repopulate the bump cache
+	gBumpImageList.destroyGL();
+	gBumpImageList.restoreGL();
 
 	LLViewerShaderMgr::instance()->setShaders();
 	return true;
-- 
GitLab


From d0a6165713aa94654f7948151c6fbbe0a7d315f2 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 26 May 2010 16:46:55 +0100
Subject: [PATCH 457/683] EXT-7479 FIXED only bumpmaps of type Brightness or
 Darkness load on 2.0.2 (205107)

---
 indra/newview/lldrawpoolbump.cpp  | 2 +-
 indra/newview/llviewercontrol.cpp | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index eefb93dc0cd..4963b95046f 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -82,7 +82,7 @@ static S32 bump_channel = -1;
 // static 
 void LLStandardBumpmap::init()
 {
-	// do nothing
+	LLStandardBumpmap::restoreGL();
 }
 
 // static 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index c9404379299..2144ab14893 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -118,10 +118,9 @@ static bool handleTerrainDetailChanged(const LLSD& newvalue)
 
 static bool handleSetShaderChanged(const LLSD& newvalue)
 {
-	// changing shader level may invalidate existing cached bump maps, as the shader type determines the format of the bump map it expects - clear the bump cache
-	gBumpImageList.clear();
-	LLStandardBumpmap::clear();
-	LLStandardBumpmap::addstandard();
+	// changing shader level may invalidate existing cached bump maps, as the shader type determines the format of the bump map it expects - clear and repopulate the bump cache
+	gBumpImageList.destroyGL();
+	gBumpImageList.restoreGL();
 
 	LLViewerShaderMgr::instance()->setShaders();
 	return true;
-- 
GitLab


From fe2419b71a3a24d221a5da99c32c257dab92fcb1 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 26 May 2010 17:31:58 +0100
Subject: [PATCH 458/683] I couldn't convince GCC that these wouldn't be used
 uninitialized, so init them (it's outside of the vertex loop at least).  Also
 fix some other gcc whines.

---
 indra/newview/llface.cpp | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 5cdfdbacde0..0f129c9d306 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1019,7 +1019,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	bool rebuild_weights = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_WEIGHT4);
 
 	const LLTextureEntry *tep = mVObjp->getTE(f);
-	U8  bump_code = tep ? tep->getBumpmap() : 0;
+	const U8 bump_code = tep ? tep->getBumpmap() : 0;
 
 	if (rebuild_pos)
 	{
@@ -1161,7 +1161,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		}
 	}
 
-    // INDICES
+	// INDICES
 	if (full_rebuild)
 	{
 		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
@@ -1173,9 +1173,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	
 	
 	//bump setup
-	LLVector4a binormal_dir( -sin_ang, cos_ang, 0 );
-	LLVector4a bump_s_primary_light_ray;
-	LLVector4a bump_t_primary_light_ray;
+	LLVector4a binormal_dir( -sin_ang, cos_ang, 0.f );
+	LLVector4a bump_s_primary_light_ray(0.f, 0.f, 0.f);
+	LLVector4a bump_t_primary_light_ray(0.f, 0.f, 0.f);
 
 	LLQuaternion bump_quat;
 	if (mDrawablep->isActive())
@@ -1227,7 +1227,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		LLVector3   moon_ray = gSky.getMoonDirection();
 		LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray;
 
-		bump_s_primary_light_ray;
 		bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV);
 		bump_t_primary_light_ray.load3((offset_multiple * t_scale * primary_light_ray).mV);
 	}
@@ -1239,15 +1238,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	}
 
 	LLMatrix4a mat_normal;
-
-	if (rebuild_normal || rebuild_binormal || rebuild_tcoord)
-	{
-		mat_normal.loadu(mat_norm_in);
-	}
+	mat_normal.loadu(mat_norm_in);
 	
 	//if it's not fullbright and has no normals, bake sunlight based on face normal
-	bool bake_sunlight = !getTextureEntry()->getFullbright() &&
-		!mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
+	//bool bake_sunlight = !getTextureEntry()->getFullbright() &&
+	//  !mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
 
 	if (rebuild_tcoord)
 	{
-- 
GitLab


From bac3623e26d62f6e1eb3c6be1f5fcfcf69a0e714 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 26 May 2010 14:55:29 -0500
Subject: [PATCH 459/683] Faster index buffer copying.

---
 indra/newview/llface.cpp     | 16 ++++++++++++++--
 indra/newview/llvovolume.cpp |  1 -
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 5cdfdbacde0..26554997c06 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1165,9 +1165,21 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	if (full_rebuild)
 	{
 		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
-		for (U32 i = 0; i < (U32) num_indices; i++)
+		__m128i* dst = (__m128i*) indicesp.get();
+		__m128i* src = (__m128i*) vf.mIndices;
+		__m128i offset = _mm_set1_epi16(index_offset);
+
+		S32 end = num_indices/8;
+		
+		for (S32 i = 0; i < end; i++)
+		{
+			__m128i res = _mm_add_epi16(src[i], offset);
+			_mm_storeu_si128(dst+i, res);
+		}
+
+		for (S32 i = end*8; i < num_indices; ++i)
 		{
-			*indicesp++ = vf.mIndices[i] + index_offset;
+			indicesp[i] = vf.mIndices[i]+index_offset;
 		}
 	}
 	
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index c03ec67c796..a9f3abeef8d 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3354,7 +3354,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 		model_mat = &(drawable->getRegion()->mRenderMatrix);
 	}
 
-
 	U8 bump = (type == LLRenderPass::PASS_BUMP || type == LLRenderPass::PASS_POST_BUMP) ? facep->getTextureEntry()->getBumpmap() : 0;
 	
 	LLViewerTexture* tex = facep->getTexture();
-- 
GitLab


From 673eef187777f4283aa2f90027f1b2ee3dadebe0 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 27 May 2010 15:14:20 +0100
Subject: [PATCH 460/683] we now require SSE_2_ so bump up the architecture for
 gcc.

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

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 802db82091c..25cc05332b9 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -169,7 +169,7 @@ if (LINUX)
     add_definitions(-fvisibility=hidden)
     # don't catch SIGCHLD in our base application class for the viewer - some of our 3rd party libs may need their *own* SIGCHLD handler to work.  Sigh!  The viewer doesn't need to catch SIGCHLD anyway.
     add_definitions(-DLL_IGNORE_SIGCHLD)
-    add_definitions(-march=pentium3 -mfpmath=sse)
+    add_definitions(-march=pentium4 -mfpmath=sse)
     #add_definitions(-ftree-vectorize) # THIS CRASHES GCC 3.1-3.2
     if (NOT STANDALONE)
       # this stops us requiring a really recent glibc at runtime
-- 
GitLab


From 383d695fe6d14ba988820475e0cc9b64e18b7de5 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 29 May 2010 06:18:02 +0100
Subject: [PATCH 461/683] EXT-7543 FIXED(maybe) - crash in
 LLRenderPass::pushBatch

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

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 4963b95046f..84fbb861bae 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -100,7 +100,10 @@ void LLStandardBumpmap::restoreGL()
 // static
 void LLStandardBumpmap::addstandard()
 {
-	llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
+	// can't assert; we destroyGL and restoreGL a lot during *first* startup, which populates this list already, THEN we explicitly init the list as part of *normal* startup.  Sigh.  So clear the list every time before we (re-)add the standard bumpmaps.
+	//llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
+	clear();
+	llinfos << "Adding standard bumpmaps." << llendl;
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("None");		// BE_NO_BUMP
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Brightness");	// BE_BRIGHTNESS
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness");	// BE_DARKNESS
@@ -164,6 +167,7 @@ void LLStandardBumpmap::addstandard()
 // static
 void LLStandardBumpmap::clear()
 {
+	llinfos << "Clearing standard bumpmaps." << llendl;
 	for( U32 i = 0; i < LLStandardBumpmap::sStandardBumpmapCount; i++ )
 	{
 		gStandardBumpmapList[i].mLabel.assign("");
@@ -817,7 +821,7 @@ void LLDrawPoolBump::renderPostDeferred(S32 pass)
 }
 
 ////////////////////////////////////////////////////////////////
-// List of one-component bump-maps created from other texures.
+// List of bump-maps created from other textures.
 
 
 //const LLUUID TEST_BUMP_ID("3d33eaf2-459c-6f97-fd76-5fce3fc29447");
@@ -832,6 +836,7 @@ void LLBumpImageList::init()
 
 void LLBumpImageList::clear()
 {
+	llinfos << "Clearing dynamic bumpmaps." << llendl;
 	// these will be re-populated on-demand
 	mBrightnessEntries.clear();
 	mDarknessEntries.clear();
-- 
GitLab


From 8b16faec3096e32b76b227efcb67fd33e7254f40 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sat, 29 May 2010 06:18:02 +0100
Subject: [PATCH 462/683] EXT-7543 FIXED(maybe) - crash in
 LLRenderPass::pushBatch (transplanted from
 3f95c322795af28d9b8f8730b9479a8925042039)

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

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 711034a972a..fb58b6affae 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -100,7 +100,10 @@ void LLStandardBumpmap::restoreGL()
 // static
 void LLStandardBumpmap::addstandard()
 {
-	llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
+	// can't assert; we destroyGL and restoreGL a lot during *first* startup, which populates this list already, THEN we explicitly init the list as part of *normal* startup.  Sigh.  So clear the list every time before we (re-)add the standard bumpmaps.
+	//llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
+	clear();
+	llinfos << "Adding standard bumpmaps." << llendl;
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("None");		// BE_NO_BUMP
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Brightness");	// BE_BRIGHTNESS
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness");	// BE_DARKNESS
@@ -164,6 +167,7 @@ void LLStandardBumpmap::addstandard()
 // static
 void LLStandardBumpmap::clear()
 {
+	llinfos << "Clearing standard bumpmaps." << llendl;
 	for( U32 i = 0; i < LLStandardBumpmap::sStandardBumpmapCount; i++ )
 	{
 		gStandardBumpmapList[i].mLabel.assign("");
@@ -858,7 +862,7 @@ void LLDrawPoolBump::renderPostDeferred(S32 pass)
 }
 
 ////////////////////////////////////////////////////////////////
-// List of one-component bump-maps created from other texures.
+// List of bump-maps created from other textures.
 
 
 //const LLUUID TEST_BUMP_ID("3d33eaf2-459c-6f97-fd76-5fce3fc29447");
@@ -873,6 +877,7 @@ void LLBumpImageList::init()
 
 void LLBumpImageList::clear()
 {
+	llinfos << "Clearing dynamic bumpmaps." << llendl;
 	// these will be re-populated on-demand
 	mBrightnessEntries.clear();
 	mDarknessEntries.clear();
-- 
GitLab


From 1655256c0c1f536593292d81b89f3580ad1dee73 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 29 May 2010 04:18:44 -0500
Subject: [PATCH 463/683] UI rendering optimization.

---
 indra/llrender/llrender.cpp | 97 ++++++++++++++++++++++---------------
 indra/llrender/llrender.h   | 13 +++--
 indra/llui/llview.cpp       | 22 ++++++---
 3 files changed, 80 insertions(+), 52 deletions(-)

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 2472339ec4c..3f70ccacb10 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -39,6 +39,7 @@
 #include "llimagegl.h"
 #include "llrendertarget.h"
 #include "lltexture.h"
+#include "llvector4a.h"
 
 LLRender gGL;
 
@@ -53,6 +54,7 @@ U32 LLRender::sUICalls = 0;
 U32 LLRender::sUIVerts = 0;
 
 static const U32 LL_NUM_TEXTURE_LAYERS = 16; 
+static const U32 LL_MAX_UI_STACK_DEPTH = 32;
 
 static GLenum sGLTextureType[] =
 {
@@ -757,14 +759,27 @@ LLRender::LLRender()
     mCount(0),
     mMode(LLRender::TRIANGLES),
     mCurrTextureUnitIndex(0),
-    mMaxAnisotropy(0.f) 
+    mMaxAnisotropy(0.f),
+	mUIStackDepth(0)
 {
 	mBuffer = new LLVertexBuffer(immediate_mask, 0);
 	mBuffer->allocateBuffer(4096, 0, TRUE);
-	mBuffer->getVertexStrider(mVerticesp);
-	mBuffer->getTexCoord0Strider(mTexcoordsp);
-	mBuffer->getColorStrider(mColorsp);
-	
+
+	LLStrider<LLVector3> vert;
+	LLStrider<LLVector2> tc;
+	LLStrider<LLColor4U> color;
+
+	mBuffer->getVertexStrider(vert);
+	mBuffer->getTexCoord0Strider(tc);
+	mBuffer->getColorStrider(color);
+
+	mVerticesp = (LLVector4a*) vert.get();
+	mTexcoordsp = tc.get();
+	mColorsp = color.get();
+
+	mUIOffset = (LLVector4a*) _mm_malloc(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a), 16);
+	mUIScale = (LLVector4a*) _mm_malloc(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a), 16);
+		
 	mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);
 	for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++)
 	{
@@ -800,6 +815,11 @@ void LLRender::shutdown()
 	mTexUnits.clear();
 	delete mDummyTexUnit;
 	mDummyTexUnit = NULL;
+
+	_mm_free(mUIOffset);
+	mUIOffset = NULL;
+	_mm_free(mUIScale);
+	mUIScale = NULL;
 }
 
 void LLRender::refreshState(void)
@@ -848,84 +868,83 @@ void LLRender::popMatrix()
 
 void LLRender::translateUI(F32 x, F32 y, F32 z)
 {
-	if (mUIOffset.empty())
+	if (mUIStackDepth == 0)
 	{
 		llerrs << "Need to push a UI translation frame before offsetting" << llendl;
 	}
 
-	mUIOffset.front().mV[0] += x;
-	mUIOffset.front().mV[1] += y;
-	mUIOffset.front().mV[2] += z;
+	LLVector4a trans(x,y,z);
+	mUIOffset[mUIStackDepth-1].add(trans);
 }
 
 void LLRender::scaleUI(F32 x, F32 y, F32 z)
 {
-	if (mUIScale.empty())
+	if (mUIStackDepth == 0)
 	{
 		llerrs << "Need to push a UI transformation frame before scaling." << llendl;
 	}
 
-	mUIScale.front().scaleVec(LLVector3(x,y,z));
+	LLVector4a scale(x,y,z);
+	mUIScale[mUIStackDepth-1].mul(scale);
 }
 
 void LLRender::pushUIMatrix()
 {
-	if (mUIOffset.empty())
+	if (mUIStackDepth == 0)
 	{
-		mUIOffset.push_front(LLVector3(0,0,0));
+		mUIOffset[0].clear();
+		mUIScale[0].splat(1.f);
 	}
-	else
+	else if (mUIStackDepth < LL_MAX_UI_STACK_DEPTH)
 	{
-		mUIOffset.push_front(mUIOffset.front());
-	}
-	
-	if (mUIScale.empty())
-	{
-		mUIScale.push_front(LLVector3(1,1,1));
+		mUIOffset[mUIStackDepth] = mUIOffset[mUIStackDepth-1];
+		mUIScale[mUIStackDepth] = mUIScale[mUIStackDepth-1];
 	}
 	else
 	{
-		mUIScale.push_front(mUIScale.front());
+		llerrs << "Blown UI matrix stack." << llendl;
 	}
+	
+	++mUIStackDepth;
+	
 }
 
 void LLRender::popUIMatrix()
 {
-	if (mUIOffset.empty())
+	if (mUIStackDepth == 0)
 	{
 		llerrs << "UI offset stack blown." << llendl;
 	}
-	mUIOffset.pop_front();
-	mUIScale.pop_front();
+	--mUIStackDepth;
 }
 
 LLVector3 LLRender::getUITranslation()
 {
-	if (mUIOffset.empty())
+	if (mUIStackDepth == 0)
 	{
 		llerrs << "UI offset stack empty." << llendl;
 	}
-	return mUIOffset.front();
+	return LLVector3(mUIOffset[mUIStackDepth-1].getF32());
 }
 
 LLVector3 LLRender::getUIScale()
 {
-	if (mUIScale.empty())
+	if (mUIStackDepth == 0)
 	{
 		llerrs << "UI scale stack empty." << llendl;
 	}
-	return mUIScale.front();
+	return LLVector3(mUIScale[mUIStackDepth-1].getF32());
 }
 
 
 void LLRender::loadUIIdentity()
 {
-	if (mUIOffset.empty())
+	if (mUIStackDepth == 0)
 	{
 		llerrs << "Need to push UI translation frame before clearing offset." << llendl;
 	}
-	mUIOffset.front().setVec(0,0,0);
-	mUIScale.front().setVec(1,1,1);
+	mUIOffset[mUIStackDepth-1].clear();
+	mUIScale[mUIStackDepth-1].splat(1.f);
 }
 
 void LLRender::setColorMask(bool writeColor, bool writeAlpha)
@@ -1154,7 +1173,7 @@ void LLRender::flush()
 		}
 #endif
 				
-		if (!mUIOffset.empty())
+		if (mUIStackDepth > 0)
 		{
 			sUICalls++;
 			sUIVerts += mCount;
@@ -1206,24 +1225,22 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
 		return;
 	}
 
-	if (mUIOffset.empty())
+	LLVector3& v = reinterpret_cast<LLVector3&>(mVerticesp[mCount]);
+	v.set(x,y,z);
+	if (mUIStackDepth != 0)
 	{
-		mVerticesp[mCount] = LLVector3(x,y,z);
-	}
-	else
-	{
-		LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.front()).scaledVec(mUIScale.front());
-		mVerticesp[mCount] = vert;
+		v += reinterpret_cast<LLVector3&>(mUIOffset[mUIStackDepth-1]);
+		v.scaleVec(reinterpret_cast<LLVector3&>(mUIScale[mUIStackDepth-1]));
 	}
 
 	mCount++;
 	if (mCount < 4096)
 	{
-		mVerticesp[mCount] = mVerticesp[mCount-1];
 		mColorsp[mCount] = mColorsp[mCount-1];
 		mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
 	}
 }
+
 void LLRender::vertex2i(const GLint& x, const GLint& y)
 {
 	vertex3f((GLfloat) x, (GLfloat) y, 0);	
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 3cda4b57700..2bacf16dc67 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -52,6 +52,7 @@ class LLCubeMap;
 class LLImageGL;
 class LLRenderTarget;
 class LLTexture ;
+class LLVector4a;
 
 class LLTexUnit
 {
@@ -360,9 +361,10 @@ class LLRender
 	F32				mCurrAlphaFuncVal;
 
 	LLPointer<LLVertexBuffer>	mBuffer;
-	LLStrider<LLVector3>		mVerticesp;
-	LLStrider<LLVector2>		mTexcoordsp;
-	LLStrider<LLColor4U>		mColorsp;
+	LLVector4a*					mVerticesp;
+	LLVector2*					mTexcoordsp;
+	LLColor4U*					mColorsp;
+
 	std::vector<LLTexUnit*>		mTexUnits;
 	LLTexUnit*			mDummyTexUnit;
 
@@ -372,9 +374,10 @@ class LLRender
 	eBlendFactor mCurrBlendAlphaDFactor;
 	F32				mMaxAnisotropy;
 
-	std::list<LLVector3> mUIOffset;
-	std::list<LLVector3> mUIScale;
+	LLVector4a* mUIOffset;
+	LLVector4a* mUIScale;
 
+	U32 mUIStackDepth;
 };
 
 extern F64 gGLModelView[16];
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index e67f0ec3fcc..459041f67d7 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -123,7 +123,8 @@ LLView::Params::Params()
 }
 
 LLView::LLView(const LLView::Params& p)
-:	mName(p.name),
+:	mVisible(p.visible),
+	mName(p.name),
 	mParentView(NULL),
 	mReshapeFlags(FOLLOWS_NONE),
 	mFromXUI(p.from_xui),
@@ -132,7 +133,6 @@ LLView::LLView(const LLView::Params& p)
 	mNextInsertionOrdinal(0),
 	mHoverCursor(getCursorFromString(p.hover_cursor)),
 	mEnabled(p.enabled),
-	mVisible(p.visible),
 	mMouseOpaque(p.mouse_opaque),
 	mSoundFlags(p.sound_flags),
 	mUseBoundingRect(p.use_bounding_rect),
@@ -1309,7 +1309,13 @@ void LLView::drawChildren()
 {
 	if (!mChildList.empty())
 	{
-		LLRect rootRect = getRootView()->getRect();
+		static const LLRect* rootRect = NULL;
+		
+		if (!mParentView)
+		{
+			rootRect = &mRect;
+		}
+
 		LLRect screenRect;
 
 		++sDepth;
@@ -1319,13 +1325,15 @@ void LLView::drawChildren()
 			child_list_reverse_iter_t child = child_iter++;
 			LLView *viewp = *child;
 
-			if (viewp->getVisible() && viewp->getRect().isValid())
+			if (!viewp->getVisible() || !viewp->getRect().isValid())
+			{
+				continue;
+			}
+
 			{
-				// check for bad data
-				llassert_always(viewp->getVisible() == TRUE);
 				// Only draw views that are within the root view
 				localRectToScreen(viewp->getRect(),&screenRect);
-				if ( rootRect.overlaps(screenRect)  && LLUI::sDirtyRect.overlaps(screenRect))
+				if ( rootRect->overlaps(screenRect)  && LLUI::sDirtyRect.overlaps(screenRect))
 				{
 					LLUI::pushMatrix();
 					{
-- 
GitLab


From 0a54fb6b24790263c45f096415fee0e2d03323e0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 29 May 2010 04:19:25 -0500
Subject: [PATCH 464/683] Faster texture coordinate updates.

---
 indra/newview/llface.cpp | 581 ++++++++++++++++++++++-----------------
 1 file changed, 334 insertions(+), 247 deletions(-)

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 7a0aa9244dd..98a50ca4e7d 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1073,8 +1073,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		mVertexBuffer->getColorStrider(colors, mGeomIndex);
 	}
 
-	F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0;
-	
 	BOOL is_static = mDrawablep->isStatic();
 	BOOL is_global = is_static;
 
@@ -1089,57 +1087,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		clearState(GLOBAL);
 	}
 
-	LLVector2 tmin, tmax;
-	
-	if (rebuild_tcoord)
-	{
-		if (tep)
-		{
-			r  = tep->getRotation();
-			os = tep->mOffsetS;
-			ot = tep->mOffsetT;
-			ms = tep->mScaleS;
-			mt = tep->mScaleT;
-			cos_ang = cos(r);
-			sin_ang = sin(r);
-		}
-		else
-		{
-			cos_ang = 1.0f;
-			sin_ang = 0.0f;
-			os = 0.0f;
-			ot = 0.0f;
-			ms = 1.0f;
-			mt = 1.0f;
-		}
-	}
-
-	U8 tex_mode = 0;
-	
-	if (isState(TEXTURE_ANIM))
-	{
-		LLVOVolume* vobj = (LLVOVolume*) (LLViewerObject*) mVObjp;	
-		tex_mode = vobj->mTexAnimMode;
-
-		if (!tex_mode)
-		{
-			clearState(TEXTURE_ANIM);
-		}
-		else
-		{
-			os = ot = 0.f;
-			r = 0.f;
-			cos_ang = 1.f;
-			sin_ang = 0.f;
-			ms = mt = 1.f;
-		}
-
-		if (getVirtualSize() >= MIN_TEX_ANIM_SIZE)
-		{ //don't override texture transform during tc bake
-			tex_mode = 0;
-		}
-	}
-
 	LLColor4U color = tep->getColor();
 
 	if (rebuild_color)
@@ -1183,242 +1130,382 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		}
 	}
 	
+	LLMatrix4a mat_normal;
+	mat_normal.loadu(mat_norm_in);
 	
-	//bump setup
-	LLVector4a binormal_dir( -sin_ang, cos_ang, 0.f );
-	LLVector4a bump_s_primary_light_ray(0.f, 0.f, 0.f);
-	LLVector4a bump_t_primary_light_ray(0.f, 0.f, 0.f);
+	//if it's not fullbright and has no normals, bake sunlight based on face normal
+	//bool bake_sunlight = !getTextureEntry()->getFullbright() &&
+	//  !mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
 
-	LLQuaternion bump_quat;
-	if (mDrawablep->isActive())
-	{
-		bump_quat = LLQuaternion(mDrawablep->getRenderMatrix());
-	}
-	
-	if (bump_code)
+	F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0;
+
+	if (rebuild_tcoord)
 	{
-		mVObjp->getVolume()->genBinormals(f);
-		F32 offset_multiple; 
-		switch( bump_code )
+		bool do_xform;
+			
+		if (tep)
 		{
-			case BE_NO_BUMP:
-			offset_multiple = 0.f;
-			break;
-			case BE_BRIGHTNESS:
-			case BE_DARKNESS:
-			if( mTexture.notNull() && mTexture->hasGLTexture())
+			r  = tep->getRotation();
+			os = tep->mOffsetS;
+			ot = tep->mOffsetT;
+			ms = tep->mScaleS;
+			mt = tep->mScaleT;
+			cos_ang = cos(r);
+			sin_ang = sin(r);
+
+			if (cos_ang != 1.f || 
+				sin_ang != 0.f ||
+				os != 0.f ||
+				ot != 0.f ||
+				ms != 1.f ||
+				mt != 1.f)
 			{
-				// Offset by approximately one texel
-				S32 cur_discard = mTexture->getDiscardLevel();
-				S32 max_size = llmax( mTexture->getWidth(), mTexture->getHeight() );
-				max_size <<= cur_discard;
-				const F32 ARTIFICIAL_OFFSET = 2.f;
-				offset_multiple = ARTIFICIAL_OFFSET / (F32)max_size;
+				do_xform = true;
 			}
 			else
 			{
-				offset_multiple = 1.f/256;
-			}
-			break;
-
-			default:  // Standard bumpmap textures.  Assumed to be 256x256
-			offset_multiple = 1.f / 256;
-			break;
+				do_xform = false;
+			}	
 		}
-
-		F32 s_scale = 1.f;
-		F32 t_scale = 1.f;
-		if( tep )
+		else
 		{
-			tep->getScale( &s_scale, &t_scale );
+			do_xform = false;
 		}
-		// Use the nudged south when coming from above sun angle, such
-		// that emboss mapping always shows up on the upward faces of cubes when 
-		// it's noon (since a lot of builders build with the sun forced to noon).
-		LLVector3   sun_ray  = gSky.mVOSkyp->mBumpSunDir;
-		LLVector3   moon_ray = gSky.getMoonDirection();
-		LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray;
+						
+		//bump setup
+		LLVector4a binormal_dir( -sin_ang, cos_ang, 0.f );
+		LLVector4a bump_s_primary_light_ray(0.f, 0.f, 0.f);
+		LLVector4a bump_t_primary_light_ray(0.f, 0.f, 0.f);
 
-		bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV);
-		bump_t_primary_light_ray.load3((offset_multiple * t_scale * primary_light_ray).mV);
-	}
+		LLQuaternion bump_quat;
+		if (mDrawablep->isActive())
+		{
+			bump_quat = LLQuaternion(mDrawablep->getRenderMatrix());
+		}
 		
-	U8 texgen = getTextureEntry()->getTexGen();
-	if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT)
-	{ //planar texgen needs binormals
-		mVObjp->getVolume()->genBinormals(f);
-	}
-
-	LLMatrix4a mat_normal;
-	mat_normal.loadu(mat_norm_in);
-	
-	//if it's not fullbright and has no normals, bake sunlight based on face normal
-	//bool bake_sunlight = !getTextureEntry()->getFullbright() &&
-	//  !mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
-
-	if (rebuild_tcoord)
-	{
-		LLVector4a scalea;
-		scalea.load3(scale.mV);
-
+		if (bump_code)
+		{
+			mVObjp->getVolume()->genBinormals(f);
+			F32 offset_multiple; 
+			switch( bump_code )
+			{
+				case BE_NO_BUMP:
+				offset_multiple = 0.f;
+				break;
+				case BE_BRIGHTNESS:
+				case BE_DARKNESS:
+				if( mTexture.notNull() && mTexture->hasGLTexture())
+				{
+					// Offset by approximately one texel
+					S32 cur_discard = mTexture->getDiscardLevel();
+					S32 max_size = llmax( mTexture->getWidth(), mTexture->getHeight() );
+					max_size <<= cur_discard;
+					const F32 ARTIFICIAL_OFFSET = 2.f;
+					offset_multiple = ARTIFICIAL_OFFSET / (F32)max_size;
+				}
+				else
+				{
+					offset_multiple = 1.f/256;
+				}
+				break;
 
-		for (S32 i = 0; i < num_vertices; i++)
-		{	
-			LLVector2 tc(vf.mTexCoords[i]);
-		
-			LLVector4a& norm = vf.mNormals[i];
-			
-			LLVector4a& center = *(vf.mCenter);
+				default:  // Standard bumpmap textures.  Assumed to be 256x256
+				offset_multiple = 1.f / 256;
+				break;
+			}
 
-			if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
+			F32 s_scale = 1.f;
+			F32 t_scale = 1.f;
+			if( tep )
 			{
-				LLVector4a vec = vf.mPositions[i];
-			
-				vec.mul(scalea);
-
-				switch (texgen)
-				{
-					case LLTextureEntry::TEX_GEN_PLANAR:
-						planarProjection(tc, norm, center, vec);
-						break;
-					case LLTextureEntry::TEX_GEN_SPHERICAL:
-						sphericalProjection(tc, norm, center, vec);
-						break;
-					case LLTextureEntry::TEX_GEN_CYLINDRICAL:
-						cylindricalProjection(tc, norm, center, vec);
-						break;
-					default:
-						break;
-				}		
+				tep->getScale( &s_scale, &t_scale );
 			}
+			// Use the nudged south when coming from above sun angle, such
+			// that emboss mapping always shows up on the upward faces of cubes when 
+			// it's noon (since a lot of builders build with the sun forced to noon).
+			LLVector3   sun_ray  = gSky.mVOSkyp->mBumpSunDir;
+			LLVector3   moon_ray = gSky.getMoonDirection();
+			LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray;
+
+			bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV);
+			bump_t_primary_light_ray.load3((offset_multiple * t_scale * primary_light_ray).mV);
+		}
 
-			if (tex_mode && mTextureMatrix)
+		U8 texgen = getTextureEntry()->getTexGen();
+		if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT)
+		{ //planar texgen needs binormals
+			mVObjp->getVolume()->genBinormals(f);
+		}
+
+		U8 tex_mode = 0;
+	
+		if (isState(TEXTURE_ANIM))
+		{
+			LLVOVolume* vobj = (LLVOVolume*) (LLViewerObject*) mVObjp;	
+			tex_mode = vobj->mTexAnimMode;
+
+			if (!tex_mode)
 			{
-				LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
-				tmp = tmp * *mTextureMatrix;
-				tc.mV[0] = tmp.mV[0];
-				tc.mV[1] = tmp.mV[1];
+				clearState(TEXTURE_ANIM);
 			}
 			else
 			{
-				xform(tc, cos_ang, sin_ang, os, ot, ms, mt);
+				os = ot = 0.f;
+				r = 0.f;
+				cos_ang = 1.f;
+				sin_ang = 0.f;
+				ms = mt = 1.f;
+
+				do_xform = false;
 			}
 
-			if(in_atlas)
-			{
-				//
-				//manually calculate tex-coord per vertex for varying address modes.
-				//should be removed if shader can handle this.
-				//
+			if (getVirtualSize() >= MIN_TEX_ANIM_SIZE)
+			{ //don't override texture transform during tc bake
+				tex_mode = 0;
+			}
+		}
 
-				S32 int_part = 0 ;
-				switch(mTexture->getAddressMode())
-				{
-				case LLTexUnit::TAM_CLAMP:
-					if(tc.mV[0] < 0.f)
-					{
-						tc.mV[0] = 0.f ;
-					}
-					else if(tc.mV[0] > 1.f)
-					{
-						tc.mV[0] = 1.f;
-					}
+		LLVector4a scalea;
+		scalea.load3(scale.mV);
 
-					if(tc.mV[1] < 0.f)
-					{
-						tc.mV[1] = 0.f ;
-					}
-					else if(tc.mV[1] > 1.f)
-					{
-						tc.mV[1] = 1.f;
-					}
-					break;
-				case LLTexUnit::TAM_MIRROR:
-					if(tc.mV[0] < 0.f)
-					{
-						tc.mV[0] = -tc.mV[0] ;
-					}
-					int_part = (S32)tc.mV[0] ;
-					if(int_part & 1) //odd number
-					{
-						tc.mV[0] = int_part + 1 - tc.mV[0] ;
-					}
-					else //even number
-					{
-						tc.mV[0] -= int_part ;
-					}
+		bool do_bump = bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1);
+		bool do_tex_mat = tex_mode && mTextureMatrix;
 
-					if(tc.mV[1] < 0.f)
+		if (!in_atlas && !do_bump)
+		{ //not in atlas or not bump mapped, might be able to do a cheap update
+			if (texgen != LLTextureEntry::TEX_GEN_PLANAR)
+			{
+				if (!do_tex_mat)
+				{
+					if (!do_xform)
 					{
-						tc.mV[1] = -tc.mV[1] ;
+						LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, num_vertices*2);
 					}
-					int_part = (S32)tc.mV[1] ;
-					if(int_part & 1) //odd number
+					else
 					{
-						tc.mV[1] = int_part + 1 - tc.mV[1] ;
+						for (S32 i = 0; i < num_vertices; i++)
+						{	
+							LLVector2 tc(vf.mTexCoords[i]);
+							xform(tc, cos_ang, sin_ang, os, ot, ms, mt);
+							*tex_coords++ = tc;	
+						}
 					}
-					else //even number
-					{
-						tc.mV[1] -= int_part ;
+				}
+				else
+				{ //do tex mat, no texgen, no atlas, no bump
+					for (S32 i = 0; i < num_vertices; i++)
+					{	
+						LLVector2 tc(vf.mTexCoords[i]);
+						LLVector4a& norm = vf.mNormals[i];
+						LLVector4a& center = *(vf.mCenter);
+
+						LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
+						tmp = tmp * *mTextureMatrix;
+						tc.mV[0] = tmp.mV[0];
+						tc.mV[1] = tmp.mV[1];
+						*tex_coords++ = tc;	
 					}
-					break;
-				case LLTexUnit::TAM_WRAP:
-					if(tc.mV[0] > 1.f)
-						tc.mV[0] -= (S32)(tc.mV[0] - 0.00001f) ;
-					else if(tc.mV[0] < -1.f)
-						tc.mV[0] -= (S32)(tc.mV[0] + 0.00001f) ;
-
-					if(tc.mV[1] > 1.f)
-						tc.mV[1] -= (S32)(tc.mV[1] - 0.00001f) ;
-					else if(tc.mV[1] < -1.f)
-						tc.mV[1] -= (S32)(tc.mV[1] + 0.00001f) ;
-
-					if(tc.mV[0] < 0.f)
-					{
-						tc.mV[0] = 1.0f + tc.mV[0] ;
+				}
+			}
+			else
+			{ //no bump, no atlas, tex gen planar
+				if (do_tex_mat)
+				{
+					for (S32 i = 0; i < num_vertices; i++)
+					{	
+						LLVector2 tc(vf.mTexCoords[i]);
+						LLVector4a& norm = vf.mNormals[i];
+						LLVector4a& center = *(vf.mCenter);
+						LLVector4a vec = vf.mPositions[i];	
+						vec.mul(scalea);
+						planarProjection(tc, norm, center, vec);
+						
+						LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
+						tmp = tmp * *mTextureMatrix;
+						tc.mV[0] = tmp.mV[0];
+						tc.mV[1] = tmp.mV[1];
+				
+						*tex_coords++ = tc;	
 					}
-					if(tc.mV[1] < 0.f)
-					{
-						tc.mV[1] = 1.0f + tc.mV[1] ;
+				}
+				else
+				{
+					for (S32 i = 0; i < num_vertices; i++)
+					{	
+						LLVector2 tc(vf.mTexCoords[i]);
+						LLVector4a& norm = vf.mNormals[i];
+						LLVector4a& center = *(vf.mCenter);
+						LLVector4a vec = vf.mPositions[i];	
+						vec.mul(scalea);
+						planarProjection(tc, norm, center, vec);
+						
+						xform(tc, cos_ang, sin_ang, os, ot, ms, mt);
+
+						*tex_coords++ = tc;	
 					}
-					break;
-				default:
-					break;
 				}
-			
-				tc.mV[0] = tcoord_xoffset + tcoord_xscale * tc.mV[0] ;
-				tc.mV[1] = tcoord_yoffset + tcoord_yscale * tc.mV[1] ;
 			}
+		}
+		else
+		{ //either bump mapped or in atlas, just do the whole expensive loop
+			for (S32 i = 0; i < num_vertices; i++)
+			{	
+				LLVector2 tc(vf.mTexCoords[i]);
 			
+				LLVector4a& norm = vf.mNormals[i];
+				
+				LLVector4a& center = *(vf.mCenter);
 
-			*tex_coords++ = tc;
-			
-			if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1))
-			{
-				LLVector4a tangent;
-				tangent.setCross3(vf.mBinormals[i], vf.mNormals[i]);
-
-				LLMatrix4a tangent_to_object;
-				tangent_to_object.setRows(tangent, vf.mBinormals[i], vf.mNormals[i]);
-				LLVector4a t;
-				tangent_to_object.rotate(binormal_dir, t);
-				LLVector4a binormal;
-				mat_normal.rotate(t, binormal);
-					
-				//VECTORIZE THIS
-				if (mDrawablep->isActive())
+				if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
+				{
+					LLVector4a vec = vf.mPositions[i];
+				
+					vec.mul(scalea);
+
+					switch (texgen)
+					{
+						case LLTextureEntry::TEX_GEN_PLANAR:
+							planarProjection(tc, norm, center, vec);
+							break;
+						case LLTextureEntry::TEX_GEN_SPHERICAL:
+							sphericalProjection(tc, norm, center, vec);
+							break;
+						case LLTextureEntry::TEX_GEN_CYLINDRICAL:
+							cylindricalProjection(tc, norm, center, vec);
+							break;
+						default:
+							break;
+					}		
+				}
+
+				if (tex_mode && mTextureMatrix)
 				{
-					LLVector3 t;
-					t.set(binormal.getF32());
-					t *= bump_quat;
-					binormal.load3(t.mV);
+					LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
+					tmp = tmp * *mTextureMatrix;
+					tc.mV[0] = tmp.mV[0];
+					tc.mV[1] = tmp.mV[1];
+				}
+				else
+				{
+					xform(tc, cos_ang, sin_ang, os, ot, ms, mt);
 				}
 
-				binormal.normalize3fast();
-				tc += LLVector2( bump_s_primary_light_ray.dot3(tangent), bump_t_primary_light_ray.dot3(binormal) );
+				if(in_atlas)
+				{
+					//
+					//manually calculate tex-coord per vertex for varying address modes.
+					//should be removed if shader can handle this.
+					//
+
+					S32 int_part = 0 ;
+					switch(mTexture->getAddressMode())
+					{
+					case LLTexUnit::TAM_CLAMP:
+						if(tc.mV[0] < 0.f)
+						{
+							tc.mV[0] = 0.f ;
+						}
+						else if(tc.mV[0] > 1.f)
+						{
+							tc.mV[0] = 1.f;
+						}
+
+						if(tc.mV[1] < 0.f)
+						{
+							tc.mV[1] = 0.f ;
+						}
+						else if(tc.mV[1] > 1.f)
+						{
+							tc.mV[1] = 1.f;
+						}
+						break;
+					case LLTexUnit::TAM_MIRROR:
+						if(tc.mV[0] < 0.f)
+						{
+							tc.mV[0] = -tc.mV[0] ;
+						}
+						int_part = (S32)tc.mV[0] ;
+						if(int_part & 1) //odd number
+						{
+							tc.mV[0] = int_part + 1 - tc.mV[0] ;
+						}
+						else //even number
+						{
+							tc.mV[0] -= int_part ;
+						}
+
+						if(tc.mV[1] < 0.f)
+						{
+							tc.mV[1] = -tc.mV[1] ;
+						}
+						int_part = (S32)tc.mV[1] ;
+						if(int_part & 1) //odd number
+						{
+							tc.mV[1] = int_part + 1 - tc.mV[1] ;
+						}
+						else //even number
+						{
+							tc.mV[1] -= int_part ;
+						}
+						break;
+					case LLTexUnit::TAM_WRAP:
+						if(tc.mV[0] > 1.f)
+							tc.mV[0] -= (S32)(tc.mV[0] - 0.00001f) ;
+						else if(tc.mV[0] < -1.f)
+							tc.mV[0] -= (S32)(tc.mV[0] + 0.00001f) ;
+
+						if(tc.mV[1] > 1.f)
+							tc.mV[1] -= (S32)(tc.mV[1] - 0.00001f) ;
+						else if(tc.mV[1] < -1.f)
+							tc.mV[1] -= (S32)(tc.mV[1] + 0.00001f) ;
+
+						if(tc.mV[0] < 0.f)
+						{
+							tc.mV[0] = 1.0f + tc.mV[0] ;
+						}
+						if(tc.mV[1] < 0.f)
+						{
+							tc.mV[1] = 1.0f + tc.mV[1] ;
+						}
+						break;
+					default:
+						break;
+					}
 				
-				*tex_coords2++ = tc;
-			}	
+					tc.mV[0] = tcoord_xoffset + tcoord_xscale * tc.mV[0] ;
+					tc.mV[1] = tcoord_yoffset + tcoord_yscale * tc.mV[1] ;
+				}
+				
+
+				*tex_coords++ = tc;
+				
+				if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1))
+				{
+					LLVector4a tangent;
+					tangent.setCross3(vf.mBinormals[i], vf.mNormals[i]);
+
+					LLMatrix4a tangent_to_object;
+					tangent_to_object.setRows(tangent, vf.mBinormals[i], vf.mNormals[i]);
+					LLVector4a t;
+					tangent_to_object.rotate(binormal_dir, t);
+					LLVector4a binormal;
+					mat_normal.rotate(t, binormal);
+						
+					//VECTORIZE THIS
+					if (mDrawablep->isActive())
+					{
+						LLVector3 t;
+						t.set(binormal.getF32());
+						t *= bump_quat;
+						binormal.load3(t.mV);
+					}
+
+					binormal.normalize3fast();
+					tc += LLVector2( bump_s_primary_light_ray.dot3(tangent), bump_t_primary_light_ray.dot3(binormal) );
+					
+					*tex_coords2++ = tc;
+				}	
+			}
 		}
 	}
 
-- 
GitLab


From 0e7f4dc5cef8a97cb1dd08aa2f79538ced267888 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 29 May 2010 05:37:38 -0500
Subject: [PATCH 465/683] Octree per LLVolumeFace WIP

---
 indra/llmath/lloctree.h                    |  18 +
 indra/llmath/llvolume.cpp                  | 625 ++++++++++++++++-----
 indra/llmath/llvolume.h                    |  45 +-
 indra/newview/llhudicon.cpp                |   7 +-
 indra/newview/llhudtext.cpp                |   7 +-
 indra/newview/llpanelprimmediacontrols.cpp |   1 +
 indra/newview/llspatialpartition.cpp       |  30 +
 indra/newview/llvograss.cpp                |   8 +-
 8 files changed, 582 insertions(+), 159 deletions(-)

diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 2f34fb1bb04..8bba12783f8 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -72,6 +72,13 @@ class LLOctreeTraveler
 	virtual void visit(const LLOctreeNode<T>* branch) = 0;
 };
 
+template <class T>
+class LLOctreeTravelerDepthFirst : public LLOctreeTraveler<T>
+{
+public:
+	virtual void traverse(const LLOctreeNode<T>* node);
+};
+
 template <class T>
 class LLOctreeNode : public LLTreeNode<T>
 {
@@ -710,4 +717,15 @@ void LLOctreeTraveler<T>::traverse(const LLOctreeNode<T>* node)
 		traverse(node->getChild(i));
 	}
 }
+
+template <class T>
+void LLOctreeTravelerDepthFirst<T>::traverse(const LLOctreeNode<T>* node)
+{
+	for (U32 i = 0; i < node->getChildCount(); i++)
+	{
+		traverse(node->getChild(i));
+	}
+	node->accept(this);
+}
+
 #endif
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 9b6e2488e65..d261811aa23 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -45,6 +45,7 @@
 #include "m4math.h"
 #include "m3math.h"
 #include "llmatrix4a.h"
+#include "lloctree.h"
 #include "lldarray.h"
 #include "llvolume.h"
 #include "llstl.h"
@@ -132,6 +133,51 @@ BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* cent
 	return true;
 }
 
+BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size)
+{
+	LLVector4a fAWdU;
+	LLVector4a dir;
+	LLVector4a diff;
+
+	dir.setSub(end, start);
+	dir.mul(0.5f);
+
+	diff.setAdd(end,start);
+	diff.mul(0.5f);
+	diff.sub(center);
+	fAWdU.setAbs(dir); 
+
+	LLVector4a rhs;
+	rhs.setAdd(size, fAWdU);
+
+	LLVector4a lhs;
+	lhs.setAbs(diff);
+
+	S32 grt = lhs.greaterThan4(rhs).getComparisonMask();
+
+	if (grt & 0x7)
+	{
+		return false;
+	}
+	
+	LLVector4a f;
+	f.setCross3(dir, diff);
+	f.setAbs(f);
+
+	LLVector4a v0; v0.mQ = _mm_shuffle_ps(size.mQ, size.mQ, _MM_SHUFFLE(3,1,0,0));
+	LLVector4a v1; v1.mQ = _mm_shuffle_ps(fAWdU.mQ, fAWdU.mQ, _MM_SHUFFLE(3,2,2,1));
+	lhs.setMul(v0, v1);
+
+	v0.mQ = _mm_shuffle_ps(size.mQ, size.mQ, _MM_SHUFFLE(3,2,2,1));
+	v1.mQ = _mm_shuffle_ps(fAWdU.mQ, fAWdU.mQ, _MM_SHUFFLE(3,1,0,0));
+	rhs.setMul(v0, v1);
+	rhs.add(lhs);
+
+	grt = f.greaterThan4(rhs).getComparisonMask();
+
+	return (grt & 0x7) ? false : true;	
+}
+
 
 // intersect test between triangle vert0, vert1, vert2 and a ray from orig in direction dir.
 // returns TRUE if intersecting and returns barycentric coordinates in intersection_a, intersection_b,
@@ -139,15 +185,13 @@ BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* cent
 
 // Moller-Trumbore algorithm
 BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
-							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided)
+							F32& intersection_a, F32& intersection_b, F32& intersection_t)
 {
-	F32 u, v, t;
 	
 	/* find vectors for two edges sharing vert0 */
 	LLVector4a edge1;
 	edge1.setSub(vert1, vert0);
 	
-	
 	LLVector4a edge2;
 	edge2.setSub(vert2, vert0);
 
@@ -156,87 +200,116 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 	pvec.setCross3(dir, edge2);
 
 	/* if determinant is near zero, ray lies in plane of triangle */
-	F32 det = edge1.dot3(pvec);
-
-	if (!two_sided)
+	LLVector4a det;
+	det.setAllDot3(edge1, pvec);
+	
+	if (det.greaterEqual4(LLVector4a::getApproximatelyZero()).getComparisonMask())
 	{
-		if (det < F_APPROXIMATELY_ZERO)
-		{
-			return FALSE;
-		}
-
 		/* calculate distance from vert0 to ray origin */
 		LLVector4a tvec;
 		tvec.setSub(orig, vert0);
 
 		/* calculate U parameter and test bounds */
-		u = tvec.dot3(pvec);	
+		LLVector4a u;
+		u.setAllDot3(tvec,pvec);
 
-		if (u < 0.f || u > det)
+		if (u.greaterEqual4(LLVector4a::getZero()).getComparisonMask() &&
+			u.lessEqual4(det).getComparisonMask())
 		{
-			return FALSE;
+			/* prepare to test V parameter */
+			LLVector4a qvec;
+			qvec.setCross3(tvec, edge1);
+			
+			/* calculate V parameter and test bounds */
+			LLVector4a v;
+			v.setAllDot3(dir, qvec);
+
+			
+			//if (!(v < 0.f || u + v > det))
+
+			LLVector4a sum_uv;
+			sum_uv.setAdd(u, v);
+
+			S32 v_gequal = v.greaterEqual4(LLVector4a::getZero()).getComparisonMask();
+			S32 sum_lequal = sum_uv.lessEqual4(det).getComparisonMask();
+
+			if (v_gequal && sum_lequal)
+			{
+				/* calculate t, scale parameters, ray intersects triangle */
+				LLVector4a t;
+				t.setAllDot3(edge2,qvec);
+
+				t.div(det);
+				u.div(det);
+				v.div(det);
+				
+				intersection_a = u[0];
+				intersection_b = v[0];
+				intersection_t = t[0];
+				return TRUE;
+			}
 		}
-	
-		/* prepare to test V parameter */
-		LLVector4a qvec;
-		qvec.setCross3(tvec, edge1);
+	}
 		
-		/* calculate V parameter and test bounds */
-		v = dir.dot3(qvec);
-		if (v < 0.f || u + v > det)
-		{
-			return FALSE;
-		}
+	return FALSE;
+} 
 
-		/* calculate t, scale parameters, ray intersects triangle */
-		t = edge2.dot3(qvec);
-		F32 inv_det = 1.0 / det;
-		t *= inv_det;
-		u *= inv_det;
-		v *= inv_det;
-	}
+BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
+							F32& intersection_a, F32& intersection_b, F32& intersection_t)
+{
+	F32 u, v, t;
 	
-	else // two sided
-			{
-		if (det > -F_APPROXIMATELY_ZERO && det < F_APPROXIMATELY_ZERO)
-				{
-			return FALSE;
-				}
-		F32 inv_det = 1.0 / det;
+	/* find vectors for two edges sharing vert0 */
+	LLVector4a edge1;
+	edge1.setSub(vert1, vert0);
+	
+	
+	LLVector4a edge2;
+	edge2.setSub(vert2, vert0);
 
-		/* calculate distance from vert0 to ray origin */
-		LLVector4a tvec;
-		tvec.setSub(orig, vert0);
-		
-		/* calculate U parameter and test bounds */
-		u = (tvec.dot3(pvec)) * inv_det;
-		if (u < 0.f || u > 1.f)
-		{
-			return FALSE;
-			}
+	/* begin calculating determinant - also used to calculate U parameter */
+	LLVector4a pvec;
+	pvec.setCross3(dir, edge2);
 
-		/* prepare to test V parameter */
-		LLVector4a qvec;
-		qvec.setSub(tvec, edge1);
-		
-		/* calculate V parameter and test bounds */
-		v = (dir.dot3(qvec)) * inv_det;
-		
-		if (v < 0.f || u + v > 1.f)
-		{
-			return FALSE;
-		}
+	/* if determinant is near zero, ray lies in plane of triangle */
+	F32 det = edge1.dot3(pvec);
+
+	
+	if (det > -F_APPROXIMATELY_ZERO && det < F_APPROXIMATELY_ZERO)
+	{
+		return FALSE;
+	}
+
+	F32 inv_det = 1.f / det;
+
+	/* calculate distance from vert0 to ray origin */
+	LLVector4a tvec;
+	tvec.setSub(orig, vert0);
+	
+	/* calculate U parameter and test bounds */
+	u = (tvec.dot3(pvec)) * inv_det;
+	if (u < 0.f || u > 1.f)
+	{
+		return FALSE;
+	}
 
-		/* calculate t, ray intersects triangle */
-		t = (edge2.dot3(qvec)) * inv_det;
+	/* prepare to test V parameter */
+	tvec.sub(edge1);
+		
+	/* calculate V parameter and test bounds */
+	v = (dir.dot3(tvec)) * inv_det;
+	
+	if (v < 0.f || u + v > 1.f)
+	{
+		return FALSE;
 	}
+
+	/* calculate t, ray intersects triangle */
+	t = (edge2.dot3(tvec)) * inv_det;
 	
-	if (intersection_a != NULL)
-		*intersection_a = u;
-	if (intersection_b != NULL)
-		*intersection_b = v;
-	if (intersection_t != NULL)
-		*intersection_t = t;
+	intersection_a = u;
+	intersection_b = v;
+	intersection_t = t;
 	
 	
 	return TRUE;
@@ -244,7 +317,7 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 
 //helper for non-aligned vectors
 BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
-							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided)
+							F32& intersection_a, F32& intersection_b, F32& intersection_t, BOOL two_sided)
 {
 	LLVector4a vert0a, vert1a, vert2a, origa, dira;
 	vert0a.load3(vert0.mV);
@@ -253,11 +326,130 @@ BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, cons
 	origa.load3(orig.mV);
 	dira.load3(dir.mV);
 
-	return LLTriangleRayIntersect(vert0a, vert1a, vert2a, origa, dira, 
-			intersection_a, intersection_b, intersection_t, two_sided);
+	if (two_sided)
+	{
+		return LLTriangleRayIntersectTwoSided(vert0a, vert1a, vert2a, origa, dira, 
+				intersection_a, intersection_b, intersection_t);
+	}
+	else
+	{
+		return LLTriangleRayIntersect(vert0a, vert1a, vert2a, origa, dira, 
+				intersection_a, intersection_b, intersection_t);
+	}
 }
 
 
+class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeFace::Triangle>
+{
+public:
+	
+	LLVolumeOctreeListener(LLOctreeNode<LLVolumeFace::Triangle>* node)
+	{
+		node->addListener(this);
+
+		mBounds = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*4, 16);
+		mExtents = mBounds+2;
+	}
+
+	~LLVolumeOctreeListener()
+	{
+		_mm_free(mBounds);
+	}
+	
+	 //LISTENER FUNCTIONS
+	virtual void handleChildAddition(const LLOctreeNode<LLVolumeFace::Triangle>* parent, 
+		LLOctreeNode<LLVolumeFace::Triangle>* child)
+	{
+		new LLVolumeOctreeListener(child);
+	}
+
+	virtual void handleStateChange(const LLTreeNode<LLVolumeFace::Triangle>* node) { }
+	virtual void handleChildRemoval(const LLOctreeNode<LLVolumeFace::Triangle>* parent, 
+			const LLOctreeNode<LLVolumeFace::Triangle>* child) {	}
+	virtual void handleInsertion(const LLTreeNode<LLVolumeFace::Triangle>* node, LLVolumeFace::Triangle* tri) { }
+	virtual void handleRemoval(const LLTreeNode<LLVolumeFace::Triangle>* node, LLVolumeFace::Triangle* tri) { }
+	virtual void handleDestruction(const LLTreeNode<LLVolumeFace::Triangle>* node) { }
+	
+
+public:
+	LLVector4a* mBounds; // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LLVector4a* mExtents; // extents (min, max) of this node and all its children
+};
+
+class LLVolumeOctreeRebound : public LLOctreeTravelerDepthFirst<LLVolumeFace::Triangle>
+{
+public:
+	const LLVolumeFace* mFace;
+
+	LLVolumeOctreeRebound(const LLVolumeFace* face)
+	{
+		mFace = face;
+	}
+
+	virtual void visit(const LLOctreeNode<LLVolumeFace::Triangle>* branch)
+	{
+		LLVolumeOctreeListener* node = (LLVolumeOctreeListener*) branch->getListener(0);
+
+		LLVector4a& min = node->mExtents[0];
+		LLVector4a& max = node->mExtents[1];
+
+		if (branch->getElementCount() != 0)
+		{
+			const LLVolumeFace::Triangle* tri = *(branch->getData().begin());
+						
+			min = *(tri->mV[0]);
+			max = *(tri->mV[0]);
+			
+			for (LLOctreeNode<LLVolumeFace::Triangle>::const_element_iter iter = 
+				branch->getData().begin(); iter != branch->getData().end(); ++iter)
+			{
+				//stretch by triangles in node
+				tri = *iter;
+				
+				min.setMin(*tri->mV[0]);
+				min.setMin(*tri->mV[1]);
+				min.setMin(*tri->mV[2]);
+
+				max.setMax(*tri->mV[0]);
+				max.setMax(*tri->mV[1]);
+				max.setMax(*tri->mV[2]);
+			}
+
+			for (S32 i = 0; i < branch->getChildCount(); ++i)
+			{  //stretch by child extents
+				LLVolumeOctreeListener* child = (LLVolumeOctreeListener*) branch->getChild(i)->getListener(0);
+				min.setMin(child->mExtents[0]);
+				max.setMax(child->mExtents[1]);
+			}
+		}
+		else if (branch->getChildCount() != 0)
+		{
+			LLVolumeOctreeListener* child = (LLVolumeOctreeListener*) branch->getChild(0)->getListener(0);
+
+			min = child->mExtents[0];
+			max = child->mExtents[1];
+
+			for (S32 i = 1; i < branch->getChildCount(); ++i)
+			{  //stretch by child extents
+				child = (LLVolumeOctreeListener*) branch->getChild(i)->getListener(0);
+				min.setMin(child->mExtents[0]);
+				max.setMax(child->mExtents[1]);
+			}
+		}
+		else
+		{
+			llerrs << "WTF? Empty leaf" << llendl;
+		}
+		
+		node->mBounds[0].setAdd(min, max);
+		node->mBounds[0].mul(0.5f);
+
+		node->mBounds[1].setSub(max,min);
+		node->mBounds[1].mul(0.5f);
+	}
+};
+
+
 //-------------------------------------------------------------------
 // statics
 //-------------------------------------------------------------------
@@ -4244,6 +4436,114 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 }
 
+class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeFace::Triangle>
+{
+public:
+	const LLVolumeFace* mFace;
+	LLVector4a mStart;
+	LLVector4a mDir;
+	LLVector4a mEnd;
+	LLVector3* mIntersection;
+	LLVector2* mTexCoord;
+	LLVector3* mNormal;
+	LLVector3* mBinormal;
+	F32* mClosestT;
+	bool mHitFace;
+
+	LLOctreeTriangleRayIntersect(const LLVector4a& start, const LLVector4a& dir, 
+								   const LLVolumeFace* face, F32* closest_t,
+								   LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
+								   : mFace(face),
+								     mStart(start),
+									 mDir(dir),
+									 mIntersection(intersection),
+									 mTexCoord(tex_coord),
+									 mNormal(normal),
+									 mBinormal(bi_normal),
+									 mClosestT(closest_t),
+									 mHitFace(false)
+	{
+		mEnd.setAdd(mStart, mDir);
+	}
+
+	void traverse(const LLOctreeNode<LLVolumeFace::Triangle>* node)
+	{
+		LLVolumeOctreeListener* vl = (LLVolumeOctreeListener*) node->getListener(0);
+
+		/*const F32* start = mStart.getF32();
+		const F32* end = mEnd.getF32();
+		const F32* center = vl->mBounds[0].getF32();
+		const F32* size = vl->mBounds[1].getF32();*/
+
+		if (LLLineSegmentBoxIntersect(mStart, mEnd, vl->mBounds[0], vl->mBounds[1]))
+		{
+			node->accept(this);
+			for (S32 i = 0; i < node->getChildCount(); ++i)
+			{
+				traverse(node->getChild(i));
+			}
+		}
+	}
+
+	void visit(const LLOctreeNode<LLVolumeFace::Triangle>* node)
+	{
+		for (LLOctreeNode<LLVolumeFace::Triangle>::const_element_iter iter = 
+				node->getData().begin(); iter != node->getData().end(); ++iter)
+		{
+			const LLVolumeFace::Triangle* tri = *iter;
+
+			F32 a, b, t;
+			
+			if (LLTriangleRayIntersect(*tri->mV[0], *tri->mV[1], *tri->mV[2],
+					mStart, mDir, a, b, t))
+			{
+				if ((t >= 0.f) &&      // if hit is after start
+					(t <= 1.f) &&      // and before end
+					(t < *mClosestT))   // and this hit is closer
+				{
+					*mClosestT = t;
+					mHitFace = true;
+
+					if (mIntersection != NULL)
+					{
+						LLVector4a intersect = mDir;
+						intersect.mul(*mClosestT);
+						intersect.add(mStart);
+						mIntersection->set(intersect.getF32());
+					}
+
+
+					if (mTexCoord != NULL)
+					{
+						LLVector2* tc = (LLVector2*) mFace->mTexCoords;
+						*mTexCoord = ((1.f - a - b)  * tc[tri->mIndex[0]] +
+							a              * tc[tri->mIndex[1]] +
+							b              * tc[tri->mIndex[2]]);
+
+					}
+
+					if (mNormal != NULL)
+					{
+						LLVector4* norm = (LLVector4*) mFace->mNormals;
+
+						*mNormal    = ((1.f - a - b)  * LLVector3(norm[tri->mIndex[0]]) + 
+							a              * LLVector3(norm[tri->mIndex[1]]) +
+							b              * LLVector3(norm[tri->mIndex[2]]));
+					}
+
+					if (mBinormal != NULL)
+					{
+						LLVector4* binormal = (LLVector4*) mFace->mBinormals;
+						*mBinormal = ((1.f - a - b)  * LLVector3(binormal[tri->mIndex[0]]) + 
+								a              * LLVector3(binormal[tri->mIndex[1]]) +
+								b              * LLVector3(binormal[tri->mIndex[2]]));
+					}
+				}
+			}
+		}
+	}
+};
+
 S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, 
 								   S32 face,
 								   LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
@@ -4288,66 +4588,19 @@ S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& en
 			{
 				genBinormals(i);
 			}
-			
-			LLVector4a* p = (LLVector4a*) face.mPositions;
 
-			for (U32 tri = 0; tri < face.mNumIndices/3; tri++) 
+			if (!face.mOctree)
 			{
-				S32 index1 = face.mIndices[tri*3+0];
-				S32 index2 = face.mIndices[tri*3+1];
-				S32 index3 = face.mIndices[tri*3+2];
-
-				F32 a, b, t;
+				face.createOctree();
+			}
 			
-				if (LLTriangleRayIntersect(p[index1],
-					p[index2],
-					p[index3],
-					start, dir, &a, &b, &t, FALSE))
-				{
-					if ((t >= 0.f) &&      // if hit is after start
-						(t <= 1.f) &&      // and before end
-						(t < closest_t))   // and this hit is closer
-					{
-						closest_t = t;
-						hit_face = i;
-
-						if (intersection != NULL)
-						{
-							LLVector4a intersect = dir;
-							intersect.mul(closest_t);
-							intersect.add(start);
-							intersection->set(intersect.getF32());
-						}
-
-
-						if (tex_coord != NULL)
-						{
-							LLVector2* tc = (LLVector2*) face.mTexCoords;
-							*tex_coord = ((1.f - a - b)  * tc[index1] +
-								a              * tc[index2] +
-								b              * tc[index3]);
-
-						}
-
-						if (normal != NULL)
-						{
-							LLVector4* norm = (LLVector4*) face.mNormals;
-
-							*normal    = ((1.f - a - b)  * LLVector3(norm[index1]) + 
-								a              * LLVector3(norm[index2]) +
-								b              * LLVector3(norm[index3]));
-						}
-
-						if (bi_normal != NULL)
-						{
-							LLVector4* binormal = (LLVector4*) face.mBinormals;
-							*bi_normal = ((1.f - a - b)  * LLVector3(binormal[index1]) + 
-									a              * LLVector3(binormal[index2]) +
-									b              * LLVector3(binormal[index3]));
-						}
+			LLVector4a* p = (LLVector4a*) face.mPositions;
 
-					}
-				}
+			LLOctreeTriangleRayIntersect intersect(start, dir, &face, &closest_t, intersection, tex_coord, normal, bi_normal);
+			intersect.traverse(face.mOctree);
+			if (intersect.mHitFace)
+			{
+				hit_face = i;
 			}
 		}		
 	}
@@ -5128,13 +5381,29 @@ LLVolumeFace::LLVolumeFace() :
 	mBinormals(NULL),
 	mTexCoords(NULL),
 	mIndices(NULL),
-	mWeights(NULL)
+	mWeights(NULL),
+	mOctree(NULL)
 {
 	mExtents = (LLVector4a*) _mm_malloc(48, 16);
 	mCenter = mExtents+2;
 }
 
 LLVolumeFace::LLVolumeFace(const LLVolumeFace& src)
+:	mID(0),
+	mTypeMask(0),
+	mBeginS(0),
+	mBeginT(0),
+	mNumS(0),
+	mNumT(0),
+	mNumVertices(0),
+	mNumIndices(0),
+	mPositions(NULL),
+	mNormals(NULL),
+	mBinormals(NULL),
+	mTexCoords(NULL),
+	mIndices(NULL),
+	mWeights(NULL),
+	mOctree(NULL)
 { 
 	mExtents = (LLVector4a*) _mm_malloc(48, 16);
 	mCenter = mExtents+2;
@@ -5157,13 +5426,9 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 
 	mNumVertices = 0;
 	mNumIndices = 0;
-	mPositions = NULL;
-	mNormals = NULL;
-	mBinormals = NULL;
-	mTexCoords = NULL;
-	mWeights = NULL;
-	mIndices = NULL;
 
+	freeData();
+	
 	LLVector4a::memcpyNonAliased16((F32*) mExtents, (F32*) src.mExtents, 12);
 
 	resizeVertices(src.mNumVertices);
@@ -5179,6 +5444,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 		LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) src.mNormals, vert_size);
 		LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) src.mTexCoords, vert_size);
 
+
 		if (src.mBinormals)
 		{
 			allocateBinormals(src.mNumVertices);
@@ -5216,18 +5482,38 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 }
 
 LLVolumeFace::~LLVolumeFace()
+{
+	_mm_free(mExtents);
+	mExtents = NULL;
+
+	freeData();
+}
+
+void LLVolumeFace::freeData()
 {
 	_mm_free(mPositions);
+	mPositions = NULL;
 	_mm_free(mNormals);
+	mNormals = NULL;
 	_mm_free(mTexCoords);
+	mTexCoords = NULL;
 	_mm_free(mIndices);
+	mIndices = NULL;
 	_mm_free(mBinormals);
+	mBinormals = NULL;
 	_mm_free(mWeights);
-	_mm_free(mExtents);
+	mWeights = NULL;
+
+	delete mOctree;
+	mOctree = NULL;
 }
 
 BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
 {
+	//tree for this face is no longer valid
+	delete mOctree;
+	mOctree = NULL;
+
 	if (mTypeMask & CAP_MASK)
 	{
 		return createCap(volume, partial_build);
@@ -5250,6 +5536,18 @@ void LLVolumeFace::getVertexData(U16 index, LLVolumeFace::VertexData& cv)
 	cv.mTexCoord = mTexCoords[index];
 }
 
+bool LLVolumeFace::VertexMapData::operator==(const LLVolumeFace::VertexData& rhs) const
+{
+	return getPosition().equal3(rhs.getPosition()) &&
+		mTexCoord == rhs.mTexCoord &&
+		getNormal().equal3(rhs.getNormal());
+}
+
+bool LLVolumeFace::VertexMapData::ComparePosition::operator()(const LLVector4a& a, const LLVector4a& b) const
+{
+	return a.less3(b);			
+}
+
 void LLVolumeFace::optimize(F32 angle_cutoff)
 {
 	LLVolumeFace new_face;
@@ -5305,6 +5603,65 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 	swapData(new_face);
 }
 
+
+void LLVolumeFace::createOctree()
+{
+	mOctree = new LLOctreeRoot<Triangle>(LLVector3d(0,0,0), LLVector3d(1,1,1), NULL);
+	new LLVolumeOctreeListener(mOctree);
+
+	for (U32 i = 0; i < mNumIndices; i+= 3)
+	{
+		Triangle* tri = new Triangle();
+				
+		const LLVector4a& v0 = mPositions[mIndices[i]];
+		const LLVector4a& v1 = mPositions[mIndices[i+1]];
+		const LLVector4a& v2 = mPositions[mIndices[i+2]];
+
+		tri->mV[0] = &v0;
+		tri->mV[1] = &v1;
+		tri->mV[2] = &v2;
+
+		tri->mIndex[0] = mIndices[i];
+		tri->mIndex[1] = mIndices[i+1];
+		tri->mIndex[2] = mIndices[i+2];
+
+		LLVector4a min = v0;
+		min.setMin(v1);
+		min.setMin(v2);
+
+		LLVector4a max = v0;
+		max.setMax(v1);
+		max.setMax(v2);
+
+		LLVector4a center;
+		center.setAdd(min, max);
+		center.mul(0.5f);
+
+
+		tri->mPositionGroup.setVec(center[0], center[1], center[2]);
+
+		LLVector4a size;
+		size.setSub(max,min);
+		
+		tri->mRadius = size.length3() * 0.5f;
+		
+		mOctree->insert(tri);
+	}
+
+	LLVolumeOctreeRebound rebound(this);
+	rebound.traverse(mOctree);
+}
+
+const LLVector3d& LLVolumeFace::Triangle::getPositionGroup() const
+{
+	return mPositionGroup;
+}
+
+const F64& LLVolumeFace::Triangle::getBinRadius() const
+{
+	return mRadius;
+}
+
 void LLVolumeFace::swapData(LLVolumeFace& rhs)
 {
 	llswap(rhs.mPositions, mPositions);
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 7c63266aab8..a40a21b4059 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -40,6 +40,9 @@ class LLPathParams;
 class LLVolumeParams;
 class LLProfile;
 class LLPath;
+
+template <class T> class LLOctreeNode;
+class LLVector4a;
 class LLVolumeFace;
 class LLVolume;
 
@@ -49,15 +52,14 @@ class LLVolume;
 //#include "vmath.h"
 #include "v2math.h"
 #include "v3math.h"
+#include "v3dmath.h"
 #include "v4math.h"
-#include "llvector4a.h"
 #include "llquaternion.h"
 #include "llstrider.h"
 #include "v4coloru.h"
 #include "llrefcount.h"
 #include "llfile.h"
 
-
 //============================================================================
 
 const S32 MIN_DETAIL_FACES = 6;
@@ -830,6 +832,9 @@ class LLVolumeFace
 	LLVolumeFace& operator=(const LLVolumeFace& rhs);
 
 	~LLVolumeFace();
+private:
+	void freeData();
+public:
 
 	BOOL create(LLVolume* volume, BOOL partial_build = FALSE);
 	void createBinormals();
@@ -855,26 +860,19 @@ class LLVolumeFace
 	public:
 		U16 mIndex;
 
-		bool operator==(const LLVolumeFace::VertexData& rhs) const
-		{
-			return getPosition().equal3(rhs.getPosition()) &&
-				mTexCoord == rhs.mTexCoord &&
-				getNormal().equal3(rhs.getNormal());
-		}
+		bool operator==(const LLVolumeFace::VertexData& rhs) const;
 
 		struct ComparePosition
 		{
-			bool operator()(const LLVector4a& a, const LLVector4a& b) const
-			{
-				return a.less3(b);			
-			}
+			bool operator()(const LLVector4a& a, const LLVector4a& b) const;
 		};
 
 		typedef std::map<LLVector4a, std::vector<VertexMapData>, VertexMapData::ComparePosition > PointMap;
 	};
 
 	void optimize(F32 angle_cutoff = 2.f);
-	
+	void createOctree();
+
 	enum
 	{
 		SINGLE_MASK =	0x0001,
@@ -919,6 +917,21 @@ class LLVolumeFace
 	// mWeights.size() should be empty or match mVertices.size()  
 	LLVector4a* mWeights;
 
+	class Triangle : public LLRefCount
+	{
+	public:
+		const LLVector4a* mV[3];
+		U16 mIndex[3];
+
+		LLVector3d mPositionGroup;
+		F64 mRadius;
+
+		virtual const LLVector3d& getPositionGroup() const;
+		virtual const F64& getBinRadius() const;
+	};
+
+	LLOctreeNode<Triangle>* mOctree;
+
 private:
 	BOOL createUnCutCubeCap(LLVolume* volume, BOOL partial_build = FALSE);
 	BOOL createCap(LLVolume* volume, BOOL partial_build = FALSE);
@@ -1084,10 +1097,12 @@ BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* cent
 BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size);
 
 BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
-							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided);
+							F32& intersection_a, F32& intersection_b, F32& intersection_t, BOOL two_sided);
 
 BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
-							F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided);
+							F32& intersection_a, F32& intersection_b, F32& intersection_t);
+BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
+							F32& intersection_a, F32& intersection_b, F32& intersection_t);
 	
 	
 
diff --git a/indra/newview/llhudicon.cpp b/indra/newview/llhudicon.cpp
index 3c5a4de7f8a..63040904dff 100644
--- a/indra/newview/llhudicon.cpp
+++ b/indra/newview/llhudicon.cpp
@@ -286,7 +286,6 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 	LLVector4a upper_right;
 	upper_right.setAdd(lower_right, y_scalea);
 
-	F32 t = 0.f;
 	LLVector4a enda;
 	enda.load3(end.mV);
 	LLVector4a starta;
@@ -294,8 +293,10 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 	LLVector4a dir;
 	dir.setSub(enda, starta);
 
-	if (LLTriangleRayIntersect(upper_right, upper_left, lower_right, starta, dir, NULL, NULL, &t, FALSE) ||
-		LLTriangleRayIntersect(upper_left, lower_left, lower_right, starta, dir, NULL, NULL, &t, FALSE))
+	F32 a,b,t;
+
+	if (LLTriangleRayIntersect(upper_right, upper_left, lower_right, starta, dir, a,b,t) ||
+		LLTriangleRayIntersect(upper_left, lower_left, lower_right, starta, dir, a,b,t))
 	{
 		if (intersection)
 		{
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 9ed5d13831c..7f9eddc837c 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -207,10 +207,11 @@ BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 		}
 
 		LLVector3 dir = end-start;
-		F32 t = 0.f;
+		F32 a,b,t;
 
-		if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, NULL, NULL, &t, FALSE) ||
-			LLTriangleRayIntersect(v[2], v[3], v[0], start, dir, NULL, NULL, &t, FALSE) )
+
+		if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, a, b, t, FALSE) ||
+			LLTriangleRayIntersect(v[2], v[3], v[0], start, dir, a, b, t, FALSE) )
 		{
 			if (t <= 1.f)
 			{
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index a5804aa04e9..98fbebbc5d2 100644
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -65,6 +65,7 @@
 #include "llweb.h"
 #include "llwindow.h"
 #include "llfloatertools.h"  // to enable hide if build tools are up
+#include "llvector4a.h"
 
 // Functions pulled from pipeline.cpp
 glh::matrix4f glh_get_current_modelview();
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 470c332b42b..60e704d3607 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2769,6 +2769,19 @@ void renderLights(LLDrawable* drawablep)
 	}
 }
 
+class LLRenderOctree : public LLOctreeTraveler<LLVolumeFace::Triangle>
+{
+public:
+	void visit(const LLOctreeNode<LLVolumeFace::Triangle>* branch)
+	{
+		const LLVector3d& c = branch->getCenter();
+		const LLVector3d& s = branch->getSize();
+
+		LLVector3 pos((F32) c.mdV[0], (F32) c.mdV[1], (F32) c.mdV[2]);
+		LLVector3 size((F32) s.mdV[0], (F32) s.mdV[1], (F32) s.mdV[2]);
+		drawBoxOutline(pos, size);
+	}
+};
 
 void renderRaycast(LLDrawable* drawablep)
 {
@@ -2787,6 +2800,23 @@ void renderRaycast(LLDrawable* drawablep)
 			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 			pushVerts(drawablep->getFace(gDebugRaycastFaceHit), LLVertexBuffer::MAP_VERTEX);
 			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+			LLVOVolume* vobj = drawablep->getVOVolume();
+			LLVolume* volume = vobj->getVolume();
+			if (volume && volume->getNumVolumeFaces() > gDebugRaycastFaceHit)
+			{
+				const LLVolumeFace& face = volume->getVolumeFace(gDebugRaycastFaceHit);
+				if (!face.mOctree)
+				{
+					((LLVolumeFace*) &face)->createOctree(); 
+				}
+
+				gGL.pushMatrix();
+				glMultMatrixf((F32*) vobj->getRelativeXform().mMatrix);
+				LLRenderOctree render;
+				render.traverse(face.mOctree);
+				gGL.popMatrix();		
+			}
 		}
 		else if (drawablep->isAvatar())
 		{
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index 91c9b762c57..fe1e36cbe8c 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -647,23 +647,23 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 
 		U32 idx0 = 0,idx1 = 0,idx2 = 0;
 
-		if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, &a, &b, &t, FALSE))
+		if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, a, b, t, FALSE))
 		{
 			hit = TRUE;
 			idx0 = 0; idx1 = 1; idx2 = 2;
 		}
-		else if (LLTriangleRayIntersect(v[1], v[3], v[2], start, dir, &a, &b, &t, FALSE))
+		else if (LLTriangleRayIntersect(v[1], v[3], v[2], start, dir, a, b, t, FALSE))
 		{
 			hit = TRUE;
 			idx0 = 1; idx1 = 3; idx2 = 2;
 		}
-		else if (LLTriangleRayIntersect(v[2], v[1], v[0], start, dir, &a, &b, &t, FALSE))
+		else if (LLTriangleRayIntersect(v[2], v[1], v[0], start, dir, a, b, t, FALSE))
 		{
 			normal1 = -normal1;
 			hit = TRUE;
 			idx0 = 2; idx1 = 1; idx2 = 0;
 		}
-		else if (LLTriangleRayIntersect(v[2], v[3], v[1], start, dir, &a, &b, &t, FALSE))
+		else if (LLTriangleRayIntersect(v[2], v[3], v[1], start, dir, a, b, t, FALSE))
 		{
 			normal1 = -normal1;
 			hit = TRUE;
-- 
GitLab


From 9a869d630162292864e01fdd1707efc609fbd6b4 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 29 May 2010 19:55:13 -0500
Subject: [PATCH 466/683] Octree triven raycast works, time to profile.

---
 indra/llmath/CMakeLists.txt          |   2 +
 indra/llmath/lltreenode.h            |   3 +
 indra/llmath/llvolume.cpp            | 202 +--------------------------
 indra/llmath/llvolume.h              |   2 +
 indra/newview/llspatialpartition.cpp |  28 +++-
 indra/newview/llviewerwindow.cpp     |  21 ++-
 indra/newview/llviewerwindow.h       |   6 +-
 7 files changed, 58 insertions(+), 206 deletions(-)

diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt
index 367486eee73..dda07133d59 100644
--- a/indra/llmath/CMakeLists.txt
+++ b/indra/llmath/CMakeLists.txt
@@ -22,6 +22,7 @@ set(llmath_SOURCE_FILES
     llsphere.cpp
     llvolume.cpp
     llvolumemgr.cpp
+    llvolumeoctree.cpp
     llsdutil_math.cpp
     m3math.cpp
     m4math.cpp
@@ -66,6 +67,7 @@ set(llmath_HEADER_FILES
     llmatrix4a.h
     llvolume.h
     llvolumemgr.h
+    llvolumeoctree.h
     llsdutil_math.h
     m3math.h
     m4math.h
diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h
index ee9836241a5..e6d2521b2ac 100644
--- a/indra/llmath/lltreenode.h
+++ b/indra/llmath/lltreenode.h
@@ -34,6 +34,9 @@
 
 #include "stdtypes.h"
 #include "xform.h"
+#include "llpointer.h"
+#include "llrefcount.h"
+
 #include <vector>
 
 template <class T> class LLTreeNode;
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index d261811aa23..c4172de651b 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -48,6 +48,7 @@
 #include "lloctree.h"
 #include "lldarray.h"
 #include "llvolume.h"
+#include "llvolumeoctree.h"
 #include "llstl.h"
 #include "llsdserialize.h"
 #include "llvector4a.h"
@@ -133,50 +134,6 @@ BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* cent
 	return true;
 }
 
-BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size)
-{
-	LLVector4a fAWdU;
-	LLVector4a dir;
-	LLVector4a diff;
-
-	dir.setSub(end, start);
-	dir.mul(0.5f);
-
-	diff.setAdd(end,start);
-	diff.mul(0.5f);
-	diff.sub(center);
-	fAWdU.setAbs(dir); 
-
-	LLVector4a rhs;
-	rhs.setAdd(size, fAWdU);
-
-	LLVector4a lhs;
-	lhs.setAbs(diff);
-
-	S32 grt = lhs.greaterThan4(rhs).getComparisonMask();
-
-	if (grt & 0x7)
-	{
-		return false;
-	}
-	
-	LLVector4a f;
-	f.setCross3(dir, diff);
-	f.setAbs(f);
-
-	LLVector4a v0; v0.mQ = _mm_shuffle_ps(size.mQ, size.mQ, _MM_SHUFFLE(3,1,0,0));
-	LLVector4a v1; v1.mQ = _mm_shuffle_ps(fAWdU.mQ, fAWdU.mQ, _MM_SHUFFLE(3,2,2,1));
-	lhs.setMul(v0, v1);
-
-	v0.mQ = _mm_shuffle_ps(size.mQ, size.mQ, _MM_SHUFFLE(3,2,2,1));
-	v1.mQ = _mm_shuffle_ps(fAWdU.mQ, fAWdU.mQ, _MM_SHUFFLE(3,1,0,0));
-	rhs.setMul(v0, v1);
-	rhs.add(lhs);
-
-	grt = f.greaterThan4(rhs).getComparisonMask();
-
-	return (grt & 0x7) ? false : true;	
-}
 
 
 // intersect test between triangle vert0, vert1, vert2 and a ray from orig in direction dir.
@@ -203,7 +160,7 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 	LLVector4a det;
 	det.setAllDot3(edge1, pvec);
 	
-	if (det.greaterEqual4(LLVector4a::getApproximatelyZero()).getComparisonMask())
+	if (det.greaterEqual4(LLVector4a::getApproximatelyZero()).getComparisonMask() & 0x7)
 	{
 		/* calculate distance from vert0 to ray origin */
 		LLVector4a tvec;
@@ -213,8 +170,8 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 		LLVector4a u;
 		u.setAllDot3(tvec,pvec);
 
-		if (u.greaterEqual4(LLVector4a::getZero()).getComparisonMask() &&
-			u.lessEqual4(det).getComparisonMask())
+		if ((u.greaterEqual4(LLVector4a::getZero()).getComparisonMask() & 0x7) &&
+			(u.lessEqual4(det).getComparisonMask() & 0x7))
 		{
 			/* prepare to test V parameter */
 			LLVector4a qvec;
@@ -230,10 +187,10 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 			LLVector4a sum_uv;
 			sum_uv.setAdd(u, v);
 
-			S32 v_gequal = v.greaterEqual4(LLVector4a::getZero()).getComparisonMask();
-			S32 sum_lequal = sum_uv.lessEqual4(det).getComparisonMask();
+			S32 v_gequal = v.greaterEqual4(LLVector4a::getZero()).getComparisonMask() & 0x7;
+			S32 sum_lequal = sum_uv.lessEqual4(det).getComparisonMask() & 0x7;
 
-			if (v_gequal && sum_lequal)
+			if (v_gequal  && sum_lequal)
 			{
 				/* calculate t, scale parameters, ray intersects triangle */
 				LLVector4a t;
@@ -338,44 +295,6 @@ BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, cons
 	}
 }
 
-
-class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeFace::Triangle>
-{
-public:
-	
-	LLVolumeOctreeListener(LLOctreeNode<LLVolumeFace::Triangle>* node)
-	{
-		node->addListener(this);
-
-		mBounds = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*4, 16);
-		mExtents = mBounds+2;
-	}
-
-	~LLVolumeOctreeListener()
-	{
-		_mm_free(mBounds);
-	}
-	
-	 //LISTENER FUNCTIONS
-	virtual void handleChildAddition(const LLOctreeNode<LLVolumeFace::Triangle>* parent, 
-		LLOctreeNode<LLVolumeFace::Triangle>* child)
-	{
-		new LLVolumeOctreeListener(child);
-	}
-
-	virtual void handleStateChange(const LLTreeNode<LLVolumeFace::Triangle>* node) { }
-	virtual void handleChildRemoval(const LLOctreeNode<LLVolumeFace::Triangle>* parent, 
-			const LLOctreeNode<LLVolumeFace::Triangle>* child) {	}
-	virtual void handleInsertion(const LLTreeNode<LLVolumeFace::Triangle>* node, LLVolumeFace::Triangle* tri) { }
-	virtual void handleRemoval(const LLTreeNode<LLVolumeFace::Triangle>* node, LLVolumeFace::Triangle* tri) { }
-	virtual void handleDestruction(const LLTreeNode<LLVolumeFace::Triangle>* node) { }
-	
-
-public:
-	LLVector4a* mBounds; // bounding box (center, size) of this node and all its children (tight fit to objects)
-	LLVector4a* mExtents; // extents (min, max) of this node and all its children
-};
-
 class LLVolumeOctreeRebound : public LLOctreeTravelerDepthFirst<LLVolumeFace::Triangle>
 {
 public:
@@ -4436,113 +4355,6 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 
 }
 
-class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeFace::Triangle>
-{
-public:
-	const LLVolumeFace* mFace;
-	LLVector4a mStart;
-	LLVector4a mDir;
-	LLVector4a mEnd;
-	LLVector3* mIntersection;
-	LLVector2* mTexCoord;
-	LLVector3* mNormal;
-	LLVector3* mBinormal;
-	F32* mClosestT;
-	bool mHitFace;
-
-	LLOctreeTriangleRayIntersect(const LLVector4a& start, const LLVector4a& dir, 
-								   const LLVolumeFace* face, F32* closest_t,
-								   LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
-								   : mFace(face),
-								     mStart(start),
-									 mDir(dir),
-									 mIntersection(intersection),
-									 mTexCoord(tex_coord),
-									 mNormal(normal),
-									 mBinormal(bi_normal),
-									 mClosestT(closest_t),
-									 mHitFace(false)
-	{
-		mEnd.setAdd(mStart, mDir);
-	}
-
-	void traverse(const LLOctreeNode<LLVolumeFace::Triangle>* node)
-	{
-		LLVolumeOctreeListener* vl = (LLVolumeOctreeListener*) node->getListener(0);
-
-		/*const F32* start = mStart.getF32();
-		const F32* end = mEnd.getF32();
-		const F32* center = vl->mBounds[0].getF32();
-		const F32* size = vl->mBounds[1].getF32();*/
-
-		if (LLLineSegmentBoxIntersect(mStart, mEnd, vl->mBounds[0], vl->mBounds[1]))
-		{
-			node->accept(this);
-			for (S32 i = 0; i < node->getChildCount(); ++i)
-			{
-				traverse(node->getChild(i));
-			}
-		}
-	}
-
-	void visit(const LLOctreeNode<LLVolumeFace::Triangle>* node)
-	{
-		for (LLOctreeNode<LLVolumeFace::Triangle>::const_element_iter iter = 
-				node->getData().begin(); iter != node->getData().end(); ++iter)
-		{
-			const LLVolumeFace::Triangle* tri = *iter;
-
-			F32 a, b, t;
-			
-			if (LLTriangleRayIntersect(*tri->mV[0], *tri->mV[1], *tri->mV[2],
-					mStart, mDir, a, b, t))
-			{
-				if ((t >= 0.f) &&      // if hit is after start
-					(t <= 1.f) &&      // and before end
-					(t < *mClosestT))   // and this hit is closer
-				{
-					*mClosestT = t;
-					mHitFace = true;
-
-					if (mIntersection != NULL)
-					{
-						LLVector4a intersect = mDir;
-						intersect.mul(*mClosestT);
-						intersect.add(mStart);
-						mIntersection->set(intersect.getF32());
-					}
-
-
-					if (mTexCoord != NULL)
-					{
-						LLVector2* tc = (LLVector2*) mFace->mTexCoords;
-						*mTexCoord = ((1.f - a - b)  * tc[tri->mIndex[0]] +
-							a              * tc[tri->mIndex[1]] +
-							b              * tc[tri->mIndex[2]]);
-
-					}
-
-					if (mNormal != NULL)
-					{
-						LLVector4* norm = (LLVector4*) mFace->mNormals;
-
-						*mNormal    = ((1.f - a - b)  * LLVector3(norm[tri->mIndex[0]]) + 
-							a              * LLVector3(norm[tri->mIndex[1]]) +
-							b              * LLVector3(norm[tri->mIndex[2]]));
-					}
-
-					if (mBinormal != NULL)
-					{
-						LLVector4* binormal = (LLVector4*) mFace->mBinormals;
-						*mBinormal = ((1.f - a - b)  * LLVector3(binormal[tri->mIndex[0]]) + 
-								a              * LLVector3(binormal[tri->mIndex[1]]) +
-								b              * LLVector3(binormal[tri->mIndex[2]]));
-					}
-				}
-			}
-		}
-	}
-};
 
 S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, 
 								   S32 face,
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index a40a21b4059..0ae8aa19caa 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -42,6 +42,7 @@ class LLProfile;
 class LLPath;
 
 template <class T> class LLOctreeNode;
+
 class LLVector4a;
 class LLVolumeFace;
 class LLVolume;
@@ -1095,6 +1096,7 @@ void calc_binormal_from_triangle(
 
 BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size);
 BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size);
+BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size);
 
 BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
 							F32& intersection_a, F32& intersection_b, F32& intersection_t, BOOL two_sided);
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 60e704d3607..355173772b7 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -38,6 +38,7 @@
 #include "llviewerobjectlist.h"
 #include "llvovolume.h"
 #include "llvolume.h"
+#include "llvolumeoctree.h"
 #include "llviewercamera.h"
 #include "llface.h"
 #include "llviewercontrol.h"
@@ -2769,17 +2770,26 @@ void renderLights(LLDrawable* drawablep)
 	}
 }
 
-class LLRenderOctree : public LLOctreeTraveler<LLVolumeFace::Triangle>
+class LLRenderOctreeRaycast : public LLOctreeTriangleRayIntersect
 {
 public:
+	
+	LLRenderOctreeRaycast(const LLVector3& start, const LLVector3& end)
+	{
+		mStart.load3(start.mV);
+		mEnd.load3(end.mV);
+		mDir.setSub(mEnd, mStart);
+	}
+
 	void visit(const LLOctreeNode<LLVolumeFace::Triangle>* branch)
 	{
-		const LLVector3d& c = branch->getCenter();
-		const LLVector3d& s = branch->getSize();
+		LLVolumeOctreeListener* vl = (LLVolumeOctreeListener*) branch->getListener(0);
 
-		LLVector3 pos((F32) c.mdV[0], (F32) c.mdV[1], (F32) c.mdV[2]);
-		LLVector3 size((F32) s.mdV[0], (F32) s.mdV[1], (F32) s.mdV[2]);
-		drawBoxOutline(pos, size);
+		LLVector3 center, size;
+		center.set(vl->mBounds[0].getF32());
+		size.set(vl->mBounds[1].getF32());
+
+		drawBoxOutline(center, size);
 	}
 };
 
@@ -2813,7 +2823,11 @@ void renderRaycast(LLDrawable* drawablep)
 
 				gGL.pushMatrix();
 				glMultMatrixf((F32*) vobj->getRelativeXform().mMatrix);
-				LLRenderOctree render;
+				LLVector3 start, end;
+				start = vobj->agentPositionToVolume(gDebugRaycastStart);
+				end = vobj->agentPositionToVolume(gDebugRaycastEnd);
+
+				LLRenderOctreeRaycast render(start, end);
 				render.traverse(face.mOctree);
 				gGL.popMatrix();		
 			}
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 2422995288b..0564f02ce56 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -231,6 +231,8 @@ LLVector2       gDebugRaycastTexCoord;
 LLVector3       gDebugRaycastNormal;
 LLVector3       gDebugRaycastBinormal;
 S32				gDebugRaycastFaceHit;
+LLVector3		gDebugRaycastStart;
+LLVector3		gDebugRaycastEnd;
 
 // HUD display lines in lower right
 BOOL				gDisplayWindInfo = FALSE;
@@ -2529,7 +2531,9 @@ void LLViewerWindow::updateUI()
 											  &gDebugRaycastIntersection,
 											  &gDebugRaycastTexCoord,
 											  &gDebugRaycastNormal,
-											  &gDebugRaycastBinormal);
+											  &gDebugRaycastBinormal,
+											  &gDebugRaycastStart,
+											  &gDebugRaycastEnd);
 	}
 
 	updateMouseDelta();
@@ -3445,7 +3449,9 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
 												LLVector3 *intersection,
 												LLVector2 *uv,
 												LLVector3 *normal,
-												LLVector3 *binormal)
+												LLVector3 *binormal,
+												LLVector3* start,
+												LLVector3* end)
 {
 	S32 x = mouse_x;
 	S32 y = mouse_y;
@@ -3477,7 +3483,16 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
 	LLVector3 mouse_world_start = mouse_point_global;
 	LLVector3 mouse_world_end   = mouse_point_global + mouse_direction_global * depth;
 
-	
+	if (start)
+	{
+		*start = mouse_world_start;
+	}
+
+	if (end)
+	{
+		*end = mouse_world_end;
+	}
+
 	LLViewerObject* found = NULL;
 
 	if (this_object)  // check only this object
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 410445d97fa..156a1ff8ad0 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -361,7 +361,9 @@ class LLViewerWindow : public LLWindowCallbacks
 									LLVector3 *intersection = NULL,
 									LLVector2 *uv = NULL,
 									LLVector3 *normal = NULL,
-									LLVector3 *binormal = NULL);
+									LLVector3 *binormal = NULL,
+									LLVector3* start = NULL,
+									LLVector3* end = NULL);
 	
 	
 	// Returns a pointer to the last object hit
@@ -507,6 +509,8 @@ extern LLVector2        gDebugRaycastTexCoord;
 extern LLVector3        gDebugRaycastNormal;
 extern LLVector3        gDebugRaycastBinormal;
 extern S32				gDebugRaycastFaceHit;
+extern LLVector3		gDebugRaycastStart;
+extern LLVector3		gDebugRaycastEnd;
 
 extern S32 CHAT_BAR_HEIGHT; 
 
-- 
GitLab


From 19e9cada814ee116fcd325b37da0bd2f578e7d2d Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 3 Jun 2010 14:43:29 +0100
Subject: [PATCH 467/683] Really, never turn on deferred by default.  Might
 help with mysterious EXT-7543

---
 indra/newview/featuretable.txt       | 12 ++++++------
 indra/newview/featuretable_linux.txt | 16 ++++++++--------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 9b828e7dcc2..fafb9f91329 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -56,9 +56,9 @@ Disregard96DefaultDrawDistance	1	1
 RenderTextureMemoryMultiple		1	1.0
 RenderShaderLightingMaxLevel	1	3
 SkyUseClassicClouds			1	1
-RenderDeferred				1	1
-RenderDeferredSSAO			1	1
-RenderShadowDetail			1	2
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
 
 //
 // Low Graphics Settings
@@ -165,9 +165,9 @@ RenderVolumeLODFactor		1	2.0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
-RenderDeferred				1	1
-RenderDeferredSSAO			1	1
-RenderShadowDetail			1	2
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
 
 
 //
diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt
index ba3ad5ee617..d64e3f77e21 100644
--- a/indra/newview/featuretable_linux.txt
+++ b/indra/newview/featuretable_linux.txt
@@ -56,9 +56,9 @@ Disregard96DefaultDrawDistance	1	1
 RenderTextureMemoryMultiple		1	1.0
 SkyUseClassicClouds			1	1
 RenderShaderLightingMaxLevel		1	3
-RenderDeferred				1	1
-RenderDeferredSSAO			1	1
-RenderShadowDetail			1	2
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
 
 //
 // Low Graphics Settings
@@ -138,9 +138,9 @@ RenderVolumeLODFactor		1	1.125
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	48
-RenderDeferred				1	1
+RenderDeferred				1	0
 RenderDeferredSSAO			1	0
-RenderShadowDetail			1	1
+RenderShadowDetail			1	0
 
 
 //
@@ -165,9 +165,9 @@ RenderVolumeLODFactor		1	2.0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
-RenderDeferred				1	1
-RenderDeferredSSAO			1	1
-RenderShadowDetail			1	2
+RenderDeferred				1	0
+RenderDeferredSSAO			1	0
+RenderShadowDetail			1	0
 
 
 //
-- 
GitLab


From 2f526db82608915a6ed9d04f31fb004acf239f4f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 3 Jun 2010 15:04:42 +0100
Subject: [PATCH 468/683] trivial comment fix

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

diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index 91191287cd9..67a45e06c39 100644
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -151,7 +151,7 @@ void LLDrawPoolSimple::render(S32 pass)
 		renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask());
 
 		if (LLPipeline::sRenderDeferred)
-		{ //if deferred rendering is enabled, bump faces aren't reigstered as simple
+		{ //if deferred rendering is enabled, bump faces aren't registered as simple
 			//render bump faces here as simple so bump faces will appear under water
 			renderTexture(LLRenderPass::PASS_BUMP, getVertexDataMask());
 		}
-- 
GitLab


From 26ba00b5554d20ee958693ced87b36fa7f6e3d99 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 3 Jun 2010 12:52:28 -0500
Subject: [PATCH 469/683] Vectorized octree and much of llspatialpartition and
 lldrawable. Octree driven raycast.

---
 indra/llmath/llcamera.cpp            | 216 +++++------
 indra/llmath/llcamera.h              |  29 +-
 indra/llmath/lloctree.h              | 239 ++++++------
 indra/llmath/llvolume.cpp            |  31 +-
 indra/llmath/llvolume.h              |  16 +-
 indra/llrender/llvertexbuffer.h      |  11 +
 indra/llui/lllineeditor.cpp          |   9 +-
 indra/newview/lldrawable.cpp         | 163 +++++----
 indra/newview/lldrawable.h           |  34 +-
 indra/newview/llface.cpp             | 164 ++++++---
 indra/newview/llface.h               |  15 +-
 indra/newview/llflexibleobject.cpp   |   6 +-
 indra/newview/llflexibleobject.h     |   2 +-
 indra/newview/llselectmgr.cpp        |  16 +-
 indra/newview/llspatialpartition.cpp | 520 +++++++++++++++++----------
 indra/newview/llspatialpartition.h   |  80 ++++-
 indra/newview/llsurfacepatch.cpp     |   6 +-
 indra/newview/llviewerdisplay.cpp    |   7 +-
 indra/newview/llviewerobject.cpp     |  40 ++-
 indra/newview/llviewerobject.h       |   4 +-
 indra/newview/llviewerpartsim.cpp    |   4 +-
 indra/newview/llvoavatar.cpp         | 100 ++++--
 indra/newview/llvoavatar.h           |  10 +-
 indra/newview/llvopartgroup.cpp      |  10 +-
 indra/newview/llvopartgroup.h        |   2 +-
 indra/newview/llvosurfacepatch.cpp   |  19 +-
 indra/newview/llvosurfacepatch.h     |   2 +-
 indra/newview/llvotree.cpp           |  17 +-
 indra/newview/llvotree.h             |   2 +-
 indra/newview/llvovolume.cpp         |  35 +-
 indra/newview/llvovolume.h           |   6 +-
 indra/newview/llvowater.cpp          |  20 +-
 indra/newview/llvowater.h            |   2 +-
 indra/newview/pipeline.cpp           | 257 +++++++++++--
 indra/newview/pipeline.h             |   9 +
 35 files changed, 1333 insertions(+), 770 deletions(-)

diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp
index 487ed6451f4..6b56e4870ed 100644
--- a/indra/llmath/llcamera.cpp
+++ b/indra/llmath/llcamera.cpp
@@ -48,10 +48,10 @@ LLCamera::LLCamera() :
 	mPlaneCount(6),
 	mFrustumCornerDist(0.f)
 {
+	alignPlanes();
 	calculateFrustumPlanes();
 } 
 
-
 LLCamera::LLCamera(F32 vertical_fov_rads, F32 aspect_ratio, S32 view_height_in_pixels, F32 near_plane, F32 far_plane) :
 	LLCoordFrame(),
 	mViewHeightInPixels(view_height_in_pixels),
@@ -59,6 +59,7 @@ LLCamera::LLCamera(F32 vertical_fov_rads, F32 aspect_ratio, S32 view_height_in_p
 	mPlaneCount(6),
 	mFrustumCornerDist(0.f)
 {
+	alignPlanes();
 	mAspect = llclamp(aspect_ratio, MIN_ASPECT_RATIO, MAX_ASPECT_RATIO);
 	mNearPlane = llclamp(near_plane, MIN_NEAR_PLANE, MAX_NEAR_PLANE);
 	if(far_plane < 0) far_plane = DEFAULT_FAR_PLANE;
@@ -67,6 +68,23 @@ LLCamera::LLCamera(F32 vertical_fov_rads, F32 aspect_ratio, S32 view_height_in_p
 	setView(vertical_fov_rads);
 } 
 
+LLCamera::~LLCamera()
+{
+
+}
+
+const LLCamera& LLCamera::operator=(const LLCamera& rhs)
+{
+	memcpy(this, &rhs, sizeof(LLCamera));
+	alignPlanes();
+	LLVector4a::memcpyNonAliased16((F32*) mAgentPlanes, (F32*) rhs.mAgentPlanes, 4*7);
+	return *this;
+}
+
+void LLCamera::alignPlanes()
+{
+	mAgentPlanes = (LLPlane*) LL_NEXT_ALIGNED_ADDRESS<U8>(mAgentPlaneBuffer);
+}
 
 // ---------------- LLCamera::getFoo() member functions ----------------
 
@@ -91,8 +109,8 @@ F32 LLCamera::getMaxView() const
 void LLCamera::setUserClipPlane(LLPlane plane)
 {
 	mPlaneCount = 7;
-	mAgentPlanes[6].p = plane;
-	mAgentPlanes[6].mask = calcPlaneMask(plane);
+	mAgentPlanes[6] = plane;
+	mPlaneMask[6] = calcPlaneMask(plane);
 }
 
 void LLCamera::disableUserClipPlane()
@@ -164,129 +182,66 @@ size_t LLCamera::readFrustumFromBuffer(const char *buffer)
 
 // ---------------- test methods  ---------------- 
 
-S32 LLCamera::AABBInFrustum(const LLVector3 &center, const LLVector3& radius) 
-{
-	static const LLVector3 scaler[] = {
-		LLVector3(-1,-1,-1),
-		LLVector3( 1,-1,-1),
-		LLVector3(-1, 1,-1),
-		LLVector3( 1, 1,-1),
-		LLVector3(-1,-1, 1),
-		LLVector3( 1,-1, 1),
-		LLVector3(-1, 1, 1),
-		LLVector3( 1, 1, 1)
+S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius) 
+{
+	static const LLVector4a scaler[] = {
+		LLVector4a(-1,-1,-1),
+		LLVector4a( 1,-1,-1),
+		LLVector4a(-1, 1,-1),
+		LLVector4a( 1, 1,-1),
+		LLVector4a(-1,-1, 1),
+		LLVector4a( 1,-1, 1),
+		LLVector4a(-1, 1, 1),
+		LLVector4a( 1, 1, 1)
 	};
 
 	U8 mask = 0;
 	S32 result = 2;
 
-	/*if (mFrustumCornerDist > 0.f && radius.magVecSquared() > mFrustumCornerDist * mFrustumCornerDist)
-	{ //box is larger than frustum, check frustum quads against box planes
-
-		static const LLVector3 dir[] = 
-		{
-			LLVector3(1, 0, 0),
-			LLVector3(-1, 0, 0),
-			LLVector3(0, 1, 0),
-			LLVector3(0, -1, 0),
-			LLVector3(0, 0, 1),
-			LLVector3(0, 0, -1)
-		};
-
-		U32 quads[] = 
+	for (U32 i = 0; i < mPlaneCount; i++)
+	{
+		mask = mPlaneMask[i];
+		if (mask == 0xff)
 		{
-			0, 1, 2, 3,
-			0, 1, 5, 4,
-			2, 3, 7, 6,
-			3, 0, 7, 4,
-			1, 2, 6, 4,
-			4, 5, 6, 7
-		};
-
-		result = 0;
-
-		BOOL total_inside = TRUE;
-		for (U32 i = 0; i < 6; i++)
-		{ 
-			LLVector3 p = center + radius.scaledVec(dir[i]);
-			F32 d = -p*dir[i];
-
-			for (U32 j = 0; j <	6; j++)
-			{ //for each quad
-				F32 dist = mAgentFrustum[quads[j*4+0]]*dir[i] + d;
-				if (dist > 0)
-				{ //at least one frustum point is outside the AABB
-					total_inside = FALSE;
-					for (U32 k = 1; k < 4; k++)
-					{ //for each other point on quad
-						if ( mAgentFrustum[quads[j*4+k]]*dir[i]+d  <= 0.f)
-						{ //quad is straddling some plane of AABB
-							return 1;
-						}
-					}
-				}
-				else
-				{
-					for (U32 k = 1; k < 4; k++)
-					{
-						if (mAgentFrustum[quads[j*4+k]]*dir[i]+d > 0.f)
-						{
-							return 1;
-						}
-					}
-				}
-			}
+			continue;
 		}
 
-		if (total_inside)
+		const LLPlane& p = mAgentPlanes[i];
+		const LLVector4a& n = reinterpret_cast<const LLVector4a&>(p);
+		float d = p.mV[3];
+		LLVector4a rscale;
+		rscale.setMul(radius, scaler[mask]);
+
+		LLVector4a minp, maxp;
+		minp.setSub(center, rscale);
+		maxp.setAdd(center, rscale);
+
+		if (n.dot3(minp) > -d) 
 		{
-			result = 1;
+			return 0;
 		}
-	}
-	else*/
-	{
-		for (U32 i = 0; i < mPlaneCount; i++)
+	
+		if (n.dot3(maxp) > -d)
 		{
-			mask = mAgentPlanes[i].mask;
-			if (mask == 0xff)
-			{
-				continue;
-			}
-			LLPlane p = mAgentPlanes[i].p;
-			LLVector3 n = LLVector3(p);
-			float d = p.mV[3];
-			LLVector3 rscale = radius.scaledVec(scaler[mask]);
-
-			LLVector3 minp = center - rscale;
-			LLVector3 maxp = center + rscale;
-
-			if (n * minp > -d) 
-			{
-				return 0;
-			}
-		
-			if (n * maxp > -d)
-			{
-				result = 1;
-			}
+			result = 1;
 		}
 	}
 
-	
 	return result;
 }
 
-S32 LLCamera::AABBInFrustumNoFarClip(const LLVector3 &center, const LLVector3& radius) 
-{
-	static const LLVector3 scaler[] = {
-		LLVector3(-1,-1,-1),
-		LLVector3( 1,-1,-1),
-		LLVector3(-1, 1,-1),
-		LLVector3( 1, 1,-1),
-		LLVector3(-1,-1, 1),
-		LLVector3( 1,-1, 1),
-		LLVector3(-1, 1, 1),
-		LLVector3( 1, 1, 1)
+
+S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius) 
+{
+	static const LLVector4a scaler[] = {
+		LLVector4a(-1,-1,-1),
+		LLVector4a( 1,-1,-1),
+		LLVector4a(-1, 1,-1),
+		LLVector4a( 1, 1,-1),
+		LLVector4a(-1,-1, 1),
+		LLVector4a( 1,-1, 1),
+		LLVector4a(-1, 1, 1),
+		LLVector4a( 1, 1, 1)
 	};
 
 	U8 mask = 0;
@@ -299,25 +254,28 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector3 &center, const LLVector3& r
 			continue;
 		}
 
-		mask = mAgentPlanes[i].mask;
+		mask = mPlaneMask[i];
 		if (mask == 0xff)
 		{
 			continue;
 		}
-		LLPlane p = mAgentPlanes[i].p;
-		LLVector3 n = LLVector3(p);
+
+		const LLPlane& p = mAgentPlanes[i];
+		const LLVector4a& n = reinterpret_cast<const LLVector4a&>(p);
 		float d = p.mV[3];
-		LLVector3 rscale = radius.scaledVec(scaler[mask]);
+		LLVector4a rscale;
+		rscale.setMul(radius, scaler[mask]);
 
-		LLVector3 minp = center - rscale;
-		LLVector3 maxp = center + rscale;
+		LLVector4a minp, maxp;
+		minp.setSub(center, rscale);
+		maxp.setAdd(center, rscale);
 
-		if (n * minp > -d) 
+		if (n.dot3(minp) > -d) 
 		{
 			return 0;
 		}
 	
-		if (n * maxp > -d)
+		if (n.dot3(maxp) > -d)
 		{
 			result = 1;
 		}
@@ -447,12 +405,12 @@ int LLCamera::sphereInFrustum(const LLVector3 &sphere_center, const F32 radius)
 	int res = 2;
 	for (int i = 0; i < 6; i++)
 	{
-		if (mAgentPlanes[i].mask == 0xff)
+		if (mPlaneMask[i] == 0xff)
 		{
 			continue;
 		}
 
-		float d = mAgentPlanes[i].p.dist(sphere_center);
+		float d = mAgentPlanes[i].dist(sphere_center);
 
 		if (d > radius) 
 		{
@@ -644,12 +602,14 @@ void LLCamera::ignoreAgentFrustumPlane(S32 idx)
 		return;
 	}
 
-	mAgentPlanes[idx].mask = 0xff;
-	mAgentPlanes[idx].p.clearVec();
+	mPlaneMask[idx] = 0xff;
+	mAgentPlanes[idx].clearVec();
 }
 
 void LLCamera::calcAgentFrustumPlanes(LLVector3* frust)
 {
+	alignPlanes();
+
 	for (int i = 0; i < 8; i++)
 	{
 		mAgentFrustum[i] = frust[i];
@@ -662,27 +622,27 @@ void LLCamera::calcAgentFrustumPlanes(LLVector3* frust)
 	//order of planes is important, keep most likely to fail in the front of the list
 
 	//near - frust[0], frust[1], frust[2]
-	mAgentPlanes[2].p = planeFromPoints(frust[0], frust[1], frust[2]);
+	mAgentPlanes[2] = planeFromPoints(frust[0], frust[1], frust[2]);
 
 	//far  
-	mAgentPlanes[5].p = planeFromPoints(frust[5], frust[4], frust[6]);
+	mAgentPlanes[5] = planeFromPoints(frust[5], frust[4], frust[6]);
 
 	//left  
-	mAgentPlanes[0].p = planeFromPoints(frust[4], frust[0], frust[7]);
+	mAgentPlanes[0] = planeFromPoints(frust[4], frust[0], frust[7]);
 
 	//right  
-	mAgentPlanes[1].p = planeFromPoints(frust[1], frust[5], frust[6]);
+	mAgentPlanes[1] = planeFromPoints(frust[1], frust[5], frust[6]);
 
 	//top  
-	mAgentPlanes[4].p = planeFromPoints(frust[3], frust[2], frust[6]);
+	mAgentPlanes[4] = planeFromPoints(frust[3], frust[2], frust[6]);
 
 	//bottom  
-	mAgentPlanes[3].p = planeFromPoints(frust[1], frust[0], frust[4]);
+	mAgentPlanes[3] = planeFromPoints(frust[1], frust[0], frust[4]);
 
 	//cache plane octant facing mask for use in AABBInFrustum
 	for (U32 i = 0; i < mPlaneCount; i++)
 	{
-		mAgentPlanes[i].mask = calcPlaneMask(mAgentPlanes[i].p);
+		mPlaneMask[i] = calcPlaneMask(mAgentPlanes[i]);
 	}
 }
 
diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
index d6c5f7bbb14..c40e819dcf0 100644
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -37,6 +37,7 @@
 #include "llmath.h"
 #include "llcoordframe.h"
 #include "llplane.h"
+#include "llvector4a.h"
 
 const F32 DEFAULT_FIELD_OF_VIEW 	= 60.f * DEG_TO_RAD;
 const F32 DEFAULT_ASPECT_RATIO 		= 640.f / 480.f;
@@ -79,6 +80,14 @@ class LLCamera
 : 	public LLCoordFrame
 {
 public:
+	
+	LLCamera(const LLCamera& rhs)
+	{
+		*this = rhs;
+	}
+
+	const LLCamera& operator=(const LLCamera& rhs);
+	
 	enum {
 		PLANE_LEFT = 0,
 		PLANE_RIGHT = 1,
@@ -129,13 +138,9 @@ class LLCamera
 	LLPlane mWorldPlanes[PLANE_NUM];
 	LLPlane mHorizPlanes[HORIZ_PLANE_NUM];
 
-	struct frustum_plane
-	{
-		frustum_plane() : mask(0) {}
-		LLPlane p;
-		U8 mask;
-	};
-	frustum_plane mAgentPlanes[7];  //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
+	LLPlane* mAgentPlanes;  //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
+	U8 mAgentPlaneBuffer[sizeof(LLPlane)*8];
+	U8 mPlaneMask[7];
 
 	U32 mPlaneCount;  //defaults to 6, if setUserClipPlane is called, uses user supplied clip plane in
 
@@ -143,12 +148,14 @@ class LLCamera
 public:
 	LLVector3 mAgentFrustum[8];  //8 corners of 6-plane frustum
 	F32	mFrustumCornerDist;		//distance to corner of frustum against far clip plane
-	LLPlane& getAgentPlane(U32 idx) { return mAgentPlanes[idx].p; }
+	LLPlane& getAgentPlane(U32 idx) { return mAgentPlanes[idx]; }
 
 public:
 	LLCamera();
 	LLCamera(F32 vertical_fov_rads, F32 aspect_ratio, S32 view_height_in_pixels, F32 near_plane, F32 far_plane);
-	virtual ~LLCamera(){} // no-op virtual destructor
+	virtual ~LLCamera();
+	
+	void alignPlanes();
 
 	void setUserClipPlane(LLPlane plane);
 	void disableUserClipPlane();
@@ -199,8 +206,8 @@ class LLCamera
 	S32 sphereInFrustum(const LLVector3 &center, const F32 radius) const;
 	S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); }
 	S32 sphereInFrustumFull(const LLVector3 &center, const F32 radius) const { return sphereInFrustum(center, radius); }
-	S32 AABBInFrustum(const LLVector3 &center, const LLVector3& radius);
-	S32 AABBInFrustumNoFarClip(const LLVector3 &center, const LLVector3& radius);
+	S32 AABBInFrustum(const LLVector4a& center, const LLVector4a& radius);
+	S32 AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius);
 
 	//does a quick 'n dirty sphere-sphere check
 	S32 sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius); 
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 8bba12783f8..ae2259dba0c 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -35,6 +35,7 @@
 
 #include "lltreenode.h"
 #include "v3math.h"
+#include "llvector4a.h"
 #include <vector>
 #include <set>
 
@@ -44,7 +45,7 @@
 #define OCT_ERRS LL_WARNS("OctreeErrors")
 #endif
 
-#define LL_OCTREE_PARANOIA_CHECK 0
+#define LL_OCTREE_PARANOIA_CHECK 1
 #if LL_DARWIN
 #define LL_OCTREE_MAX_CAPACITY 32
 #else
@@ -94,23 +95,22 @@ class LLOctreeNode : public LLTreeNode<T>
 	typedef LLOctreeNode<T>		oct_node;
 	typedef LLOctreeListener<T>	oct_listener;
 
-	static const U8 OCTANT_POSITIVE_X = 0x01;
-	static const U8 OCTANT_POSITIVE_Y = 0x02;
-	static const U8 OCTANT_POSITIVE_Z = 0x04;
-		
-	LLOctreeNode(	LLVector3d center, 
-					LLVector3d size, 
+	LLOctreeNode(	const LLVector4a& center, 
+					const LLVector4a& size, 
 					BaseType* parent, 
-					U8 octant = 255)
+					S32 octant = -1)
 	:	mParent((oct_node*)parent), 
-		mCenter(center), 
-		mSize(size), 
 		mOctant(octant) 
 	{ 
+		mD = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*4, 16);
+
+		mD[CENTER] = center;
+		mD[SIZE] = size;
+
 		updateMinMax();
-		if ((mOctant == 255) && mParent)
+		if ((mOctant == -1) && mParent)
 		{
-			mOctant = ((oct_node*) mParent)->getOctant(mCenter.mdV);
+			mOctant = ((oct_node*) mParent)->getOctant(mD[CENTER]);
 		}
 
 		clearChildren();
@@ -124,43 +124,30 @@ class LLOctreeNode : public LLTreeNode<T>
 		{
 			delete getChild(i);
 		} 
+
+		_mm_free(mD);
 	}
 
 	inline const BaseType* getParent()	const			{ return mParent; }
-	inline void setParent(BaseType* parent)			{ mParent = (oct_node*) parent; }
-	inline const LLVector3d& getCenter() const			{ return mCenter; }
-	inline const LLVector3d& getSize() const			{ return mSize; }
-	inline void setCenter(LLVector3d center)			{ mCenter = center; }
-	inline void setSize(LLVector3d size)				{ mSize = size; }
-    inline oct_node* getNodeAt(T* data)				{ return getNodeAt(data->getPositionGroup(), data->getBinRadius()); }
-	inline U8 getOctant() const						{ return mOctant; }
-	inline void setOctant(U8 octant)					{ mOctant = octant; }
+	inline void setParent(BaseType* parent)				{ mParent = (oct_node*) parent; }
+	inline const LLVector4a& getCenter() const			{ return mD[CENTER]; }
+	inline const LLVector4a& getSize() const			{ return mD[SIZE]; }
+	inline void setCenter(const LLVector4a& center)		{ mD[CENTER] = center; }
+	inline void setSize(const LLVector4a& size)			{ mD[SIZE] = size; }
+    inline oct_node* getNodeAt(T* data)					{ return getNodeAt(data->getPositionGroup(), data->getBinRadius()); }
+	inline S32 getOctant() const						{ return mOctant; }
+	inline void setOctant(S32 octant)					{ mOctant = octant; }
 	inline const oct_node*	getOctParent() const		{ return (const oct_node*) getParent(); }
 	inline oct_node* getOctParent() 					{ return (oct_node*) getParent(); }
 	
-	U8 getOctant(const F64 pos[]) const	//get the octant pos is in
+	S32 getOctant(const LLVector4a& pos) const			//get the octant pos is in
 	{
-		U8 ret = 0;
-
-		if (pos[0] > mCenter.mdV[0])
-		{
-			ret |= OCTANT_POSITIVE_X;
-		}
-		if (pos[1] > mCenter.mdV[1])
-		{
-			ret |= OCTANT_POSITIVE_Y;
-		}
-		if (pos[2] > mCenter.mdV[2])
-		{
-			ret |= OCTANT_POSITIVE_Z;
-		}
-
-		return ret;
+		return pos.greaterThan4(mD[CENTER]).getComparisonMask() & 0x7;
 	}
 	
-	inline bool isInside(const LLVector3d& pos, const F64& rad) const
+	inline bool isInside(const LLVector4a& pos, const F32& rad) const
 	{
-		return rad <= mSize.mdV[0]*2.0 && isInside(pos); 
+		return rad <= mD[SIZE][0]*2.f && isInside(pos); 
 	}
 
 	inline bool isInside(T* data) const			
@@ -168,29 +155,27 @@ class LLOctreeNode : public LLTreeNode<T>
 		return isInside(data->getPositionGroup(), data->getBinRadius());
 	}
 
-	bool isInside(const LLVector3d& pos) const
+	bool isInside(const LLVector4a& pos) const
 	{
-		const F64& x = pos.mdV[0];
-		const F64& y = pos.mdV[1];
-		const F64& z = pos.mdV[2];
-			
-		if (x > mMax.mdV[0] || x <= mMin.mdV[0] ||
-			y > mMax.mdV[1] || y <= mMin.mdV[1] ||
-			z > mMax.mdV[2] || z <= mMin.mdV[2])
+		S32 gt = pos.greaterThan4(mD[MAX]).getComparisonMask() & 0x7;
+		if (gt)
 		{
 			return false;
 		}
-		
+
+		S32 lt = pos.lessEqual4(mD[MIN]).getComparisonMask() & 0x7;
+		if (lt)
+		{
+			return false;
+		}
+				
 		return true;
 	}
 	
 	void updateMinMax()
 	{
-		for (U32 i = 0; i < 3; i++)
-		{
-			mMax.mdV[i] = mCenter.mdV[i] + mSize.mdV[i];
-			mMin.mdV[i] = mCenter.mdV[i] - mSize.mdV[i];
-		}
+		mD[MAX].setAdd(mD[CENTER], mD[SIZE]);
+		mD[MIN].setSub(mD[CENTER], mD[SIZE]);
 	}
 
 	inline oct_listener* getOctListener(U32 index) 
@@ -203,34 +188,34 @@ class LLOctreeNode : public LLTreeNode<T>
 		return contains(xform->getBinRadius());
 	}
 
-	bool contains(F64 radius)
+	bool contains(F32 radius)
 	{
 		if (mParent == NULL)
 		{	//root node contains nothing
 			return false;
 		}
 
-		F64 size = mSize.mdV[0];
-		F64 p_size = size * 2.0;
+		F32 size = mD[SIZE][0];
+		F32 p_size = size * 2.f;
 
-		return (radius <= 0.001 && size <= 0.001) ||
+		return (radius <= 0.001f && size <= 0.001f) ||
 				(radius <= p_size && radius > size);
 	}
 
-	static void pushCenter(LLVector3d &center, const LLVector3d &size, const T* data)
+	static void pushCenter(LLVector4a &center, const LLVector4a &size, const T* data)
 	{
-		const LLVector3d& pos = data->getPositionGroup();
-		for (U32 i = 0; i < 3; i++)
-		{
-			if (pos.mdV[i] > center.mdV[i])
-			{
-				center.mdV[i] += size.mdV[i];
-			}
-			else 
-			{
-				center.mdV[i] -= size.mdV[i];
-			}
-		}
+		const LLVector4a& pos = data->getPositionGroup();
+
+		LLVector4a gt = pos.greaterThan4(center);
+
+		LLVector4a up;
+		up.mQ = _mm_and_ps(size.mQ, gt.mQ);
+
+		LLVector4a down;
+		down.mQ = _mm_andnot_ps(gt.mQ, size.mQ);
+
+		center.add(up);
+		center.sub(down);
 	}
 
 	void accept(oct_traveler* visitor)				{ visitor->visit(this); }
@@ -249,21 +234,21 @@ class LLOctreeNode : public LLTreeNode<T>
 	void accept(tree_traveler* visitor) const		{ visitor->visit(this); }
 	void accept(oct_traveler* visitor) const		{ visitor->visit(this); }
 	
-	oct_node* getNodeAt(const LLVector3d& pos, const F64& rad)
+	oct_node* getNodeAt(const LLVector4a& pos, const F32& rad)
 	{ 
 		LLOctreeNode<T>* node = this;
 
 		if (node->isInside(pos, rad))
 		{		
 			//do a quick search by octant
-			U8 octant = node->getOctant(pos.mdV);
+			S32 octant = node->getOctant(pos);
 			BOOL keep_going = TRUE;
 
 			//traverse the tree until we find a node that has no node
 			//at the appropriate octant or is smaller than the object.  
 			//by definition, that node is the smallest node that contains 
 			// the data
-			while (keep_going && node->getSize().mdV[0] >= rad)
+			while (keep_going && node->getSize()[0] >= rad)
 			{	
 				keep_going = FALSE;
 				for (U32 i = 0; i < node->getChildCount() && !keep_going; i++)
@@ -271,7 +256,7 @@ class LLOctreeNode : public LLTreeNode<T>
 					if (node->getChild(i)->getOctant() == octant)
 					{
 						node = node->getChild(i);
-						octant = node->getOctant(pos.mdV);
+						octant = node->getOctant(pos);
 						keep_going = TRUE;
 					}
 				}
@@ -289,7 +274,7 @@ class LLOctreeNode : public LLTreeNode<T>
 	{
 		if (data == NULL)
 		{
-			//OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << llendl;
+			OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << llendl;
 			return false;
 		}
 		LLOctreeNode<T>* parent = getOctParent();
@@ -299,7 +284,7 @@ class LLOctreeNode : public LLTreeNode<T>
 		{
 			if (getElementCount() < LL_OCTREE_MAX_CAPACITY &&
 				(contains(data->getBinRadius()) ||
-				(data->getBinRadius() > getSize().mdV[0] &&
+				(data->getBinRadius() > getSize()[0] &&
 				parent && parent->getElementCount() >= LL_OCTREE_MAX_CAPACITY))) 
 			{ //it belongs here
 #if LL_OCTREE_PARANOIA_CHECK
@@ -330,16 +315,22 @@ class LLOctreeNode : public LLTreeNode<T>
 				}
 				
 				//it's here, but no kids are in the right place, make a new kid
-				LLVector3d center(getCenter());
-				LLVector3d size(getSize()*0.5);
+				LLVector4a center = getCenter();
+				LLVector4a size = getSize();
+				size.mul(0.5f);
 		        		
 				//push center in direction of data
 				LLOctreeNode<T>::pushCenter(center, size, data);
 
 				// handle case where floating point number gets too small
-				if( llabs(center.mdV[0] - getCenter().mdV[0]) < F_APPROXIMATELY_ZERO &&
-					llabs(center.mdV[1] - getCenter().mdV[1]) < F_APPROXIMATELY_ZERO &&
-					llabs(center.mdV[2] - getCenter().mdV[2]) < F_APPROXIMATELY_ZERO)
+				LLVector4a val;
+				val.setSub(center, getCenter());
+				val.setAbs(val);
+				LLVector4a app_zero;
+				app_zero.mQ = F_APPROXIMATELY_ZERO_4A;
+				S32 lt = val.lessThan4(app_zero).getComparisonMask() & 0x7;
+
+				if( lt == 0x7 )
 				{
 					mData.insert(data);
 					BaseType::insert(data);
@@ -357,7 +348,7 @@ class LLOctreeNode : public LLTreeNode<T>
 				//make sure no existing node matches this position
 				for (U32 i = 0; i < getChildCount(); i++)
 				{
-					if (mChild[i]->getCenter() == center)
+					if (mChild[i]->getCenter().equal3(center))
 					{
 						OCT_ERRS << "Octree detected duplicate child center and gave up." << llendl;
 						return false;
@@ -375,7 +366,7 @@ class LLOctreeNode : public LLTreeNode<T>
 		else 
 		{
 			//it's not in here, give it to the root
-			//OCT_ERRS << "Octree insertion failed, starting over from root!" << llendl;
+			OCT_ERRS << "Octree insertion failed, starting over from root!" << llendl;
 
 			oct_node* node = this;
 
@@ -482,13 +473,19 @@ class LLOctreeNode : public LLTreeNode<T>
 	void addChild(oct_node* child, BOOL silent = FALSE) 
 	{
 #if LL_OCTREE_PARANOIA_CHECK
+
+		if (child->getSize().equal3(getSize()))
+		{
+			OCT_ERRS << "Child size is same as parent size!" << llendl;
+		}
+
 		for (U32 i = 0; i < getChildCount(); i++)
 		{
-			if(mChild[i]->getSize() != child->getSize()) 
+			if(!mChild[i]->getSize().equal3(child->getSize())) 
 			{
 				OCT_ERRS <<"Invalid octree child size." << llendl;
 			}
-			if (mChild[i]->getCenter() == child->getCenter())
+			if (mChild[i]->getCenter().equal3(child->getCenter()))
 			{
 				OCT_ERRS <<"Duplicate octree child position." << llendl;
 			}
@@ -513,7 +510,7 @@ class LLOctreeNode : public LLTreeNode<T>
 		}
 	}
 
-	void removeChild(U8 index, BOOL destroy = FALSE)
+	void removeChild(S32 index, BOOL destroy = FALSE)
 	{
 		for (U32 i = 0; i < this->getListenerCount(); i++)
 		{
@@ -554,18 +551,26 @@ class LLOctreeNode : public LLTreeNode<T>
 			}
 		}
 
-		//OCT_ERRS << "Octree failed to delete requested child." << llendl;
+		OCT_ERRS << "Octree failed to delete requested child." << llendl;
 	}
 
 protected:	
+	typedef enum
+	{
+		CENTER = 0,
+		SIZE = 1,
+		MAX = 2,
+		MIN = 3
+	} eDName;
+
+	LLVector4a* mD;
+	
+	oct_node* mParent;
+	S32 mOctant;
+
 	child_list mChild;
 	element_list mData;
-	oct_node* mParent;
-	LLVector3d mCenter;
-	LLVector3d mSize;
-	LLVector3d mMax;
-	LLVector3d mMin;
-	U8 mOctant;
+		
 };
 
 //just like a regular node, except it might expand on insert and compress on balance
@@ -576,9 +581,9 @@ class LLOctreeRoot : public LLOctreeNode<T>
 	typedef LLOctreeNode<T>	BaseType;
 	typedef LLOctreeNode<T>		oct_node;
 
-	LLOctreeRoot(	LLVector3d center, 
-					LLVector3d size, 
-					BaseType* parent)
+	LLOctreeRoot(const LLVector4a& center, 
+				 const LLVector4a& size, 
+				 BaseType* parent)
 	:	BaseType(center, size, parent)
 	{
 	}
@@ -619,28 +624,33 @@ class LLOctreeRoot : public LLOctreeNode<T>
 	{
 		if (data == NULL) 
 		{
-			//OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE ROOT !!!" << llendl;
+			OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE ROOT !!!" << llendl;
 			return false;
 		}
 		
 		if (data->getBinRadius() > 4096.0)
 		{
-			//OCT_ERRS << "!!! ELEMENT EXCEEDS MAXIMUM SIZE IN OCTREE ROOT !!!" << llendl;
+			OCT_ERRS << "!!! ELEMENT EXCEEDS MAXIMUM SIZE IN OCTREE ROOT !!!" << llendl;
 			return false;
 		}
 		
-		const F64 MAX_MAG = 1024.0*1024.0;
+		LLVector4a MAX_MAG;
+		MAX_MAG.splat(1024.f*1024.f);
+
+		const LLVector4a& v = data->getPositionGroup();
+
+		LLVector4a val;
+		val.setSub(v, mD[CENTER]);
+		val.setAbs(val);
+		S32 lt = val.lessThan4(MAX_MAG).getComparisonMask() & 0x7;
 
-		const LLVector3d& v = data->getPositionGroup();
-		if (!(fabs(v.mdV[0]-this->mCenter.mdV[0]) < MAX_MAG &&
-		      fabs(v.mdV[1]-this->mCenter.mdV[1]) < MAX_MAG &&
-		      fabs(v.mdV[2]-this->mCenter.mdV[2]) < MAX_MAG))
+		if (lt != 0x7)
 		{
-			//OCT_ERRS << "!!! ELEMENT EXCEEDS RANGE OF SPATIAL PARTITION !!!" << llendl;
+			OCT_ERRS << "!!! ELEMENT EXCEEDS RANGE OF SPATIAL PARTITION !!!" << llendl;
 			return false;
 		}
 
-		if (this->getSize().mdV[0] > data->getBinRadius() && isInside(data->getPositionGroup()))
+		if (this->getSize()[0] > data->getBinRadius() && isInside(data->getPositionGroup()))
 		{
 			//we got it, just act like a branch
 			oct_node* node = getNodeAt(data);
@@ -656,31 +666,34 @@ class LLOctreeRoot : public LLOctreeNode<T>
 		else if (this->getChildCount() == 0)
 		{
 			//first object being added, just wrap it up
-			while (!(this->getSize().mdV[0] > data->getBinRadius() && isInside(data->getPositionGroup())))
+			while (!(this->getSize()[0] > data->getBinRadius() && isInside(data->getPositionGroup())))
 			{
-				LLVector3d center, size;
+				LLVector4a center, size;
 				center = this->getCenter();
 				size = this->getSize();
 				LLOctreeNode<T>::pushCenter(center, size, data);
 				this->setCenter(center);
-				this->setSize(size*2);
+				size.mul(2.f);
+				this->setSize(size);
 				this->updateMinMax();
 			}
 			LLOctreeNode<T>::insert(data);
 		}
 		else
 		{
-			while (!(this->getSize().mdV[0] > data->getBinRadius() && isInside(data->getPositionGroup())))
+			while (!(this->getSize()[0] > data->getBinRadius() && isInside(data->getPositionGroup())))
 			{
 				//the data is outside the root node, we need to grow
-				LLVector3d center(this->getCenter());
-				LLVector3d size(this->getSize());
+				LLVector4a center(this->getCenter());
+				LLVector4a size(this->getSize());
 
 				//expand this node
-				LLVector3d newcenter(center);
+				LLVector4a newcenter(center);
 				LLOctreeNode<T>::pushCenter(newcenter, size, data);
 				this->setCenter(newcenter);
-				this->setSize(size*2);
+				LLVector4a size2 = size;
+				size2.mul(2.f);
+				this->setSize(size2);
 				this->updateMinMax();
 
 				//copy our children to a new branch
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index c4172de651b..72833c019f3 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -295,7 +295,7 @@ BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, cons
 	}
 }
 
-class LLVolumeOctreeRebound : public LLOctreeTravelerDepthFirst<LLVolumeFace::Triangle>
+class LLVolumeOctreeRebound : public LLOctreeTravelerDepthFirst<LLVolumeTriangle>
 {
 public:
 	const LLVolumeFace* mFace;
@@ -305,7 +305,7 @@ class LLVolumeOctreeRebound : public LLOctreeTravelerDepthFirst<LLVolumeFace::Tr
 		mFace = face;
 	}
 
-	virtual void visit(const LLOctreeNode<LLVolumeFace::Triangle>* branch)
+	virtual void visit(const LLOctreeNode<LLVolumeTriangle>* branch)
 	{
 		LLVolumeOctreeListener* node = (LLVolumeOctreeListener*) branch->getListener(0);
 
@@ -314,12 +314,12 @@ class LLVolumeOctreeRebound : public LLOctreeTravelerDepthFirst<LLVolumeFace::Tr
 
 		if (branch->getElementCount() != 0)
 		{
-			const LLVolumeFace::Triangle* tri = *(branch->getData().begin());
+			const LLVolumeTriangle* tri = *(branch->getData().begin());
 						
 			min = *(tri->mV[0]);
 			max = *(tri->mV[0]);
 			
-			for (LLOctreeNode<LLVolumeFace::Triangle>::const_element_iter iter = 
+			for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = 
 				branch->getData().begin(); iter != branch->getData().end(); ++iter)
 			{
 				//stretch by triangles in node
@@ -4394,7 +4394,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& en
 		LLVector4a box_size;
 		box_size.setSub(face.mExtents[1], face.mExtents[0]);
 
-        if (LLLineSegmentBoxIntersect(start.getF32(), end.getF32(), box_center.getF32(), box_size.getF32()))
+        if (LLLineSegmentBoxIntersect(start, end, box_center, box_size))
 		{
 			if (bi_normal != NULL) // if the caller wants binormals, we may need to generate them
 			{
@@ -5418,12 +5418,17 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 
 void LLVolumeFace::createOctree()
 {
-	mOctree = new LLOctreeRoot<Triangle>(LLVector3d(0,0,0), LLVector3d(1,1,1), NULL);
+	LLVector4a center;
+	LLVector4a size;
+	center.splat(0.f);
+	size.splat(1.f);
+
+	mOctree = new LLOctreeRoot<LLVolumeTriangle>(center, size, NULL);
 	new LLVolumeOctreeListener(mOctree);
 
 	for (U32 i = 0; i < mNumIndices; i+= 3)
 	{
-		Triangle* tri = new Triangle();
+		LLPointer<LLVolumeTriangle> tri = new LLVolumeTriangle();
 				
 		const LLVector4a& v0 = mPositions[mIndices[i]];
 		const LLVector4a& v1 = mPositions[mIndices[i+1]];
@@ -5449,8 +5454,7 @@ void LLVolumeFace::createOctree()
 		center.setAdd(min, max);
 		center.mul(0.5f);
 
-
-		tri->mPositionGroup.setVec(center[0], center[1], center[2]);
+		*tri->mPositionGroup = center;
 
 		LLVector4a size;
 		size.setSub(max,min);
@@ -5464,15 +5468,6 @@ void LLVolumeFace::createOctree()
 	rebound.traverse(mOctree);
 }
 
-const LLVector3d& LLVolumeFace::Triangle::getPositionGroup() const
-{
-	return mPositionGroup;
-}
-
-const F64& LLVolumeFace::Triangle::getBinRadius() const
-{
-	return mRadius;
-}
 
 void LLVolumeFace::swapData(LLVolumeFace& rhs)
 {
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 0ae8aa19caa..c49d1c650d9 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -46,6 +46,7 @@ template <class T> class LLOctreeNode;
 class LLVector4a;
 class LLVolumeFace;
 class LLVolume;
+class LLVolumeTriangle;
 
 #include "lldarray.h"
 #include "lluuid.h"
@@ -918,20 +919,7 @@ class LLVolumeFace
 	// mWeights.size() should be empty or match mVertices.size()  
 	LLVector4a* mWeights;
 
-	class Triangle : public LLRefCount
-	{
-	public:
-		const LLVector4a* mV[3];
-		U16 mIndex[3];
-
-		LLVector3d mPositionGroup;
-		F64 mRadius;
-
-		virtual const LLVector3d& getPositionGroup() const;
-		virtual const F64& getBinRadius() const;
-	};
-
-	LLOctreeNode<Triangle>* mOctree;
+	LLOctreeNode<LLVolumeTriangle>* mOctree;
 
 private:
 	BOOL createUnCutCubeCap(LLVolume* volume, BOOL partial_build = FALSE);
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 47146a5ec4a..715309b64a2 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -79,6 +79,17 @@ class LLVBOPool : public LLGLNamePool
 class LLVertexBuffer : public LLRefCount
 {
 public:
+	LLVertexBuffer(const LLVertexBuffer& rhs)
+	{
+		*this = rhs;
+	}
+
+	const LLVertexBuffer& operator=(const LLVertexBuffer& rhs)
+	{
+		llerrs << "Illegal operation!" << llendl;
+		return *this;
+	}
+
 	static LLVBOPool sStreamVBOPool;
 	static LLVBOPool sDynamicVBOPool;
 	static LLVBOPool sStreamIBOPool;
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 45f9de8e8d8..c0cc294c02a 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -377,7 +377,14 @@ void LLLineEditor::setText(const LLStringExplicit &new_text)
 	setCursor(llmin((S32)mText.length(), getCursor()));
 
 	// Set current history line to end of history.
-	mCurrentHistoryLine = mLineHistory.end() - 1;
+	if (mLineHistory.empty())
+	{
+		mCurrentHistoryLine = mLineHistory.end();
+	}
+	else
+	{
+		mCurrentHistoryLine = mLineHistory.end() - 1;
+	}
 
 	mPrevText = mText;
 }
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 03eee12707b..04e433dcfd8 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -41,6 +41,7 @@
 #include "llcriticaldamp.h"
 #include "llface.h"
 #include "lllightconstants.h"
+#include "llmatrix4a.h"
 #include "llsky.h"
 #include "llsurfacepatch.h"
 #include "llviewercamera.h"
@@ -91,8 +92,12 @@ void LLDrawable::incrementVisible()
 	sCurVisible++;
 	sCurPixelAngle = (F32) gViewerWindow->getWindowHeightRaw()/LLViewerCamera::getInstance()->getView();
 }
+
 void LLDrawable::init()
 {
+	mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*3, 32);
+	mPositionGroup = mExtents + 2;
+
 	// mXform
 	mParent = NULL;
 	mRenderType = 0;
@@ -121,6 +126,11 @@ void LLDrawable::initClass()
 
 void LLDrawable::destroy()
 {
+	if (gDebugGL)
+	{
+		gPipeline.checkReferences(this);
+	}
+
 	if (isDead())
 	{
 		sNumZombieDrawables--;
@@ -139,6 +149,9 @@ void LLDrawable::destroy()
 	{
 		llinfos << "- Zombie drawables: " << sNumZombieDrawables << llendl;
 	}*/	
+
+	_mm_free(mExtents);
+	mExtents = mPositionGroup = NULL;
 }
 
 void LLDrawable::markDead()
@@ -714,12 +727,14 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 					LLFace* facep = getFace(i);
 					if (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA)
 					{
-						LLVector3 box = (facep->mExtents[1] - facep->mExtents[0]) * 0.25f;
+						LLVector4a box;
+						box.setSub(facep->mExtents[1], facep->mExtents[0]);
+						box.mul(0.25f);
 						LLVector3 v = (facep->mCenterLocal-camera.getOrigin());
 						const LLVector3& at = camera.getAtAxis();
 						for (U32 j = 0; j < 3; j++)
 						{
-							v.mV[j] -= box.mV[j] * at.mV[j];
+							v.mV[j] -= box[j] * at.mV[j];
 						}
 						facep->mDistance = v * camera.getAtAxis();
 					}
@@ -728,7 +743,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 		}
 		else
 		{
-			pos = LLVector3(getPositionGroup());
+			pos = LLVector3(getPositionGroup().getF32());
 		}
 
 		pos -= camera.getOrigin();	
@@ -777,7 +792,7 @@ BOOL LLDrawable::updateGeometry(BOOL priority)
 	return res;
 }
 
-void LLDrawable::shiftPos(const LLVector3 &shift_vector)
+void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 {
 	if (isDead())
 	{
@@ -809,9 +824,9 @@ void LLDrawable::shiftPos(const LLVector3 &shift_vector)
 		for (S32 i = 0; i < getNumFaces(); i++)
 		{
 			LLFace *facep = getFace(i);
-			facep->mCenterAgent += shift_vector;
-			facep->mExtents[0] += shift_vector;
-			facep->mExtents[1] += shift_vector;
+			facep->mCenterAgent += LLVector3(shift_vector.getF32());
+			facep->mExtents[0].add(shift_vector);
+			facep->mExtents[1].add(shift_vector);
 			
 			if (!volume && facep->hasGeometry())
 			{
@@ -820,9 +835,9 @@ void LLDrawable::shiftPos(const LLVector3 &shift_vector)
 			}
 		}
 		
-		mExtents[0] += shift_vector;
-		mExtents[1] += shift_vector;
-		mPositionGroup += LLVector3d(shift_vector);
+		mExtents[0].add(shift_vector);
+		mExtents[1].add(shift_vector);
+		mPositionGroup->add(shift_vector);
 	}
 	else if (mSpatialBridge)
 	{
@@ -830,9 +845,9 @@ void LLDrawable::shiftPos(const LLVector3 &shift_vector)
 	}
 	else if (isAvatar())
 	{
-		mExtents[0] += shift_vector;
-		mExtents[1] += shift_vector;
-		mPositionGroup += LLVector3d(shift_vector);
+		mExtents[0].add(shift_vector);
+		mExtents[1].add(shift_vector);
+		mPositionGroup->add(shift_vector);
 	}
 	
 	mVObjp->onShift(shift_vector);
@@ -844,21 +859,26 @@ const LLVector3& LLDrawable::getBounds(LLVector3& min, LLVector3& max) const
 	return mXform.getPositionW();
 }
 
-const LLVector3* LLDrawable::getSpatialExtents() const
+const LLVector4a* LLDrawable::getSpatialExtents() const
 {
 	return mExtents;
 }
 
-void LLDrawable::setSpatialExtents(LLVector3 min, LLVector3 max)
+void LLDrawable::setSpatialExtents(const LLVector3& min, const LLVector3& max)
+{ 
+	mExtents[0].load3(min.mV); 
+	mExtents[1].load3(max.mV);
+}
+
+void LLDrawable::setSpatialExtents(const LLVector4a& min, const LLVector4a& max)
 { 
-	LLVector3 size = max - min;
 	mExtents[0] = min; 
-	mExtents[1] = max; 
+	mExtents[1] = max;
 }
 
-void LLDrawable::setPositionGroup(const LLVector3d& pos)
+void LLDrawable::setPositionGroup(const LLVector4a& pos)
 {
-	mPositionGroup.setVec(pos);
+	*mPositionGroup = pos;
 }
 
 void LLDrawable::updateSpatialExtents()
@@ -872,7 +892,7 @@ void LLDrawable::updateSpatialExtents()
 	
 	if (mSpatialBridge.notNull())
 	{
-		mPositionGroup.setVec(0,0,0);
+		mPositionGroup->splat(0.f);
 	}
 }
 
@@ -1083,59 +1103,72 @@ void LLSpatialBridge::updateSpatialExtents()
 		root->rebound();
 	}
 	
-	LLXformMatrix* mat = mDrawable->getXform();
-	
-	LLVector3 offset = root->mBounds[0];
-	LLVector3 size = root->mBounds[1];
+	LLVector4a offset;
+	LLVector4a size = root->mBounds[1];
 		
-	LLVector3 center = LLVector3(0,0,0) * mat->getWorldMatrix();
-	LLQuaternion rotation = LLQuaternion(mat->getWorldMatrix());
+	//VECTORIZE THIS
+	LLMatrix4a mat;
+	mat.loadu(mDrawable->getXform()->getWorldMatrix());
+
+	LLVector4a t;
+	t.splat(0.f);
+
+	LLVector4a center;
+	mat.affineTransform(t, center);
 	
-	offset *= rotation;
-	center += offset;
+	mat.rotate(root->mBounds[0], offset);
+	center.add(offset);
 	
-	LLVector3 v[4];
+	LLVector4a v[4];
+
 	//get 4 corners of bounding box
-	v[0] = (size * rotation);
-	v[1] = (LLVector3(-size.mV[0], -size.mV[1], size.mV[2]) * rotation);
-	v[2] = (LLVector3(size.mV[0], -size.mV[1], -size.mV[2]) * rotation);
-	v[3] = (LLVector3(-size.mV[0], size.mV[1], -size.mV[2]) * rotation);
+	mat.rotate(size,v[0]);
 
-	LLVector3& newMin = mExtents[0];
-	LLVector3& newMax = mExtents[1];
+	LLVector4a scale;
+	
+	scale.set(-1.f, -1.f, 1.f);
+	scale.mul(size);
+	mat.rotate(scale, v[1]);
+	
+	scale.set(1.f, -1.f, -1.f);
+	scale.mul(size);
+	mat.rotate(scale, v[2]);
+	
+	scale.set(-1.f, 1.f, -1.f);
+	scale.mul(size);
+	mat.rotate(scale, v[3]);
+
+	
+	LLVector4a& newMin = mExtents[0];
+	LLVector4a& newMax = mExtents[1];
 	
 	newMin = newMax = center;
 	
 	for (U32 i = 0; i < 4; i++)
 	{
-		for (U32 j = 0; j < 3; j++)
-		{
-			F32 delta = fabsf(v[i].mV[j]);
-			F32 min = center.mV[j] - delta;
-			F32 max = center.mV[j] + delta;
-			
-			if (min < newMin.mV[j])
-			{
-				newMin.mV[j] = min;
-			}
-			
-			if (max > newMax.mV[j])
-			{
-				newMax.mV[j] = max;
-			}
-		}
-	}
+		LLVector4a delta;
+		delta.setAbs(v[i]);
+		LLVector4a min;
+		min.setSub(center, delta);
+		LLVector4a max;
+		max.setAdd(center, delta);
 
-	LLVector3 diagonal = newMax - newMin;
-	mRadius = diagonal.magVec() * 0.5f;
+		newMin.setMin(min);
+		newMax.setMax(max);
+	}
+	
+	LLVector4a diagonal;
+	diagonal.setSub(newMax, newMin);
+	mRadius = diagonal.length3() * 0.5f;
 	
-	mPositionGroup.setVec((newMin + newMax) * 0.5f);
+	mPositionGroup->setAdd(newMin,newMax);
+	mPositionGroup->mul(0.5f);
 	updateBinRadius();
 }
 
 void LLSpatialBridge::updateBinRadius()
 {
-	mBinRadius = llmin((F32) mOctree->getSize().mdV[0]*0.5f, 256.f);
+	mBinRadius = llmin( mOctree->getSize()[0]*0.5f, 256.f);
 }
 
 LLCamera LLSpatialBridge::transformCamera(LLCamera& camera)
@@ -1276,8 +1309,12 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
 	LLSpatialGroup* group = (LLSpatialGroup*) mOctree->getListener(0);
 	group->rebound();
 	
-	LLVector3 center = (mExtents[0] + mExtents[1]) * 0.5f;
-	LLVector3 size = (mExtents[1]-mExtents[0]) * 0.5f;
+	LLVector4a center;
+	center.setAdd(mExtents[0], mExtents[1]);
+	center.mul(0.5f);
+	LLVector4a size;
+	size.setSub(mExtents[1], mExtents[0]);
+	size.mul(0.5f);
 
 	if ((LLPipeline::sShadowRender && camera_in.AABBInFrustum(center, size)) ||
 		LLPipeline::sImpostorRender ||
@@ -1389,11 +1426,11 @@ BOOL LLSpatialBridge::updateMove()
 	return TRUE;
 }
 
-void LLSpatialBridge::shiftPos(const LLVector3& vec)
+void LLSpatialBridge::shiftPos(const LLVector4a& vec)
 {
-	mExtents[0] += vec;
-	mExtents[1] += vec;
-	mPositionGroup += LLVector3d(vec);
+	mExtents[0].add(vec);
+	mExtents[1].add(vec);
+	mPositionGroup->add(vec);
 }
 
 void LLSpatialBridge::cleanupReferences()
@@ -1511,7 +1548,7 @@ F32 LLHUDBridge::calcPixelArea(LLSpatialGroup* group, LLCamera& camera)
 }
 
 
-void LLHUDBridge::shiftPos(const LLVector3& vec)
+void LLHUDBridge::shiftPos(const LLVector4a& vec)
 {
 	//don't shift hud bridges on region crossing
 }
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index c3c6cbe12f7..811ff1801b8 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -41,6 +41,7 @@
 #include "v4math.h"
 #include "m4math.h"
 #include "v4coloru.h"
+#include "llvector4a.h"
 #include "llquaternion.h"
 #include "xform.h"
 #include "llmemtype.h"
@@ -66,6 +67,17 @@ const U32 SILHOUETTE_HIGHLIGHT = 0;
 class LLDrawable : public LLRefCount
 {
 public:
+	LLDrawable(const LLDrawable& rhs)
+	{
+		*this = rhs;
+	}
+
+	const LLDrawable& operator=(const LLDrawable& rhs)
+	{
+		llerrs << "Illegal operation!" << llendl;
+		return *this;
+	}
+
 	static void initClass();
 
 	LLDrawable()				{ init(); }
@@ -94,14 +106,14 @@ class LLDrawable : public LLRefCount
 	const LLVector3&	  getPosition() const			{ return mXform.getPosition(); }
 	const LLVector3&      getWorldPosition() const		{ return mXform.getPositionW(); }
 	const LLVector3		  getPositionAgent() const;
-	const LLVector3d&	  getPositionGroup() const		{ return mPositionGroup; }
+	const LLVector4a&	  getPositionGroup() const		{ return *mPositionGroup; }
 	const LLVector3&	  getScale() const				{ return mCurrentScale; }
 	void				  setScale(const LLVector3& scale) { mCurrentScale = scale; }
 	const LLQuaternion&   getWorldRotation() const		{ return mXform.getWorldRotation(); }
 	const LLQuaternion&   getRotation() const			{ return mXform.getRotation(); }
 	F32			          getIntensity() const			{ return llmin(mXform.getScale().mV[0], 4.f); }
 	S32					  getLOD() const				{ return mVObjp ? mVObjp->getLOD() : 1; }
-	F64					  getBinRadius() const			{ return mBinRadius; }
+	F32					  getBinRadius() const			{ return mBinRadius; }
 	void  getMinMax(LLVector3& min,LLVector3& max) const { mXform.getMinMax(min,max); }
 	LLXformMatrix*		getXform() { return &mXform; }
 
@@ -155,7 +167,7 @@ class LLDrawable : public LLRefCount
 		
 	void updateSpecialHoverCursor(BOOL enabled);
 
-	virtual void shiftPos(const LLVector3 &shift_vector);
+	virtual void shiftPos(const LLVector4a &shift_vector);
 
 	S32 getGeneration() const					{ return mGeneration; }
 
@@ -173,11 +185,12 @@ class LLDrawable : public LLRefCount
 	const LLVector3& getBounds(LLVector3& min, LLVector3& max) const;
 	virtual void updateSpatialExtents();
 	virtual void updateBinRadius();
-	const LLVector3* getSpatialExtents() const;
-	void setSpatialExtents(LLVector3 min, LLVector3 max);
-	void setPositionGroup(const LLVector3d& pos);
-	void setPositionGroup(const LLVector3& pos) { setPositionGroup(LLVector3d(pos)); }
+	const LLVector4a* getSpatialExtents() const;
+	void setSpatialExtents(const LLVector3& min, const LLVector3& max);
+	void setSpatialExtents(const LLVector4a& min, const LLVector4a& max);
 
+	void setPositionGroup(const LLVector4a& pos);
+	
 	void setRenderType(S32 type) 				{ mRenderType = type; }
 	BOOL isRenderType(S32 type) 				{ return mRenderType == type; }
 	S32  getRenderType()						{ return mRenderType; }
@@ -288,6 +301,9 @@ class LLDrawable : public LLRefCount
 private:
 	typedef std::vector<LLFace*> face_list_t;
 	
+	LLVector4a*		mExtents;
+	LLVector4a*		mPositionGroup;
+		
 	U32				mState;
 	S32				mRenderType;
 	LLPointer<LLViewerObject> mVObjp;
@@ -297,9 +313,7 @@ class LLDrawable : public LLRefCount
 	
 	mutable U32		mVisible;
 	F32				mRadius;
-	LLVector3		mExtents[2];
-	LLVector3d		mPositionGroup;
-	F64				mBinRadius;
+	F32				mBinRadius;
 	S32				mGeneration;
 	
 	LLVector3		mCurrentScale;
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 98a50ca4e7d..b8407a6f5b0 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -152,6 +152,8 @@ void cylindricalProjection(LLVector2 &tc, const LLVector4a& normal, const LLVect
 
 void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
 {
+	mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*2, 16);
+
 	mLastUpdateTime = gFrameTimeSeconds;
 	mLastMoveTime = 0.f;
 	mVSize = 0.f;
@@ -206,6 +208,12 @@ static LLFastTimer::DeclareTimer FTM_FACE_DEREF("Deref");
 void LLFace::destroy()
 {
 	LLFastTimer t(FTM_DESTROY_FACE);
+
+	if (gDebugGL)
+	{
+		gPipeline.checkReferences(this);
+	}
+
 	if(mTexture.notNull())
 	{
 		LLFastTimer t(FTM_DESTROY_TEXTURE);
@@ -260,6 +268,9 @@ void LLFace::destroy()
 		mDrawablep = NULL;
 		mVObjp = NULL;
 	}
+
+	_mm_free(mExtents);
+	mExtents = NULL;
 }
 
 
@@ -725,13 +736,20 @@ static void xform(LLVector2 &tex_coord, F32 cosAng, F32 sinAng, F32 offS, F32 of
 
 
 BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
-								const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, BOOL global_volume)
+								const LLMatrix4& mat_vert_in, const LLMatrix3& mat_normal_in, BOOL global_volume)
 {
 	LLMemType mt1(LLMemType::MTYPE_DRAWABLE);
 
 	//get bounding box
 	if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION))
 	{
+		//VECTORIZE THIS
+		LLMatrix4a mat_vert;
+		mat_vert.loadu(mat_vert_in);
+
+		LLMatrix4a mat_normal;
+		mat_normal.loadu(mat_normal_in);
+
 		//if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME))
 		//{ //vertex buffer no longer valid
 		//	mVertexBuffer = NULL;
@@ -739,82 +757,96 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
 		//}
 
 		//VECTORIZE THIS
-		LLVector3 min,max;
+		LLVector4a min,max;
 	
 		if (f >= volume.getNumVolumeFaces())
 		{
-			min = LLVector3(-1,-1,-1);
-			max = LLVector3(1,1,1);
-		}
-		else
-		{
-			const LLVolumeFace &face = volume.getVolumeFace(f);
-			min.set(face.mExtents[0].getF32());
-			max.set(face.mExtents[1].getF32());
+			llwarns << "Generating bounding box for invalid face index!" << llendl;
+			f = 0;
 		}
 
+		const LLVolumeFace &face = volume.getVolumeFace(f);
+		min = face.mExtents[0];
+		max = face.mExtents[1];
+		
+
 		//min, max are in volume space, convert to drawable render space
-		LLVector3 center = ((min + max) * 0.5f)*mat_vert;
-		LLVector3 size = ((max-min) * 0.5f);
+		LLVector4a center;
+		LLVector4a t;
+		t.setAdd(min, max);
+		t.mul(0.5f);
+		mat_vert.affineTransform(t, center);
+		LLVector4a size;
+		size.setSub(max, min);
+		size.mul(0.5f);
+
 		if (!global_volume)
 		{
-			size.scaleVec(mDrawablep->getVObj()->getScale());
+			//VECTORIZE THIS
+			LLVector4a scale;
+			scale.load3(mDrawablep->getVObj()->getScale().mV);
+			size.mul(scale);
 		}
 
-		LLMatrix3 mat = mat_normal;
-		LLVector3 x = mat.getFwdRow();
-		LLVector3 y = mat.getLeftRow();
-		LLVector3 z = mat.getUpRow();
-		x.normVec();
-		y.normVec();
-		z.normVec();
+		mat_normal.mMatrix[0].normalize3fast();
+		mat_normal.mMatrix[1].normalize3fast();
+		mat_normal.mMatrix[2].normalize3fast();
+		
+		LLVector4a v[4];
 
-		mat.setRows(x,y,z);
+		//get 4 corners of bounding box
+		mat_normal.rotate(size,v[0]);
 
-		LLQuaternion rotation = LLQuaternion(mat);
+		//VECTORIZE THIS
+		LLVector4a scale;
 		
-		LLVector3 v[4];
-		//get 4 corners of bounding box
-		v[0] = (size * rotation);
-		v[1] = (LLVector3(-size.mV[0], -size.mV[1], size.mV[2]) * rotation);
-		v[2] = (LLVector3(size.mV[0], -size.mV[1], -size.mV[2]) * rotation);
-		v[3] = (LLVector3(-size.mV[0], size.mV[1], -size.mV[2]) * rotation);
+		scale.set(-1.f, -1.f, 1.f);
+		scale.mul(size);
+		mat_normal.rotate(scale, v[1]);
+		
+		scale.set(1.f, -1.f, -1.f);
+		scale.mul(size);
+		mat_normal.rotate(scale, v[2]);
+		
+		scale.set(-1.f, 1.f, -1.f);
+		scale.mul(size);
+		mat_normal.rotate(scale, v[3]);
 
-		LLVector3& newMin = mExtents[0];
-		LLVector3& newMax = mExtents[1];
+		LLVector4a& newMin = mExtents[0];
+		LLVector4a& newMax = mExtents[1];
 		
 		newMin = newMax = center;
 		
 		for (U32 i = 0; i < 4; i++)
 		{
-			for (U32 j = 0; j < 3; j++)
-			{
-				F32 delta = fabsf(v[i].mV[j]);
-				F32 min = center.mV[j] - delta;
-				F32 max = center.mV[j] + delta;
-				
-				if (min < newMin.mV[j])
-				{
-					newMin.mV[j] = min;
-				}
-				
-				if (max > newMax.mV[j])
-				{
-					newMax.mV[j] = max;
-				}
-			}
+			LLVector4a delta;
+			delta.setAbs(v[i]);
+			LLVector4a min;
+			min.setSub(center, delta);
+			LLVector4a max;
+			max.setAdd(center, delta);
+
+			newMin.setMin(min);
+			newMax.setMax(max);
 		}
 
 		if (!mDrawablep->isActive())
 		{
-			LLVector3 offset = mDrawablep->getRegion()->getOriginAgent();
-			newMin += offset;
-			newMax += offset;
+			LLVector4a offset;
+			offset.load3(mDrawablep->getRegion()->getOriginAgent().mV);
+			newMin.add(offset);
+			newMax.add(offset);
 		}
 
-		mCenterLocal = (newMin+newMax)*0.5f;
-		LLVector3 tmp = (newMin - newMax) ;
-		mBoundingSphereRadius = tmp.length() * 0.5f ;
+		t.setAdd(newMin, newMax);
+		t.mul(0.5f);
+
+		//VECTORIZE THIS
+		mCenterLocal.set(t.getF32());
+		
+		t.setSub(newMax,newMin);
+		t.mul(0.5f);
+		mBoundingSphereRadius = t.length3();
 
 		updateCenterAgent();
 	}
@@ -1647,20 +1679,31 @@ F32 LLFace::getTextureVirtualSize()
 
 BOOL LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius)
 {
+	//VECTORIZE THIS
 	//get area of circle around face
-	LLVector3 center = getPositionAgent();
-	LLVector3 size = (mExtents[1] - mExtents[0]) * 0.5f;	
+	LLVector4a center;
+	center.load3(getPositionAgent().mV);
+	LLVector4a size;
+	size.setSub(mExtents[1], mExtents[0]);
+	size.mul(0.5f);
+
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
 
-	F32 size_squared = size.lengthSquared() ;
-	LLVector3 lookAt = center - camera->getOrigin();
-	F32 dist = lookAt.normVec() ;	
+	F32 size_squared = size.dot3(size);
+	LLVector4a lookAt;
+	LLVector4a t;
+	t.load3(camera->getOrigin().mV);
+	lookAt.setSub(center, t);
+	F32 dist = lookAt.length3();
+	lookAt.normalize3fast() ;	
 
 	//get area of circle around node
 	F32 app_angle = atanf(fsqrtf(size_squared) / dist);
 	radius = app_angle*LLDrawable::sCurPixelAngle;
 	mPixelArea = radius*radius * 3.14159f;
-	cos_angle_to_view_dir = lookAt * camera->getXAxis() ;
+	LLVector4a x_axis;
+	x_axis.load3(camera->getXAxis().mV);
+	cos_angle_to_view_dir = lookAt.dot3(x_axis);
 
 	//if has media, check if the face is out of the view frustum.	
 	if(hasMedia())
@@ -1676,7 +1719,10 @@ BOOL LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius)
 		}
 		else
 		{		
-			if(dist * dist * (lookAt - camera->getXAxis()).lengthSquared() < size_squared)
+			LLVector4a d;
+			d.setSub(lookAt, x_axis);
+
+			if(dist * dist * d.dot3(d) < size_squared)
 			{
 				cos_angle_to_view_dir = 1.0f ;
 			}
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 48909d7895e..0cd472a2fd8 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -65,6 +65,17 @@ class LLFace
 {
 public:
 
+	LLFace(const LLFace& rhs)
+	{
+		*this = rhs;
+	}
+
+	const LLFace& operator=(const LLFace& rhs)
+	{
+		llerrs << "Illegal operation!" << llendl;
+		return *this;
+	}
+
 	enum EMasks
 	{
 		LIGHT			= 0x0001,
@@ -221,7 +232,9 @@ class LLFace
 	
 	LLVector3		mCenterLocal;
 	LLVector3		mCenterAgent;
-	LLVector3		mExtents[2];
+	
+	LLVector4a*		mExtents;
+	
 	LLVector2		mTexExtents[2];
 	F32				mDistance;
 	LLPointer<LLVertexBuffer> mVertexBuffer;
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 561965d0214..8be4e347488 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -97,11 +97,13 @@ void LLVolumeImplFlexible::onParameterChanged(U16 param_type, LLNetworkData *dat
 	}
 }
 
-void LLVolumeImplFlexible::onShift(const LLVector3 &shift_vector)
+void LLVolumeImplFlexible::onShift(const LLVector4a &shift_vector)
 {	
+	//VECTORIZE THIS
+	LLVector3 shift(shift_vector.getF32());
 	for (int section = 0; section < (1<<FLEXIBLE_OBJECT_MAX_SECTIONS)+1; ++section)
 	{
-		mSection[section].mPosition += shift_vector;	
+		mSection[section].mPosition += shift;	
 	}
 }
 
diff --git a/indra/newview/llflexibleobject.h b/indra/newview/llflexibleobject.h
index 811ae24df2a..bdfbded82de 100644
--- a/indra/newview/llflexibleobject.h
+++ b/indra/newview/llflexibleobject.h
@@ -90,7 +90,7 @@ class LLVolumeImplFlexible : public LLVolumeInterface
 		void onSetVolume(const LLVolumeParams &volume_params, const S32 detail);
 		void onSetScale(const LLVector3 &scale, BOOL damped);
 		void onParameterChanged(U16 param_type, LLNetworkData *data, BOOL in_use, bool local_origin);
-		void onShift(const LLVector3 &shift_vector);
+		void onShift(const LLVector4a &shift_vector);
 		bool isVolumeUnique() const { return true; }
 		bool isVolumeGlobal() const { return true; }
 		bool isActive() const { return true; }
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index e66be1023d1..d6cff719919 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1100,8 +1100,8 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
 		mGridRotation = first_grid_object->getRenderRotation();
 		LLVector3 first_grid_obj_pos = first_grid_object->getRenderPosition();
 
-		LLVector3 min_extents(F32_MAX, F32_MAX, F32_MAX);
-		LLVector3 max_extents(-F32_MAX, -F32_MAX, -F32_MAX);
+		LLVector4a min_extents(F32_MAX);
+		LLVector4a max_extents(-F32_MAX);
 		BOOL grid_changed = FALSE;
 		for (LLObjectSelection::iterator iter = mGridObjects.begin();
 			 iter != mGridObjects.end(); ++iter)
@@ -1110,7 +1110,7 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
 			LLDrawable* drawable = object->mDrawable;
 			if (drawable)
 			{
-				const LLVector3* ext = drawable->getSpatialExtents();
+				const LLVector4a* ext = drawable->getSpatialExtents();
 				update_min_max(min_extents, max_extents, ext[0]);
 				update_min_max(min_extents, max_extents, ext[1]);
 				grid_changed = TRUE;
@@ -1118,13 +1118,19 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
 		}
 		if (grid_changed)
 		{
-			mGridOrigin = lerp(min_extents, max_extents, 0.5f);
+			LLVector4a center, size;
+			center.setAdd(min_extents, max_extents);
+			center.mul(0.5f);
+			size.setSub(max_extents, min_extents);
+			size.mul(0.5f);
+
+			mGridOrigin.set(center.getF32());
 			LLDrawable* drawable = first_grid_object->mDrawable;
 			if (drawable && drawable->isActive())
 			{
 				mGridOrigin = mGridOrigin * first_grid_object->getRenderMatrix();
 			}
-			mGridScale = (max_extents - min_extents) * 0.5f;
+			mGridScale.set(size.getF32());
 		}
 	}
 	else // GRID_MODE_WORLD or just plain default
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 355173772b7..3cf01383032 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -102,23 +102,6 @@ void sg_assert(BOOL expr)
 #endif
 }
 
-#if LL_DEBUG
-void validate_drawable(LLDrawable* drawablep)
-{
-	F64 rad = drawablep->getBinRadius();
-	const LLVector3* ext = drawablep->getSpatialExtents();
-
-	if (rad < 0 || rad > 4096 ||
-		(ext[1]-ext[0]).magVec() > 4096)
-	{
-		llwarns << "Invalid drawable found in octree." << llendl;
-	}
-}
-#else
-#define validate_drawable(x)
-#endif
-
-
 S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad)
 {
 	return AABBSphereIntersectR2(min, max, origin, rad*rad);
@@ -158,6 +141,55 @@ S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVe
 }
 
 
+S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad)
+{
+	return AABBSphereIntersectR2(min, max, origin, rad*rad);
+}
+
+S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &r)
+{
+	F32 d = 0.f;
+	F32 t;
+	
+	LLVector4a origina;
+	origina.load3(origin.mV);
+
+	LLVector4a v;
+	v.setSub(min, origina);
+	
+	if (v.dot3(v) < r)
+	{
+		v.setSub(max, origina);
+		if (v.dot3(v) < r)
+		{
+			return 2;
+		}
+	}
+
+
+	for (U32 i = 0; i < 3; i++)
+	{
+		if (origin.mV[i] < min[i])
+		{
+			t = min[i] - origin.mV[i];
+			d += t*t;
+		}
+		else if (origin.mV[i] > max[i])
+		{
+			t = origin.mV[i] - max[i];
+			d += t*t;
+		}
+
+		if (d > r)
+		{
+			return 0;
+		}
+	}
+
+	return 1;
+}
+
+
 typedef enum
 {
 	b000 = 0x00,
@@ -193,24 +225,13 @@ static U8 sOcclusionIndices[] =
 		b000, b110, b100, b101, b001, b011, b010, b110,
 };
 
-U8* get_box_fan_indices(LLCamera* camera, const LLVector3& center)
+U8* get_box_fan_indices(LLCamera* camera, const LLVector4a& center)
 {
-	LLVector3 d = center - camera->getOrigin();
-
-	U8 cypher = 0;
-	if (d.mV[0] > 0)
-	{
-		cypher |= b100;
-	}
-	if (d.mV[1] > 0)
-	{
-		cypher |= b010;
-	}
-	if (d.mV[2] > 0)
-	{
-		cypher |= b001;
-	}
+	LLVector4a origin;
+	origin.load3(camera->getOrigin().mV);
 
+	S32 cypher = center.greaterThan4(origin).getComparisonMask() & 0x7;
+	
 	return sOcclusionIndices+cypher*8;
 }
 						
@@ -218,33 +239,49 @@ void LLSpatialGroup::buildOcclusion()
 {
 	if (!mOcclusionVerts)
 	{
-		mOcclusionVerts = new F32[8*3];
+		mOcclusionVerts = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*8, 16);
 	}
 
-	LLVector3 r = mBounds[1] + LLVector3(SG_OCCLUSION_FUDGE, SG_OCCLUSION_FUDGE, SG_OCCLUSION_FUDGE);
+	LLVector4a fudge;
+	fudge.splat(SG_OCCLUSION_FUDGE);
 
-	for (U32 k = 0; k < 3; k++)
-	{
-		r.mV[k] = llmin(mBounds[1].mV[k]+0.25f, r.mV[k]);
-	}
+	LLVector4a r;
+	r.setAdd(mBounds[1], fudge);
 
-	F32* v = mOcclusionVerts;
-	F32* c = mBounds[0].mV;
-	F32* s = r.mV;
+	LLVector4a r2;
+	r2.splat(0.25f);
+	r2.add(mBounds[1]);
+
+	r.setMin(r2);
+
+	LLVector4a* v = mOcclusionVerts;
+	const LLVector4a& c = mBounds[0];
+	const LLVector4a& s = r;
 	
+	static const LLVector4a octant[] =
+	{
+		LLVector4a(-1.f, -1.f, -1.f),
+		LLVector4a(-1.f, -1.f, 1.f),
+		LLVector4a(-1.f, 1.f, -1.f),
+		LLVector4a(-1.f, 1.f, 1.f),
+
+		LLVector4a(1.f, -1.f, -1.f),
+		LLVector4a(1.f, -1.f, 1.f),
+		LLVector4a(1.f, 1.f, -1.f),
+		LLVector4a(1.f, 1.f, 1.f),
+	};
+
 	//vertex positions are encoded so the 3 bits of their vertex index 
 	//correspond to their axis facing, with bit position 3,2,1 matching
 	//axis facing x,y,z, bit set meaning positive facing, bit clear 
 	//meaning negative facing
-	v[0] = c[0]-s[0]; v[1]  = c[1]-s[1]; v[2]  = c[2]-s[2];  // 0 - 0000 
-	v[3] = c[0]-s[0]; v[4]  = c[1]-s[1]; v[5]  = c[2]+s[2];  // 1 - 0001
-	v[6] = c[0]-s[0]; v[7]  = c[1]+s[1]; v[8]  = c[2]-s[2];  // 2 - 0010
-	v[9] = c[0]-s[0]; v[10] = c[1]+s[1]; v[11] = c[2]+s[2];  // 3 - 0011
-																					   
-	v[12] = c[0]+s[0]; v[13] = c[1]-s[1]; v[14] = c[2]-s[2]; // 4 - 0100
-	v[15] = c[0]+s[0]; v[16] = c[1]-s[1]; v[17] = c[2]+s[2]; // 5 - 0101
-	v[18] = c[0]+s[0]; v[19] = c[1]+s[1]; v[20] = c[2]-s[2]; // 6 - 0110
-	v[21] = c[0]+s[0]; v[22] = c[1]+s[1]; v[23] = c[2]+s[2]; // 7 - 0111
+	
+	for (S32 i = 0; i < 8; ++i)
+	{
+		v[i] = s;
+		v[i].mul(octant[i]);
+		v[i].add(c);
+	}
 
 	clearState(LLSpatialGroup::OCCLUSION_DIRTY);
 }
@@ -288,6 +325,11 @@ LLSpatialGroup::~LLSpatialGroup()
 		llerrs << "Illegal deletion of LLSpatialGroup!" << llendl;
 	}*/
 
+	if (gDebugGL)
+	{
+		gPipeline.checkReferences(this);
+	}
+
 	if (isState(DEAD))
 	{
 		sZombieGroups--;
@@ -300,11 +342,13 @@ LLSpatialGroup::~LLSpatialGroup()
 		sQueryPool.release(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
 	}
 
-	delete [] mOcclusionVerts;
+	_mm_free(mOcclusionVerts);
 
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	clearDrawMap();
 	clearAtlasList() ;
+
+	_mm_free(mBounds);
 }
 
 BOOL LLSpatialGroup::hasAtlas(LLTextureAtlas* atlasp)
@@ -456,8 +500,10 @@ void LLSpatialGroup::validate()
 	sg_assert(!isState(DIRTY));
 	sg_assert(!isDead());
 
-	LLVector3 myMin = mBounds[0] - mBounds[1];
-	LLVector3 myMax = mBounds[0] + mBounds[1];
+	LLVector4a myMin;
+	myMin.setSub(mBounds[0], mBounds[1]);
+	LLVector4a myMax;
+	myMax.setAdd(mBounds[0], mBounds[1]);
 
 	validateDrawMap();
 
@@ -489,16 +535,18 @@ void LLSpatialGroup::validate()
 		group->validate();
 		
 		//ensure all children are enclosed in this node
-		LLVector3 center = group->mBounds[0];
-		LLVector3 size = group->mBounds[1];
+		LLVector4a center = group->mBounds[0];
+		LLVector4a size = group->mBounds[1];
 		
-		LLVector3 min = center - size;
-		LLVector3 max = center + size;
+		LLVector4a min;
+		min.setSub(center, size);
+		LLVector4a max;
+		max.setAdd(center, size);
 		
 		for (U32 j = 0; j < 3; j++)
 		{
-			sg_assert(min.mV[j] >= myMin.mV[j]-0.02f);
-			sg_assert(max.mV[j] <= myMax.mV[j]+0.02f);
+			sg_assert(min[j] >= myMin[j]-0.02f);
+			sg_assert(max[j] <= myMax[j]+0.02f);
 		}
 	}
 
@@ -508,8 +556,8 @@ void LLSpatialGroup::validate()
 void LLSpatialGroup::checkStates()
 {
 #if LL_OCTREE_PARANOIA_CHECK
-	LLOctreeStateCheck checker;
-	checker.traverse(mOctreeNode);
+	//LLOctreeStateCheck checker;
+	//checker.traverse(mOctreeNode);
 #endif
 }
 
@@ -534,19 +582,17 @@ BOOL LLSpatialGroup::updateInGroup(LLDrawable *drawablep, BOOL immediate)
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 		
 	drawablep->updateSpatialExtents();
-	validate_drawable(drawablep);
 
 	OctreeNode* parent = mOctreeNode->getOctParent();
 	
 	if (mOctreeNode->isInside(drawablep->getPositionGroup()) && 
 		(mOctreeNode->contains(drawablep) ||
-		 (drawablep->getBinRadius() > mOctreeNode->getSize().mdV[0] &&
+		 (drawablep->getBinRadius() > mOctreeNode->getSize()[0] &&
 				parent && parent->getElementCount() >= LL_OCTREE_MAX_CAPACITY)))
 	{
 		unbound();
 		setState(OBJECT_DIRTY);
 		//setState(GEOM_DIRTY);
-		validate_drawable(drawablep);
 		return TRUE;
 	}
 		
@@ -564,7 +610,6 @@ BOOL LLSpatialGroup::addObject(LLDrawable *drawablep, BOOL add_all, BOOL from_oc
 	else
 	{
 		drawablep->setSpatialGroup(this);
-		validate_drawable(drawablep);
 		setState(OBJECT_DIRTY | GEOM_DIRTY);
 		setOcclusionState(LLSpatialGroup::DISCARD_QUERY, LLSpatialGroup::STATE_MODE_ALL_CAMERAS);
 		gPipeline.markRebuild(this, TRUE);
@@ -665,7 +710,7 @@ void LLSpatialPartition::rebuildMesh(LLSpatialGroup* group)
 
 }
 
-BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector3& minOut, LLVector3& maxOut)
+BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut)
 {	
 	const OctreeNode* node = mOctreeNode;
 
@@ -678,8 +723,8 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector3& minOut, LLVector3& maxO
 		return FALSE;
 	}
 
-	LLVector3& newMin = mObjectExtents[0];
-	LLVector3& newMax = mObjectExtents[1];
+	LLVector4a& newMin = mObjectExtents[0];
+	LLVector4a& newMax = mObjectExtents[1];
 	
 	if (isState(OBJECT_DIRTY))
 	{ //calculate new bounding box
@@ -688,10 +733,10 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector3& minOut, LLVector3& maxO
 		//initialize bounding box to first element
 		OctreeNode::const_element_iter i = node->getData().begin();
 		LLDrawable* drawablep = *i;
-		const LLVector3* minMax = drawablep->getSpatialExtents();
+		const LLVector4a* minMax = drawablep->getSpatialExtents();
 
-		newMin.setVec(minMax[0]);
-		newMax.setVec(minMax[1]);
+		newMin = minMax[0];
+		newMax = minMax[1];
 
 		for (++i; i != node->getData().end(); ++i)
 		{
@@ -715,8 +760,10 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector3& minOut, LLVector3& maxO
 			}*/
 		}
 		
-		mObjectBounds[0] = (newMin + newMax) * 0.5f;
-		mObjectBounds[1] = (newMax - newMin) * 0.5f;
+		mObjectBounds[0].setAdd(newMin, newMax);
+		mObjectBounds[0].mul(0.5f);
+		mObjectBounds[1].setSub(newMax, newMin);
+		mObjectBounds[1].mul(0.5f);
 	}
 	
 	if (empty)
@@ -726,17 +773,8 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector3& minOut, LLVector3& maxO
 	}
 	else
 	{
-		for (U32 i = 0; i < 3; i++)
-		{
-			if (newMin.mV[i] < minOut.mV[i])
-			{
-				minOut.mV[i] = newMin.mV[i];
-			}
-			if (newMax.mV[i] > maxOut.mV[i])
-			{
-				maxOut.mV[i] = newMax.mV[i];
-			}
-		}
+		minOut.setMin(newMin);
+		maxOut.setMax(newMax);
 	}
 		
 	return TRUE;
@@ -827,18 +865,19 @@ BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree)
 	return TRUE;
 }
 
-void LLSpatialGroup::shift(const LLVector3 &offset)
+void LLSpatialGroup::shift(const LLVector4a &offset)
 {
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
-	LLVector3d offsetd(offset);
-	mOctreeNode->setCenter(mOctreeNode->getCenter()+offsetd);
+	LLVector4a t = mOctreeNode->getCenter();
+	t.add(offset);	
+	mOctreeNode->setCenter(t);
 	mOctreeNode->updateMinMax();
-	mBounds[0] += offset;
-	mExtents[0] += offset;
-	mExtents[1] += offset;
-	mObjectBounds[0] += offset;
-	mObjectExtents[0] += offset;
-	mObjectExtents[1] += offset;
+	mBounds[0].add(offset);
+	mExtents[0].add(offset);
+	mExtents[1].add(offset);
+	mObjectBounds[0].add(offset);
+	mObjectExtents[0].add(offset);
+	mObjectExtents[1].add(offset);
 
 	//if (!mSpatialPartition->mRenderByGroup)
 	{
@@ -850,10 +889,7 @@ void LLSpatialGroup::shift(const LLVector3 &offset)
 	{
 		for (U32 i = 0; i < 8; i++)
 		{
-			F32* v = mOcclusionVerts+i*3;
-			v[0] += offset.mV[0];
-			v[1] += offset.mV[1];
-			v[2] += offset.mV[2];
+			mOcclusionVerts[i].add(offset);
 		}
 	}
 }
@@ -1119,8 +1155,6 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
 	mDepth(0.f),
 	mLastUpdateDistance(-1.f), 
 	mLastUpdateTime(gFrameTimeSeconds),
-	mViewAngle(0.f),
-	mLastUpdateViewAngle(-1.f),
 	mAtlasList(4),
 	mCurUpdatingTime(0),
 	mCurUpdatingSlotp(NULL),
@@ -1129,13 +1163,25 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
 	sNodeCount++;
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 
+	mBounds = (LLVector4a*) _mm_malloc(sizeof(LLVector4a) * V4_COUNT, 16);
+	mExtents = mBounds + EXTENTS;
+	mObjectBounds = mBounds + OBJECT_BOUNDS;
+	mObjectExtents = mBounds + OBJECT_EXTENTS;
+	mViewAngle = mBounds+VIEW_ANGLE;
+	mLastUpdateViewAngle = mBounds+LAST_VIEW_ANGLE;
+
+	mViewAngle->splat(0.f);
+	mLastUpdateViewAngle->splat(-1.f);
+	mExtents[0] = mExtents[1] = mObjectBounds[0] = mObjectBounds[0] = mObjectBounds[1] = 
+		mObjectExtents[0] = mObjectExtents[1] = *mViewAngle;
+
 	sg_assert(mOctreeNode->getListenerCount() == 0);
 	mOctreeNode->addListener(this);
 	setState(SG_INITIAL_STATE_MASK);
 	gPipeline.markRebuild(this, TRUE);
 
-	mBounds[0] = LLVector3(node->getCenter());
-	mBounds[1] = LLVector3(node->getSize());
+	mBounds[0] = node->getCenter();
+	mBounds[1] = node->getSize();
 
 	part->mLODSeed = (part->mLODSeed+1)%part->mLODPeriod;
 	mLODHash = part->mLODSeed;
@@ -1172,8 +1218,8 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 #endif
 	if (!getData().empty())
 	{
-		mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].magVec() :
-						(F32) mOctreeNode->getSize().magVec();
+		mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].length3() :
+						(F32) mOctreeNode->getSize().length3();
 		mDistance = mSpatialPartition->calcDistance(this, camera);
 		mPixelArea = mSpatialPartition->calcPixelArea(this, camera);
 	}
@@ -1181,27 +1227,34 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 
 F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera)
 {
-	LLVector3 eye = group->mObjectBounds[0] - camera.getOrigin();
+	LLVector4a eye;
+	LLVector4a origin;
+	origin.load3(camera.getOrigin().mV);
+
+	eye.setSub(group->mObjectBounds[0], origin);
 
 	F32 dist = 0.f;
 
 	if (group->mDrawMap.find(LLRenderPass::PASS_ALPHA) != group->mDrawMap.end())
 	{
-		LLVector3 v = eye;
-		dist = eye.normVec();
+		LLVector4a v = eye;
+
+		dist = eye.length3();
+		eye.normalize3fast();
 
 		if (!group->isState(LLSpatialGroup::ALPHA_DIRTY))
 		{
 			if (!group->mSpatialPartition->isBridge())
 			{
-				LLVector3 view_angle = LLVector3(eye * LLVector3(1,0,0),
-												 eye * LLVector3(0,1,0),
-												 eye * LLVector3(0,0,1));
+				LLVector4a view_angle = eye;
 
-				if ((view_angle-group->mLastUpdateViewAngle).magVec() > 0.64f)
+				LLVector4a diff;
+				diff.setSub(view_angle, *group->mLastUpdateViewAngle);
+
+				if (diff.length3() > 0.64f)
 				{
-					group->mViewAngle = view_angle;
-					group->mLastUpdateViewAngle = view_angle;
+					*group->mViewAngle = view_angle;
+					*group->mLastUpdateViewAngle = view_angle;
 					//for occasional alpha sorting within the group
 					//NOTE: If there is a trivial way to detect that alpha sorting here would not change the render order,
 					//not setting this node to dirty would be a very good thing
@@ -1215,17 +1268,20 @@ F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera)
 
 		LLVector3 at = camera.getAtAxis();
 
-		//front of bounding box
-		for (U32 i = 0; i < 3; i++)
-		{
-			v.mV[i] -= group->mObjectBounds[1].mV[i]*0.25f * at.mV[i];
-		}
+		LLVector4a ata;
+		ata.load3(at.mV);
 
-		group->mDepth = v * at;
+		LLVector4a t = ata;
+		//front of bounding box
+		t.mul(0.25f);
+		t.mul(group->mObjectBounds[1]);
+		v.sub(t);
+		
+		group->mDepth = v.dot3(ata);
 	}
 	else
 	{
-		dist = eye.magVec();
+		dist = eye.length3();
 	}
 
 	if (dist < 16.f)
@@ -1378,7 +1434,7 @@ void LLSpatialGroup::destroyGL()
 		}
 	}
 
-	delete [] mOcclusionVerts;
+	_mm_free(mOcclusionVerts);
 	mOcclusionVerts = NULL;
 
 	for (LLSpatialGroup::element_iter i = getData().begin(); i != getData().end(); ++i)
@@ -1421,8 +1477,8 @@ BOOL LLSpatialGroup::rebound()
 	}
 	else
 	{
-		LLVector3& newMin = mExtents[0];
-		LLVector3& newMax = mExtents[1];
+		LLVector4a& newMin = mExtents[0];
+		LLVector4a& newMax = mExtents[1];
 		LLSpatialGroup* group = (LLSpatialGroup*) mOctreeNode->getChild(0)->getListener(0);
 		group->clearState(SKIP_FRUSTUM_CHECK);
 		group->rebound();
@@ -1436,26 +1492,19 @@ BOOL LLSpatialGroup::rebound()
 			group = (LLSpatialGroup*) mOctreeNode->getChild(i)->getListener(0);
 			group->clearState(SKIP_FRUSTUM_CHECK);
 			group->rebound();
-			const LLVector3& max = group->mExtents[1];
-			const LLVector3& min = group->mExtents[0];
+			const LLVector4a& max = group->mExtents[1];
+			const LLVector4a& min = group->mExtents[0];
 
-			for (U32 j = 0; j < 3; j++)
-			{
-				if (max.mV[j] > newMax.mV[j])
-				{
-					newMax.mV[j] = max.mV[j];
-				}
-				if (min.mV[j] < newMin.mV[j])
-				{
-					newMin.mV[j] = min.mV[j];
-				}
-			}
+			newMax.setMax(max);
+			newMin.setMin(min);
 		}
 
 		boundObjects(FALSE, newMin, newMax);
 		
-		mBounds[0] = (newMin + newMax)*0.5f;
-		mBounds[1] = (newMax - newMin)*0.5f;
+		mBounds[0].setAdd(newMin, newMax);
+		mBounds[0].mul(0.5f);
+		mBounds[1].setSub(newMax, newMin);
+		mBounds[1].mul(0.5f);
 	}
 	
 	setState(OCCLUSION_DIRTY);
@@ -1540,7 +1589,7 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera)
 				}
 
 				glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mOcclusionQuery[LLViewerCamera::sCurCameraID]);					
-				glVertexPointer(3, GL_FLOAT, 0, mOcclusionVerts);
+				glVertexPointer(3, GL_FLOAT, 16, mOcclusionVerts);
 				if (camera->getOrigin().isExactlyZero())
 				{ //origin is invalid, draw entire box
 					glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8,
@@ -1581,8 +1630,11 @@ LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32
 
 	LLGLNamePool::registerPool(&sQueryPool);
 
-	mOctree = new LLSpatialGroup::OctreeRoot(LLVector3d(0,0,0), 
-											LLVector3d(1,1,1), 
+	LLVector4a center, size;
+	center.splat(0.f);
+	size.splat(1.f);
+
+	mOctree = new LLSpatialGroup::OctreeRoot(center,size,
 											NULL);
 	new LLSpatialGroup(mOctree, this);
 }
@@ -1602,7 +1654,6 @@ LLSpatialGroup *LLSpatialPartition::put(LLDrawable *drawablep, BOOL was_visible)
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 		
 	drawablep->updateSpatialExtents();
-	validate_drawable(drawablep);
 
 	//keep drawable from being garbage collected
 	LLPointer<LLDrawable> ptr = drawablep;
@@ -1686,16 +1737,16 @@ void LLSpatialPartition::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL
 class LLSpatialShift : public LLSpatialGroup::OctreeTraveler
 {
 public:
-	LLSpatialShift(LLVector3 offset) : mOffset(offset) { }
+	const LLVector4a& mOffset;
+
+	LLSpatialShift(const LLVector4a& offset) : mOffset(offset) { }
 	virtual void visit(const LLSpatialGroup::OctreeNode* branch) 
 	{ 
 		((LLSpatialGroup*) branch->getListener(0))->shift(mOffset); 
 	}
-		
-	LLVector3 mOffset;
 };
 
-void LLSpatialPartition::shift(const LLVector3 &offset)
+void LLSpatialPartition::shift(const LLVector4a &offset)
 { //shift octree node bounding boxes by offset
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	LLSpatialShift shifter(offset);
@@ -1857,7 +1908,7 @@ class LLOctreeCullShadow : public LLOctreeCull
 class LLOctreeCullVisExtents: public LLOctreeCullShadow
 {
 public:
-	LLOctreeCullVisExtents(LLCamera* camera, LLVector3& min, LLVector3& max)
+	LLOctreeCullVisExtents(LLCamera* camera, LLVector4a& min, LLVector4a& max)
 		: LLOctreeCullShadow(camera), mMin(min), mMax(max), mEmpty(TRUE) { }
 
 	virtual bool earlyFail(LLSpatialGroup* group)
@@ -1924,8 +1975,8 @@ class LLOctreeCullVisExtents: public LLOctreeCullShadow
 	}
 
 	BOOL mEmpty;
-	LLVector3& mMin;
-	LLVector3& mMax;
+	LLVector4a& mMin;
+	LLVector4a& mMax;
 };
 
 class LLOctreeCullDetectVisible: public LLOctreeCullShadow
@@ -2029,6 +2080,11 @@ void drawBox(const LLVector3& c, const LLVector3& r)
 	gGL.end();	
 }
 
+void drawBox(const LLVector4a& c, const LLVector4a& r)
+{
+	drawBox(reinterpret_cast<const LLVector3&>(c), reinterpret_cast<const LLVector3&>(r));
+}
+
 void drawBoxOutline(const LLVector3& pos, const LLVector3& size)
 {
 	LLVector3 v1 = size.scaledVec(LLVector3( 1, 1,1));
@@ -2075,6 +2131,11 @@ void drawBoxOutline(const LLVector3& pos, const LLVector3& size)
 	gGL.end();
 }
 
+void drawBoxOutline(const LLVector4a& pos, const LLVector4a& size)
+{
+	drawBoxOutline(reinterpret_cast<const LLVector3&>(pos), reinterpret_cast<const LLVector3&>(size));
+}
+
 class LLOctreeDirty : public LLOctreeTraveler<LLDrawable>
 {
 public:
@@ -2118,14 +2179,21 @@ BOOL LLSpatialPartition::isOcclusionEnabled()
 
 BOOL LLSpatialPartition::getVisibleExtents(LLCamera& camera, LLVector3& visMin, LLVector3& visMax)
 {
+	LLVector4a visMina, visMaxa;
+	visMina.load3(visMin.mV);
+	visMaxa.load3(visMax.mV);
+
 	{
 		LLFastTimer ftm(FTM_CULL_REBOUND);		
 		LLSpatialGroup* group = (LLSpatialGroup*) mOctree->getListener(0);
 		group->rebound();
 	}
 
-	LLOctreeCullVisExtents vis(&camera, visMin, visMax);
+	LLOctreeCullVisExtents vis(&camera, visMina, visMaxa);
 	vis.traverse(mOctree);
+
+	visMin.set(visMina.getF32());
+	visMax.set(visMina.getF32());
 	return vis.mEmpty;
 }
 
@@ -2188,25 +2256,36 @@ BOOL earlyFail(LLCamera* camera, LLSpatialGroup* group)
 	}
 
 	const F32 vel = SG_OCCLUSION_FUDGE*2.f;
-	LLVector3 c = group->mBounds[0];
-	LLVector3 r = group->mBounds[1] + LLVector3(vel,vel,vel);
-    
+	LLVector4a fudge;
+	fudge.splat(vel);
+
+	const LLVector4a& c = group->mBounds[0];
+	LLVector4a r;
+	r.setAdd(group->mBounds[1], fudge);
+
 	/*if (r.magVecSquared() > 1024.0*1024.0)
 	{
 		return TRUE;
 	}*/
 
-	LLVector3 e = camera->getOrigin();
+	LLVector4a e;
+	e.load3(camera->getOrigin().mV);
 	
-	LLVector3 min = c - r;
-	LLVector3 max = c + r;
+	LLVector4a min;
+	min.setSub(c,r);
+	LLVector4a max;
+	max.setAdd(c,r);
 	
-	for (U32 j = 0; j < 3; j++)
+	S32 lt = e.lessThan4(min).getComparisonMask() & 0x7;
+	if (lt)
 	{
-		if (e.mV[j] < min.mV[j] || e.mV[j] > max.mV[j])
-		{
-			return FALSE;
-		}
+		return FALSE;
+	}
+
+	S32 gt = e.greaterThan4(max).getComparisonMask() & 0x7;
+	if (gt)
+	{
+		return FALSE;
 	}
 
 	return TRUE;
@@ -2411,7 +2490,13 @@ void renderOctree(LLSpatialGroup* group)
 	}
 
 	gGL.color4fv(col.mV);
-	drawBox(group->mObjectBounds[0], group->mObjectBounds[1]*1.01f+LLVector3(0.001f, 0.001f, 0.001f));
+	LLVector4a fudge;
+	fudge.splat(0.001f);
+	LLVector4a size = group->mObjectBounds[1];
+	size.mul(1.01f);
+	size.add(fudge);
+
+	drawBox(group->mObjectBounds[0], fudge);
 	
 	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 
@@ -2442,8 +2527,12 @@ void renderOctree(LLSpatialGroup* group)
 				for (LLSpatialGroup::drawmap_elem_t::iterator j = i->second.begin(); j != i->second.end(); ++j)
 				{
 					LLDrawInfo* draw_info = *j;
-					LLVector3 center = (draw_info->mExtents[1] + draw_info->mExtents[0])*0.5f;
-					LLVector3 size = (draw_info->mExtents[1] - draw_info->mExtents[0])*0.5f;
+					LLVector4a center;
+					center.setAdd(draw_info->mExtents[1], draw_info->mExtents[0]);
+					center.mul(0.5f);
+					LLVector4a size;
+					size.setSub(draw_info->mExtents[1], draw_info->mExtents[0]);
+					size.mul(0.5f);
 					drawBoxOutline(center, size);
 				}
 			}
@@ -2493,7 +2582,7 @@ void renderVisibility(LLSpatialGroup* group, LLCamera* camera)
 		else if (camera && group->mOcclusionVerts)
 		{
 			LLVertexBuffer::unbind();
-			glVertexPointer(3, GL_FLOAT, 0, group->mOcclusionVerts);
+			glVertexPointer(3, GL_FLOAT, 16, group->mOcclusionVerts);
 
 			glColor4f(1.0f, 0.f, 0.f, 0.5f);
 			glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, GL_UNSIGNED_BYTE, get_box_fan_indices(camera, group->mBounds[0]));
@@ -2572,8 +2661,8 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE)
 		}
 	}
 
-	const LLVector3* ext;
-	LLVector3 pos, size;
+	const LLVector4a* ext;
+	LLVector4a pos, size;
 
 	//render face bounding boxes
 	for (S32 i = 0; i < drawable->getNumFaces(); i++)
@@ -2582,20 +2671,21 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE)
 
 		ext = facep->mExtents;
 
-		if (ext[0].isExactlyZero() && ext[1].isExactlyZero())
-		{
-			continue;
-		}
-		pos = (ext[0] + ext[1]) * 0.5f;
-		size = (ext[1] - ext[0]) * 0.5f;
+		pos.setAdd(ext[0], ext[1]);
+		pos.mul(0.5f);
+		size.setSub(ext[1], ext[0]);
+		size.mul(0.5f);
+		
 		drawBoxOutline(pos,size);
 	}
 
 	//render drawable bounding box
 	ext = drawable->getSpatialExtents();
 
-	pos = (ext[0] + ext[1]) * 0.5f;
-	size = (ext[1] - ext[0]) * 0.5f;
+	pos.setAdd(ext[0], ext[1]);
+	pos.mul(0.5f);
+	size.setSub(ext[1], ext[0]);
+	size.mul(0.5f);
 	
 	LLViewerObject* vobj = drawable->getVObj();
 	if (vobj && vobj->onActiveList())
@@ -2651,8 +2741,13 @@ void renderTexturePriority(LLDrawable* drawable)
 		//	gGL.color4f(1,0,1,1);
 		//}
 		
-		LLVector3 center = (facep->mExtents[1]+facep->mExtents[0])*0.5f;
-		LLVector3 size = (facep->mExtents[1]-facep->mExtents[0])*0.5f + LLVector3(0.01f, 0.01f, 0.01f);
+		LLVector4a center;
+		center.setAdd(facep->mExtents[1],facep->mExtents[0]);
+		center.mul(0.5f);
+		LLVector4a size;
+		size.setSub(facep->mExtents[1],facep->mExtents[0]);
+		size.mul(0.5f);
+		size.add(LLVector4a(0.01f));
 		drawBox(center, size);
 		
 		/*S32 boost = imagep->getBoostLevel();
@@ -2676,7 +2771,6 @@ void renderPoints(LLDrawable* drawablep)
 	{
 		gGL.begin(LLRender::POINTS);
 		gGL.color3f(1,1,1);
-		LLVector3 center(drawablep->getPositionGroup());
 		for (S32 i = 0; i < drawablep->getNumFaces(); i++)
 		{
 			gGL.vertex3fv(drawablep->getFace(i)->mCenterLocal.mV);
@@ -2708,8 +2802,12 @@ void renderShadowFrusta(LLDrawInfo* params)
 	LLGLEnable blend(GL_BLEND);
 	gGL.setSceneBlendType(LLRender::BT_ADD);
 
-	LLVector3 center = (params->mExtents[1]+params->mExtents[0])*0.5f;
-	LLVector3 size = (params->mExtents[1]-params->mExtents[0])*0.5f;
+	LLVector4a center;
+	center.setAdd(params->mExtents[1], params->mExtents[0]);
+	center.mul(0.5f);
+	LLVector4a size;
+	size.setSub(params->mExtents[1],params->mExtents[0]);
+	size.mul(0.5f);
 
 	if (gPipeline.mShadowCamera[4].AABBInFrustum(center, size))
 	{
@@ -2753,10 +2851,14 @@ void renderLights(LLDrawable* drawablep)
 			pushVerts(drawablep->getFace(i), LLVertexBuffer::MAP_VERTEX);
 		}
 
-		const LLVector3* ext = drawablep->getSpatialExtents();
+		const LLVector4a* ext = drawablep->getSpatialExtents();
 
-		LLVector3 pos = (ext[0] + ext[1]) * 0.5f;
-		LLVector3 size = (ext[1] - ext[0]) * 0.5f;
+		LLVector4a pos;
+		pos.setAdd(ext[0], ext[1]);
+		pos.mul(0.5f);
+		LLVector4a size;
+		size.setSub(ext[1], ext[0]);
+		size.mul(0.5f);
 
 		{
 			LLGLDepthTest depth(GL_FALSE, GL_TRUE);
@@ -2766,7 +2868,7 @@ void renderLights(LLDrawable* drawablep)
 
 		gGL.color4f(1,1,0,1);
 		F32 rad = drawablep->getVOVolume()->getLightRadius();
-		drawBoxOutline(pos, LLVector3(rad,rad,rad));
+		drawBoxOutline(pos, LLVector4a(rad));
 	}
 }
 
@@ -2781,7 +2883,7 @@ class LLRenderOctreeRaycast : public LLOctreeTriangleRayIntersect
 		mDir.setSub(mEnd, mStart);
 	}
 
-	void visit(const LLOctreeNode<LLVolumeFace::Triangle>* branch)
+	void visit(const LLOctreeNode<LLVolumeTriangle>* branch)
 	{
 		LLVolumeOctreeListener* vl = (LLVolumeOctreeListener*) branch->getListener(0);
 
@@ -2859,10 +2961,14 @@ void renderRaycast(LLDrawable* drawablep)
 		glPopMatrix();
 
 		// draw bounding box of prim
-		const LLVector3* ext = drawablep->getSpatialExtents();
+		const LLVector4a* ext = drawablep->getSpatialExtents();
 
-		LLVector3 pos = (ext[0] + ext[1]) * 0.5f;
-		LLVector3 size = (ext[1] - ext[0]) * 0.5f;
+		LLVector4a pos;
+		pos.setAdd(ext[0], ext[1]);
+		pos.mul(0.5f);
+		LLVector4a size;
+		size.setSub(ext[1], ext[0]);
+		size.mul(0.5f);
 
 		LLGLDepthTest depth(GL_FALSE, GL_TRUE);
 		gGL.color4f(0,0.5f,0.5f,1);
@@ -2949,8 +3055,8 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 			return;
 		}
 
-		LLVector3 nodeCenter = group->mBounds[0];
-		LLVector3 octCenter = LLVector3(group->mOctreeNode->getCenter());
+		LLVector4a nodeCenter = group->mBounds[0];
+		LLVector4a octCenter = group->mOctreeNode->getCenter();
 
 		group->rebuildGeom();
 		group->rebuildMesh();
@@ -2979,8 +3085,14 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 				if (drawable->isState(LLDrawable::IN_REBUILD_Q2))
 				{
 					gGL.color4f(0.6f, 0.6f, 0.1f, 1.f);
-					const LLVector3* ext = drawable->getSpatialExtents();
-					drawBoxOutline((ext[0]+ext[1])*0.5f, (ext[1]-ext[0])*0.5f);
+					const LLVector4a* ext = drawable->getSpatialExtents();
+					LLVector4a center;
+					center.setAdd(ext[0], ext[1]);
+					center.mul(0.5f);
+					LLVector4a size;
+					size.setSub(ext[1], ext[0]);
+					size.mul(0.5f);
+					drawBoxOutline(center, size);
 				}
 			}	
 
@@ -3211,7 +3323,11 @@ void LLSpatialPartition::renderDebug()
 void LLSpatialGroup::drawObjectBox(LLColor4 col)
 {
 	gGL.color4fv(col.mV);
-	drawBox(mObjectBounds[0], mObjectBounds[1]*1.01f+LLVector3(0.001f, 0.001f, 0.001f));
+	LLVector4a size;
+	size = mObjectBounds[0];
+	size.mul(1.01f);
+	size.add(LLVector4a(0.001f));
+	drawBox(mObjectBounds[0], size);
 }
 
 
@@ -3271,8 +3387,8 @@ class LLOctreeIntersect : public LLSpatialGroup::OctreeTraveler
 
 			LLSpatialGroup* group = (LLSpatialGroup*) child->getListener(0);
 			
-			LLVector3 size;
-			LLVector3 center;
+			LLVector4a size;
+			LLVector4a center;
 			
 			size = group->mBounds[1];
 			center = group->mBounds[0];
@@ -3289,7 +3405,11 @@ class LLOctreeIntersect : public LLSpatialGroup::OctreeTraveler
 				local_end   = mEnd   * local_matrix;
 			}
 
-			if (LLLineSegmentBoxIntersect(local_start, local_end, center, size))
+			LLVector4a start, end;
+			start.load3(local_start.mV);
+			end.load3(local_end.mV);
+
+			if (LLLineSegmentBoxIntersect(start, end, center, size))
 			{
 				check(child);
 			}
@@ -3380,6 +3500,7 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset,
 	mDrawMode(LLRender::TRIANGLES)
 {
 	mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset);
+	mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*2, 16);
 
 	mDebugColor = (rand() << 16) + rand();
 }
@@ -3395,6 +3516,13 @@ LLDrawInfo::~LLDrawInfo()
 	{
 		mFace->setDrawInfo(NULL);
 	}
+
+	if (gDebugGL)
+	{
+		gPipeline.checkReferences(this);
+	}
+
+	_mm_free(mExtents);
 }
 
 void LLDrawInfo::validate()
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 9b252d10350..119945113ab 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -45,7 +45,7 @@
 #include "lldrawpool.h"
 #include "llface.h"
 #include "llviewercamera.h"
-
+#include "llvector4a.h"
 #include <queue>
 
 #define SG_STATE_INHERIT_MASK (OCCLUDED)
@@ -57,12 +57,15 @@ class LLSpatialGroup;
 class LLTextureAtlas;
 class LLTextureAtlasSlot;
 
+S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad);
+S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &radius_squared);
+
 S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad);
 S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared);
 void pushVerts(LLFace* face, U32 mask);
 
 // get index buffer for binary encoded axis vertex buffer given a box at center being viewed by given camera
-U8* get_box_fan_indices(LLCamera* camera, const LLVector3& center);
+U8* get_box_fan_indices(LLCamera* camera, const LLVector4a& center);
 
 class LLDrawInfo : public LLRefCount 
 {
@@ -70,6 +73,18 @@ class LLDrawInfo : public LLRefCount
 	~LLDrawInfo();	
 	
 public:
+
+	LLDrawInfo(const LLDrawInfo& rhs)
+	{
+		*this = rhs;
+	}
+
+	const LLDrawInfo& operator=(const LLDrawInfo& rhs)
+	{
+		llerrs << "Illegal operation!" << llendl;
+		return *this;
+	}
+
 	LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, 
 				LLViewerTexture* image, LLVertexBuffer* buffer, 
 				BOOL fullbright = FALSE, U8 bump = 0, BOOL particle = FALSE, F32 part_size = 0);
@@ -77,6 +92,8 @@ class LLDrawInfo : public LLRefCount
 
 	void validate();
 
+	LLVector4a* mExtents;
+	
 	LLPointer<LLVertexBuffer> mVertexBuffer;
 	LLPointer<LLViewerTexture>     mTexture;
 	LLColor4U mGlowColor;
@@ -95,7 +112,6 @@ class LLDrawInfo : public LLRefCount
 	LLSpatialGroup* mGroup;
 	LLFace* mFace; //associated face
 	F32 mDistance;
-	LLVector3 mExtents[2];
 	U32 mDrawMode;
 
 	struct CompareTexture
@@ -158,11 +174,24 @@ class LLDrawInfo : public LLRefCount
 	};
 };
 
+LL_ALIGN_PREFIX(64)
 class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 {
 	friend class LLSpatialPartition;
 	friend class LLOctreeStateCheck;
 public:
+
+	LLSpatialGroup(const LLSpatialGroup& rhs)
+	{
+		*this = rhs;
+	}
+
+	const LLSpatialGroup& operator=(const LLSpatialGroup& rhs)
+	{
+		llerrs << "Illegal operation!" << llendl;
+		return *this;
+	}
+
 	static U32 sNodeCount;
 	static BOOL sNoDelete; //deletion of spatial groups and draw info not allowed if TRUE
 
@@ -273,8 +302,8 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	BOOL isVisible() const;
 	BOOL isRecentlyVisible() const;
 	void setVisible();
-	void shift(const LLVector3 &offset);
-	BOOL boundObjects(BOOL empty, LLVector3& newMin, LLVector3& newMax);
+	void shift(const LLVector4a &offset);
+	BOOL boundObjects(BOOL empty, LLVector4a& newMin, LLVector4a& newMax);
 	void unbound();
 	BOOL rebound();
 	void buildOcclusion(); //rebuild mOcclusionVerts
@@ -322,6 +351,27 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	void addAtlas(LLTextureAtlas* atlasp, S8 recursive_level = 3) ;
 	void removeAtlas(LLTextureAtlas* atlasp, BOOL remove_group = TRUE, S8 recursive_level = 3) ;
 	void clearAtlasList() ;
+
+public:
+
+	typedef enum
+	{
+		BOUNDS = 0,
+		EXTENTS = 2,
+		OBJECT_BOUNDS = 4,
+		OBJECT_EXTENTS = 6,
+		VIEW_ANGLE = 8,
+		LAST_VIEW_ANGLE = 9,
+		V4_COUNT = 10
+	} eV4Index;
+
+	LLVector4a* mBounds; // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LLVector4a* mExtents; // extents (min, max) of this node and all its children
+	LLVector4a* mObjectExtents; // extents (min, max) of objects in this node
+	LLVector4a* mObjectBounds; // bounding box (center, size) of objects in this node
+	LLVector4a* mViewAngle;
+	LLVector4a* mLastUpdateViewAngle;
+		
 private:
 	U32                     mCurUpdatingTime ;
 	//do not make the below two to use LLPointer
@@ -349,14 +399,9 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	F32 mBuilt;
 	OctreeNode* mOctreeNode;
 	LLSpatialPartition* mSpatialPartition;
-	LLVector3 mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
-	LLVector3 mExtents[2]; // extents (min, max) of this node and all its children
 	
-	LLVector3 mObjectExtents[2]; // extents (min, max) of objects in this node
-	LLVector3 mObjectBounds[2]; // bounding box (center, size) of objects in this node
-
 	LLPointer<LLVertexBuffer> mVertexBuffer;
-	F32*					mOcclusionVerts;
+	LLVector4a*				mOcclusionVerts;
 	GLuint					mOcclusionQuery[LLViewerCamera::NUM_CAMERAS];
 
 	U32 mBufferUsage;
@@ -367,13 +412,10 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	F32 mDepth;
 	F32 mLastUpdateDistance;
 	F32 mLastUpdateTime;
-			
-	LLVector3 mViewAngle;
-	LLVector3 mLastUpdateViewAngle;
 	
 	F32 mPixelArea;
 	F32 mRadius;
-};
+} LL_ALIGN_POSTFIX(64);
 
 class LLGeometryManager
 {
@@ -409,7 +451,7 @@ class LLSpatialPartition: public LLGeometryManager
 	
 	// If the drawable moves, move it here.
 	virtual void move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate = FALSE);
-	virtual void shift(const LLVector3 &offset);
+	virtual void shift(const LLVector4a &offset);
 
 	virtual F32 calcDistance(LLSpatialGroup* group, LLCamera& camera);
 	virtual F32 calcPixelArea(LLSpatialGroup* group, LLCamera& camera);
@@ -467,7 +509,7 @@ class LLSpatialBridge : public LLDrawable, public LLSpatialPartition
 	virtual void makeActive();
 	virtual void move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate = FALSE);
 	virtual BOOL updateMove();
-	virtual void shiftPos(const LLVector3& vec);
+	virtual void shiftPos(const LLVector4a& vec);
 	virtual void cleanupReferences();
 	virtual LLSpatialPartition* asPartition()		{ return this; }
 	virtual LLSpatialBridge* asBridge()				{ return this; }
@@ -658,7 +700,7 @@ class LLHUDBridge : public LLVolumeBridge
 {
 public:
 	LLHUDBridge(LLDrawable* drawablep);
-	virtual void shiftPos(const LLVector3& vec);
+	virtual void shiftPos(const LLVector4a& vec);
 	virtual F32 calcPixelArea(LLSpatialGroup* group, LLCamera& camera);
 };
 
@@ -675,7 +717,7 @@ class LLHUDPartition : public LLBridgePartition
 {
 public:
 	LLHUDPartition();
-	virtual void shift(const LLVector3 &offset);
+	virtual void shift(const LLVector4a &offset);
 };
 
 extern const F32 SG_BOX_SIDE;
diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp
index 48e4a6ccc75..06431d428f1 100644
--- a/indra/newview/llsurfacepatch.cpp
+++ b/indra/newview/llsurfacepatch.cpp
@@ -860,8 +860,10 @@ void LLSurfacePatch::updateVisibility()
 	F32 stride_per_distance = DEFAULT_DELTA_ANGLE / mSurfacep->getMetersPerGrid();
 	U32 grids_per_patch_edge = mSurfacep->getGridsPerPatchEdge();
 
-	LLVector3 center = mCenterRegion + mSurfacep->getOriginAgent();
-	LLVector3 radius = LLVector3(mRadius, mRadius, mRadius);
+	LLVector4a center;
+	center.load3( (mCenterRegion + mSurfacep->getOriginAgent()).mV);
+	LLVector4a radius;
+	radius.splat(mRadius);
 
 	// sphere in frustum on global coordinates
 	if (LLViewerCamera::getInstance()->AABBInFrustumNoFarClip(center, radius))
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 1490f8153c1..d31b0f51fdc 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -900,9 +900,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			render_ui();
 		}
 
-		gPipeline.rebuildGroups();
-
+		
 		LLSpatialGroup::sNoDelete = FALSE;
+		gPipeline.clearReferences();
+
+		gPipeline.rebuildGroups();
 	}
 
 	LLAppViewer::instance()->pingMainloopTimeout("Display:FrameStats");
@@ -1000,6 +1002,7 @@ void render_hud_attachments()
 		gPipeline.renderGeom(hud_cam);
 
 		LLSpatialGroup::sNoDelete = FALSE;
+		gPipeline.clearReferences();
 
 		render_hud_elements();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 3aecd0175d2..0ed2d1da091 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2863,21 +2863,26 @@ void LLViewerObject::setScale(const LLVector3 &scale, BOOL damped)
 	}
 }
 
-void LLViewerObject::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax)
-{
-	LLVector3 center = getRenderPosition();
-	LLVector3 size = getScale();
-	newMin.setVec(center-size);
-	newMax.setVec(center+size);
-	mDrawable->setPositionGroup((newMin + newMax) * 0.5f);
+void LLViewerObject::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
+{
+	LLVector4a center;
+	center.load3(getRenderPosition().mV);
+	LLVector4a size;
+	size.load3(getScale().mV);
+	newMin.setSub(center, size);
+	newMax.setAdd(center, size);
+	
+	mDrawable->setPositionGroup(center);
 }
 
 F32 LLViewerObject::getBinRadius()
 {
 	if (mDrawable.notNull())
 	{
-		const LLVector3* ext = mDrawable->getSpatialExtents();
-		return (ext[1]-ext[0]).magVec();
+		const LLVector4a* ext = mDrawable->getSpatialExtents();
+		LLVector4a diff;
+		diff.setSub(ext[1], ext[0]);
+		return diff.length3();
 	}
 	
 	return getScale().magVec();
@@ -3469,12 +3474,21 @@ BOOL LLViewerObject::lineSegmentBoundingBox(const LLVector3& start, const LLVect
 		return FALSE;
 	}
 
-	const LLVector3* ext = mDrawable->getSpatialExtents();
+	const LLVector4a* ext = mDrawable->getSpatialExtents();
+
+	//VECTORIZE THIS
+	LLVector4a center;
+	center.setAdd(ext[1], ext[0]);
+	center.mul(0.5f);
+	LLVector4a size;
+	size.setSub(ext[1], ext[0]);
+	size.mul(0.5f);
 
-	LLVector3 center = (ext[1]+ext[0])*0.5f;
-	LLVector3 size = (ext[1]-ext[0])*0.5f;
+	LLVector4a starta, enda;
+	starta.load3(start.mV);
+	enda.load3(end.mV);
 
-	return LLLineSegmentBoxIntersect(start, end, center, size);
+	return LLLineSegmentBoxIntersect(starta, enda, center, size);
 }
 
 U8 LLViewerObject::getMediaType() const
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 0fd0cbfa604..6ebd1cbe212 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -373,7 +373,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	void markForUpdate(BOOL priority);
 	void updateVolume(const LLVolumeParams& volume_params);
-	virtual	void updateSpatialExtents(LLVector3& min, LLVector3& max);
+	virtual	void updateSpatialExtents(LLVector4a& min, LLVector4a& max);
 	virtual F32 getBinRadius();
 	
 	LLBBox				getBoundingBoxAgent() const;
@@ -386,7 +386,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	void clearDrawableState(U32 state, BOOL recursive = TRUE);
 
 	// Called when the drawable shifts
-	virtual void onShift(const LLVector3 &shift_vector)	{ }
+	virtual void onShift(const LLVector4a &shift_vector)	{ }
 		
 	//////////////////////////////////////
 	//
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index 6b480ccf8e5..41848e8b7ad 100644
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -161,8 +161,8 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 bo
 
 	if (group != NULL)
 	{
-		LLVector3 center(group->mOctreeNode->getCenter());
-		LLVector3 size(group->mOctreeNode->getSize());
+		LLVector3 center(group->mOctreeNode->getCenter().getF32());
+		LLVector3 size(group->mOctreeNode->getSize().getF32());
 		size += LLVector3(0.01f, 0.01f, 0.01f);
 		mMinObjPos = center - size;
 		mMaxObjPos = center + size;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index ac109771dd3..b0974618227 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1286,41 +1286,46 @@ void LLVOAvatar::updateDrawable(BOOL force_damped)
 	clearChanged(SHIFTED);
 }
 
-void LLVOAvatar::onShift(const LLVector3& shift_vector)
+void LLVOAvatar::onShift(const LLVector4a& shift_vector)
 {
-	mLastAnimExtents[0] += shift_vector;
-	mLastAnimExtents[1] += shift_vector;
+	const LLVector3& shift = reinterpret_cast<const LLVector3&>(shift_vector);
+	mLastAnimExtents[0] += shift;
+	mLastAnimExtents[1] += shift;
 	mNeedsImpostorUpdate = TRUE;
 	mNeedsAnimUpdate = TRUE;
 }
 
-void LLVOAvatar::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax)
+void LLVOAvatar::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
 {
 	if (isImpostor() && !needsImpostorUpdate())
 	{
 		LLVector3 delta = getRenderPosition() -
-			((LLVector3(mDrawable->getPositionGroup())-mImpostorOffset));
+			((LLVector3(mDrawable->getPositionGroup().getF32())-mImpostorOffset));
 		
-		newMin = mLastAnimExtents[0] + delta;
-		newMax = mLastAnimExtents[1] + delta;
+		newMin.load3( (mLastAnimExtents[0] + delta).mV);
+		newMax.load3( (mLastAnimExtents[1] + delta).mV);
 	}
 	else
 	{
 		getSpatialExtents(newMin,newMax);
-		mLastAnimExtents[0] = newMin;
-		mLastAnimExtents[1] = newMax;
-		LLVector3 pos_group = (newMin+newMax)*0.5f;
-		mImpostorOffset = pos_group-getRenderPosition();
+		mLastAnimExtents[0].set(newMin.getF32());
+		mLastAnimExtents[1].set(newMax.getF32());
+		LLVector4a pos_group;
+		pos_group.setAdd(newMin,newMax);
+		pos_group.mul(0.5f);
+		mImpostorOffset = LLVector3(pos_group.getF32())-getRenderPosition();
 		mDrawable->setPositionGroup(pos_group);
 	}
 }
 
-void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
+void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
 {
-	LLVector3 buffer(0.25f, 0.25f, 0.25f);
-	LLVector3 pos = getRenderPosition();
-	newMin = pos - buffer;
-	newMax = pos + buffer;
+	LLVector4a buffer(0.25f);
+	LLVector4a pos;
+	pos.load3(getRenderPosition().mV);
+	newMin.setSub(pos, buffer);
+	newMax.setAdd(pos, buffer);
+
 	float max_attachment_span = DEFAULT_MAX_PRIM_SCALE * 5.0f;
 	
 	//stretch bounding box by joint positions
@@ -1329,12 +1334,20 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
 		LLPolyMesh* mesh = i->second;
 		for (S32 joint_num = 0; joint_num < mesh->mJointRenderData.count(); joint_num++)
 		{
-			update_min_max(newMin, newMax, 
-						   mesh->mJointRenderData[joint_num]->mWorldMatrix->getTranslation());
+			LLVector4a trans;
+			trans.load3( mesh->mJointRenderData[joint_num]->mWorldMatrix->getTranslation().mV);
+			update_min_max(newMin, newMax, trans);
 		}
 	}
 
-	mPixelArea = LLPipeline::calcPixelArea((newMin+newMax)*0.5f, (newMax-newMin)*0.5f, *LLViewerCamera::getInstance());
+	LLVector4a center, size;
+	center.setAdd(newMin, newMax);
+	center.mul(0.5f);
+
+	size.setSub(newMax,newMin);
+	size.mul(0.5f);
+
+	mPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance());
 
 	//stretch bounding box by attachments
 	for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); 
@@ -1361,15 +1374,17 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
 					LLSpatialBridge* bridge = drawable->getSpatialBridge();
 					if (bridge)
 					{
-						const LLVector3* ext = bridge->getSpatialExtents();
-						LLVector3 distance = (ext[1] - ext[0]);
+						const LLVector4a* ext = bridge->getSpatialExtents();
+						LLVector4a distance;
+						distance.setSub(ext[1], ext[0]);
+						LLVector4a max_span(max_attachment_span);
+
+						S32 lt = distance.lessThan4(max_span).getComparisonMask() & 0x7;
 						
 						// Only add the prim to spatial extents calculations if it isn't a megaprim.
 						// max_attachment_span calculated at the start of the function 
 						// (currently 5 times our max prim size) 
-						if (distance.mV[0] < max_attachment_span 
-							&& distance.mV[1] < max_attachment_span
-							&& distance.mV[2] < max_attachment_span)
+						if (lt == 0x7)
 						{
 							update_min_max(newMin,newMax,ext[0]);
 							update_min_max(newMin,newMax,ext[1]);
@@ -1381,8 +1396,9 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
 	}
 
 	//pad bounding box	
-	newMin -= buffer;
-	newMax += buffer;
+
+	newMin.sub(buffer);
+	newMax.add(buffer);
 }
 
 //-----------------------------------------------------------------------------
@@ -2371,7 +2387,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 
 	if (isImpostor() && !mNeedsImpostorUpdate)
 	{
-		LLVector3 ext[2];
+		LLVector4a ext[2];
 		F32 distance;
 		LLVector3 angle;
 
@@ -2400,12 +2416,22 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 			}
 			else
 			{
+				//VECTORIZE THIS
 				getSpatialExtents(ext[0], ext[1]);
-				if ((ext[1]-mImpostorExtents[1]).length() > 0.05f ||
-					(ext[0]-mImpostorExtents[0]).length() > 0.05f)
+				LLVector4a diff;
+				diff.setSub(ext[1], mImpostorExtents[1]);
+				if (diff.length3() > 0.05f)
 				{
 					mNeedsImpostorUpdate = TRUE;
 				}
+				else
+				{
+					diff.setSub(ext[0], mImpostorExtents[0]);
+					if (diff.length3() > 0.05f)
+					{
+						mNeedsImpostorUpdate = TRUE;
+					}
+				}
 			}
 		}
 	}
@@ -5151,9 +5177,13 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent)
 		return;
 	}
 
-	const LLVector3* ext = mDrawable->getSpatialExtents();
-	LLVector3 center = (ext[1] + ext[0]) * 0.5f;
-	LLVector3 size = (ext[1]-ext[0])*0.5f;
+	const LLVector4a* ext = mDrawable->getSpatialExtents();
+	LLVector4a center;
+	center.setAdd(ext[1], ext[0]);
+	center.mul(0.5f);
+	LLVector4a size;
+	size.setSub(ext[1], ext[0]);
+	size.mul(0.5f);
 
 	mImpostorPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance());
 
@@ -5165,7 +5195,7 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent)
 	}
 	else
 	{
-		F32 radius = size.length();
+		F32 radius = size.length3();
 		mAppAngle = (F32) atan2( radius, range) * RAD_TO_DEG;
 	}
 
@@ -7546,9 +7576,9 @@ void LLVOAvatar::cacheImpostorValues()
 	getImpostorValues(mImpostorExtents, mImpostorAngle, mImpostorDistance);
 }
 
-void LLVOAvatar::getImpostorValues(LLVector3* extents, LLVector3& angle, F32& distance) const
+void LLVOAvatar::getImpostorValues(LLVector4a* extents, LLVector3& angle, F32& distance) const
 {
-	const LLVector3* ext = mDrawable->getSpatialExtents();
+	const LLVector4a* ext = mDrawable->getSpatialExtents();
 	extents[0] = ext[0];
 	extents[1] = ext[1];
 
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index a851b7a1501..71c3ed1cc28 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -127,7 +127,7 @@ class LLVOAvatar :
 	virtual BOOL   	 	 	isActive() const; // Whether this object needs to do an idleUpdate.
 	virtual void   	 	 	updateTextures();
 	virtual S32    	 	 	setTETexture(const U8 te, const LLUUID& uuid); // If setting a baked texture, need to request it from a non-local sim.
-	virtual void   	 	 	onShift(const LLVector3& shift_vector);
+	virtual void   	 	 	onShift(const LLVector4a& shift_vector);
 	virtual U32    	 	 	getPartitionType() const;
 	virtual const  	 	 	LLVector3 getRenderPosition() const;
 	virtual void   	 	 	updateDrawable(BOOL force_damped);
@@ -135,8 +135,8 @@ class LLVOAvatar :
 	virtual BOOL   	 	 	updateGeometry(LLDrawable *drawable);
 	virtual void   	 	 	setPixelAreaAndAngle(LLAgent &agent);
 	virtual void   	 	 	updateRegion(LLViewerRegion *regionp);
-	virtual void   	 	 	updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax);
-	virtual void   	 	 	getSpatialExtents(LLVector3& newMin, LLVector3& newMax);
+	virtual void   	 	 	updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax);
+	virtual void   	 	 	getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax);
 	virtual BOOL   	 	 	lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
 													 S32 face = -1,                    // which face to check, -1 = ALL_SIDES
 													 BOOL pick_transparent = FALSE,
@@ -391,7 +391,7 @@ class LLVOAvatar :
 	BOOL 	    needsImpostorUpdate() const;
 	const LLVector3& getImpostorOffset() const;
 	const LLVector2& getImpostorDim() const;
-	void 		getImpostorValues(LLVector3* extents, LLVector3& angle, F32& distance) const;
+	void 		getImpostorValues(LLVector4a* extents, LLVector3& angle, F32& distance) const;
 	void 		cacheImpostorValues();
 	void 		setImpostorDim(const LLVector2& dim);
 	static void	resetImpostors();
@@ -402,7 +402,7 @@ class LLVOAvatar :
 	LLVector3	mImpostorOffset;
 	LLVector2	mImpostorDim;
 	BOOL		mNeedsAnimUpdate;
-	LLVector3	mImpostorExtents[2];
+	LL_ALIGN_16(LLVector4a	mImpostorExtents[2]);
 	LLVector3	mImpostorAngle;
 	F32			mImpostorDistance;
 	F32			mImpostorPixelArea;
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 3ba4ecad0ce..b5fd8182c60 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -79,12 +79,14 @@ F32 LLVOPartGroup::getBinRadius()
 	return mScale.mV[0]*2.f;
 }
 
-void LLVOPartGroup::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax)
+void LLVOPartGroup::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
 {		
 	const LLVector3& pos_agent = getPositionAgent();
-	newMin = pos_agent - mScale;
-	newMax = pos_agent + mScale;
-	mDrawable->setPositionGroup(pos_agent);
+	newMin.load3( (pos_agent - mScale).mV);
+	newMax.load3( (pos_agent + mScale).mV);
+	LLVector4a pos;
+	pos.load3(pos_agent.mV);
+	mDrawable->setPositionGroup(pos);
 }
 
 BOOL LLVOPartGroup::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h
index 18583b4be9a..771ae1c1eb9 100644
--- a/indra/newview/llvopartgroup.h
+++ b/indra/newview/llvopartgroup.h
@@ -57,7 +57,7 @@ class LLVOPartGroup : public LLAlphaObject
 	BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 
 	virtual F32 getBinRadius();
-	virtual void updateSpatialExtents(LLVector3& newMin, LLVector3& newMax);
+	virtual void updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax);
 	virtual U32 getPartitionType() const;
 	
 	/*virtual*/ void setPixelAreaAndAngle(LLAgent &agent);
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp
index eef62ddf1a1..02e7e7e60fc 100644
--- a/indra/newview/llvosurfacepatch.cpp
+++ b/indra/newview/llvosurfacepatch.cpp
@@ -995,7 +995,13 @@ BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector3& start, const LLVect
 
 	//step one meter at a time until intersection point found
 
-	const LLVector3* ext = mDrawable->getSpatialExtents();
+	//VECTORIZE THIS
+	const LLVector4a* exta = mDrawable->getSpatialExtents();
+
+	LLVector3 ext[2];
+	ext[0].set(exta[0].getF32());
+	ext[1].set(exta[1].getF32());
+
 	F32 rad = (delta*tdelta).magVecSquared();
 
 	F32 t = 0.f;
@@ -1057,13 +1063,16 @@ BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector3& start, const LLVect
 	return FALSE;
 }
 
-void LLVOSurfacePatch::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax)
+void LLVOSurfacePatch::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
 {
 	LLVector3 posAgent = getPositionAgent();
 	LLVector3 scale = getScale();
-	newMin = posAgent-scale*0.5f; // Changing to 2.f makes the culling a -little- better, but still wrong
-	newMax = posAgent+scale*0.5f;
-	mDrawable->setPositionGroup((newMin+newMax)*0.5f);
+	newMin.load3( (posAgent-scale*0.5f).mV); // Changing to 2.f makes the culling a -little- better, but still wrong
+	newMax.load3( (posAgent+scale*0.5f).mV);
+	LLVector4a pos;
+	pos.setAdd(newMin,newMax);
+	pos.mul(0.5f);
+	mDrawable->setPositionGroup(pos);
 }
 
 U32 LLVOSurfacePatch::getPartitionType() const
diff --git a/indra/newview/llvosurfacepatch.h b/indra/newview/llvosurfacepatch.h
index 10a5888526c..15442e1947d 100644
--- a/indra/newview/llvosurfacepatch.h
+++ b/indra/newview/llvosurfacepatch.h
@@ -78,7 +78,7 @@ class LLVOSurfacePatch : public LLStaticViewerObject
 	/*virtual*/ void updateTextures();
 	/*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area
 
-	/*virtual*/ void updateSpatialExtents(LLVector3& newMin, LLVector3& newMax);
+	/*virtual*/ void updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax);
 	/*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate.
 
 	void setPatch(LLSurfacePatch *patchp);
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index b89c0cd6385..d5646431618 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -1238,7 +1238,7 @@ void LLVOTree::updateRadius()
 	mDrawable->setRadius(32.0f);
 }
 
-void LLVOTree::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax)
+void LLVOTree::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
 {
 	F32 radius = getScale().length()*0.05f;
 	LLVector3 center = getRenderPosition();
@@ -1248,9 +1248,11 @@ void LLVOTree::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax)
 
 	center += LLVector3(0, 0, size.mV[2]) * getRotation();
 	
-	newMin.set(center-size);
-	newMax.set(center+size);
-	mDrawable->setPositionGroup(center);
+	newMin.load3((center-size).mV);
+	newMax.load3((center+size).mV);
+	LLVector4a pos;
+	pos.load3(center.mV);
+	mDrawable->setPositionGroup(pos);
 }
 
 BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
@@ -1263,8 +1265,13 @@ BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end
 		return FALSE;
 	}
 
-	const LLVector3* ext = mDrawable->getSpatialExtents();
+	const LLVector4a* exta = mDrawable->getSpatialExtents();
 
+	//VECTORIZE THIS
+	LLVector3 ext[2];
+	ext[0].set(exta[0].getF32());
+	ext[1].set(exta[1].getF32());
+	
 	LLVector3 center = (ext[1]+ext[0])*0.5f;
 	LLVector3 size = (ext[1]-ext[0]);
 
diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h
index feac9e0675e..2ce1b03d268 100644
--- a/indra/newview/llvotree.h
+++ b/indra/newview/llvotree.h
@@ -73,7 +73,7 @@ class LLVOTree : public LLViewerObject
 
 	/*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
 	/*virtual*/ BOOL		updateGeometry(LLDrawable *drawable);
-	/*virtual*/ void		updateSpatialExtents(LLVector3 &min, LLVector3 &max);
+	/*virtual*/ void		updateSpatialExtents(LLVector4a &min, LLVector4a &max);
 
 	virtual U32 getPartitionType() const;
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index a9f3abeef8d..db9e0b88e18 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -701,7 +701,7 @@ void LLVOVolume::updateTextureVirtualSize()
 		const LLTextureEntry *te = face->getTextureEntry();
 		LLViewerTexture *imagep = face->getTexture();
 		if (!imagep || !te ||			
-			face->mExtents[0] == face->mExtents[1])
+			face->mExtents[0].equal3(face->mExtents[1]))
 		{
 			continue;
 		}
@@ -1332,7 +1332,7 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
 {
 	BOOL res = TRUE;
 
-	LLVector3 min,max;
+	LLVector4a min,max;
 
 	BOOL rebuild = mDrawable->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION);
 
@@ -1356,17 +1356,8 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
 			}
 			else
 			{
-				for (U32 i = 0; i < 3; i++)
-				{
-					if (face->mExtents[0].mV[i] < min.mV[i])
-					{
-						min.mV[i] = face->mExtents[0].mV[i];
-					}
-					if (face->mExtents[1].mV[i] > max.mV[i])
-					{
-						max.mV[i] = face->mExtents[1].mV[i];
-					}
-				}
+				min.setMin(face->mExtents[0]);
+				max.setMax(face->mExtents[1]);
 			}
 		}
 	}
@@ -1374,7 +1365,9 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
 	if (rebuild)
 	{
 		mDrawable->setSpatialExtents(min,max);
-		mDrawable->setPositionGroup((min+max)*0.5f);	
+		min.add(max);
+		min.mul(0.5f);
+		mDrawable->setPositionGroup(min);	
 	}
 
 	updateRadius();
@@ -3007,7 +3000,7 @@ void LLVOVolume::setSelected(BOOL sel)
 	}
 }
 
-void LLVOVolume::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax)
+void LLVOVolume::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
 {		
 }
 
@@ -3039,7 +3032,7 @@ F32 LLVOVolume::getBinRadius()
 		}
 	}
 
-	const LLVector3* ext = mDrawable->getSpatialExtents();
+	const LLVector4a* ext = mDrawable->getSpatialExtents();
 	
 	BOOL shrink_wrap = mDrawable->isAnimating();
 	BOOL alpha_wrap = FALSE;
@@ -3071,7 +3064,10 @@ F32 LLVOVolume::getBinRadius()
 	}
 	else if (shrink_wrap)
 	{
-		radius = (ext[1]-ext[0]).length()*0.5f;
+		LLVector4a rad;
+		rad.setSub(ext[1], ext[0]);
+		
+		radius = rad.length3()*0.5f;
 	}
 	else if (mDrawable->isStatic())
 	{
@@ -3107,7 +3103,7 @@ const LLVector3 LLVOVolume::getPivotPositionAgent() const
 	return LLViewerObject::getPivotPositionAgent();
 }
 
-void LLVOVolume::onShift(const LLVector3 &shift_vector)
+void LLVOVolume::onShift(const LLVector4a &shift_vector)
 {
 	if (mVolumeImpl)
 	{
@@ -3610,7 +3606,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 							}
 						}
 					}
-
 				}
 
 				continue;
@@ -4217,7 +4212,7 @@ LLHUDPartition::LLHUDPartition()
 	mLODPeriod = 1;
 }
 
-void LLHUDPartition::shift(const LLVector3 &offset)
+void LLHUDPartition::shift(const LLVector4a &offset)
 {
 	//HUD objects don't shift with region crossing.  That would be silly.
 }
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 2776988a122..d5606034d05 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -66,7 +66,7 @@ class LLVolumeInterface
 	virtual void onSetVolume(const LLVolumeParams &volume_params, const S32 detail) = 0;
 	virtual void onSetScale(const LLVector3 &scale, BOOL damped) = 0;
 	virtual void onParameterChanged(U16 param_type, LLNetworkData *data, BOOL in_use, bool local_origin) = 0;
-	virtual void onShift(const LLVector3 &shift_vector) = 0;
+	virtual void onShift(const LLVector4a &shift_vector) = 0;
 	virtual bool isVolumeUnique() const = 0; // Do we need a unique LLVolume instance?
 	virtual bool isVolumeGlobal() const = 0; // Are we in global space?
 	virtual bool isActive() const = 0; // Is this object currently active?
@@ -145,7 +145,7 @@ class LLVOVolume : public LLViewerObject
 
 				void	markForUpdate(BOOL priority)			{ LLViewerObject::markForUpdate(priority); mVolumeChanged = TRUE; }
 
-	/*virtual*/ void	onShift(const LLVector3 &shift_vector); // Called when the drawable shifts
+	/*virtual*/ void	onShift(const LLVector4a &shift_vector); // Called when the drawable shifts
 
 	/*virtual*/ void	parameterChanged(U16 param_type, bool local_origin);
 	/*virtual*/ void	parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_use, bool local_origin);
@@ -201,7 +201,7 @@ class LLVOVolume : public LLViewerObject
 				void	regenFaces();
 				BOOL	genBBoxes(BOOL force_global);
 				void	preRebuild();
-	virtual		void	updateSpatialExtents(LLVector3& min, LLVector3& max);
+	virtual		void	updateSpatialExtents(LLVector4a& min, LLVector4a& max);
 	virtual		F32		getBinRadius();
 	
 	virtual U32 getPartitionType() const;
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp
index a8c4625f6ed..7c1b22d4321 100644
--- a/indra/newview/llvowater.cpp
+++ b/indra/newview/llvowater.cpp
@@ -258,15 +258,21 @@ void LLVOWater::setIsEdgePatch(const BOOL edge_patch)
 	mIsEdgePatch = edge_patch;
 }
 
-void LLVOWater::updateSpatialExtents(LLVector3 &newMin, LLVector3& newMax)
+void LLVOWater::updateSpatialExtents(LLVector4a &newMin, LLVector4a& newMax)
 {
-	LLVector3 pos = getPositionAgent();
-	LLVector3 scale = getScale();
-
-	newMin = pos - scale * 0.5f;
-	newMax = pos + scale * 0.5f;
+	LLVector4a pos;
+	pos.load3(getPositionAgent().mV);
+	LLVector4a scale;
+	scale.load3(getScale().mV);
+	scale.mul(0.5f);
+
+	newMin.setSub(pos, scale);
+	newMax.setAdd(pos, scale);
+	
+	pos.setAdd(newMin,newMax);
+	pos.mul(0.5f);
 
-	mDrawable->setPositionGroup((newMin + newMax) * 0.5f);
+	mDrawable->setPositionGroup(pos);
 }
 
 U32 LLVOWater::getPartitionType() const
diff --git a/indra/newview/llvowater.h b/indra/newview/llvowater.h
index 3cc031e589a..a868afe58b5 100644
--- a/indra/newview/llvowater.h
+++ b/indra/newview/llvowater.h
@@ -66,7 +66,7 @@ class LLVOWater : public LLStaticViewerObject
 	/*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 	/*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
 	/*virtual*/ BOOL        updateGeometry(LLDrawable *drawable);
-	/*virtual*/ void		updateSpatialExtents(LLVector3& newMin, LLVector3& newMax);
+	/*virtual*/ void		updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax);
 
 	/*virtual*/ void updateTextures();
 	/*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 91c3805d3b4..01027e5be6e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1508,11 +1508,214 @@ F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera
 	return radius*radius * F_PI;
 }
 
+//static
+F32 LLPipeline::calcPixelArea(const LLVector4a& center, const LLVector4a& size, LLCamera &camera)
+{
+	LLVector4a origin;
+	origin.load3(camera.getOrigin().mV);
+
+	LLVector4a lookAt;
+	lookAt.setSub(center, origin);
+	F32 dist = lookAt.length3();
+
+	//ramp down distance for nearby objects
+	//shrink dist by dist/16.
+	if (dist < 16.f)
+	{
+		dist /= 16.f;
+		dist *= dist;
+		dist *= 16.f;
+	}
+
+	//get area of circle around node
+	F32 app_angle = atanf(size.length3()/dist);
+	F32 radius = app_angle*LLDrawable::sCurPixelAngle;
+	return radius*radius * F_PI;
+}
+
 void LLPipeline::grabReferences(LLCullResult& result)
 {
 	sCull = &result;
 }
 
+void LLPipeline::clearReferences()
+{
+	sCull = NULL;
+}
+
+void check_references(LLSpatialGroup* group, LLDrawable* drawable)
+{
+	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+	{
+		if (drawable == *i)
+		{
+			llerrs << "LLDrawable deleted while actively reference by LLPipeline." << llendl;
+		}
+	}			
+}
+
+void check_references(LLDrawable* drawable, LLFace* face)
+{
+	for (S32 i = 0; i < drawable->getNumFaces(); ++i)
+	{
+		if (drawable->getFace(i) == face)
+		{
+			llerrs << "LLFace deleted while actively referenced by LLPipeline." << llendl;
+		}
+	}
+}
+
+void check_references(LLSpatialGroup* group, LLFace* face)
+{
+	for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+	{
+		LLDrawable* drawable = *i;
+		check_references(drawable, face);
+	}			
+}
+
+void LLPipeline::checkReferences(LLFace* face)
+{
+#if 0
+	if (sCull)
+	{
+		for (LLCullResult::sg_list_t::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)
+		{
+			LLSpatialGroup* group = *iter;
+			check_references(group, face);
+		}
+
+		for (LLCullResult::sg_list_t::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)
+		{
+			LLDrawable* drawable = *iter;
+			check_references(drawable, face);	
+		}
+	}
+#endif
+}
+
+void LLPipeline::checkReferences(LLDrawable* drawable)
+{
+#if 0
+	if (sCull)
+	{
+		for (LLCullResult::sg_list_t::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)
+		{
+			LLSpatialGroup* group = *iter;
+			check_references(group, drawable);
+		}
+
+		for (LLCullResult::sg_list_t::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)
+		{
+			if (drawable == *iter)
+			{
+				llerrs << "LLDrawable deleted while actively referenced by LLPipeline." << llendl;
+			}
+		}
+	}
+#endif
+}
+
+void check_references(LLSpatialGroup* group, LLDrawInfo* draw_info)
+{
+	for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
+	{
+		LLSpatialGroup::drawmap_elem_t& draw_vec = i->second;
+		for (LLSpatialGroup::drawmap_elem_t::iterator j = draw_vec.begin(); j != draw_vec.end(); ++j)
+		{
+			LLDrawInfo* params = *j;
+			if (params == draw_info)
+			{
+				llerrs << "LLDrawInfo deleted while actively referenced by LLPipeline." << llendl;
+			}
+		}
+	}
+}
+
+
+void LLPipeline::checkReferences(LLDrawInfo* draw_info)
+{
+#if 0
+	if (sCull)
+	{
+		for (LLCullResult::sg_list_t::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)
+		{
+			LLSpatialGroup* group = *iter;
+			check_references(group, draw_info);
+		}
+
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		{
+			LLSpatialGroup* group = *iter;
+			check_references(group, draw_info);
+		}
+	}
+#endif
+}
+
+void LLPipeline::checkReferences(LLSpatialGroup* group)
+{
+#if 0
+	if (sCull)
+	{
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter)
+		{
+			if (group == *iter)
+			{
+				llerrs << "LLSpatialGroup deleted while actively referenced by LLPipeline." << llendl;
+			}
+		}
+
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginAlphaGroups(); iter != sCull->endAlphaGroups(); ++iter)
+		{
+			if (group == *iter)
+			{
+				llerrs << "LLSpatialGroup deleted while actively referenced by LLPipeline." << llendl;
+			}
+		}
+
+		for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter)
+		{
+			if (group == *iter)
+			{
+				llerrs << "LLSpatialGroup deleted while actively referenced by LLPipeline." << llendl;
+			}
+		}
+	}
+#endif
+}
+
+
 BOOL LLPipeline::visibleObjectsInFrustum(LLCamera& camera)
 {
 	for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
@@ -1714,7 +1917,7 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
 	}
 
 	if (sMinRenderSize > 0.f && 
-			llmax(llmax(group->mBounds[1].mV[0], group->mBounds[1].mV[1]), group->mBounds[1].mV[2]) < sMinRenderSize)
+			llmax(llmax(group->mBounds[1][0], group->mBounds[1][1]), group->mBounds[1][2]) < sMinRenderSize)
 	{
 		return;
 	}
@@ -2100,6 +2303,9 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 	glClear(GL_DEPTH_BUFFER_BIT);
 	gDepthDirty = TRUE;
 		
+	LLVector4a offseta;
+	offseta.load3(offset.mV);
+
 	for (LLDrawable::drawable_vector_t::iterator iter = mShiftList.begin();
 		 iter != mShiftList.end(); iter++)
 	{
@@ -2108,7 +2314,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 		{
 			continue;
 		}	
-		drawablep->shiftPos(offset);	
+		drawablep->shiftPos(offseta);	
 		drawablep->clearState(LLDrawable::ON_SHIFT_LIST);
 	}
 	mShiftList.resize(0);
@@ -2122,7 +2328,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 			LLSpatialPartition* part = region->getSpatialPartition(i);
 			if (part)
 			{
-				part->shift(offset);
+				part->shift(offseta);
 			}
 		}
 	}
@@ -2659,8 +2865,10 @@ void LLPipeline::postSort(LLCamera& camera)
 			{
 				if (sMinRenderSize > 0.f)
 				{
-					LLVector3 bounds = (*k)->mExtents[1]-(*k)->mExtents[0];
-					if (llmax(llmax(bounds.mV[0], bounds.mV[1]), bounds.mV[2]) > sMinRenderSize)
+					LLVector4a bounds;
+					bounds.setSub((*k)->mExtents[1],(*k)->mExtents[0]);
+
+					if (llmax(llmax(bounds[0], bounds[1]), bounds[2]) > sMinRenderSize)
 					{
 						sCull->pushDrawInfo(j->first, *k);
 					}
@@ -6770,8 +6978,9 @@ void LLPipeline::renderDeferredLighting()
 					}
 
 
-					LLVector3 center = drawablep->getPositionAgent();
-					F32* c = center.mV;
+					LLVector4a center;
+					center.load3(drawablep->getPositionAgent().mV);
+					const F32* c = center.getF32();
 					F32 s = volume->getLightRadius()*1.5f;
 
 					LLColor3 col = volume->getLightColor();
@@ -6787,7 +6996,9 @@ void LLPipeline::renderDeferredLighting()
 						continue;
 					}
 
-					if (camera->AABBInFrustumNoFarClip(center, LLVector3(s,s,s)) == 0)
+					LLVector4a sa;
+					sa.splat(s);
+					if (camera->AABBInFrustumNoFarClip(center, sa) == 0)
 					{
 						continue;
 					}
@@ -6865,8 +7076,9 @@ void LLPipeline::renderDeferredLighting()
 
 					LLVOVolume* volume = drawablep->getVOVolume();
 
-					LLVector3 center = drawablep->getPositionAgent();
-					F32* c = center.mV;
+					LLVector4a center;
+					center.load3(drawablep->getPositionAgent().mV);
+					const F32* c = center.getF32();
 					F32 s = volume->getLightRadius()*1.5f;
 
 					sVisibleLightCount++;
@@ -8952,7 +9164,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 
 	stateSort(*LLViewerCamera::getInstance(), result);
 	
-	const LLVector3* ext = avatar->mDrawable->getSpatialExtents();
+	const LLVector4a* ext = avatar->mDrawable->getSpatialExtents();
 	LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset());
 
 	LLCamera camera = *viewer_camera;
@@ -8961,18 +9173,23 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	
 	LLVector2 tdim;
 
-	LLVector3 half_height = (ext[1]-ext[0])*0.5f;
 
-	LLVector3 left = camera.getLeftAxis();
-	left *= left;
-	left.normalize();
+	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();
 
-	LLVector3 up = camera.getUpAxis();
-	up *= up;
-	up.normalize();
+	LLVector4a up;
+	up.load3(camera.getUpAxis().mV);
+	up.mul(up);
+	up.normalize3fast();
 
-	tdim.mV[0] = fabsf(half_height * left);
-	tdim.mV[1] = fabsf(half_height * up);
+	tdim.mV[0] = fabsf(half_height.dot3(left));
+	tdim.mV[1] = fabsf(half_height.dot3(up));
 
 	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index c9384f5ba22..52f943cd1d1 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -217,6 +217,7 @@ class LLPipeline
 
 	//calculate pixel area of given box from vantage point of given camera
 	static F32 calcPixelArea(LLVector3 center, LLVector3 size, LLCamera& camera);
+	static F32 calcPixelArea(const LLVector4a& center, const LLVector4a& size, LLCamera &camera);
 
 	void stateSort(LLCamera& camera, LLCullResult& result);
 	void stateSort(LLSpatialGroup* group, LLCamera& camera);
@@ -229,6 +230,14 @@ class LLPipeline
 	void renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture);
 
 	void grabReferences(LLCullResult& result);
+	void clearReferences();
+
+	//check references will assert that there are no references in sCullResult to the provided data
+	void checkReferences(LLFace* face);
+	void checkReferences(LLDrawable* drawable);
+	void checkReferences(LLDrawInfo* draw_info);
+	void checkReferences(LLSpatialGroup* group);
+
 
 	void renderGeom(LLCamera& camera, BOOL forceVBOUpdate = FALSE);
 	void renderGeomDeferred(LLCamera& camera);
-- 
GitLab


From a4ce5c9eaa0d69ff7acf5fb710f0b9a601fb2a75 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 4 Jun 2010 00:09:52 -0500
Subject: [PATCH 470/683] Fix for useVBOs being busted when sEnableVBOs gets
 flipped.

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

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 7f14a8d5ac8..4f2dae0cdf2 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -900,7 +900,7 @@ BOOL LLVertexBuffer::useVBOs() const
 		return FALSE;
 	}
 #endif
-	return sEnableVBOs;
+	return TRUE;
 }
 
 //----------------------------------------------------------------------------
@@ -1317,7 +1317,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 	{		
 		if (mGLBuffer)
 		{
-			if (sEnableVBOs && sVBOActive)
+			if (useVBOs() && sVBOActive)
 			{
 				glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
 				sBindCount++;
@@ -1329,7 +1329,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 				setup = TRUE; // ... or a client memory pointer changed
 			}
 		}
-		if (sEnableVBOs && mGLIndices && sIBOActive)
+		if (useVBOs() && mGLIndices && sIBOActive)
 		{
 			/*if (sMapped)
 			{
-- 
GitLab


From 697e7a3b0c6a6a014bbf4eebc801f15c0af0a235 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 4 Jun 2010 00:09:52 -0500
Subject: [PATCH 471/683] Fix for useVBOs being busted when sEnableVBOs gets
 flipped. (transplanted from 19717602f45950c058c8ddce792d57ef21f67c99)

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

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index ae43915a9d0..4e941387466 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -819,7 +819,7 @@ BOOL LLVertexBuffer::useVBOs() const
 		return FALSE;
 	}
 #endif
-	return sEnableVBOs;
+	return TRUE;
 }
 
 //----------------------------------------------------------------------------
@@ -1183,7 +1183,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 	{		
 		if (mGLBuffer)
 		{
-			if (sEnableVBOs && sVBOActive)
+			if (useVBOs() && sVBOActive)
 			{
 				glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
 				sBindCount++;
@@ -1195,7 +1195,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 				setup = TRUE; // ... or a client memory pointer changed
 			}
 		}
-		if (sEnableVBOs && mGLIndices && sIBOActive)
+		if (useVBOs() && mGLIndices && sIBOActive)
 		{
 			/*if (sMapped)
 			{
-- 
GitLab


From 7db6a5a64d8eacb63b45dc7cc48bdd681f3e19af Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 4 Jun 2010 00:10:05 -0500
Subject: [PATCH 472/683] Disable octree paranoia checks.

---
 indra/llmath/lloctree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index ae2259dba0c..f61ce6ce05d 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -45,7 +45,7 @@
 #define OCT_ERRS LL_WARNS("OctreeErrors")
 #endif
 
-#define LL_OCTREE_PARANOIA_CHECK 1
+#define LL_OCTREE_PARANOIA_CHECK 0
 #if LL_DARWIN
 #define LL_OCTREE_MAX_CAPACITY 32
 #else
-- 
GitLab


From 9a96da9c96bea01ae59e35cd196406904153dbbd Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 4 Jun 2010 00:11:08 -0500
Subject: [PATCH 473/683] Better branch prediction in UI rendering.

---
 indra/llui/llview.cpp | 6 +-----
 indra/llui/llview.h   | 8 ++++----
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 459041f67d7..262ebf7c21e 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -1325,11 +1325,7 @@ void LLView::drawChildren()
 			child_list_reverse_iter_t child = child_iter++;
 			LLView *viewp = *child;
 
-			if (!viewp->getVisible() || !viewp->getRect().isValid())
-			{
-				continue;
-			}
-
+			if (viewp->getVisible() && viewp->getRect().isValid())
 			{
 				// Only draw views that are within the root view
 				localRectToScreen(viewp->getRect(),&screenRect);
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index efae00f0e54..aaa13051613 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -295,7 +295,7 @@ class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElem
 	void 	setAllChildrenEnabled(BOOL b);
 
 	virtual void	setVisible(BOOL visible);
-	BOOL			getVisible() const			{ return mVisible; }
+	const BOOL&		getVisible() const			{ return mVisible; }
 	virtual void	setEnabled(BOOL enabled);
 	BOOL			getEnabled() const			{ return mEnabled; }
 	/// 'available' in this context means 'visible and enabled': in other
@@ -555,11 +555,13 @@ class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElem
 	LLView*		mParentView;
 	child_list_t mChildList;
 
-	std::string	mName;
 	// location in pixels, relative to surrounding structure, bottom,left=0,0
+	BOOL		mVisible;
 	LLRect		mRect;
 	LLRect		mBoundingRect;
+	
 	std::string mLayout;
+	std::string	mName;
 	
 	U32			mReshapeFlags;
 
@@ -581,8 +583,6 @@ class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElem
 	LLRootHandle<LLView> mHandle;
 	BOOL		mLastVisible;
 
-	BOOL		mVisible;
-
 	S32			mNextInsertionOrdinal;
 
 	static LLWindow* sWindow;	// All root views must know about their window.
-- 
GitLab


From 22b62c1a5bf43b498774261a2a6ea43e813a2869 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 4 Jun 2010 00:11:37 -0500
Subject: [PATCH 474/683] Slightly faster position transformations.

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

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index b8407a6f5b0..0b5cf782612 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1546,10 +1546,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		LLMatrix4a mat_vert;
 		mat_vert.loadu(mat_vert_in);
 
-		for (S32 i = 0; i < num_vertices; i++)
+		LLVector4a* src = vf.mPositions;
+		LLVector4a* dst = vertices;
+
+		LLVector4a* end = dst+num_vertices;
+		do
 		{	
-			mat_vert.affineTransform(vf.mPositions[i], vertices[i]);
+			mat_vert.affineTransform(*src++, *dst++);
 		}
+		while(dst < end);
 	}
 		
 	if (rebuild_normal)
-- 
GitLab


From ca1caeb1deedd1b8e59a90223153ca6f05914b95 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 4 Jun 2010 00:11:57 -0500
Subject: [PATCH 475/683] Fix for occlusion culling cypher bits being flipped.

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

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 3cf01383032..05e7bbb6cd2 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -207,20 +207,20 @@ typedef enum
 //gives you a triangle fan index array
 static U8 sOcclusionIndices[] =
 {
-	 // 000
+	 //000
 		b111, b110, b010, b011, b001, b101, b100, b110,
-	//001 
-		b110, b000, b010, b011, b111, b101, b100, b000,
+	 //001 
+		b011, b010, b000, b001, b101, b111, b110, b010,
 	 //010
 		b101, b100, b110, b111, b011, b001, b000, b100,
 	 //011 
-		b100, b010, b110, b111, b101, b001, b000, b010,
-	//100 
-		b011, b010, b000, b001, b101, b111, b110, b010,
+		b001, b000, b100, b101, b111, b011, b010, b000,
+	 //100 
+		b110, b000, b010, b011, b111, b101, b100, b000,
 	 //101 
 		b010, b100, b000, b001, b011, b111, b110, b100,
 	 //110
-		b001, b000, b100, b101, b111, b011, b010, b000,
+		b100, b010, b110, b111, b101, b001, b000, b010,
 	 //111
 		b000, b110, b100, b101, b001, b011, b010, b110,
 };
@@ -2045,6 +2045,8 @@ class LLOctreeSelect : public LLOctreeCull
 
 void drawBox(const LLVector3& c, const LLVector3& r)
 {
+	LLVertexBuffer::unbind();
+
 	gGL.begin(LLRender::TRIANGLE_STRIP);
 	//left front
 	gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,-1))).mV);
-- 
GitLab


From 087b7499082c7f0ae867990a102bc8f90a83471d Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 4 Jun 2010 08:46:00 +0100
Subject: [PATCH 476/683] fix scoping issues for gcc

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

diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index f61ce6ce05d..df779712041 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -640,7 +640,7 @@ class LLOctreeRoot : public LLOctreeNode<T>
 		const LLVector4a& v = data->getPositionGroup();
 
 		LLVector4a val;
-		val.setSub(v, mD[CENTER]);
+		val.setSub(v, BaseType::mD[BaseType::CENTER]);
 		val.setAbs(val);
 		S32 lt = val.lessThan4(MAX_MAG).getComparisonMask() & 0x7;
 
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 72833c019f3..ef1ab570365 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4406,7 +4406,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& en
 				face.createOctree();
 			}
 			
-			LLVector4a* p = (LLVector4a*) face.mPositions;
+			//LLVector4a* p = (LLVector4a*) face.mPositions;
 
 			LLOctreeTriangleRayIntersect intersect(start, dir, &face, &closest_t, intersection, tex_coord, normal, bi_normal);
 			intersect.traverse(face.mOctree);
-- 
GitLab


From dc2f50642bf6c785263d91ca53ec337f3898b990 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 4 Jun 2010 08:54:03 +0100
Subject: [PATCH 477/683] lots of _mm_malloc and _mm_free ->
 ll_aligned_malloc_16 and ll_aligned_free_16

more to come.
---
 indra/llcommon/llmemory.h |  2 +-
 indra/llmath/lloctree.h   |  4 +-
 indra/llmath/llvolume.cpp | 86 +++++++++++++++++++--------------------
 3 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 117268cfe7b..93dd7a7fe3c 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -34,7 +34,7 @@
 
 #include <stdlib.h>
 
-inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free().
+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);
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index df779712041..59828ae5650 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -102,7 +102,7 @@ class LLOctreeNode : public LLTreeNode<T>
 	:	mParent((oct_node*)parent), 
 		mOctant(octant) 
 	{ 
-		mD = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*4, 16);
+		mD = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*4);
 
 		mD[CENTER] = center;
 		mD[SIZE] = size;
@@ -125,7 +125,7 @@ class LLOctreeNode : public LLTreeNode<T>
 			delete getChild(i);
 		} 
 
-		_mm_free(mD);
+		ll_aligned_free_16(mD);
 	}
 
 	inline const BaseType* getParent()	const			{ return mParent; }
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index ef1ab570365..a8684759f3d 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1987,7 +1987,7 @@ BOOL LLVolume::generate()
 
 void LLVolumeFace::VertexData::init()
 {
-	mData = (LLVector4a*) _mm_malloc(32, 16);
+	mData = (LLVector4a*) ll_aligned_malloc_16(32);
 }
 
 LLVolumeFace::VertexData::VertexData()
@@ -2004,7 +2004,7 @@ LLVolumeFace::VertexData::VertexData(const VertexData& rhs)
 
 LLVolumeFace::VertexData::~VertexData()
 {
-	_mm_free(mData);
+	ll_aligned_free_16(mData);
 }
 
 LLVector4a& LLVolumeFace::VertexData::getPosition()
@@ -5196,7 +5196,7 @@ LLVolumeFace::LLVolumeFace() :
 	mWeights(NULL),
 	mOctree(NULL)
 {
-	mExtents = (LLVector4a*) _mm_malloc(48, 16);
+	mExtents = (LLVector4a*) ll_aligned_malloc_16(48);
 	mCenter = mExtents+2;
 }
 
@@ -5217,7 +5217,7 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src)
 	mWeights(NULL),
 	mOctree(NULL)
 { 
-	mExtents = (LLVector4a*) _mm_malloc(48, 16);
+	mExtents = (LLVector4a*) ll_aligned_malloc_16(48);
 	mCenter = mExtents+2;
 	*this = src;
 }
@@ -5264,7 +5264,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 		}
 		else
 		{
-			_mm_free(mBinormals);
+			ll_aligned_free_16(mBinormals);
 			mBinormals = NULL;
 		}
 
@@ -5275,7 +5275,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 		}
 		else
 		{
-			_mm_free(mWeights);
+			ll_aligned_free_16(mWeights);
 			mWeights = NULL;
 		}
 	}
@@ -5295,7 +5295,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 
 LLVolumeFace::~LLVolumeFace()
 {
-	_mm_free(mExtents);
+	ll_aligned_free_16(mExtents);
 	mExtents = NULL;
 
 	freeData();
@@ -5303,17 +5303,17 @@ LLVolumeFace::~LLVolumeFace()
 
 void LLVolumeFace::freeData()
 {
-	_mm_free(mPositions);
+	ll_aligned_free_16(mPositions);
 	mPositions = NULL;
-	_mm_free(mNormals);
+	ll_aligned_free_16(mNormals);
 	mNormals = NULL;
-	_mm_free(mTexCoords);
+	ll_aligned_free_16(mTexCoords);
 	mTexCoords = NULL;
-	_mm_free(mIndices);
+	ll_aligned_free_16(mIndices);
 	mIndices = NULL;
-	_mm_free(mBinormals);
+	ll_aligned_free_16(mBinormals);
 	mBinormals = NULL;
-	_mm_free(mWeights);
+	ll_aligned_free_16(mWeights);
 	mWeights = NULL;
 
 	delete mOctree;
@@ -6082,21 +6082,21 @@ void LLVolumeFace::createBinormals()
 
 void LLVolumeFace::resizeVertices(S32 num_verts)
 {
-	_mm_free(mPositions);
-	_mm_free(mNormals);
-	_mm_free(mBinormals);
-	_mm_free(mTexCoords);
+	ll_aligned_free_16(mPositions);
+	ll_aligned_free_16(mNormals);
+	ll_aligned_free_16(mBinormals);
+	ll_aligned_free_16(mTexCoords);
 
 	mBinormals = NULL;
 
 	if (num_verts)
 	{
-		mPositions = (LLVector4a*) _mm_malloc(num_verts*16, 16);
-		mNormals = (LLVector4a*) _mm_malloc(num_verts*16, 16);
+		mPositions = (LLVector4a*) ll_aligned_malloc_16(num_verts*16);
+		mNormals = (LLVector4a*) ll_aligned_malloc_16(num_verts*16);
 
 		//pad texture coordinate block end to allow for QWORD reads
 		S32 size = ((num_verts*8) + 0xF) & ~0xF;
-		mTexCoords = (LLVector2*) _mm_malloc(size, 16);
+		mTexCoords = (LLVector2*) ll_aligned_malloc_16(size);
 	}
 	else
 	{
@@ -6119,20 +6119,20 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 	S32 new_size = new_verts*16;
 	
 	//positions
-	LLVector4a* dst = (LLVector4a*) _mm_malloc(new_size, 16);
+	LLVector4a* dst = (LLVector4a*) ll_aligned_malloc_16(new_size);
 	if (mPositions)
 	{
 		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mPositions, new_size/4);
-		_mm_free(mPositions);
+		ll_aligned_free_16(mPositions);
 	}
 	mPositions = dst;
 
 	//normals
-	dst = (LLVector4a*) _mm_malloc(new_size, 16);
+	dst = (LLVector4a*) ll_aligned_malloc_16(new_size);
 	if (mNormals)
 	{
 		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mNormals, new_size/4);
-		_mm_free(mNormals);
+		ll_aligned_free_16(mNormals);
 	}
 	mNormals = dst;
 
@@ -6140,16 +6140,16 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 	new_size = ((new_verts*8)+0xF) & ~0xF;
 
 	{
-		LLVector2* dst = (LLVector2*) _mm_malloc(new_size, 16);
+		LLVector2* dst = (LLVector2*) ll_aligned_malloc_16(new_size);
 		if (mTexCoords)
 		{
 			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mTexCoords, new_size/4);
-			_mm_free(mTexCoords);
+			ll_aligned_free_16(mTexCoords);
 		}
 	}
 
 	//just clear binormals
-	_mm_free(mBinormals);
+	ll_aligned_free_16(mBinormals);
 	mBinormals = NULL;
 
 	mPositions[mNumVertices] = pos;
@@ -6161,26 +6161,26 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 
 void LLVolumeFace::allocateBinormals(S32 num_verts)
 {
-	_mm_free(mBinormals);
-	mBinormals = (LLVector4a*) _mm_malloc(num_verts*16, 16);
+	ll_aligned_free_16(mBinormals);
+	mBinormals = (LLVector4a*) ll_aligned_malloc_16(num_verts*16);
 }
 
 void LLVolumeFace::allocateWeights(S32 num_verts)
 {
-	_mm_free(mWeights);
-	mWeights = (LLVector4a*) _mm_malloc(num_verts*16, 16);
+	ll_aligned_free_16(mWeights);
+	mWeights = (LLVector4a*) ll_aligned_malloc_16(num_verts*16);
 }
 
 void LLVolumeFace::resizeIndices(S32 num_indices)
 {
-	_mm_free(mIndices);
+	ll_aligned_free_16(mIndices);
 
 	if (num_indices)
 	{
 		//pad index block end to allow for QWORD reads
 		S32 size = ((num_indices*2) + 0xF) & ~0xF;
 		
-		mIndices = (U16*) _mm_malloc(size,16);	
+		mIndices = (U16*) ll_aligned_malloc_16(size);	
 	}
 	else
 	{
@@ -6198,9 +6198,9 @@ void LLVolumeFace::pushIndex(const U16& idx)
 	S32 old_size = (mNumIndices+0xF) & ~0xF;
 	if (new_size != old_size)
 	{
-		U16* dst = (U16*) _mm_malloc(new_size, 16);
+		U16* dst = (U16*) ll_aligned_malloc_16(new_size);
 		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mIndices, new_size/4);
-		_mm_free(mIndices);
+		ll_aligned_free_16(mIndices);
 		mIndices = dst;
 	}
 	
@@ -6237,17 +6237,17 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	}
 	
 	
-	LLVector4a* new_pos = (LLVector4a*) _mm_malloc(new_count*16, 16);
-	LLVector4a* new_norm = (LLVector4a*) _mm_malloc(new_count*16, 16);
-	LLVector2* new_tc = (LLVector2*) _mm_malloc((new_count*8+0xF) & ~0xF, 16);
+	LLVector4a* new_pos = (LLVector4a*) ll_aligned_malloc_16(new_count*16);
+	LLVector4a* new_norm = (LLVector4a*) ll_aligned_malloc_16(new_count*16);
+	LLVector2* new_tc = (LLVector2*) ll_aligned_malloc_16((new_count*8+0xF) & ~0xF);
 
 	LLVector4a::memcpyNonAliased16((F32*) new_pos, (F32*) mPositions, new_count*4);
 	LLVector4a::memcpyNonAliased16((F32*) new_norm, (F32*) mNormals, new_count*4);
 	LLVector4a::memcpyNonAliased16((F32*) new_tc, (F32*) mTexCoords, new_count*2);
 
-	_mm_free(mPositions);
-	_mm_free(mNormals);
-	_mm_free(mTexCoords);
+	ll_aligned_free_16(mPositions);
+	ll_aligned_free_16(mNormals);
+	ll_aligned_free_16(mTexCoords);
 
 	mPositions = new_pos;
 	mNormals = new_norm;
@@ -6287,9 +6287,9 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 
 
 	new_count = mNumIndices + face.mNumIndices;
-	U16* new_indices = (U16*) _mm_malloc((new_count*2+0xF) & ~0xF, 16);
+	U16* new_indices = (U16*) ll_aligned_malloc_16((new_count*2+0xF) & ~0xF);
 	LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, new_count/2);
-	_mm_free(mIndices);
+	ll_aligned_free_16(mIndices);
 	mIndices = new_indices;
 	mNumIndices = new_count;
 
-- 
GitLab


From f40d07512ab54ba3da38c8a8b92cf0c6d1469bc6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 4 Jun 2010 09:04:36 +0100
Subject: [PATCH 478/683] finish conversion to ll_aligned_*() wrappers

---
 indra/llcommon/llmemory.h            | 30 ++++++++++++++++++++++++----
 indra/llrender/llrender.cpp          |  8 ++++----
 indra/llrender/llvertexbuffer.cpp    | 16 +++++++--------
 indra/newview/lldrawable.cpp         |  4 ++--
 indra/newview/llface.cpp             |  4 ++--
 indra/newview/llspatialpartition.cpp | 14 ++++++-------
 6 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 93dd7a7fe3c..1c8c91f57e2 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -43,13 +43,9 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi
 #else
 	void *rtn;
 	if (LL_LIKELY(0 == posix_memalign(&rtn, 16, size)))
-	{
 		return rtn;
-	}
 	else // bad alignment requested, or out of memory
-	{
 		return NULL;
-	}
 #endif
 }
 
@@ -64,6 +60,32 @@ inline void ll_aligned_free_16(void *p)
 #endif
 }
 
+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);
+#elif defined(LL_DARWIN)
+# error implement me.
+#else
+	void *rtn;
+	if (LL_LIKELY(0 == posix_memalign(&rtn, 32, size)))
+		return rtn;
+	else // bad alignment requested, or out of memory
+		return NULL;
+#endif
+}
+
+inline void ll_aligned_free_32(void *p)
+{
+#if defined(LL_WINDOWS)
+	_mm_free(p);
+#elif defined(LL_DARWIN)
+# error implement me.
+#else
+	free(p); // posix_memalign() is compatible with heap deallocator
+#endif
+}
+
 class LL_COMMON_API LLMemory
 {
 public:
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 3f70ccacb10..70601663e65 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -777,8 +777,8 @@ LLRender::LLRender()
 	mTexcoordsp = tc.get();
 	mColorsp = color.get();
 
-	mUIOffset = (LLVector4a*) _mm_malloc(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a), 16);
-	mUIScale = (LLVector4a*) _mm_malloc(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a), 16);
+	mUIOffset = (LLVector4a*) ll_aligned_malloc_16(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a));
+	mUIScale = (LLVector4a*) ll_aligned_malloc_16(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a));
 		
 	mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);
 	for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++)
@@ -816,9 +816,9 @@ void LLRender::shutdown()
 	delete mDummyTexUnit;
 	mDummyTexUnit = NULL;
 
-	_mm_free(mUIOffset);
+	ll_aligned_free_16(mUIOffset);
 	mUIOffset = NULL;
-	_mm_free(mUIScale);
+	ll_aligned_free_16(mUIScale);
 	mUIScale = NULL;
 }
 
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 4f2dae0cdf2..ff966f1e95e 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -627,7 +627,7 @@ void LLVertexBuffer::createGLBuffer()
 	{
 		static int gl_buffer_idx = 0;
 		mGLBuffer = ++gl_buffer_idx;
-		mMappedData = (U8*) _mm_malloc(size, 16);
+		mMappedData = (U8*) ll_aligned_malloc_16(size);
 		memset(mMappedData, 0, size);
 	}
 }
@@ -662,7 +662,7 @@ void LLVertexBuffer::createGLIndices()
 	}
 	else
 	{
-		mMappedIndexData = (U8*) _mm_malloc(size, 16);
+		mMappedIndexData = (U8*) ll_aligned_malloc_16(size);
 		static int gl_buffer_idx = 0;
 		mGLIndices = ++gl_buffer_idx;
 	}
@@ -683,7 +683,7 @@ void LLVertexBuffer::destroyGLBuffer()
 		}
 		else
 		{
-			_mm_free(mMappedData);
+			ll_aligned_free_16(mMappedData);
 			mMappedData = NULL;
 			mEmpty = TRUE;
 		}
@@ -710,7 +710,7 @@ void LLVertexBuffer::destroyGLIndices()
 		}
 		else
 		{
-			_mm_free(mMappedIndexData);
+			ll_aligned_free_16(mMappedIndexData);
 			mMappedIndexData = NULL;
 			mEmpty = TRUE;
 		}
@@ -846,8 +846,8 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
 			{
 				if (!useVBOs())
 				{
-					_mm_free(mMappedData);
-					mMappedData = (U8*) _mm_malloc(newsize, 16);
+					ll_aligned_free_16(mMappedData);
+					mMappedData = (U8*) ll_aligned_malloc_16(newsize);
 				}
 				mResized = TRUE;
 			}
@@ -867,8 +867,8 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
 			{
 				if (!useVBOs())
 				{
-					_mm_free(mMappedIndexData);
-					mMappedIndexData = (U8*) _mm_malloc(new_index_size, 16);
+					ll_aligned_free_16(mMappedIndexData);
+					mMappedIndexData = (U8*) ll_aligned_malloc_16(new_index_size);
 				}
 				mResized = TRUE;
 			}
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 04e433dcfd8..96ec51300f8 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -95,7 +95,7 @@ void LLDrawable::incrementVisible()
 
 void LLDrawable::init()
 {
-	mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*3, 32);
+	mExtents = (LLVector4a*) ll_aligned_malloc_32(sizeof(LLVector4a)*3, 32);
 	mPositionGroup = mExtents + 2;
 
 	// mXform
@@ -150,7 +150,7 @@ void LLDrawable::destroy()
 		llinfos << "- Zombie drawables: " << sNumZombieDrawables << llendl;
 	}*/	
 
-	_mm_free(mExtents);
+	ll_aligned_free_32(mExtents);
 	mExtents = mPositionGroup = NULL;
 }
 
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 0b5cf782612..9b5a1eb07cb 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -152,7 +152,7 @@ void cylindricalProjection(LLVector2 &tc, const LLVector4a& normal, const LLVect
 
 void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
 {
-	mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*2, 16);
+	mExtents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*2);
 
 	mLastUpdateTime = gFrameTimeSeconds;
 	mLastMoveTime = 0.f;
@@ -269,7 +269,7 @@ void LLFace::destroy()
 		mVObjp = NULL;
 	}
 
-	_mm_free(mExtents);
+	ll_aligned_free_16(mExtents);
 	mExtents = NULL;
 }
 
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 05e7bbb6cd2..e5d0e064c6d 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -239,7 +239,7 @@ void LLSpatialGroup::buildOcclusion()
 {
 	if (!mOcclusionVerts)
 	{
-		mOcclusionVerts = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*8, 16);
+		mOcclusionVerts = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*8);
 	}
 
 	LLVector4a fudge;
@@ -342,13 +342,13 @@ LLSpatialGroup::~LLSpatialGroup()
 		sQueryPool.release(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
 	}
 
-	_mm_free(mOcclusionVerts);
+	ll_aligned_free_16(mOcclusionVerts);
 
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 	clearDrawMap();
 	clearAtlasList() ;
 
-	_mm_free(mBounds);
+	ll_aligned_free_16(mBounds);
 }
 
 BOOL LLSpatialGroup::hasAtlas(LLTextureAtlas* atlasp)
@@ -1163,7 +1163,7 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
 	sNodeCount++;
 	LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
 
-	mBounds = (LLVector4a*) _mm_malloc(sizeof(LLVector4a) * V4_COUNT, 16);
+	mBounds = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a) * V4_COUNT);
 	mExtents = mBounds + EXTENTS;
 	mObjectBounds = mBounds + OBJECT_BOUNDS;
 	mObjectExtents = mBounds + OBJECT_EXTENTS;
@@ -1434,7 +1434,7 @@ void LLSpatialGroup::destroyGL()
 		}
 	}
 
-	_mm_free(mOcclusionVerts);
+	ll_aligned_free_16(mOcclusionVerts);
 	mOcclusionVerts = NULL;
 
 	for (LLSpatialGroup::element_iter i = getData().begin(); i != getData().end(); ++i)
@@ -3502,7 +3502,7 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset,
 	mDrawMode(LLRender::TRIANGLES)
 {
 	mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset);
-	mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*2, 16);
+	mExtents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*2);
 
 	mDebugColor = (rand() << 16) + rand();
 }
@@ -3524,7 +3524,7 @@ LLDrawInfo::~LLDrawInfo()
 		gPipeline.checkReferences(this);
 	}
 
-	_mm_free(mExtents);
+	ll_aligned_free_16(mExtents);
 }
 
 void LLDrawInfo::validate()
-- 
GitLab


From 9878c0240450ad3d580d0518762ae0db96c25eff Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 4 Jun 2010 09:07:25 +0100
Subject: [PATCH 479/683] add some #includes for our wrappers

---
 indra/llrender/llrender.h         | 1 +
 indra/llrender/llvertexbuffer.cpp | 1 +
 2 files changed, 2 insertions(+)

diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 2bacf16dc67..11cd95646f4 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -45,6 +45,7 @@
 #include "v4coloru.h"
 #include "llstrider.h"
 #include "llpointer.h"
+#include "llmemory.h"
 #include "llglheaders.h"
 
 class LLVertexBuffer;
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index ff966f1e95e..48c20b09a8d 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -31,6 +31,7 @@
  */
 
 #include "linden_common.h"
+#include "llmemory.h"
 
 #include <boost/static_assert.hpp>
 
-- 
GitLab


From 6ca40c7afbd794b161904b63b88a95273ae80c9c Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 4 Jun 2010 09:10:00 +0100
Subject: [PATCH 480/683] more needed #includes

---
 indra/llmath/llvolume.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index a8684759f3d..ce7e20e9b42 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -31,6 +31,7 @@
  */
 
 #include "linden_common.h"
+#include "llmemory.h"
 #include "llmath.h"
 
 #include <set>
-- 
GitLab


From c13c38e25ea9e754d0bb83bf849eadda94778cc6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 4 Jun 2010 09:24:22 +0100
Subject: [PATCH 481/683] unused vars whine.

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

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 9b5a1eb07cb..dea160ae643 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1328,8 +1328,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 					for (S32 i = 0; i < num_vertices; i++)
 					{	
 						LLVector2 tc(vf.mTexCoords[i]);
-						LLVector4a& norm = vf.mNormals[i];
-						LLVector4a& center = *(vf.mCenter);
+						//LLVector4a& norm = vf.mNormals[i];
+						//LLVector4a& center = *(vf.mCenter);
 
 						LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
 						tmp = tmp * *mTextureMatrix;
-- 
GitLab


From 83aed5b6b7aae32c48abcbd3a6bead6e2b099f7d Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 4 Jun 2010 09:26:23 +0100
Subject: [PATCH 482/683] fix new macro usage.

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

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 96ec51300f8..ca408a309e3 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -95,7 +95,7 @@ void LLDrawable::incrementVisible()
 
 void LLDrawable::init()
 {
-	mExtents = (LLVector4a*) ll_aligned_malloc_32(sizeof(LLVector4a)*3, 32);
+	mExtents = (LLVector4a*) ll_aligned_malloc_32(sizeof(LLVector4a)*3);
 	mPositionGroup = mExtents + 2;
 
 	// mXform
-- 
GitLab


From a8f0e47fd5deee1e45b4126ee43955a7bc68bb5d Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 4 Jun 2010 12:07:55 -0500
Subject: [PATCH 483/683] Normal debug display and fix for bad bump mapping and
 planar texture coordinates.

---
 indra/llmath/llvolume.cpp                     |  2 +
 indra/newview/app_settings/settings.xml       | 13 ++++-
 indra/newview/llspatialpartition.cpp          | 57 ++++++++++++++++++-
 indra/newview/llviewermenu.cpp                |  4 ++
 indra/newview/pipeline.h                      |  1 +
 .../skins/default/xui/en/menu_viewer.xml      | 10 ++++
 6 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 72833c019f3..8cb94759944 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -6076,6 +6076,8 @@ void LLVolumeFace::createBinormals()
 		for (U32 i = 0; i < mNumVertices; i++) 
 		{
 			binorm[i].normalize3fast();
+			//bump map/planar projection code requires normals to be normalized
+			mNormals[i].normalize3fast();
 		}
 	}
 }
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 9b7cc041204..a95100d9baf 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6280,7 +6280,18 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>RenderDebugPipeline</key>
+  <key>RenderDebugNormalScale</key>
+  <map>
+    <key>Comment</key>
+    <string>Scale of normals in debug display.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>0.03</real>
+  </map>
+  <key>RenderDebugPipeline</key>
     <map>
       <key>Comment</key>
       <string>Enable strict pipeline debugging.</string>
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 05e7bbb6cd2..77d36b1c2e7 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2704,7 +2704,56 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE)
 	{
 		drawBoxOutline(pos,size);
 	}
-	
+}
+
+void renderNormals(LLDrawable* drawablep)
+{
+	LLVertexBuffer::unbind();
+
+	LLVOVolume* vol = drawablep->getVOVolume();
+	if (vol)
+	{
+		LLVolume* volume = vol->getVolume();
+		gGL.pushMatrix();
+		glMultMatrixf((F32*) vol->getRelativeXform().mMatrix);
+		
+		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
+		LLVector4a scale(gSavedSettings.getF32("RenderDebugNormalScale"));
+
+		for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i)
+		{
+			const LLVolumeFace& face = volume->getVolumeFace(i);
+
+			gGL.begin(LLRender::LINES);
+			
+			for (S32 j = 0; j < face.mNumVertices; ++j)
+			{
+				LLVector4a n,p;
+				
+				n.setMul(face.mNormals[j], scale);
+				p.setAdd(face.mPositions[j], n);
+				
+				gGL.color4f(1,1,1,1);
+				gGL.vertex3fv(face.mPositions[j].getF32());
+				gGL.vertex3fv(p.getF32());
+				
+				if (face.mBinormals)
+				{
+					n.setMul(face.mBinormals[j], scale);
+					p.setAdd(face.mPositions[j], n);
+				
+					gGL.color4f(0,1,1,1);
+					gGL.vertex3fv(face.mPositions[j].getF32());
+					gGL.vertex3fv(p.getF32());
+				}	
+			}
+
+			gGL.end();
+		}
+
+		gGL.popMatrix();
+	}
 }
 
 void renderTexturePriority(LLDrawable* drawable)
@@ -3081,6 +3130,11 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 			{
 				renderBoundingBox(drawable);			
 			}
+
+			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_NORMALS))
+			{
+				renderNormals(drawable);
+			}
 			
 			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BUILD_QUEUE))
 			{
@@ -3280,6 +3334,7 @@ void LLSpatialPartition::renderDebug()
 									  LLPipeline::RENDER_DEBUG_LIGHTS |
 									  LLPipeline::RENDER_DEBUG_BATCH_SIZE |
 									  LLPipeline::RENDER_DEBUG_BBOXES |
+									  LLPipeline::RENDER_DEBUG_NORMALS |
 									  LLPipeline::RENDER_DEBUG_POINTS |
 									  LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY |
 									  LLPipeline::RENDER_DEBUG_TEXTURE_ANIM |
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index b63ef921ac1..eb2ee94af31 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -857,6 +857,10 @@ U32 info_display_from_string(std::string info_display)
 	{
 		return LLPipeline::RENDER_DEBUG_BBOXES;
 	}
+	else if ("normals" == info_display)
+	{
+		return LLPipeline::RENDER_DEBUG_NORMALS;
+	}
 	else if ("points" == info_display)
 	{
 		return LLPipeline::RENDER_DEBUG_POINTS;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 52f943cd1d1..4e8760947ce 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -440,6 +440,7 @@ class LLPipeline
 		RENDER_DEBUG_AVATAR_VOLUME      = 0x0100000,
 		RENDER_DEBUG_BUILD_QUEUE		= 0x0200000,
 		RENDER_DEBUG_AGENT_TARGET       = 0x0400000,
+		RENDER_DEBUG_NORMALS	        = 0x0800000,
 	};
 
 public:
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index bdc171ea529..9cc1a481f58 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -1925,6 +1925,16 @@
          function="Advanced.ToggleInfoDisplay"
          parameter="bboxes" />
         </menu_item_check>
+        <menu_item_check
+         label="Normals"
+         name="Normals">
+          <menu_item_check.on_check
+           function="Advanced.CheckInfoDisplay"
+           parameter="normals" />
+          <menu_item_check.on_click
+           function="Advanced.ToggleInfoDisplay"
+           parameter="normals" />
+        </menu_item_check>
         <menu_item_check
          label="Octree"
          name="Octree">
-- 
GitLab


From 84e619a6dc9e5a5967c4ce035ac530a4588f72a5 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 7 Jun 2010 13:43:30 -0500
Subject: [PATCH 484/683] Fix for bad shadow frustum calculation.

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

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index d0e3a1428f0..bda59f49d1f 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2195,7 +2195,7 @@ BOOL LLSpatialPartition::getVisibleExtents(LLCamera& camera, LLVector3& visMin,
 	vis.traverse(mOctree);
 
 	visMin.set(visMina.getF32());
-	visMax.set(visMina.getF32());
+	visMax.set(visMaxa.getF32());
 	return vis.mEmpty;
 }
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 01027e5be6e..dcf9f52f258 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3883,6 +3883,8 @@ void LLPipeline::renderDebug()
 
 	if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA))
 	{
+		LLVertexBuffer::unbind();
+
 		LLGLEnable blend(GL_BLEND);
 		LLGLDepthTest depth(TRUE, FALSE);
 		LLGLDisable cull(GL_CULL_FACE);
@@ -3946,7 +3948,7 @@ void LLPipeline::renderDebug()
 			if (i < 4)
 			{
 
-				if (i == 0 || !mShadowFrustPoints[i].empty())
+				//if (i == 0 || !mShadowFrustPoints[i].empty())
 				{
 					//render visible point cloud
 					gGL.flush();
-- 
GitLab


From 48809cb3a9350a0357a0fc710140e2437f3e068e Mon Sep 17 00:00:00 2001
From: Leyla Farazha <leyla@lindenlab.com>
Date: Mon, 7 Jun 2010 16:01:10 -0700
Subject: [PATCH 485/683] Merge

---
 indra/newview/llvoicevivox.cpp | 1082 +++-----------------------------
 1 file changed, 78 insertions(+), 1004 deletions(-)

diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 2e003dd2b82..d6028b78cbe 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -2,25 +2,31 @@
  * @file LLVivoxVoiceClient.cpp
  * @brief Implementation of LLVivoxVoiceClient class which is the interface to the voice client process.
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2010, Linden Research, Inc.
  * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -54,7 +60,6 @@
 #include "llviewerparcelmgr.h"
 //#include "llfirstuse.h"
 #include "llspeakers.h"
-#include "lltrans.h"
 #include "llviewerwindow.h"
 #include "llviewercamera.h"
 
@@ -62,11 +67,15 @@
 #include "llviewernetwork.h"
 #include "llnotificationsutil.h"
 
-#include "stringize.h"
-
 // for base64 decoding
 #include "apr_base64.h"
 
+// for SHA1 hash
+#include "apr_sha1.h"
+
+// for MD5 hash
+#include "llmd5.h"
+
 #define USE_SESSION_GROUPS 0
 
 const F32 VOLUME_SCALE_VIVOX = 0.01f;
@@ -91,15 +100,14 @@ const int MAX_LOGIN_RETRIES = 12;
 // blocked is VERY rare and it's better to sacrifice response time in this situation for the sake of stability.
 const int MAX_NORMAL_JOINING_SPATIAL_NUM = 50;
 
-// How often to check for expired voice fonts in seconds
-const F32 VOICE_FONT_EXPIRY_INTERVAL = 10.f;
-// Time of day at which Vivox expires voice font subscriptions.
-// Used to replace the time portion of received expiry timestamps.
-static const std::string VOICE_FONT_EXPIRY_TIME = "T05:00:00Z";
-
-// Maximum length of capture buffer recordings in seconds.
-const F32 CAPTURE_BUFFER_MAX_TIME = 10.f;
 
+static void setUUIDFromStringHash(LLUUID &uuid, const std::string &str)
+{
+	LLMD5 md5_uuid;
+	md5_uuid.update((const unsigned char*)str.data(), str.size());
+	md5_uuid.finalize();
+	md5_uuid.raw_digest(uuid.mData);
+}
 
 static int scale_mic_volume(float volume)
 {
@@ -317,7 +325,6 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() :
 	mBuddyListMapPopulated(false),
 	mBlockRulesListReceived(false),
 	mAutoAcceptRulesListReceived(false),
-
 	mCaptureDeviceDirty(false),
 	mRenderDeviceDirty(false),
 	mSpatialCoordsDirty(false),
@@ -341,17 +348,10 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() :
 	mVoiceEnabled(false),
 	mWriteInProgress(false),
 
-	mLipSyncEnabled(false),
+	mLipSyncEnabled(false)
+
 
-	mVoiceFontsReceived(false),
-	mVoiceFontsNew(false),
-	mVoiceFontListDirty(false),
 
-	mCaptureBufferMode(false),
-	mCaptureBufferRecording(false),
-	mCaptureBufferRecorded(false),
-	mCaptureBufferPlaying(false),
-	mPlayRequestCount(0)
 {	
 	mSpeakerVolume = scale_speaker_volume(0);
 
@@ -396,16 +396,19 @@ void LLVivoxVoiceClient::init(LLPumpIO *pump)
 
 void LLVivoxVoiceClient::terminate()
 {
-	if(mConnected)
-	{
-		logout();
-		connectorShutdown();
-		closeSocket();		// Need to do this now -- bad things happen if the destructor does it later.	
-	}
-	else
-	{
-		killGateway();
-	}
+
+//	leaveAudioSession();
+	logout();
+	// As of SDK version 4885, this should no longer be necessary.  It will linger after the socket close if it needs to.
+	// ms_sleep(2000);
+	connectorShutdown();
+	closeSocket();		// Need to do this now -- bad things happen if the destructor does it later.
+	
+	// This will do unpleasant things on windows.
+//	killGateway();
+	
+
+
 }
 
 const LLVoiceVersionInfo& LLVivoxVoiceClient::getVersion()
@@ -651,11 +654,6 @@ std::string LLVivoxVoiceClient::state2string(LLVivoxVoiceClient::state inState)
 		CASE(stateMicTuningStart);
 		CASE(stateMicTuningRunning);
 		CASE(stateMicTuningStop);
-		CASE(stateCaptureBufferPaused);
-		CASE(stateCaptureBufferRecStart);
-		CASE(stateCaptureBufferRecording);
-		CASE(stateCaptureBufferPlayStart);
-		CASE(stateCaptureBufferPlaying);
 		CASE(stateConnectorStart);
 		CASE(stateConnectorStarting);
 		CASE(stateConnectorStarted);
@@ -664,8 +662,6 @@ std::string LLVivoxVoiceClient::state2string(LLVivoxVoiceClient::state inState)
 		CASE(stateNeedsLogin);
 		CASE(stateLoggingIn);
 		CASE(stateLoggedIn);
-		CASE(stateVoiceFontsWait);
-		CASE(stateVoiceFontsReceived);
 		CASE(stateCreatingSessionGroup);
 		CASE(stateNoChannel);
 		CASE(stateJoiningSession);
@@ -779,10 +775,8 @@ void LLVivoxVoiceClient::stateMachine()
 			// Clean up and reset everything. 
 			closeSocket();
 			deleteAllSessions();
-			deleteAllBuddies();
-			deleteAllVoiceFonts();
-			deleteVoiceFontTemplates();
-
+			deleteAllBuddies();		
+			
 			mConnectorHandle.clear();
 			mAccountHandle.clear();
 			mAccountPassword.clear();
@@ -1132,97 +1126,8 @@ void LLVivoxVoiceClient::stateMachine()
 			
 		}
 		break;
-
-		//MARK: stateCaptureBufferPaused
-		case stateCaptureBufferPaused:
-			if (!mCaptureBufferMode)
-			{
-				// Leaving capture mode.
-
-				mCaptureBufferRecording = false;
-				mCaptureBufferRecorded = false;
-				mCaptureBufferPlaying = false;
-
-				// Return to stateNoChannel to trigger reconnection to a channel.
-				setState(stateNoChannel);
-			}
-			else if (mCaptureBufferRecording)
-			{
-				setState(stateCaptureBufferRecStart);
-			}
-			else if (mCaptureBufferPlaying)
-			{
-				setState(stateCaptureBufferPlayStart);
-			}
-		break;
-
-		//MARK: stateCaptureBufferRecStart
-		case stateCaptureBufferRecStart:
-			captureBufferRecordStartSendMessage();
-
-			// Flag that something is recorded to allow playback.
-			mCaptureBufferRecorded = true;
-
-			// Start the timer, recording will be stopped when it expires.
-			mCaptureTimer.start();
-			mCaptureTimer.setTimerExpirySec(CAPTURE_BUFFER_MAX_TIME);
-
-			// Update UI, should really use a separate callback.
-			notifyVoiceFontObservers();
-
-			setState(stateCaptureBufferRecording);
-		break;
-
-		//MARK: stateCaptureBufferRecording
-		case stateCaptureBufferRecording:
-			if (!mCaptureBufferMode || !mCaptureBufferRecording ||
-				mCaptureBufferPlaying || mCaptureTimer.hasExpired())
-			{
-				// Stop recording
-				captureBufferRecordStopSendMessage();
-				mCaptureBufferRecording = false;
-
-				// Update UI, should really use a separate callback.
-				notifyVoiceFontObservers();
-
-				setState(stateCaptureBufferPaused);
-			}
-		break;
-
-		//MARK: stateCaptureBufferPlayStart
-		case stateCaptureBufferPlayStart:
-			captureBufferPlayStartSendMessage(mPreviewVoiceFont);
-
-			// Store the voice font being previewed, so that we know to restart if it changes.
-			mPreviewVoiceFontLast = mPreviewVoiceFont;
-
-			// Update UI, should really use a separate callback.
-			notifyVoiceFontObservers();
-
-			setState(stateCaptureBufferPlaying);
-		break;
-
-		//MARK: stateCaptureBufferPlaying
-		case stateCaptureBufferPlaying:
-			if (mCaptureBufferPlaying && mPreviewVoiceFont != mPreviewVoiceFontLast)
-			{
-				// If the preview voice font changes, restart playing with the new font.
-				setState(stateCaptureBufferPlayStart);
-			}
-			else if (!mCaptureBufferMode || !mCaptureBufferPlaying || mCaptureBufferRecording)
-			{
-				// Stop playing.
-				captureBufferPlayStopSendMessage();
-				mCaptureBufferPlaying = false;
-
-				// Update UI, should really use a separate callback.
-				notifyVoiceFontObservers();
-
-				setState(stateCaptureBufferPaused);
-			}
-		break;
-
-			//MARK: stateConnectorStart
+												
+		//MARK: stateConnectorStart
 		case stateConnectorStart:
 			if(!mVoiceEnabled)
 			{
@@ -1317,18 +1222,6 @@ void LLVivoxVoiceClient::stateMachine()
 
 			notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_LOGGED_IN);
 
-			if (LLVoiceClient::instance().getVoiceEffectEnabled())
-			{
-				// Request the set of available voice fonts.
-				setState(stateVoiceFontsWait);
-				refreshVoiceEffectLists(true);
-			}
-			else
-			{
-				// If voice effects are disabled, pretend we've received them and carry on.
-				setState(stateVoiceFontsReceived);
-			}
-
 			// request the current set of block rules (we'll need them when updating the friends list)
 			accountListBlockRulesSendMessage();
 			
@@ -1360,25 +1253,12 @@ void LLVivoxVoiceClient::stateMachine()
 					writeString(stream.str());
 				}
 			}
-		break;
-
-		//MARK: stateVoiceFontsWait
-		case stateVoiceFontsWait:		// Await voice font list
-			// accountGetSessionFontsResponse() will transition from here to
-			// stateVoiceFontsReceived, to ensure we have the voice font list
-			// before attempting to create a session.
-		break;
 			
-		//MARK: stateVoiceFontsReceived
-		case stateVoiceFontsReceived:	// Voice font list received
-			// Set up the timer to check for expiring voice fonts
-			mVoiceFontExpiryTimer.start();
-			mVoiceFontExpiryTimer.setTimerExpirySec(VOICE_FONT_EXPIRY_INTERVAL);
-
 #if USE_SESSION_GROUPS			
 			// create the main session group
-			setState(stateCreatingSessionGroup);
 			sessionGroupCreateSendMessage();
+			
+			setState(stateCreatingSessionGroup);
 #else
 			// Not using session groups -- skip the stateCreatingSessionGroup state.
 			setState(stateNoChannel);
@@ -1426,10 +1306,6 @@ void LLVivoxVoiceClient::stateMachine()
 				mTuningExitState = stateNoChannel;
 				setState(stateMicTuningStart);
 			}
-			else if(mCaptureBufferMode)
-			{
-				setState(stateCaptureBufferPaused);
-			}
 			else if(sessionNeedsRelog(mNextAudioSession))
 			{
 				requestRelog();
@@ -1440,7 +1316,6 @@ void LLVivoxVoiceClient::stateMachine()
 				sessionState *oldSession = mAudioSession;
 
 				mAudioSession = mNextAudioSession;
-				mAudioSessionChanged = true;
 				if(!mAudioSession->mReconnect)	
 				{
 					mNextAudioSession = NULL;
@@ -1603,13 +1478,6 @@ void LLVivoxVoiceClient::stateMachine()
 					enforceTether();
 				}
 				
-				// Do notifications for expiring Voice Fonts.
-				if (mVoiceFontExpiryTimer.hasExpired())
-				{
-					expireVoiceFonts();
-					mVoiceFontExpiryTimer.setTimerExpirySec(VOICE_FONT_EXPIRY_INTERVAL);
-				}
-
 				// Send an update only if the ptt or mute state has changed (which shouldn't be able to happen that often
 				// -- the user can only click so fast) or every 10hz, whichever is sooner.
 				// Sending for every volume update causes an excessive flood of messages whenever a volume slider is dragged.
@@ -1679,8 +1547,6 @@ void LLVivoxVoiceClient::stateMachine()
 			mAccountHandle.clear();
 			deleteAllSessions();
 			deleteAllBuddies();
-			deleteAllVoiceFonts();
-			deleteVoiceFontTemplates();
 
 			if(mVoiceEnabled && !mRelogRequested)
 			{
@@ -1761,15 +1627,15 @@ void LLVivoxVoiceClient::stateMachine()
 
 	}
 	
-	if (mAudioSessionChanged)
+	if(mAudioSession && mAudioSession->mParticipantsChanged)
 	{
-		mAudioSessionChanged = false;
-		notifyParticipantObservers();
-		notifyVoiceFontObservers();
+		mAudioSession->mParticipantsChanged = false;
+		mAudioSessionChanged = true;
 	}
-	else if (mAudioSession && mAudioSession->mParticipantsChanged)
+	
+	if(mAudioSessionChanged)
 	{
-		mAudioSession->mParticipantsChanged = false;
+		mAudioSessionChanged = false;
 		notifyParticipantObservers();
 	}
 }
@@ -1885,11 +1751,8 @@ void LLVivoxVoiceClient::sessionGroupCreateSendMessage()
 
 void LLVivoxVoiceClient::sessionCreateSendMessage(sessionState *session, bool startAudio, bool startText)
 {
-	LL_DEBUGS("Voice") << "Requesting create: " << session->mSIPURI << LL_ENDL;
-
-	S32 font_index = getVoiceFontIndex(session->mVoiceFontID);
-	LL_DEBUGS("Voice") << "With voice font: " << session->mVoiceFontID << " (" << font_index << ")" << LL_ENDL;
-
+	LL_DEBUGS("Voice") << "requesting create: " << session->mSIPURI << LL_ENDL;
+	
 	session->mCreateInProgress = true;
 	if(startAudio)
 	{
@@ -1913,11 +1776,10 @@ void LLVivoxVoiceClient::sessionCreateSendMessage(sessionState *session, bool st
 			<< "<Password>" << LLURI::escape(session->mHash, allowed_chars) << "</Password>"
 			<< "<PasswordHashAlgorithm>SHA1UserName</PasswordHashAlgorithm>";
 	}
-
+	
 	stream
 		<< "<ConnectAudio>" << (startAudio?"true":"false") << "</ConnectAudio>"
 		<< "<ConnectText>" << (startText?"true":"false") << "</ConnectText>"
-		<< "<VoiceFontID>" << font_index << "</VoiceFontID>"
 		<< "<Name>" << mChannelName << "</Name>"
 	<< "</Request>\n\n\n";
 	writeString(stream.str());
@@ -1925,11 +1787,8 @@ void LLVivoxVoiceClient::sessionCreateSendMessage(sessionState *session, bool st
 
 void LLVivoxVoiceClient::sessionGroupAddSessionSendMessage(sessionState *session, bool startAudio, bool startText)
 {
-	LL_DEBUGS("Voice") << "Requesting create: " << session->mSIPURI << LL_ENDL;
-
-	S32 font_index = getVoiceFontIndex(session->mVoiceFontID);
-	LL_DEBUGS("Voice") << "With voice font: " << session->mVoiceFontID << " (" << font_index << ")" << LL_ENDL;
-
+	LL_DEBUGS("Voice") << "requesting create: " << session->mSIPURI << LL_ENDL;
+	
 	session->mCreateInProgress = true;
 	if(startAudio)
 	{
@@ -1955,7 +1814,6 @@ void LLVivoxVoiceClient::sessionGroupAddSessionSendMessage(sessionState *session
 		<< "<Name>" << mChannelName << "</Name>"
 		<< "<ConnectAudio>" << (startAudio?"true":"false") << "</ConnectAudio>"
 		<< "<ConnectText>" << (startText?"true":"false") << "</ConnectText>"
-		<< "<VoiceFontID>" << font_index << "</VoiceFontID>"
 		<< "<Password>" << password << "</Password>"
 		<< "<PasswordHashAlgorithm>SHA1UserName</PasswordHashAlgorithm>"
 	<< "</Request>\n\n\n"
@@ -1966,10 +1824,7 @@ void LLVivoxVoiceClient::sessionGroupAddSessionSendMessage(sessionState *session
 
 void LLVivoxVoiceClient::sessionMediaConnectSendMessage(sessionState *session)
 {
-	LL_DEBUGS("Voice") << "Connecting audio to session handle: " << session->mHandle << LL_ENDL;
-
-	S32 font_index = getVoiceFontIndex(session->mVoiceFontID);
-	LL_DEBUGS("Voice") << "With voice font: " << session->mVoiceFontID << " (" << font_index << ")" << LL_ENDL;
+	LL_DEBUGS("Voice") << "connecting audio to session handle: " << session->mHandle << LL_ENDL;
 
 	session->mMediaConnectInProgress = true;
 	
@@ -1979,7 +1834,6 @@ void LLVivoxVoiceClient::sessionMediaConnectSendMessage(sessionState *session)
 	<< "<Request requestId=\"" << session->mHandle << "\" action=\"Session.MediaConnect.1\">"
 		<< "<SessionGroupHandle>" << session->mGroupHandle << "</SessionGroupHandle>"
 		<< "<SessionHandle>" << session->mHandle << "</SessionHandle>"
-		<< "<VoiceFontID>" << font_index << "</VoiceFontID>"
 		<< "<Media>Audio</Media>"
 	<< "</Request>\n\n\n";
 
@@ -3302,7 +3156,7 @@ void LLVivoxVoiceClient::sessionAddedEvent(
 			else
 			{
 				LL_INFOS("Voice") << "Could not generate caller id from uri, using hash of uri " << session->mSIPURI << LL_ENDL;
-				session->mCallerID.generate(session->mSIPURI);
+				setUUIDFromStringHash(session->mCallerID, session->mSIPURI);
 				session->mSynthesizedCallerID = true;
 				
 				// Can't look up the name in this case -- we have to extract it from the URI.
@@ -3580,26 +3434,6 @@ void LLVivoxVoiceClient::accountLoginStateChangeEvent(
 	}
 }
 
-void LLVivoxVoiceClient::mediaCompletionEvent(std::string &sessionGroupHandle, std::string &mediaCompletionType)
-{
-	if (mediaCompletionType == "AuxBufferAudioCapture")
-	{
-		mCaptureBufferRecording = false;
-	}
-	else if (mediaCompletionType == "AuxBufferAudioRender")
-	{
-		// Ignore all but the last stop event
-		if (--mPlayRequestCount <= 0)
-		{
-			mCaptureBufferPlaying = false;
-		}
-	}
-	else
-	{
-		LL_DEBUGS("Voice") << "Unknown MediaCompletionType: " << mediaCompletionType << LL_ENDL;
-	}
-}
-
 void LLVivoxVoiceClient::mediaStreamUpdatedEvent(
 	std::string &sessionHandle, 
 	std::string &sessionGroupHandle, 
@@ -4308,8 +4142,8 @@ LLVivoxVoiceClient::participantState *LLVivoxVoiceClient::sessionState::addParti
 			else
 			{
 				// Create a UUID by hashing the URI, but do NOT set mAvatarIDValid.
-				// This indicates that the ID will not be in the name cache.
-				result->mAvatarID.generate(uri);
+				// This tells code in LLVivoxVoiceClient that the ID will not be in the name cache.
+				setUUIDFromStringHash(result->mAvatarID, uri);
 			}
 		}
 
@@ -4804,7 +4638,7 @@ BOOL LLVivoxVoiceClient::isOnlineSIP(const LLUUID &id)
 	return result;
 }
 
-bool LLVivoxVoiceClient::isVoiceWorking() const
+bool LLVivoxVoiceClient::isVoiceWorking()
 {
   //Added stateSessionTerminated state to avoid problems with call in parcels with disabled voice (EXT-4758)
   // Condition with joining spatial num was added to take into account possible problems with connection to voice
@@ -5826,12 +5660,7 @@ LLVivoxVoiceClient::sessionState *LLVivoxVoiceClient::addSession(const std::stri
 		result = new sessionState();
 		result->mSIPURI = uri;
 		result->mHandle = handle;
-
-		if (LLVoiceClient::instance().getVoiceEffectEnabled())
-		{
-			result->mVoiceFontID = LLVoiceClient::instance().getVoiceEffectDefault();
-		}
-
+		
 		mSessions.insert(result);
 
 		if(!result->mHandle.empty())
@@ -6256,8 +6085,8 @@ void LLVivoxVoiceClient::notifyParticipantObservers()
 		)
 	{
 		LLVoiceClientParticipantObserver* observer = *it;
-		observer->onParticipantsChanged();
-		// In case onParticipantsChanged() deleted an entry.
+		observer->onChange();
+		// In case onChange() deleted an entry.
 		it = mParticipantObservers.upper_bound(observer);
 	}
 }
@@ -6420,660 +6249,6 @@ void LLVivoxVoiceClient::avatarNameResolved(const LLUUID &id, const std::string
 	}
 }
 
-bool LLVivoxVoiceClient::setVoiceEffect(const LLUUID& id)
-{
-	if (!mAudioSession)
-	{
-		return false;
-	}
-
-	if (!id.isNull())
-	{
-		if (mVoiceFontMap.empty())
-		{
-			LL_DEBUGS("Voice") << "Voice fonts not available." << LL_ENDL;
-			return false;
-		}
-		else if (mVoiceFontMap.find(id) == mVoiceFontMap.end())
-		{
-			LL_DEBUGS("Voice") << "Invalid voice font " << id << LL_ENDL;
-			return false;
-		}
-	}
-
-	// *TODO: Check for expired fonts?
-	mAudioSession->mVoiceFontID = id;
-
-	// *TODO: Separate voice font defaults for spatial chat and IM?
-	gSavedPerAccountSettings.setString("VoiceEffectDefault", id.asString());
-
-	sessionSetVoiceFontSendMessage(mAudioSession);
-	notifyVoiceFontObservers();
-
-	return true;
-}
-
-const LLUUID LLVivoxVoiceClient::getVoiceEffect()
-{
-	return mAudioSession ? mAudioSession->mVoiceFontID : LLUUID::null;
-}
-
-LLSD LLVivoxVoiceClient::getVoiceEffectProperties(const LLUUID& id)
-{
-	LLSD sd;
-
-	voice_font_map_t::iterator iter = mVoiceFontMap.find(id);
-	if (iter != mVoiceFontMap.end())
-	{
-		sd["template_only"] = false;
-	}
-	else
-	{
-		// Voice effect is not in the voice font map, see if there is a template
-		iter = mVoiceFontTemplateMap.find(id);
-		if (iter == mVoiceFontTemplateMap.end())
-		{
-			LL_WARNS("Voice") << "Voice effect " << id << "not found." << LL_ENDL;
-			return sd;
-		}
-		sd["template_only"] = true;
-	}
-
-	voiceFontEntry *font = iter->second;
-	sd["name"] = font->mName;
-	sd["expiry_date"] = font->mExpirationDate;
-	sd["is_new"] = font->mIsNew;
-
-	return sd;
-}
-
-LLVivoxVoiceClient::voiceFontEntry::voiceFontEntry(LLUUID& id) :
-	mID(id),
-	mFontIndex(0),
-	mFontType(VOICE_FONT_TYPE_NONE),
-	mFontStatus(VOICE_FONT_STATUS_NONE),
-	mIsNew(false)
-{
-	mExpiryTimer.stop();
-	mExpiryWarningTimer.stop();
-}
-
-LLVivoxVoiceClient::voiceFontEntry::~voiceFontEntry()
-{
-}
-
-void LLVivoxVoiceClient::refreshVoiceEffectLists(bool clear_lists)
-{
-	if (clear_lists)
-	{
-		mVoiceFontsReceived = false;
-		deleteAllVoiceFonts();
-		deleteVoiceFontTemplates();
-	}
-
-	accountGetSessionFontsSendMessage();
-	accountGetTemplateFontsSendMessage();
-}
-
-const voice_effect_list_t& LLVivoxVoiceClient::getVoiceEffectList() const
-{
-	return mVoiceFontList;
-}
-
-const voice_effect_list_t& LLVivoxVoiceClient::getVoiceEffectTemplateList() const
-{
-	return mVoiceFontTemplateList;
-}
-
-void LLVivoxVoiceClient::addVoiceFont(const S32 font_index,
-								 const std::string &name,
-								 const std::string &description,
-								 const LLDate &expiration_date,
-								 bool has_expired,
-								 const S32 font_type,
-								 const S32 font_status,
-								 const bool template_font)
-{
-	// Vivox SessionFontIDs are not guaranteed to remain the same between
-	// sessions or grids so use a UUID for the name.
-
-	// If received name is not a UUID, fudge one by hashing the name and type.
-	LLUUID font_id;
-	if (LLUUID::validate(name))
-	{
-		font_id = LLUUID(name);
-	}
-	else
-	{
-		font_id.generate(STRINGIZE(font_type << ":" << name));
-	}
-
-	voiceFontEntry *font = NULL;
-
-	voice_font_map_t& font_map = template_font ? mVoiceFontTemplateMap : mVoiceFontMap;
-	voice_effect_list_t& font_list = template_font ? mVoiceFontTemplateList : mVoiceFontList;
-
-	// Check whether we've seen this font before.
-	voice_font_map_t::iterator iter = font_map.find(font_id);
-	bool new_font = (iter == font_map.end());
-
-	// Override the has_expired flag if we have passed the expiration_date as a double check.
-	if (expiration_date.secondsSinceEpoch() < (LLDate::now().secondsSinceEpoch() + VOICE_FONT_EXPIRY_INTERVAL))
-	{
-		has_expired = true;
-	}
-
-	if (has_expired)
-	{
-		LL_DEBUGS("Voice") << "Expired " << (template_font ? "Template " : "")
-		<< expiration_date.asString() << " " << font_id
-		<< " (" << font_index << ") " << name << LL_ENDL;
-
-		// Remove existing session fonts that have expired since we last saw them.
-		if (!new_font && !template_font)
-		{
-			deleteVoiceFont(font_id);
-		}
-		return;
-	}
-
-	if (new_font)
-	{
-		// If it is a new font create a new entry.
-		font = new voiceFontEntry(font_id);
-	}
-	else
-	{
-		// Not a new font, update the existing entry
-		font = iter->second;
-	}
-
-	if (font)
-	{
-		font->mFontIndex = font_index;
-		// Use the description for the human readable name if available, as the
-		// "name" may be a UUID.
-		font->mName = description.empty() ? name : description;
-		font->mFontType = font_type;
-		font->mFontStatus = font_status;
-
-		// If the font is new or the expiration date has changed the expiry timers need updating.
-		if (!template_font && (new_font || font->mExpirationDate != expiration_date))
-		{
-			font->mExpirationDate = expiration_date;
-
-			// Set the expiry timer to trigger a notification when the voice font can no longer be used.
-			font->mExpiryTimer.start();
-			font->mExpiryTimer.setExpiryAt(expiration_date.secondsSinceEpoch() - VOICE_FONT_EXPIRY_INTERVAL);
-
-			// Set the warning timer to some interval before actual expiry.
-			S32 warning_time = gSavedSettings.getS32("VoiceEffectExpiryWarningTime");
-			if (warning_time != 0)
-			{
-				font->mExpiryWarningTimer.start();
-				F64 expiry_time = (expiration_date.secondsSinceEpoch() - (F64)warning_time);
-				font->mExpiryWarningTimer.setExpiryAt(expiry_time - VOICE_FONT_EXPIRY_INTERVAL);
-			}
-			else
-			{
-				// Disable the warning timer.
-				font->mExpiryWarningTimer.stop();
-			}
-
-			 // Only flag new session fonts after the first time we have fetched the list.
-			if (mVoiceFontsReceived)
-			{
-				font->mIsNew = true;
-				mVoiceFontsNew = true;
-			}
-		}
-
-		LL_DEBUGS("Voice") << (template_font ? "Template " : "")
-			<< font->mExpirationDate.asString() << " " << font->mID
-			<< " (" << font->mFontIndex << ") " << name << LL_ENDL;
-
-		if (new_font)
-		{
-			font_map.insert(voice_font_map_t::value_type(font->mID, font));
-			font_list.insert(voice_effect_list_t::value_type(font->mName, font->mID));
-		}
-
-		mVoiceFontListDirty = true;
-
-		// Debugging stuff
-
-		if (font_type < VOICE_FONT_TYPE_NONE || font_type >= VOICE_FONT_TYPE_UNKNOWN)
-		{
-			LL_DEBUGS("Voice") << "Unknown voice font type: " << font_type << LL_ENDL;
-		}
-		if (font_status < VOICE_FONT_STATUS_NONE || font_status >= VOICE_FONT_STATUS_UNKNOWN)
-		{
-			LL_DEBUGS("Voice") << "Unknown voice font status: " << font_status << LL_ENDL;
-		}
-	}
-}
-
-void LLVivoxVoiceClient::expireVoiceFonts()
-{
-	// *TODO: If we are selling voice fonts in packs, there are probably
-	// going to be a number of fonts with the same expiration time, so would
-	// be more efficient to just keep a list of expiration times rather
-	// than checking each font individually.
-
-	bool have_expired = false;
-	bool will_expire = false;
-	bool expired_in_use = false;
-
-	LLUUID current_effect = LLVoiceClient::instance().getVoiceEffectDefault();
-
-	voice_font_map_t::iterator iter;
-	for (iter = mVoiceFontMap.begin(); iter != mVoiceFontMap.end(); ++iter)
-	{
-		voiceFontEntry* voice_font = iter->second;
-		LLFrameTimer& expiry_timer  = voice_font->mExpiryTimer;
-		LLFrameTimer& warning_timer = voice_font->mExpiryWarningTimer;
-
-		// Check for expired voice fonts
-		if (expiry_timer.getStarted() && expiry_timer.hasExpired())
-		{
-			// Check whether it is the active voice font
-			if (voice_font->mID == current_effect)
-			{
-				// Reset to no voice effect.
-				setVoiceEffect(LLUUID::null);
-				expired_in_use = true;
-			}
-
-			LL_DEBUGS("Voice") << "Voice Font " << voice_font->mName << " has expired." << LL_ENDL;
-			deleteVoiceFont(voice_font->mID);
-			have_expired = true;
-		}
-
-		// Check for voice fonts that will expire in less that the warning time
-		if (warning_timer.getStarted() && warning_timer.hasExpired())
-		{
-			LL_DEBUGS("Voice") << "Voice Font " << voice_font->mName << " will expire soon." << LL_ENDL;
-			will_expire = true;
-			warning_timer.stop();
-		}
-	}
-
-	LLSD args;
-	args["URL"] = LLTrans::getString("voice_morphing_url");
-
-	// Give a notification if any voice fonts have expired.
-	if (have_expired)
-	{
-		if (expired_in_use)
-		{
-			LLNotificationsUtil::add("VoiceEffectsExpiredInUse", args);
-		}
-		else
-		{
-			LLNotificationsUtil::add("VoiceEffectsExpired", args);
-		}
-
-		// Refresh voice font lists in the UI.
-		notifyVoiceFontObservers();
-	}
-
-	// Give a warning notification if any voice fonts are due to expire.
-	if (will_expire)
-	{
-		S32 seconds = gSavedSettings.getS32("VoiceEffectExpiryWarningTime");
-		args["INTERVAL"] = llformat("%d", seconds / SEC_PER_DAY);
-
-		LLNotificationsUtil::add("VoiceEffectsWillExpire", args);
-	}
-}
-
-void LLVivoxVoiceClient::deleteVoiceFont(const LLUUID& id)
-{
-	// Remove the entry from the voice font list.
-	voice_effect_list_t::iterator list_iter = mVoiceFontList.begin();
-	while (list_iter != mVoiceFontList.end())
-	{
-		if (list_iter->second == id)
-		{
-			LL_DEBUGS("Voice") << "Removing " << id << " from the voice font list." << LL_ENDL;
-			mVoiceFontList.erase(list_iter++);
-			mVoiceFontListDirty = true;
-		}
-		else
-		{
-			++list_iter;
-		}
-	}
-
-	// Find the entry in the voice font map and erase its data.
-	voice_font_map_t::iterator map_iter = mVoiceFontMap.find(id);
-	if (map_iter != mVoiceFontMap.end())
-	{
-		delete map_iter->second;
-	}
-
-	// Remove the entry from the voice font map.
-	mVoiceFontMap.erase(map_iter);
-}
-
-void LLVivoxVoiceClient::deleteAllVoiceFonts()
-{
-	mVoiceFontList.clear();
-
-	voice_font_map_t::iterator iter;
-	for (iter = mVoiceFontMap.begin(); iter != mVoiceFontMap.end(); ++iter)
-	{
-		delete iter->second;
-	}
-	mVoiceFontMap.clear();
-}
-
-void LLVivoxVoiceClient::deleteVoiceFontTemplates()
-{
-	mVoiceFontTemplateList.clear();
-
-	voice_font_map_t::iterator iter;
-	for (iter = mVoiceFontTemplateMap.begin(); iter != mVoiceFontTemplateMap.end(); ++iter)
-	{
-		delete iter->second;
-	}
-	mVoiceFontTemplateMap.clear();
-}
-
-S32 LLVivoxVoiceClient::getVoiceFontIndex(const LLUUID& id) const
-{
-	S32 result = 0;
-	if (!id.isNull())
-	{
-		voice_font_map_t::const_iterator it = mVoiceFontMap.find(id);
-		if (it != mVoiceFontMap.end())
-		{
-			result = it->second->mFontIndex;
-		}
-		else
-		{
-			LL_DEBUGS("Voice") << "Selected voice font " << id << " is not available." << LL_ENDL;
-		}
-	}
-	return result;
-}
-
-S32 LLVivoxVoiceClient::getVoiceFontTemplateIndex(const LLUUID& id) const
-{
-	S32 result = 0;
-	if (!id.isNull())
-	{
-		voice_font_map_t::const_iterator it = mVoiceFontTemplateMap.find(id);
-		if (it != mVoiceFontTemplateMap.end())
-		{
-			result = it->second->mFontIndex;
-		}
-		else
-		{
-			LL_DEBUGS("Voice") << "Selected voice font template " << id << " is not available." << LL_ENDL;
-		}
-	}
-	return result;
-}
-
-void LLVivoxVoiceClient::accountGetSessionFontsSendMessage()
-{
-	if(!mAccountHandle.empty())
-	{
-		std::ostringstream stream;
-
-		LL_DEBUGS("Voice") << "Requesting voice font list." << LL_ENDL;
-
-		stream
-		<< "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Account.GetSessionFonts.1\">"
-		<< "<AccountHandle>" << mAccountHandle << "</AccountHandle>"
-		<< "</Request>"
-		<< "\n\n\n";
-
-		writeString(stream.str());
-	}
-}
-
-void LLVivoxVoiceClient::accountGetTemplateFontsSendMessage()
-{
-	if(!mAccountHandle.empty())
-	{
-		std::ostringstream stream;
-
-		LL_DEBUGS("Voice") << "Requesting voice font template list." << LL_ENDL;
-
-		stream
-		<< "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Account.GetTemplateFonts.1\">"
-		<< "<AccountHandle>" << mAccountHandle << "</AccountHandle>"
-		<< "</Request>"
-		<< "\n\n\n";
-
-		writeString(stream.str());
-	}
-}
-
-void LLVivoxVoiceClient::sessionSetVoiceFontSendMessage(sessionState *session)
-{
-	S32 font_index = getVoiceFontIndex(session->mVoiceFontID);
-	LL_DEBUGS("Voice") << "Requesting voice font: " << session->mVoiceFontID << " (" << font_index << "), session handle: " << session->mHandle << LL_ENDL;
-
-	std::ostringstream stream;
-
-	stream
-	<< "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Session.SetVoiceFont.1\">"
-	<< "<SessionHandle>" << session->mHandle << "</SessionHandle>"
-	<< "<SessionFontID>" << font_index << "</SessionFontID>"
-	<< "</Request>\n\n\n";
-
-	writeString(stream.str());
-}
-
-void LLVivoxVoiceClient::accountGetSessionFontsResponse(int statusCode, const std::string &statusString)
-{
-	// Voice font list entries were updated via addVoiceFont() during parsing.
-	if(getState() == stateVoiceFontsWait)
-	{
-		setState(stateVoiceFontsReceived);
-	}
-
-	notifyVoiceFontObservers();
-	mVoiceFontsReceived = true;
-}
-
-void LLVivoxVoiceClient::accountGetTemplateFontsResponse(int statusCode, const std::string &statusString)
-{
-	// Voice font list entries were updated via addVoiceFont() during parsing.
-	notifyVoiceFontObservers();
-}
-void LLVivoxVoiceClient::addObserver(LLVoiceEffectObserver* observer)
-{
-	mVoiceFontObservers.insert(observer);
-}
-
-void LLVivoxVoiceClient::removeObserver(LLVoiceEffectObserver* observer)
-{
-	mVoiceFontObservers.erase(observer);
-}
-
-void LLVivoxVoiceClient::notifyVoiceFontObservers()
-{
-	LL_DEBUGS("Voice") << "Notifying voice effect observers. Lists changed: " << mVoiceFontListDirty << LL_ENDL;
-
-	for (voice_font_observer_set_t::iterator it = mVoiceFontObservers.begin();
-		 it != mVoiceFontObservers.end();
-		 )
-	{
-		LLVoiceEffectObserver* observer = *it;
-		observer->onVoiceEffectChanged(mVoiceFontListDirty);
-		// In case onVoiceEffectChanged() deleted an entry.
-		it = mVoiceFontObservers.upper_bound(observer);
-	}
-	mVoiceFontListDirty = false;
-
-	// If new Voice Fonts have been added notify the user.
-	if (mVoiceFontsNew)
-	{
-		if(mVoiceFontsReceived)
-		{
-			LLNotificationsUtil::add("VoiceEffectsNew");
-		}
-		mVoiceFontsNew = false;
-	}
-}
-
-void LLVivoxVoiceClient::enablePreviewBuffer(bool enable)
-{
-	mCaptureBufferMode = enable;
-	if(mCaptureBufferMode && getState() >= stateNoChannel)
-	{
-		LL_DEBUGS("Voice") << "no channel" << LL_ENDL;
-		sessionTerminate();
-	}
-}
-
-void LLVivoxVoiceClient::recordPreviewBuffer()
-{
-	if (!mCaptureBufferMode)
-	{
-		LL_DEBUGS("Voice") << "Not in voice effect preview mode, cannot start recording." << LL_ENDL;
-		mCaptureBufferRecording = false;
-		return;
-	}
-
-	mCaptureBufferRecording = true;
-}
-
-void LLVivoxVoiceClient::playPreviewBuffer(const LLUUID& effect_id)
-{
-	if (!mCaptureBufferMode)
-	{
-		LL_DEBUGS("Voice") << "Not in voice effect preview mode, no buffer to play." << LL_ENDL;
-		mCaptureBufferRecording = false;
-		return;
-	}
-
-	if (!mCaptureBufferRecorded)
-	{
-		// Can't play until we have something recorded!
-		mCaptureBufferPlaying = false;
-		return;
-	}
-
-	mPreviewVoiceFont = effect_id;
-	mCaptureBufferPlaying = true;
-}
-
-void LLVivoxVoiceClient::stopPreviewBuffer()
-{
-	mCaptureBufferRecording = false;
-	mCaptureBufferPlaying = false;
-}
-
-bool LLVivoxVoiceClient::isPreviewRecording()
-{
-	return (mCaptureBufferMode && mCaptureBufferRecording);
-}
-
-bool LLVivoxVoiceClient::isPreviewPlaying()
-{
-	return (mCaptureBufferMode && mCaptureBufferPlaying);
-}
-
-void LLVivoxVoiceClient::captureBufferRecordStartSendMessage()
-{	if(!mAccountHandle.empty())
-	{
-		std::ostringstream stream;
-
-		LL_DEBUGS("Voice") << "Starting audio capture to buffer." << LL_ENDL;
-
-		// Start capture
-		stream
-		<< "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.StartBufferCapture.1\">"
-		<< "</Request>"
-		<< "\n\n\n";
-
-		// Unmute the mic
-		stream << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Connector.MuteLocalMic.1\">"
-			<< "<ConnectorHandle>" << mConnectorHandle << "</ConnectorHandle>"
-			<< "<Value>false</Value>"
-		<< "</Request>\n\n\n";
-
-		// Dirty the PTT state so that it will get reset when we finishing previewing
-		mPTTDirty = true;
-
-		writeString(stream.str());
-	}
-}
-
-void LLVivoxVoiceClient::captureBufferRecordStopSendMessage()
-{
-	if(!mAccountHandle.empty())
-	{
-		std::ostringstream stream;
-
-		LL_DEBUGS("Voice") << "Stopping audio capture to buffer." << LL_ENDL;
-
-		// Mute the mic. PTT state was dirtied at recording start, so will be reset when finished previewing.
-		stream << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Connector.MuteLocalMic.1\">"
-			<< "<ConnectorHandle>" << mConnectorHandle << "</ConnectorHandle>"
-			<< "<Value>true</Value>"
-		<< "</Request>\n\n\n";
-
-		// Stop capture
-		stream
-		<< "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.CaptureAudioStop.1\">"
-			<< "<AccountHandle>" << mAccountHandle << "</AccountHandle>"
-		<< "</Request>"
-		<< "\n\n\n";
-
-		writeString(stream.str());
-	}
-}
-
-void LLVivoxVoiceClient::captureBufferPlayStartSendMessage(const LLUUID& voice_font_id)
-{
-	if(!mAccountHandle.empty())
-	{
-		// Track how may play requests are sent, so we know how many stop events to
-		// expect before play actually stops.
-		++mPlayRequestCount;
-
-		std::ostringstream stream;
-
-		LL_DEBUGS("Voice") << "Starting audio buffer playback." << LL_ENDL;
-
-		S32 font_index = getVoiceFontTemplateIndex(voice_font_id);
-		LL_DEBUGS("Voice") << "With voice font: " << voice_font_id << " (" << font_index << ")" << LL_ENDL;
-
-		stream
-		<< "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.PlayAudioBuffer.1\">"
-			<< "<AccountHandle>" << mAccountHandle << "</AccountHandle>"
-			<< "<TemplateFontID>" << font_index << "</TemplateFontID>"
-			<< "<FontDelta />"
-		<< "</Request>"
-		<< "\n\n\n";
-
-		writeString(stream.str());
-	}
-}
-
-void LLVivoxVoiceClient::captureBufferPlayStopSendMessage()
-{
-	if(!mAccountHandle.empty())
-	{
-		std::ostringstream stream;
-
-		LL_DEBUGS("Voice") << "Stopping audio buffer playback." << LL_ENDL;
-
-		stream
-		<< "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.RenderAudioStop.1\">"
-			<< "<AccountHandle>" << mAccountHandle << "</AccountHandle>"
-		<< "</Request>"
-		<< "\n\n\n";
-
-		writeString(stream.str());
-	}
-}
 
 LLVivoxProtocolParser::LLVivoxProtocolParser()
 {
@@ -7111,13 +6286,6 @@ void LLVivoxProtocolParser::reset()
 	alias.clear();
 	numberOfAliases = 0;
 	applicationString.clear();
-	id = 0;
-	nameString.clear();
-	descriptionString.clear();
-	expirationDate = LLDate();
-	hasExpired = false;
-	fontType = 0;
-	fontStatus = 0;
 }
 
 //virtual 
@@ -7299,30 +6467,7 @@ void LLVivoxProtocolParser::StartTag(const char *tag, const char **attr)
 			{
 				LLVivoxVoiceClient::getInstance()->deleteAllAutoAcceptRules();
 			}
-			else if (!stricmp("SessionFont", tag))
-			{
-				id = 0;
-				nameString.clear();
-				descriptionString.clear();
-				expirationDate = LLDate();
-				hasExpired = false;
-				fontType = 0;
-				fontStatus = 0;
-			}
-			else if (!stricmp("TemplateFont", tag))
-			{
-				id = 0;
-				nameString.clear();
-				descriptionString.clear();
-				expirationDate = LLDate();
-				hasExpired = false;
-				fontType = 0;
-				fontStatus = 0;
-			}
-			else if (!stricmp("MediaCompletionType", tag))
-			{
-				mediaCompletionType.clear();
-			}
+			
 		}
 	}
 	responseDepth++;
@@ -7468,43 +6613,8 @@ void LLVivoxProtocolParser::EndTag(const char *tag)
 			subscriptionHandle = string;
 		else if (!stricmp("SubscriptionType", tag))
 			subscriptionType = string;
-		else if (!stricmp("SessionFont", tag))
-		{
-			LLVivoxVoiceClient::getInstance()->addVoiceFont(id, nameString, descriptionString, expirationDate, hasExpired, fontType, fontStatus, false);
-		}
-		else if (!stricmp("TemplateFont", tag))
-		{
-			LLVivoxVoiceClient::getInstance()->addVoiceFont(id, nameString, descriptionString, expirationDate, hasExpired, fontType, fontStatus, true);
-		}
-		else if (!stricmp("ID", tag))
-		{
-			id = strtol(string.c_str(), NULL, 10);
-		}
-		else if (!stricmp("Description", tag))
-		{
-			descriptionString = string;
-		}
-		else if (!stricmp("ExpirationDate", tag))
-		{
-			expirationDate = expiryTimeStampToLLDate(string);
-		}
-		else if (!stricmp("Expired", tag))
-		{
-			hasExpired = !stricmp(string.c_str(), "1");
-		}
-		else if (!stricmp("Type", tag))
-		{
-			fontType = strtol(string.c_str(), NULL, 10);
-		}
-		else if (!stricmp("Status", tag))
-		{
-			fontStatus = strtol(string.c_str(), NULL, 10);
-		}
-		else if (!stricmp("MediaCompletionType", tag))
-		{
-			mediaCompletionType = string;;
-		}
-
+		
+	
 		textBuffer.clear();
 		accumulateText= false;
 		
@@ -7533,21 +6643,6 @@ void LLVivoxProtocolParser::CharData(const char *buffer, int length)
 
 // --------------------------------------------------------------------------------
 
-LLDate LLVivoxProtocolParser::expiryTimeStampToLLDate(const std::string& vivox_ts)
-{
-	// *HACK: Vivox reports the time incorrectly. LLDate also only parses a
-	// subset of valid ISO 8601 dates (only handles Z, not offsets).
-	// So just use the date portion and fix the time here.
-	std::string time_stamp = vivox_ts.substr(0, 10);
-	time_stamp += VOICE_FONT_EXPIRY_TIME;
-
-	LL_DEBUGS("VivoxProtocolParser") << "Vivox timestamp " << vivox_ts << " modified to: " << time_stamp << LL_ENDL;
-
-	return LLDate(time_stamp);
-}
-
-// --------------------------------------------------------------------------------
-
 void LLVivoxProtocolParser::processResponse(std::string tag)
 {
 	LL_DEBUGS("VivoxProtocolParser") << tag << LL_ENDL;
@@ -7601,17 +6696,7 @@ void LLVivoxProtocolParser::processResponse(std::string tag)
 			 </Event>
 			 */
 			LLVivoxVoiceClient::getInstance()->mediaStreamUpdatedEvent(sessionHandle, sessionGroupHandle, statusCode, statusString, state, incoming);
-		}
-		else if (!stricmp(eventTypeCstr, "MediaCompletionEvent"))
-		{
-			/*
-			<Event type="MediaCompletionEvent">
-			<SessionGroupHandle />
-			<MediaCompletionType>AuxBufferAudioCapture</MediaCompletionType>
-			</Event>
-			*/
-			LLVivoxVoiceClient::getInstance()->mediaCompletionEvent(sessionGroupHandle, mediaCompletionType);
-		}
+		}		
 		else if (!stricmp(eventTypeCstr, "TextStreamUpdatedEvent"))
 		{
 			/*
@@ -7672,9 +6757,6 @@ void LLVivoxProtocolParser::processResponse(std::string tag)
 		}
 		else if (!stricmp(eventTypeCstr, "AuxAudioPropertiesEvent"))
 		{
-			// These are really spammy in tuning mode
-			squelchDebugOutput = true;
-
 			LLVivoxVoiceClient::getInstance()->auxAudioPropertiesEvent(energy);
 		}
 		else if (!stricmp(eventTypeCstr, "BuddyPresenceEvent"))
@@ -7789,14 +6871,6 @@ void LLVivoxProtocolParser::processResponse(std::string tag)
 			// We don't need to process these, but they're so spammy we don't want to log them.
 			squelchDebugOutput = true;
 		}
-		else if (!stricmp(actionCstr, "Account.GetSessionFonts.1"))
-		{
-			LLVivoxVoiceClient::getInstance()->accountGetSessionFontsResponse(statusCode, statusString);
-		}
-		else if (!stricmp(actionCstr, "Account.GetTemplateFonts.1"))
-		{
-			LLVivoxVoiceClient::getInstance()->accountGetTemplateFontsResponse(statusCode, statusString);
-		}
 		/*
 		 else if (!stricmp(actionCstr, "Account.ChannelGetList.1"))
 		 {
-- 
GitLab


From ba454baab38d6e782338156dfbc97f7168710df2 Mon Sep 17 00:00:00 2001
From: Dave Parks <none@none>
Date: Tue, 8 Jun 2010 12:20:32 -0500
Subject: [PATCH 486/683] Lost code.

---
 indra/newview/llinventoryfunctions.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index a4b28ceccb6..74fd331a064 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -682,6 +682,3 @@ void LLOpenFoldersWithSelection::doFolder(LLFolderViewFolder* folder)
 	}
 }
 
-	case LLAssetType::AT_MESH:
-		idx = MESH_ICON_NAME;
-		break;
\ No newline at end of file
-- 
GitLab


From 22102e41cbf4ce9e1c0d069f111849466e297520 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 8 Jun 2010 14:55:19 -0500
Subject: [PATCH 487/683] Merge cleanup.

---
 indra/newview/llinventorybridge.cpp      | 3 +--
 indra/newview/llinventorybridge.h        | 1 -
 indra/newview/llpanelobjectinventory.cpp | 2 +-
 indra/newview/llviewermenufile.cpp       | 1 +
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 8fdb965cf26..78789eb9cea 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -109,7 +109,6 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response
 bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& response);
 void teleport_via_landmark(const LLUUID& asset_id);
 
-	"Inv_Mesh",
 // +=================================================+
 // |        LLInvFVBridge                            |
 // +=================================================+
@@ -918,7 +917,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 			// Only should happen for broken links.
 			new_listener = new LLLinkItemBridge(inventory, root, uuid);
 			break;
-	        case LLAssetType::AT_MESH:
+	    case LLAssetType::AT_MESH:
 			if(!(inv_type == LLInventoryType::IT_MESH))
 			{
 				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index f7a06477a3f..d637fc6e360 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -183,7 +183,6 @@ class LLInventoryFVBridgeBuilder
 										U32 flags = 0x00) const;
 };
 
-	MESH_ICON_NAME,
 class LLItemBridge : public LLInvFVBridge
 {
 public:
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index 0d701516887..898cabb03d6 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -1268,7 +1268,7 @@ LLTaskMeshBridge::LLTaskMeshBridge(
 
 LLUIImagePtr LLTaskMeshBridge::getIcon() const
 {
-	return get_item_icon(LLAssetType::AT_MESH, LLInventoryType::IT_MESH, 0, FALSE);
+	return LLInventoryIcon::getIcon(LLAssetType::AT_MESH, LLInventoryType::IT_MESH, 0, FALSE);
 }
 
 void LLTaskMeshBridge::openItem()
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index e473461622d..dd65ca2d25d 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -66,6 +66,7 @@
 #include "llappviewer.h"
 #include "lluploaddialog.h"
 #include "lltrans.h"
+#include "llfloaterbuycurrency.h"
 #include "llfloaterimportcollada.h"
 
 // linden libraries
-- 
GitLab


From fbe9f07f178cb4b868ff87a5fd370d8ad392d810 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 8 Jun 2010 17:34:38 -0500
Subject: [PATCH 488/683] Merge fix.

---
 indra/newview/llinventorybridge.cpp                    |  2 +-
 .../default/xui/en/panel_preferences_graphics1.xml     | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 78789eb9cea..97d51a9d904 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -4849,7 +4849,7 @@ void LLLinkItemBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 
 LLUIImagePtr LLMeshBridge::getIcon() const
 {
-	return get_item_icon(LLAssetType::AT_MESH, LLInventoryType::IT_MESH, 0, FALSE);
+	return LLInventoryIcon::getIcon(LLAssetType::AT_MESH, LLInventoryType::IT_MESH, 0, FALSE);
 }
 
 void LLMeshBridge::openItem()
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 8b431e9c54c..b54bad98d07 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -160,7 +160,7 @@
      layout="topleft"
      left="5"
      name="CustomGraphics Panel"
-     top="101"
+     top="76"
      width="485">
 		<text
 		type="string"
@@ -397,7 +397,7 @@
 		label="Post process quality:"
 		label_width="185"
 		layout="topleft"
-		left_delta="0"
+		left="200"
 		max_val="9"
 		min_val="8"
 		name="RenderPostProcess"
@@ -542,7 +542,7 @@
         layout="topleft"
         left="469"
         name="PostProcessText"
-        top="328"
+        top="60"
         width="128">
            Low
         </text>
@@ -625,7 +625,7 @@
       follows="left|top"
       height="12"
       layout="topleft"
-      left_delta="-260"
+      left="200"
       name="AvatarRenderingText"
       top_pad="8"
       width="128">
@@ -673,7 +673,7 @@
         left="358"
         left_pad="-30"
         name="TerrainDetailText"
-        top="488"
+        top="226"
         width="155">
            Terrain detail:
         </text>
-- 
GitLab


From f9b13d8f8510b1f7f02fcf92685471461b79858e Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 10 Jun 2010 00:45:48 -0500
Subject: [PATCH 489/683] Add "LL_MESH_ENABLED" preprocessor flag for toggling
 mesh code.  Couple of merge fixes.

---
 indra/llcommon/llassettype.cpp                |  3 +-
 indra/llcommon/llassettype.h                  |  3 +-
 indra/llinventory/llinventorytype.cpp         |  5 +-
 indra/llinventory/llinventorytype.h           |  2 +
 indra/llmath/llvolume.cpp                     | 13 +++--
 indra/llmath/llvolume.h                       |  7 +++
 indra/llrender/llvertexbuffer.cpp             |  4 +-
 indra/llvfs/llvfs.cpp                         |  2 +
 indra/newview/app_settings/settings.xml       |  4 +-
 indra/newview/llappviewer.cpp                 |  4 ++
 indra/newview/llassetuploadresponders.cpp     |  5 ++
 indra/newview/llassetuploadresponders.h       |  3 +-
 indra/newview/lldrawpoolavatar.cpp            | 48 ++++++++++++++++++-
 indra/newview/lldrawpoolavatar.h              | 40 +++++++++-------
 indra/newview/llface.cpp                      |  2 +
 indra/newview/llinventorybridge.cpp           | 10 +++-
 indra/newview/llinventorybridge.h             |  4 +-
 indra/newview/llpanelgroupnotices.cpp         |  2 +
 indra/newview/llpanelobjectinventory.cpp      |  6 +++
 indra/newview/llselectmgr.cpp                 |  2 +
 indra/newview/lltexturectrl.cpp               | 12 ++++-
 indra/newview/lltooldraganddrop.cpp           | 10 ++++
 indra/newview/lltooldraganddrop.h             |  4 ++
 indra/newview/llviewerassettype.cpp           |  2 +
 indra/newview/llviewerfloaterreg.cpp          |  4 ++
 indra/newview/llviewermenufile.cpp            |  9 +++-
 indra/newview/llviewermenufile.h              |  2 +
 indra/newview/llviewertexteditor.cpp          |  2 +
 indra/newview/llviewerwindow.cpp              |  4 ++
 indra/newview/llvovolume.cpp                  | 15 +++++-
 indra/newview/pipeline.cpp                    |  4 ++
 indra/newview/pipeline.h                      | 13 +++--
 .../xui/en/panel_preferences_graphics1.xml    | 10 ++--
 33 files changed, 209 insertions(+), 51 deletions(-)

diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp
index e19f8b0454a..476a23ec644 100644
--- a/indra/llcommon/llassettype.cpp
+++ b/indra/llcommon/llassettype.cpp
@@ -99,8 +99,9 @@ LLAssetDictionary::LLAssetDictionary()
 
 	addEntry(LLAssetType::AT_LINK, 				new AssetEntry("LINK",				"link",		"sym link",			false,		false,		true));
 	addEntry(LLAssetType::AT_LINK_FOLDER, 		new AssetEntry("FOLDER_LINK",		"link_f", 	"sym folder link",	false,		false,		true));
-
+#if LL_MESH_ENABLED
 	addEntry(LLAssetType::AT_MESH,              new AssetEntry("MESH",              "mesh",     "mesh",             false, false, false));
+#endif
 	
 	addEntry(LLAssetType::AT_NONE, 				new AssetEntry("NONE",				"-1",		NULL,		  		FALSE,		FALSE,		FALSE));
 
diff --git a/indra/llcommon/llassettype.h b/indra/llcommon/llassettype.h
index 90cd03c4334..ebc43134cbe 100644
--- a/indra/llcommon/llassettype.h
+++ b/indra/llcommon/llassettype.h
@@ -114,9 +114,10 @@ class LL_COMMON_API LLAssetType
 
 		AT_LINK_FOLDER = 25,
 			// Inventory folder link
-
+#if LL_MESH_ENABLED
 		AT_MESH = 49,
 		    // Mesh data in our proprietary SLM format
+#endif
 
 		AT_COUNT = 50,
 
diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp
index 2d4ee604b0f..82cd22a8322 100644
--- a/indra/llinventory/llinventorytype.cpp
+++ b/indra/llinventory/llinventorytype.cpp
@@ -89,7 +89,9 @@ LLInventoryDictionary::LLInventoryDictionary()
 	addEntry(LLInventoryType::IT_WEARABLE,            new InventoryEntry("wearable",  "wearable",      2, LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART));
 	addEntry(LLInventoryType::IT_ANIMATION,           new InventoryEntry("animation", "animation",     1, LLAssetType::AT_ANIMATION));  
 	addEntry(LLInventoryType::IT_GESTURE,             new InventoryEntry("gesture",   "gesture",       1, LLAssetType::AT_GESTURE)); 
+#if LL_MESH_ENABLED
 	addEntry(LLInventoryType::IT_MESH,                new InventoryEntry("mesh",      "mesh",          1, LLAssetType::AT_MESH));
+#endif
 
 }
 
@@ -150,8 +152,9 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
 	LLInventoryType::IT_NONE,			// AT_NONE
 	LLInventoryType::IT_NONE,			// AT_NONE
 	LLInventoryType::IT_NONE,			// AT_NONE
-	
+#if LL_MESH_ENABLED
 	LLInventoryType::IT_MESH            // AT_MESH
+#endif
 };
 
 // static
diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h
index 37829f5eae1..d2fc67ef645 100644
--- a/indra/llinventory/llinventorytype.h
+++ b/indra/llinventory/llinventorytype.h
@@ -68,7 +68,9 @@ class LLInventoryType
 		IT_ANIMATION = 19,
 		IT_GESTURE = 20,
 
+#if LL_MESH_ENABLED
 		IT_MESH = 22,
+#endif
 		IT_COUNT = 23,
 
 		IT_NONE = -1
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 09ab47b8908..05868e35173 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2546,10 +2546,12 @@ S32	LLVolume::getNumFaces() const
 {
 	U8 sculpt_type = (mParams.getSculptType() & LL_SCULPT_TYPE_MASK);
 
+#if LL_MESH_ENABLED
 	if (sculpt_type == LL_SCULPT_TYPE_MESH)
 	{
 		return LL_SCULPT_MESH_MAX_FACES;
 	}
+#endif
 
 	return (S32)mProfilep->mFaces.size();
 }
@@ -2922,11 +2924,6 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 	LLMemType m1(LLMemType::MTYPE_VOLUME);
     U8 sculpt_type = mParams.getSculptType();
 
-	if (sculpt_type & LL_SCULPT_TYPE_MASK == LL_SCULPT_TYPE_MESH)
-	{
-		llerrs << "WTF?" << llendl;
-	}
-
 	BOOL data_is_empty = FALSE;
 
 	if (sculpt_width == 0 || sculpt_height == 0 || sculpt_components < 3 || sculpt_data == NULL)
@@ -4135,10 +4132,12 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
 	normals.clear();
 	segments.clear();
 
+#if LL_MESH_ENABLED
 	if ((mParams.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 	{
 		return;
 	}
+#endif
 	
 	S32 cur_index = 0;
 	//for each face
@@ -6335,10 +6334,14 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 		resizeVertices(num_vertices);
 		resizeIndices(num_indices);
 
+#if LL_MESH_ENABLED
 		if ((volume->getParams().getSculptType() & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH)
 		{
 			mEdge.resize(num_indices);
 		}
+#else
+		mEdge.resize(num_indices);
+#endif
 	}
 
 	LLVector4a* pos = (LLVector4a*) mPositions;
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index c49d1c650d9..07829440796 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -41,6 +41,8 @@ class LLVolumeParams;
 class LLProfile;
 class LLPath;
 
+#define LL_MESH_ENABLED 0
+
 template <class T> class LLOctreeNode;
 
 class LLVector4a;
@@ -190,10 +192,15 @@ const U8 LL_SCULPT_TYPE_SPHERE    = 1;
 const U8 LL_SCULPT_TYPE_TORUS     = 2;
 const U8 LL_SCULPT_TYPE_PLANE     = 3;
 const U8 LL_SCULPT_TYPE_CYLINDER  = 4;
+#if LL_MESH_ENABLED
 const U8 LL_SCULPT_TYPE_MESH      = 5;
 
 const U8 LL_SCULPT_TYPE_MASK      = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE |
 	LL_SCULPT_TYPE_CYLINDER | LL_SCULPT_TYPE_MESH;
+#else
+const U8 LL_SCULPT_TYPE_MASK      = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE |
+	LL_SCULPT_TYPE_CYLINDER;
+#endif
 
 const U8 LL_SCULPT_FLAG_INVERT    = 64;
 const U8 LL_SCULPT_FLAG_MIRROR    = 128;
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 48c20b09a8d..514ca25aa09 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -1318,7 +1318,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 	{		
 		if (mGLBuffer)
 		{
-			if (useVBOs() && sVBOActive)
+			if (sVBOActive)
 			{
 				glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
 				sBindCount++;
@@ -1330,7 +1330,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 				setup = TRUE; // ... or a client memory pointer changed
 			}
 		}
-		if (useVBOs() && mGLIndices && sIBOActive)
+		if (mGLIndices && sIBOActive)
 		{
 			/*if (sMapped)
 			{
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index ddb76fb2ba1..2b01288fd7b 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -2041,9 +2041,11 @@ std::string get_extension(LLAssetType::EType type)
 	case LLAssetType::AT_ANIMATION:
 		extension = ".lla";
 		break;
+#if LL_MESH_ENABLED
 	case LLAssetType::AT_MESH:
 		extension = ".slm";
 		break;
+#endif
 	default:
 		// Just use the asset server filename extension in most cases
 		extension += ".";
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 79b58bcd7c6..df9393c3166 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4908,7 +4908,7 @@
     <key>Type</key>
     <string>Boolean</string>
     <key>Value</key>
-    <real>1</real>
+    <real>0</real>
   </map>
   <key>MigrateCacheDirectory</key>
     <map>
@@ -6818,7 +6818,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>0.0</real>
+    <real>-0.001</real>
   </map>
   <key>RenderSpotShadowOffset</key>
   <map>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 512b1dde7fe..6978cdf672b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1302,8 +1302,10 @@ bool LLAppViewer::cleanup()
 
 	llinfos << "Cleaning Up" << llendflush;
 
+#if LL_MESH_ENABLED
 	// shut down mesh streamer
 	gMeshRepo.shutdown();
+#endif
 
 	// Must clean up texture references before viewer window is destroyed.
 	LLHUDManager::getInstance()->updateEffects();
@@ -1728,8 +1730,10 @@ bool LLAppViewer::initThreads()
 		mFastTimerLogThread->start();
 	}
 
+#if LL_MESH_ENABLED
 	// Mesh streaming and caching
 	gMeshRepo.init();
+#endif
 
 	LLFilePickerThread::initClass();
 
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index c48dcdb0618..afb76735ecb 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -305,6 +305,7 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)
 {
 }
 
+#if LL_MESH_ENABLED
 LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(
 	const LLSD& post_data,
 	const LLUUID& vfile_id,
@@ -426,6 +427,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 
 	LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE);
 }
+#endif
 
 LLSendTexLayerResponder::LLSendTexLayerResponder(const LLSD& post_data,
 												 const LLUUID& vfile_id,
@@ -675,6 +677,7 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
 }
 
 
+#if LL_MESH_ENABLED
 /////////////////////////////////////////////////////
 // LLNewAgentInventoryVariablePriceResponder::Impl //
 /////////////////////////////////////////////////////
@@ -1142,3 +1145,5 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
 				boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder>(this)));
 	}
 }
+#endif
+
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index af3b3daf468..9abaccfde09 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -61,7 +61,7 @@ class LLAssetUploadResponder : public LLHTTPClient::Responder
 	std::string mFileName;
 };
 
-
+#if LL_MESH_ENABLED
 // TODO*: Remove this once deprecated
 class LLNewAgentInventoryResponder : public LLAssetUploadResponder
 {
@@ -116,6 +116,7 @@ class LLNewAgentInventoryVariablePriceResponder :
 	class Impl;
 	Impl* mImpl;
 };
+#endif
 
 struct LLBakedUploadData;
 class LLSendTexLayerResponder : public LLAssetUploadResponder
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 9268cb1d479..63ca17d62d9 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -103,6 +103,7 @@ S32 normal_channel = -1;
 S32 specular_channel = -1;
 S32 cube_channel = -1;
 
+#if LL_MESH_ENABLED
 static const U32 rigged_data_mask[] = {
 	LLDrawPoolAvatar::RIGGED_SIMPLE_MASK,
 	LLDrawPoolAvatar::RIGGED_FULLBRIGHT_MASK,
@@ -114,6 +115,7 @@ static const U32 rigged_data_mask[] = {
 	LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP_MASK,						 
 	LLDrawPoolAvatar::RIGGED_DEFERRED_SIMPLE_MASK,
 };
+#endif
 
 
 static LLFastTimer::DeclareTimer FTM_SHADOW_AVATAR("Avatar Shadow");
@@ -194,12 +196,14 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
 	case 2:
 		beginDeferredSkinned();
 		break;
+#if LL_MESH_ENABLED
 	case 3:
 		beginDeferredRiggedSimple();
 		break;
 	case 4:
 		beginDeferredRiggedBump();
 		break;
+#endif
 	}
 }
 
@@ -226,12 +230,14 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass)
 	case 2:
 		endDeferredSkinned();
 		break;
+#if LL_MESH_ENABLED
 	case 3:
 		endDeferredRiggedSimple();
 		break;
 	case 4:
 		endDeferredRiggedBump();
 		break;
+#endif
 	}
 }
 
@@ -242,7 +248,11 @@ void LLDrawPoolAvatar::renderDeferred(S32 pass)
 
 S32 LLDrawPoolAvatar::getNumPostDeferredPasses()
 {
+#if LL_MESH_ENABLED
 	return 6;
+#else
+	return 1;
+#endif
 }
 
 void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass)
@@ -252,6 +262,7 @@ void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass)
 	case 0:
 		beginPostDeferredAlpha();
 		break;
+#if LL_MESH_ENABLED
 	case 1:
 		beginRiggedFullbright();
 		break;
@@ -267,6 +278,7 @@ void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass)
 	case 5:
 		beginRiggedGlow();
 		break;
+#endif
 	}
 }
 
@@ -284,6 +296,7 @@ void LLDrawPoolAvatar::beginPostDeferredAlpha()
 	enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
 }
 
+#if LL_MESH_ENABLED
 void LLDrawPoolAvatar::beginDeferredRiggedAlpha()
 {
 	sVertexProgram = &gDeferredSkinnedAlphaProgram;
@@ -301,6 +314,7 @@ void LLDrawPoolAvatar::endDeferredRiggedAlpha()
 	LLVertexBuffer::sWeight4Loc = -1;
 	sVertexProgram = NULL;
 }
+#endif
 
 void LLDrawPoolAvatar::endPostDeferredPass(S32 pass)
 {
@@ -309,6 +323,7 @@ void LLDrawPoolAvatar::endPostDeferredPass(S32 pass)
 	case 0:
 		endPostDeferredAlpha();
 		break;
+#if LL_MESH_ENABLED
 	case 1:
 		endRiggedFullbright();
 		break;
@@ -324,6 +339,7 @@ void LLDrawPoolAvatar::endPostDeferredPass(S32 pass)
 	case 5:
 		endRiggedGlow();
 		break;
+#endif
 	}
 }
 
@@ -357,7 +373,11 @@ void LLDrawPoolAvatar::renderPostDeferred(S32 pass)
 
 S32 LLDrawPoolAvatar::getNumShadowPasses()
 {
+#if LL_MESH_ENABLED
 	return 2;
+#else
+	return 1;
+#endif
 }
 
 void LLDrawPoolAvatar::beginShadowPass(S32 pass)
@@ -448,6 +468,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 
 		avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
 	}
+#if LL_MESH_ENABLED
 	else
 	{
 		renderRigged(avatarp, RIGGED_SIMPLE);
@@ -457,10 +478,12 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 		renderRigged(avatarp, RIGGED_SHINY);
 		renderRigged(avatarp, RIGGED_FULLBRIGHT_ALPHA);
 	}
+#endif
 }
 
 S32 LLDrawPoolAvatar::getNumPasses()
 {
+#if LL_MESH_ENABLED
 	if (LLPipeline::sImpostorRender)
 	{
 		return 8;
@@ -473,8 +496,19 @@ S32 LLDrawPoolAvatar::getNumPasses()
 	{
 		return 3;
 	}
+#else
+	if (LLPipeline::sImpostorRender)
+	{
+		return 1;
+	}
+	else 
+	{
+		return 3;
+	}
+#endif
 }
 
+
 S32 LLDrawPoolAvatar::getNumDeferredPasses()
 {
 	if (LLPipeline::sImpostorRender)
@@ -522,6 +556,7 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 	case 2:
 		beginSkinned();
 		break;
+#if LL_MESH_ENABLED
 	case 3:
 		beginRiggedSimple();
 		break;
@@ -543,6 +578,7 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 	case 9:
 		beginRiggedGlow();
 		break;
+#endif
 	}
 }
 
@@ -566,6 +602,7 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 	case 2:
 		endSkinned();
 		break;
+#if LL_MESH_ENABLED
 	case 3:
 		endRiggedSimple();
 		break;
@@ -587,6 +624,7 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
 	case 9:
 		endRiggedGlow();
 		break;
+#endif
 	}
 }
 
@@ -772,6 +810,7 @@ void LLDrawPoolAvatar::endSkinned()
 	gGL.getTexUnit(0)->activate();
 }
 
+#if LL_MESH_ENABLED
 void LLDrawPoolAvatar::beginRiggedSimple()
 {
 	sVertexProgram = &gSkinnedObjectSimpleProgram;
@@ -924,6 +963,7 @@ void LLDrawPoolAvatar::endDeferredRiggedBump()
 	sDiffuseChannel = 0;
 	sVertexProgram = NULL;
 }
+#endif
 
 void LLDrawPoolAvatar::beginDeferredSkinned()
 {
@@ -1069,6 +1109,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		return;
 	}
 
+#if LL_MESH_ENABLED
 	if (pass == 3)
 	{
 		if (is_deferred_render)
@@ -1150,7 +1191,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		gGL.setSceneBlendType(LLRender::BT_ALPHA);
 		return;
 	}
-
+#endif
 	
 	if (sShaderLevel > 0)
 	{
@@ -1188,6 +1229,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 	}
 }
 
+#if LL_MESH_ENABLED
 void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face)
 {
 	U32 data_mask = 0;
@@ -1377,7 +1419,7 @@ void LLDrawPoolAvatar::renderRiggedGlow(LLVOAvatar* avatar)
 {
 	renderRigged(avatar, RIGGED_GLOW, true);
 }
-
+#endif
 
 
 
@@ -1479,6 +1521,7 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const
 	return LLColor3(0.f, 1.f, 0.f);
 }
 
+#if LL_MESH_ENABLED
 void LLDrawPoolAvatar::addRiggedFace(LLFace* facep, U32 type)
 {
 	if (facep->mRiggedIndex.empty())
@@ -1533,6 +1576,7 @@ void LLDrawPoolAvatar::removeRiggedFace(LLFace* facep)
 		}
 	}
 }
+#endif
 
 LLVertexBufferAvatar::LLVertexBufferAvatar()
 : LLVertexBuffer(sDataMask, 
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index 4a5b0094128..46ffc42f040 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -96,6 +96,23 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginRigid();
 	void beginImpostor();
 	void beginSkinned();
+	
+	void endRigid();
+	void endImpostor();
+	void endSkinned();
+
+	void beginDeferredImpostor();
+	void beginDeferredRigid();
+	void beginDeferredSkinned();
+	
+	void endDeferredImpostor();
+	void endDeferredRigid();
+	void endDeferredSkinned();
+	
+	void beginPostDeferredAlpha();
+	void endPostDeferredAlpha();
+
+#if LL_MESH_ENABLED
 	void beginRiggedSimple();
 	void beginRiggedFullbright();
 	void beginRiggedFullbrightShiny();
@@ -103,12 +120,8 @@ class LLDrawPoolAvatar : public LLFacePool
 	void beginRiggedAlpha();
 	void beginRiggedFullbrightAlpha();
 	void beginRiggedGlow();
-	void beginPostDeferredAlpha();
 	void beginDeferredRiggedAlpha();
 
-	void endRigid();
-	void endImpostor();
-	void endSkinned();
 	void endRiggedSimple();
 	void endRiggedFullbright();
 	void endRiggedFullbrightShiny();
@@ -116,18 +129,11 @@ class LLDrawPoolAvatar : public LLFacePool
 	void endRiggedAlpha();
 	void endRiggedFullbrightAlpha();
 	void endRiggedGlow();
-	void endPostDeferredAlpha();
 	void endDeferredRiggedAlpha();
 
-	void beginDeferredImpostor();
-	void beginDeferredRigid();
-	void beginDeferredSkinned();
 	void beginDeferredRiggedSimple();
 	void beginDeferredRiggedBump();
 	
-	void endDeferredImpostor();
-	void endDeferredRigid();
-	void endDeferredSkinned();
 	void endDeferredRiggedSimple();
 	void endDeferredRiggedBump();
 		
@@ -147,11 +153,6 @@ class LLDrawPoolAvatar : public LLFacePool
 	void renderDeferredRiggedSimple(LLVOAvatar* avatar);
 	void renderDeferredRiggedBump(LLVOAvatar* avatar);
 
-	/*virtual*/ LLViewerTexture *getDebugTexture();
-	/*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display
-
-	void renderAvatars(LLVOAvatar *single_avatar, S32 pass = -1); // renders only one avatar if single_avatar is not null.
-
 	typedef enum
 	{
 		RIGGED_SIMPLE = 0,
@@ -202,6 +203,13 @@ class LLDrawPoolAvatar : public LLFacePool
 	void removeRiggedFace(LLFace* facep); 
 
 	std::vector<LLFace*> mRiggedFace[NUM_RIGGED_PASSES];
+#endif
+
+	/*virtual*/ LLViewerTexture *getDebugTexture();
+	/*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display
+
+	void renderAvatars(LLVOAvatar *single_avatar, S32 pass = -1); // renders only one avatar if single_avatar is not null.
+
 
 	static BOOL sSkipOpaque;
 	static BOOL sSkipTransparent;
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index e4f9e28c775..c48106863ed 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -224,11 +224,13 @@ void LLFace::destroy()
 	{
 		LLFastTimer t(FTM_DESTROY_DRAWPOOL);
 
+#if LL_MESH_ENABLED
 		if (this->isState(LLFace::RIGGED) && mDrawPoolp->getType() == LLDrawPool::POOL_AVATAR)
 		{
 			((LLDrawPoolAvatar*) mDrawPoolp)->removeRiggedFace(this);
 		}
 		else
+#endif
 		{
 			mDrawPoolp->removeFace(this);
 		}
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 78789eb9cea..3999a8ee88b 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -917,6 +917,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 			// Only should happen for broken links.
 			new_listener = new LLLinkItemBridge(inventory, root, uuid);
 			break;
+#if LL_MESH_ENABLED
 	    case LLAssetType::AT_MESH:
 			if(!(inv_type == LLInventoryType::IT_MESH))
 			{
@@ -924,6 +925,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 			}
 			new_listener = new LLMeshBridge(inventory, root, uuid);
 			break;
+#endif
 
 		default:
 			llinfos << "Unhandled asset type (llassetstorage.h): "
@@ -2765,7 +2767,9 @@ BOOL LLFolderBridge::dragOrDrop(MASK mask, BOOL drop,
 		case DAD_ANIMATION:
 		case DAD_GESTURE:
 		case DAD_LINK:
+#if LL_MESH_ENABLED
 		case DAD_MESH:
+#endif
 			accept = dragItemIntoFolder((LLInventoryItem*)cargo_data,
 										drop);
 			break;
@@ -3635,7 +3639,9 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop,
 			case DAD_BODYPART:
 			case DAD_ANIMATION:
 			case DAD_GESTURE:
-		case DAD_MESH:
+#if LL_MESH_ENABLED
+			case DAD_MESH:
+#endif
 			{
 				LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
 				const LLPermissions& perm = inv_item->getPermissions();
@@ -4843,6 +4849,7 @@ void LLLinkItemBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 	hide_context_entries(menu, items, disabled_items);
 }
 
+#if LL_MESH_ENABLED
 // +=================================================+
 // |        LLMeshBridge                             |
 // +=================================================+
@@ -4899,6 +4906,7 @@ void LLMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 	hide_context_entries(menu, items, disabled_items);
 }
 
+#endif
 
 // +=================================================+
 // |        LLLinkBridge                             |
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index d637fc6e360..8de7d631738 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -527,7 +527,7 @@ class LLLinkFolderBridge : public LLItemBridge
 };
 
 
-
+#if LL_MESH_ENABLED
 class LLMeshBridge : public LLItemBridge
 {
 	friend class LLInvFVBridge;
@@ -543,7 +543,7 @@ class LLMeshBridge : public LLItemBridge
 		     const LLUUID& uuid) :
                        LLItemBridge(inventory, root, uuid) {}
 };
-
+#endif
 
 
 
diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp
index 7d82a10ca2d..d8cfd4fc5da 100644
--- a/indra/newview/llpanelgroupnotices.cpp
+++ b/indra/newview/llpanelgroupnotices.cpp
@@ -159,7 +159,9 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 		case DAD_ANIMATION:
 		case DAD_GESTURE:
 		case DAD_CALLINGCARD:
+#if LL_MESH_ENABLED
 		case DAD_MESH:
+#endif
 		{
 			LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
 			if(gInventory.getItem(inv_item->getUUID())
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index 898cabb03d6..58df2746f33 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -819,7 +819,9 @@ BOOL LLTaskCategoryBridge::dragOrDrop(MASK mask, BOOL drop,
 		case DAD_ANIMATION:
 		case DAD_GESTURE:
 		case DAD_CALLINGCARD:
+#if LL_MESH_ENABLED
 		case DAD_MESH:
+#endif
 			accept = LLToolDragAndDrop::isInventoryDropAcceptable(object, (LLViewerInventoryItem*)cargo_data);
 			if(accept && drop)
 			{
@@ -1240,6 +1242,7 @@ LLUIImagePtr LLTaskWearableBridge::getIcon() const
 	return LLInventoryIcon::getIcon(mAssetType, mInventoryType, FALSE, mFlags, FALSE );
 }
 
+#if LL_MESH_ENABLED
 ///----------------------------------------------------------------------------
 /// Class LLTaskMeshBridge
 ///----------------------------------------------------------------------------
@@ -1351,6 +1354,7 @@ void LLTaskMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 	hide_context_entries(menu, items, disabled_items);
 }
 
+#endif
 
 ///----------------------------------------------------------------------------
 /// LLTaskInvFVBridge impl
@@ -1431,11 +1435,13 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory*
 						 object->getUUID(),
 						 object->getName());
 		break;
+#if LL_MESH_ENABLED
 	case LLAssetType::AT_MESH:
 		new_bridge = new LLTaskMeshBridge(panel,
 										  object->getUUID(),
 										  object->getName());
 		break;
+#endif
 	default:
 		llinfos << "Unhandled inventory type (llassetstorage.h): "
 				<< (S32)type << llendl;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index ceef03d2f83..0ce7ffb0776 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -6165,6 +6165,7 @@ S32 LLObjectSelection::getObjectCount(BOOL mesh_adjust)
 	cleanupNodes();
 	S32 count = mList.size();
 
+#if LL_MESH_ENABLED
 	if (mesh_adjust)
 	{
 		for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
@@ -6185,6 +6186,7 @@ S32 LLObjectSelection::getObjectCount(BOOL mesh_adjust)
 
 		}
 	}
+#endif
 
 	return count;
 }
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 7b57f09e594..6088c315596 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -292,7 +292,11 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop(
 {
 	BOOL handled = FALSE;
 
-	if ((cargo_type == DAD_TEXTURE) || (cargo_type == DAD_MESH))
+	bool is_mesh = false;
+#if LL_MESH_ENABLED
+	is_mesh = cargo_type == DAD_MESH;
+#endif
+	if ((cargo_type == DAD_TEXTURE) || is_mesh)
 	{
 		LLInventoryItem *item = (LLInventoryItem *)cargo_data;
 
@@ -1177,8 +1181,12 @@ BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
 	// returns true, then the cast was valid, and we can perform
 	// the third test without problems.
 	LLInventoryItem* item = (LLInventoryItem*)cargo_data; 
+	bool is_mesh = false;
+#if LL_MESH_ENABLED
+	is_mesh = cargo_type == DAD_MESH;
+#endif
 	if (getEnabled() &&
-		((cargo_type == DAD_TEXTURE) || (cargo_type == DAD_MESH)) &&
+		((cargo_type == DAD_TEXTURE) || is_mesh) &&
 		 allowDrop(item))
 	{
 		if (drop)
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 15924d67cfd..d679ccd3d8d 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -331,7 +331,9 @@ LLToolDragAndDrop::LLDragAndDropDictionary::LLDragAndDropDictionary()
 	addEntry(DAD_ANIMATION, 	new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dUpdateInventory,			&LLToolDragAndDrop::dad3dNULL));
 	addEntry(DAD_GESTURE, 		new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dActivateGesture,		&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dUpdateInventory,			&LLToolDragAndDrop::dad3dNULL));
 	addEntry(DAD_LINK, 			new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dNULL,						&LLToolDragAndDrop::dad3dNULL));
+#if LL_MESH_ENABLED
 	addEntry(DAD_MESH, 			new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL,	&LLToolDragAndDrop::dad3dNULL,					&LLToolDragAndDrop::dad3dGiveInventory,		&LLToolDragAndDrop::dad3dMeshObject,			&LLToolDragAndDrop::dad3dNULL));
+#endif
 	// TODO: animation on self could play it?  edit it?
 	// TODO: gesture on self could play it?  edit it?
 };
@@ -1035,6 +1037,7 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
 	hit_obj->sendTEUpdate();
 }
 
+#if LL_MESH_EANBLED
 void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj,
 								 LLInventoryItem* item,
 								 LLToolDragAndDrop::ESource source,
@@ -1059,6 +1062,7 @@ void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj,
 	
 	dialog_refresh_all();
 }
+#endif
 
 /*
 void LLToolDragAndDrop::dropTextureOneFaceAvatar(LLVOAvatar* avatar, S32 hit_face, LLInventoryItem* item)
@@ -1501,7 +1505,9 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_
 	case DAD_ANIMATION:
 	case DAD_GESTURE:
 	case DAD_CALLINGCARD:
+#if LL_MESH_ENABLED
 	case DAD_MESH:
+#endif
 	{
 		LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
 		if(gInventory.getItem(inv_item->getUUID())
@@ -1858,10 +1864,12 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
 				dropTextureOneFace(obj, face, item, mSource, mSourceID);
 			}
 		}
+#if LL_MESH_ENABLED
 		else if (cargo_type == DAD_MESH)
 		{
 			dropMesh(obj, item, mSource, mSourceID);
 		}
+#endif
 		else
 		{
 			llwarns << "unsupported asset type" << llendl;
@@ -1886,11 +1894,13 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject(
 	return dad3dApplyToObject(obj, face, mask, drop, DAD_TEXTURE);
 }
 
+#if LL_MESH_ENABLED
 EAcceptance LLToolDragAndDrop::dad3dMeshObject(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
 	return dad3dApplyToObject(obj, face, mask, drop, DAD_MESH);
 }
+#endif
 
 
 
diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h
index 596cc2ee887..ceeaa8c8209 100644
--- a/indra/newview/lltooldraganddrop.h
+++ b/indra/newview/lltooldraganddrop.h
@@ -154,8 +154,10 @@ class LLToolDragAndDrop : public LLTool, public LLSingleton<LLToolDragAndDrop>
 							   MASK mask, BOOL drop);
 	EAcceptance dad3dTextureObject(LLViewerObject* obj, S32 face,
 								   MASK mask, BOOL drop);
+#if LL_MESH_ENABLED
 	EAcceptance dad3dMeshObject(LLViewerObject* obj, S32 face,
 								   MASK mask, BOOL drop);
+#endif
 //	EAcceptance dad3dTextureSelf(LLViewerObject* obj, S32 face,
 //								 MASK mask, BOOL drop);
 	EAcceptance dad3dWearItem(LLViewerObject* obj, S32 face,
@@ -242,10 +244,12 @@ class LLToolDragAndDrop : public LLTool, public LLSingleton<LLToolDragAndDrop>
 									LLInventoryItem* item,
 									ESource source,
 									const LLUUID& src_id);
+#if LL_MESH_ENABLED
 	static void dropMesh(LLViewerObject* hit_obj,
 						 LLInventoryItem* item,
 						 ESource source,
 						 const LLUUID& src_id);
+#endif
 	
 	//static void	dropTextureOneFaceAvatar(LLVOAvatar* avatar,S32 hit_face,
 	//									 LLInventoryItem* item)
diff --git a/indra/newview/llviewerassettype.cpp b/indra/newview/llviewerassettype.cpp
index 4c088a72b7f..370767002ae 100644
--- a/indra/newview/llviewerassettype.cpp
+++ b/indra/newview/llviewerassettype.cpp
@@ -85,7 +85,9 @@ LLViewerAssetDictionary::LLViewerAssetDictionary()
 	addEntry(LLViewerAssetType::AT_LINK, 				new ViewerAssetEntry(DAD_LINK));
 	addEntry(LLViewerAssetType::AT_LINK_FOLDER, 		new ViewerAssetEntry(DAD_LINK));
 
+#if LL_MESH_ENABLED
 	addEntry(LLViewerAssetType::AT_MESH, 				new ViewerAssetEntry(DAD_MESH));
+#endif
 
 	addEntry(LLViewerAssetType::AT_NONE, 				new ViewerAssetEntry(DAD_NONE));
 };
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 525610f9838..c953fb23e31 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -177,7 +177,9 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("hud", "floater_hud.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHUD>);
 
 	LLFloaterReg::add("impanel", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMFloater>);
+#if LL_MESH_ENABLED
 	LLFloaterReg::add("import_collada", "floater_import_collada.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImportCollada>);
+#endif
 	LLFloaterReg::add("im_container", "floater_im_container.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMFloaterContainer>);
 	LLFloaterReg::add("im_well_window", "floater_sys_well.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMWellWindow>);
 	LLFloaterReg::add("incoming_call", "floater_incoming_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>);
@@ -258,7 +260,9 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("upload_anim", "floater_animation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload");
 	LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
 	LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
+#if LL_MESH_ENABLED
 	LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
+#endif
 
 	LLFloaterReg::add("voice_controls", "floater_voice_controls.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLCallFloater>);
 	LLFloaterReg::add("voice_effect", "floater_voice_effect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceEffect>);
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index dd65ca2d25d..af4549f7e13 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -350,6 +350,7 @@ class LLFileUploadImage : public view_listener_t
 	}
 };
 
+#if LL_MESH_ENABLED
 class LLFileUploadScene : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
@@ -376,6 +377,7 @@ class LLFileUploadModel : public view_listener_t
 		return TRUE;
 	}
 };
+#endif
 	
 class LLFileUploadSound : public view_listener_t
 {
@@ -1144,6 +1146,7 @@ void upload_new_resource(
 	lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type) << llendl;
 	lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl;
 
+#if LL_MESH_ENABLED
 	std::string url = gAgent.getRegion()->getCapability(
 		"NewFileAgentInventory");
 
@@ -1171,8 +1174,8 @@ void upload_new_resource(
 				asset_type));
 	}
 	else
+#endif
 	{
-		llinfos << "NewAgentInventory capability not found, new agent inventory via asset system." << llendl;
 		// check for adequate funds
 		// TODO: do this check on the sim
 		if (LLAssetType::AT_SOUND == asset_type ||
@@ -1217,6 +1220,7 @@ void upload_new_resource(
 	}
 }
 
+#if LL_MESH_ENABLED
 BOOL upload_new_variable_price_resource(
 	const LLTransactionID &tid, 
 	LLAssetType::EType asset_type,
@@ -1288,6 +1292,7 @@ BOOL upload_new_variable_price_resource(
 		return FALSE;
 	}
 }
+#endif
 
 LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid)
 {
@@ -1358,8 +1363,10 @@ void init_menu_file()
 	view_listener_t::addCommit(new LLFileUploadImage(), "File.UploadImage");
 	view_listener_t::addCommit(new LLFileUploadSound(), "File.UploadSound");
 	view_listener_t::addCommit(new LLFileUploadAnim(), "File.UploadAnim");
+#if LL_MESH_ENABLED
 	view_listener_t::addCommit(new LLFileUploadModel(), "File.UploadModel");
 	view_listener_t::addCommit(new LLFileUploadScene(), "File.UploadScene");
+#endif
 	view_listener_t::addCommit(new LLFileUploadBulk(), "File.UploadBulk");
 	view_listener_t::addCommit(new LLFileCloseWindow(), "File.CloseWindow");
 	view_listener_t::addCommit(new LLFileCloseAllWindows(), "File.CloseAllWindows");
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 08444551a9f..bb7cfce8627 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -74,6 +74,7 @@ void upload_new_resource(
 	S32 expected_upload_cost,
 	void *userdata);
 
+#if LL_MESH_ENABLED
 // TODO* : Move all uploads to use this new function
 // since at some point, that upload path will be deprecated and no longer
 // used
@@ -91,6 +92,7 @@ BOOL upload_new_variable_price_resource(
 	U32 everyone_perms,
 	const std::string& display_name,
 	const LLSD& asset_resources);
+#endif
 
 LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid);
 void increase_new_upload_stats(LLAssetType::EType asset_type);
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index d35be8e1bf8..697e8afa65e 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -535,7 +535,9 @@ LLUIImagePtr LLEmbeddedItems::getItemImage(llwchar ext_char) const
 			case LLAssetType::AT_BODYPART:		img_name = "Inv_Skin";		break;
 			case LLAssetType::AT_ANIMATION:		img_name = "Inv_Animation";	break;
 			case LLAssetType::AT_GESTURE:		img_name = "Inv_Gesture";	break;
+#if LL_MESH_ENABLED
 			case LLAssetType::AT_MESH:          img_name = "Inv_Mesh";	    break;
+#endif
 			default: llassert(0);
 		}
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index fc4b590bf4c..9f559331b0f 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -591,8 +591,10 @@ class LLDebugText
 
 		if (gSavedSettings.getBOOL("DebugShowUploadCost"))
 		{
+#if LL_MESH_ENABLED
 			addText(xpos, ypos, llformat("       Meshes: L$%d", gPipeline.mDebugMeshUploadCost));
 			ypos += y_inc/2;
+#endif
 			addText(xpos, ypos, llformat("    Sculpties: L$%d", gPipeline.mDebugSculptUploadCost));
 			ypos += y_inc/2;
 			addText(xpos, ypos, llformat("     Textures: L$%d", gPipeline.mDebugTextureUploadCost));
@@ -602,6 +604,7 @@ class LLDebugText
 			ypos += y_inc;
 		}
 
+#if LL_MESH_ENABLED
 		//temporary hack to give feedback on mesh upload progress
 		if (!gMeshRepo.mUploads.empty())
 		{
@@ -631,6 +634,7 @@ class LLDebugText
 
 			ypos += y_inc;
 		}
+#endif
 	}
 
 	void draw()
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index db9e0b88e18..d66aa567a8c 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -926,6 +926,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 
 	BOOL is404 = FALSE;
 
+#if LL_MESH_ENABLED
 	if (isSculpted())
 	{
 		// if it's a mesh
@@ -945,6 +946,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 			}
 		}
 	}
+#endif
 
 	// Check if we need to change implementations
 	bool is_flexible = (volume_params.getPathParams().getCurveType() == LL_PCODE_PATH_FLEXIBLE);
@@ -989,10 +991,11 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 	
 		updateSculptTexture();
 
+
 		if (isSculpted())
 		{
 			updateSculptTexture();
-
+#if LL_MESH_ENABLED
 			// if it's a mesh
 			if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 			{
@@ -1008,6 +1011,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
 				}
 			}
 			else // otherwise is sculptie
+#endif
 			{
 				if (mSculptTexture.notNull())
 				{
@@ -2659,12 +2663,13 @@ BOOL LLVOVolume::isMesh() const
 	{
 		LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
 		U8 sculpt_type = sculpt_params->getSculptType();
-
+#if LL_MESH_ENABLED
 		if ((sculpt_type & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 			// mesh is a mesh
 		{
 			return TRUE;	
 		}
+#endif
 	}
 
 	return FALSE;
@@ -3010,6 +3015,7 @@ F32 LLVOVolume::getBinRadius()
 	
 	F32 scale = 1.f;
 
+#if LL_MESH_ENABLED
 	if (isSculpted())
 	{
 		LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
@@ -3031,6 +3037,7 @@ F32 LLVOVolume::getBinRadius()
 			scale = 1.f/llmax(vert_count/1024.f, 1.f);
 		}
 	}
+#endif
 
 	const LLVector4a* ext = mDrawable->getSpatialExtents();
 	
@@ -3513,9 +3520,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 		drawablep->clearState(LLDrawable::HAS_ALPHA);
 
+#if LL_MESH_ENABLED
 		bool rigged = vobj->isAttachment() && 
 					vobj->isMesh() && 
 					gMeshRepo.getSkinInfo(vobj->getVolume()->getParams().getSculptID());
+#endif
 
 		bool bake_sunlight = LLPipeline::sBakeSunlight && drawablep->isStatic();
 
@@ -3526,6 +3535,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 			drawablep->updateFaceSize(i);
 			LLFace* facep = drawablep->getFace(i);
 
+#if LL_MESH_ENABLED
 			if (rigged) 
 			{
 				if (!facep->isState(LLFace::RIGGED))
@@ -3622,6 +3632,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 					facep->clearState(LLFace::RIGGED);
 				}
 			}
+#endif
 
 			if (cur_total > max_total || facep->getIndicesCount() <= 0 || facep->getGeomCount() <= 0)
 			{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 583b3df0e54..c5c72772112 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2025,7 +2025,9 @@ void LLPipeline::rebuildPriorityGroups()
 	
 	assertInitialized();
 
+#if LL_MESH_ENABLED
 	gMeshRepo.notifyLoadedMeshes();
+#endif
 
 	// Iterate through all drawables on the priority build queue,
 	for (LLSpatialGroup::sg_list_t::iterator iter = mGroupQ1.begin();
@@ -3859,6 +3861,7 @@ void LLPipeline::renderDebug()
 		gPipeline.mDebugTextureUploadCost = textures.size() * 10;
 		gPipeline.mDebugSculptUploadCost = sculpts.size()*10;
 		
+#if LL_MESH_ENABLED
 		U32 mesh_cost = 0;
 
 		for (std::set<LLUUID>::iterator iter = meshes.begin(); iter != meshes.end(); ++iter)
@@ -3867,6 +3870,7 @@ void LLPipeline::renderDebug()
 		}
 
 		gPipeline.mDebugMeshUploadCost = mesh_cost;
+#endif
 	}
 
 	for (LLCullResult::bridge_list_t::const_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i)
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 4e8760947ce..95f951b393e 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -45,6 +45,7 @@
 #include "llgl.h"
 #include "lldrawable.h"
 #include "llrendertarget.h"
+#include "llmodel.h" //for LL_MESH_ENaBLED
 
 #include <stack>
 
@@ -61,7 +62,10 @@ class LLCullResult;
 class LLVOAvatar;
 class LLGLSLShader;
 class LLCurlRequest;
+
+#if LL_MESH_ENABLED
 class LLMeshResponder;
+#endif
 
 typedef enum e_avatar_skinning_method
 {
@@ -465,7 +469,9 @@ class LLPipeline
 
 	S32						 mDebugTextureUploadCost;
 	S32						 mDebugSculptUploadCost;
+#if LL_MESH_ENABLED
 	S32						 mDebugMeshUploadCost;
+#endif
 
 	S32						 mLightingChanges;
 	S32						 mGeometryChanges;
@@ -712,13 +718,6 @@ class LLPipeline
 protected:
 	std::vector<LLFace*>		mSelectedFaces;
 
-
-	typedef std::map<LLUUID, std::set<LLUUID> > mesh_load_map;
-	mesh_load_map mLoadingMeshes[4];
-	
-	typedef std::list<LLMeshResponder*> mesh_response_list;
-	mesh_response_list			mMeshResponseList;
-
 	LLPointer<LLViewerFetchedTexture>	mFaceSelectImagep;
 	
 	U32						mLightMask;
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 8b431e9c54c..b54bad98d07 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -160,7 +160,7 @@
      layout="topleft"
      left="5"
      name="CustomGraphics Panel"
-     top="101"
+     top="76"
      width="485">
 		<text
 		type="string"
@@ -397,7 +397,7 @@
 		label="Post process quality:"
 		label_width="185"
 		layout="topleft"
-		left_delta="0"
+		left="200"
 		max_val="9"
 		min_val="8"
 		name="RenderPostProcess"
@@ -542,7 +542,7 @@
         layout="topleft"
         left="469"
         name="PostProcessText"
-        top="328"
+        top="60"
         width="128">
            Low
         </text>
@@ -625,7 +625,7 @@
       follows="left|top"
       height="12"
       layout="topleft"
-      left_delta="-260"
+      left="200"
       name="AvatarRenderingText"
       top_pad="8"
       width="128">
@@ -673,7 +673,7 @@
         left="358"
         left_pad="-30"
         name="TerrainDetailText"
-        top="488"
+        top="226"
         width="155">
            Terrain detail:
         </text>
-- 
GitLab


From 9440f84dca48e3e2f6022dbf5f916d6439c7a826 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 10 Jun 2010 14:58:02 -0500
Subject: [PATCH 490/683] Potential fix for busted binormals on cubes.

---
 indra/llmath/llvolume.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 05868e35173..ba5d5e7ca19 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5566,6 +5566,8 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 		corners[0].getPosition(), corners[0].mTexCoord,
 		corners[1].getPosition(), corners[1].mTexCoord,
 		corners[2].getPosition(), corners[2].mTexCoord);
+	
+	binormal.normalize3fast();
 
 	S32 size = (grid_size+1)*(grid_size+1);
 	resizeVertices(size);
-- 
GitLab


From d2d49e3d84956ec4efb9f1a7a308d530c7fc4737 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 10 Jun 2010 15:02:41 -0500
Subject: [PATCH 491/683] Fix for memcpyNonAliased16 issues.

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

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 09ab47b8908..cafa1e5c44c 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5255,7 +5255,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 			
 		LLVector4a::memcpyNonAliased16((F32*) mPositions, (F32*) src.mPositions, vert_size);
 		LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) src.mNormals, vert_size);
-		LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) src.mTexCoords, vert_size);
+		LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) src.mTexCoords, tc_size);
 
 
 		if (src.mBinormals)
-- 
GitLab


From 3ea0018dc6f94c029d7dbf13bdd5b0bc0558c8d8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 10 Jun 2010 15:07:30 -0500
Subject: [PATCH 492/683] Enable meshes.

---
 indra/llmath/llvolume.h                 | 2 +-
 indra/newview/app_settings/settings.xml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 07829440796..98db7f31c0e 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -41,7 +41,7 @@ class LLVolumeParams;
 class LLProfile;
 class LLPath;
 
-#define LL_MESH_ENABLED 0
+#define LL_MESH_ENABLED 1
 
 template <class T> class LLOctreeNode;
 
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index df9393c3166..1d5d1584d3e 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4908,7 +4908,7 @@
     <key>Type</key>
     <string>Boolean</string>
     <key>Value</key>
-    <real>0</real>
+    <real>1</real>
   </map>
   <key>MigrateCacheDirectory</key>
     <map>
-- 
GitLab


From 2ff888d2bc7424e70a836adb8ec4cf27df75ab7b Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 10 Jun 2010 21:47:49 -0500
Subject: [PATCH 493/683] Unused variable.

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

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index ba5d5e7ca19..ac3ed5d63ea 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2544,9 +2544,9 @@ void LLVolume::copyVolumeFaces(LLVolume* volume)
 
 S32	LLVolume::getNumFaces() const
 {
+#if LL_MESH_ENABLED
 	U8 sculpt_type = (mParams.getSculptType() & LL_SCULPT_TYPE_MASK);
 
-#if LL_MESH_ENABLED
 	if (sculpt_type == LL_SCULPT_TYPE_MESH)
 	{
 		return LL_SCULPT_MESH_MAX_FACES;
-- 
GitLab


From a7eadcccd02210349a07d10a52669f4678d8fae2 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 10 Jun 2010 23:11:21 -0500
Subject: [PATCH 494/683] Unused variable/function

---
 indra/newview/llvovolume.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index d66aa567a8c..38e54342ead 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2659,18 +2659,20 @@ BOOL LLVOVolume::isSculpted() const
 
 BOOL LLVOVolume::isMesh() const
 {
+#if LL_MESH_ENABLED
 	if (isSculpted())
 	{
 		LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
 		U8 sculpt_type = sculpt_params->getSculptType();
-#if LL_MESH_ENABLED
+
 		if ((sculpt_type & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
 			// mesh is a mesh
 		{
 			return TRUE;	
 		}
-#endif
 	}
+#endif
+
 
 	return FALSE;
 }
@@ -3427,6 +3429,7 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_VB("Volume");
 static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
 
+#if LL_MESH_ENABLED
 static LLDrawPoolAvatar* get_avatar_drawpool(LLViewerObject* vobj)
 {
 	LLVOAvatar* avatar = vobj->getAvatar();
@@ -3453,7 +3456,7 @@ static LLDrawPoolAvatar* get_avatar_drawpool(LLViewerObject* vobj)
 
 	return NULL;
 }
-		
+#endif		
 
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
-- 
GitLab


From ad5a45624a702433d481c3dbc0f348a8755b367c Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 10 Jun 2010 23:11:37 -0500
Subject: [PATCH 495/683] Fix for unaligned LLVector4a causing crash in
 attachObject.

---
 indra/newview/llvoavatar.cpp | 17 ++++++++++++++---
 indra/newview/llvoavatar.h   |  2 +-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 05114c1ca43..63c2ce87ca7 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -683,7 +683,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 {
 	LLMemType mt(LLMemType::MTYPE_AVATAR);
 	//VTResume();  // VTune
-	
+	mImpostorExtents = (LLVector4a*) ll_aligned_malloc_16(32);
+
 	// mVoiceVisualizer is created by the hud effects manager and uses the HUD Effects pipeline
 	const BOOL needsSendToSim = false; // currently, this HUD effect doesn't need to pack and unpack data to do its job
 	mVoiceVisualizer = ( LLVoiceVisualizer *)LLHUDManager::getInstance()->createViewerEffect( LLHUDObject::LL_HUD_EFFECT_VOICE_VISUALIZER, needsSendToSim );
@@ -829,6 +830,9 @@ LLVOAvatar::~LLVOAvatar()
 	
 	mAnimationSources.clear();
 
+	ll_aligned_free_16(mImpostorExtents);
+	mImpostorExtents = NULL;
+
 	lldebugs << "LLVOAvatar Destructor end" << llendl;
 }
 
@@ -5558,8 +5562,7 @@ LLViewerJointAttachment* LLVOAvatar::getTargetAttachmentPoint(LLViewerObject* vi
 	// correctly, but putting this check in here to be safe.
 	if (attachmentID & ATTACHMENT_ADD)
 	{
-		llwarns << "Got an attachment with ATTACHMENT_ADD mask, removing ( attach pt:" << attachmentID << " )" << llendl;
-		attachmentID &= ~ATTACHMENT_ADD;
+		llwarns << "Got an attachment with ATTACHMENT_ADD mask, removing ( attach pt:" << attachmentID << " )" << llendl;		attachmentID &= ~ATTACHMENT_ADD;
 	}
 	
 	LLViewerJointAttachment* attachment = get_if_there(mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL);
@@ -5680,6 +5683,14 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
 			return TRUE;
 		}
 	}
+
+	std::vector<LLPointer<LLViewerObject> >::iterator iter = std::find(mPendingAttachment.begin(), mPendingAttachment.end(), viewer_object);
+	if (iter != mPendingAttachment.end())
+	{
+		mPendingAttachment.erase(iter);
+		return TRUE;
+	}
+	
 	return FALSE;
 }
 
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index b4da8ba5a42..358a1c256f3 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -405,7 +405,7 @@ class LLVOAvatar :
 	LLVector3	mImpostorOffset;
 	LLVector2	mImpostorDim;
 	BOOL		mNeedsAnimUpdate;
-	LL_ALIGN_16(LLVector4a	mImpostorExtents[2]);
+	LLVector4a*	mImpostorExtents;
 	LLVector3	mImpostorAngle;
 	F32			mImpostorDistance;
 	F32			mImpostorPixelArea;
-- 
GitLab


From 818e970b3efe65f6e471d071ae5f01603f61da79 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Sun, 13 Jun 2010 12:36:02 +0100
Subject: [PATCH 496/683] SNOW-541 PARTIAL GSTREAMER fail to load (slplugin?)

Robustify the plugin a bunch more, and turn off a dodgy-and-unused visualization feature.
(transplanted from 43273f751dac21d53dba83a90d7f9e057865f789)
---
 .../media_plugin_gstreamer010.cpp             | 28 ++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp b/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp
index 033c4ba2f33..e6d2ad3edcb 100644
--- a/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp
+++ b/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp
@@ -544,8 +544,12 @@ MediaPluginGStreamer010::pause()
 {
 	DEBUGMSG("pausing media...");
 	// todo: error-check this?
-	llgst_element_set_state(mPlaybin, GST_STATE_PAUSED);
-	return true;
+	if (mDoneInit && mPlaybin)
+	{
+		llgst_element_set_state(mPlaybin, GST_STATE_PAUSED);
+		return true;
+	}
+	return false;
 }
 
 bool
@@ -553,8 +557,12 @@ MediaPluginGStreamer010::stop()
 {
 	DEBUGMSG("stopping media...");
 	// todo: error-check this?
-	llgst_element_set_state(mPlaybin, GST_STATE_READY);
-	return true;
+	if (mDoneInit && mPlaybin)
+	{
+		llgst_element_set_state(mPlaybin, GST_STATE_READY);
+		return true;
+	}
+	return false;
 }
 
 bool
@@ -564,8 +572,12 @@ MediaPluginGStreamer010::play(double rate)
 
         DEBUGMSG("playing media... rate=%f", rate);
 	// todo: error-check this?
-	llgst_element_set_state(mPlaybin, GST_STATE_PLAYING);
-	return true;
+	if (mDoneInit && mPlaybin)
+	{
+		llgst_element_set_state(mPlaybin, GST_STATE_PLAYING);
+		return true;
+	}
+	return false;
 }
 
 bool
@@ -608,7 +620,7 @@ bool
 MediaPluginGStreamer010::getTimePos(double &sec_out)
 {
 	bool got_position = false;
-	if (mPlaybin)
+	if (mDoneInit && mPlaybin)
 	{
 		gint64 pos;
 		GstFormat timefmt = GST_FORMAT_TIME;
@@ -688,6 +700,7 @@ MediaPluginGStreamer010::load()
 					   this);
 	llgst_object_unref (bus);
 
+#if 0 // not quite stable/correct yet
 	// get a visualizer element (bonus feature!)
 	char* vis_name = getenv("LL_GST_VIS_NAME");
 	if (!vis_name ||
@@ -714,6 +727,7 @@ MediaPluginGStreamer010::load()
 			}
 		}
 	}
+#endif
 
 	if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) {
 		// instantiate a custom video sink
-- 
GitLab


From 6e37ec08f678451a526f34218cb070d117cdf60a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 14 Jun 2010 23:13:10 -0500
Subject: [PATCH 497/683] Builds with LLConvexDecompInter as a static lib.

---
 indra/cmake/CMakeLists.txt                           | 2 ++
 indra/llcommon/llassettype.h                         | 2 --
 indra/llinventory/llinventorytype.h                  | 3 ---
 indra/llmath/llvolume.cpp                            | 8 ++++----
 indra/llmath/llvolume.h                              | 4 ++--
 indra/newview/CMakeLists.txt                         | 3 +++
 indra/newview/llassetuploadresponders.h              | 1 +
 indra/newview/lldrawpoolavatar.h                     | 1 +
 indra/newview/llinventorybridge.h                    | 1 +
 indra/newview/lltooldraganddrop.cpp                  | 2 +-
 indra/newview/lltooldraganddrop.h                    | 1 +
 indra/newview/llvovolume.cpp                         | 2 +-
 indra/newview/skins/default/xui/en/floater_about.xml | 4 +++-
 13 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt
index 4fc25dcc241..8612c463760 100644
--- a/indra/cmake/CMakeLists.txt
+++ b/indra/cmake/CMakeLists.txt
@@ -34,6 +34,7 @@ set(cmake_SOURCE_FILES
     FindXmlRpcEpi.cmake
     FMOD.cmake
     FreeType.cmake
+    GLOD.cmake
     GStreamer010Plugin.cmake
     GooglePerfTools.cmake
     JPEG.cmake
@@ -41,6 +42,7 @@ set(cmake_SOURCE_FILES
     LLAudio.cmake
     LLCharacter.cmake
     LLCommon.cmake
+    LLConvexDecompInter.cmake
     LLCrashLogger.cmake
     LLDatabase.cmake
     LLImage.cmake
diff --git a/indra/llcommon/llassettype.h b/indra/llcommon/llassettype.h
index ebc43134cbe..27d35e95ffc 100644
--- a/indra/llcommon/llassettype.h
+++ b/indra/llcommon/llassettype.h
@@ -114,10 +114,8 @@ class LL_COMMON_API LLAssetType
 
 		AT_LINK_FOLDER = 25,
 			// Inventory folder link
-#if LL_MESH_ENABLED
 		AT_MESH = 49,
 		    // Mesh data in our proprietary SLM format
-#endif
 
 		AT_COUNT = 50,
 
diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h
index d2fc67ef645..17ed3df951d 100644
--- a/indra/llinventory/llinventorytype.h
+++ b/indra/llinventory/llinventorytype.h
@@ -67,10 +67,7 @@ class LLInventoryType
 		IT_WEARABLE = 18,
 		IT_ANIMATION = 19,
 		IT_GESTURE = 20,
-
-#if LL_MESH_ENABLED
 		IT_MESH = 22,
-#endif
 		IT_COUNT = 23,
 
 		IT_NONE = -1
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 10cef533b01..53f484fb791 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5355,9 +5355,9 @@ bool LLVolumeFace::VertexMapData::operator==(const LLVolumeFace::VertexData& rhs
 		getNormal().equal3(rhs.getNormal());
 }
 
-bool LLVolumeFace::VertexMapData::ComparePosition::operator()(const LLVector4a& a, const LLVector4a& b) const
+bool LLVolumeFace::VertexMapData::ComparePosition::operator()(const LLVector3& a, const LLVector3& b) const
 {
-	return a.less3(b);			
+	return a < b;			
 }
 
 void LLVolumeFace::optimize(F32 angle_cutoff)
@@ -5375,7 +5375,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 		getVertexData(index, cv);
 		
 		BOOL found = FALSE;
-		VertexMapData::PointMap::iterator point_iter = point_map.find(cv.getPosition());
+		VertexMapData::PointMap::iterator point_iter = point_map.find(LLVector3(cv.getPosition().getF32()));
 		if (point_iter != point_map.end())
 		{ //duplicate point might exist
 			for (U32 j = 0; j < point_iter->second.size(); ++j)
@@ -5407,7 +5407,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 			}
 			else
 			{
-				point_map[d.getPosition()].push_back(d);
+				point_map[LLVector3(d.getPosition().getF32())].push_back(d);
 			}
 		}
 	}
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 98db7f31c0e..4aef3be9737 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -873,10 +873,10 @@ class LLVolumeFace
 
 		struct ComparePosition
 		{
-			bool operator()(const LLVector4a& a, const LLVector4a& b) const;
+			bool operator()(const LLVector3& a, const LLVector3& b) const;
 		};
 
-		typedef std::map<LLVector4a, std::vector<VertexMapData>, VertexMapData::ComparePosition > PointMap;
+		typedef std::map<LLVector3, std::vector<VertexMapData>, VertexMapData::ComparePosition > PointMap;
 	};
 
 	void optimize(F32 angle_cutoff = 2.f);
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index d2ae81180be..9de1d4aca5c 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -16,6 +16,7 @@ include(FindOpenGL)
 include(LLAudio)
 include(LLCharacter)
 include(LLCommon)
+include(LLConvexDecompInter)
 include(LLImage)
 include(LLImageJ2COJ)
 include(LLInventory)
@@ -49,6 +50,7 @@ include_directories(
     ${LLAUDIO_INCLUDE_DIRS}
     ${LLCHARACTER_INCLUDE_DIRS}
     ${LLCOMMON_INCLUDE_DIRS}
+    ${LLCONVEXDECOMPINTER_INCLUDE_DIRS}
     ${LLIMAGE_INCLUDE_DIRS}
     ${LLINVENTORY_INCLUDE_DIRS}
     ${LLMATH_INCLUDE_DIRS}
@@ -1683,6 +1685,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
     ${CRYPTO_LIBRARIES}
     ${LLLOGIN_LIBRARIES}
     ${GOOGLE_PERFTOOLS_LIBRARIES}
+    ${LLCONVEXDECOMPINTER_LIBRARIES}
     )
 
 build_version(viewer)
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index 9abaccfde09..5890fbbc088 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -34,6 +34,7 @@
 #define LL_LLASSETUPLOADRESPONDER_H
 
 #include "llhttpclient.h"
+#include "llvolume.h" //for LL_MESH_ENABLED
 
 // Abstract class for supporting asset upload
 // via capabilities
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index 46ffc42f040..b01394534b3 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -34,6 +34,7 @@
 #define LL_LLDRAWPOOLAVATAR_H
 
 #include "lldrawpool.h"
+#include "llvolume.h" // for LL_MESH_ENABLED
 
 class LLVOAvatar;
 class LLGLSLShader;
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index 8de7d631738..0e3b5bc3c9d 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -40,6 +40,7 @@
 #include "llinventoryobserver.h"
 #include "llviewercontrol.h"
 #include "llwearable.h"
+#include "llvolume.h"  //for LL_MESH_ENABLED
 
 class LLInventoryPanel;
 class LLInventoryModel;
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index d679ccd3d8d..c4ecba1aa20 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1037,7 +1037,7 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
 	hit_obj->sendTEUpdate();
 }
 
-#if LL_MESH_EANBLED
+#if LL_MESH_ENABLED
 void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj,
 								 LLInventoryItem* item,
 								 LLToolDragAndDrop::ESource source,
diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h
index ceeaa8c8209..09da4c29554 100644
--- a/indra/newview/lltooldraganddrop.h
+++ b/indra/newview/lltooldraganddrop.h
@@ -43,6 +43,7 @@
 #include "llpermissions.h"
 #include "llwindow.h"
 #include "llviewerinventory.h"
+#include "llvolume.h" //for LL_MESH_ENABLED
 
 class LLToolDragAndDrop;
 class LLViewerRegion;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index d66aa567a8c..8f51edc1de1 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1594,7 +1594,7 @@ void LLVOVolume::updateFaceSize(S32 idx)
 	LLFace* facep = mDrawable->getFace(idx);
 	if (idx >= getVolume()->getNumVolumeFaces())
 	{
-		facep->setSize(0,0);
+		facep->setSize(0,0, true);
 	}
 	else
 	{
diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml
index 294a68255d8..860cff6664f 100644
--- a/indra/newview/skins/default/xui/en/floater_about.xml
+++ b/indra/newview/skins/default/xui/en/floater_about.xml
@@ -160,10 +160,12 @@ xmlrpc-epi Copyright (C) 2000 Epinions, Inc.
 zlib Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler.
 google-perftools Copyright (c) 2005, Google Inc.
 
+Second Life Viewer uses Havok (TM) Physics. (c)Copyright 1999-2010 Havok.com Inc. (and its Licensors). All Rights Reserved. See www.havok.com for details.
+
 All rights reserved.  See licenses.txt for details.
 
 Voice chat Audio coding: Polycom(R) Siren14(TM) (ITU-T Rec. G.722.1 Annex C)
-      </text_editor>
+        </text_editor>
       </panel>
     </tab_container>
 </floater>
-- 
GitLab


From 66e353812f4732c77206322d271b2346dd74feec Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 15 Jun 2010 19:16:39 -0500
Subject: [PATCH 498/683] Get meshes working post-SSE pass.

---
 indra/llmath/llvolume.cpp | 89 +++++++++++++++++++++++----------------
 indra/llmath/llvolume.h   |  2 +
 2 files changed, 54 insertions(+), 37 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 62e488452a3..a4022c842dc 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1988,19 +1988,33 @@ BOOL LLVolume::generate()
 
 void LLVolumeFace::VertexData::init()
 {
-	mData = (LLVector4a*) ll_aligned_malloc_16(32);
+	if (!mData)
+	{
+		mData = (LLVector4a*) ll_aligned_malloc_16(32);
+	}
 }
 
 LLVolumeFace::VertexData::VertexData()
 {
+	mData = NULL;
 	init();
 }
 	
 LLVolumeFace::VertexData::VertexData(const VertexData& rhs)
 {
-	init();
-	LLVector4a::memcpyNonAliased16((F32*) mData, (F32*) rhs.mData, 8);
-	mTexCoord = rhs.mTexCoord;
+	mData = NULL;
+	*this = rhs;
+}
+
+const LLVolumeFace::VertexData& LLVolumeFace::VertexData::operator=(const LLVolumeFace::VertexData& rhs)
+{
+	if (this != &rhs)
+	{
+		init();
+		LLVector4a::memcpyNonAliased16((F32*) mData, (F32*) rhs.mData, 8);
+		mTexCoord = rhs.mTexCoord;
+	}
+	return *this;
 }
 
 LLVolumeFace::VertexData::~VertexData()
@@ -2041,34 +2055,29 @@ void LLVolumeFace::VertexData::setNormal(const LLVector4a& norm)
 
 bool LLVolumeFace::VertexData::operator<(const LLVolumeFace::VertexData& rhs)const
 {
-	const U8* l = (const U8*) this;
-	const U8* r = (const U8*) &rhs;
+	if (mData[POSITION].notEqual3(rhs.getPosition()))
+	{
+		return mData[POSITION].less3(rhs.getPosition());
+	}
 
-	for (U32 i = 0; i < sizeof(VertexData); ++i)
+	if (mData[NORMAL].notEqual3(rhs.getNormal()))
 	{
-		if (l[i] != r[i])
-		{
-			return r[i] < l[i];
-		}
+		return mData[NORMAL].less3(rhs.getNormal());
 	}
-	
+
+	if (mTexCoord != rhs.mTexCoord)
+	{
+		return mTexCoord < rhs.mTexCoord;
+	}
+
 	return false;
 }
 
 bool LLVolumeFace::VertexData::operator==(const LLVolumeFace::VertexData& rhs)const
 {
-	const U8* l = (const U8*) this;
-	const U8* r = (const U8*) &rhs;
-
-	for (U32 i = 0; i < sizeof(VertexData); ++i)
-	{
-		if (l[i] != r[i])
-		{
-			return false;
-		}
-	}
-	
-	return true;
+	return mData[POSITION].equal3(rhs.getPosition()) &&
+			mData[NORMAL].equal3(rhs.getNormal()) &&
+			mTexCoord == rhs.mTexCoord;
 }
 
 bool LLVolumeFace::VertexData::compareNormal(const LLVolumeFace::VertexData& rhs, F32 angle_cutoff) const
@@ -6244,10 +6253,13 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	LLVector4a* new_pos = (LLVector4a*) ll_aligned_malloc_16(new_count*16);
 	LLVector4a* new_norm = (LLVector4a*) ll_aligned_malloc_16(new_count*16);
 	LLVector2* new_tc = (LLVector2*) ll_aligned_malloc_16((new_count*8+0xF) & ~0xF);
-
-	LLVector4a::memcpyNonAliased16((F32*) new_pos, (F32*) mPositions, new_count*4);
-	LLVector4a::memcpyNonAliased16((F32*) new_norm, (F32*) mNormals, new_count*4);
-	LLVector4a::memcpyNonAliased16((F32*) new_tc, (F32*) mTexCoords, new_count*2);
+	
+	if (mNumVertices > 0)
+	{
+		LLVector4a::memcpyNonAliased16((F32*) new_pos, (F32*) mPositions, mNumVertices*4);
+		LLVector4a::memcpyNonAliased16((F32*) new_norm, (F32*) mNormals, mNumVertices*4);
+		LLVector4a::memcpyNonAliased16((F32*) new_tc, (F32*) mTexCoords, mNumVertices*2);
+	}
 
 	ll_aligned_free_16(mPositions);
 	ll_aligned_free_16(mNormals);
@@ -6259,13 +6271,13 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 
 	mNumVertices = new_count;
 
-	LLVector4a* dst_pos = (LLVector4a*) mPositions+offset;
-	LLVector2* dst_tc = (LLVector2*) mTexCoords+offset;
-	LLVector4a* dst_norm = (LLVector4a*) mNormals+offset;
+	LLVector4a* dst_pos = mPositions+offset;
+	LLVector2* dst_tc = mTexCoords+offset;
+	LLVector4a* dst_norm = mNormals+offset;
 
-	LLVector4a* src_pos = (LLVector4a*) face.mPositions;
-	LLVector2* src_tc = (LLVector2*) face.mTexCoords;
-	LLVector4a* src_norm = (LLVector4a*) face.mNormals;
+	const LLVector4a* src_pos = face.mPositions;
+	const LLVector2* src_tc = face.mTexCoords;
+	const LLVector4a* src_norm = face.mNormals;
 
 	LLMatrix4a mat, norm_mat;
 	mat.loadu(mat_in);
@@ -6292,13 +6304,16 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 
 	new_count = mNumIndices + face.mNumIndices;
 	U16* new_indices = (U16*) ll_aligned_malloc_16((new_count*2+0xF) & ~0xF);
-	LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, new_count/2);
+	if (mNumIndices > 0)
+	{
+		LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, llmax(mNumIndices/2, 1));
+	}
+
 	ll_aligned_free_16(mIndices);
 	mIndices = new_indices;
+	U16* dst_idx = mIndices+mNumIndices;
 	mNumIndices = new_count;
 
-	U16* dst_idx = mIndices+offset;
-
 	for (U32 i = 0; i < face.mNumIndices; ++i)
 	{
 		dst_idx[i] = face.mIndices[i]+offset;
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 4aef3be9737..af28337f57d 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -817,6 +817,8 @@ class LLVolumeFace
 	public:
 		VertexData();
 		VertexData(const VertexData& rhs);
+		const VertexData& operator=(const VertexData& rhs);
+
 		~VertexData();
 		LLVector4a& getPosition();
 		LLVector4a& getNormal();
-- 
GitLab


From 7f73d1414b113089d3be244a978d5f4af6d9afc3 Mon Sep 17 00:00:00 2001
From: Leyla Farazha <leyla@lindenlab.com>
Date: Mon, 21 Jun 2010 11:48:54 -0700
Subject: [PATCH 499/683] merge fix, commenting out code after return true

---
 indra/newview/llviewerwindow.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 37e07fd58c1..a2d0bd673a8 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -4460,7 +4460,7 @@ void LLViewerWindow::restartDisplay(BOOL show_progress_bar)
 
 BOOL LLViewerWindow::changeDisplaySettings(LLCoordScreen size, BOOL disable_vsync, BOOL show_progress_bar)
 {
-	BOOL was_maximized = gSavedSettings.getBOOL("WindowMaximized");
+	//BOOL was_maximized = gSavedSettings.getBOOL("WindowMaximized");
 
 	//gResizeScreenTexture = TRUE;
 
@@ -4473,11 +4473,13 @@ BOOL LLViewerWindow::changeDisplaySettings(LLCoordScreen size, BOOL disable_vsyn
 		mWindow->setSize(size);
 	}
 
-		//if (fsaa == old_fsaa)
+	//if (fsaa == old_fsaa)
 	{
 		return TRUE;
 	}
 
+/*
+
 	// Close floaters that don't handle settings change
 	LLFloaterReg::hideInstance("snapshot");
 	
@@ -4553,6 +4555,8 @@ BOOL LLViewerWindow::changeDisplaySettings(LLCoordScreen size, BOOL disable_vsyn
 	gFocusMgr.setKeyboardFocus(keyboard_focus);
 	
 	return success;
+
+	*/
 }
 
 F32	LLViewerWindow::getWorldViewAspectRatio() const
-- 
GitLab


From 3827b395fbca941846dab494ee8449786a39561d Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Thu, 24 Jun 2010 16:45:47 -0700
Subject: [PATCH 500/683] Fixed cmake to grab the decomposition libraries.

---
 indra/cmake/CMakeLists.txt   |  2 +-
 indra/newview/CMakeLists.txt |  6 +++---
 install.xml                  | 26 ++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt
index 8612c463760..cadd2608e2a 100644
--- a/indra/cmake/CMakeLists.txt
+++ b/indra/cmake/CMakeLists.txt
@@ -42,7 +42,7 @@ set(cmake_SOURCE_FILES
     LLAudio.cmake
     LLCharacter.cmake
     LLCommon.cmake
-    LLConvexDecompInter.cmake
+    LLConvexDecomposition.cmake
     LLCrashLogger.cmake
     LLDatabase.cmake
     LLImage.cmake
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index f0b58b385c5..45291e60f99 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -16,7 +16,7 @@ include(FindOpenGL)
 include(LLAudio)
 include(LLCharacter)
 include(LLCommon)
-include(LLConvexDecompInter)
+include(LLConvexDecomposition)
 include(LLImage)
 include(LLImageJ2COJ)
 include(LLInventory)
@@ -50,7 +50,7 @@ include_directories(
     ${LLAUDIO_INCLUDE_DIRS}
     ${LLCHARACTER_INCLUDE_DIRS}
     ${LLCOMMON_INCLUDE_DIRS}
-    ${LLCONVEXDECOMPINTER_INCLUDE_DIRS}
+    ${LLCONVEXDECOMP_INCLUDE_DIRS}
     ${LLIMAGE_INCLUDE_DIRS}
     ${LLINVENTORY_INCLUDE_DIRS}
     ${LLMATH_INCLUDE_DIRS}
@@ -1682,7 +1682,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
     ${CRYPTO_LIBRARIES}
     ${LLLOGIN_LIBRARIES}
     ${GOOGLE_PERFTOOLS_LIBRARIES}
-    ${LLCONVEXDECOMPINTER_LIBRARIES}
+    ${LLCONVEXDECOMP_LIBRARY}
     )
 
 build_version(viewer)
diff --git a/install.xml b/install.xml
index ae3f930a1d6..a944e7709db 100644
--- a/install.xml
+++ b/install.xml
@@ -1038,6 +1038,32 @@ anguage Infrstructure (CLI) international standard</string>
           </map>
         </map>
       </map>
+      <key>llconvexdecomposition</key>
+      <map>
+        <key>copyright</key>
+        <string>on file</string>
+        <key>description</key>
+        <string>Convex decomposition utility for mesh</string>
+        <key>license</key>
+        <string>havok</string>
+        <key>packages</key>
+        <map>
+          <key>windows</key>
+          <map>
+            <key>md5sum</key>
+            <string>9b895f616dfb5ce9814d4e53417950a9</string>
+            <key>url</key>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-windows-20100622.tar.bz2</uri>
+          </map>
+          <key>linux</key>
+          <map>
+            <key>md5sum</key>
+            <string>da4d464008fac288865f259873cafad2</string>
+            <key>url</key>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100622.tar.bz2</uri>
+          </map>          
+        </map>
+      </map>
       <key>llqtwebkit</key>
       <map>
         <key>license</key>
-- 
GitLab


From a043cfbe463e94a5c6e6f0e31e22912b025890c7 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Fri, 25 Jun 2010 14:59:17 -0700
Subject: [PATCH 501/683] Added Darwin llconvexdecomposition to install.xml

---
 install.xml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/install.xml b/install.xml
index a944e7709db..d84ab14d539 100644
--- a/install.xml
+++ b/install.xml
@@ -1061,6 +1061,13 @@ anguage Infrstructure (CLI) international standard</string>
             <string>da4d464008fac288865f259873cafad2</string>
             <key>url</key>
             <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100622.tar.bz2</uri>
+          </map>
+          <key>darwin</key>
+          <map>
+            <key>md5sum</key>
+            <string>01853c92592c9b969d2cdbc339738b98</string>
+            <key>url</key>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-darwin-20100624.tar.bz2</uri>
           </map>          
         </map>
       </map>
-- 
GitLab


From 6f2bd694d9a21174648b4e4f76d6d078aa88265f Mon Sep 17 00:00:00 2001
From: Matthew Breindel <falcon@lindenlab.com>
Date: Sat, 26 Jun 2010 12:35:05 -0700
Subject: [PATCH 502/683] Fixed mac build (given LL_MESH_ENABLED set to 0).

---
 indra/llcommon/llmemory.h            | 20 ++++++++++++++++++--
 indra/llmath/llvolume.h              |  2 +-
 indra/newview/llspatialpartition.cpp |  4 +++-
 install.xml                          |  4 ++--
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 1c8c91f57e2..35935efa889 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -34,6 +34,22 @@
 
 #include <stdlib.h>
 
+// A not necessarily efficient, but general, aligned malloc http://stackoverflow.com/questions/196329/osx-lacks-memalign
+inline void* ll_aligned_malloc( size_t size, int align )
+{
+	void* mem = malloc( size + (align - 1) + sizeof(void*) );
+	char* aligned = ((char*)mem) + sizeof(void*);
+	aligned += align - ((uintptr_t)aligned & (align - 1));
+	
+	((void**)aligned)[-1] = mem;
+	return aligned;
+}
+
+inline void ll_aligned_free( void* ptr )
+{
+	free( ((void**)ptr)[-1] );
+}
+
 inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
 {
 #if defined(LL_WINDOWS)
@@ -65,7 +81,7 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi
 #if defined(LL_WINDOWS)
 	return _mm_malloc(size, 32);
 #elif defined(LL_DARWIN)
-# error implement me.
+	return ll_aligned_malloc( size, 32 );
 #else
 	void *rtn;
 	if (LL_LIKELY(0 == posix_memalign(&rtn, 32, size)))
@@ -80,7 +96,7 @@ inline void ll_aligned_free_32(void *p)
 #if defined(LL_WINDOWS)
 	_mm_free(p);
 #elif defined(LL_DARWIN)
-# error implement me.
+	ll_aligned_free( p );
 #else
 	free(p); // posix_memalign() is compatible with heap deallocator
 #endif
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index af28337f57d..9cce94e6cf3 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -41,7 +41,7 @@ class LLVolumeParams;
 class LLProfile;
 class LLPath;
 
-#define LL_MESH_ENABLED 1
+#define LL_MESH_ENABLED 0
 
 template <class T> class LLOctreeNode;
 
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index dc193dc6002..9951cf0193f 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2791,6 +2791,7 @@ void renderPhysicsShape(LLDrawable* drawable)
 
 		U32 data_mask = LLVertexBuffer::MAP_VERTEX;
 
+#if LL_MESH_ENABLED
 		if (volume->isMesh())
 		{			
 			LLUUID mesh_id = volume->getVolume()->getParams().getSculptID();
@@ -2827,7 +2828,8 @@ void renderPhysicsShape(LLDrawable* drawable)
 				return;
 			}
 		}
-
+#endif //LL_MESH_ENABLED
+		
 		//push faces
 		glColor3fv(color.mV);
 		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
diff --git a/install.xml b/install.xml
index d84ab14d539..40ec65b2b01 100644
--- a/install.xml
+++ b/install.xml
@@ -1065,9 +1065,9 @@ anguage Infrstructure (CLI) international standard</string>
           <key>darwin</key>
           <map>
             <key>md5sum</key>
-            <string>01853c92592c9b969d2cdbc339738b98</string>
+            <string>b9fe5149a23cbc55a341867c2f6abb8e</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-darwin-20100624.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-darwin-20100626.tar.bz2</uri>
           </map>          
         </map>
       </map>
-- 
GitLab


From 6fcc0994dff2bd88256ff8306c8df670df627ef6 Mon Sep 17 00:00:00 2001
From: Aimee Linden <aimee@lindenlab.com>
Date: Mon, 28 Jun 2010 16:30:08 +0100
Subject: [PATCH 503/683] EXT-7498 WIP Snapshot Sharing

Reviewed by Tofu.
---
 indra/llmessage/llhttpclient.cpp              |  11 +-
 indra/llmessage/llurlrequest.cpp              |   5 +
 indra/llmessage/llurlrequest.h                |   5 +
 indra/newview/CMakeLists.txt                  |   2 +
 indra/newview/app_settings/settings.xml       |  22 +
 indra/newview/llfloatersnapshot.cpp           | 182 ++++--
 indra/newview/llstartup.cpp                   |   7 +
 indra/newview/llviewermedia.cpp               |   4 +
 indra/newview/llwebsharing.cpp                | 609 ++++++++++++++++++
 indra/newview/llwebsharing.h                  | 230 +++++++
 .../skins/default/xui/en/floater_snapshot.xml |  34 +-
 11 files changed, 1057 insertions(+), 54 deletions(-)
 create mode 100644 indra/newview/llwebsharing.cpp
 create mode 100644 indra/newview/llwebsharing.h

diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp
index e8dc2071144..5d9448b42c6 100644
--- a/indra/llmessage/llhttpclient.cpp
+++ b/indra/llmessage/llhttpclient.cpp
@@ -240,9 +240,14 @@ static void request(
 	lldebugs << LLURLRequest::actionAsVerb(method) << " " << url << " "
 		<< headers << llendl;
 
-    // Insert custom headers is the caller sent any
-    if (headers.isMap())
-    {
+	// Insert custom headers if the caller sent any
+	if (headers.isMap())
+	{
+		if (headers.has("Cookie"))
+		{
+			req->allowCookies();
+		}
+
         LLSD::map_const_iterator iter = headers.beginMap();
         LLSD::map_const_iterator end  = headers.endMap();
 
diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp
index 1e76d108289..295f69e902a 100644
--- a/indra/llmessage/llurlrequest.cpp
+++ b/indra/llmessage/llurlrequest.cpp
@@ -251,6 +251,11 @@ void LLURLRequest::useProxy(const std::string &proxy)
     mDetail->mCurlRequest->setoptString(CURLOPT_PROXY, proxy);
 }
 
+void LLURLRequest::allowCookies()
+{
+	mDetail->mCurlRequest->setoptString(CURLOPT_COOKIEFILE, "");
+}
+
 // virtual
 LLIOPipe::EStatus LLURLRequest::handleError(
 	LLIOPipe::EStatus status,
diff --git a/indra/llmessage/llurlrequest.h b/indra/llmessage/llurlrequest.h
index 69fd22e5928..378cc563743 100644
--- a/indra/llmessage/llurlrequest.h
+++ b/indra/llmessage/llurlrequest.h
@@ -189,6 +189,11 @@ class LLURLRequest : public LLIOPipe
      */
 	void useProxy(const std::string& proxy);
 
+	/**
+	 * @brief Turn on cookie handling for this request with CURLOPT_COOKIEFILE.
+	 */
+	void allowCookies();
+
 public:
 	/** 
 	 * @brief Give this pipe a chance to handle a generated error
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index ce42cb60381..e7475114b26 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -552,6 +552,7 @@ set(viewer_SOURCE_FILES
     llwearablelist.cpp
     llwearabletype.cpp
     llweb.cpp
+    llwebsharing.cpp
     llwind.cpp
     llwlanimator.cpp
     llwldaycycle.cpp
@@ -1076,6 +1077,7 @@ set(viewer_HEADER_FILES
     llwearablelist.h
     llwearabletype.h
     llweb.h
+    llwebsharing.h
     llwind.h
     llwlanimator.h
     llwldaycycle.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 50eee73c4c8..dd93f1bfa6b 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9483,6 +9483,28 @@
       <key>Value</key>
       <integer>75</integer>
     </map>
+    <key>SnapshotSharingEnabled</key>
+    <map>
+      <key>Comment</key>
+      <string>Enable uploading of snapshots to a web service.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>0</integer>
+    </map>
+    <key>SnapshotConfigURL</key>
+    <map>
+      <key>Comment</key>
+      <string>URL to fetch Snapshot Sharing configuration data from.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>String</string>
+      <key>Value</key>
+      <string>http://photos.apps.staging.avatarsunited.com/viewer_config</string>
+    </map>
     <key>SnapshotTextureLastResolution</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index f3baa482a0a..43ea6143b10 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -46,6 +46,7 @@
 #include "llbutton.h"
 #include "llcombobox.h"
 #include "lleconomy.h"
+#include "lllandmarkactions.h"
 #include "llsliderctrl.h"
 #include "llspinctrl.h"
 #include "llviewercontrol.h"
@@ -59,6 +60,7 @@
 #include "llradiogroup.h"
 #include "lltoolfocus.h"
 #include "lltoolmgr.h"
+#include "llwebsharing.h"
 #include "llworld.h"
 #include "llagentui.h"
 
@@ -86,8 +88,8 @@
 ///----------------------------------------------------------------------------
 /// Local function declarations, constants, enums, and typedefs
 ///----------------------------------------------------------------------------
-S32 LLFloaterSnapshot::sUIWinHeightLong = 526 ;
-S32 LLFloaterSnapshot::sUIWinHeightShort = LLFloaterSnapshot::sUIWinHeightLong - 230 ;
+S32 LLFloaterSnapshot::sUIWinHeightLong = 530 ;
+S32 LLFloaterSnapshot::sUIWinHeightShort = LLFloaterSnapshot::sUIWinHeightLong - 240 ;
 S32 LLFloaterSnapshot::sUIWinWidth = 215 ;
 
 LLSnapshotFloaterView* gSnapshotFloaterView = NULL;
@@ -115,7 +117,8 @@ class LLSnapshotLivePreview : public LLView
 	{
 		SNAPSHOT_POSTCARD,
 		SNAPSHOT_TEXTURE,
-		SNAPSHOT_LOCAL
+		SNAPSHOT_LOCAL,
+		SNAPSHOT_WEB
 	};
 
 
@@ -161,6 +164,7 @@ class LLSnapshotLivePreview : public LLView
 	void setSnapshotQuality(S32 quality);
 	void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; }
 	void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f);
+	void saveWeb();
 	LLFloaterPostcard* savePostcard();
 	void saveTexture();
 	BOOL saveLocal();
@@ -173,6 +177,9 @@ class LLSnapshotLivePreview : public LLView
 	// Returns TRUE when snapshot generated, FALSE otherwise.
 	static BOOL onIdle( void* snapshot_preview );
 
+	// callback for region name resolve
+	void regionNameCallback(LLImageJPEG* snapshot, LLSD& metadata, const std::string& name, S32 x, S32 y, S32 z);
+
 private:
 	LLColor4					mColor;
 	LLPointer<LLViewerTexture>	mViewerImage[2]; //used to represent the scene when the frame is frozen.
@@ -826,9 +833,19 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
 			// delete any existing image
 			previewp->mFormattedImage = NULL;
 			// now create the new one of the appropriate format.
-			// note: postcards hardcoded to use jpeg always.
-			LLFloaterSnapshot::ESnapshotFormat format = previewp->getSnapshotType() == SNAPSHOT_POSTCARD
-				? LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG : previewp->getSnapshotFormat();
+			// note: postcards and web hardcoded to use jpeg always.
+			LLFloaterSnapshot::ESnapshotFormat format;
+
+			if (previewp->getSnapshotType() == SNAPSHOT_POSTCARD ||
+				previewp->getSnapshotType() == SNAPSHOT_WEB)
+			{
+				format = LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG;
+			}
+			else
+			{
+				format = previewp->getSnapshotFormat();
+			}
+
 			switch(format)
 			{
 			case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG:
@@ -1021,6 +1038,33 @@ BOOL LLSnapshotLivePreview::saveLocal()
 	return success;
 }
 
+void LLSnapshotLivePreview::saveWeb()
+{
+	// *FIX: Will break if the window closes because of CloseSnapshotOnKeep!
+	// Needs to pass on ownership of the image.
+	LLImageJPEG* jpg = dynamic_cast<LLImageJPEG*>(mFormattedImage.get());
+	if(!jpg)
+	{
+		llwarns << "Formatted image not a JPEG" << llendl;
+		return;
+	}
+
+	LLSD metadata;
+	metadata["description"] = getChild<LLLineEditor>("description")->getText();
+
+	LLLandmarkActions::getRegionNameAndCoordsFromPosGlobal(gAgentCamera.getCameraPositionGlobal(),
+		boost::bind(&LLSnapshotLivePreview::regionNameCallback, this, jpg, metadata, _1, _2, _3, _4));
+
+	gViewerWindow->playSnapshotAnimAndSound();
+}
+
+void LLSnapshotLivePreview::regionNameCallback(LLImageJPEG* snapshot, LLSD& metadata, const std::string& name, S32 x, S32 y, S32 z)
+{
+	metadata["slurl"] = LLSLURL(name, LLVector3d(x, y, z)).getSLURLString();
+
+	LLWebSharing::instance().shareSnapshot(snapshot, metadata);
+}
+
 ///----------------------------------------------------------------------------
 /// Class LLFloaterSnapshot::Impl
 ///----------------------------------------------------------------------------
@@ -1071,6 +1115,7 @@ class LLFloaterSnapshot::Impl
 
 private:
 	static LLSnapshotLivePreview::ESnapshotType getTypeIndex(LLFloaterSnapshot* floater);
+	static LLSD getTypeName(LLSnapshotLivePreview::ESnapshotType index);
 	static ESnapshotFormat getFormatIndex(LLFloaterSnapshot* floater);
 	static LLViewerWindow::ESnapshotType getLayerType(LLFloaterSnapshot* floater);
 	static void comboSetCustom(LLFloaterSnapshot *floater, const std::string& comboname);
@@ -1097,16 +1142,50 @@ LLSnapshotLivePreview::ESnapshotType LLFloaterSnapshot::Impl::getTypeIndex(LLFlo
 {
 	LLSnapshotLivePreview::ESnapshotType index = LLSnapshotLivePreview::SNAPSHOT_POSTCARD;
 	LLSD value = floater->childGetValue("snapshot_type_radio");
+
 	const std::string id = value.asString();
 	if (id == "postcard")
+	{
 		index = LLSnapshotLivePreview::SNAPSHOT_POSTCARD;
+	}
 	else if (id == "texture")
+	{
 		index = LLSnapshotLivePreview::SNAPSHOT_TEXTURE;
+	}
 	else if (id == "local")
+	{
 		index = LLSnapshotLivePreview::SNAPSHOT_LOCAL;
+	}
+	else if (id == "share_to_web")
+	{
+		index = LLSnapshotLivePreview::SNAPSHOT_WEB;
+	}
+
 	return index;
 }
 
+// static
+LLSD LLFloaterSnapshot::Impl::getTypeName(LLSnapshotLivePreview::ESnapshotType index)
+{
+	std::string id;
+	switch (index)
+	{
+		case LLSnapshotLivePreview::SNAPSHOT_WEB:
+			id = "share_to_web";
+			break;
+		case LLSnapshotLivePreview::SNAPSHOT_POSTCARD:
+			id = "postcard";
+			break;
+		case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:
+			id = "texture";
+			break;
+		case LLSnapshotLivePreview::SNAPSHOT_LOCAL:
+		default:
+			id = "local";
+			break;
+	}
+	return LLSD(id);
+}
 
 // static
 LLFloaterSnapshot::ESnapshotFormat LLFloaterSnapshot::Impl::getFormatIndex(LLFloaterSnapshot* floater)
@@ -1243,11 +1322,14 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
 void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 {
 	LLRadioGroup* snapshot_type_radio = floater->getChild<LLRadioGroup>("snapshot_type_radio");
-	snapshot_type_radio->setSelectedIndex(gSavedSettings.getS32("LastSnapshotType"));
-	LLSnapshotLivePreview::ESnapshotType shot_type = getTypeIndex(floater);
-	ESnapshotFormat shot_format = (ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat"); //getFormatIndex(floater);	LLViewerWindow::ESnapshotType layer_type = getLayerType(floater);
+	LLSnapshotLivePreview::ESnapshotType shot_type = (LLSnapshotLivePreview::ESnapshotType)gSavedSettings.getS32("LastSnapshotType");
+	snapshot_type_radio->setSelectedByValue(getTypeName(shot_type), true);
+
+	ESnapshotFormat shot_format = (ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat");
 	LLViewerWindow::ESnapshotType layer_type = getLayerType(floater);
 
+	floater->childSetVisible("share_to_web", gSavedSettings.getBOOL("SnapshotSharingEnabled"));
+
 	floater->childSetVisible("postcard_size_combo", FALSE);
 	floater->childSetVisible("texture_size_combo", FALSE);
 	floater->childSetVisible("local_size_combo", FALSE);
@@ -1257,17 +1339,19 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 	floater->getChild<LLComboBox>("local_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotLocalLastResolution"));
 	floater->getChild<LLComboBox>("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat"));
 
+	// *TODO: Separate settings for Web images from postcards
+	floater->childSetVisible("send_btn",			shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD ||
+													shot_type == LLSnapshotLivePreview::SNAPSHOT_WEB);
 	floater->childSetVisible("upload_btn",			shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE);
-	floater->childSetVisible("send_btn",			shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD);
 	floater->childSetVisible("save_btn",			shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL);
 	floater->childSetEnabled("keep_aspect_check",	shot_type != LLSnapshotLivePreview::SNAPSHOT_TEXTURE && !floater->impl.mAspectRatioCheckOff);
 	floater->childSetEnabled("layer_types",			shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL);
 
 	BOOL is_advance = gSavedSettings.getBOOL("AdvanceSnapshot");
 	BOOL is_local = shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL;
-	BOOL show_slider = 
-		shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD
-		|| (is_local && shot_format == LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG);
+	BOOL show_slider = (shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD ||
+						shot_type == LLSnapshotLivePreview::SNAPSHOT_WEB ||
+					   (is_local && shot_format == LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG));
 
 	floater->childSetVisible("more_btn", !is_advance); // the only item hidden in advanced mode
 	floater->childSetVisible("less_btn",				is_advance);
@@ -1290,7 +1374,10 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 	BOOL got_bytes = previewp && previewp->getDataSize() > 0;
 	BOOL got_snap = previewp && previewp->getSnapshotUpToDate();
 
-	floater->childSetEnabled("send_btn",   shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD && got_snap && previewp->getDataSize() <= MAX_POSTCARD_DATASIZE);
+	// *TODO: Separate maximum size for Web images from postcards
+	floater->childSetEnabled("send_btn",   (shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD ||
+											shot_type == LLSnapshotLivePreview::SNAPSHOT_WEB) &&
+											got_snap && previewp->getDataSize() <= MAX_POSTCARD_DATASIZE);
 	floater->childSetEnabled("upload_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE  && got_snap);
 	floater->childSetEnabled("save_btn",   shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL    && got_snap);
 
@@ -1311,6 +1398,8 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 
 	switch(shot_type)
 	{
+	  // *TODO: Separate settings for Web images from postcards
+	  case LLSnapshotLivePreview::SNAPSHOT_WEB:
 	  case LLSnapshotLivePreview::SNAPSHOT_POSTCARD:
 		layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
 		floater->childSetValue("layer_types", "colors");
@@ -1402,28 +1491,39 @@ void LLFloaterSnapshot::Impl::onClickKeep(void* data)
 {
 	LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
 	LLSnapshotLivePreview* previewp = getPreviewView(view);
-	
+
 	if (previewp)
 	{
-		if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_POSTCARD)
+		switch (previewp->getSnapshotType())
 		{
-			LLFloaterPostcard* floater = previewp->savePostcard();
-			// if still in snapshot mode, put postcard floater in snapshot floaterview
-			// and link it to snapshot floater
-			if (floater && !gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
+		  case LLSnapshotLivePreview::SNAPSHOT_WEB:
+			previewp->saveWeb();
+			break;
+
+		  case LLSnapshotLivePreview::SNAPSHOT_POSTCARD:
 			{
-				gFloaterView->removeChild(floater);
-				gSnapshotFloaterView->addChild(floater);
-				view->addDependentFloater(floater, FALSE);
+				LLFloaterPostcard* floater = previewp->savePostcard();
+				// if still in snapshot mode, put postcard floater in snapshot floaterview
+				// and link it to snapshot floater
+				if (floater && !gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
+				{
+					gFloaterView->removeChild(floater);
+					gSnapshotFloaterView->addChild(floater);
+					view->addDependentFloater(floater, FALSE);
+				}
 			}
-		}
-		else if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_TEXTURE)
-		{
+			break;
+
+		  case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:
 			previewp->saveTexture();
-		}
-		else
-		{
+			break;
+
+		  case LLSnapshotLivePreview::SNAPSHOT_LOCAL:
 			previewp->saveLocal();
+			break;
+
+		  default:
+			break;
 		}
 
 		if (gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
@@ -1648,18 +1748,22 @@ static std::string lastSnapshotWidthName()
 {
 	switch(gSavedSettings.getS32("LastSnapshotType"))
 	{
-	case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: return "LastSnapshotToEmailWidth";
-	case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:  return "LastSnapshotToInventoryWidth";
-	default:                                       return "LastSnapshotToDiskWidth";
+	  // *TODO: Separate settings for Web snapshots and postcards
+	  case LLSnapshotLivePreview::SNAPSHOT_WEB:		 return "LastSnapshotToEmailWidth";
+	  case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: return "LastSnapshotToEmailWidth";
+	  case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:  return "LastSnapshotToInventoryWidth";
+	  default:                                       return "LastSnapshotToDiskWidth";
 	}
 }
 static std::string lastSnapshotHeightName()
 {
 	switch(gSavedSettings.getS32("LastSnapshotType"))
 	{
-	case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: return "LastSnapshotToEmailHeight";
-	case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:  return "LastSnapshotToInventoryHeight";
-	default:                                       return "LastSnapshotToDiskHeight";
+	  // *TODO: Separate settings for Web snapshots and postcards
+	  case LLSnapshotLivePreview::SNAPSHOT_WEB:	     return "LastSnapshotToEmailHeight";
+	  case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: return "LastSnapshotToEmailHeight";
+	  case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:  return "LastSnapshotToInventoryHeight";
+	  default:                                       return "LastSnapshotToDiskHeight";
 	}
 }
 
@@ -1773,7 +1877,7 @@ void LLFloaterSnapshot::Impl::onCommitSnapshotType(LLUICtrl* ctrl, void* data)
 //static 
 void LLFloaterSnapshot::Impl::onCommitSnapshotFormat(LLUICtrl* ctrl, void* data)
 {
-	LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;		
+	LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
 	if (view)
 	{
 		gSavedSettings.setS32("SnapshotFormat", getFormatIndex(view));
@@ -1994,6 +2098,12 @@ LLFloaterSnapshot::~LLFloaterSnapshot()
 
 BOOL LLFloaterSnapshot::postBuild()
 {
+	// Kick start Web Sharing, to fetch its config data if it needs to.
+	if (gSavedSettings.getBOOL("SnapshotSharingEnabled"))
+	{
+		LLWebSharing::instance().init();
+	}
+
 	childSetCommitCallback("snapshot_type_radio", Impl::onCommitSnapshotType, this);
 	childSetCommitCallback("local_format_combo", Impl::onCommitSnapshotFormat, this);
 	
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 96088fed9cc..e9efc49e277 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -3148,6 +3148,13 @@ bool process_login_success_response()
 		}
 	}
 
+	// Set the location of the snapshot sharing config endpoint
+	std::string snapshot_config_url = response["snapshot_config_url"];
+	if(!snapshot_config_url.empty())
+	{
+		gSavedSettings.setString("SnapshotConfigURL", snapshot_config_url);
+	}
+
 	// Start the process of fetching the OpenID session cookie for this user login
 	std::string openid_url = response["openid_url"];
 	if(!openid_url.empty())
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 34e30b3ccd1..178d928f57e 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -56,6 +56,7 @@
 #include "llvoavatar.h"
 #include "llvoavatarself.h"
 #include "llviewerregion.h"
+#include "llwebsharing.h"	// For LLWebSharing::setOpenIDCookie(), *TODO: find a better way to do this!
 
 #include "llevent.h"		// LLSimpleListener
 #include "llnotificationsutil.h"
@@ -1318,6 +1319,9 @@ void LLViewerMedia::setOpenIDCookie()
 		}
 		
 		getCookieStore()->setCookiesFromHost(sOpenIDCookie, authority.substr(host_start, host_end - host_start));
+
+		// *HACK: Doing this here is nasty, find a better way.
+		LLWebSharing::instance().setOpenIDCookie(sOpenIDCookie);
 	}
 }
 
diff --git a/indra/newview/llwebsharing.cpp b/indra/newview/llwebsharing.cpp
new file mode 100644
index 00000000000..2b9e5cc8cb2
--- /dev/null
+++ b/indra/newview/llwebsharing.cpp
@@ -0,0 +1,609 @@
+/** 
+ * @file llwebsharing.cpp
+ * @author Aimee
+ * @brief Web Snapshot Sharing
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llwebsharing.h"
+
+#include "llagentui.h"
+#include "llbufferstream.h"
+#include "llhttpclient.h"
+#include "llhttpstatuscodes.h"
+#include "llsdserialize.h"
+#include "llsdutil.h"
+#include "llurl.h"
+#include "llviewercontrol.h"
+
+#include <boost/regex.hpp>
+#include <boost/algorithm/string/replace.hpp>
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+class LLWebSharingConfigResponder : public LLHTTPClient::Responder
+{
+	LOG_CLASS(LLWebSharingConfigResponder);
+public:
+	/// Overrides the default LLSD parsing behaviour, to allow parsing a JSON response.
+	virtual void completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer)
+	{
+		LLSD content;
+		LLBufferStream istr(channels, buffer.get());
+		LLPointer<LLSDParser> parser = new LLSDNotationParser();
+
+		if (parser->parse(istr, content, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
+		{
+			LL_WARNS("WebSharing") << "Failed to deserialize LLSD from JSON response. " << " [" << status << "]: " << reason << LL_ENDL;
+		}
+		else
+		{
+			completed(status, reason, content);
+		}
+	}
+
+	virtual void error(U32 status, const std::string& reason)
+	{
+		LL_WARNS("WebSharing") << "Error [" << status << "]: " << reason << LL_ENDL;
+	}
+
+	virtual void result(const LLSD& content)
+	{
+		LLWebSharing::instance().receiveConfig(content);
+	}
+};
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+class LLWebSharingOpenIDAuthResponder : public LLHTTPClient::Responder
+{
+	LOG_CLASS(LLWebSharingOpenIDAuthResponder);
+public:
+	/* virtual */ void completedHeader(U32 status, const std::string& reason, const LLSD& content)
+	{
+		completed(status, reason, content);
+	}
+
+	/* virtual */ void completedRaw(U32 status, const std::string& reason,
+									const LLChannelDescriptors& channels,
+									const LLIOPipe::buffer_ptr_t& buffer)
+	{
+		/// Left empty to override the default LLSD parsing behaviour.
+	}
+
+	virtual void error(U32 status, const std::string& reason)
+	{
+		if (HTTP_UNAUTHORIZED == status)
+		{
+			LL_WARNS("WebSharing") << "AU account not authenticated." << LL_ENDL;
+			// *TODO: No account found on AU, so start the account creation process here.
+		}
+		else
+		{
+			LL_WARNS("WebSharing") << "Error [" << status << "]: " << reason << LL_ENDL;
+			LLWebSharing::instance().retryOpenIDAuth();
+		}
+
+	}
+
+	virtual void result(const LLSD& content)
+	{
+		if (content.has("set-cookie"))
+		{
+			// OpenID request succeeded and returned a session cookie.
+			LLWebSharing::instance().receiveSessionCookie(content["set-cookie"].asString());
+		}
+	}
+};
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+class LLWebSharingSecurityTokenResponder : public LLHTTPClient::Responder
+{
+	LOG_CLASS(LLWebSharingSecurityTokenResponder);
+public:
+	/// Overrides the default LLSD parsing behaviour, to allow parsing a JSON response.
+	virtual void completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer)
+	{
+		LLSD content;
+		LLBufferStream istr(channels, buffer.get());
+		LLPointer<LLSDParser> parser = new LLSDNotationParser();
+
+		if (parser->parse(istr, content, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
+		{
+			LL_WARNS("WebSharing") << "Failed to deserialize LLSD from JSON response. " << " [" << status << "]: " << reason << LL_ENDL;
+			LLWebSharing::instance().retryOpenIDAuth();
+		}
+		else
+		{
+			completed(status, reason, content);
+		}
+	}
+
+	virtual void error(U32 status, const std::string& reason)
+	{
+		LL_WARNS("WebSharing") << "Error [" << status << "]: " << reason << LL_ENDL;
+		LLWebSharing::instance().retryOpenIDAuth();
+	}
+
+	virtual void result(const LLSD& content)
+	{
+		if (content[0].has("st") && content[0].has("expires"))
+		{
+			const std::string& token   = content[0]["st"].asString();
+			const std::string& expires = content[0]["expires"].asString();
+			if (LLWebSharing::instance().receiveSecurityToken(token, expires))
+			{
+				// Sucessfully received a valid security token.
+				return;
+			}
+		}
+		else
+		{
+			LL_WARNS("WebSharing") << "No security token received." << LL_ENDL;
+		}
+
+		LLWebSharing::instance().retryOpenIDAuth();
+	}
+};
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+class LLWebSharingUploadResponder : public LLHTTPClient::Responder
+{
+	LOG_CLASS(LLWebSharingUploadResponder);
+public:
+	/// Overrides the default LLSD parsing behaviour, to allow parsing a JSON response.
+	virtual void completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer)
+	{
+/*
+		 // Dump the body, for debugging.
+
+		 LLBufferStream istr1(channels, buffer.get());
+		 std::ostringstream ostr;
+		 std::string body;
+
+		 while (istr1.good())
+		 {
+			char buf[1024];
+			istr1.read(buf, sizeof(buf));
+			body.append(buf, istr1.gcount());
+		 }
+		 LL_DEBUGS("WebSharing") << body << LL_ENDL;
+*/
+		LLSD content;
+		LLBufferStream istr(channels, buffer.get());
+		LLPointer<LLSDParser> parser = new LLSDNotationParser();
+
+		if (parser->parse(istr, content, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
+		{
+			LL_WARNS("WebSharing") << "Failed to deserialize LLSD from JSON response. " << " [" << status << "]: " << reason << LL_ENDL;
+		}
+		else
+		{
+			completed(status, reason, content);
+		}
+	}
+
+	virtual void error(U32 status, const std::string& reason)
+	{
+		LL_WARNS("WebSharing") << "Error [" << status << "]: " << reason << LL_ENDL;
+	}
+
+	virtual void result(const LLSD& content)
+	{
+		if (content[0].has("result") && content[0].has("id") &&
+			content[0]["id"].asString() == "newMediaItem")
+		{
+			// *TODO: Upload successful, continue from here to post metadata and create AU activity.
+		}
+		else
+		{
+			LL_WARNS("WebSharing") << "Error [" << content[0]["code"].asString()
+								   << "]: " << content[0]["message"].asString() << LL_ENDL;
+		}
+	}
+};
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+LLWebSharing::LLWebSharing()
+:	mConfig(),
+	mSecurityToken(LLSD::emptyMap()),
+	mEnabled(false),
+	mRetries(0),
+	mImage(NULL),
+	mMetadata(LLSD::emptyMap())
+{
+}
+
+void LLWebSharing::init()
+{
+	if (!mEnabled)
+	{
+		sendConfigRequest();
+	}
+}
+
+bool LLWebSharing::shareSnapshot(LLImageJPEG* snapshot, LLSD& metadata)
+{
+	LL_INFOS("WebSharing") << metadata << LL_ENDL;
+
+	if (mImage)
+	{
+		// *TODO: Handle this possibility properly, queue them up?
+		LL_WARNS("WebSharing") << "Snapshot upload already in progress." << LL_ENDL;
+		return false;
+	}
+
+	mImage = snapshot;
+	mMetadata = metadata;
+
+	// *TODO: Check whether we have a valid security token already and re-use it.
+	sendOpenIDAuthRequest();
+	return true;
+}
+
+bool LLWebSharing::setOpenIDCookie(const std::string& cookie)
+{
+	LL_DEBUGS("WebSharing") << "Setting OpenID cookie " << cookie << LL_ENDL;
+	mOpenIDCookie = cookie;
+	return validateConfig();
+}
+
+bool LLWebSharing::receiveConfig(const LLSD& config)
+{
+	LL_DEBUGS("WebSharing") << "Received config data: " << config << LL_ENDL;
+	mConfig = config;
+	return validateConfig();
+}
+
+bool LLWebSharing::receiveSessionCookie(const std::string& cookie)
+{
+	LL_DEBUGS("WebSharing") << "Received AU session cookie: " << cookie << LL_ENDL;
+	mSessionCookie = cookie;
+
+	// Fetch a security token using the new session cookie.
+	LLWebSharing::instance().sendSecurityTokenRequest();
+
+	return (!mSessionCookie.empty());
+}
+
+bool LLWebSharing::receiveSecurityToken(const std::string& token, const std::string& expires)
+{
+	mSecurityToken["st"] = token;
+	mSecurityToken["expires"] = LLDate(expires);
+
+	if (!securityTokenIsValid(mSecurityToken))
+	{
+		LL_WARNS("WebSharing") << "Invalid security token received: \"" << token << "\" Expires: " << expires << LL_ENDL;
+		return false;
+	}
+
+	LL_DEBUGS("WebSharing") << "Received security token: \"" << token << "\" Expires: " << expires << LL_ENDL;
+	mRetries = 0;
+
+	// Continue the upload process now that we have a security token.
+	sendUploadRequest();
+
+	return true;
+}
+
+void LLWebSharing::sendConfigRequest()
+{
+	std::string config_url = gSavedSettings.getString("SnapshotConfigURL");
+	LL_DEBUGS("WebSharing") << "Requesting Snapshot Sharing config data from: " << config_url << LL_ENDL;
+
+	LLSD headers = LLSD::emptyMap();
+	headers["Accept"] = "application/json";
+
+	LLHTTPClient::get(config_url, new LLWebSharingConfigResponder(), headers);
+}
+
+void LLWebSharing::sendOpenIDAuthRequest()
+{
+	std::string auth_url = mConfig["openIdAuthUrl"];
+	LL_DEBUGS("WebSharing") << "Starting OpenID Auth: " << auth_url << LL_ENDL;
+
+	LLSD headers = LLSD::emptyMap();
+	headers["Cookie"] = mOpenIDCookie;
+	headers["Accept"] = "*/*";
+
+	// Send request, successful login will trigger fetching a security token.
+	LLHTTPClient::get(auth_url, new LLWebSharingOpenIDAuthResponder(), headers);
+}
+
+bool LLWebSharing::retryOpenIDAuth()
+{
+	if (mRetries++ >= MAX_AUTH_RETRIES)
+	{
+		LL_WARNS("WebSharing") << "Exceeded maximum number of authorization attempts, aborting." << LL_ENDL;
+		mRetries = 0;
+		return false;
+	}
+
+	LL_WARNS("WebSharing") << "Authorization failed, retrying (" << mRetries << "/" << MAX_AUTH_RETRIES << ")" << LL_ENDL;
+	sendOpenIDAuthRequest();
+	return true;
+}
+
+void LLWebSharing::sendSecurityTokenRequest()
+{
+	std::string token_url = mConfig["securityTokenUrl"];
+	LL_DEBUGS("WebSharing") << "Fetching security token from: " << token_url << LL_ENDL;
+
+	LLSD headers = LLSD::emptyMap();
+	headers["Cookie"] = mSessionCookie;
+
+	headers["Accept"] = "application/json";
+	headers["Content-Type"] = "application/json";
+
+	std::ostringstream body;
+	body << "{ \"gadgets\": [{ \"url\":\""
+		 << mConfig["gadgetSpecUrl"].asString()
+		 << "\" }] }";
+
+	// postRaw() takes ownership of the buffer and releases it later.
+	size_t size = body.str().size();
+	U8 *data = new U8[size];
+	memcpy(data, body.str().data(), size);
+
+	// Send request, receiving a valid token will trigger snapshot upload.
+	LLHTTPClient::postRaw(token_url, data, size, new LLWebSharingSecurityTokenResponder(), headers);
+}
+
+void LLWebSharing::sendUploadRequest()
+{
+	LLUriTemplate upload_template(mConfig["openSocialRpcUrlTemplate"].asString());
+	std::string upload_url(upload_template.buildURI(mSecurityToken));
+
+	LL_DEBUGS("WebSharing") << "Posting upload to: " << upload_url << LL_ENDL;
+
+	static const std::string BOUNDARY("------------abcdef012345xyZ");
+
+	LLSD headers = LLSD::emptyMap();
+	headers["Cookie"] = mSessionCookie;
+
+	headers["Accept"] = "application/json";
+	headers["Content-Type"] = "multipart/form-data; boundary=" + BOUNDARY;
+
+	std::ostringstream body;
+	body << "--" << BOUNDARY << "\r\n"
+		 << "Content-Disposition: form-data; name=\"request\"\r\n\r\n"
+		 << "[{"
+		 <<	  "\"method\":\"mediaItems.create\","
+		 <<	  "\"params\": {"
+		 <<	    "\"userId\":[\"@me\"],"
+		 <<	    "\"groupId\":\"@self\","
+		 <<	    "\"mediaItem\": {"
+		 <<	      "\"mimeType\":\"image/jpeg\","
+		 <<	      "\"type\":\"image\","
+		 <<       "\"url\":\"@field:image1\""
+		 <<	    "}"
+		 <<	  "},"
+		 <<	  "\"id\":\"newMediaItem\""
+		 <<	"}]"
+		 <<	"--" << BOUNDARY << "\r\n"
+		 <<	"Content-Disposition: form-data; name=\"image1\"\r\n\r\n";
+
+	// Insert the image data.
+	// *FIX: Treating this as a string will probably screw it up ...
+	U8* image_data = mImage->getData();
+	for (S32 i = 0; i < mImage->getDataSize(); ++i)
+	{
+		body << image_data[i];
+	}
+
+	body <<	"\r\n--" << BOUNDARY << "--\r\n";
+
+	// postRaw() takes ownership of the buffer and releases it later.
+	size_t size = body.str().size();
+	U8 *data = new U8[size];
+	memcpy(data, body.str().data(), size);
+
+	// Send request, successful upload will trigger posting metadata.
+	LLHTTPClient::postRaw(upload_url, data, size, new LLWebSharingUploadResponder(), headers);
+}
+
+bool LLWebSharing::validateConfig()
+{
+	// Check the OpenID Cookie has been set.
+	if (mOpenIDCookie.empty())
+	{
+		mEnabled = false;
+		return mEnabled;
+	}
+
+	if (!mConfig.isMap())
+	{
+		mEnabled = false;
+		return mEnabled;
+	}
+
+	// Template to match the received config against.
+	LLSD required(LLSD::emptyMap());
+	required["gadgetSpecUrl"] = "";
+	required["loginTokenUrl"] = "";
+	required["openIdAuthUrl"] = "";
+	required["photoPageUrlTemplate"] = "";
+	required["openSocialRpcUrlTemplate"] = "";
+	required["securityTokenUrl"] = "";
+	required["tokenBasedLoginUrlTemplate"] = "";
+	required["viewerIdUrl"] = "";
+
+	std::string mismatch(llsd_matches(required, mConfig));
+	if (!mismatch.empty())
+	{
+		LL_WARNS("WebSharing") << "Malformed config data response: " << mismatch << LL_ENDL;
+		mEnabled = false;
+		return mEnabled;
+	}
+
+	mEnabled = true;
+	return mEnabled;
+}
+
+// static
+bool LLWebSharing::securityTokenIsValid(LLSD& token)
+{
+	return (token.has("st") &&
+			token.has("expires") &&
+			(token["st"].asString() != "") &&
+			(token["expires"].asDate() > LLDate::now()));
+}
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+LLUriTemplate::LLUriTemplate(const std::string& uri_template)
+	:
+	mTemplate(uri_template)
+{
+}
+
+std::string LLUriTemplate::buildURI(const LLSD& vars)
+{
+	// *TODO: Separate parsing the template from building the URI.
+	// Parsing only needs to happen on construction/assignnment.
+
+	static const std::string VAR_NAME_REGEX("[[:alpha:]][[:alnum:]\\._-]*");
+	// Capture var name with and without surrounding {}
+	static const std::string VAR_REGEX("\\{(" + VAR_NAME_REGEX + ")\\}");
+	// Capture delimiter and comma separated list of var names.
+	static const std::string JOIN_REGEX("\\{-join\\|(&)\\|(" + VAR_NAME_REGEX + "(?:," + VAR_NAME_REGEX + ")*)\\}");
+
+	std::string uri = mTemplate;
+	boost::smatch results;
+
+	// Validate and expand join operators : {-join|&|var1,var2,...}
+
+	boost::regex join_regex(JOIN_REGEX);
+
+	while (boost::regex_search(uri, results, join_regex))
+	{
+		// Extract the list of var names from the results.
+		std::string delim = results[1].str();
+		std::string var_list = results[2].str();
+
+		// Expand the list of vars into a query string with their values
+		std::string query = expandJoin(delim, var_list, vars);
+
+		// Substitute the query string into the template.
+		uri = boost::regex_replace(uri, join_regex, query, boost::format_first_only);
+	}
+
+	// Expand vars : {var1}
+
+	boost::regex var_regex(VAR_REGEX);
+
+	std::set<std::string> var_names;
+	std::string::const_iterator start = uri.begin();
+	std::string::const_iterator end = uri.end();
+
+	// Extract the var names used.
+	while (boost::regex_search(start, end, results, var_regex))
+	{
+		var_names.insert(results[1].str());
+		start = results[0].second;
+	}
+
+	// Replace each var with its value.
+	for (std::set<std::string>::const_iterator it = var_names.begin(); it != var_names.end(); ++it)
+	{
+		std::string var = *it;
+		if (vars.has(var))
+		{
+			boost::replace_all(uri, "{" + var + "}", vars[var].asString());
+		}
+	}
+
+	return uri;
+}
+
+std::string LLUriTemplate::expandJoin(const std::string& delim, const std::string& var_list, const LLSD& vars)
+{
+	std::ostringstream query;
+
+	typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
+	boost::char_separator<char> sep(",");
+	tokenizer var_names(var_list, sep);
+	tokenizer::const_iterator it = var_names.begin();
+
+	// First var does not need a delimiter
+	if (it != var_names.end())
+	{
+		const std::string& name = *it;
+		if (vars.has(name))
+		{
+			// URL encode the value before appending the name=value pair.
+			query << name << "=" << escapeURL(vars[name].asString());
+		}
+	}
+
+	for (++it; it != var_names.end(); ++it)
+	{
+		const std::string& name = *it;
+		if (vars.has(name))
+		{
+			// URL encode the value before appending the name=value pair.
+			query << delim << name << "=" << escapeURL(vars[name].asString());
+		}
+	}
+
+	return query.str();
+}
+
+// static
+std::string LLUriTemplate::escapeURL(const std::string& unescaped)
+{
+	char* escaped = curl_escape(unescaped.c_str(), unescaped.size());
+	std::string result = escaped;
+	curl_free(escaped);
+	return result;
+}
+
diff --git a/indra/newview/llwebsharing.h b/indra/newview/llwebsharing.h
new file mode 100644
index 00000000000..70046ff1d83
--- /dev/null
+++ b/indra/newview/llwebsharing.h
@@ -0,0 +1,230 @@
+/** 
+ * @file llwebsharing.h
+ * @author Aimee
+ * @brief Web Snapshot Sharing
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLWEBSHARING_H
+#define LL_LLWEBSHARING_H
+
+#include "llimagejpeg.h"
+#include "llsingleton.h"
+
+
+
+/**
+ * @class LLWebSharing
+ *
+ * Manages authentication to, and interaction with, a web service allowing the
+ * upload of snapshot images taken within the viewer, using OpenID and the
+ * OpenSocial APIs.
+ * http://www.opensocial.org/Technical-Resources/opensocial-spec-v09/RPC-Protocol.html
+ */
+class LLWebSharing : public LLSingleton<LLWebSharing>
+{
+	LOG_CLASS(LLWebSharing);
+public:
+	/*
+	 * Performs initial setup, by requesting config data from the web service if
+	 * it has not already been received.
+	 */
+	void init();
+
+	/*
+	 * @return true if both the OpenID cookie and config data have been received.
+	 */
+	bool enabled() const { return mEnabled; };
+
+	/*
+	 * Sets the OpenID cookie to use for login to the web service.
+	 *
+	 * @param cookie a string containing the OpenID cookie.
+	 *
+	 * @return true if both the OpenID cookie and config data have been received.
+	 */
+	bool setOpenIDCookie(const std::string& cookie);
+
+	/*
+	 * Receive config data used to connect to the web service.
+	 *
+	 * @param config an LLSD map of URL templates for the web service end-points.
+	 *
+	 * @return true if both the OpenID cookie and config data have been received.
+	 *
+	 * @see sendConfigRequest()
+	 */
+	bool receiveConfig(const LLSD& config);
+
+	/*
+	 * Receive the session cookie from the web service, which is the result of
+	 * the OpenID login process.
+	 *
+	 * @see sendOpenIDAuthRequest()
+	 */
+	bool receiveSessionCookie(const std::string& cookie);
+
+	/*
+	 * Receive a security token for the upload service.
+	 *
+	 * @see sendSecurityTokenRequest()
+	 */
+	bool receiveSecurityToken(const std::string& token, const std::string& expires);
+
+	/*
+	 * Restarts the authentication process if the maximum number of retries has
+	 * not been exceeded.
+	 *
+	 * @return true if retrying, false if LLWebSharing::MAX_AUTH_RETRIES has been exceeded.
+	 */
+	bool retryOpenIDAuth();
+
+	/*
+	 * Post a snapshot to the upload service.
+	 *
+	 * @return true if accepted for upload, false if already uploading another image.
+	 */
+	bool shareSnapshot(LLImageJPEG* snapshot, LLSD& metadata);
+
+private:
+	static const S32 MAX_AUTH_RETRIES = 4;
+
+	friend class LLSingleton<LLWebSharing>;
+
+	LLWebSharing();
+	~LLWebSharing() {};
+
+	/*
+	 * Request a map of URLs and URL templates to the web service end-points.
+	 *
+	 * @see receiveConfig()
+	 */
+	void sendConfigRequest();
+
+	/*
+	 * Initiate the OpenID login process.
+	 *
+	 * @see receiveSessionCookie()
+	 */
+	void sendOpenIDAuthRequest();
+
+	/*
+	 * Request a security token for the upload service.
+	 *
+	 * @see receiveSecurityToken()
+	 */
+	void sendSecurityTokenRequest();
+
+	/*
+	 * Request a security token for the upload service.
+	 *
+	 * @see receiveSecurityToken()
+	 */
+	void sendUploadRequest();
+
+	/*
+	 * Checks all necessary config information has been received, and sets mEnabled.
+	 *
+	 * @return true if both the OpenID cookie and config data have been received.
+	 */
+	bool validateConfig();
+
+	/*
+	 * Checks the security token is present and has not expired.
+	 *
+	 * @param token an LLSD map containing the token string and the time it expires.
+	 *
+	 * @return true if the token is not empty and has not expired.
+	 */
+	static bool securityTokenIsValid(LLSD& token);
+
+	std::string mOpenIDCookie;
+	std::string mSessionCookie;
+	LLSD mSecurityToken;
+
+	LLSD mConfig;
+	bool mEnabled;
+
+	LLPointer<LLImageJPEG> mImage;
+	LLSD mMetadata;
+
+	S32 mRetries;
+};
+
+/**
+ * @class LLUriTemplate
+ *
+ * @brief Builds complete URIs, given URI template and a map of keys and values
+ *        to use for substition.
+ *        Note: This is only a partial implementation of a draft standard required
+ *        by the web API used by LLWebSharing.
+ *        See: http://tools.ietf.org/html/draft-gregorio-uritemplate-03
+ *
+ * @see LLWebSharing
+ */
+class LLUriTemplate
+{
+	LOG_CLASS(LLUriTemplate);
+public:
+	LLUriTemplate(const std::string& uri_template);
+	~LLUriTemplate() {};
+
+	/*
+	 * Builds a complete URI from the template.
+	 *
+	 * @param vars an LLSD map of keys and values for substitution.
+	 *
+	 * @return a string containing the complete URI.
+	 */
+	std::string buildURI(const LLSD& vars);
+
+private:
+	/*
+	 * Builds a URL query string.
+	 *
+	 * @param delim    a string containing the separator to use between name=value pairs.
+	 * @param var_list a string containing a comma separated list of variable names.
+	 * @param vars     an LLSD map of keys and values for substitution.
+	 *
+	 * @return a URL query string.
+	 */
+	std::string expandJoin(const std::string& delim, const std::string& var_list, const LLSD& vars);
+
+	/*
+	 * URL escape the given string.
+	 * LLWeb::escapeURL() only does a partial escape, so this uses curl_escape() instead.
+	 */
+	static std::string escapeURL(const std::string& unescaped);
+
+	std::string mTemplate;
+};
+
+
+
+#endif // LL_LLWEBSHARING_H
diff --git a/indra/newview/skins/default/xui/en/floater_snapshot.xml b/indra/newview/skins/default/xui/en/floater_snapshot.xml
index 452b2ac664f..857932e51a1 100644
--- a/indra/newview/skins/default/xui/en/floater_snapshot.xml
+++ b/indra/newview/skins/default/xui/en/floater_snapshot.xml
@@ -4,48 +4,52 @@
  can_minimize="false"
  can_close="true"
  follows="left|top"
- height="516"
+ height="520"
  layout="topleft"
  name="Snapshot"
  help_topic="snapshot"
  save_rect="true"
  save_visibility="true"
  title="SNAPSHOT PREVIEW"
- width="215">   
-    <floater.string
-     name="share_to_web_url" translate="false">
-http://pdp36.lindenlab.com:12777/
-    </floater.string>
+ width="215">
     <floater.string
      name="unknown">
         unknown
     </floater.string>
     <radio_group
-     height="58"
+     height="70"
      label="Snapshot type"
      layout="topleft"
      left="10"
      name="snapshot_type_radio"
-     top="25"
+     top="20"
      width="205">
+<!--
         <radio_item
-         bottom="19"
+         height="16"
+         label="Share to Web"
+         layout="topleft"
+         name="share_to_web"
+         top_pad="0" />
+-->
+         <radio_item
          height="16"
          label="Email"
          layout="topleft"
-         name="postcard" />
+         name="postcard"
+         top_pad="2" />
         <radio_item
-         bottom="38"
          height="16"
          label="My inventory (L$[AMOUNT])"
          layout="topleft"
-         name="texture" />
+         name="texture"
+         top_pad="2" />
         <radio_item
-         bottom="57"
          height="16"
          label="Save to my computer"
          layout="topleft"
-         name="local" />
+         name="local"
+         top_pad="2" />
     </radio_group>
   <ui_ctrl 
     height="90"
@@ -67,7 +71,7 @@ http://pdp36.lindenlab.com:12777/
      left_delta="0"
      halign="right"
      name="file_size_label"
-     top_pad="10"
+     top_pad="8"
      width="195">
         [SIZE] KB
     </text>
-- 
GitLab


From 0fc367441762d85dd77867e78ff75b867c946b4a Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Mon, 28 Jun 2010 14:40:09 -0700
Subject: [PATCH 504/683] Updated install.xml for linux/windows to point to
 newest llconvexdecomposition.

---
 install.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/install.xml b/install.xml
index 40ec65b2b01..2e7fa762201 100644
--- a/install.xml
+++ b/install.xml
@@ -1051,16 +1051,16 @@ anguage Infrstructure (CLI) international standard</string>
           <key>windows</key>
           <map>
             <key>md5sum</key>
-            <string>9b895f616dfb5ce9814d4e53417950a9</string>
+            <string>afd03c92ac261134237b648896c5e537</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-windows-20100622.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-windows-20100628.tar.bz2</uri>
           </map>
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>da4d464008fac288865f259873cafad2</string>
+            <string>3427b3c31ed66132b19e1f6679894c57</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100622.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100628.tar.bz2</uri>
           </map>
           <key>darwin</key>
           <map>
-- 
GitLab


From b54fd9d6855c8547ce03beacf1ef04eb6396e75e Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 29 Jun 2010 13:04:31 +0100
Subject: [PATCH 505/683] VWR-8885 CMAKE build hard depends on artwork files

Warn earlier, clearer and harder about missing artwork bundle - this still bites snowglobe builders regularly.
Reviewed by Aimee.
---
 indra/cmake/ViewerMiscLibs.cmake             | 7 +++++++
 indra/newview/ViewerInstall.cmake            | 4 ++--
 indra/newview/res/have_artwork_bundle.marker | 1 +
 3 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 indra/newview/res/have_artwork_bundle.marker

diff --git a/indra/cmake/ViewerMiscLibs.cmake b/indra/cmake/ViewerMiscLibs.cmake
index 2a8abdac23a..32c4bc81dfc 100644
--- a/indra/cmake/ViewerMiscLibs.cmake
+++ b/indra/cmake/ViewerMiscLibs.cmake
@@ -7,3 +7,10 @@ if (NOT STANDALONE)
   use_prebuilt_binary(fontconfig)
 endif(NOT STANDALONE)
 
+if(VIEWER AND NOT STANDALONE)
+  if(EXISTS ${CMAKE_SOURCE_DIR}/newview/res/have_artwork_bundle.marker)
+    message(STATUS "We seem to have an artwork bundle in the tree - brilliant.")
+  else(EXISTS ${CMAKE_SOURCE_DIR}/newview/res/have_artwork_bundle.marker)
+    message(FATAL_ERROR "Didn't find an artwork bundle - this needs to be downloaded separately and unpacked into this tree.  You can probably get it from the same place you got your viewer source.  Thanks!")
+  endif(EXISTS ${CMAKE_SOURCE_DIR}/newview/res/have_artwork_bundle.marker)
+endif(VIEWER AND NOT STANDALONE)
diff --git a/indra/newview/ViewerInstall.cmake b/indra/newview/ViewerInstall.cmake
index 8168e91a068..0b0d3e2adc5 100644
--- a/indra/newview/ViewerInstall.cmake
+++ b/indra/newview/ViewerInstall.cmake
@@ -7,8 +7,8 @@ install(DIRECTORY skins app_settings linux_tools
         PATTERN ".svn" EXCLUDE
         )
 
-find_file(IS_ARTWORK_PRESENT NAMES avatar_lad.xml
-          PATHS ${VIEWER_DIR}/newview/character)
+find_file(IS_ARTWORK_PRESENT NAMES have_artwork_bundle.marker
+          PATHS ${VIEWER_DIR}/newview/res)
 
 if (IS_ARTWORK_PRESENT)
   install(DIRECTORY res res-sdl character
diff --git a/indra/newview/res/have_artwork_bundle.marker b/indra/newview/res/have_artwork_bundle.marker
new file mode 100644
index 00000000000..1dbb238d536
--- /dev/null
+++ b/indra/newview/res/have_artwork_bundle.marker
@@ -0,0 +1 @@
+If this file exists then you have the artwork bundle installed, which is packaged separately from the Viewer source in the open-source tree.  This marker is for the benefit of the build system so it can warn you properly if it's not there. :)
-- 
GitLab


From a7fba99d55f335f3f366cac351b782b803cdf349 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Tue, 29 Jun 2010 20:07:33 +0300
Subject: [PATCH 506/683] EXT-7676 FIXED Added items sorting from gear menu for
 'Add Wearable'. - Added new gear menu when 'Add Wearable' panel is open in
 'Edit Outfit'. - Added wearable items list comparator to sort by wearable
 creation date. - Added storing sorting type in viewer settings.

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/661/.

--HG--
branch : product-engine
---
 indra/newview/app_settings/settings.xml       |  11 ++
 indra/newview/llinventorylistitem.cpp         |  11 ++
 indra/newview/llinventorylistitem.h           |   3 +
 indra/newview/llpaneloutfitedit.cpp           | 172 +++++++++++++++++-
 indra/newview/llpaneloutfitedit.h             |   5 +-
 indra/newview/llwearableitemslist.cpp         |  44 ++++-
 indra/newview/llwearableitemslist.h           |  26 +++
 .../default/xui/en/menu_add_wearable_gear.xml |  41 +++++
 8 files changed, 303 insertions(+), 10 deletions(-)
 create mode 100644 indra/newview/skins/default/xui/en/menu_add_wearable_gear.xml

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index dd93f1bfa6b..3055207ba9b 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -35,6 +35,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>AddWearableSortOrder</key>
+    <map>
+      <key>Comment</key>
+      <string>Specifies sort order for add wearable panel (0 = name, 1 = date, 2 = by type)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>U32</string>
+      <key>Value</key>
+      <integer>0</integer>
+    </map>
     <key>AgentPause</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llinventorylistitem.cpp b/indra/newview/llinventorylistitem.cpp
index c487aa10a7c..7ed4c0dbe59 100644
--- a/indra/newview/llinventorylistitem.cpp
+++ b/indra/newview/llinventorylistitem.cpp
@@ -211,6 +211,17 @@ const std::string& LLPanelInventoryListItemBase::getDescription() const
 	return inv_item->getDescription();
 }
 
+time_t LLPanelInventoryListItemBase::getCreationDate() const
+{
+	LLViewerInventoryItem* inv_item = getItem();
+	if (NULL == inv_item)
+	{
+		return 0;
+	}
+
+	return inv_item->getCreationDate();
+}
+
 LLViewerInventoryItem* LLPanelInventoryListItemBase::getItem() const
 {
 	return gInventory.getItem(mInventoryItemUUID);
diff --git a/indra/newview/llinventorylistitem.h b/indra/newview/llinventorylistitem.h
index f29d92d51c5..600bf772301 100644
--- a/indra/newview/llinventorylistitem.h
+++ b/indra/newview/llinventorylistitem.h
@@ -146,6 +146,9 @@ class LLPanelInventoryListItemBase : public LLPanel
 	/** Get the description of a corresponding inventory item */
 	const std::string& getDescription() const;
 
+	/** Get the creation date of a corresponding inventory item */
+	time_t getCreationDate() const;
+
 	/** Get the associated inventory item */
 	LLViewerInventoryItem* getItem() const;
 
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index ffd879dfd75..6a859696498 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -43,7 +43,6 @@
 #include "llcofwearables.h"
 #include "llfilteredwearablelist.h"
 #include "llinventory.h"
-#include "llinventoryitemslist.h"
 #include "llviewercontrol.h"
 #include "llui.h"
 #include "llfloater.h"
@@ -84,6 +83,11 @@ const U64 ALL_ITEMS_MASK = WEARABLE_MASK | ATTACHMENT_MASK;
 
 static const std::string REVERT_BTN("revert_btn");
 
+
+///////////////////////////////////////////////////////////////////////////////
+// LLShopURLDispatcher
+///////////////////////////////////////////////////////////////////////////////
+
 class LLShopURLDispatcher
 {
 public:
@@ -143,6 +147,10 @@ std::string LLShopURLDispatcher::resolveURL(LLAssetType::EType asset_type, ESex
 	return gSavedSettings.getString(setting_name);
 }
 
+///////////////////////////////////////////////////////////////////////////////
+// LLPanelOutfitEditGearMenu
+///////////////////////////////////////////////////////////////////////////////
+
 class LLPanelOutfitEditGearMenu
 {
 public:
@@ -158,7 +166,6 @@ class LLPanelOutfitEditGearMenu
 		if (menu)
 		{
 			populateCreateWearableSubmenus(menu);
-			menu->buildDrawLabels();
 		}
 
 		return menu;
@@ -207,6 +214,131 @@ class LLPanelOutfitEditGearMenu
 	}
 };
 
+///////////////////////////////////////////////////////////////////////////////
+// LLAddWearablesGearMenu
+///////////////////////////////////////////////////////////////////////////////
+
+class LLAddWearablesGearMenu : public LLInitClass<LLAddWearablesGearMenu>
+{
+public:
+	static LLMenuGL* create(LLWearableItemsList* flat_list, LLInventoryPanel* inventory_panel)
+	{
+		LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
+		LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
+
+		llassert(flat_list);
+		llassert(inventory_panel);
+
+		registrar.add("AddWearable.Gear.Sort", boost::bind(onSort, flat_list, inventory_panel, _2));
+		enable_registrar.add("AddWearable.Gear.Check", boost::bind(onCheck, flat_list, inventory_panel, _2));
+		enable_registrar.add("AddWearable.Gear.Visible", boost::bind(onVisible, inventory_panel, _2));
+
+		LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(
+			"menu_add_wearable_gear.xml",
+			LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
+
+		return menu;
+	}
+
+private:
+	static void onSort(LLWearableItemsList* flat_list,
+					   LLInventoryPanel* inventory_panel,
+					   LLSD::String sort_order_str)
+	{
+		if (!flat_list || !inventory_panel) return;
+
+		LLWearableItemsList::ESortOrder	sort_order;
+
+		if ("by_most_recent" == sort_order_str)
+		{
+			sort_order = LLWearableItemsList::E_SORT_BY_MOST_RECENT;
+		}
+		else if ("by_name" == sort_order_str)
+		{
+			sort_order = LLWearableItemsList::E_SORT_BY_NAME;
+		}
+		else if ("by_type" == sort_order_str)
+		{
+			sort_order = LLWearableItemsList::E_SORT_BY_TYPE;
+		}
+		else
+		{
+			llwarns << "Unrecognized sort order action" << llendl;
+			return;
+		}
+
+		if (inventory_panel->getVisible())
+		{
+			inventory_panel->setSortOrder(sort_order);
+		}
+		else
+		{
+			flat_list->setSortOrder(sort_order);
+			gSavedSettings.setU32("AddWearableSortOrder", sort_order);
+		}
+	}
+
+	static bool onCheck(LLWearableItemsList* flat_list,
+						LLInventoryPanel* inventory_panel,
+						LLSD::String sort_order_str)
+	{
+		if (!inventory_panel || !flat_list) return false;
+
+		// Inventory panel uses its own sort order independent from
+		// flat list view so this flag is used to distinguish between
+		// currently visible "tree" or "flat" representation of inventory.
+		bool inventory_tree_visible = inventory_panel->getVisible();
+
+		if (inventory_tree_visible)
+		{
+			U32 sort_order = inventory_panel->getSortOrder();
+
+			if ("by_most_recent" == sort_order_str)
+			{
+				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & sort_order;
+			}
+			else if ("by_name" == sort_order_str)
+			{
+				// If inventory panel is not sorted by date then it is sorted by name.
+				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & ~sort_order;
+			}
+			llwarns << "Unrecognized inventory panel sort order" << llendl;
+		}
+		else
+		{
+			LLWearableItemsList::ESortOrder	sort_order = flat_list->getSortOrder();
+
+			if ("by_most_recent" == sort_order_str)
+			{
+				return LLWearableItemsList::E_SORT_BY_MOST_RECENT == sort_order;
+			}
+			else if ("by_name" == sort_order_str)
+			{
+				return LLWearableItemsList::E_SORT_BY_NAME == sort_order;
+			}
+			else if ("by_type" == sort_order_str)
+			{
+				return LLWearableItemsList::E_SORT_BY_TYPE == sort_order;
+			}
+			llwarns << "Unrecognized wearable list sort order" << llendl;
+		}
+		return false;
+	}
+
+	static bool onVisible(LLInventoryPanel* inventory_panel,
+						  LLSD::String sort_order_str)
+	{
+		// Enable sorting by type only for the flat list of items
+		// because inventory panel doesn't support this kind of sorting.
+		return ( "by_type" == sort_order_str )
+				&&	( !inventory_panel || !inventory_panel->getVisible() );
+	}
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// LLCOFDragAndDropObserver
+///////////////////////////////////////////////////////////////////////////////
+
 class LLCOFDragAndDropObserver : public LLInventoryAddItemByAssetObserver
 {
 public:
@@ -242,12 +374,17 @@ void LLCOFDragAndDropObserver::done()
 	LLAppearanceMgr::instance().updateAppearanceFromCOF();
 }
 
+///////////////////////////////////////////////////////////////////////////////
+// LLPanelOutfitEdit
+///////////////////////////////////////////////////////////////////////////////
+
 LLPanelOutfitEdit::LLPanelOutfitEdit()
 :	LLPanel(), 
 	mSearchFilter(NULL),
 	mCOFWearables(NULL),
 	mInventoryItemsPanel(NULL),
 	mGearMenu(NULL),
+	mAddWearablesGearMenu(NULL),
 	mCOFDragAndDropObserver(NULL),
 	mInitialized(false),
 	mAddWearablesPanel(NULL),
@@ -384,10 +521,11 @@ BOOL LLPanelOutfitEdit::postBuild()
 	childSetAction(REVERT_BTN, boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance()));
 
 	mWearablesListViewPanel = getChild<LLPanel>("filtered_wearables_panel");
-	mWearableItemsList = getChild<LLInventoryItemsList>("list_view");
+	mWearableItemsList = getChild<LLWearableItemsList>("list_view");
 	mWearableItemsList->setCommitOnSelectionChange(true);
 	mWearableItemsList->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onInventorySelectionChange, this));
 	mWearableItemsList->setDoubleClickCallback(boost::bind(&LLPanelOutfitEdit::onPlusBtnClicked, this));
+	mWearableItemsList->setSortOrder((LLWearableItemsList::ESortOrder)gSavedSettings.getU32("AddWearableSortOrder"));
 
 	mSaveComboBtn.reset(new LLSaveOutfitComboBtn(this));
 	return TRUE;
@@ -894,13 +1032,33 @@ bool LLPanelOutfitEdit::switchPanels(LLPanel* switch_from_panel, LLPanel* switch
 
 void LLPanelOutfitEdit::onGearButtonClick(LLUICtrl* clicked_button)
 {
-	if(!mGearMenu)
+	LLMenuGL* menu = NULL;
+
+	if (mAddWearablesPanel->getVisible())
+	{
+		if (!mAddWearablesGearMenu)
+		{
+			mAddWearablesGearMenu = LLAddWearablesGearMenu::create(mWearableItemsList, mInventoryItemsPanel);
+		}
+
+		menu = mAddWearablesGearMenu;
+	}
+	else
 	{
-		mGearMenu = LLPanelOutfitEditGearMenu::create();
+		if (!mGearMenu)
+		{
+			mGearMenu = LLPanelOutfitEditGearMenu::create();
+		}
+
+		menu = mGearMenu;
 	}
 
-	S32 menu_y = mGearMenu->getRect().getHeight() + clicked_button->getRect().getHeight();
-	LLMenuGL::showPopup(clicked_button, mGearMenu, 0, menu_y);
+	if (!menu) return;
+
+	menu->arrangeAndClear(); // update menu height
+	S32 menu_y = menu->getRect().getHeight() + clicked_button->getRect().getHeight();
+	menu->buildDrawLabels();
+	LLMenuGL::showPopup(clicked_button, menu, 0, menu_y);
 }
 
 void LLPanelOutfitEdit::onAddMoreButtonClicked()
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index de1bf87fb32..924765d3085 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -43,8 +43,8 @@
 #include "llremoteparcelrequest.h"
 #include "llinventory.h"
 #include "llinventoryfunctions.h"
-#include "llinventoryitemslist.h"
 #include "llinventorymodel.h"
+#include "llwearableitemslist.h"
 
 class LLButton;
 class LLCOFWearables;
@@ -211,7 +211,7 @@ class LLPanelOutfitEdit : public LLPanel
 	LLComboBox*			mListViewFilterCmbBox;
 
 	LLFilteredWearableListManager* 	mWearableListManager;
-	LLInventoryItemsList* 			mWearableItemsList;
+	LLWearableItemsList* 			mWearableItemsList;
 	LLPanel*						mWearablesListViewPanel;
 
 	LLCOFDragAndDropObserver* mCOFDragAndDropObserver;
@@ -221,6 +221,7 @@ class LLPanelOutfitEdit : public LLPanel
 
 	LLCOFWearables*		mCOFWearables;
 	LLMenuGL*			mGearMenu;
+	LLMenuGL*			mAddWearablesGearMenu;
 	bool				mInitialized;
 	std::auto_ptr<LLSaveOutfitComboBtn> mSaveComboBtn;
 
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index cf165f8f660..17b871338f3 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -437,11 +437,27 @@ LLWearableItemTypeNameComparator::ETypeListOrder LLWearableItemTypeNameComparato
 	}
 }
 
+/*virtual*/
+bool LLWearableItemCreationDateComparator::doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const
+{
+	time_t date1 = item1->getCreationDate();
+	time_t date2 = item2->getCreationDate();
+
+	if (date1 == date2)
+	{
+		return LLWearableItemNameComparator::doCompare(item1, item2);
+	}
+
+	return date1 > date2;
+}
+
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 
 static const LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
+static const LLWearableItemNameComparator WEARABLE_NAME_COMPARATOR;
+static const LLWearableItemCreationDateComparator WEARABLE_CREATION_DATE_COMPARATOR;
 
 static const LLDefaultChildRegistry::Register<LLWearableItemsList> r("wearable_items_list");
 
@@ -453,7 +469,7 @@ LLWearableItemsList::Params::Params()
 LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p)
 :	LLInventoryItemsList(p)
 {
-	setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
+	setSortOrder(E_SORT_BY_TYPE, false);
 	mIsStandalone = p.standalone;
 	if (mIsStandalone)
 	{
@@ -553,6 +569,32 @@ void LLWearableItemsList::onRightClick(S32 x, S32 y)
 	ContextMenu::instance().show(this, selected_uuids, x, y);
 }
 
+void LLWearableItemsList::setSortOrder(ESortOrder sort_order, bool sort_now)
+{
+	switch (sort_order)
+	{
+	case E_SORT_BY_MOST_RECENT:
+		setComparator(&WEARABLE_CREATION_DATE_COMPARATOR);
+		break;
+	case E_SORT_BY_NAME:
+		setComparator(&WEARABLE_NAME_COMPARATOR);
+		break;
+	case E_SORT_BY_TYPE:
+		setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
+		break;
+
+	// No "default:" to raise compiler warning
+	// if we're not handling something
+	}
+
+	mSortOrder = sort_order;
+
+	if (sort_now)
+	{
+		sort();
+	}
+}
+
 //////////////////////////////////////////////////////////////////////////
 /// ContextMenu
 //////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index d16a2a89c8e..b6d210b4fe0 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -310,6 +310,19 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 	static LLWearableItemTypeNameComparator::ETypeListOrder getTypeListOrder(LLAssetType::EType item_type);
 };
 
+/**
+ * @class LLWearableItemCreationDateComparator
+ *
+ * Comparator for sorting wearable list items by creation date (newest go first).
+ */
+class LLWearableItemCreationDateComparator : public LLWearableItemNameComparator
+{
+	LOG_CLASS(LLWearableItemCreationDateComparator);
+
+protected:
+	/*virtual*/ bool doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const;
+};
+
 /**
  * @class LLWearableItemsList
  *
@@ -362,6 +375,13 @@ class LLWearableItemsList : public LLInventoryItemsList
 		Params();
 	};
 
+	typedef enum e_sort_order {
+		// Values should be compatible with InventorySortOrder setting.
+		E_SORT_BY_NAME			= 0,
+		E_SORT_BY_MOST_RECENT	= 1,
+		E_SORT_BY_TYPE			= 2,
+	} ESortOrder;
+
 	virtual ~LLWearableItemsList();
 
 	/*virtual*/ void addNewItem(LLViewerInventoryItem* item, bool rearrange = true);
@@ -376,6 +396,10 @@ class LLWearableItemsList : public LLInventoryItemsList
 
 	bool isStandalone() const { return mIsStandalone; }
 
+	ESortOrder getSortOrder() const { return mSortOrder; }
+
+	void setSortOrder(ESortOrder sort_order, bool sort_now = true);
+
 protected:
 	friend class LLUICtrlFactory;
 	LLWearableItemsList(const LLWearableItemsList::Params& p);
@@ -384,6 +408,8 @@ class LLWearableItemsList : public LLInventoryItemsList
 
 	bool mIsStandalone;
 	bool mWornIndicationEnabled;
+
+	ESortOrder		mSortOrder;
 };
 
 #endif //LL_LLWEARABLEITEMSLIST_H
diff --git a/indra/newview/skins/default/xui/en/menu_add_wearable_gear.xml b/indra/newview/skins/default/xui/en/menu_add_wearable_gear.xml
new file mode 100644
index 00000000000..1925d3396fc
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/menu_add_wearable_gear.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<menu
+ layout="topleft"
+ name="Add Wearable Gear Menu">
+    <menu_item_check
+     label="Sort by Most Recent"
+     layout="topleft"
+     name="sort_by_most_recent">
+        <on_check
+         function="AddWearable.Gear.Check"
+         parameter="by_most_recent" />
+        <on_click
+         function="AddWearable.Gear.Sort"
+         parameter="by_most_recent" />
+    </menu_item_check>
+    <menu_item_check
+     label="Sort by Name"
+     layout="topleft"
+     name="sort_by_name">
+        <on_check
+         function="AddWearable.Gear.Check"
+         parameter="by_name" />
+        <on_click
+         function="AddWearable.Gear.Sort"
+         parameter="by_name" />
+    </menu_item_check>
+    <menu_item_check
+     label="Sort by Type"
+     layout="topleft"
+     name="sort_by_type">
+        <on_check
+         function="AddWearable.Gear.Check"
+         parameter="by_type" />
+        <on_click
+         function="AddWearable.Gear.Sort"
+         parameter="by_type" />
+        <on_visible
+         function="AddWearable.Gear.Visible"
+         parameter="by_type" />
+    </menu_item_check>
+</menu>
-- 
GitLab


From 47ace2fc41d09aef6d8fded281a4a2da765bef86 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 1 Jul 2010 15:45:47 +0100
Subject: [PATCH 507/683] Attempt to fix viewer-public build from bad merge.

---
 indra/llrender/llvertexbuffer.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 431102ac73b..e2fecdffef9 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -86,8 +86,6 @@ class LLVertexBuffer : public LLRefCount
 	
 	static BOOL	sUseStreamDraw;
 
-	static BOOL	sUseStreamDraw;
-
 	static void initClass(bool use_vbo);
 	static void cleanupClass();
 	static void setupClientArrays(U32 data_mask);
-- 
GitLab


From d5bed7df3545f0765e6767c085f64a0a04136e7e Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Thu, 1 Jul 2010 20:00:00 +0300
Subject: [PATCH 508/683] EXT-7565 FIXED Would be nice to preserve selection
 while switching between folder/list view modes

- Created callback called 'SaveSelecton' (which preserves selection while switching between folder/list view modes) for folder/list view modes buttons in LLPanelOutfitEdit.

- Added 'scrollToShowFirstSelectedItem' method in the LLFlatListView which scrools and shows the first selected item in case multiselection.

- It's possible to set selection for flat list view items before list is build. The result is that any items will be selected. To get rid of it:
   1. Overrided LLFlatListView::selectItemByValue method in LLInventoryItemsList so that if list is not created yet, items ids are saved to the vector.
   2. Added 'LLInventoryItemsList::updateSelection()' method which selects items with ids from that vector when list is created.

- A little refactoring: moved funcionality of updating WearablesPanel's verb buttons to the separate method called LLPanelOutfitEdit::updateWearablesPanelVerbButtons() to made code more readable and self-explanatory

Reviewed by Vadim Savchuk and Neal Orman at https://codereview.productengine.com/secondlife/r/579/

--HG--
branch : product-engine
---
 indra/llui/llflatlistview.cpp          | 12 +++++
 indra/llui/llflatlistview.h            |  1 +
 indra/newview/llinventoryitemslist.cpp | 37 +++++++++++++
 indra/newview/llinventoryitemslist.h   |  7 +++
 indra/newview/llpaneloutfitedit.cpp    | 72 +++++++++++++++++++++++---
 indra/newview/llpaneloutfitedit.h      |  6 +++
 6 files changed, 129 insertions(+), 6 deletions(-)

diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index b87851490db..a3debdb19ad 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -776,6 +776,18 @@ bool LLFlatListView::selectItemPair(item_pair_t* item_pair, bool select)
 	return true;
 }
 
+void LLFlatListView::scrollToShowFirstSelectedItem()
+{
+	if (!mSelectedItemPairs.size())	return;
+
+	LLRect selected_rc = mSelectedItemPairs.front()->first->getRect();
+
+	if (selected_rc.isValid())
+	{
+		scrollToShowRect(selected_rc);
+	}
+}
+
 LLRect LLFlatListView::getLastSelectedItemRect()
 {
 	if (!mSelectedItemPairs.size())
diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h
index ded46d81226..bf72289c47f 100644
--- a/indra/llui/llflatlistview.h
+++ b/indra/llui/llflatlistview.h
@@ -293,6 +293,7 @@ class LLFlatListView : public LLScrollContainer, public LLEditMenuHandler
 
 	bool updateValue(const LLSD& old_value, const LLSD& new_value);
 
+	void scrollToShowFirstSelectedItem();
 
 	void selectFirstItem	();
 	void selectLastItem		();
diff --git a/indra/newview/llinventoryitemslist.cpp b/indra/newview/llinventoryitemslist.cpp
index fbb37749171..83725f40ee0 100644
--- a/indra/newview/llinventoryitemslist.cpp
+++ b/indra/newview/llinventoryitemslist.cpp
@@ -85,6 +85,37 @@ boost::signals2::connection LLInventoryItemsList::setRefreshCompleteCallback(con
 	return mRefreshCompleteSignal.connect(cb);
 }
 
+bool LLInventoryItemsList::selectItemByValue(const LLSD& value, bool select)
+{
+	if (!LLFlatListView::selectItemByValue(value, select) && !value.isUndefined())
+	{
+		mSelectTheseIDs.push_back(value);
+		return false;
+	}
+	return true;
+}
+
+void LLInventoryItemsList::updateSelection()
+{
+	if(mSelectTheseIDs.empty()) return;
+
+	std::vector<LLSD> cur;
+	getValues(cur);
+
+	for(std::vector<LLSD>::const_iterator cur_id_it = cur.begin(); cur_id_it != cur.end() && !mSelectTheseIDs.empty(); ++cur_id_it)
+	{
+		uuid_vec_t::iterator select_ids_it = std::find(mSelectTheseIDs.begin(), mSelectTheseIDs.end(), *cur_id_it);
+		if(select_ids_it != mSelectTheseIDs.end())
+		{
+			selectItemByUUID(*select_ids_it);
+			mSelectTheseIDs.erase(select_ids_it);
+		}
+	}
+
+	scrollToShowFirstSelectedItem();
+	mSelectTheseIDs.clear();
+}
+
 void LLInventoryItemsList::doIdle()
 {
 	if (!mNeedsRefresh) return;
@@ -149,6 +180,12 @@ void LLInventoryItemsList::refresh()
 	bool needs_refresh = add_limit_exceeded;
 	setNeedsRefresh(needs_refresh);
 	setForceRefresh(needs_refresh);
+
+	// After list building completed, select items that had been requested to select before list was build
+	if(!needs_refresh)
+	{
+		updateSelection();
+	}
 }
 
 void LLInventoryItemsList::computeDifference(
diff --git a/indra/newview/llinventoryitemslist.h b/indra/newview/llinventoryitemslist.h
index 71c7b6a6750..5800111f469 100644
--- a/indra/newview/llinventoryitemslist.h
+++ b/indra/newview/llinventoryitemslist.h
@@ -68,6 +68,10 @@ class LLInventoryItemsList : public LLFlatListViewEx
 	 */
 	void setForceRefresh(bool force_refresh){ mForceRefresh = force_refresh; }
 
+	virtual bool selectItemByValue(const LLSD& value, bool select = true);
+
+	void updateSelection();
+
 	/**
 	 * Idle routine used to refresh the list regardless of the current list
 	 * visibility, unlike draw() which is called only for the visible list.
@@ -104,6 +108,9 @@ class LLInventoryItemsList : public LLFlatListViewEx
 private:
 	uuid_vec_t mIDs; // IDs of items that were added in refreshList().
 					 // Will be used in refresh() to determine added and removed ids
+
+	uuid_vec_t mSelectTheseIDs; // IDs that will be selected if list is not loaded till now
+
 	bool mNeedsRefresh;
 
 	bool mForceRefresh;
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 6a859696498..a04a0401413 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -42,6 +42,7 @@
 #include "lloutfitobserver.h"
 #include "llcofwearables.h"
 #include "llfilteredwearablelist.h"
+#include "llfolderviewitem.h"
 #include "llinventory.h"
 #include "llviewercontrol.h"
 #include "llui.h"
@@ -462,7 +463,9 @@ BOOL LLPanelOutfitEdit::postBuild()
 
 	childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL);
 	childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL);
+	childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL);
 	childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL);
+	childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL);
 	childSetCommitCallback("wearables_gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
 	childSetCommitCallback("gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
 	childSetCommitCallback("shop_btn_1", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL);
@@ -610,9 +613,7 @@ void LLPanelOutfitEdit::showWearablesListView()
 {
 	if(switchPanels(mInventoryItemsPanel, mWearablesListViewPanel))
 	{
-		mFolderViewBtn->setToggleState(FALSE);
-		mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
-		mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
+		updateWearablesPanelVerbButtons();
 		updateFiltersVisibility();
 	}
 	mListViewBtn->setToggleState(TRUE);
@@ -622,9 +623,7 @@ void LLPanelOutfitEdit::showWearablesFolderView()
 {
 	if(switchPanels(mWearablesListViewPanel, mInventoryItemsPanel))
 	{
-		mListViewBtn->setToggleState(FALSE);
-		mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
-		mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
+		updateWearablesPanelVerbButtons();
 		updateFiltersVisibility();
 	}
 	mFolderViewBtn->setToggleState(TRUE);
@@ -1138,5 +1137,66 @@ void LLPanelOutfitEdit::getSelectedItemsUUID(uuid_vec_t& uuid_list)
 //	return selected_id;
 }
 
+void LLPanelOutfitEdit::updateWearablesPanelVerbButtons()
+{
+	if(mWearablesListViewPanel->getVisible())
+	{
+		mFolderViewBtn->setToggleState(FALSE);
+		mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
+		mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
+	}
+	else if(mInventoryItemsPanel->getVisible())
+	{
+		mListViewBtn->setToggleState(FALSE);
+		mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
+		mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
+	}
+}
+
+void LLPanelOutfitEdit::saveListSelection()
+{
+	if(mWearablesListViewPanel->getVisible())
+	{
+		std::set<LLUUID> selected_ids = mInventoryItemsPanel->getRootFolder()->getSelectionList();
+
+		if(!selected_ids.size()) return;
+
+		mWearableItemsList->resetSelection();
+
+		for (std::set<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
+		{
+			mWearableItemsList->selectItemByUUID(*item_id, true);
+		}
+		mWearableItemsList->scrollToShowFirstSelectedItem();
+	}
+	else if(mInventoryItemsPanel->getVisible())
+	{
+		std::vector<LLUUID> selected_ids;
+		mWearableItemsList->getSelectedUUIDs(selected_ids);
+
+		if(!selected_ids.size()) return;
+
+		mInventoryItemsPanel->clearSelection();
+		LLFolderView* root = mInventoryItemsPanel->getRootFolder();
+
+		if(!root) return;
+
+		for(std::vector<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
+		{
+			LLFolderViewItem* item = root->getItemByID(*item_id);
+			if (!item) continue;
+
+			LLFolderViewFolder* parent = item->getParentFolder();
+			if(parent)
+			{
+				parent->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP);
+			}
+			mInventoryItemsPanel->getRootFolder()->changeSelection(item, TRUE);
+		}
+		mInventoryItemsPanel->getRootFolder()->scrollToShowSelection();
+	}
+
+}
+
 
 // EOF
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index 924765d3085..c19b43c9fd1 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -140,6 +140,12 @@ class LLPanelOutfitEdit : public LLPanel
 	void showWearablesListView();
 	void showWearablesFolderView();
 
+	/**
+	 * Method preserves selection while switching between folder/list view modes
+	*/
+	void saveListSelection();
+
+	void updateWearablesPanelVerbButtons();
 	void updateFiltersVisibility();
 
 	void onFolderViewFilterCommitted(LLUICtrl* ctrl);
-- 
GitLab


From 2530b057bb18550ed2825c14988a807ab90d460f Mon Sep 17 00:00:00 2001
From: "Karl Stiefvater (qarl)" <qarl@lindenlab.com>
Date: Thu, 1 Jul 2010 17:18:55 -0500
Subject: [PATCH 509/683] added new physics parameters to prims

---
 indra/newview/llpanelobject.cpp               | 76 +++++++++++++-----
 indra/newview/llpanelobject.h                 | 15 ++--
 indra/newview/llselectmgr.cpp                 | 33 ++++++--
 indra/newview/llselectmgr.h                   |  3 +-
 indra/newview/llviewerobject.cpp              | 64 ++++++++++++---
 indra/newview/llviewerobject.h                | 16 ++++
 .../skins/default/xui/en/floater_tools.xml    | 78 ++++++++++++++++++-
 indra/newview/viewer_manifest.py              |  4 +
 scripts/messages/message_template.msg         |  5 ++
 9 files changed, 249 insertions(+), 45 deletions(-)

diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 77f3984ecb3..e972e17894f 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -140,7 +140,28 @@ BOOL	LLPanelObject::postBuild()
 
 	// PhysicsShapeType combobox
 	mComboPhysicsShapeType = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
-	childSetCommitCallback("Physics Shape Type Combo Ctrl", onCommitPhysicsShapeType,this);
+	childSetCommitCallback("Physics Shape Type Combo Ctrl", onCommitPhysicsParam, this);
+
+	// PhysicsGravity
+	mSpinPhysicsGravity = getChild<LLSpinCtrl>("Physics Gravity");
+	childSetCommitCallback("Physics Gravity", onCommitPhysicsParam, this);
+
+	// PhysicsMaterialOverride
+	mCheckPhysicsMaterialOverride = getChild<LLCheckBoxCtrl>("Physics Material Override");
+	childSetCommitCallback("Physics Material Override", onCommitPhysicsParam, this);
+
+	// PhysicsFriction
+	mSpinPhysicsFriction = getChild<LLSpinCtrl>("Physics Friction");
+	childSetCommitCallback("Physics Friction", onCommitPhysicsParam, this);
+	
+	// PhysicsDensity
+	mSpinPhysicsDensity = getChild<LLSpinCtrl>("Physics Density");
+	childSetCommitCallback("Physics Density", onCommitPhysicsParam, this);
+
+	// PhysicsRestitution
+	mSpinPhysicsRestitution = getChild<LLSpinCtrl>("Physics Restitution");
+	childSetCommitCallback("Physics Restitution", onCommitPhysicsParam, this);
+
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -324,7 +345,6 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
-	mPhysicsShapeType(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -532,9 +552,23 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
-	mPhysicsShapeType = objectp->getPhysicsShapeType();
-	mComboPhysicsShapeType->setCurrentByIndex(mPhysicsShapeType);
+	mComboPhysicsShapeType->setCurrentByIndex(objectp->getPhysicsShapeType());
 	mComboPhysicsShapeType->setEnabled(editable);
+	
+	mSpinPhysicsGravity->set(objectp->getPhysicsGravity());
+	mSpinPhysicsGravity->setEnabled(editable);
+
+	mCheckPhysicsMaterialOverride->set(objectp->getPhysicsMaterialOverride());
+	mCheckPhysicsMaterialOverride->setEnabled(editable);
+	
+	mSpinPhysicsFriction->set(objectp->getPhysicsFriction());
+	mSpinPhysicsFriction->setEnabled(editable);
+	
+	mSpinPhysicsDensity->set(objectp->getPhysicsDensity());
+	mSpinPhysicsDensity->setEnabled(editable);
+	
+	mSpinPhysicsRestitution->set(objectp->getPhysicsRestitution());
+	mSpinPhysicsRestitution->setEnabled(editable);
 
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
@@ -1251,20 +1285,17 @@ class CostResponder : public LLHTTPClient::Responder
 	U32 mID;
 };
 
-void LLPanelObject::sendPhysicsShapeType()
+void LLPanelObject::sendPhysicsParam()
 {
-	U8 value = (U8)mComboPhysicsShapeType->getCurrentIndex();
-	if (mPhysicsShapeType != value)
-	{
-		LLSelectMgr::getInstance()->selectionUpdatePhysicsShapeType(value);
-		mPhysicsShapeType = value;
-		
-		llinfos << "update physics shape type sent" << llendl;
-	}
-	else
-	{
-		llinfos << "update physics shape type not changed" << llendl;
-	}
+	U8 type = (U8)mComboPhysicsShapeType->getCurrentIndex();
+	F32 gravity = mSpinPhysicsGravity->get();
+	BOOL material_override = mCheckPhysicsMaterialOverride->get();
+	F32 friction = mSpinPhysicsFriction->get();
+	F32 density = mSpinPhysicsDensity->get();
+	F32 restitution = mSpinPhysicsRestitution->get();
+	
+	LLSelectMgr::getInstance()->selectionUpdatePhysicsParam(type, gravity, material_override,
+															friction, density, restitution);
 
 	std::string url = gAgent.getRegion()->getCapability("GetObjectCost");
 	LLSD body = LLSD::emptyArray();
@@ -1947,8 +1978,15 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
+	
 	mComboPhysicsShapeType->setCurrentByIndex(0);
 	mComboPhysicsShapeType->setEnabled(FALSE);
+	mSpinPhysicsGravity->setEnabled(FALSE);
+	mCheckPhysicsMaterialOverride->setEnabled(FALSE);
+	mSpinPhysicsFriction->setEnabled(FALSE);
+	mSpinPhysicsDensity->setEnabled(FALSE);
+	mSpinPhysicsRestitution->setEnabled(FALSE);
+							 
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
@@ -2044,10 +2082,10 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 }
 
 // static
-void LLPanelObject::onCommitPhysicsShapeType(LLUICtrl* ctrl, void* userdata )
+void LLPanelObject::onCommitPhysicsParam(LLUICtrl* ctrl, void* userdata )
 {
 	LLPanelObject* self = (LLPanelObject*) userdata;
-	self->sendPhysicsShapeType();
+	self->sendPhysicsParam();
 }
 
 // static
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index 7f368c38c70..2c62002ac67 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -71,7 +71,7 @@ class LLPanelObject : public LLPanel
 	static void 	onCommitPhysics(			LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitTemporary(			LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitPhantom(			LLUICtrl* ctrl, void* userdata);
-	static void     onCommitPhysicsShapeType(   LLUICtrl* ctrl, void* userdata);
+	static void     onCommitPhysicsParam(       LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitCastShadows(		LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
@@ -94,7 +94,7 @@ class LLPanelObject : public LLPanel
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
-	void            sendPhysicsShapeType();
+	void            sendPhysicsParam();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -167,9 +167,15 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
-	LLComboBox      *mComboPhysicsShapeType;
 	LLCheckBoxCtrl	*mCheckCastShadows;
-	
+
+	LLComboBox*     mComboPhysicsShapeType;
+	LLSpinCtrl*     mSpinPhysicsGravity;
+	LLCheckBoxCtrl* mCheckPhysicsMaterialOverride;
+	LLSpinCtrl*     mSpinPhysicsFriction;
+	LLSpinCtrl*     mSpinPhysicsDensity;
+	LLSpinCtrl*     mSpinPhysicsRestitution;
+
 	LLTextureCtrl   *mCtrlSculptTexture;
 	LLTextBox       *mLabelSculptType;
 	LLComboBox      *mCtrlSculptType;
@@ -180,7 +186,6 @@ class LLPanelObject : public LLPanel
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
 	BOOL			mIsTemporary;			// to avoid sending "temporary" when not changed
 	BOOL			mIsPhantom;				// to avoid sending "phantom" when not changed
-	U8              mPhysicsShapeType;		// to avoid sending "physics shape type" when not changed
 	BOOL			mCastShadows;			// to avoid sending "cast shadows" when not changed
 	S32				mSelectedType;			// So we know what selected type we last were
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 559c802f51e..8ab9910f67f 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3937,15 +3937,33 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
-struct LLSelectMgrApplyPhysicsShapeType : public LLSelectedObjectFunctor
-{
-	LLSelectMgrApplyPhysicsShapeType(U8 value) : mValue(value) {}
-	U8 mValue;
+struct LLSelectMgrApplyPhysicsParam : public LLSelectedObjectFunctor
+{
+	LLSelectMgrApplyPhysicsParam(U8 type, F32 gravity, BOOL material_override,
+								 F32 friction, F32 density, F32 restitution) :
+		mType(type),
+		mGravity(gravity),
+		mMaterialOverride(material_override),
+		mFriction(friction),
+		mDensity(density),
+		mRestitution(restitution)
+	{}
+	U8 mType;
+	F32 mGravity;
+	BOOL mMaterialOverride;
+	F32 mFriction;
+	F32 mDensity;
+	F32 mRestitution;
 	virtual bool apply(LLViewerObject* object)
 	{
 		if ( object->permModify() ) 	// preemptive permissions check
 		{
-			object->setPhysicsShapeType( mValue );
+			object->setPhysicsShapeType( mType );
+			object->setPhysicsGravity(mGravity);
+			object->setPhysicsMaterialOverride(mMaterialOverride);
+			object->setPhysicsFriction(mFriction);
+			object->setPhysicsDensity(mDensity);
+			object->setPhysicsRestitution(mRestitution);
 			object->updateFlags();
 		}
 		return true;
@@ -3953,10 +3971,11 @@ struct LLSelectMgrApplyPhysicsShapeType : public LLSelectedObjectFunctor
 };
 
 
-void LLSelectMgr::selectionUpdatePhysicsShapeType(U8 type)
+void LLSelectMgr::selectionUpdatePhysicsParam(U8 type, F32 gravity, BOOL material_override,
+											  F32 friction, F32 density, F32 restitution)
 {
 	llwarns << "physics shape type ->" << (U32)type << llendl;
-	LLSelectMgrApplyPhysicsShapeType func(type);
+	LLSelectMgrApplyPhysicsParam func(type, gravity, material_override, friction, density, restitution);
 	getSelection()->applyToObjects(&func);	
 }
 
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 5302cfae683..e5db0b6df16 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -485,9 +485,10 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void saveSelectedObjectTextures();
 
 	void selectionUpdatePhysics(BOOL use_physics);
+	void selectionUpdatePhysicsParam(U8 type, F32 gravity, BOOL material_override,
+									 F32 friction, F32 density, F32 restitution);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
-	void selectionUpdatePhysicsShapeType(U8 type);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 03e524268da..82147dd3394 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -201,6 +201,11 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mbCanSelect(TRUE),
 	mFlags(0),
 	mPhysicsShapeType(0),
+	mPhysicsGravity(0),
+	mPhysicsMaterialOverride(FALSE),
+	mPhysicsFriction(0),
+	mPhysicsDensity(0),
+	mPhysicsRestitution(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -5022,6 +5027,11 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
 	gMessageSystem->nextBlock("ExtraPhysics");
 	gMessageSystem->addU8("PhysicsShapeType", getPhysicsShapeType() );
+	gMessageSystem->addF32("PhysicsGravity", getPhysicsGravity() );
+	gMessageSystem->addBOOL("PhysicsMaterialOverride", getPhysicsMaterialOverride() );
+	gMessageSystem->addF32("PhysicsFriction", getPhysicsFriction() );
+	gMessageSystem->addF32("PhysicsDensity", getPhysicsDensity() );
+	gMessageSystem->addF32("PhysicsRestitution", getPhysicsRestitution() );
 	gMessageSystem->sendReliable( regionp->getHost() );
 
 	if (getPhysicsShapeType() != 0)
@@ -5062,7 +5072,31 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 void LLViewerObject::setPhysicsShapeType(U8 type)
 {
 	mPhysicsShapeType = type;
-	updateFlags();
+}
+
+void LLViewerObject::setPhysicsGravity(F32 gravity)
+{
+	mPhysicsGravity = gravity;
+}
+
+void LLViewerObject::setPhysicsMaterialOverride(BOOL material_override)
+{
+	mPhysicsMaterialOverride = material_override;
+}
+
+void LLViewerObject::setPhysicsFriction(F32 friction)
+{
+	mPhysicsFriction = friction;
+}
+
+void LLViewerObject::setPhysicsDensity(F32 density)
+{
+	mPhysicsDensity = density;
+}
+
+void LLViewerObject::setPhysicsRestitution(F32 restitution)
+{
+	mPhysicsRestitution = restitution;
 }
 
 void LLViewerObject::applyAngularVelocity(F32 dt)
@@ -5303,13 +5337,13 @@ class ObjectPhysicsProperties : public LLHTTPNode
 		const LLSD& context,
 		const LLSD& input) const
 	{
-		LLSD objectData = input["body"]["ObjectData"];
-		S32 numEntries = objectData.size();
+		LLSD object_data = input["body"]["ObjectData"];
+		S32 num_entries = object_data.size();
 		
-		for ( S32 i = 0; i < numEntries; i++ )
+		for ( S32 i = 0; i < num_entries; i++ )
 		{
-			LLSD& currObjectData = objectData[i];
-			U32 localID = currObjectData["LocalID"].asInteger();
+			LLSD& curr_object_data = object_data[i];
+			U32 local_id = curr_object_data["LocalID"].asInteger();
 
 			// Iterate through nodes at end, since it can be on both the regular AND hover list
 			struct f : public LLSelectedNodeFunctor
@@ -5320,16 +5354,26 @@ class ObjectPhysicsProperties : public LLHTTPNode
 				{
 					return (node->getObject() && node->getObject()->mLocalID == mID );
 				}
-			} func(localID);
+			} func(local_id);
 
 			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
 
 			if (node)
 			{
 				// The LLSD message builder doesn't know how to handle U8, so we need to send as S8 and cast
-				U8 physicsShapeType = (U8)currObjectData["PhysicsShapeType"].asInteger();
-
-				node->getObject()->setPhysicsShapeType(physicsShapeType);
+				U8 type = (U8)curr_object_data["PhysicsShapeType"].asInteger();
+				F32 gravity = (F32)curr_object_data["PhysicsGravity"].asReal();
+				BOOL material_override = curr_object_data["PhysicsMaterialOverride"].asBoolean();
+				F32 friction = (F32)curr_object_data["PhysicsFriction"].asReal();
+				F32 density = (F32)curr_object_data["PhysicsDensity"].asReal();
+				F32 restitution = (F32)curr_object_data["PhysicsRestitution"].asReal();
+
+				node->getObject()->setPhysicsShapeType(type);
+				node->getObject()->setPhysicsGravity(gravity);
+				node->getObject()->setPhysicsMaterialOverride(material_override);
+				node->getObject()->setPhysicsFriction(friction);
+				node->getObject()->setPhysicsDensity(density);
+				node->getObject()->setPhysicsRestitution(restitution);
 			}	
 		}
 		
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 092d8fdc82d..90c9ba0f7a8 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -468,6 +468,11 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
 	inline U8       getPhysicsShapeType() const     { return mPhysicsShapeType; }
+	inline F32      getPhysicsGravity() const       { return mPhysicsGravity; }
+	inline BOOL     getPhysicsMaterialOverride() const { return mPhysicsMaterialOverride; }
+	inline F32      getPhysicsFriction() const      { return mPhysicsFriction; }
+	inline F32      getPhysicsDensity() const       { return mPhysicsDensity; }
+	inline F32      getPhysicsRestitution() const   { return mPhysicsRestitution; }
 	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
@@ -485,6 +490,11 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
 	void setPhysicsShapeType(U8 type);
+	void setPhysicsGravity(F32 gravity);
+	void setPhysicsMaterialOverride(BOOL material_override);
+	void setPhysicsFriction(F32 friction);
+	void setPhysicsDensity(F32 density);
+	void setPhysicsRestitution(F32 restitution);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -566,6 +576,12 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
 	U8              mPhysicsShapeType;
+	F32             mPhysicsGravity;
+	BOOL            mPhysicsMaterialOverride;
+	F32             mPhysicsFriction;
+	F32             mPhysicsDensity;
+	F32             mPhysicsRestitution;
+	
 
 	// Pipeline classes
 	LLPointer<LLDrawable> mDrawable;
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index b83ac3282b6..808ba22dbb7 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -2,7 +2,7 @@
 <floater
  legacy_header_height="18"
  follows="left|top|right"
- height="580"
+ height="780"
  layout="topleft"
  bg_opaque_image="Window_NoTitle_Foreground"
  bg_alpha_image="Window_NoTitle_Background"
@@ -751,7 +751,7 @@
     </text>
     <tab_container
      follows="left|top"
-     height="410"
+     height="610"
      halign="center"
      left="0"
      name="Object Info Tabs"
@@ -1217,7 +1217,7 @@ even though the user gets a free copy.
       <panel
          border="false"
          follows="all"
-         height="367"
+         height="567"
          label="Object"
          layout="topleft"
          left_delta="0"
@@ -1466,6 +1466,78 @@ even though the user gets a free copy.
 				 value="Convex Hull" />
 			</combo_box>
 
+            <spinner
+             follows="left|top"
+             height="19"
+             increment="1"
+             initial_value="1"
+             label="Gravity"
+             label_width="70"
+             layout="topleft"
+             left="10"
+             min_val="-1"
+             max_val="10"
+             name="Physics Gravity"
+             top_pad="10"
+             width="128" />
+
+            <check_box
+             height="19"
+             label="Override material"
+             layout="topleft"
+             left_delta="0"
+             name="Physics Material Override"
+             tool_tip="Override Material"
+             top_pad="10"
+             width="121" />
+
+            <spinner
+             follows="left|top"
+             height="19"
+             increment="0.1"
+             initial_value="0"
+             label="Friction"
+             label_width="70"
+             layout="topleft"
+             left_delta="0"
+             max_val="255"
+             min_val="0"
+             name="Physics Friction"
+             top_pad="4"
+             width="128" />
+
+            <spinner
+             follows="left|top"
+             height="19"
+             increment="0.1"
+             initial_value="0"
+             label="Density"
+             label_width="70"
+             layout="topleft"
+             left_delta="0"
+             max_val="10"
+             min_val="0"
+             name="Physics Density"
+             top_pad="4"
+             width="128" />
+
+            <spinner
+             follows="left|top"
+             height="19"
+             increment="0.01"
+             initial_value="0"
+             label="Restitution"
+             label_width="70"
+             layout="topleft"
+             left_delta="0"
+             max_val="1"
+             min_val="0"
+             name="Physics Restitution"
+             top_pad="4"
+             width="128" />
+
+
+
  <!--           <text
              type="string"
              length="1"
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 06050db6275..bb091731db8 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -568,6 +568,10 @@ def package_finish(self):
 
 
 class DarwinManifest(ViewerManifest):
+    def is_packaging_viewer(self):
+        # darwin requires full app bundle packaging even for debugging.
+        return True
+
     def construct(self):
         # copy over the build result (this is a no-op if run within the xcode script)
         self.path(self.args['configuration'] + "/Second Life.app", dst="")
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 6043542877a..8cfd3c5ce69 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2064,6 +2064,11 @@ version 2.0
     {
 		ExtraPhysics        Variable
 		{   PhysicsShapeType U8     }
+		{   PhysicsGravity   F32    }
+		{   PhysicsMaterialOverride BOOL }
+		{   PhysicsFriction  F32    }
+		{   PhysicsDensity   F32    }
+		{   PhysicsRestitution F32  }
 	}
 }
 
-- 
GitLab


From 7c413593f46dedaca23cac17bf761d8246c842f9 Mon Sep 17 00:00:00 2001
From: Vladimir Pchelko <pchelko@productengine.com>
Date: Fri, 2 Jul 2010 17:17:19 +0300
Subject: [PATCH 510/683] EXT-7473 FIXED ("Share" button was added to "gear"
 menu in Inventory SP.)

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/678/

--HG--
branch : product-engine
---
 indra/newview/llpanelmaininventory.cpp                |  8 ++++++++
 indra/newview/llsidepanelinventory.h                  |  5 +++--
 .../default/xui/en/menu_inventory_gear_default.xml    | 11 +++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index 9eece818615..7412812c62e 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -53,6 +53,8 @@
 #include "lltooldraganddrop.h"
 #include "llviewermenu.h"
 #include "llviewertexturelist.h"
+#include "llsidepanelinventory.h"
+#include "llsidetray.h"
 
 const std::string FILTERS_FILENAME("filters.xml");
 
@@ -1158,6 +1160,12 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata)
 		return FALSE;
 	}
 
+	if (command_name == "share")
+	{
+		LLSidepanelInventory* parent = dynamic_cast<LLSidepanelInventory*>(LLSideTray::getInstance()->getPanel("sidepanel_inventory"));
+		return parent ? parent->canShare() : FALSE;
+	}
+
 	return TRUE;
 }
 
diff --git a/indra/newview/llsidepanelinventory.h b/indra/newview/llsidepanelinventory.h
index 951fdd630ca..f2f2509f9a5 100644
--- a/indra/newview/llsidepanelinventory.h
+++ b/indra/newview/llsidepanelinventory.h
@@ -58,6 +58,9 @@ class LLSidepanelInventory : public LLPanel
 	void showTaskInfoPanel();
 	void showInventoryPanel();
 
+	// checks can share selected item(s)
+	bool canShare();
+
 protected:
 	// Tracks highlighted (selected) item in inventory panel.
 	LLInventoryItem *getSelectedItem();
@@ -65,8 +68,6 @@ class LLSidepanelInventory : public LLPanel
 	void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action);
 	// "wear", "teleport", etc.
 	void performActionOnSelection(const std::string &action);
-	bool canShare();
-
 	void updateVerbs();
 
 	//
diff --git a/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml b/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml
index 62365f7cc28..c3947000816 100644
--- a/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml
@@ -81,6 +81,17 @@
 			 function="Inventory.GearDefault.Enable"
 			 parameter="save_texture" />
         </menu_item_call>
+    <menu_item_call
+     label="Share"
+     layout="topleft"
+     name="Share"
+     visible="true">
+     <on_click
+         function="Inventory.Share" />
+     <on_enable
+         function="Inventory.GearDefault.Enable"
+         parameter="share" />
+    </menu_item_call>
     <menu_item_call 
          label="Find Original"
          layout="topleft"
-- 
GitLab


From 3733337011c781b6dabe978181d8ae4c5c96188b Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Fri, 9 Jul 2010 17:47:58 -0700
Subject: [PATCH 511/683] Gravity, Friction, Restitution, Density now work with
 simulator.

---
 indra/newview/llpanelobject.cpp       | 13 ++-----------
 indra/newview/llpanelobject.h         |  1 -
 indra/newview/llselectmgr.cpp         | 13 +++++--------
 indra/newview/llselectmgr.h           |  4 ++--
 indra/newview/llviewerobject.cpp      | 25 ++++++++-----------------
 indra/newview/llviewerobject.h        |  3 ---
 scripts/messages/message_template.msg | 10 +++++-----
 7 files changed, 22 insertions(+), 47 deletions(-)

diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index e972e17894f..55e73731c1d 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -146,10 +146,6 @@ BOOL	LLPanelObject::postBuild()
 	mSpinPhysicsGravity = getChild<LLSpinCtrl>("Physics Gravity");
 	childSetCommitCallback("Physics Gravity", onCommitPhysicsParam, this);
 
-	// PhysicsMaterialOverride
-	mCheckPhysicsMaterialOverride = getChild<LLCheckBoxCtrl>("Physics Material Override");
-	childSetCommitCallback("Physics Material Override", onCommitPhysicsParam, this);
-
 	// PhysicsFriction
 	mSpinPhysicsFriction = getChild<LLSpinCtrl>("Physics Friction");
 	childSetCommitCallback("Physics Friction", onCommitPhysicsParam, this);
@@ -558,9 +554,6 @@ void LLPanelObject::getState( )
 	mSpinPhysicsGravity->set(objectp->getPhysicsGravity());
 	mSpinPhysicsGravity->setEnabled(editable);
 
-	mCheckPhysicsMaterialOverride->set(objectp->getPhysicsMaterialOverride());
-	mCheckPhysicsMaterialOverride->setEnabled(editable);
-	
 	mSpinPhysicsFriction->set(objectp->getPhysicsFriction());
 	mSpinPhysicsFriction->setEnabled(editable);
 	
@@ -1289,13 +1282,12 @@ void LLPanelObject::sendPhysicsParam()
 {
 	U8 type = (U8)mComboPhysicsShapeType->getCurrentIndex();
 	F32 gravity = mSpinPhysicsGravity->get();
-	BOOL material_override = mCheckPhysicsMaterialOverride->get();
 	F32 friction = mSpinPhysicsFriction->get();
 	F32 density = mSpinPhysicsDensity->get();
 	F32 restitution = mSpinPhysicsRestitution->get();
 	
-	LLSelectMgr::getInstance()->selectionUpdatePhysicsParam(type, gravity, material_override,
-															friction, density, restitution);
+	LLSelectMgr::getInstance()->selectionUpdatePhysicsParam(type, gravity, friction, 
+																density, restitution);
 
 	std::string url = gAgent.getRegion()->getCapability("GetObjectCost");
 	LLSD body = LLSD::emptyArray();
@@ -1982,7 +1974,6 @@ void LLPanelObject::clearCtrls()
 	mComboPhysicsShapeType->setCurrentByIndex(0);
 	mComboPhysicsShapeType->setEnabled(FALSE);
 	mSpinPhysicsGravity->setEnabled(FALSE);
-	mCheckPhysicsMaterialOverride->setEnabled(FALSE);
 	mSpinPhysicsFriction->setEnabled(FALSE);
 	mSpinPhysicsDensity->setEnabled(FALSE);
 	mSpinPhysicsRestitution->setEnabled(FALSE);
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index 2c62002ac67..ca6316f54e8 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -171,7 +171,6 @@ class LLPanelObject : public LLPanel
 
 	LLComboBox*     mComboPhysicsShapeType;
 	LLSpinCtrl*     mSpinPhysicsGravity;
-	LLCheckBoxCtrl* mCheckPhysicsMaterialOverride;
 	LLSpinCtrl*     mSpinPhysicsFriction;
 	LLSpinCtrl*     mSpinPhysicsDensity;
 	LLSpinCtrl*     mSpinPhysicsRestitution;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 8ab9910f67f..c11a6f289b2 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3939,18 +3939,16 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 
 struct LLSelectMgrApplyPhysicsParam : public LLSelectedObjectFunctor
 {
-	LLSelectMgrApplyPhysicsParam(U8 type, F32 gravity, BOOL material_override,
-								 F32 friction, F32 density, F32 restitution) :
+	LLSelectMgrApplyPhysicsParam(U8 type, F32 gravity, F32 friction, 
+									F32 density, F32 restitution) :
 		mType(type),
 		mGravity(gravity),
-		mMaterialOverride(material_override),
 		mFriction(friction),
 		mDensity(density),
 		mRestitution(restitution)
 	{}
 	U8 mType;
 	F32 mGravity;
-	BOOL mMaterialOverride;
 	F32 mFriction;
 	F32 mDensity;
 	F32 mRestitution;
@@ -3960,7 +3958,6 @@ struct LLSelectMgrApplyPhysicsParam : public LLSelectedObjectFunctor
 		{
 			object->setPhysicsShapeType( mType );
 			object->setPhysicsGravity(mGravity);
-			object->setPhysicsMaterialOverride(mMaterialOverride);
 			object->setPhysicsFriction(mFriction);
 			object->setPhysicsDensity(mDensity);
 			object->setPhysicsRestitution(mRestitution);
@@ -3971,11 +3968,11 @@ struct LLSelectMgrApplyPhysicsParam : public LLSelectedObjectFunctor
 };
 
 
-void LLSelectMgr::selectionUpdatePhysicsParam(U8 type, F32 gravity, BOOL material_override,
-											  F32 friction, F32 density, F32 restitution)
+void LLSelectMgr::selectionUpdatePhysicsParam(U8 type, F32 gravity, F32 friction, 
+											  F32 density, F32 restitution)
 {
 	llwarns << "physics shape type ->" << (U32)type << llendl;
-	LLSelectMgrApplyPhysicsParam func(type, gravity, material_override, friction, density, restitution);
+	LLSelectMgrApplyPhysicsParam func(type, gravity, friction, density, restitution);
 	getSelection()->applyToObjects(&func);	
 }
 
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index e5db0b6df16..54b9b39a8e0 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -485,8 +485,8 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void saveSelectedObjectTextures();
 
 	void selectionUpdatePhysics(BOOL use_physics);
-	void selectionUpdatePhysicsParam(U8 type, F32 gravity, BOOL material_override,
-									 F32 friction, F32 density, F32 restitution);
+	void selectionUpdatePhysicsParam(U8 type, F32 gravity, F32 friction, 
+										F32 density, F32 restitution);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 82147dd3394..80d645ca80a 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -202,7 +202,6 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mFlags(0),
 	mPhysicsShapeType(0),
 	mPhysicsGravity(0),
-	mPhysicsMaterialOverride(FALSE),
 	mPhysicsFriction(0),
 	mPhysicsDensity(0),
 	mPhysicsRestitution(0),
@@ -5027,11 +5026,10 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
 	gMessageSystem->nextBlock("ExtraPhysics");
 	gMessageSystem->addU8("PhysicsShapeType", getPhysicsShapeType() );
-	gMessageSystem->addF32("PhysicsGravity", getPhysicsGravity() );
-	gMessageSystem->addBOOL("PhysicsMaterialOverride", getPhysicsMaterialOverride() );
-	gMessageSystem->addF32("PhysicsFriction", getPhysicsFriction() );
-	gMessageSystem->addF32("PhysicsDensity", getPhysicsDensity() );
-	gMessageSystem->addF32("PhysicsRestitution", getPhysicsRestitution() );
+	gMessageSystem->addF32("Density", getPhysicsDensity() );
+	gMessageSystem->addF32("Friction", getPhysicsFriction() );
+	gMessageSystem->addF32("Restitution", getPhysicsRestitution() );
+	gMessageSystem->addF32("GravityMultiplier", getPhysicsGravity() );
 	gMessageSystem->sendReliable( regionp->getHost() );
 
 	if (getPhysicsShapeType() != 0)
@@ -5079,11 +5077,6 @@ void LLViewerObject::setPhysicsGravity(F32 gravity)
 	mPhysicsGravity = gravity;
 }
 
-void LLViewerObject::setPhysicsMaterialOverride(BOOL material_override)
-{
-	mPhysicsMaterialOverride = material_override;
-}
-
 void LLViewerObject::setPhysicsFriction(F32 friction)
 {
 	mPhysicsFriction = friction;
@@ -5362,15 +5355,13 @@ class ObjectPhysicsProperties : public LLHTTPNode
 			{
 				// The LLSD message builder doesn't know how to handle U8, so we need to send as S8 and cast
 				U8 type = (U8)curr_object_data["PhysicsShapeType"].asInteger();
-				F32 gravity = (F32)curr_object_data["PhysicsGravity"].asReal();
-				BOOL material_override = curr_object_data["PhysicsMaterialOverride"].asBoolean();
-				F32 friction = (F32)curr_object_data["PhysicsFriction"].asReal();
-				F32 density = (F32)curr_object_data["PhysicsDensity"].asReal();
-				F32 restitution = (F32)curr_object_data["PhysicsRestitution"].asReal();
+				F32 density = (F32)curr_object_data["Density"].asReal();
+				F32 friction = (F32)curr_object_data["Friction"].asReal();
+				F32 restitution = (F32)curr_object_data["Restitution"].asReal();
+				F32 gravity = (F32)curr_object_data["GravityMultiplier"].asReal();
 
 				node->getObject()->setPhysicsShapeType(type);
 				node->getObject()->setPhysicsGravity(gravity);
-				node->getObject()->setPhysicsMaterialOverride(material_override);
 				node->getObject()->setPhysicsFriction(friction);
 				node->getObject()->setPhysicsDensity(density);
 				node->getObject()->setPhysicsRestitution(restitution);
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 90c9ba0f7a8..70bc916acb0 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -469,7 +469,6 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	inline U8       getPhysicsShapeType() const     { return mPhysicsShapeType; }
 	inline F32      getPhysicsGravity() const       { return mPhysicsGravity; }
-	inline BOOL     getPhysicsMaterialOverride() const { return mPhysicsMaterialOverride; }
 	inline F32      getPhysicsFriction() const      { return mPhysicsFriction; }
 	inline F32      getPhysicsDensity() const       { return mPhysicsDensity; }
 	inline F32      getPhysicsRestitution() const   { return mPhysicsRestitution; }
@@ -491,7 +490,6 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	BOOL setFlags(U32 flag, BOOL state);
 	void setPhysicsShapeType(U8 type);
 	void setPhysicsGravity(F32 gravity);
-	void setPhysicsMaterialOverride(BOOL material_override);
 	void setPhysicsFriction(F32 friction);
 	void setPhysicsDensity(F32 density);
 	void setPhysicsRestitution(F32 restitution);
@@ -577,7 +575,6 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
 	U8              mPhysicsShapeType;
 	F32             mPhysicsGravity;
-	BOOL            mPhysicsMaterialOverride;
 	F32             mPhysicsFriction;
 	F32             mPhysicsDensity;
 	F32             mPhysicsRestitution;
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 8cfd3c5ce69..1dd9b5c2b2c 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2064,11 +2064,11 @@ version 2.0
     {
 		ExtraPhysics        Variable
 		{   PhysicsShapeType U8     }
-		{   PhysicsGravity   F32    }
-		{   PhysicsMaterialOverride BOOL }
-		{   PhysicsFriction  F32    }
-		{   PhysicsDensity   F32    }
-		{   PhysicsRestitution F32  }
+        {   Density          F32    }
+        {   Friction         F32    }
+        {   Restitution      F32    }
+        {   GravityMultiplier    F32    }
+
 	}
 }
 
-- 
GitLab


From f0d3cfc7bbd067a004c8206dd90c1fb8af1e703a Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Fri, 9 Jul 2010 17:48:27 -0700
Subject: [PATCH 512/683] Unix EOL

---
 scripts/messages/message_template.msg | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 1dd9b5c2b2c..3fe05be20a3 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2064,10 +2064,10 @@ version 2.0
     {
 		ExtraPhysics        Variable
 		{   PhysicsShapeType U8     }
-        {   Density          F32    }
-        {   Friction         F32    }
-        {   Restitution      F32    }
-        {   GravityMultiplier    F32    }
+        {   Density          F32    }
+        {   Friction         F32    }
+        {   Restitution      F32    }
+        {   GravityMultiplier    F32    }
 
 	}
 }
-- 
GitLab


From 46768c3c6c263ec27a80c854734ce0b61d29686f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 12 Jul 2010 07:39:23 -0500
Subject: [PATCH 513/683] Merge?

---
 indra/llmath/llvolume.cpp          | 186 +++++++++++++++++------------
 indra/llrender/llvertexbuffer.cpp  |   2 +-
 indra/newview/lldrawpoolavatar.cpp |   4 +-
 indra/newview/llface.cpp           |   2 +-
 4 files changed, 116 insertions(+), 78 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index a4022c842dc..38944d3855b 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5245,6 +5245,10 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 	mNumS = src.mNumS;
 	mNumT = src.mNumT;
 
+	mExtents[0] = src.mExtents[0];
+	mExtents[1] = src.mExtents[1];
+	*mCenter = *src.mCenter;
+
 	mNumVertices = 0;
 	mNumIndices = 0;
 
@@ -5297,7 +5301,6 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 		LLVector4a::memcpyNonAliased16((F32*) mIndices, (F32*) src.mIndices, idx_size);
 	}
 	
-
 	//delete 
 	return *this;
 }
@@ -5535,88 +5538,100 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 
 	S32 offset = 0;
 	if (mTypeMask & TOP_MASK)
+	{
 		offset = (max_t-1) * max_s;
+	}
 	else
+	{
 		offset = mBeginS;
-
-	VertexData	corners[4];
-	VertexData baseVert;
-	for(int t = 0; t < 4; t++){
-		corners[t].getPosition().load3( mesh[offset + (grid_size*t)].mPos.mV);
-		corners[t].mTexCoord.mV[0] = profile[grid_size*t].mV[0]+0.5f;
-		corners[t].mTexCoord.mV[1] = 0.5f - profile[grid_size*t].mV[1];
 	}
 
 	{
-		LLVector4a lhs;
-		lhs.setSub(corners[1].getPosition(), corners[0].getPosition());
-		LLVector4a rhs;
-		rhs.setSub(corners[2].getPosition(), corners[1].getPosition());
-		baseVert.getNormal().setCross3(lhs, rhs); 
-		baseVert.getNormal().normalize3fast();
-	}
+		VertexData	corners[4];
+		VertexData baseVert;
+		for(S32 t = 0; t < 4; t++)
+		{
+			corners[t].getPosition().load3( mesh[offset + (grid_size*t)].mPos.mV);
+			corners[t].mTexCoord.mV[0] = profile[grid_size*t].mV[0]+0.5f;
+			corners[t].mTexCoord.mV[1] = 0.5f - profile[grid_size*t].mV[1];
+		}
 
-	if(!(mTypeMask & TOP_MASK)){
-		baseVert.getNormal().mul(-1.0f);
-	}else{
-		//Swap the UVs on the U(X) axis for top face
-		LLVector2 swap;
-		swap = corners[0].mTexCoord;
-		corners[0].mTexCoord=corners[3].mTexCoord;
-		corners[3].mTexCoord=swap;
-		swap = corners[1].mTexCoord;
-		corners[1].mTexCoord=corners[2].mTexCoord;
-		corners[2].mTexCoord=swap;
-	}
+		{
+			LLVector4a lhs;
+			lhs.setSub(corners[1].getPosition(), corners[0].getPosition());
+			LLVector4a rhs;
+			rhs.setSub(corners[2].getPosition(), corners[1].getPosition());
+			baseVert.getNormal().setCross3(lhs, rhs); 
+			baseVert.getNormal().normalize3fast();
+		}
 
-	LLVector4a binormal;
-	
-	calc_binormal_from_triangle( binormal,
-		corners[0].getPosition(), corners[0].mTexCoord,
-		corners[1].getPosition(), corners[1].mTexCoord,
-		corners[2].getPosition(), corners[2].mTexCoord);
-	
-	binormal.normalize3fast();
+		if(!(mTypeMask & TOP_MASK))
+		{
+			baseVert.getNormal().mul(-1.0f);
+		}
+		else
+		{
+			//Swap the UVs on the U(X) axis for top face
+			LLVector2 swap;
+			swap = corners[0].mTexCoord;
+			corners[0].mTexCoord=corners[3].mTexCoord;
+			corners[3].mTexCoord=swap;
+			swap = corners[1].mTexCoord;
+			corners[1].mTexCoord=corners[2].mTexCoord;
+			corners[2].mTexCoord=swap;
+		}
 
-	S32 size = (grid_size+1)*(grid_size+1);
-	resizeVertices(size);
-	allocateBinormals(size);
+		LLVector4a binormal;
+		
+		calc_binormal_from_triangle( binormal,
+			corners[0].getPosition(), corners[0].mTexCoord,
+			corners[1].getPosition(), corners[1].mTexCoord,
+			corners[2].getPosition(), corners[2].mTexCoord);
+		
+		binormal.normalize3fast();
 
-	LLVector4a* pos = (LLVector4a*) mPositions;
-	LLVector4a* norm = (LLVector4a*) mNormals;
-	LLVector4a* binorm = (LLVector4a*) mBinormals;
-	LLVector2* tc = (LLVector2*) mTexCoords;
+		S32 size = (grid_size+1)*(grid_size+1);
+		resizeVertices(size);
+		allocateBinormals(size);
 
-	for(int gx = 0;gx<grid_size+1;gx++){
-		for(int gy = 0;gy<grid_size+1;gy++){
-			VertexData newVert;
-			LerpPlanarVertex(
-				corners[0],
-				corners[1],
-				corners[3],
-				newVert,
-				(F32)gx/(F32)grid_size,
-				(F32)gy/(F32)grid_size);
-
-			*pos++ = newVert.getPosition();
-			*norm++ = baseVert.getNormal();
-			*tc++ = newVert.mTexCoord;
-			*binorm++ = binormal;
-
-			if (gx == 0 && gy == 0)
-			{
-				min = max = newVert.getPosition();
-			}
-			else
+		LLVector4a* pos = (LLVector4a*) mPositions;
+		LLVector4a* norm = (LLVector4a*) mNormals;
+		LLVector4a* binorm = (LLVector4a*) mBinormals;
+		LLVector2* tc = (LLVector2*) mTexCoords;
+
+		for(int gx = 0;gx<grid_size+1;gx++)
+		{
+			for(int gy = 0;gy<grid_size+1;gy++)
 			{
-				min.setMin(newVert.getPosition());
-				max.setMax(newVert.getPosition());
+				VertexData newVert;
+				LerpPlanarVertex(
+					corners[0],
+					corners[1],
+					corners[3],
+					newVert,
+					(F32)gx/(F32)grid_size,
+					(F32)gy/(F32)grid_size);
+
+				*pos++ = newVert.getPosition();
+				*norm++ = baseVert.getNormal();
+				*tc++ = newVert.mTexCoord;
+				*binorm++ = binormal;
+
+				if (gx == 0 && gy == 0)
+				{
+					min = max = newVert.getPosition();
+				}
+				else
+				{
+					min.setMin(newVert.getPosition());
+					max.setMax(newVert.getPosition());
+				}
 			}
 		}
-	}
 	
-	mCenter->setAdd(min, max);
-	mCenter->mul(0.5f); 
+		mCenter->setAdd(min, max);
+		mCenter->mul(0.5f); 
+	}
 
 	if (!partial_build)
 	{
@@ -6249,73 +6264,96 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 		llerrs << "Cannot append face -- 16-bit overflow will occur." << llendl;
 	}
 	
-	
+	if (face.mNumVertices == 0)
+	{
+		llerrs << "Cannot append empty face." << llendl;
+	}
+
+	//allocate new buffer space
 	LLVector4a* new_pos = (LLVector4a*) ll_aligned_malloc_16(new_count*16);
 	LLVector4a* new_norm = (LLVector4a*) ll_aligned_malloc_16(new_count*16);
 	LLVector2* new_tc = (LLVector2*) ll_aligned_malloc_16((new_count*8+0xF) & ~0xF);
 	
+
 	if (mNumVertices > 0)
-	{
+	{ //copy old buffers
 		LLVector4a::memcpyNonAliased16((F32*) new_pos, (F32*) mPositions, mNumVertices*4);
 		LLVector4a::memcpyNonAliased16((F32*) new_norm, (F32*) mNormals, mNumVertices*4);
 		LLVector4a::memcpyNonAliased16((F32*) new_tc, (F32*) mTexCoords, mNumVertices*2);
 	}
 
+	//free old buffer space
 	ll_aligned_free_16(mPositions);
 	ll_aligned_free_16(mNormals);
 	ll_aligned_free_16(mTexCoords);
 
+	//point to new buffers
 	mPositions = new_pos;
 	mNormals = new_norm;
 	mTexCoords = new_tc;
 
 	mNumVertices = new_count;
 
+	//get destination address of appended face
 	LLVector4a* dst_pos = mPositions+offset;
 	LLVector2* dst_tc = mTexCoords+offset;
 	LLVector4a* dst_norm = mNormals+offset;
 
+	//get source addresses of appended face
 	const LLVector4a* src_pos = face.mPositions;
 	const LLVector2* src_tc = face.mTexCoords;
 	const LLVector4a* src_norm = face.mNormals;
 
+	//load aligned matrices
 	LLMatrix4a mat, norm_mat;
 	mat.loadu(mat_in);
 	norm_mat.loadu(norm_mat_in);
 
 	for (U32 i = 0; i < face.mNumVertices; ++i)
 	{
+		//transform appended face position and store
 		mat.affineTransform(src_pos[i], dst_pos[i]);
+
+		//transform appended face normal and store
 		norm_mat.rotate(src_norm[i], dst_norm[i]);
 		dst_norm[i].normalize3fast();
 
+		//copy appended face texture coordinate
 		dst_tc[i] = src_tc[i];
 
 		if (offset == 0 && i == 0)
-		{
+		{ //initialize bounding box
 			mExtents[0] = mExtents[1] = dst_pos[i];
 		}
 		else
 		{
+			//stretch bounding box
 			update_min_max(mExtents[0], mExtents[1], dst_pos[i]);
 		}
 	}
 
 
 	new_count = mNumIndices + face.mNumIndices;
+
+	//allocate new index buffer
 	U16* new_indices = (U16*) ll_aligned_malloc_16((new_count*2+0xF) & ~0xF);
 	if (mNumIndices > 0)
-	{
-		LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, llmax(mNumIndices/2, 1));
+	{ //copy old index buffer
+		LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, llmax(mNumIndices/2, 4));
 	}
 
+	//free old index buffer
 	ll_aligned_free_16(mIndices);
+
+	//point to new index buffer
 	mIndices = new_indices;
+
+	//get destination address into new index buffer
 	U16* dst_idx = mIndices+mNumIndices;
 	mNumIndices = new_count;
 
 	for (U32 i = 0; i < face.mNumIndices; ++i)
-	{
+	{ //copy indices, offsetting by old vertex count
 		dst_idx[i] = face.mIndices[i]+offset;
 	}
 }
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 514ca25aa09..1d02ca4f4c0 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -267,7 +267,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of
 	if (start >= (U32) mRequestedNumVerts ||
 	    end >= (U32) mRequestedNumVerts)
 	{
-		llerrs << "Bad vertex buffer draw range: [" << start << ", " << end << "]" << llendl;
+		llerrs << "Bad vertex buffer draw range: [" << start << ", " << end << "] vs " << mRequestedNumVerts << llendl;
 	}
 
 	llassert(mRequestedNumIndices >= 0);
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 63ca17d62d9..c7e77fd6ba9 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1249,10 +1249,10 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSk
 	{
 		face->setGeomIndex(0);
 		face->setIndicesIndex(0);
-		face->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
+		face->setSize(vol_face.mNumVertices, vol_face.mNumIndices, true);
 
 		face->mVertexBuffer = new LLVertexBuffer(data_mask, 0);
-		face->mVertexBuffer->allocateBuffer(vol_face.mNumVertices, vol_face.mNumIndices, true);
+		face->mVertexBuffer->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), true);
 
 		U16 offset = 0;
 		
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index c48106863ed..8533f9710c8 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1583,7 +1583,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	
 	if (rebuild_weights && vf.mWeights)
 	{
-		LLVector4a::memcpyNonAliased16((F32*) weights, (F32*) vf.mWeights, num_vertices/4);
+		LLVector4a::memcpyNonAliased16((F32*) weights, (F32*) vf.mWeights, num_vertices*4);
 	}
 
 	if (rebuild_color)
-- 
GitLab


From eb6153d2c3cb1e2105804e28f81f894873315545 Mon Sep 17 00:00:00 2001
From: Igor Borovkov <iborovkov@productengine.com>
Date: Mon, 12 Jul 2010 19:47:44 +0300
Subject: [PATCH 514/683] EXT-7796 FIXED disabling/enabling presets and camera
 modes on switching to/from camera customize mode

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/732/

--HG--
branch : product-engine
---
 indra/newview/llagent.cpp         |  4 ++++
 indra/newview/llfloatercamera.cpp | 14 ++++++++++++++
 indra/newview/llfloatercamera.h   |  3 +++
 3 files changed, 21 insertions(+)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 4e5fdb1219d..92c2570c331 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -1785,6 +1785,8 @@ void LLAgent::endAnimationUpdateUI()
 			
 		}
 		gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
+
+		LLFloaterCamera::onAvatarEditingAppearance(false);
 	}
 
 	//---------------------------------------------------------------------
@@ -1891,6 +1893,8 @@ void LLAgent::endAnimationUpdateUI()
 		{
 			mPauseRequest = gAgentAvatarp->requestPause();
 		}
+
+		LLFloaterCamera::onAvatarEditingAppearance(true);
 	}
 
 	if (isAgentAvatarValid())
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index d6effb2b21d..0fa536dfadc 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -243,6 +243,20 @@ void LLFloaterCamera::resetCameraMode()
 	floater_camera->switchMode(CAMERA_CTRL_MODE_PAN);
 }
 
+void LLFloaterCamera::onAvatarEditingAppearance(bool editing)
+{
+	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+	if (!floater_camera) return;
+
+	//camera presets (rear, front, etc.)
+	floater_camera->childSetEnabled("preset_views_list", !editing);
+	floater_camera->childSetEnabled("presets_btn", !editing);
+
+	//camera modes (object view, mouselook view)
+	floater_camera->childSetEnabled("camera_modes_list", !editing);
+	floater_camera->childSetEnabled("avatarview_btn", !editing);
+}
+
 void LLFloaterCamera::update()
 {
 	ECameraControlMode mode = determineMode();
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index 564e38d02de..c5f8cd6db5d 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -68,6 +68,9 @@ class LLFloaterCamera
 	/** resets current camera mode to orbit mode */
 	static void resetCameraMode();
 
+	/** Called when Avatar is entered/exited editing appearance mode */
+	static void onAvatarEditingAppearance(bool editing);
+
 	/* determines actual mode and updates ui */
 	void update();
 
-- 
GitLab


From 8aec2ce3549ff0a39308d47fd3f136eaa8068639 Mon Sep 17 00:00:00 2001
From: Igor Borovkov <iborovkov@productengine.com>
Date: Tue, 13 Jul 2010 18:43:30 +0300
Subject: [PATCH 515/683] EXT-7668 FIXED prohibited deselecting a single
 selected item w/o using CTRL

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/746/

--HG--
branch : product-engine
---
 indra/llui/llflatlistview.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index f9e08a3f4cc..fbc6295d49e 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -608,8 +608,14 @@ void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask)
 		return;
 	}
 
-	if (!(mask & MASK_CONTROL) || !mMultipleSelection) resetSelection();
-	selectItemPair(item_pair, select_item);
+	//no need to do additional commit on selection reset
+	if (!(mask & MASK_CONTROL) || !mMultipleSelection) resetSelection(true);
+
+	//only CTRL usage allows to deselect an item, usual clicking on an item cannot deselect it
+	if (mask & MASK_CONTROL)
+		selectItemPair(item_pair, select_item);
+	else
+		selectItemPair(item_pair, true);
 }
 
 void LLFlatListView::onItemRightMouseClick(item_pair_t* item_pair, MASK mask)
-- 
GitLab


From 2dd3a6be720ed6ce7c17415fc8d81869cf46f3a0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 13 Jul 2010 12:02:14 -0500
Subject: [PATCH 516/683] Fix for mesh upload, consolidate generating bad
 indices, and normal generation.

---
 indra/llcommon/llassettype.cpp        |  3 ---
 indra/llinventory/llinventorytype.cpp |  5 ----
 indra/llmath/llvolume.cpp             | 36 ++++++++++++++++++++-------
 indra/llmath/llvolume.h               |  2 +-
 4 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp
index 476a23ec644..bdd115364e8 100644
--- a/indra/llcommon/llassettype.cpp
+++ b/indra/llcommon/llassettype.cpp
@@ -99,10 +99,7 @@ LLAssetDictionary::LLAssetDictionary()
 
 	addEntry(LLAssetType::AT_LINK, 				new AssetEntry("LINK",				"link",		"sym link",			false,		false,		true));
 	addEntry(LLAssetType::AT_LINK_FOLDER, 		new AssetEntry("FOLDER_LINK",		"link_f", 	"sym folder link",	false,		false,		true));
-#if LL_MESH_ENABLED
 	addEntry(LLAssetType::AT_MESH,              new AssetEntry("MESH",              "mesh",     "mesh",             false, false, false));
-#endif
-	
 	addEntry(LLAssetType::AT_NONE, 				new AssetEntry("NONE",				"-1",		NULL,		  		FALSE,		FALSE,		FALSE));
 
 };
diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp
index 82cd22a8322..5c5500b6f4c 100644
--- a/indra/llinventory/llinventorytype.cpp
+++ b/indra/llinventory/llinventorytype.cpp
@@ -89,10 +89,7 @@ LLInventoryDictionary::LLInventoryDictionary()
 	addEntry(LLInventoryType::IT_WEARABLE,            new InventoryEntry("wearable",  "wearable",      2, LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART));
 	addEntry(LLInventoryType::IT_ANIMATION,           new InventoryEntry("animation", "animation",     1, LLAssetType::AT_ANIMATION));  
 	addEntry(LLInventoryType::IT_GESTURE,             new InventoryEntry("gesture",   "gesture",       1, LLAssetType::AT_GESTURE)); 
-#if LL_MESH_ENABLED
 	addEntry(LLInventoryType::IT_MESH,                new InventoryEntry("mesh",      "mesh",          1, LLAssetType::AT_MESH));
-#endif
-
 }
 
 
@@ -152,9 +149,7 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
 	LLInventoryType::IT_NONE,			// AT_NONE
 	LLInventoryType::IT_NONE,			// AT_NONE
 	LLInventoryType::IT_NONE,			// AT_NONE
-#if LL_MESH_ENABLED
 	LLInventoryType::IT_MESH            // AT_MESH
-#endif
 };
 
 // static
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 38944d3855b..51bcfb38d44 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5369,7 +5369,17 @@ bool LLVolumeFace::VertexMapData::operator==(const LLVolumeFace::VertexData& rhs
 
 bool LLVolumeFace::VertexMapData::ComparePosition::operator()(const LLVector3& a, const LLVector3& b) const
 {
-	return a < b;			
+	if (a.mV[0] != b.mV[0])
+	{
+		return a.mV[0] < b.mV[0];
+	}
+	
+	if (a.mV[1] != b.mV[1])
+	{
+		return a.mV[1] < b.mV[1];
+	}
+	
+	return a.mV[2] < b.mV[2];			
 }
 
 void LLVolumeFace::optimize(F32 angle_cutoff)
@@ -6145,12 +6155,13 @@ 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;
+
 	//positions
 	LLVector4a* dst = (LLVector4a*) ll_aligned_malloc_16(new_size);
 	if (mPositions)
 	{
-		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mPositions, new_size/4);
+		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mPositions, old_size/4);
 		ll_aligned_free_16(mPositions);
 	}
 	mPositions = dst;
@@ -6159,22 +6170,25 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 	dst = (LLVector4a*) ll_aligned_malloc_16(new_size);
 	if (mNormals)
 	{
-		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mNormals, new_size/4);
+		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mNormals, old_size/4);
 		ll_aligned_free_16(mNormals);
 	}
 	mNormals = dst;
 
 	//tex coords
 	new_size = ((new_verts*8)+0xF) & ~0xF;
+	old_size = ((mNumVertices*8)+0xF) & ~0xF;
 
+	dst = (LLVector4a*) ll_aligned_malloc_16(new_size);
 	{
 		LLVector2* dst = (LLVector2*) ll_aligned_malloc_16(new_size);
 		if (mTexCoords)
 		{
-			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mTexCoords, new_size/4);
+			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mTexCoords, old_size/4);
 			ll_aligned_free_16(mTexCoords);
 		}
 	}
+	mTexCoords = (LLVector2*) dst;
 
 	//just clear binormals
 	ll_aligned_free_16(mBinormals);
@@ -6223,12 +6237,15 @@ void LLVolumeFace::pushIndex(const U16& idx)
 	S32 new_count = mNumIndices + 1;
 	S32 new_size = ((new_count*2)+0xF) & ~0xF;
 
-	S32 old_size = (mNumIndices+0xF) & ~0xF;
+	S32 old_size = ((mNumIndices*2)+0xF) & ~0xF;
 	if (new_size != old_size)
 	{
 		U16* dst = (U16*) ll_aligned_malloc_16(new_size);
-		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mIndices, new_size/4);
-		ll_aligned_free_16(mIndices);
+		if (mIndices)
+		{
+			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mIndices, old_size/4);
+			ll_aligned_free_16(mIndices);
+		}
 		mIndices = dst;
 	}
 	
@@ -6339,7 +6356,8 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	U16* new_indices = (U16*) ll_aligned_malloc_16((new_count*2+0xF) & ~0xF);
 	if (mNumIndices > 0)
 	{ //copy old index buffer
-		LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, llmax(mNumIndices/2, 4));
+		S32 old_size = (mNumIndices*2+0xF) & ~0xF;
+		LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, old_size/4);
 	}
 
 	//free old index buffer
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 9cce94e6cf3..af28337f57d 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -41,7 +41,7 @@ class LLVolumeParams;
 class LLProfile;
 class LLPath;
 
-#define LL_MESH_ENABLED 0
+#define LL_MESH_ENABLED 1
 
 template <class T> class LLOctreeNode;
 
-- 
GitLab


From c9430abf455c3282e60b96a6ca88d13d66a0cc82 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Thu, 15 Jul 2010 15:57:57 +0300
Subject: [PATCH 517/683] EXT-8284 FIXED ('Add More' panel items aren't sorted
 by clothing type after it was opened by 'Replace' item of context menu)

- Set proper callback for 'Replace' clothing
- Renamed onReplaceBodyPartMenuItemClicked to onReplaceMenuItemClicked because now this callback is used not only for Body Parts but for clothing also
- Added argument 'const LLUUID& item_id' for 'static void replaceWearable()' to be able to call onReplaceMenuItemClicked with LLUUID argument

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/750/

--HG--
branch : product-engine
---
 indra/newview/llcofwearables.cpp    | 8 ++++----
 indra/newview/llpaneloutfitedit.cpp | 4 ++--
 indra/newview/llpaneloutfitedit.h   | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index 86d9121213f..45e144ca414 100644
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -163,7 +163,7 @@ class CofClothingContextMenu : public CofContextMenu
 	}
 
 protected:
-	static void replaceWearable()
+	static void replaceWearable(const LLUUID& item_id)
 	{
 		// *TODO: Most probable that accessing to LLPanelOutfitEdit instance should be:
 		// LLSideTray::getInstance()->getSidepanelAppearance()->getPanelOutfitEdit()
@@ -175,7 +175,7 @@ class CofClothingContextMenu : public CofContextMenu
 								"panel_outfit_edit"));
 		if (panel_outfit_edit != NULL)
 		{
-			panel_outfit_edit->showAddWearablesPanel(true);
+			panel_outfit_edit->onReplaceMenuItemClicked(item_id);
 		}
 	}
 
@@ -187,7 +187,7 @@ class CofClothingContextMenu : public CofContextMenu
 		functor_t take_off = boost::bind(&LLAppearanceMgr::removeItemFromAvatar, LLAppearanceMgr::getInstance(), _1);
 
 		registrar.add("Clothing.TakeOff", boost::bind(handleMultiple, take_off, mUUIDs));
-		registrar.add("Clothing.Replace", boost::bind(replaceWearable));
+		registrar.add("Clothing.Replace", boost::bind(replaceWearable, selected_id));
 		registrar.add("Clothing.Edit", boost::bind(LLAgentWearables::editWearable, selected_id));
 		registrar.add("Clothing.Create", boost::bind(&CofClothingContextMenu::createNew, this, selected_id));
 
@@ -244,7 +244,7 @@ class CofBodyPartContextMenu : public CofContextMenu
 		// *HACK* need to pass pointer to LLPanelOutfitEdit instead of LLSideTray::getInstance()->getPanel().
 		// LLSideTray::getInstance()->getPanel() is rather slow variant
 		LLPanelOutfitEdit* panel_oe = dynamic_cast<LLPanelOutfitEdit*>(LLSideTray::getInstance()->getPanel("panel_outfit_edit"));
-		registrar.add("BodyPart.Replace", boost::bind(&LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked, panel_oe, selected_id));
+		registrar.add("BodyPart.Replace", boost::bind(&LLPanelOutfitEdit::onReplaceMenuItemClicked, panel_oe, selected_id));
 		registrar.add("BodyPart.Edit", boost::bind(LLAgentWearables::editWearable, selected_id));
 		registrar.add("BodyPart.Create", boost::bind(&CofBodyPartContextMenu::createNew, this, selected_id));
 
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 5b2b7e0ffc8..6d9465d4229 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -746,11 +746,11 @@ void LLPanelOutfitEdit::onAddWearableClicked(void)
 	}
 }
 
-void LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id)
+void LLPanelOutfitEdit::onReplaceMenuItemClicked(LLUUID selected_item_id)
 {
 	LLViewerInventoryItem* item = gInventory.getLinkedItem(selected_item_id);
 
-	if (item && item->getType() == LLAssetType::AT_BODYPART)
+	if (item)
 	{
 		showFilteredWearablesListView(item->getWearableType());
 	}
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index ff49e2075ea..87d60d3b80a 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -170,7 +170,7 @@ class LLPanelOutfitEdit : public LLPanel
 	void onRemoveFromOutfitClicked(void);
 	void onEditWearableClicked(void);
 	void onAddWearableClicked(void);
-	void onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id);
+	void onReplaceMenuItemClicked(LLUUID selected_item_id);
 	void onShopButtonClicked();
 
 	void displayCurrentOutfit();
-- 
GitLab


From 2fb2efe2a24127ccb274cfdf1ca8e7e22d301ed5 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 15 Jul 2010 10:20:06 -0700
Subject: [PATCH 518/683] changed allow_html to parse_urls to be clearer about
 its meaning allow_html still supported as alternate

---
 indra/llui/lldraghandle.cpp                                  | 2 +-
 indra/llui/lltextbase.cpp                                    | 5 +++--
 indra/llui/lltextbase.h                                      | 2 +-
 indra/llui/lltooltip.cpp                                     | 2 +-
 indra/newview/llfolderview.cpp                               | 2 +-
 indra/newview/skins/default/xui/en/floater_aaa.xml           | 2 +-
 indra/newview/skins/default/xui/en/floater_about.xml         | 2 +-
 indra/newview/skins/default/xui/en/floater_im_session.xml    | 2 +-
 indra/newview/skins/default/xui/en/floater_nearby_chat.xml   | 2 +-
 .../skins/default/xui/en/floater_preview_notecard.xml        | 2 +-
 indra/newview/skins/default/xui/en/inspect_object.xml        | 2 +-
 .../skins/default/xui/en/panel_body_parts_list_item.xml      | 2 +-
 indra/newview/skins/default/xui/en/panel_chat_header.xml     | 2 +-
 indra/newview/skins/default/xui/en/panel_classified_info.xml | 4 ++--
 .../skins/default/xui/en/panel_clothing_list_item.xml        | 2 +-
 .../default/xui/en/panel_deletable_wearable_list_item.xml    | 2 +-
 .../skins/default/xui/en/panel_dummy_clothing_list_item.xml  | 2 +-
 indra/newview/skins/default/xui/en/panel_group_list_item.xml | 2 +-
 indra/newview/skins/default/xui/en/panel_group_notify.xml    | 2 +-
 indra/newview/skins/default/xui/en/panel_inventory_item.xml  | 2 +-
 indra/newview/skins/default/xui/en/panel_landmark_info.xml   | 2 +-
 indra/newview/skins/default/xui/en/panel_notification.xml    | 2 +-
 indra/newview/skins/default/xui/en/panel_pick_info.xml       | 2 +-
 indra/newview/skins/default/xui/en/panel_place_profile.xml   | 4 ++--
 .../skins/default/xui/en/panel_teleport_history_item.xml     | 2 +-
 .../skins/default/xui/en/widgets/bodyparts_list_item.xml     | 2 +-
 .../skins/default/xui/en/widgets/clothing_list_item.xml      | 2 +-
 .../default/xui/en/widgets/deletable_wearable_list_item.xml  | 2 +-
 .../default/xui/en/widgets/dummy_clothing_list_item.xml      | 2 +-
 .../newview/skins/default/xui/en/widgets/expandable_text.xml | 2 +-
 .../skins/default/xui/en/widgets/inventory_list_item.xml     | 2 +-
 .../skins/default/xui/en/widgets/simple_text_editor.xml      | 2 +-
 indra/newview/skins/default/xui/en/widgets/text.xml          | 2 +-
 indra/newview/skins/default/xui/en/widgets/text_editor.xml   | 2 +-
 34 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp
index 9f83fcca354..b52cb2b751a 100644
--- a/indra/llui/lldraghandle.cpp
+++ b/indra/llui/lldraghandle.cpp
@@ -113,7 +113,7 @@ void LLDragHandleTop::setTitle(const std::string& title)
 		params.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT);
 		params.font_shadow(LLFontGL::DROP_SHADOW_SOFT);
 		params.use_ellipses = true;
-		params.allow_html = false; //cancel URL replacement in floater title
+		params.parse_urls = false; //cancel URL replacement in floater title
 		mTitleBox = LLUICtrlFactory::create<LLTextBox> (params);
 		addChild( mTitleBox );
 	}
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index ed03645944a..dd0b7ebad1e 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -167,11 +167,12 @@ LLTextBase::Params::Params()
 	font_shadow("font_shadow"),
 	wrap("wrap"),
 	use_ellipses("use_ellipses", false),
-	allow_html("allow_html", false),
+	parse_urls("parse_urls", false),
 	parse_highlights("parse_highlights", false)
 {
 	addSynonym(track_end, "track_bottom");
 	addSynonym(wrap, "word_wrap");
+	addSynonym(parse_urls, "allow_html");
 }
 
 
@@ -209,7 +210,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
 	mPlainText ( p.plain_text ),
 	mWordWrap(p.wrap),
 	mUseEllipses( p.use_ellipses ),
-	mParseHTML(p.allow_html),
+	mParseHTML(p.parse_urls),
 	mParseHighlights(p.parse_highlights),
 	mBGVisible(p.bg_visible),
 	mScroller(NULL),
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 4b0eeeb7d6b..bd41272f11e 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -251,7 +251,7 @@ class LLTextBase
 								plain_text,
 								wrap,
 								use_ellipses,
-								allow_html,
+								parse_urls,
 								parse_highlights,
 								clip_partial;
 								
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp
index ed7fd02e14a..025725476eb 100644
--- a/indra/llui/lltooltip.cpp
+++ b/indra/llui/lltooltip.cpp
@@ -186,7 +186,7 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p)
 	params.font = p.font;
 	params.use_ellipses = true;
 	params.wrap = p.wrap;
-	params.allow_html = false; // disallow hyperlinks in tooltips, as they want to spawn their own explanatory tooltips
+	params.parse_urls = false; // disallow hyperlinks in tooltips, as they want to spawn their own explanatory tooltips
 	mTextBox = LLUICtrlFactory::create<LLTextBox> (params);
 	addChild(mTextBox);
 	
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index 87c5a830e93..8708ebebb09 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -250,7 +250,7 @@ LLFolderView::LLFolderView(const Params& p)
 	text_p.name(std::string(p.name));
 	text_p.font(font);
 	text_p.visible(false);
-	text_p.allow_html(true);
+	text_p.parse_urls(true);
 	text_p.wrap(true); // allow multiline text. See EXT-7564, EXT-7047
 	// set text padding the same as in People panel. EXT-7047, EXT-4837
 	text_p.h_pad(STATUS_TEXT_HPAD);
diff --git a/indra/newview/skins/default/xui/en/floater_aaa.xml b/indra/newview/skins/default/xui/en/floater_aaa.xml
index b9bc45a10b0..cae61468804 100644
--- a/indra/newview/skins/default/xui/en/floater_aaa.xml
+++ b/indra/newview/skins/default/xui/en/floater_aaa.xml
@@ -21,7 +21,7 @@
   <string name="test_the_vlt">This string CHANGE2 is extracted.</string>
   <string name="testing_eli">Just a test. changes.</string>
   <chat_history
-   allow_html="true"
+   parse_urls="true"
    bg_readonly_color="ChatHistoryBgColor"
    bg_writeable_color="ChatHistoryBgColor" 
    border_visible="false"
diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml
index b5be03346e2..f4d65bdb3aa 100644
--- a/indra/newview/skins/default/xui/en/floater_about.xml
+++ b/indra/newview/skins/default/xui/en/floater_about.xml
@@ -73,7 +73,7 @@ Packets Lost: [PACKETS_LOST,number,0]/[PACKETS_IN,number,0] ([PACKETS_PCT,number
       help_topic="about_support_tab"
       name="support_panel">
       <text_editor
-        allow_html="true" 
+        parse_urls="true" 
        follows="top|left"
        font="SansSerif"
        height="343"
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 c9b013099bc..6c1214f1522 100644
--- a/indra/newview/skins/default/xui/en/floater_im_session.xml
+++ b/indra/newview/skins/default/xui/en/floater_im_session.xml
@@ -67,7 +67,7 @@
          height="150"
          name="chat_history"
          parse_highlights="true"
-         allow_html="true"
+         parse_urls="true"
         left="1"
          width="249">
         </chat_history>
diff --git a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
index ec097a8e876..3b26c2ab590 100644
--- a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
+++ b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml
@@ -25,7 +25,7 @@
  single_instance="true"
  width="320">
   <chat_history
-    allow_html="true"
+    parse_urls="true"
     bg_readonly_color="ChatHistoryBgColor"
     bg_writeable_color="ChatHistoryBgColor"
     follows="all"
diff --git a/indra/newview/skins/default/xui/en/floater_preview_notecard.xml b/indra/newview/skins/default/xui/en/floater_preview_notecard.xml
index 0e8eef2a21b..e5a5fab9b93 100644
--- a/indra/newview/skins/default/xui/en/floater_preview_notecard.xml
+++ b/indra/newview/skins/default/xui/en/floater_preview_notecard.xml
@@ -71,7 +71,7 @@
      left="4"
      max_length="65536"
      name="Notecard Editor"
-     allow_html="false" 
+     parse_urls="false" 
      tab_group="1"
      top="46"
      width="392"
diff --git a/indra/newview/skins/default/xui/en/inspect_object.xml b/indra/newview/skins/default/xui/en/inspect_object.xml
index 8aeec46ba37..eb2e7ea7887 100644
--- a/indra/newview/skins/default/xui/en/inspect_object.xml
+++ b/indra/newview/skins/default/xui/en/inspect_object.xml
@@ -26,7 +26,7 @@ Owner [OWNER]
   <string name="Touch">Touch</string>
   <string name="Sit">Sit</string>
   <text
-     allow_html="false"
+     parse_urls="false"
      follows="all"
      font="SansSerifLarge"
      height="30"
diff --git a/indra/newview/skins/default/xui/en/panel_body_parts_list_item.xml b/indra/newview/skins/default/xui/en/panel_body_parts_list_item.xml
index 4f989a6f6f1..216a2651644 100644
--- a/indra/newview/skins/default/xui/en/panel_body_parts_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_body_parts_list_item.xml
@@ -41,7 +41,7 @@
      height="16"
      layout="topleft"
      left_pad="5"
-     allow_html="false"
+     parse_urls="false"
      use_ellipses="true"
      name="item_name"
      text_color="white"
diff --git a/indra/newview/skins/default/xui/en/panel_chat_header.xml b/indra/newview/skins/default/xui/en/panel_chat_header.xml
index 9124ad528d9..c98213f6c73 100644
--- a/indra/newview/skins/default/xui/en/panel_chat_header.xml
+++ b/indra/newview/skins/default/xui/en/panel_chat_header.xml
@@ -21,7 +21,7 @@
          top="3"
          width="18" />
     <text
-      allow_html="false"
+      parse_urls="false"
       allow_scroll="false"
       v_pad = "7"
       read_only = "true"
diff --git a/indra/newview/skins/default/xui/en/panel_classified_info.xml b/indra/newview/skins/default/xui/en/panel_classified_info.xml
index b7fd9773f26..07753e880ab 100644
--- a/indra/newview/skins/default/xui/en/panel_classified_info.xml
+++ b/indra/newview/skins/default/xui/en/panel_classified_info.xml
@@ -201,7 +201,7 @@
          value="Category:"
          width="140" />
         <text_editor
-         allow_html="true"
+         parse_urls="true"
          allow_scroll="false"
          bg_visible="false"
          follows="left|top|right"
@@ -370,7 +370,7 @@
          value="Description:"
          width="250" />
         <text_editor
-         allow_html="true"
+         parse_urls="true"
          allow_scroll="true"
          bg_visible="false"
          follows="all"
diff --git a/indra/newview/skins/default/xui/en/panel_clothing_list_item.xml b/indra/newview/skins/default/xui/en/panel_clothing_list_item.xml
index 93d7720c57b..cc0541e65c0 100644
--- a/indra/newview/skins/default/xui/en/panel_clothing_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_clothing_list_item.xml
@@ -53,7 +53,7 @@
      height="16"
      layout="topleft"
      left_pad="5"
-     allow_html="false"
+     parse_urls="false"
      use_ellipses="true"
      name="item_name"
      text_color="white"
diff --git a/indra/newview/skins/default/xui/en/panel_deletable_wearable_list_item.xml b/indra/newview/skins/default/xui/en/panel_deletable_wearable_list_item.xml
index 75b5fd1532f..de2ff0afc93 100644
--- a/indra/newview/skins/default/xui/en/panel_deletable_wearable_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_deletable_wearable_list_item.xml
@@ -53,7 +53,7 @@
      height="16"
      layout="topleft"
      left_pad="5"
-     allow_html="false"
+     parse_urls="false"
      use_ellipses="true"
      name="item_name"
      text_color="white"
diff --git a/indra/newview/skins/default/xui/en/panel_dummy_clothing_list_item.xml b/indra/newview/skins/default/xui/en/panel_dummy_clothing_list_item.xml
index a5dd34bd224..df459b40836 100644
--- a/indra/newview/skins/default/xui/en/panel_dummy_clothing_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_dummy_clothing_list_item.xml
@@ -42,7 +42,7 @@
      height="16"
      layout="topleft"
      left_pad="5"
-     allow_html="false"
+     parse_urls="false"
      use_ellipses="true"
      name="item_name"
      text_color="LtGray_50"
diff --git a/indra/newview/skins/default/xui/en/panel_group_list_item.xml b/indra/newview/skins/default/xui/en/panel_group_list_item.xml
index b674b39d9b1..ab34cbf20e4 100644
--- a/indra/newview/skins/default/xui/en/panel_group_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_list_item.xml
@@ -36,7 +36,7 @@
      top="2"
      width="20" />
    <text
-     allow_html="false"
+     parse_urls="false"
      follows="left|right"
      font="SansSerifSmall"
      height="15"
diff --git a/indra/newview/skins/default/xui/en/panel_group_notify.xml b/indra/newview/skins/default/xui/en/panel_group_notify.xml
index 65b2e81d502..6f271a757c4 100644
--- a/indra/newview/skins/default/xui/en/panel_group_notify.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_notify.xml
@@ -50,7 +50,7 @@
          width="230" />
     </panel>
     <text_editor
-     allow_html="true"
+     parse_urls="true"
      enabled="true"
      follows="all"
      height="0"
diff --git a/indra/newview/skins/default/xui/en/panel_inventory_item.xml b/indra/newview/skins/default/xui/en/panel_inventory_item.xml
index f1b7b92ece2..2e38835810c 100644
--- a/indra/newview/skins/default/xui/en/panel_inventory_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_inventory_item.xml
@@ -41,7 +41,7 @@
      height="20"
      layout="topleft"
      left_pad="5"
-     allow_html="false"
+     parse_urls="false"
      use_ellipses="true"
      name="item_name"
      text_color="white"
diff --git a/indra/newview/skins/default/xui/en/panel_landmark_info.xml b/indra/newview/skins/default/xui/en/panel_landmark_info.xml
index a0a1e2963a9..4eb7943746f 100644
--- a/indra/newview/skins/default/xui/en/panel_landmark_info.xml
+++ b/indra/newview/skins/default/xui/en/panel_landmark_info.xml
@@ -236,7 +236,7 @@
                  value="Title:"
                  width="290" />
                 <text
-                 allow_html="false"
+                 parse_urls="false"
                  follows="left|top"
                  height="22"
                  layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_notification.xml b/indra/newview/skins/default/xui/en/panel_notification.xml
index 34738745ebc..59ead84127a 100644
--- a/indra/newview/skins/default/xui/en/panel_notification.xml
+++ b/indra/newview/skins/default/xui/en/panel_notification.xml
@@ -78,7 +78,7 @@
       width="285"
       wrap="true"
       parse_highlights="true"
-      allow_html="true"/>
+      parse_urls="true"/>
   </panel>
   <panel
     background_visible="false"
diff --git a/indra/newview/skins/default/xui/en/panel_pick_info.xml b/indra/newview/skins/default/xui/en/panel_pick_info.xml
index 1d01bcb8a5c..a2ef4a85c5f 100644
--- a/indra/newview/skins/default/xui/en/panel_pick_info.xml
+++ b/indra/newview/skins/default/xui/en/panel_pick_info.xml
@@ -100,7 +100,7 @@
          follows="all"
          height="100"
          width="280"
-         allow_html="true"	
+         parse_urls="true"	
          hide_scrollbar="false"
          layout="topleft"
          left="10"
diff --git a/indra/newview/skins/default/xui/en/panel_place_profile.xml b/indra/newview/skins/default/xui/en/panel_place_profile.xml
index 35e80758966..0e36945f077 100644
--- a/indra/newview/skins/default/xui/en/panel_place_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_place_profile.xml
@@ -264,7 +264,7 @@
                 </layout_panel>
             </layout_stack>
             <text
-             allow_html="false"
+             parse_urls="false"
              follows="left|top|right"
              font="SansSerifLarge"
              height="14"
@@ -277,7 +277,7 @@
              value="SampleRegion"
              width="290" />
             <text
-             allow_html="false"
+             parse_urls="false"
              follows="left|top|right"
              height="14"
              layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_teleport_history_item.xml b/indra/newview/skins/default/xui/en/panel_teleport_history_item.xml
index c5f3fcc27df..d38ad8c5f88 100644
--- a/indra/newview/skins/default/xui/en/panel_teleport_history_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_teleport_history_item.xml
@@ -41,7 +41,7 @@
      height="20"
      layout="topleft"
      left_pad="5"
-     allow_html="false"
+     parse_urls="false"
      use_ellipses="true"
      name="region"
      text_color="white"
diff --git a/indra/newview/skins/default/xui/en/widgets/bodyparts_list_item.xml b/indra/newview/skins/default/xui/en/widgets/bodyparts_list_item.xml
index c08267de827..0eec002006d 100644
--- a/indra/newview/skins/default/xui/en/widgets/bodyparts_list_item.xml
+++ b/indra/newview/skins/default/xui/en/widgets/bodyparts_list_item.xml
@@ -21,7 +21,7 @@
    height="16"
    layout="topleft"
    left="21"
-   allow_html="false"
+   parse_urls="false"
    use_ellipses="true"
    name="item_name"
    text_color="white"
diff --git a/indra/newview/skins/default/xui/en/widgets/clothing_list_item.xml b/indra/newview/skins/default/xui/en/widgets/clothing_list_item.xml
index f7a05e9bc41..96d72c78a65 100644
--- a/indra/newview/skins/default/xui/en/widgets/clothing_list_item.xml
+++ b/indra/newview/skins/default/xui/en/widgets/clothing_list_item.xml
@@ -21,7 +21,7 @@
    height="16"
    layout="topleft"
    left="42"
-   allow_html="false"
+   parse_urls="false"
    use_ellipses="true"
    name="item_name"
    text_color="white"
diff --git a/indra/newview/skins/default/xui/en/widgets/deletable_wearable_list_item.xml b/indra/newview/skins/default/xui/en/widgets/deletable_wearable_list_item.xml
index 88a4682e134..0534485ddd5 100644
--- a/indra/newview/skins/default/xui/en/widgets/deletable_wearable_list_item.xml
+++ b/indra/newview/skins/default/xui/en/widgets/deletable_wearable_list_item.xml
@@ -33,7 +33,7 @@
    height="16"
    layout="topleft"
    left="45"
-   allow_html="false"
+   parse_urls="false"
    use_ellipses="true"
    name="item_name"
    text_color="white"
diff --git a/indra/newview/skins/default/xui/en/widgets/dummy_clothing_list_item.xml b/indra/newview/skins/default/xui/en/widgets/dummy_clothing_list_item.xml
index 80a877a6c2a..6c606248050 100644
--- a/indra/newview/skins/default/xui/en/widgets/dummy_clothing_list_item.xml
+++ b/indra/newview/skins/default/xui/en/widgets/dummy_clothing_list_item.xml
@@ -22,7 +22,7 @@
     height="16"
     layout="topleft"
     left="41"
-    allow_html="false"
+    parse_urls="false"
     use_ellipses="true"
     name="item_name"
     text_color="LtGray_50"
diff --git a/indra/newview/skins/default/xui/en/widgets/expandable_text.xml b/indra/newview/skins/default/xui/en/widgets/expandable_text.xml
index 216c4dea95c..a8520c235c9 100644
--- a/indra/newview/skins/default/xui/en/widgets/expandable_text.xml
+++ b/indra/newview/skins/default/xui/en/widgets/expandable_text.xml
@@ -2,7 +2,7 @@
 <expandable_text
  max_height="300" >
  <textbox
-  allow_html="true"
+  parse_urls="true"
   allow_scroll="true"
   bg_visible="false"
   label="More" 
diff --git a/indra/newview/skins/default/xui/en/widgets/inventory_list_item.xml b/indra/newview/skins/default/xui/en/widgets/inventory_list_item.xml
index 0a5930c8204..da9059c819f 100644
--- a/indra/newview/skins/default/xui/en/widgets/inventory_list_item.xml
+++ b/indra/newview/skins/default/xui/en/widgets/inventory_list_item.xml
@@ -32,7 +32,7 @@
     height="20"
     layout="topleft"
     left="21"
-    allow_html="false"
+    parse_urls="false"
     use_ellipses="true"
     name="item_name"
     text_color="white"
diff --git a/indra/newview/skins/default/xui/en/widgets/simple_text_editor.xml b/indra/newview/skins/default/xui/en/widgets/simple_text_editor.xml
index bb46ec09541..f575304c760 100644
--- a/indra/newview/skins/default/xui/en/widgets/simple_text_editor.xml
+++ b/indra/newview/skins/default/xui/en/widgets/simple_text_editor.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <simple_text_editor
-  allow_html="false" 
+  parse_urls="false" 
   mouse_opaque="true"
   font="SansSerifSmall"
   max_length="255" 
diff --git a/indra/newview/skins/default/xui/en/widgets/text.xml b/indra/newview/skins/default/xui/en/widgets/text.xml
index 3006df22b87..6e331b1c67a 100644
--- a/indra/newview/skins/default/xui/en/widgets/text.xml
+++ b/indra/newview/skins/default/xui/en/widgets/text.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<text allow_html="true"
+<text parse_urls="true"
       mouse_opaque="false" 
       name="text_box" 
       font="SansSerifSmall"
diff --git a/indra/newview/skins/default/xui/en/widgets/text_editor.xml b/indra/newview/skins/default/xui/en/widgets/text_editor.xml
index 2ced8b1b4ba..0f7f50b3129 100644
--- a/indra/newview/skins/default/xui/en/widgets/text_editor.xml
+++ b/indra/newview/skins/default/xui/en/widgets/text_editor.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <!-- Core parameters are in simple_text_editor.xml -->
 <text_editor
-  allow_html="false"
+  parse_urls="false"
   show_context_menu="true"/>
-- 
GitLab


From 88edd15674ca62bcb26bd28c38bfba25ef72e90c Mon Sep 17 00:00:00 2001
From: brad kittenbrink <brad@lindenlab.com>
Date: Thu, 15 Jul 2010 11:29:55 -0700
Subject: [PATCH 519/683] Fix for SNOW-742 compile & link errors under certain
 gcc versions due to violation of One Definition Rule. reviewed by Moss.

---
 indra/newview/tests/llsecapi_test.cpp | 92 +++++----------------------
 1 file changed, 16 insertions(+), 76 deletions(-)

diff --git a/indra/newview/tests/llsecapi_test.cpp b/indra/newview/tests/llsecapi_test.cpp
index caa1461987e..8f2f299fc47 100644
--- a/indra/newview/tests/llsecapi_test.cpp
+++ b/indra/newview/tests/llsecapi_test.cpp
@@ -35,6 +35,7 @@
 #include "../llviewernetwork.h"
 #include "../test/lltut.h"
 #include "../llsecapi.h"
+#include "../llsechandler_basic.h"
 #include "../../llxml/llcontrol.h"
 
 
@@ -56,82 +57,21 @@ std::string LLControlGroup::getString(const std::string& name)
 
 
 LLControlGroup gSavedSettings("test");
-class LLSecAPIBasicHandler : public LLSecAPIHandler
-{
-protected:
-	LLPointer<LLCertificateChain> mCertChain;
-	LLPointer<LLCertificate> mCert;
-	LLPointer<LLCertificateStore> mCertStore;
-	LLSD mLLSD;
-	
-public:
-	LLSecAPIBasicHandler() {}
-	
-	virtual ~LLSecAPIBasicHandler() {}
-	
-	// instantiate a certificate from a pem string
-	virtual LLPointer<LLCertificate> getCertificate(const std::string& pem_cert) 
-	{ 
-		return mCert; 
-	}
-	
-	
-	// instiate a certificate from an openssl X509 structure
-	virtual LLPointer<LLCertificate> getCertificate(X509* openssl_cert) 
-	{	
-		return mCert; 
-	}
-	
-	
-	// instantiate a chain from an X509_STORE_CTX
-	virtual LLPointer<LLCertificateChain> getCertificateChain(const X509_STORE_CTX* chain) 
-	{ 
-		return mCertChain; 
-	}
-	
-	// instantiate a cert store given it's id.  if a persisted version
-	// exists, it'll be loaded.  If not, one will be created (but not
-	// persisted)
-	virtual LLPointer<LLCertificateStore> getCertificateStore(const std::string& store_id) 
-	{ 
-		return mCertStore; 
-	}
-	
-	// persist data in a protected store
-	virtual void setProtectedData(const std::string& data_type,
-								  const std::string& data_id,
-								  const LLSD& data) {}
-	
-	// retrieve protected data
-	virtual LLSD getProtectedData(const std::string& data_type,
-								  const std::string& data_id) 
-	{ 
-		return mLLSD;
-	}
-	
-	virtual void deleteProtectedData(const std::string& data_type,
-									 const std::string& data_id)
-	{
-	}
-	
-	virtual LLPointer<LLCredential> createCredential(const std::string& grid,
-													 const LLSD& identifier, 
-													 const LLSD& authenticator)
-	{
-		LLPointer<LLCredential> cred = NULL;
-		return cred;
-	}
-	
-	virtual LLPointer<LLCredential> loadCredential(const std::string& grid)
-	{
-		LLPointer<LLCredential> cred = NULL;
-		return cred;
-	}
-	
-	virtual void saveCredential(LLPointer<LLCredential> cred, bool save_authenticator) {}
-	
-	virtual void deleteCredential(LLPointer<LLCredential> cred) {}
-};
+
+LLSecAPIBasicHandler::LLSecAPIBasicHandler() {}
+void LLSecAPIBasicHandler::init() {}
+LLSecAPIBasicHandler::~LLSecAPIBasicHandler() {}
+LLPointer<LLCertificate> LLSecAPIBasicHandler::getCertificate(const std::string& pem_cert) { return NULL; }
+LLPointer<LLCertificate> LLSecAPIBasicHandler::getCertificate(X509* openssl_cert) { return NULL; }
+LLPointer<LLCertificateChain> LLSecAPIBasicHandler::getCertificateChain(const X509_STORE_CTX* chain) { return NULL; }
+LLPointer<LLCertificateStore> LLSecAPIBasicHandler::getCertificateStore(const std::string& store_id) { return NULL; }
+void LLSecAPIBasicHandler::setProtectedData(const std::string& data_type, const std::string& data_id, const LLSD& data) {}
+LLSD LLSecAPIBasicHandler::getProtectedData(const std::string& data_type, const std::string& data_id) { return LLSD(); }
+void LLSecAPIBasicHandler::deleteProtectedData(const std::string& data_type, const std::string& data_id) {}
+LLPointer<LLCredential> LLSecAPIBasicHandler::createCredential(const std::string& grid, const LLSD& identifier, const LLSD& authenticator) { return NULL; }
+LLPointer<LLCredential> LLSecAPIBasicHandler::loadCredential(const std::string& grid) { return NULL; }
+void LLSecAPIBasicHandler::saveCredential(LLPointer<LLCredential> cred, bool save_authenticator) {}
+void LLSecAPIBasicHandler::deleteCredential(LLPointer<LLCredential> cred) {}
 
 // -------------------------------------------------------------------------------------------
 // TUT
-- 
GitLab


From 93ea3d2850067c23ff07f0ffb362b73247840e9a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 15 Jul 2010 14:17:51 -0500
Subject: [PATCH 520/683] Merge cleanup.

---
 indra/llmath/llvolume.cpp           | 22 +---------------------
 indra/newview/llappviewer.cpp       |  2 --
 indra/newview/llfloatersnapshot.cpp |  4 ++--
 indra/newview/llpanelobject.cpp     |  2 ++
 indra/newview/llvovolume.cpp        |  5 -----
 5 files changed, 5 insertions(+), 30 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 25db58491e2..0976487cbde 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -93,8 +93,6 @@ const F32 SKEW_MAX	=  0.95f;
 const F32 SCULPT_MIN_AREA = 0.002f;
 const S32 SCULPT_MIN_AREA_DETAIL = 1;
 
-#define GEN_TRI_STRIP 0
-
 BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
 {    
 	LLVector3 test = (pt2-pt1)%(pt3-pt2);
@@ -5663,8 +5661,6 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 					{
 						*out++ = ((gy*(grid_size+1))+gx+idxs[i]);
 					}		
-#if GEN_TRI_STRIP
-#endif
 				}
 				else
 				{
@@ -5672,14 +5668,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 					{
 						*out++ = ((gy*(grid_size+1))+gx+idxs[i]);
 					}
-#if GEN_TRI_STRIP
-#endif
 				}
-			}
-			
-#if GEN_TRI_STRIP
+			}	
 		}
-#endif
 	}
 		
 	return TRUE;
@@ -6539,13 +6530,9 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 
 	if (!partial_build)
 	{
-#if GEN_TRI_STRIP
-#endif
 		// Now we generate the indices.
 		for (t = 0; t < (mNumT-1); t++)
 		{
-#if GEN_TRI_STRIP
-#endif
 			for (s = 0; s < (mNumS-1); s++)
 			{	
 				mIndices[cur_index++] = s   + mNumS*t;			//bottom left
@@ -6555,8 +6542,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				mIndices[cur_index++] = s+1 + mNumS*t;			//bottom right
 				mIndices[cur_index++] = s+1 + mNumS*(t+1);		//top right
 
-#if GEN_TRI_STRIP
-#endif
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1;						//bottom left/top right neighbor face 
 				if (t < mNumT-2) {												//top right/top left neighbor face 
 					mEdge[cur_edge++] = (mNumS-1)*2*(t+1)+s*2+1;
@@ -6597,11 +6582,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 				}
 				mEdge[cur_edge++] = (mNumS-1)*2*t+s*2;							//top right/bottom left neighbor face	
 			}
-#if GEN_TRI_STRIP
-#endif
-#if GEN_TRI_STRIP
 		}
-#endif
 	}
 
 	//generate normals 
@@ -6684,7 +6665,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
 			}
 		}
 	}
-	
 	else  // logic for sculpt volumes
 	{
 		BOOL average_poles = FALSE;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0ef403720bc..8ffdd30d04a 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -3515,8 +3515,6 @@ static LLFastTimer::DeclareTimer FTM_REGION_UPDATE("Update Region");
 static LLFastTimer::DeclareTimer FTM_WORLD_UPDATE("Update World");
 static LLFastTimer::DeclareTimer FTM_NETWORK("Network");
 static LLFastTimer::DeclareTimer FTM_AGENT_NETWORK("Agent Network");
-static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot");
-static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update");
 static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager");
 
 ///////////////////////////////////////////////////////
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 187a5e2040d..43ea6143b10 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -999,7 +999,7 @@ void LLSnapshotLivePreview::saveTexture()
 		void *userdata = NULL;
 		upload_new_resource(tid,	// tid
 				    LLAssetType::AT_TEXTURE,
-				    snapname,
+				    "Snapshot : " + pos_string,
 				    "Taken by " + who_took_it + " at " + pos_string,
 				    0,
 				    LLFolderType::FT_SNAPSHOT_CATEGORY,
@@ -1007,7 +1007,7 @@ void LLSnapshotLivePreview::saveTexture()
 				    PERM_ALL,  // Note: Snapshots to inventory is a special case of content upload
 				    PERM_NONE, // that ignores the user's premissions preferences and continues to
 				    PERM_NONE, // always use these fairly permissive hard-coded initial perms. - MG
-				    snapname,
+				    "Snapshot : " + pos_string,
 				    callback, expected_upload_cost, userdata);
 		gViewerWindow->playSnapshotAnimAndSound();
 	}
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 63490d4fa23..1de04967372 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -1289,6 +1289,8 @@ void LLPanelObject::sendPhysicsParam()
 	body.append(LLSelectMgr::getInstance()->getSelection()->getFirstObject()->getID());
 	
 	LLHTTPClient::post( url, body, new CostResponder(body[0].asInteger()) );
+}
+
 void LLPanelObject::sendCastShadows()
 {
 	BOOL value = mCheckCastShadows->get();
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 4faef57074e..36391a3602e 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -96,13 +96,8 @@ LLPointer<LLObjectMediaNavigateClient> LLVOVolume::sObjectMediaNavigateClient =
 
 static LLFastTimer::DeclareTimer FTM_GEN_TRIANGLES("Generate Triangles");
 static LLFastTimer::DeclareTimer FTM_GEN_VOLUME("Generate Volumes");
-static LLFastTimer::DeclareTimer FTM_BUILD_MESH("Mesh");
-static LLFastTimer::DeclareTimer FTM_MESH_VFS("VFS");
-static LLFastTimer::DeclareTimer FTM_MESH_STREAM("Stream");
-static LLFastTimer::DeclareTimer FTM_MESH_FACES("Faces");
 static LLFastTimer::DeclareTimer FTM_VOLUME_TEXTURES("Volume Textures");
 
-
 // Implementation class of LLMediaDataClientObject.  See llmediadataclient.h
 class LLMediaDataClientObjectImpl : public LLMediaDataClientObject
 {
-- 
GitLab


From e4c81b920f0fe8efec4047b86fb683fcd8bc2318 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 15 Jul 2010 17:06:26 -0500
Subject: [PATCH 521/683] Make tools floater update automatically when object
 cost received.

---
 indra/newview/llviewerobject.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 862359005ec..2b89deaa53d 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -69,6 +69,7 @@
 #include "lldrawable.h"
 #include "llface.h"
 #include "llfloaterproperties.h"
+#include "llfloatertools.h"
 #include "llfollowcam.h"
 #include "llselectmgr.h"
 #include "llrendersphere.h"
@@ -855,6 +856,10 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 #endif
 				//clear cost and linkset cost
 				mCostStale = true;
+				if (isSelected())
+				{
+					gFloaterTools->dirty();
+				}
 
 				LLUUID audio_uuid;
 				LLUUID owner_id;	// only valid if audio_uuid or particle system is not null
@@ -1423,6 +1428,11 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 #endif
 				mCostStale = true;
 
+				if (isSelected())
+				{
+					gFloaterTools->dirty();
+				}
+	
 				dp->unpackU32(crc, "CRC");
 				mTotalCRC = crc;
 				dp->unpackU8(material, "Material");
@@ -2903,12 +2913,22 @@ void LLViewerObject::setObjectCost(F32 cost)
 {
 	mObjectCost = cost;
 	mCostStale = false;
+
+	if (isSelected())
+	{
+		gFloaterTools->dirty();
+	}
 }
 
 void LLViewerObject::setLinksetCost(F32 cost)
 {
 	mLinksetCost = cost;
 	mCostStale = false;
+	
+	if (isSelected())
+	{
+		gFloaterTools->dirty();
+	}
 }
 
 
-- 
GitLab


From 6ad6f9116311ffb565003f7cceb0188ba7115fc8 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Thu, 15 Jul 2010 16:32:50 -0700
Subject: [PATCH 522/683] Changes to allow disabling an LLTextBox (or LLTextBox
 subclass) to gray out the text.

Due to some legacy issues, text boxes will not gray out on disable unless they have their text_readonly_color property in xui set to "LabelDisabledColor" (or some other color distinct from their text color).

Reviewed by Richard.
---
 indra/llui/lltextbase.cpp                             |  3 ---
 indra/llui/lltextbox.cpp                              | 11 +++++++++++
 indra/llui/lltextbox.h                                |  2 ++
 indra/llui/lltexteditor.cpp                           |  3 +++
 indra/newview/skins/default/xui/en/widgets/text.xml   |  2 +-
 .../skins/default/xui/en/widgets/text_editor.xml      |  1 +
 6 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index ed03645944a..5175583dc96 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -269,9 +269,6 @@ void LLTextBase::initFromParams(const LLTextBase::Params& p)
 	{
 		mReadOnly = p.read_only;
 	}
-
-	// HACK:  text editors always need to be enabled so that we can scroll
-	LLView::setEnabled(true);
 }
 
 bool LLTextBase::truncate()
diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp
index a1f5b5726bf..686179b94e5 100644
--- a/indra/llui/lltextbox.cpp
+++ b/indra/llui/lltextbox.cpp
@@ -119,6 +119,17 @@ BOOL LLTextBox::handleHover(S32 x, S32 y, MASK mask)
 	return handled;
 }
 
+void LLTextBox::setEnabled(BOOL enabled)
+{
+	// just treat enabled as read-only flag
+	bool read_only = !enabled;
+	if (read_only != mReadOnly)
+	{
+		LLTextBase::setReadOnly(read_only);
+		updateSegments();
+	}
+}
+
 void LLTextBox::setText(const LLStringExplicit& text , const LLStyle::Params& input_params )
 {
 	// does string argument insertion
diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h
index 3a045534d38..b2ccde94c64 100644
--- a/indra/llui/lltextbox.h
+++ b/indra/llui/lltextbox.h
@@ -58,6 +58,8 @@ class LLTextBox :
 	/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
 
+	/*virtual*/ void setEnabled(BOOL enabled);
+
 	/*virtual*/ void setText( const LLStringExplicit& text, const LLStyle::Params& input_params = LLStyle::Params() );
 	
 	void			setRightAlign()							{ mHAlign = LLFontGL::RIGHT; }
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 130cda3784a..6781c23416a 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -289,6 +289,9 @@ void LLTextEditor::initFromParams( const LLTextEditor::Params& p)
 {
 	LLTextBase::initFromParams(p);
 
+	// HACK:  text editors always need to be enabled so that we can scroll
+	LLView::setEnabled(true);
+
 	if (p.commit_on_focus_lost.isProvided())
 	{
 		mCommitOnFocusLost = p.commit_on_focus_lost;
diff --git a/indra/newview/skins/default/xui/en/widgets/text.xml b/indra/newview/skins/default/xui/en/widgets/text.xml
index 3006df22b87..3fa3f3eb902 100644
--- a/indra/newview/skins/default/xui/en/widgets/text.xml
+++ b/indra/newview/skins/default/xui/en/widgets/text.xml
@@ -8,7 +8,7 @@
       halign="left" 
       h_pad="0" 
       allow_scroll="false"
-      text_readonly_color="LabelDisabledColor"
+      text_readonly_color="LabelTextColor"
       bg_writeable_color="FloaterDefaultBackgroundColor" 
       use_ellipses="false"
       bg_visible="false" 
diff --git a/indra/newview/skins/default/xui/en/widgets/text_editor.xml b/indra/newview/skins/default/xui/en/widgets/text_editor.xml
index 2ced8b1b4ba..af2e17fc3f5 100644
--- a/indra/newview/skins/default/xui/en/widgets/text_editor.xml
+++ b/indra/newview/skins/default/xui/en/widgets/text_editor.xml
@@ -2,4 +2,5 @@
 <!-- Core parameters are in simple_text_editor.xml -->
 <text_editor
   allow_html="false"
+  text_readonly_color="LabelDisabledColor"
   show_context_menu="true"/>
-- 
GitLab


From 7844914b03c062596812cdad1feffff700bcd45c Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Thu, 15 Jul 2010 17:07:05 -0700
Subject: [PATCH 523/683] Fix for EXT-8230

LLPanelMediaSettingsPermissions::initValues() was referencing both XUI elements that don't exist and strings that don't appear in strings.xml.

Also fixed a number of elements in panel_media_settings_permissions.xml and floater_tools.xml that weren't graying out properly when non-editable items were selected, and some mixed up image attributes that made the media "gear" icon states look wrong.
---
 indra/newview/llpanelface.cpp                 | 10 ----------
 .../llpanelmediasettingspermissions.cpp       | 20 ++++++++++---------
 .../skins/default/xui/en/floater_tools.xml    | 15 ++++++++++----
 .../en/panel_media_settings_permissions.xml   | 15 +++++++++-----
 4 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 7d5be39074b..e3503c065ba 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -505,8 +505,6 @@ void LLPanelFace::getState()
 
 		// Texture scale
 		{
-			childSetEnabled("tex scale",editable);
-			//mLabelTexScale->setEnabled( editable );
 			F32 scale_s = 1.f;
 			struct f2 : public LLSelectedTEGetFunctor<F32>
 			{
@@ -577,7 +575,6 @@ void LLPanelFace::getState()
 
 		// Texture rotation
 		{
-			childSetEnabled("tex rotate",editable);
 			F32 rotation = 0.f;
 			struct f6 : public LLSelectedTEGetFunctor<F32>
 			{
@@ -720,14 +717,9 @@ void LLPanelFace::getState()
 
 			if (selected_texgen == 1)
 			{
-				childSetText("tex scale",getString("string repeats per meter"));
 				childSetValue("TexScaleU", 2.0f * childGetValue("TexScaleU").asReal() );
 				childSetValue("TexScaleV", 2.0f * childGetValue("TexScaleV").asReal() );
 			}
-			else
-			{
-				childSetText("tex scale",getString("string repeats per face"));
-			}
 
 		}
 
@@ -802,9 +794,7 @@ void LLPanelFace::getState()
 		}
 		childSetEnabled("color trans",FALSE);
 		childSetEnabled("rpt",FALSE);
-		childSetEnabled("tex scale",FALSE);
 		childSetEnabled("tex offset",FALSE);
-		childSetEnabled("tex rotate",FALSE);
 		childSetEnabled("tex gen",FALSE);
 		childSetEnabled("label shininess",FALSE);
 		childSetEnabled("label bumpiness",FALSE);
diff --git a/indra/newview/llpanelmediasettingspermissions.cpp b/indra/newview/llpanelmediasettingspermissions.cpp
index e5caaaaffcd..7779ac63920 100644
--- a/indra/newview/llpanelmediasettingspermissions.cpp
+++ b/indra/newview/llpanelmediasettingspermissions.cpp
@@ -107,7 +107,6 @@ void LLPanelMediaSettingsPermissions::draw()
 		if(mPermsGroupName)
 		{
 			mPermsGroupName->setNameID(group_id, true);
-			mPermsGroupName->setEnabled(true);
 		};
 	}
 	else
@@ -116,7 +115,6 @@ void LLPanelMediaSettingsPermissions::draw()
 		{
 			mPermsGroupName->setNameID(LLUUID::null, TRUE);
 			mPermsGroupName->refresh(LLUUID::null, LLStringUtil::null, LLStringUtil::null, true);
-			mPermsGroupName->setEnabled(false);
 		};
 	};
 }
@@ -142,6 +140,12 @@ void LLPanelMediaSettingsPermissions::clearValues( void* userdata, bool editable
 	self->mPermsGroupControl->setEnabled(editable);
 	self->mPermsWorldInteract->setEnabled(editable);
 	self->mPermsWorldControl->setEnabled(editable);
+
+	self->getChild< LLTextBox >("controls_label")->setEnabled(editable);
+	self->getChild< LLTextBox >("owner_label")->setEnabled(editable);
+	self->getChild< LLTextBox >("group_label")->setEnabled(editable);
+	self->getChild< LLNameBox >("perms_group_name")->setEnabled(editable);
+	self->getChild< LLTextBox >("anyone_label")->setEnabled(editable);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -216,13 +220,11 @@ void LLPanelMediaSettingsPermissions::initValues( void* userdata, const LLSD& me
 		self->mPermsWorldControl->setEnabled(false);
 	}
 	
-	
-	self->childSetEnabled("media_perms_label_owner", editable );
-	self->childSetText("media_perms_label_owner",  LLTrans::getString("Media Perms Owner") );
-	self->childSetEnabled("media_perms_label_group", editable );
-	self->childSetText("media_perms_label_group",  LLTrans::getString("Media Perms Group") );
-	self->childSetEnabled("media_perms_label_anyone", editable );
-	self->childSetText("media_perms_label_anyone", LLTrans::getString("Media Perms Anyone") );
+	self->getChild< LLTextBox >("controls_label")->setEnabled(editable);
+	self->getChild< LLTextBox >("owner_label")->setEnabled(editable);
+	self->getChild< LLTextBox >("group_label")->setEnabled(editable);
+	self->getChild< LLNameBox >("perms_group_name")->setEnabled(editable);
+	self->getChild< LLTextBox >("anyone_label")->setEnabled(editable);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index a96dbe35534..514b0a501b6 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -2322,6 +2322,7 @@ even though the user gets a free copy.
              layout="topleft"
              left_pad="15"
              name="color trans"
+             text_readonly_color="LabelDisabledColor"
              top="6"
              width="110">
                 Transparency %
@@ -2346,6 +2347,7 @@ even though the user gets a free copy.
              layout="topleft"
              left_delta="0"
              name="glow label"
+             text_readonly_color="LabelDisabledColor"
              top_pad="8"
              width="80">
                 Glow
@@ -2376,6 +2378,7 @@ even though the user gets a free copy.
              layout="topleft"
              left="10"
              name="tex gen"
+             text_readonly_color="LabelDisabledColor"
              top_pad="5"
              width="90">
                 Mapping
@@ -2404,6 +2407,7 @@ even though the user gets a free copy.
              layout="topleft"
              name="label shininess"
              left_pad="4"
+             text_readonly_color="LabelDisabledColor"
              top_pad="-36"
              width="90">
                 Shininess
@@ -2440,6 +2444,7 @@ even though the user gets a free copy.
              layout="topleft"
              left_pad="4"
              name="label bumpiness"
+             text_readonly_color="LabelDisabledColor"
              top_pad="-36"
              width="90">
                 Bumpiness
@@ -2565,7 +2570,8 @@ even though the user gets a free copy.
              height="10"
              layout="topleft"
              left="10"
-             name="tex scale"
+             name="rpt"
+             text_readonly_color="LabelDisabledColor"
              top_pad="4"
              width="200">
                 Repeats / Face
@@ -2654,6 +2660,7 @@ even though the user gets a free copy.
              layout="topleft"
              left="10"
              name="tex offset"
+             text_readonly_color="LabelDisabledColor"
              width="200">
                 Texture Offset
             </text>
@@ -2737,9 +2744,9 @@ even though the user gets a free copy.
 			 follows="top|left"
 			 tool_tip="Edit this Media"
 			 height="12"
-			 image_disabled="Icon_Gear_Foreground"
-			 image_selected="Icon_Gear_Background"
-			 image_unselected="Icon_Gear_Press"
+             image_disabled="Icon_Gear_Background"
+             image_selected="Icon_Gear_Press"
+             image_unselected="Icon_Gear_Foreground"
 			 layout="topleft"
 			 left_pad="10"
 			 name="edit_media"
diff --git a/indra/newview/skins/default/xui/en/panel_media_settings_permissions.xml b/indra/newview/skins/default/xui/en/panel_media_settings_permissions.xml
index c5f44cd049a..d3a58fed584 100644
--- a/indra/newview/skins/default/xui/en/panel_media_settings_permissions.xml
+++ b/indra/newview/skins/default/xui/en/panel_media_settings_permissions.xml
@@ -16,7 +16,8 @@
    follows="top|left"
    height="15"
    left="10"
-   name="controls_label">
+   name="controls_label" 
+   text_readonly_color="LabelDisabledColor">
     Controls:
   </text>
   <combo_box
@@ -46,7 +47,8 @@
    follows="top|left" 
    height="15" 
    left="10" 
-   name="owner_label">
+   name="owner_label" 
+   text_readonly_color="LabelDisabledColor">
     Owner
   </text>
   
@@ -83,8 +85,9 @@
    enabled="false"
    follows="top|left" 
    height="15" 
-   left="10" 
-   name="group_label">
+   left="10"
+   name="group_label" 
+   text_readonly_color="LabelDisabledColor">
     Group:
   </text>
   
@@ -95,6 +98,7 @@
    font="SansSerif"
    height="20" left="60" 
    name="perms_group_name"
+   text_readonly_color="LabelDisabledColor"
    value ="" 
    width="200" />
    
@@ -132,7 +136,8 @@
    follows="top|left" 
    height="15" 
    left="10" 
-   name="anyone_label">
+   name="anyone_label" 
+   text_readonly_color="LabelDisabledColor">
     Anyone
   </text>
   
-- 
GitLab


From bc87b6078bdcd36aeca908f9369f11edf6c61447 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Fri, 16 Jul 2010 19:08:37 +0300
Subject: [PATCH 524/683] EXT-8258 FIXED Update the Trash button in 'My
 Inventory' if selected items get worn or taken off.

Reviewed by Nyx at https://codereview.productengine.com/secondlife/r/772/

--HG--
branch : product-engine
---
 indra/newview/llpanelmaininventory.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index 3e12f0ba9aa..98cb88e7516 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -45,6 +45,7 @@
 #include "llinventorypanel.h"
 #include "llfiltereditor.h"
 #include "llfloaterreg.h"
+#include "lloutfitobserver.h"
 #include "llpreviewtexture.h"
 #include "llresmgr.h"
 #include "llscrollcontainer.h"
@@ -919,6 +920,9 @@ void LLPanelMainInventory::initListCommandsHandlers()
 	mEnableCallbackRegistrar.add("Inventory.GearDefault.Enable", boost::bind(&LLPanelMainInventory::isActionEnabled, this, _2));
 	mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
 	mMenuAdd = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+
+	// Update the trash button when selected item(s) get worn or taken off.
+	LLOutfitObserver::instance().addCOFChangedCallback(boost::bind(&LLPanelMainInventory::updateListCommands, this));
 }
 
 void LLPanelMainInventory::updateListCommands()
-- 
GitLab


From feab33f952446cf765e5c14f09289362b966eb56 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Fri, 16 Jul 2010 19:12:46 +0300
Subject: [PATCH 525/683] EXT-8365 FIXED Untranslated "More" link in the
 Residents Profiles.

The default link label specified in widgets/expandable_text.xml didn't seem to be taken into account for translation.
So I moved the label to strings.xml to make sure it's localized.
Also I removed overridden textbox.label attribute values because VLT can't handle them.

Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/770/

--HG--
branch : product-engine
---
 indra/newview/llexpandabletextbox.cpp                          | 3 ++-
 indra/newview/skins/default/xui/en/floater_event.xml           | 1 -
 .../skins/default/xui/en/panel_classifieds_list_item.xml       | 1 -
 indra/newview/skins/default/xui/en/panel_landmark_info.xml     | 1 -
 indra/newview/skins/default/xui/en/panel_my_profile.xml        | 3 ---
 indra/newview/skins/default/xui/en/panel_pick_list_item.xml    | 1 -
 indra/newview/skins/default/xui/en/panel_place_profile.xml     | 1 -
 indra/newview/skins/default/xui/en/panel_profile.xml           | 3 ---
 indra/newview/skins/default/xui/en/widgets/expandable_text.xml | 1 -
 9 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp
index 92fda31cc23..8ccc5fb2484 100644
--- a/indra/newview/llexpandabletextbox.cpp
+++ b/indra/newview/llexpandabletextbox.cpp
@@ -34,6 +34,7 @@
 #include "llexpandabletextbox.h"
 
 #include "llscrollcontainer.h"
+#include "lltrans.h"
 #include "llwindow.h"
 #include "llviewerwindow.h"
 
@@ -117,7 +118,7 @@ LLExpandableTextBox::LLTextBoxEx::Params::Params()
 
 LLExpandableTextBox::LLTextBoxEx::LLTextBoxEx(const Params& p)
 :	LLTextEditor(p),
-	mExpanderLabel(p.label),
+	mExpanderLabel(p.label.isProvided() ? p.label : LLTrans::getString("More")),
 	mExpanderVisible(false)
 {
 	setIsChrome(TRUE);
diff --git a/indra/newview/skins/default/xui/en/floater_event.xml b/indra/newview/skins/default/xui/en/floater_event.xml
index 887cedc33fb..98640834420 100644
--- a/indra/newview/skins/default/xui/en/floater_event.xml
+++ b/indra/newview/skins/default/xui/en/floater_event.xml
@@ -244,7 +244,6 @@
        layout="topleft"
        left="6"
        name="event_desc"
-       textbox.label="More"
        width="322">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</expandable_text>
     </layout_panel>
diff --git a/indra/newview/skins/default/xui/en/panel_classifieds_list_item.xml b/indra/newview/skins/default/xui/en/panel_classifieds_list_item.xml
index af3315ebfe1..996e28c5752 100644
--- a/indra/newview/skins/default/xui/en/panel_classifieds_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_classifieds_list_item.xml
@@ -65,7 +65,6 @@
      left="103"
      name="description"
      textbox.max_length="1024"
-     textbox.label="More"
      textbox.show_context_menu="false" 
      top_pad="0"
      width="178"
diff --git a/indra/newview/skins/default/xui/en/panel_landmark_info.xml b/indra/newview/skins/default/xui/en/panel_landmark_info.xml
index a0a1e2963a9..f5202382cc9 100644
--- a/indra/newview/skins/default/xui/en/panel_landmark_info.xml
+++ b/indra/newview/skins/default/xui/en/panel_landmark_info.xml
@@ -139,7 +139,6 @@
              layout="topleft"
              left="10"
              name="description"
-             textbox.label="More"
              top_pad="10"
              value="Du waltz die spritz"
              width="280" />
diff --git a/indra/newview/skins/default/xui/en/panel_my_profile.xml b/indra/newview/skins/default/xui/en/panel_my_profile.xml
index 1083f4d4676..0310391846d 100644
--- a/indra/newview/skins/default/xui/en/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_my_profile.xml
@@ -118,7 +118,6 @@
                layout="topleft"
                left="107"
                textbox.max_length="512"
-               textbox.label="More"
                textbox.show_context_menu="true"
                name="sl_description_edit"
                top_pad="-3"
@@ -174,7 +173,6 @@
                layout="topleft"
                left="107"
                textbox.max_length="512"
-               textbox.label="More"
                textbox.show_context_menu="true"
                name="fl_description_edit"
                top_pad="-3"
@@ -316,7 +314,6 @@
             name="sl_groups"
           top_pad="0"
             translate="false"
-            textbox.label="More"
             textbox.show_context_menu="true"
             width="298"
             expanded_bg_visible="true"
diff --git a/indra/newview/skins/default/xui/en/panel_pick_list_item.xml b/indra/newview/skins/default/xui/en/panel_pick_list_item.xml
index 41651edaa02..715dc5f23cf 100644
--- a/indra/newview/skins/default/xui/en/panel_pick_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_pick_list_item.xml
@@ -65,7 +65,6 @@
      left="103"
      name="picture_descr"
      textbox.max_length="1024"
-     textbox.label="More"
      textbox.show_context_menu="false" 
      top_pad="0"
      width="178"
diff --git a/indra/newview/skins/default/xui/en/panel_place_profile.xml b/indra/newview/skins/default/xui/en/panel_place_profile.xml
index 35e80758966..cba4e0693a5 100644
--- a/indra/newview/skins/default/xui/en/panel_place_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_place_profile.xml
@@ -293,7 +293,6 @@
              layout="topleft"
              left="5"
              name="description"
-             textbox.label="More"
              top_pad="10"
              value="Du waltz die spritz"
              width="300" />
diff --git a/indra/newview/skins/default/xui/en/panel_profile.xml b/indra/newview/skins/default/xui/en/panel_profile.xml
index fc33836c79d..e41b80baf27 100644
--- a/indra/newview/skins/default/xui/en/panel_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_profile.xml
@@ -108,7 +108,6 @@
                layout="topleft"
                left="107"
                textbox.max_length="512"
-               textbox.label="More"
                textbox.show_context_menu="true"
                name="sl_description_edit"
                top_pad="-3"
@@ -155,7 +154,6 @@
                layout="topleft"
                left="107"
                textbox.max_length="512"
-               textbox.label="More"
                textbox.show_context_menu="true"
                name="fl_description_edit"
                top_pad="-3"
@@ -295,7 +293,6 @@
             left="7"
             name="sl_groups"
             textbox.max_length="512"
-            textbox.label="More"
             textbox.show_context_menu="true"
             top_pad="0"
             translate="false"
diff --git a/indra/newview/skins/default/xui/en/widgets/expandable_text.xml b/indra/newview/skins/default/xui/en/widgets/expandable_text.xml
index 216c4dea95c..46a681b697e 100644
--- a/indra/newview/skins/default/xui/en/widgets/expandable_text.xml
+++ b/indra/newview/skins/default/xui/en/widgets/expandable_text.xml
@@ -5,7 +5,6 @@
   allow_html="true"
   allow_scroll="true"
   bg_visible="false"
-  label="More" 
   follows="left|top|right"
   name="text"
   read_only="true"
-- 
GitLab


From c7549513974bdf8028824135bd017c7ea390ea77 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Fri, 16 Jul 2010 19:03:13 +0300
Subject: [PATCH 526/683] EXT-8188 FIXED Added SelectionEnabled flag to fix
 accordion tab header highlighting.

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/735/.

--HG--
branch : product-engine
---
 indra/llui/llaccordionctrltab.cpp | 5 +++--
 indra/llui/llaccordionctrltab.h   | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp
index 37fc571bbdc..0cccd4e6de0 100644
--- a/indra/llui/llaccordionctrltab.cpp
+++ b/indra/llui/llaccordionctrltab.cpp
@@ -358,6 +358,7 @@ LLAccordionCtrlTab::LLAccordionCtrlTab(const LLAccordionCtrlTab::Params&p)
 	,mPaddingBottom(p.padding_bottom)
 	,mCanOpenClose(true)
 	,mFitPanel(p.fit_panel)
+	,mSelectionEnabled(p.selection_enabled)
 	,mContainerPanel(NULL)
 	,mScrollbar(NULL)
 {
@@ -371,7 +372,7 @@ LLAccordionCtrlTab::LLAccordionCtrlTab(const LLAccordionCtrlTab::Params&p)
 	mHeader = LLUICtrlFactory::create<LLAccordionCtrlTabHeader>(headerParams);
 	addChild(mHeader, 1);
 
-	if (p.selection_enabled)
+	if (mSelectionEnabled)
 	{
 		LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLAccordionCtrlTab::selectOnFocusReceived, this));
 	}
@@ -797,7 +798,7 @@ void LLAccordionCtrlTab::showAndFocusHeader()
 {
 	LLAccordionCtrlTabHeader* header = getChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME);	
 	header->setFocus(true);
-	header->setSelected(true);
+	header->setSelected(mSelectionEnabled);
 
 	LLRect screen_rc;
 	LLRect selected_rc = header->getRect();
diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h
index 5646a355d07..1344ce0a300 100644
--- a/indra/llui/llaccordionctrltab.h
+++ b/indra/llui/llaccordionctrltab.h
@@ -241,6 +241,8 @@ class LLAccordionCtrlTab : public LLUICtrl
 	bool mStoredOpenCloseState;
 	bool mWasStateStored;
 
+	bool mSelectionEnabled;
+
 	LLScrollbar*	mScrollbar;
 	LLView*			mContainerPanel;
 
-- 
GitLab


From 109ff259ca4f2d2d9d7d4b6e8120bf201736b434 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 16 Jul 2010 17:11:51 -0700
Subject: [PATCH 527/683] EXT-8465 FIX Text selection is often unreadable

---
 indra/llui/llstyle.cpp                        | 12 +++---
 indra/llui/llstyle.h                          | 37 +++++++++----------
 indra/llui/lltextbase.cpp                     | 31 ++++++----------
 indra/llui/lltextbase.h                       |  6 ++-
 .../xui/en/widgets/simple_text_editor.xml     |  2 +
 5 files changed, 43 insertions(+), 45 deletions(-)

diff --git a/indra/llui/llstyle.cpp b/indra/llui/llstyle.cpp
index b8f93b6a0ea..d63f67b4c1d 100644
--- a/indra/llui/llstyle.cpp
+++ b/indra/llui/llstyle.cpp
@@ -42,6 +42,8 @@ LLStyle::Params::Params()
 :	visible("visible", true),
 	drop_shadow("drop_shadow", LLFontGL::NO_SHADOW),
 	color("color", LLColor4::black),
+	readonly_color("readonly_color", LLColor4::black),
+	selected_color("selected_color", LLColor4::black),
 	font("font", LLFontGL::getFontMonospace()),
 	image("image"),
 	link_href("href")
@@ -49,12 +51,10 @@ LLStyle::Params::Params()
 
 
 LLStyle::LLStyle(const LLStyle::Params& p)
-:	mItalic(FALSE),
-	mBold(FALSE),
-	mUnderline(FALSE),
-	mVisible(p.visible),
-	mColor(p.color()),
-	mReadOnlyColor(p.readonly_color()),
+:	mVisible(p.visible),
+	mColor(p.color),
+	mReadOnlyColor(p.readonly_color),
+	mSelectedColor(p.selected_color),
 	mFont(p.font()),
 	mLink(p.link_href),
 	mDropShadow(p.drop_shadow),
diff --git a/indra/llui/llstyle.h b/indra/llui/llstyle.h
index 2067e8e8be3..44d9da7a1eb 100644
--- a/indra/llui/llstyle.h
+++ b/indra/llui/llstyle.h
@@ -47,7 +47,8 @@ class LLStyle : public LLRefCount
 		Optional<bool>					visible;
 		Optional<LLFontGL::ShadowType>	drop_shadow;
 		Optional<LLUIColor>				color,
-										readonly_color;
+										readonly_color,
+										selected_color;
 		Optional<const LLFontGL*>		font;
 		Optional<LLUIImage*>			image;
 		Optional<std::string>			link_href;
@@ -55,11 +56,14 @@ class LLStyle : public LLRefCount
 	};
 	LLStyle(const Params& p = Params());
 public:
-	const LLColor4& getColor() const { return mColor; }
-	void setColor(const LLColor4 &color) { mColor = color; }
+	const LLUIColor& getColor() const { return mColor; }
+	void setColor(const LLUIColor &color) { mColor = color; }
 
-	const LLColor4& getReadOnlyColor() const { return mReadOnlyColor; }
-	void setReadOnlyColor(const LLColor4& color) { mReadOnlyColor = color; }
+	const LLUIColor& getReadOnlyColor() const { return mReadOnlyColor; }
+	void setReadOnlyColor(const LLUIColor& color) { mReadOnlyColor = color; }
+
+	const LLUIColor& getSelectedColor() const { return mSelectedColor; }
+	void setSelectedColor(const LLUIColor& color) { mSelectedColor = color; }
 
 	BOOL isVisible() const;
 	void setVisible(BOOL is_visible);
@@ -79,41 +83,36 @@ class LLStyle : public LLRefCount
 
 	BOOL isImage() const { return mImagep.notNull(); }
 
-	// inlined here to make it easier to compare to member data below. -MG
 	bool operator==(const LLStyle &rhs) const
 	{
 		return 
 			mVisible == rhs.mVisible
 			&& mColor == rhs.mColor
 			&& mReadOnlyColor == rhs.mReadOnlyColor
+			&& mSelectedColor == rhs.mSelectedColor
 			&& mFont == rhs.mFont
 			&& mLink == rhs.mLink
 			&& mImagep == rhs.mImagep
-			&& mItalic == rhs.mItalic
-			&& mBold == rhs.mBold
-			&& mUnderline == rhs.mUnderline
 			&& mDropShadow == rhs.mDropShadow;
 	}
 
 	bool operator!=(const LLStyle& rhs) const { return !(*this == rhs); }
 
 public:	
-	BOOL        mItalic;
-	BOOL        mBold;
-	BOOL        mUnderline;
 	LLFontGL::ShadowType		mDropShadow;
 
 protected:
 	~LLStyle() { }
 
 private:
-	BOOL		mVisible;
-	LLUIColor	mColor;
-	LLUIColor   mReadOnlyColor;
-	std::string	mFontName;
-	const LLFontGL*   mFont;		// cached for performance
-	std::string	mLink;
-	LLUIImagePtr mImagep;
+	BOOL				mVisible;
+	LLUIColor			mColor;
+	LLUIColor   		mReadOnlyColor;
+	LLUIColor			mSelectedColor;
+	std::string			mFontName;
+	const LLFontGL*		mFont;
+	std::string			mLink;
+	LLUIImagePtr		mImagep;
 };
 
 typedef LLPointer<LLStyle> LLStyleSP;
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index dd0b7ebad1e..538924e5d1e 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -155,6 +155,8 @@ LLTextBase::Params::Params()
 	bg_readonly_color("bg_readonly_color"),
 	bg_writeable_color("bg_writeable_color"),
 	bg_focus_color("bg_focus_color"),
+	text_selected_color("text_selected_color"),
+	bg_selected_color("bg_selected_color"),
 	allow_scroll("allow_scroll", true),
 	plain_text("plain_text",false),
 	track_end("track_end", false),
@@ -191,6 +193,8 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
 	mWriteableBgColor(p.bg_writeable_color),
 	mReadOnlyBgColor(p.bg_readonly_color),
 	mFocusBgColor(p.bg_focus_color),
+	mTextSelectedColor(p.text_selected_color),
+	mSelectedBGColor(p.bg_selected_color),
 	mReflowIndex(S32_MAX),
 	mCursorPos( 0 ),
 	mScrollNeeded(FALSE),
@@ -302,11 +306,14 @@ bool LLTextBase::truncate()
 
 const LLStyle::Params& LLTextBase::getDefaultStyleParams()
 {
+	//FIXME: convert mDefaultStyle to a flyweight http://www.boost.org/doc/libs/1_40_0/libs/flyweight/doc/index.html
+	//and eliminate color member values
 	if (mStyleDirty)
 	{
 		  mDefaultStyle
-				  .color(LLUIColor(&mFgColor))
+				  .color(LLUIColor(&mFgColor))						// pass linked color instead of copy of mFGColor
 				  .readonly_color(LLUIColor(&mReadOnlyFgColor))
+				  .selected_color(LLUIColor(&mTextSelectedColor))
 				  .font(mDefaultFont)
 				  .drop_shadow(mFontShadow);
 		  mStyleDirty = false;
@@ -404,7 +411,7 @@ void LLTextBase::drawSelectionBackground()
 		
 		// Draw the selection box (we're using a box instead of reversing the colors on the selected text).
 		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-		const LLColor4& color = mReadOnly ? mReadOnlyFgColor.get() : mFgColor.get();
+		const LLColor4& color = mSelectedBGColor;
 		F32 alpha = hasFocus() ? 0.7f : 0.3f;
 		alpha *= getDrawContext().mAlpha;
 		LLColor4 selection_color(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], alpha);
@@ -444,7 +451,6 @@ void LLTextBase::drawCursor()
 		}
 		else
 		{
-			//segmentp = mSegments.back();
 			return;
 		}
 
@@ -478,21 +484,8 @@ void LLTextBase::drawCursor()
 			{
 				LLColor4 text_color;
 				const LLFontGL* fontp;
-				if (segmentp)
-				{
-					text_color = segmentp->getColor();
-					fontp = segmentp->getStyle()->getFont();
-				}
-				else if (mReadOnly)
-				{
-					text_color = mReadOnlyFgColor.get();
-					fontp = mDefaultFont;
-				}
-				else
-				{
-					text_color = mFgColor.get();
-					fontp = mDefaultFont;
-				}
+				text_color = segmentp->getColor();
+				fontp = segmentp->getStyle()->getFont();
 				fontp->render(text, mCursorPos, cursor_rect, 
 					LLColor4(1.f - text_color.mV[VRED], 1.f - text_color.mV[VGREEN], 1.f - text_color.mV[VBLUE], alpha),
 					LLFontGL::LEFT, mVAlign,
@@ -2482,7 +2475,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
 
 		font->render(text, start, 
 			     rect,
-			     LLColor4( 1.f - color.mV[0], 1.f - color.mV[1], 1.f - color.mV[2], 1.f ),
+			     mStyle->getSelectedColor().get(),
 			     LLFontGL::LEFT, mEditor.mVAlign, 
 			     LLFontGL::NORMAL, 
 			     LLFontGL::NO_SHADOW, 
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index bd41272f11e..86f0e55a1d9 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -241,7 +241,9 @@ class LLTextBase
 								text_readonly_color,
 								bg_readonly_color,
 								bg_writeable_color,
-								bg_focus_color;
+								bg_focus_color,
+								text_selected_color,
+								bg_selected_color;
 
 		Optional<bool>			bg_visible,
 								border_visible,
@@ -507,6 +509,8 @@ class LLTextBase
 	LLUIColor					mWriteableBgColor;
 	LLUIColor					mReadOnlyBgColor;
 	LLUIColor					mFocusBgColor;
+	LLUIColor					mTextSelectedColor;
+	LLUIColor					mSelectedBGColor;
 
 	// cursor
 	S32							mCursorPos;			// I-beam is just after the mCursorPos-th character.
diff --git a/indra/newview/skins/default/xui/en/widgets/simple_text_editor.xml b/indra/newview/skins/default/xui/en/widgets/simple_text_editor.xml
index f575304c760..3878c7a144c 100644
--- a/indra/newview/skins/default/xui/en/widgets/simple_text_editor.xml
+++ b/indra/newview/skins/default/xui/en/widgets/simple_text_editor.xml
@@ -15,11 +15,13 @@
   default_color="TextDefaultColor"
   text_color="TextFgColor"
   text_readonly_color="TextFgReadOnlyColor"
+  text_selected_color="White" 
   h_pad="6" 
   v_pad="4"
   bg_visible="true"
   bg_readonly_color="TextBgReadOnlyColor"
   bg_writeable_color="TextBgWriteableColor"
+  bg_selected_color="EmphasisColor"
   bg_focus_color="TextBgFocusColor">
   <simple_text_editor.border
     bevel_style="in"
-- 
GitLab


From a919bda24dfc6fb7fc031546e69ed7f531d828e8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Sat, 17 Jul 2010 11:23:26 -0500
Subject: [PATCH 528/683] Fix for rigged attachments disappearing when toggling
 lighting and shadows.

---
 indra/newview/llvovolume.cpp | 111 ++++++++++++++++++-----------------
 1 file changed, 56 insertions(+), 55 deletions(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 36391a3602e..b69fd3f90b5 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3544,77 +3544,78 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 				{
 					facep->mVertexBuffer = NULL;
 					facep->mLastVertexBuffer = NULL;
-					facep->setState(LLFace::RIGGED);
-					
-					//get drawpool of avatar with rigged face
-					LLDrawPoolAvatar* pool = get_avatar_drawpool(vobj);
-					
-					if (pool)
+				}
+				
+			facep->setState(LLFace::RIGGED);
+				
+				//get drawpool of avatar with rigged face
+				LLDrawPoolAvatar* pool = get_avatar_drawpool(vobj);
+				
+				if (pool)
+				{
+					const LLTextureEntry* te = facep->getTextureEntry();
+
+					//remove face from old pool if it exists
+					LLDrawPool* old_pool = facep->getPool();
+					if (old_pool && old_pool->getType() == LLDrawPool::POOL_AVATAR)
 					{
-						const LLTextureEntry* te = facep->getTextureEntry();
+						((LLDrawPoolAvatar*) old_pool)->removeRiggedFace(facep);
+					}
+
+					//add face to new pool
+					LLViewerTexture* tex = facep->getTexture();
+					U32 type = gPipeline.getPoolTypeFromTE(te, tex);
 
-						//remove face from old pool if it exists
-						LLDrawPool* old_pool = facep->getPool();
-						if (old_pool && old_pool->getType() == LLDrawPool::POOL_AVATAR)
+					if (type == LLDrawPool::POOL_ALPHA)
+					{
+						if (te->getFullbright())
 						{
-							((LLDrawPoolAvatar*) old_pool)->removeRiggedFace(facep);
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA);
 						}
-
-						//add face to new pool
-						LLViewerTexture* tex = facep->getTexture();
-						U32 type = gPipeline.getPoolTypeFromTE(te, tex);
-
-						if (type == LLDrawPool::POOL_ALPHA)
+						else
 						{
-							if (te->getFullbright())
-							{
-								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA);
-							}
-							else
-							{
-								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_ALPHA);
-							}
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_ALPHA);
 						}
-						else if (te->getShiny())
+					}
+					else if (te->getShiny())
+					{
+						if (te->getFullbright())
 						{
-							if (te->getFullbright())
-							{
-								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_SHINY);
-							}
-							else
-							{
-								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SHINY);
-							}
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_SHINY);
 						}
 						else
 						{
-							if (te->getFullbright())
-							{
-								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT);
-							}
-							else
-							{
-								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SIMPLE);
-							}
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SHINY);
 						}
-
-						if (te->getGlow())
+					}
+					else
+					{
+						if (te->getFullbright())
 						{
-							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_GLOW);
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_FULLBRIGHT);
 						}
+						else
+						{
+							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SIMPLE);
+						}
+					}
 
-						if (LLPipeline::sRenderDeferred)
+					if (te->getGlow())
+					{
+						pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_GLOW);
+					}
+
+					if (LLPipeline::sRenderDeferred)
+					{
+						if (type != LLDrawPool::POOL_ALPHA && !te->getFullbright())
 						{
-							if (type != LLDrawPool::POOL_ALPHA && !te->getFullbright())
+							if (te->getBumpmap())
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP);
+							}
+							else
 							{
-								if (te->getBumpmap())
-								{
-									pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP);
-								}
-								else
-								{
-									pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_DEFERRED_SIMPLE);
-								}
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_DEFERRED_SIMPLE);
 							}
 						}
 					}
-- 
GitLab


From 1ec9346f6a87074713624ac27f25432532d18409 Mon Sep 17 00:00:00 2001
From: Vladimir Pchelko <pchelko@productengine.com>
Date: Mon, 19 Jul 2010 12:56:53 +0300
Subject: [PATCH 529/683] EXT-7899 FIXED setVisible() was overridden IN
 LLPanelEditWearable to hide(close) LLPanelEditWearable "child" controls by
 calling "showWearable(mWearablePtr, FALSE);"

The problem was in LLPanelEditWearable "child" controls does not handle parent's setVisible() (for example - floater's).

--HG--
branch : product-engine
---
 indra/newview/llpaneleditwearable.cpp | 9 +++++++++
 indra/newview/llpaneleditwearable.h   | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 14f05bdb173..60a49c01bae 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -806,6 +806,15 @@ void LLPanelEditWearable::draw()
 	LLPanel::draw();
 }
 
+void LLPanelEditWearable::setVisible(BOOL visible)
+{
+	if (!visible)
+	{
+		showWearable(mWearablePtr, FALSE);
+	}
+	LLPanel::setVisible(visible);
+}
+
 void LLPanelEditWearable::setWearable(LLWearable *wearable)
 {
 	showWearable(mWearablePtr, FALSE);
diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h
index bfce2ae56ed..85b88e6185a 100644
--- a/indra/newview/llpaneleditwearable.h
+++ b/indra/newview/llpaneleditwearable.h
@@ -76,6 +76,8 @@ class LLPanelEditWearable : public LLPanel
 	void				onSaveAsButtonClicked();
 	void				saveAsCallback(const LLSD& notification, const LLSD& response);
 
+	virtual void		setVisible(BOOL visible);
+
 
 private:
 	typedef std::map<F32, LLViewerVisualParam*> value_map_t;
-- 
GitLab


From cc90425fed9ade362c9d842db2c72ea021d0bd40 Mon Sep 17 00:00:00 2001
From: Aimee Linden <aimee@lindenlab.com>
Date: Mon, 19 Jul 2010 13:23:19 +0100
Subject: [PATCH 530/683] Bury the dead code day: Removed LLFloaterParcelInfo,
 LLFloaterURLDisplay and LLPanelPlace

Moved LLParcelHandler from now defunct llfloaterparcel.cpp to llpanelplaces.cpp
---
 indra/newview/CMakeLists.txt            |   6 -
 indra/newview/llfloaterparcel.cpp       | 128 -------
 indra/newview/llfloaterparcel.h         |  59 ----
 indra/newview/llfloaterurldisplay.cpp   | 109 ------
 indra/newview/llfloaterurldisplay.h     |  64 ----
 indra/newview/llpanelplace.cpp          | 424 ------------------------
 indra/newview/llpanelplace.h            | 120 -------
 indra/newview/llpanelplaces.cpp         |  37 +++
 indra/newview/llremoteparcelrequest.cpp |   1 -
 indra/newview/llstartup.cpp             |   1 -
 indra/newview/llurldispatcher.cpp       |  20 --
 indra/newview/llviewerfloaterreg.cpp    |   4 -
 12 files changed, 37 insertions(+), 936 deletions(-)
 delete mode 100644 indra/newview/llfloaterparcel.cpp
 delete mode 100644 indra/newview/llfloaterparcel.h
 delete mode 100644 indra/newview/llfloaterurldisplay.cpp
 delete mode 100644 indra/newview/llfloaterurldisplay.h
 delete mode 100644 indra/newview/llpanelplace.cpp
 delete mode 100644 indra/newview/llpanelplace.h

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 4e87dd9225c..64bcf12b065 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -190,7 +190,6 @@ set(viewer_SOURCE_FILES
     llfloaternamedesc.cpp
     llfloaternotificationsconsole.cpp
     llfloateropenobject.cpp
-    llfloaterparcel.cpp
     llfloaterpay.cpp
     llfloaterperms.cpp
     llfloaterpostcard.cpp
@@ -212,7 +211,6 @@ set(viewer_SOURCE_FILES
     llfloatertopobjects.cpp
     llfloatertos.cpp
     llfloateruipreview.cpp
-    llfloaterurldisplay.cpp
     llfloaterurlentry.cpp
     llfloatervoicedevicesettings.cpp
     llfloatervoiceeffect.cpp
@@ -349,7 +347,6 @@ set(viewer_SOURCE_FILES
     llpanelpermissions.cpp
     llpanelpick.cpp
     llpanelpicks.cpp
-    llpanelplace.cpp
     llpanelplaceinfo.cpp
     llpanelplaceprofile.cpp
     llpanelplaces.cpp
@@ -717,7 +714,6 @@ set(viewer_HEADER_FILES
     llfloaternamedesc.h
     llfloaternotificationsconsole.h
     llfloateropenobject.h
-    llfloaterparcel.h
     llfloaterpay.h
     llfloaterperms.h
     llfloaterpostcard.h
@@ -739,7 +735,6 @@ set(viewer_HEADER_FILES
     llfloatertopobjects.h
     llfloatertos.h
     llfloateruipreview.h
-    llfloaterurldisplay.h
     llfloaterurlentry.h
     llfloatervoicedevicesettings.h
     llfloatervoiceeffect.h
@@ -872,7 +867,6 @@ set(viewer_HEADER_FILES
     llpanelpermissions.h
     llpanelpick.h
     llpanelpicks.h
-    llpanelplace.h
     llpanelplaceinfo.h
     llpanelplaceprofile.h
     llpanelplaces.h
diff --git a/indra/newview/llfloaterparcel.cpp b/indra/newview/llfloaterparcel.cpp
deleted file mode 100644
index e2be7841163..00000000000
--- a/indra/newview/llfloaterparcel.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/** 
- * @file llfloaterparcel.cpp
- * @brief LLFloaterParcel class implementation
- * Parcel information as shown in a floating window from secondlife:// command
- * handler.  
- *
- * $LicenseInfo:firstyear=2007&license=viewergpl$
- * 
- * Copyright (c) 2007-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-#include "llviewerprecompiledheaders.h"
-
-#include "llfloaterparcel.h"
-
-#include "llfloaterreg.h"
-
-// viewer project includes
-#include "llcommandhandler.h"
-#include "llpanelplace.h"
-#include "llsidetray.h"
-
-// linden library includes
-#include "lluuid.h"
-#include "lluictrlfactory.h"
-
-//-----------------------------------------------------------------------------
-// Globals
-//-----------------------------------------------------------------------------
-
-class LLParcelHandler : public LLCommandHandler
-{
-public:
-	// requires trusted browser to trigger
-	LLParcelHandler() : LLCommandHandler("parcel", UNTRUSTED_THROTTLE) { }
-	bool handle(const LLSD& params, const LLSD& query_map,
-				LLMediaCtrl* web)
-	{
-		if (params.size() < 2)
-		{
-			return false;
-		}
-		LLUUID parcel_id;
-		if (!parcel_id.set(params[0], FALSE))
-		{
-			return false;
-		}
-		if (params[1].asString() == "about")
-		{
-			if (parcel_id.notNull())
-			{
-				LLSD key;
-				key["type"] = "remote_place";
-				key["id"] = parcel_id;
-				LLSideTray::getInstance()->showPanel("panel_places", key);
-				return true;
-			}
-		}
-		return false;
-	}
-};
-LLParcelHandler gParcelHandler;
-
-//-----------------------------------------------------------------------------
-// Member functions
-//-----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-
-void* LLFloaterParcelInfo::createPanelPlace(void* data)
-{
-	LLFloaterParcelInfo* self = (LLFloaterParcelInfo*)data;
-	self->mPanelParcelp = new LLPanelPlace(); // allow edit self
-	LLUICtrlFactory::getInstance()->buildPanel(self->mPanelParcelp, "panel_place.xml");
-	return self->mPanelParcelp;
-}
-
-//----------------------------------------------------------------------------
-
-
-LLFloaterParcelInfo::LLFloaterParcelInfo(const LLSD& parcel_id)
-:	LLFloater(parcel_id),
-	mParcelID( parcel_id.asUUID() ),
-	mPanelParcelp(NULL)
-{
-	mFactoryMap["place_details_panel"] = LLCallbackMap(LLFloaterParcelInfo::createPanelPlace, this);
-// 	LLUICtrlFactory::getInstance()->buildFloater(this, "floater_preview_url.xml");
-}
-
-// virtual
-LLFloaterParcelInfo::~LLFloaterParcelInfo()
-{
-
-}
-
-BOOL LLFloaterParcelInfo::postBuild()
-{
-	if (mPanelParcelp)
-	{
-		mPanelParcelp->setParcelID(mParcelID);
-	}
-	center();
-	return LLFloater::postBuild();
-}
-
-
diff --git a/indra/newview/llfloaterparcel.h b/indra/newview/llfloaterparcel.h
deleted file mode 100644
index 386acb3fd50..00000000000
--- a/indra/newview/llfloaterparcel.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/** 
- * @file llfloaterparcel.h
- * @brief Parcel information as shown in a floating window from a sl-url.
- * Just a wrapper for LLPanelPlace, shared with the Find directory.
- *
- * $LicenseInfo:firstyear=2007&license=viewergpl$
- * 
- * Copyright (c) 2007-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-#ifndef LL_FLOATERPARCELINFO_H
-#define LL_FLOATERPARCELINFO_H
-
-#include "llfloater.h"
-
-class LLPanelPlace;
-
-class LLFloaterParcelInfo
-:	public LLFloater
-{
-public:
-	static	void*	createPanelPlace(void*	data);
-
-	LLFloaterParcelInfo( const LLSD& parcel_id );
-	/*virtual*/ ~LLFloaterParcelInfo();
-	
-	/*virtual*/ BOOL postBuild();
-	
-	void displayParcelInfo(const LLUUID& parcel_id);
-
-private:
-	LLUUID			mParcelID;			// for which parcel is this window?
-	LLPanelPlace*	mPanelParcelp;
-};
-
-
-#endif
diff --git a/indra/newview/llfloaterurldisplay.cpp b/indra/newview/llfloaterurldisplay.cpp
deleted file mode 100644
index 4b67cbb3087..00000000000
--- a/indra/newview/llfloaterurldisplay.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/** 
- * @file llfloaterurldisplay.h
- * @brief Probably should be called LLFloaterTeleport, or LLFloaterLandmark
- * as it gives you a preview of a potential teleport location.
- *
- * $LicenseInfo:firstyear=2007&license=viewergpl$
- * 
- * Copyright (c) 2007-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llregionhandle.h"
-#include "v3dmath.h"
-
-#include "llfloaterurldisplay.h"
-
-#include "llpanelplace.h"
-#include "lluictrlfactory.h"
-
-////////////////////////////////////////////////////////////////////////////
-// LLFloaterURLDisplay
-
-
-LLFloaterURLDisplay::LLFloaterURLDisplay(const LLSD& sd)
-	: LLFloater(sd)
-{	
-	mFactoryMap["place_details_panel"] = LLCallbackMap(LLFloaterURLDisplay::createPlaceDetail, this);
-//	LLUICtrlFactory::getInstance()->buildFloater(this, "floater_preview_url.xml");
-
-	// If positioned at 0,0 the teleport button is behind the toolbar.
-	LLRect r = getRect();
-	if (r.mBottom == 0 && r.mLeft == 0)
-	{
-		// first use, center it
-		center();
-	}
-	else
-	{
-		gFloaterView->adjustToFitScreen(this, FALSE);
-	}
-}
-
-LLFloaterURLDisplay::~LLFloaterURLDisplay()
-{
-}
-
-void LLFloaterURLDisplay::displayParcelInfo(U64 region_handle, const LLVector3& pos_local)
-{
-	mRegionHandle = region_handle;
-	mRegionPosition = pos_local;
-	LLVector3d pos_global = from_region_handle(region_handle);
-	pos_global += (LLVector3d)pos_local;
-
-	LLUUID region_id;			// don't know this
-	LLUUID landmark_asset_id;	// don't know this either
-	mPlacePanel->displayParcelInfo(pos_local, landmark_asset_id, region_id, pos_global);
-
-	this->setVisible(true);
-	this->setFrontmost(true);
-}
-
-void LLFloaterURLDisplay::setSnapshotDisplay(const LLUUID& snapshot_id)
-{
-	mPlacePanel->setSnapshot(snapshot_id);
-}
-
-void LLFloaterURLDisplay::setName(const std::string& name)
-{	// Set the name and also clear description
-	mPlacePanel->resetName(name);
-}
-
-void LLFloaterURLDisplay::setLocationString(const std::string& name)
-{
-	mPlacePanel->setLocationString(name);
-}
-
-// static
-void* LLFloaterURLDisplay::createPlaceDetail(void* userdata)
-{
-	LLFloaterURLDisplay *self = (LLFloaterURLDisplay*)userdata;
-	self->mPlacePanel = new LLPanelPlace();
-	LLUICtrlFactory::getInstance()->buildPanel(self->mPlacePanel, "panel_place.xml");
-
-	return self->mPlacePanel;
-}
diff --git a/indra/newview/llfloaterurldisplay.h b/indra/newview/llfloaterurldisplay.h
deleted file mode 100644
index 22f5a95ad01..00000000000
--- a/indra/newview/llfloaterurldisplay.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/** 
- * @file llfloaterurldisplay.h
- * @brief LLFloaterURLDisplay class implementation
- *
- * $LicenseInfo:firstyear=2006&license=viewergpl$
- * 
- * Copyright (c) 2006-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLFLOATERURLDISPLAY_H
-#define LL_LLFLOATERURLDISPLAY_H
-
-#include "llfloater.h"
-#include "v3math.h"
-
-class LLPanelPlace;
-class LLSD;
-class LLUUID;
-
-class LLFloaterURLDisplay : public LLFloater
-{
-	friend class LLFloaterReg;
-public:
-
-	void displayParcelInfo(U64 region_handle, const LLVector3& pos);
-	void setSnapshotDisplay(const LLUUID& snapshot_id);
-	void setName(const std::string& name);
-	void setLocationString(const std::string& name);
-
-	static void* createPlaceDetail(void* userdata);
-
-private:
-	LLFloaterURLDisplay(const LLSD& sd);
-	virtual ~LLFloaterURLDisplay();
-
-	LLVector3		mRegionPosition;
-	U64				mRegionHandle;
-	LLPanelPlace*	mPlacePanel;
-};
-
-#endif // LL_LLFLOATERURLDISPLAY_H
diff --git a/indra/newview/llpanelplace.cpp b/indra/newview/llpanelplace.cpp
deleted file mode 100644
index 1446088c4fe..00000000000
--- a/indra/newview/llpanelplace.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/** 
- * @file llpanelplace.cpp
- * @brief Display of a place in the Find directory.
- *
- * $LicenseInfo:firstyear=2004&license=viewergpl$
- * 
- * Copyright (c) 2004-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llpanelplace.h"
-
-#include "llviewercontrol.h"
-#include "llqueryflags.h"
-#include "llui.h"
-#include "llsecondlifeurls.h"
-#include "llfloater.h"
-#include "llfloaterreg.h"
-#include "llregionhandle.h"
-
-#include "llagent.h"
-#include "llviewerwindow.h"
-#include "llbutton.h"
-#include "llfloaterworldmap.h"
-#include "lllineeditor.h"
-#include "llnotificationsutil.h"
-#include "lluiconstants.h"
-#include "lltextbox.h"
-#include "lltexteditor.h"
-#include "lltexturectrl.h"
-#include "lltrans.h"
-#include "llworldmap.h"
-#include "llviewerregion.h"
-#include "llvoavatarself.h"
-#include "lluictrlfactory.h"
-//#include "llviewermenu.h"	// create_landmark()
-#include "llweb.h"
-#include "llsdutil.h"
-#include "llsdutil_math.h"
-
-LLPanelPlace::LLPanelPlace()
-:	LLPanel(),
-	mParcelID(),
-	mRequestedID(),
-	mRegionID(),
-	mPosGlobal(),
-	mPosRegion(),
-	mAuctionID(0),
-	mLandmarkAssetID()
-{}
-
-LLPanelPlace::~LLPanelPlace()
-{
-	if (mParcelID.notNull())
-	{
-		LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mParcelID, this);
-	}
-}
-
-BOOL LLPanelPlace::postBuild()
-{
-	// Since this is only used in the directory browser, always
-	// disable the snapshot control. Otherwise clicking on it will
-	// open a texture picker.
-	mSnapshotCtrl = getChild<LLTextureCtrl>("snapshot_ctrl");
-	mSnapshotCtrl->setEnabled(FALSE);
-
-    mNameEditor = getChild<LLTextBox>("name_editor");
-	// Text boxes appear to have a " " in them by default.  This breaks the
-	// emptiness test for filling in data from the network.  Slam to empty.
-	mNameEditor->setText( LLStringUtil::null );
-
-    mDescEditor = getChild<LLTextEditor>("desc_editor");
-
-	mInfoEditor = getChild<LLTextBox>("info_editor");
-	mLandTypeEditor = getChild<LLTextBox>("land_type_display");
-
-    mLocationDisplay = getChild<LLTextBox>("location_editor");
-
-	mTeleportBtn = getChild<LLButton>( "teleport_btn");
-	mTeleportBtn->setClickedCallback(onClickTeleport, this);
-
-	mMapBtn = getChild<LLButton>( "map_btn");
-	mMapBtn->setClickedCallback(onClickMap, this);
-
-	//mLandmarkBtn = getChild<LLButton>( "landmark_btn");
-	//mLandmarkBtn->setClickedCallback(onClickLandmark, this);
-
-	mAuctionBtn = getChild<LLButton>( "auction_btn");
-	mAuctionBtn->setClickedCallback(onClickAuction, this);
-
-	// Default to no auction button.  We'll show it if we get an auction id
-	mAuctionBtn->setVisible(FALSE);
-
-	// Temporary text to explain why the description panel is blank.
-	// mDescEditor->setText("Parcel information not available without server update");
-
-	return TRUE;
-}
-
-void LLPanelPlace::displayItemInfo(const LLInventoryItem* pItem)
-{
-	if (pItem)
-	{
-		mNameEditor->setText(pItem->getName());
-		mDescEditor->setText(pItem->getDescription());
-	}
-}
-
-// Use this for search directory clicks, because we are totally
-// recycling the panel and don't need to use what's there.
-//
-// For SLURL clicks, don't call this, because we need to cache
-// the location info from the user.
-void LLPanelPlace::resetLocation()
-{
-	mParcelID.setNull();
-	mRequestedID.setNull();
-	mRegionID.setNull();
-	mLandmarkAssetID.setNull();
-	mPosGlobal.clearVec();
-	mPosRegion.clearVec();
-	mAuctionID = 0;
-	mNameEditor->setText( LLStringUtil::null );
-	mDescEditor->setText( LLStringUtil::null );
-	mInfoEditor->setText( LLStringUtil::null );
-	mLandTypeEditor->setText( LLStringUtil::null );
-	mLocationDisplay->setText( LLStringUtil::null );
-}
-
-
-// Set the name and clear other bits of info.  Used for SLURL clicks
-void LLPanelPlace::resetName(const std::string& name)
-{
-	setName(name);
-	if(mDescEditor)
-	{
-		mDescEditor->setText( LLStringUtil::null );
-	}
-	if(mNameEditor)
-	{
-		llinfos << "Clearing place name" << llendl;
-		mNameEditor->setText( LLStringUtil::null );
-	}
-	if(mInfoEditor)
-	{
-		mInfoEditor->setText( LLStringUtil::null );
-	}
-	if(mLandTypeEditor)
-	{
-		mLandTypeEditor->setText( LLStringUtil::null );
-	}
-}
-
-//virtual
-void LLPanelPlace::setParcelID(const LLUUID& parcel_id)
-{
-	mParcelID = parcel_id;
-	sendParcelInfoRequest();
-}
-
-void LLPanelPlace::setSnapshot(const LLUUID& snapshot_id)
-{
-	mSnapshotCtrl->setImageAssetID(snapshot_id);
-}
-
-void LLPanelPlace::setLocationString(const std::string& location)
-{
-	mLocationDisplay->setText(location);
-}
-
-void LLPanelPlace::setLandTypeString(const std::string& land_type)
-{
-	mLandTypeEditor->setText(land_type);
-}
-
-void LLPanelPlace::sendParcelInfoRequest()
-{
-	if (mParcelID != mRequestedID)
-	{
-		LLRemoteParcelInfoProcessor::getInstance()->addObserver(mParcelID, this);
-		LLRemoteParcelInfoProcessor::getInstance()->sendParcelInfoRequest(mParcelID);
-
-		mRequestedID = mParcelID;
-	}
-}
-
-//virtual
-void LLPanelPlace::setErrorStatus(U32 status, const std::string& reason)
-{
-	// We only really handle 404 and 499 errors
-	std::string error_text;
-	if(status == 404)
-	{
-		error_text = getString("server_error_text");
-	}
-	else if(status == 499)
-	{
-		error_text = getString("server_forbidden_text");
-	}
-	mDescEditor->setText(error_text);
-}
-
-//virtual
-void LLPanelPlace::processParcelInfo(const LLParcelData& parcel_data)
-{
-	mAuctionID = parcel_data.auction_id;
-
-	if(parcel_data.snapshot_id.notNull())
-	{
-		mSnapshotCtrl->setImageAssetID(parcel_data.snapshot_id);
-	}
-
-	if( !parcel_data.name.empty()
-	   && mNameEditor && mNameEditor->getText().empty())
-	{
-		mNameEditor->setText(parcel_data.name);
-	}
-
-	if( !parcel_data.desc.empty()
-		&& mDescEditor && mDescEditor->getText().empty())
-	{
-		mDescEditor->setText(parcel_data.desc);
-	}
-
-	std::string info_text;
-	LLUIString traffic = getString("traffic_text");
-	traffic.setArg("[TRAFFIC]", llformat("%d ", (int)parcel_data.dwell));
-	info_text = traffic;
-	LLUIString area = getString("area_text");
-	area.setArg("[AREA]", llformat("%d", parcel_data.actual_area));
-	info_text += area;
-	if (parcel_data.flags & DFQ_FOR_SALE)
-	{
-		LLUIString forsale = getString("forsale_text");
-		forsale.setArg("[PRICE]", llformat("%d", parcel_data.sale_price));
-		info_text += forsale;
-	}
-	if (parcel_data.auction_id != 0)
-	{
-		LLUIString auction = getString("auction_text");
-		auction.setArg("[ID]", llformat("%010d ", parcel_data.auction_id));
-		info_text += auction;
-	}
-	if (mInfoEditor)
-	{
-		mInfoEditor->setText(info_text);
-	}
-
-	// HACK: Flag 0x2 == adult region,
-	// Flag 0x1 == mature region, otherwise assume PG
-	std::string rating = LLViewerRegion::accessToString(SIM_ACCESS_PG);
-	if (parcel_data.flags & 0x2)
-	{
-		rating = LLViewerRegion::accessToString(SIM_ACCESS_ADULT);
-	}
-	else if (parcel_data.flags & 0x1)
-	{
-		rating = LLViewerRegion::accessToString(SIM_ACCESS_MATURE);
-	}
-
-	// Just use given region position for display
-	S32 region_x = llround(mPosRegion.mV[0]);
-	S32 region_y = llround(mPosRegion.mV[1]);
-	S32 region_z = llround(mPosRegion.mV[2]);
-
-	// If the region position is zero, grab position from the global
-	if(mPosRegion.isExactlyZero())
-	{
-		region_x = llround(parcel_data.global_x) % REGION_WIDTH_UNITS;
-		region_y = llround(parcel_data.global_y) % REGION_WIDTH_UNITS;
-		region_z = llround(parcel_data.global_z);
-	}
-
-	if(mPosGlobal.isExactlyZero())
-	{
-		mPosGlobal.setVec(parcel_data.global_x, parcel_data.global_y, parcel_data.global_z);
-	}
-
-	std::string location = llformat("%s %d, %d, %d (%s)",
-									parcel_data.sim_name.c_str(), region_x, region_y, region_z, rating.c_str());
-	if (mLocationDisplay)
-	{
-		mLocationDisplay->setText(location);
-	}
-
-	BOOL show_auction = (parcel_data.auction_id > 0);
-	mAuctionBtn->setVisible(show_auction);
-}
-
-
-void LLPanelPlace::displayParcelInfo(const LLVector3& pos_region,
-									 const LLUUID& landmark_asset_id,
-									 const LLUUID& region_id,
-									 const LLVector3d& pos_global)
-{
-	LLSD body;
-	mPosRegion = pos_region;
-	mPosGlobal = pos_global;
-	mLandmarkAssetID = landmark_asset_id;
-	std::string url = gAgent.getRegion()->getCapability("RemoteParcelRequest");
-	if (!url.empty())
-	{
-		body["location"] = ll_sd_from_vector3(pos_region);
-		if (!region_id.isNull())
-		{
-			body["region_id"] = region_id;
-		}
-		if (!pos_global.isExactlyZero())
-		{
-			U64 region_handle = to_region_handle(pos_global);
-			body["region_handle"] = ll_sd_from_U64(region_handle);
-		}
-		LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle()));
-	}
-	else
-	{
-		mDescEditor->setText(getString("server_update_text"));
-	}
-	mSnapshotCtrl->setImageAssetID(LLUUID::null);
-}
-
-// static
-void LLPanelPlace::onClickTeleport(void* data)
-{
-	LLPanelPlace* self = (LLPanelPlace*)data;
-
-	LLView* parent_viewp = self->getParent();
-	LLFloater* parent_floaterp = dynamic_cast<LLFloater*>(parent_viewp);
-	if (parent_floaterp)
-	{
-		parent_floaterp->closeFloater();
-	}
-	// LLFloater* parent_floaterp = (LLFloater*)self->getParent();
-	parent_viewp->setVisible(false);
-	LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance();
-	if(self->mLandmarkAssetID.notNull() && worldmap_instance)
-	{
-		gAgent.teleportViaLandmark(self->mLandmarkAssetID);
-		worldmap_instance->trackLandmark(self->mLandmarkAssetID);
-
-	}
-	else if (!self->mPosGlobal.isExactlyZero() && worldmap_instance)
-	{
-		gAgent.teleportViaLocation(self->mPosGlobal);
-		worldmap_instance->trackLocation(self->mPosGlobal);
-	}
-}
-
-// static
-void LLPanelPlace::onClickMap(void* data)
-{
-	LLPanelPlace* self = (LLPanelPlace*)data;
-	LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance();
-	
-	if (!self->mPosGlobal.isExactlyZero() && worldmap_instance)
-	{
-		worldmap_instance->trackLocation(self->mPosGlobal);
-		LLFloaterReg::showInstance("world_map", "center");
-	}
-}
-
-// static
-/*
-void LLPanelPlace::onClickLandmark(void* data)
-{
-	LLPanelPlace* self = (LLPanelPlace*)data;
-
-	create_landmark(self->mNameEditor->getText(), "", self->mPosGlobal);
-}
-*/
-
-
-// static
-void LLPanelPlace::onClickAuction(void* data)
-{
-	LLPanelPlace* self = (LLPanelPlace*)data;
-	LLSD args;
-	args["AUCTION_ID"] = self->mAuctionID;
-
-	LLNotificationsUtil::add("GoToAuctionPage", args);
-}
-/*
-// static
-bool LLPanelPlace::callbackAuctionWebPage(const LLSD& notification, const LLSD& response)
-{
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	if (0 == option)
-	{
-		std::string url;
-		url = LLNotifications::instance().getGlobalString("AUCTION_URL")  + llformat("%010d", response["auction_id"].asInteger());
-
-		llinfos << "Loading auction page " << url << llendl;
-
-		LLWeb::loadURL(url);
-	}
-	return false;
-}
-*/
-
diff --git a/indra/newview/llpanelplace.h b/indra/newview/llpanelplace.h
deleted file mode 100644
index f90a1b0567c..00000000000
--- a/indra/newview/llpanelplace.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/** 
- * @file llpanelplace.h
- * @brief Display of a place in the Find directory.
- *
- * $LicenseInfo:firstyear=2004&license=viewergpl$
- * 
- * Copyright (c) 2004-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLPANELPLACE_H
-#define LL_LLPANELPLACE_H
-
-#include "llpanel.h"
-
-#include "v3dmath.h"
-#include "lluuid.h"
-
-#include "llremoteparcelrequest.h"
-
-class LLButton;
-class LLTextBox;
-class LLLineEditor;
-class LLTextEditor;
-class LLTextureCtrl;
-class LLMessageSystem;
-class LLInventoryItem;
-
-class LLPanelPlace : public LLPanel, LLRemoteParcelInfoObserver
-{
-public:
-	LLPanelPlace();
-	/*virtual*/ ~LLPanelPlace();
-
-	/*virtual*/ BOOL postBuild();
-
-	void resetLocation();
-		// Ignore all old location information, useful if you are 
-		// recycling an existing dialog and need to clear it.
-
-	/*virtual*/ void setParcelID(const LLUUID& parcel_id);
-		// Sends a request for data about the given parcel, which will
-		// only update the location if there is none already available.
-
-	void displayItemInfo(const LLInventoryItem* pItem);
-	void setRegionID(const LLUUID& region_id) { mRegionID = region_id; }
-	void setSnapshot(const LLUUID& snapshot_id);
-	void setLocationString(const std::string& location);
-	void setLandTypeString(const std::string& land_type);
-	/*virtual*/ void setErrorStatus(U32 status, const std::string& reason);
-	void resetName(const std::string& name);
-
-	void sendParcelInfoRequest();
-	void displayParcelInfo(const LLVector3& pos_region,
-			const LLUUID& landmark_asset_id,
-			const LLUUID& region_id,
-			const LLVector3d& pos_global);
-	/*virtual*/ void processParcelInfo(const LLParcelData& parcel_data);
-
-	LLTextureCtrl *getSnapshotCtrl() const { return mSnapshotCtrl; }
-
-protected:
-	static void onClickTeleport(void* data);
-	static void onClickMap(void* data);
-	//static void onClickLandmark(void* data);
-	static void onClickAuction(void* data);
-
-	// Go to auction web page if user clicked OK
-	static bool callbackAuctionWebPage(const LLSD& notification, const LLSD& response);
-
-protected:
-	LLUUID			mParcelID;
-	LLUUID			mRequestedID;
-	LLUUID			mRegionID;
-	LLUUID			mLandmarkAssetID;
-	// Absolute position of the location for teleport, may not
-	// be available (hence zero)
-	LLVector3d		mPosGlobal;
-	// Region-local position for teleport, always available.
-	LLVector3		mPosRegion;
-	// Zero if this is not an auction
-	S32				mAuctionID;
-
-	LLTextureCtrl* mSnapshotCtrl;
-
-	LLTextBox* mNameEditor;
-	LLTextEditor* mDescEditor;
-	LLTextBox* mInfoEditor;
-	LLTextBox* mLandTypeEditor;
-	LLTextBox* mLocationDisplay; //not calling it "editor" because it isn't
-
-	LLButton*	mTeleportBtn;
-	LLButton*	mMapBtn;
-	//LLButton*	mLandmarkBtn;
-	LLButton*	mAuctionBtn;
-};
-
-#endif // LL_LLPANELPLACE_H
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index 705b196ef11..07adb18902a 100644
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -54,6 +54,7 @@
 #include "llagent.h"
 #include "llagentpicksinfo.h"
 #include "llavatarpropertiesprocessor.h"
+#include "llcommandhandler.h"
 #include "llfloaterworldmap.h"
 #include "llinventorybridge.h"
 #include "llinventoryobserver.h"
@@ -66,6 +67,7 @@
 #include "llpanelplaceprofile.h"
 #include "llpanelteleporthistory.h"
 #include "llremoteparcelrequest.h"
+#include "llsidetray.h"
 #include "llteleporthistorystorage.h"
 #include "lltoggleablemenu.h"
 #include "llviewerinventory.h"
@@ -75,6 +77,7 @@
 #include "llviewerregion.h"
 #include "llviewerwindow.h"
 
+// Constants
 static const S32 LANDMARK_FOLDERS_MENU_WIDTH = 250;
 static const F32 PLACE_INFO_UPDATE_INTERVAL = 3.0;
 static const std::string AGENT_INFO_TYPE			= "agent";
@@ -83,6 +86,40 @@ static const std::string LANDMARK_INFO_TYPE			= "landmark";
 static const std::string REMOTE_PLACE_INFO_TYPE		= "remote_place";
 static const std::string TELEPORT_HISTORY_INFO_TYPE	= "teleport_history";
 
+// Support for secondlife:///app/parcel/{UUID}/about SLapps
+class LLParcelHandler : public LLCommandHandler
+{
+public:
+	// requires trusted browser to trigger
+	LLParcelHandler() : LLCommandHandler("parcel", UNTRUSTED_THROTTLE) { }
+	bool handle(const LLSD& params, const LLSD& query_map,
+				LLMediaCtrl* web)
+	{
+		if (params.size() < 2)
+		{
+			return false;
+		}
+		LLUUID parcel_id;
+		if (!parcel_id.set(params[0], FALSE))
+		{
+			return false;
+		}
+		if (params[1].asString() == "about")
+		{
+			if (parcel_id.notNull())
+			{
+				LLSD key;
+				key["type"] = "remote_place";
+				key["id"] = parcel_id;
+				LLSideTray::getInstance()->showPanel("panel_places", key);
+				return true;
+			}
+		}
+		return false;
+	}
+};
+LLParcelHandler gParcelHandler;
+
 // Helper functions
 static bool is_agent_in_selected_parcel(LLParcel* parcel);
 static void onSLURLBuilt(std::string& slurl);
diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp
index 95e3dd6d787..c28c041d0c1 100644
--- a/indra/newview/llremoteparcelrequest.cpp
+++ b/indra/newview/llremoteparcelrequest.cpp
@@ -36,7 +36,6 @@
 
 #include "message.h"
 
-#include "llpanelplace.h"
 #include "llpanel.h"
 #include "llhttpclient.h"
 #include "llsdserialize.h"
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index e9efc49e277..1ee73034f64 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -128,7 +128,6 @@
 #include "llfloaterevent.h"
 #include "llpanelclassified.h"
 #include "llpanelpick.h"
-#include "llpanelplace.h"
 #include "llpanelgrouplandmoney.h"
 #include "llpanelgroupnotices.h"
 #include "llpreview.h"
diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp
index cbaa7248a28..ad7969681bc 100644
--- a/indra/newview/llurldispatcher.cpp
+++ b/indra/newview/llurldispatcher.cpp
@@ -37,7 +37,6 @@
 #include "llcommandhandler.h"
 #include "llfloaterhelpbrowser.h"
 #include "llfloaterreg.h"
-#include "llfloaterurldisplay.h"
 #include "llfloaterworldmap.h"
 #include "llpanellogin.h"
 #include "llregionhandle.h"
@@ -182,10 +181,6 @@ bool LLURLDispatcherImpl::dispatchRegion(const LLSLURL& slurl, bool right_mouse)
 		return true;
 	}
 
-	// LLFloaterURLDisplay functionality moved to LLPanelPlaces in Side Tray.
-	//LLFloaterURLDisplay* slurl_displayp = LLFloaterReg::getTypedInstance<LLFloaterURLDisplay>("preview_url",LLSD());
-	//if(slurl_displayp) slurl_displayp->setName(region_name);
-
 	// Request a region handle by name
 	LLWorldMapMessage::getInstance()->sendNamedRegionRequest(slurl.getRegion(),
 									  LLURLDispatcherImpl::regionNameCallback,
@@ -251,21 +246,6 @@ void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const LLSLURL&
 		key["z"] = global_pos.mdV[VZ];
 
 		LLSideTray::getInstance()->showPanel("panel_places", key);
-
-		// LLFloaterURLDisplay functionality moved to LLPanelPlaces in Side Tray.
-
-//		// display informational floater, allow user to click teleport btn
-//		LLFloaterURLDisplay* slurl_displayp = LLFloaterReg::getTypedInstance<LLFloaterURLDisplay>("preview_url",LLSD());
-//		if(slurl_displayp)
-//		{
-//			url_displayp->displayParcelInfo(region_handle, local_pos);
-//			if(snapshot_id.notNull())
-//			{
-//				url_displayp->setSnapshotDisplay(snapshot_id);
-//			}
-//			std::string locationString = llformat("%s %d, %d, %d", region_name.c_str(), x, y, z);
-//			url_displayp->setLocationString(locationString);
-//		}
 	}
 }
 
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index efe59744bca..0e3ffe14115 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -81,7 +81,6 @@
 #include "llfloaternotificationsconsole.h"
 #include "llfloateropenobject.h"
 #include "llfloaterpay.h"
-#include "llfloaterparcel.h"
 #include "llfloaterperms.h"
 #include "llfloaterpostcard.h"
 #include "llfloaterpostprocess.h"
@@ -101,7 +100,6 @@
 #include "llfloatertos.h"
 #include "llfloatertopobjects.h"
 #include "llfloateruipreview.h"
-#include "llfloaterurldisplay.h"
 #include "llfloatervoicedevicesettings.h"
 #include "llfloatervoiceeffect.h"
 #include "llfloaterwater.h"
@@ -202,14 +200,12 @@ void LLViewerFloaterReg::registerFloaters()
 
 	LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOpenObject>);
 	LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLOutgoingCallDialog>);
-	LLFloaterReg::add("parcel_info", "floater_preview_url.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterParcelInfo>);
 	LLFloaterPayUtil::registerFloater();
 
 	LLFloaterReg::add("postcard", "floater_postcard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostcard>);
 	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
 	LLFloaterReg::add("prefs_hardware_settings", "floater_hardware_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHardwareSettings>);
 	LLFloaterReg::add("perm_prefs", "floater_perm_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPerms>);
-	LLFloaterReg::add("preview_url", "floater_preview_url.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterURLDisplay>);
 	LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterJoystick>);
 	LLFloaterReg::add("pref_voicedevicesettings", "floater_device_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceDeviceSettings>);
 	LLFloaterReg::add("preview_anim", "floater_preview_animation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewAnim>, "preview");
-- 
GitLab


From 5fbde8f0f95061682cc74f5a1d35af5dfcf15726 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Mon, 19 Jul 2010 16:49:06 +0300
Subject: [PATCH 531/683] No Ticket Removed unused members in LLSysWellItem
 left by mistake in code when widget was removed from xml in 0b6a4c546d75.

This prevents a warning: 'WARNING: LLView::getChild: Making dummy class LLIconCtrl named "icon" in sys_well_item'.

Reviewed by Vadim Savchuk.

--HG--
branch : product-engine
---
 indra/newview/llsyswellitem.cpp | 4 +---
 indra/newview/llsyswellitem.h   | 1 -
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/indra/newview/llsyswellitem.cpp b/indra/newview/llsyswellitem.cpp
index 0cfcfdc6345..1f3d6a582d6 100644
--- a/indra/newview/llsyswellitem.cpp
+++ b/indra/newview/llsyswellitem.cpp
@@ -42,14 +42,12 @@
 //---------------------------------------------------------------------------------
 LLSysWellItem::LLSysWellItem(const Params& p) : LLPanel(p),
 												mTitle(NULL),
-												mCloseBtn(NULL),
-												mIcon(NULL)
+												mCloseBtn(NULL)
 {
 	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_sys_well_item.xml");
 
 	mTitle = getChild<LLTextBox>("title");
 	mCloseBtn = getChild<LLButton>("close_btn");
-	mIcon = getChild<LLIconCtrl>("icon");
 
 	mTitle->setValue(p.title);
 	mCloseBtn->setClickedCallback(boost::bind(&LLSysWellItem::onClickCloseBtn,this));
diff --git a/indra/newview/llsyswellitem.h b/indra/newview/llsyswellitem.h
index b9b00e972af..3680e502185 100644
--- a/indra/newview/llsyswellitem.h
+++ b/indra/newview/llsyswellitem.h
@@ -79,7 +79,6 @@ class LLSysWellItem : public LLPanel
 
 	LLTextBox*	mTitle;
 	LLButton*	mCloseBtn;
-	LLIconCtrl*	mIcon;
 	LLUUID		mID;
 };
 
-- 
GitLab


From 5c9fc08604bf7abb807f09fa5519ea420ef146c5 Mon Sep 17 00:00:00 2001
From: Aimee Linden <aimee@lindenlab.com>
Date: Mon, 19 Jul 2010 14:55:58 +0100
Subject: [PATCH 532/683] Bury the dead code day: Cleanup redundant XUI files

---
 indra/llinventory/llparcel.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp
index b08cb28218f..d741cc855bc 100644
--- a/indra/llinventory/llparcel.cpp
+++ b/indra/llinventory/llparcel.cpp
@@ -58,7 +58,6 @@ static const std::string PARCEL_OWNERSHIP_STATUS_STRING[LLParcel::OS_COUNT+1] =
 };
 
 // NOTE: Adding parcel categories also requires updating:
-// * floater_directory.xml category combobox
 // * floater_about_land.xml category combobox
 // * Web site "create event" tools
 // DO NOT DELETE ITEMS FROM THIS LIST WITHOUT DEEPLY UNDERSTANDING WHAT YOU'RE DOING.
-- 
GitLab


From 7fc07e1084b37db4477f6392ed11b9bda509b153 Mon Sep 17 00:00:00 2001
From: Aimee Linden <aimee@lindenlab.com>
Date: Tue, 20 Jul 2010 01:42:26 +0100
Subject: [PATCH 533/683] Bury the dead code day: Removed LLPanelClassified and
 LLFloaterPriceForListing

Made redundant by EXT-2095
---
 indra/newview/llpanelclassified.cpp           | 1057 +----------------
 indra/newview/llpanelclassified.h             |  166 +--
 .../skins/default/xui/en/panel_classified.xml |  138 ---
 3 files changed, 8 insertions(+), 1353 deletions(-)
 delete mode 100644 indra/newview/skins/default/xui/en/panel_classified.xml

diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 7f027d299b4..af6214385b4 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -38,53 +38,34 @@
 
 #include "llpanelclassified.h"
 
-#include "lldir.h"
 #include "lldispatcher.h"
 #include "llfloaterreg.h"
 #include "llhttpclient.h"
 #include "llnotifications.h"
 #include "llnotificationsutil.h"
 #include "llparcel.h"
-#include "lltabcontainer.h"
-#include "message.h"
 
 #include "llagent.h"
-#include "llavataractions.h"
-#include "llbutton.h"
-#include "llcheckboxctrl.h"
 #include "llclassifiedflags.h"
 #include "llclassifiedstatsresponder.h"
 #include "llcommandhandler.h" // for classified HTML detail page click tracking
-#include "llviewercontrol.h"
+#include "lliconctrl.h"
 #include "lllineeditor.h"
-#include "lltextbox.h"
 #include "llcombobox.h"
 #include "lltexturectrl.h"
 #include "lltexteditor.h"
-#include "lluiconstants.h"
-#include "llurldispatcher.h"	// for classified HTML detail click teleports
-#include "lluictrlfactory.h"
 #include "llviewerparcelmgr.h"
-#include "llviewerwindow.h"
-#include "llworldmap.h"
 #include "llfloaterworldmap.h"
 #include "llviewergenericmessage.h"	// send_generic_message
 #include "llviewerregion.h"
-#include "llviewerwindow.h"	// for window width, height
-#include "llappviewer.h"	// abortQuit()
 #include "lltrans.h"
 #include "llscrollcontainer.h"
 #include "llstatusbar.h"
 
 const S32 MINIMUM_PRICE_FOR_LISTING = 50;	// L$
-const S32 MATURE_UNDEFINED = -1;
-const S32 MATURE_CONTENT = 1;
-const S32 PG_CONTENT = 2;
-const S32 DECLINE_TO_STATE = 0;
 
 //static
-std::list<LLPanelClassified*> LLPanelClassified::sAllPanels;
-std::list<LLPanelClassifiedInfo*> LLPanelClassifiedInfo::sAllPanels;
+LLPanelClassifiedInfo::panel_list_t LLPanelClassifiedInfo::sAllPanels;
 
 // "classifiedclickthrough"
 // strings[0] = classified_id
@@ -131,1040 +112,6 @@ class LLClassifiedClickMessageResponder : public LLHTTPClient::Responder
 	}
 };
 
-
-/* Re-expose this if we need to have classified ad HTML detail
-   pages.  JC
-
-// We need to count classified teleport clicks from the search HTML detail pages,
-// so we need have a teleport that also sends a click count message.
-class LLClassifiedTeleportHandler : public LLCommandHandler
-{
-public:
-	// don't allow from external browsers because it moves you immediately
-	LLClassifiedTeleportHandler() : LLCommandHandler("classifiedteleport", UNTRUSTED_BLOCK) { }
-
-	bool handle(const LLSD& tokens, const LLSD& queryMap)
-	{
-		// Need at least classified id and region name, so 2 params
-		if (tokens.size() < 2) return false;
-		LLUUID classified_id = tokens[0].asUUID();
-		if (classified_id.isNull()) return false;
-		// *HACK: construct a SLURL to do the teleport
-		std::string url("secondlife:///app/teleport/");
-		// skip the uuid we took off above, rebuild URL
-		// separated by slashes.
-		for (S32 i = 1; i < tokens.size(); ++i)
-		{
-			url += tokens[i].asString();
-			url += "/";
-		}
-		llinfos << "classified teleport to " << url << llendl;
-		// *TODO: separately track old search, sidebar, and new search
-		// Right now detail HTML pages count as new search.
-		const bool from_search = true;
-		LLPanelClassified::sendClassifiedClickMessage(classified_id, "teleport", from_search);
-		// Invoke teleport
-		LLMediaCtrl* web = NULL;
-		const bool trusted_browser = true;
-		return LLURLDispatcher::dispatch(url, web, trusted_browser);
-	}
-};
-// Creating the object registers with the dispatcher.
-LLClassifiedTeleportHandler gClassifiedTeleportHandler;
-*/
-
-LLPanelClassified::LLPanelClassified(bool in_finder, bool from_search)
-:	LLPanel(),
-	mInFinder(in_finder),
-	mFromSearch(from_search),
-	mDirty(false),
-	mForceClose(false),
-	mLocationChanged(false),
-	mClassifiedID(),
-	mCreatorID(),
-	mPriceForListing(0),
-	mDataRequested(FALSE),
-	mPaidFor(FALSE),
-	mPosGlobal(),
-	mSnapshotCtrl(NULL),
-	mNameEditor(NULL),
-	mDescEditor(NULL),
-	mLocationEditor(NULL),
-	mCategoryCombo(NULL),
-	mMatureCombo(NULL),
-	mAutoRenewCheck(NULL),
-	mUpdateBtn(NULL),
-	mTeleportBtn(NULL),
-	mMapBtn(NULL),
-	mProfileBtn(NULL),
-	mInfoText(NULL),
-	mSetBtn(NULL),
-	mClickThroughText(NULL),
-	mTeleportClicksOld(0),
-	mMapClicksOld(0),
-	mProfileClicksOld(0),
-	mTeleportClicksNew(0),
-	mMapClicksNew(0),
-	mProfileClicksNew(0)
-
-{
-    sAllPanels.push_back(this);
-
-	std::string classified_def_file;
-	if (mInFinder)
-	{
-		LLUICtrlFactory::getInstance()->buildPanel(this, "panel_classified.xml");
-	}
-	else
-	{
-		LLUICtrlFactory::getInstance()->buildPanel(this, "panel_avatar_classified.xml");
-	}
-
-	// Register dispatcher
-	gGenericDispatcher.addHandler("classifiedclickthrough", 
-								  &sClassifiedClickThrough);
-}
-
-
-LLPanelClassified::~LLPanelClassified()
-{
-    sAllPanels.remove(this);
-}
-
-
-void LLPanelClassified::reset()
-{
-	mClassifiedID.setNull();
-	mCreatorID.setNull();
-	mParcelID.setNull();
-
-	// Don't request data, this isn't valid
-	mDataRequested = TRUE;
-
-	mDirty = false;
-	mPaidFor = FALSE;
-
-	mPosGlobal.clearVec();
-
-	clearCtrls();
-	resetDirty();
-}
-
-
-BOOL LLPanelClassified::postBuild()
-{
-    mSnapshotCtrl = getChild<LLTextureCtrl>("snapshot_ctrl");
-	mSnapshotCtrl->setCommitCallback(onCommitAny, this);
-	mSnapshotSize = mSnapshotCtrl->getRect();
-
-    mNameEditor = getChild<LLLineEditor>("given_name_editor");
-	mNameEditor->setMaxTextLength(DB_PARCEL_NAME_LEN);
-	mNameEditor->setCommitOnFocusLost(TRUE);
-	mNameEditor->setFocusReceivedCallback(boost::bind(focusReceived, _1, this));
-	mNameEditor->setCommitCallback(onCommitAny, this);
-	mNameEditor->setPrevalidate( LLTextValidate::validateASCII );
-
-    mDescEditor = getChild<LLTextEditor>("desc_editor");
-	mDescEditor->setCommitOnFocusLost(TRUE);
-	mDescEditor->setFocusReceivedCallback(boost::bind(focusReceived, _1, this));
-	mDescEditor->setCommitCallback(onCommitAny, this);
-	
-    mLocationEditor = getChild<LLLineEditor>("location_editor");
-
-    mSetBtn = getChild<LLButton>( "set_location_btn");
-    mSetBtn->setClickedCallback(onClickSet, this);
-
-    mTeleportBtn = getChild<LLButton>( "classified_teleport_btn");
-    mTeleportBtn->setClickedCallback(onClickTeleport, this);
-
-    mMapBtn = getChild<LLButton>( "classified_map_btn");
-    mMapBtn->setClickedCallback(onClickMap, this);
-
-	if(mInFinder)
-	{
-		mProfileBtn  = getChild<LLButton>( "classified_profile_btn");
-		mProfileBtn->setClickedCallback(onClickProfile, this);
-	}
-
-	mCategoryCombo = getChild<LLComboBox>( "classified_category_combo");
-	LLClassifiedInfo::cat_map::iterator iter;
-	for (iter = LLClassifiedInfo::sCategories.begin();
-		iter != LLClassifiedInfo::sCategories.end();
-		iter++)
-	{
-		mCategoryCombo->add(LLTrans::getString(iter->second), (void *)((intptr_t)iter->first), ADD_BOTTOM);
-	}
-	mCategoryCombo->setCurrentByIndex(0);
-	mCategoryCombo->setCommitCallback(onCommitAny, this);
-
-	mMatureCombo = getChild<LLComboBox>( "classified_mature_check");
-	mMatureCombo->setCurrentByIndex(0);
-	mMatureCombo->setCommitCallback(onCommitAny, this);
-	if (gAgent.wantsPGOnly())
-	{
-		// Teens don't get to set mature flag. JC
-		mMatureCombo->setVisible(FALSE);
-		mMatureCombo->setCurrentByIndex(PG_CONTENT);
-	}
-
-	if (!mInFinder)
-	{
-		mAutoRenewCheck = getChild<LLCheckBoxCtrl>( "auto_renew_check");
-		mAutoRenewCheck->setCommitCallback(onCommitAny, this);
-	}
-
-	mUpdateBtn = getChild<LLButton>("classified_update_btn");
-    mUpdateBtn->setClickedCallback(onClickUpdate, this);
-
-	if (!mInFinder)
-	{
-		mClickThroughText = getChild<LLTextBox>("click_through_text");
-	}
-	
-	resetDirty();
-    return TRUE;
-}
-
-BOOL LLPanelClassified::titleIsValid()
-{
-	// Disallow leading spaces, punctuation, etc. that screw up
-	// sort order.
-	const std::string& name = mNameEditor->getText();
-	if (name.empty())
-	{
-		LLNotificationsUtil::add("BlankClassifiedName");
-		return FALSE;
-	}
-	if (!isalnum(name[0]))
-	{
-		LLNotificationsUtil::add("ClassifiedMustBeAlphanumeric");
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-void LLPanelClassified::apply()
-{
-	// Apply is used for automatically saving results, so only
-	// do that if there is a difference, and this is a save not create.
-	if (checkDirty() && mPaidFor)
-	{
-		sendClassifiedInfoUpdate();
-	}
-}
-
-bool LLPanelClassified::saveCallback(const LLSD& notification, const LLSD& response)
-{
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-
-	switch(option)
-	{
-		case 0: // Save
-			sendClassifiedInfoUpdate();
-			// fall through to close
-
-		case 1: // Don't Save
-			{
-				mForceClose = true;
-				// Close containing floater
-				LLFloater* parent_floater = gFloaterView->getParentFloater(this);
-				if (parent_floater)
-				{
-					parent_floater->closeFloater();
-				}
-			}
-			break;
-
-		case 2: // Cancel
-		default:
-            LLAppViewer::instance()->abortQuit();
-			break;
-	}
-	return false;
-}
-
-
-BOOL LLPanelClassified::canClose()
-{
-	if (mForceClose || !checkDirty()) 
-		return TRUE;
-
-	LLSD args;
-	args["NAME"] = mNameEditor->getText();
-	LLNotificationsUtil::add("ClassifiedSave", args, LLSD(), boost::bind(&LLPanelClassified::saveCallback, this, _1, _2));
-	return FALSE;
-}
-
-// Fill in some reasonable defaults for a new classified.
-void LLPanelClassified::initNewClassified()
-{
-	// TODO:  Don't generate this on the client.
-	mClassifiedID.generate();
-
-	mCreatorID = gAgent.getID();
-
-	mPosGlobal = gAgent.getPositionGlobal();
-
-	mPaidFor = FALSE;
-
-	// Try to fill in the current parcel
-	LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
-	if (parcel)
-	{
-		mNameEditor->setText(parcel->getName());
-		//mDescEditor->setText(parcel->getDesc());
-		mSnapshotCtrl->setImageAssetID(parcel->getSnapshotID());
-		//mPriceEditor->setText("0");
-		mCategoryCombo->setCurrentByIndex(0);
-	}
-
-	mUpdateBtn->setLabel(getString("publish_txt"));
-	
-	// simulate clicking the "location" button
-	LLPanelClassified::onClickSet(this);
-}
-
-
-void LLPanelClassified::setClassifiedID(const LLUUID& id)
-{
-	mClassifiedID = id;
-}
-
-//static
-void LLPanelClassified::setClickThrough(const LLUUID& classified_id,
-										S32 teleport,
-										S32 map,
-										S32 profile,
-										bool from_new_table)
-{
-	for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
-	{
-		LLPanelClassified* self = *iter;
-		// For top picks, must match pick id
-		if (self->mClassifiedID != classified_id)
-		{
-			continue;
-		}
-
-		// We need to check to see if the data came from the new stat_table 
-		// or the old classified table. We also need to cache the data from 
-		// the two separate sources so as to display the aggregate totals.
-
-		if (from_new_table)
-		{
-			self->mTeleportClicksNew = teleport;
-			self->mMapClicksNew = map;
-			self->mProfileClicksNew = profile;
-		}
-		else
-		{
-			self->mTeleportClicksOld = teleport;
-			self->mMapClicksOld = map;
-			self->mProfileClicksOld = profile;
-		}
-
-		if (self->mClickThroughText)
-		{
-			LLStringUtil::format_map_t args;
-			args["[TELEPORT]"] = llformat ("%d", self->mTeleportClicksNew + self->mTeleportClicksOld);
-			args["[MAP]"] = llformat ("%d", self->mMapClicksNew + self->mMapClicksOld);
-			args["[PROFILE]"] = llformat ("%d", self->mProfileClicksNew + self->mProfileClicksOld);
-			std::string msg = LLTrans::getString ("ClassifiedClicksTxt", args);
-			self->mClickThroughText->setText(msg);
-		}
-	}
-}
-
-// Schedules the panel to request data
-// from the server next time it is drawn.
-void LLPanelClassified::markForServerRequest()
-{
-	mDataRequested = FALSE;
-}
-
-
-std::string LLPanelClassified::getClassifiedName()
-{
-	return mNameEditor->getText();
-}
-
-
-void LLPanelClassified::sendClassifiedInfoRequest()
-{
-    LLMessageSystem *msg = gMessageSystem;
-
-	if (mClassifiedID != mRequestedID)
-	{
-		msg->newMessageFast(_PREHASH_ClassifiedInfoRequest);
-		msg->nextBlockFast(_PREHASH_AgentData);
-		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
-		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
-		msg->nextBlockFast(_PREHASH_Data);
-		msg->addUUIDFast(_PREHASH_ClassifiedID, mClassifiedID);
-		gAgent.sendReliableMessage();
-
-		mDataRequested = TRUE;
-		mRequestedID = mClassifiedID;
-
-		// While we're at it let's get the stats from the new table if that
-		// capability exists.
-		std::string url = gAgent.getRegion()->getCapability("SearchStatRequest");
-		LLSD body;
-		body["classified_id"] = mClassifiedID;
-
-		if (!url.empty())
-		{
-			llinfos << "Classified stat request via capability" << llendl;
-			LLHTTPClient::post(url, body, new LLClassifiedStatsResponder(mClassifiedID));
-		}
-	}
-}
-
-
-void LLPanelClassified::sendClassifiedInfoUpdate()
-{
-	// If we don't have a classified id yet, we'll need to generate one,
-	// otherwise we'll keep overwriting classified_id 00000 in the database.
-	if (mClassifiedID.isNull())
-	{
-		// TODO:  Don't do this on the client.
-		mClassifiedID.generate();
-	}
-
-	LLMessageSystem* msg = gMessageSystem;
-
-	msg->newMessageFast(_PREHASH_ClassifiedInfoUpdate);
-	msg->nextBlockFast(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	msg->nextBlockFast(_PREHASH_Data);
-	msg->addUUIDFast(_PREHASH_ClassifiedID, mClassifiedID);
-	// TODO: fix this
-	U32 category = mCategoryCombo->getCurrentIndex() + 1;
-	msg->addU32Fast(_PREHASH_Category, category);
-	msg->addStringFast(_PREHASH_Name, mNameEditor->getText());
-	msg->addStringFast(_PREHASH_Desc, mDescEditor->getText());
-
-	// fills in on simulator if null
-	msg->addUUIDFast(_PREHASH_ParcelID, mParcelID);
-	// fills in on simulator if null
-	msg->addU32Fast(_PREHASH_ParentEstate, 0);
-	msg->addUUIDFast(_PREHASH_SnapshotID, mSnapshotCtrl->getImageAssetID());
-	msg->addVector3dFast(_PREHASH_PosGlobal, mPosGlobal);
-	BOOL mature = mMatureCombo->getCurrentIndex() == MATURE_CONTENT;
-	BOOL auto_renew = FALSE;
-	if (mAutoRenewCheck) 
-	{
-		auto_renew = mAutoRenewCheck->get();
-	}
-    // These flags doesn't matter here.
-    const bool adult_enabled = false;
-	const bool is_pg = false;
-	U8 flags = pack_classified_flags_request(auto_renew, is_pg, mature, adult_enabled);
-	msg->addU8Fast(_PREHASH_ClassifiedFlags, flags);
-	msg->addS32("PriceForListing", mPriceForListing);
-	gAgent.sendReliableMessage();
-
-	mDirty = false;
-}
-
-
-//static
-void LLPanelClassified::processClassifiedInfoReply(LLMessageSystem *msg, void **)
-{
-	lldebugs << "processClassifiedInfoReply()" << llendl;
-    // Extract the agent id and verify the message is for this
-    // client.
-    LLUUID agent_id;
-    msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
-    if (agent_id != gAgent.getID())
-    {
-        llwarns << "Agent ID mismatch in processClassifiedInfoReply"
-            << llendl;
-		return;
-    }
-
-    LLUUID classified_id;
-    msg->getUUIDFast(_PREHASH_Data, _PREHASH_ClassifiedID, classified_id);
-
-    LLUUID creator_id;
-    msg->getUUIDFast(_PREHASH_Data, _PREHASH_CreatorID, creator_id);
-
-    LLUUID parcel_id;
-    msg->getUUIDFast(_PREHASH_Data, _PREHASH_ParcelID, parcel_id);
-
-	std::string name;
-	msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name);
-
-	std::string desc;
-	msg->getStringFast(_PREHASH_Data, _PREHASH_Desc, desc);
-
-	LLUUID snapshot_id;
-	msg->getUUIDFast(_PREHASH_Data, _PREHASH_SnapshotID, snapshot_id);
-
-    // "Location text" is actually the original
-    // name that owner gave the parcel, and the location.
-	std::string location_text;
-
-    msg->getStringFast(_PREHASH_Data, _PREHASH_ParcelName, location_text);
-	if (!location_text.empty())
-	{
-		location_text.append(", ");
-	}
-
-	std::string sim_name;
-	msg->getStringFast(_PREHASH_Data, _PREHASH_SimName, sim_name);
-
-	LLVector3d pos_global;
-	msg->getVector3dFast(_PREHASH_Data, _PREHASH_PosGlobal, pos_global);
-
-    S32 region_x = llround((F32)pos_global.mdV[VX]) % REGION_WIDTH_UNITS;
-    S32 region_y = llround((F32)pos_global.mdV[VY]) % REGION_WIDTH_UNITS;
-	S32 region_z = llround((F32)pos_global.mdV[VZ]);
-
-	std::string buffer = llformat("%s (%d, %d, %d)", sim_name.c_str(), region_x, region_y, region_z);
-    location_text.append(buffer);
-
-	U8 flags;
-	msg->getU8Fast(_PREHASH_Data, _PREHASH_ClassifiedFlags, flags);
-	//BOOL enabled = is_cf_enabled(flags);
-	bool mature = is_cf_mature(flags);
-	bool auto_renew = is_cf_auto_renew(flags);
-
-	U32 date = 0;
-	msg->getU32Fast(_PREHASH_Data, _PREHASH_CreationDate, date);
-	time_t tim = date;
-
-	// future use
-	U32 expiration_date = 0;
-	msg->getU32("Data", "ExpirationDate", expiration_date);
-
-	U32 category = 0;
-	msg->getU32Fast(_PREHASH_Data, _PREHASH_Category, category);
-
-	S32 price_for_listing = 0;
-	msg->getS32("Data", "PriceForListing", price_for_listing);
-
-    // Look up the panel to fill in
-	for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
-	{
-		LLPanelClassified* self = *iter;
-		// For top picks, must match pick id
-		if (self->mClassifiedID != classified_id)
-		{
-			continue;
-		}
-
-        // Found the panel, now fill in the information
-		self->mClassifiedID = classified_id;
-		self->mCreatorID = creator_id;
-		self->mParcelID = parcel_id;
-		self->mPriceForListing = price_for_listing;
-		self->mSimName.assign(sim_name);
-		self->mPosGlobal = pos_global;
-
-		// Update UI controls
-        self->mNameEditor->setText(name);
-        self->mDescEditor->setText(desc);
-        self->mSnapshotCtrl->setImageAssetID(snapshot_id);
-        self->mLocationEditor->setText(location_text);
-		self->mLocationChanged = false;
-
-		self->mCategoryCombo->setCurrentByIndex(category - 1);
-		if(mature)
-		{
-			self->mMatureCombo->setCurrentByIndex(MATURE_CONTENT);
-		}
-		else
-		{
-			self->mMatureCombo->setCurrentByIndex(PG_CONTENT);
-		}
-		if (self->mAutoRenewCheck)
-		{
-			self->mAutoRenewCheck->set(auto_renew);
-		}
-
-		std::string dateStr = self->getString("dateStr");
-		LLSD substitution;
-		substitution["datetime"] = (S32) tim;
-		LLStringUtil::format (dateStr, substitution);
-
-		LLStringUtil::format_map_t string_args;
-		string_args["[DATE]"] = dateStr;
-		string_args["[AMT]"] = llformat("%d", price_for_listing);
-		self->childSetText("classified_info_text", self->getString("ad_placed_paid", string_args));
-
-		// If we got data from the database, we know the listing is paid for.
-		self->mPaidFor = TRUE;
-
-		self->mUpdateBtn->setLabel(self->getString("update_txt"));
-
-		self->resetDirty();
-
-		// I don't know if a second call is deliberate or a bad merge, so I'm leaving it here. 
-		self->resetDirty();
-    }
-}
-
-void LLPanelClassified::draw()
-{
-	refresh();
-
-	LLPanel::draw();
-}
-
-
-void LLPanelClassified::refresh()
-{
-	if (!mDataRequested)
-	{
-		sendClassifiedInfoRequest();
-	}
-
-    // Check for god mode
-    BOOL godlike = gAgent.isGodlike();
-	BOOL is_self = (gAgent.getID() == mCreatorID);
-
-    // Set button visibility/enablement appropriately
-	if (mInFinder)
-	{
-
-		// End user doesn't ned to see price twice, or date posted.
-
-		mSnapshotCtrl->setEnabled(godlike);
-		if(godlike)
-		{
-			//make it smaller, so text is more legible
-			mSnapshotCtrl->setOrigin(20, 175);
-			mSnapshotCtrl->reshape(300, 200);
-		}
-		else
-		{
-			mSnapshotCtrl->setOrigin(mSnapshotSize.mLeft, mSnapshotSize.mBottom);
-			mSnapshotCtrl->reshape(mSnapshotSize.getWidth(), mSnapshotSize.getHeight());
-			//normal
-		}
-		mNameEditor->setEnabled(godlike);
-		mDescEditor->setEnabled(godlike);
-		mCategoryCombo->setEnabled(godlike);
-		mCategoryCombo->setVisible(godlike);
-
-		mMatureCombo->setEnabled(godlike);
-		mMatureCombo->setVisible(godlike);
-
-		// Jesse (who is the only one who uses this, as far as we can tell
-		// Says that he does not want a set location button - he has used it
-		// accidently in the past.
-		mSetBtn->setVisible(FALSE);
-		mSetBtn->setEnabled(FALSE);
-
-		mUpdateBtn->setEnabled(godlike);
-		mUpdateBtn->setVisible(godlike);
-	}
-	else
-	{
-		mSnapshotCtrl->setEnabled(is_self);
-		mNameEditor->setEnabled(is_self);
-		mDescEditor->setEnabled(is_self);
-		//mPriceEditor->setEnabled(is_self);
-		mCategoryCombo->setEnabled(is_self);
-		mMatureCombo->setEnabled(is_self);
-
-		if( is_self )
-		{							
-			if( mMatureCombo->getCurrentIndex() == 0 )
-			{
-				// It's a new panel.
-				// PG regions should have PG classifieds. AO should have mature.
-								
-				setDefaultAccessCombo();
-			}
-		}
-		
-		if (mAutoRenewCheck)
-		{
-			mAutoRenewCheck->setEnabled(is_self);
-			mAutoRenewCheck->setVisible(is_self);
-		}
-		
-		mClickThroughText->setEnabled(is_self);
-		mClickThroughText->setVisible(is_self);
-
-		mSetBtn->setVisible(is_self);
-		mSetBtn->setEnabled(is_self);
-
-		mUpdateBtn->setEnabled(is_self && checkDirty());
-		mUpdateBtn->setVisible(is_self);
-	}
-}
-
-// static
-void LLPanelClassified::onClickUpdate(void* data)
-{
-	LLPanelClassified* self = (LLPanelClassified*)data;
-
-	if(self == NULL) return;
-
-	// Disallow leading spaces, punctuation, etc. that screw up
-	// sort order.
-	if ( ! self->titleIsValid() )
-	{
-		return;
-	};
-
-	// If user has not set mature, do not allow publish
-	if(self->mMatureCombo->getCurrentIndex() == DECLINE_TO_STATE)
-	{
-		// Tell user about it
-		LLNotificationsUtil::add("SetClassifiedMature", 
-				LLSD(), 
-				LLSD(), 
-				boost::bind(&LLPanelClassified::confirmMature, self, _1, _2));
-		return;
-	}
-
-	// Mature content flag is set, proceed
-	self->gotMature();
-}
-
-// Callback from a dialog indicating response to mature notification
-bool LLPanelClassified::confirmMature(const LLSD& notification, const LLSD& response)
-{
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	
-	// 0 == Yes
-	// 1 == No
-	// 2 == Cancel
-	switch(option)
-	{
-	case 0:
-		mMatureCombo->setCurrentByIndex(MATURE_CONTENT);
-		break;
-	case 1:
-		mMatureCombo->setCurrentByIndex(PG_CONTENT);
-		break;
-	default:
-		return false;
-	}
-	
-	// If we got here it means they set a valid value
-	gotMature();
-	return false;
-}
-
-// Called after we have determined whether this classified has
-// mature content or not.
-void LLPanelClassified::gotMature()
-{
-	// if already paid for, just do the update
-	if (mPaidFor)
-	{
-		LLNotification::Params params("PublishClassified");
-		params.functor.function(boost::bind(&LLPanelClassified::confirmPublish, this, _1, _2));
-		LLNotifications::instance().forceResponse(params, 0);
-	}
-	else
-	{
-		// Ask the user how much they want to pay
-		LLFloaterPriceForListing::show( callbackGotPriceForListing, this );
-	}
-}
-
-// static
-void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text, void* data)
-{
-	LLPanelClassified* self = (LLPanelClassified*)data;
-
-	// Only do something if user hits publish
-	if (option != 0) return;
-
-	S32 price_for_listing = strtol(text.c_str(), NULL, 10);
-	if (price_for_listing < MINIMUM_PRICE_FOR_LISTING)
-	{
-		LLSD args;
-		std::string price_text = llformat("%d", MINIMUM_PRICE_FOR_LISTING);
-		args["MIN_PRICE"] = price_text;
-			
-		LLNotificationsUtil::add("MinClassifiedPrice", args);
-		return;
-	}
-
-	// price is acceptable, put it in the dialog for later read by 
-	// update send
-	self->mPriceForListing = price_for_listing;
-
-	LLSD args;
-	args["AMOUNT"] = llformat("%d", price_for_listing);
-	LLNotificationsUtil::add("PublishClassified", args, LLSD(), 
-									boost::bind(&LLPanelClassified::confirmPublish, self, _1, _2));
-}
-
-void LLPanelClassified::resetDirty()
-{
-	// Tell all the widgets to reset their dirty state since the ad was just saved
-	if (mSnapshotCtrl)
-		mSnapshotCtrl->resetDirty();
-	if (mNameEditor)
-		mNameEditor->resetDirty();
-	if (mDescEditor)
-		mDescEditor->resetDirty();
-	if (mLocationEditor)
-		mLocationEditor->resetDirty();
-	mLocationChanged = false;
-	if (mCategoryCombo)
-		mCategoryCombo->resetDirty();
-	if (mMatureCombo)
-		mMatureCombo->resetDirty();
-	if (mAutoRenewCheck)
-		mAutoRenewCheck->resetDirty();
-}
-
-// invoked from callbackConfirmPublish
-bool LLPanelClassified::confirmPublish(const LLSD& notification, const LLSD& response)
-{
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	// Option 0 = publish
-	if (option != 0) return false;
-
-	sendClassifiedInfoUpdate();
-
-	// Big hack - assume that top picks are always in a browser,
-	// and non-finder-classifieds are always in a tab container.
-	if (! mInFinder)
-	{
-		LLTabContainer* tab = (LLTabContainer*)getParent();
-		tab->setCurrentTabName(mNameEditor->getText());
-	}
-
-	resetDirty();
-	return false;
-}
-
-
-// static
-void LLPanelClassified::onClickTeleport(void* data)
-{
-    LLPanelClassified* self = (LLPanelClassified*)data;
-	LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance();
-	
-    if (!self->mPosGlobal.isExactlyZero()&&worldmap_instance)
-    {
-        gAgent.teleportViaLocation(self->mPosGlobal);		
-        worldmap_instance->trackLocation(self->mPosGlobal);
-		self->sendClassifiedClickMessage("teleport");
-    }
-}
-
-
-// static
-void LLPanelClassified::onClickMap(void* data)
-{
-	LLPanelClassified* self = (LLPanelClassified*)data;
-	LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance();
-	if(worldmap_instance)
-	{
-		worldmap_instance->trackLocation(self->mPosGlobal);
-		LLFloaterReg::showInstance("world_map", "center");
-	}
-	self->sendClassifiedClickMessage("map");
-}
-
-// static
-void LLPanelClassified::onClickProfile(void* data)
-{
-	LLPanelClassified* self = (LLPanelClassified*)data;
-	LLAvatarActions::showProfile(self->mCreatorID);
-	self->sendClassifiedClickMessage("profile");
-}
-
-// static
-/*
-void LLPanelClassified::onClickLandmark(void* data)
-{
-    LLPanelClassified* self = (LLPanelClassified*)data;
-	create_landmark(self->mNameEditor->getText(), "", self->mPosGlobal);
-}
-*/
-
-// static
-void LLPanelClassified::onClickSet(void* data)
-{
-    LLPanelClassified* self = (LLPanelClassified*)data;
-
-	// Save location for later.
-	self->mPosGlobal = gAgent.getPositionGlobal();
-
-	std::string location_text;
-	std::string regionName = LLTrans::getString("ClassifiedUpdateAfterPublish");
-	LLViewerRegion* pRegion = gAgent.getRegion();
-	if (pRegion)
-	{
-		regionName = pRegion->getName();
-	}
-	location_text.assign(regionName);
-	location_text.append(", ");
-
-    S32 region_x = llround((F32)self->mPosGlobal.mdV[VX]) % REGION_WIDTH_UNITS;
-    S32 region_y = llround((F32)self->mPosGlobal.mdV[VY]) % REGION_WIDTH_UNITS;
-	S32 region_z = llround((F32)self->mPosGlobal.mdV[VZ]);
-   
-	location_text.append(self->mSimName);
-    location_text.append(llformat(" (%d, %d, %d)", region_x, region_y, region_z));
-
-	self->mLocationEditor->setText(location_text);
-	self->mLocationChanged = true;
-	
-	self->setDefaultAccessCombo();	
-
-	// Set this to null so it updates on the next save.
-	self->mParcelID.setNull();
-
-	onCommitAny(NULL, data);
-}
-
-
-BOOL LLPanelClassified::checkDirty()
-{
-	mDirty = FALSE;
-	if	( mSnapshotCtrl )			mDirty |= mSnapshotCtrl->isDirty();
-	if	( mNameEditor )				mDirty |= mNameEditor->isDirty();
-	if	( mDescEditor )				mDirty |= mDescEditor->isDirty();
-	if	( mLocationEditor )			mDirty |= mLocationEditor->isDirty();
-	if  ( mLocationChanged )		mDirty |= TRUE;
-	if	( mCategoryCombo )			mDirty |= mCategoryCombo->isDirty();
-	if	( mMatureCombo )			mDirty |= mMatureCombo->isDirty();
-	if	( mAutoRenewCheck )			mDirty |= mAutoRenewCheck->isDirty();
-
-	return mDirty;
-}
-
-// static
-void LLPanelClassified::onCommitAny(LLUICtrl* ctrl, void* data)
-{
-	LLPanelClassified* self = (LLPanelClassified*)data;
-	if (self)
-	{
-		self->checkDirty();
-	}
-}
-
-// static
-void LLPanelClassified::focusReceived(LLFocusableElement* ctrl, void* data)
-{
-	// allow the data to be saved
-	onCommitAny((LLUICtrl*)ctrl, data);
-}
-
-
-void LLPanelClassified::sendClassifiedClickMessage(const std::string& type)
-{
-	// You're allowed to click on your own ads to reassure yourself
-	// that the system is working.
-	LLSD body;
-	body["type"] = type;
-	body["from_search"] = mFromSearch;
-	body["classified_id"] = mClassifiedID;
-	body["parcel_id"] = mParcelID;
-	body["dest_pos_global"] = mPosGlobal.getValue();
-	body["region_name"] = mSimName;
-
-	std::string url = gAgent.getRegion()->getCapability("SearchStatTracking");
-	llinfos << "LLPanelClassified::sendClassifiedClickMessage via capability" << llendl;
-	LLHTTPClient::post(url, body, new LLHTTPClient::Responder());
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-
-LLFloaterPriceForListing::LLFloaterPriceForListing()
-:	LLFloater(LLSD()),
-	mCallback(NULL),
-	mUserData(NULL)
-{ }
-
-//virtual
-LLFloaterPriceForListing::~LLFloaterPriceForListing()
-{ }
-
-//virtual
-BOOL LLFloaterPriceForListing::postBuild()
-{
-	LLLineEditor* edit = getChild<LLLineEditor>("price_edit");
-	if (edit)
-	{
-		edit->setPrevalidate(LLTextValidate::validateNonNegativeS32);
-		std::string min_price = llformat("%d", MINIMUM_PRICE_FOR_LISTING);
-		edit->setText(min_price);
-		edit->selectAll();
-		edit->setFocus(TRUE);
-	}
-
-	childSetAction("set_price_btn", onClickSetPrice, this);
-
-	childSetAction("cancel_btn", onClickCancel, this);
-
-	setDefaultBtn("set_price_btn");
-	return TRUE;
-}
-
-//static
-void LLFloaterPriceForListing::show( void (*callback)(S32, std::string, void*), void* userdata)
-{
-	LLFloaterPriceForListing *self = new LLFloaterPriceForListing();
-
-	// Builds and adds to gFloaterView
-	LLUICtrlFactory::getInstance()->buildFloater(self, "floater_price_for_listing.xml", NULL);
-	self->center();
-
-	self->mCallback = callback;
-	self->mUserData = userdata;
-}
-
-//static
-void LLFloaterPriceForListing::onClickSetPrice(void* data)
-{
-	buttonCore(0, data);
-}
-
-//static
-void LLFloaterPriceForListing::onClickCancel(void* data)
-{
-	buttonCore(1, data);
-}
-
-//static
-void LLFloaterPriceForListing::buttonCore(S32 button, void* data)
-{
-	LLFloaterPriceForListing* self = (LLFloaterPriceForListing*)data;
-
-	if (self->mCallback)
-	{
-		std::string text = self->childGetText("price_edit");
-		self->mCallback(button, text, self->mUserData);
-		self->closeFloater();
-	}
-}
-
-void LLPanelClassified::setDefaultAccessCombo()
-{
-	// PG regions should have PG classifieds. AO should have mature.
-
-	LLViewerRegion *regionp = gAgent.getRegion();
-
-	switch( regionp->getSimAccess() )
-	{
-		case SIM_ACCESS_PG:	
-			mMatureCombo->setCurrentByIndex(PG_CONTENT);
-			break;
-		case SIM_ACCESS_ADULT:
-			mMatureCombo->setCurrentByIndex(MATURE_CONTENT);
-			break;
-		default:
-			// You are free to move about the cabin.
-			break;
-	}
-}
-
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h
index eaf652ca063..7d2b1ae5719 100644
--- a/indra/newview/llpanelclassified.h
+++ b/indra/newview/llpanelclassified.h
@@ -33,174 +33,20 @@
 // Display of a classified used both for the global view in the
 // Find directory, and also for each individual user's classified in their
 // profile.
-
 #ifndef LL_LLPANELCLASSIFIED_H
 #define LL_LLPANELCLASSIFIED_H
 
 #include "llavatarpropertiesprocessor.h"
-#include "llpanel.h"
 #include "llclassifiedinfo.h"
-#include "v3dmath.h"
-#include "lluuid.h"
 #include "llfloater.h"
-//#include "llrect.h"
-
-class LLButton;
-class LLCheckBoxCtrl;
-class LLComboBox;
-class LLIconCtrl;
-class LLLineEditor;
-class LLTextBox;
-class LLTextEditor;
+#include "llpanel.h"
+#include "llrect.h"
+#include "lluuid.h"
+#include "v3dmath.h"
+
+class LLScrollContainer;
 class LLTextureCtrl;
 class LLUICtrl;
-class LLMessageSystem;
-class LLScrollContainer;
-
-// *TODO deprecated, should be removed.
-// New class implemented in ticket EXT-2095
-class LLPanelClassified : public LLPanel
-{
-public:
-    LLPanelClassified(bool in_finder, bool from_search);
-    /*virtual*/ ~LLPanelClassified();
-
-	void reset();
-
-    /*virtual*/ BOOL postBuild();
-
-    /*virtual*/ void draw();
-
-	/*virtual*/ void refresh();
-
-	void apply();
-
-	// If can close, return TRUE.  If cannot close, pop save/discard dialog
-	// and return FALSE.
-	BOOL canClose();
-
-	// Setup a new classified, including creating an id, giving a sane
-	// initial position, etc.
-	void initNewClassified();
-
-	void setClassifiedID(const LLUUID& id);
-	void setClickThroughText(const std::string& text);
-	static void setClickThrough(const LLUUID& classified_id,
-								S32 teleport, S32 map, S32 profile, bool from_new_table);
-
-	// check that the title is valid (E.G. starts with a number or letter)
-	BOOL titleIsValid();
-
-	// Schedules the panel to request data
-	// from the server next time it is drawn.
-	void markForServerRequest();
-
-	std::string getClassifiedName();
-	const LLUUID& getClassifiedID() const { return mClassifiedID; }
-
-    void sendClassifiedInfoRequest();
-	void sendClassifiedInfoUpdate();
-	void resetDirty();
-
-    static void processClassifiedInfoReply(LLMessageSystem* msg, void**);
-
-	// Confirmation dialogs flow in this order
-	bool confirmMature(const LLSD& notification, const LLSD& response);
-	void gotMature();
-	static void callbackGotPriceForListing(S32 option, std::string text, void* data);
-	bool confirmPublish(const LLSD& notification, const LLSD& response);
-
-	void sendClassifiedClickMessage(const std::string& type);
-
-protected:
-	bool saveCallback(const LLSD& notification, const LLSD& response);
-
-	static void onClickUpdate(void* data);
-    static void onClickTeleport(void* data);
-    static void onClickMap(void* data);
-	static void onClickProfile(void* data);
-    static void onClickSet(void* data);
-
-	static void focusReceived(LLFocusableElement* ctrl, void* data);
-	static void onCommitAny(LLUICtrl* ctrl, void* data);
-
-	void setDefaultAccessCombo(); // Default AO and PG regions to proper classified access
-	
-	BOOL checkDirty();		// Update and return mDirty
-
-protected:
-	bool mInFinder;
-	bool mFromSearch;		// from web-based "All" search sidebar
-	BOOL mDirty;
-	bool mForceClose;
-	bool mLocationChanged;
-	LLUUID mClassifiedID;
-	LLUUID mRequestedID;
-	LLUUID mCreatorID;
-	LLUUID mParcelID;
-	S32 mPriceForListing;
-
-	// Needed for stat tracking
-	S32 mTeleportClicksOld;
-	S32 mMapClicksOld;
-	S32 mProfileClicksOld;
-	S32 mTeleportClicksNew;
-	S32 mMapClicksNew;
-	S32 mProfileClicksNew;
-
-	// Data will be requested on first draw
-	BOOL mDataRequested;
-
-	// For avatar panel classifieds only, has the user been charged
-	// yet for this classified?  That is, have they saved once?
-	BOOL mPaidFor;
-
-	std::string mSimName;
-	LLVector3d mPosGlobal;
-
-	// Values the user may change
-	LLTextureCtrl*	mSnapshotCtrl;
-	LLLineEditor*	mNameEditor;
-	LLTextEditor*	mDescEditor;
-	LLLineEditor*	mLocationEditor;
-	LLComboBox*		mCategoryCombo;
-	LLComboBox*		mMatureCombo;
-	LLCheckBoxCtrl* mAutoRenewCheck;
-
-	LLButton*    mUpdateBtn;
-	LLButton*    mTeleportBtn;
-	LLButton*    mMapBtn;
-	LLButton*	 mProfileBtn;
-
-	LLTextBox*		mInfoText;
-	LLButton*		mSetBtn;
-	LLTextBox*		mClickThroughText;
-
-	LLRect		mSnapshotSize;
-	typedef std::list<LLPanelClassified*> panel_list_t;
-	static panel_list_t sAllPanels;
-};
-
-
-class LLFloaterPriceForListing
-: public LLFloater
-{
-public:
-	LLFloaterPriceForListing();
-	virtual ~LLFloaterPriceForListing();
-	virtual BOOL postBuild();
-
-	static void show( void (*callback)(S32 option, std::string value, void* userdata), void* userdata );
-
-private:
-	static void onClickSetPrice(void*);
-	static void onClickCancel(void*);
-	static void buttonCore(S32 button, void* data);
-
-private:
-	void (*mCallback)(S32 option, std::string, void*);
-	void* mUserData;
-};
 
 class LLPublishClassifiedFloater : public LLFloater
 {
diff --git a/indra/newview/skins/default/xui/en/panel_classified.xml b/indra/newview/skins/default/xui/en/panel_classified.xml
deleted file mode 100644
index c8293d36639..00000000000
--- a/indra/newview/skins/default/xui/en/panel_classified.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<panel
- follows="bottom|left"
- height="490"
- label="Classified"
- layout="topleft"
- left="330"
- name="Classified"
- top="490"
- width="450">
-    <panel.string
-     name="ad_placed_paid">
-        Ad placed: [DATE], Paid L$[AMT] for listing.
-    </panel.string>
-    <panel.string
-     name="update_txt">
-        Update
-    </panel.string>
-    <panel.string
-     name="publish_txt">
-        Publish...
-    </panel.string>
-    <panel.string
-     name="dateStr">
-        [mthnum,datetime,slt]/[day,datetime,slt]/[year,datetime,slt]
-    </panel.string>
-    <texture_picker
-     follows="left|top"
-     height="300"
-     layout="topleft"
-     left="20"
-     name="snapshot_ctrl"
-     top="15"
-     width="400" />
-    <line_editor
-     enabled="false"
-     follows="left|top"
-     font="SansSerif"
-     height="20"
-     layout="topleft"
-     left_delta="0"
-     name="given_name_editor"
-     tool_tip="Name must begin with a letter or number, not punctuation"
-     top_delta="288"
-     width="400" />
-    <text_editor
-     enabled="false"
-     follows="left|top"
-     height="90"
-     layout="topleft"
-     left="20"
-     max_length="1023"
-     name="desc_editor"
-     width="400"
-     word_wrap="true" />
-    <line_editor
-     enabled="false"
-     follows="left|top"
-     font="SansSerif"
-     height="20"
-     layout="topleft"
-     left="20"
-     name="location_editor"
-     tool_tip="Set the location for this classified to your current position"
-     width="400" />
-    <button
-     follows="left|top"
-     height="20"
-     label="Set"
-     layout="topleft"
-     left_delta="360"
-     name="set_location_btn"
-     top_delta="0"
-     width="60" />
-    <button
-     follows="left|top"
-     height="20"
-     label="Teleport"
-     layout="topleft"
-     left="20"
-     name="classified_teleport_btn"
-     top="449"
-     width="100" />
-    <button
-     follows="left|top"
-     height="20"
-     label="Map"
-     layout="topleft"
-     left_pad="5"
-     name="classified_map_btn"
-     top_delta="0"
-     width="100" />
-    <button
-     follows="left|top"
-     height="20"
-     label="Profile"
-     layout="topleft"
-     left_pad="5"
-     name="classified_profile_btn"
-     top_delta="0"
-     width="100" />
-    <combo_box
-     height="20"
-     layout="topleft"
-     left="30"
-     name="classified_mature_check"
-     top="48"
-     width="130">
-        <combo_box.item
-         label="- Select one -"
-         name="select_mature"
-         value="Select" />
-        <combo_box.item
-         label="Moderate Content"
-         name="mature"
-         value="Mature" />
-        <combo_box.item
-         label="General Content"
-         name="pg"
-         value="PG" />
-    </combo_box>
-    <combo_box
-     bottom="45"
-     height="18"
-     layout="topleft"
-     left="20"
-     name="classified_category_combo"
-     right="150" />
-    <button
-     follows="left|top"
-     height="20"
-     label="Update"
-     layout="topleft"
-     left="30"
-     name="classified_update_btn"
-     top="70"
-     width="70" />
-</panel>
-- 
GitLab


From c28c2df676d2520b3f9e523385c0541df83a46b7 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Tue, 20 Jul 2010 14:02:51 +0300
Subject: [PATCH 534/683] EXT-7406 FIXED Replaced inventory collector for
 objects to exclude links from the Edit Outfit->Add More panel.

Reviewed by Vadim Savchuk and Neal Orman at https://codereview.productengine.com/secondlife/r/777/

--HG--
branch : product-engine
---
 indra/newview/llpaneloutfitedit.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 6d9465d4229..6fecdb2286d 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -439,7 +439,7 @@ BOOL LLPanelOutfitEdit::postBuild()
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.All"), new LLFindNonLinksByMask(ALL_ITEMS_MASK)));
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Clothing"), new LLIsTypeActual(LLAssetType::AT_CLOTHING)));
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Bodyparts"), new LLIsTypeActual(LLAssetType::AT_BODYPART)));
-	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindByMask(ATTACHMENT_MASK)));;
+	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindNonLinksByMask(ATTACHMENT_MASK)));;
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("shape"), new LLFindActualWearablesOfType(LLWearableType::WT_SHAPE)));
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("skin"), new LLFindActualWearablesOfType(LLWearableType::WT_SKIN)));
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("hair"), new LLFindActualWearablesOfType(LLWearableType::WT_HAIR)));
-- 
GitLab


From 67fb58847981f69cb31c34d7141165ba3f49aef6 Mon Sep 17 00:00:00 2001
From: Aimee Linden <aimee@lindenlab.com>
Date: Tue, 20 Jul 2010 15:20:05 +0100
Subject: [PATCH 535/683] Trivial: Correct speeling
 "LLAvatarList::onItemDoucleClicked"

---
 indra/newview/llavatarlist.cpp | 4 ++--
 indra/newview/llavatarlist.h   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 99156b9d9df..57e186b6a8b 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -384,7 +384,7 @@ void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is
 	item->setShowProfileBtn(mShowProfileBtn);
 	item->showSpeakingIndicator(mShowSpeakingIndicator);
 
-	item->setDoubleClickCallback(boost::bind(&LLAvatarList::onItemDoucleClicked, this, _1, _2, _3, _4));
+	item->setDoubleClickCallback(boost::bind(&LLAvatarList::onItemDoubleClicked, this, _1, _2, _3, _4));
 
 	addItem(item, id, pos);
 }
@@ -447,7 +447,7 @@ void LLAvatarList::updateLastInteractionTimes()
 	}
 }
 
-void LLAvatarList::onItemDoucleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask)
+void LLAvatarList::onItemDoubleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask)
 {
 	mItemDoubleClickSignal(ctrl, x, y, mask);
 }
diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h
index fffc6e6e73d..5b010c9cfec 100644
--- a/indra/newview/llavatarlist.h
+++ b/indra/newview/llavatarlist.h
@@ -110,7 +110,7 @@ class LLAvatarList : public LLFlatListViewEx
 		uuid_vec_t& vadded,
 		uuid_vec_t& vremoved);
 	void updateLastInteractionTimes();
-	void onItemDoucleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask);
+	void onItemDoubleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask);
 
 private:
 
-- 
GitLab


From 4d2daeed21dfba9d6a40e88ecd92aaaa6df92ae1 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Wed, 21 Jul 2010 19:25:36 +0300
Subject: [PATCH 536/683] EXT-8401 FIXED Added new text prevalidation callback
 to allow ascii characters and new line in text editor.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/786/.

--HG--
branch : product-engine
---
 indra/llui/lltextvalidate.cpp                  | 18 ++++++++++++++++++
 indra/llui/lltextvalidate.h                    |  1 +
 .../default/xui/en/panel_landmark_info.xml     |  2 +-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/indra/llui/lltextvalidate.cpp b/indra/llui/lltextvalidate.cpp
index 8b6bc5bd7da..53c4d211517 100644
--- a/indra/llui/lltextvalidate.cpp
+++ b/indra/llui/lltextvalidate.cpp
@@ -50,6 +50,7 @@ namespace LLTextValidate
 		declare("alpha_num_space", validateAlphaNumSpace);
 		declare("ascii_printable_no_pipe", validateASCIIPrintableNoPipe);
 		declare("ascii_printable_no_space", validateASCIIPrintableNoSpace);
+		declare("ascii_with_newline", validateASCIIWithNewLine);
 	}
 
 	// Limits what characters can be used to [1234567890.-] with [-] only valid in the first position.
@@ -299,4 +300,21 @@ namespace LLTextValidate
 		}
 		return rv;
 	}
+
+	// Used for multiline text stored on the server.
+	// Example is landmark description in Places SP.
+	bool validateASCIIWithNewLine(const LLWString &str)
+	{
+		bool rv = TRUE;
+		S32 len = str.length();
+		while(len--)
+		{
+			if (str[len] < 0x20 && str[len] != 0xA || str[len] > 0x7f)
+			{
+				rv = FALSE;
+				break;
+			}
+		}
+		return rv;
+	}
 }
diff --git a/indra/llui/lltextvalidate.h b/indra/llui/lltextvalidate.h
index ffb4e85e7cc..c033f5045b8 100644
--- a/indra/llui/lltextvalidate.h
+++ b/indra/llui/lltextvalidate.h
@@ -57,6 +57,7 @@ namespace LLTextValidate
 	bool	validateASCIIPrintableNoPipe(const LLWString &str); 
 	bool	validateASCIIPrintableNoSpace(const LLWString &str);
 	bool	validateASCII(const LLWString &str);
+	bool	validateASCIIWithNewLine(const LLWString &str);
 }
 
 
diff --git a/indra/newview/skins/default/xui/en/panel_landmark_info.xml b/indra/newview/skins/default/xui/en/panel_landmark_info.xml
index 40cb7c7f4b9..c5d6aced7af 100644
--- a/indra/newview/skins/default/xui/en/panel_landmark_info.xml
+++ b/indra/newview/skins/default/xui/en/panel_landmark_info.xml
@@ -275,7 +275,7 @@
                  name="notes_editor"
                  read_only="true"
                  text_readonly_color="white"
-                 text_type="ascii"
+                 text_type="ascii_with_newline"
                  top_pad="5"
                  width="290"
                  wrap="true" />
-- 
GitLab


From 8bbd9317fbc08fd03cd8adc9115efd261413c7d2 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Wed, 21 Jul 2010 17:46:17 -0700
Subject: [PATCH 537/683] Miscellaneous cleanup in and around
 llmediadataclient.

Added tags to some media-related logging in LLVOVolume.

Made LLMediaDataClient::Responder do most of its work in tick() instead of its destructor.

Added a comment to llmediadataclient.cpp that explains the idea behind the two-queue system.

Made LLMediaDataClient::sortQueue() remove requests from the queue that hold references to dead items.  This should make teleporting away solve many of the pathological queueing cases.

Updated llmediadataclient test cases to reflect the change in behavior in sortQueue().

Removed some unnecessary const-ness in LLMediaDataClient::enqueue, which caused it to have to use const_cast.
---
 indra/newview/llmediadataclient.cpp           | 137 +++++++++++++-----
 indra/newview/llmediadataclient.h             |   8 +-
 indra/newview/llvovolume.cpp                  |   6 +-
 .../newview/tests/llmediadataclient_test.cpp  |  16 +-
 4 files changed, 111 insertions(+), 56 deletions(-)

diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp
index b8da368bd7a..8f5290bac2a 100755
--- a/indra/newview/llmediadataclient.cpp
+++ b/indra/newview/llmediadataclient.cpp
@@ -58,6 +58,32 @@
 // - Any request that gets a 503 still goes through the retry logic
 //
 
+/***************************************************************************************************************
+	What's up with this queueing code?
+
+	First, a bit of background:
+
+	Media on a prim was added into the system in the Viewer 2.0 timeframe.  In order to avoid changing the 
+	network format of objects, an unused field in the object (the "MediaURL" string) was repurposed to 
+	indicate that the object had media data, and also hold a sequence number and the UUID of the agent 
+	who last updated the data.  The actual media data for objects is accessed via the "ObjectMedia" capability.  
+	Due to concerns about sim performance, requests to this capability are rate-limited to 5 requests every 
+	5 seconds per agent.
+
+	The initial implementation of LLMediaDataClient used a single queue to manage requests to the "ObjectMedia" cap.  
+	Requests to the cap were queued so that objects closer to the avatar were loaded in first, since they were most 
+	likely to be the ones the media performance manager would load.
+
+	This worked in some cases, but we found that it was possible for a scripted object that constantly updated its 
+	media data to starve other objects, since the same queue contained both requests to load previously unseen media 
+	data and requests to fetch media data in response to object updates.
+
+	The solution for this we came up with was to have two queues.  The sorted queue contains requests to fetch media 
+	data for objects that don't have it yet, and the round-robin queue contains requests to update media data for 
+	objects that have already completed their initial load.  When both queues are non-empty, the code ping-pongs 
+	between them so that updates can't completely block initial load-in.
+**************************************************************************************************************/
+
 //
 // Forward decls
 //
@@ -149,7 +175,7 @@ void LLMediaDataClient::request(const LLMediaDataClientObject::ptr_t &object, co
 	enqueue(new Request(getCapabilityName(), payload, object, this));
 }
 
-void LLMediaDataClient::enqueue(const Request *request)
+void LLMediaDataClient::enqueue(Request *request)
 {
 	if (request->isNew())
 	{		
@@ -161,8 +187,7 @@ void LLMediaDataClient::enqueue(const Request *request)
 		
 		LL_DEBUGS("LLMediaDataClient") << "Queuing SORTED request for " << *request << LL_ENDL;
 		
-		// Sadly, we have to const-cast because items put into the queue are not const
-		mSortedQueue.push_back(const_cast<LLMediaDataClient::Request*>(request));
+		mSortedQueue.push_back(request);
 		
 		LL_DEBUGS("LLMediaDataClientQueue") << "SORTED queue:" << mSortedQueue << LL_ENDL;
 	}
@@ -184,8 +209,7 @@ void LLMediaDataClient::enqueue(const Request *request)
 		{
 			LL_DEBUGS("LLMediaDataClient") << "Queuing RR request for " << *request << LL_ENDL;
 			// Push the request on the pending queue
-			// Sadly, we have to const-cast because items put into the queue are not const
-			mRoundRobinQueue.push_front(const_cast<LLMediaDataClient::Request*>(request));
+			mRoundRobinQueue.push_front(request);
 			
 			LL_DEBUGS("LLMediaDataClientQueue") << "RR queue:" << mRoundRobinQueue << LL_ENDL;			
 		}
@@ -240,17 +264,64 @@ bool LLMediaDataClient::processQueueTimer()
 	return isEmpty();
 }
 
+bool LLMediaDataClient::request_needs_purge(LLMediaDataClient::request_ptr_t request)
+{
+	// Check for conditions that should cause a request to get removed from the queue
+	if(request.isNull())
+	{
+		LL_WARNS("LLMediaDataClient") << "removing NULL request" << LL_ENDL;
+		return true;
+	}
+
+	// For some reason, the existing code put sent items onto the back of the round-robin queue and let them come through again
+	// before stripping them off the front.  Was there a good reason for this?
+//	if(request->isMarkedSent())
+//	{
+//		LL_INFOS("LLMediaDataClient") << "removing : " << *request << " request is marked sent" << LL_ENDL;
+//		return true;
+//	}
+
+	const LLMediaDataClientObject *object = request->getObject();
+	
+	if(object == NULL)
+	{
+		LL_INFOS("LLMediaDataClient") << "removing : " << *request << " object is NULL" << LL_ENDL;
+		return true;
+	}
+	
+	if(object->isDead())
+	{
+		LL_INFOS("LLMediaDataClient") << "removing : " << *request << " object is dead" << LL_ENDL;
+		return true;
+	}
+	
+	if(!object->hasMedia())
+	{
+		LL_INFOS("LLMediaDataClient") << "removing : " << *request << " object has no media" << LL_ENDL;
+		return true;
+	}
+
+	return false;	
+}
+
 void LLMediaDataClient::sortQueue()
 {
 	if(!mSortedQueue.empty())
 	{
-		// Score all items first
+		// Cull dead objects and score all remaining items first
 		request_queue_t::iterator iter = mSortedQueue.begin();
 		request_queue_t::iterator end = mSortedQueue.end();
 		while (iter != end)
 		{
-			(*iter)->updateScore();
-			iter++;
+			if(request_needs_purge(*iter))
+			{
+				iter = mSortedQueue.erase(iter);
+			}
+			else
+			{
+				(*iter)->updateScore();
+				iter++;
+			}
 		}
 		
 		// Re-sort the list...
@@ -270,6 +341,19 @@ void LLMediaDataClient::sortQueue()
 			}
 		}
 	}
+	
+	// Cull dead items from the round robin queue as well.
+	for(request_queue_t::iterator iter = mRoundRobinQueue.begin(); iter != mRoundRobinQueue.end();)
+	{
+		if(request_needs_purge(*iter))
+		{
+			iter = mRoundRobinQueue.erase(iter);
+		}
+		else
+		{
+			iter++;
+		}
+	}
 }
 
 // static
@@ -298,26 +382,14 @@ void LLMediaDataClient::serviceQueue()
 		llassert(!request.isNull());
 		const LLMediaDataClientObject *object = (request.isNull()) ? NULL : request->getObject();
 		llassert(NULL != object);
-		
+
 		// Check for conditions that would make us just pop and rapidly loop through
 		// the queue.
-		if(request.isNull() ||
-		   request->isMarkedSent() ||
-		   NULL == object ||
-		   object->isDead() ||
-		   !object->hasMedia())
+		if(request->isMarkedSent())
 		{
-			if (request.isNull()) 
-			{
-				LL_WARNS("LLMediaDataClient") << "Skipping NULL request" << LL_ENDL;
-			}
-			else {
-				LL_INFOS("LLMediaDataClient") << "Skipping : " << *request << " " 
-				<< ((request->isMarkedSent()) ? " request is marked sent" :
-					((NULL == object) ? " object is NULL " :
-					 ((object->isDead()) ? "object is dead" : 
-					  ((!object->hasMedia()) ? "object has no media!" : "BADNESS!")))) << LL_ENDL;
-			}
+			// Sent items that make it back to the head of the queue need to be skipped.
+			LL_INFOS("LLMediaDataClient") << "removing : " << *request << " request is marked sent" << LL_ENDL;
+			
 			queue_p->pop_front();
 			continue;	// jump back to the start of the quick retry loop
 		}
@@ -448,24 +520,15 @@ LLMediaDataClient::Responder::RetryTimer::RetryTimer(F32 time, Responder *mdr)
 {
 }
 
-// virtual 
-LLMediaDataClient::Responder::RetryTimer::~RetryTimer() 
+// virtual
+BOOL LLMediaDataClient::Responder::RetryTimer::tick()
 {
-	LL_DEBUGS("LLMediaDataClient") << "~RetryTimer" << *(mResponder->getRequest()) << LL_ENDL;
-	
-	// XXX This is weird: Instead of doing the work in tick()  (which re-schedules
-	// a timer, which might be risky), do it here, in the destructor.  Yes, it is very odd.
-	// Instead of retrying, we just put the request back onto the queue
 	LL_INFOS("LLMediaDataClient") << "RetryTimer fired for: " << *(mResponder->getRequest()) << " retrying" << LL_ENDL;
 	mResponder->getRequest()->reEnqueue();
 	
 	// Release the ref to the responder.
 	mResponder = NULL;
-}
 
-// virtual
-BOOL LLMediaDataClient::Responder::RetryTimer::tick()
-{
 	// Don't fire again
 	return TRUE;
 }
@@ -552,7 +615,7 @@ const char *LLMediaDataClient::Request::getTypeAsString() const
 }
 
 
-void LLMediaDataClient::Request::reEnqueue() const
+void LLMediaDataClient::Request::reEnqueue()
 {
 	// I sure hope this doesn't deref a bad pointer:
 	mMDC->enqueue(this);
diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h
index 8dd72cb5952..3e86c52c63f 100755
--- a/indra/newview/llmediadataclient.h
+++ b/indra/newview/llmediadataclient.h
@@ -142,7 +142,7 @@ class LLMediaDataClient : public LLRefCount
 		const char *getTypeAsString() const;
 		
 		// Re-enqueue thyself
-		void reEnqueue() const;
+		void reEnqueue();
 		
 		F32 getRetryTimerDelay() const;
 		U32 getMaxNumRetries() const;
@@ -185,7 +185,7 @@ class LLMediaDataClient : public LLRefCount
 		//If we get back a normal response, handle it here.	 Default just logs it.
 		virtual void result(const LLSD& content);
 
-		const request_ptr_t &getRequest() const { return mRequest; }
+		request_ptr_t &getRequest() { return mRequest; }
 
     protected:
 		virtual ~Responder();
@@ -196,7 +196,6 @@ class LLMediaDataClient : public LLRefCount
 		{
 		public:
 			RetryTimer(F32 time, Responder *);
-			virtual ~RetryTimer();
 			virtual BOOL tick();
 		private:
 			// back-pointer
@@ -214,13 +213,14 @@ class LLMediaDataClient : public LLRefCount
 	// Subclasses must override to return a cap name
 	virtual const char *getCapabilityName() const = 0;
 	
+	virtual bool request_needs_purge(request_ptr_t request);
 	virtual void sortQueue();
 	virtual void serviceQueue();
 	
 private:
 	typedef std::list<request_ptr_t> request_queue_t;
 		
-	void enqueue(const Request*);
+	void enqueue(Request*);
 	
 	// Return whether the given object is/was in the queue
 	static LLMediaDataClient::request_ptr_t findOrRemove(request_queue_t &queue, const LLMediaDataClientObject::ptr_t &obj, bool remove, Request::Type type);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 5644e021349..c838e9a28d8 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2025,12 +2025,12 @@ void LLVOVolume::mediaNavigated(LLViewerMediaImpl *impl, LLPluginClassMedia* plu
 	}
 	else
 	{
-		llwarns << "Couldn't find media entry!" << llendl;
+		LL_WARNS("MediaOnAPrim") << "Couldn't find media entry!" << LL_ENDL;
 	}
 						
 	if(block_navigation)
 	{
-		llinfos << "blocking navigate to URI " << new_location << llendl;
+		LL_INFOS("MediaOnAPrim") << "blocking navigate to URI " << new_location << LL_ENDL;
 
 		// "bounce back" to the current URL from the media entry
 		mediaNavigateBounceBack(face_index);
@@ -2038,7 +2038,7 @@ void LLVOVolume::mediaNavigated(LLViewerMediaImpl *impl, LLPluginClassMedia* plu
 	else if (sObjectMediaNavigateClient)
 	{
 		
-		llinfos << "broadcasting navigate with URI " << new_location << llendl;
+		LL_DEBUGS("MediaOnAPrim") << "broadcasting navigate with URI " << new_location << LL_ENDL;
 
 		sObjectMediaNavigateClient->navigate(new LLMediaDataClientObjectImpl(this, false), face_index, new_location);
 	}
diff --git a/indra/newview/tests/llmediadataclient_test.cpp b/indra/newview/tests/llmediadataclient_test.cpp
index 33d413bd211..d73ea24768a 100644
--- a/indra/newview/tests/llmediadataclient_test.cpp
+++ b/indra/newview/tests/llmediadataclient_test.cpp
@@ -580,25 +580,17 @@ namespace tut
 			
 			::pump_timers();
 			
-			// The first tick should remove the first one 
+			// The first tick should remove the second and fourth ones, and process the first one 
 			ensure("is not in queue 1", !mdc->isInQueue(o1));
-			ensure("is in queue 2", mdc->isInQueue(o2));
+			ensure("is not in queue 2", !mdc->isInQueue(o2));
 			ensure("is in queue 3", mdc->isInQueue(o3));
-			ensure("is in queue 4", mdc->isInQueue(o4));
+			ensure("is not in queue 4", !mdc->isInQueue(o4));
 			ensure("post records", gPostRecords->size(), 1);
 			
 			::pump_timers();
 			
-			// The second tick should skip the second and remove the third
-			ensure("is not in queue 2", !mdc->isInQueue(o2));
+			// The second tick should process the third, emptying the queue
 			ensure("is not in queue 3", !mdc->isInQueue(o3));
-			ensure("is in queue 4", mdc->isInQueue(o4));
-			ensure("post records", gPostRecords->size(), 2);
-
-			::pump_timers();
-
-			// The third tick should skip the fourth one and empty the queue.
-			ensure("is not in queue 4", !mdc->isInQueue(o4));
 			ensure("post records", gPostRecords->size(), 2);
 
 			ensure("queue empty", mdc->isEmpty());
-- 
GitLab


From 85b677823f1515f242e403a6c160af4a9f3ee595 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Fri, 23 Jul 2010 17:42:06 +0300
Subject: [PATCH 538/683] EXT-8299 FIXED Added rearranging of the group
 accordion to fit all space if only General tab is visible.

Also fixed name of accordion in code to be consistent with xml.
Replaced findChild with getChild (when getting accordion and its tabs) to avoid extra checks against NULL of returned pointers
 and have warnings in log is xml is not consistent with code.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/798/

--HG--
branch : product-engine
---
 indra/newview/llpanelgroup.cpp | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index d997b83cbbb..2112c8c0266 100644
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -413,19 +413,14 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 
 	getChild<LLUICtrl>("prepend_founded_by")->setVisible(!is_null_group_id);
 
-	LLAccordionCtrl* tab_ctrl = findChild<LLAccordionCtrl>("group_accordion");
-	if(tab_ctrl)
-		tab_ctrl->reset();
+	LLAccordionCtrl* tab_ctrl = getChild<LLAccordionCtrl>("groups_accordion");
+	tab_ctrl->reset();
 
-	LLAccordionCtrlTab* tab_general = findChild<LLAccordionCtrlTab>("group_general_tab");
-	LLAccordionCtrlTab* tab_roles = findChild<LLAccordionCtrlTab>("group_roles_tab");
-	LLAccordionCtrlTab* tab_notices = findChild<LLAccordionCtrlTab>("group_notices_tab");
-	LLAccordionCtrlTab* tab_land = findChild<LLAccordionCtrlTab>("group_land_tab");
+	LLAccordionCtrlTab* tab_general = getChild<LLAccordionCtrlTab>("group_general_tab");
+	LLAccordionCtrlTab* tab_roles = getChild<LLAccordionCtrlTab>("group_roles_tab");
+	LLAccordionCtrlTab* tab_notices = getChild<LLAccordionCtrlTab>("group_notices_tab");
+	LLAccordionCtrlTab* tab_land = getChild<LLAccordionCtrlTab>("group_land_tab");
 
-
-	if(!tab_general || !tab_roles || !tab_notices || !tab_land)
-		return;
-	
 	if(mButtonJoin)
 		mButtonJoin->setVisible(false);
 
@@ -486,6 +481,8 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 			button_chat->setVisible(is_member);
 	}
 
+	tab_ctrl->arrange();
+
 	reposButtons();
 	update(GC_ALL);//show/hide "join" button if data is already ready
 }
-- 
GitLab


From 41b084eefe91f203117ad5e784ebc5efe07b553e Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Fri, 23 Jul 2010 13:36:48 -0700
Subject: [PATCH 539/683] More cleanup around llmediadataclient.

LLMediaDataClient::Request no longer stores the LLSD payload -- it now uses the link to the LLVOVolume (which it was already keeping around) to generate the LLSD for the request at the time it's sent.

LLMediaDataClient::Request no longer stores a capability name.  Instead it uses the reference to its parent LLMediaDataClient subclass to refer to it as needed.

LLMediaDataClient::Request is now a base class, with subclasses for each specific request type -- GET, UPDATE, and NAVIGATE.

Responders are now created by a virtual method in the LLMediaDataClient::Request subclass instead of being created by the MDC.  This allows different request types to use different responder classes.

Fixed an issue with LLMediaDataClient::QueueTimer and LLMediaDataClient::RetryTimer that caused the unit test to fail (they now do all the work in their tick() functions instead of using the destructor).
---
 indra/newview/llmediadataclient.cpp | 238 ++++++++++++++--------------
 indra/newview/llmediadataclient.h   |  90 ++++++-----
 2 files changed, 171 insertions(+), 157 deletions(-)

diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp
index 8f5290bac2a..f0091d6fdcb 100755
--- a/indra/newview/llmediadataclient.cpp
+++ b/indra/newview/llmediadataclient.cpp
@@ -167,14 +167,6 @@ LLMediaDataClient::request_ptr_t LLMediaDataClient::findOrRemove(request_queue_t
 	return result;
 }
 
-void LLMediaDataClient::request(const LLMediaDataClientObject::ptr_t &object, const LLSD &payload)
-{
-	if (object.isNull() || ! object->hasMedia()) return; 
-	
-	// Push the object on the queue
-	enqueue(new Request(getCapabilityName(), payload, object, this));
-}
-
 void LLMediaDataClient::enqueue(Request *request)
 {
 	if (request->isNew())
@@ -412,7 +404,7 @@ void LLMediaDataClient::serviceQueue()
 			LL_INFOS("LLMediaDataClient") << "Sending request for " << *request << LL_ENDL;
 			
 			// Call the subclass for creating the responder
-			LLHTTPClient::post(url, sd_payload, createResponder(request));
+			LLHTTPClient::post(url, sd_payload, request->createResponder());
 		}
 		else {
 			LL_INFOS("LLMediaDataClient") << "NOT Sending request for " << *request << ": empty cap url!" << LL_ENDL;
@@ -494,18 +486,24 @@ LLMediaDataClient::QueueTimer::QueueTimer(F32 time, LLMediaDataClient *mdc)
 	mMDC->setIsRunning(true);
 }
 
-LLMediaDataClient::QueueTimer::~QueueTimer()
-{
-	LL_DEBUGS("LLMediaDataClient") << "~QueueTimer" << LL_ENDL;
-	mMDC->setIsRunning(false);
-	mMDC = NULL;
-}
-
 // virtual
 BOOL LLMediaDataClient::QueueTimer::tick()
 {
-	if (mMDC.isNull()) return TRUE;
-	return mMDC->processQueueTimer();
+	BOOL result = TRUE;
+	
+	if (!mMDC.isNull())
+	{
+		result = mMDC->processQueueTimer();
+	
+		if(result)
+		{
+			// This timer won't fire again.  
+			mMDC->setIsRunning(false);
+			mMDC = NULL;
+		}
+	}
+
+	return result;
 }
 
 
@@ -541,12 +539,10 @@ BOOL LLMediaDataClient::Responder::RetryTimer::tick()
 //////////////////////////////////////////////////////////////////////////////////////
 /*static*/U32 LLMediaDataClient::Request::sNum = 0;
 
-LLMediaDataClient::Request::Request(const char *cap_name, 
-									const LLSD& sd_payload,
+LLMediaDataClient::Request::Request(Type in_type,
 									LLMediaDataClientObject *obj, 
 									LLMediaDataClient *mdc)
-: mCapName(cap_name), 
-  mPayload(sd_payload), 
+: mType(in_type),
   mObject(obj),
   mNum(++sNum), 
   mRetryCount(0),
@@ -556,43 +552,16 @@ LLMediaDataClient::Request::Request(const char *cap_name,
 {
 }
 
-LLMediaDataClient::Request::~Request()
+const char *LLMediaDataClient::Request::getCapName() const
 {
-	LL_DEBUGS("LLMediaDataClient") << "~Request" << (*this) << LL_ENDL;
-	mMDC = NULL;
-	mObject = NULL;
+	return mMDC->getCapabilityName();
 }
 
-
 std::string LLMediaDataClient::Request::getCapability() const
 {
 	return getObject()->getCapabilityUrl(getCapName());
 }
 
-// Helper function to get the "type" of request, which just pokes around to
-// discover it.
-LLMediaDataClient::Request::Type LLMediaDataClient::Request::getType() const
-{
-	if (0 == strcmp(mCapName, "ObjectMediaNavigate"))
-	{
-		return NAVIGATE;
-	}
-	else if (0 == strcmp(mCapName, "ObjectMedia"))
-	{
-		const std::string &verb = mPayload["verb"];
-		if (verb == "GET")
-		{
-			return GET;
-		}
-		else if (verb == "UPDATE")
-		{
-			return UPDATE;
-		}
-	}
-	llassert(false);
-	return GET;
-}
-
 const char *LLMediaDataClient::Request::getTypeAsString() const
 {
 	Type t = getType();
@@ -617,19 +586,17 @@ const char *LLMediaDataClient::Request::getTypeAsString() const
 
 void LLMediaDataClient::Request::reEnqueue()
 {
-	// I sure hope this doesn't deref a bad pointer:
 	mMDC->enqueue(this);
 }
 
 F32 LLMediaDataClient::Request::getRetryTimerDelay() const
 {
-	return (mMDC == NULL) ? LLMediaDataClient::UNAVAILABLE_RETRY_TIMER_DELAY :
-	mMDC->mRetryTimerDelay; 
+	return mMDC->mRetryTimerDelay; 
 }
 
 U32 LLMediaDataClient::Request::getMaxNumRetries() const
 {
-	return (mMDC == NULL) ? LLMediaDataClient::MAX_RETRIES : mMDC->mMaxNumRetries;
+	return mMDC->mMaxNumRetries;
 }
 
 void LLMediaDataClient::Request::markSent(bool flag)
@@ -675,12 +642,6 @@ LLMediaDataClient::Responder::Responder(const request_ptr_t &request)
 {
 }
 
-LLMediaDataClient::Responder::~Responder()
-{
-	LL_DEBUGS("LLMediaDataClient") << "~Responder" << *(getRequest()) << LL_ENDL;
-	mRequest = NULL;
-}
-
 /*virtual*/
 void LLMediaDataClient::Responder::error(U32 status, const std::string& reason)
 {
@@ -722,11 +683,6 @@ void LLMediaDataClient::Responder::result(const LLSD& content)
 //
 //////////////////////////////////////////////////////////////////////////////////////
 
-LLMediaDataClient::Responder *LLObjectMediaDataClient::createResponder(const request_ptr_t &request) const
-{
-	return new LLObjectMediaDataClient::Responder(request);
-}
-
 const char *LLObjectMediaDataClient::getCapabilityName() const 
 {
 	return "ObjectMedia";
@@ -734,68 +690,97 @@ const char *LLObjectMediaDataClient::getCapabilityName() const
 
 void LLObjectMediaDataClient::fetchMedia(LLMediaDataClientObject *object)
 {
-	LLSD sd_payload;
-	sd_payload["verb"] = "GET";
-	sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID();
-	request(object, sd_payload);
+	// Create a get request and put it in the queue.
+	enqueue(new RequestGet(object, this));
 }
 
+LLObjectMediaDataClient::RequestGet::RequestGet(LLMediaDataClientObject *obj, LLMediaDataClient *mdc):
+	LLMediaDataClient::Request(LLMediaDataClient::Request::GET, obj, mdc)
+{
+}
+
+LLSD LLObjectMediaDataClient::RequestGet::getPayload() const
+{
+	LLSD result;
+	result["verb"] = "GET";
+	result[LLTextureEntry::OBJECT_ID_KEY] = mObject->getID();
+	
+	return result;
+}
+
+LLMediaDataClient::Responder *LLObjectMediaDataClient::RequestGet::createResponder()
+{
+	return new LLObjectMediaDataClient::Responder(this);
+}
+
+
 void LLObjectMediaDataClient::updateMedia(LLMediaDataClientObject *object)
 {
-	LLSD sd_payload;
-	sd_payload["verb"] = "UPDATE";
-	sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID();
+	// Create an update request and put it in the queue.
+	enqueue(new RequestUpdate(object, this));
+}
+
+LLObjectMediaDataClient::RequestUpdate::RequestUpdate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc):
+	LLMediaDataClient::Request(LLMediaDataClient::Request::UPDATE, obj, mdc)
+{
+}
+
+LLSD LLObjectMediaDataClient::RequestUpdate::getPayload() const
+{
+	LLSD result;
+	result["verb"] = "UPDATE";
+	result[LLTextureEntry::OBJECT_ID_KEY] = mObject->getID();
+
 	LLSD object_media_data;
 	int i = 0;
-	int end = object->getMediaDataCount();
+	int end = mObject->getMediaDataCount();
 	for ( ; i < end ; ++i) 
 	{
-		object_media_data.append(object->getMediaDataLLSD(i));
+		object_media_data.append(mObject->getMediaDataLLSD(i));
 	}
-	sd_payload[LLTextureEntry::OBJECT_MEDIA_DATA_KEY] = object_media_data;
-		
-	LL_DEBUGS("LLMediaDataClient") << "update media data: " << object->getID() << " " << ll_print_sd(sd_payload) << LL_ENDL;
 	
-	request(object, sd_payload);
+	result[LLTextureEntry::OBJECT_MEDIA_DATA_KEY] = object_media_data;
+	
+	return result;
+}
+
+LLMediaDataClient::Responder *LLObjectMediaDataClient::RequestUpdate::createResponder()
+{
+	// This just uses the base class's responder.
+	return new LLMediaDataClient::Responder(this);
 }
 
+
 /*virtual*/
 void LLObjectMediaDataClient::Responder::result(const LLSD& content)
 {
-	const LLMediaDataClient::Request::Type type = getRequest()->getType();
-	llassert(type == LLMediaDataClient::Request::GET || type == LLMediaDataClient::Request::UPDATE)
-	if (type == LLMediaDataClient::Request::GET)
+	// This responder is only used for GET requests, not UPDATE.
+
+	LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " GET returned: " << ll_print_sd(content) << LL_ENDL;
+	
+	// Look for an error
+	if (content.has("error"))
 	{
-		LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " GET returned: " << ll_print_sd(content) << LL_ENDL;
+		const LLSD &error = content["error"];
+		LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error getting media data for object: code=" << 
+			error["code"].asString() << ": " << error["message"].asString() << LL_ENDL;
 		
-		// Look for an error
-		if (content.has("error"))
-		{
-			const LLSD &error = content["error"];
-			LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error getting media data for object: code=" << 
-				error["code"].asString() << ": " << error["message"].asString() << LL_ENDL;
-			
-			// XXX Warn user?
-		}
-		else {
-			// Check the data
-			const LLUUID &object_id = content[LLTextureEntry::OBJECT_ID_KEY];
-			if (object_id != getRequest()->getObject()->getID()) 
-			{
-				// NOT good, wrong object id!!
-				LL_WARNS("LLMediaDataClient") << *(getRequest()) << " DROPPING response with wrong object id (" << object_id << ")" << LL_ENDL;
-				return;
-			}
-			
-			// Otherwise, update with object media data
-			getRequest()->getObject()->updateObjectMediaData(content[LLTextureEntry::OBJECT_MEDIA_DATA_KEY],
-															 content[LLTextureEntry::MEDIA_VERSION_KEY]);
-		}
+		// XXX Warn user?
 	}
-	else if (type == LLMediaDataClient::Request::UPDATE)
+	else 
 	{
-		// just do what our superclass does
-		LLMediaDataClient::Responder::result(content);
+		// Check the data
+		const LLUUID &object_id = content[LLTextureEntry::OBJECT_ID_KEY];
+		if (object_id != getRequest()->getObject()->getID()) 
+		{
+			// NOT good, wrong object id!!
+			LL_WARNS("LLMediaDataClient") << *(getRequest()) << " DROPPING response with wrong object id (" << object_id << ")" << LL_ENDL;
+			return;
+		}
+		
+		// Otherwise, update with object media data
+		getRequest()->getObject()->updateObjectMediaData(content[LLTextureEntry::OBJECT_MEDIA_DATA_KEY],
+														 content[LLTextureEntry::MEDIA_VERSION_KEY]);
 	}
 }
 
@@ -805,10 +790,6 @@ void LLObjectMediaDataClient::Responder::result(const LLSD& content)
 // Subclass of LLMediaDataClient for the ObjectMediaNavigate cap
 //
 //////////////////////////////////////////////////////////////////////////////////////
-LLMediaDataClient::Responder *LLObjectMediaNavigateClient::createResponder(const request_ptr_t &request) const
-{
-	return new LLObjectMediaNavigateClient::Responder(request);
-}
 
 const char *LLObjectMediaNavigateClient::getCapabilityName() const 
 {
@@ -817,14 +798,33 @@ const char *LLObjectMediaNavigateClient::getCapabilityName() const
 
 void LLObjectMediaNavigateClient::navigate(LLMediaDataClientObject *object, U8 texture_index, const std::string &url)
 {
-	LLSD sd_payload;
-	sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID();
-	sd_payload[LLMediaEntry::CURRENT_URL_KEY] = url;
-	sd_payload[LLTextureEntry::TEXTURE_INDEX_KEY] = (LLSD::Integer)texture_index;
+
+//	LL_INFOS("LLMediaDataClient") << "navigate() initiated: " << ll_print_sd(sd_payload) << LL_ENDL;
 	
-	LL_INFOS("LLMediaDataClient") << "navigate() initiated: " << ll_print_sd(sd_payload) << LL_ENDL;
+	// Create a get request and put it in the queue.
+	enqueue(new RequestNavigate(object, this, texture_index, url));
+}
+
+LLObjectMediaNavigateClient::RequestNavigate::RequestNavigate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc, U8 texture_index, const std::string &url):
+	LLMediaDataClient::Request(LLMediaDataClient::Request::NAVIGATE, obj, mdc),
+	mTextureIndex(texture_index),
+	mURL(url)
+{
+}
+
+LLSD LLObjectMediaNavigateClient::RequestNavigate::getPayload() const
+{
+	LLSD result;
+	result[LLTextureEntry::OBJECT_ID_KEY] = mObject->getID();
+	result[LLMediaEntry::CURRENT_URL_KEY] = mURL;
+	result[LLTextureEntry::TEXTURE_INDEX_KEY] = (LLSD::Integer)mTextureIndex;
 	
-	request(object, sd_payload);
+	return result;
+}
+
+LLMediaDataClient::Responder *LLObjectMediaNavigateClient::RequestNavigate::createResponder()
+{
+	return new LLObjectMediaNavigateClient::Responder(this);
 }
 
 /*virtual*/
diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h
index 3e86c52c63f..9504a0a2a91 100755
--- a/indra/newview/llmediadataclient.h
+++ b/indra/newview/llmediadataclient.h
@@ -93,9 +93,6 @@ class LLMediaDataClient : public LLRefCount
 					  U32 max_sorted_queue_size = MAX_SORTED_QUEUE_SIZE,
 					  U32 max_round_robin_queue_size = MAX_ROUND_ROBIN_QUEUE_SIZE);
 	
-	// Make the request
-	void request(const LLMediaDataClientObject::ptr_t &object, const LLSD &payload);
-
 	F32 getRetryTimerDelay() const { return mRetryTimerDelay; }
 	
 	// Returns true iff the queue is empty
@@ -114,10 +111,17 @@ class LLMediaDataClient : public LLRefCount
 	// Destructor
 	virtual ~LLMediaDataClient(); // use unref
     
-	// Request
+	class Responder;
+	
+	// Request (pure virtual base class for requests in the queue)
 	class Request : public LLRefCount
 	{
 	public:
+		// Subclasses must implement this to build a payload for their request type.
+		virtual LLSD getPayload() const = 0;
+		// and must create the correct type of responder.
+		virtual Responder *createResponder() = 0;
+
         enum Type {
             GET,
             UPDATE,
@@ -125,20 +129,22 @@ class LLMediaDataClient : public LLRefCount
 			ANY
         };
         
-		Request(const char *cap_name, const LLSD& sd_payload, LLMediaDataClientObject *obj, LLMediaDataClient *mdc);
-		const char *getCapName() const { return mCapName; }
-		const LLSD &getPayload() const { return mPayload; }
+	protected:
+		// The only way to create one of these is through a subclass.
+		Request(Type in_type, LLMediaDataClientObject *obj, LLMediaDataClient *mdc);
+	public:
 		LLMediaDataClientObject *getObject() const { return mObject; }
 
         U32 getNum() const { return mNum; }
-
 		U32 getRetryCount() const { return mRetryCount; }
-		void incRetryCount() { mRetryCount++; }
+		void incRetryCount() { mRetryCount++; };
+        Type getType() const { return mType; };
+		bool isMarkedSent() const { return mMarkedSent; }
+		F64 getScore() const { return mScore; }
 		
 		// Note: may return empty string!
 		std::string getCapability() const;
-        
-        Type getType() const;
+		const char *getCapName() const;
 		const char *getTypeAsString() const;
 		
 		// Re-enqueue thyself
@@ -148,21 +154,16 @@ class LLMediaDataClient : public LLRefCount
 		U32 getMaxNumRetries() const;
 		
 		bool isNew() const { return mObject.notNull() ? mObject->isNew() : false; }
+		bool isObjectValid() const { return mObject.notNull() ? (!mObject->isDead()) : false; }
 		void markSent(bool flag);
-		bool isMarkedSent() const { return mMarkedSent; }
 		void updateScore();
-		F64 getScore() const { return mScore; }
 		
-	public:
 		friend std::ostream& operator<<(std::ostream &s, const Request &q);
-		
-    protected:
-        virtual ~Request(); // use unref();
-        
-	private:
-		const char *mCapName;
-		LLSD mPayload;
+
+	protected:
 		LLMediaDataClientObject::ptr_t mObject;
+	private:
+		Type mType;
 		// Simple tracking
 		U32 mNum;
 		static U32 sNum;
@@ -187,9 +188,6 @@ class LLMediaDataClient : public LLRefCount
 
 		request_ptr_t &getRequest() { return mRequest; }
 
-    protected:
-		virtual ~Responder();
-        
 	private:
 
 		class RetryTimer : public LLEventTimer
@@ -207,20 +205,17 @@ class LLMediaDataClient : public LLRefCount
 	
 protected:
 
-	// Subclasses must override this factory method to return a new responder
-	virtual Responder *createResponder(const request_ptr_t &request) const = 0;
-	
 	// Subclasses must override to return a cap name
 	virtual const char *getCapabilityName() const = 0;
 	
 	virtual bool request_needs_purge(request_ptr_t request);
 	virtual void sortQueue();
 	virtual void serviceQueue();
+
+	virtual void enqueue(Request*);
 	
 private:
 	typedef std::list<request_ptr_t> request_queue_t;
-		
-	void enqueue(Request*);
 	
 	// Return whether the given object is/was in the queue
 	static LLMediaDataClient::request_ptr_t findOrRemove(request_queue_t &queue, const LLMediaDataClientObject::ptr_t &obj, bool remove, Request::Type type);
@@ -237,8 +232,6 @@ class LLMediaDataClient : public LLRefCount
 	public:
 		QueueTimer(F32 time, LLMediaDataClient *mdc);
 		virtual BOOL tick();
-    protected:
-		virtual ~QueueTimer();
 	private:
 		// back-pointer
 		LLPointer<LLMediaDataClient> mMDC;
@@ -280,11 +273,24 @@ class LLObjectMediaDataClient : public LLMediaDataClient
     
 	void fetchMedia(LLMediaDataClientObject *object); 
     void updateMedia(LLMediaDataClientObject *object);
-    
+
+	class RequestGet: public Request
+	{
+	public:
+		RequestGet(LLMediaDataClientObject *obj, LLMediaDataClient *mdc);
+		/*virtual*/ LLSD getPayload() const;
+		/*virtual*/ Responder *createResponder();
+	};
+
+	class RequestUpdate: public Request
+	{
+	public:
+		RequestUpdate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc);
+		/*virtual*/ LLSD getPayload() const;
+		/*virtual*/ Responder *createResponder();
+	};
+	    
 protected:
-	// Subclasses must override this factory method to return a new responder
-	virtual Responder *createResponder(const request_ptr_t &request) const;
-	
 	// Subclasses must override to return a cap name
 	virtual const char *getCapabilityName() const;
     
@@ -315,11 +321,19 @@ class LLObjectMediaNavigateClient : public LLMediaDataClient
     virtual ~LLObjectMediaNavigateClient() {}
     
     void navigate(LLMediaDataClientObject *object, U8 texture_index, const std::string &url);
+
+	class RequestNavigate: public Request
+	{
+	public:
+		RequestNavigate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc, U8 texture_index, const std::string &url);
+		/*virtual*/ LLSD getPayload() const;
+		/*virtual*/ Responder *createResponder();
+	private:
+		U8 mTextureIndex;
+		std::string mURL;
+	};
     
 protected:
-	// Subclasses must override this factory method to return a new responder
-	virtual Responder *createResponder(const request_ptr_t &request) const;
-	
 	// Subclasses must override to return a cap name
 	virtual const char *getCapabilityName() const;
 
-- 
GitLab


From 6cc6f816780e64c5fb1e17a22fb5e473e75efe69 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 23 Jul 2010 22:07:15 -0700
Subject: [PATCH 540/683] first pass ui rendering performance improvements

---
 indra/llrender/llfontfreetype.cpp |   6 +-
 indra/llrender/llfontfreetype.h   |   4 +-
 indra/llrender/llfontgl.cpp       | 195 +++++++++++++++++-------------
 indra/llrender/llfontgl.h         |   4 +-
 indra/llrender/llrender.cpp       |  97 ++++++++++++---
 indra/llrender/llrender.h         |   8 +-
 indra/llui/lllocalcliprect.cpp    |  42 +------
 indra/llui/lllocalcliprect.h      |  26 +++-
 indra/llui/lltextbase.cpp         |  15 ++-
 9 files changed, 242 insertions(+), 155 deletions(-)

diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp
index a86bbbffff3..0a16b5120ae 100644
--- a/indra/llrender/llfontfreetype.cpp
+++ b/indra/llrender/llfontfreetype.cpp
@@ -259,10 +259,10 @@ F32 LLFontFreetype::getXAdvance(llwchar wch) const
 	}
 	else
 	{
-		gi = get_if_there(mCharGlyphInfoMap, (llwchar)0, (LLFontGlyphInfo*)NULL);
-		if (gi)
+		char_glyph_info_map_t::iterator found_it = mCharGlyphInfoMap.find((llwchar)0);
+		if (found_it != mCharGlyphInfoMap.end())
 		{
-			return gi->mXAdvance;
+			return found_it->second->mXAdvance;
 		}
 	}
 
diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h
index f60d09316dc..4b4a0bb189e 100644
--- a/indra/llrender/llfontfreetype.h
+++ b/indra/llrender/llfontfreetype.h
@@ -33,7 +33,7 @@
 #ifndef LL_LLFONTFREETYPE_H
 #define LL_LLFONTFREETYPE_H
 
-#include <map>
+#include <boost/unordered_map.hpp>
 #include "llpointer.h"
 #include "llstl.h"
 
@@ -170,7 +170,7 @@ class LLFontFreetype : public LLRefCount
 
 	BOOL mValid;
 
-	typedef std::map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t;
+	typedef boost::unordered_map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t;
 	mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap
 
 	mutable LLPointer<LLFontBitmapCache> mFontBitmapCachep;
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 6eb5e0eff41..c0297eae3e5 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -181,12 +181,17 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 
 	gGL.loadUIIdentity();
 	
-	gGL.translateUI(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
+	//gGL.translateUI(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
 
 	// this code snaps the text origin to a pixel grid to start with
-	F32 pixel_offset_x = llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
-	F32 pixel_offset_y = llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
-	gGL.translateUI(-pixel_offset_x, -pixel_offset_y, 0.f);
+	//F32 pixel_offset_x = llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
+	//F32 pixel_offset_y = llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
+	//gGL.translateUI(-pixel_offset_x, -pixel_offset_y, 0.f);
+
+	LLVector2 origin(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY));
+	// snap the text origin to a pixel grid to start with
+	origin.mV[VX] -= llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
+	origin.mV[VY] -= llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
 
 	LLFastTimer t(FTM_RENDER_FONTS);
 
@@ -210,8 +215,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
  	// Not guaranteed to be set correctly
 	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 	
-	cur_x = ((F32)x * sScaleX);
-	cur_y = ((F32)y * sScaleY);
+	cur_x = ((F32)x * sScaleX) + origin.mV[VX];
+	cur_y = ((F32)y * sScaleY) + origin.mV[VY];
 
 	// Offset y by vertical alignment.
 	switch (valign)
@@ -276,6 +281,12 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 
 	const LLFontGlyphInfo* next_glyph = NULL;
 
+	const S32 GLYPH_BATCH_SIZE = 30;
+	LLVector3 vertices[GLYPH_BATCH_SIZE * 4];
+	LLVector2 uvs[GLYPH_BATCH_SIZE * 4];
+	LLColor4U colors[GLYPH_BATCH_SIZE * 4];
+
+	S32 glyph_count = 0;
 	for (i = begin_offset; i < begin_offset + length; i++)
 	{
 		llwchar wch = wstr[i];
@@ -313,7 +324,18 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 				    llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth,
 				    llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight);
 		
-		drawGlyph(screen_rect, uv_rect, color, style_to_add, shadow, drop_shadow_strength);
+		if (glyph_count >= GLYPH_BATCH_SIZE)
+		{
+			gGL.begin(LLRender::QUADS);
+			{
+				gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4);
+			}
+			gGL.end();
+
+			glyph_count = 0;
+		}
+
+		drawGlyph(glyph_count, vertices, uvs, colors, screen_rect, uv_rect, color, style_to_add, shadow, drop_shadow_strength);
 
 		chars_drawn++;
 		cur_x += fgi->mXAdvance;
@@ -338,11 +360,19 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 		cur_render_y = cur_y;
 	}
 
+	gGL.begin(LLRender::QUADS);
+	{
+		gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4);
+	}
+	gGL.end();
+
+
 	if (right_x)
 	{
 		*right_x = cur_x / sScaleX;
 	}
 
+	//FIXME: add underline as glyph?
 	if (style_to_add & UNDERLINE)
 	{
 		F32 descender = mFontFreetype->getDescenderHeight();
@@ -1091,95 +1121,96 @@ LLFontGL &LLFontGL::operator=(const LLFontGL &source)
 	return *this;
 }
 
-void LLFontGL::renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const
+void LLFontGL::renderQuad(LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, F32 slant_amt) const
 {
-	gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
-	gGL.vertex2f(llfont_round_x(screen_rect.mRight), 
-				llfont_round_y(screen_rect.mTop));
-
-	gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
-	gGL.vertex2f(llfont_round_x(screen_rect.mLeft), 
-				llfont_round_y(screen_rect.mTop));
-
-	gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
-	gGL.vertex2f(llfont_round_x(screen_rect.mLeft + slant_amt), 
-				llfont_round_y(screen_rect.mBottom));
-
-	gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
-	gGL.vertex2f(llfont_round_x(screen_rect.mRight + slant_amt), 
-				llfont_round_y(screen_rect.mBottom));
+	S32 index = 0;
+
+	vertex_out[index] = LLVector3(llfont_round_x(screen_rect.mRight), llfont_round_y(screen_rect.mTop), 0.f);
+	uv_out[index] = LLVector2(uv_rect.mRight, uv_rect.mTop);
+	colors_out[index] = color;
+	index++;
+
+	vertex_out[index] = LLVector3(llfont_round_x(screen_rect.mLeft), llfont_round_y(screen_rect.mTop), 0.f);
+	uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop);
+	colors_out[index] = color;
+	index++;
+
+	vertex_out[index] = LLVector3(llfont_round_x(screen_rect.mLeft), llfont_round_y(screen_rect.mBottom), 0.f);
+	uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mBottom);
+	colors_out[index] = color;
+	index++;
+
+	vertex_out[index] = LLVector3(llfont_round_x(screen_rect.mRight), llfont_round_y(screen_rect.mBottom), 0.f);
+	uv_out[index] = LLVector2(uv_rect.mRight, uv_rect.mBottom);
+	colors_out[index] = color;
 }
 
-void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4& color, U8 style, ShadowType shadow, F32 drop_shadow_strength) const
+//FIXME: do colors out as well
+void LLFontGL::drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, U8 style, ShadowType shadow, F32 drop_shadow_strength) const
 {
 	F32 slant_offset;
 	slant_offset = ((style & ITALIC) ? ( -mFontFreetype->getAscenderHeight() * 0.2f) : 0.f);
 
-	gGL.begin(LLRender::QUADS);
+	//FIXME: bold and drop shadow are mutually exclusive only for convenience
+	//Allow both when we need them.
+	if (style & BOLD)
 	{
-		//FIXME: bold and drop shadow are mutually exclusive only for convenience
-		//Allow both when we need them.
-		if (style & BOLD)
+		for (S32 pass = 0; pass < 2; pass++)
 		{
-			gGL.color4fv(color.mV);
-			for (S32 pass = 0; pass < 2; pass++)
-			{
-				LLRectf screen_rect_offset = screen_rect;
+			LLRectf screen_rect_offset = screen_rect;
 
-				screen_rect_offset.translate((F32)(pass * BOLD_OFFSET), 0.f);
-				renderQuad(screen_rect_offset, uv_rect, slant_offset);
-			}
+			screen_rect_offset.translate((F32)(pass * BOLD_OFFSET), 0.f);
+			renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_offset, uv_rect, color, slant_offset);
+			glyph_count++;
 		}
-		else if (shadow == DROP_SHADOW_SOFT)
+	}
+	else if (shadow == DROP_SHADOW_SOFT)
+	{
+		LLColor4U shadow_color = LLFontGL::sShadowColor;
+		shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH;
+		for (S32 pass = 0; pass < 5; pass++)
 		{
-			LLColor4 shadow_color = LLFontGL::sShadowColor;
-			shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH;
-			gGL.color4fv(shadow_color.mV);
-			for (S32 pass = 0; pass < 5; pass++)
-			{
-				LLRectf screen_rect_offset = screen_rect;
+			LLRectf screen_rect_offset = screen_rect;
 
-				switch(pass)
-				{
-				case 0:
-					screen_rect_offset.translate(-1.f, -1.f);
-					break;
-				case 1:
-					screen_rect_offset.translate(1.f, -1.f);
-					break;
-				case 2:
-					screen_rect_offset.translate(1.f, 1.f);
-					break;
-				case 3:
-					screen_rect_offset.translate(-1.f, 1.f);
-					break;
-				case 4:
-					screen_rect_offset.translate(0, -2.f);
-					break;
-				}
-			
-				renderQuad(screen_rect_offset, uv_rect, slant_offset);
+			switch(pass)
+			{
+			case 0:
+				screen_rect_offset.translate(-1.f, -1.f);
+				break;
+			case 1:
+				screen_rect_offset.translate(1.f, -1.f);
+				break;
+			case 2:
+				screen_rect_offset.translate(1.f, 1.f);
+				break;
+			case 3:
+				screen_rect_offset.translate(-1.f, 1.f);
+				break;
+			case 4:
+				screen_rect_offset.translate(0, -2.f);
+				break;
 			}
-			gGL.color4fv(color.mV);
-			renderQuad(screen_rect, uv_rect, slant_offset);
-		}
-		else if (shadow == DROP_SHADOW)
-		{
-			LLColor4 shadow_color = LLFontGL::sShadowColor;
-			shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength;
-			gGL.color4fv(shadow_color.mV);
-			LLRectf screen_rect_shadow = screen_rect;
-			screen_rect_shadow.translate(1.f, -1.f);
-			renderQuad(screen_rect_shadow, uv_rect, slant_offset);
-			gGL.color4fv(color.mV);
-			renderQuad(screen_rect, uv_rect, slant_offset);
-		}
-		else // normal rendering
-		{
-			gGL.color4fv(color.mV);
-			renderQuad(screen_rect, uv_rect, slant_offset);
+		
+			renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_offset, uv_rect, shadow_color, slant_offset);
+			glyph_count++;
 		}
-
+		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
+		glyph_count++;
+	}
+	else if (shadow == DROP_SHADOW)
+	{
+		LLColor4 shadow_color = LLFontGL::sShadowColor;
+		shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength;
+		LLRectf screen_rect_shadow = screen_rect;
+		screen_rect_shadow.translate(1.f, -1.f);
+		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_shadow, uv_rect, shadow_color, slant_offset);
+		glyph_count++;
+		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
+		glyph_count++;
+	}
+	else // normal rendering
+	{
+		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
+		glyph_count++;
 	}
-	gGL.end();
 }
diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h
index f29ac5165c5..8bc45fbf74c 100644
--- a/indra/llrender/llfontgl.h
+++ b/indra/llrender/llfontgl.h
@@ -217,8 +217,8 @@ class LLFontGL
 	LLFontDescriptor mFontDescriptor;
 	LLPointer<LLFontFreetype> mFontFreetype;
 
-	void renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const;
-	void drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4& color, U8 style, ShadowType shadow, F32 drop_shadow_fade) const;
+	void renderQuad(LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, F32 slant_amt) const;
+	void drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, U8 style, ShadowType shadow, F32 drop_shadow_fade) const;
 
 	// Registry holds all instantiated fonts.
 	static LLFontRegistry* sFontRegistry;
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 5597b23c69f..64238b2008d 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -851,9 +851,9 @@ void LLRender::translateUI(F32 x, F32 y, F32 z)
 		llerrs << "Need to push a UI translation frame before offsetting" << llendl;
 	}
 
-	mUIOffset.front().mV[0] += x;
-	mUIOffset.front().mV[1] += y;
-	mUIOffset.front().mV[2] += z;
+	mUIOffset.back().mV[0] += x;
+	mUIOffset.back().mV[1] += y;
+	mUIOffset.back().mV[2] += z;
 }
 
 void LLRender::scaleUI(F32 x, F32 y, F32 z)
@@ -863,27 +863,27 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z)
 		llerrs << "Need to push a UI transformation frame before scaling." << llendl;
 	}
 
-	mUIScale.front().scaleVec(LLVector3(x,y,z));
+	mUIScale.back().scaleVec(LLVector3(x,y,z));
 }
 
 void LLRender::pushUIMatrix()
 {
 	if (mUIOffset.empty())
 	{
-		mUIOffset.push_front(LLVector3(0,0,0));
+		mUIOffset.push_back(LLVector3(0,0,0));
 	}
 	else
 	{
-		mUIOffset.push_front(mUIOffset.front());
+		mUIOffset.push_back(mUIOffset.back());
 	}
 	
 	if (mUIScale.empty())
 	{
-		mUIScale.push_front(LLVector3(1,1,1));
+		mUIScale.push_back(LLVector3(1,1,1));
 	}
 	else
 	{
-		mUIScale.push_front(mUIScale.front());
+		mUIScale.push_back(mUIScale.back());
 	}
 }
 
@@ -893,8 +893,8 @@ void LLRender::popUIMatrix()
 	{
 		llerrs << "UI offset stack blown." << llendl;
 	}
-	mUIOffset.pop_front();
-	mUIScale.pop_front();
+	mUIOffset.pop_back();
+	mUIScale.pop_back();
 }
 
 LLVector3 LLRender::getUITranslation()
@@ -903,7 +903,7 @@ LLVector3 LLRender::getUITranslation()
 	{
 		llerrs << "UI offset stack empty." << llendl;
 	}
-	return mUIOffset.front();
+	return mUIOffset.back();
 }
 
 LLVector3 LLRender::getUIScale()
@@ -912,7 +912,7 @@ LLVector3 LLRender::getUIScale()
 	{
 		llerrs << "UI scale stack empty." << llendl;
 	}
-	return mUIScale.front();
+	return mUIScale.back();
 }
 
 
@@ -922,8 +922,8 @@ void LLRender::loadUIIdentity()
 	{
 		llerrs << "Need to push UI translation frame before clearing offset." << llendl;
 	}
-	mUIOffset.front().setVec(0,0,0);
-	mUIScale.front().setVec(1,1,1);
+	mUIOffset.back().setVec(0,0,0);
+	mUIScale.back().setVec(1,1,1);
 }
 
 void LLRender::setColorMask(bool writeColor, bool writeAlpha)
@@ -1210,18 +1210,79 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
 	}
 	else
 	{
-		LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.front()).scaledVec(mUIScale.front());
+		LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back());
 		mVerticesp[mCount] = vert;
 	}
 
 	mCount++;
-	if (mCount < 4096)
+	mVerticesp[mCount] = mVerticesp[mCount-1];
+	mColorsp[mCount] = mColorsp[mCount-1];
+	mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
+}
+
+void LLRender::vertexBatchPreTransformed(LLVector3* verts, S32 vert_count)
+{
+	if (mCount + vert_count > 4094)
 	{
-		mVerticesp[mCount] = mVerticesp[mCount-1];
-		mColorsp[mCount] = mColorsp[mCount-1];
+		//	llwarns << "GL immediate mode overflow.  Some geometry not drawn." << llendl;
+		return;
+	}
+
+	for (S32 i = 0; i < vert_count; i++)
+	{
+		mVerticesp[mCount] = verts[i];
+
+		mCount++;
 		mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
+		mColorsp[mCount] = mColorsp[mCount-1];
 	}
+
+	mVerticesp[mCount] = mVerticesp[mCount-1];
 }
+
+void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count)
+{
+	if (mCount + vert_count > 4094)
+	{
+		//	llwarns << "GL immediate mode overflow.  Some geometry not drawn." << llendl;
+		return;
+	}
+
+	for (S32 i = 0; i < vert_count; i++)
+	{
+		mVerticesp[mCount] = verts[i];
+		mTexcoordsp[mCount] = uvs[i];
+
+		mCount++;
+		mColorsp[mCount] = mColorsp[mCount-1];
+	}
+
+	mVerticesp[mCount] = mVerticesp[mCount-1];
+	mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
+}
+
+void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count)
+{
+	if (mCount + vert_count > 4094)
+	{
+		//	llwarns << "GL immediate mode overflow.  Some geometry not drawn." << llendl;
+		return;
+	}
+
+	for (S32 i = 0; i < vert_count; i++)
+	{
+		mVerticesp[mCount] = verts[i];
+		mTexcoordsp[mCount] = uvs[i];
+		mColorsp[mCount] = colors[i];
+
+		mCount++;
+	}
+
+	mVerticesp[mCount] = mVerticesp[mCount-1];
+	mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
+	mColorsp[mCount] = mColorsp[mCount-1];
+}
+
 void LLRender::vertex2i(const GLint& x, const GLint& y)
 {
 	vertex3f((GLfloat) x, (GLfloat) y, 0);	
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index f6c87aa1dbc..0fa503182e4 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -317,6 +317,10 @@ class LLRender
 	void color3fv(const GLfloat* c);
 	void color4ubv(const GLubyte* c);
 
+	void vertexBatchPreTransformed(LLVector3* verts, S32 vert_count);
+	void vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count);
+	void vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLColor4U*, S32 vert_count);
+
 	void setColorMask(bool writeColor, bool writeAlpha);
 	void setColorMask(bool writeColorR, bool writeColorG, bool writeColorB, bool writeAlpha);
 	void setSceneBlendType(eBlendType type);
@@ -373,8 +377,8 @@ class LLRender
 
 	F32				mMaxAnisotropy;
 
-	std::list<LLVector3> mUIOffset;
-	std::list<LLVector3> mUIScale;
+	std::vector<LLVector3> mUIOffset;
+	std::vector<LLVector3> mUIScale;
 
 };
 
diff --git a/indra/llui/lllocalcliprect.cpp b/indra/llui/lllocalcliprect.cpp
index 43c21e250ce..55329f64e45 100644
--- a/indra/llui/lllocalcliprect.cpp
+++ b/indra/llui/lllocalcliprect.cpp
@@ -33,33 +33,8 @@
 #include "lllocalcliprect.h"
 
 #include "llfontgl.h"
-#include "llgl.h"
 #include "llui.h"
 
-#include <stack>
-
-//---------------------------------------------------------------------------
-// LLScreenClipRect
-// implementation class in screen space
-//---------------------------------------------------------------------------
-class LLScreenClipRect
-{
-public:
-	LLScreenClipRect(const LLRect& rect, BOOL enabled = TRUE);
-	virtual ~LLScreenClipRect();
-
-private:
-	static void pushClipRect(const LLRect& rect);
-	static void popClipRect();
-	static void updateScissorRegion();
-
-private:
-	LLGLState		mScissorState;
-	BOOL			mEnabled;
-
-	static std::stack<LLRect> sClipRectStack;
-};
-
 /*static*/ std::stack<LLRect> LLScreenClipRect::sClipRectStack;
 
 
@@ -131,16 +106,11 @@ void LLScreenClipRect::updateScissorRegion()
 // LLLocalClipRect
 //---------------------------------------------------------------------------
 LLLocalClipRect::LLLocalClipRect(const LLRect& rect, BOOL enabled /* = TRUE */)
-{
-	LLRect screen(rect.mLeft + LLFontGL::sCurOrigin.mX, 
-		rect.mTop + LLFontGL::sCurOrigin.mY, 
-		rect.mRight + LLFontGL::sCurOrigin.mX, 
-		rect.mBottom + LLFontGL::sCurOrigin.mY);
-	mScreenClipRect = new LLScreenClipRect(screen, enabled);
-}
+:	LLScreenClipRect(LLRect(rect.mLeft + LLFontGL::sCurOrigin.mX, 
+					rect.mTop + LLFontGL::sCurOrigin.mY, 
+					rect.mRight + LLFontGL::sCurOrigin.mX, 
+					rect.mBottom + LLFontGL::sCurOrigin.mY), enabled)
+{}
 
 LLLocalClipRect::~LLLocalClipRect()
-{
-	delete mScreenClipRect;
-	mScreenClipRect = NULL;
-}
+{}
diff --git a/indra/llui/lllocalcliprect.h b/indra/llui/lllocalcliprect.h
index cd0c55ca721..36413f14960 100644
--- a/indra/llui/lllocalcliprect.h
+++ b/indra/llui/lllocalcliprect.h
@@ -31,7 +31,9 @@
 #ifndef LLLOCALCLIPRECT_H
 #define LLLOCALCLIPRECT_H
 
+#include "llgl.h"
 #include "llrect.h"		// can't forward declare, it's templated
+#include <stack>
 
 // Clip rendering to a specific rectangle using GL scissor
 // Just create one of these on the stack:
@@ -39,15 +41,29 @@
 //     LLLocalClipRect(rect);
 //     draw();
 // }
-class LLLocalClipRect
+class LLScreenClipRect
 {
 public:
-	LLLocalClipRect(const LLRect& rect, BOOL enabled = TRUE);
-	~LLLocalClipRect();
+	LLScreenClipRect(const LLRect& rect, BOOL enabled = TRUE);
+	virtual ~LLScreenClipRect();
+
+private:
+	static void pushClipRect(const LLRect& rect);
+	static void popClipRect();
+	static void updateScissorRegion();
 
 private:
-	// implementation class
-	class LLScreenClipRect* mScreenClipRect;
+	LLGLState		mScissorState;
+	BOOL			mEnabled;
+
+	static std::stack<LLRect> sClipRectStack;
+};
+
+class LLLocalClipRect : public LLScreenClipRect
+{
+public:
+	LLLocalClipRect(const LLRect& rect, BOOL enabled = TRUE);
+	~LLLocalClipRect();
 };
 
 #endif
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 617c496d6a1..0587b3f48df 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1012,22 +1012,25 @@ void LLTextBase::draw()
 	if (mBGVisible)
 	{
 		// clip background rect against extents, if we support scrolling
-		LLLocalClipRect clip(doc_rect, mScroller != NULL);
-
+		LLRect bg_rect = mVisibleTextRect;
+		if (mScroller)
+		{
+			bg_rect.intersectWith(doc_rect);
+		}
 		LLColor4 bg_color = mReadOnly 
 							? mReadOnlyBgColor.get()
 							: hasFocus() 
 								? mFocusBgColor.get() 
 								: mWriteableBgColor.get();
-		gl_rect_2d(mVisibleTextRect, bg_color, TRUE);
+		gl_rect_2d(doc_rect, bg_color, TRUE);
 	}
 
 	// draw document view
 	LLUICtrl::draw();
 
 	{
-		// only clip if we support scrolling (mScroller != NULL)
-		LLLocalClipRect clip(doc_rect, mScroller != NULL);
+		// only clip if we support scrolling or have word wrap turned off
+		LLLocalClipRect clip(doc_rect, !getWordWrap() || mScroller != NULL);
 		drawSelectionBackground();
 		drawText();
 		drawCursor();
@@ -1495,6 +1498,7 @@ LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index)
 	// when there are no segments, we return the end iterator, which must be checked by caller
 	if (mSegments.size() <= 1) { return mSegments.begin(); }
 
+	//FIXME: avoid operator new somehow (without running into refcount problems)
 	segment_set_t::iterator it = mSegments.upper_bound(new LLIndexSegment(index));
 	return it;
 }
@@ -2269,6 +2273,7 @@ void LLTextBase::updateRects()
 	// allow horizontal scrolling?
 	// if so, use entire width of text contents
 	// otherwise, stop at width of mVisibleTextRect
+	//FIXME: consider use of getWordWrap() instead
 	doc_rect.mRight = mScroller 
 		? llmax(mVisibleTextRect.getWidth(), mTextBoundingRect.mRight)
 		: mVisibleTextRect.getWidth();
-- 
GitLab


From 68a718c14093f07f14aba3ac3e97ac5412bd5f68 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 26 Jul 2010 14:01:45 +0100
Subject: [PATCH 541/683] Conflict resolution.  Erring on the side of
 viewer-release.

---
 indra/newview/llcofwearables.cpp      |   8 +-
 indra/newview/llpaneloutfitedit.cpp   | 247 +++-----------------------
 indra/newview/llpaneloutfitedit.h     |  13 +-
 indra/newview/llwearableitemslist.cpp |  33 +---
 indra/newview/llwearableitemslist.h   |  26 ---
 5 files changed, 28 insertions(+), 299 deletions(-)

diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index 01932949e43..f356a04fa4b 100644
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -163,7 +163,7 @@ class CofClothingContextMenu : public CofContextMenu
 	}
 
 protected:
-	static void replaceWearable(const LLUUID& item_id)
+	static void replaceWearable()
 	{
 		// *TODO: Most probable that accessing to LLPanelOutfitEdit instance should be:
 		// LLSideTray::getInstance()->getSidepanelAppearance()->getPanelOutfitEdit()
@@ -175,7 +175,7 @@ class CofClothingContextMenu : public CofContextMenu
 								"panel_outfit_edit"));
 		if (panel_outfit_edit != NULL)
 		{
-			panel_outfit_edit->onReplaceMenuItemClicked(item_id);
+			panel_outfit_edit->showAddWearablesPanel(true);
 		}
 	}
 
@@ -187,7 +187,7 @@ class CofClothingContextMenu : public CofContextMenu
 		functor_t take_off = boost::bind(&LLAppearanceMgr::removeItemFromAvatar, LLAppearanceMgr::getInstance(), _1);
 
 		registrar.add("Clothing.TakeOff", boost::bind(handleMultiple, take_off, mUUIDs));
-		registrar.add("Clothing.Replace", boost::bind(replaceWearable, selected_id));
+		registrar.add("Clothing.Replace", boost::bind(replaceWearable));
 		registrar.add("Clothing.Edit", boost::bind(LLAgentWearables::editWearable, selected_id));
 		registrar.add("Clothing.Create", boost::bind(&CofClothingContextMenu::createNew, this, selected_id));
 
@@ -244,7 +244,7 @@ class CofBodyPartContextMenu : public CofContextMenu
 		// *HACK* need to pass pointer to LLPanelOutfitEdit instead of LLSideTray::getInstance()->getPanel().
 		// LLSideTray::getInstance()->getPanel() is rather slow variant
 		LLPanelOutfitEdit* panel_oe = dynamic_cast<LLPanelOutfitEdit*>(LLSideTray::getInstance()->getPanel("panel_outfit_edit"));
-		registrar.add("BodyPart.Replace", boost::bind(&LLPanelOutfitEdit::onReplaceMenuItemClicked, panel_oe, selected_id));
+		registrar.add("BodyPart.Replace", boost::bind(&LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked, panel_oe, selected_id));
 		registrar.add("BodyPart.Edit", boost::bind(LLAgentWearables::editWearable, selected_id));
 		registrar.add("BodyPart.Create", boost::bind(&CofBodyPartContextMenu::createNew, this, selected_id));
 
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 6c6f8300001..38f637cabf3 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -42,8 +42,8 @@
 #include "lloutfitobserver.h"
 #include "llcofwearables.h"
 #include "llfilteredwearablelist.h"
-#include "llfolderviewitem.h"
 #include "llinventory.h"
+#include "llinventoryitemslist.h"
 #include "llviewercontrol.h"
 #include "llui.h"
 #include "llfloater.h"
@@ -85,11 +85,6 @@ const U64 ALL_ITEMS_MASK = WEARABLE_MASK | ATTACHMENT_MASK;
 
 static const std::string REVERT_BTN("revert_btn");
 
-
-///////////////////////////////////////////////////////////////////////////////
-// LLShopURLDispatcher
-///////////////////////////////////////////////////////////////////////////////
-
 class LLShopURLDispatcher
 {
 public:
@@ -149,10 +144,6 @@ std::string LLShopURLDispatcher::resolveURL(LLAssetType::EType asset_type, ESex
 	return gSavedSettings.getString(setting_name);
 }
 
-///////////////////////////////////////////////////////////////////////////////
-// LLPanelOutfitEditGearMenu
-///////////////////////////////////////////////////////////////////////////////
-
 class LLPanelOutfitEditGearMenu
 {
 public:
@@ -168,6 +159,7 @@ class LLPanelOutfitEditGearMenu
 		if (menu)
 		{
 			populateCreateWearableSubmenus(menu);
+			menu->buildDrawLabels();
 		}
 
 		return menu;
@@ -216,131 +208,6 @@ class LLPanelOutfitEditGearMenu
 	}
 };
 
-///////////////////////////////////////////////////////////////////////////////
-// LLAddWearablesGearMenu
-///////////////////////////////////////////////////////////////////////////////
-
-class LLAddWearablesGearMenu : public LLInitClass<LLAddWearablesGearMenu>
-{
-public:
-	static LLMenuGL* create(LLWearableItemsList* flat_list, LLInventoryPanel* inventory_panel)
-	{
-		LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
-		LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
-
-		llassert(flat_list);
-		llassert(inventory_panel);
-
-		registrar.add("AddWearable.Gear.Sort", boost::bind(onSort, flat_list, inventory_panel, _2));
-		enable_registrar.add("AddWearable.Gear.Check", boost::bind(onCheck, flat_list, inventory_panel, _2));
-		enable_registrar.add("AddWearable.Gear.Visible", boost::bind(onVisible, inventory_panel, _2));
-
-		LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(
-			"menu_add_wearable_gear.xml",
-			LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
-
-		return menu;
-	}
-
-private:
-	static void onSort(LLWearableItemsList* flat_list,
-					   LLInventoryPanel* inventory_panel,
-					   LLSD::String sort_order_str)
-	{
-		if (!flat_list || !inventory_panel) return;
-
-		LLWearableItemsList::ESortOrder	sort_order;
-
-		if ("by_most_recent" == sort_order_str)
-		{
-			sort_order = LLWearableItemsList::E_SORT_BY_MOST_RECENT;
-		}
-		else if ("by_name" == sort_order_str)
-		{
-			sort_order = LLWearableItemsList::E_SORT_BY_NAME;
-		}
-		else if ("by_type" == sort_order_str)
-		{
-			sort_order = LLWearableItemsList::E_SORT_BY_TYPE;
-		}
-		else
-		{
-			llwarns << "Unrecognized sort order action" << llendl;
-			return;
-		}
-
-		if (inventory_panel->getVisible())
-		{
-			inventory_panel->setSortOrder(sort_order);
-		}
-		else
-		{
-			flat_list->setSortOrder(sort_order);
-			gSavedSettings.setU32("AddWearableSortOrder", sort_order);
-		}
-	}
-
-	static bool onCheck(LLWearableItemsList* flat_list,
-						LLInventoryPanel* inventory_panel,
-						LLSD::String sort_order_str)
-	{
-		if (!inventory_panel || !flat_list) return false;
-
-		// Inventory panel uses its own sort order independent from
-		// flat list view so this flag is used to distinguish between
-		// currently visible "tree" or "flat" representation of inventory.
-		bool inventory_tree_visible = inventory_panel->getVisible();
-
-		if (inventory_tree_visible)
-		{
-			U32 sort_order = inventory_panel->getSortOrder();
-
-			if ("by_most_recent" == sort_order_str)
-			{
-				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & sort_order;
-			}
-			else if ("by_name" == sort_order_str)
-			{
-				// If inventory panel is not sorted by date then it is sorted by name.
-				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & ~sort_order;
-			}
-			llwarns << "Unrecognized inventory panel sort order" << llendl;
-		}
-		else
-		{
-			LLWearableItemsList::ESortOrder	sort_order = flat_list->getSortOrder();
-
-			if ("by_most_recent" == sort_order_str)
-			{
-				return LLWearableItemsList::E_SORT_BY_MOST_RECENT == sort_order;
-			}
-			else if ("by_name" == sort_order_str)
-			{
-				return LLWearableItemsList::E_SORT_BY_NAME == sort_order;
-			}
-			else if ("by_type" == sort_order_str)
-			{
-				return LLWearableItemsList::E_SORT_BY_TYPE == sort_order;
-			}
-			llwarns << "Unrecognized wearable list sort order" << llendl;
-		}
-		return false;
-	}
-
-	static bool onVisible(LLInventoryPanel* inventory_panel,
-						  LLSD::String sort_order_str)
-	{
-		// Enable sorting by type only for the flat list of items
-		// because inventory panel doesn't support this kind of sorting.
-		return ( "by_type" == sort_order_str )
-				&&	( !inventory_panel || !inventory_panel->getVisible() );
-	}
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// LLCOFDragAndDropObserver
-///////////////////////////////////////////////////////////////////////////////
-
 class LLCOFDragAndDropObserver : public LLInventoryAddItemByAssetObserver
 {
 public:
@@ -376,17 +243,12 @@ void LLCOFDragAndDropObserver::done()
 	LLAppearanceMgr::instance().updateAppearanceFromCOF();
 }
 
-///////////////////////////////////////////////////////////////////////////////
-// LLPanelOutfitEdit
-///////////////////////////////////////////////////////////////////////////////
-
 LLPanelOutfitEdit::LLPanelOutfitEdit()
 :	LLPanel(), 
 	mSearchFilter(NULL),
 	mCOFWearables(NULL),
 	mInventoryItemsPanel(NULL),
 	mGearMenu(NULL),
-	mAddWearablesGearMenu(NULL),
 	mCOFDragAndDropObserver(NULL),
 	mInitialized(false),
 	mAddWearablesPanel(NULL),
@@ -441,7 +303,7 @@ BOOL LLPanelOutfitEdit::postBuild()
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.All"), new LLFindNonLinksByMask(ALL_ITEMS_MASK)));
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Clothing"), new LLIsTypeActual(LLAssetType::AT_CLOTHING)));
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Bodyparts"), new LLIsTypeActual(LLAssetType::AT_BODYPART)));
-	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindNonLinksByMask(ATTACHMENT_MASK)));;
+	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindByMask(ATTACHMENT_MASK)));;
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("shape"), new LLFindActualWearablesOfType(LLWearableType::WT_SHAPE)));
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("skin"), new LLFindActualWearablesOfType(LLWearableType::WT_SKIN)));
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("hair"), new LLFindActualWearablesOfType(LLWearableType::WT_HAIR)));
@@ -466,9 +328,7 @@ BOOL LLPanelOutfitEdit::postBuild()
 
 	childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL);
 	childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL);
-	childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL);
 	childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL);
-	childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL);
 	childSetCommitCallback("wearables_gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
 	childSetCommitCallback("gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
 	childSetCommitCallback("shop_btn_1", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL);
@@ -541,12 +401,11 @@ BOOL LLPanelOutfitEdit::postBuild()
 	mWearableListViewItemsComparator->setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANK_1, false, true);
 
 	mWearablesListViewPanel = getChild<LLPanel>("filtered_wearables_panel");
-	mWearableItemsList = getChild<LLWearableItemsList>("list_view");
+	mWearableItemsList = getChild<LLInventoryItemsList>("list_view");
 	mWearableItemsList->setCommitOnSelectionChange(true);
 	mWearableItemsList->setCommitCallback(boost::bind(&LLPanelOutfitEdit::updatePlusButton, this));
 	mWearableItemsList->setDoubleClickCallback(boost::bind(&LLPanelOutfitEdit::onPlusBtnClicked, this));
 	mWearableItemsList->setComparator(mWearableListViewItemsComparator);
-        mWearableItemsList->setSortOrder((LLWearableItemsList::ESortOrder)gSavedSettings.getU32("AddWearableSortOrder"));
 
 	mSaveComboBtn.reset(new LLSaveOutfitComboBtn(this));
 	return TRUE;
@@ -630,7 +489,9 @@ void LLPanelOutfitEdit::showWearablesListView()
 {
 	if(switchPanels(mInventoryItemsPanel, mWearablesListViewPanel))
 	{
-		updateWearablesPanelVerbButtons();
+		mFolderViewBtn->setToggleState(FALSE);
+		mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
+		mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
 		updateFiltersVisibility();
 	}
 	mListViewBtn->setToggleState(TRUE);
@@ -640,7 +501,9 @@ void LLPanelOutfitEdit::showWearablesFolderView()
 {
 	if(switchPanels(mWearablesListViewPanel, mInventoryItemsPanel))
 	{
-		updateWearablesPanelVerbButtons();
+		mListViewBtn->setToggleState(FALSE);
+		mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
+		mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
 		updateFiltersVisibility();
 	}
 	mFolderViewBtn->setToggleState(TRUE);
@@ -761,11 +624,11 @@ void LLPanelOutfitEdit::onAddWearableClicked(void)
 	}
 }
 
-void LLPanelOutfitEdit::onReplaceMenuItemClicked(LLUUID selected_item_id)
+void LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id)
 {
 	LLViewerInventoryItem* item = gInventory.getLinkedItem(selected_item_id);
 
-	if (item)
+	if (item && item->getType() == LLAssetType::AT_BODYPART)
 	{
 		showFilteredWearablesListView(item->getWearableType());
 	}
@@ -1169,8 +1032,6 @@ bool LLPanelOutfitEdit::switchPanels(LLPanel* switch_from_panel, LLPanel* switch
 void LLPanelOutfitEdit::resetAccordionState()
 {
 	if (mCOFWearables != NULL)
-
-	if (mAddWearablesPanel->getVisible())
 	{
 		mCOFWearables->expandDefaultAccordionTab();
 	}
@@ -1178,25 +1039,17 @@ void LLPanelOutfitEdit::resetAccordionState()
 	{
 		llwarns << "mCOFWearables is NULL" << llendl;
 	}
+}
 
-		menu = mAddWearablesGearMenu;
-	}
-	else
+void LLPanelOutfitEdit::onGearButtonClick(LLUICtrl* clicked_button)
+{
+	if(!mGearMenu)
 	{
-		if (!mGearMenu)
-		{
-			mGearMenu = LLPanelOutfitEditGearMenu::create();
-		}
-
-		menu = mGearMenu;
+		mGearMenu = LLPanelOutfitEditGearMenu::create();
 	}
 
-	if (!menu) return;
-
-	menu->arrangeAndClear(); // update menu height
-	S32 menu_y = menu->getRect().getHeight() + clicked_button->getRect().getHeight();
-	menu->buildDrawLabels();
-	LLMenuGL::showPopup(clicked_button, menu, 0, menu_y);
+	S32 menu_y = mGearMenu->getRect().getHeight() + clicked_button->getRect().getHeight();
+	LLMenuGL::showPopup(clicked_button, mGearMenu, 0, menu_y);
 }
 
 void LLPanelOutfitEdit::onAddMoreButtonClicked()
@@ -1276,70 +1129,10 @@ void LLPanelOutfitEdit::getSelectedItemsUUID(uuid_vec_t& uuid_list)
 //	return selected_id;
 }
 
-void LLPanelOutfitEdit::updateWearablesPanelVerbButtons()
-{
-	if(mWearablesListViewPanel->getVisible())
-	{
-		mFolderViewBtn->setToggleState(FALSE);
-		mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
-		mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
-	}
-	else if(mInventoryItemsPanel->getVisible())
-	{
-		mListViewBtn->setToggleState(FALSE);
-		mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
-		mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
-	}
-}
-
-void LLPanelOutfitEdit::saveListSelection()
-{
-	if(mWearablesListViewPanel->getVisible())
-	{
-		std::set<LLUUID> selected_ids = mInventoryItemsPanel->getRootFolder()->getSelectionList();
-
-		if(!selected_ids.size()) return;
-
-		mWearableItemsList->resetSelection();
-
-		for (std::set<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
-		{
-			mWearableItemsList->selectItemByUUID(*item_id, true);
-		}
-		mWearableItemsList->scrollToShowFirstSelectedItem();
-	}
-	else if(mInventoryItemsPanel->getVisible())
-	{
-		std::vector<LLUUID> selected_ids;
-		mWearableItemsList->getSelectedUUIDs(selected_ids);
-
-		if(!selected_ids.size()) return;
-
-		mInventoryItemsPanel->clearSelection();
-		LLFolderView* root = mInventoryItemsPanel->getRootFolder();
-
-		if(!root) return;
-
-		for(std::vector<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
-		{
-			LLFolderViewItem* item = root->getItemByID(*item_id);
-			if (!item) continue;
-
-			LLFolderViewFolder* parent = item->getParentFolder();
-			if(parent)
-			{
-				parent->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP);
-			}
-			mInventoryItemsPanel->getRootFolder()->changeSelection(item, TRUE);
-		}
-		mInventoryItemsPanel->getRootFolder()->scrollToShowSelection();
-	}
-
-}
-
 void LLPanelOutfitEdit::onCOFChanged()
 {
 	update();
 }
 
+
 // EOF
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index fa3c48c3e73..13ceda98a6c 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -43,8 +43,8 @@
 #include "llremoteparcelrequest.h"
 #include "llinventory.h"
 #include "llinventoryfunctions.h"
+#include "llinventoryitemslist.h"
 #include "llinventorymodel.h"
-#include "llwearableitemslist.h"
 
 class LLButton;
 class LLCOFWearables;
@@ -141,12 +141,6 @@ class LLPanelOutfitEdit : public LLPanel
 	void showWearablesListView();
 	void showWearablesFolderView();
 
-	/**
-	 * Method preserves selection while switching between folder/list view modes
-	*/
-	void saveListSelection();
-
-	void updateWearablesPanelVerbButtons();
 	void updateFiltersVisibility();
 
 	void onFolderViewFilterCommitted(LLUICtrl* ctrl);
@@ -171,7 +165,7 @@ class LLPanelOutfitEdit : public LLPanel
 	void onRemoveFromOutfitClicked(void);
 	void onEditWearableClicked(void);
 	void onAddWearableClicked(void);
-	void onReplaceMenuItemClicked(LLUUID selected_item_id);
+	void onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id);
 	void onShopButtonClicked();
 
 	void displayCurrentOutfit();
@@ -229,7 +223,7 @@ class LLPanelOutfitEdit : public LLPanel
 	LLComboBox*			mListViewFilterCmbBox;
 
 	LLFilteredWearableListManager* 	mWearableListManager;
-	LLWearableItemsList* 			mWearableItemsList;
+	LLInventoryItemsList* 			mWearableItemsList;
 	LLPanel*						mWearablesListViewPanel;
 	LLWearableItemTypeNameComparator* mWearableListViewItemsComparator;
 
@@ -240,7 +234,6 @@ class LLPanelOutfitEdit : public LLPanel
 
 	LLCOFWearables*		mCOFWearables;
 	LLMenuGL*			mGearMenu;
-	LLMenuGL*			mAddWearablesGearMenu;
 	bool				mInitialized;
 	std::auto_ptr<LLSaveOutfitComboBtn> mSaveComboBtn;
 
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index d9b2dfbec04..fe8c09e3290 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -572,10 +572,8 @@ bool LLWearableItemTypeNameComparator::sortAssetTypeByName(LLAssetType::EType it
 }
 
 bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType item_type) const
-bool LLWearableItemCreationDateComparator::doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const
 {
 	wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type);
-	time_t date2 = item2->getCreationDate();
 
 	if(const_it == mWearableOrder.end())
 	{
@@ -585,14 +583,11 @@ bool LLWearableItemCreationDateComparator::doCompare(const LLPanelInventoryListI
 
 	return const_it->second.mSortWearableTypeByName;
 }
-
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 
 static const LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
-static const LLWearableItemNameComparator WEARABLE_NAME_COMPARATOR;
-static const LLWearableItemCreationDateComparator WEARABLE_CREATION_DATE_COMPARATOR;
 
 static const LLDefaultChildRegistry::Register<LLWearableItemsList> r("wearable_items_list");
 
@@ -604,7 +599,7 @@ LLWearableItemsList::Params::Params()
 LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p)
 :	LLInventoryItemsList(p)
 {
-	setSortOrder(E_SORT_BY_TYPE, false);
+	setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
 	mIsStandalone = p.standalone;
 	if (mIsStandalone)
 	{
@@ -704,32 +699,6 @@ void LLWearableItemsList::onRightClick(S32 x, S32 y)
 	ContextMenu::instance().show(this, selected_uuids, x, y);
 }
 
-void LLWearableItemsList::setSortOrder(ESortOrder sort_order, bool sort_now)
-{
-	switch (sort_order)
-	{
-	case E_SORT_BY_MOST_RECENT:
-		setComparator(&WEARABLE_CREATION_DATE_COMPARATOR);
-		break;
-	case E_SORT_BY_NAME:
-		setComparator(&WEARABLE_NAME_COMPARATOR);
-		break;
-	case E_SORT_BY_TYPE:
-		setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
-		break;
-
-	// No "default:" to raise compiler warning
-	// if we're not handling something
-	}
-
-	mSortOrder = sort_order;
-
-	if (sort_now)
-	{
-		sort();
-	}
-}
-
 //////////////////////////////////////////////////////////////////////////
 /// ContextMenu
 //////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index 84e999cd57b..f2f81968eeb 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -379,19 +379,6 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 	wearable_type_order_map_t mWearableOrder;
 };
 
-/**
- * @class LLWearableItemCreationDateComparator
- *
- * Comparator for sorting wearable list items by creation date (newest go first).
- */
-class LLWearableItemCreationDateComparator : public LLWearableItemNameComparator
-{
-	LOG_CLASS(LLWearableItemCreationDateComparator);
-
-protected:
-	/*virtual*/ bool doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const;
-};
-
 /**
  * @class LLWearableItemsList
  *
@@ -444,13 +431,6 @@ class LLWearableItemsList : public LLInventoryItemsList
 		Params();
 	};
 
-	typedef enum e_sort_order {
-		// Values should be compatible with InventorySortOrder setting.
-		E_SORT_BY_NAME			= 0,
-		E_SORT_BY_MOST_RECENT	= 1,
-		E_SORT_BY_TYPE			= 2,
-	} ESortOrder;
-
 	virtual ~LLWearableItemsList();
 
 	/*virtual*/ void addNewItem(LLViewerInventoryItem* item, bool rearrange = true);
@@ -465,10 +445,6 @@ class LLWearableItemsList : public LLInventoryItemsList
 
 	bool isStandalone() const { return mIsStandalone; }
 
-	ESortOrder getSortOrder() const { return mSortOrder; }
-
-	void setSortOrder(ESortOrder sort_order, bool sort_now = true);
-
 protected:
 	friend class LLUICtrlFactory;
 	LLWearableItemsList(const LLWearableItemsList::Params& p);
@@ -477,8 +453,6 @@ class LLWearableItemsList : public LLInventoryItemsList
 
 	bool mIsStandalone;
 	bool mWornIndicationEnabled;
-
-	ESortOrder		mSortOrder;
 };
 
 #endif //LL_LLWEARABLEITEMSLIST_H
-- 
GitLab


From 5904c4770ca06fbda6c4176ebd5f1b3a0c4e6518 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 26 Jul 2010 14:02:57 +0100
Subject: [PATCH 542/683] dos2unix

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

diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 671b0a108c4..2693c0e22b9 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -673,9 +673,9 @@ std::string ll_convert_wide_to_string(const wchar_t* in, unsigned int code_page)
 wchar_t* ll_convert_string_to_wide(const std::string& in, unsigned int code_page)
 {
 	// From review:
-	// We can preallocate a wide char buffer that is the same length (in wchar_t elements) as the utf8 input,
-	// plus one for a null terminator, and be guaranteed to not overflow.
-
+	// We can preallocate a wide char buffer that is the same length (in wchar_t elements) as the utf8 input,
+	// plus one for a null terminator, and be guaranteed to not overflow.
+
 	//	Normally, I'd call that sort of thing premature optimization,
 	// but we *are* seeing string operations taking a bunch of time, especially when constructing widgets.
 //	int output_str_len = MultiByteToWideChar(code_page, 0, in.c_str(), in.length(), NULL, 0);
-- 
GitLab


From 75addb32d6b1b6af07a2c8f66722b651602e661a Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Mon, 26 Jul 2010 16:14:23 +0300
Subject: [PATCH 543/683] EXT-8391 FIXED Landmark creation and error handling.
 - Added displaying error messages in Create Landmark panel upon remote parcel
 request fail. - Moved landmark creation from
 LLPanelLandmarkInfo::processParcelInfo() because we use only agent's current
 coordinates instead of waiting for remote parcel request to complete.

Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/793/.

--HG--
branch : product-engine
---
 indra/newview/llpanellandmarkinfo.cpp | 65 ++++++++++++++++++---------
 indra/newview/llpanelplaceinfo.cpp    | 16 ++++++-
 2 files changed, 58 insertions(+), 23 deletions(-)

diff --git a/indra/newview/llpanellandmarkinfo.cpp b/indra/newview/llpanellandmarkinfo.cpp
index 4ffd43cb0fe..c05cffc59e6 100644
--- a/indra/newview/llpanellandmarkinfo.cpp
+++ b/indra/newview/llpanellandmarkinfo.cpp
@@ -123,11 +123,54 @@ void LLPanelLandmarkInfo::setInfoType(EInfoType type)
 	switch(type)
 	{
 		case CREATE_LANDMARK:
+		{
 			mCurrentTitle = getString("title_create_landmark");
 
 			mLandmarkTitle->setVisible(FALSE);
 			mLandmarkTitleEditor->setVisible(TRUE);
 			mNotesEditor->setEnabled(TRUE);
+
+			LLViewerParcelMgr* parcel_mgr = LLViewerParcelMgr::getInstance();
+			std::string name = parcel_mgr->getAgentParcelName();
+			LLVector3 agent_pos = gAgent.getPositionAgent();
+
+			if (name.empty())
+			{
+				S32 region_x = llround(agent_pos.mV[VX]);
+				S32 region_y = llround(agent_pos.mV[VY]);
+				S32 region_z = llround(agent_pos.mV[VZ]);
+
+				std::string region_name;
+				LLViewerRegion* region = parcel_mgr->getSelectionRegion();
+				if (region)
+				{
+					region_name = region->getName();
+				}
+				else
+				{
+					region_name = getString("unknown");
+				}
+
+				mLandmarkTitleEditor->setText(llformat("%s (%d, %d, %d)",
+									  region_name.c_str(), region_x, region_y, region_z));
+			}
+			else
+			{
+				mLandmarkTitleEditor->setText(name);
+			}
+
+			std::string desc;
+			LLAgentUI::buildLocationString(desc, LLAgentUI::LOCATION_FORMAT_FULL, agent_pos);
+			mNotesEditor->setText(desc);
+
+			// Moved landmark creation here from LLPanelLandmarkInfo::processParcelInfo()
+			// because we use only agent's current coordinates instead of waiting for
+			// remote parcel request to complete.
+			if (!LLLandmarkActions::landmarkAlreadyExists())
+			{
+				createLandmark(LLUUID());
+			}
+		}
 		break;
 
 		case LANDMARK:
@@ -192,28 +235,6 @@ void LLPanelLandmarkInfo::processParcelInfo(const LLParcelData& parcel_data)
 	info["global_y"] = parcel_data.global_y;
 	info["global_z"] = parcel_data.global_z;
 	notifyParent(info);
-
-	if (mInfoType == CREATE_LANDMARK)
-	{
-		if (parcel_data.name.empty())
-		{
-			mLandmarkTitleEditor->setText(llformat("%s (%d, %d, %d)",
-								  parcel_data.sim_name.c_str(), region_x, region_y, region_z));
-		}
-		else
-		{
-			mLandmarkTitleEditor->setText(parcel_data.name);
-		}
-
-		std::string desc;
-		LLAgentUI::buildLocationString(desc, LLAgentUI::LOCATION_FORMAT_FULL, gAgent.getPositionAgent());
-		mNotesEditor->setText(desc);
-
-		if (!LLLandmarkActions::landmarkAlreadyExists())
-		{
-			createLandmark(mFolderCombo->getValue().asUUID());
-		}
-	}
 }
 
 void LLPanelLandmarkInfo::displayItemInfo(const LLInventoryItem* pItem)
diff --git a/indra/newview/llpanelplaceinfo.cpp b/indra/newview/llpanelplaceinfo.cpp
index 8c1f5d09158..38ad112438e 100644
--- a/indra/newview/llpanelplaceinfo.cpp
+++ b/indra/newview/llpanelplaceinfo.cpp
@@ -103,11 +103,11 @@ void LLPanelPlaceInfo::resetLocation()
 	mPosRegion.clearVec();
 
 	std::string loading = LLTrans::getString("LoadingData");
-	mMaturityRatingIcon->setValue(loading);
 	mMaturityRatingText->setValue(loading);
 	mRegionName->setText(loading);
 	mParcelName->setText(loading);
 	mDescEditor->setText(loading);
+	mMaturityRatingIcon->setValue(LLUUID::null);
 
 	mSnapshotCtrl->setImageAssetID(LLUUID::null);
 }
@@ -185,7 +185,21 @@ void LLPanelPlaceInfo::setErrorStatus(U32 status, const std::string& reason)
 	{
 		error_text = getString("server_forbidden_text");
 	}
+	else
+	{
+		error_text = getString("server_error_text");
+	}
+
 	mDescEditor->setText(error_text);
+
+	std::string not_available = getString("not_available");
+	mMaturityRatingText->setValue(not_available);
+	mRegionName->setText(not_available);
+	mParcelName->setText(not_available);
+	mMaturityRatingIcon->setValue(LLUUID::null);
+
+	// Enable "Back" button that was disabled when parcel request was sent.
+	getChild<LLButton>("back_btn")->setEnabled(TRUE);
 }
 
 // virtual
-- 
GitLab


From 0defb7a1d28e1d9a83635a55ada7a2d16593ca2c Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Mon, 26 Jul 2010 16:17:52 +0300
Subject: [PATCH 544/683] EXT-8257 FIXED Made "Expand" and "Collapse" menu
 items visible in Places gear menu mutually exclusive. Root cause: ==========
 The same menu is used to be shown as context and gear menus. But visibility
 of context Folder View's menu is processed in a separate way. So, once
 visibility of menu items is changed in context menu - it is unchanged in gear
 menu.

Also it was possible situation when both "Expand" and "Collapse" menu items were visible in gear menu (If it was opened before any context menu)

FIX:
===
Added "on_visible" callbacks for "Expand" and "Collapse" menu items to set proper visibility in "gear" menu.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/801/

--HG--
branch : product-engine
---
 .../skins/default/xui/en/menu_places_gear_folder.xml        | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
index 3e38503e43d..77cc3910fd3 100644
--- a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
+++ b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
@@ -94,6 +94,9 @@
         <on_enable
          function="Places.LandmarksGear.Enable"
          parameter="expand" />
+        <on_visible
+         function="Places.LandmarksGear.Enable"
+         parameter="expand" />
     </menu_item_call>
     <menu_item_call
      label="Collapse"
@@ -105,6 +108,9 @@
         <on_enable
          function="Places.LandmarksGear.Enable"
          parameter="collapse" />
+        <on_visible
+         function="Places.LandmarksGear.Enable"
+         parameter="collapse" />
     </menu_item_call>
     <menu_item_call
      label="Expand all folders"
-- 
GitLab


From 20d55088894fa47f4320616f8c5b71afd16e98a0 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Mon, 26 Jul 2010 16:20:14 +0300
Subject: [PATCH 545/683] EXT-8069 FIXED "Show Advanced Menu" item is moved to
 "Advanced/Shortcuts" submenu and made invisible. (invisible - because it is
 still located in menu it toggles)

Note: We can not completely remove this menu item to keep hot key workable.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/803/

--HG--
branch : product-engine
---
 .../skins/default/xui/en/menu_viewer.xml      | 30 +++++++++++--------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 67b8c81a014..bf1707c13e1 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -951,17 +951,6 @@
      name="Advanced"
      tear_off="true"
      visible="false">
-        <menu_item_check
-         label="Show Advanced Menu"
-         name="Show Advanced Menu"
-         shortcut="control|alt|D">
-          <on_check
-           function="CheckControl"
-           parameter="UseDebugMenus" />
-          <on_click
-           function="ToggleControl"
-           parameter="UseDebugMenus" />
-        </menu_item_check>
         <menu_item_call
          label="Stop Animating Me"
          name="Stop Animating My Avatar">
@@ -1681,7 +1670,24 @@
                 <menu_item_call.on_click
                  function="View.ZoomOut" />
             </menu_item_call>
-        </menu>
+            <menu_item_separator
+             visible="false"/>
+            <!-- Made invisible to avoid a dissonance: menu item toggle menu where it is located. EXT-8069.
+              Can't be removed to keep sortcut workable.
+            -->
+            <menu_item_check
+             label="Show Advanced Menu"
+             name="Show Advanced Menu"
+             shortcut="control|alt|D"
+             visible="false">
+                <on_check
+                 function="CheckControl"
+                 parameter="UseDebugMenus" />
+                <on_click
+                 function="ToggleControl"
+                 parameter="UseDebugMenus" />
+        </menu_item_check>
+        </menu> <!--Shortcuts-->
 
         <menu_item_separator/>
 
-- 
GitLab


From 0c8cddecc16d5bd25a2eb5159333ada1dec59259 Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Mon, 26 Jul 2010 18:10:29 +0300
Subject: [PATCH 546/683] EXT-8010 FIXED Implemented special behaviour of
 avatar links.

Avatar links are now underlined only on hover. Also they have the same color as other links.

- Underlining text and getting it back to normal are done in handleHover() and draw() of new LLOnHoverChangeableTextSegment
class derived from LLNormalTextSegment. This class has two pointers to styles- one for style which will be used for text
on hover, and another otherwise. This special type of text segment is used if link's boolean member mUnderlineOnHoverOnly
is true. So it is URL's flag depending on which textbase adds new text segment(like it currently happens with mDisabledLink).

- Changed avatar link color in colors.xml to emphasis (because it was white before and was inconsistent with other links).

Reviewed by Richard Nelson at https://codereview.productengine.com/secondlife/r/749/

--HG--
branch : product-engine
---
 indra/llui/lltextbase.cpp              | 58 ++++++++++++++++++++++----
 indra/llui/lltextbase.h                | 19 ++++++++-
 indra/llui/llurlentry.cpp              | 19 +++++++++
 indra/llui/llurlentry.h                |  5 +++
 indra/llui/llurlmatch.cpp              |  6 ++-
 indra/llui/llurlmatch.h                |  6 ++-
 indra/llui/llurlregistry.cpp           |  6 ++-
 indra/newview/skins/default/colors.xml |  2 +-
 8 files changed, 106 insertions(+), 15 deletions(-)

diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 617c496d6a1..34d58db7f89 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1642,7 +1642,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
 			}
 			else
 			{
-				appendAndHighlightText(match.getLabel(), part, link_params);
+				appendAndHighlightText(match.getLabel(), part, link_params, match.underlineOnHoverOnly());
 
 				// set the tooltip for the Url label
 				if (! match.getTooltip().empty())
@@ -1725,7 +1725,7 @@ void LLTextBase::appendWidget(const LLInlineViewSegment::Params& params, const s
 	insertStringNoUndo(getLength(), widget_wide_text, &segments);
 }
 
-void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params)
+void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only)
 {
 	// Save old state
 	S32 selection_start = mSelectionStart;
@@ -1756,7 +1756,17 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
 
 			S32 cur_length = getLength();
 			LLStyleConstSP sp(new LLStyle(highlight_params));
-			LLTextSegmentPtr segmentp = new LLNormalTextSegment(sp, cur_length, cur_length + wide_text.size(), *this);
+			LLTextSegmentPtr segmentp;
+			if(underline_on_hover_only)
+			{
+				highlight_params.font.style("NORMAL");
+				LLStyleConstSP normal_sp(new LLStyle(highlight_params));
+				segmentp = new LLOnHoverChangeableTextSegment(sp, normal_sp, cur_length, cur_length + wide_text.size(), *this);
+			}
+			else
+			{
+				segmentp = new LLNormalTextSegment(sp, cur_length, cur_length + wide_text.size(), *this);
+			}
 			segment_vec_t segments;
 			segments.push_back(segmentp);
 			insertStringNoUndo(cur_length, wide_text, &segments);
@@ -1771,7 +1781,17 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
 		S32 segment_start = old_length;
 		S32 segment_end = old_length + wide_text.size();
 		LLStyleConstSP sp(new LLStyle(style_params));
-		segments.push_back(new LLNormalTextSegment(sp, segment_start, segment_end, *this ));
+		if (underline_on_hover_only)
+		{
+			LLStyle::Params normal_style_params(style_params);
+			normal_style_params.font.style("NORMAL");
+			LLStyleConstSP normal_sp(new LLStyle(normal_style_params));
+			segments.push_back(new LLOnHoverChangeableTextSegment(sp, normal_sp, segment_start, segment_end, *this ));
+		}
+		else
+		{
+			segments.push_back(new LLNormalTextSegment(sp, segment_start, segment_end, *this ));
+		}
 
 		insertStringNoUndo(getLength(), wide_text, &segments);
 	}
@@ -1795,7 +1815,7 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
 	}
 }
 
-void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params)
+void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only)
 {
 	if (new_text.empty()) return; 
 
@@ -1807,7 +1827,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlig
 		if(pos!=start)
 		{
 			std::string str = std::string(new_text,start,pos-start);
-			appendAndHighlightTextImpl(str,highlight_part, style_params);
+			appendAndHighlightTextImpl(str,highlight_part, style_params, underline_on_hover_only);
 		}
 		appendLineBreakSegment(style_params);
 		start = pos+1;
@@ -1815,7 +1835,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlig
 	}
 
 	std::string str = std::string(new_text,start,new_text.length()-start);
-	appendAndHighlightTextImpl(str,highlight_part, style_params);
+	appendAndHighlightTextImpl(str,highlight_part, style_params, underline_on_hover_only);
 }
 
 
@@ -2675,6 +2695,30 @@ void LLNormalTextSegment::dump() const
 		llendl;
 }
 
+//
+// LLOnHoverChangeableTextSegment
+//
+
+LLOnHoverChangeableTextSegment::LLOnHoverChangeableTextSegment( LLStyleConstSP style, LLStyleConstSP normal_style, S32 start, S32 end, LLTextBase& editor ):
+	  LLNormalTextSegment(normal_style, start, end, editor),
+	  mHoveredStyle(style),
+	  mNormalStyle(normal_style){}
+
+/*virtual*/ 
+F32 LLOnHoverChangeableTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect)
+{
+	F32 result = LLNormalTextSegment::draw(start, end, selection_start, selection_end, draw_rect);
+	mStyle = mNormalStyle;
+	return result;
+}
+
+/*virtual*/
+BOOL LLOnHoverChangeableTextSegment::handleHover(S32 x, S32 y, MASK mask)
+{
+	mStyle = mHoveredStyle;
+	return LLNormalTextSegment::handleHover(x, y, mask);
+}
+
 
 //
 // LLInlineViewSegment
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 86f0e55a1d9..4b83d5effb2 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -145,6 +145,21 @@ class LLNormalTextSegment : public LLTextSegment
 	boost::signals2::connection mImageLoadedConnection;
 };
 
+// Text segment that changes it's style depending of mouse pointer position ( is it inside or outside segment)
+class LLOnHoverChangeableTextSegment : public LLNormalTextSegment
+{
+public:
+	LLOnHoverChangeableTextSegment( LLStyleConstSP style, LLStyleConstSP normal_style, S32 start, S32 end, LLTextBase& editor );
+	/*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
+	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
+protected:
+	// Style used for text when mouse pointer is over segment
+	LLStyleConstSP		mHoveredStyle;
+	// Style used for text when mouse pointer is outside segment
+	LLStyleConstSP		mNormalStyle;
+
+};
+
 class LLIndexSegment : public LLTextSegment
 {
 public:
@@ -443,7 +458,7 @@ class LLTextBase
 	S32								insertStringNoUndo(S32 pos, const LLWString &wstr, segment_vec_t* segments = NULL); // returns num of chars actually inserted
 	S32 							removeStringNoUndo(S32 pos, S32 length);
 	S32								overwriteCharNoUndo(S32 pos, llwchar wc);
-	void							appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& stylep);
+	void							appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& stylep, bool underline_on_hover_only = false);
 
 
 	// manage segments 
@@ -486,7 +501,7 @@ class LLTextBase
 	void							replaceUrlLabel(const std::string &url, const std::string &label);
 	
 	void							appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params = LLStyle::Params());
-	void							appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params);
+	void							appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only = false);
 	
 
 protected:
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index e075699a6ec..17d211fb36e 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -363,6 +363,12 @@ std::string LLUrlEntryAgent::getTooltip(const std::string &string) const
 	return LLTrans::getString("TooltipAgentUrl");
 }
 
+bool LLUrlEntryAgent::underlineOnHoverOnly(const std::string &string) const
+{
+	std::string url = getUrl(string);
+	return LLStringUtil::endsWith(url, "/about");
+}
+
 std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
 {
 	if (!gCacheName)
@@ -730,6 +736,19 @@ std::string LLUrlEntrySLLabel::getTooltip(const std::string &string) const
 	return LLUrlEntryBase::getTooltip(string);
 }
 
+bool LLUrlEntrySLLabel::underlineOnHoverOnly(const std::string &string) const
+{
+	std::string url = getUrl(string);
+	LLUrlMatch match;
+	if (LLUrlRegistry::instance().findUrl(url, match))
+	{
+		return match.underlineOnHoverOnly();
+	}
+
+	// unrecognized URL? should not happen
+	return LLUrlEntryBase::underlineOnHoverOnly(string);
+}
+
 //
 // LLUrlEntryWorldMap Describes secondlife:///<location> URLs
 //
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index 7d718b67a93..f8588dd7605 100644
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -94,6 +94,9 @@ class LLUrlEntryBase
 	/// is this a match for a URL that should not be hyperlinked?
 	bool isLinkDisabled() const { return mDisabledLink; }
 
+	/// Should this link text be underlined only when mouse is hovered over it?
+	virtual bool underlineOnHoverOnly(const std::string &string) const { return false; }
+
 	virtual LLUUID	getID(const std::string &string) const { return LLUUID::null; }
 
 protected:
@@ -173,6 +176,7 @@ class LLUrlEntryAgent : public LLUrlEntryBase
 	/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
 	/*virtual*/ std::string getTooltip(const std::string &string) const;
 	/*virtual*/ LLUUID	getID(const std::string &string) const;
+	/*virtual*/ bool underlineOnHoverOnly(const std::string &string) const;
 private:
 	void onAgentNameReceived(const LLUUID& id, const std::string& first,
 							 const std::string& last, BOOL is_group);
@@ -275,6 +279,7 @@ class LLUrlEntrySLLabel : public LLUrlEntryBase
 	/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
 	/*virtual*/ std::string getUrl(const std::string &string) const;
 	/*virtual*/ std::string getTooltip(const std::string &string) const;
+	/*virtual*/ bool underlineOnHoverOnly(const std::string &string) const;
 };
 
 ///
diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp
index 7c96665ce47..a6d3dcb40f0 100644
--- a/indra/llui/llurlmatch.cpp
+++ b/indra/llui/llurlmatch.cpp
@@ -43,7 +43,8 @@ LLUrlMatch::LLUrlMatch() :
 	mIcon(""),
 	mMenuName(""),
 	mLocation(""),
-	mDisabledLink(false)
+	mDisabledLink(false),
+	mUnderlineOnHoverOnly(false)
 {
 }
 
@@ -51,7 +52,7 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url,
 						   const std::string &label, const std::string &tooltip,
 						   const std::string &icon, const LLUIColor& color,
 						   const std::string &menu, const std::string &location,
-						   bool disabled_link, const LLUUID& id)
+						   bool disabled_link, const LLUUID& id, bool underline_on_hover_only)
 {
 	mStart = start;
 	mEnd = end;
@@ -64,4 +65,5 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url,
 	mLocation = location;
 	mDisabledLink = disabled_link;
 	mID = id;
+	mUnderlineOnHoverOnly = underline_on_hover_only;
 }
diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h
index 78dd2c528f7..7090dd3f93f 100644
--- a/indra/llui/llurlmatch.h
+++ b/indra/llui/llurlmatch.h
@@ -86,12 +86,15 @@ class LLUrlMatch
 	/// is this a match for a URL that should not be hyperlinked?
 	bool isLinkDisabled() const { return mDisabledLink; }
 
+	/// Should this link text be underlined only when mouse is hovered over it?
+	bool underlineOnHoverOnly() const { return mUnderlineOnHoverOnly; }
+
 	/// Change the contents of this match object (used by LLUrlRegistry)
 	void setValues(U32 start, U32 end, const std::string &url, const std::string &label,
 	               const std::string &tooltip, const std::string &icon,
 				   const LLUIColor& color, const std::string &menu, 
 				   const std::string &location, bool disabled_link
-				   , const LLUUID& id );
+				   , const LLUUID& id, bool underline_on_hover_only  = false );
 
 	const LLUUID& getID() const { return mID;}
 
@@ -108,6 +111,7 @@ class LLUrlMatch
 	LLUUID		mID;
 	LLUIColor	mColor;
 	bool        mDisabledLink;
+	bool		mUnderlineOnHoverOnly;
 };
 
 #endif
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index 1f86f72faa9..b37a52cad20 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -184,7 +184,8 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
 						match_entry->getMenuName(),
 						match_entry->getLocation(url),
 						match_entry->isLinkDisabled(),
-						match_entry->getID(url));
+						match_entry->getID(url),
+						match_entry->underlineOnHoverOnly(url));
 		return true;
 	}
 
@@ -219,7 +220,8 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr
 						match.getMenuName(),
 						match.getLocation(),
 						match.isLinkDisabled(),
-						match.getID());
+						match.getID(),
+						match.underlineOnHoverOnly());
 		return true;
 	}
 	return false;
diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml
index 2188c71ff9e..5ba1fc9b21a 100644
--- a/indra/newview/skins/default/colors.xml
+++ b/indra/newview/skins/default/colors.xml
@@ -113,7 +113,7 @@
      reference="LtYellow" />
     <color
      name="AgentLinkColor"
-     reference="White" />
+     reference="EmphasisColor" />
     <color
      name="AlertTextColor"
      value="0.58 0.66 0.84 1" />
-- 
GitLab


From 8c2ccb5ed3b2acdf562acf0c1a180215d49742c8 Mon Sep 17 00:00:00 2001
From: Alexei Arabadji <aarabadji@productengine.com>
Date: Tue, 27 Jul 2010 15:59:11 +0300
Subject: [PATCH 547/683] EXT-7015 FIXED Avoided wearing item moved to trash.
 Details: Disabled wear button and hidden related context menu entries if base
 object of inventory link is in trash.

reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/806/

--HG--
branch : product-engine
---
 indra/newview/lloutfitslist.cpp       | 32 ++++++++++++++++++++++++++-
 indra/newview/lloutfitslist.h         |  5 +++++
 indra/newview/llwearableitemslist.cpp | 15 ++++++++++---
 3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index 63ffb80ff28..ccde5be9007 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -665,7 +665,14 @@ bool LLOutfitsList::isActionEnabled(const LLSD& userdata)
 	}
 	if (command_name == "wear")
 	{
-		return !gAgentWearables.isCOFChangeInProgress();
+		if (gAgentWearables.isCOFChangeInProgress())
+		{
+			return false;
+		}
+		uuid_vec_t ids;
+		getSelectedItemsUUIDs(ids);
+
+		return !ids.empty() && !isSelectedInTrash();
 	}
 	if (command_name == "take_off")
 	{
@@ -711,6 +718,29 @@ void LLOutfitsList::getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const
 	}
 }
 
+bool LLOutfitsList::isSelectedInTrash()
+{
+	bool res = false;
+	const LLUUID trash_id = gInventory.findCategoryUUIDForType(
+			LLFolderType::FT_TRASH);
+
+	uuid_vec_t selected_uuids;
+	getSelectedItemsUUIDs(selected_uuids);
+
+	for (uuid_vec_t::const_iterator it = selected_uuids.begin(); it != selected_uuids.end(); it++)
+	{
+		const LLInventoryItem* item = gInventory.getItem(*it);
+		if (item != NULL && gInventory.isObjectDescendentOf(
+				item->getLinkedUUID(), trash_id))
+		{
+			res = true;
+			break;
+		}
+	}
+
+	return res;
+}
+
 boost::signals2::connection LLOutfitsList::setSelectionChangeCallback(selection_change_callback_t cb)
 {
 	return mSelectionChangeSignal.connect(cb);
diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h
index d7cf8a8c08d..dbb35c4d5f2 100644
--- a/indra/newview/lloutfitslist.h
+++ b/indra/newview/lloutfitslist.h
@@ -105,6 +105,11 @@ class LLOutfitsList : public LLPanelAppearanceTab
 
 	void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const;
 
+	/**
+	 * Returns true in case any of selected item is in trash.
+	 */
+	bool isSelectedInTrash();
+
 	boost::signals2::connection setSelectionChangeCallback(selection_change_callback_t cb);
 
 	// Collects selected items from all selected lists and wears them(if possible- adds, else replaces)
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index b614860b749..1ce89b13acf 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -767,6 +767,9 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 	U32 n_links = 0;				// number of links among the selected items
 	U32 n_editable = 0;				// number of editable items among the selected ones
 
+	bool item_in_trash = false;
+	const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+
 	for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
 	{
 		LLUUID id = *it;
@@ -802,16 +805,22 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 		{
 			++n_already_worn;
 		}
+
+		// if any in trash
+		if (!item_in_trash)
+		{
+			item_in_trash = gInventory.isObjectDescendentOf(item->getLinkedUUID(), trash_id);
+		}
 	} // for
 
 	bool standalone = mParent ? mParent->isStandalone() : false;
 
 	// *TODO: eliminate multiple traversals over the menu items
-	setMenuItemVisible(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0);
+	setMenuItemVisible(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0 && !item_in_trash);
 	setMenuItemEnabled(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0);
-	setMenuItemVisible(menu, "wear_add",			mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0);
+	setMenuItemVisible(menu, "wear_add",			mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0 && !item_in_trash);
 	setMenuItemEnabled(menu, "wear_add",			n_items == 1 && canAddWearable(ids.front()) && n_already_worn != 0);
-	setMenuItemVisible(menu, "wear_replace",		n_worn == 0 && n_already_worn != 0);
+	setMenuItemVisible(menu, "wear_replace",		n_worn == 0 && n_already_worn != 0 && !item_in_trash);
 	//visible only when one item selected and this item is worn
 	setMenuItemVisible(menu, "edit",				!standalone && mask & (MASK_CLOTHING|MASK_BODYPART) && n_worn == n_items && n_worn == 1);
 	setMenuItemEnabled(menu, "edit",				n_editable == 1 && n_worn == 1 && n_items == 1);
-- 
GitLab


From 872c7fd9573b9d694b32431d9827dd814dbb8fee Mon Sep 17 00:00:00 2001
From: Alexei Arabadji <aarabadji@productengine.com>
Date: Tue, 27 Jul 2010 18:00:37 +0300
Subject: [PATCH 548/683] Performed necessary refactoring after merge rev.
 14093:babb41195f70

--HG--
branch : product-engine
---
 indra/newview/llinventoryfunctions.cpp | 10 ++++++++++
 indra/newview/lloutfitslist.cpp        | 23 -----------------------
 indra/newview/lloutfitslist.h          |  5 -----
 indra/newview/llwearableitemslist.cpp  | 13 ++++++-------
 4 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index f20acbd016a..2517db2678a 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -251,6 +251,16 @@ BOOL get_can_item_be_worn(const LLUUID& id)
 	if (!item)
 		return FALSE;
 	
+	const LLUUID trash_id = gInventory.findCategoryUUIDForType(
+			LLFolderType::FT_TRASH);
+
+	// item can't be worn if base obj in trash, see EXT-7015
+	if (gInventory.isObjectDescendentOf(item->getLinkedUUID(),
+			trash_id))
+	{
+		return false;
+	}
+
 	switch(item->getType())
 	{
 		case LLAssetType::AT_OBJECT:
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index 1ed7ca22f55..c3eee1d1ad8 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -723,29 +723,6 @@ void LLOutfitsList::getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const
 	}
 }
 
-bool LLOutfitsList::isSelectedInTrash()
-{
-	bool res = false;
-	const LLUUID trash_id = gInventory.findCategoryUUIDForType(
-			LLFolderType::FT_TRASH);
-
-	uuid_vec_t selected_uuids;
-	getSelectedItemsUUIDs(selected_uuids);
-
-	for (uuid_vec_t::const_iterator it = selected_uuids.begin(); it != selected_uuids.end(); it++)
-	{
-		const LLInventoryItem* item = gInventory.getItem(*it);
-		if (item != NULL && gInventory.isObjectDescendentOf(
-				item->getLinkedUUID(), trash_id))
-		{
-			res = true;
-			break;
-		}
-	}
-
-	return res;
-}
-
 boost::signals2::connection LLOutfitsList::setSelectionChangeCallback(selection_change_callback_t cb)
 {
 	return mSelectionChangeSignal.connect(cb);
diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h
index af094c28d48..206854b2326 100644
--- a/indra/newview/lloutfitslist.h
+++ b/indra/newview/lloutfitslist.h
@@ -105,11 +105,6 @@ class LLOutfitsList : public LLPanelAppearanceTab
 
 	void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const;
 
-	/**
-	 * Returns true in case any of selected item is in trash.
-	 */
-	bool isSelectedInTrash();
-
 	boost::signals2::connection setSelectionChangeCallback(selection_change_callback_t cb);
 
 	// Collects selected items from all selected lists and wears them(if possible- adds, else replaces)
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 98ebd68564d..8035cd2d933 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -769,8 +769,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 	U32 n_links = 0;				// number of links among the selected items
 	U32 n_editable = 0;				// number of editable items among the selected ones
 
-	bool item_in_trash = false;
-	const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+	bool can_be_worn = false;
 
 	for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
 	{
@@ -809,20 +808,20 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 		}
 
 		// if any in trash
-		if (!item_in_trash)
+		if (!can_be_worn)
 		{
-			item_in_trash = gInventory.isObjectDescendentOf(item->getLinkedUUID(), trash_id);
+			can_be_worn = get_can_item_be_worn(item->getLinkedUUID());
 		}
 	} // for
 
 	bool standalone = mParent ? mParent->isStandalone() : false;
 
 	// *TODO: eliminate multiple traversals over the menu items
-	setMenuItemVisible(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0 && !item_in_trash);
+	setMenuItemVisible(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0 && can_be_worn);
 	setMenuItemEnabled(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0);
-	setMenuItemVisible(menu, "wear_add",			mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0 && !item_in_trash);
+	setMenuItemVisible(menu, "wear_add",			mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0 && can_be_worn);
 	setMenuItemEnabled(menu, "wear_add",			n_items == 1 && canAddWearable(ids.front()) && n_already_worn != 0);
-	setMenuItemVisible(menu, "wear_replace",		n_worn == 0 && n_already_worn != 0 && !item_in_trash);
+	setMenuItemVisible(menu, "wear_replace",		n_worn == 0 && n_already_worn != 0 && can_be_worn);
 	//visible only when one item selected and this item is worn
 	setMenuItemVisible(menu, "edit",				!standalone && mask & (MASK_CLOTHING|MASK_BODYPART) && n_worn == n_items && n_worn == 1);
 	setMenuItemEnabled(menu, "edit",				n_editable == 1 && n_worn == 1 && n_items == 1);
-- 
GitLab


From 0156e91c50ec77c92a6971c452a4cfe7a5f2bcab Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Tue, 27 Jul 2010 18:30:35 +0300
Subject: [PATCH 549/683] EXT-2707 FIXED Fixed incorrectness of coalesced
 objects icons in inventory.

Bug was caused by multiobject's icon name index substitution with ordinary object's one. It happened because index was set depending on asset type in switch that followed "if" which set index for multiobject regardless of its result.

- Added returning index icon name inside of "if" block to avoid change of the index by switch for multiobject.

Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/804/

--HG--
branch : product-engine
---
 indra/newview/llpanelgroupgeneral.cpp | 20 ++++++++------------
 indra/newview/llpanelgroupgeneral.h   |  1 -
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 8e1b7ba4d92..23027728031 100644
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -184,8 +184,7 @@ BOOL LLPanelGroupGeneral::postBuild()
 	mComboActiveTitle = getChild<LLComboBox>("active_title", recurse);
 	if (mComboActiveTitle)
 	{
-		mComboActiveTitle->setCommitCallback(onCommitTitle, this);
-		mComboActiveTitle->resetDirty();
+		mComboActiveTitle->setCommitCallback(onCommitAny, this);
 	}
 
 	mIncompleteMemberDataStr = getString("incomplete_member_data_str");
@@ -277,16 +276,6 @@ void LLPanelGroupGeneral::onCommitEnrollment(LLUICtrl* ctrl, void* data)
 	}
 }
 
-// static
-void LLPanelGroupGeneral::onCommitTitle(LLUICtrl* ctrl, void* data)
-{
-	LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
-	if (self->mGroupID.isNull() || !self->mAllowEdit) return;
-	LLGroupMgr::getInstance()->sendGroupTitleUpdate(self->mGroupID,self->mComboActiveTitle->getCurrentID());
-	self->update(GC_TITLES);
-	self->mComboActiveTitle->resetDirty();
-}
-
 // static
 void LLPanelGroupGeneral::onClickInfo(void *userdata)
 {
@@ -356,6 +345,13 @@ void LLPanelGroupGeneral::draw()
 
 bool LLPanelGroupGeneral::apply(std::string& mesg)
 {
+	if (!mGroupID.isNull() && mAllowEdit && mComboActiveTitle && mComboActiveTitle->isDirty())
+	{
+		LLGroupMgr::getInstance()->sendGroupTitleUpdate(mGroupID,mComboActiveTitle->getCurrentID());
+		update(GC_TITLES);
+		mComboActiveTitle->resetDirty();
+	}
+
 	BOOL has_power_in_group = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY);
 
 	if (has_power_in_group || mGroupID.isNull())
diff --git a/indra/newview/llpanelgroupgeneral.h b/indra/newview/llpanelgroupgeneral.h
index 6f4fa994da8..358d3530741 100644
--- a/indra/newview/llpanelgroupgeneral.h
+++ b/indra/newview/llpanelgroupgeneral.h
@@ -77,7 +77,6 @@ class LLPanelGroupGeneral : public LLPanelGroupTab
 	static void onFocusEdit(LLFocusableElement* ctrl, void* data);
 	static void onCommitAny(LLUICtrl* ctrl, void* data);
 	static void onCommitUserOnly(LLUICtrl* ctrl, void* data);
-	static void onCommitTitle(LLUICtrl* ctrl, void* data);
 	static void onCommitEnrollment(LLUICtrl* ctrl, void* data);
 	static void onClickInfo(void* userdata);
 	static void onReceiveNotices(LLUICtrl* ctrl, void* data);
-- 
GitLab


From 3cf9a103859a2d1a083a14ae321c32d552a2ef39 Mon Sep 17 00:00:00 2001
From: "Nyx (Neal Orman)" <nyx@lindenlab.com>
Date: Tue, 27 Jul 2010 17:40:41 -0400
Subject: [PATCH 550/683] CTS-201 WIP update viewer-external to run under linux

step 1 - minor cleanup that allows viewer to build under linux.
Will only run on aditi (crashes on agni), does not download meshes
successfully, and has pretty bad vertex corruption, but it runs!

Code reviewed by Falcon

 -Nyx
---
 install.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/install.xml b/install.xml
index e36ba1d33c5..4f8e7bff263 100644
--- a/install.xml
+++ b/install.xml
@@ -1058,9 +1058,9 @@ anguage Infrstructure (CLI) international standard</string>
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>3427b3c31ed66132b19e1f6679894c57</string>
+            <string>33dee1d84d006a5339cf6ba4096b8bd9</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100628.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100721.tar.bz2</uri>
           </map>
           <key>darwin</key>
           <map>
-- 
GitLab


From c96caed698afb38c50db229fff35fa8b91e40f83 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 27 Jul 2010 14:44:17 -0700
Subject: [PATCH 551/683] Merge from dessie/viewer-release

---
 indra/llui/llflatlistview.cpp                 |   2 +-
 indra/newview/app_settings/settings.xml       |   4 +-
 indra/newview/llappearancemgr.cpp             |   6 +-
 indra/newview/llcofwearables.cpp              |   8 +-
 indra/newview/llpaneloutfitedit.cpp           |  26 +-
 indra/newview/llviewerinventory.cpp           |   2 +-
 indra/newview/llviewertexture.cpp             |   4 +-
 indra/newview/llvoavatar.cpp                  |  16 +-
 indra/newview/llvoavatar.h                    |   4 +-
 indra/newview/llvoavatarself.cpp              |  12 +-
 indra/newview/llwearableitemslist.cpp         |   4 +-
 indra/newview/llwearableitemslist.h           |   4 +-
 indra/newview/pipeline.cpp                    | 456 +++++++++---------
 .../skins/default/xui/en/menu_viewer.xml      |   2 +-
 .../skins/default/xui/fr/menu_object.xml      |   6 +-
 15 files changed, 277 insertions(+), 279 deletions(-)

diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index 90c6f15d23a..0fa7949be25 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -615,7 +615,7 @@ void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask)
 
 	//only CTRL usage allows to deselect an item, usual clicking on an item cannot deselect it
 	if (mask & MASK_CONTROL)
-		selectItemPair(item_pair, select_item);
+	selectItemPair(item_pair, select_item);
 	else
 		selectItemPair(item_pair, true);
 }
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index fa7343ed628..ce22db97b49 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7339,7 +7339,7 @@
     <key>Value</key>
     <integer>0</integer>
   </map>
-  
+
   <key>RenderDeferredGI</key>
   <map>
     <key>Comment</key>
@@ -8032,7 +8032,7 @@
       <integer>2</integer>
     </map>
 
-  <key>RenderReflectionRes</key>
+    <key>RenderReflectionRes</key>
     <map>
       <key>Comment</key>
       <string>Reflection map resolution.</string>
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index b64007aa75a..dcbbf9bb2c3 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1801,9 +1801,9 @@ void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool
 	llinfos << "wearInventoryCategory( " << category->getName()
 			 << " )" << llendl;
 
-	callAfterCategoryFetch(category->getUUID(), boost::bind(&LLAppearanceMgr::wearCategoryFinal,
-															&LLAppearanceMgr::instance(),
-															category->getUUID(), copy, append));
+	callAfterCategoryFetch(category->getUUID(),boost::bind(&LLAppearanceMgr::wearCategoryFinal,
+														   &LLAppearanceMgr::instance(),
+														   category->getUUID(), copy, append));
 }
 
 void LLAppearanceMgr::wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append)
diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index f356a04fa4b..78405ebe331 100644
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -660,20 +660,20 @@ LLAssetType::EType LLCOFWearables::getExpandedAccordionAssetType()
 	{
 		const LLAccordionCtrlTab* expanded_tab = mAccordionCtrl->getExpandedTab();
 
-		return get_if_there(mTab2AssetType, expanded_tab, LLAssetType::AT_NONE);
+	return get_if_there(mTab2AssetType, expanded_tab, LLAssetType::AT_NONE);
 	}
 
 	return LLAssetType::AT_NONE;
 }
 
 LLAssetType::EType LLCOFWearables::getSelectedAccordionAssetType()
-{
+	{
 	if (mAccordionCtrl != NULL)
 	{
 		const LLAccordionCtrlTab* selected_tab = mAccordionCtrl->getSelectedTab();
 
-		return get_if_there(mTab2AssetType, selected_tab, LLAssetType::AT_NONE);
-	}
+	return get_if_there(mTab2AssetType, selected_tab, LLAssetType::AT_NONE);
+}
 
 	return LLAssetType::AT_NONE;
 }
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 58a5529505b..8c37133c91c 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -655,21 +655,21 @@ void LLPanelOutfitEdit::onShopButtonClicked()
 		}
 		else
 		{
-			if (type == LLWearableType::WT_NONE)
-			{
-				type = getCOFWearablesSelectionType();
-			}
+		if (type == LLWearableType::WT_NONE)
+		{
+			type = getCOFWearablesSelectionType();
+		}
 
-			ESex sex = gAgentAvatarp->getSex();
+		ESex sex = gAgentAvatarp->getSex();
 
-			// WT_INVALID comes for attachments
-			if (type != LLWearableType::WT_INVALID && type != LLWearableType::WT_NONE)
-			{
-				url = url_resolver.resolveURL(type, sex);
-			}
+		// WT_INVALID comes for attachments
+		if (type != LLWearableType::WT_INVALID && type != LLWearableType::WT_NONE)
+		{
+			url = url_resolver.resolveURL(type, sex);
+		}
 
-			if (url.empty())
-			{
+		if (url.empty())
+		{
 				url = url_resolver.resolveURL(
 						mCOFWearables->getExpandedAccordionAssetType(), sex);
 			}
@@ -866,7 +866,7 @@ void LLPanelOutfitEdit::filterWearablesBySelectedItem(void)
 			LLUUID selected_item_id = mWearableItemsList->getSelectedUUID();
 			LLViewerInventoryItem* item = gInventory.getLinkedItem(selected_item_id);
 			if(item)
-			{
+		{
 				showFilteredWearablesListView(item->getWearableType());
 				return;
 			}
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 9926c8d15f8..a6e8ea032ac 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -936,7 +936,7 @@ void ModifiedCOFCallback::fire(const LLUUID& inv_item)
 	gAgentWearables.editWearableIfRequested(inv_item);
 
 	// TODO: camera mode may not be changed if a debug setting is tweaked
-	if(gAgentCamera.cameraCustomizeAvatar())
+	if( gAgentCamera.cameraCustomizeAvatar() )
 	{
 		// If we're in appearance editing mode, the current tab may need to be refreshed
 		LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index e38608bcfcd..9d4f6fdd0c5 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -2131,7 +2131,7 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so
 void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry::source_callback_list_t* callback_list)
 {
 	if(!callback_list)
-	{
+{
 		mPauseLoadedCallBacks = FALSE ;
 		return ;
 	}
@@ -2160,7 +2160,7 @@ void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry:
 void LLViewerFetchedTexture::pauseLoadedCallbacks(const LLLoadedCallbackEntry::source_callback_list_t* callback_list)
 {
 	if(!callback_list)
-	{
+{
 		return ;
 	}
 
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 68085b1baf0..4fac7fe510c 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2005,8 +2005,8 @@ void LLVOAvatar::updateMeshData()
 				}
 				else
 				{
-					facep->mVertexBuffer->resizeBuffer(num_vertices, num_indices) ;
-				}
+				facep->mVertexBuffer->resizeBuffer(num_vertices, num_indices) ;
+			}
 			}
 		
 			facep->setGeomIndex(0);
@@ -3789,11 +3789,11 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
 		if (needs_rebuild || mDirtyMesh >= 2 || mVisibilityRank <= 4)
 		{
-			updateMeshData();
+		updateMeshData();
 			mDirtyMesh = 0;
-			mNeedsSkin = TRUE;
-			mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
-		}
+		mNeedsSkin = TRUE;
+		mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
+	}
 	}
 
 	if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0)
@@ -4202,7 +4202,7 @@ void LLVOAvatar::checkTextureLoading()
 	{
 		return ; //have not been invisible for enough time.
 	}
-
+	
 	for(LLLoadedCallbackEntry::source_callback_list_t::iterator iter = mCallbackTextureList.begin();
 		iter != mCallbackTextureList.end(); ++iter)
 	{
@@ -4239,7 +4239,7 @@ void LLVOAvatar::addBakedTextureStats( LLViewerFetchedTexture* imagep, F32 pixel
 	//Note:
 	//if this function is not called for the last MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL frames, 
 	//the texture pipeline will stop fetching this texture.
-	
+
 	imagep->resetTextureStats();
 	imagep->setCanUseHTTP(false) ; //turn off http fetching for baked textures.
 	imagep->setMaxVirtualSizeResetInterval(MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL);
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 4163810d6c2..eb622ce7c72 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -623,7 +623,7 @@ class LLVOAvatar :
 public:
 	void			setClothesColor(LLVOAvatarDefines::ETextureIndex te, const LLColor4& new_color, BOOL upload_bake);
 	LLColor4		getClothesColor(LLVOAvatarDefines::ETextureIndex te);
-	static BOOL		teToColorParams(LLVOAvatarDefines::ETextureIndex te, U32 *param_name);
+	static BOOL			teToColorParams(LLVOAvatarDefines::ETextureIndex te, U32 *param_name);
 
 	//--------------------------------------------------------------------
 	// Global colors
@@ -1049,7 +1049,7 @@ class LLVOAvatar :
  *******************************************************************************/
 
 }; // LLVOAvatar
-extern const F32 SELF_ADDITIONAL_PRI;
+extern const F32  SELF_ADDITIONAL_PRI;
 extern const S32 MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL;
 
 #endif // LL_VO_AVATAR_H
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 3a283e7aa6d..bddde08ca98 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -1625,15 +1625,15 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
 					if (isSelf())
 					{
 						if (gAgentAvatarp->isUsingBakedTextures())
-						{
-							requestLayerSetUpdate(type);
-						}
+					{
+						requestLayerSetUpdate(type);
+					}
 						else
-						{
-							LLVisualParamHint::requestHintUpdates();
-						}
+					{
+						LLVisualParamHint::requestHintUpdates();
 					}
 				}
+				}
 				else
 				{					
 					tex->setLoadedCallback(onLocalTextureLoaded, desired_discard, TRUE, FALSE, new LLAvatarTexData(getID(), type), NULL);
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index fe8c09e3290..912741cb5ed 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -569,7 +569,7 @@ bool LLWearableItemTypeNameComparator::sortAssetTypeByName(LLAssetType::EType it
 	}
 
 	return const_it->second.mSortAssetTypeByName;
-}
+	}
 
 bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType item_type) const
 {
@@ -579,7 +579,7 @@ bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType
 	{
 		llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
 		return true;
-	}
+}
 
 	return const_it->second.mSortWearableTypeByName;
 }
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index f2f81968eeb..2e720d13bb8 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -339,8 +339,8 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 	 *     For example by spec in MY OUTFITS the order within each items type(LLAssetType) is:
 	 *     1. AT_OBJECTS (abc order)
 	 *     2. AT_CLOTHINGS
-	 *       - by type (types order determined in LLWearableType::EType)
-	 *       - outer layer on top
+	 *         - by type (types order determined in LLWearableType::EType)
+	 *         - outer layer on top
 	 *     3. AT_BODYPARTS  (abc order)
 	 *---------------------------------------------------------------------------------------------
 	 *
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1dc46a40123..c8f834c7f7e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -635,10 +635,10 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 void LLPipeline::updateRenderDeferred()
 {
 	BOOL deferred = (gSavedSettings.getBOOL("RenderDeferred") && 
-			 LLRenderTarget::sUseFBO &&
+		LLRenderTarget::sUseFBO &&
 			 LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
-			 gSavedSettings.getBOOL("VertexShaderEnable") && 
-			 gSavedSettings.getBOOL("RenderAvatarVP") &&
+		gSavedSettings.getBOOL("VertexShaderEnable") && 
+		gSavedSettings.getBOOL("RenderAvatarVP") &&
 			 (gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE) &&
 		!gUseWireframe;
 	
@@ -1975,8 +1975,8 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 
 	if(drawablep && !drawablep->isDead())
 	{
-		if (drawablep->isSpatialBridge())
-		{
+	if (drawablep->isSpatialBridge())
+	{
 			const LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
 			llassert(root); // trying to catch a bad assumption
 			if (root && //  // this test may not be needed, see above
@@ -1988,24 +1988,24 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 					LLViewerObject *vobj = rootparent->getVObj();
 					llassert(vobj); // trying to catch a bad assumption
 					if (vobj) // this test may not be needed, see above
-					{
+		{
 						const LLVOAvatar* av = vobj->asAvatar();
-						if (av && av->isImpostor())
-						{
-							return;
-						}
-					}
-				}
+			if (av && av->isImpostor())
+			{
+				return;
 			}
-			sCull->pushBridge((LLSpatialBridge*) drawablep);
-		}
-		else
-		{
-			sCull->pushDrawable(drawablep);
 		}
-
-		drawablep->setVisible(camera);
+				}
+			}
+		sCull->pushBridge((LLSpatialBridge*) drawablep);
+	}
+	else
+	{
+		sCull->pushDrawable(drawablep);
 	}
+
+	drawablep->setVisible(camera);
+}
 }
 
 void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion)
@@ -3616,7 +3616,7 @@ void LLPipeline::renderDebug()
 			if (i > 3)
 			{ //render shadow frusta as volumes
 				if (mShadowFrustPoints[i-4].empty())
-				{
+			{
 					continue;
 				}
 
@@ -3649,22 +3649,22 @@ void LLPipeline::renderDebug()
 	
 			if (i < 4)
 			{
-
+				
 				if (i == 0 || !mShadowFrustPoints[i].empty())
 				{
 					//render visible point cloud
 					gGL.flush();
 					glPointSize(8.f);
 					gGL.begin(LLRender::POINTS);
-
+					
 					F32* c = col+i*4;
 					gGL.color3fv(c);
 
 					for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
-					{	
-						gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
+						{
+							gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
 						
-					}
+						}
 					gGL.end();
 
 					gGL.flush();
@@ -3690,7 +3690,7 @@ void LLPipeline::renderDebug()
 					gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV);
 					gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV);
 					gGL.end();
-				}
+					}
 
 			}
 
@@ -4315,7 +4315,7 @@ void LLPipeline::setupAvatarLights(BOOL for_edit)
 		glLightf (GL_LIGHT1, GL_LINEAR_ATTENUATION, 	 0.0f);
 		glLightf (GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.0f);
 		glLightf (GL_LIGHT1, GL_SPOT_EXPONENT, 		 0.0f);
-		glLightf (GL_LIGHT1, GL_SPOT_CUTOFF,		 180.0f);
+		glLightf (GL_LIGHT1, GL_SPOT_CUTOFF, 			 180.0f);
 	}
 	else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini)
 	{
@@ -4631,8 +4631,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 			}
 			else // omnidirectional (point) light
 			{
-				glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
-				glLightf (gllight, GL_SPOT_CUTOFF,   180.0f);
+			glLightf (gllight, GL_SPOT_EXPONENT,          0.0f);
+			glLightf (gllight, GL_SPOT_CUTOFF,            180.0f);
 
 				// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
 				const float specular[] = {0.f, 0.f, 0.f, 1.f};
@@ -4666,7 +4666,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 
 		F32 light_radius = 16.f;
 
-		F32 x = 3.f;
+			F32 x = 3.f;
 		float linatten = x / (light_radius); // % of brightness at radius
 
 		mHWLightColors[2] = light_color;
@@ -6336,13 +6336,13 @@ void LLPipeline::renderDeferredLighting()
 			glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0);
 		}
 
-		glPushMatrix();
-		glLoadIdentity();
-		glMatrixMode(GL_PROJECTION);
-		glPushMatrix();
-		glLoadIdentity();
+			glPushMatrix();
+			glLoadIdentity();
+			glMatrixMode(GL_PROJECTION);
+			glPushMatrix();
+			glLoadIdentity();
 
-		mDeferredLight[0].bindTarget();
+			mDeferredLight[0].bindTarget();
 
 		if (gSavedSettings.getBOOL("RenderDeferredSSAO") || gSavedSettings.getS32("RenderShadowDetail") > 0)
 		{
@@ -6387,19 +6387,19 @@ void LLPipeline::renderDeferredLighting()
 				unbindDeferredShader(gDeferredSunProgram);
 			}
 		}
-		else
-		{
+			else
+			{
 			glClearColor(1,1,1,1);
-			mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT);
+				mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT);
 			glClearColor(0,0,0,0);
-		}
+			}
 
-		mDeferredLight[0].flush();
+			mDeferredLight[0].flush();
 
 		{ //global illumination specific block (still experimental)
 			if (gSavedSettings.getBOOL("RenderDeferredBlurLight") &&
-				gSavedSettings.getBOOL("RenderDeferredGI"))
-			{ 
+			    gSavedSettings.getBOOL("RenderDeferredGI"))
+			{
 				LLFastTimer ftm(FTM_EDGE_DETECTION);
 				//generate edge map
 				LLGLDisable blend(GL_BLEND);
@@ -6501,75 +6501,75 @@ void LLPipeline::renderDeferredLighting()
 		}
 
 		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
-		{ //soften direct lighting lightmap
-			LLFastTimer ftm(FTM_SOFTEN_SHADOW);
-			//blur lightmap
-			mDeferredLight[1].bindTarget();
+			{ //soften direct lighting lightmap
+				LLFastTimer ftm(FTM_SOFTEN_SHADOW);
+				//blur lightmap
+				mDeferredLight[1].bindTarget();
 
-			glClearColor(1,1,1,1);
-			mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
-			glClearColor(0,0,0,0);
-			
-			bindDeferredShader(gDeferredBlurLightProgram);
+				glClearColor(1,1,1,1);
+				mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
+				glClearColor(0,0,0,0);
+				
+				bindDeferredShader(gDeferredBlurLightProgram);
 
-			LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian");
-			const U32 kern_length = 4;
-			F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize");
-			F32 dist_factor = gSavedSettings.getF32("RenderShadowBlurDistFactor");
+				LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian");
+				const U32 kern_length = 4;
+				F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize");
+				F32 dist_factor = gSavedSettings.getF32("RenderShadowBlurDistFactor");
 
-			// sample symmetrically with the middle sample falling exactly on 0.0
-			F32 x = 0.f;
+				// sample symmetrically with the middle sample falling exactly on 0.0
+				F32 x = 0.f;
 
-			LLVector3 gauss[32]; // xweight, yweight, offset
+				LLVector3 gauss[32]; // xweight, yweight, offset
 
-			for (U32 i = 0; i < kern_length; i++)
-			{
-				gauss[i].mV[0] = llgaussian(x, go.mV[0]);
-				gauss[i].mV[1] = llgaussian(x, go.mV[1]);
-				gauss[i].mV[2] = x;
-				x += 1.f;
-			}
+				for (U32 i = 0; i < kern_length; i++)
+				{
+					gauss[i].mV[0] = llgaussian(x, go.mV[0]);
+					gauss[i].mV[1] = llgaussian(x, go.mV[1]);
+					gauss[i].mV[2] = x;
+					x += 1.f;
+				}
 
-			gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f);
-			gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor);
-			gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV);
-			gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV);
-			gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f));
-		
-			{
-				LLGLDisable blend(GL_BLEND);
-				LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-				stop_glerror();
-				glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
-				stop_glerror();
-			}
+				gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f);
+				gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor);
+				gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV);
+				gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV);
+				gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f));
 			
-			mDeferredLight[1].flush();
-			unbindDeferredShader(gDeferredBlurLightProgram);
+				{
+					LLGLDisable blend(GL_BLEND);
+					LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+					stop_glerror();
+					glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+					stop_glerror();
+				}
+				
+				mDeferredLight[1].flush();
+				unbindDeferredShader(gDeferredBlurLightProgram);
 
-			bindDeferredShader(gDeferredBlurLightProgram, 1);
-			mDeferredLight[0].bindTarget();
+				bindDeferredShader(gDeferredBlurLightProgram, 1);
+				mDeferredLight[0].bindTarget();
 
-			gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f);
+				gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f);
 
-			{
-				LLGLDisable blend(GL_BLEND);
-				LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-				stop_glerror();
-				glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
-				stop_glerror();
+				{
+					LLGLDisable blend(GL_BLEND);
+					LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+					stop_glerror();
+					glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+					stop_glerror();
+				}
+				mDeferredLight[0].flush();
+				unbindDeferredShader(gDeferredBlurLightProgram);
 			}
-			mDeferredLight[0].flush();
-			unbindDeferredShader(gDeferredBlurLightProgram);
-		}
 
-		stop_glerror();
-		glPopMatrix();
-		stop_glerror();
-		glMatrixMode(GL_MODELVIEW);
-		stop_glerror();
-		glPopMatrix();
-		stop_glerror();
+			stop_glerror();
+			glPopMatrix();
+			stop_glerror();
+			glMatrixMode(GL_MODELVIEW);
+			stop_glerror();
+			glPopMatrix();
+			stop_glerror();
 
 		//copy depth and stencil from deferred screen
 		//mScreen.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(),
@@ -7232,7 +7232,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 		LLPipeline::sUseOcclusion = llmin(occlusion, 1);
 		
 		gPipeline.pushRenderTypeMask();
-		
+
 		glh::matrix4f projection = glh_get_current_projection();
 		glh::matrix4f mat;
 
@@ -7322,24 +7322,24 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 				}
 
 				gPipeline.pushRenderTypeMask();
-				
+
 				clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
 									LLPipeline::RENDER_TYPE_GROUND,
 									LLPipeline::RENDER_TYPE_SKY,
 									LLPipeline::RENDER_TYPE_CLOUDS,
 									LLPipeline::END_RENDER_TYPES);	
 
-				S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
+					S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
 				if (detail > 0)
 				{ //mask out selected geometry based on reflection detail
 					if (detail < 4)
 					{
 						clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES);
-						if (detail < 3)
-						{
+					if (detail < 3)
+					{
 							clearRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES);
-							if (detail < 2)
-							{
+						if (detail < 2)
+						{
 								clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES);
 							}
 						}
@@ -7351,15 +7351,15 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 					stateSort(camera, ref_result);
 				}
 				
-				if (LLDrawPoolWater::sNeedsDistortionUpdate)
-				{
+			if (LLDrawPoolWater::sNeedsDistortionUpdate)
+			{
 					if (gSavedSettings.getS32("RenderReflectionDetail") > 0)
-					{
-						gPipeline.grabReferences(ref_result);
-						LLGLUserClipPlane clip_plane(plane, mat, projection);
-						renderGeom(camera);
-					}
+				{
+					gPipeline.grabReferences(ref_result);
+					LLGLUserClipPlane clip_plane(plane, mat, projection);
+					renderGeom(camera);
 				}
+			}	
 
 				gPipeline.popRenderTypeMask();
 			}	
@@ -7663,7 +7663,7 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 
 	//bounding box line segments
 	U32 bs[] = 
-	{
+			{
 		0,1,
 		1,3,
 		3,2,
@@ -7701,9 +7701,9 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 				LLVector3 intersect = v2+line*t;
 				pp.push_back(intersect);
 			}
+			}
 		}
-	}
-
+			
 	//camera frustum line segments
 	const U32 fs[] =
 	{
@@ -7716,7 +7716,7 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 		5,6,
 		6,7,
 		7,4,
-
+	
 		0,4,
 		1,5,
 		2,6,
@@ -7725,7 +7725,7 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 
 	LLVector3 center = (max+min)*0.5f;
 	LLVector3 size = (max-min)*0.5f;
-
+	
 	for (U32 i = 0; i < 12; i++)
 	{
 		for (U32 j = 0; j < 6; ++j)
@@ -7748,17 +7748,17 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 				pp.push_back(intersect);
 			}	
 		}
-	}
-	
+				}
+
 	LLVector3 ext[] = { min-LLVector3(0.05f,0.05f,0.05f),
 		max+LLVector3(0.05f,0.05f,0.05f) };
 
 	for (U32 i = 0; i < pp.size(); ++i)
 	{
 		bool found = true;
-		
-		const F32* p = pp[i].mV;
 
+		const F32* p = pp[i].mV;
+			
 		for (U32 j = 0; j < 3; ++j)
 		{
 			if (p[j] < ext[0].mV[j] ||
@@ -7768,24 +7768,24 @@ BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector
 				break;
 			}
 		}
-			
+				
 		for (U32 j = 0; j < 6; ++j)
 		{
 			const LLPlane& cp = camera.getAgentPlane(j);
 			F32 dist = cp.dist(pp[i]);
 			if (dist > 0.05f) //point is above some plane, not contained
-			{
+					{
 				found = false;
 				break;
-			}
-		}
+						}
+					}
 
-		if (found)
-		{
+					if (found)
+					{
 			fp.push_back(pp[i]);
 		}
 	}
-
+	
 	if (fp.empty())
 	{
 		return FALSE;
@@ -8588,141 +8588,141 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		}
 	}
 
-
+	
 	//hack to disable projector shadows 
 	static bool clear = true;
 	bool gen_shadow = gSavedSettings.getS32("RenderShadowDetail") > 1;
-	
+
 	if (gen_shadow)
 	{
 		clear = true;
-		F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
+	F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
 
-		//update shadow targets
-		for (U32 i = 0; i < 2; i++)
-		{ //for each current shadow
-			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i;
-
-			if (mShadowSpotLight[i].notNull() && 
-				(mShadowSpotLight[i] == mTargetShadowSpotLight[0] ||
-				mShadowSpotLight[i] == mTargetShadowSpotLight[1]))
-			{ //keep this spotlight
-				mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f);
-			}
-			else
-			{ //fade out this light
-				mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f);
-				
-				if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull())
-				{ //faded out, grab one of the pending spots (whichever one isn't already taken)
-					if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2])
-					{
-						mShadowSpotLight[i] = mTargetShadowSpotLight[0];
-					}
-					else
-					{
-						mShadowSpotLight[i] = mTargetShadowSpotLight[1];
-					}
+	//update shadow targets
+	for (U32 i = 0; i < 2; i++)
+	{ //for each current shadow
+		LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i;
+
+		if (mShadowSpotLight[i].notNull() && 
+			(mShadowSpotLight[i] == mTargetShadowSpotLight[0] ||
+			mShadowSpotLight[i] == mTargetShadowSpotLight[1]))
+		{ //keep this spotlight
+			mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f);
+		}
+		else
+		{ //fade out this light
+			mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f);
+			
+			if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull())
+			{ //faded out, grab one of the pending spots (whichever one isn't already taken)
+				if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2])
+				{
+					mShadowSpotLight[i] = mTargetShadowSpotLight[0];
+				}
+				else
+				{
+					mShadowSpotLight[i] = mTargetShadowSpotLight[1];
 				}
 			}
 		}
-		
-		for (S32 i = 0; i < 2; i++)
-		{
-			glh_set_current_modelview(saved_view);
-			glh_set_current_projection(saved_proj);
+	}
 
-			if (mShadowSpotLight[i].isNull())
-			{
-				continue;
-			}
+	for (S32 i = 0; i < 2; i++)
+	{
+		glh_set_current_modelview(saved_view);
+		glh_set_current_projection(saved_proj);
 
-			LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume();
+		if (mShadowSpotLight[i].isNull())
+		{
+			continue;
+		}
 
-			if (!volume)
-			{
-				mShadowSpotLight[i] = NULL;
-				continue;
-			}
+		LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume();
 
-			LLDrawable* drawable = mShadowSpotLight[i];
+		if (!volume)
+		{
+			mShadowSpotLight[i] = NULL;
+			continue;
+		}
 
-			LLVector3 params = volume->getSpotLightParams();
-			F32 fov = params.mV[0];
+		LLDrawable* drawable = mShadowSpotLight[i];
 
-			//get agent->light space matrix (modelview)
-			LLVector3 center = drawable->getPositionAgent();
-			LLQuaternion quat = volume->getRenderRotation();
+		LLVector3 params = volume->getSpotLightParams();
+		F32 fov = params.mV[0];
 
-			//get near clip plane
-			LLVector3 scale = volume->getScale();
-			LLVector3 at_axis(0,0,-scale.mV[2]*0.5f);
-			at_axis *= quat;
+		//get agent->light space matrix (modelview)
+		LLVector3 center = drawable->getPositionAgent();
+		LLQuaternion quat = volume->getRenderRotation();
 
-			LLVector3 np = center+at_axis;
-			at_axis.normVec();
+		//get near clip plane
+		LLVector3 scale = volume->getScale();
+		LLVector3 at_axis(0,0,-scale.mV[2]*0.5f);
+		at_axis *= quat;
 
-			//get origin that has given fov for plane np, at_axis, and given scale
-			F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f);
+		LLVector3 np = center+at_axis;
+		at_axis.normVec();
 
-			LLVector3 origin = np - at_axis*dist;
+		//get origin that has given fov for plane np, at_axis, and given scale
+		F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f);
 
-			LLMatrix4 mat(quat, LLVector4(origin, 1.f));
+		LLVector3 origin = np - at_axis*dist;
 
-			view[i+4] = glh::matrix4f((F32*) mat.mMatrix);
+		LLMatrix4 mat(quat, LLVector4(origin, 1.f));
 
-			view[i+4] = view[i+4].inverse();
+		view[i+4] = glh::matrix4f((F32*) mat.mMatrix);
 
-			//get perspective matrix
-			F32 near_clip = dist+0.01f;
-			F32 width = scale.mV[VX];
-			F32 height = scale.mV[VY];
-			F32 far_clip = dist+volume->getLightRadius()*1.5f;
+		view[i+4] = view[i+4].inverse();
 
-			F32 fovy = fov * RAD_TO_DEG;
-			F32 aspect = width/height;
-			
-			proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip);
+		//get perspective matrix
+		F32 near_clip = dist+0.01f;
+		F32 width = scale.mV[VX];
+		F32 height = scale.mV[VY];
+		F32 far_clip = dist+volume->getLightRadius()*1.5f;
 
-			//translate and scale to from [-1, 1] to [0, 1]
-			glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f,
-							0.f, 0.5f, 0.f, 0.5f,
-							0.f, 0.f, 0.5f, 0.5f,
-							0.f, 0.f, 0.f, 1.f);
+		F32 fovy = fov * RAD_TO_DEG;
+		F32 aspect = width/height;
+		
+		proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip);
 
-			glh_set_current_modelview(view[i+4]);
-			glh_set_current_projection(proj[i+4]);
+		//translate and scale to from [-1, 1] to [0, 1]
+		glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f,
+						0.f, 0.5f, 0.f, 0.5f,
+						0.f, 0.f, 0.5f, 0.5f,
+						0.f, 0.f, 0.f, 1.f);
 
-			mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view;
-			
-			for (U32 j = 0; j < 16; j++)
-			{
-				gGLLastModelView[j] = mShadowModelview[i+4].m[j];
-				gGLLastProjection[j] = mShadowProjection[i+4].m[j];
-			}
+		glh_set_current_modelview(view[i+4]);
+		glh_set_current_projection(proj[i+4]);
+
+		mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view;
+		
+		for (U32 j = 0; j < 16; j++)
+		{
+			gGLLastModelView[j] = mShadowModelview[i+4].m[j];
+			gGLLastProjection[j] = mShadowProjection[i+4].m[j];
+		}
 
-			mShadowModelview[i+4] = view[i+4];
-			mShadowProjection[i+4] = proj[i+4];
+		mShadowModelview[i+4] = view[i+4];
+		mShadowProjection[i+4] = proj[i+4];
 
-			LLCamera shadow_cam = camera;
-			shadow_cam.setFar(far_clip);
-			shadow_cam.setOrigin(origin);
+		LLCamera shadow_cam = camera;
+		shadow_cam.setFar(far_clip);
+		shadow_cam.setOrigin(origin);
 
-			LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
+		LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
 
-			stop_glerror();
+		stop_glerror();
 
-			mShadow[i+4].bindTarget();
-			mShadow[i+4].getViewport(gGLViewport);
+		mShadow[i+4].bindTarget();
+		mShadow[i+4].getViewport(gGLViewport);
 
-			static LLCullResult result[2];
+		static LLCullResult result[2];
 
-			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4;
+		LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4;
 
-			renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE);
+		renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE);
 
-			mShadow[i+4].flush();
- 		}
+		mShadow[i+4].flush();
+ 	}
 	}
 	else
 	{
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index bf1707c13e1..52cf24333f2 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -3395,4 +3395,4 @@
             </menu>
         </menu>
     </menu>
-</menu_bar>
\ No newline at end of file
+</menu_bar>
diff --git a/indra/newview/skins/default/xui/fr/menu_object.xml b/indra/newview/skins/default/xui/fr/menu_object.xml
index 257c44795f8..6492a83e063 100644
--- a/indra/newview/skins/default/xui/fr/menu_object.xml
+++ b/indra/newview/skins/default/xui/fr/menu_object.xml
@@ -1,9 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Object Pie">
-	<menu_item_call label="Toucher" name="Object Touch">
-		<on_enable parameter="Toucher" name="EnableTouch"/>
-	</menu_item_call>
-	<menu_item_call label="Modifier" name="Edit..."/>
+	<menu_item_call label="Toucher" name="Object Touch"/>
+	<menu_item_call label="Éditer" name="Edit..."/>
 	<menu_item_call label="Construire" name="Build"/>
 	<menu_item_call label="Ouvrir" name="Open"/>
 	<menu_item_call label="M&apos;asseoir ici" name="Object Sit"/>
-- 
GitLab


From e0b61911135543df133936f847446063074db85f Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 28 Jul 2010 11:45:01 +0100
Subject: [PATCH 552/683] fix an implicit downcast in font code.

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

diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index c0297eae3e5..6a7eba2712b 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -1167,7 +1167,7 @@ void LLFontGL::drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_
 	else if (shadow == DROP_SHADOW_SOFT)
 	{
 		LLColor4U shadow_color = LLFontGL::sShadowColor;
-		shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH;
+		shadow_color.mV[VALPHA] = U8(color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH);
 		for (S32 pass = 0; pass < 5; pass++)
 		{
 			LLRectf screen_rect_offset = screen_rect;
-- 
GitLab


From 9fe54b19c031c9152426262af33ce7d13873d0f8 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Wed, 28 Jul 2010 14:48:44 +0300
Subject: [PATCH 553/683] No Ticket Just updated comments.

--HG--
branch : product-engine
---
 indra/newview/llinventoryfunctions.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h
index 4a7721098d1..7ff6e57966a 100644
--- a/indra/newview/llinventoryfunctions.h
+++ b/indra/newview/llinventoryfunctions.h
@@ -301,6 +301,7 @@ class LLFindByMask : public LLInventoryCollectFunctor
 
 	virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item)
 	{
+		//converting an inventory type to a bitmap filter mask
 		if(item && (mFilterMask & (1LL << item->getInventoryType())) )
 		{
 			return true;
@@ -314,7 +315,7 @@ class LLFindByMask : public LLInventoryCollectFunctor
 };
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// Class LLFindNonLinksByMask
+// Class LLFindByMask
 //
 //
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
GitLab


From fc84ffcbec21d63e1666e93c9453149acf2f9832 Mon Sep 17 00:00:00 2001
From: Alexei Arabadji <aarabadji@productengine.com>
Date: Wed, 28 Jul 2010 18:27:09 +0300
Subject: [PATCH 554/683] EXT-7015 ADDITIONAL FIX Updated condition of hiding
 wear related context menu entries from "hide if all can't be worn" to "hide
 if any can't be worn".

reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/813/

--HG--
branch : product-engine
---
 indra/newview/llwearableitemslist.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 8ea731cf10e..34f6fbebd62 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -769,7 +769,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 	U32 n_links = 0;				// number of links among the selected items
 	U32 n_editable = 0;				// number of editable items among the selected ones
 
-	bool can_be_worn = false;
+	bool can_be_worn = true;
 
 	for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
 	{
@@ -807,8 +807,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 			++n_already_worn;
 		}
 
-		// if any in trash
-		if (!can_be_worn)
+		if (can_be_worn)
 		{
 			can_be_worn = get_can_item_be_worn(item->getLinkedUUID());
 		}
-- 
GitLab


From 0a5eaf89bc0bbe47290629d465aa0503dd73a513 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Wed, 28 Jul 2010 21:23:14 +0300
Subject: [PATCH 555/683] EXT-8258 ADDITIONAL FIX Enable the 'Trash' button in
 'My Inventory' when a selected item gets worn.

This is an additional fix to the one approved in https://codereview.productengine.com/secondlife/r/772/.

Looks like sometimes get_is_item_worn() fails to determine that an item is actually worn.
I suppose it happens when the item is already linked to COF but not yet known to LLAgentWearables.

So I try fixing it by adding a COF links check to get_is_item_worn(), so that an item is considered worn as soon as it's linked to COF.

Reviewed by Nyx at https://codereview.productengine.com/secondlife/r/822/

--HG--
branch : product-engine
---
 indra/newview/llinventoryfunctions.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 86af76e0a49..303031ab290 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -221,7 +221,13 @@ BOOL get_is_item_worn(const LLUUID& id)
 	const LLViewerInventoryItem* item = gInventory.getItem(id);
 	if (!item)
 		return FALSE;
-	
+
+	// Consider the item as worn if it has links in COF.
+	if (LLAppearanceMgr::instance().isLinkInCOF(id))
+	{
+		return TRUE;
+	}
+
 	switch(item->getType())
 	{
 		case LLAssetType::AT_OBJECT:
-- 
GitLab


From 1229730484ff6121cfd6461b9062c43058045a44 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Thu, 29 Jul 2010 10:29:23 +0300
Subject: [PATCH 556/683] EXT-8429 FIXED Added a workaround to localize server
 hardcoded "Conference" string for incoming ad-hoc chats.

Added a new string "conference-title-incoming" to strings.xml
For now the "Conference" word is localized wherever this session name is shown:
 * IM window title
 * Voice notifications

Further Localization is out of scope of this ticket and will be done in a separate localization cycle.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/816/

--HG--
branch : product-engine
---
 indra/newview/llimview.cpp                    | 19 +++++++++++++++++++
 indra/newview/llimview.h                      |  3 ++-
 .../newview/skins/default/xui/en/strings.xml  |  3 +++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 21313f9df70..9d88c156d37 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -237,6 +237,25 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string&
 		new LLSessionTimeoutTimer(mSessionID, SESSION_INITIALIZATION_TIMEOUT);
 	}
 
+	// *WORKAROUND: for server hard-coded string in indra\newsim\llsimchatterbox.cpp
+	if (isAdHocSessionType() && IM_SESSION_INVITE == type)
+	{
+		// For an ad-hoc incoming chat name is received from the server and is in a form of "<Avatar's name> Conference"
+		// Lets update it to localize the "Conference" word. See EXT-8429.
+		S32 separator_index = mName.rfind(" ");
+		std::string name = mName.substr(0, separator_index);
+		++separator_index;
+		std::string conference_word = mName.substr(separator_index, mName.length());
+
+		// additional check that session name is what we expected
+		if ("Conference" == conference_word)
+		{
+			LLStringUtil::format_map_t args;
+			args["[AGENT_NAME]"] = name;
+			LLTrans::findString(mName, "conference-title-incoming", args);
+		}
+	}
+
 	if (IM_NOTHING_SPECIAL == type)
 	{
 		mCallBackEnabled = LLVoiceClient::getInstance()->isSessionCallBackPossible(mSessionID);
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index ffa8a167974..57d31795cad 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -233,7 +233,8 @@ class LLIMModel :  public LLSingleton<LLIMModel>
 	 * Get a session's name. 
 	 * For a P2P chat - it's an avatar's name, 
 	 * For a group chat - it's a group's name
-	 * For an ad-hoc chat - is received from the server and is in a from of "<Avatar's name> conference"
+	 * For an incoming ad-hoc chat - is received from the server and is in a from of "<Avatar's name> Conference"
+	 *	It is updated in LLIMModel::LLIMSession's constructor to localize the "Conference".
 	 */
 	const std::string& getName(const LLUUID& session_id) const;
 
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 048de700453..9941732c30a 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -3024,6 +3024,9 @@ If you continue to receive this message, contact the [SUPPORT_SITE].
   <string name="conference-title">
     Ad-hoc Conference
   </string>
+  <string name="conference-title-incoming">
+    [AGENT_NAME] Conference
+  </string>
   <string name="inventory_item_offered-im">
     Inventory item offered
   </string>
-- 
GitLab


From d11fc1133a890651c51a2b94ec72407b1681e9a4 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Thu, 29 Jul 2010 13:35:54 +0300
Subject: [PATCH 557/683] EXT-7565 FIXED RECOVER FROM BAD MERGE (Would be nice
 to preserve selection while switching between folder/list view modes)

Added missed (during bad merge 14077:5b5cc4a8642d) code to the llpanloutfitedit(.h/.cpp):
  recover LLPanelOutfitEdit::updateWearablesPanelVerbButtons() and LLPanelOutfitEdit::saveListSelection() methods

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/817/

--HG--
branch : product-engine
---
 indra/newview/llpaneloutfitedit.cpp | 70 ++++++++++++++++++++++++++---
 indra/newview/llpaneloutfitedit.h   |  7 +++
 2 files changed, 71 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index b56cf5c3cec..126830e05d2 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -42,6 +42,7 @@
 #include "lloutfitobserver.h"
 #include "llcofwearables.h"
 #include "llfilteredwearablelist.h"
+#include "llfolderviewitem.h"
 #include "llinventory.h"
 #include "llinventoryitemslist.h"
 #include "llviewercontrol.h"
@@ -328,7 +329,9 @@ BOOL LLPanelOutfitEdit::postBuild()
 
 	childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL);
 	childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL);
+	childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL);
 	childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL);
+	childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL);
 	childSetCommitCallback("wearables_gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
 	childSetCommitCallback("gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
 	childSetCommitCallback("shop_btn_1", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL);
@@ -489,9 +492,7 @@ void LLPanelOutfitEdit::showWearablesListView()
 {
 	if(switchPanels(mInventoryItemsPanel, mWearablesListViewPanel))
 	{
-		mFolderViewBtn->setToggleState(FALSE);
-		mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
-		mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
+		updateWearablesPanelVerbButtons();
 		updateFiltersVisibility();
 	}
 	mListViewBtn->setToggleState(TRUE);
@@ -501,9 +502,7 @@ void LLPanelOutfitEdit::showWearablesFolderView()
 {
 	if(switchPanels(mWearablesListViewPanel, mInventoryItemsPanel))
 	{
-		mListViewBtn->setToggleState(FALSE);
-		mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
-		mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
+		updateWearablesPanelVerbButtons();
 		updateFiltersVisibility();
 	}
 	mFolderViewBtn->setToggleState(TRUE);
@@ -1155,5 +1154,64 @@ void LLPanelOutfitEdit::onCOFChanged()
 	update();
 }
 
+void LLPanelOutfitEdit::updateWearablesPanelVerbButtons()
+{
+	if(mWearablesListViewPanel->getVisible())
+	{
+		mFolderViewBtn->setToggleState(FALSE);
+		mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
+		mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
+	}
+	else if(mInventoryItemsPanel->getVisible())
+	{
+		mListViewBtn->setToggleState(FALSE);
+		mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
+		mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
+	}
+}
+
+void LLPanelOutfitEdit::saveListSelection()
+{
+	if(mWearablesListViewPanel->getVisible())
+	{
+		std::set<LLUUID> selected_ids = mInventoryItemsPanel->getRootFolder()->getSelectionList();
+
+		if(!selected_ids.size()) return;
+
+		mWearableItemsList->resetSelection();
+
+		for (std::set<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
+		{
+			mWearableItemsList->selectItemByUUID(*item_id, true);
+		}
+		mWearableItemsList->scrollToShowFirstSelectedItem();
+	}
+	else if(mInventoryItemsPanel->getVisible())
+	{
+		std::vector<LLUUID> selected_ids;
+		mWearableItemsList->getSelectedUUIDs(selected_ids);
+
+		if(!selected_ids.size()) return;
+
+		mInventoryItemsPanel->clearSelection();
+		LLFolderView* root = mInventoryItemsPanel->getRootFolder();
+
+		if(!root) return;
+
+		for(std::vector<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
+		{
+			LLFolderViewItem* item = root->getItemByID(*item_id);
+			if (!item) continue;
+
+			LLFolderViewFolder* parent = item->getParentFolder();
+			if(parent)
+			{
+				parent->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP);
+			}
+			mInventoryItemsPanel->getRootFolder()->changeSelection(item, TRUE);
+		}
+		mInventoryItemsPanel->getRootFolder()->scrollToShowSelection();
+	}
+}
 
 // EOF
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index 13ceda98a6c..b3394e45a38 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -201,6 +201,13 @@ class LLPanelOutfitEdit : public LLPanel
 	void getCurrentItemUUID(LLUUID& selected_id);
 	void onCOFChanged();
 
+	/**
+	 * Method preserves selection while switching between folder/list view modes
+	*/
+	void saveListSelection();
+
+	void updateWearablesPanelVerbButtons();
+
 	typedef std::pair<LLWearableType::EType, size_t> selection_info_t;
 
 	LLWearableType::EType getCOFWearablesSelectionType() const;
-- 
GitLab


From 90353be438268c71300a5dfaac0a5fb79c71551c Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Thu, 29 Jul 2010 13:37:29 +0300
Subject: [PATCH 558/683] EXT-8179 FIXED (Group profile: 'Save' button remains
 disabled if state of check-boxes was changed during refreshing of 'General'
 accordion)

Disable accordion while refreshing group properties so the user could not change properties during refresh

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/815/

--HG--
branch : product-engine
---
 indra/newview/llpanelgroup.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index 2fc74e138b4..c383d04940c 100644
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -545,6 +545,7 @@ void LLPanelGroup::draw()
 	{
 		mRefreshTimer.stop();
 		childEnable("btn_refresh");
+		childEnable("groups_accordion");
 	}
 
 	LLButton* button_apply = findChild<LLButton>("btn_apply");
@@ -573,6 +574,8 @@ void LLPanelGroup::refreshData()
 	
 	// 5 second timeout
 	childDisable("btn_refresh");
+	childDisable("groups_accordion");
+
 	mRefreshTimer.start();
 	mRefreshTimer.setTimerExpirySec(5);
 }
-- 
GitLab


From 92afbfaf88764e9be75458c5e2b2514e59a0deed Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Thu, 29 Jul 2010 15:52:36 +0300
Subject: [PATCH 559/683] EXT-7706 FIXED Implemented delayed friends cards
 synchronization and filling People/Friends tab with data until it is visible
 to user first time. * Moved location of synchronization of the Friends/All
 inventory folder with friends list from startup to first requesting of data.
 * Also updated "update Friends list" logic to be really trigged only when
 Friends tab is visible to user.

NOTE:
 * Friends List/All is filled with some delay on first opening.

TODO: refactoring is needed to switch code of updating People/nearby list to use the same approach as for Friends.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/805/

--HG--
branch : product-engine
---
 indra/newview/llfriendcard.cpp  | 11 +++++++++++
 indra/newview/llpanelpeople.cpp | 32 +++++++++++++++++++++++++++-----
 indra/newview/llstartup.cpp     |  7 -------
 3 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp
index 7f28e099330..2f4dae0af86 100644
--- a/indra/newview/llfriendcard.cpp
+++ b/indra/newview/llfriendcard.cpp
@@ -299,6 +299,17 @@ void LLFriendCardsManager::collectFriendsLists(folderid_buddies_map_t& folderBud
 {
 	folderBuddiesMap.clear();
 
+	static bool syncronize_friends_folders = true;
+	if (syncronize_friends_folders)
+	{
+		// Checks whether "Friends" and "Friends/All" folders exist in "Calling Cards" folder,
+		// fetches their contents if needed and synchronizes it with buddies list.
+		// If the folders are not found they are created.
+		LLFriendCardsManager::instance().syncFriendCardsFolders();
+		syncronize_friends_folders = false;
+	}
+
+
 	LLInventoryModel::cat_array_t* listFolders;
 	LLInventoryModel::item_array_t* items;
 
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 6dd800c0c6a..3140fe8de12 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -272,6 +272,7 @@ class LLFriendListUpdater : public LLAvatarListUpdater, public LLFriendObserver
 	friend class LLInventoryFriendCardObserver;
 	LLFriendListUpdater(callback_t cb)
 	:	LLAvatarListUpdater(cb, FRIEND_LIST_UPDATE_TIMEOUT)
+	,	mIsActive(false)
 	{
 		LLAvatarTracker::instance().addObserver(this);
 
@@ -290,9 +291,12 @@ class LLFriendListUpdater : public LLAvatarListUpdater, public LLFriendObserver
 
 	/*virtual*/ void changed(U32 mask)
 	{
-		// events can arrive quickly in bulk - we need not process EVERY one of them -
-		// so we wait a short while to let others pile-in, and process them in aggregate.
-		mEventTimer.start();
+		if (mIsActive)
+		{
+			// events can arrive quickly in bulk - we need not process EVERY one of them -
+			// so we wait a short while to let others pile-in, and process them in aggregate.
+			mEventTimer.start();
+		}
 
 		// save-up all the mask-bits which have come-in
 		mMask |= mask;
@@ -301,8 +305,12 @@ class LLFriendListUpdater : public LLAvatarListUpdater, public LLFriendObserver
 
 	/*virtual*/ BOOL tick()
 	{
+		if (!mIsActive) return FALSE;
+
 		if (mMask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE))
+		{
 			updateList();
+		}
 
 		// Stop updates.
 		mEventTimer.stop();
@@ -311,9 +319,20 @@ class LLFriendListUpdater : public LLAvatarListUpdater, public LLFriendObserver
 		return FALSE;
 	}
 
+	// virtual
+	void setActive(bool active)
+	{
+		mIsActive = active;
+		if (active)
+		{
+			tick();
+		}
+	}
+
 private:
 	U32 mMask;
 	LLInventoryFriendCardObserver* mInvObserver;
+	bool mIsActive;
 
 	/**
 	 *	This class is intended for updating Friend List when Inventory Friend Card is added/removed.
@@ -504,8 +523,11 @@ BOOL LLPanelPeople::postBuild()
 	mTabContainer = getChild<LLTabContainer>("tabs");
 	mTabContainer->setCommitCallback(boost::bind(&LLPanelPeople::onTabSelected, this, _2));
 
-	mOnlineFriendList = getChild<LLPanel>(FRIENDS_TAB_NAME)->getChild<LLAvatarList>("avatars_online");
-	mAllFriendList = getChild<LLPanel>(FRIENDS_TAB_NAME)->getChild<LLAvatarList>("avatars_all");
+	LLPanel* friends_tab = getChild<LLPanel>(FRIENDS_TAB_NAME);
+	// updater is active only if panel is visible to user.
+	friends_tab->setVisibleCallback(boost::bind(&Updater::setActive, mFriendListUpdater, _2));
+	mOnlineFriendList = friends_tab->getChild<LLAvatarList>("avatars_online");
+	mAllFriendList = friends_tab->getChild<LLAvatarList>("avatars_all");
 	mOnlineFriendList->setNoItemsCommentText(getString("no_friends_online"));
 	mOnlineFriendList->setShowIcons("FriendsListShowIcons");
 	mAllFriendList->setNoItemsCommentText(getString("no_friends"));
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 1ee73034f64..2475870b178 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -118,7 +118,6 @@
 #include "llinventorybridge.h"
 #include "llinventorymodel.h"
 #include "llinventorymodelbackgroundfetch.h"
-#include "llfriendcard.h"
 #include "llkeyboard.h"
 #include "llloginhandler.h"			// gLoginHandler, SLURL support
 #include "lllogininstance.h" // Host the login module.
@@ -1645,12 +1644,6 @@ bool idle_startup()
 		//all categories loaded. lets create "My Favorites" category
 		gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE,true);
 
-		// Checks whether "Friends" and "Friends/All" folders exist in "Calling Cards" folder,
-		// fetches their contents if needed and synchronizes it with buddies list.
-		// If the folders are not found they are created.
-		LLFriendCardsManager::instance().syncFriendCardsFolders();
-
-
 		// set up callbacks
 		llinfos << "Registering Callbacks" << llendl;
 		LLMessageSystem* msg = gMessageSystem;
-- 
GitLab


From d4657fd42bf2d60b068b9b6fd7f758a2094d48d3 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 29 Jul 2010 14:30:17 +0100
Subject: [PATCH 560/683] remove panel_bars.xml which I can't find any trace of
 being used.

---
 .../skins/default/xui/en/panel_bars.xml        | 18 ------------------
 1 file changed, 18 deletions(-)
 delete mode 100644 indra/newview/skins/default/xui/en/panel_bars.xml

diff --git a/indra/newview/skins/default/xui/en/panel_bars.xml b/indra/newview/skins/default/xui/en/panel_bars.xml
deleted file mode 100644
index 96722ce2780..00000000000
--- a/indra/newview/skins/default/xui/en/panel_bars.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<panel
- follows="left|right|top|bottom"
- height="768"
- layout="topleft"
- left="0"
- mouse_opaque="false"
- name="screen"
- width="1024">
-  <layout_stack name="menu_stack" orientation="vertical" height="768" border_size="0">
-    <panel auto_resize="false" width="1024" name="status_bar" filename="panel_status_bar.xml"/>
-    <panel auto_resize="false" width="1024" height="60" name="navigation bar" filename="panel_navigation_bar.xml"/>
-    <layout_stack name="hud_stack" orientation="horizontal" auto_resize="true" width="1024" height="500" follows="all">
-      <panel auto_resize="true" name="floater_view" height="500"/>
-      <panel auto_resize="false" filename="panel_side_tray.xml" height="500" width="333"/>
-    </layout_stack>
-  </layout_stack>
-</panel>
-- 
GitLab


From 0a32095830703bf5d266f0e75cbe1b1447f70296 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Thu, 29 Jul 2010 17:12:37 +0300
Subject: [PATCH 561/683] EXT-7406 RE FIXED Replaced inventory collector for
 objects to exclude links from the Edit Outfit->Add More panel.

Restored fix that was previosly committed in 76bd52803506 and then somewhy reverted in 5b5cc4a8642d.

--HG--
branch : product-engine
---
 indra/newview/llpaneloutfitedit.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 126830e05d2..8f065aa711b 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -304,7 +304,7 @@ BOOL LLPanelOutfitEdit::postBuild()
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.All"), new LLFindNonLinksByMask(ALL_ITEMS_MASK)));
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Clothing"), new LLIsTypeActual(LLAssetType::AT_CLOTHING)));
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Bodyparts"), new LLIsTypeActual(LLAssetType::AT_BODYPART)));
-	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindByMask(ATTACHMENT_MASK)));;
+	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindNonLinksByMask(ATTACHMENT_MASK)));;
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("shape"), new LLFindActualWearablesOfType(LLWearableType::WT_SHAPE)));
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("skin"), new LLFindActualWearablesOfType(LLWearableType::WT_SKIN)));
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("hair"), new LLFindActualWearablesOfType(LLWearableType::WT_HAIR)));
-- 
GitLab


From 2c0632792101ebe5caedc3335fd9f28824cf1da9 Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Thu, 29 Jul 2010 20:05:53 +0300
Subject: [PATCH 562/683] EXT-8043 FIXED Fixed wrong position of notifications
 when 'Move' or 'View' floaters are open and docked.

Bug was caused by LLDockableFloater's mOverlapsScreenChannel to false only in one of it's constructors. So some floaters got initial value of mOverlapsScreenChannel depending on system- that's why bug reproduced on Windows and didn't reproduce on Linux.

- Moved setting mOverlapsScreenChannel to false into LLDockableFloater's init() which is called by all of it's constructors.

Reviewed by Alexei Arabadji at https://codereview.productengine.com/secondlife/r/818

--HG--
branch : product-engine
---
 indra/llui/lldockablefloater.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp
index 3d8670fef20..4f5fcddbf4c 100644
--- a/indra/llui/lldockablefloater.cpp
+++ b/indra/llui/lldockablefloater.cpp
@@ -49,12 +49,12 @@ void LLDockableFloater::init(LLDockableFloater* thiz)
 	thiz->setCanClose(TRUE);
 	thiz->setCanDock(true);
 	thiz->setCanMinimize(TRUE);
+	thiz->setOverlapsScreenChannel(false);
 }
 
 LLDockableFloater::LLDockableFloater(LLDockControl* dockControl,
 		const LLSD& key, const Params& params) :
 	LLFloater(key, params), mDockControl(dockControl), mUniqueDocking(true)
-	, mOverlapsScreenChannel(false)
 {
 	init(this);
 	mUseTongue = true;
-- 
GitLab


From 4431d603703f9dc2ecb62f889921d9e65b092623 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 29 Jul 2010 11:53:31 -0700
Subject: [PATCH 563/683] fix for truncated text rendering

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

diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index c0297eae3e5..eaff42aaeb7 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -369,7 +369,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 
 	if (right_x)
 	{
-		*right_x = cur_x / sScaleX;
+		*right_x = (cur_x - origin.mV[VX]) / sScaleX;
 	}
 
 	//FIXME: add underline as glyph?
-- 
GitLab


From e69f0f8a02466ab17a9bd90fd4a6451b37fe7cfa Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 29 Jul 2010 11:56:19 -0700
Subject: [PATCH 564/683] fix for vertical truncation of sidebar headers

---
 indra/llui/lltextbase.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index a580345b6cb..4bcf7e69803 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1029,8 +1029,10 @@ void LLTextBase::draw()
 	LLUICtrl::draw();
 
 	{
-		// only clip if we support scrolling or have word wrap turned off
-		LLLocalClipRect clip(doc_rect, !getWordWrap() || mScroller != NULL);
+		// only clip if we support scrolling...
+		// since convention is that text boxes never vertically truncate their contents
+		// regardless of rect bounds
+		LLLocalClipRect clip(doc_rect, mScroller != NULL);
 		drawSelectionBackground();
 		drawText();
 		drawCursor();
-- 
GitLab


From 33ebc9674926eb0fd5679ae8e41d05d790b03de1 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 29 Jul 2010 14:09:23 -0700
Subject: [PATCH 565/683] removed unnecessary hack (no repro for EXT-8259,
 possibly due to other recent lltextbase changes)

---
 indra/newview/llexpandabletextbox.cpp | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp
index 8ccc5fb2484..8c6265fbc26 100644
--- a/indra/newview/llexpandabletextbox.cpp
+++ b/indra/newview/llexpandabletextbox.cpp
@@ -141,13 +141,7 @@ void LLExpandableTextBox::LLTextBoxEx::setText(const LLStringExplicit& text,cons
 	// LLTextBox::setText will obliterate the expander segment, so make sure
 	// we generate it again by clearing mExpanderVisible
 	mExpanderVisible = false;
-
-	// Workaround for EXT-8259: trim text before rendering it.
-	{
-		std::string trimmed_text(text);
-		LLStringUtil::trim(trimmed_text);
-		LLTextEditor::setText(trimmed_text, input_params);
-	}
+	LLTextEditor::setText(text, input_params);
 
 	// text contents have changed, segments are cleared out
 	// so hide the expander and determine if we need it
-- 
GitLab


From 5102e34595bc64275774843e4e8713f2a6e3b58b Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Thu, 29 Jul 2010 15:50:20 -0700
Subject: [PATCH 566/683] Yet more cleanup around llmediadataclient.

In LLVOVolume, added a count of LLMediaDataClientObjectImpl objects referencing each LLVOVolume object.  This allows LLVOVolume::markDead() to skip the relatively expensive calls to removeFromQueue() when the LLVOVolume is known to have no active references.

Refactored LLMediaDataClient and its two child classes so that only LLObjectMediaDataClient has the round-robin queue (LLObjectMediaNavigateClient doesn't need it), and cleaned up some of the virtual function hierarchy around queue processing.

In LLMediaDataClient, added tracking for requests that aren't currently in a queue (i.e. requests that are in flight or waiting for retries) so they can be found when their objects are marked dead.

LLMediaDataClient::Request now directly keeps track of the object ID and face associated with the request.

Removed the "markedSent" concept from requests.  Requests that have been sent are no longer kept in a queue.

The Retry timer now references the Request object instead of the Responder.

Replaced LLMediaDataClient::findOrRemove() with separate template functions for find and remove.
---
 indra/newview/llmediadataclient.cpp           | 817 +++++++++++-------
 indra/newview/llmediadataclient.h             | 168 ++--
 indra/newview/llvovolume.cpp                  |  32 +-
 indra/newview/llvovolume.h                    |   5 +
 .../newview/tests/llmediadataclient_test.cpp  |  95 +-
 5 files changed, 725 insertions(+), 392 deletions(-)

diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp
index f0091d6fdcb..a577776ad05 100755
--- a/indra/newview/llmediadataclient.cpp
+++ b/indra/newview/llmediadataclient.cpp
@@ -97,6 +97,54 @@ const U32 LLMediaDataClient::MAX_ROUND_ROBIN_QUEUE_SIZE = 10000;
 std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::request_queue_t &q);
 std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &q);
 
+template <typename T>
+static typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY)
+{
+	for(typename T::iterator iter = c.begin(); iter != c.end(); ++iter)
+	{
+		if(request->isMatch(*iter, match_type))
+		{
+			return iter;
+		}
+	}
+	
+	return c.end();
+}
+
+template <typename T>
+static typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY)
+{
+	for(typename T::iterator iter = c.begin(); iter != c.end(); ++iter)
+	{
+		if(((*iter)->getID() == id) && ((match_type == LLMediaDataClient::Request::ANY) || (match_type == (*iter)->getType())))
+		{
+			return iter;
+		}
+	}
+	
+	return c.end();
+}
+
+// NOTE: remove_matching_requests will not work correctly for containers where deleting an element may invalidate iterators
+// to other elements in the container (such as std::vector).
+// If the implementation is changed to use a container with this property, this will need to be revisited.
+template <typename T>
+static void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY)
+{
+	for(typename T::iterator iter = c.begin(); iter != c.end();)
+	{
+		typename T::value_type i = *iter;
+		typename T::iterator next = iter;
+		next++;
+		if((i->getID() == id) && ((match_type == LLMediaDataClient::Request::ANY) || (match_type == i->getType())))
+		{
+			i->markDead();
+			c.erase(iter);
+		}
+		iter = next;
+	}
+}
+
 //////////////////////////////////////////////////////////////////////////////////////
 //
 // LLMediaDataClient
@@ -113,107 +161,36 @@ LLMediaDataClient::LLMediaDataClient(F32 queue_timer_delay,
 	  mMaxNumRetries(max_retries),
 	  mMaxSortedQueueSize(max_sorted_queue_size),
 	  mMaxRoundRobinQueueSize(max_round_robin_queue_size),
-	  mQueueTimerIsRunning(false),
-	  mCurrentQueueIsTheSortedQueue(true)
+	  mQueueTimerIsRunning(false)
 {
 }
 
 LLMediaDataClient::~LLMediaDataClient()
 {
 	stopQueueTimer();
-
-	// This should clear the queue, and hopefully call all the destructors.
-	LL_DEBUGS("LLMediaDataClient") << "~LLMediaDataClient destructor: queue: " << 
-		(isEmpty() ? "<empty> " : "<not empty> ") << LL_ENDL;
-	
-	mSortedQueue.clear();
-	mRoundRobinQueue.clear();
 }
 
 bool LLMediaDataClient::isEmpty() const
 {
-	return mSortedQueue.empty() && mRoundRobinQueue.empty();
+	return mQueue.empty();
 }
 
 bool LLMediaDataClient::isInQueue(const LLMediaDataClientObject::ptr_t &object)
 {
-	return (LLMediaDataClient::findOrRemove(mSortedQueue, object, false/*remove*/, LLMediaDataClient::Request::ANY).notNull()
-		|| (LLMediaDataClient::findOrRemove(mRoundRobinQueue, object, false/*remove*/, LLMediaDataClient::Request::ANY).notNull()));
-}
-
-bool LLMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr_t &object)
-{
-	bool removedFromSortedQueue = LLMediaDataClient::findOrRemove(mSortedQueue, object, true/*remove*/, LLMediaDataClient::Request::ANY).notNull();
-	bool removedFromRoundRobinQueue = LLMediaDataClient::findOrRemove(mRoundRobinQueue, object, true/*remove*/, LLMediaDataClient::Request::ANY).notNull();
-	return removedFromSortedQueue || removedFromRoundRobinQueue;
+	if(find_matching_request(mQueue, object->getID()) != mQueue.end())
+		return true;
+	
+	if(find_matching_request(mUnQueuedRequests, object->getID()) != mUnQueuedRequests.end())
+		return true;
+	
+	return false;
 }
 
-//static
-LLMediaDataClient::request_ptr_t LLMediaDataClient::findOrRemove(request_queue_t &queue, const LLMediaDataClientObject::ptr_t &obj, bool remove, LLMediaDataClient::Request::Type type)
+void LLMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr_t &object)
 {
-	request_ptr_t result;
-	request_queue_t::iterator iter = queue.begin();
-	request_queue_t::iterator end = queue.end();
-	while (iter != end)
-	{
-		if (obj->getID() == (*iter)->getObject()->getID() && (type == LLMediaDataClient::Request::ANY || type == (*iter)->getType()))
-		{
-			result = *iter;
-			if (remove) queue.erase(iter);
-			break;
-		}
-		iter++;
-	}
-	return result;
-}
-
-void LLMediaDataClient::enqueue(Request *request)
-{
-	if (request->isNew())
-	{		
-		// Add to sorted queue
-		if (LLMediaDataClient::findOrRemove(mSortedQueue, request->getObject(), true/*remove*/, request->getType()).notNull())
-		{
-			LL_DEBUGS("LLMediaDataClient") << "REMOVING OLD request for " << *request << " ALREADY THERE!" << LL_ENDL;
-		}
-		
-		LL_DEBUGS("LLMediaDataClient") << "Queuing SORTED request for " << *request << LL_ENDL;
-		
-		mSortedQueue.push_back(request);
-		
-		LL_DEBUGS("LLMediaDataClientQueue") << "SORTED queue:" << mSortedQueue << LL_ENDL;
-	}
-	else {
-		if (mRoundRobinQueue.size() > mMaxRoundRobinQueueSize) 
-		{
-			LL_INFOS_ONCE("LLMediaDataClient") << "RR QUEUE MAXED OUT!!!" << LL_ENDL;
-			LL_DEBUGS("LLMediaDataClient") << "Not queuing " << *request << LL_ENDL;
-			return;
-		}
-				
-		// ROUND ROBIN: if it is there, and it is a GET request, leave it.  If not, put at front!		
-		request_ptr_t existing_request;
-		if (request->getType() == Request::GET)
-		{
-			existing_request = LLMediaDataClient::findOrRemove(mRoundRobinQueue, request->getObject(), false/*remove*/, request->getType());
-		}
-		if (existing_request.isNull())
-		{
-			LL_DEBUGS("LLMediaDataClient") << "Queuing RR request for " << *request << LL_ENDL;
-			// Push the request on the pending queue
-			mRoundRobinQueue.push_front(request);
-			
-			LL_DEBUGS("LLMediaDataClientQueue") << "RR queue:" << mRoundRobinQueue << LL_ENDL;			
-		}
-		else
-		{
-			LL_DEBUGS("LLMediaDataClient") << "ALREADY THERE: NOT Queuing request for " << *request << LL_ENDL;
-						
-			existing_request->markSent(false);
-		}
-	}	
-	// Start the timer if not already running
-	startQueueTimer();
+	LL_DEBUGS("LLMediaDataClient") << "removing requests matching ID " << object->getID() << LL_ENDL;
+	remove_matching_requests(mQueue, object->getID());
+	remove_matching_requests(mUnQueuedRequests, object->getID());
 }
 
 void LLMediaDataClient::startQueueTimer() 
@@ -225,7 +202,7 @@ void LLMediaDataClient::startQueueTimer()
 		new QueueTimer(mQueueTimerDelay, this);
 	}
 	else { 
-		LL_DEBUGS("LLMediaDataClient") << "not starting queue timer (it's already running, right???)" << LL_ENDL;
+		LL_DEBUGS("LLMediaDataClient") << "queue timer is already running" << LL_ENDL;
 	}
 }
 
@@ -236,227 +213,138 @@ void LLMediaDataClient::stopQueueTimer()
 
 bool LLMediaDataClient::processQueueTimer()
 {
-	sortQueue();
-	
-	if(!isEmpty())
-	{
-		LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() started, SORTED queue size is:	  " << mSortedQueue.size() 
-			<< ", RR queue size is:	  " << mRoundRobinQueue.size() << LL_ENDL;
-		LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() started, SORTED queue is:	  " << mSortedQueue << LL_ENDL;
-		LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() started, RR queue is:	  " << mRoundRobinQueue << LL_ENDL;
-	}
-	
+	if(isEmpty())
+		return true;
+
+	LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() started, queue size is:	  " << mQueue.size() << LL_ENDL;
+	LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() started, SORTED queue is:	  " << mQueue << LL_ENDL;
+			
 	serviceQueue();
 	
-	LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() finished, SORTED queue size is:	  " << mSortedQueue.size() 
-		<< ", RR queue size is:	  " << mRoundRobinQueue.size() << LL_ENDL;
-	LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() finished, SORTED queue is:	  " << mSortedQueue << LL_ENDL;
-	LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() finished, RR queue is:	  " << mRoundRobinQueue << LL_ENDL;
+	LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() finished, queue size is:	  " << mQueue.size() << LL_ENDL;
+	LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() finished, SORTED queue is:	  " << mQueue << LL_ENDL;
 	
 	return isEmpty();
 }
 
-bool LLMediaDataClient::request_needs_purge(LLMediaDataClient::request_ptr_t request)
+LLMediaDataClient::request_ptr_t LLMediaDataClient::dequeue()
 {
-	// Check for conditions that should cause a request to get removed from the queue
-	if(request.isNull())
-	{
-		LL_WARNS("LLMediaDataClient") << "removing NULL request" << LL_ENDL;
-		return true;
-	}
-
-	// For some reason, the existing code put sent items onto the back of the round-robin queue and let them come through again
-	// before stripping them off the front.  Was there a good reason for this?
-//	if(request->isMarkedSent())
-//	{
-//		LL_INFOS("LLMediaDataClient") << "removing : " << *request << " request is marked sent" << LL_ENDL;
-//		return true;
-//	}
-
-	const LLMediaDataClientObject *object = request->getObject();
+	request_ptr_t request;
+	request_queue_t *queue_p = getQueue();
 	
-	if(object == NULL)
+	if (queue_p->empty())
 	{
-		LL_INFOS("LLMediaDataClient") << "removing : " << *request << " object is NULL" << LL_ENDL;
-		return true;
+		LL_DEBUGS("LLMediaDataClient") << "queue empty: " << (*queue_p) << LL_ENDL;
 	}
-	
-	if(object->isDead())
-	{
-		LL_INFOS("LLMediaDataClient") << "removing : " << *request << " object is dead" << LL_ENDL;
-		return true;
-	}
-	
-	if(!object->hasMedia())
+	else
 	{
-		LL_INFOS("LLMediaDataClient") << "removing : " << *request << " object has no media" << LL_ENDL;
-		return true;
+		request = queue_p->front();
+		
+		if(canServiceRequest(request))
+		{
+			// We will be returning this request, so remove it from the queue.
+			queue_p->pop_front();
+		}
+		else
+		{
+			// Don't return this request -- it's not ready to be serviced.
+			request = NULL;
+		}
 	}
 
-	return false;	
+	return request;
+}
+
+void LLMediaDataClient::pushBack(request_ptr_t request)
+{
+	request_queue_t *queue_p = getQueue();
+	queue_p->push_front(request);
 }
 
-void LLMediaDataClient::sortQueue()
+void LLMediaDataClient::trackRequest(request_ptr_t request)
 {
-	if(!mSortedQueue.empty())
+	request_set_t::iterator iter = mUnQueuedRequests.lower_bound(request);
+	
+	if(*iter == request)
 	{
-		// Cull dead objects and score all remaining items first
-		request_queue_t::iterator iter = mSortedQueue.begin();
-		request_queue_t::iterator end = mSortedQueue.end();
-		while (iter != end)
-		{
-			if(request_needs_purge(*iter))
-			{
-				iter = mSortedQueue.erase(iter);
-			}
-			else
-			{
-				(*iter)->updateScore();
-				iter++;
-			}
-		}
-		
-		// Re-sort the list...
-		// NOTE: should this be a stable_sort?  If so we need to change to using a vector.
-		mSortedQueue.sort(LLMediaDataClient::compareRequests);
-		
-		// ...then cull items over the max
-		U32 size = mSortedQueue.size();
-		if (size > mMaxSortedQueueSize) 
-		{
-			U32 num_to_cull = (size - mMaxSortedQueueSize);
-			LL_INFOS_ONCE("LLMediaDataClient") << "sorted queue MAXED OUT!  Culling " 
-				<< num_to_cull << " items" << LL_ENDL;
-			while (num_to_cull-- > 0)
-			{
-				mSortedQueue.pop_back();
-			}
-		}
+		LL_WARNS("LLMediaDataClient") << "Tracking already tracked request: " << *request << LL_ENDL;
 	}
-	
-	// Cull dead items from the round robin queue as well.
-	for(request_queue_t::iterator iter = mRoundRobinQueue.begin(); iter != mRoundRobinQueue.end();)
+	else
 	{
-		if(request_needs_purge(*iter))
-		{
-			iter = mRoundRobinQueue.erase(iter);
-		}
-		else
-		{
-			iter++;
-		}
+		mUnQueuedRequests.insert(iter, request);
 	}
 }
 
-// static
-bool LLMediaDataClient::compareRequests(const request_ptr_t &o1, const request_ptr_t &o2)
+void LLMediaDataClient::stopTrackingRequest(request_ptr_t request)
 {
-	if (o2.isNull()) return true;
-	if (o1.isNull()) return false;
-	return ( o1->getScore() > o2->getScore() );
+	request_set_t::iterator iter = mUnQueuedRequests.find(request);
+	
+	if(*iter == request)
+	{
+		mUnQueuedRequests.erase(iter);
+	}
+	else
+	{
+		LL_WARNS("LLMediaDataClient") << "Removing an untracked request: " << *request << LL_ENDL;
+	}
 }
 
 void LLMediaDataClient::serviceQueue()
 {	
-	request_queue_t *queue_p = getCurrentQueue();
+	// Peel one off of the items from the queue and execute it
+	request_ptr_t request;
 	
-	// quick retry loop for cases where we shouldn't wait for the next timer tick
-	while(true)
+	do
 	{
-		if (queue_p->empty())
+		request = dequeue();
+
+		if(request.isNull())
 		{
-			LL_DEBUGS("LLMediaDataClient") << "queue empty: " << (*queue_p) << LL_ENDL;
-			break;
+			// Queue is empty.
+			return;
 		}
-		
-		// Peel one off of the items from the queue, and execute request
-		request_ptr_t request = queue_p->front();
-		llassert(!request.isNull());
-		const LLMediaDataClientObject *object = (request.isNull()) ? NULL : request->getObject();
-		llassert(NULL != object);
-
-		// Check for conditions that would make us just pop and rapidly loop through
-		// the queue.
-		if(request->isMarkedSent())
+
+		if(request->isDead())
 		{
-			// Sent items that make it back to the head of the queue need to be skipped.
-			LL_INFOS("LLMediaDataClient") << "removing : " << *request << " request is marked sent" << LL_ENDL;
-			
-			queue_p->pop_front();
-			continue;	// jump back to the start of the quick retry loop
+			LL_INFOS("LLMediaDataClient") << "Skipping dead request " << *request << LL_ENDL;
+			continue;
 		}
+
+	} while(false);
 		
-		// Next, ask if this is "interesting enough" to fetch.  If not, just stop
-		// and wait for the next timer go-round.  Only do this for the sorted 
-		// queue.
-		if (mCurrentQueueIsTheSortedQueue && !object->isInterestingEnough())
-		{
-			LL_DEBUGS("LLMediaDataClient") << "Not fetching " << *request << ": not interesting enough" << LL_ENDL;
-			break;
-		}
+	// try to send the HTTP message to the cap url
+	std::string url = request->getCapability();
+	if (!url.empty())
+	{
+		const LLSD &sd_payload = request->getPayload();
+		LL_INFOS("LLMediaDataClient") << "Sending request for " << *request << LL_ENDL;
 		
-		// Finally, try to send the HTTP message to the cap url
-		std::string url = request->getCapability();
-		bool maybe_retry = false;
-		if (!url.empty())
-		{
-			const LLSD &sd_payload = request->getPayload();
-			LL_INFOS("LLMediaDataClient") << "Sending request for " << *request << LL_ENDL;
-			
-			// Call the subclass for creating the responder
-			LLHTTPClient::post(url, sd_payload, request->createResponder());
-		}
-		else {
-			LL_INFOS("LLMediaDataClient") << "NOT Sending request for " << *request << ": empty cap url!" << LL_ENDL;
-			maybe_retry = true;
-		}
-
-		bool exceeded_retries = request->getRetryCount() > mMaxNumRetries;
-		if (maybe_retry && ! exceeded_retries) // Try N times before giving up 
+		// Add this request to the non-queued tracking list
+		trackRequest(request);
+		
+		// and make the post
+		LLHTTPClient::post(url, sd_payload, request->createResponder());
+	}
+	else 
+	{
+		// Cap url doesn't exist.
+		
+		if(request->getRetryCount() < mMaxNumRetries)
 		{
-			// We got an empty cap, but in that case we will retry again next
-			// timer fire.
+			LL_WARNS("LLMediaDataClient") << "Could not send request " << *request << " (empty cap url), will retry." << LL_ENDL; 
+			// Put this request back at the head of its queue, and retry next time the queue timer fires.
 			request->incRetryCount();
+			pushBack(request);
 		}
-		else {
-			if (exceeded_retries)
-			{
-				LL_WARNS("LLMediaDataClient") << "Could not send request " << *request << " for " 
-					<< mMaxNumRetries << " tries...popping object id " << object->getID() << LL_ENDL; 
-				// XXX Should we bring up a warning dialog??
-			}
-			
-			queue_p->pop_front();
-			
-			if (! mCurrentQueueIsTheSortedQueue) {
-				// Round robin
-				request->markSent(true);
-				mRoundRobinQueue.push_back(request);				
-			}
+		else
+		{
+			// This request has exceeded its maxumim retry count.  It will be dropped.
+			LL_WARNS("LLMediaDataClient") << "Could not send request " << *request << " for " << mMaxNumRetries << " tries, dropping request." << LL_ENDL; 
 		}
-		
- 		// end of quick loop -- any cases where we want to loop will use 'continue' to jump back to the start.
- 		break;
-	}
-	
-	swapCurrentQueue();
-}
 
-void LLMediaDataClient::swapCurrentQueue()
-{
-	// Swap
-	mCurrentQueueIsTheSortedQueue = !mCurrentQueueIsTheSortedQueue;
-	// If its empty, swap back
-	if (getCurrentQueue()->empty()) 
-	{
-		mCurrentQueueIsTheSortedQueue = !mCurrentQueueIsTheSortedQueue;
 	}
 }
 
-LLMediaDataClient::request_queue_t *LLMediaDataClient::getCurrentQueue()
-{
-	return (mCurrentQueueIsTheSortedQueue) ? &mSortedQueue : &mRoundRobinQueue;
-}
 
 // dump the queue
 std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::request_queue_t &q)
@@ -466,7 +354,7 @@ std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::request_queue
 	LLMediaDataClient::request_queue_t::const_iterator end = q.end();
 	while (iter != end)
 	{
-		s << "\t" << i << "]: " << (*iter)->getObject()->getID().asString() << "(" << (*iter)->getObject()->getMediaInterest() << ")";
+		s << "\t" << i << "]: " << (*iter)->getID().asString() << "(" << (*iter)->getObject()->getMediaInterest() << ")";
 		iter++;
 		i++;
 	}
@@ -513,19 +401,29 @@ BOOL LLMediaDataClient::QueueTimer::tick()
 //
 //////////////////////////////////////////////////////////////////////////////////////
 
-LLMediaDataClient::Responder::RetryTimer::RetryTimer(F32 time, Responder *mdr)
-: LLEventTimer(time), mResponder(mdr)
+LLMediaDataClient::RetryTimer::RetryTimer(F32 time, request_ptr_t request)
+: LLEventTimer(time), mRequest(request)
 {
+	mRequest->startTracking();
 }
 
 // virtual
-BOOL LLMediaDataClient::Responder::RetryTimer::tick()
+BOOL LLMediaDataClient::RetryTimer::tick()
 {
-	LL_INFOS("LLMediaDataClient") << "RetryTimer fired for: " << *(mResponder->getRequest()) << " retrying" << LL_ENDL;
-	mResponder->getRequest()->reEnqueue();
+	mRequest->stopTracking();
+
+	if(mRequest->isDead())
+	{
+		LL_INFOS("LLMediaDataClient") << "RetryTimer fired for dead request: " << *mRequest << ", aborting." << LL_ENDL;
+	}
+	else
+	{
+		LL_INFOS("LLMediaDataClient") << "RetryTimer fired for: " << *mRequest << ", retrying." << LL_ENDL;
+		mRequest->reEnqueue();
+	}
 	
-	// Release the ref to the responder.
-	mResponder = NULL;
+	// Release the ref to the request.
+	mRequest = NULL;
 
 	// Don't fire again
 	return TRUE;
@@ -541,25 +439,35 @@ BOOL LLMediaDataClient::Responder::RetryTimer::tick()
 
 LLMediaDataClient::Request::Request(Type in_type,
 									LLMediaDataClientObject *obj, 
-									LLMediaDataClient *mdc)
+									LLMediaDataClient *mdc,
+									S32 face)
 : mType(in_type),
   mObject(obj),
   mNum(++sNum), 
   mRetryCount(0),
   mMDC(mdc),
-  mMarkedSent(false),
-  mScore((F64)0.0)
+  mScore((F64)0.0),
+  mFace(face)
 {
+	mObjectID = mObject->getID();
 }
 
 const char *LLMediaDataClient::Request::getCapName() const
 {
-	return mMDC->getCapabilityName();
+	if(mMDC)
+		return mMDC->getCapabilityName();
+	
+	return "";
 }
 
 std::string LLMediaDataClient::Request::getCapability() const
 {
-	return getObject()->getCapabilityUrl(getCapName());
+	if(mMDC)
+	{
+		return getObject()->getCapabilityUrl(getCapName());
+	}
+	
+	return "";
 }
 
 const char *LLMediaDataClient::Request::getTypeAsString() const
@@ -586,31 +494,28 @@ const char *LLMediaDataClient::Request::getTypeAsString() const
 
 void LLMediaDataClient::Request::reEnqueue()
 {
-	mMDC->enqueue(this);
+	if(mMDC)
+	{
+		mMDC->enqueue(this);
+	}
 }
 
 F32 LLMediaDataClient::Request::getRetryTimerDelay() const
 {
-	return mMDC->mRetryTimerDelay; 
+	if(mMDC)
+		return mMDC->mRetryTimerDelay; 
+		
+	return 0.0f;
 }
 
 U32 LLMediaDataClient::Request::getMaxNumRetries() const
 {
-	return mMDC->mMaxNumRetries;
+	if(mMDC)
+		return mMDC->mMaxNumRetries;
+	
+	return 0;
 }
 
-void LLMediaDataClient::Request::markSent(bool flag)
-{
-	 if (mMarkedSent != flag)
-	 {
-		 mMarkedSent = flag;
-		 if (!mMarkedSent)
-		 {
-			 mNum = ++sNum;
-		 }
-	 }
-}
-		   
 void LLMediaDataClient::Request::updateScore()
 {				
 	F64 tmp = mObject->getMediaInterest();
@@ -621,15 +526,37 @@ void LLMediaDataClient::Request::updateScore()
 	}
 }
 		   
+void LLMediaDataClient::Request::markDead() 
+{ 
+	mMDC = NULL;
+}
+
+bool LLMediaDataClient::Request::isDead() 
+{ 
+	return ((mMDC == NULL) || mObject->isDead()); 
+}
+
+void LLMediaDataClient::Request::startTracking() 
+{ 
+	if(mMDC) 
+		mMDC->trackRequest(this); 
+}
+
+void LLMediaDataClient::Request::stopTracking() 
+{ 
+	if(mMDC) 
+		mMDC->stopTrackingRequest(this); 
+}
+
 std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &r)
 {
 	s << "request: num=" << r.getNum() 
 	<< " type=" << r.getTypeAsString() 
-	<< " ID=" << r.getObject()->getID() 
+	<< " ID=" << r.getID() 
+	<< " face=" << r.getFace() 
 	<< " #retries=" << r.getRetryCount();
 	return s;
 }
-
 			
 //////////////////////////////////////////////////////////////////////////////////////
 //
@@ -645,6 +572,14 @@ LLMediaDataClient::Responder::Responder(const request_ptr_t &request)
 /*virtual*/
 void LLMediaDataClient::Responder::error(U32 status, const std::string& reason)
 {
+	mRequest->stopTracking();
+
+	if(mRequest->isDead())
+	{
+		LL_WARNS("LLMediaDataClient") << "dead request " << *mRequest << LL_ENDL;
+		return;
+	}
+	
 	if (status == HTTP_SERVICE_UNAVAILABLE)
 	{
 		F32 retry_timeout = mRequest->getRetryTimerDelay();
@@ -657,14 +592,16 @@ void LLMediaDataClient::Responder::error(U32 status, const std::string& reason)
 			
 			// Start timer (instances are automagically tracked by
 			// InstanceTracker<> and LLEventTimer)
-			new RetryTimer(F32(retry_timeout/*secs*/), this);
+			new RetryTimer(F32(retry_timeout/*secs*/), mRequest);
 		}
-		else {
+		else 
+		{
 			LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retry count " 
 				<< mRequest->getRetryCount() << " exceeds " << mRequest->getMaxNumRetries() << ", not retrying" << LL_ENDL;
 		}
 	}
-	else {
+	else 
+	{
 		std::string msg = boost::lexical_cast<std::string>(status) + ": " + reason;
 		LL_WARNS("LLMediaDataClient") << *mRequest << " http error(" << msg << ")" << LL_ENDL;
 	}
@@ -673,6 +610,14 @@ void LLMediaDataClient::Responder::error(U32 status, const std::string& reason)
 /*virtual*/
 void LLMediaDataClient::Responder::result(const LLSD& content)
 {
+	mRequest->stopTracking();
+
+	if(mRequest->isDead())
+	{
+		LL_WARNS("LLMediaDataClient") << "dead request " << *mRequest << LL_ENDL;
+		return;
+	}
+
 	LL_DEBUGS("LLMediaDataClientResponse") << *mRequest << " result : " << ll_print_sd(content) << LL_ENDL;
 }
 
@@ -683,15 +628,200 @@ void LLMediaDataClient::Responder::result(const LLSD& content)
 //
 //////////////////////////////////////////////////////////////////////////////////////
 
+void LLObjectMediaDataClient::fetchMedia(LLMediaDataClientObject *object)
+{
+	// Create a get request and put it in the queue.
+	enqueue(new RequestGet(object, this));
+}
+
 const char *LLObjectMediaDataClient::getCapabilityName() const 
 {
 	return "ObjectMedia";
 }
 
-void LLObjectMediaDataClient::fetchMedia(LLMediaDataClientObject *object)
+LLObjectMediaDataClient::request_queue_t *LLObjectMediaDataClient::getQueue()
 {
-	// Create a get request and put it in the queue.
-	enqueue(new RequestGet(object, this));
+	return (mCurrentQueueIsTheSortedQueue) ? &mQueue : &mRoundRobinQueue;
+}
+
+void LLObjectMediaDataClient::sortQueue()
+{
+	if(!mQueue.empty())
+	{
+		// score all elements in the sorted queue.
+		for(request_queue_t::iterator iter = mQueue.begin(); iter != mQueue.end(); iter++)
+		{
+			(*iter)->updateScore();
+		}
+		
+		// Re-sort the list...
+		mQueue.sort(compareRequestScores);
+		
+		// ...then cull items over the max
+		U32 size = mQueue.size();
+		if (size > mMaxSortedQueueSize) 
+		{
+			U32 num_to_cull = (size - mMaxSortedQueueSize);
+			LL_INFOS_ONCE("LLMediaDataClient") << "sorted queue MAXED OUT!  Culling " 
+				<< num_to_cull << " items" << LL_ENDL;
+			while (num_to_cull-- > 0)
+			{
+				mQueue.back()->markDead();
+				mQueue.pop_back();
+			}
+		}
+	}
+	
+}
+
+// static
+bool LLObjectMediaDataClient::compareRequestScores(const request_ptr_t &o1, const request_ptr_t &o2)
+{
+	if (o2.isNull()) return true;
+	if (o1.isNull()) return false;
+	return ( o1->getScore() > o2->getScore() );
+}
+
+void LLObjectMediaDataClient::enqueue(Request *request)
+{
+	if(request->isDead())
+	{
+		LL_DEBUGS("LLMediaDataClient") << "not queueing dead request " << *request << LL_ENDL;
+		return;
+	}
+
+	// Invariants:
+	// new requests always go into the sorted queue.
+	//  
+	
+	bool is_new = request->isNew();
+	
+	if(!is_new && (request->getType() == Request::GET))
+	{
+		// For GET requests that are not new, if a matching request is already in the round robin queue, 
+		// in flight, or being retried, leave it at its current position.
+		request_queue_t::iterator iter = find_matching_request(mRoundRobinQueue, request->getID(), Request::GET);
+		request_set_t::iterator iter2 = find_matching_request(mUnQueuedRequests, request->getID(), Request::GET);
+		
+		if( (iter != mRoundRobinQueue.end()) || (iter2 != mUnQueuedRequests.end()) )
+		{
+			LL_DEBUGS("LLMediaDataClient") << "ALREADY THERE: NOT Queuing request for " << *request << LL_ENDL;
+
+			return;
+		}
+	}
+	
+	// TODO: should an UPDATE cause pending GET requests for the same object to be removed from the queue?
+	// IF the update will cause an object update message to be sent out at some point in the future, it probably should.
+	
+	// Remove any existing requests of this type for this object
+	remove_matching_requests(mQueue, request->getID(), request->getType());
+	remove_matching_requests(mRoundRobinQueue, request->getID(), request->getType());
+	remove_matching_requests(mUnQueuedRequests, request->getID(), request->getType());
+
+	if (is_new)
+	{
+		LL_DEBUGS("LLMediaDataClient") << "Queuing SORTED request for " << *request << LL_ENDL;
+		
+		mQueue.push_back(request);
+		
+		LL_DEBUGS("LLMediaDataClientQueue") << "SORTED queue:" << mQueue << LL_ENDL;
+	}
+	else
+	{
+		if (mRoundRobinQueue.size() > mMaxRoundRobinQueueSize) 
+		{
+			LL_INFOS_ONCE("LLMediaDataClient") << "RR QUEUE MAXED OUT!!!" << LL_ENDL;
+			LL_DEBUGS("LLMediaDataClient") << "Not queuing " << *request << LL_ENDL;
+			return;
+		}
+				
+		LL_DEBUGS("LLMediaDataClient") << "Queuing RR request for " << *request << LL_ENDL;
+		// Push the request on the pending queue
+		mRoundRobinQueue.push_back(request);
+		
+		LL_DEBUGS("LLMediaDataClientQueue") << "RR queue:" << mRoundRobinQueue << LL_ENDL;			
+	}	
+	// Start the timer if not already running
+	startQueueTimer();
+}
+
+bool LLObjectMediaDataClient::canServiceRequest(request_ptr_t request) 
+{
+	if(mCurrentQueueIsTheSortedQueue)
+	{
+		if(!request->getObject()->isInterestingEnough())
+		{
+			LL_DEBUGS("LLMediaDataClient") << "Not fetching " << *request << ": not interesting enough" << LL_ENDL;
+			return false;
+		}
+	}
+	
+	return true; 
+};
+
+void LLObjectMediaDataClient::swapCurrentQueue()
+{
+	// Swap
+	mCurrentQueueIsTheSortedQueue = !mCurrentQueueIsTheSortedQueue;
+	// If its empty, swap back
+	if (getQueue()->empty()) 
+	{
+		mCurrentQueueIsTheSortedQueue = !mCurrentQueueIsTheSortedQueue;
+	}
+}
+
+bool LLObjectMediaDataClient::isEmpty() const
+{
+	return mQueue.empty() && mRoundRobinQueue.empty();
+}
+
+bool LLObjectMediaDataClient::isInQueue(const LLMediaDataClientObject::ptr_t &object)
+{
+	// First, call parent impl.
+	if(LLMediaDataClient::isInQueue(object))
+		return true;
+
+	if(find_matching_request(mRoundRobinQueue, object->getID()) != mRoundRobinQueue.end())
+		return true;
+	
+	return false;
+}
+
+void LLObjectMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr_t &object)
+{
+	// First, call parent impl.
+	LLMediaDataClient::removeFromQueue(object);
+	
+	remove_matching_requests(mRoundRobinQueue, object->getID());
+}
+
+bool LLObjectMediaDataClient::processQueueTimer()
+{
+	if(isEmpty())
+		return true;
+		
+	LL_DEBUGS("LLMediaDataClient") << "started, SORTED queue size is:	  " << mQueue.size() 
+		<< ", RR queue size is:	  " << mRoundRobinQueue.size() << LL_ENDL;
+	LL_DEBUGS("LLMediaDataClientQueue") << "    SORTED queue is:	  " << mQueue << LL_ENDL;
+	LL_DEBUGS("LLMediaDataClientQueue") << "    RR queue is:	  " << mRoundRobinQueue << LL_ENDL;
+
+//	purgeDeadRequests();
+
+	sortQueue();
+
+	LL_DEBUGS("LLMediaDataClientQueue") << "after sort, SORTED queue is:	  " << mQueue << LL_ENDL;
+	
+	serviceQueue();
+
+	swapCurrentQueue();
+	
+	LL_DEBUGS("LLMediaDataClient") << "finished, SORTED queue size is:	  " << mQueue.size() 
+		<< ", RR queue size is:	  " << mRoundRobinQueue.size() << LL_ENDL;
+	LL_DEBUGS("LLMediaDataClientQueue") << "    SORTED queue is:	  " << mQueue << LL_ENDL;
+	LL_DEBUGS("LLMediaDataClientQueue") << "    RR queue is:	  " << mRoundRobinQueue << LL_ENDL;
+	
+	return isEmpty();
 }
 
 LLObjectMediaDataClient::RequestGet::RequestGet(LLMediaDataClientObject *obj, LLMediaDataClient *mdc):
@@ -754,6 +884,14 @@ LLMediaDataClient::Responder *LLObjectMediaDataClient::RequestUpdate::createResp
 /*virtual*/
 void LLObjectMediaDataClient::Responder::result(const LLSD& content)
 {
+	getRequest()->stopTracking();
+
+	if(getRequest()->isDead())
+	{
+		LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL;
+		return;
+	}
+
 	// This responder is only used for GET requests, not UPDATE.
 
 	LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " GET returned: " << ll_print_sd(content) << LL_ENDL;
@@ -796,6 +934,50 @@ const char *LLObjectMediaNavigateClient::getCapabilityName() const
 	return "ObjectMediaNavigate";
 }
 
+void LLObjectMediaNavigateClient::enqueue(Request *request)
+{
+	if(request->isDead())
+	{
+		LL_DEBUGS("LLMediaDataClient") << "not queueing dead request " << *request << LL_ENDL;
+		return;
+	}
+	
+	// If there's already a matching request in the queue, remove it.
+	request_queue_t::iterator iter = find_matching_request(mQueue, request);
+	if(iter != mQueue.end())
+	{
+		LL_DEBUGS("LLMediaDataClient") << "removing matching queued request " << (**iter) << LL_ENDL;
+		mQueue.erase(iter);
+	}
+	else
+	{
+		request_set_t::iterator set_iter = find_matching_request(mUnQueuedRequests, request);
+		if(set_iter != mUnQueuedRequests.end())
+		{
+			LL_DEBUGS("LLMediaDataClient") << "removing matching unqueued request " << (**set_iter) << LL_ENDL;
+			mUnQueuedRequests.erase(set_iter);
+		}
+	}
+
+#if 0
+	// Sadly, this doesn't work.  It ends up creating a race condition when the user navigates and then hits the "back" button
+	// where the navigate-back appears to be spurious and doesn't get broadcast.	
+	if(request->getObject()->isCurrentMediaUrl(request->getFace(), request->getURL()))
+	{
+		// This navigate request is trying to send the face to the current URL.  Drop it.
+		LL_DEBUGS("LLMediaDataClient") << "dropping spurious request " << (*request) << LL_ENDL;
+	}
+	else
+#endif
+	{
+		LL_DEBUGS("LLMediaDataClient") << "queueing new request " << (*request) << LL_ENDL;
+		mQueue.push_back(request);
+		
+		// Start the timer if not already running
+		startQueueTimer();
+	}
+}
+
 void LLObjectMediaNavigateClient::navigate(LLMediaDataClientObject *object, U8 texture_index, const std::string &url)
 {
 
@@ -806,8 +988,7 @@ void LLObjectMediaNavigateClient::navigate(LLMediaDataClientObject *object, U8 t
 }
 
 LLObjectMediaNavigateClient::RequestNavigate::RequestNavigate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc, U8 texture_index, const std::string &url):
-	LLMediaDataClient::Request(LLMediaDataClient::Request::NAVIGATE, obj, mdc),
-	mTextureIndex(texture_index),
+	LLMediaDataClient::Request(LLMediaDataClient::Request::NAVIGATE, obj, mdc, (S32)texture_index),
 	mURL(url)
 {
 }
@@ -815,9 +996,9 @@ LLObjectMediaNavigateClient::RequestNavigate::RequestNavigate(LLMediaDataClientO
 LLSD LLObjectMediaNavigateClient::RequestNavigate::getPayload() const
 {
 	LLSD result;
-	result[LLTextureEntry::OBJECT_ID_KEY] = mObject->getID();
+	result[LLTextureEntry::OBJECT_ID_KEY] = getID();
 	result[LLMediaEntry::CURRENT_URL_KEY] = mURL;
-	result[LLTextureEntry::TEXTURE_INDEX_KEY] = (LLSD::Integer)mTextureIndex;
+	result[LLTextureEntry::TEXTURE_INDEX_KEY] = (LLSD::Integer)getFace();
 	
 	return result;
 }
@@ -830,13 +1011,22 @@ LLMediaDataClient::Responder *LLObjectMediaNavigateClient::RequestNavigate::crea
 /*virtual*/
 void LLObjectMediaNavigateClient::Responder::error(U32 status, const std::string& reason)
 {
+	getRequest()->stopTracking();
+
+	if(getRequest()->isDead())
+	{
+		LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL;
+		return;
+	}
+
 	// Bounce back (unless HTTP_SERVICE_UNAVAILABLE, in which case call base
 	// class
 	if (status == HTTP_SERVICE_UNAVAILABLE)
 	{
 		LLMediaDataClient::Responder::error(status, reason);
 	}
-	else {
+	else
+	{
 		// bounce the face back
 		LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: http code=" << status << LL_ENDL;
 		const LLSD &payload = getRequest()->getPayload();
@@ -848,6 +1038,14 @@ void LLObjectMediaNavigateClient::Responder::error(U32 status, const std::string
 /*virtual*/
 void LLObjectMediaNavigateClient::Responder::result(const LLSD& content)
 {
+	getRequest()->stopTracking();
+
+	if(getRequest()->isDead())
+	{
+		LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL;
+		return;
+	}
+
 	LL_INFOS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned " << ll_print_sd(content) << LL_ENDL;
 	
 	if (content.has("error"))
@@ -862,14 +1060,17 @@ void LLObjectMediaNavigateClient::Responder::result(const LLSD& content)
 			// bounce the face back
 			getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]);
 		}
-		else {
+		else
+		{
 			LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" << 
 				error["code"].asString() << ": " << error["message"].asString() << LL_ENDL;
 		}			 
+
 		// XXX Warn user?
 	}
-	else {
-		// just do what our superclass does
-		LLMediaDataClient::Responder::result(content);
+	else 
+	{
+		// No action required.
+		LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " result : " << ll_print_sd(content) << LL_ENDL;
 	}
 }
diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h
index 9504a0a2a91..39614424125 100755
--- a/indra/newview/llmediadataclient.h
+++ b/indra/newview/llmediadataclient.h
@@ -34,7 +34,7 @@
 #define LL_LLMEDIADATACLIENT_H
 
 #include "llhttpclient.h"
-#include <queue>
+#include <set>
 #include "llrefcount.h"
 #include "llpointer.h"
 #include "lleventtimer.h"
@@ -48,6 +48,8 @@ class LLMediaDataClientObject : public LLRefCount
 	virtual U8 getMediaDataCount() const = 0;
 	// Get the media data at index, as an LLSD
 	virtual LLSD getMediaDataLLSD(U8 index) const = 0;
+	// Return true if the current URL for the face in the media data matches the specified URL.
+	virtual bool isCurrentMediaUrl(U8 index, const std::string &url) const = 0;
 	// Get this object's UUID
 	virtual LLUUID getID() const = 0;
 	// Navigate back to previous URL
@@ -96,16 +98,16 @@ class LLMediaDataClient : public LLRefCount
 	F32 getRetryTimerDelay() const { return mRetryTimerDelay; }
 	
 	// Returns true iff the queue is empty
-	bool isEmpty() const;
+	virtual bool isEmpty() const;
 	
 	// Returns true iff the given object is in the queue
-	bool isInQueue(const LLMediaDataClientObject::ptr_t &object);
+	virtual bool isInQueue(const LLMediaDataClientObject::ptr_t &object);
 	
 	// Remove the given object from the queue. Returns true iff the given object is removed.
-	bool removeFromQueue(const LLMediaDataClientObject::ptr_t &object);
+	virtual void removeFromQueue(const LLMediaDataClientObject::ptr_t &object);
 	
 	// Called only by the Queue timer and tests (potentially)
-	bool processQueueTimer();
+	virtual bool processQueueTimer();
 	
 protected:
 	// Destructor
@@ -122,6 +124,8 @@ class LLMediaDataClient : public LLRefCount
 		// and must create the correct type of responder.
 		virtual Responder *createResponder() = 0;
 
+		virtual std::string getURL() { return ""; }
+
         enum Type {
             GET,
             UPDATE,
@@ -131,15 +135,14 @@ class LLMediaDataClient : public LLRefCount
         
 	protected:
 		// The only way to create one of these is through a subclass.
-		Request(Type in_type, LLMediaDataClientObject *obj, LLMediaDataClient *mdc);
+		Request(Type in_type, LLMediaDataClientObject *obj, LLMediaDataClient *mdc, S32 face = -1);
 	public:
 		LLMediaDataClientObject *getObject() const { return mObject; }
 
         U32 getNum() const { return mNum; }
 		U32 getRetryCount() const { return mRetryCount; }
-		void incRetryCount() { mRetryCount++; };
-        Type getType() const { return mType; };
-		bool isMarkedSent() const { return mMarkedSent; }
+		void incRetryCount() { mRetryCount++; }
+        Type getType() const { return mType; }
 		F64 getScore() const { return mScore; }
 		
 		// Note: may return empty string!
@@ -153,13 +156,26 @@ class LLMediaDataClient : public LLRefCount
 		F32 getRetryTimerDelay() const;
 		U32 getMaxNumRetries() const;
 		
-		bool isNew() const { return mObject.notNull() ? mObject->isNew() : false; }
-		bool isObjectValid() const { return mObject.notNull() ? (!mObject->isDead()) : false; }
-		void markSent(bool flag);
+		bool isObjectValid() const { return mObject.notNull() && (!mObject->isDead()); }
+		bool isNew() const { return isObjectValid() && mObject->isNew(); }
 		void updateScore();
 		
+		void markDead();
+		bool isDead();
+		void startTracking();
+		void stopTracking();
+		
 		friend std::ostream& operator<<(std::ostream &s, const Request &q);
-
+		
+		const LLUUID &getID() const { return mObjectID; }
+		S32 getFace() const { return mFace; }
+		
+		bool isMatch (const Request* other, Type match_type = ANY) const 
+		{ 
+			return ((match_type == ANY) || (mType == other->mType)) && 
+					(mFace == other->mFace) && 
+					(mObjectID == other->mObjectID); 
+		}
 	protected:
 		LLMediaDataClientObject::ptr_t mObject;
 	private:
@@ -169,7 +185,9 @@ class LLMediaDataClient : public LLRefCount
 		static U32 sNum;
         U32 mRetryCount;
 		F64 mScore;
-		bool mMarkedSent;
+		
+		LLUUID mObjectID;
+		S32 mFace;
 
 		// Back pointer to the MDC...not a ref!
 		LLMediaDataClient *mMDC;
@@ -189,39 +207,63 @@ class LLMediaDataClient : public LLRefCount
 		request_ptr_t &getRequest() { return mRequest; }
 
 	private:
+		request_ptr_t mRequest;
+	};
 
-		class RetryTimer : public LLEventTimer
-		{
-		public:
-			RetryTimer(F32 time, Responder *);
-			virtual BOOL tick();
-		private:
-			// back-pointer
-			boost::intrusive_ptr<Responder> mResponder;
-		};
-		
+	class RetryTimer : public LLEventTimer
+	{
+	public:
+		RetryTimer(F32 time, request_ptr_t);
+		virtual BOOL tick();
+	private:
+		// back-pointer
 		request_ptr_t mRequest;
 	};
+		
 	
 protected:
+	typedef std::list<request_ptr_t> request_queue_t;
+	typedef std::set<request_ptr_t> request_set_t;
 
 	// Subclasses must override to return a cap name
 	virtual const char *getCapabilityName() const = 0;
+
+	// Puts the request into a queue, appropriately handling duplicates, etc.
+	virtual void enqueue(Request*) = 0;
 	
-	virtual bool request_needs_purge(request_ptr_t request);
-	virtual void sortQueue();
 	virtual void serviceQueue();
 
-	virtual void enqueue(Request*);
+	virtual request_queue_t *getQueue() { return &mQueue; };
+
+	// Gets the next request, removing it from the queue
+	virtual request_ptr_t dequeue();
 	
-private:
-	typedef std::list<request_ptr_t> request_queue_t;
+	virtual bool canServiceRequest(request_ptr_t request) { return true; };
+
+	// Returns a request to the head of the queue (should only be used for requests that came from dequeue
+	virtual void pushBack(request_ptr_t request);
 	
-	// Return whether the given object is/was in the queue
-	static LLMediaDataClient::request_ptr_t findOrRemove(request_queue_t &queue, const LLMediaDataClientObject::ptr_t &obj, bool remove, Request::Type type);
+	void trackRequest(request_ptr_t request);
+	void stopTrackingRequest(request_ptr_t request);
+	
+	request_queue_t mQueue;
+
+	const F32 mQueueTimerDelay;
+	const F32 mRetryTimerDelay;
+	const U32 mMaxNumRetries;
+	const U32 mMaxSortedQueueSize;
+	const U32 mMaxRoundRobinQueueSize;
+	
+	// Set for keeping track of requests that aren't in either queue.  This includes:
+	//	Requests that have been sent and are awaiting a response (pointer held by the Responder)
+	//  Requests that are waiting for their retry timers to fire (pointer held by the retry timer)
+	request_set_t mUnQueuedRequests;
+
+	void startQueueTimer();
+	void stopQueueTimer();
+
+private:
 	
-	// Comparator for sorting
-	static bool compareRequests(const request_ptr_t &o1, const request_ptr_t &o2);
 	static F64 getObjectScore(const LLMediaDataClientObject::ptr_t &obj);
     
 	friend std::ostream& operator<<(std::ostream &s, const Request &q);
@@ -237,24 +279,10 @@ class LLMediaDataClient : public LLRefCount
 		LLPointer<LLMediaDataClient> mMDC;
 	};
 	
-	void startQueueTimer();
-	void stopQueueTimer();
 	void setIsRunning(bool val) { mQueueTimerIsRunning = val; }
-	
-	void swapCurrentQueue();
-	request_queue_t *getCurrentQueue();
-	
-	const F32 mQueueTimerDelay;
-	const F32 mRetryTimerDelay;
-	const U32 mMaxNumRetries;
-	const U32 mMaxSortedQueueSize;
-	const U32 mMaxRoundRobinQueueSize;
-	
+		
 	bool mQueueTimerIsRunning;
-	
-	request_queue_t mSortedQueue;
-	request_queue_t mRoundRobinQueue;
-	bool mCurrentQueueIsTheSortedQueue;
+		
 };
 
 
@@ -262,14 +290,15 @@ class LLMediaDataClient : public LLRefCount
 class LLObjectMediaDataClient : public LLMediaDataClient
 {
 public:
+    LOG_CLASS(LLObjectMediaDataClient);
     LLObjectMediaDataClient(F32 queue_timer_delay = QUEUE_TIMER_DELAY,
 							F32 retry_timer_delay = UNAVAILABLE_RETRY_TIMER_DELAY,
 							U32 max_retries = MAX_RETRIES,
 							U32 max_sorted_queue_size = MAX_SORTED_QUEUE_SIZE,
 							U32 max_round_robin_queue_size = MAX_ROUND_ROBIN_QUEUE_SIZE)
-		: LLMediaDataClient(queue_timer_delay, retry_timer_delay, max_retries)
+		: LLMediaDataClient(queue_timer_delay, retry_timer_delay, max_retries),
+		  mCurrentQueueIsTheSortedQueue(true)
 		{}
-    virtual ~LLObjectMediaDataClient() {}
     
 	void fetchMedia(LLMediaDataClientObject *object); 
     void updateMedia(LLMediaDataClientObject *object);
@@ -289,11 +318,29 @@ class LLObjectMediaDataClient : public LLMediaDataClient
 		/*virtual*/ LLSD getPayload() const;
 		/*virtual*/ Responder *createResponder();
 	};
+
+	// Returns true iff the queue is empty
+	virtual bool isEmpty() const;
+	
+	// Returns true iff the given object is in the queue
+	virtual bool isInQueue(const LLMediaDataClientObject::ptr_t &object);
 	    
+	// Remove the given object from the queue. Returns true iff the given object is removed.
+	virtual void removeFromQueue(const LLMediaDataClientObject::ptr_t &object);
+
+	virtual bool processQueueTimer();
+
+	virtual bool canServiceRequest(request_ptr_t request);
+
 protected:
 	// Subclasses must override to return a cap name
 	virtual const char *getCapabilityName() const;
-    
+	
+	virtual request_queue_t *getQueue();
+
+	// Puts the request into the appropriate queue
+	virtual void enqueue(Request*);
+		    
     class Responder : public LLMediaDataClient::Responder
     {
     public:
@@ -301,6 +348,16 @@ class LLObjectMediaDataClient : public LLMediaDataClient
             : LLMediaDataClient::Responder(request) {}
         virtual void result(const LLSD &content);
     };
+private:
+	// The Get/Update data client needs a second queue to avoid object updates starving load-ins.
+	void swapCurrentQueue();
+	
+	request_queue_t mRoundRobinQueue;
+	bool mCurrentQueueIsTheSortedQueue;
+
+	// Comparator for sorting
+	static bool compareRequestScores(const request_ptr_t &o1, const request_ptr_t &o2);
+	void sortQueue();
 };
 
 
@@ -308,6 +365,7 @@ class LLObjectMediaDataClient : public LLMediaDataClient
 class LLObjectMediaNavigateClient : public LLMediaDataClient
 {
 public:
+    LOG_CLASS(LLObjectMediaNavigateClient);
 	// NOTE: from llmediaservice.h
 	static const int ERROR_PERMISSION_DENIED_CODE = 8002;
 	
@@ -318,18 +376,20 @@ class LLObjectMediaNavigateClient : public LLMediaDataClient
 								U32 max_round_robin_queue_size = MAX_ROUND_ROBIN_QUEUE_SIZE)
 		: LLMediaDataClient(queue_timer_delay, retry_timer_delay, max_retries)
 		{}
-    virtual ~LLObjectMediaNavigateClient() {}
     
     void navigate(LLMediaDataClientObject *object, U8 texture_index, const std::string &url);
 
+	// Puts the request into the appropriate queue
+	virtual void enqueue(Request*);
+
 	class RequestNavigate: public Request
 	{
 	public:
 		RequestNavigate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc, U8 texture_index, const std::string &url);
 		/*virtual*/ LLSD getPayload() const;
 		/*virtual*/ Responder *createResponder();
+		/*virtual*/ std::string getURL() { return mURL; }
 	private:
-		U8 mTextureIndex;
 		std::string mURL;
 	};
     
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index c838e9a28d8..00d67a4ea93 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -93,8 +93,14 @@ static LLFastTimer::DeclareTimer FTM_GEN_VOLUME("Generate Volumes");
 class LLMediaDataClientObjectImpl : public LLMediaDataClientObject
 {
 public:
-	LLMediaDataClientObjectImpl(LLVOVolume *obj, bool isNew) : mObject(obj), mNew(isNew) {}
-	LLMediaDataClientObjectImpl() { mObject = NULL; }
+	LLMediaDataClientObjectImpl(LLVOVolume *obj, bool isNew) : mObject(obj), mNew(isNew) 
+	{
+		mObject->addMDCImpl();
+	}
+	~LLMediaDataClientObjectImpl()
+	{
+		mObject->removeMDCImpl();
+	}
 	
 	virtual U8 getMediaDataCount() const 
 		{ return mObject->getNumTEs(); }
@@ -119,6 +125,18 @@ class LLMediaDataClientObjectImpl : public LLMediaDataClientObject
 			}
 			return result;
 		}
+	virtual bool isCurrentMediaUrl(U8 index, const std::string &url) const
+		{
+			LLTextureEntry *te = mObject->getTE(index); 
+			if (te)
+			{
+				if (te->getMediaData())
+				{
+					return (te->getMediaData()->getCurrentURL() == url);
+				}
+			}
+			return url.empty();
+		}
 
 	virtual LLUUID getID() const
 		{ return mObject->getID(); }
@@ -193,6 +211,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re
 	mMediaImplList.resize(getNumTEs());
 	mLastFetchedMediaVersion = -1;
 	mIndexInTex = 0;
+	mMDCImplCount = 0;
 }
 
 LLVOVolume::~LLVOVolume()
@@ -218,9 +237,12 @@ void LLVOVolume::markDead()
 {
 	if (!mDead)
 	{
-		LLMediaDataClientObject::ptr_t obj = new LLMediaDataClientObjectImpl(const_cast<LLVOVolume*>(this), false);
-		if (sObjectMediaClient) sObjectMediaClient->removeFromQueue(obj);
-		if (sObjectMediaNavigateClient) sObjectMediaNavigateClient->removeFromQueue(obj);
+		if(getMDCImplCount() > 0)
+		{
+			LLMediaDataClientObject::ptr_t obj = new LLMediaDataClientObjectImpl(const_cast<LLVOVolume*>(this), false);
+			if (sObjectMediaClient) sObjectMediaClient->removeFromQueue(obj);
+			if (sObjectMediaNavigateClient) sObjectMediaNavigateClient->removeFromQueue(obj);
+		}
 		
 		// Detach all media impls from this object
 		for(U32 i = 0 ; i < mMediaImplList.size() ; i++)
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index fbae011ffc8..1bd6a0fafe1 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -274,6 +274,10 @@ class LLVOVolume : public LLViewerObject
 	
 	// Returns the "last fetched" media version, or -1 if not fetched yet
 	S32 getLastFetchedMediaVersion() const { return mLastFetchedMediaVersion; }
+
+	void addMDCImpl() { ++mMDCImplCount; }
+	void removeMDCImpl() { --mMDCImplCount; }
+	S32 getMDCImplCount() { return mMDCImplCount; }
 	
 protected:
 	S32	computeLODDetail(F32	distance, F32 radius);
@@ -307,6 +311,7 @@ class LLVOVolume : public LLViewerObject
 	media_list_t mMediaImplList;
 	S32			mLastFetchedMediaVersion; // as fetched from the server, starts as -1
 	S32 mIndexInTex;
+	S32 mMDCImplCount;
 	// statics
 public:
 	static F32 sLODSlopDistanceFactor;// Changing this to zero, effectively disables the LOD transition slop 
diff --git a/indra/newview/tests/llmediadataclient_test.cpp b/indra/newview/tests/llmediadataclient_test.cpp
index d73ea24768a..05e178653b2 100644
--- a/indra/newview/tests/llmediadataclient_test.cpp
+++ b/indra/newview/tests/llmediadataclient_test.cpp
@@ -70,8 +70,8 @@
 
 #define MEDIA_DATA "\
 <array>														\
-<string>foo</string>										\
-<string>bar</string>										\
+<string>http://foo.example.com</string>										\
+<string>http://bar.example.com</string>										\
 <string>baz</string>										\
 </array>"
 
@@ -167,6 +167,8 @@ class LLMediaDataClientObjectTest : public LLMediaDataClientObject
 		{ return mRep["media_data"].size(); }
 	virtual LLSD getMediaDataLLSD(U8 index) const
 		{ return mRep["media_data"][(LLSD::Integer)index]; }
+	virtual bool isCurrentMediaUrl(U8 index, const std::string &url) const
+		{ return (mRep["media_data"][(LLSD::Integer)index].asString() == url); }
 	virtual LLUUID getID() const 
 		{ return mRep["uuid"]; }
 	virtual void mediaNavigateBounceBack(U8 index)
@@ -567,20 +569,29 @@ namespace tut
 			mdc->fetchMedia(o2);
 			mdc->fetchMedia(o3);
 			mdc->fetchMedia(o4);
+
+			ensure("is in queue 1", mdc->isInQueue(o1));
+			ensure("is in queue 2", mdc->isInQueue(o2));
+			ensure("is in queue 3", mdc->isInQueue(o3));
+			ensure("is in queue 4", mdc->isInQueue(o4));
+			ensure("post records", gPostRecords->size(), 0);
 			
-			// and mark the second and fourth ones dead.
+			// and mark the second and fourth ones dead.  Call removeFromQueue when marking dead, since this is what LLVOVolume will do.
 			dynamic_cast<LLMediaDataClientObjectTest*>(static_cast<LLMediaDataClientObject*>(o2))->markDead();
+			mdc->removeFromQueue(o2);
 			dynamic_cast<LLMediaDataClientObjectTest*>(static_cast<LLMediaDataClientObject*>(o4))->markDead();
+			mdc->removeFromQueue(o4);
 
+			// The removeFromQueue calls should remove the second and fourth ones
 			ensure("is in queue 1", mdc->isInQueue(o1));
-			ensure("is in queue 2", mdc->isInQueue(o2));
+			ensure("is not in queue 2", !mdc->isInQueue(o2));
 			ensure("is in queue 3", mdc->isInQueue(o3));
-			ensure("is in queue 4", mdc->isInQueue(o4));
+			ensure("is not in queue 4", !mdc->isInQueue(o4));
 			ensure("post records", gPostRecords->size(), 0);
 			
 			::pump_timers();
 			
-			// The first tick should remove the second and fourth ones, and process the first one 
+			// The first tick should process the first item
 			ensure("is not in queue 1", !mdc->isInQueue(o1));
 			ensure("is not in queue 2", !mdc->isInQueue(o2));
 			ensure("is in queue 3", mdc->isInQueue(o3));
@@ -701,7 +712,7 @@ namespace tut
 			// queue up all 4 objects.  The first two should be in the sorted
 			// queue [2 1], the second in the round-robin queue.  The queues
 			// are serviced interleaved, so we should expect:
-			// 2, 4, 1, 3
+			// 2, 3, 1, 4
 			mdc->fetchMedia(o1);
 			mdc->fetchMedia(o2);
 			mdc->fetchMedia(o3);
@@ -720,8 +731,8 @@ namespace tut
 			++tick_num;
 			
 			// 1 The first tick should remove object 2
-			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
 			ensure(STR(tick_num) + ". is in queue 1", mdc->isInQueue(o1));
+			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
 			ensure(STR(tick_num) + ". is in queue 3", mdc->isInQueue(o3));
 			ensure(STR(tick_num) + ". is in queue 4", mdc->isInQueue(o4));
 			ensure(STR(tick_num) + ". post records", gPostRecords->size(), 1);
@@ -730,22 +741,21 @@ namespace tut
 			::pump_timers();
 			++tick_num;
 			
-			// 2 The second tick should send object 4, but it will still be
-			// "in the queue"
-			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
+			// 2 The second tick should send object 3
 			ensure(STR(tick_num) + ". is in queue 1", mdc->isInQueue(o1));
-			ensure(STR(tick_num) + ". is in queue 3", mdc->isInQueue(o3));
+			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
+			ensure(STR(tick_num) + ". is not in queue 3", !mdc->isInQueue(o3));
 			ensure(STR(tick_num) + ". is in queue 4", mdc->isInQueue(o4));
 			ensure(STR(tick_num) + ". post records", gPostRecords->size(), 2);
-			ensure(STR(tick_num) + ". post object id", (*gPostRecords)[1]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID_4));
+			ensure(STR(tick_num) + ". post object id", (*gPostRecords)[1]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID_3));
 			
 			::pump_timers();
 			++tick_num;
 			
 			// 3 The third tick should remove object 1
-			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
 			ensure(STR(tick_num) + ". is not in queue 1", !mdc->isInQueue(o1));
-			ensure(STR(tick_num) + ". is in queue 3", mdc->isInQueue(o3));
+			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
+			ensure(STR(tick_num) + ". is not in queue 3", !mdc->isInQueue(o3));
 			ensure(STR(tick_num) + ". is in queue 4", mdc->isInQueue(o4));
 			ensure(STR(tick_num) + ". post records", gPostRecords->size(), 3);
 			ensure(STR(tick_num) + ". post object id", (*gPostRecords)[2]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID_1));
@@ -753,22 +763,20 @@ namespace tut
 			::pump_timers();
 			++tick_num;
 			
-			// 4 The fourth tick should send object 3, but it will still be
-			// "in the queue"
-			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
+			// 4 The fourth tick should send object 4
 			ensure(STR(tick_num) + ". is not in queue 1", !mdc->isInQueue(o1));
-			ensure(STR(tick_num) + ". is in queue 3", mdc->isInQueue(o3));
-			ensure(STR(tick_num) + ". is in queue 4", mdc->isInQueue(o4));
+			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
+			ensure(STR(tick_num) + ". is not in queue 3", !mdc->isInQueue(o3));
+			ensure(STR(tick_num) + ". is not in queue 4", !mdc->isInQueue(o4));
 			ensure(STR(tick_num) + ". post records", gPostRecords->size(), 4);
-			ensure(STR(tick_num) + ". post object id", (*gPostRecords)[3]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID_3));
+			ensure(STR(tick_num) + ". post object id", (*gPostRecords)[3]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID_4));
 			
 			::pump_timers();
 			++tick_num;
 						
-			// 5 The fifth tick should now identify objects 3 and 4 as no longer
-			// needing "updating", and remove them from the queue
-			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
+			// 5 The fifth tick should not change the state of anything.
 			ensure(STR(tick_num) + ". is not in queue 1", !mdc->isInQueue(o1));
+			ensure(STR(tick_num) + ". is not in queue 2", !mdc->isInQueue(o2));
 			ensure(STR(tick_num) + ". is not in queue 3", !mdc->isInQueue(o3));
 			ensure(STR(tick_num) + ". is not in queue 4", !mdc->isInQueue(o4));
 			ensure(STR(tick_num) + ". post records", gPostRecords->size(), 4);
@@ -918,7 +926,7 @@ namespace tut
 			
 			// But, we need to clear the queue, or else we won't destroy MDC...
 			// this is a strange interplay between the queue timer and the MDC
-			ensure("o2 couldn't be removed from queue", mdc->removeFromQueue(o2));
+			mdc->removeFromQueue(o2);
 			// tick
 			::pump_timers();
 		}
@@ -927,4 +935,41 @@ namespace tut
 		ensure("refcount of o3", o3->getNumRefs(), 1);
 		ensure("refcount of o4", o4->getNumRefs(), 1);		
 	}
+
+	template<> template<>
+	void mediadataclient_object_t::test<13>()
+	{
+		//
+		// Test supression of redundant navigates.
+		//
+		LOG_TEST(13);
+		
+		LLMediaDataClientObject::ptr_t o1 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_1,"1.0","true"));
+		{
+			LLPointer<LLObjectMediaNavigateClient> mdc = new LLObjectMediaNavigateClient(NO_PERIOD,NO_PERIOD);
+			const char *TEST_URL = "http://foo.example.com";
+			const char *TEST_URL_2 = "http://example.com";
+			mdc->navigate(o1, 0, TEST_URL);
+			mdc->navigate(o1, 1, TEST_URL);
+			mdc->navigate(o1, 0, TEST_URL_2);
+			mdc->navigate(o1, 1, TEST_URL_2);
+			
+			// This should add two requests to the queue, one for face 0 of the object and one for face 1.
+			
+			ensure("before pump: 1 is in queue", mdc->isInQueue(o1));
+
+			::pump_timers();
+
+			ensure("after first pump: 1 is in queue", mdc->isInQueue(o1));
+
+			::pump_timers();
+
+			ensure("after second pump: 1 is not in queue", !mdc->isInQueue(o1));
+
+			ensure("first post has correct url", (*gPostRecords)[0]["body"][LLMediaEntry::CURRENT_URL_KEY].asString(), std::string(TEST_URL_2));
+			ensure("second post has correct url", (*gPostRecords)[1]["body"][LLMediaEntry::CURRENT_URL_KEY].asString(), std::string(TEST_URL_2));
+
+		}		
+	}
+	
 }
-- 
GitLab


From 7fcca83169287b5011b5b5a0193456e9a789619c Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Fri, 30 Jul 2010 10:02:09 +0300
Subject: [PATCH 567/683] EXT-8522 FIXED (Code improvements: Update a way in
 which Nearby people list is controlled depend on its visibility to user) 1.
 Removed special processing of Nearby People List Updater when:  * tabs in
 People panel are changed;  * People panel change its visibility. 2.
 Subscribed Nearby People List Updater's setActive() method directly to Nearby
 list Panel's onVisibleChange callback.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/825/

--HG--
branch : product-engine
---
 indra/newview/llpanelpeople.cpp | 31 +++----------------------------
 indra/newview/llpanelpeople.h   |  4 ----
 2 files changed, 3 insertions(+), 32 deletions(-)

diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 3140fe8de12..3f5191ca12b 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -515,8 +515,6 @@ void LLPanelPeople::onFriendsAccordionExpandedCollapsed(LLUICtrl* ctrl, const LL
 
 BOOL LLPanelPeople::postBuild()
 {
-	setVisibleCallback(boost::bind(&LLPanelPeople::onVisibilityChange, this, _2));
-	
 	mFilterEditor = getChild<LLFilterEditor>("filter_input");
 	mFilterEditor->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2));
 
@@ -533,7 +531,9 @@ BOOL LLPanelPeople::postBuild()
 	mAllFriendList->setNoItemsCommentText(getString("no_friends"));
 	mAllFriendList->setShowIcons("FriendsListShowIcons");
 
-	mNearbyList = getChild<LLPanel>(NEARBY_TAB_NAME)->getChild<LLAvatarList>("avatar_list");
+	LLPanel* nearby_tab = getChild<LLPanel>(NEARBY_TAB_NAME);
+	nearby_tab->setVisibleCallback(boost::bind(&Updater::setActive, mNearbyListUpdater, _2));
+	mNearbyList = nearby_tab->getChild<LLAvatarList>("avatar_list");
 	mNearbyList->setNoItemsCommentText(getString("no_one_near"));
 	mNearbyList->setNoItemsMsg(getString("no_one_near"));
 	mNearbyList->setNoFilteredItemsMsg(getString("no_one_filtered_near"));
@@ -977,28 +977,6 @@ void LLPanelPeople::setSortOrder(LLAvatarList* list, ESortOrder order, bool save
 	}
 }
 
-void LLPanelPeople::onVisibilityChange(const LLSD& new_visibility)
-{
-	if (new_visibility.asBoolean() == FALSE)
-	{
-		// Don't update anything while we're invisible.
-		mNearbyListUpdater->setActive(FALSE);
-	}
-	else
-	{
-		reSelectedCurrentTab();
-	}
-}
-
-// Make the tab-container re-select current tab
-// for onTabSelected() callback to get called.
-// (currently this is needed to reactivate nearby list updates
-// when we get visible)
-void LLPanelPeople::reSelectedCurrentTab()
-{
-	mTabContainer->selectTab(mTabContainer->getCurrentPanelIndex());
-}
-
 bool LLPanelPeople::isRealGroup()
 {
 	return getCurrentItemID() != LLUUID::null;
@@ -1046,7 +1024,6 @@ void LLPanelPeople::onFilterEdit(const std::string& search_string)
 void LLPanelPeople::onTabSelected(const LLSD& param)
 {
 	std::string tab_name = getChild<LLPanel>(param.asString())->getName();
-	mNearbyListUpdater->setActive(tab_name == NEARBY_TAB_NAME);
 	updateButtons();
 
 	showFriendsAccordionsIfNeeded();
@@ -1410,8 +1387,6 @@ void	LLPanelPeople::onOpen(const LLSD& key)
 	
 	if (!tab_name.empty())
 		mTabContainer->selectTabByName(tab_name);
-	else
-		reSelectedCurrentTab();
 }
 
 bool LLPanelPeople::notifyChildren(const LLSD& info)
diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h
index 17c45a034b2..ff8df5c7a8c 100644
--- a/indra/newview/llpanelpeople.h
+++ b/indra/newview/llpanelpeople.h
@@ -91,10 +91,6 @@ class LLPanelPeople
 	void					showGroupMenu(LLMenuGL* menu);
 	void					setSortOrder(LLAvatarList* list, ESortOrder order, bool save = true);
 
-	void					onVisibilityChange( const LLSD& new_visibility);
-
-	void					reSelectedCurrentTab();
-
 	// UI callbacks
 	void					onFilterEdit(const std::string& search_string);
 	void					onTabSelected(const LLSD& param);
-- 
GitLab


From 2051ba7248f11af083bbda9cd8b67be99d0d844b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 30 Jul 2010 11:19:28 +0100
Subject: [PATCH 568/683] remove a nonsense assert that gcc was choking on.

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

diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index 8a52cf715fc..6cfd810c108 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -393,10 +393,8 @@ LLGestureComboList::~LLGestureComboList()
 
 LLCtrlListInterface* LLGestureComboList::getListInterface()
 {
-	LLCtrlListInterface *result = mList;
-	llassert((LLCtrlListInterface*)mList==result);
 	return mList;
-};
+}
 
 LLNearbyChatBar::LLNearbyChatBar() 
 	: LLPanel()
-- 
GitLab


From 143f6583174aa498fac4c23365d01f916392b961 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Fri, 30 Jul 2010 16:11:03 +0300
Subject: [PATCH 569/683] EXT-8161 FIXED Moved Invite button 5 px to the right
 to prevent cropping its border (when selected) by parent.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/827/

--HG--
branch : product-engine
---
 indra/newview/skins/default/xui/en/panel_group_roles.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/panel_group_roles.xml b/indra/newview/skins/default/xui/en/panel_group_roles.xml
index 18a2f37ba2d..4af4774304c 100644
--- a/indra/newview/skins/default/xui/en/panel_group_roles.xml
+++ b/indra/newview/skins/default/xui/en/panel_group_roles.xml
@@ -103,7 +103,7 @@ clicking on their names.
              height="23"
              follows="top|left"
              label="Invite"
-             left="0"
+             left="5"
              name="member_invite"
              width="100" />
             <button
-- 
GitLab


From 9fcfa8277b5ab6177a5ed54418c545776dea2fc5 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Fri, 30 Jul 2010 16:16:55 +0300
Subject: [PATCH 570/683] EXT-7796 ADDITIOANL FIXED Reopen reason - Camera
 Floater did not take into account edit appearance mode while it is being
 built.

FIX:
Store the "edit appearance" mode as internal floater's flag and apply it while building to ensure that its controls have right "enable" state.
Also added forcing of Pan Camera mode if floater is opened first time in Edit appearance mode.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/824/

--HG--
branch : product-engine
---
 indra/newview/llfloatercamera.cpp | 23 +++++++++++++++++++----
 indra/newview/llfloatercamera.h   |  3 +++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 0fa536dfadc..85a5f076ab9 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -62,6 +62,7 @@ const F32 CAMERA_BUTTON_DELAY = 0.0f;
 #define CONTROLS "controls"
 
 bool LLFloaterCamera::sFreeCamera = false;
+bool LLFloaterCamera::sAppearanceEditing = false;
 
 // Zoom the camera in and out
 class LLPanelCameraZoom
@@ -245,16 +246,21 @@ void LLFloaterCamera::resetCameraMode()
 
 void LLFloaterCamera::onAvatarEditingAppearance(bool editing)
 {
+	sAppearanceEditing = editing;
 	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
 	if (!floater_camera) return;
+	floater_camera->handleAvatarEditingAppearance(editing);
+}
 
+void LLFloaterCamera::handleAvatarEditingAppearance(bool editing)
+{
 	//camera presets (rear, front, etc.)
-	floater_camera->childSetEnabled("preset_views_list", !editing);
-	floater_camera->childSetEnabled("presets_btn", !editing);
+	childSetEnabled("preset_views_list", !editing);
+	childSetEnabled("presets_btn", !editing);
 
 	//camera modes (object view, mouselook view)
-	floater_camera->childSetEnabled("camera_modes_list", !editing);
-	floater_camera->childSetEnabled("avatarview_btn", !editing);
+	childSetEnabled("camera_modes_list", !editing);
+	childSetEnabled("avatarview_btn", !editing);
 }
 
 void LLFloaterCamera::update()
@@ -349,6 +355,9 @@ BOOL LLFloaterCamera::postBuild()
 
 	update();
 
+	// ensure that appearance mode is handled while building. See EXT-7796.
+	handleAvatarEditingAppearance(sAppearanceEditing);
+
 	return LLDockableFloater::postBuild();
 }
 
@@ -371,6 +380,12 @@ void LLFloaterCamera::fillFlatlistFromPanel (LLFlatListView* list, LLPanel* pane
 
 ECameraControlMode LLFloaterCamera::determineMode()
 {
+	if (sAppearanceEditing)
+	{
+		// this is the only enabled camera mode while editing agent appearance.
+		return CAMERA_CTRL_MODE_PAN;
+	}
+
 	LLTool* curr_tool = LLToolMgr::getInstance()->getCurrentTool();
 	if (curr_tool == LLToolCamera::getInstance())
 	{
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index c5f8cd6db5d..737bd17e726 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -124,9 +124,12 @@ class LLFloaterCamera
 	// fills flatlist with items from given panel
 	void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel);
 
+	void handleAvatarEditingAppearance(bool editing);
+
 	// set to true when free camera mode is selected in modes list
 	// remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed
 	static bool sFreeCamera;
+	static bool sAppearanceEditing;
 	BOOL mClosed;
 	ECameraControlMode mPrevMode;
 	ECameraControlMode mCurrMode;
-- 
GitLab


From efca9657a22ebbcacee705c00cac4e803f2ffa98 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 09:36:02 -0700
Subject: [PATCH 571/683] converted static callbacks to member functions

---
 indra/newview/llfloateranimpreview.cpp | 304 ++++++++++++-------------
 indra/newview/llfloateranimpreview.h   |  28 +--
 2 files changed, 159 insertions(+), 173 deletions(-)

diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp
index f14e64e3e42..1169093d423 100644
--- a/indra/newview/llfloateranimpreview.cpp
+++ b/indra/newview/llfloateranimpreview.cpp
@@ -161,27 +161,27 @@ LLFloaterAnimPreview::LLFloaterAnimPreview(const std::string& filename) :
 //-----------------------------------------------------------------------------
 void LLFloaterAnimPreview::setAnimCallbacks()
 {
-	childSetCommitCallback("playback_slider", onSliderMove, this);
+	getChild<LLUICtrl>("playback_slider")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onSliderMove, this));
 	
-	childSetCommitCallback("preview_base_anim", onCommitBaseAnim, this);
-	childSetValue("preview_base_anim", "Standing");
+	getChild<LLUICtrl>("preview_base_anim")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitBaseAnim, this));
+	getChild<LLUICtrl>("preview_base_anim")->setValue("Standing");
 
-	childSetCommitCallback("priority", onCommitPriority, this);
-	childSetCommitCallback("loop_check", onCommitLoop, this);
-	childSetCommitCallback("loop_in_point", onCommitLoopIn, this);
-	childSetValidate("loop_in_point", boost::bind(&LLFloaterAnimPreview::validateLoopIn, this, _1));
-	childSetCommitCallback("loop_out_point", onCommitLoopOut, this);
-	childSetValidate("loop_out_point", boost::bind(&LLFloaterAnimPreview::validateLoopOut, this, _1));
+	getChild<LLUICtrl>("priority")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitPriority, this));
+	getChild<LLUICtrl>("loop_check")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitLoop, this));
+	getChild<LLUICtrl>("loop_in_point")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitLoopIn, this));
+	getChild<LLUICtrl>("loop_in_point")->setValidateBeforeCommit( boost::bind(&LLFloaterAnimPreview::validateLoopIn, this, _1));
+	getChild<LLUICtrl>("loop_out_point")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitLoopOut, this));
+	getChild<LLUICtrl>("loop_out_point")->setValidateBeforeCommit( boost::bind(&LLFloaterAnimPreview::validateLoopOut, this, _1));
 
-	childSetCommitCallback("hand_pose_combo", onCommitHandPose, this);
+	getChild<LLUICtrl>("hand_pose_combo")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitHandPose, this));
 	
-	childSetCommitCallback("emote_combo", onCommitEmote, this);
-	childSetValue("emote_combo", "[None]");
+	getChild<LLUICtrl>("emote_combo")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitEmote, this));
+	getChild<LLUICtrl>("emote_combo")->setValue("[None]");
 
-	childSetCommitCallback("ease_in_time", onCommitEaseIn, this);
-	childSetValidate("ease_in_time", boost::bind(&LLFloaterAnimPreview::validateEaseIn, this, _1));
-	childSetCommitCallback("ease_out_time", onCommitEaseOut, this);
-	childSetValidate("ease_out_time", boost::bind(&LLFloaterAnimPreview::validateEaseOut, this, _1));
+	getChild<LLUICtrl>("ease_in_time")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitEaseIn, this));
+	getChild<LLUICtrl>("ease_in_time")->setValidateBeforeCommit( boost::bind(&LLFloaterAnimPreview::validateEaseIn, this, _1));
+	getChild<LLUICtrl>("ease_out_time")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitEaseOut, this));
+	getChild<LLUICtrl>("ease_out_time")->setValidateBeforeCommit( boost::bind(&LLFloaterAnimPreview::validateEaseOut, this, _1));
 }
 
 //-----------------------------------------------------------------------------
@@ -197,7 +197,7 @@ BOOL LLFloaterAnimPreview::postBuild()
 		return FALSE;
 	}
 
-	childSetCommitCallback("name_form", onCommitName, this);
+	getChild<LLUICtrl>("name_form")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitName, this));
 
 	childSetAction("ok_btn", onBtnOK, this);
 	setDefaultBtn();
@@ -209,17 +209,17 @@ BOOL LLFloaterAnimPreview::postBuild()
 	mPreviewImageRect.set(0.f, 1.f, 1.f, 0.f);
 
 	mPlayButton = getChild<LLButton>( "play_btn");
-	mPlayButton->setClickedCallback(onBtnPlay, this);
+	mPlayButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnPlay, this));
 	mPlayButton->setVisible(true);
 
 	mPauseButton = getChild<LLButton>( "pause_btn");
-	mPauseButton->setClickedCallback(onBtnPause, this);
+	mPauseButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnPause, this));
 	mPauseButton->setVisible(false);
 	
 	mStopButton = getChild<LLButton>( "stop_btn");
-	mStopButton->setClickedCallback(onBtnStop, this);
+	mStopButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnStop, this));
 
-	childHide("bad_animation_text");
+	getChildView("bad_animation_text")->setVisible(FALSE);
 
 	std::string exten = gDirUtilp->getExtension(mFilename);
 	if (exten == "bvh")
@@ -311,19 +311,19 @@ BOOL LLFloaterAnimPreview::postBuild()
 		
 			mAnimPreview->setZoom(camera_zoom);
 
-			motionp->setName(childGetValue("name_form").asString());
+			motionp->setName(getChild<LLUICtrl>("name_form")->getValue().asString());
 			mAnimPreview->getDummyAvatar()->startMotion(mMotionID);
 			
 			getChild<LLSlider>("playback_slider")->setMinValue(0.0);
 			getChild<LLSlider>("playback_slider")->setMaxValue(1.0);
 
-			childSetValue("loop_check", LLSD(motionp->getLoop()));
-			childSetValue("loop_in_point", LLSD(motionp->getLoopIn() / motionp->getDuration() * 100.f));
-			childSetValue("loop_out_point", LLSD(motionp->getLoopOut() / motionp->getDuration() * 100.f));
-			childSetValue("priority", LLSD((F32)motionp->getPriority()));
-			childSetValue("hand_pose_combo", LLHandMotion::getHandPoseName(motionp->getHandPose()));
-			childSetValue("ease_in_time", LLSD(motionp->getEaseInDuration()));
-			childSetValue("ease_out_time", LLSD(motionp->getEaseOutDuration()));
+			getChild<LLUICtrl>("loop_check")->setValue(LLSD(motionp->getLoop()));
+			getChild<LLUICtrl>("loop_in_point")->setValue(LLSD(motionp->getLoopIn() / motionp->getDuration() * 100.f));
+			getChild<LLUICtrl>("loop_out_point")->setValue(LLSD(motionp->getLoopOut() / motionp->getDuration() * 100.f));
+			getChild<LLUICtrl>("priority")->setValue(LLSD((F32)motionp->getPriority()));
+			getChild<LLUICtrl>("hand_pose_combo")->setValue(LLHandMotion::getHandPoseName(motionp->getHandPose()));
+			getChild<LLUICtrl>("ease_in_time")->setValue(LLSD(motionp->getEaseInDuration()));
+			getChild<LLUICtrl>("ease_out_time")->setValue(LLSD(motionp->getEaseOutDuration()));
 			setEnabled(TRUE);
 			std::string seconds_string;
 			seconds_string = llformat(" - %.2f seconds", motionp->getDuration());
@@ -334,7 +334,7 @@ BOOL LLFloaterAnimPreview::postBuild()
 		{
 			mAnimPreview = NULL;
 			mMotionID.setNull();
-			childSetValue("bad_animation_text", getString("failed_to_initialize"));
+			getChild<LLUICtrl>("bad_animation_text")->setValue(getString("failed_to_initialize"));
 		}
 	}
 	else
@@ -346,13 +346,13 @@ BOOL LLFloaterAnimPreview::postBuild()
 				LLUIString out_str = getString("anim_too_long");
 				out_str.setArg("[LENGTH]", llformat("%.1f", loaderp->getDuration()));
 				out_str.setArg("[MAX_LENGTH]", llformat("%.1f", MAX_ANIM_DURATION));
-				childSetValue("bad_animation_text", out_str.getString());
+				getChild<LLUICtrl>("bad_animation_text")->setValue(out_str.getString());
 			}
 			else
 			{
 				LLUIString out_str = getString("failed_file_read");
 				out_str.setArg("[STATUS]", getString(STATUS[loaderp->getStatus()])); 
-				childSetValue("bad_animation_text", out_str.getString());
+				getChild<LLUICtrl>("bad_animation_text")->setValue(out_str.getString());
 			}
 		}
 
@@ -429,17 +429,17 @@ void LLFloaterAnimPreview::resetMotion()
 	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
 	
 	// Set emotion
-	std::string emote = childGetValue("emote_combo").asString();
+	std::string emote = getChild<LLUICtrl>("emote_combo")->getValue().asString();
 	motionp->setEmote(mIDList[emote]);
 	
-	LLUUID base_id = mIDList[childGetValue("preview_base_anim").asString()];
+	LLUUID base_id = mIDList[getChild<LLUICtrl>("preview_base_anim")->getValue().asString()];
 	avatarp->deactivateAllMotions();
 	avatarp->startMotion(mMotionID, 0.0f);
 	avatarp->startMotion(base_id, BASE_ANIM_TIME_OFFSET);
-	childSetValue("playback_slider", 0.0f);
+	getChild<LLUICtrl>("playback_slider")->setValue(0.0f);
 
 	// Set pose
-	std::string handpose = childGetValue("hand_pose_combo").asString();
+	std::string handpose = getChild<LLUICtrl>("hand_pose_combo")->getValue().asString();
 	avatarp->startMotion( ANIM_AGENT_HAND_MOTION, 0.0f );
 	motionp->setHandPose(LLHandMotion::getHandPose(handpose));
 
@@ -558,24 +558,23 @@ void LLFloaterAnimPreview::onMouseCaptureLost()
 //-----------------------------------------------------------------------------
 // onBtnPlay()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onBtnPlay(void* user_data)
+void LLFloaterAnimPreview::onBtnPlay()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	if (previewp->mMotionID.notNull() && previewp->mAnimPreview)
+	if (mMotionID.notNull() && mAnimPreview)
 	{
-		LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
+		LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
 		
-		if (!avatarp->isMotionActive(previewp->mMotionID))
+		if (!avatarp->isMotionActive(mMotionID))
 		{
-			previewp->resetMotion();
-			previewp->mPauseRequest = NULL;
+			resetMotion();
+			mPauseRequest = NULL;
 		}
 		else if (avatarp->areAnimationsPaused())
 		{			
-			previewp->mPauseRequest = NULL;
+			mPauseRequest = NULL;
 		}
 	}
 }
@@ -583,21 +582,20 @@ void LLFloaterAnimPreview::onBtnPlay(void* user_data)
 //-----------------------------------------------------------------------------
 // onBtnPause()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onBtnPause(void* user_data)
+void LLFloaterAnimPreview::onBtnPause()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 	
-	if (previewp->mMotionID.notNull() && previewp->mAnimPreview)
+	if (mMotionID.notNull() && mAnimPreview)
 	{
-		LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
+		LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
 
-		if (avatarp->isMotionActive(previewp->mMotionID))
+		if (avatarp->isMotionActive(mMotionID))
 		{
 			if (!avatarp->areAnimationsPaused())
 			{
-				previewp->mPauseRequest = avatarp->requestPause();
+				mPauseRequest = avatarp->requestPause();
 			}
 		}
 	}
@@ -606,42 +604,40 @@ void LLFloaterAnimPreview::onBtnPause(void* user_data)
 //-----------------------------------------------------------------------------
 // onBtnStop()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onBtnStop(void* user_data)
+void LLFloaterAnimPreview::onBtnStop()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	if (previewp->mMotionID.notNull() && previewp->mAnimPreview)
+	if (mMotionID.notNull() && mAnimPreview)
 	{
-		LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-		previewp->resetMotion();
-		previewp->mPauseRequest = avatarp->requestPause();
+		LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+		resetMotion();
+		mPauseRequest = avatarp->requestPause();
 	}
 }
 
 //-----------------------------------------------------------------------------
 // onSliderMove()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onSliderMove(LLUICtrl* ctrl, void*user_data)
+void LLFloaterAnimPreview::onSliderMove()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	if (previewp->mAnimPreview)
+	if (mAnimPreview)
 	{
-		LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-		F32 slider_value = (F32)previewp->childGetValue("playback_slider").asReal();
-		LLUUID base_id = previewp->mIDList[previewp->childGetValue("preview_base_anim").asString()];
-		LLMotion* motionp = avatarp->findMotion(previewp->mMotionID);
+		LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+		F32 slider_value = (F32)getChild<LLUICtrl>("playback_slider")->getValue().asReal();
+		LLUUID base_id = mIDList[getChild<LLUICtrl>("preview_base_anim")->getValue().asString()];
+		LLMotion* motionp = avatarp->findMotion(mMotionID);
 		F32 duration = motionp->getDuration();// + motionp->getEaseOutDuration();
 		F32 delta_time = duration * slider_value;
 		avatarp->deactivateAllMotions();
 		avatarp->startMotion(base_id, delta_time + BASE_ANIM_TIME_OFFSET);
-		avatarp->startMotion(previewp->mMotionID, delta_time);
-		previewp->mPauseRequest = avatarp->requestPause();
-		previewp->refresh();
+		avatarp->startMotion(mMotionID, delta_time);
+		mPauseRequest = avatarp->requestPause();
+		refresh();
 	}
 
 }
@@ -649,29 +645,28 @@ void LLFloaterAnimPreview::onSliderMove(LLUICtrl* ctrl, void*user_data)
 //-----------------------------------------------------------------------------
 // onCommitBaseAnim()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitBaseAnim(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitBaseAnim()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	if (previewp->mAnimPreview)
+	if (mAnimPreview)
 	{
-		LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
+		LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
 
 		BOOL paused = avatarp->areAnimationsPaused();
 
 		// stop all other possible base motions
-		avatarp->stopMotion(previewp->mIDList["Standing"], TRUE);
-		avatarp->stopMotion(previewp->mIDList["Walking"], TRUE);
-		avatarp->stopMotion(previewp->mIDList["Sitting"], TRUE);
-		avatarp->stopMotion(previewp->mIDList["Flying"], TRUE);
+		avatarp->stopMotion(mIDList["Standing"], TRUE);
+		avatarp->stopMotion(mIDList["Walking"], TRUE);
+		avatarp->stopMotion(mIDList["Sitting"], TRUE);
+		avatarp->stopMotion(mIDList["Flying"], TRUE);
 
-		previewp->resetMotion();
+		resetMotion();
 
 		if (!paused)
 		{
-			previewp->mPauseRequest = NULL;
+			mPauseRequest = NULL;
 		}
 	}
 }
@@ -679,154 +674,145 @@ void LLFloaterAnimPreview::onCommitBaseAnim(LLUICtrl* ctrl, void* data)
 //-----------------------------------------------------------------------------
 // onCommitLoop()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitLoop(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitLoop()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 	
-	LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
+	LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
 
 	if (motionp)
 	{
-		motionp->setLoop(previewp->childGetValue("loop_check").asBoolean());
-		motionp->setLoopIn((F32)previewp->childGetValue("loop_in_point").asReal() * 0.01f * motionp->getDuration());
-		motionp->setLoopOut((F32)previewp->childGetValue("loop_out_point").asReal() * 0.01f * motionp->getDuration());
+		motionp->setLoop(getChild<LLUICtrl>("loop_check")->getValue().asBoolean());
+		motionp->setLoopIn((F32)getChild<LLUICtrl>("loop_in_point")->getValue().asReal() * 0.01f * motionp->getDuration());
+		motionp->setLoopOut((F32)getChild<LLUICtrl>("loop_out_point")->getValue().asReal() * 0.01f * motionp->getDuration());
 	}
 }
 
 //-----------------------------------------------------------------------------
 // onCommitLoopIn()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitLoopIn(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitLoopIn()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
+	LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
 
 	if (motionp)
 	{
-		motionp->setLoopIn((F32)previewp->childGetValue("loop_in_point").asReal() / 100.f);
-		previewp->resetMotion();
-		previewp->childSetValue("loop_check", LLSD(TRUE));
-		onCommitLoop(ctrl, data);
+		motionp->setLoopIn((F32)getChild<LLUICtrl>("loop_in_point")->getValue().asReal() / 100.f);
+		resetMotion();
+		getChild<LLUICtrl>("loop_check")->setValue(LLSD(TRUE));
+		onCommitLoop();
 	}
 }
 
 //-----------------------------------------------------------------------------
 // onCommitLoopOut()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitLoopOut(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitLoopOut()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
+	LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
 
 	if (motionp)
 	{
-		motionp->setLoopOut((F32)previewp->childGetValue("loop_out_point").asReal() * 0.01f * motionp->getDuration());
-		previewp->resetMotion();
-		previewp->childSetValue("loop_check", LLSD(TRUE));
-		onCommitLoop(ctrl, data);
+		motionp->setLoopOut((F32)getChild<LLUICtrl>("loop_out_point")->getValue().asReal() * 0.01f * motionp->getDuration());
+		resetMotion();
+		getChild<LLUICtrl>("loop_check")->setValue(LLSD(TRUE));
+		onCommitLoop();
 	}
 }
 
 //-----------------------------------------------------------------------------
 // onCommitName()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitName(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitName()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
+	LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
 
 	if (motionp)
 	{
-		motionp->setName(previewp->childGetValue("name_form").asString());
+		motionp->setName(getChild<LLUICtrl>("name_form")->getValue().asString());
 	}
 
-	previewp->doCommit();
+	doCommit();
 }
 
 //-----------------------------------------------------------------------------
 // onCommitHandPose()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitHandPose(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitHandPose()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	previewp->resetMotion(); // sets hand pose
+	resetMotion(); // sets hand pose
 }
 
 //-----------------------------------------------------------------------------
 // onCommitEmote()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitEmote(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitEmote()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	previewp->resetMotion(); // ssts emote
+	resetMotion(); // ssts emote
 }
 
 //-----------------------------------------------------------------------------
 // onCommitPriority()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitPriority(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitPriority()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
+	LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
 
-	motionp->setPriority(llfloor((F32)previewp->childGetValue("priority").asReal()));
+	motionp->setPriority(llfloor((F32)getChild<LLUICtrl>("priority")->getValue().asReal()));
 }
 
 //-----------------------------------------------------------------------------
 // onCommitEaseIn()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitEaseIn(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitEaseIn()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
+	LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
 
-	motionp->setEaseIn((F32)previewp->childGetValue("ease_in_time").asReal());
-	previewp->resetMotion();
+	motionp->setEaseIn((F32)getChild<LLUICtrl>("ease_in_time")->getValue().asReal());
+	resetMotion();
 }
 
 //-----------------------------------------------------------------------------
 // onCommitEaseOut()
 //-----------------------------------------------------------------------------
-void LLFloaterAnimPreview::onCommitEaseOut(LLUICtrl* ctrl, void* data)
+void LLFloaterAnimPreview::onCommitEaseOut()
 {
-	LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-	if (!previewp->getEnabled())
+	if (!getEnabled())
 		return;
 
-	LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
+	LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+	LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
 
-	motionp->setEaseOut((F32)previewp->childGetValue("ease_out_time").asReal());
-	previewp->resetMotion();
+	motionp->setEaseOut((F32)getChild<LLUICtrl>("ease_out_time")->getValue().asReal());
+	resetMotion();
 }
 
 //-----------------------------------------------------------------------------
@@ -842,8 +828,8 @@ bool LLFloaterAnimPreview::validateEaseIn(const LLSD& data)
 	
 	if (!motionp->getLoop())
 	{
-		F32 new_ease_in = llclamp((F32)childGetValue("ease_in_time").asReal(), 0.f, motionp->getDuration() - motionp->getEaseOutDuration());
-		childSetValue("ease_in_time", LLSD(new_ease_in));
+		F32 new_ease_in = llclamp((F32)getChild<LLUICtrl>("ease_in_time")->getValue().asReal(), 0.f, motionp->getDuration() - motionp->getEaseOutDuration());
+		getChild<LLUICtrl>("ease_in_time")->setValue(LLSD(new_ease_in));
 	}
 	
 	return true;
@@ -862,8 +848,8 @@ bool LLFloaterAnimPreview::validateEaseOut(const LLSD& data)
 	
 	if (!motionp->getLoop())
 	{
-		F32 new_ease_out = llclamp((F32)childGetValue("ease_out_time").asReal(), 0.f, motionp->getDuration() - motionp->getEaseInDuration());
-		childSetValue("ease_out_time", LLSD(new_ease_out));
+		F32 new_ease_out = llclamp((F32)getChild<LLUICtrl>("ease_out_time")->getValue().asReal(), 0.f, motionp->getDuration() - motionp->getEaseInDuration());
+		getChild<LLUICtrl>("ease_out_time")->setValue(LLSD(new_ease_out));
 	}
 
 	return true;
@@ -877,8 +863,8 @@ bool LLFloaterAnimPreview::validateLoopIn(const LLSD& data)
 	if (!getEnabled())
 		return false;
 
-	F32 loop_in_value = (F32)childGetValue("loop_in_point").asReal();
-	F32 loop_out_value = (F32)childGetValue("loop_out_point").asReal();
+	F32 loop_in_value = (F32)getChild<LLUICtrl>("loop_in_point")->getValue().asReal();
+	F32 loop_out_value = (F32)getChild<LLUICtrl>("loop_out_point")->getValue().asReal();
 
 	if (loop_in_value < 0.f)
 	{
@@ -893,7 +879,7 @@ bool LLFloaterAnimPreview::validateLoopIn(const LLSD& data)
 		loop_in_value = loop_out_value;
 	}
 
-	childSetValue("loop_in_point", LLSD(loop_in_value));
+	getChild<LLUICtrl>("loop_in_point")->setValue(LLSD(loop_in_value));
 	return true;
 }
 
@@ -905,8 +891,8 @@ bool LLFloaterAnimPreview::validateLoopOut(const LLSD& data)
 	if (!getEnabled())
 		return false;
 
-	F32 loop_out_value = (F32)childGetValue("loop_out_point").asReal();
-	F32 loop_in_value = (F32)childGetValue("loop_in_point").asReal();
+	F32 loop_out_value = (F32)getChild<LLUICtrl>("loop_out_point")->getValue().asReal();
+	F32 loop_in_value = (F32)getChild<LLUICtrl>("loop_in_point")->getValue().asReal();
 
 	if (loop_out_value < 0.f)
 	{
@@ -921,7 +907,7 @@ bool LLFloaterAnimPreview::validateLoopOut(const LLSD& data)
 		loop_out_value = loop_in_value;
 	}
 
-	childSetValue("loop_out_point", LLSD(loop_out_value));
+	getChild<LLUICtrl>("loop_out_point")->setValue(LLSD(loop_out_value));
 	return true;
 }
 
@@ -935,15 +921,15 @@ void LLFloaterAnimPreview::refresh()
 	bool show_play = true;
 	if (!mAnimPreview)
 	{
-		childShow("bad_animation_text");
+		getChildView("bad_animation_text")->setVisible(TRUE);
 		// play button visible but disabled
 		mPlayButton->setEnabled(FALSE);
 		mStopButton->setEnabled(FALSE);
-		childDisable("ok_btn");
+		getChildView("ok_btn")->setEnabled(FALSE);
 	}
 	else
 	{
-		childHide("bad_animation_text");
+		getChildView("bad_animation_text")->setVisible(FALSE);
 		// re-enabled in case previous animation was bad
 		mPlayButton->setEnabled(TRUE);
 		mStopButton->setEnabled(TRUE);
@@ -958,7 +944,7 @@ void LLFloaterAnimPreview::refresh()
 				if (motionp)
 				{
 					F32 fraction_complete = motionp->getLastUpdateTime() / motionp->getDuration();
-					childSetValue("playback_slider", fraction_complete);
+					getChild<LLUICtrl>("playback_slider")->setValue(fraction_complete);
 				}
 				show_play = false;
 			}
@@ -968,7 +954,7 @@ void LLFloaterAnimPreview::refresh()
 			// Motion just finished playing
 			mPauseRequest = avatarp->requestPause();
 		}
-		childEnable("ok_btn");
+		getChildView("ok_btn")->setEnabled(TRUE);
 		mAnimPreview->requestUpdate();
 	}
 	mPlayButton->setVisible(show_play);
@@ -999,8 +985,8 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata)
 			file.setMaxSize(size);
 			if (file.write((U8*)buffer, size))
 			{
-				std::string name = floaterp->childGetValue("name_form").asString();
-				std::string desc = floaterp->childGetValue("description_form").asString();
+				std::string name = floaterp->getChild<LLUICtrl>("name_form")->getValue().asString();
+				std::string desc = floaterp->getChild<LLUICtrl>("description_form")->getValue().asString();
 				LLAssetStorage::LLStoreAssetCallback callback = NULL;
 				S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
 				void *userdata = NULL;
diff --git a/indra/newview/llfloateranimpreview.h b/indra/newview/llfloateranimpreview.h
index 84f131a3221..24d7a93a17e 100644
--- a/indra/newview/llfloateranimpreview.h
+++ b/indra/newview/llfloateranimpreview.h
@@ -89,22 +89,22 @@ class LLFloaterAnimPreview : public LLFloaterNameDesc
 
 	void refresh();
 
-	static void	onBtnPlay(void*);
-	static void	onBtnPause(void*);	
-	static void	onBtnStop(void*);
-	static void onSliderMove(LLUICtrl*, void*);
-	static void onCommitBaseAnim(LLUICtrl*, void*);
-	static void onCommitLoop(LLUICtrl*, void*);
-	static void onCommitLoopIn(LLUICtrl*, void*);
-	static void onCommitLoopOut(LLUICtrl*, void*);
+	void onBtnPlay();
+	void onBtnPause();	
+	void onBtnStop();
+	void onSliderMove();
+	void onCommitBaseAnim();
+	void onCommitLoop();
+	void onCommitLoopIn();
+	void onCommitLoopOut();
 	bool validateLoopIn(const LLSD& data);
 	bool validateLoopOut(const LLSD& data);
-	static void onCommitName(LLUICtrl*, void*);
-	static void onCommitHandPose(LLUICtrl*, void*);
-	static void onCommitEmote(LLUICtrl*, void*);
-	static void onCommitPriority(LLUICtrl*, void*);
-	static void onCommitEaseIn(LLUICtrl*, void*);
-	static void onCommitEaseOut(LLUICtrl*, void*);
+	void onCommitName();
+	void onCommitHandPose();
+	void onCommitEmote();
+	void onCommitPriority();
+	void onCommitEaseIn();
+	void onCommitEaseOut();
 	bool validateEaseIn(const LLSD& data);
 	bool validateEaseOut(const LLSD& data);
 	static void	onBtnOK(void*);
-- 
GitLab


From ce75ef377c6ff9a54c3a56fd52ab5b3776f80927 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 09:40:41 -0700
Subject: [PATCH 572/683] converted static callbacks to member functions and
 deprecated LLPanel::child*() methods

---
 indra/newview/llfloaterland.cpp | 173 +++++++++++++++-----------------
 indra/newview/llfloaterland.h   |   5 +-
 2 files changed, 84 insertions(+), 94 deletions(-)

diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 913bb676b04..5c263444360 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -371,7 +371,7 @@ BOOL LLPanelLandGeneral::postBuild()
 {
 	mEditName = getChild<LLLineEditor>("Name");
 	mEditName->setCommitCallback(onCommitAny, this);	
-	childSetPrevalidate("Name", LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("Name")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
 
 	mEditDesc = getChild<LLTextEditor>("Description");
 	mEditDesc->setCommitOnFocusLost(TRUE);
@@ -388,7 +388,7 @@ BOOL LLPanelLandGeneral::postBuild()
 	mLandType = getChild<LLTextBox>("LandTypeText");
 	
 	mBtnProfile = getChild<LLButton>("Profile...");
-	mBtnProfile->setClickedCallback(onClickProfile, this);
+	mBtnProfile->setClickedCallback(boost::bind(&LLPanelLandGeneral::onClickProfile, this));
 
 	
 	mTextGroupLabel = getChild<LLTextBox>("Group:");
@@ -865,11 +865,9 @@ void LLPanelLandGeneral::onClickSetGroup()
 	}
 }
 
-// static
-void LLPanelLandGeneral::onClickProfile(void* data)
+void LLPanelLandGeneral::onClickProfile()
 {
-	LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)data;
-	LLParcel* parcel = panelp->mParcel->getParcel();
+	LLParcel* parcel = mParcel->getParcel();
 	if (!parcel) return;
 
 	if (parcel->getIsGroupOwned())
@@ -920,13 +918,6 @@ void LLPanelLandGeneral::onClickScriptLimits(void* data)
 	}
 }
 
-BOOL LLPanelLandGeneral::enableDeedToGroup(void* data)
-{
-	LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)data;
-	LLParcel* parcel = panelp->mParcel->getParcel();
-	return (parcel != NULL) && (parcel->getParcelFlag(PF_ALLOW_DEED_TO_GROUP));
-}
-
 // static
 void LLPanelLandGeneral::onClickDeed(void*)
 {
@@ -1140,7 +1131,7 @@ BOOL LLPanelLandObjects::postBuild()
 
 	mCleanOtherObjectsTime->setFocusLostCallback(boost::bind(onLostFocus, _1, this));
 	mCleanOtherObjectsTime->setCommitCallback(onCommitClean, this);
-	childSetPrevalidate("clean other time", LLTextValidate::validateNonNegativeS32);
+	getChild<LLLineEditor>("clean other time")->setPrevalidate(LLTextValidate::validateNonNegativeS32);
 	
 	mBtnRefresh = getChild<LLButton>("Refresh List");
 	mBtnRefresh->setClickedCallback(onClickRefresh, this);
@@ -2404,18 +2395,18 @@ void LLPanelLandAccess::refresh()
 		BOOL use_group = parcel->getParcelFlag(PF_USE_ACCESS_GROUP);
 		BOOL public_access = !use_access_list && !use_group;
 		
-		childSetValue("public_access", public_access );
-		childSetValue("GroupCheck", use_group );
+		getChild<LLUICtrl>("public_access")->setValue(public_access );
+		getChild<LLUICtrl>("GroupCheck")->setValue(use_group );
 
 		std::string group_name;
 		gCacheName->getGroupName(parcel->getGroupID(), group_name);
-		childSetLabelArg("GroupCheck", "[GROUP]", group_name );
+		getChild<LLUICtrl>("GroupCheck")->setLabelArg("[GROUP]", group_name );
 		
 		// Allow list
 		{
 			S32 count = parcel->mAccessList.size();
-			childSetToolTipArg("AccessList", "[LISTED]", llformat("%d",count));
-			childSetToolTipArg("AccessList", "[MAX]", llformat("%d",PARCEL_MAX_ACCESS_LIST));
+			getChild<LLUICtrl>("AccessList")->setToolTipArg(LLStringExplicit("[LISTED]"), llformat("%d",count));
+			getChild<LLUICtrl>("AccessList")->setToolTipArg(LLStringExplicit("[MAX]"), llformat("%d",PARCEL_MAX_ACCESS_LIST));
 
 			for (access_map_const_iterator cit = parcel->mAccessList.begin();
 				 cit != parcel->mAccessList.end(); ++cit)
@@ -2456,8 +2447,8 @@ void LLPanelLandAccess::refresh()
 		{
 			S32 count = parcel->mBanList.size();
 
-			childSetToolTipArg("BannedList", "[LISTED]", llformat("%d",count));
-			childSetToolTipArg("BannedList", "[MAX]", llformat("%d",PARCEL_MAX_ACCESS_LIST));
+			getChild<LLUICtrl>("BannedList")->setToolTipArg(LLStringExplicit("[LISTED]"), llformat("%d",count));
+			getChild<LLUICtrl>("BannedList")->setToolTipArg(LLStringExplicit("[MAX]"), llformat("%d",PARCEL_MAX_ACCESS_LIST));
 
 			for (access_map_const_iterator cit = parcel->mBanList.begin();
 				 cit != parcel->mBanList.end(); ++cit)
@@ -2516,27 +2507,27 @@ void LLPanelLandAccess::refresh()
 
 		if(parcel->getRegionDenyAnonymousOverride())
 		{
-			childSetValue("limit_payment", TRUE);
-			childSetLabelArg( "limit_payment", "[ESTATE_PAYMENT_LIMIT]", getString("access_estate_defined") );
+			getChild<LLUICtrl>("limit_payment")->setValue(TRUE);
+			getChild<LLUICtrl>("limit_payment")->setLabelArg("[ESTATE_PAYMENT_LIMIT]", getString("access_estate_defined") );
 		}
 		else
 		{
-			childSetValue("limit_payment", (parcel->getParcelFlag(PF_DENY_ANONYMOUS)));
-			childSetLabelArg( "limit_payment", "[ESTATE_PAYMENT_LIMIT]", std::string() );
+			getChild<LLUICtrl>("limit_payment")->setValue((parcel->getParcelFlag(PF_DENY_ANONYMOUS)));
+			getChild<LLUICtrl>("limit_payment")->setLabelArg("[ESTATE_PAYMENT_LIMIT]", std::string() );
 		}
 		if(parcel->getRegionDenyAgeUnverifiedOverride())
 		{
-			childSetValue("limit_age_verified", TRUE);
-			childSetLabelArg( "limit_age_verified", "[ESTATE_AGE_LIMIT]", getString("access_estate_defined") );
+			getChild<LLUICtrl>("limit_age_verified")->setValue(TRUE);
+			getChild<LLUICtrl>("limit_age_verified")->setLabelArg("[ESTATE_AGE_LIMIT]", getString("access_estate_defined") );
 		}
 		else
 		{
-			childSetValue("limit_age_verified", (parcel->getParcelFlag(PF_DENY_AGEUNVERIFIED)));
-			childSetLabelArg( "limit_age_verified", "[ESTATE_AGE_LIMIT]", std::string() );
+			getChild<LLUICtrl>("limit_age_verified")->setValue((parcel->getParcelFlag(PF_DENY_AGEUNVERIFIED)));
+			getChild<LLUICtrl>("limit_age_verified")->setLabelArg("[ESTATE_AGE_LIMIT]", std::string() );
 		}
 		
 		BOOL use_pass = parcel->getParcelFlag(PF_USE_PASS_LIST);
-		childSetValue("PassCheck",  use_pass );
+		getChild<LLUICtrl>("PassCheck")->setValue(use_pass );
 		LLCtrlSelectionInterface* passcombo = childGetSelectionInterface("pass_combo");
 		if (passcombo)
 		{
@@ -2547,40 +2538,40 @@ void LLPanelLandAccess::refresh()
 		}
 		
 		S32 pass_price = parcel->getPassPrice();
-		childSetValue( "PriceSpin", (F32)pass_price );
+		getChild<LLUICtrl>("PriceSpin")->setValue((F32)pass_price );
 
 		F32 pass_hours = parcel->getPassHours();
-		childSetValue( "HoursSpin", pass_hours );
+		getChild<LLUICtrl>("HoursSpin")->setValue(pass_hours );
 	}
 	else
 	{
-		childSetValue("public_access", FALSE);
-		childSetValue("limit_payment", FALSE);
-		childSetValue("limit_age_verified", FALSE);
-		childSetValue("GroupCheck", FALSE);
-		childSetLabelArg("GroupCheck", "[GROUP]", LLStringUtil::null );
-		childSetValue("PassCheck", FALSE);
-		childSetValue("PriceSpin", (F32)PARCEL_PASS_PRICE_DEFAULT);
-		childSetValue( "HoursSpin", PARCEL_PASS_HOURS_DEFAULT );
-		childSetToolTipArg("AccessList", "[LISTED]", llformat("%d",0));
-		childSetToolTipArg("AccessList", "[MAX]", llformat("%d",0));
-		childSetToolTipArg("BannedList", "[LISTED]", llformat("%d",0));
-		childSetToolTipArg("BannedList", "[MAX]", llformat("%d",0));
+		getChild<LLUICtrl>("public_access")->setValue(FALSE);
+		getChild<LLUICtrl>("limit_payment")->setValue(FALSE);
+		getChild<LLUICtrl>("limit_age_verified")->setValue(FALSE);
+		getChild<LLUICtrl>("GroupCheck")->setValue(FALSE);
+		getChild<LLUICtrl>("GroupCheck")->setLabelArg("[GROUP]", LLStringUtil::null );
+		getChild<LLUICtrl>("PassCheck")->setValue(FALSE);
+		getChild<LLUICtrl>("PriceSpin")->setValue((F32)PARCEL_PASS_PRICE_DEFAULT);
+		getChild<LLUICtrl>("HoursSpin")->setValue(PARCEL_PASS_HOURS_DEFAULT );
+		getChild<LLUICtrl>("AccessList")->setToolTipArg(LLStringExplicit("[LISTED]"), llformat("%d",0));
+		getChild<LLUICtrl>("AccessList")->setToolTipArg(LLStringExplicit("[MAX]"), llformat("%d",0));
+		getChild<LLUICtrl>("BannedList")->setToolTipArg(LLStringExplicit("[LISTED]"), llformat("%d",0));
+		getChild<LLUICtrl>("BannedList")->setToolTipArg(LLStringExplicit("[MAX]"), llformat("%d",0));
 	}	
 }
 
 void LLPanelLandAccess::refresh_ui()
 {
-	childSetEnabled("public_access", FALSE);
-	childSetEnabled("limit_payment", FALSE);
-	childSetEnabled("limit_age_verified", FALSE);
-	childSetEnabled("GroupCheck", FALSE);
-	childSetEnabled("PassCheck", FALSE);
-	childSetEnabled("pass_combo", FALSE);
-	childSetEnabled("PriceSpin", FALSE);
-	childSetEnabled("HoursSpin", FALSE);
-	childSetEnabled("AccessList", FALSE);
-	childSetEnabled("BannedList", FALSE);
+	getChildView("public_access")->setEnabled(FALSE);
+	getChildView("limit_payment")->setEnabled(FALSE);
+	getChildView("limit_age_verified")->setEnabled(FALSE);
+	getChildView("GroupCheck")->setEnabled(FALSE);
+	getChildView("PassCheck")->setEnabled(FALSE);
+	getChildView("pass_combo")->setEnabled(FALSE);
+	getChildView("PriceSpin")->setEnabled(FALSE);
+	getChildView("HoursSpin")->setEnabled(FALSE);
+	getChildView("AccessList")->setEnabled(FALSE);
+	getChildView("BannedList")->setEnabled(FALSE);
 	
 	LLParcel *parcel = mParcel->getParcel();
 	if (parcel)
@@ -2588,73 +2579,73 @@ void LLPanelLandAccess::refresh_ui()
 		BOOL can_manage_allowed = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_MANAGE_ALLOWED);
 		BOOL can_manage_banned = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_MANAGE_BANNED);
 	
-		childSetEnabled("public_access", can_manage_allowed);
-		BOOL public_access = childGetValue("public_access").asBoolean();
+		getChildView("public_access")->setEnabled(can_manage_allowed);
+		BOOL public_access = getChild<LLUICtrl>("public_access")->getValue().asBoolean();
 		if (public_access)
 		{
 			bool override = false;
 			if(parcel->getRegionDenyAnonymousOverride())
 			{
 				override = true;
-				childSetEnabled("limit_payment", FALSE);
+				getChildView("limit_payment")->setEnabled(FALSE);
 			}
 			else
 			{
-				childSetEnabled("limit_payment", can_manage_allowed);
+				getChildView("limit_payment")->setEnabled(can_manage_allowed);
 			}
 			if(parcel->getRegionDenyAgeUnverifiedOverride())
 			{
 				override = true;
-				childSetEnabled("limit_age_verified", FALSE);
+				getChildView("limit_age_verified")->setEnabled(FALSE);
 			}
 			else
 			{
-				childSetEnabled("limit_age_verified", can_manage_allowed);
+				getChildView("limit_age_verified")->setEnabled(can_manage_allowed);
 			}
 			if (override)
 			{
-				childSetToolTip("Only Allow", getString("estate_override"));
+				getChildView("Only Allow")->setToolTip(getString("estate_override"));
 			}
 			else
 			{
-				childSetToolTip("Only Allow", std::string());
+				getChildView("Only Allow")->setToolTip(std::string());
 			}
-			childSetEnabled("GroupCheck", FALSE);
-			childSetEnabled("PassCheck", FALSE);
-			childSetEnabled("pass_combo", FALSE);
-			childSetEnabled("AccessList", FALSE);
+			getChildView("GroupCheck")->setEnabled(FALSE);
+			getChildView("PassCheck")->setEnabled(FALSE);
+			getChildView("pass_combo")->setEnabled(FALSE);
+			getChildView("AccessList")->setEnabled(FALSE);
 		}
 		else
 		{
-			childSetEnabled("limit_payment", FALSE);
-			childSetEnabled("limit_age_verified", FALSE);
+			getChildView("limit_payment")->setEnabled(FALSE);
+			getChildView("limit_age_verified")->setEnabled(FALSE);
 
 			std::string group_name;
 			if (gCacheName->getGroupName(parcel->getGroupID(), group_name))
 			{			
-				childSetEnabled("GroupCheck", can_manage_allowed);
+				getChildView("GroupCheck")->setEnabled(can_manage_allowed);
 			}
-			BOOL group_access = childGetValue("GroupCheck").asBoolean();
-			BOOL sell_passes = childGetValue("PassCheck").asBoolean();
-			childSetEnabled("PassCheck", can_manage_allowed);
+			BOOL group_access = getChild<LLUICtrl>("GroupCheck")->getValue().asBoolean();
+			BOOL sell_passes = getChild<LLUICtrl>("PassCheck")->getValue().asBoolean();
+			getChildView("PassCheck")->setEnabled(can_manage_allowed);
 			if (sell_passes)
 			{
-				childSetEnabled("pass_combo", group_access && can_manage_allowed);
-				childSetEnabled("PriceSpin", can_manage_allowed);
-				childSetEnabled("HoursSpin", can_manage_allowed);
+				getChildView("pass_combo")->setEnabled(group_access && can_manage_allowed);
+				getChildView("PriceSpin")->setEnabled(can_manage_allowed);
+				getChildView("HoursSpin")->setEnabled(can_manage_allowed);
 			}
 		}
-		childSetEnabled("AccessList", can_manage_allowed);
+		getChildView("AccessList")->setEnabled(can_manage_allowed);
 		S32 allowed_list_count = parcel->mAccessList.size();
-		childSetEnabled("add_allowed", can_manage_allowed && allowed_list_count < PARCEL_MAX_ACCESS_LIST);
+		getChildView("add_allowed")->setEnabled(can_manage_allowed && allowed_list_count < PARCEL_MAX_ACCESS_LIST);
 		BOOL has_selected = mListAccess->getSelectionInterface()->getFirstSelectedIndex() >= 0;
-		childSetEnabled("remove_allowed", can_manage_allowed && has_selected);
+		getChildView("remove_allowed")->setEnabled(can_manage_allowed && has_selected);
 		
-		childSetEnabled("BannedList", can_manage_banned);
+		getChildView("BannedList")->setEnabled(can_manage_banned);
 		S32 banned_list_count = parcel->mBanList.size();
-		childSetEnabled("add_banned", can_manage_banned && banned_list_count < PARCEL_MAX_ACCESS_LIST);
+		getChildView("add_banned")->setEnabled(can_manage_banned && banned_list_count < PARCEL_MAX_ACCESS_LIST);
 		has_selected = mListBanned->getSelectionInterface()->getFirstSelectedIndex() >= 0;
-		childSetEnabled("remove_banned", can_manage_banned && has_selected);
+		getChildView("remove_banned")->setEnabled(can_manage_banned && has_selected);
 	}
 }
 		
@@ -2668,7 +2659,7 @@ void LLPanelLandAccess::refreshNames()
 	{
 		gCacheName->getGroupName(parcel->getGroupID(), group_name);
 	}
-	childSetLabelArg("GroupCheck", "[GROUP]", group_name);
+	getChild<LLUICtrl>("GroupCheck")->setLabelArg("[GROUP]", group_name);
 }
 
 
@@ -2691,13 +2682,13 @@ void LLPanelLandAccess::onCommitPublicAccess(LLUICtrl *ctrl, void *userdata)
 	}
 
 	// If we disabled public access, enable group access by default (if applicable)
-	BOOL public_access = self->childGetValue("public_access").asBoolean();
+	BOOL public_access = self->getChild<LLUICtrl>("public_access")->getValue().asBoolean();
 	if (public_access == FALSE)
 	{
 		std::string group_name;
 		if (gCacheName->getGroupName(parcel->getGroupID(), group_name))
 		{
-			self->childSetValue("GroupCheck", public_access ? FALSE : TRUE);
+			self->getChild<LLUICtrl>("GroupCheck")->setValue(public_access ? FALSE : TRUE);
 		}
 	}
 	
@@ -2716,8 +2707,8 @@ void LLPanelLandAccess::onCommitAny(LLUICtrl *ctrl, void *userdata)
 	}
 
 	// Extract data from UI
-	BOOL public_access = self->childGetValue("public_access").asBoolean();
-	BOOL use_access_group = self->childGetValue("GroupCheck").asBoolean();
+	BOOL public_access = self->getChild<LLUICtrl>("public_access")->getValue().asBoolean();
+	BOOL use_access_group = self->getChild<LLUICtrl>("GroupCheck")->getValue().asBoolean();
 	if (use_access_group)
 	{
 		std::string group_name;
@@ -2735,13 +2726,13 @@ void LLPanelLandAccess::onCommitAny(LLUICtrl *ctrl, void *userdata)
 	{
 		use_access_list = FALSE;
 		use_access_group = FALSE;
-		limit_payment = self->childGetValue("limit_payment").asBoolean();
-		limit_age_verified = self->childGetValue("limit_age_verified").asBoolean();
+		limit_payment = self->getChild<LLUICtrl>("limit_payment")->getValue().asBoolean();
+		limit_age_verified = self->getChild<LLUICtrl>("limit_age_verified")->getValue().asBoolean();
 	}
 	else
 	{
 		use_access_list = TRUE;
-		use_pass_list = self->childGetValue("PassCheck").asBoolean();
+		use_pass_list = self->getChild<LLUICtrl>("PassCheck")->getValue().asBoolean();
 		if (use_access_group && use_pass_list)
 		{
 			LLCtrlSelectionInterface* passcombo = self->childGetSelectionInterface("pass_combo");
@@ -2755,8 +2746,8 @@ void LLPanelLandAccess::onCommitAny(LLUICtrl *ctrl, void *userdata)
 		}
 	}
 
-	S32 pass_price = llfloor((F32)self->childGetValue("PriceSpin").asReal());
-	F32 pass_hours = (F32)self->childGetValue("HoursSpin").asReal();
+	S32 pass_price = llfloor((F32)self->getChild<LLUICtrl>("PriceSpin")->getValue().asReal());
+	F32 pass_hours = (F32)self->getChild<LLUICtrl>("HoursSpin")->getValue().asReal();
 
 	// Push data into current parcel
 	parcel->setParcelFlag(PF_USE_ACCESS_GROUP,	use_access_group);
diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h
index 0a743e5215c..130f52361ac 100644
--- a/indra/newview/llfloaterland.h
+++ b/indra/newview/llfloaterland.h
@@ -144,9 +144,8 @@ class LLPanelLandGeneral
 	virtual void draw();
 
 	void setGroup(const LLUUID& group_id);
-	static void onClickProfile(void*);
-		   void onClickSetGroup();
-	static BOOL enableDeedToGroup(void*);
+	void onClickProfile();
+	void onClickSetGroup();
 	static void onClickDeed(void*);
 	static void onClickBuyLand(void* data);
 	static void onClickScriptLimits(void* data);
-- 
GitLab


From 37f838a86ffe9c1d6bc84656772ad39e8c97d637 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 09:42:10 -0700
Subject: [PATCH 573/683] converted static callbacks to member functions and
 deprecated LLPanel::child*() methods

---
 indra/newview/llfloaterregioninfo.cpp | 421 +++++++++++++-------------
 indra/newview/llfloaterregioninfo.h   |  26 +-
 2 files changed, 219 insertions(+), 228 deletions(-)

diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 8c219cb3fdf..8af4955f92e 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -332,20 +332,20 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg)
 
 	// GENERAL PANEL
 	panel = tab->getChild<LLPanel>("General");
-	panel->childSetValue("region_text", LLSD(sim_name));
-	panel->childSetValue("region_type", LLSD(sim_type));
-	panel->childSetValue("version_channel_text", gLastVersionChannel);
-
-	panel->childSetValue("block_terraform_check", (region_flags & REGION_FLAGS_BLOCK_TERRAFORM) ? TRUE : FALSE );
-	panel->childSetValue("block_fly_check", (region_flags & REGION_FLAGS_BLOCK_FLY) ? TRUE : FALSE );
-	panel->childSetValue("allow_damage_check", (region_flags & REGION_FLAGS_ALLOW_DAMAGE) ? TRUE : FALSE );
-	panel->childSetValue("restrict_pushobject", (region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE );
-	panel->childSetValue("allow_land_resell_check", (region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE );
-	panel->childSetValue("allow_parcel_changes_check", (region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE );
-	panel->childSetValue("block_parcel_search_check", (region_flags & REGION_FLAGS_BLOCK_PARCEL_SEARCH) ? TRUE : FALSE );
-	panel->childSetValue("agent_limit_spin", LLSD((F32)agent_limit) );
-	panel->childSetValue("object_bonus_spin", LLSD(object_bonus_factor) );
-	panel->childSetValue("access_combo", LLSD(sim_access) );
+	panel->getChild<LLUICtrl>("region_text")->setValue(LLSD(sim_name));
+	panel->getChild<LLUICtrl>("region_type")->setValue(LLSD(sim_type));
+	panel->getChild<LLUICtrl>("version_channel_text")->setValue(gLastVersionChannel);
+
+	panel->getChild<LLUICtrl>("block_terraform_check")->setValue((region_flags & REGION_FLAGS_BLOCK_TERRAFORM) ? TRUE : FALSE );
+	panel->getChild<LLUICtrl>("block_fly_check")->setValue((region_flags & REGION_FLAGS_BLOCK_FLY) ? TRUE : FALSE );
+	panel->getChild<LLUICtrl>("allow_damage_check")->setValue((region_flags & REGION_FLAGS_ALLOW_DAMAGE) ? TRUE : FALSE );
+	panel->getChild<LLUICtrl>("restrict_pushobject")->setValue((region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE );
+	panel->getChild<LLUICtrl>("allow_land_resell_check")->setValue((region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE );
+	panel->getChild<LLUICtrl>("allow_parcel_changes_check")->setValue((region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE );
+	panel->getChild<LLUICtrl>("block_parcel_search_check")->setValue((region_flags & REGION_FLAGS_BLOCK_PARCEL_SEARCH) ? TRUE : FALSE );
+	panel->getChild<LLUICtrl>("agent_limit_spin")->setValue(LLSD((F32)agent_limit) );
+	panel->getChild<LLUICtrl>("object_bonus_spin")->setValue(LLSD(object_bonus_factor) );
+	panel->getChild<LLUICtrl>("access_combo")->setValue(LLSD(sim_access) );
 
 
  	// detect teen grid for maturity
@@ -353,32 +353,32 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg)
 	U32 parent_estate_id;
 	msg->getU32("RegionInfo", "ParentEstateID", parent_estate_id);
 	BOOL teen_grid = (parent_estate_id == 5);  // *TODO add field to estate table and test that
-	panel->childSetEnabled("access_combo", gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid));
+	panel->getChildView("access_combo")->setEnabled(gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid));
 	panel->setCtrlsEnabled(allow_modify);
 	
 
 	// DEBUG PANEL
 	panel = tab->getChild<LLPanel>("Debug");
 
-	panel->childSetValue("region_text", LLSD(sim_name) );
-	panel->childSetValue("disable_scripts_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_SCRIPTS)) );
-	panel->childSetValue("disable_collisions_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_COLLISIONS)) );
-	panel->childSetValue("disable_physics_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_PHYSICS)) );
+	panel->getChild<LLUICtrl>("region_text")->setValue(LLSD(sim_name) );
+	panel->getChild<LLUICtrl>("disable_scripts_check")->setValue(LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_SCRIPTS)) );
+	panel->getChild<LLUICtrl>("disable_collisions_check")->setValue(LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_COLLISIONS)) );
+	panel->getChild<LLUICtrl>("disable_physics_check")->setValue(LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_PHYSICS)) );
 	panel->setCtrlsEnabled(allow_modify);
 
 	// TERRAIN PANEL
 	panel = tab->getChild<LLPanel>("Terrain");
 
-	panel->childSetValue("region_text", LLSD(sim_name));
-	panel->childSetValue("water_height_spin", LLSD(water_height));
-	panel->childSetValue("terrain_raise_spin", LLSD(terrain_raise_limit));
-	panel->childSetValue("terrain_lower_spin", LLSD(terrain_lower_limit));
-	panel->childSetValue("use_estate_sun_check", LLSD(use_estate_sun));
+	panel->getChild<LLUICtrl>("region_text")->setValue(LLSD(sim_name));
+	panel->getChild<LLUICtrl>("water_height_spin")->setValue(LLSD(water_height));
+	panel->getChild<LLUICtrl>("terrain_raise_spin")->setValue(LLSD(terrain_raise_limit));
+	panel->getChild<LLUICtrl>("terrain_lower_spin")->setValue(LLSD(terrain_lower_limit));
+	panel->getChild<LLUICtrl>("use_estate_sun_check")->setValue(LLSD(use_estate_sun));
 
-	panel->childSetValue("fixed_sun_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED)));
-	panel->childSetEnabled("fixed_sun_check", allow_modify && !use_estate_sun);
-	panel->childSetValue("sun_hour_slider", LLSD(sun_hour));
-	panel->childSetEnabled("sun_hour_slider", allow_modify && !use_estate_sun);
+	panel->getChild<LLUICtrl>("fixed_sun_check")->setValue(LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED)));
+	panel->getChildView("fixed_sun_check")->setEnabled(allow_modify && !use_estate_sun);
+	panel->getChild<LLUICtrl>("sun_hour_slider")->setValue(LLSD(sun_hour));
+	panel->getChildView("sun_hour_slider")->setEnabled(allow_modify && !use_estate_sun);
 	panel->setCtrlsEnabled(allow_modify);
 
 	floater->refreshFromRegion( gAgent.getRegion() );
@@ -485,7 +485,7 @@ void LLPanelRegionInfo::onChangeText(LLLineEditor* caller, void* user_data)
 BOOL LLPanelRegionInfo::postBuild()
 {
 	getChild<LLUICtrl>("apply_btn")->setCommitCallback(boost::bind(&LLPanelRegionInfo::onBtnSet, this));
-	childDisable("apply_btn");
+	getChildView("apply_btn")->setEnabled(FALSE);
 	refresh();
 	return TRUE;
 }
@@ -537,12 +537,12 @@ void LLPanelRegionInfo::sendEstateOwnerMessage(
 
 void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable)
 {
-	childSetEnabled(btn_name, enable);
+	getChildView(btn_name)->setEnabled(enable);
 }
 
 void LLPanelRegionInfo::disableButton(const std::string& btn_name)
 {
-	childDisable(btn_name);
+	getChildView(btn_name)->setEnabled(FALSE);
 }
 
 void LLPanelRegionInfo::initCtrl(const std::string& name)
@@ -563,14 +563,14 @@ bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region)
 {
 	BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
 	setCtrlsEnabled(allow_modify);
-	childDisable("apply_btn");
-	childSetEnabled("access_text", allow_modify);
-	// childSetEnabled("access_combo", allow_modify);
+	getChildView("apply_btn")->setEnabled(FALSE);
+	getChildView("access_text")->setEnabled(allow_modify);
+	// getChildView("access_combo")->setEnabled(allow_modify);
 	// now set in processRegionInfo for teen grid detection
-	childSetEnabled("kick_btn", allow_modify);
-	childSetEnabled("kick_all_btn", allow_modify);
-	childSetEnabled("im_btn", allow_modify);
-	childSetEnabled("manage_telehub_btn", allow_modify);
+	getChildView("kick_btn")->setEnabled(allow_modify);
+	getChildView("kick_all_btn")->setEnabled(allow_modify);
+	getChildView("im_btn")->setEnabled(allow_modify);
+	getChildView("manage_telehub_btn")->setEnabled(allow_modify);
 
 	// Data gets filled in by processRegionInfo
 
@@ -719,16 +719,16 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate()
 	std::string url = gAgent.getRegion()->getCapability("DispatchRegionInfo");
 	if (!url.empty())
 	{
-		body["block_terraform"] = childGetValue("block_terraform_check");
-		body["block_fly"] = childGetValue("block_fly_check");
-		body["allow_damage"] = childGetValue("allow_damage_check");
-		body["allow_land_resell"] = childGetValue("allow_land_resell_check");
-		body["agent_limit"] = childGetValue("agent_limit_spin");
-		body["prim_bonus"] = childGetValue("object_bonus_spin");
-		body["sim_access"] = childGetValue("access_combo");
-		body["restrict_pushobject"] = childGetValue("restrict_pushobject");
-		body["allow_parcel_changes"] = childGetValue("allow_parcel_changes_check");
-		body["block_parcel_search"] = childGetValue("block_parcel_search_check");
+		body["block_terraform"] = getChild<LLUICtrl>("block_terraform_check")->getValue();
+		body["block_fly"] = getChild<LLUICtrl>("block_fly_check")->getValue();
+		body["allow_damage"] = getChild<LLUICtrl>("allow_damage_check")->getValue();
+		body["allow_land_resell"] = getChild<LLUICtrl>("allow_land_resell_check")->getValue();
+		body["agent_limit"] = getChild<LLUICtrl>("agent_limit_spin")->getValue();
+		body["prim_bonus"] = getChild<LLUICtrl>("object_bonus_spin")->getValue();
+		body["sim_access"] = getChild<LLUICtrl>("access_combo")->getValue();
+		body["restrict_pushobject"] = getChild<LLUICtrl>("restrict_pushobject")->getValue();
+		body["allow_parcel_changes"] = getChild<LLUICtrl>("allow_parcel_changes_check")->getValue();
+		body["block_parcel_search"] = getChild<LLUICtrl>("block_parcel_search_check")->getValue();
 
 		LLHTTPClient::post(url, body, new LLHTTPClient::Responder());
 	}
@@ -737,33 +737,33 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate()
 		strings_t strings;
 		std::string buffer;
 
-		buffer = llformat("%s", (childGetValue("block_terraform_check").asBoolean() ? "Y" : "N"));
+		buffer = llformat("%s", (getChild<LLUICtrl>("block_terraform_check")->getValue().asBoolean() ? "Y" : "N"));
 		strings.push_back(strings_t::value_type(buffer));
 
-		buffer = llformat("%s", (childGetValue("block_fly_check").asBoolean() ? "Y" : "N"));
+		buffer = llformat("%s", (getChild<LLUICtrl>("block_fly_check")->getValue().asBoolean() ? "Y" : "N"));
 		strings.push_back(strings_t::value_type(buffer));
 
-		buffer = llformat("%s", (childGetValue("allow_damage_check").asBoolean() ? "Y" : "N"));
+		buffer = llformat("%s", (getChild<LLUICtrl>("allow_damage_check")->getValue().asBoolean() ? "Y" : "N"));
 		strings.push_back(strings_t::value_type(buffer));
 
-		buffer = llformat("%s", (childGetValue("allow_land_resell_check").asBoolean() ? "Y" : "N"));
+		buffer = llformat("%s", (getChild<LLUICtrl>("allow_land_resell_check")->getValue().asBoolean() ? "Y" : "N"));
 		strings.push_back(strings_t::value_type(buffer));
 
-		F32 value = (F32)childGetValue("agent_limit_spin").asReal();
+		F32 value = (F32)getChild<LLUICtrl>("agent_limit_spin")->getValue().asReal();
 		buffer = llformat("%f", value);
 		strings.push_back(strings_t::value_type(buffer));
 
-		value = (F32)childGetValue("object_bonus_spin").asReal();
+		value = (F32)getChild<LLUICtrl>("object_bonus_spin")->getValue().asReal();
 		buffer = llformat("%f", value);
 		strings.push_back(strings_t::value_type(buffer));
 
-		buffer = llformat("%d", childGetValue("access_combo").asInteger());
+		buffer = llformat("%d", getChild<LLUICtrl>("access_combo")->getValue().asInteger());
 		strings.push_back(strings_t::value_type(buffer));
 
-		buffer = llformat("%s", (childGetValue("restrict_pushobject").asBoolean() ? "Y" : "N"));
+		buffer = llformat("%s", (getChild<LLUICtrl>("restrict_pushobject")->getValue().asBoolean() ? "Y" : "N"));
 		strings.push_back(strings_t::value_type(buffer));
 
-		buffer = llformat("%s", (childGetValue("allow_parcel_changes_check").asBoolean() ? "Y" : "N"));
+		buffer = llformat("%s", (getChild<LLUICtrl>("allow_parcel_changes_check")->getValue().asBoolean() ? "Y" : "N"));
 		strings.push_back(strings_t::value_type(buffer));
 
 		LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
@@ -772,7 +772,7 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate()
 
 	// if we changed access levels, tell user about it
 	LLViewerRegion* region = gAgent.getRegion();
-	if (region && (childGetValue("access_combo").asInteger() != region->getSimAccess()) )
+	if (region && (getChild<LLUICtrl>("access_combo")->getValue().asInteger() != region->getSimAccess()) )
 	{
 		LLNotificationsUtil::add("RegionMaturityChange");
 	}	
@@ -805,18 +805,18 @@ bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* region)
 {
 	BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
 	setCtrlsEnabled(allow_modify);
-	childDisable("apply_btn");
-	childDisable("target_avatar_name");
+	getChildView("apply_btn")->setEnabled(FALSE);
+	getChildView("target_avatar_name")->setEnabled(FALSE);
 	
-	childSetEnabled("choose_avatar_btn", allow_modify);
-	childSetEnabled("return_scripts", allow_modify && !mTargetAvatar.isNull());
-	childSetEnabled("return_other_land", allow_modify && !mTargetAvatar.isNull());
-	childSetEnabled("return_estate_wide", allow_modify && !mTargetAvatar.isNull());
-	childSetEnabled("return_btn", allow_modify && !mTargetAvatar.isNull());
-	childSetEnabled("top_colliders_btn", allow_modify);
-	childSetEnabled("top_scripts_btn", allow_modify);
-	childSetEnabled("restart_btn", allow_modify);
-	childSetEnabled("cancel_restart_btn", allow_modify);
+	getChildView("choose_avatar_btn")->setEnabled(allow_modify);
+	getChildView("return_scripts")->setEnabled(allow_modify && !mTargetAvatar.isNull());
+	getChildView("return_other_land")->setEnabled(allow_modify && !mTargetAvatar.isNull());
+	getChildView("return_estate_wide")->setEnabled(allow_modify && !mTargetAvatar.isNull());
+	getChildView("return_btn")->setEnabled(allow_modify && !mTargetAvatar.isNull());
+	getChildView("top_colliders_btn")->setEnabled(allow_modify);
+	getChildView("top_scripts_btn")->setEnabled(allow_modify);
+	getChildView("restart_btn")->setEnabled(allow_modify);
+	getChildView("cancel_restart_btn")->setEnabled(allow_modify);
 
 	return LLPanelRegionInfo::refreshFromRegion(region);
 }
@@ -828,13 +828,13 @@ BOOL LLPanelRegionDebugInfo::sendUpdate()
 	strings_t strings;
 	std::string buffer;
 
-	buffer = llformat("%s", (childGetValue("disable_scripts_check").asBoolean() ? "Y" : "N"));
+	buffer = llformat("%s", (getChild<LLUICtrl>("disable_scripts_check")->getValue().asBoolean() ? "Y" : "N"));
 	strings.push_back(buffer);
 
-	buffer = llformat("%s", (childGetValue("disable_collisions_check").asBoolean() ? "Y" : "N"));
+	buffer = llformat("%s", (getChild<LLUICtrl>("disable_collisions_check")->getValue().asBoolean() ? "Y" : "N"));
 	strings.push_back(buffer);
 
-	buffer = llformat("%s", (childGetValue("disable_physics_check").asBoolean() ? "Y" : "N"));
+	buffer = llformat("%s", (getChild<LLUICtrl>("disable_physics_check")->getValue().asBoolean() ? "Y" : "N"));
 	strings.push_back(buffer);
 
 	LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
@@ -852,7 +852,7 @@ void LLPanelRegionDebugInfo::callbackAvatarID(const std::vector<std::string>& na
 {
 	if (ids.empty() || names.empty()) return;
 	mTargetAvatar = ids[0];
-	childSetValue("target_avatar_name", LLSD(names[0]));
+	getChild<LLUICtrl>("target_avatar_name")->setValue(LLSD(names[0]));
 	refreshFromRegion( gAgent.getRegion() );
 }
 
@@ -863,23 +863,23 @@ void LLPanelRegionDebugInfo::onClickReturn(void* data)
 	if (panelp->mTargetAvatar.isNull()) return;
 
 	LLSD args;
-	args["USER_NAME"] = panelp->childGetValue("target_avatar_name").asString();
+	args["USER_NAME"] = panelp->getChild<LLUICtrl>("target_avatar_name")->getValue().asString();
 	LLSD payload;
 	payload["avatar_id"] = panelp->mTargetAvatar;
 	
 	U32 flags = SWD_ALWAYS_RETURN_OBJECTS;
 
-	if (panelp->childGetValue("return_scripts").asBoolean())
+	if (panelp->getChild<LLUICtrl>("return_scripts")->getValue().asBoolean())
 	{
 		flags |= SWD_SCRIPTED_ONLY;
 	}
 	
-	if (panelp->childGetValue("return_other_land").asBoolean())
+	if (panelp->getChild<LLUICtrl>("return_other_land")->getValue().asBoolean())
 	{
 		flags |= SWD_OTHERS_LAND_ONLY;
 	}
 	payload["flags"] = int(flags);
-	payload["return_estate_wide"] = panelp->childGetValue("return_estate_wide").asBoolean();
+	payload["return_estate_wide"] = panelp->getChild<LLUICtrl>("return_estate_wide")->getValue().asBoolean();
 	LLNotificationsUtil::add("EstateObjectReturn", args, payload, 
 									boost::bind(&LLPanelRegionDebugInfo::callbackReturn, panelp, _1, _2));
 }
@@ -985,15 +985,15 @@ bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region)
 {
 	BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
 	setCtrlsEnabled(allow_modify);
-	childDisable("apply_btn");
+	getChildView("apply_btn")->setEnabled(FALSE);
 
 	if (region)
 	{
-		childSetValue("region_text", LLSD(region->getName()));
+		getChild<LLUICtrl>("region_text")->setValue(LLSD(region->getName()));
 	}
 	else
 	{
-		childSetValue("region_text", LLSD(""));
+		getChild<LLUICtrl>("region_text")->setValue(LLSD(""));
 	}
 
 	if (!region) return LLPanelRegionInfo::refreshFromRegion(region);
@@ -1017,9 +1017,9 @@ bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region)
 	for(S32 i = 0; i < CORNER_COUNT; ++i)
     {
 		buffer = llformat("height_start_spin_%d", i);
-		childSetValue(buffer, LLSD(compp->getStartHeight(i)));
+		getChild<LLUICtrl>(buffer)->setValue(LLSD(compp->getStartHeight(i)));
 		buffer = llformat("height_range_spin_%d", i);
-		childSetValue(buffer, LLSD(compp->getHeightRange(i)));
+		getChild<LLUICtrl>(buffer)->setValue(LLSD(compp->getHeightRange(i)));
 	}
 
 	// Call the parent for common book-keeping
@@ -1088,7 +1088,7 @@ BOOL LLPanelRegionTextureInfo::sendUpdate()
 	{
 		buffer = llformat("height_start_spin_%d", i);
 		std::string buffer2 = llformat("height_range_spin_%d", i);
-		std::string buffer3 = llformat("%d %f %f", i, (F32)childGetValue(buffer).asReal(), (F32)childGetValue(buffer2).asReal());
+		std::string buffer3 = llformat("%d %f %f", i, (F32)getChild<LLUICtrl>(buffer)->getValue().asReal(), (F32)getChild<LLUICtrl>(buffer2)->getValue().asReal());
 		strings.push_back(buffer3);
 	}
 	sendEstateOwnerMessage(msg, "textureheights", invoice, strings);
@@ -1181,11 +1181,11 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region)
 	BOOL owner_or_god_or_manager = owner_or_god
 						|| (region && region->isEstateManager());
 	setCtrlsEnabled(owner_or_god_or_manager);
-	childDisable("apply_btn");
+	getChildView("apply_btn")->setEnabled(FALSE);
 
-	childSetEnabled("download_raw_btn", owner_or_god);
-	childSetEnabled("upload_raw_btn", owner_or_god);
-	childSetEnabled("bake_terrain_btn", owner_or_god);
+	getChildView("download_raw_btn")->setEnabled(owner_or_god);
+	getChildView("upload_raw_btn")->setEnabled(owner_or_god);
+	getChildView("bake_terrain_btn")->setEnabled(owner_or_god);
 
 	return LLPanelRegionInfo::refreshFromRegion(region);
 }
@@ -1198,17 +1198,17 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate()
 	strings_t strings;
 	LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
 
-	buffer = llformat("%f", (F32)childGetValue("water_height_spin").asReal());
+	buffer = llformat("%f", (F32)getChild<LLUICtrl>("water_height_spin")->getValue().asReal());
 	strings.push_back(buffer);
-	buffer = llformat("%f", (F32)childGetValue("terrain_raise_spin").asReal());
+	buffer = llformat("%f", (F32)getChild<LLUICtrl>("terrain_raise_spin")->getValue().asReal());
 	strings.push_back(buffer);
-	buffer = llformat("%f", (F32)childGetValue("terrain_lower_spin").asReal());
+	buffer = llformat("%f", (F32)getChild<LLUICtrl>("terrain_lower_spin")->getValue().asReal());
 	strings.push_back(buffer);
-	buffer = llformat("%s", (childGetValue("use_estate_sun_check").asBoolean() ? "Y" : "N"));
+	buffer = llformat("%s", (getChild<LLUICtrl>("use_estate_sun_check")->getValue().asBoolean() ? "Y" : "N"));
 	strings.push_back(buffer);
-	buffer = llformat("%s", (childGetValue("fixed_sun_check").asBoolean() ? "Y" : "N"));
+	buffer = llformat("%s", (getChild<LLUICtrl>("fixed_sun_check")->getValue().asBoolean() ? "Y" : "N"));
 	strings.push_back(buffer);
-	buffer = llformat("%f", (F32)childGetValue("sun_hour_slider").asReal() );
+	buffer = llformat("%f", (F32)getChild<LLUICtrl>("sun_hour_slider")->getValue().asReal() );
 	strings.push_back(buffer);
 
 	// Grab estate information in case the user decided to set the
@@ -1247,27 +1247,27 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate()
 
 void LLPanelRegionTerrainInfo::onChangeUseEstateTime()
 {
-	BOOL use_estate_sun = childGetValue("use_estate_sun_check").asBoolean();
-	childSetEnabled("fixed_sun_check", !use_estate_sun);
-	childSetEnabled("sun_hour_slider", !use_estate_sun);
+	BOOL use_estate_sun = getChild<LLUICtrl>("use_estate_sun_check")->getValue().asBoolean();
+	getChildView("fixed_sun_check")->setEnabled(!use_estate_sun);
+	getChildView("sun_hour_slider")->setEnabled(!use_estate_sun);
 	if (use_estate_sun)
 	{
-		childSetValue("fixed_sun_check", LLSD(FALSE));
-		childSetValue("sun_hour_slider", LLSD(0.f));
+		getChild<LLUICtrl>("fixed_sun_check")->setValue(LLSD(FALSE));
+		getChild<LLUICtrl>("sun_hour_slider")->setValue(LLSD(0.f));
 	}
-	childEnable("apply_btn");
+	getChildView("apply_btn")->setEnabled(TRUE);
 }
 
 void LLPanelRegionTerrainInfo::onChangeFixedSun()
 {
 	// Just enable the apply button.  We let the sun-hour slider be enabled
 	// for both fixed-sun and non-fixed-sun. JC
-	childEnable("apply_btn");
+	getChildView("apply_btn")->setEnabled(TRUE);
 }
 
 void LLPanelRegionTerrainInfo::onChangeSunHour()
 {
-	childEnable("apply_btn");
+	getChildView("apply_btn")->setEnabled(TRUE);
 }
 
 // static
@@ -1363,19 +1363,19 @@ void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch)
 // Disables the sun-hour slider and the use fixed time check if the use global time is check
 void LLPanelEstateInfo::onChangeUseGlobalTime()
 {
-	bool enabled = !childGetValue("use_global_time_check").asBoolean();
-	childSetEnabled("sun_hour_slider", enabled);
-	childSetEnabled("fixed_sun_check", enabled);
-	childSetValue("fixed_sun_check", LLSD(FALSE));
+	bool enabled = !getChild<LLUICtrl>("use_global_time_check")->getValue().asBoolean();
+	getChildView("sun_hour_slider")->setEnabled(enabled);
+	getChildView("fixed_sun_check")->setEnabled(enabled);
+	getChild<LLUICtrl>("fixed_sun_check")->setValue(LLSD(FALSE));
 	enableButton("apply_btn");
 }
 
 // Enables the sun-hour slider if the fixed-sun checkbox is set
 void LLPanelEstateInfo::onChangeFixedSun()
 {
-	bool enabled = !childGetValue("fixed_sun_check").asBoolean();
-	childSetEnabled("use_global_time_check", enabled);
-	childSetValue("use_global_time_check", LLSD(FALSE));
+	bool enabled = !getChild<LLUICtrl>("fixed_sun_check")->getValue().asBoolean();
+	getChildView("use_global_time_check")->setEnabled(enabled);
+	getChild<LLUICtrl>("use_global_time_check")->setValue(LLSD(FALSE));
 	enableButton("apply_btn");
 }
 
@@ -1385,21 +1385,19 @@ void LLPanelEstateInfo::onChangeFixedSun()
 //---------------------------------------------------------------------------
 // Add/Remove estate access button callbacks
 //---------------------------------------------------------------------------
-void LLPanelEstateInfo::onClickEditSky(void* user_data)
+void LLPanelEstateInfo::onClickEditSky()
 {
 	LLFloaterReg::showInstance("env_windlight");
 }
 
-void LLPanelEstateInfo::onClickEditDayCycle(void* user_data)
+void LLPanelEstateInfo::onClickEditDayCycle()
 {
 	LLFloaterReg::showInstance("env_day_cycle");
 }
 
-// static
-void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data)
+void LLPanelEstateInfo::onClickAddAllowedAgent()
 {
-	LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
-	LLCtrlListInterface *list = self->childGetListInterface("allowed_avatar_name_list");
+	LLCtrlListInterface *list = childGetListInterface("allowed_avatar_name_list");
 	if (!list) return;
 	if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
 	{
@@ -1413,8 +1411,7 @@ void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data)
 	accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd");
 }
 
-// static
-void LLPanelEstateInfo::onClickRemoveAllowedAgent(void* user_data)
+void LLPanelEstateInfo::onClickRemoveAllowedAgent()
 {
 	accessRemoveCore(ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, "EstateAllowedAgentRemove", "allowed_avatar_name_list");
 }
@@ -1466,17 +1463,14 @@ bool LLPanelEstateInfo::addAllowedGroup(const LLSD& notification, const LLSD& re
 	return false;
 }
 
-// static
-void LLPanelEstateInfo::onClickRemoveAllowedGroup(void* user_data)
+void LLPanelEstateInfo::onClickRemoveAllowedGroup()
 {
 	accessRemoveCore(ESTATE_ACCESS_ALLOWED_GROUP_REMOVE, "EstateAllowedGroupRemove", "allowed_group_name_list");
 }
 
-// static
-void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data)
+void LLPanelEstateInfo::onClickAddBannedAgent()
 {
-	LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
-	LLCtrlListInterface *list = self->childGetListInterface("banned_avatar_name_list");
+	LLCtrlListInterface *list = childGetListInterface("banned_avatar_name_list");
 	if (!list) return;
 	if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
 	{
@@ -1488,17 +1482,15 @@ void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data)
 	accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd");
 }
 
-// static
-void LLPanelEstateInfo::onClickRemoveBannedAgent(void* user_data)
+void LLPanelEstateInfo::onClickRemoveBannedAgent()
 {
 	accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE, "EstateBannedAgentRemove", "banned_avatar_name_list");
 }
 
 // static
-void LLPanelEstateInfo::onClickAddEstateManager(void* user_data)
+void LLPanelEstateInfo::onClickAddEstateManager()
 {
-	LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
-	LLCtrlListInterface *list = self->childGetListInterface("estate_manager_name_list");
+	LLCtrlListInterface *list = childGetListInterface("estate_manager_name_list");
 	if (!list) return;
 	if (list->getItemCount() >= ESTATE_MAX_MANAGERS)
 	{	// Tell user they can't add more managers
@@ -1513,7 +1505,7 @@ void LLPanelEstateInfo::onClickAddEstateManager(void* user_data)
 }
 
 // static
-void LLPanelEstateInfo::onClickRemoveEstateManager(void* user_data)
+void LLPanelEstateInfo::onClickRemoveEstateManager()
 {
 	accessRemoveCore(ESTATE_ACCESS_MANAGER_REMOVE, "EstateManagerRemove", "estate_manager_name_list");
 }
@@ -1966,20 +1958,20 @@ void LLPanelEstateInfo::updateControls(LLViewerRegion* region)
 	BOOL manager = (region && region->isEstateManager());
 	setCtrlsEnabled(god || owner || manager);
 	
-	childDisable("apply_btn");
-	childSetEnabled("add_allowed_avatar_btn",		god || owner || manager);
-	childSetEnabled("remove_allowed_avatar_btn",	god || owner || manager);
-	childSetEnabled("add_allowed_group_btn",		god || owner || manager);
-	childSetEnabled("remove_allowed_group_btn",		god || owner || manager);
-	childSetEnabled("add_banned_avatar_btn",		god || owner || manager);
-	childSetEnabled("remove_banned_avatar_btn",		god || owner || manager);
-	childSetEnabled("message_estate_btn",			god || owner || manager);
-	childSetEnabled("kick_user_from_estate_btn",	god || owner || manager);
+	getChildView("apply_btn")->setEnabled(FALSE);
+	getChildView("add_allowed_avatar_btn")->setEnabled(god || owner || manager);
+	getChildView("remove_allowed_avatar_btn")->setEnabled(god || owner || manager);
+	getChildView("add_allowed_group_btn")->setEnabled(god || owner || manager);
+	getChildView("remove_allowed_group_btn")->setEnabled(god || owner || manager);
+	getChildView("add_banned_avatar_btn")->setEnabled(god || owner || manager);
+	getChildView("remove_banned_avatar_btn")->setEnabled(god || owner || manager);
+	getChildView("message_estate_btn")->setEnabled(god || owner || manager);
+	getChildView("kick_user_from_estate_btn")->setEnabled(god || owner || manager);
 
 	// estate managers can't add estate managers
-	childSetEnabled("add_estate_manager_btn",		god || owner);
-	childSetEnabled("remove_estate_manager_btn",	god || owner);
-	childSetEnabled("estate_manager_name_list",		god || owner);
+	getChildView("add_estate_manager_btn")->setEnabled(god || owner);
+	getChildView("remove_estate_manager_btn")->setEnabled(god || owner);
+	getChildView("estate_manager_name_list")->setEnabled(god || owner);
 }
 
 bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region)
@@ -2054,8 +2046,8 @@ BOOL LLPanelEstateInfo::postBuild()
 		avatar_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
 	}
 
-	childSetAction("add_allowed_avatar_btn", onClickAddAllowedAgent, this);
-	childSetAction("remove_allowed_avatar_btn", onClickRemoveAllowedAgent, this);
+	childSetAction("add_allowed_avatar_btn", boost::bind(&LLPanelEstateInfo::onClickAddAllowedAgent, this));
+	childSetAction("remove_allowed_avatar_btn", boost::bind(&LLPanelEstateInfo::onClickRemoveAllowedAgent, this));
 
 	getChild<LLUICtrl>("allowed_group_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
 	LLNameListCtrl* group_name_list = getChild<LLNameListCtrl>("allowed_group_name_list");
@@ -2066,7 +2058,7 @@ BOOL LLPanelEstateInfo::postBuild()
 	}
 
 	getChild<LLUICtrl>("add_allowed_group_btn")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onClickAddAllowedGroup, this));
-	childSetAction("remove_allowed_group_btn", onClickRemoveAllowedGroup, this);
+	childSetAction("remove_allowed_group_btn", boost::bind(&LLPanelEstateInfo::onClickRemoveAllowedGroup, this));
 
 	getChild<LLUICtrl>("banned_avatar_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
 	LLNameListCtrl* banned_name_list = getChild<LLNameListCtrl>("banned_avatar_name_list");
@@ -2076,8 +2068,8 @@ BOOL LLPanelEstateInfo::postBuild()
 		banned_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
 	}
 
-	childSetAction("add_banned_avatar_btn", onClickAddBannedAgent, this);
-	childSetAction("remove_banned_avatar_btn", onClickRemoveBannedAgent, this);
+	childSetAction("add_banned_avatar_btn", boost::bind(&LLPanelEstateInfo::onClickAddBannedAgent, this));
+	childSetAction("remove_banned_avatar_btn", boost::bind(&LLPanelEstateInfo::onClickRemoveBannedAgent, this));
 
 	getChild<LLUICtrl>("estate_manager_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
 	LLNameListCtrl* manager_name_list = getChild<LLNameListCtrl>("estate_manager_name_list");
@@ -2087,28 +2079,28 @@ BOOL LLPanelEstateInfo::postBuild()
 		manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS * 4);	// Allow extras for dupe issue
 	}
 
-	childSetAction("add_estate_manager_btn", onClickAddEstateManager, this);
-	childSetAction("remove_estate_manager_btn", onClickRemoveEstateManager, this);
-	childSetAction("message_estate_btn", onClickMessageEstate, this);
+	childSetAction("add_estate_manager_btn", boost::bind(&LLPanelEstateInfo::onClickAddEstateManager, this));
+	childSetAction("remove_estate_manager_btn", boost::bind(&LLPanelEstateInfo::onClickRemoveEstateManager, this));
+	childSetAction("message_estate_btn", boost::bind(&LLPanelEstateInfo::onClickMessageEstate, this));
 	childSetAction("kick_user_from_estate_btn", boost::bind(&LLPanelEstateInfo::onClickKickUser, this));
 
-	childSetAction("WLEditSky", onClickEditSky, this);
-	childSetAction("WLEditDayCycle", onClickEditDayCycle, this);
+	childSetAction("WLEditSky", boost::bind(&LLPanelEstateInfo::onClickEditSky, this));
+	childSetAction("WLEditDayCycle", boost::bind(&LLPanelEstateInfo::onClickEditDayCycle, this));
 
 	return LLPanelRegionInfo::postBuild();
 }
 
 void LLPanelEstateInfo::refresh()
 {
-	bool public_access = childGetValue("externally_visible_check").asBoolean();
-	childSetEnabled("Only Allow", public_access);
-	childSetEnabled("limit_payment", public_access);
-	childSetEnabled("limit_age_verified", public_access);
+	bool public_access = getChild<LLUICtrl>("externally_visible_check")->getValue().asBoolean();
+	getChildView("Only Allow")->setEnabled(public_access);
+	getChildView("limit_payment")->setEnabled(public_access);
+	getChildView("limit_age_verified")->setEnabled(public_access);
 	// if this is set to false, then the limit fields are meaningless and should be turned off
 	if (public_access == false)
 	{
-		childSetValue("limit_payment", false);
-		childSetValue("limit_age_verified", false);
+		getChild<LLUICtrl>("limit_payment")->setValue(false);
+		getChild<LLUICtrl>("limit_age_verified")->setValue(false);
 	}
 }
 
@@ -2231,19 +2223,19 @@ bool LLPanelEstateInfo::commitEstateInfoCaps()
 	LLSD body;
 	body["estate_name"] = getEstateName();
 
-	body["is_externally_visible"] = childGetValue("externally_visible_check").asBoolean();
-	body["allow_direct_teleport"] = childGetValue("allow_direct_teleport").asBoolean();
-	body["is_sun_fixed"         ] = childGetValue("fixed_sun_check").asBoolean();
-	body["deny_anonymous"       ] = childGetValue("limit_payment").asBoolean();
-	body["deny_age_unverified"  ] = childGetValue("limit_age_verified").asBoolean();
-	body["allow_voice_chat"     ] = childGetValue("voice_chat_check").asBoolean();
+	body["is_externally_visible"] = getChild<LLUICtrl>("externally_visible_check")->getValue().asBoolean();
+	body["allow_direct_teleport"] = getChild<LLUICtrl>("allow_direct_teleport")->getValue().asBoolean();
+	body["is_sun_fixed"         ] = getChild<LLUICtrl>("fixed_sun_check")->getValue().asBoolean();
+	body["deny_anonymous"       ] = getChild<LLUICtrl>("limit_payment")->getValue().asBoolean();
+	body["deny_age_unverified"  ] = getChild<LLUICtrl>("limit_age_verified")->getValue().asBoolean();
+	body["allow_voice_chat"     ] = getChild<LLUICtrl>("voice_chat_check")->getValue().asBoolean();
 	body["invoice"              ] = LLFloaterRegionInfo::getLastInvoice();
 
 	// block fly is in estate database but not in estate UI, so we're not supporting it
-	//body["block_fly"            ] = childGetValue("").asBoolean();
+	//body["block_fly"            ] = getChild<LLUICtrl>("")->getValue().asBoolean();
 
 	F32 sun_hour = getSunHour();
-	if (childGetValue("use_global_time_check").asBoolean())
+	if (getChild<LLUICtrl>("use_global_time_check")->getValue().asBoolean())
 	{
 		sun_hour = 0.f;			// 0 = global time
 	}
@@ -2283,7 +2275,7 @@ void LLPanelEstateInfo::commitEstateInfoDataserver()
 	msg->addString("Parameter", buffer);
 
 	F32 sun_hour = getSunHour();
-	if (childGetValue("use_global_time_check").asBoolean())
+	if (getChild<LLUICtrl>("use_global_time_check")->getValue().asBoolean())
 	{
 		sun_hour = 0.f;	// 0 = global time
 	}
@@ -2297,14 +2289,13 @@ void LLPanelEstateInfo::commitEstateInfoDataserver()
 
 void LLPanelEstateInfo::setEstateFlags(U32 flags)
 {
-	childSetValue("externally_visible_check", LLSD(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE) );
-	childSetValue("fixed_sun_check", LLSD(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE) );
-	childSetValue(
-		"voice_chat_check",
+	getChild<LLUICtrl>("externally_visible_check")->setValue(LLSD(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE) );
+	getChild<LLUICtrl>("fixed_sun_check")->setValue(LLSD(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE) );
+	getChild<LLUICtrl>("voice_chat_check")->setValue(
 		LLSD(flags & REGION_FLAGS_ALLOW_VOICE ? TRUE : FALSE));
-	childSetValue("allow_direct_teleport", LLSD(flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT ? TRUE : FALSE) );
-	childSetValue("limit_payment", LLSD(flags & REGION_FLAGS_DENY_ANONYMOUS ? TRUE : FALSE) );
-	childSetValue("limit_age_verified", LLSD(flags & REGION_FLAGS_DENY_AGEUNVERIFIED ? TRUE : FALSE) );
+	getChild<LLUICtrl>("allow_direct_teleport")->setValue(LLSD(flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT ? TRUE : FALSE) );
+	getChild<LLUICtrl>("limit_payment")->setValue(LLSD(flags & REGION_FLAGS_DENY_ANONYMOUS ? TRUE : FALSE) );
+	getChild<LLUICtrl>("limit_age_verified")->setValue(LLSD(flags & REGION_FLAGS_DENY_AGEUNVERIFIED ? TRUE : FALSE) );
 
 	refresh();
 }
@@ -2313,32 +2304,32 @@ U32 LLPanelEstateInfo::computeEstateFlags()
 {
 	U32 flags = 0;
 
-	if (childGetValue("externally_visible_check").asBoolean())
+	if (getChild<LLUICtrl>("externally_visible_check")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_EXTERNALLY_VISIBLE;
 	}
 
-	if ( childGetValue("voice_chat_check").asBoolean() )
+	if ( getChild<LLUICtrl>("voice_chat_check")->getValue().asBoolean() )
 	{
 		flags |= REGION_FLAGS_ALLOW_VOICE;
 	}
 	
-	if (childGetValue("allow_direct_teleport").asBoolean())
+	if (getChild<LLUICtrl>("allow_direct_teleport")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT;
 	}
 
-	if (childGetValue("fixed_sun_check").asBoolean())
+	if (getChild<LLUICtrl>("fixed_sun_check")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_SUN_FIXED;
 	}
 	
-	if (childGetValue("limit_payment").asBoolean())
+	if (getChild<LLUICtrl>("limit_payment")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_DENY_ANONYMOUS;
 	}
 	
-	if (childGetValue("limit_age_verified").asBoolean())
+	if (getChild<LLUICtrl>("limit_age_verified")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_DENY_AGEUNVERIFIED;
 	}
@@ -2349,24 +2340,24 @@ U32 LLPanelEstateInfo::computeEstateFlags()
 
 BOOL LLPanelEstateInfo::getGlobalTime()
 {
-	return childGetValue("use_global_time_check").asBoolean();
+	return getChild<LLUICtrl>("use_global_time_check")->getValue().asBoolean();
 }
 
 void LLPanelEstateInfo::setGlobalTime(bool b)
 {
-	childSetValue("use_global_time_check", LLSD(b));
-	childSetEnabled("fixed_sun_check", LLSD(!b));
-	childSetEnabled("sun_hour_slider", LLSD(!b));
+	getChild<LLUICtrl>("use_global_time_check")->setValue(LLSD(b));
+	getChildView("fixed_sun_check")->setEnabled(LLSD(!b));
+	getChildView("sun_hour_slider")->setEnabled(LLSD(!b));
 	if (b)
 	{
-		childSetValue("sun_hour_slider", LLSD(0.f));
+		getChild<LLUICtrl>("sun_hour_slider")->setValue(LLSD(0.f));
 	}
 }
 
 
 BOOL LLPanelEstateInfo::getFixedSun()
 {
-	return childGetValue("fixed_sun_check").asBoolean();
+	return getChild<LLUICtrl>("fixed_sun_check")->getValue().asBoolean();
 }
 
 void LLPanelEstateInfo::setSunHour(F32 sun_hour)
@@ -2375,61 +2366,61 @@ void LLPanelEstateInfo::setSunHour(F32 sun_hour)
 	{
 		sun_hour = 24.0f + sun_hour;
 	}
-	childSetValue("sun_hour_slider", LLSD(sun_hour));
+	getChild<LLUICtrl>("sun_hour_slider")->setValue(LLSD(sun_hour));
 }
 
 F32 LLPanelEstateInfo::getSunHour()
 {
-	if (childIsEnabled("sun_hour_slider"))
+	if (getChildView("sun_hour_slider")->getEnabled())
 	{
-		return (F32)childGetValue("sun_hour_slider").asReal();
+		return (F32)getChild<LLUICtrl>("sun_hour_slider")->getValue().asReal();
 	}
 	return 0.f;
 }
 
 const std::string LLPanelEstateInfo::getEstateName() const
 {
-	return childGetValue("estate_name").asString();
+	return getChild<LLUICtrl>("estate_name")->getValue().asString();
 }
 
 void LLPanelEstateInfo::setEstateName(const std::string& name)
 {
-	childSetValue("estate_name", LLSD(name));
+	getChild<LLUICtrl>("estate_name")->setValue(LLSD(name));
 }
 
 const std::string LLPanelEstateInfo::getOwnerName() const
 {
-	return childGetValue("estate_owner").asString();
+	return getChild<LLUICtrl>("estate_owner")->getValue().asString();
 }
 
 void LLPanelEstateInfo::setOwnerName(const std::string& name)
 {
-	childSetValue("estate_owner", LLSD(name));
+	getChild<LLUICtrl>("estate_owner")->setValue(LLSD(name));
 }
 
 void LLPanelEstateInfo::setAccessAllowedEnabled(bool enable_agent,
 												bool enable_group,
 												bool enable_ban)
 {
-	childSetEnabled("allow_resident_label", enable_agent);
-	childSetEnabled("allowed_avatar_name_list", enable_agent);
-	childSetVisible("allowed_avatar_name_list", enable_agent);
-	childSetEnabled("add_allowed_avatar_btn", enable_agent);
-	childSetEnabled("remove_allowed_avatar_btn", enable_agent);
+	getChildView("allow_resident_label")->setEnabled(enable_agent);
+	getChildView("allowed_avatar_name_list")->setEnabled(enable_agent);
+	getChildView("allowed_avatar_name_list")->setVisible( enable_agent);
+	getChildView("add_allowed_avatar_btn")->setEnabled(enable_agent);
+	getChildView("remove_allowed_avatar_btn")->setEnabled(enable_agent);
 
 	// Groups
-	childSetEnabled("allow_group_label", enable_group);
-	childSetEnabled("allowed_group_name_list", enable_group);
-	childSetVisible("allowed_group_name_list", enable_group);
-	childSetEnabled("add_allowed_group_btn", enable_group);
-	childSetEnabled("remove_allowed_group_btn", enable_group);
+	getChildView("allow_group_label")->setEnabled(enable_group);
+	getChildView("allowed_group_name_list")->setEnabled(enable_group);
+	getChildView("allowed_group_name_list")->setVisible( enable_group);
+	getChildView("add_allowed_group_btn")->setEnabled(enable_group);
+	getChildView("remove_allowed_group_btn")->setEnabled(enable_group);
 
 	// Ban
-	childSetEnabled("ban_resident_label", enable_ban);
-	childSetEnabled("banned_avatar_name_list", enable_ban);
-	childSetVisible("banned_avatar_name_list", enable_ban);
-	childSetEnabled("add_banned_avatar_btn", enable_ban);
-	childSetEnabled("remove_banned_avatar_btn", enable_ban);
+	getChildView("ban_resident_label")->setEnabled(enable_ban);
+	getChildView("banned_avatar_name_list")->setEnabled(enable_ban);
+	getChildView("banned_avatar_name_list")->setVisible( enable_ban);
+	getChildView("add_banned_avatar_btn")->setEnabled(enable_ban);
+	getChildView("remove_banned_avatar_btn")->setEnabled(enable_ban);
 
 	// Update removal buttons if needed
 	if (enable_agent)
@@ -2491,7 +2482,7 @@ BOOL LLPanelEstateInfo::checkRemovalButton(std::string name)
 
 	// enable the remove button if something is selected
 	LLNameListCtrl* name_list = getChild<LLNameListCtrl>(name);
-	childSetEnabled(btn_name, name_list && name_list->getFirstSelected() ? TRUE : FALSE);
+	getChildView(btn_name)->setEnabled(name_list && name_list->getFirstSelected() ? TRUE : FALSE);
 
 	return (btn_name != "");
 }
@@ -3026,7 +3017,7 @@ bool LLDispatchSetEstateAccess::operator()(
 		args["[ALLOWEDAGENTS]"] = llformat ("%d", totalAllowedAgents);
 		args["[MAXACCESS]"] = llformat ("%d", ESTATE_MAX_ACCESS_IDS);
 		std::string msg = LLTrans::getString("RegionInfoAllowedResidents", args);
-		panel->childSetValue("allow_resident_label", LLSD(msg));
+		panel->getChild<LLUICtrl>("allow_resident_label")->setValue(LLSD(msg));
 
 		if (allowed_agent_name_list)
 		{
@@ -3037,7 +3028,7 @@ bool LLDispatchSetEstateAccess::operator()(
 				memcpy(id.mData, strings[index++].data(), UUID_BYTES);		/* Flawfinder: ignore */
 				allowed_agent_name_list->addNameItem(id);
 			}
-			panel->childSetEnabled("remove_allowed_avatar_btn", allowed_agent_name_list->getFirstSelected() ? TRUE : FALSE);
+			panel->getChildView("remove_allowed_avatar_btn")->setEnabled(allowed_agent_name_list->getFirstSelected() ? TRUE : FALSE);
 			allowed_agent_name_list->sortByColumnIndex(0, TRUE);
 		}
 	}
@@ -3051,7 +3042,7 @@ bool LLDispatchSetEstateAccess::operator()(
 		args["[ALLOWEDGROUPS]"] = llformat ("%d", num_allowed_groups);
 		args["[MAXACCESS]"] = llformat ("%d", ESTATE_MAX_GROUP_IDS);
 		std::string msg = LLTrans::getString("RegionInfoAllowedGroups", args);
-		panel->childSetValue("allow_group_label", LLSD(msg));
+		panel->getChild<LLUICtrl>("allow_group_label")->setValue(LLSD(msg));
 
 		if (allowed_group_name_list)
 		{
@@ -3062,7 +3053,7 @@ bool LLDispatchSetEstateAccess::operator()(
 				memcpy(id.mData, strings[index++].data(), UUID_BYTES);		/* Flawfinder: ignore */
 				allowed_group_name_list->addGroupNameItem(id);
 			}
-			panel->childSetEnabled("remove_allowed_group_btn", allowed_group_name_list->getFirstSelected() ? TRUE : FALSE);
+			panel->getChildView("remove_allowed_group_btn")->setEnabled(allowed_group_name_list->getFirstSelected() ? TRUE : FALSE);
 			allowed_group_name_list->sortByColumnIndex(0, TRUE);
 		}
 	}
@@ -3083,7 +3074,7 @@ bool LLDispatchSetEstateAccess::operator()(
 		std::string msg = llformat("Banned residents: (%d, max %d)",
 									totalBannedAgents,
 									ESTATE_MAX_ACCESS_IDS);
-		panel->childSetValue("ban_resident_label", LLSD(msg));
+		panel->getChild<LLUICtrl>("ban_resident_label")->setValue(LLSD(msg));
 
 		if (banned_agent_name_list)
 		{
@@ -3094,7 +3085,7 @@ bool LLDispatchSetEstateAccess::operator()(
 				memcpy(id.mData, strings[index++].data(), UUID_BYTES);		/* Flawfinder: ignore */
 				banned_agent_name_list->addNameItem(id);
 			}
-			panel->childSetEnabled("remove_banned_avatar_btn", banned_agent_name_list->getFirstSelected() ? TRUE : FALSE);
+			panel->getChildView("remove_banned_avatar_btn")->setEnabled(banned_agent_name_list->getFirstSelected() ? TRUE : FALSE);
 			banned_agent_name_list->sortByColumnIndex(0, TRUE);
 		}
 	}
@@ -3104,7 +3095,7 @@ bool LLDispatchSetEstateAccess::operator()(
 		std::string msg = llformat("Estate Managers: (%d, max %d)",
 									num_estate_managers,
 									ESTATE_MAX_MANAGERS);
-		panel->childSetValue("estate_manager_label", LLSD(msg));
+		panel->getChild<LLUICtrl>("estate_manager_label")->setValue(LLSD(msg));
 
 		LLNameListCtrl* estate_manager_name_list =
 			panel->getChild<LLNameListCtrl>("estate_manager_name_list");
@@ -3121,7 +3112,7 @@ bool LLDispatchSetEstateAccess::operator()(
 				memcpy(id.mData, strings[index++].data(), UUID_BYTES);		/* Flawfinder: ignore */
 				estate_manager_name_list->addNameItem(id);
 			}
-			panel->childSetEnabled("remove_estate_manager_btn", estate_manager_name_list->getFirstSelected() ? TRUE : FALSE);
+			panel->getChildView("remove_estate_manager_btn")->setEnabled(estate_manager_name_list->getFirstSelected() ? TRUE : FALSE);
 			estate_manager_name_list->sortByColumnIndex(0, TRUE);
 		}
 	}
diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h
index 482ebb33030..135bf7102f9 100644
--- a/indra/newview/llfloaterregioninfo.h
+++ b/indra/newview/llfloaterregioninfo.h
@@ -262,19 +262,19 @@ class LLPanelEstateInfo : public LLPanelRegionInfo
 	void onChangeFixedSun();
 	void onChangeUseGlobalTime();
 	
-	static void onClickEditSky(void* userdata);
-	static void onClickEditSkyHelp(void* userdata);	
-	static void onClickEditDayCycle(void* userdata);
-	static void onClickEditDayCycleHelp(void* userdata);	
-
-	static void onClickAddAllowedAgent(void* user_data);
-	static void onClickRemoveAllowedAgent(void* user_data);
-		   void onClickAddAllowedGroup();
-	static void onClickRemoveAllowedGroup(void* user_data);
-	static void onClickAddBannedAgent(void* user_data);
-	static void onClickRemoveBannedAgent(void* user_data);
-	static void onClickAddEstateManager(void* user_data);
-	static void onClickRemoveEstateManager(void* user_data);
+	void onClickEditSky();
+	void onClickEditSkyHelp();	
+	void onClickEditDayCycle();
+	void onClickEditDayCycleHelp();
+
+	void onClickAddAllowedAgent();
+	void onClickRemoveAllowedAgent();
+	void onClickAddAllowedGroup();
+	void onClickRemoveAllowedGroup();
+	void onClickAddBannedAgent();
+	void onClickRemoveBannedAgent();
+	void onClickAddEstateManager();
+	void onClickRemoveEstateManager();
 	void onClickKickUser();
 
 	// Group picker callback is different, can't use core methods below
-- 
GitLab


From b15095c5a9333f3f194859e0549aae2a7fe317c4 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 09:46:28 -0700
Subject: [PATCH 574/683] removed void* from ui callbacks and deprecated
 LLPanel::child*() methods

---
 indra/newview/llpanelland.cpp | 69 +++++++++++++++++------------------
 indra/newview/llpanelland.h   | 19 +++-------
 2 files changed, 39 insertions(+), 49 deletions(-)

diff --git a/indra/newview/llpanelland.cpp b/indra/newview/llpanelland.cpp
index 417a8048347..6b84b2985af 100644
--- a/indra/newview/llpanelland.cpp
+++ b/indra/newview/llpanelland.cpp
@@ -64,15 +64,14 @@ class LLPanelLandSelectObserver : public LLParcelObserver
 
 BOOL	LLPanelLandInfo::postBuild()
 {
-
-	childSetAction("button buy land",onClickClaim,this);
-	childSetAction("button abandon land",onClickRelease,this);
-	childSetAction("button subdivide land",onClickDivide,this);
-	childSetAction("button join land",onClickJoin,this);
-	childSetAction("button about land",onClickAbout,this);
+	childSetAction("button buy land",boost::bind(onClickClaim));
+	childSetAction("button abandon land", boost::bind(onClickRelease));
+	childSetAction("button subdivide land", boost::bind(onClickDivide));
+	childSetAction("button join land", boost::bind(onClickJoin));
+	childSetAction("button about land", boost::bind(onClickAbout));
 
 	mCheckShowOwners = getChild<LLCheckBoxCtrl>("checkbox show owners");
-	childSetValue("checkbox show owners", gSavedSettings.getBOOL("ShowParcelOwners"));
+	getChild<LLUICtrl>("checkbox show owners")->setValue(gSavedSettings.getBOOL("ShowParcelOwners"));
 
 	return TRUE;
 }
@@ -126,17 +125,17 @@ void LLPanelLandInfo::refresh()
 	if (!parcel || !regionp)
 	{
 		// nothing selected, disable panel
-		childSetVisible("label_area_price",false);
-		childSetVisible("label_area",false);
+		getChildView("label_area_price")->setVisible(false);
+		getChildView("label_area")->setVisible(false);
 
 		//mTextPrice->setText(LLStringUtil::null);
-		childSetText("textbox price",LLStringUtil::null);
+		getChild<LLUICtrl>("textbox price")->setValue(LLStringUtil::null);
 
-		childSetEnabled("button buy land",FALSE);
-		childSetEnabled("button abandon land",FALSE);
-		childSetEnabled("button subdivide land",FALSE);
-		childSetEnabled("button join land",FALSE);
-		childSetEnabled("button about land",FALSE);
+		getChildView("button buy land")->setEnabled(FALSE);
+		getChildView("button abandon land")->setEnabled(FALSE);
+		getChildView("button subdivide land")->setEnabled(FALSE);
+		getChildView("button join land")->setEnabled(FALSE);
+		getChildView("button about land")->setEnabled(FALSE);
 	}
 	else
 	{
@@ -154,11 +153,11 @@ void LLPanelLandInfo::refresh()
 			
 		if (is_public)
 		{
-			childSetEnabled("button buy land",TRUE);
+			getChildView("button buy land")->setEnabled(TRUE);
 		}
 		else
 		{
-			childSetEnabled("button buy land",can_buy);
+			getChildView("button buy land")->setEnabled(can_buy);
 		}
 
 		BOOL owner_release = LLViewerParcelMgr::isParcelOwnedByAgent(parcel, GP_LAND_RELEASE);
@@ -170,16 +169,16 @@ void LLPanelLandInfo::refresh()
 		BOOL manager_divideable = ( gAgent.canManageEstate()
 								&& ((parcel->getOwnerID() == regionp->getOwner()) || owner_divide) );
 
-		childSetEnabled("button abandon land",owner_release || manager_releaseable || gAgent.isGodlike());
+		getChildView("button abandon land")->setEnabled(owner_release || manager_releaseable || gAgent.isGodlike());
 
 		// only mainland sims are subdividable by owner
 		if (regionp->getRegionFlags() && REGION_FLAGS_ALLOW_PARCEL_CHANGES)
 		{
-			childSetEnabled("button subdivide land",owner_divide || manager_divideable || gAgent.isGodlike());
+			getChildView("button subdivide land")->setEnabled(owner_divide || manager_divideable || gAgent.isGodlike());
 		}
 		else
 		{
-			childSetEnabled("button subdivide land",manager_divideable || gAgent.isGodlike());
+			getChildView("button subdivide land")->setEnabled(manager_divideable || gAgent.isGodlike());
 		}
 		
 		// To join land, must have something selected,
@@ -190,15 +189,15 @@ void LLPanelLandInfo::refresh()
 			//&& LLViewerParcelMgr::getInstance()->getSelfCount() > 1
 			&& !LLViewerParcelMgr::getInstance()->getParcelSelection()->getWholeParcelSelected())
 		{
-			childSetEnabled("button join land",TRUE);
+			getChildView("button join land")->setEnabled(TRUE);
 		}
 		else
 		{
 			lldebugs << "Invalid selection for joining land" << llendl;
-			childSetEnabled("button join land",FALSE);
+			getChildView("button join land")->setEnabled(FALSE);
 		}
 
-		childSetEnabled("button about land",TRUE);
+		getChildView("button about land")->setEnabled(TRUE);
 
 		// show pricing information
 		S32 area;
@@ -213,48 +212,48 @@ void LLPanelLandInfo::refresh()
 								   &dwell);
 		if(is_public || (is_for_sale && LLViewerParcelMgr::getInstance()->getParcelSelection()->getWholeParcelSelected()))
 		{
-			childSetTextArg("label_area_price","[PRICE]", llformat("%d",claim_price));
-			childSetTextArg("label_area_price","[AREA]", llformat("%d",area));
-			childSetVisible("label_area_price",true);
-			childSetVisible("label_area",false);
+			getChild<LLUICtrl>("label_area_price")->setTextArg("[PRICE]", llformat("%d",claim_price));
+			getChild<LLUICtrl>("label_area_price")->setTextArg("[AREA]", llformat("%d",area));
+			getChildView("label_area_price")->setVisible(true);
+			getChildView("label_area")->setVisible(false);
 		}
 		else
 		{
-			childSetVisible("label_area_price",false);
-			childSetTextArg("label_area","[AREA]", llformat("%d",area));
-			childSetVisible("label_area",true);
+			getChildView("label_area_price")->setVisible(false);
+			getChild<LLUICtrl>("label_area")->setTextArg("[AREA]", llformat("%d",area));
+			getChildView("label_area")->setVisible(true);
 		}
 	}
 }
 
 
 //static
-void LLPanelLandInfo::onClickClaim(void*)
+void LLPanelLandInfo::onClickClaim()
 {
 	LLViewerParcelMgr::getInstance()->startBuyLand();
 }
 
 
 //static
-void LLPanelLandInfo::onClickRelease(void*)
+void LLPanelLandInfo::onClickRelease()
 {
 	LLViewerParcelMgr::getInstance()->startReleaseLand();
 }
 
 // static
-void LLPanelLandInfo::onClickDivide(void*)
+void LLPanelLandInfo::onClickDivide()
 {
 	LLViewerParcelMgr::getInstance()->startDivideLand();
 }
 
 // static
-void LLPanelLandInfo::onClickJoin(void*)
+void LLPanelLandInfo::onClickJoin()
 {
 	LLViewerParcelMgr::getInstance()->startJoinLand();
 }
 
 //static
-void LLPanelLandInfo::onClickAbout(void*)
+void LLPanelLandInfo::onClickAbout()
 {
 	// Promote the rectangle selection to a parcel selection
 	if (!LLViewerParcelMgr::getInstance()->getParcelSelection()->getWholeParcelSelected())
diff --git a/indra/newview/llpanelland.h b/indra/newview/llpanelland.h
index 02e7e7bf385..32ddd5e93b6 100644
--- a/indra/newview/llpanelland.h
+++ b/indra/newview/llpanelland.h
@@ -55,22 +55,13 @@ class LLPanelLandInfo
 	LLCheckBoxCtrl	*mCheckShowOwners;
 
 protected:
-	static void onClickClaim(void*);
-	static void onClickRelease(void*);
-	static void onClickDivide(void*);
-	static void onClickJoin(void*);
-	static void onClickAbout(void*);
+	static void onClickClaim();
+	static void onClickRelease();
+	static void onClickDivide();
+	static void onClickJoin();
+	static void onClickAbout();
 
 protected:
-	//LLTextBox*		mTextPriceLabel;
-	//LLTextBox*		mTextPrice;
-
-	//LLButton*		mBtnClaimLand;
-	//LLButton*		mBtnReleaseLand;
-	//LLButton*		mBtnDivideLand;
-	//LLButton*		mBtnJoinLand;
-	//LLButton*		mBtnAbout;
-	
 	virtual BOOL	postBuild();
 
 	static LLPanelLandSelectObserver* sObserver;
-- 
GitLab


From 5a8715f82710d2fe01015c000973f033dca4774f Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 09:56:49 -0700
Subject: [PATCH 575/683] added LLPanel::childSetAction() that does not take a
 void* argument implemented childGetVisibleTab/PanelWithHelp using
 breadth-first-search iterator moved tentative state from llview to lluictrl
 changes llcallbackmap to use boost::function

---
 indra/llui/llcallbackmap.h |  3 +-
 indra/llui/llpanel.cpp     | 66 ++++++++++----------------------------
 indra/llui/llpanel.h       |  4 ++-
 indra/llui/lluictrl.h      |  4 +--
 indra/llui/llview.cpp      | 24 +++++++-------
 indra/llui/llview.h        |  6 ++--
 6 files changed, 41 insertions(+), 66 deletions(-)

diff --git a/indra/llui/llcallbackmap.h b/indra/llui/llcallbackmap.h
index 97b1e2fc504..60c4fc6b6d9 100644
--- a/indra/llui/llcallbackmap.h
+++ b/indra/llui/llcallbackmap.h
@@ -35,12 +35,13 @@
 
 #include <map>
 #include <string>
+#include <boost/function.hpp>
 
 class LLCallbackMap
 {
 public:
 	// callback definition.
-	typedef void* (*callback_t)(void* data);
+	typedef boost::function<void* (void* data)> callback_t;
 	
 	typedef std::map<std::string, LLCallbackMap> map_t;
 	typedef map_t::iterator map_iter_t;
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index 9ebdcb87c68..0f769bd6dce 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -661,7 +661,7 @@ void LLPanel::childSetEnabled(const std::string& id, bool enabled)
 
 void LLPanel::childSetTentative(const std::string& id, bool tentative)
 {
-	LLView* child = findChild<LLView>(id);
+	LLUICtrl* child = findChild<LLUICtrl>(id);
 	if (child)
 	{
 		child->setTentative(tentative);
@@ -860,13 +860,16 @@ LLPanel *LLPanel::childGetVisibleTab(const std::string& id) const
 	return NULL;
 }
 
-static LLPanel *childGetVisibleTabWithHelp(LLView *parent)
+LLPanel* LLPanel::childGetVisibleTabWithHelp()
 {
 	LLView *child;
 
-	// look through immediate children first for an active tab with help
-	for (child = parent->getFirstChild(); child; child = parent->findNextSibling(child))
+	bfs_tree_iterator_t it = beginTreeBFS();
+	// skip ourselves
+	++it;
+	for (; it != endTreeBFS(); ++it)
 	{
+		child = *it;
 		LLPanel *curTabPanel = NULL;
 
 		// do we have a tab container?
@@ -890,36 +893,21 @@ static LLPanel *childGetVisibleTabWithHelp(LLView *parent)
 		}
 	}
 
-	// then try a bit harder and recurse through all children
-	for (child = parent->getFirstChild(); child; child = parent->findNextSibling(child))
-	{
-		if (child->getVisible())
-		{
-			LLPanel* tab = ::childGetVisibleTabWithHelp(child);
-			if (tab)
-			{
-				return tab;
-			}
-		}
-	}
-
 	// couldn't find any active tabs with a help topic string
 	return NULL;
 }
 
-LLPanel *LLPanel::childGetVisibleTabWithHelp()
-{
-	// find a visible tab with a help topic (to determine help context)
-	return ::childGetVisibleTabWithHelp(this);
-}
 
-static LLPanel *childGetVisiblePanelWithHelp(LLView *parent)
+LLPanel *LLPanel::childGetVisiblePanelWithHelp()
 {
 	LLView *child;
 
-	// look through immediate children first for an active panel with help
-	for (child = parent->getFirstChild(); child; child = parent->findNextSibling(child))
+	bfs_tree_iterator_t it = beginTreeBFS();
+	// skip ourselves
+	++it;
+	for (; it != endTreeBFS(); ++it)
 	{
+		child = *it;
 		// do we have a panel with a help topic?
 		LLPanel *panel = dynamic_cast<LLPanel *>(child);
 		if (panel && panel->getVisible() && !panel->getHelpTopic().empty())
@@ -928,39 +916,19 @@ static LLPanel *childGetVisiblePanelWithHelp(LLView *parent)
 		}
 	}
 
-	// then try a bit harder and recurse through all children
-	for (child = parent->getFirstChild(); child; child = parent->findNextSibling(child))
-	{
-		if (child->getVisible())
-		{
-			LLPanel* panel = ::childGetVisiblePanelWithHelp(child);
-			if (panel)
-			{
-				return panel;
-			}
-		}
-	}
-
 	// couldn't find any active panels with a help topic string
 	return NULL;
 }
 
-LLPanel *LLPanel::childGetVisiblePanelWithHelp()
+void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function)
 {
-	// find a visible tab with a help topic (to determine help context)
-	return ::childGetVisiblePanelWithHelp(this);
-}
-
-void LLPanel::childSetPrevalidate(const std::string& id, bool (*func)(const LLWString &) )
-{
-	LLLineEditor* child = findChild<LLLineEditor>(id);
-	if (child)
+	LLButton* button = findChild<LLButton>(id);
+	if (button)
 	{
-		child->setPrevalidate(func);
+		button->setClickedCallback(function);
 	}
 }
 
-
 void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> function, void* value)
 {
 	LLButton* button = findChild<LLButton>(id);
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index 03e3dc0c0e9..784054cd86b 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -170,6 +170,7 @@ class LLPanel : public LLUICtrl
 	std::string getString(const std::string& name) const;
 
 	// ** Wrappers for setting child properties by name ** -TomY
+	// WARNING: These are deprecated, please use getChild<T>("name")->doStuff() idiom instead
 
 	// LLView
 	void childSetVisible(const std::string& name, bool visible);
@@ -233,7 +234,8 @@ class LLPanel : public LLUICtrl
 	void childSetPrevalidate(const std::string& id, bool (*func)(const LLWString &) );
 
 	// LLButton
-	void childSetAction(const std::string& id, boost::function<void(void*)> function, void* value = NULL);
+	void childSetAction(const std::string& id, boost::function<void(void*)> function, void* value);
+	void childSetAction(const std::string& id, const commit_signal_t::slot_type& function);
 
 	// LLTextBox
 	void childSetActionTextbox(const std::string& id, boost::function<void(void*)> function, void* value = NULL);
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 1f9d2c90494..259104f72ce 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -147,8 +147,6 @@ class LLUICtrl
 	// LLView interface
 	/*virtual*/ BOOL	setLabelArg( const std::string& key, const LLStringExplicit& text );
 	/*virtual*/ BOOL	isCtrl() const;
-	/*virtual*/ void	setTentative(BOOL b);
-	/*virtual*/ BOOL	getTentative() const;
 	/*virtual*/ void	onMouseEnter(S32 x, S32 y, MASK mask);
 	/*virtual*/ void	onMouseLeave(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	canFocusChildren() const;
@@ -180,6 +178,8 @@ class LLUICtrl
 	void setMakeVisibleControlVariable(LLControlVariable* control);
 	void setMakeInvisibleControlVariable(LLControlVariable* control);
 
+	virtual void	setTentative(BOOL b);
+	virtual BOOL	getTentative() const;
 	virtual void	setValue(const LLSD& value);
 	virtual LLSD	getValue() const;
     /// When two widgets are displaying the same data (e.g. during a skin
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 394ec957d50..9e68277b0f0 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -433,17 +433,6 @@ BOOL LLView::canFocusChildren() const
 	return TRUE;
 }
 
-//virtual
-void LLView::setTentative(BOOL b)
-{
-}
-
-//virtual
-BOOL LLView::getTentative() const
-{
-	return FALSE;
-}
-
 //virtual
 void LLView::setEnabled(BOOL enabled)
 {
@@ -2784,6 +2773,19 @@ LLView::tree_post_iterator_t LLView::endTreeDFSPost()
 	return tree_post_iterator_t();
 }
 
+LLView::bfs_tree_iterator_t LLView::beginTreeBFS() 
+{ 
+	return bfs_tree_iterator_t(this, 
+							boost::bind(boost::mem_fn(&LLView::beginChild), _1), 
+							boost::bind(boost::mem_fn(&LLView::endChild), _1)); 
+}
+
+LLView::bfs_tree_iterator_t LLView::endTreeBFS() 
+{ 
+	// an empty iterator is an "end" iterator
+	return bfs_tree_iterator_t();
+}
+
 
 LLView::root_to_view_iterator_t LLView::beginRootToView()
 {
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 8e705ed701e..745a1b6e74c 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -289,8 +289,6 @@ class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElem
 	// children, etc.
 	virtual void deleteAllChildren();
 
-	virtual void	setTentative(BOOL b);
-	virtual BOOL	getTentative() const;
 	void 	setAllChildrenEnabled(BOOL b);
 
 	virtual void	setVisible(BOOL visible);
@@ -357,6 +355,10 @@ class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElem
 	tree_post_iterator_t beginTreeDFSPost();
 	tree_post_iterator_t endTreeDFSPost();
 
+	typedef LLTreeBFSIter<LLView, child_list_const_iter_t> bfs_tree_iterator_t;
+	bfs_tree_iterator_t beginTreeBFS();
+	bfs_tree_iterator_t endTreeBFS();
+
 
 	typedef LLTreeDownIter<LLView> root_to_view_iterator_t;
 	root_to_view_iterator_t beginRootToView();
-- 
GitLab


From 5d13631452ac043b549f2b8be52c4cc3bf36206a Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 09:57:52 -0700
Subject: [PATCH 576/683] changed to use childSetAction without void* argument

---
 indra/newview/llcofwearables.cpp | 16 ++++++++--------
 indra/newview/llcofwearables.h   |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index 35a1ad747b8..b4c380b2d07 100644
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -514,10 +514,10 @@ LLPanelClothingListItem* LLCOFWearables::buildClothingListItem(LLViewerInventory
 
 	//setting callbacks
 	//*TODO move that item panel's inner structure disclosing stuff into the panels
-	item_panel->childSetAction("btn_delete", mCOFCallbacks.mDeleteWearable);
-	item_panel->childSetAction("btn_move_up", mCOFCallbacks.mMoveWearableFurther);
-	item_panel->childSetAction("btn_move_down", mCOFCallbacks.mMoveWearableCloser);
-	item_panel->childSetAction("btn_edit", mCOFCallbacks.mEditWearable);
+	item_panel->childSetAction("btn_delete", boost::bind(mCOFCallbacks.mDeleteWearable));
+	item_panel->childSetAction("btn_move_up", boost::bind(mCOFCallbacks.mMoveWearableFurther));
+	item_panel->childSetAction("btn_move_down", boost::bind(mCOFCallbacks.mMoveWearableCloser));
+	item_panel->childSetAction("btn_edit", boost::bind(mCOFCallbacks.mEditWearable));
 	
 	//turning on gray separator line for the last item in the items group of the same wearable type
 	item_panel->setSeparatorVisible(last);
@@ -543,8 +543,8 @@ LLPanelBodyPartsListItem* LLCOFWearables::buildBodypartListItem(LLViewerInventor
 
 	//setting callbacks
 	//*TODO move that item panel's inner structure disclosing stuff into the panels
-	item_panel->childSetAction("btn_delete", mCOFCallbacks.mDeleteWearable);
-	item_panel->childSetAction("btn_edit", mCOFCallbacks.mEditWearable);
+	item_panel->childSetAction("btn_delete", boost::bind(mCOFCallbacks.mDeleteWearable));
+	item_panel->childSetAction("btn_edit", boost::bind(mCOFCallbacks.mEditWearable));
 
 	return item_panel;
 }
@@ -559,7 +559,7 @@ LLPanelDeletableWearableListItem* LLCOFWearables::buildAttachemntListItem(LLView
 
 	//setting callbacks
 	//*TODO move that item panel's inner structure disclosing stuff into the panels
-	item_panel->childSetAction("btn_delete", mCOFCallbacks.mDeleteWearable);
+	item_panel->childSetAction("btn_delete", boost::bind(mCOFCallbacks.mDeleteWearable));
 
 	return item_panel;
 }
@@ -605,7 +605,7 @@ void LLCOFWearables::addClothingTypesDummies(const LLAppearanceMgr::wearables_by
 		LLWearableType::EType w_type = static_cast<LLWearableType::EType>(type);
 		LLPanelInventoryListItemBase* item_panel = LLPanelDummyClothingListItem::create(w_type);
 		if(!item_panel) continue;
-		item_panel->childSetAction("btn_add", mCOFCallbacks.mAddWearable);
+		item_panel->childSetAction("btn_add", boost::bind(mCOFCallbacks.mAddWearable));
 		mClothing->addItem(item_panel, LLUUID::null, ADD_BOTTOM, false);
 	}
 }
diff --git a/indra/newview/llcofwearables.h b/indra/newview/llcofwearables.h
index d005b75eaae..511a65c31ac 100644
--- a/indra/newview/llcofwearables.h
+++ b/indra/newview/llcofwearables.h
@@ -59,7 +59,7 @@ class LLCOFWearables : public LLPanel
 		LLCOFCallbacks() {};
 		virtual ~LLCOFCallbacks() {};
 		
-		typedef boost::function<void (void*)> cof_callback_t;
+		typedef boost::function<void ()> cof_callback_t;
 
 		cof_callback_t mAddWearable;
 		cof_callback_t mMoveWearableCloser;
-- 
GitLab


From 9b526997d93d9290602a86f91a7f096da4395d97 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 10:02:30 -0700
Subject: [PATCH 577/683] deprecated LLPanel::child*() methods

---
 indra/newview/llavatarlistitem.cpp            |   6 +-
 indra/newview/llbottomtray.cpp                |   2 +-
 indra/newview/llcallfloater.cpp               |  10 +-
 indra/newview/llchatbar.cpp                   |   4 +-
 indra/newview/llcompilequeue.cpp              |   4 +-
 indra/newview/llcurrencyuimanager.cpp         |  28 +-
 indra/newview/llfloaterauction.cpp            |  35 +-
 indra/newview/llfloateravatarpicker.cpp       |  44 +--
 indra/newview/llfloaterbuy.cpp                |   8 +-
 indra/newview/llfloaterbuycontents.cpp        |  24 +-
 indra/newview/llfloaterbuycurrency.cpp        |  80 ++--
 indra/newview/llfloaterbuyland.cpp            | 104 +++--
 indra/newview/llfloatercamera.cpp             |  29 +-
 indra/newview/llfloatercolorpicker.cpp        |  12 +-
 indra/newview/llfloaterdaycycle.cpp           |   4 +-
 indra/newview/llfloaterenvsettings.cpp        |  32 +-
 indra/newview/llfloaterevent.cpp              |  32 +-
 indra/newview/llfloatergesture.cpp            |  12 +-
 indra/newview/llfloatergodtools.cpp           | 272 ++++++-------
 indra/newview/llfloatergroups.cpp             |  28 +-
 indra/newview/llfloaterhardwaresettings.cpp   |  14 +-
 indra/newview/llfloaterhelpbrowser.cpp        |   4 +-
 indra/newview/llfloaterimagepreview.cpp       |  12 +-
 indra/newview/llfloaterinspect.cpp            |   8 +-
 indra/newview/llfloaterjoystick.cpp           |   6 +-
 indra/newview/llfloaterlagmeter.cpp           |  18 +-
 indra/newview/llfloaterlandholdings.cpp       |  10 +-
 indra/newview/llfloatermediabrowser.cpp       |  34 +-
 indra/newview/llfloatermemleak.cpp            |  20 +-
 indra/newview/llfloaternamedesc.cpp           |  10 +-
 indra/newview/llfloateropenobject.cpp         |   8 +-
 indra/newview/llfloaterpay.cpp                |  66 ++--
 indra/newview/llfloaterpostcard.cpp           |  42 +-
 indra/newview/llfloaterpostprocess.cpp        |  34 +-
 indra/newview/llfloaterpreference.cpp         | 100 ++---
 indra/newview/llfloaterproperties.cpp         | 180 ++++-----
 indra/newview/llfloaterreporter.cpp           | 104 ++---
 indra/newview/llfloaterscriptlimits.cpp       |  42 +-
 indra/newview/llfloatersearch.cpp             |   8 +-
 indra/newview/llfloatersellland.cpp           |  70 ++--
 indra/newview/llfloatersettingsdebug.cpp      |  58 +--
 indra/newview/llfloatersnapshot.cpp           | 112 +++---
 indra/newview/llfloatertelehub.cpp            |  26 +-
 indra/newview/llfloatertools.cpp              |  72 ++--
 indra/newview/llfloatertopobjects.cpp         |  18 +-
 indra/newview/llfloatertos.cpp                |   4 +-
 indra/newview/llfloateruipreview.cpp          |   4 +-
 indra/newview/llfloaterurlentry.cpp           |  14 +-
 .../newview/llfloatervoicedevicesettings.cpp  |   2 +-
 indra/newview/llfloatervoiceeffect.cpp        |   2 +-
 indra/newview/llfloaterwater.cpp              |  42 +-
 indra/newview/llfloaterwindlight.cpp          | 132 +++----
 indra/newview/llfloaterworldmap.cpp           |  82 ++--
 indra/newview/llgrouplist.cpp                 |  14 +-
 indra/newview/llimview.cpp                    |  20 +-
 indra/newview/llinspectavatar.cpp             |   4 +-
 indra/newview/llinspectgroup.cpp              |   2 +-
 indra/newview/llnavigationbar.cpp             |  12 +-
 indra/newview/llpanelavatar.cpp               | 130 +++----
 indra/newview/llpanelblockedlist.cpp          |   4 +-
 indra/newview/llpanelclassified.cpp           | 108 +++---
 indra/newview/llpanelcontents.cpp             |   4 +-
 indra/newview/llpaneleditwearable.cpp         |   8 +-
 indra/newview/llpanelface.cpp                 | 134 +++----
 indra/newview/llpanelgenerictip.cpp           |   2 +-
 indra/newview/llpanelgroup.cpp                |  16 +-
 indra/newview/llpanelgrouplandmoney.cpp       |   8 +-
 indra/newview/llpanelimcontrolpanel.cpp       |  30 +-
 indra/newview/llpanellandmarks.cpp            |   4 +-
 indra/newview/llpanellandmedia.cpp            |  18 +-
 indra/newview/llpanellogin.cpp                |  46 +--
 indra/newview/llpanelmaininventory.cpp        | 108 +++---
 indra/newview/llpanelme.cpp                   |  36 +-
 indra/newview/llpanelmediasettingsgeneral.cpp |  26 +-
 .../llpanelmediasettingspermissions.cpp       |   2 +-
 indra/newview/llpanelobject.cpp               |  58 +--
 indra/newview/llpanelonlinestatus.cpp         |   4 +-
 indra/newview/llpaneloutfitedit.cpp           |  16 +-
 indra/newview/llpaneloutfitsinventory.cpp     |  12 +-
 indra/newview/llpanelpeople.cpp               |   8 +-
 indra/newview/llpanelpermissions.cpp          | 356 ++++++++---------
 indra/newview/llpanelpick.cpp                 |  28 +-
 indra/newview/llpanelpicks.cpp                |  66 ++--
 indra/newview/llpanelpicks.h                  |   4 +-
 indra/newview/llpanelprofileview.cpp          |   4 +-
 indra/newview/llpanelteleporthistory.cpp      |   6 +-
 indra/newview/llpanelvolume.cpp               | 250 ++++++------
 indra/newview/llparticipantlist.cpp           |   4 +-
 indra/newview/llpreview.cpp                   |  12 +-
 indra/newview/llpreviewanim.cpp               |  12 +-
 indra/newview/llpreviewgesture.cpp            |  12 +-
 indra/newview/llpreviewnotecard.cpp           |  22 +-
 indra/newview/llpreviewscript.cpp             |  28 +-
 indra/newview/llpreviewsound.cpp              |   4 +-
 indra/newview/llpreviewtexture.cpp            |  31 +-
 indra/newview/llsaveoutfitcombobtn.cpp        |   2 +-
 indra/newview/llscrollingpanelparam.cpp       |  34 +-
 indra/newview/llsidepanelappearance.cpp       |   4 +-
 indra/newview/llsidepaneliteminfo.cpp         | 188 ++++-----
 indra/newview/llsidepaneltaskinfo.cpp         | 358 +++++++++---------
 indra/newview/llstatusbar.cpp                 |  22 +-
 indra/newview/lltexturectrl.cpp               |  32 +-
 indra/newview/lltoastgroupnotifypanel.cpp     |   2 +-
 indra/newview/lltoolpie.cpp                   |   2 +-
 indra/newview/llviewchildren.cpp              |   4 +-
 indra/newview/llviewermenu.cpp                |  20 +-
 indra/newview/llviewermessage.cpp             |   8 +-
 107 files changed, 2242 insertions(+), 2235 deletions(-)

diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index c74075d67f2..eead0c9b3e7 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -127,7 +127,7 @@ S32 LLAvatarListItem::notifyParent(const LLSD& info)
 
 void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask)
 {
-	childSetVisible("hovered_icon", true);
+	getChildView("hovered_icon")->setVisible( true);
 	mInfoBtn->setVisible(mShowInfoBtn);
 	mProfileBtn->setVisible(mShowProfileBtn);
 
@@ -138,7 +138,7 @@ void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask)
 
 void LLAvatarListItem::onMouseLeave(S32 x, S32 y, MASK mask)
 {
-	childSetVisible("hovered_icon", false);
+	getChildView("hovered_icon")->setVisible( false);
 	mInfoBtn->setVisible(false);
 	mProfileBtn->setVisible(false);
 
@@ -315,7 +315,7 @@ void LLAvatarListItem::setValue( const LLSD& value )
 {
 	if (!value.isMap()) return;;
 	if (!value.has("selected")) return;
-	childSetVisible("selected_icon", value["selected"]);
+	getChildView("selected_icon")->setVisible( value["selected"]);
 }
 
 const LLUUID& LLAvatarListItem::getAvatarId() const
diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp
index 41f5fe64a13..0e5e8d0fe7c 100644
--- a/indra/newview/llbottomtray.cpp
+++ b/indra/newview/llbottomtray.cpp
@@ -59,7 +59,7 @@ static void update_build_button_enable_state()
 {
 	bool can_edit = LLToolMgr::getInstance()->canEdit();
 
-	LLBottomTray::getInstance()->childSetEnabled("build_btn", can_edit);
+	LLBottomTray::getInstance()->getChildView("build_btn")->setEnabled(can_edit);
 }
 
 // Build time optimization, generate extern template once in .cpp file
diff --git a/indra/newview/llcallfloater.cpp b/indra/newview/llcallfloater.cpp
index b494470cbce..a03fe795127 100644
--- a/indra/newview/llcallfloater.cpp
+++ b/indra/newview/llcallfloater.cpp
@@ -296,7 +296,7 @@ void LLCallFloater::updateSession()
 
 	// Hide "Leave Call" button for nearby chat
 	bool is_local_chat = mVoiceType == VC_LOCAL_CHAT;
-	childSetVisible("leave_call_btn_panel", !is_local_chat);
+	getChildView("leave_call_btn_panel")->setVisible( !is_local_chat);
 
 	refreshParticipantList();
 	updateAgentModeratorState();
@@ -419,11 +419,11 @@ void LLCallFloater::initAgentData()
 
 	if ( mAgentPanel )
 	{
-		mAgentPanel->childSetValue("user_icon", gAgentID);
+		mAgentPanel->getChild<LLUICtrl>("user_icon")->setValue(gAgentID);
 
 		std::string name;
 		gCacheName->getFullName(gAgentID, name);
-		mAgentPanel->childSetValue("user_text", name);
+		mAgentPanel->getChild<LLUICtrl>("user_text")->setValue(name);
 
 		mSpeakingIndicator = mAgentPanel->getChild<LLOutputMonitorCtrl>("speaking_indicator");
 		mSpeakingIndicator->setSpeakerId(gAgentID);
@@ -461,7 +461,7 @@ void LLCallFloater::updateAgentModeratorState()
 			}
 		}
 	}
-	mAgentPanel->childSetValue("user_text", name);
+	mAgentPanel->getChild<LLUICtrl>("user_text")->setValue(name);
 }
 
 static void get_voice_participants_uuids(uuid_vec_t& speakers_uuids)
@@ -766,7 +766,7 @@ void LLCallFloater::reset(const LLVoiceChannel::EState& new_state)
 	{
 		// hides "Leave Call" when call is ended in parcel with disabled voice- hiding usually happens in
 		// updateSession() which won't be called here because connect to nearby voice never happens 
-		childSetVisible("leave_call_btn_panel", false);
+		getChildView("leave_call_btn_panel")->setVisible( false);
 		// setting title to nearby chat an "no one near..." text- because in region with disabled
 		// voice we won't have chance to really connect to nearby, so VCP is changed here manually
 		setTitle(getString("title_nearby"));
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index cd279fa10a0..73fbe78298d 100644
--- a/indra/newview/llchatbar.cpp
+++ b/indra/newview/llchatbar.cpp
@@ -191,7 +191,7 @@ void LLChatBar::refresh()
 		gAgent.stopTyping();
 	}
 
-	childSetEnabled("Say", mInputEditor->getText().size() > 0);
+	getChildView("Say")->setEnabled(mInputEditor->getText().size() > 0);
 
 }
 
@@ -393,7 +393,7 @@ void LLChatBar::sendChat( EChatType type )
 		}
 	}
 
-	childSetValue("Chat Editor", LLStringUtil::null);
+	getChild<LLUICtrl>("Chat Editor")->setValue(LLStringUtil::null);
 
 	gAgent.stopTyping();
 
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index feb8c540ef9..e91bf33502f 100644
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -106,7 +106,7 @@ LLFloaterScriptQueue::~LLFloaterScriptQueue()
 BOOL LLFloaterScriptQueue::postBuild()
 {
 	childSetAction("close",onCloseBtn,this);
-	childSetEnabled("close",FALSE);
+	getChildView("close")->setEnabled(FALSE);
 	return TRUE;
 }
 
@@ -219,7 +219,7 @@ BOOL LLFloaterScriptQueue::nextObject()
 	{
 		mDone = true;
 		getChild<LLScrollListCtrl>("queue output")->setCommentText(getString("Done"));
-		childSetEnabled("close",TRUE);
+		getChildView("close")->setEnabled(TRUE);
 	}
 	return successful_start;
 }
diff --git a/indra/newview/llcurrencyuimanager.cpp b/indra/newview/llcurrencyuimanager.cpp
index 7ebcef943ee..3d40358ce5f 100644
--- a/indra/newview/llcurrencyuimanager.cpp
+++ b/indra/newview/llcurrencyuimanager.cpp
@@ -412,8 +412,8 @@ void LLCurrencyUIManager::Impl::currencyKey(S32 value)
 		//cannot just simply refresh the whole UI, as the edit field will
 		// get reset and the cursor will change...
 		
-		mPanel.childHide("currency_est");
-		mPanel.childSetVisible("getting_data",TRUE);
+		mPanel.getChildView("currency_est")->setVisible(FALSE);
+		mPanel.getChildView("getting_data")->setVisible(TRUE);
 	}
 	
 	mCurrencyChanged = true;
@@ -442,13 +442,13 @@ void LLCurrencyUIManager::Impl::updateUI()
 {
 	if (mHidden)
 	{
-		mPanel.childHide("currency_action");
-		mPanel.childHide("currency_amt");
-		mPanel.childHide("currency_est");
+		mPanel.getChildView("currency_action")->setVisible(FALSE);
+		mPanel.getChildView("currency_amt")->setVisible(FALSE);
+		mPanel.getChildView("currency_est")->setVisible(FALSE);
 		return;
 	}
 
-	mPanel.childShow("currency_action");
+	mPanel.getChildView("currency_action")->setVisible(TRUE);
 
 	LLLineEditor* lindenAmount = mPanel.getChild<LLLineEditor>("currency_amt");
 	if (lindenAmount) 
@@ -471,17 +471,17 @@ void LLCurrencyUIManager::Impl::updateUI()
 		}
 	}
 
-	mPanel.childSetTextArg("currency_est", "[LOCALAMOUNT]", getLocalEstimate());
-	mPanel.childSetVisible("currency_est", hasEstimate() && mUserCurrencyBuy > 0);
+	mPanel.getChild<LLUICtrl>("currency_est")->setTextArg("[LOCALAMOUNT]", getLocalEstimate());
+	mPanel.getChildView("currency_est")->setVisible( hasEstimate() && mUserCurrencyBuy > 0);
 
-	mPanel.childSetVisible("currency_links", mSupportsInternationalBilling);
-	mPanel.childSetVisible("exchange_rate_note", mSupportsInternationalBilling);
+	mPanel.getChildView("currency_links")->setVisible( mSupportsInternationalBilling);
+	mPanel.getChildView("exchange_rate_note")->setVisible( mSupportsInternationalBilling);
 
-	if (mPanel.childIsEnabled("buy_btn")
-		||mPanel.childIsVisible("currency_est")
-		|| mPanel.childIsVisible("error_web"))
+	if (mPanel.getChildView("buy_btn")->getEnabled()
+		||mPanel.getChildView("currency_est")->getVisible()
+		|| mPanel.getChildView("error_web")->getVisible())
 	{
-		mPanel.childSetVisible("getting_data",FALSE);
+		mPanel.getChildView("getting_data")->setVisible(FALSE);
 	}
 }
 
diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp
index 679ab4c713d..b0265e6cd28 100644
--- a/indra/newview/llfloaterauction.cpp
+++ b/indra/newview/llfloaterauction.cpp
@@ -115,20 +115,20 @@ void LLFloaterAuction::initialize()
 		mParcelID = parcelp->getLocalID();
 		mParcelUpdateCapUrl = region->getCapability("ParcelPropertiesUpdate");
 
-		childSetText("parcel_text", parcelp->getName());
-		childEnable("snapshot_btn");
-		childEnable("reset_parcel_btn");
-		childEnable("start_auction_btn");
+		getChild<LLUICtrl>("parcel_text")->setValue(parcelp->getName());
+		getChildView("snapshot_btn")->setEnabled(TRUE);
+		getChildView("reset_parcel_btn")->setEnabled(TRUE);
+		getChildView("start_auction_btn")->setEnabled(TRUE);
 
 		LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
 		if (panel)
 		{	// Only enable "Sell to Anyone" on Teen grid or if we don't know the ID yet
 			U32 estate_id = panel->getEstateID();
-			childSetEnabled("sell_to_anyone_btn", (estate_id == ESTATE_TEEN || estate_id == 0));
+			getChildView("sell_to_anyone_btn")->setEnabled((estate_id == ESTATE_TEEN || estate_id == 0));
 		}
 		else
 		{	// Don't have the panel up, so don't know if we're on the teen grid or not.  Default to enabling it
-			childEnable("sell_to_anyone_btn");
+			getChildView("sell_to_anyone_btn")->setEnabled(TRUE);
 		}
 	}
 	else
@@ -136,17 +136,17 @@ void LLFloaterAuction::initialize()
 		mParcelHost.invalidate();
 		if(parcelp && parcelp->getForSale())
 		{
-			childSetText("parcel_text", getString("already for sale"));
+			getChild<LLUICtrl>("parcel_text")->setValue(getString("already for sale"));
 		}
 		else
 		{
-			childSetText("parcel_text", LLStringUtil::null);
+			getChild<LLUICtrl>("parcel_text")->setValue(LLStringUtil::null);
 		}
 		mParcelID = -1;
-		childSetEnabled("snapshot_btn", false);
-		childSetEnabled("reset_parcel_btn", false);
-		childSetEnabled("sell_to_anyone_btn", false);
-		childSetEnabled("start_auction_btn", false);
+		getChildView("snapshot_btn")->setEnabled(false);
+		getChildView("reset_parcel_btn")->setEnabled(false);
+		getChildView("sell_to_anyone_btn")->setEnabled(false);
+		getChildView("start_auction_btn")->setEnabled(false);
 	}
 
 	mImageID.setNull();
@@ -159,9 +159,10 @@ void LLFloaterAuction::draw()
 
 	if(!isMinimized() && mImage.notNull()) 
 	{
-		LLRect rect;
-		if (childGetRect("snapshot_icon", rect))
+		LLView* snapshot_icon = findChildView("snapshot_icon");
+		if (snapshot_icon)
 		{
+			LLRect rect = snapshot_icon->getRect();
 			{
 				gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 				gl_rect_2d(rect, LLColor4(0.f, 0.f, 0.f, 1.f));
@@ -188,7 +189,7 @@ void LLFloaterAuction::onClickSnapshot(void* data)
 
 	LLPointer<LLImageRaw> raw = new LLImageRaw;
 
-	gForceRenderLandFence = self->childGetValue("fence_check").asBoolean();
+	gForceRenderLandFence = self->getChild<LLUICtrl>("fence_check")->getValue().asBoolean();
 	BOOL success = gViewerWindow->rawSnapshot(raw,
 											  gViewerWindow->getWindowWidthScaled(),
 											  gViewerWindow->getWindowHeightScaled(),
@@ -236,7 +237,7 @@ void LLFloaterAuction::onClickStartAuction(void* data)
 
 	if(self->mImageID.notNull())
 	{
-		LLSD parcel_name = self->childGetValue("parcel_text");
+		LLSD parcel_name = self->getChild<LLUICtrl>("parcel_text")->getValue();
 
 	// create the asset
 		std::string* name = new std::string(parcel_name.asString());
@@ -345,7 +346,7 @@ void LLFloaterAuction::doResetParcel()
 
 		std::string new_name(parcel_name.str().c_str());
 		body["name"] = new_name;
-		childSetText("parcel_text", new_name);	// Set name in dialog as well, since it won't get updated otherwise
+		getChild<LLUICtrl>("parcel_text")->setValue(new_name);	// Set name in dialog as well, since it won't get updated otherwise
 
 		body["sale_price"] = (S32) 0;
 		body["description"] = empty;
diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp
index 8f6816b845e..7dbf6ebd5b7 100644
--- a/indra/newview/llfloateravatarpicker.cpp
+++ b/indra/newview/llfloateravatarpicker.cpp
@@ -94,14 +94,14 @@ BOOL LLFloaterAvatarPicker::postBuild()
 	getChild<LLLineEditor>("Edit")->setKeystrokeCallback( boost::bind(&LLFloaterAvatarPicker::editKeystroke, this, _1, _2),NULL);
 
 	childSetAction("Find", boost::bind(&LLFloaterAvatarPicker::onBtnFind, this));
-	childDisable("Find");
+	getChildView("Find")->setEnabled(FALSE);
 	childSetAction("Refresh", boost::bind(&LLFloaterAvatarPicker::onBtnRefresh, this));
 	getChild<LLUICtrl>("near_me_range")->setCommitCallback(boost::bind(&LLFloaterAvatarPicker::onRangeAdjust, this));
 	
 	LLScrollListCtrl* searchresults = getChild<LLScrollListCtrl>("SearchResults");
 	searchresults->setDoubleClickCallback( boost::bind(&LLFloaterAvatarPicker::onBtnSelect, this));
 	searchresults->setCommitCallback(boost::bind(&LLFloaterAvatarPicker::onList, this));
-	childDisable("SearchResults");
+	getChildView("SearchResults")->setEnabled(FALSE);
 	
 	LLScrollListCtrl* nearme = getChild<LLScrollListCtrl>("NearMe");
 	nearme->setDoubleClickCallback(boost::bind(&LLFloaterAvatarPicker::onBtnSelect, this));
@@ -112,10 +112,10 @@ BOOL LLFloaterAvatarPicker::postBuild()
 	getChild<LLUICtrl>("Friends")->setCommitCallback(boost::bind(&LLFloaterAvatarPicker::onList, this));
 
 	childSetAction("ok_btn", boost::bind(&LLFloaterAvatarPicker::onBtnSelect, this));
-	childDisable("ok_btn");
+	getChildView("ok_btn")->setEnabled(FALSE);
 	childSetAction("cancel_btn", boost::bind(&LLFloaterAvatarPicker::onBtnClose, this));
 
-	childSetFocus("Edit");
+	getChild<LLUICtrl>("Edit")->setFocus(TRUE);
 
 	LLPanel* search_panel = getChild<LLPanel>("SearchPanel");
 	if (search_panel)
@@ -145,7 +145,7 @@ void LLFloaterAvatarPicker::setOkBtnEnableCb(validate_callback_t cb)
 
 void LLFloaterAvatarPicker::onTabChanged()
 {
-	childSetEnabled("ok_btn", isSelectBtnEnabled());
+	getChildView("ok_btn")->setEnabled(isSelectBtnEnabled());
 }
 
 // Destroys the object
@@ -184,7 +184,7 @@ void LLFloaterAvatarPicker::onBtnSelect()
 	{
 		std::string acvtive_panel_name;
 		LLScrollListCtrl* list =  NULL;
-		LLPanel* active_panel = childGetVisibleTab("ResidentChooserTabs");
+		LLPanel* active_panel = getChild<LLTabContainer>("ResidentChooserTabs")->getCurrentPanel();
 		if(active_panel)
 		{
 			acvtive_panel_name = active_panel->getName();
@@ -239,7 +239,7 @@ void LLFloaterAvatarPicker::onRangeAdjust()
 
 void LLFloaterAvatarPicker::onList()
 {
-	childSetEnabled("ok_btn", isSelectBtnEnabled());
+	getChildView("ok_btn")->setEnabled(isSelectBtnEnabled());
 }
 
 void LLFloaterAvatarPicker::populateNearMe()
@@ -273,14 +273,14 @@ void LLFloaterAvatarPicker::populateNearMe()
 
 	if (empty)
 	{
-		childDisable("NearMe");
-		childDisable("ok_btn");
+		getChildView("NearMe")->setEnabled(FALSE);
+		getChildView("ok_btn")->setEnabled(FALSE);
 		near_me_scroller->setCommentText(getString("no_one_near"));
 	}
 	else 
 	{
-		childEnable("NearMe");
-		childEnable("ok_btn");
+		getChildView("NearMe")->setEnabled(TRUE);
+		getChildView("ok_btn")->setEnabled(TRUE);
 		near_me_scroller->selectFirstItem();
 		onList();
 		near_me_scroller->setFocus(TRUE);
@@ -327,7 +327,7 @@ void LLFloaterAvatarPicker::draw()
 	}
 
 	LLFloater::draw();
-	if (!mNearMeListComplete && childGetVisibleTab("ResidentChooserTabs") == getChild<LLPanel>("NearMePanel"))
+	if (!mNearMeListComplete && getChild<LLTabContainer>("ResidentChooserTabs")->getCurrentPanel() == getChild<LLPanel>("NearMePanel"))
 	{
 		populateNearMe();
 	}
@@ -335,7 +335,7 @@ void LLFloaterAvatarPicker::draw()
 
 BOOL LLFloaterAvatarPicker::visibleItemsSelected() const
 {
-	LLPanel* active_panel = childGetVisibleTab("ResidentChooserTabs");
+	LLPanel* active_panel = getChild<LLTabContainer>("ResidentChooserTabs")->getCurrentPanel();
 
 	if(active_panel == getChild<LLPanel>("SearchPanel"))
 	{
@@ -354,7 +354,7 @@ BOOL LLFloaterAvatarPicker::visibleItemsSelected() const
 
 void LLFloaterAvatarPicker::find()
 {
-	std::string text = childGetValue("Edit").asString();
+	std::string text = getChild<LLUICtrl>("Edit")->getValue().asString();
 
 	mQueryID.generate();
 
@@ -373,7 +373,7 @@ void LLFloaterAvatarPicker::find()
 	getChild<LLScrollListCtrl>("SearchResults")->deleteAllItems();
 	getChild<LLScrollListCtrl>("SearchResults")->setCommentText(getString("searching"));
 	
-	childSetEnabled("ok_btn", FALSE);
+	getChildView("ok_btn")->setEnabled(FALSE);
 	mNumResultsReturned = 0;
 }
 
@@ -388,7 +388,7 @@ LLScrollListCtrl* LLFloaterAvatarPicker::getActiveList()
 {
 	std::string acvtive_panel_name;
 	LLScrollListCtrl* list = NULL;
-	LLPanel* active_panel = childGetVisibleTab("ResidentChooserTabs");
+	LLPanel* active_panel = getChild<LLTabContainer>("ResidentChooserTabs")->getCurrentPanel();
 	if(active_panel)
 	{
 		acvtive_panel_name = active_panel->getName();
@@ -502,10 +502,10 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void*
 		if (avatar_id.isNull())
 		{
 			LLStringUtil::format_map_t map;
-			map["[TEXT]"] = floater->childGetText("Edit");
+			map["[TEXT]"] = floater->getChild<LLUICtrl>("Edit")->getValue().asString();
 			avatar_name = floater->getString("not_found", map);
 			search_results->setEnabled(FALSE);
-			floater->childDisable("ok_btn");
+			floater->getChildView("ok_btn")->setEnabled(FALSE);
 		}
 		else
 		{
@@ -521,7 +521,7 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void*
 
 	if (found_one)
 	{
-		floater->childEnable("ok_btn");
+		floater->getChildView("ok_btn")->setEnabled(TRUE);
 		search_results->selectFirstItem();
 		floater->onList();
 		search_results->setFocus(TRUE);
@@ -531,7 +531,7 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void*
 //static
 void LLFloaterAvatarPicker::editKeystroke(LLLineEditor* caller, void* user_data)
 {
-	childSetEnabled("Find", caller->getText().size() >= 3);
+	getChildView("Find")->setEnabled(caller->getText().size() >= 3);
 }
 
 // virtual
@@ -539,7 +539,7 @@ BOOL LLFloaterAvatarPicker::handleKeyHere(KEY key, MASK mask)
 {
 	if (key == KEY_RETURN && mask == MASK_NONE)
 	{
-		if (childHasFocus("Edit"))
+		if (getChild<LLUICtrl>("Edit")->hasFocus())
 		{
 			onBtnFind();
 		}
@@ -566,7 +566,7 @@ bool LLFloaterAvatarPicker::isSelectBtnEnabled()
 	{
 		std::string acvtive_panel_name;
 		LLScrollListCtrl* list =  NULL;
-		LLPanel* active_panel = childGetVisibleTab("ResidentChooserTabs");
+		LLPanel* active_panel = getChild<LLTabContainer>("ResidentChooserTabs")->getCurrentPanel();
 
 		if(active_panel)
 		{
diff --git a/indra/newview/llfloaterbuy.cpp b/indra/newview/llfloaterbuy.cpp
index d3598564433..eee4310ec73 100644
--- a/indra/newview/llfloaterbuy.cpp
+++ b/indra/newview/llfloaterbuy.cpp
@@ -62,8 +62,8 @@ LLFloaterBuy::LLFloaterBuy(const LLSD& key)
 
 BOOL LLFloaterBuy::postBuild()
 {
-	childDisable("object_list");
-	childDisable("item_list");
+	getChildView("object_list")->setEnabled(FALSE);
+	getChildView("item_list")->setEnabled(FALSE);
 
 	getChild<LLUICtrl>("cancel_btn")->setCommitCallback( boost::bind(&LLFloaterBuy::onClickCancel, this));
 	getChild<LLUICtrl>("buy_btn")->setCommitCallback( boost::bind(&LLFloaterBuy::onClickBuy, this));
@@ -183,8 +183,8 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info)
 	// Add after columns added so appropriate heights are correct.
 	object_list->addElement(row);
 
-	floater->childSetTextArg("buy_text", "[AMOUNT]", llformat("%d", sale_info.getSalePrice()));
-	floater->childSetTextArg("buy_text", "[NAME]", owner_name);
+	floater->getChild<LLUICtrl>("buy_text")->setTextArg("[AMOUNT]", llformat("%d", sale_info.getSalePrice()));
+	floater->getChild<LLUICtrl>("buy_text")->setTextArg("[NAME]", owner_name);
 
 	// Must do this after the floater is created, because
 	// sometimes the inventory is already there and 
diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp
index 9bde3b1dac9..76ec5da303d 100644
--- a/indra/newview/llfloaterbuycontents.cpp
+++ b/indra/newview/llfloaterbuycontents.cpp
@@ -69,9 +69,9 @@ BOOL LLFloaterBuyContents::postBuild()
 	getChild<LLUICtrl>("cancel_btn")->setCommitCallback( boost::bind(&LLFloaterBuyContents::onClickCancel, this));
 	getChild<LLUICtrl>("buy_btn")->setCommitCallback( boost::bind(&LLFloaterBuyContents::onClickBuy, this));
 
-	childDisable("item_list");
-	childDisable("buy_btn");
-	childDisable("wear_check");
+	getChildView("item_list")->setEnabled(FALSE);
+	getChildView("buy_btn")->setEnabled(FALSE);
+	getChildView("wear_check")->setEnabled(FALSE);
 
 	setDefaultBtn("cancel_btn"); // to avoid accidental buy (SL-43130)
 
@@ -129,9 +129,9 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info)
 		gCacheName->getGroupName(owner_id, owner_name);
 	}
 
-	floater->childSetTextArg("contains_text", "[NAME]", node->mName);
-	floater->childSetTextArg("buy_text", "[AMOUNT]", llformat("%d", sale_info.getSalePrice()));
-	floater->childSetTextArg("buy_text", "[NAME]", owner_name);
+	floater->getChild<LLUICtrl>("contains_text")->setTextArg("[NAME]", node->mName);
+	floater->getChild<LLUICtrl>("buy_text")->setTextArg("[AMOUNT]", llformat("%d", sale_info.getSalePrice()));
+	floater->getChild<LLUICtrl>("buy_text")->setTextArg("[NAME]", owner_name);
 
 	// Must do this after the floater is created, because
 	// sometimes the inventory is already there and 
@@ -169,7 +169,7 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
 	}
 
 	// default to turning off the buy button.
-	childDisable("buy_btn");
+	getChildView("buy_btn")->setEnabled(FALSE);
 
 	LLUUID owner_id;
 	BOOL is_group_owned;
@@ -210,7 +210,7 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
 
 		// There will be at least one item shown in the display, so go
 		// ahead and enable the buy button.
-		childEnable("buy_btn");
+		getChildView("buy_btn")->setEnabled(TRUE);
 
 		// Create the line in the list
 		LLSD row;
@@ -256,8 +256,8 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
 
 	if (wearable_count > 0)
 	{
-		childEnable("wear_check");
-		childSetValue("wear_check", LLSD(false) );
+		getChildView("wear_check")->setEnabled(TRUE);
+		getChild<LLUICtrl>("wear_check")->setValue(LLSD(false) );
 	}
 	
 	removeVOInventoryListener();
@@ -268,7 +268,7 @@ void LLFloaterBuyContents::onClickBuy()
 {
 	// Make sure this wasn't selected through other mechanisms 
 	// (ie, being the default button and pressing enter.
-	if(!childIsEnabled("buy_btn"))
+	if(!getChildView("buy_btn")->getEnabled())
 	{
 		// We shouldn't be enabled.  Just close.
 		closeFloater();
@@ -276,7 +276,7 @@ void LLFloaterBuyContents::onClickBuy()
 	}
 
 	// We may want to wear this item
-	if (childGetValue("wear_check"))
+	if (getChild<LLUICtrl>("wear_check")->getValue())
 	{
 		LLInventoryState::sWearNewClothing = TRUE;
 	}
diff --git a/indra/newview/llfloaterbuycurrency.cpp b/indra/newview/llfloaterbuycurrency.cpp
index 7fddd1fc5fa..e8e0503f480 100644
--- a/indra/newview/llfloaterbuycurrency.cpp
+++ b/indra/newview/llfloaterbuycurrency.cpp
@@ -162,7 +162,7 @@ void LLFloaterBuyCurrencyUI::draw()
 	}
 
 	// disable the Buy button when we are not able to buy
-	childSetEnabled("buy_btn", mManager.canBuy());
+	getChildView("buy_btn")->setEnabled(mManager.canBuy());
 
 	LLFloater::draw();
 }
@@ -178,27 +178,27 @@ void LLFloaterBuyCurrencyUI::updateUI()
 	mManager.updateUI(!hasError && !mManager.buying());
 
 	// hide most widgets - we'll turn them on as needed next
-	childHide("info_buying");
-	childHide("info_cannot_buy");
-	childHide("info_need_more");	
-	childHide("purchase_warning_repurchase");
-	childHide("purchase_warning_notenough");
-	childHide("contacting");
-	childHide("buy_action");
+	getChildView("info_buying")->setVisible(FALSE);
+	getChildView("info_cannot_buy")->setVisible(FALSE);
+	getChildView("info_need_more")->setVisible(FALSE);	
+	getChildView("purchase_warning_repurchase")->setVisible(FALSE);
+	getChildView("purchase_warning_notenough")->setVisible(FALSE);
+	getChildView("contacting")->setVisible(FALSE);
+	getChildView("buy_action")->setVisible(FALSE);
 
 	if (hasError)
 	{
 		// display an error from the server
-		childHide("normal_background");
-		childShow("error_background");
-		childShow("info_cannot_buy");
-		childShow("cannot_buy_message");
-		childHide("balance_label");
-		childHide("balance_amount");
-		childHide("buying_label");
-		childHide("buying_amount");
-		childHide("total_label");
-		childHide("total_amount");
+		getChildView("normal_background")->setVisible(FALSE);
+		getChildView("error_background")->setVisible(TRUE);
+		getChildView("info_cannot_buy")->setVisible(TRUE);
+		getChildView("cannot_buy_message")->setVisible(TRUE);
+		getChildView("balance_label")->setVisible(FALSE);
+		getChildView("balance_amount")->setVisible(FALSE);
+		getChildView("buying_label")->setVisible(FALSE);
+		getChildView("buying_amount")->setVisible(FALSE);
+		getChildView("total_label")->setVisible(FALSE);
+		getChildView("total_amount")->setVisible(FALSE);
 
         LLTextBox* message = getChild<LLTextBox>("cannot_buy_message");
         if (message)
@@ -206,67 +206,67 @@ void LLFloaterBuyCurrencyUI::updateUI()
 			message->setText(mManager.errorMessage());
 		}
 
-		childSetVisible("error_web", !mManager.errorURI().empty());
+		getChildView("error_web")->setVisible( !mManager.errorURI().empty());
 	}
 	else
 	{
 		// display the main Buy L$ interface
-		childShow("normal_background");
-		childHide("error_background");
-		childHide("cannot_buy_message");
-		childHide("error_web");
+		getChildView("normal_background")->setVisible(TRUE);
+		getChildView("error_background")->setVisible(FALSE);
+		getChildView("cannot_buy_message")->setVisible(FALSE);
+		getChildView("error_web")->setVisible(FALSE);
 
 		if (mHasTarget)
 		{
-			childShow("info_need_more");
+			getChildView("info_need_more")->setVisible(TRUE);
 		}
 		else
 		{
-			childShow("info_buying");
+			getChildView("info_buying")->setVisible(TRUE);
 		}
 
 		if (mManager.buying())
 		{
-			childSetVisible("contacting", true);
+			getChildView("contacting")->setVisible( true);
 		}
 		else
 		{
 			if (mHasTarget)
 			{
-				childSetVisible("buy_action", true);
-				childSetTextArg("buy_action", "[ACTION]", mTargetName);
+				getChildView("buy_action")->setVisible( true);
+				getChild<LLUICtrl>("buy_action")->setTextArg("[ACTION]", mTargetName);
 			}
 		}
 		
 		S32 balance = gStatusBar->getBalance();
-		childShow("balance_label");
-		childShow("balance_amount");
-		childSetTextArg("balance_amount", "[AMT]", llformat("%d", balance));
+		getChildView("balance_label")->setVisible(TRUE);
+		getChildView("balance_amount")->setVisible(TRUE);
+		getChild<LLUICtrl>("balance_amount")->setTextArg("[AMT]", llformat("%d", balance));
 		
 		S32 buying = mManager.getAmount();
-		childShow("buying_label");
-		childShow("buying_amount");
-		childSetTextArg("buying_amount", "[AMT]", llformat("%d", buying));
+		getChildView("buying_label")->setVisible(TRUE);
+		getChildView("buying_amount")->setVisible(TRUE);
+		getChild<LLUICtrl>("buying_amount")->setTextArg("[AMT]", llformat("%d", buying));
 		
 		S32 total = balance + buying;
-		childShow("total_label");
-		childShow("total_amount");
-		childSetTextArg("total_amount", "[AMT]", llformat("%d", total));
+		getChildView("total_label")->setVisible(TRUE);
+		getChildView("total_amount")->setVisible(TRUE);
+		getChild<LLUICtrl>("total_amount")->setTextArg("[AMT]", llformat("%d", total));
 
 		if (mHasTarget)
 		{
 			if (total >= mTargetPrice)
 			{
-				childSetVisible("purchase_warning_repurchase", true);
+				getChildView("purchase_warning_repurchase")->setVisible( true);
 			}
 			else
 			{
-				childSetVisible("purchase_warning_notenough", true);
+				getChildView("purchase_warning_notenough")->setVisible( true);
 			}
 		}
 	}
 
-	childSetVisible("getting_data", !mManager.canBuy() && !hasError);
+	getChildView("getting_data")->setVisible( !mManager.canBuy() && !hasError);
 }
 
 void LLFloaterBuyCurrencyUI::onClickBuy()
diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp
index 9379b3f5a82..455cce5e56e 100644
--- a/indra/newview/llfloaterbuyland.cpp
+++ b/indra/newview/llfloaterbuyland.cpp
@@ -732,7 +732,7 @@ void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password)
 		return;
 	}
 	
-	BOOL remove_contribution = childGetValue("remove_contribution").asBoolean();
+	BOOL remove_contribution = getChild<LLUICtrl>("remove_contribution")->getValue().asBoolean();
 	mParcelBuyInfo = LLViewerParcelMgr::getInstance()->setupParcelBuy(gAgent.getID(), gAgent.getSessionID(),
 						gAgent.getGroupID(), mIsForGroup, mIsClaim, remove_contribution);
 
@@ -1026,13 +1026,13 @@ void LLFloaterBuyLandUI::refreshUI()
 		
 		if (mParcelValid)
 		{
-			childSetText("info_parcel", mParcelLocation);
+			getChild<LLUICtrl>("info_parcel")->setValue(mParcelLocation);
 
 			LLStringUtil::format_map_t string_args;
 			string_args["[AMOUNT]"] = llformat("%d", mParcelActualArea);
 			string_args["[AMOUNT2]"] = llformat("%d", mParcelSupportedObjects);
 		
-			childSetText("info_size", getString("meters_supports_object", string_args));
+			getChild<LLUICtrl>("info_size")->setValue(getString("meters_supports_object", string_args));
 
 			F32 cost_per_sqm = 0.0f;
 			if (mParcelActualArea > 0)
@@ -1051,17 +1051,17 @@ void LLFloaterBuyLandUI::refreshUI()
 			{
 				info_price_args["[SOLD_WITH_OBJECTS]"] = getString("sold_without_objects");
 			}
-			childSetText("info_price", getString("info_price_string", info_price_args));
-			childSetVisible("info_price", mParcelIsForSale);
+			getChild<LLUICtrl>("info_price")->setValue(getString("info_price_string", info_price_args));
+			getChildView("info_price")->setVisible( mParcelIsForSale);
 		}
 		else
 		{
-			childSetText("info_parcel", getString("no_parcel_selected"));
-			childSetText("info_size", LLStringUtil::null);
-			childSetText("info_price", LLStringUtil::null);
+			getChild<LLUICtrl>("info_parcel")->setValue(getString("no_parcel_selected"));
+			getChild<LLUICtrl>("info_size")->setValue(LLStringUtil::null);
+			getChild<LLUICtrl>("info_price")->setValue(LLStringUtil::null);
 		}
 		
-		childSetText("info_action",
+		getChild<LLUICtrl>("info_action")->setValue(
 			mCanBuy
 				?
 					mIsForGroup
@@ -1092,14 +1092,13 @@ void LLFloaterBuyLandUI::refreshUI()
 			message->setValue(LLSD(!mCanBuy ? mCannotBuyReason : "(waiting for data)"));
 		}
 
-		childSetVisible("error_web", 
-				mCannotBuyIsError && !mCannotBuyURI.empty());
+		getChildView("error_web")->setVisible(mCannotBuyIsError && !mCannotBuyURI.empty());
 	}
 	else
 	{
-		childHide("step_error");
-		childHide("error_message");
-		childHide("error_web");
+		getChildView("step_error")->setVisible(FALSE);
+		getChildView("error_message")->setVisible(FALSE);
+		getChildView("error_web")->setVisible(FALSE);
 	}
 	
 	
@@ -1110,8 +1109,8 @@ void LLFloaterBuyLandUI::refreshUI()
 			mSiteMembershipUpgrade
 				? LLViewChildren::BADGE_NOTE
 				: LLViewChildren::BADGE_OK);
-		childSetText("account_action", mSiteMembershipAction);
-		childSetText("account_reason", 
+		getChild<LLUICtrl>("account_action")->setValue(mSiteMembershipAction);
+		getChild<LLUICtrl>("account_reason")->setValue( 
 			mSiteMembershipUpgrade
 				?	getString("must_upgrade")
 				:	getString("cant_own_land")
@@ -1134,16 +1133,16 @@ void LLFloaterBuyLandUI::refreshUI()
 			levels->setCurrentByIndex(mUserPlanChoice);
 		}
 
-		childShow("step_1");
-		childShow("account_action");
-		childShow("account_reason");
+		getChildView("step_1")->setVisible(TRUE);
+		getChildView("account_action")->setVisible(TRUE);
+		getChildView("account_reason")->setVisible(TRUE);
 	}
 	else
 	{
-		childHide("step_1");
-		childHide("account_action");
-		childHide("account_reason");
-		childHide("account_level");
+		getChildView("step_1")->setVisible(FALSE);
+		getChildView("account_action")->setVisible(FALSE);
+		getChildView("account_reason")->setVisible(FALSE);
+		getChildView("account_level")->setVisible(FALSE);
 	}
 	
 	// section two: land use fees
@@ -1153,7 +1152,7 @@ void LLFloaterBuyLandUI::refreshUI()
 			mSiteLandUseUpgrade
 				? LLViewChildren::BADGE_NOTE
 				: LLViewChildren::BADGE_OK);
-		childSetText("land_use_action", mSiteLandUseAction);
+		getChild<LLUICtrl>("land_use_action")->setValue(mSiteLandUseAction);
 		
 		std::string message;
 		
@@ -1199,17 +1198,17 @@ void LLFloaterBuyLandUI::refreshUI()
 			}
 		}
 
-		childSetValue("land_use_reason", message);
+		getChild<LLUICtrl>("land_use_reason")->setValue(message);
 
-		childShow("step_2");
-		childShow("land_use_action");
-		childShow("land_use_reason");
+		getChildView("step_2")->setVisible(TRUE);
+		getChildView("land_use_action")->setVisible(TRUE);
+		getChildView("land_use_reason")->setVisible(TRUE);
 	}
 	else
 	{
-		childHide("step_2");
-		childHide("land_use_action");
-		childHide("land_use_reason");
+		getChildView("step_2")->setVisible(FALSE);
+		getChildView("land_use_action")->setVisible(FALSE);
+		getChildView("land_use_reason")->setVisible(FALSE);
 	}
 	
 	// section three: purchase & currency
@@ -1233,8 +1232,8 @@ void LLFloaterBuyLandUI::refreshUI()
 		LLStringUtil::format_map_t string_args;
 		string_args["[AMOUNT]"] = llformat("%d", mParcelPrice);
 		string_args["[SELLER]"] = mParcelSellerName;
-		childSetText("purchase_action", getString("pay_to_for_land", string_args));
-		childSetVisible("purchase_action", mParcelValid);
+		getChild<LLUICtrl>("purchase_action")->setValue(getString("pay_to_for_land", string_args));
+		getChildView("purchase_action")->setVisible( mParcelValid);
 		
 		std::string reasonString;
 
@@ -1243,7 +1242,7 @@ void LLFloaterBuyLandUI::refreshUI()
 			LLStringUtil::format_map_t string_args;
 			string_args["[AMOUNT]"] = llformat("%d", mAgentCashBalance);
 
-			childSetText("currency_reason", getString("have_enough_lindens", string_args));
+			getChild<LLUICtrl>("currency_reason")->setValue(getString("have_enough_lindens", string_args));
 		}
 		else
 		{
@@ -1251,9 +1250,9 @@ void LLFloaterBuyLandUI::refreshUI()
 			string_args["[AMOUNT]"] = llformat("%d", mAgentCashBalance);
 			string_args["[AMOUNT2]"] = llformat("%d", mParcelPrice - mAgentCashBalance);
 			
-			childSetText("currency_reason", getString("not_enough_lindens", string_args));
+			getChild<LLUICtrl>("currency_reason")->setValue(getString("not_enough_lindens", string_args));
 
-			childSetTextArg("currency_est", "[LOCAL_AMOUNT]", mCurrency.getLocalEstimate());
+			getChild<LLUICtrl>("currency_est")->setTextArg("[LOCAL_AMOUNT]", mCurrency.getLocalEstimate());
 		}
 		
 		if (willHaveEnough)
@@ -1261,7 +1260,7 @@ void LLFloaterBuyLandUI::refreshUI()
 			LLStringUtil::format_map_t string_args;
 			string_args["[AMOUNT]"] = llformat("%d", finalBalance);
 
-			childSetText("currency_balance", getString("balance_left", string_args));
+			getChild<LLUICtrl>("currency_balance")->setValue(getString("balance_left", string_args));
 
 		}
 		else
@@ -1269,30 +1268,30 @@ void LLFloaterBuyLandUI::refreshUI()
 			LLStringUtil::format_map_t string_args;
 			string_args["[AMOUNT]"] = llformat("%d", mParcelPrice - mAgentCashBalance);
 	
-			childSetText("currency_balance", getString("balance_needed", string_args));
+			getChild<LLUICtrl>("currency_balance")->setValue(getString("balance_needed", string_args));
 			
 		}
 
-		childSetValue("remove_contribution", LLSD(groupContributionEnough));
-		childSetEnabled("remove_contribution", groupContributionEnough);
+		getChild<LLUICtrl>("remove_contribution")->setValue(LLSD(groupContributionEnough));
+		getChildView("remove_contribution")->setEnabled(groupContributionEnough);
 		bool showRemoveContribution = mParcelIsGroupLand
 							&& (mParcelGroupContribution > 0);
-		childSetLabelArg("remove_contribution", "[AMOUNT]",
+		getChildView("remove_contribution")->setLabelArg("[AMOUNT]",
 							llformat("%d", minContribution));
-		childSetVisible("remove_contribution", showRemoveContribution);
+		getChildView("remove_contribution")->setVisible( showRemoveContribution);
 
-		childShow("step_3");
-		childShow("purchase_action");
-		childShow("currency_reason");
-		childShow("currency_balance");
+		getChildView("step_3")->setVisible(TRUE);
+		getChildView("purchase_action")->setVisible(TRUE);
+		getChildView("currency_reason")->setVisible(TRUE);
+		getChildView("currency_balance")->setVisible(TRUE);
 	}
 	else
 	{
-		childHide("step_3");
-		childHide("purchase_action");
-		childHide("currency_reason");
-		childHide("currency_balance");
-		childHide("remove_group_donation");
+		getChildView("step_3")->setVisible(FALSE);
+		getChildView("purchase_action")->setVisible(FALSE);
+		getChildView("currency_reason")->setVisible(FALSE);
+		getChildView("currency_balance")->setVisible(FALSE);
+		getChildView("remove_group_donation")->setVisible(FALSE);
 	}
 
 
@@ -1303,8 +1302,7 @@ void LLFloaterBuyLandUI::refreshUI()
 	    agrees_to_covenant = check->get();
 	}
 
-	childSetEnabled("buy_btn",
-		mCanBuy  &&  mSiteValid  &&  willHaveEnough  &&  !mTransaction && agrees_to_covenant);
+	getChildView("buy_btn")->setEnabled(mCanBuy  &&  mSiteValid  &&  willHaveEnough  &&  !mTransaction && agrees_to_covenant);
 }
 
 void LLFloaterBuyLandUI::startBuyPreConfirm()
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 0fa536dfadc..75d3d188b11 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -125,10 +125,15 @@ LLPanelCameraItem::LLPanelCameraItem(const LLPanelCameraItem::Params& p)
 	}
 }
 
+void set_view_visible(LLView* parent, const std::string& name, bool visible)
+{
+	parent->getChildView(name)->setVisible(visible);
+}
+
 BOOL LLPanelCameraItem::postBuild()
 {
-	setMouseEnterCallback(boost::bind(&LLPanelCameraItem::childSetVisible, this, "hovered_icon", true));
-	setMouseLeaveCallback(boost::bind(&LLPanelCameraItem::childSetVisible, this, "hovered_icon", false));
+	setMouseEnterCallback(boost::bind(set_view_visible, this, "hovered_icon", true));
+	setMouseLeaveCallback(boost::bind(set_view_visible, this, "hovered_icon", false));
 	setMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
 	setRightMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
 	return TRUE;
@@ -143,9 +148,9 @@ void LLPanelCameraItem::setValue(const LLSD& value)
 {
 	if (!value.isMap()) return;;
 	if (!value.has("selected")) return;
-	childSetVisible("selected_icon", value["selected"]);
-	childSetVisible("picture", !value["selected"]);
-	childSetVisible("selected_picture", value["selected"]);
+	getChildView("selected_icon")->setVisible( value["selected"]);
+	getChildView("picture")->setVisible( !value["selected"]);
+	getChildView("selected_picture")->setVisible( value["selected"]);
 }
 
 static LLRegisterPanelClassWrapper<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel");
@@ -249,12 +254,12 @@ void LLFloaterCamera::onAvatarEditingAppearance(bool editing)
 	if (!floater_camera) return;
 
 	//camera presets (rear, front, etc.)
-	floater_camera->childSetEnabled("preset_views_list", !editing);
-	floater_camera->childSetEnabled("presets_btn", !editing);
+	floater_camera->getChildView("preset_views_list")->setEnabled(!editing);
+	floater_camera->getChildView("presets_btn")->setEnabled(!editing);
 
 	//camera modes (object view, mouselook view)
-	floater_camera->childSetEnabled("camera_modes_list", !editing);
-	floater_camera->childSetEnabled("avatarview_btn", !editing);
+	floater_camera->getChildView("camera_modes_list")->setEnabled(!editing);
+	floater_camera->getChildView("avatarview_btn")->setEnabled(!editing);
 }
 
 void LLFloaterCamera::update()
@@ -484,15 +489,15 @@ void LLFloaterCamera::assignButton2Mode(ECameraControlMode mode, const std::stri
 
 void LLFloaterCamera::updateState()
 {
-	childSetVisible(ZOOM, CAMERA_CTRL_MODE_PAN == mCurrMode);
+	getChildView(ZOOM)->setVisible(CAMERA_CTRL_MODE_PAN == mCurrMode);
 	
 	bool show_presets = (CAMERA_CTRL_MODE_PRESETS == mCurrMode) || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
 																	&& CAMERA_CTRL_MODE_PRESETS == mPrevMode);
-	childSetVisible(PRESETS, show_presets);
+	getChildView(PRESETS)->setVisible(show_presets);
 	
 	bool show_camera_modes = CAMERA_CTRL_MODE_MODES == mCurrMode || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
 																	&& CAMERA_CTRL_MODE_MODES == mPrevMode);
-	childSetVisible("camera_modes_list", show_camera_modes);
+	getChildView("camera_modes_list")->setVisible( show_camera_modes);
 
 	updateItemsSelection();
 
diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp
index b65457c4ebe..6922c515cdd 100644
--- a/indra/newview/llfloatercolorpicker.cpp
+++ b/indra/newview/llfloatercolorpicker.cpp
@@ -692,12 +692,12 @@ void LLFloaterColorPicker::drawPalette ()
 void LLFloaterColorPicker::updateTextEntry ()
 {
 	// set values in spinners
-	childSetValue("rspin", ( getCurR () * 255.0f ) );
-	childSetValue("gspin", ( getCurG () * 255.0f ) );
-	childSetValue("bspin", ( getCurB () * 255.0f ) );
-	childSetValue("hspin", ( getCurH () * 360.0f ) );
-	childSetValue("sspin", ( getCurS () * 100.0f ) );
-	childSetValue("lspin", ( getCurL () * 100.0f ) );
+	getChild<LLUICtrl>("rspin")->setValue(( getCurR () * 255.0f ) );
+	getChild<LLUICtrl>("gspin")->setValue(( getCurG () * 255.0f ) );
+	getChild<LLUICtrl>("bspin")->setValue(( getCurB () * 255.0f ) );
+	getChild<LLUICtrl>("hspin")->setValue(( getCurH () * 360.0f ) );
+	getChild<LLUICtrl>("sspin")->setValue(( getCurS () * 100.0f ) );
+	getChild<LLUICtrl>("lspin")->setValue(( getCurL () * 100.0f ) );
 }
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp
index 48d552022f9..50ea2765e75 100644
--- a/indra/newview/llfloaterdaycycle.cpp
+++ b/indra/newview/llfloaterdaycycle.cpp
@@ -158,11 +158,11 @@ void LLFloaterDayCycle::syncMenu()
 	// turn off Use Estate Time button if it's already being used
 	if(	LLWLParamManager::instance()->mAnimator.mUseLindenTime == true)
 	{
-		childDisable("WLUseLindenTime");
+		getChildView("WLUseLindenTime")->setEnabled(FALSE);
 	} 
 	else 
 	{
-		childEnable("WLUseLindenTime");
+		getChildView("WLUseLindenTime")->setEnabled(TRUE);
 	}
 }
 
diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp
index 2fffa6eece2..eb344b91d37 100644
--- a/indra/newview/llfloaterenvsettings.cpp
+++ b/indra/newview/llfloaterenvsettings.cpp
@@ -113,7 +113,7 @@ void LLFloaterEnvSettings::syncMenu()
 
 	// sync cloud coverage
 	bool err;
-	childSetValue("EnvCloudSlider", LLWLParamManager::instance()->mCurParams.getFloat("cloud_shadow", err));
+	getChild<LLUICtrl>("EnvCloudSlider")->setValue(LLWLParamManager::instance()->mCurParams.getFloat("cloud_shadow", err));
 
 	LLWaterParamManager * param_mgr = LLWaterParamManager::instance();
 	// sync water params
@@ -122,43 +122,43 @@ void LLFloaterEnvSettings::syncMenu()
 	col.mV[3] = 1.0f;
 	colCtrl->set(col);
 
-	childSetValue("EnvWaterFogSlider", param_mgr->mFogDensity.mExp);
+	getChild<LLUICtrl>("EnvWaterFogSlider")->setValue(param_mgr->mFogDensity.mExp);
 	param_mgr->setDensitySliderValue(param_mgr->mFogDensity.mExp);
 
 	// turn off Use Estate Time button if it's already being used
 	if(LLWLParamManager::instance()->mAnimator.mUseLindenTime)
 	{
-		childDisable("EnvUseEstateTimeButton");
+		getChildView("EnvUseEstateTimeButton")->setEnabled(FALSE);
 	} else {
-		childEnable("EnvUseEstateTimeButton");
+		getChildView("EnvUseEstateTimeButton")->setEnabled(TRUE);
 	}
 
 	if(!gPipeline.canUseVertexShaders())
 	{
-		childDisable("EnvWaterColor");
-		childDisable("EnvWaterColorText");
-		//childDisable("EnvAdvancedWaterButton");		
+		getChildView("EnvWaterColor")->setEnabled(FALSE);
+		getChildView("EnvWaterColorText")->setEnabled(FALSE);
+		//getChildView("EnvAdvancedWaterButton")->setEnabled(FALSE);		
 	}
 	else
 	{
-		childEnable("EnvWaterColor");
-		childEnable("EnvWaterColorText");
-		//childEnable("EnvAdvancedWaterButton");		
+		getChildView("EnvWaterColor")->setEnabled(TRUE);
+		getChildView("EnvWaterColorText")->setEnabled(TRUE);
+		//getChildView("EnvAdvancedWaterButton")->setEnabled(TRUE);		
 	}
 
 	// only allow access to these if they are using windlight
 	if(!gPipeline.canUseWindLightShaders())
 	{
 
-		childDisable("EnvCloudSlider");
-		childDisable("EnvCloudText");
-		//childDisable("EnvAdvancedSkyButton");
+		getChildView("EnvCloudSlider")->setEnabled(FALSE);
+		getChildView("EnvCloudText")->setEnabled(FALSE);
+		//getChildView("EnvAdvancedSkyButton")->setEnabled(FALSE);
 	}
 	else
 	{
-		childEnable("EnvCloudSlider");
-		childEnable("EnvCloudText");
-		//childEnable("EnvAdvancedSkyButton");
+		getChildView("EnvCloudSlider")->setEnabled(TRUE);
+		getChildView("EnvCloudText")->setEnabled(TRUE);
+		//getChildView("EnvAdvancedSkyButton")->setEnabled(TRUE);
 	}
 }
 
diff --git a/indra/newview/llfloaterevent.cpp b/indra/newview/llfloaterevent.cpp
index f6cffd4b14d..5fe0297b079 100644
--- a/indra/newview/llfloaterevent.cpp
+++ b/indra/newview/llfloaterevent.cpp
@@ -215,10 +215,10 @@ void LLFloaterEvent::processEventInfoReply(LLMessageSystem *msg, void **)
 		std::string desc = floater->mEventInfo.mSimName + llformat(" (%d, %d, %d)", region_x, region_y, region_z);
 		floater->mTBLocation->setText(desc);
 
-		floater->childSetVisible("rating_icon_m", FALSE);
-		floater->childSetVisible("rating_icon_r", FALSE);
-		floater->childSetVisible("rating_icon_pg", FALSE);
-		floater->childSetValue("rating_value", floater->getString("unknown"));
+		floater->getChildView("rating_icon_m")->setVisible( FALSE);
+		floater->getChildView("rating_icon_r")->setVisible( FALSE);
+		floater->getChildView("rating_icon_pg")->setVisible( FALSE);
+		floater->getChild<LLUICtrl>("rating_value")->setValue(floater->getString("unknown"));
 
 		//for some reason there's not adult flags for now, so see if region is adult and then
 		//set flags
@@ -259,25 +259,25 @@ void LLFloaterEvent::regionInfoCallback(U32 event_id, U64 region_handle)
 		// update the event with the maturity info
 		if (sim_info->isAdult())
 		{
-			floater->childSetVisible("rating_icon_m", FALSE);
-			floater->childSetVisible("rating_icon_r", TRUE);
-			floater->childSetVisible("rating_icon_pg", FALSE);
-			floater->childSetValue("rating_value", floater->getString("adult"));
+			floater->getChildView("rating_icon_m")->setVisible( FALSE);
+			floater->getChildView("rating_icon_r")->setVisible( TRUE);
+			floater->getChildView("rating_icon_pg")->setVisible( FALSE);
+			floater->getChild<LLUICtrl>("rating_value")->setValue(floater->getString("adult"));
 
 		}
 		else if (floater->mEventInfo.mEventFlags & EVENT_FLAG_MATURE)
 		{
-			floater->childSetVisible("rating_icon_m", TRUE);
-			floater->childSetVisible("rating_icon_r", FALSE);
-			floater->childSetVisible("rating_icon_pg", FALSE);
-			floater->childSetValue("rating_value", floater->getString("moderate"));
+			floater->getChildView("rating_icon_m")->setVisible( TRUE);
+			floater->getChildView("rating_icon_r")->setVisible( FALSE);
+			floater->getChildView("rating_icon_pg")->setVisible( FALSE);
+			floater->getChild<LLUICtrl>("rating_value")->setValue(floater->getString("moderate"));
 		}
 		else
 		{
-			floater->childSetVisible("rating_icon_m", FALSE);
-			floater->childSetVisible("rating_icon_r", FALSE);
-			floater->childSetVisible("rating_icon_pg", TRUE);
-			floater->childSetValue("rating_value", floater->getString("general"));
+			floater->getChildView("rating_icon_m")->setVisible( FALSE);
+			floater->getChildView("rating_icon_r")->setVisible( FALSE);
+			floater->getChildView("rating_icon_pg")->setVisible( TRUE);
+			floater->getChild<LLUICtrl>("rating_value")->setValue(floater->getString("general"));
 		}
 	}
 }
diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp
index eff7131145a..6cb33ea41c7 100644
--- a/indra/newview/llfloatergesture.cpp
+++ b/indra/newview/llfloatergesture.cpp
@@ -194,8 +194,8 @@ BOOL LLFloaterGesture::postBuild()
 	getChild<LLUICtrl>("new_gesture_btn")->setCommitCallback(boost::bind(&LLFloaterGesture::onClickNew, this));
 	getChild<LLButton>("del_btn")->setClickedCallback(boost::bind(&LLFloaterGesture::onDeleteSelected, this));
 
-	childSetVisible("play_btn", true);
-	childSetVisible("stop_btn", false);
+	getChildView("play_btn")->setVisible( true);
+	getChildView("stop_btn")->setVisible( false);
 	setDefaultBtn("play_btn");
 	mGestureFolderID = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE, false);
 
@@ -563,13 +563,13 @@ void LLFloaterGesture::onCommitList()
 	mSelectedID = item_id;
 	if (LLGestureMgr::instance().isGesturePlaying(item_id))
 	{
-		childSetVisible("play_btn", false);
-		childSetVisible("stop_btn", true);
+		getChildView("play_btn")->setVisible( false);
+		getChildView("stop_btn")->setVisible( true);
 	}
 	else
 	{
-		childSetVisible("play_btn", true);
-		childSetVisible("stop_btn", false);
+		getChildView("play_btn")->setVisible( true);
+		getChildView("stop_btn")->setVisible( false);
 	}
 }
 
diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp
index bd07cfdfbfe..61f5098af13 100644
--- a/indra/newview/llfloatergodtools.cpp
+++ b/indra/newview/llfloatergodtools.cpp
@@ -88,7 +88,7 @@ void LLFloaterGodTools::onOpen(const LLSD& key)
 {
 	center();
 	setFocus(TRUE);
-// 	LLPanel *panel = childGetVisibleTab("GodTools Tabs");
+// 	LLPanel *panel = getChild<LLTabContainer>("GodTools Tabs")->getCurrentPanel();
 // 	if (panel)
 // 		panel->setFocus(TRUE);
 	if (mPanelObjectTools)
@@ -134,7 +134,7 @@ LLFloaterGodTools::LLFloaterGodTools(const LLSD& key)
 BOOL LLFloaterGodTools::postBuild()
 {
 	sendRegionInfoRequest();
-	childShowTab("GodTools Tabs", "region");
+	getChild<LLTabContainer>("GodTools Tabs")->selectTabByName("region");
 	return TRUE;
 }
 // static
@@ -203,9 +203,9 @@ void LLFloaterGodTools::draw()
 
 void LLFloaterGodTools::showPanel(const std::string& panel_name)
 {
-	childShowTab("GodTools Tabs", panel_name);
+	getChild<LLTabContainer>("GodTools Tabs")->selectTabByName(panel_name);
 	openFloater();
-	LLPanel *panel = childGetVisibleTab("GodTools Tabs");
+	LLPanel *panel = getChild<LLTabContainer>("GodTools Tabs")->getCurrentPanel();
 	if (panel)
 		panel->setFocus(TRUE);
 }
@@ -416,17 +416,17 @@ LLPanelRegionTools::LLPanelRegionTools()
 BOOL LLPanelRegionTools::postBuild()
 {
 	getChild<LLLineEditor>("region name")->setKeystrokeCallback(onChangeSimName, this);
-	childSetPrevalidate("region name", &LLTextValidate::validateASCIIPrintableNoPipe);
-	childSetPrevalidate("estate", &LLTextValidate::validatePositiveS32);
-	childSetPrevalidate("parentestate", &LLTextValidate::validatePositiveS32);
-	childDisable("parentestate");
-	childSetPrevalidate("gridposx", &LLTextValidate::validatePositiveS32);
-	childDisable("gridposx");
-	childSetPrevalidate("gridposy", &LLTextValidate::validatePositiveS32);
-	childDisable("gridposy");
+	getChild<LLLineEditor>("region name")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("estate")->setPrevalidate(&LLTextValidate::validatePositiveS32);
+	getChild<LLLineEditor>("parentestate")->setPrevalidate(&LLTextValidate::validatePositiveS32);
+	getChildView("parentestate")->setEnabled(FALSE);
+	getChild<LLLineEditor>("gridposx")->setPrevalidate(&LLTextValidate::validatePositiveS32);
+	getChildView("gridposx")->setEnabled(FALSE);
+	getChild<LLLineEditor>("gridposy")->setPrevalidate(&LLTextValidate::validatePositiveS32);
+	getChildView("gridposy")->setEnabled(FALSE);
 	
-	childSetPrevalidate("redirectx", &LLTextValidate::validatePositiveS32);
-	childSetPrevalidate("redirecty", &LLTextValidate::validatePositiveS32);
+	getChild<LLLineEditor>("redirectx")->setPrevalidate(&LLTextValidate::validatePositiveS32);
+	getChild<LLLineEditor>("redirecty")->setPrevalidate(&LLTextValidate::validatePositiveS32);
 			 
 	return TRUE;
 }
@@ -453,42 +453,42 @@ void LLPanelRegionTools::refresh()
 void LLPanelRegionTools::clearAllWidgets()
 {
 	// clear all widgets
-	childSetValue("region name", "unknown");
-	childSetFocus("region name", FALSE);
+	getChild<LLUICtrl>("region name")->setValue("unknown");
+	getChild<LLUICtrl>("region name")->setFocus( FALSE);
 
-	childSetValue("check prelude", FALSE);
-	childDisable("check prelude");
+	getChild<LLUICtrl>("check prelude")->setValue(FALSE);
+	getChildView("check prelude")->setEnabled(FALSE);
 
-	childSetValue("check fixed sun", FALSE);
-	childDisable("check fixed sun");
+	getChild<LLUICtrl>("check fixed sun")->setValue(FALSE);
+	getChildView("check fixed sun")->setEnabled(FALSE);
 
-	childSetValue("check reset home", FALSE);
-	childDisable("check reset home");
+	getChild<LLUICtrl>("check reset home")->setValue(FALSE);
+	getChildView("check reset home")->setEnabled(FALSE);
 
-	childSetValue("check damage", FALSE);
-	childDisable("check damage");
+	getChild<LLUICtrl>("check damage")->setValue(FALSE);
+	getChildView("check damage")->setEnabled(FALSE);
 
-	childSetValue("check visible", FALSE);
-	childDisable("check visible");
+	getChild<LLUICtrl>("check visible")->setValue(FALSE);
+	getChildView("check visible")->setEnabled(FALSE);
 
-	childSetValue("block terraform", FALSE);
-	childDisable("block terraform");
+	getChild<LLUICtrl>("block terraform")->setValue(FALSE);
+	getChildView("block terraform")->setEnabled(FALSE);
 
-	childSetValue("block dwell", FALSE);
-	childDisable("block dwell");
+	getChild<LLUICtrl>("block dwell")->setValue(FALSE);
+	getChildView("block dwell")->setEnabled(FALSE);
 
-	childSetValue("is sandbox", FALSE);
-	childDisable("is sandbox");
+	getChild<LLUICtrl>("is sandbox")->setValue(FALSE);
+	getChildView("is sandbox")->setEnabled(FALSE);
 
-	childSetValue("billable factor", BILLABLE_FACTOR_DEFAULT);
-	childDisable("billable factor");
+	getChild<LLUICtrl>("billable factor")->setValue(BILLABLE_FACTOR_DEFAULT);
+	getChildView("billable factor")->setEnabled(FALSE);
 
-	childSetValue("land cost", PRICE_PER_METER_DEFAULT);
-	childDisable("land cost");
+	getChild<LLUICtrl>("land cost")->setValue(PRICE_PER_METER_DEFAULT);
+	getChildView("land cost")->setEnabled(FALSE);
 
-	childDisable("Apply");
-	childDisable("Bake Terrain");
-	childDisable("Autosave now");
+	getChildView("Apply")->setEnabled(FALSE);
+	getChildView("Bake Terrain")->setEnabled(FALSE);
+	getChildView("Autosave now")->setEnabled(FALSE);
 }
 
 
@@ -496,21 +496,21 @@ void LLPanelRegionTools::enableAllWidgets()
 {
 	// enable all of the widgets
 	
-	childEnable("check prelude");
-	childEnable("check fixed sun");
-	childEnable("check reset home");
-	childEnable("check damage");
-	childDisable("check visible"); // use estates to update...
-	childEnable("block terraform");
-	childEnable("block dwell");
-	childEnable("is sandbox");
+	getChildView("check prelude")->setEnabled(TRUE);
+	getChildView("check fixed sun")->setEnabled(TRUE);
+	getChildView("check reset home")->setEnabled(TRUE);
+	getChildView("check damage")->setEnabled(TRUE);
+	getChildView("check visible")->setEnabled(FALSE); // use estates to update...
+	getChildView("block terraform")->setEnabled(TRUE);
+	getChildView("block dwell")->setEnabled(TRUE);
+	getChildView("is sandbox")->setEnabled(TRUE);
 	
-	childEnable("billable factor");
-	childEnable("land cost");
+	getChildView("billable factor")->setEnabled(TRUE);
+	getChildView("land cost")->setEnabled(TRUE);
 
-	childDisable("Apply");	// don't enable this one
-	childEnable("Bake Terrain");
-	childEnable("Autosave now");
+	getChildView("Apply")->setEnabled(FALSE);	// don't enable this one
+	getChildView("Bake Terrain")->setEnabled(TRUE);
+	getChildView("Autosave now")->setEnabled(TRUE);
 }
 
 void LLPanelRegionTools::onSaveState(void* userdata)
@@ -530,74 +530,74 @@ void LLPanelRegionTools::onSaveState(void* userdata)
 
 const std::string LLPanelRegionTools::getSimName() const
 {
-	return childGetValue("region name");
+	return getChild<LLUICtrl>("region name")->getValue();
 }
 
 U32 LLPanelRegionTools::getEstateID() const
 {
-	U32 id = (U32)childGetValue("estate").asInteger();
+	U32 id = (U32)getChild<LLUICtrl>("estate")->getValue().asInteger();
 	return id;
 }
 
 U32 LLPanelRegionTools::getParentEstateID() const
 {
-	U32 id = (U32)childGetValue("parentestate").asInteger();
+	U32 id = (U32)getChild<LLUICtrl>("parentestate")->getValue().asInteger();
 	return id;
 }
 
 S32 LLPanelRegionTools::getRedirectGridX() const
 {
-	return childGetValue("redirectx").asInteger();
+	return getChild<LLUICtrl>("redirectx")->getValue().asInteger();
 }
 
 S32 LLPanelRegionTools::getRedirectGridY() const
 {
-	return childGetValue("redirecty").asInteger();
+	return getChild<LLUICtrl>("redirecty")->getValue().asInteger();
 }
 
 S32 LLPanelRegionTools::getGridPosX() const
 {
-	return childGetValue("gridposx").asInteger();
+	return getChild<LLUICtrl>("gridposx")->getValue().asInteger();
 }
 
 S32 LLPanelRegionTools::getGridPosY() const
 {
-	return childGetValue("gridposy").asInteger();
+	return getChild<LLUICtrl>("gridposy")->getValue().asInteger();
 }
 
 U32 LLPanelRegionTools::getRegionFlags() const
 {
 	U32 flags = 0x0;
-	flags = childGetValue("check prelude").asBoolean()  
+	flags = getChild<LLUICtrl>("check prelude")->getValue().asBoolean()  
 					? set_prelude_flags(flags)
 					: unset_prelude_flags(flags);
 
 	// override prelude
-	if (childGetValue("check fixed sun").asBoolean())
+	if (getChild<LLUICtrl>("check fixed sun")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_SUN_FIXED;
 	}
-	if (childGetValue("check reset home").asBoolean())
+	if (getChild<LLUICtrl>("check reset home")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_RESET_HOME_ON_TELEPORT;
 	}
-	if (childGetValue("check visible").asBoolean())
+	if (getChild<LLUICtrl>("check visible")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_EXTERNALLY_VISIBLE;
 	}
-	if (childGetValue("check damage").asBoolean())
+	if (getChild<LLUICtrl>("check damage")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_ALLOW_DAMAGE;
 	}
-	if (childGetValue("block terraform").asBoolean())
+	if (getChild<LLUICtrl>("block terraform")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_BLOCK_TERRAFORM;
 	}
-	if (childGetValue("block dwell").asBoolean())
+	if (getChild<LLUICtrl>("block dwell")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_BLOCK_DWELL;
 	}
-	if (childGetValue("is sandbox").asBoolean())
+	if (getChild<LLUICtrl>("is sandbox")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_SANDBOX;
 	}
@@ -607,35 +607,35 @@ U32 LLPanelRegionTools::getRegionFlags() const
 U32 LLPanelRegionTools::getRegionFlagsMask() const
 {
 	U32 flags = 0xffffffff;
-	flags = childGetValue("check prelude").asBoolean()
+	flags = getChild<LLUICtrl>("check prelude")->getValue().asBoolean()
 				? set_prelude_flags(flags)
 				: unset_prelude_flags(flags);
 
-	if (!childGetValue("check fixed sun").asBoolean())
+	if (!getChild<LLUICtrl>("check fixed sun")->getValue().asBoolean())
 	{
 		flags &= ~REGION_FLAGS_SUN_FIXED;
 	}
-	if (!childGetValue("check reset home").asBoolean())
+	if (!getChild<LLUICtrl>("check reset home")->getValue().asBoolean())
 	{
 		flags &= ~REGION_FLAGS_RESET_HOME_ON_TELEPORT;
 	}
-	if (!childGetValue("check visible").asBoolean())
+	if (!getChild<LLUICtrl>("check visible")->getValue().asBoolean())
 	{
 		flags &= ~REGION_FLAGS_EXTERNALLY_VISIBLE;
 	}
-	if (!childGetValue("check damage").asBoolean())
+	if (!getChild<LLUICtrl>("check damage")->getValue().asBoolean())
 	{
 		flags &= ~REGION_FLAGS_ALLOW_DAMAGE;
 	}
-	if (!childGetValue("block terraform").asBoolean())
+	if (!getChild<LLUICtrl>("block terraform")->getValue().asBoolean())
 	{
 		flags &= ~REGION_FLAGS_BLOCK_TERRAFORM;
 	}
-	if (!childGetValue("block dwell").asBoolean())
+	if (!getChild<LLUICtrl>("block dwell")->getValue().asBoolean())
 	{
 		flags &= ~REGION_FLAGS_BLOCK_DWELL;
 	}
-	if (!childGetValue("is sandbox").asBoolean())
+	if (!getChild<LLUICtrl>("is sandbox")->getValue().asBoolean())
 	{
 		flags &= ~REGION_FLAGS_SANDBOX;
 	}
@@ -644,86 +644,86 @@ U32 LLPanelRegionTools::getRegionFlagsMask() const
 
 F32 LLPanelRegionTools::getBillableFactor() const
 {
-	return (F32)childGetValue("billable factor").asReal();
+	return (F32)getChild<LLUICtrl>("billable factor")->getValue().asReal();
 }
 
 S32 LLPanelRegionTools::getPricePerMeter() const
 {
-	return childGetValue("land cost");
+	return getChild<LLUICtrl>("land cost")->getValue();
 }
 
 void LLPanelRegionTools::setSimName(const std::string& name)
 {
-	childSetValue("region name", name);
+	getChild<LLUICtrl>("region name")->setValue(name);
 }
 
 void LLPanelRegionTools::setEstateID(U32 id)
 {
-	childSetValue("estate", (S32)id);
+	getChild<LLUICtrl>("estate")->setValue((S32)id);
 }
 
 void LLPanelRegionTools::setGridPosX(S32 pos)
 {
-	childSetValue("gridposx", pos);
+	getChild<LLUICtrl>("gridposx")->setValue(pos);
 }
 
 void LLPanelRegionTools::setGridPosY(S32 pos)
 {
-	childSetValue("gridposy", pos);
+	getChild<LLUICtrl>("gridposy")->setValue(pos);
 }
 
 void LLPanelRegionTools::setRedirectGridX(S32 pos)
 {
-	childSetValue("redirectx", pos);
+	getChild<LLUICtrl>("redirectx")->setValue(pos);
 }
 
 void LLPanelRegionTools::setRedirectGridY(S32 pos)
 {
-	childSetValue("redirecty", pos);
+	getChild<LLUICtrl>("redirecty")->setValue(pos);
 }
 
 void LLPanelRegionTools::setParentEstateID(U32 id)
 {
-	childSetValue("parentestate", (S32)id);
+	getChild<LLUICtrl>("parentestate")->setValue((S32)id);
 }
 
 void LLPanelRegionTools::setCheckFlags(U32 flags)
 {
-	childSetValue("check prelude", is_prelude(flags) ? TRUE : FALSE);
-	childSetValue("check fixed sun", flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE);
-	childSetValue("check reset home", flags & REGION_FLAGS_RESET_HOME_ON_TELEPORT ? TRUE : FALSE);
-	childSetValue("check damage", flags & REGION_FLAGS_ALLOW_DAMAGE ? TRUE : FALSE);
-	childSetValue("check visible", flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE);
-	childSetValue("block terraform", flags & REGION_FLAGS_BLOCK_TERRAFORM ? TRUE : FALSE);
-	childSetValue("block dwell", flags & REGION_FLAGS_BLOCK_DWELL ? TRUE : FALSE);
-	childSetValue("is sandbox", flags & REGION_FLAGS_SANDBOX ? TRUE : FALSE );
+	getChild<LLUICtrl>("check prelude")->setValue(is_prelude(flags) ? TRUE : FALSE);
+	getChild<LLUICtrl>("check fixed sun")->setValue(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE);
+	getChild<LLUICtrl>("check reset home")->setValue(flags & REGION_FLAGS_RESET_HOME_ON_TELEPORT ? TRUE : FALSE);
+	getChild<LLUICtrl>("check damage")->setValue(flags & REGION_FLAGS_ALLOW_DAMAGE ? TRUE : FALSE);
+	getChild<LLUICtrl>("check visible")->setValue(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE);
+	getChild<LLUICtrl>("block terraform")->setValue(flags & REGION_FLAGS_BLOCK_TERRAFORM ? TRUE : FALSE);
+	getChild<LLUICtrl>("block dwell")->setValue(flags & REGION_FLAGS_BLOCK_DWELL ? TRUE : FALSE);
+	getChild<LLUICtrl>("is sandbox")->setValue(flags & REGION_FLAGS_SANDBOX ? TRUE : FALSE );
 }
 
 void LLPanelRegionTools::setBillableFactor(F32 billable_factor)
 {
-	childSetValue("billable factor", billable_factor);
+	getChild<LLUICtrl>("billable factor")->setValue(billable_factor);
 }
 
 void LLPanelRegionTools::setPricePerMeter(S32 price)
 {
-	childSetValue("land cost", price);
+	getChild<LLUICtrl>("land cost")->setValue(price);
 }
 
 void LLPanelRegionTools::onChangeAnything()
 {
 	if (gAgent.isGodlike())
 	{
-		childEnable("Apply");
+		getChildView("Apply")->setEnabled(TRUE);
 	}
 }
 
 void LLPanelRegionTools::onChangePrelude()
 {
 	// checking prelude auto-checks fixed sun
-	if (childGetValue("check prelude").asBoolean())
+	if (getChild<LLUICtrl>("check prelude")->getValue().asBoolean())
 	{
-		childSetValue("check fixed sun", TRUE);
-		childSetValue("check reset home", TRUE);
+		getChild<LLUICtrl>("check fixed sun")->setValue(TRUE);
+		getChild<LLUICtrl>("check reset home")->setValue(TRUE);
 		onChangeAnything();
 	}
 	// pass on to default onChange handler
@@ -736,7 +736,7 @@ void LLPanelRegionTools::onChangeSimName(LLLineEditor* caller, void* userdata )
 	if (userdata && gAgent.isGodlike())
 	{
 		LLPanelRegionTools* region_tools = (LLPanelRegionTools*) userdata;
-		region_tools->childEnable("Apply");
+		region_tools->getChildView("Apply")->setEnabled(TRUE);
 	}
 }
 
@@ -761,7 +761,7 @@ void LLPanelRegionTools::onApplyChanges()
 	LLViewerRegion *region = gAgent.getRegion();
 	if (region && gAgent.isGodlike())
 	{
-		childDisable("Apply");
+		getChildView("Apply")->setEnabled(FALSE);
 		god_tools->sendGodUpdateRegionInfo();
 		//LLFloaterReg::getTypedInstance<LLFloaterGodTools>("god_tools")->sendGodUpdateRegionInfo();
 	}
@@ -931,7 +931,7 @@ void LLPanelObjectTools::setTargetAvatar(const LLUUID &target_id)
 	mTargetAvatar = target_id;
 	if (target_id.isNull())
 	{
-		childSetValue("target_avatar_name", getString("no_target"));
+		getChild<LLUICtrl>("target_avatar_name")->setValue(getString("no_target"));
 	}
 } 
 
@@ -941,14 +941,14 @@ void LLPanelObjectTools::refresh()
 	LLViewerRegion *regionp = gAgent.getRegion();
 	if (regionp)
 	{
-		childSetText("region name", regionp->getName());
+		getChild<LLUICtrl>("region name")->setValue(regionp->getName());
 	}
 }
 
 
 U32 LLPanelObjectTools::computeRegionFlags(U32 flags) const
 {
-	if (childGetValue("disable scripts").asBoolean())
+	if (getChild<LLUICtrl>("disable scripts")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_SKIP_SCRIPTS;
 	}
@@ -956,7 +956,7 @@ U32 LLPanelObjectTools::computeRegionFlags(U32 flags) const
 	{
 		flags &= ~REGION_FLAGS_SKIP_SCRIPTS;
 	}
-	if (childGetValue("disable collisions").asBoolean())
+	if (getChild<LLUICtrl>("disable collisions")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_SKIP_COLLISIONS;
 	}
@@ -964,7 +964,7 @@ U32 LLPanelObjectTools::computeRegionFlags(U32 flags) const
 	{
 		flags &= ~REGION_FLAGS_SKIP_COLLISIONS;
 	}
-	if (childGetValue("disable physics").asBoolean())
+	if (getChild<LLUICtrl>("disable physics")->getValue().asBoolean())
 	{
 		flags |= REGION_FLAGS_SKIP_PHYSICS;
 	}
@@ -978,36 +978,36 @@ U32 LLPanelObjectTools::computeRegionFlags(U32 flags) const
 
 void LLPanelObjectTools::setCheckFlags(U32 flags)
 {
-	childSetValue("disable scripts", flags & REGION_FLAGS_SKIP_SCRIPTS ? TRUE : FALSE);
-	childSetValue("disable collisions", flags & REGION_FLAGS_SKIP_COLLISIONS ? TRUE : FALSE);
-	childSetValue("disable physics", flags & REGION_FLAGS_SKIP_PHYSICS ? TRUE : FALSE);
+	getChild<LLUICtrl>("disable scripts")->setValue(flags & REGION_FLAGS_SKIP_SCRIPTS ? TRUE : FALSE);
+	getChild<LLUICtrl>("disable collisions")->setValue(flags & REGION_FLAGS_SKIP_COLLISIONS ? TRUE : FALSE);
+	getChild<LLUICtrl>("disable physics")->setValue(flags & REGION_FLAGS_SKIP_PHYSICS ? TRUE : FALSE);
 }
 
 
 void LLPanelObjectTools::clearAllWidgets()
 {
-	childSetValue("disable scripts", FALSE);
-	childDisable("disable scripts");
+	getChild<LLUICtrl>("disable scripts")->setValue(FALSE);
+	getChildView("disable scripts")->setEnabled(FALSE);
 
-	childDisable("Apply");
-	childDisable("Set Target");
-	childDisable("Delete Target's Scripted Objects On Others Land");
-	childDisable("Delete Target's Scripted Objects On *Any* Land");
-	childDisable("Delete *ALL* Of Target's Objects");
+	getChildView("Apply")->setEnabled(FALSE);
+	getChildView("Set Target")->setEnabled(FALSE);
+	getChildView("Delete Target's Scripted Objects On Others Land")->setEnabled(FALSE);
+	getChildView("Delete Target's Scripted Objects On *Any* Land")->setEnabled(FALSE);
+	getChildView("Delete *ALL* Of Target's Objects")->setEnabled(FALSE);
 }
 
 
 void LLPanelObjectTools::enableAllWidgets()
 {
-	childEnable("disable scripts");
+	getChildView("disable scripts")->setEnabled(TRUE);
 
-	childDisable("Apply");	// don't enable this one
-	childEnable("Set Target");
-	childEnable("Delete Target's Scripted Objects On Others Land");
-	childEnable("Delete Target's Scripted Objects On *Any* Land");
-	childEnable("Delete *ALL* Of Target's Objects");
-	childEnable("Get Top Colliders");
-	childEnable("Get Top Scripts");
+	getChildView("Apply")->setEnabled(FALSE);	// don't enable this one
+	getChildView("Set Target")->setEnabled(TRUE);
+	getChildView("Delete Target's Scripted Objects On Others Land")->setEnabled(TRUE);
+	getChildView("Delete Target's Scripted Objects On *Any* Land")->setEnabled(TRUE);
+	getChildView("Delete *ALL* Of Target's Objects")->setEnabled(TRUE);
+	getChildView("Get Top Colliders")->setEnabled(TRUE);
+	getChildView("Get Top Scripts")->setEnabled(TRUE);
 }
 
 
@@ -1057,7 +1057,7 @@ void LLPanelObjectTools::onClickDeletePublicOwnedBy()
 			SWD_SCRIPTED_ONLY | SWD_OTHERS_LAND_ONLY;
 
 		LLSD args;
-		args["AVATAR_NAME"] = childGetValue("target_avatar_name").asString();
+		args["AVATAR_NAME"] = getChild<LLUICtrl>("target_avatar_name")->getValue().asString();
 		LLSD payload;
 		payload["avatar_id"] = mTargetAvatar;
 		payload["flags"] = (S32)mSimWideDeletesFlags;
@@ -1077,7 +1077,7 @@ void LLPanelObjectTools::onClickDeleteAllScriptedOwnedBy()
 		mSimWideDeletesFlags = SWD_SCRIPTED_ONLY;
 
 		LLSD args;
-		args["AVATAR_NAME"] = childGetValue("target_avatar_name").asString();
+		args["AVATAR_NAME"] = getChild<LLUICtrl>("target_avatar_name")->getValue().asString();
 		LLSD payload;
 		payload["avatar_id"] = mTargetAvatar;
 		payload["flags"] = (S32)mSimWideDeletesFlags;
@@ -1097,7 +1097,7 @@ void LLPanelObjectTools::onClickDeleteAllOwnedBy()
 		mSimWideDeletesFlags = 0;
 
 		LLSD args;
-		args["AVATAR_NAME"] = childGetValue("target_avatar_name").asString();
+		args["AVATAR_NAME"] = getChild<LLUICtrl>("target_avatar_name")->getValue().asString();
 		LLSD payload;
 		payload["avatar_id"] = mTargetAvatar;
 		payload["flags"] = (S32)mSimWideDeletesFlags;
@@ -1148,14 +1148,14 @@ void LLPanelObjectTools::onClickSetBySelection(void* data)
 	args["[OBJECT]"] = node->mName;
 	args["[OWNER]"] = owner_name;
 	std::string name = LLTrans::getString("GodToolsObjectOwnedBy", args);
-	panelp->childSetValue("target_avatar_name", name);
+	panelp->getChild<LLUICtrl>("target_avatar_name")->setValue(name);
 }
 
 void LLPanelObjectTools::callbackAvatarID(const std::vector<std::string>& names, const uuid_vec_t& ids)
 {
 	if (ids.empty() || names.empty()) return;
 	mTargetAvatar = ids[0];
-	childSetValue("target_avatar_name", names[0]);
+	getChild<LLUICtrl>("target_avatar_name")->setValue(names[0]);
 	refresh();
 }
 
@@ -1163,7 +1163,7 @@ void LLPanelObjectTools::onChangeAnything()
 {
 	if (gAgent.isGodlike())
 	{
-		childEnable("Apply");
+		getChildView("Apply")->setEnabled(TRUE);
 	}
 }
 
@@ -1175,7 +1175,7 @@ void LLPanelObjectTools::onApplyChanges()
 	if (region && gAgent.isGodlike())
 	{
 		// TODO -- implement this
-		childDisable("Apply");
+		getChildView("Apply")->setEnabled(FALSE);
 		god_tools->sendGodUpdateRegionInfo();
 		//LLFloaterReg::getTypedInstance<LLFloaterGodTools>("god_tools")->sendGodUpdateRegionInfo();
 	}
@@ -1208,7 +1208,7 @@ BOOL LLPanelRequestTools::postBuild()
 
 void LLPanelRequestTools::refresh()
 {
-	std::string buffer = childGetValue("destination");
+	std::string buffer = getChild<LLUICtrl>("destination")->getValue();
 	LLCtrlListInterface *list = childGetListInterface("destination");
 	if (!list) return;
 
@@ -1263,12 +1263,12 @@ void LLPanelRequestTools::sendRequest(const std::string& request,
 
 void LLPanelRequestTools::onClickRequest()
 {
-	const std::string dest = childGetValue("destination").asString();
+	const std::string dest = getChild<LLUICtrl>("destination")->getValue().asString();
 	if(dest == SELECTION)
 	{
-		std::string req =childGetValue("request");
+		std::string req =getChild<LLUICtrl>("request")->getValue();
 		req = req.substr(0, req.find_first_of(" "));
-		std::string param = childGetValue("parameter");
+		std::string param = getChild<LLUICtrl>("parameter")->getValue();
 		LLSelectMgr::getInstance()->sendGodlikeRequest(req, param);
 	}
 	else if(dest == AGENT_REGION)
@@ -1307,7 +1307,7 @@ void LLPanelRequestTools::sendRequest(const LLHost& host)
 {
 
 	// intercept viewer local actions here
-	std::string req = childGetValue("request");
+	std::string req = getChild<LLUICtrl>("request")->getValue();
 	if (req == "terrain download")
 	{
 		gXferManager->requestFile(std::string("terrain.raw"), std::string("terrain.raw"), LL_PATH_NONE,
@@ -1319,7 +1319,7 @@ void LLPanelRequestTools::sendRequest(const LLHost& host)
 	else
 	{
 		req = req.substr(0, req.find_first_of(" "));
-		sendRequest(req, childGetValue("parameter").asString(), host);
+		sendRequest(req, getChild<LLUICtrl>("parameter")->getValue().asString(), host);
 	}
 }
 
diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp
index 3952c546708..0bd8215e5cd 100644
--- a/indra/newview/llfloatergroups.cpp
+++ b/indra/newview/llfloatergroups.cpp
@@ -98,7 +98,7 @@ BOOL LLFloaterGroupPicker::postBuild()
 
 	setDefaultBtn("OK");
 
-	childEnable("OK");
+	getChildView("OK")->setEnabled(TRUE);
 
 	return TRUE;
 }
@@ -179,8 +179,8 @@ void LLPanelGroups::reset()
 	{
 		group_list->operateOnAll(LLCtrlListInterface::OP_DELETE);
 	}
-	childSetTextArg("groupcount", "[COUNT]", llformat("%d",gAgent.mGroups.count()));
-	childSetTextArg("groupcount", "[MAX]", llformat("%d",MAX_AGENT_GROUPS));
+	getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.count()));
+	getChild<LLUICtrl>("groupcount")->setTextArg("[MAX]", llformat("%d",MAX_AGENT_GROUPS));
 
 	init_group_list(getChild<LLScrollListCtrl>("group list"), gAgent.getGroupID());
 	enableButtons();
@@ -190,8 +190,8 @@ BOOL LLPanelGroups::postBuild()
 {
 	childSetCommitCallback("group list", onGroupList, this);
 
-	childSetTextArg("groupcount", "[COUNT]", llformat("%d",gAgent.mGroups.count()));
-	childSetTextArg("groupcount", "[MAX]", llformat("%d",MAX_AGENT_GROUPS));
+	getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.count()));
+	getChild<LLUICtrl>("groupcount")->setTextArg("[MAX]", llformat("%d",MAX_AGENT_GROUPS));
 
 	LLScrollListCtrl *list = getChild<LLScrollListCtrl>("group list");
 	if (list)
@@ -231,25 +231,25 @@ void LLPanelGroups::enableButtons()
 
 	if(group_id != gAgent.getGroupID())
 	{
-		childEnable("Activate");
+		getChildView("Activate")->setEnabled(TRUE);
 	}
 	else
 	{
-		childDisable("Activate");
+		getChildView("Activate")->setEnabled(FALSE);
 	}
 	if (group_id.notNull())
 	{
-		childEnable("Info");
-		childEnable("IM");
-		childEnable("Leave");
+		getChildView("Info")->setEnabled(TRUE);
+		getChildView("IM")->setEnabled(TRUE);
+		getChildView("Leave")->setEnabled(TRUE);
 	}
 	else
 	{
-		childDisable("Info");
-		childDisable("IM");
-		childDisable("Leave");
+		getChildView("Info")->setEnabled(FALSE);
+		getChildView("IM")->setEnabled(FALSE);
+		getChildView("Leave")->setEnabled(FALSE);
 	}
-	childSetEnabled("Create", gAgent.canJoinGroups());
+	getChildView("Create")->setEnabled(gAgent.canJoinGroups());
 }
 
 
diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp
index 480e4ce3a4b..a97e00122a8 100644
--- a/indra/newview/llfloaterhardwaresettings.cpp
+++ b/indra/newview/llfloaterhardwaresettings.cpp
@@ -87,7 +87,7 @@ void LLFloaterHardwareSettings::refresh()
 	mFogRatio = gSavedSettings.getF32("RenderFogRatio");
 	mProbeHardwareOnStartup = gSavedSettings.getBOOL("ProbeHardwareOnStartup");
 
-	childSetValue("fsaa", (LLSD::Integer) mFSAASamples);
+	getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer) mFSAASamples);
 	refreshEnabledState();
 }
 
@@ -101,13 +101,13 @@ void LLFloaterHardwareSettings::refreshEnabledState()
 	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
 		!gGLManager.mHasVertexBufferObject)
 	{
-		childSetEnabled("vbo", FALSE);
+		getChildView("vbo")->setEnabled(FALSE);
 	}
 
 	// if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
-	childSetEnabled("gamma", !gPipeline.canUseWindLightShaders());
-	childSetEnabled("(brightness, lower is brighter)", !gPipeline.canUseWindLightShaders());
-	childSetEnabled("fog", !gPipeline.canUseWindLightShaders());
+	getChildView("gamma")->setEnabled(!gPipeline.canUseWindLightShaders());
+	getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
+	getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
 
 }
 
@@ -130,9 +130,9 @@ void LLFloaterHardwareSettings::apply()
 {
 	// Anisotropic rendering
 	BOOL old_anisotropic = LLImageGL::sGlobalUseAnisotropic;
-	LLImageGL::sGlobalUseAnisotropic = childGetValue("ani");
+	LLImageGL::sGlobalUseAnisotropic = getChild<LLUICtrl>("ani")->getValue();
 
-	U32 fsaa = (U32) childGetValue("fsaa").asInteger();
+	U32 fsaa = (U32) getChild<LLUICtrl>("fsaa")->getValue().asInteger();
 	U32 old_fsaa = gSavedSettings.getU32("RenderFSAASamples");
 
 	BOOL logged_in = (LLStartUp::getStartupState() >= STATE_STARTED);
diff --git a/indra/newview/llfloaterhelpbrowser.cpp b/indra/newview/llfloaterhelpbrowser.cpp
index f3c6b286ab3..6aa1e924380 100644
--- a/indra/newview/llfloaterhelpbrowser.cpp
+++ b/indra/newview/llfloaterhelpbrowser.cpp
@@ -92,11 +92,11 @@ void LLFloaterHelpBrowser::handleMediaEvent(LLPluginClassMedia* self, EMediaEven
 		break;
 
 	case MEDIA_EVENT_NAVIGATE_BEGIN:
-		childSetText("status_text", getString("loading_text"));
+		getChild<LLUICtrl>("status_text")->setValue(getString("loading_text"));
 		break;
 		
 	case MEDIA_EVENT_NAVIGATE_COMPLETE:
-		childSetText("status_text", getString("done_text"));
+		getChild<LLUICtrl>("status_text")->setValue(getString("done_text"));
 		break;
 
 	default:
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index 8a20712ea85..aa5cb47a78f 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -109,7 +109,7 @@ BOOL LLFloaterImagePreview::postBuild()
 		PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD);
 	mPreviewImageRect.set(0.f, 1.f, 1.f, 0.f);
 
-	childHide("bad_image_text");
+	getChildView("bad_image_text")->setVisible(FALSE);
 
 	if (mRawImagep.notNull() && gAgent.getRegion() != NULL)
 	{
@@ -120,19 +120,19 @@ BOOL LLFloaterImagePreview::postBuild()
 		mSculptedPreview->setPreviewTarget(mRawImagep, 2.0f);
 
 		if (mRawImagep->getWidth() * mRawImagep->getHeight () <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF)
-			childEnable("lossless_check");
+			getChildView("lossless_check")->setEnabled(TRUE);
 	}
 	else
 	{
 		mAvatarPreview = NULL;
 		mSculptedPreview = NULL;
-		childShow("bad_image_text");
-		childDisable("clothing_type_combo");
-		childDisable("ok_btn");
+		getChildView("bad_image_text")->setVisible(TRUE);
+		getChildView("clothing_type_combo")->setEnabled(FALSE);
+		getChildView("ok_btn")->setEnabled(FALSE);
 
 		if(!mImageLoadError.empty())
 		{
-			childSetValue("bad_image_text",mImageLoadError.c_str());
+			getChild<LLUICtrl>("bad_image_text")->setValue(mImageLoadError.c_str());
 		}
 	}
 	
diff --git a/indra/newview/llfloaterinspect.cpp b/indra/newview/llfloaterinspect.cpp
index 13ca7638c52..4d4681a68dc 100644
--- a/indra/newview/llfloaterinspect.cpp
+++ b/indra/newview/llfloaterinspect.cpp
@@ -154,8 +154,8 @@ void LLFloaterInspect::onSelectObject()
 {
 	if(LLFloaterInspect::getSelectedUUID() != LLUUID::null)
 	{
-		childSetEnabled("button owner", true);
-		childSetEnabled("button creator", true);
+		getChildView("button owner")->setEnabled(true);
+		getChildView("button creator")->setEnabled(true);
 	}
 }
 
@@ -178,8 +178,8 @@ void LLFloaterInspect::refresh()
 	LLUUID creator_id;
 	std::string creator_name;
 	S32 pos = mObjectList->getScrollPos();
-	childSetEnabled("button owner", false);
-	childSetEnabled("button creator", false);
+	getChildView("button owner")->setEnabled(false);
+	getChildView("button creator")->setEnabled(false);
 	LLUUID selected_uuid;
 	S32 selected_index = mObjectList->getFirstSelectedIndex();
 	if(selected_index > -1)
diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index 78bc63ac8c4..9c7957603ed 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -58,11 +58,11 @@ LLFloaterJoystick::LLFloaterJoystick(const LLSD& data)
 void LLFloaterJoystick::draw()
 {
 	bool joystick_inited = LLViewerJoystick::getInstance()->isJoystickInitialized();
-	childSetEnabled("enable_joystick", joystick_inited);
-	childSetEnabled("joystick_type", joystick_inited);
+	getChildView("enable_joystick")->setEnabled(joystick_inited);
+	getChildView("joystick_type")->setEnabled(joystick_inited);
 	std::string desc = LLViewerJoystick::getInstance()->getDescription();
 	if (desc.empty()) desc = getString("NoDevice");
-	childSetText("joystick_type", desc);
+	getChild<LLUICtrl>("joystick_type")->setValue(desc);
 
 	LLViewerJoystick* joystick(LLViewerJoystick::getInstance());
 	for (U32 i = 0; i < 6; i++)
diff --git a/indra/newview/llfloaterlagmeter.cpp b/indra/newview/llfloaterlagmeter.cpp
index 100cbdb217f..9a2c34b40fa 100644
--- a/indra/newview/llfloaterlagmeter.cpp
+++ b/indra/newview/llfloaterlagmeter.cpp
@@ -329,9 +329,9 @@ void LLFloaterLagMeter::updateControls(bool shrink)
 		setRect(r);
 		reshape(mMaxWidth, getRect().getHeight());
 		
-		childSetText("client", getString("client_text_msg", mStringArgs) + ":");
-		childSetText("network", getString("network_text_msg",mStringArgs) + ":");
-		childSetText("server", getString("server_text_msg", mStringArgs) + ":");
+		getChild<LLUICtrl>("client")->setValue(getString("client_text_msg", mStringArgs) + ":");
+		getChild<LLUICtrl>("network")->setValue(getString("network_text_msg",mStringArgs) + ":");
+		getChild<LLUICtrl>("server")->setValue(getString("server_text_msg", mStringArgs) + ":");
 
 		// usually "<<"
 		button->setLabel( getString("smaller_label", mStringArgs) );
@@ -344,9 +344,9 @@ void LLFloaterLagMeter::updateControls(bool shrink)
 		setRect(r);
 		reshape(mMinWidth, getRect().getHeight());
 		
-		childSetText("client", getString("client_text_msg", mStringArgs) );
-		childSetText("network",getString("network_text_msg",mStringArgs) );
-		childSetText("server", getString("server_text_msg", mStringArgs) );
+		getChild<LLUICtrl>("client")->setValue(getString("client_text_msg", mStringArgs) );
+		getChild<LLUICtrl>("network")->setValue(getString("network_text_msg",mStringArgs) );
+		getChild<LLUICtrl>("server")->setValue(getString("server_text_msg", mStringArgs) );
 
 		// usually ">>"
 		button->setLabel( getString("bigger_label", mStringArgs) );
@@ -356,15 +356,15 @@ void LLFloaterLagMeter::updateControls(bool shrink)
 
 //	self->mClientText->setVisible(self->mShrunk);
 //	self->mClientCause->setVisible(self->mShrunk);
-//	self->childSetVisible("client_help", self->mShrunk);
+//	self->getChildView("client_help")->setVisible( self->mShrunk);
 
 //	self->mNetworkText->setVisible(self->mShrunk);
 //	self->mNetworkCause->setVisible(self->mShrunk);
-//	self->childSetVisible("network_help", self->mShrunk);
+//	self->getChildView("network_help")->setVisible( self->mShrunk);
 
 //	self->mServerText->setVisible(self->mShrunk);
 //	self->mServerCause->setVisible(self->mShrunk);
-//	self->childSetVisible("server_help", self->mShrunk);
+//	self->getChildView("server_help")->setVisible( self->mShrunk);
 
 //	self->mShrunk = !self->mShrunk;
 }
diff --git a/indra/newview/llfloaterlandholdings.cpp b/indra/newview/llfloaterlandholdings.cpp
index 19552ca9c93..3c8ee6eb9e5 100644
--- a/indra/newview/llfloaterlandholdings.cpp
+++ b/indra/newview/llfloaterlandholdings.cpp
@@ -145,8 +145,8 @@ void LLFloaterLandHoldings::refresh()
 		enable_btns = TRUE;
 	}
 
-	childSetEnabled("Teleport", enable_btns);
-	childSetEnabled("Show on Map", enable_btns);
+	getChildView("Teleport")->setEnabled(enable_btns);
+	getChildView("Show on Map")->setEnabled(enable_btns);
 
 	refreshAggregates();
 }
@@ -334,7 +334,7 @@ void LLFloaterLandHoldings::refreshAggregates()
 	S32 current_area = gStatusBar->getSquareMetersCommitted();
 	S32 available_area = gStatusBar->getSquareMetersLeft();
 
-	childSetTextArg("allowed_text", "[AREA]", llformat("%d",allowed_area));
-	childSetTextArg("current_text", "[AREA]", llformat("%d",current_area));
-	childSetTextArg("available_text", "[AREA]", llformat("%d",available_area));
+	getChild<LLUICtrl>("allowed_text")->setTextArg("[AREA]", llformat("%d",allowed_area));
+	getChild<LLUICtrl>("current_text")->setTextArg("[AREA]", llformat("%d",current_area));
+	getChild<LLUICtrl>("available_text")->setTextArg("[AREA]", llformat("%d",available_area));
 }
diff --git a/indra/newview/llfloatermediabrowser.cpp b/indra/newview/llfloatermediabrowser.cpp
index 5673550fbe4..5405de2f9ab 100644
--- a/indra/newview/llfloatermediabrowser.cpp
+++ b/indra/newview/llfloatermediabrowser.cpp
@@ -65,12 +65,12 @@ LLFloaterMediaBrowser::LLFloaterMediaBrowser(const LLSD& key)
 
 void LLFloaterMediaBrowser::draw()
 {
-	childSetEnabled("go", !mAddressCombo->getValue().asString().empty());
+	getChildView("go")->setEnabled(!mAddressCombo->getValue().asString().empty());
 	LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
 	if(parcel)
 	{
-		childSetVisible("parcel_owner_controls", LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_MEDIA));
-		childSetEnabled("assign", !mAddressCombo->getValue().asString().empty());
+		getChildView("parcel_owner_controls")->setVisible( LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_MEDIA));
+		getChildView("assign")->setEnabled(!mAddressCombo->getValue().asString().empty());
 	}
 	bool show_time_controls = false;
 	bool media_playing = false;
@@ -83,17 +83,17 @@ void LLFloaterMediaBrowser::draw()
 			media_playing = media_plugin->getStatus() == LLPluginClassMediaOwner::MEDIA_PLAYING;
 		}
 	}
-	childSetVisible("rewind", show_time_controls);
-	childSetVisible("play", show_time_controls && ! media_playing);
-	childSetVisible("pause", show_time_controls && media_playing);
-	childSetVisible("stop", show_time_controls);
-	childSetVisible("seek", show_time_controls);
+	getChildView("rewind")->setVisible( show_time_controls);
+	getChildView("play")->setVisible( show_time_controls && ! media_playing);
+	getChildView("pause")->setVisible( show_time_controls && media_playing);
+	getChildView("stop")->setVisible( show_time_controls);
+	getChildView("seek")->setVisible( show_time_controls);
 
-	childSetEnabled("play", ! media_playing);
-	childSetEnabled("stop", media_playing);
+	getChildView("play")->setEnabled(! media_playing);
+	getChildView("stop")->setEnabled(media_playing);
 
-	childSetEnabled("back", mBrowser->canNavigateBack());
-	childSetEnabled("forward", mBrowser->canNavigateForward());
+	getChildView("back")->setEnabled(mBrowser->canNavigateBack());
+	getChildView("forward")->setEnabled(mBrowser->canNavigateForward());
 
 	LLFloater::draw();
 }
@@ -173,8 +173,8 @@ void LLFloaterMediaBrowser::handleMediaEvent(LLPluginClassMedia* self, EMediaEve
 	else if(event == MEDIA_EVENT_NAVIGATE_COMPLETE)
 	{
 		// This is the event these flags are sent with.
-		childSetEnabled("back", self->getHistoryBackAvailable());
-		childSetEnabled("forward", self->getHistoryForwardAvailable());
+		getChildView("back")->setEnabled(self->getHistoryBackAvailable());
+		getChildView("forward")->setEnabled(self->getHistoryForwardAvailable());
 	}
 }
 void LLFloaterMediaBrowser::setCurrentURL(const std::string& url)
@@ -192,9 +192,9 @@ void LLFloaterMediaBrowser::setCurrentURL(const std::string& url)
 		LLURLHistory::removeURL("browser", mCurrentURL);
 		LLURLHistory::addURL("browser", mCurrentURL);
 	}
-	childSetEnabled("back", mBrowser->canNavigateBack());
-	childSetEnabled("forward", mBrowser->canNavigateForward());
-	childSetEnabled("reload", TRUE);
+	getChildView("back")->setEnabled(mBrowser->canNavigateBack());
+	getChildView("forward")->setEnabled(mBrowser->canNavigateForward());
+	getChildView("reload")->setEnabled(TRUE);
 }
 
 void LLFloaterMediaBrowser::onOpen(const LLSD& media_url)
diff --git a/indra/newview/llfloatermemleak.cpp b/indra/newview/llfloatermemleak.cpp
index 529bd68e037..51843c68336 100644
--- a/indra/newview/llfloatermemleak.cpp
+++ b/indra/newview/llfloatermemleak.cpp
@@ -64,7 +64,7 @@ LLFloaterMemLeak::LLFloaterMemLeak(const LLSD& key)
 BOOL LLFloaterMemLeak::postBuild(void) 
 {	
 	F32 a, b ;
-	a = childGetValue("leak_speed").asReal();
+	a = getChild<LLUICtrl>("leak_speed")->getValue().asReal();
 	if(a > (F32)(0xFFFFFFFF))
 	{
 		sMemLeakingSpeed = 0xFFFFFFFF ;
@@ -73,7 +73,7 @@ BOOL LLFloaterMemLeak::postBuild(void)
 	{
 		sMemLeakingSpeed = (U32)a ;
 	}
-	b = childGetValue("max_leak").asReal();
+	b = getChild<LLUICtrl>("max_leak")->getValue().asReal();
 	if(b > (F32)0xFFF)
 	{
 		sMaxLeakedMem = 0xFFFFFFFF ;
@@ -150,7 +150,7 @@ void LLFloaterMemLeak::idle()
 void LLFloaterMemLeak::onChangeLeakingSpeed()
 {
 	F32 tmp ;
-	tmp =childGetValue("leak_speed").asReal();
+	tmp =getChild<LLUICtrl>("leak_speed")->getValue().asReal();
 
 	if(tmp > (F32)0xFFFFFFFF)
 	{
@@ -167,7 +167,7 @@ void LLFloaterMemLeak::onChangeMaxMemLeaking()
 {
 
 	F32 tmp ;
-	tmp =childGetValue("max_leak").asReal();
+	tmp =getChild<LLUICtrl>("max_leak")->getValue().asReal();
 	if(tmp > (F32)0xFFF)
 	{
 		sMaxLeakedMem = 0xFFFFFFFF ;
@@ -206,22 +206,22 @@ void LLFloaterMemLeak::draw()
 	{
 		std::string bytes_string;
 		LLResMgr::getInstance()->getIntegerString(bytes_string, sTotalLeaked >> 10 );
-		childSetTextArg("total_leaked_label", "[SIZE]", bytes_string);
+		getChild<LLUICtrl>("total_leaked_label")->setTextArg("[SIZE]", bytes_string);
 	}
 	else
 	{
-		childSetTextArg("total_leaked_label", "[SIZE]", LLStringExplicit("0"));
+		getChild<LLUICtrl>("total_leaked_label")->setTextArg("[SIZE]", LLStringExplicit("0"));
 	}
 
 	if(sbAllocationFailed)
 	{
-		childSetTextArg("note_label_1", "[NOTE1]", LLStringExplicit("Memory leaking simulation stops. Reduce leaking speed or"));
-		childSetTextArg("note_label_2", "[NOTE2]", LLStringExplicit("increase max leaked memory, then press Start to continue."));
+		getChild<LLUICtrl>("note_label_1")->setTextArg("[NOTE1]", LLStringExplicit("Memory leaking simulation stops. Reduce leaking speed or"));
+		getChild<LLUICtrl>("note_label_2")->setTextArg("[NOTE2]", LLStringExplicit("increase max leaked memory, then press Start to continue."));
 	}
 	else
 	{
-		childSetTextArg("note_label_1", "[NOTE1]", LLStringExplicit(""));
-		childSetTextArg("note_label_2", "[NOTE2]", LLStringExplicit(""));
+		getChild<LLUICtrl>("note_label_1")->setTextArg("[NOTE1]", LLStringExplicit(""));
+		getChild<LLUICtrl>("note_label_2")->setTextArg("[NOTE2]", LLStringExplicit(""));
 	}
 
 	LLFloater::draw();
diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp
index 159ce41b790..dc9b883fb2e 100644
--- a/indra/newview/llfloaternamedesc.cpp
+++ b/indra/newview/llfloaternamedesc.cpp
@@ -105,7 +105,7 @@ BOOL LLFloaterNameDesc::postBuild()
 	r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );    
 
 	getChild<LLUICtrl>("name_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this));
-	childSetValue("name_form", LLSD(asset_name));
+	getChild<LLUICtrl>("name_form")->setValue(LLSD(asset_name));
 
 	LLLineEditor *NameEditor = getChild<LLLineEditor>("name_form");
 	if (NameEditor)
@@ -131,7 +131,7 @@ BOOL LLFloaterNameDesc::postBuild()
 	// Cancel button
 	getChild<LLUICtrl>("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnCancel, this));
 
-	childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d", LLGlobalEconomy::Singleton::getInstance()->getPriceUpload() ));
+	getChild<LLUICtrl>("ok_btn")->setLabelArg("[AMOUNT]", llformat("%d", LLGlobalEconomy::Singleton::getInstance()->getPriceUpload() ));
 	
 	setDefaultBtn("ok_btn");
 	
@@ -167,15 +167,15 @@ void LLFloaterNameDesc::doCommit()
 //-----------------------------------------------------------------------------
 void LLFloaterNameDesc::onBtnOK( )
 {
-	childDisable("ok_btn"); // don't allow inadvertent extra uploads
+	getChildView("ok_btn")->setEnabled(FALSE); // don't allow inadvertent extra uploads
 	
 	LLAssetStorage::LLStoreAssetCallback callback = NULL;
 	S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass).
 	void *nruserdata = NULL;
 	std::string display_name = LLStringUtil::null;
 	upload_new_resource(mFilenameAndPath, // file
-			    childGetValue("name_form").asString(), 
-			    childGetValue("description_form").asString(), 
+			    getChild<LLUICtrl>("name_form")->getValue().asString(), 
+			    getChild<LLUICtrl>("description_form")->getValue().asString(), 
 			    0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
 			    LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
 			    display_name, callback, expected_upload_cost, nruserdata);
diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp
index d39ed774914..a2a3d300e74 100644
--- a/indra/newview/llfloateropenobject.cpp
+++ b/indra/newview/llfloateropenobject.cpp
@@ -75,7 +75,7 @@ LLFloaterOpenObject::~LLFloaterOpenObject()
 // virtual
 BOOL LLFloaterOpenObject::postBuild()
 {
-	childSetTextArg("object_name", "[DESC]", std::string("Object") ); // *Note: probably do not want to translate this
+	getChild<LLUICtrl>("object_name")->setTextArg("[DESC]", std::string("Object") ); // *Note: probably do not want to translate this
 	mPanelInventoryObject = getChild<LLPanelObjectInventory>("object_contents");
 	
 	refresh();
@@ -119,9 +119,9 @@ void LLFloaterOpenObject::refresh()
 		enabled = FALSE;
 	}
 	
-	childSetTextArg("object_name", "[DESC]", name);
-	childSetEnabled("copy_to_inventory_button", enabled);
-	childSetEnabled("copy_and_wear_button", enabled);
+	getChild<LLUICtrl>("object_name")->setTextArg("[DESC]", name);
+	getChildView("copy_to_inventory_button")->setEnabled(enabled);
+	getChildView("copy_and_wear_button")->setEnabled(enabled);
 
 }
 
diff --git a/indra/newview/llfloaterpay.cpp b/indra/newview/llfloaterpay.cpp
index ba7526ccd51..c1640e26098 100644
--- a/indra/newview/llfloaterpay.cpp
+++ b/indra/newview/llfloaterpay.cpp
@@ -158,7 +158,7 @@ BOOL LLFloaterPay::postBuild()
 	mCallbackData.push_back(info);
 
 	childSetAction("fastpay 1",&LLFloaterPay::onGive,info);
-	childSetVisible("fastpay 1", FALSE);
+	getChildView("fastpay 1")->setVisible( FALSE);
 
 	mQuickPayButton[i] = getChild<LLButton>("fastpay 1");
 	mQuickPayInfo[i] = info;
@@ -168,7 +168,7 @@ BOOL LLFloaterPay::postBuild()
 	mCallbackData.push_back(info);
 
 	childSetAction("fastpay 5",&LLFloaterPay::onGive,info);
-	childSetVisible("fastpay 5", FALSE);
+	getChildView("fastpay 5")->setVisible( FALSE);
 
 	mQuickPayButton[i] = getChild<LLButton>("fastpay 5");
 	mQuickPayInfo[i] = info;
@@ -178,7 +178,7 @@ BOOL LLFloaterPay::postBuild()
 	mCallbackData.push_back(info);
 
 	childSetAction("fastpay 10",&LLFloaterPay::onGive,info);
-	childSetVisible("fastpay 10", FALSE);
+	getChildView("fastpay 10")->setVisible( FALSE);
 
 	mQuickPayButton[i] = getChild<LLButton>("fastpay 10");
 	mQuickPayInfo[i] = info;
@@ -188,14 +188,14 @@ BOOL LLFloaterPay::postBuild()
 	mCallbackData.push_back(info);
 
 	childSetAction("fastpay 20",&LLFloaterPay::onGive,info);
-	childSetVisible("fastpay 20", FALSE);
+	getChildView("fastpay 20")->setVisible( FALSE);
 
 	mQuickPayButton[i] = getChild<LLButton>("fastpay 20");
 	mQuickPayInfo[i] = info;
 	++i;
 
 
-	childSetVisible("amount text", FALSE);	
+	getChildView("amount text")->setVisible( FALSE);	
 
 	std::string last_amount;
 	if(sLastAmount > 0)
@@ -203,19 +203,19 @@ BOOL LLFloaterPay::postBuild()
 		last_amount = llformat("%d", sLastAmount);
 	}
 
-	childSetVisible("amount", FALSE);
+	getChildView("amount")->setVisible( FALSE);
 
 	getChild<LLLineEditor>("amount")->setKeystrokeCallback(&LLFloaterPay::onKeystroke, this);
-	childSetText("amount", last_amount);
-	childSetPrevalidate("amount", LLTextValidate::validateNonNegativeS32);
+	getChild<LLUICtrl>("amount")->setValue(last_amount);
+	getChild<LLLineEditor>("amount")->setPrevalidate(LLTextValidate::validateNonNegativeS32);
 
 	info = new LLGiveMoneyInfo(this, 0);
 	mCallbackData.push_back(info);
 
 	childSetAction("pay btn",&LLFloaterPay::onGive,info);
 	setDefaultBtn("pay btn");
-	childSetVisible("pay btn", FALSE);
-	childSetEnabled("pay btn", (sLastAmount > 0));
+	getChildView("pay btn")->setVisible( FALSE);
+	getChildView("pay btn")->setEnabled((sLastAmount > 0));
 
 	childSetAction("cancel btn",&LLFloaterPay::onCancel,this);
 
@@ -249,27 +249,27 @@ void LLFloaterPay::processPayPriceReply(LLMessageSystem* msg, void **userdata)
 		
 		if (PAY_PRICE_HIDE == price)
 		{
-			self->childSetVisible("amount", FALSE);
-			self->childSetVisible("pay btn", FALSE);
-			self->childSetVisible("amount text", FALSE);
+			self->getChildView("amount")->setVisible( FALSE);
+			self->getChildView("pay btn")->setVisible( FALSE);
+			self->getChildView("amount text")->setVisible( FALSE);
 		}
 		else if (PAY_PRICE_DEFAULT == price)
 		{			
-			self->childSetVisible("amount", TRUE);
-			self->childSetVisible("pay btn", TRUE);
-			self->childSetVisible("amount text", TRUE);
+			self->getChildView("amount")->setVisible( TRUE);
+			self->getChildView("pay btn")->setVisible( TRUE);
+			self->getChildView("amount text")->setVisible( TRUE);
 		}
 		else
 		{
 			// PAY_PRICE_HIDE and PAY_PRICE_DEFAULT are negative values
 			// So we take the absolute value here after we have checked for those cases
 			
-			self->childSetVisible("amount", TRUE);
-			self->childSetVisible("pay btn", TRUE);
-			self->childSetEnabled("pay btn", TRUE);
-			self->childSetVisible("amount text", TRUE);
+			self->getChildView("amount")->setVisible( TRUE);
+			self->getChildView("pay btn")->setVisible( TRUE);
+			self->getChildView("pay btn")->setEnabled(TRUE);
+			self->getChildView("amount text")->setVisible( TRUE);
 
-			self->childSetText("amount", llformat("%d", llabs(price)));
+			self->getChild<LLUICtrl>("amount")->setValue(llformat("%d", llabs(price)));
 		}
 
 		S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_ButtonData);
@@ -292,7 +292,7 @@ void LLFloaterPay::processPayPriceReply(LLMessageSystem* msg, void **userdata)
 				self->mQuickPayButton[i]->setLabelUnselected(button_str);
 				self->mQuickPayButton[i]->setVisible(TRUE);
 				self->mQuickPayInfo[i]->mAmount = pay_button;
-				self->childSetVisible("fastpay text",TRUE);
+				self->getChildView("fastpay text")->setVisible(TRUE);
 
 				if ( pay_button > max_pay_amount )
 				{
@@ -399,7 +399,7 @@ void LLFloaterPay::payViaObject(money_callback callback, LLSafeHandle<LLObjectSe
 	BOOL is_group = FALSE;
 	node->mPermissions->getOwnership(owner_id, is_group);
 	
-	floater->childSetText("object_name_text",node->mName);
+	floater->getChild<LLUICtrl>("object_name_text")->setValue(node->mName);
 
 	floater->finishPayUI(owner_id, is_group);
 }
@@ -415,11 +415,11 @@ void LLFloaterPay::payDirectly(money_callback callback,
 	floater->setCallback(callback);
 	floater->mObjectSelection = NULL;
 	
-	floater->childSetVisible("amount", TRUE);
-	floater->childSetVisible("pay btn", TRUE);
-	floater->childSetVisible("amount text", TRUE);
+	floater->getChildView("amount")->setVisible( TRUE);
+	floater->getChildView("pay btn")->setVisible( TRUE);
+	floater->getChildView("amount text")->setVisible( TRUE);
 
-	floater->childSetVisible("fastpay text",TRUE);
+	floater->getChildView("fastpay text")->setVisible(TRUE);
 	for(S32 i=0;i<MAX_PAY_BUTTONS;++i)
 	{
 		floater->mQuickPayButton[i]->setVisible(TRUE);
@@ -434,7 +434,7 @@ void LLFloaterPay::finishPayUI(const LLUUID& target_id, BOOL is_group)
 
 	// Make sure the amount field has focus
 
-	childSetFocus("amount", TRUE);
+	getChild<LLUICtrl>("amount")->setFocus( TRUE);
 	
 	LLLineEditor* amount = getChild<LLLineEditor>("amount");
 	amount->selectAll();
@@ -455,8 +455,8 @@ void LLFloaterPay::onCacheOwnerName(const LLUUID& owner_id,
 		setTitle(getString("payee_resident"));
 	}
 	
-	childSetTextArg("payee_name", "[FIRST]", firstname);
-	childSetTextArg("payee_name", "[LAST]", lastname);
+	getChild<LLUICtrl>("payee_name")->setTextArg("[FIRST]", firstname);
+	getChild<LLUICtrl>("payee_name")->setTextArg("[LAST]", lastname);
 }
 
 // static
@@ -476,8 +476,8 @@ void LLFloaterPay::onKeystroke(LLLineEditor*, void* data)
 	if(self)
 	{
 		// enable the Pay button when amount is non-empty and positive, disable otherwise
-		std::string amtstr = self->childGetText("amount");
-		self->childSetEnabled("pay btn", !amtstr.empty() && atoi(amtstr.c_str()) > 0);
+		std::string amtstr = self->getChild<LLUICtrl>("amount")->getValue().asString();
+		self->getChildView("pay btn")->setEnabled(!amtstr.empty() && atoi(amtstr.c_str()) > 0);
 	}
 }
 
@@ -500,7 +500,7 @@ void LLFloaterPay::give(S32 amount)
 		// text field.
 		if(amount == 0)
 		{
-			amount = atoi(childGetText("amount").c_str());
+			amount = atoi(getChild<LLUICtrl>("amount")->getValue().asString().c_str());
 		}
 		sLastAmount = amount;
 
diff --git a/indra/newview/llfloaterpostcard.cpp b/indra/newview/llfloaterpostcard.cpp
index 8da44e20350..dc4553ef96f 100644
--- a/indra/newview/llfloaterpostcard.cpp
+++ b/indra/newview/llfloaterpostcard.cpp
@@ -99,16 +99,16 @@ BOOL LLFloaterPostcard::postBuild()
 	childSetAction("cancel_btn", onClickCancel, this);
 	childSetAction("send_btn", onClickSend, this);
 
-	childDisable("from_form");
+	getChildView("from_form")->setEnabled(FALSE);
 
 	std::string name_string;
 	LLAgentUI::buildFullname(name_string);
-	childSetValue("name_form", LLSD(name_string));
+	getChild<LLUICtrl>("name_form")->setValue(LLSD(name_string));
 
 	// For the first time a user focusess to .the msg box, all text will be selected.
 	getChild<LLUICtrl>("msg_form")->setFocusChangedCallback(boost::bind(onMsgFormFocusRecieved, _1, this));
 	
-	childSetFocus("to_form", TRUE);
+	getChild<LLUICtrl>("to_form")->setFocus(TRUE);
 
     return TRUE;
 }
@@ -215,8 +215,8 @@ void LLFloaterPostcard::onClickSend(void* data)
 	{
 		LLFloaterPostcard *self = (LLFloaterPostcard *)data;
 
-		std::string from(self->childGetValue("from_form").asString());
-		std::string to(self->childGetValue("to_form").asString());
+		std::string from(self->getChild<LLUICtrl>("from_form")->getValue().asString());
+		std::string to(self->getChild<LLUICtrl>("to_form")->getValue().asString());
 		
 		boost::regex emailFormat("[A-Za-z0-9.%+-_]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}(,[ \t]*[A-Za-z0-9.%+-_]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})*");
 		
@@ -232,7 +232,7 @@ void LLFloaterPostcard::onClickSend(void* data)
 			return;
 		}
 
-		std::string subject(self->childGetValue("subject_form").asString());
+		std::string subject(self->getChild<LLUICtrl>("subject_form")->getValue().asString());
 		if(subject.empty() || !self->mHasFirstMsgFocus)
 		{
 			LLNotificationsUtil::add("PromptMissingSubjMsg", LLSD(), LLSD(), boost::bind(&LLFloaterPostcard::missingSubjMsgAlertCallback, self, _1, _2));
@@ -275,11 +275,11 @@ void LLFloaterPostcard::uploadCallback(const LLUUID& asset_id, void *user_data,
 		msg->addUUID("SessionID", gAgent.getSessionID());
 		msg->addUUID("AssetID", self->mAssetID);
 		msg->addVector3d("PosGlobal", self->mPosTakenGlobal);
-		msg->addString("To", self->childGetValue("to_form").asString());
-		msg->addString("From", self->childGetValue("from_form").asString());
-		msg->addString("Name", self->childGetValue("name_form").asString());
-		msg->addString("Subject", self->childGetValue("subject_form").asString());
-		msg->addString("Msg", self->childGetValue("msg_form").asString());
+		msg->addString("To", self->getChild<LLUICtrl>("to_form")->getValue().asString());
+		msg->addString("From", self->getChild<LLUICtrl>("from_form")->getValue().asString());
+		msg->addString("Name", self->getChild<LLUICtrl>("name_form")->getValue().asString());
+		msg->addString("Subject", self->getChild<LLUICtrl>("subject_form")->getValue().asString());
+		msg->addString("Msg", self->getChild<LLUICtrl>("msg_form")->getValue().asString());
 		msg->addBOOL("AllowPublish", FALSE);
 		msg->addBOOL("MaturePublish", FALSE);
 		gAgent.sendReliableMessage();
@@ -296,11 +296,11 @@ void LLFloaterPostcard::updateUserInfo(const std::string& email)
 		 iter != inst_list.end(); ++iter)
 	{
 		LLFloater* instance = *iter;
-		const std::string& text = instance->childGetValue("from_form").asString();
+		const std::string& text = instance->getChild<LLUICtrl>("from_form")->getValue().asString();
 		if (text.empty())
 		{
 			// there's no text in this field yet, pre-populate
-			instance->childSetValue("from_form", LLSD(email));
+			instance->getChild<LLUICtrl>("from_form")->setValue(LLSD(email));
 		}
 	}
 }
@@ -325,17 +325,17 @@ bool LLFloaterPostcard::missingSubjMsgAlertCallback(const LLSD& notification, co
 	if(0 == option)
 	{
 		// User clicked OK
-		if((childGetValue("subject_form").asString()).empty())
+		if((getChild<LLUICtrl>("subject_form")->getValue().asString()).empty())
 		{
 			// Stuff the subject back into the form.
-			childSetValue("subject_form", getString("default_subject"));
+			getChild<LLUICtrl>("subject_form")->setValue(getString("default_subject"));
 		}
 
 		if(!mHasFirstMsgFocus)
 		{
 			// The user never switched focus to the messagee window. 
 			// Using the default string.
-			childSetValue("msg_form", getString("default_message"));
+			getChild<LLUICtrl>("msg_form")->setValue(getString("default_message"));
 		}
 
 		sendPostcard();
@@ -357,11 +357,11 @@ void LLFloaterPostcard::sendPostcard()
 		LLSD body = LLSD::emptyMap();
 		// the capability already encodes: agent ID, region ID
 		body["pos-global"] = mPosTakenGlobal.getValue();
-		body["to"] = childGetValue("to_form").asString();
-		body["from"] = childGetValue("from_form").asString();
-		body["name"] = childGetValue("name_form").asString();
-		body["subject"] = childGetValue("subject_form").asString();
-		body["msg"] = childGetValue("msg_form").asString();
+		body["to"] = getChild<LLUICtrl>("to_form")->getValue().asString();
+		body["from"] = getChild<LLUICtrl>("from_form")->getValue().asString();
+		body["name"] = getChild<LLUICtrl>("name_form")->getValue().asString();
+		body["subject"] = getChild<LLUICtrl>("subject_form")->getValue().asString();
+		body["msg"] = getChild<LLUICtrl>("msg_form")->getValue().asString();
 		LLHTTPClient::post(url, body, new LLSendPostcardResponder(body, mAssetID, LLAssetType::AT_IMAGE_JPEG));
 	} 
 	else
diff --git a/indra/newview/llfloaterpostprocess.cpp b/indra/newview/llfloaterpostprocess.cpp
index 87a12d3d66c..06c0a94afab 100644
--- a/indra/newview/llfloaterpostprocess.cpp
+++ b/indra/newview/llfloaterpostprocess.cpp
@@ -212,25 +212,25 @@ void LLFloaterPostProcess::syncMenu()
 	comboBox->selectByValue(gPostProcess->getSelectedEffect());
 
 	/// Sync Color Filter Menu
-	childSetValue("ColorFilterToggle", gPostProcess->tweaks.useColorFilter());
-	//childSetValue("ColorFilterGamma", gPostProcess->tweaks.gamma());
-	childSetValue("ColorFilterBrightness", gPostProcess->tweaks.brightness());
-	childSetValue("ColorFilterSaturation", gPostProcess->tweaks.saturation());
-	childSetValue("ColorFilterContrast", gPostProcess->tweaks.contrast());
-	childSetValue("ColorFilterBaseR", gPostProcess->tweaks.contrastBaseR());
-	childSetValue("ColorFilterBaseG", gPostProcess->tweaks.contrastBaseG());
-	childSetValue("ColorFilterBaseB", gPostProcess->tweaks.contrastBaseB());
-	childSetValue("ColorFilterBaseI", gPostProcess->tweaks.contrastBaseIntensity());
+	getChild<LLUICtrl>("ColorFilterToggle")->setValue(gPostProcess->tweaks.useColorFilter());
+	//getChild<LLUICtrl>("ColorFilterGamma")->setValue(gPostProcess->tweaks.gamma());
+	getChild<LLUICtrl>("ColorFilterBrightness")->setValue(gPostProcess->tweaks.brightness());
+	getChild<LLUICtrl>("ColorFilterSaturation")->setValue(gPostProcess->tweaks.saturation());
+	getChild<LLUICtrl>("ColorFilterContrast")->setValue(gPostProcess->tweaks.contrast());
+	getChild<LLUICtrl>("ColorFilterBaseR")->setValue(gPostProcess->tweaks.contrastBaseR());
+	getChild<LLUICtrl>("ColorFilterBaseG")->setValue(gPostProcess->tweaks.contrastBaseG());
+	getChild<LLUICtrl>("ColorFilterBaseB")->setValue(gPostProcess->tweaks.contrastBaseB());
+	getChild<LLUICtrl>("ColorFilterBaseI")->setValue(gPostProcess->tweaks.contrastBaseIntensity());
 	
 	/// Sync Night Vision Menu
-	childSetValue("NightVisionToggle", gPostProcess->tweaks.useNightVisionShader());
-	childSetValue("NightVisionBrightMult", gPostProcess->tweaks.brightMult());
-	childSetValue("NightVisionNoiseSize", gPostProcess->tweaks.noiseSize());
-	childSetValue("NightVisionNoiseStrength", gPostProcess->tweaks.noiseStrength());
+	getChild<LLUICtrl>("NightVisionToggle")->setValue(gPostProcess->tweaks.useNightVisionShader());
+	getChild<LLUICtrl>("NightVisionBrightMult")->setValue(gPostProcess->tweaks.brightMult());
+	getChild<LLUICtrl>("NightVisionNoiseSize")->setValue(gPostProcess->tweaks.noiseSize());
+	getChild<LLUICtrl>("NightVisionNoiseStrength")->setValue(gPostProcess->tweaks.noiseStrength());
 
 	/// Sync Bloom Menu
-	childSetValue("BloomToggle", LLSD(gPostProcess->tweaks.useBloomShader()));
-	childSetValue("BloomExtract", gPostProcess->tweaks.extractLow());
-	childSetValue("BloomSize", gPostProcess->tweaks.bloomWidth());
-	childSetValue("BloomStrength", gPostProcess->tweaks.bloomStrength());
+	getChild<LLUICtrl>("BloomToggle")->setValue(LLSD(gPostProcess->tweaks.useBloomShader()));
+	getChild<LLUICtrl>("BloomExtract")->setValue(gPostProcess->tweaks.extractLow());
+	getChild<LLUICtrl>("BloomSize")->setValue(gPostProcess->tweaks.bloomWidth());
+	getChild<LLUICtrl>("BloomStrength")->setValue(gPostProcess->tweaks.bloomStrength());
 }
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index ab32c2f6bfd..7791c037d38 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -144,7 +144,7 @@ LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key)
 BOOL LLVoiceSetKeyDialog::postBuild()
 {
 	childSetAction("Cancel", onCancel, this);
-	childSetFocus("Cancel");
+	getChild<LLUICtrl>("Cancel")->setFocus(TRUE);
 	
 	gFocusMgr.setKeystrokesOnly(TRUE);
 	
@@ -330,7 +330,7 @@ BOOL LLFloaterPreference::postBuild()
 		tabcontainer->selectFirstTab();
 
 	std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
-	childSetText("cache_location", cache_location);
+	getChild<LLUICtrl>("cache_location")->setValue(cache_location);
 
 	// if floater is opened before login set default localized busy message
 	if (LLStartUp::getStartupState() < STATE_STARTED)
@@ -426,28 +426,28 @@ void LLFloaterPreference::apply()
 	fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
 	
 	std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
-	childSetText("cache_location", cache_location);		
+	getChild<LLUICtrl>("cache_location")->setValue(cache_location);		
 	
-	LLViewerMedia::setCookiesEnabled(childGetValue("cookies_enabled"));
+	LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
 	
 	if(hasChild("web_proxy_enabled") &&hasChild("web_proxy_editor") && hasChild("web_proxy_port"))
 	{
-		bool proxy_enable = childGetValue("web_proxy_enabled");
-		std::string proxy_address = childGetValue("web_proxy_editor");
-		int proxy_port = childGetValue("web_proxy_port");
+		bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue();
+		std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue();
+		int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue();
 		LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port);
 	}
 	
 //	LLWString busy_response = utf8str_to_wstring(getChild<LLUICtrl>("busy_response")->getValue().asString());
 //	LLWStringUtil::replaceTabsWithSpaces(busy_response, 4);
 
-	gSavedSettings.setBOOL("PlainTextChatHistory", childGetValue("plain_text_chat_history").asBoolean());
+	gSavedSettings.setBOOL("PlainTextChatHistory", getChild<LLUICtrl>("plain_text_chat_history")->getValue().asBoolean());
 	
 	if(mGotPersonalInfo)
 	{ 
 //		gSavedSettings.setString("BusyModeResponse2", std::string(wstring_to_utf8str(busy_response)));
-		bool new_im_via_email = childGetValue("send_im_to_email").asBoolean();
-		bool new_hide_online = childGetValue("online_visibility").asBoolean();		
+		bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean();
+		bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean();		
 	
 		if((new_im_via_email != mOriginalIMViaEmail)
 			||(new_hide_online != mOriginalHideOnlineStatus))
@@ -545,13 +545,13 @@ void LLFloaterPreference::onOpen(const LLSD& key)
 				maturity_list->deleteItems(LLSD(SIM_ACCESS_ADULT));
 			}
 		}
-		childSetVisible("maturity_desired_combobox", true);
-		childSetVisible("maturity_desired_textbox", false);
+		getChildView("maturity_desired_combobox")->setVisible( true);
+		getChildView("maturity_desired_textbox")->setVisible( false);
 	}
 	else
 	{
-		childSetText("maturity_desired_textbox",  maturity_combo->getSelectedItemLabel());
-		childSetVisible("maturity_desired_combobox", false);
+		getChild<LLUICtrl>("maturity_desired_textbox")->setValue(maturity_combo->getSelectedItemLabel());
+		getChildView("maturity_desired_combobox")->setVisible( false);
 	}
 
 	// Display selected maturity icons.
@@ -930,7 +930,7 @@ void LLFloaterPreference::refreshEnabledState()
 	// now turn off any features that are unavailable
 	disableUnavailableSettings();
 
-	childSetEnabled ("block_list", LLLoginInstance::getInstance()->authSuccess());
+	getChildView("block_list")->setEnabled(LLLoginInstance::getInstance()->authSuccess());
 }
 
 void LLFloaterPreference::disableUnavailableSettings()
@@ -1101,7 +1101,7 @@ void LLFloaterPreference::onClickSetKey()
 
 void LLFloaterPreference::setKey(KEY key)
 {
-	childSetValue("modifier_combo", LLKeyboard::stringFromKey(key));
+	getChild<LLUICtrl>("modifier_combo")->setValue(LLKeyboard::stringFromKey(key));
 	// update the control right away since we no longer wait for apply
 	getChild<LLUICtrl>("modifier_combo")->onCommit();
 }
@@ -1214,46 +1214,46 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im
 	if(visibility == VISIBILITY_DEFAULT)
 	{
 		mOriginalHideOnlineStatus = false;
-		childEnable("online_visibility"); 	 
+		getChildView("online_visibility")->setEnabled(TRUE); 	 
 	}
 	else if(visibility == VISIBILITY_HIDDEN)
 	{
 		mOriginalHideOnlineStatus = true;
-		childEnable("online_visibility"); 	 
+		getChildView("online_visibility")->setEnabled(TRUE); 	 
 	}
 	else
 	{
 		mOriginalHideOnlineStatus = true;
 	}
 	
-	childEnable("include_im_in_chat_history");
-	childEnable("show_timestamps_check_im");
-	childEnable("friends_online_notify_checkbox");
-	
-	childSetValue("online_visibility", mOriginalHideOnlineStatus); 	 
-	childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility);
-	childEnable("send_im_to_email");
-	childSetValue("send_im_to_email", im_via_email);
-	childEnable("plain_text_chat_history");
-	childSetValue("plain_text_chat_history", gSavedSettings.getBOOL("PlainTextChatHistory"));
-	childEnable("log_instant_messages");
-//	childEnable("log_chat");
-//	childEnable("busy_response");
-//	childEnable("log_instant_messages_timestamp");
-//	childEnable("log_chat_timestamp");
-	childEnable("log_chat_IM");
-	childEnable("log_date_timestamp");
-	
-//	childSetText("busy_response", gSavedSettings.getString("BusyModeResponse2"));
-	
-	childEnable("log_nearby_chat");
-	childEnable("log_instant_messages");
-	childEnable("show_timestamps_check_im");
-	childDisable("log_path_string");// LineEditor becomes readonly in this case.
-	childEnable("log_path_button");
+	getChildView("include_im_in_chat_history")->setEnabled(TRUE);
+	getChildView("show_timestamps_check_im")->setEnabled(TRUE);
+	getChildView("friends_online_notify_checkbox")->setEnabled(TRUE);
+	
+	getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus); 	 
+	getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility);
+	getChildView("send_im_to_email")->setEnabled(TRUE);
+	getChild<LLUICtrl>("send_im_to_email")->setValue(im_via_email);
+	getChildView("plain_text_chat_history")->setEnabled(TRUE);
+	getChild<LLUICtrl>("plain_text_chat_history")->setValue(gSavedSettings.getBOOL("PlainTextChatHistory"));
+	getChildView("log_instant_messages")->setEnabled(TRUE);
+//	getChildView("log_chat")->setEnabled(TRUE);
+//	getChildView("busy_response")->setEnabled(TRUE);
+//	getChildView("log_instant_messages_timestamp")->setEnabled(TRUE);
+//	getChildView("log_chat_timestamp")->setEnabled(TRUE);
+	getChildView("log_chat_IM")->setEnabled(TRUE);
+	getChildView("log_date_timestamp")->setEnabled(TRUE);
+	
+//	getChild<LLUICtrl>("busy_response")->setValue(gSavedSettings.getString("BusyModeResponse2"));
+	
+	getChildView("log_nearby_chat")->setEnabled(TRUE);
+	getChildView("log_instant_messages")->setEnabled(TRUE);
+	getChildView("show_timestamps_check_im")->setEnabled(TRUE);
+	getChildView("log_path_string")->setEnabled(FALSE);// LineEditor becomes readonly in this case.
+	getChildView("log_path_button")->setEnabled(TRUE);
 	
 	std::string display_email(email);
-	childSetText("email_address",display_email);
+	getChild<LLUICtrl>("email_address")->setValue(display_email);
 
 }
 
@@ -1352,8 +1352,8 @@ BOOL LLPanelPreference::postBuild()
 	if(hasChild("voice_unavailable"))
 	{
 		BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice");
-		childSetVisible("voice_unavailable", voice_disabled);
-		childSetVisible("enable_voice_check", !voice_disabled);
+		getChildView("voice_unavailable")->setVisible( voice_disabled);
+		getChildView("enable_voice_check")->setVisible( !voice_disabled);
 	}
 	
 	//////////////////////PanelSkins ///////////////////
@@ -1373,8 +1373,8 @@ BOOL LLPanelPreference::postBuild()
 
 	if(hasChild("online_visibility") && hasChild("send_im_to_email"))
 	{
-		childSetText("email_address",getString("log_in_to_change") );
-//		childSetText("busy_response", getString("log_in_to_change"));		
+		getChild<LLUICtrl>("email_address")->setValue(getString("log_in_to_change") );
+//		getChild<LLUICtrl>("busy_response")->setValue(getString("log_in_to_change"));		
 	}
 	
 	//////////////////////PanelPrivacy ///////////////////
@@ -1398,9 +1398,9 @@ BOOL LLPanelPreference::postBuild()
 	if (hasChild("modifier_combo"))
 	{
 		//localizing if push2talk button is set to middle mouse
-		if (MIDDLE_MOUSE_CV == childGetValue("modifier_combo").asString())
+		if (MIDDLE_MOUSE_CV == getChild<LLUICtrl>("modifier_combo")->getValue().asString())
 		{
-			childSetValue("modifier_combo", getString("middle_mouse"));
+			getChild<LLUICtrl>("modifier_combo")->setValue(getString("middle_mouse"));
 		}
 	}
 
diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp
index 30b654de24e..b6a98bdada8 100644
--- a/indra/newview/llfloaterproperties.cpp
+++ b/indra/newview/llfloaterproperties.cpp
@@ -130,9 +130,9 @@ BOOL LLFloaterProperties::postBuild()
 {
 	// build the UI
 	// item name & description
-	childSetPrevalidate("LabelItemName",&LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("LabelItemName")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 	getChild<LLUICtrl>("LabelItemName")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitName,this));
-	childSetPrevalidate("LabelItemDesc",&LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("LabelItemDesc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 	getChild<LLUICtrl>("LabelItemDesc")->setCommitCallback(boost::bind(&LLFloaterProperties:: onCommitDescription, this));
 	// Creator information
 	getChild<LLUICtrl>("BtnCreator")->setCommitCallback(boost::bind(&LLFloaterProperties::onClickCreator,this));
@@ -201,7 +201,7 @@ void LLFloaterProperties::refresh()
 		};
 		for(size_t t=0; t<LL_ARRAY_SIZE(enableNames); ++t)
 		{
-			childSetEnabled(enableNames[t],false);
+			getChildView(enableNames[t])->setEnabled(false);
 		}
 		const char* hideNames[]={
 			"BaseMaskDebug",
@@ -212,7 +212,7 @@ void LLFloaterProperties::refresh()
 		};
 		for(size_t t=0; t<LL_ARRAY_SIZE(hideNames); ++t)
 		{
-			childSetVisible(hideNames[t],false);
+			getChildView(hideNames[t])->setVisible(false);
 		}
 	}
 }
@@ -265,13 +265,13 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 											   GP_OBJECT_MANIPULATE)
 		&& is_obj_modify && is_complete;
 
-	childSetEnabled("LabelItemNameTitle",TRUE);
-	childSetEnabled("LabelItemName",is_modifiable && !is_calling_card); // for now, don't allow rename of calling cards
-	childSetText("LabelItemName",item->getName());
-	childSetEnabled("LabelItemDescTitle",TRUE);
-	childSetEnabled("LabelItemDesc",is_modifiable);
-	childSetVisible("IconLocked",!is_modifiable);
-	childSetText("LabelItemDesc",item->getDescription());
+	getChildView("LabelItemNameTitle")->setEnabled(TRUE);
+	getChildView("LabelItemName")->setEnabled(is_modifiable && !is_calling_card); // for now, don't allow rename of calling cards
+	getChild<LLUICtrl>("LabelItemName")->setValue(item->getName());
+	getChildView("LabelItemDescTitle")->setEnabled(TRUE);
+	getChildView("LabelItemDesc")->setEnabled(is_modifiable);
+	getChildView("IconLocked")->setVisible(!is_modifiable);
+	getChild<LLUICtrl>("LabelItemDesc")->setValue(item->getDescription());
 
 	//////////////////
 	// CREATOR NAME //
@@ -283,17 +283,17 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 	{
 		std::string name;
 		gCacheName->getFullName(item->getCreatorUUID(), name);
-		childSetEnabled("BtnCreator",TRUE);
-		childSetEnabled("LabelCreatorTitle",TRUE);
-		childSetEnabled("LabelCreatorName",TRUE);
-		childSetText("LabelCreatorName",name);
+		getChildView("BtnCreator")->setEnabled(TRUE);
+		getChildView("LabelCreatorTitle")->setEnabled(TRUE);
+		getChildView("LabelCreatorName")->setEnabled(TRUE);
+		getChild<LLUICtrl>("LabelCreatorName")->setValue(name);
 	}
 	else
 	{
-		childSetEnabled("BtnCreator",FALSE);
-		childSetEnabled("LabelCreatorTitle",FALSE);
-		childSetEnabled("LabelCreatorName",FALSE);
-		childSetText("LabelCreatorName",getString("unknown"));
+		getChildView("BtnCreator")->setEnabled(FALSE);
+		getChildView("LabelCreatorTitle")->setEnabled(FALSE);
+		getChildView("LabelCreatorName")->setEnabled(FALSE);
+		getChild<LLUICtrl>("LabelCreatorName")->setValue(getString("unknown"));
 	}
 
 	////////////////
@@ -310,17 +310,17 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 		{
 			gCacheName->getFullName(perm.getOwner(), name);
 		}
-		childSetEnabled("BtnOwner",TRUE);
-		childSetEnabled("LabelOwnerTitle",TRUE);
-		childSetEnabled("LabelOwnerName",TRUE);
-		childSetText("LabelOwnerName",name);
+		getChildView("BtnOwner")->setEnabled(TRUE);
+		getChildView("LabelOwnerTitle")->setEnabled(TRUE);
+		getChildView("LabelOwnerName")->setEnabled(TRUE);
+		getChild<LLUICtrl>("LabelOwnerName")->setValue(name);
 	}
 	else
 	{
-		childSetEnabled("BtnOwner",FALSE);
-		childSetEnabled("LabelOwnerTitle",FALSE);
-		childSetEnabled("LabelOwnerName",FALSE);
-		childSetText("LabelOwnerName",getString("public"));
+		getChildView("BtnOwner")->setEnabled(FALSE);
+		getChildView("LabelOwnerTitle")->setEnabled(FALSE);
+		getChildView("LabelOwnerName")->setEnabled(FALSE);
+		getChild<LLUICtrl>("LabelOwnerName")->setValue(getString("public"));
 	}
 	
 	//////////////////
@@ -330,7 +330,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 	time_t time_utc = item->getCreationDate();
 	if (0 == time_utc)
 	{
-		childSetText("LabelAcquiredDate",getString("unknown"));
+		getChild<LLUICtrl>("LabelAcquiredDate")->setValue(getString("unknown"));
 	}
 	else
 	{
@@ -338,7 +338,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 		LLSD substitution;
 		substitution["datetime"] = (S32) time_utc;
 		LLStringUtil::format (timeStr, substitution);
-		childSetText ("LabelAcquiredDate", timeStr);
+		getChild<LLUICtrl>("LabelAcquiredDate")->setValue(timeStr);
 	}
 
 	///////////////////////
@@ -346,11 +346,11 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 	///////////////////////
 	if(can_agent_manipulate)
 	{
-		childSetText("OwnerLabel",getString("you_can"));
+		getChild<LLUICtrl>("OwnerLabel")->setValue(getString("you_can"));
 	}
 	else
 	{
-		childSetText("OwnerLabel",getString("owner_can"));
+		getChild<LLUICtrl>("OwnerLabel")->setValue(getString("owner_can"));
 	}
 
 	U32 base_mask		= perm.getMaskBase();
@@ -359,13 +359,13 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 	U32 everyone_mask	= perm.getMaskEveryone();
 	U32 next_owner_mask	= perm.getMaskNextOwner();
 
-	childSetEnabled("OwnerLabel",TRUE);
-	childSetEnabled("CheckOwnerModify",FALSE);
-	childSetValue("CheckOwnerModify",LLSD((BOOL)(owner_mask & PERM_MODIFY)));
-	childSetEnabled("CheckOwnerCopy",FALSE);
-	childSetValue("CheckOwnerCopy",LLSD((BOOL)(owner_mask & PERM_COPY)));
-	childSetEnabled("CheckOwnerTransfer",FALSE);
-	childSetValue("CheckOwnerTransfer",LLSD((BOOL)(owner_mask & PERM_TRANSFER)));
+	getChildView("OwnerLabel")->setEnabled(TRUE);
+	getChildView("CheckOwnerModify")->setEnabled(FALSE);
+	getChild<LLUICtrl>("CheckOwnerModify")->setValue(LLSD((BOOL)(owner_mask & PERM_MODIFY)));
+	getChildView("CheckOwnerCopy")->setEnabled(FALSE);
+	getChild<LLUICtrl>("CheckOwnerCopy")->setValue(LLSD((BOOL)(owner_mask & PERM_COPY)));
+	getChildView("CheckOwnerTransfer")->setEnabled(FALSE);
+	getChild<LLUICtrl>("CheckOwnerTransfer")->setValue(LLSD((BOOL)(owner_mask & PERM_TRANSFER)));
 
 	///////////////////////
 	// DEBUG PERMISSIONS //
@@ -389,39 +389,39 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 
 		perm_string = "B: ";
 		perm_string += mask_to_string(base_mask);
-		childSetText("BaseMaskDebug",perm_string);
-		childSetVisible("BaseMaskDebug",TRUE);
+		getChild<LLUICtrl>("BaseMaskDebug")->setValue(perm_string);
+		getChildView("BaseMaskDebug")->setVisible(TRUE);
 		
 		perm_string = "O: ";
 		perm_string += mask_to_string(owner_mask);
-		childSetText("OwnerMaskDebug",perm_string);
-		childSetVisible("OwnerMaskDebug",TRUE);
+		getChild<LLUICtrl>("OwnerMaskDebug")->setValue(perm_string);
+		getChildView("OwnerMaskDebug")->setVisible(TRUE);
 		
 		perm_string = "G";
 		perm_string += overwrite_group ? "*: " : ": ";
 		perm_string += mask_to_string(group_mask);
-		childSetText("GroupMaskDebug",perm_string);
-		childSetVisible("GroupMaskDebug",TRUE);
+		getChild<LLUICtrl>("GroupMaskDebug")->setValue(perm_string);
+		getChildView("GroupMaskDebug")->setVisible(TRUE);
 		
 		perm_string = "E";
 		perm_string += overwrite_everyone ? "*: " : ": ";
 		perm_string += mask_to_string(everyone_mask);
-		childSetText("EveryoneMaskDebug",perm_string);
-		childSetVisible("EveryoneMaskDebug",TRUE);
+		getChild<LLUICtrl>("EveryoneMaskDebug")->setValue(perm_string);
+		getChildView("EveryoneMaskDebug")->setVisible(TRUE);
 		
 		perm_string = "N";
 		perm_string += slam_perm ? "*: " : ": ";
 		perm_string += mask_to_string(next_owner_mask);
-		childSetText("NextMaskDebug",perm_string);
-		childSetVisible("NextMaskDebug",TRUE);
+		getChild<LLUICtrl>("NextMaskDebug")->setValue(perm_string);
+		getChildView("NextMaskDebug")->setVisible(TRUE);
 	}
 	else
 	{
-		childSetVisible("BaseMaskDebug",FALSE);
-		childSetVisible("OwnerMaskDebug",FALSE);
-		childSetVisible("GroupMaskDebug",FALSE);
-		childSetVisible("EveryoneMaskDebug",FALSE);
-		childSetVisible("NextMaskDebug",FALSE);
+		getChildView("BaseMaskDebug")->setVisible(FALSE);
+		getChildView("OwnerMaskDebug")->setVisible(FALSE);
+		getChildView("GroupMaskDebug")->setVisible(FALSE);
+		getChildView("EveryoneMaskDebug")->setVisible(FALSE);
+		getChildView("NextMaskDebug")->setVisible(FALSE);
 	}
 
 	/////////////
@@ -431,18 +431,18 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 	// Check for ability to change values.
 	if (is_link || cannot_restrict_permissions)
 	{
-		childSetEnabled("CheckShareWithGroup",FALSE);
-		childSetEnabled("CheckEveryoneCopy",FALSE);
+		getChildView("CheckShareWithGroup")->setEnabled(FALSE);
+		getChildView("CheckEveryoneCopy")->setEnabled(FALSE);
 	}
 	else if (is_obj_modify && can_agent_manipulate)
 	{
-		childSetEnabled("CheckShareWithGroup",TRUE);
-		childSetEnabled("CheckEveryoneCopy",(owner_mask & PERM_COPY) && (owner_mask & PERM_TRANSFER));
+		getChildView("CheckShareWithGroup")->setEnabled(TRUE);
+		getChildView("CheckEveryoneCopy")->setEnabled((owner_mask & PERM_COPY) && (owner_mask & PERM_TRANSFER));
 	}
 	else
 	{
-		childSetEnabled("CheckShareWithGroup",FALSE);
-		childSetEnabled("CheckEveryoneCopy",FALSE);
+		getChildView("CheckShareWithGroup")->setEnabled(FALSE);
+		getChildView("CheckEveryoneCopy")->setEnabled(FALSE);
 	}
 
 	// Set values.
@@ -452,7 +452,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 
 	if (is_group_copy && is_group_modify && is_group_move)
 	{
-		childSetValue("CheckShareWithGroup",LLSD((BOOL)TRUE));
+		getChild<LLUICtrl>("CheckShareWithGroup")->setValue(LLSD((BOOL)TRUE));
 
 		LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
 		if(ctl)
@@ -462,7 +462,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 	}
 	else if (!is_group_copy && !is_group_modify && !is_group_move)
 	{
-		childSetValue("CheckShareWithGroup",LLSD((BOOL)FALSE));
+		getChild<LLUICtrl>("CheckShareWithGroup")->setValue(LLSD((BOOL)FALSE));
 		LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
 		if(ctl)
 		{
@@ -479,7 +479,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 		}
 	}
 	
-	childSetValue("CheckEveryoneCopy",LLSD((BOOL)(everyone_mask & PERM_COPY)));
+	getChild<LLUICtrl>("CheckEveryoneCopy")->setValue(LLSD((BOOL)(everyone_mask & PERM_COPY)));
 
 	///////////////
 	// SALE INFO //
@@ -491,40 +491,40 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 	if (is_obj_modify && can_agent_sell 
 		&& gAgent.allowOperation(PERM_TRANSFER, perm, GP_OBJECT_MANIPULATE))
 	{
-		childSetEnabled("SaleLabel",is_complete);
-		childSetEnabled("CheckPurchase",is_complete);
+		getChildView("SaleLabel")->setEnabled(is_complete);
+		getChildView("CheckPurchase")->setEnabled(is_complete);
 
-		childSetEnabled("NextOwnerLabel",TRUE);
-		childSetEnabled("CheckNextOwnerModify",(base_mask & PERM_MODIFY) && !cannot_restrict_permissions);
-		childSetEnabled("CheckNextOwnerCopy",(base_mask & PERM_COPY) && !cannot_restrict_permissions);
-		childSetEnabled("CheckNextOwnerTransfer",(next_owner_mask & PERM_COPY) && !cannot_restrict_permissions);
+		getChildView("NextOwnerLabel")->setEnabled(TRUE);
+		getChildView("CheckNextOwnerModify")->setEnabled((base_mask & PERM_MODIFY) && !cannot_restrict_permissions);
+		getChildView("CheckNextOwnerCopy")->setEnabled((base_mask & PERM_COPY) && !cannot_restrict_permissions);
+		getChildView("CheckNextOwnerTransfer")->setEnabled((next_owner_mask & PERM_COPY) && !cannot_restrict_permissions);
 
-		childSetEnabled("RadioSaleType",is_complete && is_for_sale);
-		childSetEnabled("TextPrice",is_complete && is_for_sale);
-		childSetEnabled("Edit Cost",is_complete && is_for_sale);
+		getChildView("RadioSaleType")->setEnabled(is_complete && is_for_sale);
+		getChildView("TextPrice")->setEnabled(is_complete && is_for_sale);
+		getChildView("Edit Cost")->setEnabled(is_complete && is_for_sale);
 	}
 	else
 	{
-		childSetEnabled("SaleLabel",FALSE);
-		childSetEnabled("CheckPurchase",FALSE);
+		getChildView("SaleLabel")->setEnabled(FALSE);
+		getChildView("CheckPurchase")->setEnabled(FALSE);
 
-		childSetEnabled("NextOwnerLabel",FALSE);
-		childSetEnabled("CheckNextOwnerModify",FALSE);
-		childSetEnabled("CheckNextOwnerCopy",FALSE);
-		childSetEnabled("CheckNextOwnerTransfer",FALSE);
+		getChildView("NextOwnerLabel")->setEnabled(FALSE);
+		getChildView("CheckNextOwnerModify")->setEnabled(FALSE);
+		getChildView("CheckNextOwnerCopy")->setEnabled(FALSE);
+		getChildView("CheckNextOwnerTransfer")->setEnabled(FALSE);
 
-		childSetEnabled("RadioSaleType",FALSE);
-		childSetEnabled("TextPrice",FALSE);
-		childSetEnabled("Edit Cost",FALSE);
+		getChildView("RadioSaleType")->setEnabled(FALSE);
+		getChildView("TextPrice")->setEnabled(FALSE);
+		getChildView("Edit Cost")->setEnabled(FALSE);
 	}
 
 	// Set values.
-	childSetValue("CheckPurchase", is_for_sale);
-	childSetEnabled("combobox sale copy", is_for_sale);
-	childSetEnabled("Edit Cost", is_for_sale);
-	childSetValue("CheckNextOwnerModify",LLSD(BOOL(next_owner_mask & PERM_MODIFY)));
-	childSetValue("CheckNextOwnerCopy",LLSD(BOOL(next_owner_mask & PERM_COPY)));
-	childSetValue("CheckNextOwnerTransfer",LLSD(BOOL(next_owner_mask & PERM_TRANSFER)));
+	getChild<LLUICtrl>("CheckPurchase")->setValue(is_for_sale);
+	getChildView("combobox sale copy")->setEnabled(is_for_sale);
+	getChildView("Edit Cost")->setEnabled(is_for_sale);
+	getChild<LLUICtrl>("CheckNextOwnerModify")->setValue(LLSD(BOOL(next_owner_mask & PERM_MODIFY)));
+	getChild<LLUICtrl>("CheckNextOwnerCopy")->setValue(LLSD(BOOL(next_owner_mask & PERM_COPY)));
+	getChild<LLUICtrl>("CheckNextOwnerTransfer")->setValue(LLSD(BOOL(next_owner_mask & PERM_TRANSFER)));
 
 	LLRadioGroup* radioSaleType = getChild<LLRadioGroup>("RadioSaleType");
 	if (is_for_sale)
@@ -532,12 +532,12 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
 		radioSaleType->setSelectedIndex((S32)sale_info.getSaleType() - 1);
 		S32 numerical_price;
 		numerical_price = sale_info.getSalePrice();
-		childSetText("Edit Cost",llformat("%d",numerical_price));
+		getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",numerical_price));
 	}
 	else
 	{
 		radioSaleType->setSelectedIndex(-1);
-		childSetText("Edit Cost",llformat("%d",0));
+		getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",0));
 	}
 }
 
@@ -758,10 +758,10 @@ void LLFloaterProperties::updateSaleInfo()
 	LLSaleInfo sale_info(item->getSaleInfo());
 	if(!gAgent.allowOperation(PERM_TRANSFER, item->getPermissions(), GP_OBJECT_SET_SALE))
 	{
-		childSetValue("CheckPurchase",LLSD((BOOL)FALSE));
+		getChild<LLUICtrl>("CheckPurchase")->setValue(LLSD((BOOL)FALSE));
 	}
 
-	if((BOOL)childGetValue("CheckPurchase"))
+	if((BOOL)getChild<LLUICtrl>("CheckPurchase")->getValue())
 	{
 		// turn on sale info
 		LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_COPY;
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp
index f7c8855bf65..230d4be85b8 100644
--- a/indra/newview/llfloaterreporter.cpp
+++ b/indra/newview/llfloaterreporter.cpp
@@ -128,7 +128,7 @@ BOOL LLFloaterReporter::postBuild()
 {
 	LLSLURL slurl;
 	LLAgentUI::buildSLURL(slurl);
-	childSetText("abuse_location_edit", slurl.getSLURLString());
+	getChild<LLUICtrl>("abuse_location_edit")->setValue(slurl.getSLURLString());
 
 	enableControls(TRUE);
 
@@ -137,7 +137,7 @@ BOOL LLFloaterReporter::postBuild()
 	LLViewerRegion *regionp = gAgent.getRegion();
 	if (regionp)
 	{
-		childSetText("sim_field", regionp->getName());
+		getChild<LLUICtrl>("sim_field")->setValue(regionp->getName());
 		pos -= regionp->getOriginGlobal();
 	}
 	setPosBox(pos);
@@ -148,13 +148,13 @@ BOOL LLFloaterReporter::postBuild()
 	setVisible(TRUE);
 
 	// Default text to be blank
-	childSetText("object_name", LLStringUtil::null);
-	childSetText("owner_name", LLStringUtil::null);
+	getChild<LLUICtrl>("object_name")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("owner_name")->setValue(LLStringUtil::null);
 	mOwnerName = LLStringUtil::null;
 
-	childSetFocus("summary_edit");
+	getChild<LLUICtrl>("summary_edit")->setFocus(TRUE);
 
-	mDefaultSummary = childGetText("details_edit");
+	mDefaultSummary = getChild<LLUICtrl>("details_edit")->getValue().asString();
 
 	// send a message and ask for information about this region - 
 	// result comes back in processRegionInfo(..)
@@ -184,7 +184,7 @@ BOOL LLFloaterReporter::postBuild()
 	// grab the user's name
 	std::string fullname;
 	LLAgentUI::buildFullname(fullname);
-	childSetText("reporter_field", fullname);
+	getChild<LLUICtrl>("reporter_field")->setValue(fullname);
 	
 	center();
 
@@ -212,22 +212,22 @@ LLFloaterReporter::~LLFloaterReporter()
 // virtual
 void LLFloaterReporter::draw()
 {
-	childSetEnabled("screen_check", TRUE );
+	getChildView("screen_check")->setEnabled(TRUE );
 
 	LLFloater::draw();
 }
 
 void LLFloaterReporter::enableControls(BOOL enable)
 {
-	childSetEnabled("category_combo", enable);
-	childSetEnabled("chat_check", enable);
-	childSetEnabled("screen_check",	enable);
-	childDisable("screenshot");
-	childSetEnabled("pick_btn",		enable);
-	childSetEnabled("summary_edit",	enable);
-	childSetEnabled("details_edit",	enable);
-	childSetEnabled("send_btn",		enable);
-	childSetEnabled("cancel_btn",	enable);
+	getChildView("category_combo")->setEnabled(enable);
+	getChildView("chat_check")->setEnabled(enable);
+	getChildView("screen_check")->setEnabled(enable);
+	getChildView("screenshot")->setEnabled(FALSE);
+	getChildView("pick_btn")->setEnabled(enable);
+	getChildView("summary_edit")->setEnabled(enable);
+	getChildView("details_edit")->setEnabled(enable);
+	getChildView("send_btn")->setEnabled(enable);
+	getChildView("cancel_btn")->setEnabled(enable);
 }
 
 void LLFloaterReporter::getObjectInfo(const LLUUID& object_id)
@@ -259,7 +259,7 @@ void LLFloaterReporter::getObjectInfo(const LLUUID& object_id)
 			LLViewerRegion *regionp = objectp->getRegion();
 			if (regionp)
 			{
-				childSetText("sim_field", regionp->getName());
+				getChild<LLUICtrl>("sim_field")->setValue(regionp->getName());
 				LLVector3d global_pos;
 				global_pos.setVec(objectp->getPositionRegion());
 				setPosBox(global_pos);
@@ -313,7 +313,7 @@ void LLFloaterReporter::callbackAvatarID(const std::vector<std::string>& names,
 {
 	if (ids.empty() || names.empty()) return;
 
-	childSetText("abuser_name_edit", names[0] );
+	getChild<LLUICtrl>("abuser_name_edit")->setValue(names[0] );
 
 	mAbuserID = ids[0];
 
@@ -328,9 +328,9 @@ void LLFloaterReporter::setFromAvatar(const LLUUID& avatar_id, const std::string
 
 	std::string avatar_link =
 	  LLSLURL("agent", mObjectID, "inspect").getSLURLString();
-	childSetText("owner_name", avatar_link);
-	childSetText("object_name", avatar_name);
-	childSetText("abuser_name_edit", avatar_name);
+	getChild<LLUICtrl>("owner_name")->setValue(avatar_link);
+	getChild<LLUICtrl>("object_name")->setValue(avatar_name);
+	getChild<LLUICtrl>("abuser_name_edit")->setValue(avatar_name);
 }
 
 // static
@@ -354,9 +354,9 @@ void LLFloaterReporter::onClickSend(void *userdata)
 			if ( ! self->mCopyrightWarningSeen )
 			{
 
-				std::string details_lc = self->childGetText("details_edit");
+				std::string details_lc = self->getChild<LLUICtrl>("details_edit")->getValue().asString();
 				LLStringUtil::toLower( details_lc );
-				std::string summary_lc = self->childGetText("summary_edit");
+				std::string summary_lc = self->getChild<LLUICtrl>("summary_edit")->getValue().asString();
 				LLStringUtil::toLower( summary_lc );
 				if ( details_lc.find( "copyright" ) != std::string::npos ||
 					summary_lc.find( "copyright" ) != std::string::npos  ||
@@ -387,10 +387,10 @@ void LLFloaterReporter::onClickSend(void *userdata)
 		}
 		else
 		{
-			if(self->childGetValue("screen_check"))
+			if(self->getChild<LLUICtrl>("screen_check")->getValue())
 			{
-				self->childDisable("send_btn");
-				self->childDisable("cancel_btn");
+				self->getChildView("send_btn")->setEnabled(FALSE);
+				self->getChildView("cancel_btn")->setEnabled(FALSE);
 				// the callback from uploading the image calls sendReportViaLegacy()
 				self->uploadImage();
 			}
@@ -428,8 +428,8 @@ void LLFloaterReporter::onClickObjPicker(void *userdata)
 	LLToolObjPicker::getInstance()->setExitCallback(LLFloaterReporter::closePickTool, self);
 	LLToolMgr::getInstance()->setTransientTool(LLToolObjPicker::getInstance());
 	self->mPicking = TRUE;
-	self->childSetText("object_name", LLStringUtil::null);
-	self->childSetText("owner_name", LLStringUtil::null);
+	self->getChild<LLUICtrl>("object_name")->setValue(LLStringUtil::null);
+	self->getChild<LLUICtrl>("owner_name")->setValue(LLStringUtil::null);
 	self->mOwnerName = LLStringUtil::null;
 	LLButton* pick_btn = self->getChild<LLButton>("pick_btn");
 	if (pick_btn) pick_btn->setToggleState(TRUE);
@@ -475,7 +475,7 @@ void LLFloaterReporter::show(const LLUUID& object_id, const std::string& avatar_
 	// grab the user's name
 	std::string fullname;
 	LLAgentUI::buildFullname(fullname);
-	f->childSetText("reporter_field", fullname);
+	f->getChild<LLUICtrl>("reporter_field")->setValue(fullname);
 
 	if (avatar_name.empty())
 		// Request info for this object
@@ -504,11 +504,11 @@ void LLFloaterReporter::showFromAvatar(const LLUUID& avatar_id, const std::strin
 
 void LLFloaterReporter::setPickedObjectProperties(const std::string& object_name, const std::string& owner_name, const LLUUID owner_id)
 {
-	childSetText("object_name", object_name);
+	getChild<LLUICtrl>("object_name")->setValue(object_name);
 	std::string owner_link =
 		LLSLURL("agent", owner_id, "inspect").getSLURLString();
-	childSetText("owner_name", owner_link);
-	childSetText("abuser_name_edit", owner_name);
+	getChild<LLUICtrl>("owner_name")->setValue(owner_link);
+	getChild<LLUICtrl>("abuser_name_edit")->setValue(owner_name);
 	mAbuserID = owner_id;
 	mOwnerName = owner_name;
 }
@@ -517,7 +517,7 @@ void LLFloaterReporter::setPickedObjectProperties(const std::string& object_name
 bool LLFloaterReporter::validateReport()
 {
 	// Ensure user selected a category from the list
-	LLSD category_sd = childGetValue("category_combo");
+	LLSD category_sd = getChild<LLUICtrl>("category_combo")->getValue();
 	U8 category = (U8)category_sd.asInteger();
 	if (category == 0)
 	{
@@ -526,32 +526,32 @@ bool LLFloaterReporter::validateReport()
 	}
 
 
-	if ( childGetText("abuser_name_edit").empty() )
+	if ( getChild<LLUICtrl>("abuser_name_edit")->getValue().asString().empty() )
 	{
 		LLNotificationsUtil::add("HelpReportAbuseAbuserNameEmpty");
 		return false;
 	};
 
-	if ( childGetText("abuse_location_edit").empty() )
+	if ( getChild<LLUICtrl>("abuse_location_edit")->getValue().asString().empty() )
 	{
 		LLNotificationsUtil::add("HelpReportAbuseAbuserLocationEmpty");
 		return false;
 	};
 
-	if ( childGetText("abuse_location_edit").empty() )
+	if ( getChild<LLUICtrl>("abuse_location_edit")->getValue().asString().empty() )
 	{
 		LLNotificationsUtil::add("HelpReportAbuseAbuserLocationEmpty");
 		return false;
 	};
 
 
-	if ( childGetText("summary_edit").empty() )
+	if ( getChild<LLUICtrl>("summary_edit")->getValue().asString().empty() )
 	{
 		LLNotificationsUtil::add("HelpReportAbuseSummaryEmpty");
 		return false;
 	};
 
-	if ( childGetText("details_edit") == mDefaultSummary )
+	if ( getChild<LLUICtrl>("details_edit")->getValue().asString() == mDefaultSummary )
 	{
 		LLNotificationsUtil::add("HelpReportAbuseDetailsEmpty");
 		return false;
@@ -597,17 +597,17 @@ LLSD LLFloaterReporter::gatherReport()
 
 	summary << ""
 		<< " |" << regionp->getName() << "|"								// region reporter is currently in.
-		<< " (" << childGetText("abuse_location_edit") << ")"				// region abuse occured in (freeform text - no LLRegionPicker tool)
+		<< " (" << getChild<LLUICtrl>("abuse_location_edit")->getValue().asString() << ")"				// region abuse occured in (freeform text - no LLRegionPicker tool)
 		<< " [" << category_name << "] "									// updated category
-		<< " {" << childGetText("abuser_name_edit") << "} "					// name of abuse entered in report (chosen using LLAvatarPicker)
-		<< " \"" << childGetValue("summary_edit").asString() << "\"";		// summary as entered
+		<< " {" << getChild<LLUICtrl>("abuser_name_edit")->getValue().asString() << "} "					// name of abuse entered in report (chosen using LLAvatarPicker)
+		<< " \"" << getChild<LLUICtrl>("summary_edit")->getValue().asString() << "\"";		// summary as entered
 
 
 	std::ostringstream details;
 
 	details << "V" << LLVersionInfo::getVersion() << std::endl << std::endl;	// client version moved to body of email for abuse reports
 
-	std::string object_name = childGetText("object_name");
+	std::string object_name = getChild<LLUICtrl>("object_name")->getValue().asString();
 	if (!object_name.empty() && !mOwnerName.empty())
 	{
 		details << "Object: " << object_name << "\n";
@@ -615,10 +615,10 @@ LLSD LLFloaterReporter::gatherReport()
 	}
 
 
-	details << "Abuser name: " << childGetText("abuser_name_edit") << " \n";
-	details << "Abuser location: " << childGetText("abuse_location_edit") << " \n";
+	details << "Abuser name: " << getChild<LLUICtrl>("abuser_name_edit")->getValue().asString() << " \n";
+	details << "Abuser location: " << getChild<LLUICtrl>("abuse_location_edit")->getValue().asString() << " \n";
 
-	details << childGetValue("details_edit").asString();
+	details << getChild<LLUICtrl>("details_edit")->getValue().asString();
 
 	std::string version_string;
 	version_string = llformat(
@@ -632,14 +632,14 @@ LLSD LLFloaterReporter::gatherReport()
 	// only send a screenshot ID if we're asked to and the email is 
 	// going to LL - Estate Owners cannot see the screenshot asset
 	LLUUID screenshot_id = LLUUID::null;
-	if (childGetValue("screen_check"))
+	if (getChild<LLUICtrl>("screen_check")->getValue())
 	{
-		screenshot_id = childGetValue("screenshot");
+		screenshot_id = getChild<LLUICtrl>("screenshot")->getValue();
 	};
 
 	LLSD report = LLSD::emptyMap();
 	report["report-type"] = (U8) mReportType;
-	report["category"] = childGetValue("category_combo");
+	report["category"] = getChild<LLUICtrl>("category_combo")->getValue();
 	report["position"] = mPosition.getValue();
 	report["check-flags"] = (U8)0; // this is not used
 	report["screenshot-id"] = screenshot_id;
@@ -721,7 +721,7 @@ class LLUserReportResponder : public LLHTTPClient::Responder
 
 void LLFloaterReporter::sendReportViaCaps(std::string url, std::string sshot_url, const LLSD& report)
 {
-	if(childGetValue("screen_check").asBoolean() && !sshot_url.empty())
+	if(getChild<LLUICtrl>("screen_check")->getValue().asBoolean() && !sshot_url.empty())
 	{
 		// try to upload screenshot
 		LLHTTPClient::post(sshot_url, report, new LLUserReportScreenshotResponder(report, 
@@ -853,7 +853,7 @@ void LLFloaterReporter::setPosBox(const LLVector3d &pos)
 		mPosition.mV[VX],
 		mPosition.mV[VY],
 		mPosition.mV[VZ]);
-	childSetText("pos_field", pos_string);
+	getChild<LLUICtrl>("pos_field")->setValue(pos_string);
 }
 
 // void LLFloaterReporter::setDescription(const std::string& description, LLMeanCollisionData *mcd)
@@ -861,7 +861,7 @@ void LLFloaterReporter::setPosBox(const LLVector3d &pos)
 // 	LLFloaterReporter *self = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter");
 // 	if (self)
 // 	{
-// 		self->childSetText("details_edit", description);
+// 		self->getChild<LLUICtrl>("details_edit")->setValue(description);
 
 // 		for_each(self->mMCDList.begin(), self->mMCDList.end(), DeletePointer());
 // 		self->mMCDList.clear();
diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp
index 0a5499b1666..e0f646349e3 100644
--- a/indra/newview/llfloaterscriptlimits.cpp
+++ b/indra/newview/llfloaterscriptlimits.cpp
@@ -298,7 +298,7 @@ void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref)
 			LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel");
 			if(panel_memory)
 			{
-				panel_memory->childSetValue("loading_text", LLSD(std::string("")));
+				panel_memory->getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string("")));
 
 				LLButton* btn = panel_memory->getChild<LLButton>("refresh_list_btn");
 				if(btn)
@@ -495,7 +495,7 @@ void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content_ref)
 			LLPanelScriptLimitsAttachment* panel = (LLPanelScriptLimitsAttachment*)tab->getChild<LLPanel>("script_limits_my_avatar_panel");
 			if(panel)
 			{
-				panel->childSetValue("loading_text", LLSD(std::string("")));
+				panel->getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string("")));
 
 				LLButton* btn = panel->getChild<LLButton>("refresh_list_btn");
 				if(btn)
@@ -560,12 +560,12 @@ void LLPanelScriptLimitsRegionMemory::processParcelInfo(const LLParcelData& parc
 	if(!getLandScriptResources())
 	{
 		std::string msg_error = LLTrans::getString("ScriptLimitsRequestError");
-		childSetValue("loading_text", LLSD(msg_error));
+		getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_error));
 	}
 	else
 	{
 		std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting");
-		childSetValue("loading_text", LLSD(msg_waiting));
+		getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting));
 	}
 }
 
@@ -585,7 +585,7 @@ void LLPanelScriptLimitsRegionMemory::setParcelID(const LLUUID& parcel_id)
 	else
 	{
 		std::string msg_error = LLTrans::getString("ScriptLimitsRequestError");
-		childSetValue("loading_text", LLSD(msg_error));
+		getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_error));
 	}
 }
 
@@ -641,7 +641,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content)
 	LLStringUtil::format_map_t args_parcels;
 	args_parcels["[PARCELS]"] = llformat ("%d", number_parcels);
 	std::string msg_parcels = LLTrans::getString("ScriptLimitsParcelsOwned", args_parcels);
-	childSetValue("parcels_listed", LLSD(msg_parcels));
+	getChild<LLUICtrl>("parcels_listed")->setValue(LLSD(msg_parcels));
 
 	uuid_vec_t names_requested;
 
@@ -818,7 +818,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionSummary(LLSD content)
 		args_parcel_memory["[MAX]"] = llformat ("%d", mParcelMemoryMax);
 		args_parcel_memory["[AVAILABLE]"] = llformat ("%d", parcel_memory_available);
 		std::string msg_parcel_memory = LLTrans::getString("ScriptLimitsMemoryUsed", args_parcel_memory);
-		childSetValue("memory_used", LLSD(msg_parcel_memory));
+		getChild<LLUICtrl>("memory_used")->setValue(LLSD(msg_parcel_memory));
 	}
 
 	if((mParcelURLsUsed >= 0) && (mParcelURLsMax >= 0))
@@ -830,7 +830,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionSummary(LLSD content)
 		args_parcel_urls["[MAX]"] = llformat ("%d", mParcelURLsMax);
 		args_parcel_urls["[AVAILABLE]"] = llformat ("%d", parcel_urls_available);
 		std::string msg_parcel_urls = LLTrans::getString("ScriptLimitsURLsUsed", args_parcel_urls);
-		childSetValue("urls_used", LLSD(msg_parcel_urls));
+		getChild<LLUICtrl>("urls_used")->setValue(LLSD(msg_parcel_urls));
 	}
 }
 
@@ -841,7 +841,7 @@ BOOL LLPanelScriptLimitsRegionMemory::postBuild()
 	childSetAction("return_btn", onClickReturn, this);
 		
 	std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting");
-	childSetValue("loading_text", LLSD(msg_waiting));
+	getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting));
 
 	LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list");
 	if(!list)
@@ -866,7 +866,7 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain()
 	LLFloaterLand* instance = LLFloaterReg::getTypedInstance<LLFloaterLand>("about_land");
 	if(!instance)
 	{
-		childSetValue("loading_text", LLSD(std::string("")));
+		getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string("")));
 		//might have to do parent post build here
 		//if not logic below could use early outs
 		return FALSE;
@@ -885,7 +885,7 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain()
 		if(region_id != current_region_id)
 		{
 			std::string msg_wrong_region = LLTrans::getString("ScriptLimitsRequestWrongRegion");
-			childSetValue("loading_text", LLSD(msg_wrong_region));
+			getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_wrong_region));
 			return FALSE;
 		}
 		
@@ -914,13 +914,13 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain()
 					<< " does not support RemoteParcelRequest" << llendl;
 					
 			std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError");
-			childSetValue("loading_text", LLSD(msg_waiting));
+			getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting));
 		}
 	}
 	else
 	{
 		std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestNoParcelSelected");
-		childSetValue("loading_text", LLSD(msg_waiting));
+		getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting));
 	}
 
 	return LLPanelScriptLimitsInfo::postBuild();
@@ -942,9 +942,9 @@ void LLPanelScriptLimitsRegionMemory::clearList()
 	
 	LLStringUtil::format_map_t args_parcel_memory;
 	std::string msg_empty_string("");
-	childSetValue("memory_used", LLSD(msg_empty_string));
-	childSetValue("urls_used", LLSD(msg_empty_string));
-	childSetValue("parcels_listed", LLSD(msg_empty_string));
+	getChild<LLUICtrl>("memory_used")->setValue(LLSD(msg_empty_string));
+	getChild<LLUICtrl>("urls_used")->setValue(LLSD(msg_empty_string));
+	getChild<LLUICtrl>("parcels_listed")->setValue(LLSD(msg_empty_string));
 
 	mObjectListItems.clear();
 }
@@ -1213,7 +1213,7 @@ void LLPanelScriptLimitsAttachment::setAttachmentDetails(LLSD content)
 	
 	setAttachmentSummary(content);
 
-	childSetValue("loading_text", LLSD(std::string("")));
+	getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string("")));
 
 	LLButton* btn = getChild<LLButton>("refresh_list_btn");
 	if(btn)
@@ -1227,7 +1227,7 @@ BOOL LLPanelScriptLimitsAttachment::postBuild()
 	childSetAction("refresh_list_btn", onClickRefresh, this);
 		
 	std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting");
-	childSetValue("loading_text", LLSD(msg_waiting));
+	getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting));
 	return requestAttachmentDetails();
 }
 
@@ -1241,7 +1241,7 @@ void LLPanelScriptLimitsAttachment::clearList()
 	}
 
 	std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting");
-	childSetValue("loading_text", LLSD(msg_waiting));
+	getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting));
 }
 
 void LLPanelScriptLimitsAttachment::setAttachmentSummary(LLSD content)
@@ -1291,7 +1291,7 @@ void LLPanelScriptLimitsAttachment::setAttachmentSummary(LLSD content)
 		args_attachment_memory["[MAX]"] = llformat ("%d", mAttachmentMemoryMax);
 		args_attachment_memory["[AVAILABLE]"] = llformat ("%d", attachment_memory_available);
 		std::string msg_attachment_memory = LLTrans::getString("ScriptLimitsMemoryUsed", args_attachment_memory);
-		childSetValue("memory_used", LLSD(msg_attachment_memory));
+		getChild<LLUICtrl>("memory_used")->setValue(LLSD(msg_attachment_memory));
 	}
 
 	if((mAttachmentURLsUsed >= 0) && (mAttachmentURLsMax >= 0))
@@ -1303,7 +1303,7 @@ void LLPanelScriptLimitsAttachment::setAttachmentSummary(LLSD content)
 		args_attachment_urls["[MAX]"] = llformat ("%d", mAttachmentURLsMax);
 		args_attachment_urls["[AVAILABLE]"] = llformat ("%d", attachment_urls_available);
 		std::string msg_attachment_urls = LLTrans::getString("ScriptLimitsURLsUsed", args_attachment_urls);
-		childSetValue("urls_used", LLSD(msg_attachment_urls));
+		getChild<LLUICtrl>("urls_used")->setValue(LLSD(msg_attachment_urls));
 	}
 }
 
diff --git a/indra/newview/llfloatersearch.cpp b/indra/newview/llfloatersearch.cpp
index 76caa0cf919..381b2dee332 100644
--- a/indra/newview/llfloatersearch.cpp
+++ b/indra/newview/llfloatersearch.cpp
@@ -128,11 +128,11 @@ void LLFloaterSearch::handleMediaEvent(LLPluginClassMedia *self, EMediaEvent eve
 	switch (event) 
 	{
 	case MEDIA_EVENT_NAVIGATE_BEGIN:
-		childSetText("status_text", getString("loading_text"));
+		getChild<LLUICtrl>("status_text")->setValue(getString("loading_text"));
 		break;
 		
 	case MEDIA_EVENT_NAVIGATE_COMPLETE:
-		childSetText("status_text", getString("done_text"));
+		getChild<LLUICtrl>("status_text")->setValue(getString("done_text"));
 		break;
 
 	default:
@@ -146,7 +146,7 @@ void LLFloaterSearch::godLevelChanged(U8 godlevel)
 	// changes god level, then give them a warning (we don't refresh
 	// the search as this might undo any page navigation or
 	// AJAX-driven changes since the last search).
-	childSetVisible("refresh_search", (godlevel != mSearchGodLevel));
+	getChildView("refresh_search")->setVisible( (godlevel != mSearchGodLevel));
 }
 
 void LLFloaterSearch::search(const LLSD &key)
@@ -157,7 +157,7 @@ void LLFloaterSearch::search(const LLSD &key)
 	}
 
 	// reset the god level warning as we're sending the latest state
-	childHide("refresh_search");
+	getChildView("refresh_search")->setVisible(FALSE);
 	mSearchGodLevel = gAgent.getGodLevel();
 
 	// work out the subdir to use based on the requested category
diff --git a/indra/newview/llfloatersellland.cpp b/indra/newview/llfloatersellland.cpp
index 9dddbd998af..b10a297bb84 100644
--- a/indra/newview/llfloatersellland.cpp
+++ b/indra/newview/llfloatersellland.cpp
@@ -163,7 +163,7 @@ BOOL LLFloaterSellLandUI::postBuild()
 {
 	childSetCommitCallback("sell_to", onChangeValue, this);
 	childSetCommitCallback("price", onChangeValue, this);
-	childSetPrevalidate("price", LLTextValidate::validateNonNegativeS32);
+	getChild<LLLineEditor>("price")->setPrevalidate(LLTextValidate::validateNonNegativeS32);
 	childSetCommitCallback("sell_objects", onChangeValue, this);
 	childSetAction("sell_to_select_agent", boost::bind( &LLFloaterSellLandUI::doSelectAgent, this));
 	childSetAction("cancel_btn", doCancel, this);
@@ -207,20 +207,20 @@ void LLFloaterSellLandUI::updateParcelInfo()
 	mParcelSoldWithObjects = parcelp->getSellWithObjects();
 	if (mParcelIsForSale)
 	{
-		childSetValue("price", mParcelPrice);
+		getChild<LLUICtrl>("price")->setValue(mParcelPrice);
 		if (mParcelSoldWithObjects)
 		{
-			childSetValue("sell_objects", "yes");
+			getChild<LLUICtrl>("sell_objects")->setValue("yes");
 		}
 		else
 		{
-			childSetValue("sell_objects", "no");
+			getChild<LLUICtrl>("sell_objects")->setValue("no");
 		}
 	}
 	else
 	{
-		childSetValue("price", "");
-		childSetValue("sell_objects", "none");
+		getChild<LLUICtrl>("price")->setValue("");
+		getChild<LLUICtrl>("sell_objects")->setValue("none");
 	}
 
 	mParcelSnapshot = parcelp->getSnapshotID();
@@ -232,7 +232,7 @@ void LLFloaterSellLandUI::updateParcelInfo()
 	{
 		std::string name;
 		gCacheName->getFullName(mAuthorizedBuyer, name);
-		childSetText("sell_to_agent", name);
+		getChild<LLUICtrl>("sell_to_agent")->setValue(name);
 	}
 }
 
@@ -253,7 +253,7 @@ void LLFloaterSellLandUI::setBadge(const char* id, Badge badge)
 		case BADGE_ERROR:	badgeName = badgeError;	break;
 	}
 	
-	childSetValue(id, badgeName);
+	getChild<LLUICtrl>(id)->setValue(badgeName);
 }
 
 void LLFloaterSellLandUI::refreshUI()
@@ -264,10 +264,10 @@ void LLFloaterSellLandUI::refreshUI()
 	LLTextureCtrl* snapshot = getChild<LLTextureCtrl>("info_image");
 	snapshot->setImageAssetID(mParcelSnapshot);
 
-	childSetText("info_parcel", parcelp->getName());
-	childSetTextArg("info_size", "[AREA]", llformat("%d", mParcelActualArea));
+	getChild<LLUICtrl>("info_parcel")->setValue(parcelp->getName());
+	getChild<LLUICtrl>("info_size")->setTextArg("[AREA]", llformat("%d", mParcelActualArea));
 
-	std::string price_str = childGetValue("price").asString();
+	std::string price_str = getChild<LLUICtrl>("price")->getValue().asString();
 	bool valid_price = false;
 	valid_price = (price_str != "") && LLTextValidate::validateNonNegativeS32(utf8str_to_wstring(price_str));
 
@@ -275,14 +275,14 @@ void LLFloaterSellLandUI::refreshUI()
 	{
 		F32 per_meter_price = 0;
 		per_meter_price = F32(mParcelPrice) / F32(mParcelActualArea);
-		childSetTextArg("price_per_m", "[PER_METER]", llformat("%0.2f", per_meter_price));
-		childShow("price_per_m");
+		getChild<LLUICtrl>("price_per_m")->setTextArg("[PER_METER]", llformat("%0.2f", per_meter_price));
+		getChildView("price_per_m")->setVisible(TRUE);
 
 		setBadge("step_price", BADGE_OK);
 	}
 	else
 	{
-		childHide("price_per_m");
+		getChildView("price_per_m")->setVisible(FALSE);
 
 		if ("" == price_str)
 		{
@@ -296,26 +296,26 @@ void LLFloaterSellLandUI::refreshUI()
 
 	if (mSellToBuyer)
 	{
-		childSetValue("sell_to", "user");
-		childShow("sell_to_agent");
-		childShow("sell_to_select_agent");
+		getChild<LLUICtrl>("sell_to")->setValue("user");
+		getChildView("sell_to_agent")->setVisible(TRUE);
+		getChildView("sell_to_select_agent")->setVisible(TRUE);
 	}
 	else
 	{
 		if (mChoseSellTo)
 		{
-			childSetValue("sell_to", "anyone");
+			getChild<LLUICtrl>("sell_to")->setValue("anyone");
 		}
 		else
 		{
-			childSetValue("sell_to", "select");
+			getChild<LLUICtrl>("sell_to")->setValue("select");
 		}
-		childHide("sell_to_agent");
-		childHide("sell_to_select_agent");
+		getChildView("sell_to_agent")->setVisible(FALSE);
+		getChildView("sell_to_select_agent")->setVisible(FALSE);
 	}
 
 	// Must select Sell To: Anybody, or User (with a specified username)
-	std::string sell_to = childGetValue("sell_to").asString();
+	std::string sell_to = getChild<LLUICtrl>("sell_to")->getValue().asString();
 	bool valid_sell_to = "select" != sell_to &&
 		("user" != sell_to || mAuthorizedBuyer.notNull());
 
@@ -328,7 +328,7 @@ void LLFloaterSellLandUI::refreshUI()
 		setBadge("step_sell_to", BADGE_OK);
 	}
 
-	bool valid_sell_objects = ("none" != childGetValue("sell_objects").asString());
+	bool valid_sell_objects = ("none" != getChild<LLUICtrl>("sell_objects")->getValue().asString());
 
 	if (!valid_sell_objects)
 	{
@@ -341,11 +341,11 @@ void LLFloaterSellLandUI::refreshUI()
 
 	if (valid_sell_to && valid_price && valid_sell_objects)
 	{
-		childEnable("sell_btn");
+		getChildView("sell_btn")->setEnabled(TRUE);
 	}
 	else
 	{
-		childDisable("sell_btn");
+		getChildView("sell_btn")->setEnabled(FALSE);
 	}
 }
 
@@ -354,7 +354,7 @@ void LLFloaterSellLandUI::onChangeValue(LLUICtrl *ctrl, void *userdata)
 {
 	LLFloaterSellLandUI *self = (LLFloaterSellLandUI *)userdata;
 
-	std::string sell_to = self->childGetValue("sell_to").asString();
+	std::string sell_to = self->getChild<LLUICtrl>("sell_to")->getValue().asString();
 
 	if (sell_to == "user")
 	{
@@ -371,9 +371,9 @@ void LLFloaterSellLandUI::onChangeValue(LLUICtrl *ctrl, void *userdata)
 		self->mSellToBuyer = false;
 	}
 
-	self->mParcelPrice = self->childGetValue("price");
+	self->mParcelPrice = self->getChild<LLUICtrl>("price")->getValue();
 
-	if ("yes" == self->childGetValue("sell_objects").asString())
+	if ("yes" == self->getChild<LLUICtrl>("sell_objects")->getValue().asString())
 	{
 		self->mParcelSoldWithObjects = true;
 	}
@@ -402,7 +402,7 @@ void LLFloaterSellLandUI::callbackAvatarPick(const std::vector<std::string>& nam
 
 	mAuthorizedBuyer = ids[0];
 
-	childSetText("sell_to_agent", names[0]);
+	getChild<LLUICtrl>("sell_to_agent")->setValue(names[0]);
 
 	refreshUI();
 }
@@ -445,13 +445,13 @@ void LLFloaterSellLandUI::doSellLand(void *userdata)
 	LLParcel* parcel = self->mParcelSelection->getParcel();
 
 	// Do a confirmation
-	S32 sale_price = self->childGetValue("price");
+	S32 sale_price = self->getChild<LLUICtrl>("price")->getValue();
 	S32 area = parcel->getArea();
 	std::string authorizedBuyerName = "Anyone";
 	bool sell_to_anyone = true;
-	if ("user" == self->childGetValue("sell_to").asString())
+	if ("user" == self->getChild<LLUICtrl>("sell_to")->getValue().asString())
 	{
-		authorizedBuyerName = self->childGetText("sell_to_agent");
+		authorizedBuyerName = self->getChild<LLUICtrl>("sell_to_agent")->getValue().asString();
 		sell_to_anyone = false;
 	}
 
@@ -498,7 +498,7 @@ bool LLFloaterSellLandUI::onConfirmSale(const LLSD& notification, const LLSD& re
 	{
 		return false;
 	}
-	S32  sale_price	= childGetValue("price");
+	S32  sale_price	= getChild<LLUICtrl>("price")->getValue();
 
 	// Valid extracted data
 	if (sale_price < 0)
@@ -520,12 +520,12 @@ bool LLFloaterSellLandUI::onConfirmSale(const LLSD& notification, const LLSD& re
 	parcel->setParcelFlag(PF_FOR_SALE, TRUE);
 	parcel->setSalePrice(sale_price);
 	bool sell_with_objects = false;
-	if ("yes" == childGetValue("sell_objects").asString())
+	if ("yes" == getChild<LLUICtrl>("sell_objects")->getValue().asString())
 	{
 		sell_with_objects = true;
 	}
 	parcel->setSellWithObjects(sell_with_objects);
-	if ("user" == childGetValue("sell_to").asString())
+	if ("user" == getChild<LLUICtrl>("sell_to")->getValue().asString())
 	{
 		parcel->setAuthorizedBuyerID(mAuthorizedBuyer);
 	}
diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp
index a6ffa5ec09d..77e0e4e6770 100644
--- a/indra/newview/llfloatersettingsdebug.cpp
+++ b/indra/newview/llfloatersettingsdebug.cpp
@@ -127,49 +127,49 @@ void LLFloaterSettingsDebug::onCommitSettings()
 	switch(controlp->type())
 	{		
 	  case TYPE_U32:
-		controlp->set(childGetValue("val_spinner_1"));
+		controlp->set(getChild<LLUICtrl>("val_spinner_1")->getValue());
 		break;
 	  case TYPE_S32:
-		controlp->set(childGetValue("val_spinner_1"));
+		controlp->set(getChild<LLUICtrl>("val_spinner_1")->getValue());
 		break;
 	  case TYPE_F32:
-		controlp->set(LLSD(childGetValue("val_spinner_1").asReal()));
+		controlp->set(LLSD(getChild<LLUICtrl>("val_spinner_1")->getValue().asReal()));
 		break;
 	  case TYPE_BOOLEAN:
-		controlp->set(childGetValue("boolean_combo"));
+		controlp->set(getChild<LLUICtrl>("boolean_combo")->getValue());
 		break;
 	  case TYPE_STRING:
-		controlp->set(LLSD(childGetValue("val_text").asString()));
+		controlp->set(LLSD(getChild<LLUICtrl>("val_text")->getValue().asString()));
 		break;
 	  case TYPE_VEC3:
-		vector.mV[VX] = (F32)childGetValue("val_spinner_1").asReal();
-		vector.mV[VY] = (F32)childGetValue("val_spinner_2").asReal();
-		vector.mV[VZ] = (F32)childGetValue("val_spinner_3").asReal();
+		vector.mV[VX] = (F32)getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
+		vector.mV[VY] = (F32)getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
+		vector.mV[VZ] = (F32)getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
 		controlp->set(vector.getValue());
 		break;
 	  case TYPE_VEC3D:
-		vectord.mdV[VX] = childGetValue("val_spinner_1").asReal();
-		vectord.mdV[VY] = childGetValue("val_spinner_2").asReal();
-		vectord.mdV[VZ] = childGetValue("val_spinner_3").asReal();
+		vectord.mdV[VX] = getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
+		vectord.mdV[VY] = getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
+		vectord.mdV[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
 		controlp->set(vectord.getValue());
 		break;
 	  case TYPE_RECT:
-		rect.mLeft = childGetValue("val_spinner_1").asInteger();
-		rect.mRight = childGetValue("val_spinner_2").asInteger();
-		rect.mBottom = childGetValue("val_spinner_3").asInteger();
-		rect.mTop = childGetValue("val_spinner_4").asInteger();
+		rect.mLeft = getChild<LLUICtrl>("val_spinner_1")->getValue().asInteger();
+		rect.mRight = getChild<LLUICtrl>("val_spinner_2")->getValue().asInteger();
+		rect.mBottom = getChild<LLUICtrl>("val_spinner_3")->getValue().asInteger();
+		rect.mTop = getChild<LLUICtrl>("val_spinner_4")->getValue().asInteger();
 		controlp->set(rect.getValue());
 		break;
 	  case TYPE_COL4:
-		col3.setValue(childGetValue("val_color_swatch"));
-		col4 = LLColor4(col3, (F32)childGetValue("val_spinner_4").asReal());
+		col3.setValue(getChild<LLUICtrl>("val_color_swatch")->getValue());
+		col4 = LLColor4(col3, (F32)getChild<LLUICtrl>("val_spinner_4")->getValue().asReal());
 		controlp->set(col4.getValue());
 		break;
 	  case TYPE_COL3:
-		controlp->set(childGetValue("val_color_swatch"));
-		//col3.mV[VRED] = (F32)floaterp->childGetValue("val_spinner_1").asC();
-		//col3.mV[VGREEN] = (F32)floaterp->childGetValue("val_spinner_2").asReal();
-		//col3.mV[VBLUE] = (F32)floaterp->childGetValue("val_spinner_3").asReal();
+		controlp->set(getChild<LLUICtrl>("val_color_swatch")->getValue());
+		//col3.mV[VRED] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_1")->getValue().asC();
+		//col3.mV[VGREEN] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
+		//col3.mV[VBLUE] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
 		//controlp->set(col3.getValue());
 		break;
 	  default:
@@ -211,7 +211,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
 	spinner3->setVisible(FALSE);
 	spinner4->setVisible(FALSE);
 	color_swatch->setVisible(FALSE);
-	childSetVisible("val_text", FALSE);
+	getChildView("val_text")->setVisible( FALSE);
 	mComment->setText(LLStringUtil::null);
 
 	if (controlp)
@@ -219,7 +219,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
 		eControlType type = controlp->type();
 
 		//hide combo box only for non booleans, otherwise this will result in the combo box closing every frame
-		childSetVisible("boolean_combo", type == TYPE_BOOLEAN);
+		getChildView("boolean_combo")->setVisible( type == TYPE_BOOLEAN);
 		
 
 		mComment->setText(controlp->getComment());
@@ -285,23 +285,23 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
 			}
 			break;
 		  case TYPE_BOOLEAN:
-			if (!childHasFocus("boolean_combo"))
+			if (!getChild<LLUICtrl>("boolean_combo")->hasFocus())
 			{
 				if (sd.asBoolean())
 				{
-					childSetValue("boolean_combo", LLSD("true"));
+					getChild<LLUICtrl>("boolean_combo")->setValue(LLSD("true"));
 				}
 				else
 				{
-					childSetValue("boolean_combo", LLSD(""));
+					getChild<LLUICtrl>("boolean_combo")->setValue(LLSD(""));
 				}
 			}
 			break;
 		  case TYPE_STRING:
-			childSetVisible("val_text", TRUE);
-			if (!childHasFocus("val_text"))
+			getChildView("val_text")->setVisible( TRUE);
+			if (!getChild<LLUICtrl>("val_text")->hasFocus())
 			{
-				childSetValue("val_text", sd);
+				getChild<LLUICtrl>("val_text")->setValue(sd);
 			}
 			break;
 		  case TYPE_VEC3:
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 43ea6143b10..e8a89bb7055 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -1141,7 +1141,7 @@ LLSnapshotLivePreview* LLFloaterSnapshot::Impl::getPreviewView(LLFloaterSnapshot
 LLSnapshotLivePreview::ESnapshotType LLFloaterSnapshot::Impl::getTypeIndex(LLFloaterSnapshot* floater)
 {
 	LLSnapshotLivePreview::ESnapshotType index = LLSnapshotLivePreview::SNAPSHOT_POSTCARD;
-	LLSD value = floater->childGetValue("snapshot_type_radio");
+	LLSD value = floater->getChild<LLUICtrl>("snapshot_type_radio")->getValue();
 
 	const std::string id = value.asString();
 	if (id == "postcard")
@@ -1211,7 +1211,7 @@ LLFloaterSnapshot::ESnapshotFormat LLFloaterSnapshot::Impl::getFormatIndex(LLFlo
 LLViewerWindow::ESnapshotType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSnapshot* floater)
 {
 	LLViewerWindow::ESnapshotType type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
-	LLSD value = floater->childGetValue("layer_types");
+	LLSD value = floater->getChild<LLUICtrl>("layer_types")->getValue();
 	const std::string id = value.asString();
 	if (id == "colors")
 		type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
@@ -1254,7 +1254,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
 		previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw());
 	}
 
-	bool use_freeze_frame = floaterp->childGetValue("freeze_frame_check").asBoolean();
+	bool use_freeze_frame = floaterp->getChild<LLUICtrl>("freeze_frame_check")->getValue().asBoolean();
 
 	if (use_freeze_frame)
 	{
@@ -1328,11 +1328,11 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 	ESnapshotFormat shot_format = (ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat");
 	LLViewerWindow::ESnapshotType layer_type = getLayerType(floater);
 
-	floater->childSetVisible("share_to_web", gSavedSettings.getBOOL("SnapshotSharingEnabled"));
+	floater->getChildView("share_to_web")->setVisible( gSavedSettings.getBOOL("SnapshotSharingEnabled"));
 
-	floater->childSetVisible("postcard_size_combo", FALSE);
-	floater->childSetVisible("texture_size_combo", FALSE);
-	floater->childSetVisible("local_size_combo", FALSE);
+	floater->getChildView("postcard_size_combo")->setVisible( FALSE);
+	floater->getChildView("texture_size_combo")->setVisible( FALSE);
+	floater->getChildView("local_size_combo")->setVisible( FALSE);
 
 	floater->getChild<LLComboBox>("postcard_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotPostcardLastResolution"));
 	floater->getChild<LLComboBox>("texture_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotTextureLastResolution"));
@@ -1340,12 +1340,12 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 	floater->getChild<LLComboBox>("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat"));
 
 	// *TODO: Separate settings for Web images from postcards
-	floater->childSetVisible("send_btn",			shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD ||
+	floater->getChildView("send_btn")->setVisible(	shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD ||
 													shot_type == LLSnapshotLivePreview::SNAPSHOT_WEB);
-	floater->childSetVisible("upload_btn",			shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE);
-	floater->childSetVisible("save_btn",			shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL);
-	floater->childSetEnabled("keep_aspect_check",	shot_type != LLSnapshotLivePreview::SNAPSHOT_TEXTURE && !floater->impl.mAspectRatioCheckOff);
-	floater->childSetEnabled("layer_types",			shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL);
+	floater->getChildView("upload_btn")->setVisible(shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE);
+	floater->getChildView("save_btn")->setVisible(	shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL);
+	floater->getChildView("keep_aspect_check")->setEnabled(shot_type != LLSnapshotLivePreview::SNAPSHOT_TEXTURE && !floater->impl.mAspectRatioCheckOff);
+	floater->getChildView("layer_types")->setEnabled(shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL);
 
 	BOOL is_advance = gSavedSettings.getBOOL("AdvanceSnapshot");
 	BOOL is_local = shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL;
@@ -1353,33 +1353,33 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 						shot_type == LLSnapshotLivePreview::SNAPSHOT_WEB ||
 					   (is_local && shot_format == LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG));
 
-	floater->childSetVisible("more_btn", !is_advance); // the only item hidden in advanced mode
-	floater->childSetVisible("less_btn",				is_advance);
-	floater->childSetVisible("type_label2",				is_advance);
-	floater->childSetVisible("format_label",			is_advance && is_local);
-	floater->childSetVisible("local_format_combo",		is_advance && is_local);
-	floater->childSetVisible("layer_types",				is_advance);
-	floater->childSetVisible("layer_type_label",		is_advance);
-	floater->childSetVisible("snapshot_width",			is_advance);
-	floater->childSetVisible("snapshot_height",			is_advance);
-	floater->childSetVisible("keep_aspect_check",		is_advance);
-	floater->childSetVisible("ui_check",				is_advance);
-	floater->childSetVisible("hud_check",				is_advance);
-	floater->childSetVisible("keep_open_check",			is_advance);
-	floater->childSetVisible("freeze_frame_check",		is_advance);
-	floater->childSetVisible("auto_snapshot_check",		is_advance);
-	floater->childSetVisible("image_quality_slider",	is_advance && show_slider);
+	floater->getChildView("more_btn")->setVisible( !is_advance); // the only item hidden in advanced mode
+	floater->getChildView("less_btn")->setVisible(				is_advance);
+	floater->getChildView("type_label2")->setVisible(				is_advance);
+	floater->getChildView("format_label")->setVisible(			is_advance && is_local);
+	floater->getChildView("local_format_combo")->setVisible(		is_advance && is_local);
+	floater->getChildView("layer_types")->setVisible(				is_advance);
+	floater->getChildView("layer_type_label")->setVisible(		is_advance);
+	floater->getChildView("snapshot_width")->setVisible(			is_advance);
+	floater->getChildView("snapshot_height")->setVisible(			is_advance);
+	floater->getChildView("keep_aspect_check")->setVisible(		is_advance);
+	floater->getChildView("ui_check")->setVisible(				is_advance);
+	floater->getChildView("hud_check")->setVisible(				is_advance);
+	floater->getChildView("keep_open_check")->setVisible(			is_advance);
+	floater->getChildView("freeze_frame_check")->setVisible(		is_advance);
+	floater->getChildView("auto_snapshot_check")->setVisible(		is_advance);
+	floater->getChildView("image_quality_slider")->setVisible(	is_advance && show_slider);
 
 	LLSnapshotLivePreview* previewp = getPreviewView(floater);
 	BOOL got_bytes = previewp && previewp->getDataSize() > 0;
 	BOOL got_snap = previewp && previewp->getSnapshotUpToDate();
 
 	// *TODO: Separate maximum size for Web images from postcards
-	floater->childSetEnabled("send_btn",   (shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD ||
+	floater->getChildView("send_btn")->setEnabled((shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD ||
 											shot_type == LLSnapshotLivePreview::SNAPSHOT_WEB) &&
 											got_snap && previewp->getDataSize() <= MAX_POSTCARD_DATASIZE);
-	floater->childSetEnabled("upload_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE  && got_snap);
-	floater->childSetEnabled("save_btn",   shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL    && got_snap);
+	floater->getChildView("upload_btn")->setEnabled(shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE  && got_snap);
+	floater->getChildView("save_btn")->setEnabled(shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL    && got_snap);
 
 	LLLocale locale(LLLocale::USER_LOCALE);
 	std::string bytes_string;
@@ -1388,10 +1388,10 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 		LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 );
 	}
 	S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
-	floater->childSetLabelArg("texture", "[AMOUNT]", llformat("%d",upload_cost));
-	floater->childSetLabelArg("upload_btn", "[AMOUNT]", llformat("%d",upload_cost));
-	floater->childSetTextArg("file_size_label", "[SIZE]", got_snap ? bytes_string : floater->getString("unknown"));
-	floater->childSetColor("file_size_label", 
+	floater->getChild<LLUICtrl>("texture")->setLabelArg("[AMOUNT]", llformat("%d",upload_cost));
+	floater->getChild<LLUICtrl>("upload_btn")->setLabelArg("[AMOUNT]", llformat("%d",upload_cost));
+	floater->getChild<LLUICtrl>("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown"));
+	floater->getChild<LLUICtrl>("file_size_label")->setColor(
 		shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD 
 		&& got_bytes
 		&& previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" ));
@@ -1402,7 +1402,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 	  case LLSnapshotLivePreview::SNAPSHOT_WEB:
 	  case LLSnapshotLivePreview::SNAPSHOT_POSTCARD:
 		layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
-		floater->childSetValue("layer_types", "colors");
+		floater->getChild<LLUICtrl>("layer_types")->setValue("colors");
 		if(is_advance)
 		{			
 			setResolution(floater, "postcard_size_combo");
@@ -1410,7 +1410,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 		break;
 	  case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:
 		layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
-		floater->childSetValue("layer_types", "colors");
+		floater->getChild<LLUICtrl>("layer_types")->setValue("colors");
 		if(is_advance)
 		{
 			setResolution(floater, "texture_size_combo");			
@@ -1710,7 +1710,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde
 	if(0 == index) //current window size
 	{
 		view->impl.mAspectRatioCheckOff = true ;
-		view->childSetEnabled("keep_aspect_check", FALSE) ;
+		view->getChildView("keep_aspect_check")->setEnabled(FALSE) ;
 
 		if(previewp)
 		{
@@ -1722,7 +1722,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde
 		view->impl.mAspectRatioCheckOff = false ;
 		//if(LLSnapshotLivePreview::SNAPSHOT_TEXTURE != gSavedSettings.getS32("LastSnapshotType"))
 		{
-			view->childSetEnabled("keep_aspect_check", TRUE) ;
+			view->getChildView("keep_aspect_check")->setEnabled(TRUE) ;
 
 			if(previewp)
 			{
@@ -1733,7 +1733,7 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde
 	else
 	{
 		view->impl.mAspectRatioCheckOff = true ;
-		view->childSetEnabled("keep_aspect_check", FALSE) ;
+		view->getChildView("keep_aspect_check")->setEnabled(FALSE) ;
 
 		if(previewp)
 		{
@@ -1822,10 +1822,10 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
 			resetSnapshotSizeOnUI(view, width, height) ;
 		}
 		
-		if(view->childGetValue("snapshot_width").asInteger() != width || view->childGetValue("snapshot_height").asInteger() != height)
+		if(view->getChild<LLUICtrl>("snapshot_width")->getValue().asInteger() != width || view->getChild<LLUICtrl>("snapshot_height")->getValue().asInteger() != height)
 		{
-			view->childSetValue("snapshot_width", width);
-			view->childSetValue("snapshot_height", height);
+			view->getChild<LLUICtrl>("snapshot_width")->setValue(width);
+			view->getChild<LLUICtrl>("snapshot_height")->setValue(height);
 		}
 
 		if(original_width != width || original_height != height)
@@ -2008,8 +2008,8 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat
 	LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;		
 	if (view)
 	{
-		S32 w = llfloor((F32)view->childGetValue("snapshot_width").asReal());
-		S32 h = llfloor((F32)view->childGetValue("snapshot_height").asReal());
+		S32 w = llfloor((F32)view->getChild<LLUICtrl>("snapshot_width")->getValue().asReal());
+		S32 h = llfloor((F32)view->getChild<LLUICtrl>("snapshot_height")->getValue().asReal());
 
 		LLSnapshotLivePreview* previewp = getPreviewView(view);
 		if (previewp)
@@ -2118,34 +2118,34 @@ BOOL LLFloaterSnapshot::postBuild()
 	childSetAction("discard_btn", Impl::onClickDiscard, this);
 
 	childSetCommitCallback("image_quality_slider", Impl::onCommitQuality, this);
-	childSetValue("image_quality_slider", gSavedSettings.getS32("SnapshotQuality"));
+	getChild<LLUICtrl>("image_quality_slider")->setValue(gSavedSettings.getS32("SnapshotQuality"));
 
 	childSetCommitCallback("snapshot_width", Impl::onCommitCustomResolution, this);
 	childSetCommitCallback("snapshot_height", Impl::onCommitCustomResolution, this);
 
 	childSetCommitCallback("ui_check", Impl::onClickUICheck, this);
-	childSetValue("ui_check", gSavedSettings.getBOOL("RenderUIInSnapshot"));
+	getChild<LLUICtrl>("ui_check")->setValue(gSavedSettings.getBOOL("RenderUIInSnapshot"));
 
 	childSetCommitCallback("hud_check", Impl::onClickHUDCheck, this);
-	childSetValue("hud_check", gSavedSettings.getBOOL("RenderHUDInSnapshot"));
+	getChild<LLUICtrl>("hud_check")->setValue(gSavedSettings.getBOOL("RenderHUDInSnapshot"));
 
 	childSetCommitCallback("keep_open_check", Impl::onClickKeepOpenCheck, this);
-	childSetValue("keep_open_check", !gSavedSettings.getBOOL("CloseSnapshotOnKeep"));
+	getChild<LLUICtrl>("keep_open_check")->setValue(!gSavedSettings.getBOOL("CloseSnapshotOnKeep"));
 
 	childSetCommitCallback("keep_aspect_check", Impl::onClickKeepAspectCheck, this);
-	childSetValue("keep_aspect_check", gSavedSettings.getBOOL("KeepAspectForSnapshot"));
+	getChild<LLUICtrl>("keep_aspect_check")->setValue(gSavedSettings.getBOOL("KeepAspectForSnapshot"));
 
 	childSetCommitCallback("layer_types", Impl::onCommitLayerTypes, this);
-	childSetValue("layer_types", "colors");
-	childSetEnabled("layer_types", FALSE);
+	getChild<LLUICtrl>("layer_types")->setValue("colors");
+	getChildView("layer_types")->setEnabled(FALSE);
 
-	childSetValue("snapshot_width", gSavedSettings.getS32(lastSnapshotWidthName()));
-	childSetValue("snapshot_height", gSavedSettings.getS32(lastSnapshotHeightName()));
+	getChild<LLUICtrl>("snapshot_width")->setValue(gSavedSettings.getS32(lastSnapshotWidthName()));
+	getChild<LLUICtrl>("snapshot_height")->setValue(gSavedSettings.getS32(lastSnapshotHeightName()));
 
-	childSetValue("freeze_frame_check", gSavedSettings.getBOOL("UseFreezeFrame"));
+	getChild<LLUICtrl>("freeze_frame_check")->setValue(gSavedSettings.getBOOL("UseFreezeFrame"));
 	childSetCommitCallback("freeze_frame_check", Impl::onCommitFreezeFrame, this);
 
-	childSetValue("auto_snapshot_check", gSavedSettings.getBOOL("AutoSnapshot"));
+	getChild<LLUICtrl>("auto_snapshot_check")->setValue(gSavedSettings.getBOOL("AutoSnapshot"));
 	childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this);
 
 	childSetCommitCallback("postcard_size_combo", Impl::onCommitResolution, this);
diff --git a/indra/newview/llfloatertelehub.cpp b/indra/newview/llfloatertelehub.cpp
index 816181643f1..6bd1e70f13c 100644
--- a/indra/newview/llfloatertelehub.cpp
+++ b/indra/newview/llfloatertelehub.cpp
@@ -112,19 +112,19 @@ void LLFloaterTelehub::refresh()
 	
 	BOOL have_selection = (object != NULL);
 	BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
-	childSetEnabled("connect_btn", have_selection && all_volume);
+	getChildView("connect_btn")->setEnabled(have_selection && all_volume);
 
 	BOOL have_telehub = mTelehubObjectID.notNull();
-	childSetEnabled("disconnect_btn", have_telehub);
+	getChildView("disconnect_btn")->setEnabled(have_telehub);
 
 	BOOL space_avail = (mNumSpawn < MAX_SPAWNPOINTS_PER_TELEHUB);
-	childSetEnabled("add_spawn_point_btn", have_selection && all_volume && space_avail);
+	getChildView("add_spawn_point_btn")->setEnabled(have_selection && all_volume && space_avail);
 
 	LLScrollListCtrl* list = getChild<LLScrollListCtrl>("spawn_points_list");
 	if (list)
 	{
 		BOOL enable_remove = (list->getFirstSelected() != NULL);
-		childSetEnabled("remove_spawn_point_btn", enable_remove);
+		getChildView("remove_spawn_point_btn")->setEnabled(enable_remove);
 	}
 }
 
@@ -255,18 +255,18 @@ void LLFloaterTelehub::unpackTelehubInfo(LLMessageSystem* msg)
 
 	if (mTelehubObjectID.isNull())
 	{
-		childSetVisible("status_text_connected", false);
-		childSetVisible("status_text_not_connected", true);
-		childSetVisible("help_text_connected", false);
-		childSetVisible("help_text_not_connected", true);
+		getChildView("status_text_connected")->setVisible( false);
+		getChildView("status_text_not_connected")->setVisible( true);
+		getChildView("help_text_connected")->setVisible( false);
+		getChildView("help_text_not_connected")->setVisible( true);
 	}
 	else
 	{
-		childSetTextArg("status_text_connected", "[OBJECT]", mTelehubObjectName);
-		childSetVisible("status_text_connected", true);
-		childSetVisible("status_text_not_connected", false);
-		childSetVisible("help_text_connected", true);
-		childSetVisible("help_text_not_connected", false);
+		getChild<LLUICtrl>("status_text_connected")->setTextArg("[OBJECT]", mTelehubObjectName);
+		getChildView("status_text_connected")->setVisible( true);
+		getChildView("status_text_not_connected")->setVisible( false);
+		getChildView("help_text_connected")->setVisible( true);
+		getChildView("help_text_not_connected")->setVisible( false);
 	}
 
 	LLScrollListCtrl* list = getChild<LLScrollListCtrl>("spawn_points_list");
diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp
index 565f0619a51..0988588d9cf 100644
--- a/indra/newview/llfloatertools.cpp
+++ b/indra/newview/llfloatertools.cpp
@@ -228,13 +228,13 @@ BOOL	LLFloaterTools::postBuild()
 	mTitleMedia			= getChild<LLMediaCtrl>("title_media");
 	
 	mCheckSelectIndividual	= getChild<LLCheckBoxCtrl>("checkbox edit linked parts");	
-	childSetValue("checkbox edit linked parts",(BOOL)gSavedSettings.getBOOL("EditLinkedParts"));
+	getChild<LLUICtrl>("checkbox edit linked parts")->setValue((BOOL)gSavedSettings.getBOOL("EditLinkedParts"));
 	mCheckSnapToGrid		= getChild<LLCheckBoxCtrl>("checkbox snap to grid");
-	childSetValue("checkbox snap to grid",(BOOL)gSavedSettings.getBOOL("SnapEnabled"));
+	getChild<LLUICtrl>("checkbox snap to grid")->setValue((BOOL)gSavedSettings.getBOOL("SnapEnabled"));
 	mCheckStretchUniform	= getChild<LLCheckBoxCtrl>("checkbox uniform");
-	childSetValue("checkbox uniform",(BOOL)gSavedSettings.getBOOL("ScaleUniform"));
+	getChild<LLUICtrl>("checkbox uniform")->setValue((BOOL)gSavedSettings.getBOOL("ScaleUniform"));
 	mCheckStretchTexture	= getChild<LLCheckBoxCtrl>("checkbox stretch textures");
-	childSetValue("checkbox stretch textures",(BOOL)gSavedSettings.getBOOL("ScaleStretchTextures"));
+	getChild<LLUICtrl>("checkbox stretch textures")->setValue((BOOL)gSavedSettings.getBOOL("ScaleStretchTextures"));
 	mComboGridMode			= getChild<LLComboBox>("combobox grid mode");
 	mCheckStretchUniformLabel = getChild<LLTextBox>("checkbox uniform label");
 
@@ -254,21 +254,21 @@ BOOL	LLFloaterTools::postBuild()
 		}
 	}
 	mCheckCopySelection = getChild<LLCheckBoxCtrl>("checkbox copy selection");
-	childSetValue("checkbox copy selection",(BOOL)gSavedSettings.getBOOL("CreateToolCopySelection"));
+	getChild<LLUICtrl>("checkbox copy selection")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopySelection"));
 	mCheckSticky = getChild<LLCheckBoxCtrl>("checkbox sticky");
-	childSetValue("checkbox sticky",(BOOL)gSavedSettings.getBOOL("CreateToolKeepSelected"));
+	getChild<LLUICtrl>("checkbox sticky")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolKeepSelected"));
 	mCheckCopyCenters = getChild<LLCheckBoxCtrl>("checkbox copy centers");
-	childSetValue("checkbox copy centers",(BOOL)gSavedSettings.getBOOL("CreateToolCopyCenters"));
+	getChild<LLUICtrl>("checkbox copy centers")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopyCenters"));
 	mCheckCopyRotates = getChild<LLCheckBoxCtrl>("checkbox copy rotates");
-	childSetValue("checkbox copy rotates",(BOOL)gSavedSettings.getBOOL("CreateToolCopyRotates"));
+	getChild<LLUICtrl>("checkbox copy rotates")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopyRotates"));
 
 	mRadioGroupLand			= getChild<LLRadioGroup>("land_radio_group");
 	mBtnApplyToSelection	= getChild<LLButton>("button apply to selection");
 	mSliderDozerSize		= getChild<LLSlider>("slider brush size");
-	childSetValue( "slider brush size", gSavedSettings.getF32("LandBrushSize"));
+	getChild<LLUICtrl>("slider brush size")->setValue(gSavedSettings.getF32("LandBrushSize"));
 	mSliderDozerForce		= getChild<LLSlider>("slider force");
 	// the setting stores the actual force multiplier, but the slider is logarithmic, so we convert here
-	childSetValue( "slider force", log10(gSavedSettings.getF32("LandBrushForce")));
+	getChild<LLUICtrl>("slider force")->setValue(log10(gSavedSettings.getF32("LandBrushForce")));
 
 	mTab = getChild<LLTabContainer>("Object Info Tabs");
 	if(mTab)
@@ -421,25 +421,25 @@ void LLFloaterTools::refresh()
 	LLLocale locale(LLLocale::USER_LOCALE);
 	std::string obj_count_string;
 	LLResMgr::getInstance()->getIntegerString(obj_count_string, LLSelectMgr::getInstance()->getSelection()->getRootObjectCount());
-	childSetTextArg("obj_count",  "[COUNT]", obj_count_string);	
+	getChild<LLUICtrl>("obj_count")->setTextArg("[COUNT]", obj_count_string);	
 	std::string prim_count_string;
 	LLResMgr::getInstance()->getIntegerString(prim_count_string, LLSelectMgr::getInstance()->getSelection()->getObjectCount());
-	childSetTextArg("prim_count", "[COUNT]", prim_count_string);
+	getChild<LLUICtrl>("prim_count")->setTextArg("[COUNT]", prim_count_string);
 
 	// calculate selection rendering cost
 	if (sShowObjectCost)
 	{
 		std::string prim_cost_string;
 		LLResMgr::getInstance()->getIntegerString(prim_cost_string, calcRenderCost());
-		childSetTextArg("RenderingCost", "[COUNT]", prim_cost_string);
+		getChild<LLUICtrl>("RenderingCost")->setTextArg("[COUNT]", prim_cost_string);
 	}
 
 
 	// disable the object and prim counts if nothing selected
 	bool have_selection = ! LLSelectMgr::getInstance()->getSelection()->isEmpty();
-	childSetEnabled("obj_count", have_selection);
-	childSetEnabled("prim_count", have_selection);
-	childSetEnabled("RenderingCost", have_selection && sShowObjectCost);
+	getChildView("obj_count")->setEnabled(have_selection);
+	getChildView("prim_count")->setEnabled(have_selection);
+	getChildView("RenderingCost")->setEnabled(have_selection && sShowObjectCost);
 
 	// Refresh child tabs
 	mPanelPermissions->refresh();
@@ -507,8 +507,8 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask)
 	mBtnFocus	->setToggleState( focus_visible );
 
 	mRadioGroupFocus->setVisible( focus_visible );
-	childSetVisible("slider zoom", focus_visible);
-	childSetEnabled("slider zoom", gCameraBtnZoom);
+	getChildView("slider zoom")->setVisible( focus_visible);
+	getChildView("slider zoom")->setEnabled(gCameraBtnZoom);
 
 	if (!gCameraBtnOrbit &&
 		!gCameraBtnPan &&
@@ -533,7 +533,7 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask)
 	}
 
 	// multiply by correction factor because volume sliders go [0, 0.5]
-	childSetValue( "slider zoom", gAgentCamera.getCameraZoomFraction() * 0.5f);
+	getChild<LLUICtrl>("slider zoom")->setValue(gAgentCamera.getCameraZoomFraction() * 0.5f);
 
 	// Move buttons
 	BOOL move_visible = (tool == LLToolGrab::getInstance());
@@ -571,7 +571,7 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask)
 	mBtnEdit	->setToggleState( edit_visible );
 	mRadioGroupEdit->setVisible( edit_visible );
 	bool linked_parts = gSavedSettings.getBOOL("EditLinkedParts");
-	childSetVisible("RenderingCost", !linked_parts && (edit_visible || focus_visible || move_visible) && sShowObjectCost);
+	getChildView("RenderingCost")->setVisible( !linked_parts && (edit_visible || focus_visible || move_visible) && sShowObjectCost);
 
 	if (mCheckSelectIndividual)
 	{
@@ -714,17 +714,17 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask)
 	if (mSliderDozerSize)
 	{
 		mSliderDozerSize	->setVisible( land_visible );
-		childSetVisible("Bulldozer:", land_visible);
-		childSetVisible("Dozer Size:", land_visible);
+		getChildView("Bulldozer:")->setVisible( land_visible);
+		getChildView("Dozer Size:")->setVisible( land_visible);
 	}
 	if (mSliderDozerForce)
 	{
 		mSliderDozerForce	->setVisible( land_visible );
-		childSetVisible("Strength:", land_visible);
+		getChildView("Strength:")->setVisible( land_visible);
 	}
 
-	childSetVisible("obj_count", !land_visible);
-	childSetVisible("prim_count", !land_visible);
+	getChildView("obj_count")->setVisible( !land_visible);
+	getChildView("prim_count")->setVisible( !land_visible);
 	mTab->setVisible(!land_visible);
 	mPanelLandInfo->setVisible(land_visible);
 }
@@ -1091,7 +1091,7 @@ void LLFloaterTools::getMediaState()
 		  &&first_object->permModify() 
 	      ))
 	{
-		childSetEnabled("Add_Media",  FALSE);
+		getChildView("Add_Media")->setEnabled(FALSE);
 		media_info->clear();
 		clearMediaSettings();
 		return;
@@ -1102,7 +1102,7 @@ void LLFloaterTools::getMediaState()
 	
 	if(!has_media_capability)
 	{
-		childSetEnabled("Add_Media",  FALSE);
+		getChildView("Add_Media")->setEnabled(FALSE);
 		LL_WARNS("LLFloaterTools: media") << "Media not enabled (no capability) in this region!" << LL_ENDL;
 		clearMediaSettings();
 		return;
@@ -1194,7 +1194,7 @@ void LLFloaterTools::getMediaState()
 	// update UI depending on whether "object" (prim or face) has media
 	// and whether or not you are allowed to edit it.
 	
-	childSetEnabled("Add_Media",  editable);
+	getChildView("Add_Media")->setEnabled(editable);
 	// IF all the faces have media (or all dont have media)
 	if ( LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo )
 	{
@@ -1221,10 +1221,10 @@ void LLFloaterTools::getMediaState()
 			mNeedMediaTitle = false;
 		}
 		
-		childSetEnabled("media_tex",  bool_has_media && editable);
-		childSetEnabled( "edit_media", bool_has_media && LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo && editable );
-		childSetEnabled( "delete_media", bool_has_media && editable );
-		childSetEnabled( "add_media", ( ! bool_has_media ) && editable );
+		getChildView("media_tex")->setEnabled(bool_has_media && editable);
+		getChildView("edit_media")->setEnabled(bool_has_media && LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo && editable );
+		getChildView("delete_media")->setEnabled(bool_has_media && editable );
+		getChildView("add_media")->setEnabled(( ! bool_has_media ) && editable );
 			// TODO: display a list of all media on the face - use 'identical' flag
 	}
 	else // not all face has media but at least one does.
@@ -1251,10 +1251,10 @@ void LLFloaterTools::getMediaState()
 			}
 		}
 		
-		childSetEnabled("media_tex",  TRUE);
-		childSetEnabled( "edit_media", LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo);
-		childSetEnabled( "delete_media", TRUE);
-		childSetEnabled( "add_media", FALSE );
+		getChildView("media_tex")->setEnabled(TRUE);
+		getChildView("edit_media")->setEnabled(LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo);
+		getChildView("delete_media")->setEnabled(TRUE);
+		getChildView("add_media")->setEnabled(FALSE );
 	}
 	media_info->setText(media_title);
 	
diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp
index 84ea353dabe..d80f26657d8 100644
--- a/indra/newview/llfloatertopobjects.cpp
+++ b/indra/newview/llfloatertopobjects.cpp
@@ -98,7 +98,7 @@ LLFloaterTopObjects::~LLFloaterTopObjects()
 BOOL LLFloaterTopObjects::postBuild()
 {
 	LLScrollListCtrl *objects_list = getChild<LLScrollListCtrl>("objects_list");
-	childSetFocus("objects_list");
+	getChild<LLUICtrl>("objects_list")->setFocus(TRUE);
 	objects_list->setDoubleClickCallback(onDoubleClickObjectsList, this);
 	objects_list->setCommitOnSelectionChange(TRUE);
 
@@ -253,7 +253,7 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data)
 		LLUIString format = getString("top_scripts_text");
 		format.setArg("[COUNT]", llformat("%d", total_count));
 		format.setArg("[TIME]", llformat("%0.1f", mtotalScore));
-		childSetValue("title_text", LLSD(format));
+		getChild<LLUICtrl>("title_text")->setValue(LLSD(format));
 	}
 	else
 	{
@@ -262,7 +262,7 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data)
 		list->setColumnLabel("mono_time", "");
 		LLUIString format = getString("top_colliders_text");
 		format.setArg("[COUNT]", llformat("%d", total_count));
-		childSetValue("title_text", LLSD(format));
+		getChild<LLUICtrl>("title_text")->setValue(LLSD(format));
 	}
 }
 
@@ -282,13 +282,13 @@ void LLFloaterTopObjects::updateSelectionInfo()
 
 	std::string object_id_string = object_id.asString();
 
-	childSetValue("id_editor", LLSD(object_id_string));
+	getChild<LLUICtrl>("id_editor")->setValue(LLSD(object_id_string));
 	LLScrollListItem* sli = list->getFirstSelected();
 	llassert(sli);
 	if (sli)
 	{
-		childSetValue("object_name_editor", sli->getColumn(1)->getValue().asString());
-		childSetValue("owner_name_editor", sli->getColumn(2)->getValue().asString());
+		getChild<LLUICtrl>("object_name_editor")->setValue(sli->getColumn(1)->getValue().asString());
+		getChild<LLUICtrl>("owner_name_editor")->setValue(sli->getColumn(2)->getValue().asString());
 	}
 }
 
@@ -312,7 +312,7 @@ void LLFloaterTopObjects::doToObjects(int action, bool all)
 	LLViewerRegion* region = gAgent.getRegion();
 	if (!region) return;
 
-	LLCtrlListInterface *list = childGetListInterface("objects_list");
+	LLCtrlListInterface *list = getChild<LLUICtrl>("objects_list")->getListInterface();
 	if (!list || list->getItemCount() == 0) return;
 
 	uuid_vec_t::iterator id_itor;
@@ -457,14 +457,14 @@ void LLFloaterTopObjects::onRefresh()
 void LLFloaterTopObjects::onGetByObjectName()
 {
 	mFlags  = STAT_FILTER_BY_OBJECT;
-	mFilter = childGetText("object_name_editor");
+	mFilter = getChild<LLUICtrl>("object_name_editor")->getValue().asString();
 	onRefresh();
 }
 
 void LLFloaterTopObjects::onGetByOwnerName()
 {
 	mFlags  = STAT_FILTER_BY_OWNER;
-	mFilter = childGetText("owner_name_editor");
+	mFilter = getChild<LLUICtrl>("owner_name_editor")->getValue().asString();
 	onRefresh();
 }
 
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp
index 104827f4a3d..b4c6f7da9eb 100644
--- a/indra/newview/llfloatertos.cpp
+++ b/indra/newview/llfloatertos.cpp
@@ -199,8 +199,8 @@ void LLFloaterTOS::draw()
 void LLFloaterTOS::updateAgree(LLUICtrl*, void* userdata )
 {
 	LLFloaterTOS* self = (LLFloaterTOS*) userdata;
-	bool agree = self->childGetValue("agree_chk").asBoolean(); 
-	self->childSetEnabled("Continue", agree);
+	bool agree = self->getChild<LLUICtrl>("agree_chk")->getValue().asBoolean(); 
+	self->getChildView("Continue")->setEnabled(agree);
 }
 
 // static
diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp
index 1b6ef0e97a1..41f4580495b 100644
--- a/indra/newview/llfloateruipreview.cpp
+++ b/indra/newview/llfloateruipreview.cpp
@@ -475,7 +475,7 @@ BOOL LLFloaterUIPreview::postBuild()
 	// Set up overlap panel
 	mOverlapPanel = getChild<LLOverlapPanel>("overlap_panel");
 
-	childSetVisible("overlap_scroll", mHighlightingOverlaps);
+	getChildView("overlap_scroll")->setVisible( mHighlightingOverlaps);
 	
 	mDelim = gDirUtilp->getDirDelimiter();	// initialize delimiter to dir sep slash
 
@@ -1699,7 +1699,7 @@ void LLFloaterUIPreview::onClickToggleOverlapping()
 		setRect(LLRect(getRect().mLeft,getRect().mTop,getRect().mRight + mOverlapPanel->getRect().getWidth(),getRect().mBottom));
 		setResizeLimits(width + mOverlapPanel->getRect().getWidth(), height);
 	}
-	childSetVisible("overlap_scroll", mHighlightingOverlaps);
+	getChildView("overlap_scroll")->setVisible( mHighlightingOverlaps);
 }
 
 void LLFloaterUIPreview::findOverlapsInChildren(LLView* parent)
diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp
index 0e802e97364..fa871d84a62 100644
--- a/indra/newview/llfloaterurlentry.cpp
+++ b/indra/newview/llfloaterurlentry.cpp
@@ -111,7 +111,7 @@ BOOL LLFloaterURLEntry::postBuild()
 	// clear media list button
 	LLSD parcel_history = LLURLHistory::getURLHistory("parcel");
 	bool enable_clear_button = parcel_history.size() > 0 ? true : false;
-	childSetEnabled( "clear_btn", enable_clear_button );
+	getChildView("clear_btn")->setEnabled(enable_clear_button );
 
 	// OK button
 	childSetAction("ok_btn", onBtnOK, this);
@@ -163,7 +163,7 @@ void LLFloaterURLEntry::headerFetchComplete(U32 status, const std::string& mime_
 	}
 	// Decrement the cursor
 	getWindow()->decBusyCount();
-	childSetVisible("loading_label", false);
+	getChildView("loading_label")->setVisible( false);
 	closeFloater();
 }
 
@@ -236,13 +236,13 @@ void LLFloaterURLEntry::onBtnOK( void* userdata )
 	}
 
 	// Grey the buttons until we get the header response
-	self->childSetEnabled("ok_btn", false);
-	self->childSetEnabled("cancel_btn", false);
-	self->childSetEnabled("media_entry", false);
+	self->getChildView("ok_btn")->setEnabled(false);
+	self->getChildView("cancel_btn")->setEnabled(false);
+	self->getChildView("media_entry")->setEnabled(false);
 
 	// show progress bar here?
 	getWindow()->incBusyCount();
-	self->childSetVisible("loading_label", true);
+	self->getChildView("loading_label")->setVisible( true);
 }
 
 // static
@@ -284,7 +284,7 @@ bool LLFloaterURLEntry::callback_clear_url_list(const LLSD& notification, const
 		LLURLHistory::clear("parcel");
 
 		// cleared the list so disable Clear button
-		childSetEnabled( "clear_btn", false );
+		getChildView("clear_btn")->setEnabled(false );
 	}
 	return false;
 }
diff --git a/indra/newview/llfloatervoicedevicesettings.cpp b/indra/newview/llfloatervoicedevicesettings.cpp
index 48095ff2000..036ef32016d 100644
--- a/indra/newview/llfloatervoicedevicesettings.cpp
+++ b/indra/newview/llfloatervoicedevicesettings.cpp
@@ -103,7 +103,7 @@ void LLPanelVoiceDeviceSettings::draw()
 
 	// let user know that volume indicator is not yet available
 	bool is_in_tuning_mode = LLVoiceClient::getInstance()->inTuningMode();
-	childSetVisible("wait_text", !is_in_tuning_mode);
+	getChildView("wait_text")->setVisible( !is_in_tuning_mode);
 
 	LLPanel::draw();
 
diff --git a/indra/newview/llfloatervoiceeffect.cpp b/indra/newview/llfloatervoiceeffect.cpp
index 61fe50e3016..160c15bc341 100644
--- a/indra/newview/llfloatervoiceeffect.cpp
+++ b/indra/newview/llfloatervoiceeffect.cpp
@@ -66,7 +66,7 @@ BOOL LLFloaterVoiceEffect::postBuild()
 {
 	setDefaultBtn("record_btn");
 	getChild<LLButton>("record_btn")->setFocus(true);
-	childSetTextArg("voice_morphing_link", "[URL]", LLTrans::getString("voice_morphing_url"));
+	getChild<LLUICtrl>("voice_morphing_link")->setTextArg("[URL]", LLTrans::getString("voice_morphing_url"));
 
 	mVoiceEffectList = getChild<LLScrollListCtrl>("voice_effect_list");
 	if (mVoiceEffectList)
diff --git a/indra/newview/llfloaterwater.cpp b/indra/newview/llfloaterwater.cpp
index 1bbee2625ca..0f0d85cacbb 100644
--- a/indra/newview/llfloaterwater.cpp
+++ b/indra/newview/llfloaterwater.cpp
@@ -210,7 +210,7 @@ void LLFloaterWater::syncMenu()
 	param_mgr->mFogColor = current_params.getVector4(param_mgr->mFogColor.mName, err);
 
 	LLColor4 col = param_mgr->getFogColor();
-	childSetValue("WaterGlow", col.mV[3]);
+	getChild<LLUICtrl>("WaterGlow")->setValue(col.mV[3]);
 	col.mV[3] = 1.0f;
 	LLColorSwatchCtrl* colCtrl = getChild<LLColorSwatchCtrl>("WaterFogColor");
 
@@ -221,41 +221,41 @@ void LLFloaterWater::syncMenu()
 		log(current_params.getFloat(param_mgr->mFogDensity.mName, err)) / 
 		log(param_mgr->mFogDensity.mBase);
 	param_mgr->setDensitySliderValue(param_mgr->mFogDensity.mExp);
-	childSetValue("WaterFogDensity", param_mgr->mFogDensity.mExp);
+	getChild<LLUICtrl>("WaterFogDensity")->setValue(param_mgr->mFogDensity.mExp);
 	
 	param_mgr->mUnderWaterFogMod.mX = 
 		current_params.getFloat(param_mgr->mUnderWaterFogMod.mName, err);
-	childSetValue("WaterUnderWaterFogMod", param_mgr->mUnderWaterFogMod.mX);
+	getChild<LLUICtrl>("WaterUnderWaterFogMod")->setValue(param_mgr->mUnderWaterFogMod.mX);
 
 	param_mgr->mNormalScale = current_params.getVector3(param_mgr->mNormalScale.mName, err);
-	childSetValue("WaterNormalScaleX", param_mgr->mNormalScale.mX);
-	childSetValue("WaterNormalScaleY", param_mgr->mNormalScale.mY);
-	childSetValue("WaterNormalScaleZ", param_mgr->mNormalScale.mZ);
+	getChild<LLUICtrl>("WaterNormalScaleX")->setValue(param_mgr->mNormalScale.mX);
+	getChild<LLUICtrl>("WaterNormalScaleY")->setValue(param_mgr->mNormalScale.mY);
+	getChild<LLUICtrl>("WaterNormalScaleZ")->setValue(param_mgr->mNormalScale.mZ);
 
 	// Fresnel
 	param_mgr->mFresnelScale.mX = current_params.getFloat(param_mgr->mFresnelScale.mName, err);
-	childSetValue("WaterFresnelScale", param_mgr->mFresnelScale.mX);
+	getChild<LLUICtrl>("WaterFresnelScale")->setValue(param_mgr->mFresnelScale.mX);
 	param_mgr->mFresnelOffset.mX = current_params.getFloat(param_mgr->mFresnelOffset.mName, err);
-	childSetValue("WaterFresnelOffset", param_mgr->mFresnelOffset.mX);
+	getChild<LLUICtrl>("WaterFresnelOffset")->setValue(param_mgr->mFresnelOffset.mX);
 
 	// Scale Above/Below
 	param_mgr->mScaleAbove.mX = current_params.getFloat(param_mgr->mScaleAbove.mName, err);
-	childSetValue("WaterScaleAbove", param_mgr->mScaleAbove.mX);
+	getChild<LLUICtrl>("WaterScaleAbove")->setValue(param_mgr->mScaleAbove.mX);
 	param_mgr->mScaleBelow.mX = current_params.getFloat(param_mgr->mScaleBelow.mName, err);
-	childSetValue("WaterScaleBelow", param_mgr->mScaleBelow.mX);
+	getChild<LLUICtrl>("WaterScaleBelow")->setValue(param_mgr->mScaleBelow.mX);
 
 	// blur mult
 	param_mgr->mBlurMultiplier.mX = current_params.getFloat(param_mgr->mBlurMultiplier.mName, err);
-	childSetValue("WaterBlurMult", param_mgr->mBlurMultiplier.mX);
+	getChild<LLUICtrl>("WaterBlurMult")->setValue(param_mgr->mBlurMultiplier.mX);
 
 	// wave directions
 	param_mgr->mWave1Dir = current_params.getVector2(param_mgr->mWave1Dir.mName, err);
-	childSetValue("WaterWave1DirX", param_mgr->mWave1Dir.mX);
-	childSetValue("WaterWave1DirY", param_mgr->mWave1Dir.mY);
+	getChild<LLUICtrl>("WaterWave1DirX")->setValue(param_mgr->mWave1Dir.mX);
+	getChild<LLUICtrl>("WaterWave1DirY")->setValue(param_mgr->mWave1Dir.mY);
 
 	param_mgr->mWave2Dir = current_params.getVector2(param_mgr->mWave2Dir.mName, err);
-	childSetValue("WaterWave2DirX", param_mgr->mWave2Dir.mX);
-	childSetValue("WaterWave2DirY", param_mgr->mWave2Dir.mY);
+	getChild<LLUICtrl>("WaterWave2DirX")->setValue(param_mgr->mWave2Dir.mX);
+	getChild<LLUICtrl>("WaterWave2DirY")->setValue(param_mgr->mWave2Dir.mY);
 
 	LLTextureCtrl* textCtrl = getChild<LLTextureCtrl>("WaterNormalMap");
 	textCtrl->setImageAssetID(param_mgr->getNormalMapID());
@@ -339,7 +339,7 @@ void LLFloaterWater::onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* col
 		std::string name = colorControl->mSliderName;
 		name.append("I");
 		
-		childSetValue(name, colorControl->mR);
+		getChild<LLUICtrl>(name)->setValue(colorControl->mR);
 	}
 
 	colorControl->update(LLWaterParamManager::instance()->mCurParams);
@@ -362,7 +362,7 @@ void LLFloaterWater::onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* col
 		std::string name = colorControl->mSliderName;
 		name.append("I");
 
-		childSetValue(name, colorControl->mG);
+		getChild<LLUICtrl>(name)->setValue(colorControl->mG);
 
 	}
 
@@ -386,7 +386,7 @@ void LLFloaterWater::onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* col
 		std::string name = colorControl->mSliderName;
 		name.append("I");
 
-		childSetValue(name, colorControl->mB);
+		getChild<LLUICtrl>(name)->setValue(colorControl->mB);
 	}
 
 	colorControl->update(LLWaterParamManager::instance()->mCurParams);
@@ -455,9 +455,9 @@ void LLFloaterWater::onColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* col
 		}
 
 		// set the sliders to the new vals
-		childSetValue(rName, colorControl->mR);
-		childSetValue(gName, colorControl->mG);
-		childSetValue(bName, colorControl->mB);
+		getChild<LLUICtrl>(rName)->setValue(colorControl->mR);
+		getChild<LLUICtrl>(gName)->setValue(colorControl->mG);
+		getChild<LLUICtrl>(bName)->setValue(colorControl->mB);
 	}
 
 	// now update the current parameters and send them to shaders
diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp
index c1b15c578c2..c8ea6e406bd 100644
--- a/indra/newview/llfloaterwindlight.cpp
+++ b/indra/newview/llfloaterwindlight.cpp
@@ -278,31 +278,31 @@ void LLFloaterWindLight::syncMenu()
 
 	// blue horizon
 	param_mgr->mBlueHorizon = currentParams.getVector(param_mgr->mBlueHorizon.mName, err);
-	childSetValue("WLBlueHorizonR", param_mgr->mBlueHorizon.r / 2.0);
-	childSetValue("WLBlueHorizonG", param_mgr->mBlueHorizon.g / 2.0);
-	childSetValue("WLBlueHorizonB", param_mgr->mBlueHorizon.b / 2.0);
-	childSetValue("WLBlueHorizonI", 
+	getChild<LLUICtrl>("WLBlueHorizonR")->setValue(param_mgr->mBlueHorizon.r / 2.0);
+	getChild<LLUICtrl>("WLBlueHorizonG")->setValue(param_mgr->mBlueHorizon.g / 2.0);
+	getChild<LLUICtrl>("WLBlueHorizonB")->setValue(param_mgr->mBlueHorizon.b / 2.0);
+	getChild<LLUICtrl>("WLBlueHorizonI")->setValue(
 		std::max(param_mgr->mBlueHorizon.r / 2.0, 
 			std::max(param_mgr->mBlueHorizon.g / 2.0, 
 				param_mgr->mBlueHorizon.b / 2.0)));
 
 	// haze density, horizon, mult, and altitude
 	param_mgr->mHazeDensity = currentParams.getVector(param_mgr->mHazeDensity.mName, err);
-	childSetValue("WLHazeDensity", param_mgr->mHazeDensity.r);
+	getChild<LLUICtrl>("WLHazeDensity")->setValue(param_mgr->mHazeDensity.r);
 	param_mgr->mHazeHorizon = currentParams.getVector(param_mgr->mHazeHorizon.mName, err);
-	childSetValue("WLHazeHorizon", param_mgr->mHazeHorizon.r);
+	getChild<LLUICtrl>("WLHazeHorizon")->setValue(param_mgr->mHazeHorizon.r);
 	param_mgr->mDensityMult = currentParams.getVector(param_mgr->mDensityMult.mName, err);
-	childSetValue("WLDensityMult", param_mgr->mDensityMult.x * 
+	getChild<LLUICtrl>("WLDensityMult")->setValue(param_mgr->mDensityMult.x * 
 		param_mgr->mDensityMult.mult);
 	param_mgr->mMaxAlt = currentParams.getVector(param_mgr->mMaxAlt.mName, err);
-	childSetValue("WLMaxAltitude", param_mgr->mMaxAlt.x);
+	getChild<LLUICtrl>("WLMaxAltitude")->setValue(param_mgr->mMaxAlt.x);
 
 	// blue density
 	param_mgr->mBlueDensity = currentParams.getVector(param_mgr->mBlueDensity.mName, err);
-	childSetValue("WLBlueDensityR", param_mgr->mBlueDensity.r / 2.0);
-	childSetValue("WLBlueDensityG", param_mgr->mBlueDensity.g / 2.0);
-	childSetValue("WLBlueDensityB", param_mgr->mBlueDensity.b / 2.0);
-	childSetValue("WLBlueDensityI", 
+	getChild<LLUICtrl>("WLBlueDensityR")->setValue(param_mgr->mBlueDensity.r / 2.0);
+	getChild<LLUICtrl>("WLBlueDensityG")->setValue(param_mgr->mBlueDensity.g / 2.0);
+	getChild<LLUICtrl>("WLBlueDensityB")->setValue(param_mgr->mBlueDensity.b / 2.0);
+	getChild<LLUICtrl>("WLBlueDensityI")->setValue(
 		std::max(param_mgr->mBlueDensity.r / 2.0, 
 		std::max(param_mgr->mBlueDensity.g / 2.0, param_mgr->mBlueDensity.b / 2.0)));
 
@@ -310,93 +310,93 @@ void LLFloaterWindLight::syncMenu()
 	
 	// sunlight
 	param_mgr->mSunlight = currentParams.getVector(param_mgr->mSunlight.mName, err);
-	childSetValue("WLSunlightR", param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE);
-	childSetValue("WLSunlightG", param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE);
-	childSetValue("WLSunlightB", param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE);
-	childSetValue("WLSunlightI", 
+	getChild<LLUICtrl>("WLSunlightR")->setValue(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE);
+	getChild<LLUICtrl>("WLSunlightG")->setValue(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE);
+	getChild<LLUICtrl>("WLSunlightB")->setValue(param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE);
+	getChild<LLUICtrl>("WLSunlightI")->setValue(
 		std::max(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE, 
 		std::max(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE)));
 
 	// glow
 	param_mgr->mGlow = currentParams.getVector(param_mgr->mGlow.mName, err);
-	childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f);
-	childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f);
+	getChild<LLUICtrl>("WLGlowR")->setValue(2 - param_mgr->mGlow.r / 20.0f);
+	getChild<LLUICtrl>("WLGlowB")->setValue(-param_mgr->mGlow.b / 5.0f);
 		
 	// ambient
 	param_mgr->mAmbient = currentParams.getVector(param_mgr->mAmbient.mName, err);
-	childSetValue("WLAmbientR", param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE);
-	childSetValue("WLAmbientG", param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE);
-	childSetValue("WLAmbientB", param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE);
-	childSetValue("WLAmbientI", 
+	getChild<LLUICtrl>("WLAmbientR")->setValue(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE);
+	getChild<LLUICtrl>("WLAmbientG")->setValue(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE);
+	getChild<LLUICtrl>("WLAmbientB")->setValue(param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE);
+	getChild<LLUICtrl>("WLAmbientI")->setValue(
 		std::max(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE, 
 		std::max(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE)));		
 
-	childSetValue("WLSunAngle", param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI);
-	childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI);
+	getChild<LLUICtrl>("WLSunAngle")->setValue(param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI);
+	getChild<LLUICtrl>("WLEastAngle")->setValue(param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI);
 
 	// Clouds
 
 	// Cloud Color
 	param_mgr->mCloudColor = currentParams.getVector(param_mgr->mCloudColor.mName, err);
-	childSetValue("WLCloudColorR", param_mgr->mCloudColor.r);
-	childSetValue("WLCloudColorG", param_mgr->mCloudColor.g);
-	childSetValue("WLCloudColorB", param_mgr->mCloudColor.b);
-	childSetValue("WLCloudColorI", 
+	getChild<LLUICtrl>("WLCloudColorR")->setValue(param_mgr->mCloudColor.r);
+	getChild<LLUICtrl>("WLCloudColorG")->setValue(param_mgr->mCloudColor.g);
+	getChild<LLUICtrl>("WLCloudColorB")->setValue(param_mgr->mCloudColor.b);
+	getChild<LLUICtrl>("WLCloudColorI")->setValue(
 		std::max(param_mgr->mCloudColor.r, 
 		std::max(param_mgr->mCloudColor.g, param_mgr->mCloudColor.b)));
 
 	// Cloud
 	param_mgr->mCloudMain = currentParams.getVector(param_mgr->mCloudMain.mName, err);
-	childSetValue("WLCloudX", param_mgr->mCloudMain.r);
-	childSetValue("WLCloudY", param_mgr->mCloudMain.g);
-	childSetValue("WLCloudDensity", param_mgr->mCloudMain.b);
+	getChild<LLUICtrl>("WLCloudX")->setValue(param_mgr->mCloudMain.r);
+	getChild<LLUICtrl>("WLCloudY")->setValue(param_mgr->mCloudMain.g);
+	getChild<LLUICtrl>("WLCloudDensity")->setValue(param_mgr->mCloudMain.b);
 
 	// Cloud Detail
 	param_mgr->mCloudDetail = currentParams.getVector(param_mgr->mCloudDetail.mName, err);
-	childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r);
-	childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g);
-	childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b);
+	getChild<LLUICtrl>("WLCloudDetailX")->setValue(param_mgr->mCloudDetail.r);
+	getChild<LLUICtrl>("WLCloudDetailY")->setValue(param_mgr->mCloudDetail.g);
+	getChild<LLUICtrl>("WLCloudDetailDensity")->setValue(param_mgr->mCloudDetail.b);
 
 	// Cloud extras
 	param_mgr->mCloudCoverage = currentParams.getVector(param_mgr->mCloudCoverage.mName, err);
 	param_mgr->mCloudScale = currentParams.getVector(param_mgr->mCloudScale.mName, err);
-	childSetValue("WLCloudCoverage", param_mgr->mCloudCoverage.x);
-	childSetValue("WLCloudScale", param_mgr->mCloudScale.x);
+	getChild<LLUICtrl>("WLCloudCoverage")->setValue(param_mgr->mCloudCoverage.x);
+	getChild<LLUICtrl>("WLCloudScale")->setValue(param_mgr->mCloudScale.x);
 
 	// cloud scrolling
 	bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX();
 	bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY();
-	childSetValue("WLCloudLockX", lockX);
-	childSetValue("WLCloudLockY", lockY);
-	childSetValue("DrawClassicClouds", gSavedSettings.getBOOL("SkyUseClassicClouds"));
+	getChild<LLUICtrl>("WLCloudLockX")->setValue(lockX);
+	getChild<LLUICtrl>("WLCloudLockY")->setValue(lockY);
+	getChild<LLUICtrl>("DrawClassicClouds")->setValue(gSavedSettings.getBOOL("SkyUseClassicClouds"));
 	
 	// disable if locked, enable if not
 	if(lockX) 
 	{
-		childDisable("WLCloudScrollX");
+		getChildView("WLCloudScrollX")->setEnabled(FALSE);
 	} else {
-		childEnable("WLCloudScrollX");
+		getChildView("WLCloudScrollX")->setEnabled(TRUE);
 	}
 	if(lockY)
 	{
-		childDisable("WLCloudScrollY");
+		getChildView("WLCloudScrollY")->setEnabled(FALSE);
 	} else {
-		childEnable("WLCloudScrollY");
+		getChildView("WLCloudScrollY")->setEnabled(TRUE);
 	}
 
 	// *HACK cloud scrolling is off my an additive of 10
-	childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f);
-	childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f);
+	getChild<LLUICtrl>("WLCloudScrollX")->setValue(param_mgr->mCurParams.getCloudScrollX() - 10.0f);
+	getChild<LLUICtrl>("WLCloudScrollY")->setValue(param_mgr->mCurParams.getCloudScrollY() - 10.0f);
 
 	param_mgr->mDistanceMult = currentParams.getVector(param_mgr->mDistanceMult.mName, err);
-	childSetValue("WLDistanceMult", param_mgr->mDistanceMult.x);
+	getChild<LLUICtrl>("WLDistanceMult")->setValue(param_mgr->mDistanceMult.x);
 
 	// Tweak extras
 
 	param_mgr->mWLGamma = currentParams.getVector(param_mgr->mWLGamma.mName, err);
-	childSetValue("WLGamma", param_mgr->mWLGamma.x);
+	getChild<LLUICtrl>("WLGamma")->setValue(param_mgr->mWLGamma.x);
 
-	childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness());
+	getChild<LLUICtrl>("WLStarAlpha")->setValue(param_mgr->mCurParams.getStarBrightness());
 
 	LLTabContainer* tab = getChild<LLTabContainer>("WindLight Tabs");
 	LLPanel* panel = getChild<LLPanel>("Scattering");
@@ -428,11 +428,11 @@ void LLFloaterWindLight::onColorControlRMoved(LLUICtrl* ctrl, WLColorControl* co
 		name.append("I");
 		
 		if(colorControl->isSunOrAmbientColor) {
-			childSetValue(name, colorControl->r / 3);
+			getChild<LLUICtrl>(name)->setValue(colorControl->r / 3);
 		} else if(colorControl->isBlueHorizonOrDensity) {
-			childSetValue(name, colorControl->r / 2);
+			getChild<LLUICtrl>(name)->setValue(colorControl->r / 2);
 		} else {
-			childSetValue(name, colorControl->r);
+			getChild<LLUICtrl>(name)->setValue(colorControl->r);
 		}
 	}
 
@@ -463,11 +463,11 @@ void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, WLColorControl* co
 		name.append("I");
 
 		if(colorControl->isSunOrAmbientColor) {
-			childSetValue(name, colorControl->g / 3);
+			getChild<LLUICtrl>(name)->setValue(colorControl->g / 3);
 		} else if(colorControl->isBlueHorizonOrDensity) {
-			childSetValue(name, colorControl->g / 2);
+			getChild<LLUICtrl>(name)->setValue(colorControl->g / 2);
 		} else {
-			childSetValue(name, colorControl->g);
+			getChild<LLUICtrl>(name)->setValue(colorControl->g);
 		}
 	}
 
@@ -498,11 +498,11 @@ void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, WLColorControl* co
 		name.append("I");
 
 		if(colorControl->isSunOrAmbientColor) {
-			childSetValue(name, colorControl->b / 3);
+			getChild<LLUICtrl>(name)->setValue(colorControl->b / 3);
 		} else if(colorControl->isBlueHorizonOrDensity) {
-			childSetValue(name, colorControl->b / 2);
+			getChild<LLUICtrl>(name)->setValue(colorControl->b / 2);
 		} else {
-			childSetValue(name, colorControl->b);
+			getChild<LLUICtrl>(name)->setValue(colorControl->b);
 		}
 	}
 
@@ -572,24 +572,24 @@ void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, WLColorControl* co
 		// divide sun color vals by three
 		if(colorControl->isSunOrAmbientColor) 
 		{
-			childSetValue(rName, colorControl->r/3);
-			childSetValue(gName, colorControl->g/3);
-			childSetValue(bName, colorControl->b/3);	
+			getChild<LLUICtrl>(rName)->setValue(colorControl->r/3);
+			getChild<LLUICtrl>(gName)->setValue(colorControl->g/3);
+			getChild<LLUICtrl>(bName)->setValue(colorControl->b/3);	
 		
 		} 
 		else if(colorControl->isBlueHorizonOrDensity) 
 		{
-			childSetValue(rName, colorControl->r/2);
-			childSetValue(gName, colorControl->g/2);
-			childSetValue(bName, colorControl->b/2);	
+			getChild<LLUICtrl>(rName)->setValue(colorControl->r/2);
+			getChild<LLUICtrl>(gName)->setValue(colorControl->g/2);
+			getChild<LLUICtrl>(bName)->setValue(colorControl->b/2);	
 		
 		} 
 		else 
 		{
 			// set the sliders to the new vals
-			childSetValue(rName, colorControl->r);
-			childSetValue(gName, colorControl->g);
-			childSetValue(bName, colorControl->b);
+			getChild<LLUICtrl>(rName)->setValue(colorControl->r);
+			getChild<LLUICtrl>(gName)->setValue(colorControl->g);
+			getChild<LLUICtrl>(bName)->setValue(colorControl->b);
 		}
 	}
 
diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index 983fd97b0ba..d5e8801247d 100644
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -247,7 +247,7 @@ BOOL LLFloaterWorldMap::postBuild()
 	landmark_combo->setTextEntryCallback( boost::bind(&LLFloaterWorldMap::onComboTextEntry, this) );
 
 	mCurZoomVal = log(LLWorldMapView::sMapScale)/log(2.f);
-	childSetValue("zoom slider", LLWorldMapView::sMapScale);
+	getChild<LLUICtrl>("zoom slider")->setValue(LLWorldMapView::sMapScale);
 
 	setDefaultBtn(NULL);
 
@@ -320,7 +320,7 @@ void LLFloaterWorldMap::onOpen(const LLSD& key)
 		const LLUUID landmark_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK);
 		LLInventoryModelBackgroundFetch::instance().start(landmark_folder_id);
 
-		childSetFocus("location", TRUE);
+		getChild<LLUICtrl>("location")->setFocus( TRUE);
 		gFocusMgr.triggerFocusFlash();
 
 		buildAvatarIDList();
@@ -358,9 +358,9 @@ BOOL LLFloaterWorldMap::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	{
 		if(mPanel->pointInView(x, y))
 		{
-			F32 slider_value = (F32)childGetValue("zoom slider").asReal();
+			F32 slider_value = (F32)getChild<LLUICtrl>("zoom slider")->getValue().asReal();
 			slider_value += ((F32)clicks * -0.3333f);
-			childSetValue("zoom slider", LLSD(slider_value));
+			getChild<LLUICtrl>("zoom slider")->setValue(LLSD(slider_value));
 			return TRUE;
 		}
 	}
@@ -388,32 +388,32 @@ void LLFloaterWorldMap::draw()
 	LLViewerRegion* regionp = gAgent.getRegion();
 	bool agent_on_prelude = (regionp && regionp->isPrelude());
 	bool enable_go_home = gAgent.isGodlike() || !agent_on_prelude;
-	childSetEnabled("Go Home", enable_go_home);
+	getChildView("Go Home")->setEnabled(enable_go_home);
 
 	updateLocation();
 	
 	LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); 
 	if (LLTracker::TRACKING_AVATAR == tracking_status)
 	{
-		childSetColor("avatar_icon", map_track_color);
+		getChild<LLUICtrl>("avatar_icon")->setColor( map_track_color);
 	}
 	else
 	{
-		childSetColor("avatar_icon", map_track_disabled_color);
+		getChild<LLUICtrl>("avatar_icon")->setColor( map_track_disabled_color);
 	}
 
 	if (LLTracker::TRACKING_LANDMARK == tracking_status)
 	{
-		childSetColor("landmark_icon", map_track_color);
+		getChild<LLUICtrl>("landmark_icon")->setColor( map_track_color);
 	}
 	else
 	{
-		childSetColor("landmark_icon", map_track_disabled_color);
+		getChild<LLUICtrl>("landmark_icon")->setColor( map_track_disabled_color);
 	}
 
 	if (LLTracker::TRACKING_LOCATION == tracking_status)
 	{
-		childSetColor("location_icon", map_track_color);
+		getChild<LLUICtrl>("location_icon")->setColor( map_track_color);
 	}
 	else
 	{
@@ -423,11 +423,11 @@ void LLFloaterWorldMap::draw()
 			double value = fmod(seconds, 2);
 			value = 0.5 + 0.5*cos(value * F_PI);
 			LLColor4 loading_color(0.0, F32(value/2), F32(value), 1.0);
-			childSetColor("location_icon", loading_color);
+			getChild<LLUICtrl>("location_icon")->setColor( loading_color);
 		}
 		else
 		{
-			childSetColor("location_icon", map_track_disabled_color);
+			getChild<LLUICtrl>("location_icon")->setColor( map_track_disabled_color);
 		}
 	}
 
@@ -437,16 +437,16 @@ void LLFloaterWorldMap::draw()
 		centerOnTarget(TRUE);
 	}
 
-	childSetEnabled("Teleport", (BOOL)tracking_status);
-//	childSetEnabled("Clear", (BOOL)tracking_status);
-	childSetEnabled("Show Destination", (BOOL)tracking_status || LLWorldMap::getInstance()->isTracking());
-	childSetEnabled("copy_slurl", (mSLURL.isValid()) );
+	getChildView("Teleport")->setEnabled((BOOL)tracking_status);
+//	getChildView("Clear")->setEnabled((BOOL)tracking_status);
+	getChildView("Show Destination")->setEnabled((BOOL)tracking_status || LLWorldMap::getInstance()->isTracking());
+	getChildView("copy_slurl")->setEnabled((mSLURL.isValid()) );
 
 	setMouseOpaque(TRUE);
 	getDragHandle()->setMouseOpaque(TRUE);
 
 	//RN: snaps to zoom value because interpolation caused jitter in the text rendering
-	if (!mZoomTimer.getStarted() && mCurZoomVal != (F32)childGetValue("zoom slider").asReal())
+	if (!mZoomTimer.getStarted() && mCurZoomVal != (F32)getChild<LLUICtrl>("zoom slider")->getValue().asReal())
 	{
 		mZoomTimer.start();
 	}
@@ -456,7 +456,7 @@ void LLFloaterWorldMap::draw()
 		interp = 1.f;
 		mZoomTimer.stop();
 	}
-	mCurZoomVal = lerp(mCurZoomVal, (F32)childGetValue("zoom slider").asReal(), interp);
+	mCurZoomVal = lerp(mCurZoomVal, (F32)getChild<LLUICtrl>("zoom slider")->getValue().asReal(), interp);
 	F32 map_scale = 256.f*pow(2.f, mCurZoomVal);
 	LLWorldMapView::setScale( map_scale );
 
@@ -464,13 +464,13 @@ void LLFloaterWorldMap::draw()
 	// If above threshold level (i.e. low res) -> Disable all checkboxes
 	// If under threshold level (i.e. high res) -> Enable all checkboxes
 	bool enable = LLWorldMapView::showRegionInfo();
-	childSetEnabled("people_chk", enable);
-	childSetEnabled("infohub_chk", enable);
-	childSetEnabled("telehub_chk", enable);
-	childSetEnabled("land_for_sale_chk", enable);
-	childSetEnabled("event_chk", enable);
-	childSetEnabled("events_mature_chk", enable);
-	childSetEnabled("events_adult_chk", enable);
+	getChildView("people_chk")->setEnabled(enable);
+	getChildView("infohub_chk")->setEnabled(enable);
+	getChildView("telehub_chk")->setEnabled(enable);
+	getChildView("land_for_sale_chk")->setEnabled(enable);
+	getChildView("event_chk")->setEnabled(enable);
+	getChildView("events_mature_chk")->setEnabled(enable);
+	getChildView("events_adult_chk")->setEnabled(enable);
 	
 	LLFloater::draw();
 }
@@ -494,7 +494,7 @@ void LLFloaterWorldMap::trackAvatar( const LLUUID& avatar_id, const std::string&
 		// convenience.
 		if(gAgent.isGodlike())
 		{
-			childSetValue("spin z", LLSD(200.f));
+			getChild<LLUICtrl>("spin z")->setValue(LLSD(200.f));
 		}
 		// Don't re-request info if we already have it or we won't have it in time to teleport
 		if (mTrackedStatus != LLTracker::TRACKING_AVATAR || name != mTrackedAvatarName)
@@ -636,7 +636,7 @@ void LLFloaterWorldMap::updateLocation()
 				mSetToUserPosition = FALSE;
 
 				// Fill out the location field
-				childSetValue("location", agent_sim_name);
+				getChild<LLUICtrl>("location")->setValue(agent_sim_name);
 
 				// Figure out where user is
 				// Set the current SLURL
@@ -666,7 +666,7 @@ void LLFloaterWorldMap::updateLocation()
 			}
 		}
 
-		childSetValue("location", sim_name);
+		getChild<LLUICtrl>("location")->setValue(sim_name);
 
 		// simNameFromPosGlobal can fail, so don't give the user an invalid SLURL
 		if ( gotSimName )
@@ -697,7 +697,7 @@ void LLFloaterWorldMap::trackURL(const std::string& region_name, S32 x_coord, S3
 	else
 	{
 		// fill in UI based on URL
-		gFloaterWorldMap->childSetValue("location", region_name);
+		gFloaterWorldMap->getChild<LLUICtrl>("location")->setValue(region_name);
 
 		// Save local coords to highlight position after region global
 		// position is returned.
@@ -1094,7 +1094,7 @@ void LLFloaterWorldMap::onLocationFocusChanged( LLFocusableElement* focus )
 void LLFloaterWorldMap::updateSearchEnabled()
 {
 	if (childHasKeyboardFocus("location") && 
-		childGetValue("location").asString().length() > 0)
+		getChild<LLUICtrl>("location")->getValue().asString().length() > 0)
 	{
 		setDefaultBtn("DoSearch");
 	}
@@ -1115,14 +1115,14 @@ void LLFloaterWorldMap::onLocationCommit()
 	mCompletingRegionName = "";
 	mLastRegionName = "";
 
-	std::string str = childGetValue("location").asString();
+	std::string str = getChild<LLUICtrl>("location")->getValue().asString();
 
 	// Trim any leading and trailing spaces in the search target
 	std::string saved_str = str;
 	LLStringUtil::trim( str );
 	if ( str != saved_str )
 	{	// Set the value in the UI if any spaces were removed
-		childSetValue("location", str);
+		getChild<LLUICtrl>("location")->setValue(str);
 	}
 
 	LLStringUtil::toLower(str);
@@ -1243,7 +1243,7 @@ void LLFloaterWorldMap::teleport()
 		&& av_tracker.haveTrackingInfo() )
 	{
 		pos_global = av_tracker.getGlobalPos();
-		pos_global.mdV[VZ] = childGetValue("spin z");
+		pos_global.mdV[VZ] = getChild<LLUICtrl>("spin z")->getValue();
 	}
 	else if ( LLTracker::TRACKING_LANDMARK == tracking_status)
 	{
@@ -1412,7 +1412,7 @@ void LLFloaterWorldMap::updateSims(bool found_null_sim)
 	if (!match.isUndefined())
 	{
 		list->selectByValue(match);
-		childSetFocus("search_results");
+		getChild<LLUICtrl>("search_results")->setFocus(TRUE);
 		onCommitSearchResult();
 	}
 
@@ -1460,7 +1460,7 @@ void LLFloaterWorldMap::onCommitSearchResult()
 			pos_global.mdV[VY] += (F64)pos_local.mV[VY];
 			pos_global.mdV[VZ] = (F64)pos_local.mV[VZ];
 
-			childSetValue("location", sim_name);
+			getChild<LLUICtrl>("location")->setValue(sim_name);
 			trackLocation(pos_global);
 			setDefaultBtn("Teleport");
 			break;
@@ -1475,13 +1475,13 @@ void LLFloaterWorldMap::onChangeMaturity()
 	bool can_access_mature = gAgent.canAccessMature();
 	bool can_access_adult = gAgent.canAccessAdult();
 
-	childSetVisible("events_mature_icon", can_access_mature);
-	childSetVisible("events_mature_label", can_access_mature);
-	childSetVisible("events_mature_chk", can_access_mature);
+	getChildView("events_mature_icon")->setVisible( can_access_mature);
+	getChildView("events_mature_label")->setVisible( can_access_mature);
+	getChildView("events_mature_chk")->setVisible( can_access_mature);
 
-	childSetVisible("events_adult_icon", can_access_adult);
-	childSetVisible("events_adult_label", can_access_adult);
-	childSetVisible("events_adult_chk", can_access_adult);
+	getChildView("events_adult_icon")->setVisible( can_access_adult);
+	getChildView("events_adult_label")->setVisible( can_access_adult);
+	getChildView("events_adult_chk")->setVisible( can_access_adult);
 
 	// disable mature / adult events.
 	if (!can_access_mature)
diff --git a/indra/newview/llgrouplist.cpp b/indra/newview/llgrouplist.cpp
index da5196df45c..125936b9c70 100644
--- a/indra/newview/llgrouplist.cpp
+++ b/indra/newview/llgrouplist.cpp
@@ -212,8 +212,8 @@ void LLGroupList::addNewItem(const LLUUID& id, const std::string& name, const LL
 	item->setName(name, mNameFilter);
 	item->setGroupIconID(icon_id);
 
-	item->childSetVisible("info_btn", false);
-	item->childSetVisible("profile_btn", false);
+	item->getChildView("info_btn")->setVisible( false);
+	item->getChildView("profile_btn")->setVisible( false);
 	item->setGroupIconVisible(mShowIcons);
 
 	addItem(item, id, pos);
@@ -323,16 +323,16 @@ void LLGroupListItem::setValue( const LLSD& value )
 {
 	if (!value.isMap()) return;
 	if (!value.has("selected")) return;
-	childSetVisible("selected_icon", value["selected"]);
+	getChildView("selected_icon")->setVisible( value["selected"]);
 }
 
 void LLGroupListItem::onMouseEnter(S32 x, S32 y, MASK mask)
 {
-	childSetVisible("hovered_icon", true);
+	getChildView("hovered_icon")->setVisible( true);
 	if (mGroupID.notNull()) // don't show the info button for the "none" group
 	{
 		mInfoBtn->setVisible(true);
-		childSetVisible("profile_btn", true);
+		getChildView("profile_btn")->setVisible( true);
 	}
 
 	LLPanel::onMouseEnter(x, y, mask);
@@ -340,9 +340,9 @@ void LLGroupListItem::onMouseEnter(S32 x, S32 y, MASK mask)
 
 void LLGroupListItem::onMouseLeave(S32 x, S32 y, MASK mask)
 {
-	childSetVisible("hovered_icon", false);
+	getChildView("hovered_icon")->setVisible( false);
 	mInfoBtn->setVisible(false);
-	childSetVisible("profile_btn", false);
+	getChildView("profile_btn")->setVisible( false);
 
 	LLPanel::onMouseLeave(x, y, mask);
 }
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 21313f9df70..d2bddfdd9a1 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -1709,12 +1709,12 @@ void LLOutgoingCallDialog::show(const LLSD& key)
 			old_caller_name = LLTextUtil::formatPhoneNumber(old_caller_name);
 		}
 
-		childSetTextArg("leaving", "[CURRENT_CHAT]", old_caller_name);
+		getChild<LLUICtrl>("leaving")->setTextArg("[CURRENT_CHAT]", old_caller_name);
 		show_oldchannel = true;
 	}
 	else
 	{
-		childSetTextArg("leaving", "[CURRENT_CHAT]", getString("localchat"));		
+		getChild<LLUICtrl>("leaving")->setTextArg("[CURRENT_CHAT]", getString("localchat"));		
 	}
 
 	if (!mPayload["disconnected_channel_name"].asString().empty())
@@ -1724,16 +1724,16 @@ void LLOutgoingCallDialog::show(const LLSD& key)
 		{
 			channel_name = LLTextUtil::formatPhoneNumber(channel_name);
 		}
-		childSetTextArg("nearby", "[VOICE_CHANNEL_NAME]", channel_name);
+		getChild<LLUICtrl>("nearby")->setTextArg("[VOICE_CHANNEL_NAME]", channel_name);
 
 		// skipping "You will now be reconnected to nearby" in notification when call is ended by disabling voice,
 		// so no reconnection to nearby chat happens (EXT-4397)
 		bool voice_works = LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking();
 		std::string reconnect_nearby = voice_works ? LLTrans::getString("reconnect_nearby") : std::string();
-		childSetTextArg("nearby", "[RECONNECT_NEARBY]", reconnect_nearby);
+		getChild<LLUICtrl>("nearby")->setTextArg("[RECONNECT_NEARBY]", reconnect_nearby);
 
 		const std::string& nearby_str = mPayload["ended_by_agent"] ? NEARBY_P2P_BY_AGENT : NEARBY_P2P_BY_OTHER;
-		childSetTextArg(nearby_str, "[RECONNECT_NEARBY]", reconnect_nearby);
+		getChild<LLUICtrl>(nearby_str)->setTextArg("[RECONNECT_NEARBY]", reconnect_nearby);
 	}
 
 	std::string callee_name = mPayload["session_name"].asString();
@@ -1753,8 +1753,8 @@ void LLOutgoingCallDialog::show(const LLSD& key)
 	setTitle(callee_name);
 
 	LLSD callee_id = mPayload["other_user_id"];
-	childSetTextArg("calling", "[CALLEE_NAME]", callee_name);
-	childSetTextArg("connecting", "[CALLEE_NAME]", callee_name);
+	getChild<LLUICtrl>("calling")->setTextArg("[CALLEE_NAME]", callee_name);
+	getChild<LLUICtrl>("connecting")->setTextArg("[CALLEE_NAME]", callee_name);
 
 	// for outgoing group calls callee_id == group id == session id
 	setIcon(callee_id, callee_id);
@@ -1939,7 +1939,7 @@ BOOL LLIncomingCallDialog::postBuild()
 
 	//it's not possible to connect to existing Ad-Hoc/Group chat through incoming ad-hoc call
 	//and no IM for avaline
-	childSetVisible("Start IM", is_avatar && notify_box_type != "VoiceInviteAdHoc" && notify_box_type != "VoiceInviteGroup");
+	getChildView("Start IM")->setVisible( is_avatar && notify_box_type != "VoiceInviteAdHoc" && notify_box_type != "VoiceInviteGroup");
 
 	setCanDrag(FALSE);
 
@@ -1963,12 +1963,12 @@ void LLIncomingCallDialog::onOpen(const LLSD& key)
 	if (voice && !voice->getSessionName().empty())
 	{
 		args["[CURRENT_CHAT]"] = voice->getSessionName();
-		childSetText("question", getString(key["question_type"].asString(), args));
+		getChild<LLUICtrl>("question")->setValue(getString(key["question_type"].asString(), args));
 	}
 	else
 	{
 		args["[CURRENT_CHAT]"] = getString("localchat");
-		childSetText("question", getString(key["question_type"].asString(), args));
+		getChild<LLUICtrl>("question")->setValue(getString(key["question_type"].asString(), args));
 	}
 }
 
diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp
index d9fdc876dbd..3c437907c41 100644
--- a/indra/newview/llinspectavatar.cpp
+++ b/indra/newview/llinspectavatar.cpp
@@ -371,7 +371,7 @@ void LLInspectAvatar::requestUpdate()
 	//remove avatar id from cache to get fresh info
 	LLAvatarIconIDCache::getInstance()->remove(mAvatarID);
 
-	childSetValue("avatar_icon", LLSD(mAvatarID) );
+	getChild<LLUICtrl>("avatar_icon")->setValue(LLSD(mAvatarID) );
 
 	gCacheName->get(mAvatarID, FALSE,
 		boost::bind(&LLInspectAvatar::nameUpdatedCallback,
@@ -621,7 +621,7 @@ void LLInspectAvatar::nameUpdatedCallback(
 	if (id == mAvatarID)
 	{
 		mAvatarName = first + " " + last;
-		childSetValue("user_name", LLSD(mAvatarName) );
+		getChild<LLUICtrl>("user_name")->setValue(LLSD(mAvatarName) );
 	}
 }
 
diff --git a/indra/newview/llinspectgroup.cpp b/indra/newview/llinspectgroup.cpp
index 7fd7b69021c..f054d612624 100644
--- a/indra/newview/llinspectgroup.cpp
+++ b/indra/newview/llinspectgroup.cpp
@@ -239,7 +239,7 @@ void LLInspectGroup::nameUpdatedCallback(
 	if (id == mGroupID)
 	{
 		// group names are returned as a first name
-		childSetValue("group_name", LLSD(first) );
+		getChild<LLUICtrl>("group_name")->setValue(LLSD(first) );
 	}
 	
 	// Otherwise possibly a request for an older inspector, ignore it
diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp
index 67295179b21..18ef3e19ee0 100644
--- a/indra/newview/llnavigationbar.cpp
+++ b/indra/newview/llnavigationbar.cpp
@@ -816,9 +816,9 @@ void LLNavigationBar::showNavigationPanel(BOOL visible)
 		}
 	}
 
-	childSetVisible("bg_icon", visible && fpVisible);
-	childSetVisible("bg_icon_no_fav_bevel", visible && !fpVisible);
-	childSetVisible("bg_icon_no_nav_bevel", !visible && fpVisible);
+	getChildView("bg_icon")->setVisible( visible && fpVisible);
+	getChildView("bg_icon_no_fav_bevel")->setVisible( visible && !fpVisible);
+	getChildView("bg_icon_no_nav_bevel")->setVisible( !visible && fpVisible);
 }
 
 void LLNavigationBar::showFavoritesPanel(BOOL visible)
@@ -883,9 +883,9 @@ void LLNavigationBar::showFavoritesPanel(BOOL visible)
 		getParent()->reshape(nbRect.getWidth(), nbRect.getHeight());
 	}
 
-	childSetVisible("bg_icon", npVisible && visible);
-	childSetVisible("bg_icon_no_fav_bevel", npVisible && !visible);
-	childSetVisible("bg_icon_no_nav_bevel", !npVisible && visible);
+	getChildView("bg_icon")->setVisible( npVisible && visible);
+	getChildView("bg_icon_no_fav_bevel")->setVisible( npVisible && !visible);
+	getChildView("bg_icon_no_nav_bevel")->setVisible( !npVisible && visible);
 
 	fb->setVisible(visible);
 }
diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index 534bb6e3fc7..c8f97ecd139 100644
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -176,14 +176,14 @@ void LLPanelAvatarNotes::onOpen(const LLSD& key)
 	fillRightsData();
 
 	//Disable "Add Friend" button for friends.
-	childSetEnabled("add_friend", !LLAvatarActions::isFriend(getAvatarId()));
+	getChildView("add_friend")->setEnabled(!LLAvatarActions::isFriend(getAvatarId()));
 }
 
 void LLPanelAvatarNotes::fillRightsData()
 {
-	childSetValue("status_check", FALSE);
-	childSetValue("map_check", FALSE);
-	childSetValue("objects_check", FALSE);
+	getChild<LLUICtrl>("status_check")->setValue(FALSE);
+	getChild<LLUICtrl>("map_check")->setValue(FALSE);
+	getChild<LLUICtrl>("objects_check")->setValue(FALSE);
 
 	const LLRelationship* relation = LLAvatarTracker::instance().getBuddyInfo(getAvatarId());
 	// If true - we are viewing friend's profile, enable check boxes and set values.
@@ -191,9 +191,9 @@ void LLPanelAvatarNotes::fillRightsData()
 	{
 		S32 rights = relation->getRightsGrantedTo();
 
-		childSetValue("status_check",LLRelationship::GRANT_ONLINE_STATUS & rights ? TRUE : FALSE);
-		childSetValue("map_check",LLRelationship::GRANT_MAP_LOCATION & rights ? TRUE : FALSE);
-		childSetValue("objects_check",LLRelationship::GRANT_MODIFY_OBJECTS & rights ? TRUE : FALSE);
+		getChild<LLUICtrl>("status_check")->setValue(LLRelationship::GRANT_ONLINE_STATUS & rights ? TRUE : FALSE);
+		getChild<LLUICtrl>("map_check")->setValue(LLRelationship::GRANT_MAP_LOCATION & rights ? TRUE : FALSE);
+		getChild<LLUICtrl>("objects_check")->setValue(LLRelationship::GRANT_MODIFY_OBJECTS & rights ? TRUE : FALSE);
 
 	}
 
@@ -202,7 +202,7 @@ void LLPanelAvatarNotes::fillRightsData()
 
 void LLPanelAvatarNotes::onCommitNotes()
 {
-	std::string notes = childGetValue("notes_edit").asString();
+	std::string notes = getChild<LLUICtrl>("notes_edit")->getValue().asString();
 	LLAvatarPropertiesProcessor::getInstance()-> sendNotes(getAvatarId(),notes);
 }
 
@@ -217,8 +217,8 @@ void LLPanelAvatarNotes::rightsConfirmationCallback(const LLSD& notification,
 	}
 	else
 	{
-		childSetValue("objects_check",
-				childGetValue("objects_check").asBoolean() ? FALSE : TRUE);
+		getChild<LLUICtrl>("objects_check")->setValue(
+				getChild<LLUICtrl>("objects_check")->getValue().asBoolean() ? FALSE : TRUE);
 	}
 }
 
@@ -261,14 +261,14 @@ void LLPanelAvatarNotes::onCommitRights()
 
 	S32 rights = 0;
 
-	if(childGetValue("status_check").asBoolean())
+	if(getChild<LLUICtrl>("status_check")->getValue().asBoolean())
 		rights |= LLRelationship::GRANT_ONLINE_STATUS;
-	if(childGetValue("map_check").asBoolean())
+	if(getChild<LLUICtrl>("map_check")->getValue().asBoolean())
 		rights |= LLRelationship::GRANT_MAP_LOCATION;
-	if(childGetValue("objects_check").asBoolean())
+	if(getChild<LLUICtrl>("objects_check")->getValue().asBoolean())
 		rights |= LLRelationship::GRANT_MODIFY_OBJECTS;
 
-	bool allow_modify_objects = childGetValue("objects_check").asBoolean();
+	bool allow_modify_objects = getChild<LLUICtrl>("objects_check")->getValue().asBoolean();
 
 	// if modify objects checkbox clicked
 	if (buddy_relationship->isRightGrantedTo(
@@ -291,8 +291,8 @@ void LLPanelAvatarNotes::processProperties(void* data, EAvatarProcessorType type
 		LLAvatarNotes* avatar_notes = static_cast<LLAvatarNotes*>(data);
 		if(avatar_notes && getAvatarId() == avatar_notes->target_id)
 		{
-			childSetValue("notes_edit",avatar_notes->notes);
-			childSetEnabled("notes edit", true);
+			getChild<LLUICtrl>("notes_edit")->setValue(avatar_notes->notes);
+			getChildView("notes edit")->setEnabled(true);
 
 			LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(),this);
 		}
@@ -301,15 +301,15 @@ void LLPanelAvatarNotes::processProperties(void* data, EAvatarProcessorType type
 
 void LLPanelAvatarNotes::resetData()
 {
-	childSetValue("notes_edit",LLStringUtil::null);
+	getChild<LLUICtrl>("notes_edit")->setValue(LLStringUtil::null);
 	// Default value is TRUE
-	childSetValue("status_check", TRUE);
+	getChild<LLUICtrl>("status_check")->setValue(TRUE);
 }
 
 void LLPanelAvatarNotes::resetControls()
 {
 	//Disable "Add Friend" button for friends.
-	childSetEnabled("add_friend", TRUE);
+	getChildView("add_friend")->setEnabled(TRUE);
 
 	enableCheckboxes(false);
 }
@@ -341,9 +341,9 @@ void LLPanelAvatarNotes::onShareButtonClick()
 
 void LLPanelAvatarNotes::enableCheckboxes(bool enable)
 {
-	childSetEnabled("status_check", enable);
-	childSetEnabled("map_check", enable);
-	childSetEnabled("objects_check", enable);
+	getChildView("status_check")->setEnabled(enable);
+	getChildView("map_check")->setEnabled(enable);
+	getChildView("objects_check")->setEnabled(enable);
 }
 
 LLPanelAvatarNotes::~LLPanelAvatarNotes()
@@ -361,7 +361,7 @@ LLPanelAvatarNotes::~LLPanelAvatarNotes()
 // virtual, called by LLAvatarTracker
 void LLPanelAvatarNotes::changed(U32 mask)
 {
-	childSetEnabled("teleport", LLAvatarTracker::instance().isBuddyOnline(getAvatarId()));
+	getChildView("teleport")->setEnabled(LLAvatarTracker::instance().isBuddyOnline(getAvatarId()));
 
 	// update rights to avoid have checkboxes enabled when friendship is terminated. EXT-4947.
 	fillRightsData();
@@ -375,7 +375,7 @@ void LLPanelAvatarNotes::onChange(EStatusType status, const std::string &channel
 		return;
 	}
 
-	childSetEnabled("call", LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking());
+	getChildView("call")->setEnabled(LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking());
 }
 
 void LLPanelAvatarNotes::setAvatarId(const LLUUID& id)
@@ -457,17 +457,17 @@ void LLPanelProfileTab::updateButtons()
 	
 	if(LLAvatarActions::isFriend(getAvatarId()))
 	{
-		childSetEnabled("teleport", is_buddy_online);
+		getChildView("teleport")->setEnabled(is_buddy_online);
 	}
 	else
 	{
-		childSetEnabled("teleport", true);
+		getChildView("teleport")->setEnabled(true);
 	}
 
 	bool enable_map_btn = (is_buddy_online &&
 			       is_agent_mappable(getAvatarId()))
 		|| gAgent.isGodlike();
-	childSetEnabled("show_on_map_btn", enable_map_btn);
+	getChildView("show_on_map_btn")->setEnabled(enable_map_btn);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -528,7 +528,7 @@ void LLPanelAvatarProfile::onOpen(const LLSD& key)
 	mGroups.clear();
 
 	//Disable "Add Friend" button for friends.
-	childSetEnabled("add_friend", !LLAvatarActions::isFriend(getAvatarId()));
+	getChildView("add_friend")->setEnabled(!LLAvatarActions::isFriend(getAvatarId()));
 }
 
 void LLPanelAvatarProfile::updateData()
@@ -544,32 +544,32 @@ void LLPanelAvatarProfile::updateData()
 
 void LLPanelAvatarProfile::resetControls()
 {
-	childSetVisible("status_panel", true);
-	childSetVisible("profile_buttons_panel", true);
-	childSetVisible("title_groups_text", true);
-	childSetVisible("sl_groups", true);
-	childSetEnabled("add_friend", true);
+	getChildView("status_panel")->setVisible( true);
+	getChildView("profile_buttons_panel")->setVisible( true);
+	getChildView("title_groups_text")->setVisible( true);
+	getChildView("sl_groups")->setVisible( true);
+	getChildView("add_friend")->setEnabled(true);
 
-	childSetVisible("status_me_panel", false);
-	childSetVisible("profile_me_buttons_panel", false);
-	childSetVisible("account_actions_panel", false);
+	getChildView("status_me_panel")->setVisible( false);
+	getChildView("profile_me_buttons_panel")->setVisible( false);
+	getChildView("account_actions_panel")->setVisible( false);
 }
 
 void LLPanelAvatarProfile::resetData()
 {
 	mGroups.clear();
-	childSetValue("2nd_life_pic",LLUUID::null);
-	childSetValue("real_world_pic",LLUUID::null);
-	childSetValue("online_status",LLStringUtil::null);
-	childSetValue("status_message",LLStringUtil::null);
-	childSetValue("sl_description_edit",LLStringUtil::null);
-	childSetValue("fl_description_edit",LLStringUtil::null);
-	childSetValue("sl_groups",LLStringUtil::null);
-	childSetValue("homepage_edit",LLStringUtil::null);
-	childSetValue("register_date",LLStringUtil::null);
-	childSetValue("acc_status_text",LLStringUtil::null);
-	childSetTextArg("partner_text", "[FIRST]", LLStringUtil::null);
-	childSetTextArg("partner_text", "[LAST]", LLStringUtil::null);
+	getChild<LLUICtrl>("2nd_life_pic")->setValue(LLUUID::null);
+	getChild<LLUICtrl>("real_world_pic")->setValue(LLUUID::null);
+	getChild<LLUICtrl>("online_status")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("status_message")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("sl_description_edit")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("fl_description_edit")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("sl_groups")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("homepage_edit")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("register_date")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("acc_status_text")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("partner_text")->setTextArg("[FIRST]", LLStringUtil::null);
+	getChild<LLUICtrl>("partner_text")->setTextArg("[LAST]", LLStringUtil::null);
 }
 
 void LLPanelAvatarProfile::processProperties(void* data, EAvatarProcessorType type)
@@ -631,7 +631,7 @@ void LLPanelAvatarProfile::processGroupProperties(const LLAvatarGroups* avatar_g
 		groups += group_url;
 	}
 
-	childSetValue("sl_groups", groups);
+	getChild<LLUICtrl>("sl_groups")->setValue(groups);
 }
 
 void LLPanelAvatarProfile::fillCommonData(const LLAvatarData* avatar_data)
@@ -647,15 +647,15 @@ void LLPanelAvatarProfile::fillCommonData(const LLAvatarData* avatar_data)
 	}
 	args["[AGE]"] = LLDateUtil::ageFromDate( avatar_data->born_on, LLDate::now());
 	std::string register_date = getString("RegisterDateFormat", args);
-	childSetValue("register_date", register_date );
-	childSetValue("sl_description_edit", avatar_data->about_text);
-	childSetValue("fl_description_edit",avatar_data->fl_about_text);
-	childSetValue("2nd_life_pic", avatar_data->image_id);
-	childSetValue("real_world_pic", avatar_data->fl_image_id);
-	childSetValue("homepage_edit", avatar_data->profile_url);
+	getChild<LLUICtrl>("register_date")->setValue(register_date );
+	getChild<LLUICtrl>("sl_description_edit")->setValue(avatar_data->about_text);
+	getChild<LLUICtrl>("fl_description_edit")->setValue(avatar_data->fl_about_text);
+	getChild<LLUICtrl>("2nd_life_pic")->setValue(avatar_data->image_id);
+	getChild<LLUICtrl>("real_world_pic")->setValue(avatar_data->fl_image_id);
+	getChild<LLUICtrl>("homepage_edit")->setValue(avatar_data->profile_url);
 
 	// Hide home page textbox if no page was set to fix "homepage URL appears clickable without URL - EXT-4734"
-	childSetVisible("homepage_edit", !avatar_data->profile_url.empty());
+	getChildView("homepage_edit")->setVisible( !avatar_data->profile_url.empty());
 }
 
 void LLPanelAvatarProfile::fillPartnerData(const LLAvatarData* avatar_data)
@@ -681,7 +681,7 @@ void LLPanelAvatarProfile::fillAccountStatus(const LLAvatarData* avatar_data)
 	// dataserver/lldataavatar.cpp for privacy considerations
 	args["[AGEVERIFICATION]"] = "";
 	std::string caption_text = getString("CaptionTextAcctInfo", args);
-	childSetValue("acc_status_text", caption_text);
+	getChild<LLUICtrl>("acc_status_text")->setValue(caption_text);
 }
 
 void LLPanelAvatarProfile::pay()
@@ -797,7 +797,7 @@ LLPanelAvatarProfile::~LLPanelAvatarProfile()
 // virtual, called by LLAvatarTracker
 void LLPanelAvatarProfile::changed(U32 mask)
 {
-	childSetEnabled("teleport", LLAvatarTracker::instance().isBuddyOnline(getAvatarId()));
+	getChildView("teleport")->setEnabled(LLAvatarTracker::instance().isBuddyOnline(getAvatarId()));
 }
 
 // virtual
@@ -808,7 +808,7 @@ void LLPanelAvatarProfile::onChange(EStatusType status, const std::string &chann
 		return;
 	}
 
-	childSetEnabled("call", LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking());
+	getChildView("call")->setEnabled(LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking());
 }
 
 void LLPanelAvatarProfile::setAvatarId(const LLUUID& id)
@@ -861,12 +861,12 @@ void LLPanelMyProfile::processProfileProperties(const LLAvatarData* avatar_data)
 
 void LLPanelMyProfile::resetControls()
 {
-	childSetVisible("status_panel", false);
-	childSetVisible("profile_buttons_panel", false);
-	childSetVisible("title_groups_text", false);
-	childSetVisible("sl_groups", false);
-	childSetVisible("status_me_panel", true);
-	childSetVisible("profile_me_buttons_panel", true);
+	getChildView("status_panel")->setVisible( false);
+	getChildView("profile_buttons_panel")->setVisible( false);
+	getChildView("title_groups_text")->setVisible( false);
+	getChildView("sl_groups")->setVisible( false);
+	getChildView("status_me_panel")->setVisible( true);
+	getChildView("profile_me_buttons_panel")->setVisible( true);
 }
 
 
diff --git a/indra/newview/llpanelblockedlist.cpp b/indra/newview/llpanelblockedlist.cpp
index c72f0f8012c..d24c2f7f1b2 100644
--- a/indra/newview/llpanelblockedlist.cpp
+++ b/indra/newview/llpanelblockedlist.cpp
@@ -132,7 +132,7 @@ void LLPanelBlockedList::refreshBlockedList()
 void LLPanelBlockedList::updateButtons()
 {
 	bool hasSelected = NULL != mBlockedList->getFirstSelected();
-	childSetEnabled("Unblock", hasSelected);
+	getChildView("Unblock")->setEnabled(hasSelected);
 }
 
 
@@ -269,7 +269,7 @@ void LLFloaterGetBlockedObjectName::applyBlocking()
 {
 	if (mGetObjectNameCallback)
 	{
-		const std::string& text = childGetValue("object_name").asString();
+		const std::string& text = getChild<LLUICtrl>("object_name")->getValue().asString();
 		mGetObjectNameCallback(text);
 	}
 	closeFloater();
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index af6214385b4..09b718f8b85 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -263,7 +263,7 @@ void LLPanelClassifiedInfo::processProperties(void* data, EAvatarProcessorType t
 			setSimName(c_info->sim_name);
 
 			setClassifiedLocation(createLocationText(c_info->parcel_name, c_info->sim_name, c_info->pos_global));
-			childSetValue("category", LLClassifiedInfo::sCategories[c_info->category]);
+			getChild<LLUICtrl>("category")->setValue(LLClassifiedInfo::sCategories[c_info->category]);
 
 			static std::string mature_str = getString("type_mature");
 			static std::string pg_str = getString("type_pg");
@@ -271,20 +271,20 @@ void LLPanelClassifiedInfo::processProperties(void* data, EAvatarProcessorType t
 			static std::string date_fmt = getString("date_fmt");
 
 			bool mature = is_cf_mature(c_info->flags);
-			childSetValue("content_type", mature ? mature_str : pg_str);
+			getChild<LLUICtrl>("content_type")->setValue(mature ? mature_str : pg_str);
 			getChild<LLIconCtrl>("content_type_moderate")->setVisible(mature);
 			getChild<LLIconCtrl>("content_type_general")->setVisible(!mature);
 
 			std::string auto_renew_str = is_cf_auto_renew(c_info->flags) ? 
 				getString("auto_renew_on") : getString("auto_renew_off");
-			childSetValue("auto_renew", auto_renew_str);
+			getChild<LLUICtrl>("auto_renew")->setValue(auto_renew_str);
 
 			price_str.setArg("[PRICE]", llformat("%d", c_info->price_for_listing));
-			childSetValue("price_for_listing", LLSD(price_str));
+			getChild<LLUICtrl>("price_for_listing")->setValue(LLSD(price_str));
 
 			std::string date_str = date_fmt;
 			LLStringUtil::format(date_str, LLSD().with("datetime", (S32) c_info->creation_date));
-			childSetText("creation_date", date_str);
+			getChild<LLUICtrl>("creation_date")->setValue(date_str);
 
 			setInfoLoaded(true);
 		}
@@ -311,13 +311,13 @@ void LLPanelClassifiedInfo::resetData()
 	mMapClicksNew		= 0;
 	mProfileClicksNew	= 0;
 
-	childSetText("category", LLStringUtil::null);
-	childSetText("content_type", LLStringUtil::null);
-	childSetText("click_through_text", LLStringUtil::null);
-	childSetText("price_for_listing", LLStringUtil::null);
-	childSetText("auto_renew", LLStringUtil::null);
-	childSetText("creation_date", LLStringUtil::null);
-	childSetText("click_through_text", LLStringUtil::null);
+	getChild<LLUICtrl>("category")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("content_type")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("click_through_text")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("price_for_listing")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("auto_renew")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("creation_date")->setValue(LLStringUtil::null);
+	getChild<LLUICtrl>("click_through_text")->setValue(LLStringUtil::null);
 	getChild<LLIconCtrl>("content_type_moderate")->setVisible(FALSE);
 	getChild<LLIconCtrl>("content_type_general")->setVisible(FALSE);
 }
@@ -326,40 +326,40 @@ void LLPanelClassifiedInfo::resetControls()
 {
 	bool is_self = getAvatarId() == gAgent.getID();
 
-	childSetEnabled("edit_btn", is_self);
-	childSetVisible("edit_btn", is_self);
-	childSetVisible("price_layout_panel", is_self);
-	childSetVisible("clickthrough_layout_panel", is_self);
+	getChildView("edit_btn")->setEnabled(is_self);
+	getChildView("edit_btn")->setVisible( is_self);
+	getChildView("price_layout_panel")->setVisible( is_self);
+	getChildView("clickthrough_layout_panel")->setVisible( is_self);
 }
 
 void LLPanelClassifiedInfo::setClassifiedName(const std::string& name)
 {
-	childSetValue("classified_name", name);
+	getChild<LLUICtrl>("classified_name")->setValue(name);
 }
 
 std::string LLPanelClassifiedInfo::getClassifiedName()
 {
-	return childGetValue("classified_name").asString();
+	return getChild<LLUICtrl>("classified_name")->getValue().asString();
 }
 
 void LLPanelClassifiedInfo::setDescription(const std::string& desc)
 {
-	childSetValue("classified_desc", desc);
+	getChild<LLUICtrl>("classified_desc")->setValue(desc);
 }
 
 std::string LLPanelClassifiedInfo::getDescription()
 {
-	return childGetValue("classified_desc").asString();
+	return getChild<LLUICtrl>("classified_desc")->getValue().asString();
 }
 
 void LLPanelClassifiedInfo::setClassifiedLocation(const std::string& location)
 {
-	childSetValue("classified_location", location);
+	getChild<LLUICtrl>("classified_location")->setValue(location);
 }
 
 std::string LLPanelClassifiedInfo::getClassifiedLocation()
 {
-	return childGetValue("classified_location").asString();
+	return getChild<LLUICtrl>("classified_location")->getValue().asString();
 }
 
 void LLPanelClassifiedInfo::setSnapshotId(const LLUUID& id)
@@ -382,7 +382,7 @@ void LLPanelClassifiedInfo::draw()
 
 LLUUID LLPanelClassifiedInfo::getSnapshotId()
 {
-	return childGetValue("classified_snapshot").asUUID();
+	return getChild<LLUICtrl>("classified_snapshot")->getValue().asUUID();
 }
 
 // static
@@ -437,9 +437,9 @@ void LLPanelClassifiedInfo::setClickThrough(
 		ct_str.setArg("[MAP]",		llformat("%d", self->mMapClicksNew + self->mMapClicksOld));
 		ct_str.setArg("[PROFILE]",	llformat("%d", self->mProfileClicksNew + self->mProfileClicksOld));
 
-		self->childSetText("click_through_text", ct_str.getString());
+		self->getChild<LLUICtrl>("click_through_text")->setValue(ct_str.getString());
 		// *HACK: remove this when there is enough room for click stats in the info panel
-		self->childSetToolTip("click_through_text", ct_str.getString());  
+		self->getChildView("click_through_text")->setToolTip(ct_str.getString());  
 
 		llinfos << "teleport: " << llformat("%d", self->mTeleportClicksNew + self->mTeleportClicksOld)
 				<< ", map: "    << llformat("%d", self->mMapClicksNew + self->mMapClicksOld)
@@ -687,8 +687,8 @@ void LLPanelClassifiedEdit::fillIn(const LLSD& key)
 			region_name = region->getName();
 		}
 
-		childSetValue("classified_name", makeClassifiedName());
-		childSetValue("classified_desc", desc);
+		getChild<LLUICtrl>("classified_name")->setValue(makeClassifiedName());
+		getChild<LLUICtrl>("classified_desc")->setValue(desc);
 		setSnapshotId(snapshot_id);
 		setClassifiedLocation(createLocationText(getLocationNotice(), region_name, getPosGlobal()));
 		// server will set valid parcel id
@@ -703,8 +703,8 @@ void LLPanelClassifiedEdit::fillIn(const LLSD& key)
 		setCategory((U32)key["category"].asInteger());
 		setContentType((U32)key["content_type"].asInteger());
 		setClassifiedLocation(key["location_text"]);
-		childSetValue("auto_renew", key["auto_renew"]);
-		childSetValue("price_for_listing", key["price_for_listing"].asInteger());
+		getChild<LLUICtrl>("auto_renew")->setValue(key["auto_renew"]);
+		getChild<LLUICtrl>("price_for_listing")->setValue(key["price_for_listing"].asInteger());
 	}
 }
 
@@ -735,7 +735,7 @@ void LLPanelClassifiedEdit::onOpen(const LLSD& key)
 	}
 
 	std::string save_btn_label = is_new ? getString("publish_label") : getString("save_label");
-	childSetLabelArg("save_changes_btn", "[LABEL]", save_btn_label);
+	getChild<LLUICtrl>("save_changes_btn")->setLabelArg("[LABEL]", save_btn_label);
 
 	enableVerbs(is_new);
 	enableEditing(is_new);
@@ -774,16 +774,16 @@ void LLPanelClassifiedEdit::processProperties(void* data, EAvatarProcessorType t
 			bool auto_renew = is_cf_auto_renew(c_info->flags);
 
 			setContentType(mature ? CB_ITEM_MATURE : CB_ITEM_PG);
-			childSetValue("auto_renew", auto_renew);
-			childSetValue("price_for_listing", c_info->price_for_listing);
-			childSetEnabled("price_for_listing", isNew());
+			getChild<LLUICtrl>("auto_renew")->setValue(auto_renew);
+			getChild<LLUICtrl>("price_for_listing")->setValue(c_info->price_for_listing);
+			getChildView("price_for_listing")->setEnabled(isNew());
 
 			resetDirty();
 			setInfoLoaded(true);
 			enableVerbs(false);
 
 			// for just created classified - in case user opened edit panel before processProperties() callback 
-			childSetLabelArg("save_changes_btn", "[LABEL]", getString("save_label"));
+			getChild<LLUICtrl>("save_changes_btn")->setLabelArg("[LABEL]", getString("save_label"));
 		}
 	}
 }
@@ -842,9 +842,9 @@ void LLPanelClassifiedEdit::resetControls()
 
 	getChild<LLComboBox>("category")->setCurrentByIndex(0);
 	getChild<LLComboBox>("content_type")->setCurrentByIndex(0);
-	childSetValue("auto_renew", false);
-	childSetValue("price_for_listing", MINIMUM_PRICE_FOR_LISTING);
-	childSetEnabled("price_for_listing", TRUE);
+	getChild<LLUICtrl>("auto_renew")->setValue(false);
+	getChild<LLUICtrl>("price_for_listing")->setValue(MINIMUM_PRICE_FOR_LISTING);
+	getChildView("price_for_listing")->setEnabled(TRUE);
 }
 
 bool LLPanelClassifiedEdit::canClose()
@@ -883,7 +883,7 @@ void LLPanelClassifiedEdit::setContentType(U32 content_type)
 
 bool LLPanelClassifiedEdit::getAutoRenew()
 {
-	return childGetValue("auto_renew").asBoolean();
+	return getChild<LLUICtrl>("auto_renew")->getValue().asBoolean();
 }
 
 void LLPanelClassifiedEdit::sendUpdate()
@@ -934,7 +934,7 @@ void LLPanelClassifiedEdit::setCategory(U32 category)
 
 U8 LLPanelClassifiedEdit::getFlags()
 {
-	bool auto_renew = childGetValue("auto_renew").asBoolean();
+	bool auto_renew = getChild<LLUICtrl>("auto_renew")->getValue().asBoolean();
 
 	LLComboBox* content_cb = getChild<LLComboBox>("content_type");
 	bool mature = content_cb->getCurrentIndex() == CB_ITEM_MATURE;
@@ -944,25 +944,25 @@ U8 LLPanelClassifiedEdit::getFlags()
 
 void LLPanelClassifiedEdit::enableVerbs(bool enable)
 {
-	childSetEnabled("save_changes_btn", enable);
+	getChildView("save_changes_btn")->setEnabled(enable);
 }
 
 void LLPanelClassifiedEdit::enableEditing(bool enable)
 {
-	childSetEnabled("classified_snapshot", enable);
-	childSetEnabled("classified_name", enable);
-	childSetEnabled("classified_desc", enable);
-	childSetEnabled("set_to_curr_location_btn", enable);
-	childSetEnabled("category", enable);
-	childSetEnabled("content_type", enable);
-	childSetEnabled("price_for_listing", enable);
-	childSetEnabled("auto_renew", enable);
+	getChildView("classified_snapshot")->setEnabled(enable);
+	getChildView("classified_name")->setEnabled(enable);
+	getChildView("classified_desc")->setEnabled(enable);
+	getChildView("set_to_curr_location_btn")->setEnabled(enable);
+	getChildView("category")->setEnabled(enable);
+	getChildView("content_type")->setEnabled(enable);
+	getChildView("price_for_listing")->setEnabled(enable);
+	getChildView("auto_renew")->setEnabled(enable);
 }
 
 void LLPanelClassifiedEdit::showEditing(bool show)
 {
-	childSetVisible("price_for_listing_label", show);
-	childSetVisible("price_for_listing", show);
+	getChildView("price_for_listing_label")->setVisible( show);
+	getChildView("price_for_listing")->setVisible( show);
 }
 
 std::string LLPanelClassifiedEdit::makeClassifiedName()
@@ -991,12 +991,12 @@ std::string LLPanelClassifiedEdit::makeClassifiedName()
 
 S32 LLPanelClassifiedEdit::getPriceForListing()
 {
-	return childGetValue("price_for_listing").asInteger();
+	return getChild<LLUICtrl>("price_for_listing")->getValue().asInteger();
 }
 
 void LLPanelClassifiedEdit::setPriceForListing(S32 price)
 {
-	childSetValue("price_for_listing", price);
+	getChild<LLUICtrl>("price_for_listing")->setValue(price);
 }
 
 void LLPanelClassifiedEdit::onSetLocationClick()
@@ -1154,12 +1154,12 @@ BOOL LLPublishClassifiedFloater::postBuild()
 
 void LLPublishClassifiedFloater::setPrice(S32 price)
 {
-	childSetValue("price_for_listing", price);
+	getChild<LLUICtrl>("price_for_listing")->setValue(price);
 }
 
 S32 LLPublishClassifiedFloater::getPrice()
 {
-	return childGetValue("price_for_listing").asInteger();
+	return getChild<LLUICtrl>("price_for_listing")->getValue().asInteger();
 }
 
 void LLPublishClassifiedFloater::setPublishClickedCallback(const commit_signal_t::slot_type& cb)
diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp
index f4c0a842e79..02db3d3715b 100644
--- a/indra/newview/llpanelcontents.cpp
+++ b/indra/newview/llpanelcontents.cpp
@@ -113,7 +113,7 @@ void LLPanelContents::getState(LLViewerObject *objectp )
 {
 	if( !objectp )
 	{
-		childSetEnabled("button new script",FALSE);
+		getChildView("button new script")->setEnabled(FALSE);
 		return;
 	}
 
@@ -127,7 +127,7 @@ void LLPanelContents::getState(LLViewerObject *objectp )
 	BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
 
 	// Edit script button - ok if object is editable and there's an unambiguous destination for the object.
-	childSetEnabled("button new script",
+	getChildView("button new script")->setEnabled(
 		editable &&
 		all_volume &&
 		((LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() == 1)
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 094769b8f5f..d8ae6ad9f40 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -1186,9 +1186,9 @@ void LLPanelEditWearable::toggleTypeSpecificControls(LLWearableType::EType type)
 	// Toggle controls specific to shape editing panel.
 	{
 		bool is_shape = (type == LLWearableType::WT_SHAPE);
-		childSetVisible("sex_radio", is_shape);
-		childSetVisible("female_icon", is_shape);
-		childSetVisible("male_icon", is_shape);
+		getChildView("sex_radio")->setVisible( is_shape);
+		getChildView("female_icon")->setVisible( is_shape);
+		getChildView("male_icon")->setVisible( is_shape);
 	}
 }
 
@@ -1388,7 +1388,7 @@ void LLPanelEditWearable::updateVerbs()
 	BOOL is_dirty = isDirty();
 
 	mBtnRevert->setEnabled(is_dirty);
-	childSetEnabled("save_as_button", is_dirty && can_copy);
+	getChildView("save_as_button")->setEnabled(is_dirty && can_copy);
 
 	if(isAgentAvatarValid())
 	{
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index e3503c065ba..36713f65bd7 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -394,8 +394,8 @@ void LLPanelFace::getState()
 		BOOL editable = objectp->permModify();
 
 		// only turn on auto-adjust button if there is a media renderer and the media is loaded
-		childSetEnabled("textbox autofix", editable);
-		childSetEnabled("button align", editable);
+		getChildView("textbox autofix")->setEnabled(editable);
+		getChildView("button align")->setEnabled(editable);
 		
 		//if ( LLMediaEngine::getInstance()->getMediaRenderer () )
 		//	if ( LLMediaEngine::getInstance()->getMediaRenderer ()->isLoaded () )
@@ -405,7 +405,7 @@ void LLPanelFace::getState()
 		//		
 		//		//mBtnAutoFix->setEnabled ( editable );
 		//	}
-		childSetEnabled("button apply",editable);
+		getChildView("button apply")->setEnabled(editable);
 
 		bool identical;
 		LLTextureCtrl*	texture_ctrl = getChild<LLTextureCtrl>("texture control");
@@ -445,8 +445,8 @@ void LLPanelFace::getState()
 
 			if(LLViewerMedia::textureHasMedia(id))
 			{
-				childSetEnabled("textbox autofix",editable);
-				childSetEnabled("button align",editable);
+				getChildView("textbox autofix")->setEnabled(editable);
+				getChildView("button align")->setEnabled(editable);
 			}
 			
 			if (identical)
@@ -514,12 +514,12 @@ void LLPanelFace::getState()
 				}
 			} func;
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_s );
-			childSetValue("TexScaleU",editable ? llabs(scale_s) : 0);
-			childSetTentative("TexScaleU",LLSD((BOOL)(!identical)));
-			childSetEnabled("TexScaleU",editable);
-			childSetValue("checkbox flip s",LLSD((BOOL)(scale_s < 0 ? TRUE : FALSE )));
-			childSetTentative("checkbox flip s",LLSD((BOOL)((!identical) ? TRUE : FALSE )));
-			childSetEnabled("checkbox flip s",editable);
+			getChild<LLUICtrl>("TexScaleU")->setValue(editable ? llabs(scale_s) : 0);
+			getChild<LLUICtrl>("TexScaleU")->setTentative(LLSD((BOOL)(!identical)));
+			getChildView("TexScaleU")->setEnabled(editable);
+			getChild<LLUICtrl>("checkbox flip s")->setValue(LLSD((BOOL)(scale_s < 0 ? TRUE : FALSE )));
+			getChild<LLUICtrl>("checkbox flip s")->setTentative(LLSD((BOOL)((!identical) ? TRUE : FALSE )));
+			getChildView("checkbox flip s")->setEnabled(editable);
 		}
 
 		{
@@ -533,17 +533,17 @@ void LLPanelFace::getState()
 			} func;
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_t );
 
-			childSetValue("TexScaleV",llabs(editable ? llabs(scale_t) : 0));
-			childSetTentative("TexScaleV",LLSD((BOOL)(!identical)));
-			childSetEnabled("TexScaleV",editable);
-			childSetValue("checkbox flip t",LLSD((BOOL)(scale_t< 0 ? TRUE : FALSE )));
-			childSetTentative("checkbox flip t",LLSD((BOOL)((!identical) ? TRUE : FALSE )));
-			childSetEnabled("checkbox flip t",editable);
+			getChild<LLUICtrl>("TexScaleV")->setValue(llabs(editable ? llabs(scale_t) : 0));
+			getChild<LLUICtrl>("TexScaleV")->setTentative(LLSD((BOOL)(!identical)));
+			getChildView("TexScaleV")->setEnabled(editable);
+			getChild<LLUICtrl>("checkbox flip t")->setValue(LLSD((BOOL)(scale_t< 0 ? TRUE : FALSE )));
+			getChild<LLUICtrl>("checkbox flip t")->setTentative(LLSD((BOOL)((!identical) ? TRUE : FALSE )));
+			getChildView("checkbox flip t")->setEnabled(editable);
 		}
 
 		// Texture offset
 		{
-			childSetEnabled("tex offset",editable);
+			getChildView("tex offset")->setEnabled(editable);
 			F32 offset_s = 0.f;
 			struct f4 : public LLSelectedTEGetFunctor<F32>
 			{
@@ -553,9 +553,9 @@ void LLPanelFace::getState()
 				}
 			} func;
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, offset_s );
-			childSetValue("TexOffsetU", editable ? offset_s : 0);
-			childSetTentative("TexOffsetU",!identical);
-			childSetEnabled("TexOffsetU",editable);
+			getChild<LLUICtrl>("TexOffsetU")->setValue(editable ? offset_s : 0);
+			getChild<LLUICtrl>("TexOffsetU")->setTentative(!identical);
+			getChildView("TexOffsetU")->setEnabled(editable);
 		}
 
 		{
@@ -568,9 +568,9 @@ void LLPanelFace::getState()
 				}
 			} func;
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, offset_t );
-			childSetValue("TexOffsetV", editable ? offset_t : 0);
-			childSetTentative("TexOffsetV",!identical);
-			childSetEnabled("TexOffsetV",editable);
+			getChild<LLUICtrl>("TexOffsetV")->setValue(editable ? offset_t : 0);
+			getChild<LLUICtrl>("TexOffsetV")->setTentative(!identical);
+			getChildView("TexOffsetV")->setEnabled(editable);
 		}
 
 		// Texture rotation
@@ -584,9 +584,9 @@ void LLPanelFace::getState()
 				}
 			} func;
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, rotation );
-			childSetValue("TexRot", editable ? rotation * RAD_TO_DEG : 0);
-			childSetTentative("TexRot",!identical);
-			childSetEnabled("TexRot",editable);
+			getChild<LLUICtrl>("TexRot")->setValue(editable ? rotation * RAD_TO_DEG : 0);
+			getChild<LLUICtrl>("TexRot")->setTentative(!identical);
+			getChildView("TexRot")->setEnabled(editable);
 		}
 
 		// Color swatch
@@ -612,13 +612,13 @@ void LLPanelFace::getState()
 		}
 		// Color transparency
 		{
-			childSetEnabled("color trans",editable);
+			getChildView("color trans")->setEnabled(editable);
 		}
 
 		F32 transparency = (1.f - color.mV[VALPHA]) * 100.f;
 		{
-			childSetValue("ColorTrans", editable ? transparency : 0);
-			childSetEnabled("ColorTrans",editable);
+			getChild<LLUICtrl>("ColorTrans")->setValue(editable ? transparency : 0);
+			getChildView("ColorTrans")->setEnabled(editable);
 		}
 
 		{
@@ -632,10 +632,10 @@ void LLPanelFace::getState()
 			} func;
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, glow );
 
-			childSetValue("glow",glow);
-			childSetEnabled("glow",editable);
-			childSetTentative("glow",!identical);
-			childSetEnabled("glow label",editable);
+			getChild<LLUICtrl>("glow")->setValue(glow);
+			getChildView("glow")->setEnabled(editable);
+			getChild<LLUICtrl>("glow")->setTentative(!identical);
+			getChildView("glow label")->setEnabled(editable);
 
 		}
 
@@ -660,9 +660,9 @@ void LLPanelFace::getState()
 			{
 				llwarns << "failed childGetSelectionInterface for 'combobox shininess'" << llendl;
 			}
-			childSetEnabled("combobox shininess",editable);
-			childSetTentative("combobox shininess",!identical);
-			childSetEnabled("label shininess",editable);
+			getChildView("combobox shininess")->setEnabled(editable);
+			getChild<LLUICtrl>("combobox shininess")->setTentative(!identical);
+			getChildView("label shininess")->setEnabled(editable);
 		}
 
 		{
@@ -685,9 +685,9 @@ void LLPanelFace::getState()
 			{
 				llwarns << "failed childGetSelectionInterface for 'combobox bumpiness'" << llendl;
 			}
-			childSetEnabled("combobox bumpiness",editable);
-			childSetTentative("combobox bumpiness",!identical);
-			childSetEnabled("label bumpiness",editable);
+			getChildView("combobox bumpiness")->setEnabled(editable);
+			getChild<LLUICtrl>("combobox bumpiness")->setTentative(!identical);
+			getChildView("label bumpiness")->setEnabled(editable);
 		}
 
 		{
@@ -711,14 +711,14 @@ void LLPanelFace::getState()
 			{
 				llwarns << "failed childGetSelectionInterface for 'combobox texgen'" << llendl;
 			}
-			childSetEnabled("combobox texgen",editable);
-			childSetTentative("combobox texgen",!identical);
-			childSetEnabled("tex gen",editable);
+			getChildView("combobox texgen")->setEnabled(editable);
+			getChild<LLUICtrl>("combobox texgen")->setTentative(!identical);
+			getChildView("tex gen")->setEnabled(editable);
 
 			if (selected_texgen == 1)
 			{
-				childSetValue("TexScaleU", 2.0f * childGetValue("TexScaleU").asReal() );
-				childSetValue("TexScaleV", 2.0f * childGetValue("TexScaleV").asReal() );
+				getChild<LLUICtrl>("TexScaleU")->setValue(2.0f * getChild<LLUICtrl>("TexScaleU")->getValue().asReal() );
+				getChild<LLUICtrl>("TexScaleV")->setValue(2.0f * getChild<LLUICtrl>("TexScaleV")->getValue().asReal() );
 			}
 
 		}
@@ -734,14 +734,14 @@ void LLPanelFace::getState()
 			} func;
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, fullbrightf );
 
-			childSetValue("checkbox fullbright",(S32)fullbrightf);
-			childSetEnabled("checkbox fullbright",editable);
-			childSetTentative("checkbox fullbright",!identical);
+			getChild<LLUICtrl>("checkbox fullbright")->setValue((S32)fullbrightf);
+			getChildView("checkbox fullbright")->setEnabled(editable);
+			getChild<LLUICtrl>("checkbox fullbright")->setTentative(!identical);
 		}
 		
 		// Repeats per meter label
 		{
-			childSetEnabled("rpt",editable);
+			getChildView("rpt")->setEnabled(editable);
 		}
 
 		// Repeats per meter
@@ -761,14 +761,14 @@ void LLPanelFace::getState()
 			} func;			
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, repeats );
 			
-			childSetValue("rptctrl", editable ? repeats : 0);
-			childSetTentative("rptctrl",!identical);
+			getChild<LLUICtrl>("rptctrl")->setValue(editable ? repeats : 0);
+			getChild<LLUICtrl>("rptctrl")->setTentative(!identical);
 			LLComboBox*	mComboTexGen = getChild<LLComboBox>("combobox texgen");
 			if (mComboTexGen)
 			{
 				BOOL enabled = editable && (!mComboTexGen || mComboTexGen->getCurrentIndex() != 1);
-				childSetEnabled("rptctrl",enabled);
-				childSetEnabled("button apply",enabled);
+				getChildView("rptctrl")->setEnabled(enabled);
+				getChildView("button apply")->setEnabled(enabled);
 			}
 		}
 	}
@@ -792,19 +792,19 @@ void LLPanelFace::getState()
 			mColorSwatch->setFallbackImageName("locked_image.j2c" );
 			mColorSwatch->setValid(FALSE);
 		}
-		childSetEnabled("color trans",FALSE);
-		childSetEnabled("rpt",FALSE);
-		childSetEnabled("tex offset",FALSE);
-		childSetEnabled("tex gen",FALSE);
-		childSetEnabled("label shininess",FALSE);
-		childSetEnabled("label bumpiness",FALSE);
-
-		childSetEnabled("textbox autofix",FALSE);
-
-		childSetEnabled("button align",FALSE);
-		childSetEnabled("button apply",FALSE);
-		//childSetEnabled("has media", FALSE);
-		//childSetEnabled("media info set", FALSE);
+		getChildView("color trans")->setEnabled(FALSE);
+		getChildView("rpt")->setEnabled(FALSE);
+		getChildView("tex offset")->setEnabled(FALSE);
+		getChildView("tex gen")->setEnabled(FALSE);
+		getChildView("label shininess")->setEnabled(FALSE);
+		getChildView("label bumpiness")->setEnabled(FALSE);
+
+		getChildView("textbox autofix")->setEnabled(FALSE);
+
+		getChildView("button align")->setEnabled(FALSE);
+		getChildView("button apply")->setEnabled(FALSE);
+		//getChildView("has media")->setEnabled(FALSE);
+		//getChildView("media info set")->setEnabled(FALSE);
 		
 	}
 }
@@ -934,7 +934,7 @@ void LLPanelFace::onClickApply(void* userdata)
 	gFocusMgr.setKeyboardFocus( NULL );
 
 	//F32 repeats_per_meter = self->mCtrlRepeatsPerMeter->get();
-	F32 repeats_per_meter = (F32)self->childGetValue( "rptctrl" ).asReal();//self->mCtrlRepeatsPerMeter->get();
+	F32 repeats_per_meter = (F32)self->getChild<LLUICtrl>("rptctrl")->getValue().asReal();//self->mCtrlRepeatsPerMeter->get();
 	LLSelectMgr::getInstance()->selectionTexScaleAutofit( repeats_per_meter );
 }
 
diff --git a/indra/newview/llpanelgenerictip.cpp b/indra/newview/llpanelgenerictip.cpp
index 8ba2e6d01c7..5a71f7f3155 100644
--- a/indra/newview/llpanelgenerictip.cpp
+++ b/indra/newview/llpanelgenerictip.cpp
@@ -44,7 +44,7 @@ LLPanelGenericTip::LLPanelGenericTip(
 {
 	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_generic_tip.xml");
 
-	childSetValue("message", notification->getMessage());
+	getChild<LLUICtrl>("message")->setValue(notification->getMessage());
 
 
 	S32 max_line_count =  gSavedSettings.getS32("TipToastMessageLineCount");
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index d997b83cbbb..62852f98d99 100644
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -321,7 +321,7 @@ void LLPanelGroup::onChange(EStatusType status, const std::string &channelURI, b
 		return;
 	}
 
-	childSetEnabled("btn_call", LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking());
+	getChildView("btn_call")->setEnabled(LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking());
 }
 
 void LLPanelGroup::notifyObservers()
@@ -335,8 +335,8 @@ void LLPanelGroup::update(LLGroupChange gc)
 	if(gdatap)
 	{
 		std::string group_name =  gdatap->mName.empty() ? LLTrans::getString("LoadingData") : gdatap->mName;
-		childSetValue("group_name", group_name);
-		childSetToolTip("group_name",group_name);
+		getChild<LLUICtrl>("group_name")->setValue(group_name);
+		getChildView("group_name")->setToolTip(group_name);
 		
 		LLGroupData agent_gdatap;
 		bool is_member = gAgent.getGroupData(mID,agent_gdatap) || gAgent.isGodlike();
@@ -382,8 +382,8 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 	if(gdatap)
 	{
 		std::string group_name =  gdatap->mName.empty() ? LLTrans::getString("LoadingData") : gdatap->mName;
-		childSetValue("group_name", group_name);
-		childSetToolTip("group_name",group_name);
+		getChild<LLUICtrl>("group_name")->setValue(group_name);
+		getChildView("group_name")->setToolTip(group_name);
 	}
 
 	LLButton* button_apply = findChild<LLButton>("btn_apply");
@@ -535,7 +535,7 @@ void LLPanelGroup::draw()
 	if (mRefreshTimer.hasExpired())
 	{
 		mRefreshTimer.stop();
-		childEnable("btn_refresh");
+		getChildView("btn_refresh")->setEnabled(TRUE);
 	}
 
 	LLButton* button_apply = findChild<LLButton>("btn_apply");
@@ -547,7 +547,7 @@ void LLPanelGroup::draw()
 		for(std::vector<LLPanelGroupTab* >::iterator it = mTabs.begin();it!=mTabs.end();++it)
 			enable = enable || (*it)->needsApply(mesg);
 
-		childSetEnabled("btn_apply", enable);
+		getChildView("btn_apply")->setEnabled(enable);
 	}
 }
 
@@ -563,7 +563,7 @@ void LLPanelGroup::refreshData()
 	setGroupID(getID());
 	
 	// 5 second timeout
-	childDisable("btn_refresh");
+	getChildView("btn_refresh")->setEnabled(FALSE);
 	mRefreshTimer.start();
 	mRefreshTimer.setTimerExpirySec(5);
 }
diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp
index 65fe7165c29..7f4a273e32c 100644
--- a/indra/newview/llpanelgrouplandmoney.cpp
+++ b/indra/newview/llpanelgrouplandmoney.cpp
@@ -371,7 +371,7 @@ void LLPanelGroupLandMoney::impl::setYourContributionTextField(int contrib)
 
 void LLPanelGroupLandMoney::impl::setYourMaxContributionTextBox(int max)
 {
-	mPanel.childSetTextArg("your_contribution_max_value", "[AMOUNT]", llformat("%d", max));
+	mPanel.getChild<LLUICtrl>("your_contribution_max_value")->setTextArg("[AMOUNT]", llformat("%d", max));
 }
 
 //static
@@ -433,14 +433,14 @@ void LLPanelGroupLandMoney::impl::processGroupLand(LLMessageSystem* msg)
 			
 			S32 total_contribution;
 			msg->getS32("QueryData", "ActualArea", total_contribution, 0);
-			mPanel.childSetTextArg("total_contributed_land_value", "[AREA]", llformat("%d", total_contribution));
+			mPanel.getChild<LLUICtrl>("total_contributed_land_value")->setTextArg("[AREA]", llformat("%d", total_contribution));
 
 			S32 committed;
 			msg->getS32("QueryData", "BillableArea", committed, 0);
-			mPanel.childSetTextArg("total_land_in_use_value", "[AREA]", llformat("%d", committed));
+			mPanel.getChild<LLUICtrl>("total_land_in_use_value")->setTextArg("[AREA]", llformat("%d", committed));
 			
 			S32 available = total_contribution - committed;
-			mPanel.childSetTextArg("land_available_value", "[AREA]", llformat("%d", available));
+			mPanel.getChild<LLUICtrl>("land_available_value")->setTextArg("[AREA]", llformat("%d", available));
 
 			if ( mGroupOverLimitTextp && mGroupOverLimitIconp )
 			{
diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp
index b79a4f359ad..32efdf20642 100644
--- a/indra/newview/llpanelimcontrolpanel.cpp
+++ b/indra/newview/llpanelimcontrolpanel.cpp
@@ -89,7 +89,7 @@ void LLPanelChatControlPanel::updateCallButton()
 	
 	if (!session) 
 	{
-		childSetEnabled("call_btn", false);
+		getChildView("call_btn")->setEnabled(false);
 		return;
 	}
 
@@ -99,14 +99,14 @@ void LLPanelChatControlPanel::updateCallButton()
 	BOOL enable_connect = session_initialized
 		&& voice_enabled
 		&& callback_enabled;
-	childSetEnabled("call_btn", enable_connect);
+	getChildView("call_btn")->setEnabled(enable_connect);
 }
 
 void LLPanelChatControlPanel::updateButtons(bool is_call_started)
 {
-	childSetVisible("end_call_btn_panel", is_call_started);
-	childSetVisible("voice_ctrls_btn_panel", is_call_started);
-	childSetVisible("call_btn_panel", ! is_call_started);
+	getChildView("end_call_btn_panel")->setVisible( is_call_started);
+	getChildView("voice_ctrls_btn_panel")->setVisible( is_call_started);
+	getChildView("call_btn_panel")->setVisible( ! is_call_started);
 	updateCallButton();
 	
 }
@@ -162,7 +162,7 @@ BOOL LLPanelIMControlPanel::postBuild()
 	childSetAction("share_btn", boost::bind(&LLPanelIMControlPanel::onShareButtonClicked, this));
 	childSetAction("teleport_btn", boost::bind(&LLPanelIMControlPanel::onTeleportButtonClicked, this));
 	childSetAction("pay_btn", boost::bind(&LLPanelIMControlPanel::onPayButtonClicked, this));
-	childSetEnabled("add_friend_btn", !LLAvatarActions::isFriend(getChild<LLAvatarIconCtrl>("avatar_icon")->getAvatarId()));
+	getChildView("add_friend_btn")->setEnabled(!LLAvatarActions::isFriend(getChild<LLAvatarIconCtrl>("avatar_icon")->getAvatarId()));
 
 	setFocusReceivedCallback(boost::bind(&LLPanelIMControlPanel::onFocusReceived, this));
 	
@@ -215,12 +215,12 @@ void LLPanelIMControlPanel::setSessionId(const LLUUID& session_id)
 	LLAvatarTracker::instance().addParticularFriendObserver(mAvatarID, this);
 
 	// Disable "Add friend" button for friends.
-	childSetEnabled("add_friend_btn", !LLAvatarActions::isFriend(mAvatarID));
+	getChildView("add_friend_btn")->setEnabled(!LLAvatarActions::isFriend(mAvatarID));
 	
 	// Disable "Teleport" button if friend is offline
 	if(LLAvatarActions::isFriend(mAvatarID))
 	{
-		childSetEnabled("teleport_btn", LLAvatarTracker::instance().isBuddyOnline(mAvatarID));
+		getChildView("teleport_btn")->setEnabled(LLAvatarTracker::instance().isBuddyOnline(mAvatarID));
 	}
 
 	getChild<LLAvatarIconCtrl>("avatar_icon")->setValue(mAvatarID);
@@ -231,24 +231,24 @@ void LLPanelIMControlPanel::setSessionId(const LLUUID& session_id)
 		im_model.findIMSession(session_id);
 	if( im_session && !im_session->mOtherParticipantIsAvatar )
 	{
-		childSetEnabled("view_profile_btn", FALSE);
-		childSetEnabled("add_friend_btn", FALSE);
+		getChildView("view_profile_btn")->setEnabled(FALSE);
+		getChildView("add_friend_btn")->setEnabled(FALSE);
 
-		childSetEnabled("share_btn", FALSE);
-		childSetEnabled("teleport_btn", FALSE);
-		childSetEnabled("pay_btn", FALSE);
+		getChildView("share_btn")->setEnabled(FALSE);
+		getChildView("teleport_btn")->setEnabled(FALSE);
+		getChildView("pay_btn")->setEnabled(FALSE);
 	}
 }
 
 //virtual
 void LLPanelIMControlPanel::changed(U32 mask)
 {
-	childSetEnabled("add_friend_btn", !LLAvatarActions::isFriend(mAvatarID));
+	getChildView("add_friend_btn")->setEnabled(!LLAvatarActions::isFriend(mAvatarID));
 	
 	// Disable "Teleport" button if friend is offline
 	if(LLAvatarActions::isFriend(mAvatarID))
 	{
-		childSetEnabled("teleport_btn", LLAvatarTracker::instance().isBuddyOnline(mAvatarID));
+		getChildView("teleport_btn")->setEnabled(LLAvatarTracker::instance().isBuddyOnline(mAvatarID));
 	}
 }
 
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp
index ce1131f45cf..b399e417914 100644
--- a/indra/newview/llpanellandmarks.cpp
+++ b/indra/newview/llpanellandmarks.cpp
@@ -718,8 +718,8 @@ void LLLandmarksPanel::updateListCommands()
 	bool trash_enabled = isActionEnabled("delete");
 
 	// keep Options & Add Landmark buttons always enabled
-	mListCommands->childSetEnabled(ADD_FOLDER_BUTTON_NAME, add_folder_enabled);
-	mListCommands->childSetEnabled(TRASH_BUTTON_NAME, trash_enabled);
+	mListCommands->getChildView(ADD_FOLDER_BUTTON_NAME)->setEnabled(add_folder_enabled);
+	mListCommands->getChildView(TRASH_BUTTON_NAME)->setEnabled(trash_enabled);
 }
 
 void LLLandmarksPanel::onActionsButtonClick()
diff --git a/indra/newview/llpanellandmedia.cpp b/indra/newview/llpanellandmedia.cpp
index e834e229cd3..f428e1f7953 100644
--- a/indra/newview/llpanellandmedia.cpp
+++ b/indra/newview/llpanellandmedia.cpp
@@ -145,7 +145,7 @@ void LLPanelLandMedia::refresh()
 		mMediaURLEdit->setText(parcel->getMediaURL());
 		mMediaURLEdit->setEnabled( FALSE );
 
-		childSetText("current_url", parcel->getMediaCurrentURL());
+		getChild<LLUICtrl>("current_url")->setValue(parcel->getMediaCurrentURL());
 
 		mMediaDescEdit->setText(parcel->getMediaDesc());
 		mMediaDescEdit->setEnabled( can_change_media );
@@ -157,7 +157,7 @@ void LLPanelLandMedia::refresh()
 		}
 		setMediaType(mime_type);
 		mMediaTypeCombo->setEnabled( can_change_media );
-		childSetText("mime_type", mime_type);
+		getChild<LLUICtrl>("mime_type")->setValue(mime_type);
 
 		mMediaUrlCheck->set( parcel->getObscureMedia() );
 		mMediaUrlCheck->setEnabled( can_change_media );
@@ -255,7 +255,7 @@ void LLPanelLandMedia::setMediaType(const std::string& mime_type)
 		// localizable - "none" for example (see EXT-6542)
 		mime_str = LLMIMETypes::getDefaultMimeTypeTranslation();
 	}
-	childSetText("mime_type", mime_str);
+	getChild<LLUICtrl>("mime_type")->setValue(mime_str);
 }
 
 void LLPanelLandMedia::setMediaURL(const std::string& media_url)
@@ -269,7 +269,7 @@ void LLPanelLandMedia::setMediaURL(const std::string& media_url)
 
 	mMediaURLEdit->onCommit();
 	// LLViewerParcelMedia::sendMediaNavigateMessage(media_url);
-	childSetText("current_url", media_url);
+	getChild<LLUICtrl>("current_url")->setValue(media_url);
 }
 std::string LLPanelLandMedia::getMediaURL()
 {
@@ -280,11 +280,11 @@ std::string LLPanelLandMedia::getMediaURL()
 void LLPanelLandMedia::onCommitType(LLUICtrl *ctrl, void *userdata)
 {
 	LLPanelLandMedia *self = (LLPanelLandMedia *)userdata;
-	std::string current_type = LLMIMETypes::widgetType(self->childGetText("mime_type"));
+	std::string current_type = LLMIMETypes::widgetType(self->getChild<LLUICtrl>("mime_type")->getValue().asString());
 	std::string new_type = self->mMediaTypeCombo->getValue();
 	if(current_type != new_type)
 	{
-		self->childSetText("mime_type", LLMIMETypes::findDefaultMimeType(new_type));
+		self->getChild<LLUICtrl>("mime_type")->setValue(LLMIMETypes::findDefaultMimeType(new_type));
 	}
 	onCommitAny(ctrl, userdata);
 
@@ -304,7 +304,7 @@ void LLPanelLandMedia::onCommitAny(LLUICtrl*, void *userdata)
 	// Extract data from UI
 	std::string media_url	= self->mMediaURLEdit->getText();
 	std::string media_desc	= self->mMediaDescEdit->getText();
-	std::string mime_type	= self->childGetText("mime_type");
+	std::string mime_type	= self->getChild<LLUICtrl>("mime_type")->getValue().asString();
 	U8 media_auto_scale		= self->mMediaAutoScaleCheck->get();
 	U8 media_loop           = self->mMediaLoopCheck->get();
 	U8 obscure_media		= self->mMediaUrlCheck->get();
@@ -313,7 +313,7 @@ void LLPanelLandMedia::onCommitAny(LLUICtrl*, void *userdata)
 	LLUUID media_id			= self->mMediaTextureCtrl->getImageAssetID();
 
 
-	self->childSetText("mime_type", mime_type);
+	self->getChild<LLUICtrl>("mime_type")->setValue(mime_type);
 
 	// Remove leading/trailing whitespace (common when copying/pasting)
 	LLStringUtil::trim(media_url);
@@ -354,7 +354,7 @@ void LLPanelLandMedia::onResetBtn(void *userdata)
 	LLParcel* parcel = self->mParcel->getParcel();
 	// LLViewerMedia::navigateHome();
 	self->refresh();
-	self->childSetText("current_url", parcel->getMediaURL());
+	self->getChild<LLUICtrl>("current_url")->setValue(parcel->getMediaURL());
 	// LLViewerParcelMedia::sendMediaNavigateMessage(parcel->getMediaURL());
 
 }
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index 144839b554e..4b23e63f12b 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -211,7 +211,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
 	}
 
 #if !USE_VIEWER_AUTH
-	childSetPrevalidate("username_edit", LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("username_edit")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
 	getChild<LLLineEditor>("password_edit")->setKeystrokeCallback(onPassKey, this);
 
 	// change z sort of clickable text to be behind buttons
@@ -441,8 +441,8 @@ void LLPanelLogin::giveFocus()
 	if( sInstance )
 	{
 		// Grab focus and move cursor to first blank input field
-		std::string username = sInstance->childGetText("username_edit");
-		std::string pass = sInstance->childGetText("password_edit");
+		std::string username = sInstance->getChild<LLUICtrl>("username_edit")->getValue().asString();
+		std::string pass = sInstance->getChild<LLUICtrl>("password_edit")->getValue().asString();
 
 		BOOL have_username = !username.empty();
 		BOOL have_pass = !pass.empty();
@@ -472,7 +472,7 @@ void LLPanelLogin::giveFocus()
 // static
 void LLPanelLogin::showLoginWidgets()
 {
-	sInstance->childSetVisible("login_widgets", true);
+	sInstance->getChildView("login_widgets")->setVisible( true);
 	LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html");
 	sInstance->reshapeBrowser();
 	// *TODO: Append all the usual login parameters, like first_login=Y etc.
@@ -514,16 +514,16 @@ void LLPanelLogin::setFields(LLPointer<LLCredential> credential,
 	LLSD identifier = credential->getIdentifier();
 	if((std::string)identifier["type"] == "agent") 
 	{
-		sInstance->childSetText("username_edit", (std::string)identifier["first_name"] + " " + 
+		sInstance->getChild<LLUICtrl>("username_edit")->setValue((std::string)identifier["first_name"] + " " + 
 								(std::string)identifier["last_name"]);	
 	}
 	else if((std::string)identifier["type"] == "account")
 	{
-		sInstance->childSetText("username_edit", (std::string)identifier["account_name"]);		
+		sInstance->getChild<LLUICtrl>("username_edit")->setValue((std::string)identifier["account_name"]);		
 	}
 	else
 	{
-	  sInstance->childSetText("username_edit", std::string());	
+	  sInstance->getChild<LLUICtrl>("username_edit")->setValue(std::string());	
 	}
 	// if the password exists in the credential, set the password field with
 	// a filler to get some stars
@@ -539,13 +539,13 @@ void LLPanelLogin::setFields(LLPointer<LLCredential> credential,
 		// fill it with MAX_PASSWORD characters so we get a 
 		// nice row of asterixes.
 		const std::string filler("123456789!123456");
-		sInstance->childSetText("password_edit", std::string("123456789!123456"));
+		sInstance->getChild<LLUICtrl>("password_edit")->setValue(std::string("123456789!123456"));
 	}
 	else
 	{
-		sInstance->childSetText("password_edit", std::string());		
+		sInstance->getChild<LLUICtrl>("password_edit")->setValue(std::string());		
 	}
-	sInstance->childSetValue("remember_check", remember);
+	sInstance->getChild<LLUICtrl>("remember_check")->setValue(remember);
 }
 
 
@@ -572,9 +572,9 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential,
 		authenticator = credential->getAuthenticator();
 	}
 
-	std::string username = sInstance->childGetText("username_edit");
+	std::string username = sInstance->getChild<LLUICtrl>("username_edit")->getValue().asString();
 	LLStringUtil::trim(username);
-	std::string password = sInstance->childGetText("password_edit");
+	std::string password = sInstance->getChild<LLUICtrl>("password_edit")->getValue().asString();
 
 	LL_INFOS2("Credentials", "Authentication") << "retrieving username:" << username << LL_ENDL;
 	// determine if the username is a first/last form or not.
@@ -621,7 +621,7 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential,
 		}
 	}
 	credential = gSecAPIHandler->createCredential(LLGridManager::getInstance()->getGrid(), identifier, authenticator);
-	remember = sInstance->childGetValue("remember_check");
+	remember = sInstance->getChild<LLUICtrl>("remember_check")->getValue();
 }
 
 // static
@@ -649,9 +649,9 @@ BOOL LLPanelLogin::areCredentialFieldsDirty()
 	}
 	else
 	{
-		std::string username = sInstance->childGetText("username_edit");
+		std::string username = sInstance->getChild<LLUICtrl>("username_edit")->getValue().asString();
 		LLStringUtil::trim(username);
-		std::string password = sInstance->childGetText("password_edit");
+		std::string password = sInstance->getChild<LLUICtrl>("password_edit")->getValue().asString();
 		LLLineEditor* ctrl = sInstance->getChild<LLLineEditor>("username_edit");
 		if(ctrl && ctrl->isDirty())
 		{
@@ -699,12 +699,12 @@ void LLPanelLogin::updateLocationCombo( bool force_visible )
 	if ( ! force_visible )
 		show_start = gSavedSettings.getBOOL("ShowStartLocation");
 	
-	sInstance->childSetVisible("start_location_combo", show_start);
-	sInstance->childSetVisible("start_location_text", show_start);
+	sInstance->getChildView("start_location_combo")->setVisible( show_start);
+	sInstance->getChildView("start_location_text")->setVisible( show_start);
 	
 	BOOL show_server = gSavedSettings.getBOOL("ForceShowGrid");
-	sInstance->childSetVisible("server_combo_text", show_server);	
-	sInstance->childSetVisible("server_combo", show_server);
+	sInstance->getChildView("server_combo_text")->setVisible( show_server);	
+	sInstance->getChildView("server_combo")->setVisible( show_server);
 }
 
 // static
@@ -964,7 +964,7 @@ void LLPanelLogin::onClickConnect(void *)
 			return;
 		}
 		updateStartSLURL();
-		std::string username = sInstance->childGetText("username_edit");
+		std::string username = sInstance->getChild<LLUICtrl>("username_edit")->getValue().asString();
 
 		
 		if(username.empty())
@@ -1079,7 +1079,7 @@ void LLPanelLogin::updateServer()
 		if(sInstance && !sInstance->areCredentialFieldsDirty())
 		{
 			LLPointer<LLCredential> credential = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid());	
-			bool remember = sInstance->childGetValue("remember_check");
+			bool remember = sInstance->getChild<LLUICtrl>("remember_check")->getValue();
 			sInstance->setFields(credential, remember);
 		}
 		// grid changed so show new splash screen (possibly)
@@ -1173,6 +1173,6 @@ void LLPanelLogin::updateLoginPanelLinks()
 	
 	// need to call through sInstance, as it's called from onSelectServer, which
 	// is static.
-	sInstance->childSetVisible("create_new_account_text", system_grid);
-	sInstance->childSetVisible("forgot_password_text", system_grid);
+	sInstance->getChildView("create_new_account_text")->setVisible( system_grid);
+	sInstance->getChildView("forgot_password_text")->setVisible( system_grid);
 }
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index 873ac4134cf..d7ffdacb701 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -491,7 +491,7 @@ void LLPanelMainInventory::onFilterEdit(const std::string& search_string )
 void LLPanelMainInventory::onFilterSelected()
 {
 	// Find my index
-	mActivePanel = (LLInventoryPanel*)childGetVisibleTab("inventory filter tabs");
+	mActivePanel = (LLInventoryPanel*)getChild<LLTabContainer>("inventory filter tabs")->getCurrentPanel();
 
 	if (!mActivePanel)
 	{
@@ -499,7 +499,7 @@ void LLPanelMainInventory::onFilterSelected()
 	}
 
 	BOOL recent_active = ("Recent Items" == mActivePanel->getName());
-	childSetVisible("add_btn_panel", !recent_active);
+	getChildView("add_btn_panel")->setVisible( !recent_active);
 
 	setFilterSubString(mFilterSubString);
 	LLInventoryFilter* filter = mActivePanel->getFilter();
@@ -591,7 +591,7 @@ void LLPanelMainInventory::updateItemcountText()
 	{
 		text = getString("ItemcountUnknown");
 	}
-	childSetText("ItemcountText",text);
+	getChild<LLUICtrl>("ItemcountText")->setValue(text);
 }
 
 void LLPanelMainInventory::setFilterTextFromFilter() 
@@ -658,7 +658,7 @@ void LLFloaterInventoryFinder::onCheckSinceLogoff(LLUICtrl *ctrl, void *user_dat
 	LLFloaterInventoryFinder *self = (LLFloaterInventoryFinder *)user_data;
 	if (!self) return;
 
-	bool since_logoff= self->childGetValue("check_since_logoff");
+	bool since_logoff= self->getChild<LLUICtrl>("check_since_logoff")->getValue();
 	
 	if (!since_logoff && 
 	    !(  self->mSpinSinceDays->get() ||  self->mSpinSinceHours->get() ) )
@@ -698,7 +698,7 @@ void LLFloaterInventoryFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data)
 	{
 		since_logoff = false;
 	}
-	self->childSetValue("check_since_logoff", since_logoff);
+	self->getChild<LLUICtrl>("check_since_logoff")->setValue(since_logoff);
 }
 
 void LLFloaterInventoryFinder::changeFilter(LLInventoryFilter* filter)
@@ -721,20 +721,20 @@ void LLFloaterInventoryFinder::updateElementsFromFilter()
 	// update the ui elements
 	setTitle(mFilter->getName());
 
-	childSetValue("check_animation", (S32) (filter_types & 0x1 << LLInventoryType::IT_ANIMATION));
-
-	childSetValue("check_calling_card", (S32) (filter_types & 0x1 << LLInventoryType::IT_CALLINGCARD));
-	childSetValue("check_clothing", (S32) (filter_types & 0x1 << LLInventoryType::IT_WEARABLE));
-	childSetValue("check_gesture", (S32) (filter_types & 0x1 << LLInventoryType::IT_GESTURE));
-	childSetValue("check_landmark", (S32) (filter_types & 0x1 << LLInventoryType::IT_LANDMARK));
-	childSetValue("check_notecard", (S32) (filter_types & 0x1 << LLInventoryType::IT_NOTECARD));
-	childSetValue("check_object", (S32) (filter_types & 0x1 << LLInventoryType::IT_OBJECT));
-	childSetValue("check_script", (S32) (filter_types & 0x1 << LLInventoryType::IT_LSL));
-	childSetValue("check_sound", (S32) (filter_types & 0x1 << LLInventoryType::IT_SOUND));
-	childSetValue("check_texture", (S32) (filter_types & 0x1 << LLInventoryType::IT_TEXTURE));
-	childSetValue("check_snapshot", (S32) (filter_types & 0x1 << LLInventoryType::IT_SNAPSHOT));
-	childSetValue("check_show_empty", show_folders == LLInventoryFilter::SHOW_ALL_FOLDERS);
-	childSetValue("check_since_logoff", mFilter->isSinceLogoff());
+	getChild<LLUICtrl>("check_animation")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_ANIMATION));
+
+	getChild<LLUICtrl>("check_calling_card")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_CALLINGCARD));
+	getChild<LLUICtrl>("check_clothing")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_WEARABLE));
+	getChild<LLUICtrl>("check_gesture")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_GESTURE));
+	getChild<LLUICtrl>("check_landmark")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_LANDMARK));
+	getChild<LLUICtrl>("check_notecard")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_NOTECARD));
+	getChild<LLUICtrl>("check_object")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_OBJECT));
+	getChild<LLUICtrl>("check_script")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_LSL));
+	getChild<LLUICtrl>("check_sound")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SOUND));
+	getChild<LLUICtrl>("check_texture")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_TEXTURE));
+	getChild<LLUICtrl>("check_snapshot")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SNAPSHOT));
+	getChild<LLUICtrl>("check_show_empty")->setValue(show_folders == LLInventoryFilter::SHOW_ALL_FOLDERS);
+	getChild<LLUICtrl>("check_since_logoff")->setValue(mFilter->isSinceLogoff());
 	mSpinSinceHours->set((F32)(hours % 24));
 	mSpinSinceDays->set((F32)(hours / 24));
 }
@@ -745,32 +745,32 @@ void LLFloaterInventoryFinder::draw()
 	U32 filter = 0xffffffff;
 	BOOL filtered_by_all_types = TRUE;
 
-	if (!childGetValue("check_animation"))
+	if (!getChild<LLUICtrl>("check_animation")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_ANIMATION);
 		filtered_by_all_types = FALSE;
 	}
 
 
-	if (!childGetValue("check_calling_card"))
+	if (!getChild<LLUICtrl>("check_calling_card")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_CALLINGCARD);
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_clothing"))
+	if (!getChild<LLUICtrl>("check_clothing")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_WEARABLE);
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_gesture"))
+	if (!getChild<LLUICtrl>("check_gesture")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_GESTURE);
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_landmark"))
+	if (!getChild<LLUICtrl>("check_landmark")->getValue())
 
 
 	{
@@ -778,38 +778,38 @@ void LLFloaterInventoryFinder::draw()
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_notecard"))
+	if (!getChild<LLUICtrl>("check_notecard")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_NOTECARD);
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_object"))
+	if (!getChild<LLUICtrl>("check_object")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_OBJECT);
 		filter &= ~(0x1 << LLInventoryType::IT_ATTACHMENT);
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_script"))
+	if (!getChild<LLUICtrl>("check_script")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_LSL);
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_sound"))
+	if (!getChild<LLUICtrl>("check_sound")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_SOUND);
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_texture"))
+	if (!getChild<LLUICtrl>("check_texture")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_TEXTURE);
 		filtered_by_all_types = FALSE;
 	}
 
-	if (!childGetValue("check_snapshot"))
+	if (!getChild<LLUICtrl>("check_snapshot")->getValue())
 	{
 		filter &= ~(0x1 << LLInventoryType::IT_SNAPSHOT);
 		filtered_by_all_types = FALSE;
@@ -849,12 +849,12 @@ void LLFloaterInventoryFinder::draw()
 
 BOOL LLFloaterInventoryFinder::getCheckShowEmpty()
 {
-	return childGetValue("check_show_empty");
+	return getChild<LLUICtrl>("check_show_empty")->getValue();
 }
 
 BOOL LLFloaterInventoryFinder::getCheckSinceLogoff()
 {
-	return childGetValue("check_since_logoff");
+	return getChild<LLUICtrl>("check_since_logoff")->getValue();
 }
 
 void LLFloaterInventoryFinder::onCloseBtn(void* user_data)
@@ -869,17 +869,17 @@ void LLFloaterInventoryFinder::selectAllTypes(void* user_data)
 	LLFloaterInventoryFinder* self = (LLFloaterInventoryFinder*)user_data;
 	if(!self) return;
 
-	self->childSetValue("check_animation", TRUE);
-	self->childSetValue("check_calling_card", TRUE);
-	self->childSetValue("check_clothing", TRUE);
-	self->childSetValue("check_gesture", TRUE);
-	self->childSetValue("check_landmark", TRUE);
-	self->childSetValue("check_notecard", TRUE);
-	self->childSetValue("check_object", TRUE);
-	self->childSetValue("check_script", TRUE);
-	self->childSetValue("check_sound", TRUE);
-	self->childSetValue("check_texture", TRUE);
-	self->childSetValue("check_snapshot", TRUE);
+	self->getChild<LLUICtrl>("check_animation")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_calling_card")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_clothing")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_gesture")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_landmark")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_notecard")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_object")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_script")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_sound")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_texture")->setValue(TRUE);
+	self->getChild<LLUICtrl>("check_snapshot")->setValue(TRUE);
 }
 
 //static
@@ -888,17 +888,17 @@ void LLFloaterInventoryFinder::selectNoTypes(void* user_data)
 	LLFloaterInventoryFinder* self = (LLFloaterInventoryFinder*)user_data;
 	if(!self) return;
 
-	self->childSetValue("check_animation", FALSE);
-	self->childSetValue("check_calling_card", FALSE);
-	self->childSetValue("check_clothing", FALSE);
-	self->childSetValue("check_gesture", FALSE);
-	self->childSetValue("check_landmark", FALSE);
-	self->childSetValue("check_notecard", FALSE);
-	self->childSetValue("check_object", FALSE);
-	self->childSetValue("check_script", FALSE);
-	self->childSetValue("check_sound", FALSE);
-	self->childSetValue("check_texture", FALSE);
-	self->childSetValue("check_snapshot", FALSE);
+	self->getChild<LLUICtrl>("check_animation")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_calling_card")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_clothing")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_gesture")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_landmark")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_notecard")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_object")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_script")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_sound")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_texture")->setValue(FALSE);
+	self->getChild<LLUICtrl>("check_snapshot")->setValue(FALSE);
 }
 
 //////////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp
index 3f620869e09..017f6de63bf 100644
--- a/indra/newview/llpanelme.cpp
+++ b/indra/newview/llpanelme.cpp
@@ -146,10 +146,10 @@ void LLPanelMe::onSaveChangesClicked()
 	data.avatar_id = gAgent.getID();
 	data.image_id = mEditPanel->getChild<LLTextureCtrl>(PICKER_SECOND_LIFE)->getImageAssetID();
 	data.fl_image_id = mEditPanel->getChild<LLTextureCtrl>(PICKER_FIRST_LIFE)->getImageAssetID();
-	data.about_text = mEditPanel->childGetValue("sl_description_edit").asString();
-	data.fl_about_text = mEditPanel->childGetValue("fl_description_edit").asString();
-	data.profile_url = mEditPanel->childGetValue("homepage_edit").asString();
-	data.allow_publish = mEditPanel->childGetValue("show_in_search_checkbox");
+	data.about_text = mEditPanel->getChild<LLUICtrl>("sl_description_edit")->getValue().asString();
+	data.fl_about_text = mEditPanel->getChild<LLUICtrl>("fl_description_edit")->getValue().asString();
+	data.profile_url = mEditPanel->getChild<LLUICtrl>("homepage_edit")->getValue().asString();
+	data.allow_publish = mEditPanel->getChild<LLUICtrl>("show_in_search_checkbox")->getValue();
 
 	LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate(&data);
 	togglePanel(mEditPanel); // close
@@ -205,20 +205,20 @@ void LLPanelMyProfileEdit::processProfileProperties(const LLAvatarData* avatar_d
 
 	// 'Home page' was hidden in LLPanelAvatarProfile::fillCommonData() to fix  EXT-4734
 	// Show 'Home page' in Edit My Profile (EXT-4873)
-	childSetVisible("homepage_edit", true);
+	getChildView("homepage_edit")->setVisible( true);
 
 	fillPartnerData(avatar_data);
 
 	fillAccountStatus(avatar_data);
 
-	childSetValue("show_in_search_checkbox", (BOOL)(avatar_data->flags & AVATAR_ALLOW_PUBLISH));
+	getChild<LLUICtrl>("show_in_search_checkbox")->setValue((BOOL)(avatar_data->flags & AVATAR_ALLOW_PUBLISH));
 
 	std::string first, last;
 	BOOL found = gCacheName->getName(avatar_data->avatar_id, first, last);
 	if (found)
 	{
-		childSetTextArg("name_text", "[FIRST]", first);
-		childSetTextArg("name_text", "[LAST]", last);
+		getChild<LLUICtrl>("name_text")->setTextArg("[FIRST]", first);
+		getChild<LLUICtrl>("name_text")->setTextArg("[LAST]", last);
 	}
 }
 
@@ -226,8 +226,8 @@ BOOL LLPanelMyProfileEdit::postBuild()
 {
 	initTexturePickerMouseEvents();
 
-	childSetTextArg("partner_edit_link", "[URL]", getString("partner_edit_link_url"));
-	childSetTextArg("my_account_link", "[URL]", getString("my_account_link_url"));
+	getChild<LLUICtrl>("partner_edit_link")->setTextArg("[URL]", getString("partner_edit_link_url"));
+	getChild<LLUICtrl>("my_account_link")->setTextArg("[URL]", getString("my_account_link_url"));
 
 	return LLPanelAvatarProfile::postBuild();
 }
@@ -256,8 +256,8 @@ void LLPanelMyProfileEdit::resetData()
 {
 	LLPanelMyProfile::resetData();
 
-	childSetTextArg("name_text", "[FIRST]", LLStringUtil::null);
-	childSetTextArg("name_text", "[LAST]", LLStringUtil::null);
+	getChild<LLUICtrl>("name_text")->setTextArg("[FIRST]", LLStringUtil::null);
+	getChild<LLUICtrl>("name_text")->setTextArg("[LAST]", LLStringUtil::null);
 }
 
 void LLPanelMyProfileEdit::onTexturePickerMouseEnter(LLUICtrl* ctrl)
@@ -271,10 +271,10 @@ void LLPanelMyProfileEdit::onTexturePickerMouseLeave(LLUICtrl* ctrl)
 
 void LLPanelMyProfileEdit::enableEditing(bool enable)
 {
-	childSetEnabled("2nd_life_pic", enable);
-	childSetEnabled("real_world_pic", enable);
-	childSetEnabled("sl_description_edit", enable);
-	childSetEnabled("fl_description_edit", enable);
-	childSetEnabled("homepage_edit", enable);
-	childSetEnabled("show_in_search_checkbox", enable);
+	getChildView("2nd_life_pic")->setEnabled(enable);
+	getChildView("real_world_pic")->setEnabled(enable);
+	getChildView("sl_description_edit")->setEnabled(enable);
+	getChildView("fl_description_edit")->setEnabled(enable);
+	getChildView("homepage_edit")->setEnabled(enable);
+	getChildView("show_in_search_checkbox")->setEnabled(enable);
 }
diff --git a/indra/newview/llpanelmediasettingsgeneral.cpp b/indra/newview/llpanelmediasettingsgeneral.cpp
index f601a8d51c2..7a61872bc79 100644
--- a/indra/newview/llpanelmediasettingsgeneral.cpp
+++ b/indra/newview/llpanelmediasettingsgeneral.cpp
@@ -131,13 +131,13 @@ void LLPanelMediaSettingsGeneral::draw()
 	// enable/disable pixel values image entry based on auto scale checkbox 
 	if ( mAutoScale->getValue().asBoolean() == false )
 	{
-		childSetEnabled( LLMediaEntry::WIDTH_PIXELS_KEY, true );
-		childSetEnabled( LLMediaEntry::HEIGHT_PIXELS_KEY, true );
+		getChildView( LLMediaEntry::WIDTH_PIXELS_KEY )->setEnabled( true );
+		getChildView( LLMediaEntry::HEIGHT_PIXELS_KEY )->setEnabled( true );
 	}
 	else
 	{
-		childSetEnabled( LLMediaEntry::WIDTH_PIXELS_KEY, false );
-		childSetEnabled( LLMediaEntry::HEIGHT_PIXELS_KEY, false );
+		getChildView( LLMediaEntry::WIDTH_PIXELS_KEY )->setEnabled( false );
+		getChildView( LLMediaEntry::HEIGHT_PIXELS_KEY )->setEnabled( false );
 	};
 
 	// enable/disable UI based on type of media
@@ -158,17 +158,17 @@ void LLPanelMediaSettingsGeneral::draw()
 			bool show_time_controls = media_plugin->pluginSupportsMediaTime();
 			if ( show_time_controls )
 			{
-				childSetEnabled( LLMediaEntry::CURRENT_URL_KEY, false );
+				getChildView( LLMediaEntry::CURRENT_URL_KEY )->setEnabled( false );
 				reset_button_is_active = false;
-				childSetEnabled( "current_url_label", false );
-				childSetEnabled( LLMediaEntry::AUTO_LOOP_KEY, true );
+				getChildView("current_url_label")->setEnabled(false );
+				getChildView( LLMediaEntry::AUTO_LOOP_KEY )->setEnabled( true );
 			}
 			else
 			{
-				childSetEnabled( LLMediaEntry::CURRENT_URL_KEY, true );
+				getChildView( LLMediaEntry::CURRENT_URL_KEY )->setEnabled( true );
 				reset_button_is_active = true;
-				childSetEnabled( "current_url_label", true );
-				childSetEnabled( LLMediaEntry::AUTO_LOOP_KEY, false );
+				getChildView("current_url_label")->setEnabled(true );
+				getChildView( LLMediaEntry::AUTO_LOOP_KEY )->setEnabled( false );
 			};
 		};
 	};
@@ -185,18 +185,18 @@ void LLPanelMediaSettingsGeneral::draw()
 		// user has perms to press reset button and it is active
 		if ( user_can_press_reset )
 		{
-			childSetEnabled( "current_url_reset_btn", true );
+			getChildView("current_url_reset_btn")->setEnabled(true );
 		}
 		// user does not has perms to press reset button and it is active
 		else
 		{
-			childSetEnabled( "current_url_reset_btn", false );
+			getChildView("current_url_reset_btn")->setEnabled(false );
 		};
 	}
 	else
 	// reset button is inactive so we just slam it to off - other states don't matter
 	{
-		childSetEnabled( "current_url_reset_btn", false );
+		getChildView("current_url_reset_btn")->setEnabled(false );
 	};
 }
 
diff --git a/indra/newview/llpanelmediasettingspermissions.cpp b/indra/newview/llpanelmediasettingspermissions.cpp
index 7779ac63920..5effba515bf 100644
--- a/indra/newview/llpanelmediasettingspermissions.cpp
+++ b/indra/newview/llpanelmediasettingspermissions.cpp
@@ -99,7 +99,7 @@ void LLPanelMediaSettingsPermissions::draw()
 	// housekeeping
 	LLPanel::draw();
 
-	childSetText("perms_group_name",LLStringUtil::null);
+	getChild<LLUICtrl>("perms_group_name")->setValue(LLStringUtil::null);
 	LLUUID group_id;
 	BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
 	if (groups_identical)
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index a1b3114bb48..aadd14d97af 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -464,17 +464,17 @@ void LLPanelObject::getState( )
 	BOOL editable = root_objectp->permModify();
 
 	// Select Single Message
-	childSetVisible("select_single", FALSE);
-	childSetVisible("edit_object", FALSE);
+	getChildView("select_single")->setVisible( FALSE);
+	getChildView("edit_object")->setVisible( FALSE);
 	if (!editable || single_volume || selected_count <= 1)
 	{
-		childSetVisible("edit_object", TRUE);
-		childSetEnabled("edit_object", TRUE);
+		getChildView("edit_object")->setVisible( TRUE);
+		getChildView("edit_object")->setEnabled(TRUE);
 	}
 	else
 	{
-		childSetVisible("select_single", TRUE);
-		childSetEnabled("select_single", TRUE);
+		getChildView("select_single")->setVisible( TRUE);
+		getChildView("select_single")->setEnabled(TRUE);
 	}
 	// Lock checkbox - only modifiable if you own the object.
 	BOOL self_owned = (gAgent.getID() == owner_id);
@@ -993,19 +993,19 @@ void LLPanelObject::getState( )
 	mLabelSkew		->setEnabled( enabled );
 	mSpinSkew		->setEnabled( enabled );
 
-	childSetVisible("scale_hole", FALSE);
-	childSetVisible("scale_taper", FALSE);
+	getChildView("scale_hole")->setVisible( FALSE);
+	getChildView("scale_taper")->setVisible( FALSE);
 	if (top_size_x_visible || top_size_y_visible)
 	{
 		if (size_is_hole)
 		{
-			childSetVisible("scale_hole", TRUE);
-			childSetEnabled("scale_hole", enabled);
+			getChildView("scale_hole")->setVisible( TRUE);
+			getChildView("scale_hole")->setEnabled(enabled);
 		}
 		else
 		{
-			childSetVisible("scale_taper", TRUE);
-			childSetEnabled("scale_taper", enabled);
+			getChildView("scale_taper")->setVisible( TRUE);
+			getChildView("scale_taper")->setEnabled(enabled);
 		}
 	}
 	
@@ -1016,27 +1016,27 @@ void LLPanelObject::getState( )
 	mSpinShearX		->setEnabled( enabled );
 	mSpinShearY		->setEnabled( enabled );
 
-	childSetVisible("advanced_cut", FALSE);
-	childSetVisible("advanced_dimple", FALSE);
-	childSetVisible("advanced_slice", FALSE);
+	getChildView("advanced_cut")->setVisible( FALSE);
+	getChildView("advanced_dimple")->setVisible( FALSE);
+	getChildView("advanced_slice")->setVisible( FALSE);
 
 	if (advanced_cut_visible)
 	{
 		if (advanced_is_dimple)
 		{
-			childSetVisible("advanced_dimple", TRUE);
-			childSetEnabled("advanced_dimple", enabled);
+			getChildView("advanced_dimple")->setVisible( TRUE);
+			getChildView("advanced_dimple")->setEnabled(enabled);
 		}
 
 		else if (advanced_is_slice)
 		{
-			childSetVisible("advanced_slice", TRUE);
-			childSetEnabled("advanced_slice", enabled);
+			getChildView("advanced_slice")->setVisible( TRUE);
+			getChildView("advanced_slice")->setEnabled(enabled);
 		}
 		else
 		{
-			childSetVisible("advanced_cut", TRUE);
-			childSetEnabled("advanced_cut", enabled);
+			getChildView("advanced_cut")->setVisible( TRUE);
+			getChildView("advanced_cut")->setEnabled(enabled);
 		}
 	}
 	
@@ -1919,15 +1919,15 @@ void LLPanelObject::clearCtrls()
 	mLabelRadiusOffset->setEnabled( FALSE );
 	mLabelRevolutions->setEnabled( FALSE );
 
-	childSetVisible("select_single", FALSE);
-	childSetVisible("edit_object", TRUE);	
-	childSetEnabled("edit_object", FALSE);
+	getChildView("select_single")->setVisible( FALSE);
+	getChildView("edit_object")->setVisible( TRUE);	
+	getChildView("edit_object")->setEnabled(FALSE);
 	
-	childSetEnabled("scale_hole", FALSE);
-	childSetEnabled("scale_taper", FALSE);
-	childSetEnabled("advanced_cut", FALSE);
-	childSetEnabled("advanced_dimple", FALSE);
-	childSetVisible("advanced_slice", FALSE);
+	getChildView("scale_hole")->setEnabled(FALSE);
+	getChildView("scale_taper")->setEnabled(FALSE);
+	getChildView("advanced_cut")->setEnabled(FALSE);
+	getChildView("advanced_dimple")->setEnabled(FALSE);
+	getChildView("advanced_slice")->setVisible( FALSE);
 }
 
 //
diff --git a/indra/newview/llpanelonlinestatus.cpp b/indra/newview/llpanelonlinestatus.cpp
index b21fd7d3859..7de4e8e49df 100644
--- a/indra/newview/llpanelonlinestatus.cpp
+++ b/indra/newview/llpanelonlinestatus.cpp
@@ -45,8 +45,8 @@ LLPanelOnlineStatus::LLPanelOnlineStatus(
 			"panel_online_status_toast.xml");
 
 
-	childSetValue("avatar_icon", notification->getPayload()["FROM_ID"]);
-	childSetValue("message", notification->getMessage());
+	getChild<LLUICtrl>("avatar_icon")->setValue(notification->getPayload()["FROM_ID"]);
+	getChild<LLUICtrl>("message")->setValue(notification->getMessage());
 
 	if (notification->getPayload().has("respond_on_mousedown")
 			&& notification->getPayload()["respond_on_mousedown"])
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 2074fd89c03..b37fc23f954 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -570,15 +570,15 @@ void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables)
 {
 	mAddWearablesPanel->setVisible(show_add_wearables);
 	
-	childSetValue("show_add_wearables_btn", show_add_wearables);
+	getChild<LLUICtrl>("show_add_wearables_btn")->setValue(show_add_wearables);
 
 	updateFiltersVisibility();
-	childSetVisible("filter_button", show_add_wearables);
+	getChildView("filter_button")->setVisible( show_add_wearables);
 
 	//search filter should be disabled
 	if (!show_add_wearables)
 	{
-		childSetValue("filter_button", false);
+		getChild<LLUICtrl>("filter_button")->setValue(false);
 
 		mFolderViewFilterCmbBox->setVisible(false);
 		mListViewFilterCmbBox->setVisible(false);
@@ -590,15 +590,15 @@ void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables)
 	}
 
 	//switching button bars
-	childSetVisible("no_add_wearables_button_bar", !show_add_wearables);
-	childSetVisible("add_wearables_button_bar", show_add_wearables);
+	getChildView("no_add_wearables_button_bar")->setVisible( !show_add_wearables);
+	getChildView("add_wearables_button_bar")->setVisible( show_add_wearables);
 }
 
 void LLPanelOutfitEdit::showWearablesFilter()
 {
-	bool filter_visible = childGetValue("filter_button");
+	bool filter_visible = getChild<LLUICtrl>("filter_button")->getValue();
 
-	childSetVisible("filter_panel", filter_visible);
+	getChildView("filter_panel")->setVisible( filter_visible);
 
 	if(!filter_visible)
 	{
@@ -1126,7 +1126,7 @@ void LLPanelOutfitEdit::updateVerbs()
 	bool has_baseoutfit = LLAppearanceMgr::getInstance()->getBaseOutfitUUID().notNull();
 
 	mSaveComboBtn->setSaveBtnEnabled(!outfit_locked && outfit_is_dirty);
-	childSetEnabled(REVERT_BTN, outfit_is_dirty && has_baseoutfit);
+	getChildView(REVERT_BTN)->setEnabled(outfit_is_dirty && has_baseoutfit);
 
 	mSaveComboBtn->setMenuItemEnabled("save_outfit", !outfit_locked && outfit_is_dirty);
 
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp
index ca5679d5b09..dfe4680035f 100644
--- a/indra/newview/llpaneloutfitsinventory.cpp
+++ b/indra/newview/llpaneloutfitsinventory.cpp
@@ -258,17 +258,17 @@ void LLPanelOutfitsInventory::updateListCommands()
 	bool wear_visible = !isCOFPanelActive();
 	bool make_outfit_enabled = isActionEnabled("save_outfit");
 
-	mMyOutfitsPanel->childSetEnabled("trash_btn", trash_enabled);
-	mListCommands->childSetEnabled("wear_btn", wear_enabled);
-	mListCommands->childSetVisible("wear_btn", wear_visible);
+	mMyOutfitsPanel->getChildView("trash_btn")->setEnabled(trash_enabled);
+	mListCommands->getChildView("wear_btn")->setEnabled(wear_enabled);
+	mListCommands->getChildView("wear_btn")->setVisible( wear_visible);
 	mSaveComboBtn->setMenuItemEnabled("save_outfit", make_outfit_enabled);
 	if (mMyOutfitsPanel->hasItemSelected())
 	{
-		mListCommands->childSetToolTip("wear_btn", getString("wear_items_tooltip"));
+		mListCommands->getChildView("wear_btn")->setToolTip(getString("wear_items_tooltip"));
 	}
 	else
 	{
-		mListCommands->childSetToolTip("wear_btn", getString("wear_outfit_tooltip"));
+		mListCommands->getChildView("wear_btn")->setToolTip(getString("wear_outfit_tooltip"));
 	}
 }
 
@@ -337,7 +337,7 @@ bool LLPanelOutfitsInventory::isCOFPanelActive() const
 
 void LLPanelOutfitsInventory::setWearablesLoading(bool val)
 {
-	mListCommands->childSetEnabled("wear_btn", !val);
+	mListCommands->getChildView("wear_btn")->setEnabled(!val);
 }
 
 void LLPanelOutfitsInventory::onWearablesLoaded()
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 6dd800c0c6a..7573dd7ad32 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -800,8 +800,8 @@ void LLPanelPeople::updateButtons()
 		}
 
 		LLPanel* groups_panel = mTabContainer->getCurrentPanel();
-		groups_panel->childSetEnabled("activate_btn",	item_selected && !cur_group_active); // "none" or a non-active group selected
-		groups_panel->childSetEnabled("minus_btn",		item_selected && selected_id.notNull());
+		groups_panel->getChildView("activate_btn")->setEnabled(item_selected && !cur_group_active); // "none" or a non-active group selected
+		groups_panel->getChildView("minus_btn")->setEnabled(item_selected && selected_id.notNull());
 	}
 	else
 	{
@@ -817,10 +817,10 @@ void LLPanelPeople::updateButtons()
 		LLPanel* cur_panel = mTabContainer->getCurrentPanel();
 		if (cur_panel)
 		{
-			cur_panel->childSetEnabled("add_friend_btn", !is_friend);
+			cur_panel->getChildView("add_friend_btn")->setEnabled(!is_friend);
 			if (friends_tab_active)
 			{
-				cur_panel->childSetEnabled("del_btn", multiple_selected);
+				cur_panel->getChildView("del_btn")->setEnabled(multiple_selected);
 			}
 		}
 	}
diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp
index 71d16a08b48..87e02bd5f42 100644
--- a/indra/newview/llpanelpermissions.cpp
+++ b/indra/newview/llpanelpermissions.cpp
@@ -142,9 +142,9 @@ LLPanelPermissions::LLPanelPermissions() :
 BOOL LLPanelPermissions::postBuild()
 {
 	childSetCommitCallback("Object Name",LLPanelPermissions::onCommitName,this);
-	childSetPrevalidate("Object Name",LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("Object Name")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
 	childSetCommitCallback("Object Description",LLPanelPermissions::onCommitDesc,this);
-	childSetPrevalidate("Object Description",LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("Object Description")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
 
 	
 	getChild<LLUICtrl>("button set group")->setCommitCallback(boost::bind(&LLPanelPermissions::onClickGroup,this));
@@ -183,81 +183,81 @@ LLPanelPermissions::~LLPanelPermissions()
 
 void LLPanelPermissions::disableAll()
 {
-	childSetEnabled("perm_modify",						FALSE);
-	childSetText("perm_modify",							LLStringUtil::null);
-
-	childSetEnabled("Creator:",					   		FALSE);
-	childSetText("Creator Name",						LLStringUtil::null);
-	childSetEnabled("Creator Name",						FALSE);
-
-	childSetEnabled("Owner:",							FALSE);
-	childSetText("Owner Name",							LLStringUtil::null);
-	childSetEnabled("Owner Name",						FALSE);
-
-	childSetEnabled("Group:",							FALSE);
-	childSetText("Group Name Proxy",					LLStringUtil::null);
-	childSetEnabled("Group Name Proxy",					FALSE);
-	childSetEnabled("button set group",					FALSE);
-
-	childSetText("Object Name",							LLStringUtil::null);
-	childSetEnabled("Object Name",						FALSE);
-	childSetEnabled("Name:",						   	FALSE);
-	childSetText("Group Name",							LLStringUtil::null);
-	childSetEnabled("Group Name",						FALSE);
-	childSetEnabled("Description:",						FALSE);
-	childSetText("Object Description",					LLStringUtil::null);
-	childSetEnabled("Object Description",				FALSE);
-
-	childSetEnabled("Permissions:",						FALSE);
+	getChildView("perm_modify")->setEnabled(FALSE);
+	getChild<LLUICtrl>("perm_modify")->setValue(LLStringUtil::null);
+
+	getChildView("Creator:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Creator Name")->setValue(LLStringUtil::null);
+	getChildView("Creator Name")->setEnabled(FALSE);
+
+	getChildView("Owner:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Owner Name")->setValue(LLStringUtil::null);
+	getChildView("Owner Name")->setEnabled(FALSE);
+
+	getChildView("Group:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Group Name Proxy")->setValue(LLStringUtil::null);
+	getChildView("Group Name Proxy")->setEnabled(FALSE);
+	getChildView("button set group")->setEnabled(FALSE);
+
+	getChild<LLUICtrl>("Object Name")->setValue(LLStringUtil::null);
+	getChildView("Object Name")->setEnabled(FALSE);
+	getChildView("Name:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
+	getChildView("Group Name")->setEnabled(FALSE);
+	getChildView("Description:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Object Description")->setValue(LLStringUtil::null);
+	getChildView("Object Description")->setEnabled(FALSE);
+
+	getChildView("Permissions:")->setEnabled(FALSE);
 		
-	childSetValue("checkbox share with group",			FALSE);
-	childSetEnabled("checkbox share with group",	   	FALSE);
-	childSetEnabled("button deed",						FALSE);
+	getChild<LLUICtrl>("checkbox share with group")->setValue(FALSE);
+	getChildView("checkbox share with group")->setEnabled(FALSE);
+	getChildView("button deed")->setEnabled(FALSE);
 
-	childSetValue("checkbox allow everyone move",	   	FALSE);
-	childSetEnabled("checkbox allow everyone move",	   	FALSE);
-	childSetValue("checkbox allow everyone copy",	   	FALSE);
-	childSetEnabled("checkbox allow everyone copy",	   	FALSE);
+	getChild<LLUICtrl>("checkbox allow everyone move")->setValue(FALSE);
+	getChildView("checkbox allow everyone move")->setEnabled(FALSE);
+	getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(FALSE);
+	getChildView("checkbox allow everyone copy")->setEnabled(FALSE);
 
 	//Next owner can:
-	childSetEnabled("Next owner can:",					FALSE);
-	childSetValue("checkbox next owner can modify",		FALSE);
-	childSetEnabled("checkbox next owner can modify",  	FALSE);
-	childSetValue("checkbox next owner can copy",	   	FALSE);
-	childSetEnabled("checkbox next owner can copy",	   	FALSE);
-	childSetValue("checkbox next owner can transfer",  	FALSE);
-	childSetEnabled("checkbox next owner can transfer",	FALSE);
+	getChildView("Next owner can:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("checkbox next owner can modify")->setValue(FALSE);
+	getChildView("checkbox next owner can modify")->setEnabled(FALSE);
+	getChild<LLUICtrl>("checkbox next owner can copy")->setValue(FALSE);
+	getChildView("checkbox next owner can copy")->setEnabled(FALSE);
+	getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(FALSE);
+	getChildView("checkbox next owner can transfer")->setEnabled(FALSE);
 
 	//checkbox for sale
-	childSetValue("checkbox for sale",					FALSE);
-	childSetEnabled("checkbox for sale",			   	FALSE);
+	getChild<LLUICtrl>("checkbox for sale")->setValue(FALSE);
+	getChildView("checkbox for sale")->setEnabled(FALSE);
 
 	//checkbox include in search
-	childSetValue("search_check",			 			FALSE);
-	childSetEnabled("search_check",			 			FALSE);
+	getChild<LLUICtrl>("search_check")->setValue(FALSE);
+	getChildView("search_check")->setEnabled(FALSE);
 		
 	LLComboBox*	combo_sale_type = getChild<LLComboBox>("sale type");
 	combo_sale_type->setValue(LLSaleInfo::FS_COPY);
 	combo_sale_type->setEnabled(FALSE);
 		
-	childSetEnabled("Cost",								FALSE);
-	childSetText("Cost",							   	getString("Cost Default"));
-	childSetText("Edit Cost",							LLStringUtil::null);
-	childSetEnabled("Edit Cost",					   	FALSE);
+	getChildView("Cost")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
+	getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
+	getChildView("Edit Cost")->setEnabled(FALSE);
 		
-	childSetEnabled("label click action",				FALSE);
+	getChildView("label click action")->setEnabled(FALSE);
 	LLComboBox*	combo_click_action = getChild<LLComboBox>("clickaction");
 	if (combo_click_action)
 	{
 		combo_click_action->setEnabled(FALSE);
 		combo_click_action->clear();
 	}
-	childSetVisible("B:",								FALSE);
-	childSetVisible("O:",								FALSE);
-	childSetVisible("G:",								FALSE);
-	childSetVisible("E:",								FALSE);
-	childSetVisible("N:",								FALSE);
-	childSetVisible("F:",								FALSE);
+	getChildView("B:")->setVisible(								FALSE);
+	getChildView("O:")->setVisible(								FALSE);
+	getChildView("G:")->setVisible(								FALSE);
+	getChildView("E:")->setVisible(								FALSE);
+	getChildView("N:")->setVisible(								FALSE);
+	getChildView("F:")->setVisible(								FALSE);
 }
 
 void LLPanelPermissions::refresh()
@@ -323,23 +323,23 @@ void LLPanelPermissions::refresh()
 	{
 		++string_index;
 	}
-	childSetEnabled("perm_modify", 			   			TRUE);
-	childSetText("perm_modify",							MODIFY_INFO_STRINGS[string_index]);
+	getChildView("perm_modify")->setEnabled(TRUE);
+	getChild<LLUICtrl>("perm_modify")->setValue(MODIFY_INFO_STRINGS[string_index]);
 
-	childSetEnabled("Permissions:", 					TRUE);
+	getChildView("Permissions:")->setEnabled(TRUE);
 	
 	// Update creator text field
-	childSetEnabled("Creator:", 						TRUE);
+	getChildView("Creator:")->setEnabled(TRUE);
 	BOOL creators_identical;
 	std::string creator_name;
 	creators_identical = LLSelectMgr::getInstance()->selectGetCreator(mCreatorID,
 																	  creator_name);
 
-	childSetText("Creator Name",						creator_name);
-	childSetEnabled("Creator Name", 					TRUE);
+	getChild<LLUICtrl>("Creator Name")->setValue(creator_name);
+	getChildView("Creator Name")->setEnabled(TRUE);
 
 	// Update owner text field
-	childSetEnabled("Owner:", 							TRUE);
+	getChildView("Owner:")->setEnabled(TRUE);
 
 	std::string owner_name;
 	const BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(mOwnerID, owner_name);
@@ -364,12 +364,12 @@ void LLPanelPermissions::refresh()
 			}
 		}
 	}
-	childSetText("Owner Name",						owner_name);
-	childSetEnabled("Owner Name", 					TRUE);
+	getChild<LLUICtrl>("Owner Name")->setValue(owner_name);
+	getChildView("Owner Name")->setEnabled(TRUE);
 
 	// update group text field
-	childSetEnabled("Group:", 						TRUE);
-	childSetText("Group Name", 						LLStringUtil::null);
+	getChildView("Group:")->setEnabled(TRUE);
+	getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
 	LLUUID group_id;
 	BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
 	if (groups_identical)
@@ -390,18 +390,18 @@ void LLPanelPermissions::refresh()
 		}
 	}
 	
-	childSetEnabled("button set group", owners_identical && (mOwnerID == gAgent.getID()));
+	getChildView("button set group")->setEnabled(owners_identical && (mOwnerID == gAgent.getID()));
 
-	childSetEnabled("Name:", 						TRUE);
+	getChildView("Name:")->setEnabled(TRUE);
 	LLLineEditor* LineEditorObjectName = getChild<LLLineEditor>("Object Name");
-	childSetEnabled("Description:", 				TRUE);
+	getChildView("Description:")->setEnabled(TRUE);
 	LLLineEditor* LineEditorObjectDesc = getChild<LLLineEditor>("Object Description");
 
 	if (is_one_object)
 	{
 		if (keyboard_focus_view != LineEditorObjectName)
 		{
-			childSetText("Object Name",nodep->mName);
+			getChild<LLUICtrl>("Object Name")->setValue(nodep->mName);
 		}
 
 		if (LineEditorObjectDesc)
@@ -414,7 +414,7 @@ void LLPanelPermissions::refresh()
 	}
 	else
 	{
-		childSetText("Object Name",					LLStringUtil::null);
+		getChild<LLUICtrl>("Object Name")->setValue(LLStringUtil::null);
 		LineEditorObjectDesc->setText(LLStringUtil::null);
 	}
 
@@ -426,13 +426,13 @@ void LLPanelPermissions::refresh()
 	}
 	if (edit_name_desc)
 	{
-		childSetEnabled("Object Name", 				TRUE);
-		childSetEnabled("Object Description", 		TRUE);
+		getChildView("Object Name")->setEnabled(TRUE);
+		getChildView("Object Description")->setEnabled(TRUE);
 	}
 	else
 	{
-		childSetEnabled("Object Name", 				FALSE);
-		childSetEnabled("Object Description", 		FALSE);
+		getChildView("Object Name")->setEnabled(FALSE);
+		getChildView("Object Description")->setEnabled(FALSE);
 	}
 
 	S32 total_sale_price = 0;
@@ -454,9 +454,9 @@ void LLPanelPermissions::refresh()
 
 	if (!owners_identical)
 	{
-		childSetEnabled("Cost", 					FALSE);
-		childSetText("Edit Cost",					LLStringUtil::null);
-		childSetEnabled("Edit Cost", 				FALSE);
+		getChildView("Cost")->setEnabled(FALSE);
+		getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
+		getChildView("Edit Cost")->setEnabled(FALSE);
 	}
 	// You own these objects.
 	else if (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id,GP_OBJECT_SET_SALE)))
@@ -464,11 +464,11 @@ void LLPanelPermissions::refresh()
 		// If there are multiple items for sale then set text to PRICE PER UNIT.
 		if (num_for_sale > 1)
 		{
-			childSetText("Cost",					getString("Cost Per Unit"));
+			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Per Unit"));
 		}
 		else
 		{
-			childSetText("Cost",					getString("Cost Default"));
+			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 		}
 		
 		LLSpinCtrl *edit_price = getChild<LLSpinCtrl>("Edit Cost");
@@ -492,35 +492,35 @@ void LLPanelPermissions::refresh()
 		// The edit fields are only enabled if you can sell this object
 		// and the sale price is not mixed.
 		BOOL enable_edit = (num_for_sale && can_transfer) ? !is_for_sale_mixed : FALSE;
-		childSetEnabled("Cost",					enable_edit);
-		childSetEnabled("Edit Cost",			enable_edit);
+		getChildView("Cost")->setEnabled(enable_edit);
+		getChildView("Edit Cost")->setEnabled(enable_edit);
 	}
 	// Someone, not you, owns these objects.
 	else if (!public_owned)
 	{
-		childSetEnabled("Cost",					FALSE);
-		childSetEnabled("Edit Cost",			FALSE);
+		getChildView("Cost")->setEnabled(FALSE);
+		getChildView("Edit Cost")->setEnabled(FALSE);
 		
 		// Don't show a price if none of the items are for sale.
 		if (num_for_sale)
-			childSetText("Edit Cost",			llformat("%d",total_sale_price));
+			getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",total_sale_price));
 		else
-			childSetText("Edit Cost",			LLStringUtil::null);
+			getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
 
 		// If multiple items are for sale, set text to TOTAL PRICE.
 		if (num_for_sale > 1)
-			childSetText("Cost",				getString("Cost Total"));
+			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Total"));
 		else
-			childSetText("Cost",				getString("Cost Default"));
+			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 	}
 	// This is a public object.
 	else
 	{
-		childSetEnabled("Cost",					FALSE);
-		childSetText("Cost",					getString("Cost Default"));
+		getChildView("Cost")->setEnabled(FALSE);
+		getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 		
-		childSetText("Edit Cost",				LLStringUtil::null);
-		childSetEnabled("Edit Cost",			FALSE);
+		getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
+		getChildView("Edit Cost")->setEnabled(FALSE);
 	}
 
 	// Enable and disable the permissions checkboxes
@@ -562,20 +562,20 @@ void LLPanelPermissions::refresh()
 	{
 		if (valid_base_perms)
 		{
-			childSetText("B:",								"B: " + mask_to_string(base_mask_on));
-			childSetVisible("B:",							TRUE);
+			getChild<LLUICtrl>("B:")->setValue("B: " + mask_to_string(base_mask_on));
+			getChildView("B:")->setVisible(							TRUE);
 			
-			childSetText("O:",								"O: " + mask_to_string(owner_mask_on));
-			childSetVisible("O:",							TRUE);
+			getChild<LLUICtrl>("O:")->setValue("O: " + mask_to_string(owner_mask_on));
+			getChildView("O:")->setVisible(							TRUE);
 			
-			childSetText("G:",								"G: " + mask_to_string(group_mask_on));
-			childSetVisible("G:",							TRUE);
+			getChild<LLUICtrl>("G:")->setValue("G: " + mask_to_string(group_mask_on));
+			getChildView("G:")->setVisible(							TRUE);
 			
-			childSetText("E:",								"E: " + mask_to_string(everyone_mask_on));
-			childSetVisible("E:",							TRUE);
+			getChild<LLUICtrl>("E:")->setValue("E: " + mask_to_string(everyone_mask_on));
+			getChildView("E:")->setVisible(							TRUE);
 			
-			childSetText("N:",								"N: " + mask_to_string(next_owner_mask_on));
-			childSetVisible("N:",							TRUE);
+			getChild<LLUICtrl>("N:")->setValue("N: " + mask_to_string(next_owner_mask_on));
+			getChildView("N:")->setVisible(							TRUE);
 		}
 
 		U32 flag_mask = 0x0;
@@ -584,17 +584,17 @@ void LLPanelPermissions::refresh()
 		if (objectp->permCopy()) 		flag_mask |= PERM_COPY;
 		if (objectp->permTransfer()) 	flag_mask |= PERM_TRANSFER;
 
-		childSetText("F:",									"F:" + mask_to_string(flag_mask));
-		childSetVisible("F:",								TRUE);
+		getChild<LLUICtrl>("F:")->setValue("F:" + mask_to_string(flag_mask));
+		getChildView("F:")->setVisible(								TRUE);
 	}
 	else
 	{
-		childSetVisible("B:",								FALSE);
-		childSetVisible("O:",								FALSE);
-		childSetVisible("G:",								FALSE);
-		childSetVisible("E:",								FALSE);
-		childSetVisible("N:",								FALSE);
-		childSetVisible("F:",								FALSE);
+		getChildView("B:")->setVisible(								FALSE);
+		getChildView("O:")->setVisible(								FALSE);
+		getChildView("G:")->setVisible(								FALSE);
+		getChildView("E:")->setVisible(								FALSE);
+		getChildView("N:")->setVisible(								FALSE);
+		getChildView("F:")->setVisible(								FALSE);
 	}
 
 	BOOL has_change_perm_ability = FALSE;
@@ -614,65 +614,65 @@ void LLPanelPermissions::refresh()
 	if (!has_change_perm_ability && !has_change_sale_ability && !root_selected)
 	{
 		// ...must select root to choose permissions
-		childSetValue("perm_modify", 						getString("text modify warning"));
+		getChild<LLUICtrl>("perm_modify")->setValue(getString("text modify warning"));
 	}
 
 	if (has_change_perm_ability)
 	{
-		childSetEnabled("checkbox share with group",		TRUE);
-		childSetEnabled("checkbox allow everyone move",		owner_mask_on & PERM_MOVE);
-		childSetEnabled("checkbox allow everyone copy",		owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
+		getChildView("checkbox share with group")->setEnabled(TRUE);
+		getChildView("checkbox allow everyone move")->setEnabled(owner_mask_on & PERM_MOVE);
+		getChildView("checkbox allow everyone copy")->setEnabled(owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
 	}
 	else
 	{
-		childSetEnabled("checkbox share with group", 		FALSE);
-		childSetEnabled("checkbox allow everyone move", 	FALSE);
-		childSetEnabled("checkbox allow everyone copy", 	FALSE);
+		getChildView("checkbox share with group")->setEnabled(FALSE);
+		getChildView("checkbox allow everyone move")->setEnabled(FALSE);
+		getChildView("checkbox allow everyone copy")->setEnabled(FALSE);
 	}
 
 	if (has_change_sale_ability && (owner_mask_on & PERM_TRANSFER))
 	{
-		childSetEnabled("checkbox for sale", 				can_transfer || (!can_transfer && num_for_sale));
+		getChildView("checkbox for sale")->setEnabled(can_transfer || (!can_transfer && num_for_sale));
 		// Set the checkbox to tentative if the prices of each object selected
 		// are not the same.
-		childSetTentative("checkbox for sale", 				is_for_sale_mixed);
-		childSetEnabled("sale type", 						num_for_sale && can_transfer && !is_sale_price_mixed);
+		getChild<LLUICtrl>("checkbox for sale")->setTentative( 				is_for_sale_mixed);
+		getChildView("sale type")->setEnabled(num_for_sale && can_transfer && !is_sale_price_mixed);
 
-		childSetEnabled("Next owner can:", 					TRUE);
-		childSetEnabled("checkbox next owner can modify", 	base_mask_on & PERM_MODIFY);
-		childSetEnabled("checkbox next owner can copy", 	base_mask_on & PERM_COPY);
-		childSetEnabled("checkbox next owner can transfer", next_owner_mask_on & PERM_COPY);
+		getChildView("Next owner can:")->setEnabled(TRUE);
+		getChildView("checkbox next owner can modify")->setEnabled(base_mask_on & PERM_MODIFY);
+		getChildView("checkbox next owner can copy")->setEnabled(base_mask_on & PERM_COPY);
+		getChildView("checkbox next owner can transfer")->setEnabled(next_owner_mask_on & PERM_COPY);
 	}
 	else 
 	{
-		childSetEnabled("checkbox for sale",				FALSE);
-		childSetEnabled("sale type",						FALSE);
+		getChildView("checkbox for sale")->setEnabled(FALSE);
+		getChildView("sale type")->setEnabled(FALSE);
 
-		childSetEnabled("Next owner can:",					FALSE);
-		childSetEnabled("checkbox next owner can modify",	FALSE);
-		childSetEnabled("checkbox next owner can copy",		FALSE);
-		childSetEnabled("checkbox next owner can transfer",	FALSE);
+		getChildView("Next owner can:")->setEnabled(FALSE);
+		getChildView("checkbox next owner can modify")->setEnabled(FALSE);
+		getChildView("checkbox next owner can copy")->setEnabled(FALSE);
+		getChildView("checkbox next owner can transfer")->setEnabled(FALSE);
 	}
 
 	if (valid_group_perms)
 	{
 		if ((group_mask_on & PERM_COPY) && (group_mask_on & PERM_MODIFY) && (group_mask_on & PERM_MOVE))
 		{
-			childSetValue("checkbox share with group",		TRUE);
-			childSetTentative("checkbox share with group",	FALSE);
-			childSetEnabled("button deed",					gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
+			getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox share with group")->setTentative(	FALSE);
+			getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
 		}
 		else if ((group_mask_off & PERM_COPY) && (group_mask_off & PERM_MODIFY) && (group_mask_off & PERM_MOVE))
 		{
-			childSetValue("checkbox share with group",		FALSE);
-			childSetTentative("checkbox share with group",	FALSE);
-			childSetEnabled("button deed",					FALSE);
+			getChild<LLUICtrl>("checkbox share with group")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox share with group")->setTentative(	FALSE);
+			getChildView("button deed")->setEnabled(FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox share with group",		TRUE);
-			childSetTentative("checkbox share with group",	TRUE);
-			childSetEnabled("button deed",					gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
+			getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox share with group")->setTentative(	TRUE);
+			getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
 		}
 	}			
 
@@ -681,35 +681,35 @@ void LLPanelPermissions::refresh()
 		// Move
 		if (everyone_mask_on & PERM_MOVE)
 		{
-			childSetValue("checkbox allow everyone move",		TRUE);
-			childSetTentative("checkbox allow everyone move", 	FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	FALSE);
 		}
 		else if (everyone_mask_off & PERM_MOVE)
 		{
-			childSetValue("checkbox allow everyone move",		FALSE);
-			childSetTentative("checkbox allow everyone move", 	FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox allow everyone move",		TRUE);
-			childSetTentative("checkbox allow everyone move", 	TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	TRUE);
 		}
 
 		// Copy == everyone can't copy
 		if (everyone_mask_on & PERM_COPY)
 		{
-			childSetValue("checkbox allow everyone copy",		TRUE);
-			childSetTentative("checkbox allow everyone copy", 	!can_copy || !can_transfer);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( 	!can_copy || !can_transfer);
 		}
 		else if (everyone_mask_off & PERM_COPY)
 		{
-			childSetValue("checkbox allow everyone copy",		FALSE);
-			childSetTentative("checkbox allow everyone copy",	FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative(	FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox allow everyone copy",		TRUE);
-			childSetTentative("checkbox allow everyone copy",	TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative(	TRUE);
 		}
 	}
 
@@ -718,52 +718,52 @@ void LLPanelPermissions::refresh()
 		// Modify == next owner canot modify
 		if (next_owner_mask_on & PERM_MODIFY)
 		{
-			childSetValue("checkbox next owner can modify",		TRUE);
-			childSetTentative("checkbox next owner can modify",	FALSE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	FALSE);
 		}
 		else if (next_owner_mask_off & PERM_MODIFY)
 		{
-			childSetValue("checkbox next owner can modify",		FALSE);
-			childSetTentative("checkbox next owner can modify",	FALSE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox next owner can modify",		TRUE);
-			childSetTentative("checkbox next owner can modify",	TRUE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	TRUE);
 		}
 
 		// Copy == next owner cannot copy
 		if (next_owner_mask_on & PERM_COPY)
 		{			
-			childSetValue("checkbox next owner can copy",		TRUE);
-			childSetTentative("checkbox next owner can copy",	!can_copy);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	!can_copy);
 		}
 		else if (next_owner_mask_off & PERM_COPY)
 		{
-			childSetValue("checkbox next owner can copy",		FALSE);
-			childSetTentative("checkbox next owner can copy",	FALSE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox next owner can copy",		TRUE);
-			childSetTentative("checkbox next owner can copy",	TRUE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	TRUE);
 		}
 
 		// Transfer == next owner cannot transfer
 		if (next_owner_mask_on & PERM_TRANSFER)
 		{
-			childSetValue("checkbox next owner can transfer",	TRUE);
-			childSetTentative("checkbox next owner can transfer", !can_transfer);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( !can_transfer);
 		}
 		else if (next_owner_mask_off & PERM_TRANSFER)
 		{
-			childSetValue("checkbox next owner can transfer",	FALSE);
-			childSetTentative("checkbox next owner can transfer", FALSE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox next owner can transfer",	TRUE);
-			childSetTentative("checkbox next owner can transfer", TRUE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( TRUE);
 		}
 	}
 
@@ -785,7 +785,7 @@ void LLPanelPermissions::refresh()
 		combo_sale_type->setTentative(				TRUE); // unfortunately this doesn't do anything at the moment.
 	}
 
-	childSetValue("checkbox for sale", (num_for_sale != 0));
+	getChild<LLUICtrl>("checkbox for sale")->setValue((num_for_sale != 0));
 
 	// HACK: There are some old objects in world that are set for sale,
 	// but are no-transfer.  We need to let users turn for-sale off, but only
@@ -795,7 +795,7 @@ void LLPanelPermissions::refresh()
 	{
 		if (num_for_sale && has_change_sale_ability)
 		{
-			childSetEnabled("checkbox for sale", true);
+			getChildView("checkbox for sale")->setEnabled(true);
 		}
 	}
 	
@@ -803,9 +803,9 @@ void LLPanelPermissions::refresh()
 	const BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
 	bool include_in_search;
 	const BOOL all_include_in_search = LLSelectMgr::getInstance()->selectionGetIncludeInSearch(&include_in_search);
-	childSetEnabled("search_check", 				has_change_sale_ability && all_volume);
-	childSetValue("search_check", 					include_in_search);
-	childSetTentative("search_check", 				!all_include_in_search);
+	getChildView("search_check")->setEnabled(has_change_sale_ability && all_volume);
+	getChild<LLUICtrl>("search_check")->setValue(include_in_search);
+	getChild<LLUICtrl>("search_check")->setTentative( 				!all_include_in_search);
 
 	// Click action (touch, sit, buy)
 	U8 click_action = 0;
@@ -818,8 +818,8 @@ void LLPanelPermissions::refresh()
 			combo_click_action->setValue(LLSD(combo_value));
 		}
 	}
-	childSetEnabled("label click action",			is_perm_modify && all_volume);
-	childSetEnabled("clickaction",					is_perm_modify && all_volume);
+	getChildView("label click action")->setEnabled(is_perm_modify && all_volume);
+	getChildView("clickaction")->setEnabled(is_perm_modify && all_volume);
 }
 
 
diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp
index f0dc493ebee..11b51f4dd40 100644
--- a/indra/newview/llpanelpick.cpp
+++ b/indra/newview/llpanelpick.cpp
@@ -247,13 +247,13 @@ void LLPanelPickInfo::resetControls()
 {
 	if(getAvatarId() == gAgent.getID())
 	{
-		childSetEnabled("edit_btn", TRUE);
-		childSetVisible("edit_btn", TRUE);
+		getChildView("edit_btn")->setEnabled(TRUE);
+		getChildView("edit_btn")->setVisible( TRUE);
 	}
 	else
 	{
-		childSetEnabled("edit_btn", FALSE);
-		childSetVisible("edit_btn", FALSE);
+		getChildView("edit_btn")->setEnabled(FALSE);
+		getChildView("edit_btn")->setVisible( FALSE);
 	}
 }
 
@@ -306,17 +306,17 @@ void LLPanelPickInfo::setSnapshotId(const LLUUID& id)
 
 void LLPanelPickInfo::setPickName(const std::string& name)
 {
-	childSetValue(XML_NAME, name);
+	getChild<LLUICtrl>(XML_NAME)->setValue(name);
 }
 
 void LLPanelPickInfo::setPickDesc(const std::string& desc)
 {
-	childSetValue(XML_DESC, desc);
+	getChild<LLUICtrl>(XML_DESC)->setValue(desc);
 }
 
 void LLPanelPickInfo::setPickLocation(const std::string& location)
 {
-	childSetValue(XML_LOCATION, location);
+	getChild<LLUICtrl>(XML_LOCATION)->setValue(location);
 }
 
 void LLPanelPickInfo::onClickMap()
@@ -399,8 +399,8 @@ void LLPanelPickEdit::onOpen(const LLSD& key)
 		}
 
 		setParcelID(parcel_id);
-		childSetValue("pick_name", pick_name.empty() ? region_name : pick_name);
-		childSetValue("pick_desc", pick_desc);
+		getChild<LLUICtrl>("pick_name")->setValue(pick_name.empty() ? region_name : pick_name);
+		getChild<LLUICtrl>("pick_desc")->setValue(pick_desc);
 		setSnapshotId(snapshot_id);
 		setPickLocation(createLocationText(getLocationNotice(), pick_name, region_name, getPosGlobal()));
 
@@ -428,8 +428,8 @@ void LLPanelPickEdit::setPickData(const LLPickData* pick_data)
 	mNeedData = false;
 
 	setParcelID(pick_data->parcel_id);
-	childSetValue("pick_name", pick_data->name);
-	childSetValue("pick_desc", pick_data->desc);
+	getChild<LLUICtrl>("pick_name")->setValue(pick_data->name);
+	getChild<LLUICtrl>("pick_desc")->setValue(pick_data->desc);
 	setSnapshotId(pick_data->snapshot_id);
 	setPosGlobal(pick_data->pos_global);
 	setPickLocation(createLocationText(LLStringUtil::null, pick_data->name,
@@ -511,8 +511,8 @@ void LLPanelPickEdit::sendUpdate()
 	//legacy var  need to be deleted
 	pick_data.top_pick = FALSE; 
 	pick_data.parcel_id = mParcelId;
-	pick_data.name = childGetValue(XML_NAME).asString();
-	pick_data.desc = childGetValue(XML_DESC).asString();
+	pick_data.name = getChild<LLUICtrl>(XML_NAME)->getValue().asString();
+	pick_data.desc = getChild<LLUICtrl>(XML_DESC)->getValue().asString();
 	pick_data.snapshot_id = mSnapshotCtrl->getImageAssetID();
 	pick_data.pos_global = getPosGlobal();
 	pick_data.sort_order = 0;
@@ -547,7 +547,7 @@ void LLPanelPickEdit::resetData()
 
 void LLPanelPickEdit::enableSaveButton(bool enable)
 {
-	childSetEnabled(XML_BTN_SAVE, enable);
+	getChildView(XML_BTN_SAVE)->setEnabled(enable);
 }
 
 void LLPanelPickEdit::onClickSetLocation()
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index bde8d028855..65254e50b4b 100644
--- a/indra/newview/llpanelpicks.cpp
+++ b/indra/newview/llpanelpicks.cpp
@@ -218,7 +218,7 @@ void LLPanelPicks::updateData()
 		mNoPicks = false;
 		mNoClassifieds = false;
 
-		childSetValue("picks_panel_text", LLTrans::getString("PicksClassifiedsLoadingText"));
+		getChild<LLUICtrl>("picks_panel_text")->setValue(LLTrans::getString("PicksClassifiedsLoadingText"));
 
 		mPicksList->clear();
 		LLAvatarPropertiesProcessor::getInstance()->sendAvatarPicksRequest(getAvatarId());
@@ -237,7 +237,7 @@ void LLPanelPicks::processProperties(void* data, EAvatarProcessorType type)
 		{
 			std::string name, second_name;
 			gCacheName->getName(getAvatarId(),name,second_name);
-			childSetTextArg("pick_title", "[NAME]",name);
+			getChild<LLUICtrl>("pick_title")->setTextArg("[NAME]", name);
 			
 			// Save selection, to be able to edit same item after saving changes. See EXT-3023.
 			LLUUID selected_id = mPicksList->getSelectedValue()[PICK_ID];
@@ -324,11 +324,11 @@ void LLPanelPicks::processProperties(void* data, EAvatarProcessorType type)
 	{
 		if(getAvatarId() == gAgentID)
 		{
-			childSetValue("picks_panel_text", LLTrans::getString("NoPicksClassifiedsText"));
+			getChild<LLUICtrl>("picks_panel_text")->setValue(LLTrans::getString("NoPicksClassifiedsText"));
 		}
 		else
 		{
-			childSetValue("picks_panel_text", LLTrans::getString("NoAvatarPicksClassifiedsText"));
+			getChild<LLUICtrl>("picks_panel_text")->setValue(LLTrans::getString("NoAvatarPicksClassifiedsText"));
 		}
 	}
 }
@@ -460,22 +460,22 @@ void LLPanelPicks::onOpen(const LLSD& key)
 	BOOL self = (gAgent.getID() == id);
 
 	// only agent can edit her picks 
-	childSetEnabled("edit_panel", self);
-	childSetVisible("edit_panel", self);
+	getChildView("edit_panel")->setEnabled(self);
+	getChildView("edit_panel")->setVisible( self);
 
 	// Disable buttons when viewing profile for first time
 	if(getAvatarId() != id)
 	{
-		childSetEnabled(XML_BTN_INFO,FALSE);
-		childSetEnabled(XML_BTN_TELEPORT,FALSE);
-		childSetEnabled(XML_BTN_SHOW_ON_MAP,FALSE);
+		getChildView(XML_BTN_INFO)->setEnabled(FALSE);
+		getChildView(XML_BTN_TELEPORT)->setEnabled(FALSE);
+		getChildView(XML_BTN_SHOW_ON_MAP)->setEnabled(FALSE);
 	}
 
 	// and see a special title - set as invisible by default in xml file
 	if (self)
 	{
-		childSetVisible("pick_title", !self);
-		childSetVisible("pick_title_agent", self);
+		getChildView("pick_title")->setVisible( !self);
+		getChildView("pick_title_agent")->setVisible( self);
 
 		mPopupMenu->setItemVisible("pick_delete", TRUE);
 		mPopupMenu->setItemVisible("pick_edit", TRUE);
@@ -670,17 +670,17 @@ void LLPanelPicks::updateButtons()
 
 	if (getAvatarId() == gAgentID)
 	{
-		childSetEnabled(XML_BTN_DELETE, has_selected);
+		getChildView(XML_BTN_DELETE)->setEnabled(has_selected);
 	}
 
-	childSetEnabled(XML_BTN_INFO, has_selected);
-	childSetEnabled(XML_BTN_TELEPORT, has_selected);
-	childSetEnabled(XML_BTN_SHOW_ON_MAP, has_selected);
+	getChildView(XML_BTN_INFO)->setEnabled(has_selected);
+	getChildView(XML_BTN_TELEPORT)->setEnabled(has_selected);
+	getChildView(XML_BTN_SHOW_ON_MAP)->setEnabled(has_selected);
 
 	LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem());
 	if(c_item)
 	{
-		childSetEnabled(XML_BTN_INFO, isClassifiedPublished(c_item));
+		getChildView(XML_BTN_INFO)->setEnabled(isClassifiedPublished(c_item));
 	}
 }
 
@@ -701,8 +701,7 @@ void LLPanelPicks::buildPickPanel()
 
 void LLPanelPicks::onClickPlusBtn()
 {
-	LLRect rect;
-	childGetRect(XML_BTN_NEW, rect);
+	LLRect rect(getChildView(XML_BTN_NEW)->getRect());
 
 	mPlusMenu->updateParent(LLMenuGL::sMenuContainer);
 	mPlusMenu->setButtonRect(rect, this);
@@ -1080,7 +1079,7 @@ void LLPickItem::init(LLPickData* pick_data)
 void LLPickItem::setPickName(const std::string& name)
 {
 	mPickName = name;
-	childSetValue("picture_name",name);
+	getChild<LLUICtrl>("picture_name")->setValue(name);
 
 }
 
@@ -1101,7 +1100,7 @@ const LLUUID& LLPickItem::getSnapshotId()
 
 void LLPickItem::setPickDesc(const std::string& descr)
 {
-	childSetValue("picture_descr",descr);
+	getChild<LLUICtrl>("picture_descr")->setValue(descr);
 }
 
 void LLPickItem::setPickId(const LLUUID& id)
@@ -1121,7 +1120,7 @@ const LLVector3d& LLPickItem::getPosGlobal()
 
 const std::string LLPickItem::getDescription()
 {
-	return childGetValue("picture_descr").asString();
+	return getChild<LLUICtrl>("picture_descr")->getValue().asString();
 }
 
 void LLPickItem::update()
@@ -1148,10 +1147,15 @@ void LLPickItem::processProperties(void *data, EAvatarProcessorType type)
 	LLAvatarPropertiesProcessor::instance().removeObserver(mCreatorID, this);
 }
 
+void set_child_visible(LLView* parent, const std::string& child_name, bool visible)
+{
+	parent->getChildView(child_name)->setVisible(visible);
+}
+
 BOOL LLPickItem::postBuild()
 {
-	setMouseEnterCallback(boost::bind(&LLPanelPickInfo::childSetVisible, this, "hovered_icon", true));
-	setMouseLeaveCallback(boost::bind(&LLPanelPickInfo::childSetVisible, this, "hovered_icon", false));
+	setMouseEnterCallback(boost::bind(&set_child_visible, this, "hovered_icon", true));
+	setMouseLeaveCallback(boost::bind(&set_child_visible, this, "hovered_icon", false));
 	return TRUE;
 }
 
@@ -1159,7 +1163,7 @@ void LLPickItem::setValue(const LLSD& value)
 {
 	if (!value.isMap()) return;;
 	if (!value.has("selected")) return;
-	childSetVisible("selected_icon", value["selected"]);
+	getChildView("selected_icon")->setVisible( value["selected"]);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -1205,8 +1209,8 @@ void LLClassifiedItem::processProperties(void* data, EAvatarProcessorType type)
 
 BOOL LLClassifiedItem::postBuild()
 {
-	setMouseEnterCallback(boost::bind(&LLPanelPickInfo::childSetVisible, this, "hovered_icon", true));
-	setMouseLeaveCallback(boost::bind(&LLPanelPickInfo::childSetVisible, this, "hovered_icon", false));
+	setMouseEnterCallback(boost::bind(&set_child_visible, this, "hovered_icon", true));
+	setMouseLeaveCallback(boost::bind(&set_child_visible, this, "hovered_icon", false));
 	return TRUE;
 }
 
@@ -1214,7 +1218,7 @@ void LLClassifiedItem::setValue(const LLSD& value)
 {
 	if (!value.isMap()) return;;
 	if (!value.has("selected")) return;
-	childSetVisible("selected_icon", value["selected"]);
+	getChildView("selected_icon")->setVisible( value["selected"]);
 }
 
 void LLClassifiedItem::fillIn(LLPanelClassifiedEdit* panel)
@@ -1237,22 +1241,22 @@ void LLClassifiedItem::fillIn(LLPanelClassifiedEdit* panel)
 
 void LLClassifiedItem::setClassifiedName(const std::string& name)
 {
-	childSetValue("name", name);
+	getChild<LLUICtrl>("name")->setValue(name);
 }
 
 void LLClassifiedItem::setDescription(const std::string& desc)
 {
-	childSetValue("description", desc);
+	getChild<LLUICtrl>("description")->setValue(desc);
 }
 
 void LLClassifiedItem::setSnapshotId(const LLUUID& snapshot_id)
 {
-	childSetValue("picture", snapshot_id);
+	getChild<LLUICtrl>("picture")->setValue(snapshot_id);
 }
 
 LLUUID LLClassifiedItem::getSnapshotId()
 {
-	return childGetValue("picture");
+	return getChild<LLUICtrl>("picture")->getValue();
 }
 
 //EOF
diff --git a/indra/newview/llpanelpicks.h b/indra/newview/llpanelpicks.h
index a98b8c413ed..9dd1ba6ff9c 100644
--- a/indra/newview/llpanelpicks.h
+++ b/indra/newview/llpanelpicks.h
@@ -275,11 +275,11 @@ class LLClassifiedItem : public LLPanel, public LLAvatarPropertiesObserver
 
 	void setClassifiedName (const std::string& name);
 
-	std::string getClassifiedName() { return childGetValue("name").asString(); }
+	std::string getClassifiedName() { return getChild<LLUICtrl>("name")->getValue().asString(); }
 
 	void setDescription(const std::string& desc);
 
-	std::string getDescription() { return childGetValue("description").asString(); }
+	std::string getDescription() { return getChild<LLUICtrl>("description")->getValue().asString(); }
 
 	void setSnapshotId(const LLUUID& snapshot_id);
 
diff --git a/indra/newview/llpanelprofileview.cpp b/indra/newview/llpanelprofileview.cpp
index 044036ea50e..d59e694be6b 100644
--- a/indra/newview/llpanelprofileview.cpp
+++ b/indra/newview/llpanelprofileview.cpp
@@ -123,8 +123,8 @@ BOOL LLPanelProfileView::postBuild()
 	getTabContainer()[PANEL_NOTES] = getChild<LLPanelAvatarNotes>(PANEL_NOTES);
 	
 	//*TODO remove this, according to style guide we don't use status combobox
-	getTabContainer()[PANEL_PROFILE]->childSetVisible("online_me_status_text", FALSE);
-	getTabContainer()[PANEL_PROFILE]->childSetVisible("status_combo", FALSE);
+	getTabContainer()[PANEL_PROFILE]->getChildView("online_me_status_text")->setVisible( FALSE);
+	getTabContainer()[PANEL_PROFILE]->getChildView("status_combo")->setVisible( FALSE);
 
 	mStatusText = getChild<LLTextBox>("status");
 	mStatusText->setVisible(false);
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 1048e3fcc01..af58912b38a 100644
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -169,7 +169,7 @@ void LLTeleportHistoryFlatItem::setValue(const LLSD& value)
 {
 	if (!value.isMap()) return;;
 	if (!value.has("selected")) return;
-	childSetVisible("selected_icon", value["selected"]);
+	getChildView("selected_icon")->setVisible( value["selected"]);
 }
 
 void LLTeleportHistoryFlatItem::setHighlightedText(const std::string& text)
@@ -193,7 +193,7 @@ void LLTeleportHistoryFlatItem::updateTitle()
 
 void LLTeleportHistoryFlatItem::onMouseEnter(S32 x, S32 y, MASK mask)
 {
-	childSetVisible("hovered_icon", true);
+	getChildView("hovered_icon")->setVisible( true);
 	mProfileBtn->setVisible(true);
 
 	LLPanel::onMouseEnter(x, y, mask);
@@ -201,7 +201,7 @@ void LLTeleportHistoryFlatItem::onMouseEnter(S32 x, S32 y, MASK mask)
 
 void LLTeleportHistoryFlatItem::onMouseLeave(S32 x, S32 y, MASK mask)
 {
-	childSetVisible("hovered_icon", false);
+	getChildView("hovered_icon")->setVisible( false);
 	mProfileBtn->setVisible(false);
 
 	LLPanel::onMouseLeave(x, y, mask);
diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp
index 8b016372392..2b76b715682 100644
--- a/indra/newview/llpanelvolume.cpp
+++ b/indra/newview/llpanelvolume.cpp
@@ -85,21 +85,21 @@ BOOL	LLPanelVolume::postBuild()
 	{
 		childSetCommitCallback("Flexible1D Checkbox Ctrl",onCommitIsFlexible,this);
 		childSetCommitCallback("FlexNumSections",onCommitFlexible,this);
-		childSetValidate("FlexNumSections",precommitValidate);
+		getChild<LLUICtrl>("FlexNumSections")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("FlexGravity",onCommitFlexible,this);
-		childSetValidate("FlexGravity",precommitValidate);
+		getChild<LLUICtrl>("FlexGravity")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("FlexFriction",onCommitFlexible,this);
-		childSetValidate("FlexFriction",precommitValidate);
+		getChild<LLUICtrl>("FlexFriction")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("FlexWind",onCommitFlexible,this);
-		childSetValidate("FlexWind",precommitValidate);
+		getChild<LLUICtrl>("FlexWind")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("FlexTension",onCommitFlexible,this);
-		childSetValidate("FlexTension",precommitValidate);
+		getChild<LLUICtrl>("FlexTension")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("FlexForceX",onCommitFlexible,this);
-		childSetValidate("FlexForceX",precommitValidate);
+		getChild<LLUICtrl>("FlexForceX")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("FlexForceY",onCommitFlexible,this);
-		childSetValidate("FlexForceY",precommitValidate);
+		getChild<LLUICtrl>("FlexForceY")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("FlexForceZ",onCommitFlexible,this);
-		childSetValidate("FlexForceZ",precommitValidate);
+		getChild<LLUICtrl>("FlexForceZ")->setValidateBeforeCommit(precommitValidate);
 	}
 
 	// LIGHT Parameters
@@ -121,18 +121,18 @@ BOOL	LLPanelVolume::postBuild()
 		}
 
 		childSetCommitCallback("Light Intensity",onCommitLight,this);
-		childSetValidate("Light Intensity",precommitValidate);
+		getChild<LLUICtrl>("Light Intensity")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("Light Radius",onCommitLight,this);
-		childSetValidate("Light Radius",precommitValidate);
+		getChild<LLUICtrl>("Light Radius")->setValidateBeforeCommit(precommitValidate);
 		childSetCommitCallback("Light Falloff",onCommitLight,this);
-		childSetValidate("Light Falloff",precommitValidate);
+		getChild<LLUICtrl>("Light Falloff")->setValidateBeforeCommit(precommitValidate);
 		
 		childSetCommitCallback("Light FOV", onCommitLight, this);
-		childSetValidate("Light FOV", precommitValidate);
+		getChild<LLUICtrl>("Light FOV")->setValidateBeforeCommit( precommitValidate);
 		childSetCommitCallback("Light Focus", onCommitLight, this);
-		childSetValidate("Light Focus", precommitValidate);
+		getChild<LLUICtrl>("Light Focus")->setValidateBeforeCommit( precommitValidate);
 		childSetCommitCallback("Light Ambiance", onCommitLight, this);
-		childSetValidate("Light Ambiance", precommitValidate);
+		getChild<LLUICtrl>("Light Ambiance")->setValidateBeforeCommit( precommitValidate);
 	}
 	
 	// Start with everyone disabled
@@ -210,25 +210,25 @@ void LLPanelVolume::getState( )
 	// Select Single Message
 	if (single_volume)
 	{
-		childSetVisible("edit_object",true);
-		childSetEnabled("edit_object",true);
-		childSetVisible("select_single",false);
+		getChildView("edit_object")->setVisible(true);
+		getChildView("edit_object")->setEnabled(true);
+		getChildView("select_single")->setVisible(false);
 	}
 	else
 	{	
-		childSetVisible("edit_object",false);
-		childSetVisible("select_single",true);
-		childSetEnabled("select_single",true);
+		getChildView("edit_object")->setVisible(false);
+		getChildView("select_single")->setVisible(true);
+		getChildView("select_single")->setEnabled(true);
 	}
 	
 	// Light properties
 	BOOL is_light = volobjp && volobjp->getIsLight();
-	childSetValue("Light Checkbox Ctrl",is_light);
-	childSetEnabled("Light Checkbox Ctrl",editable && single_volume && volobjp);
+	getChild<LLUICtrl>("Light Checkbox Ctrl")->setValue(is_light);
+	getChildView("Light Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp);
 	
 	if (is_light && editable && single_volume)
 	{
-		childSetEnabled("label color",true);
+		getChildView("label color")->setEnabled(true);
 		//mLabelColor		 ->setEnabled( TRUE );
 		LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
 		if(LightColorSwatch)
@@ -246,22 +246,22 @@ void LLPanelVolume::getState( )
 			LightTextureCtrl->setImageAssetID(volobjp->getLightTextureID());
 		}
 
-		childSetEnabled("Light Intensity",true);
-		childSetEnabled("Light Radius",true);
-		childSetEnabled("Light Falloff",true);
+		getChildView("Light Intensity")->setEnabled(true);
+		getChildView("Light Radius")->setEnabled(true);
+		getChildView("Light Falloff")->setEnabled(true);
 
-		childSetEnabled("Light FOV", true);
-		childSetEnabled("Light Focus", true);
-		childSetEnabled("Light Ambiance", true);
+		getChildView("Light FOV")->setEnabled(true);
+		getChildView("Light Focus")->setEnabled(true);
+		getChildView("Light Ambiance")->setEnabled(true);
 		
-		childSetValue("Light Intensity",volobjp->getLightIntensity());
-		childSetValue("Light Radius",volobjp->getLightRadius());
-		childSetValue("Light Falloff",volobjp->getLightFalloff());
+		getChild<LLUICtrl>("Light Intensity")->setValue(volobjp->getLightIntensity());
+		getChild<LLUICtrl>("Light Radius")->setValue(volobjp->getLightRadius());
+		getChild<LLUICtrl>("Light Falloff")->setValue(volobjp->getLightFalloff());
 
 		LLVector3 params = volobjp->getSpotLightParams();
-		childSetValue("Light FOV", params.mV[0]);
-		childSetValue("Light Focus", params.mV[1]);
-		childSetValue("Light Ambiance", params.mV[2]);
+		getChild<LLUICtrl>("Light FOV")->setValue(params.mV[0]);
+		getChild<LLUICtrl>("Light Focus")->setValue(params.mV[1]);
+		getChild<LLUICtrl>("Light Ambiance")->setValue(params.mV[2]);
 
 		mLightSavedColor = volobjp->getLightColor();
 	}
@@ -271,7 +271,7 @@ void LLPanelVolume::getState( )
 		getChild<LLSpinCtrl>("Light Radius", true)->clear();
 		getChild<LLSpinCtrl>("Light Falloff", true)->clear();
 
-		childSetEnabled("label color",false);	
+		getChildView("label color")->setEnabled(false);	
 		LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
 		if(LightColorSwatch)
 		{
@@ -285,56 +285,56 @@ void LLPanelVolume::getState( )
 			LightTextureCtrl->setValid(FALSE);
 		}
 
-		childSetEnabled("Light Intensity",false);
-		childSetEnabled("Light Radius",false);
-		childSetEnabled("Light Falloff",false);
+		getChildView("Light Intensity")->setEnabled(false);
+		getChildView("Light Radius")->setEnabled(false);
+		getChildView("Light Falloff")->setEnabled(false);
 
-		childSetEnabled("Light FOV",false);
-		childSetEnabled("Light Focus",false);
-		childSetEnabled("Light Ambiance",false);
+		getChildView("Light FOV")->setEnabled(false);
+		getChildView("Light Focus")->setEnabled(false);
+		getChildView("Light Ambiance")->setEnabled(false);
 	}
 	
 	// Flexible properties
 	BOOL is_flexible = volobjp && volobjp->isFlexible();
-	childSetValue("Flexible1D Checkbox Ctrl",is_flexible);
+	getChild<LLUICtrl>("Flexible1D Checkbox Ctrl")->setValue(is_flexible);
 	if (is_flexible || (volobjp && volobjp->canBeFlexible()))
 	{
-		childSetEnabled("Flexible1D Checkbox Ctrl", editable && single_volume && volobjp);
+		getChildView("Flexible1D Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp);
 	}
 	else
 	{
-		childSetEnabled("Flexible1D Checkbox Ctrl", false);
+		getChildView("Flexible1D Checkbox Ctrl")->setEnabled(false);
 	}
 	if (is_flexible && editable && single_volume)
 	{
-		childSetVisible("FlexNumSections",true);
-		childSetVisible("FlexGravity",true);
-		childSetVisible("FlexTension",true);
-		childSetVisible("FlexFriction",true);
-		childSetVisible("FlexWind",true);
-		childSetVisible("FlexForceX",true);
-		childSetVisible("FlexForceY",true);
-		childSetVisible("FlexForceZ",true);
-
-		childSetEnabled("FlexNumSections",true);
-		childSetEnabled("FlexGravity",true);
-		childSetEnabled("FlexTension",true);
-		childSetEnabled("FlexFriction",true);
-		childSetEnabled("FlexWind",true);
-		childSetEnabled("FlexForceX",true);
-		childSetEnabled("FlexForceY",true);
-		childSetEnabled("FlexForceZ",true);
+		getChildView("FlexNumSections")->setVisible(true);
+		getChildView("FlexGravity")->setVisible(true);
+		getChildView("FlexTension")->setVisible(true);
+		getChildView("FlexFriction")->setVisible(true);
+		getChildView("FlexWind")->setVisible(true);
+		getChildView("FlexForceX")->setVisible(true);
+		getChildView("FlexForceY")->setVisible(true);
+		getChildView("FlexForceZ")->setVisible(true);
+
+		getChildView("FlexNumSections")->setEnabled(true);
+		getChildView("FlexGravity")->setEnabled(true);
+		getChildView("FlexTension")->setEnabled(true);
+		getChildView("FlexFriction")->setEnabled(true);
+		getChildView("FlexWind")->setEnabled(true);
+		getChildView("FlexForceX")->setEnabled(true);
+		getChildView("FlexForceY")->setEnabled(true);
+		getChildView("FlexForceZ")->setEnabled(true);
 
 		LLFlexibleObjectData *attributes = (LLFlexibleObjectData *)objectp->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
 		
-		childSetValue("FlexNumSections",(F32)attributes->getSimulateLOD());
-		childSetValue("FlexGravity",attributes->getGravity());
-		childSetValue("FlexTension",attributes->getTension());
-		childSetValue("FlexFriction",attributes->getAirFriction());
-		childSetValue("FlexWind",attributes->getWindSensitivity());
-		childSetValue("FlexForceX",attributes->getUserForce().mV[VX]);
-		childSetValue("FlexForceY",attributes->getUserForce().mV[VY]);
-		childSetValue("FlexForceZ",attributes->getUserForce().mV[VZ]);
+		getChild<LLUICtrl>("FlexNumSections")->setValue((F32)attributes->getSimulateLOD());
+		getChild<LLUICtrl>("FlexGravity")->setValue(attributes->getGravity());
+		getChild<LLUICtrl>("FlexTension")->setValue(attributes->getTension());
+		getChild<LLUICtrl>("FlexFriction")->setValue(attributes->getAirFriction());
+		getChild<LLUICtrl>("FlexWind")->setValue(attributes->getWindSensitivity());
+		getChild<LLUICtrl>("FlexForceX")->setValue(attributes->getUserForce().mV[VX]);
+		getChild<LLUICtrl>("FlexForceY")->setValue(attributes->getUserForce().mV[VY]);
+		getChild<LLUICtrl>("FlexForceZ")->setValue(attributes->getUserForce().mV[VZ]);
 	}
 	else
 	{
@@ -347,14 +347,14 @@ void LLPanelVolume::getState( )
 		getChild<LLSpinCtrl>("FlexForceY", true)->clear();
 		getChild<LLSpinCtrl>("FlexForceZ", true)->clear();
 
-		childSetEnabled("FlexNumSections",false);
-		childSetEnabled("FlexGravity",false);
-		childSetEnabled("FlexTension",false);
-		childSetEnabled("FlexFriction",false);
-		childSetEnabled("FlexWind",false);
-		childSetEnabled("FlexForceX",false);
-		childSetEnabled("FlexForceY",false);
-		childSetEnabled("FlexForceZ",false);
+		getChildView("FlexNumSections")->setEnabled(false);
+		getChildView("FlexGravity")->setEnabled(false);
+		getChildView("FlexTension")->setEnabled(false);
+		getChildView("FlexFriction")->setEnabled(false);
+		getChildView("FlexWind")->setEnabled(false);
+		getChildView("FlexForceX")->setEnabled(false);
+		getChildView("FlexForceY")->setEnabled(false);
+		getChildView("FlexForceZ")->setEnabled(false);
 	}
 	
 	mObject = objectp;
@@ -384,11 +384,11 @@ void LLPanelVolume::refresh()
 
 	BOOL visible = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 0 ? TRUE : FALSE;
 
-	childSetVisible("label texture", visible);
-	childSetVisible("Light FOV", visible);
-	childSetVisible("Light Focus", visible);
-	childSetVisible("Light Ambiance", visible);
-	childSetVisible("light texture control", visible);
+	getChildView("label texture")->setVisible( visible);
+	getChildView("Light FOV")->setVisible( visible);
+	getChildView("Light Focus")->setVisible( visible);
+	getChildView("Light Ambiance")->setVisible( visible);
+	getChildView("light texture control")->setVisible( visible);
 
 }
 
@@ -403,13 +403,13 @@ void LLPanelVolume::clearCtrls()
 {
 	LLPanel::clearCtrls();
 
-	childSetEnabled("select_single",false);
-	childSetVisible("select_single",true);
-	childSetEnabled("edit_object",false);
-	childSetVisible("edit_object",false);
-	childSetEnabled("Light Checkbox Ctrl",false);
-	childSetEnabled("label color",false);
-	childSetEnabled("label color",false);
+	getChildView("select_single")->setEnabled(false);
+	getChildView("select_single")->setVisible(true);
+	getChildView("edit_object")->setEnabled(false);
+	getChildView("edit_object")->setVisible(false);
+	getChildView("Light Checkbox Ctrl")->setEnabled(false);
+	getChildView("label color")->setEnabled(false);
+	getChildView("label color")->setEnabled(false);
 	LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
 	if(LightColorSwatch)
 	{
@@ -423,19 +423,19 @@ void LLPanelVolume::clearCtrls()
 		LightTextureCtrl->setValid( FALSE );
 	}
 
-	childSetEnabled("Light Intensity",false);
-	childSetEnabled("Light Radius",false);
-	childSetEnabled("Light Falloff",false);
-
-	childSetEnabled("Flexible1D Checkbox Ctrl",false);
-	childSetEnabled("FlexNumSections",false);
-	childSetEnabled("FlexGravity",false);
-	childSetEnabled("FlexTension",false);
-	childSetEnabled("FlexFriction",false);
-	childSetEnabled("FlexWind",false);
-	childSetEnabled("FlexForceX",false);
-	childSetEnabled("FlexForceY",false);
-	childSetEnabled("FlexForceZ",false);
+	getChildView("Light Intensity")->setEnabled(false);
+	getChildView("Light Radius")->setEnabled(false);
+	getChildView("Light Falloff")->setEnabled(false);
+
+	getChildView("Flexible1D Checkbox Ctrl")->setEnabled(false);
+	getChildView("FlexNumSections")->setEnabled(false);
+	getChildView("FlexGravity")->setEnabled(false);
+	getChildView("FlexTension")->setEnabled(false);
+	getChildView("FlexFriction")->setEnabled(false);
+	getChildView("FlexWind")->setEnabled(false);
+	getChildView("FlexForceX")->setEnabled(false);
+	getChildView("FlexForceY")->setEnabled(false);
+	getChildView("FlexForceZ")->setEnabled(false);
 }
 
 //
@@ -451,7 +451,7 @@ void LLPanelVolume::sendIsLight()
 	}	
 	LLVOVolume *volobjp = (LLVOVolume *)objectp;
 	
-	BOOL value = childGetValue("Light Checkbox Ctrl");
+	BOOL value = getChild<LLUICtrl>("Light Checkbox Ctrl")->getValue();
 	volobjp->setIsLight(value);
 	llinfos << "update light sent" << llendl;
 }
@@ -465,7 +465,7 @@ void LLPanelVolume::sendIsFlexible()
 	}	
 	LLVOVolume *volobjp = (LLVOVolume *)objectp;
 	
-	BOOL is_flexible = childGetValue("Flexible1D Checkbox Ctrl");
+	BOOL is_flexible = getChild<LLUICtrl>("Flexible1D Checkbox Ctrl")->getValue();
 	//BOOL is_flexible = mCheckFlexible1D->get();
 
 	if (is_flexible)
@@ -557,9 +557,9 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
 	LLVOVolume *volobjp = (LLVOVolume *)objectp;
 	
 	
-	volobjp->setLightIntensity((F32)self->childGetValue("Light Intensity").asReal());
-	volobjp->setLightRadius((F32)self->childGetValue("Light Radius").asReal());
-	volobjp->setLightFalloff((F32)self->childGetValue("Light Falloff").asReal());
+	volobjp->setLightIntensity((F32)self->getChild<LLUICtrl>("Light Intensity")->getValue().asReal());
+	volobjp->setLightRadius((F32)self->getChild<LLUICtrl>("Light Radius")->getValue().asReal());
+	volobjp->setLightFalloff((F32)self->getChild<LLUICtrl>("Light Falloff")->getValue().asReal());
 
 	LLColorSwatchCtrl*	LightColorSwatch = self->getChild<LLColorSwatchCtrl>("colorswatch");
 	if(LightColorSwatch)
@@ -578,25 +578,25 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
 			{ //this commit is making this a spot light, set UI to default params
 				volobjp->setLightTextureID(id);
 				LLVector3 spot_params = volobjp->getSpotLightParams();
-				self->childSetValue("Light FOV", spot_params.mV[0]);
-				self->childSetValue("Light Focus", spot_params.mV[1]);
-				self->childSetValue("Light Ambiance", spot_params.mV[2]);
+				self->getChild<LLUICtrl>("Light FOV")->setValue(spot_params.mV[0]);
+				self->getChild<LLUICtrl>("Light Focus")->setValue(spot_params.mV[1]);
+				self->getChild<LLUICtrl>("Light Ambiance")->setValue(spot_params.mV[2]);
 			}
 			else
 			{ //modifying existing params
 				LLVector3 spot_params;
-				spot_params.mV[0] = (F32) self->childGetValue("Light FOV").asReal();
-				spot_params.mV[1] = (F32) self->childGetValue("Light Focus").asReal();
-				spot_params.mV[2] = (F32) self->childGetValue("Light Ambiance").asReal();
+				spot_params.mV[0] = (F32) self->getChild<LLUICtrl>("Light FOV")->getValue().asReal();
+				spot_params.mV[1] = (F32) self->getChild<LLUICtrl>("Light Focus")->getValue().asReal();
+				spot_params.mV[2] = (F32) self->getChild<LLUICtrl>("Light Ambiance")->getValue().asReal();
 				volobjp->setSpotLightParams(spot_params);
 			}
 		}
 		else if (volobjp->isLightSpotlight())
 		{ //no longer a spot light
 			volobjp->setLightTextureID(id);
-			//self->childDisable("Light FOV");
-			//self->childDisable("Light Focus");
-			//self->childDisable("Light Ambiance");
+			//self->getChildView("Light FOV")->setEnabled(FALSE);
+			//self->getChildView("Light Focus")->setEnabled(FALSE);
+			//self->getChildView("Light Ambiance")->setEnabled(FALSE);
 		}
 	}
 
@@ -629,14 +629,14 @@ void LLPanelVolume::onCommitFlexible( LLUICtrl* ctrl, void* userdata )
 		new_attributes = *attributes;
 
 
-		new_attributes.setSimulateLOD(self->childGetValue("FlexNumSections").asInteger());//(S32)self->mSpinSections->get());
-		new_attributes.setGravity((F32)self->childGetValue("FlexGravity").asReal());
-		new_attributes.setTension((F32)self->childGetValue("FlexTension").asReal());
-		new_attributes.setAirFriction((F32)self->childGetValue("FlexFriction").asReal());
-		new_attributes.setWindSensitivity((F32)self->childGetValue("FlexWind").asReal());
-		F32 fx = (F32)self->childGetValue("FlexForceX").asReal();
-		F32 fy = (F32)self->childGetValue("FlexForceY").asReal();
-		F32 fz = (F32)self->childGetValue("FlexForceZ").asReal();
+		new_attributes.setSimulateLOD(self->getChild<LLUICtrl>("FlexNumSections")->getValue().asInteger());//(S32)self->mSpinSections->get());
+		new_attributes.setGravity((F32)self->getChild<LLUICtrl>("FlexGravity")->getValue().asReal());
+		new_attributes.setTension((F32)self->getChild<LLUICtrl>("FlexTension")->getValue().asReal());
+		new_attributes.setAirFriction((F32)self->getChild<LLUICtrl>("FlexFriction")->getValue().asReal());
+		new_attributes.setWindSensitivity((F32)self->getChild<LLUICtrl>("FlexWind")->getValue().asReal());
+		F32 fx = (F32)self->getChild<LLUICtrl>("FlexForceX")->getValue().asReal();
+		F32 fy = (F32)self->getChild<LLUICtrl>("FlexForceY")->getValue().asReal();
+		F32 fz = (F32)self->getChild<LLUICtrl>("FlexForceZ")->getValue().asReal();
 		LLVector3 force(fx,fy,fz);
 
 		new_attributes.setUserForce(force);
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index f2e69699984..4e8e4e3a401 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -695,11 +695,11 @@ void LLParticipantList::LLParticipantListMenu::show(LLView* spawning_view, const
 
 	if (is_muted)
 	{
-		LLMenuGL::sMenuContainer->childSetVisible("ModerateVoiceMuteSelected", false);
+		LLMenuGL::sMenuContainer->getChildView("ModerateVoiceMuteSelected")->setVisible( false);
 	}
 	else
 	{
-		LLMenuGL::sMenuContainer->childSetVisible("ModerateVoiceUnMuteSelected", false);
+		LLMenuGL::sMenuContainer->getChildView("ModerateVoiceUnMuteSelected")->setVisible( false);
 	}
 }
 
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index dd31a626422..4becde7ab5c 100644
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -149,12 +149,12 @@ void LLPreview::onCommit()
 		}
 		
 		LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
-		new_item->setDescription(childGetText("desc"));
+		new_item->setDescription(getChild<LLUICtrl>("desc")->getValue().asString());
 
-		std::string new_name = childGetText("name");
+		std::string new_name = getChild<LLUICtrl>("name")->getValue().asString();
 		if ( (new_item->getName() != new_name) && !new_name.empty())
 		{
-			new_item->rename(childGetText("name"));
+			new_item->rename(getChild<LLUICtrl>("name")->getValue().asString());
 		}
 
 		if(mObjectUUID.notNull())
@@ -186,7 +186,7 @@ void LLPreview::onCommit()
 					{
 						LLSelectMgr::getInstance()->deselectAll();
 						LLSelectMgr::getInstance()->addAsIndividual( obj, SELECT_ALL_TES, FALSE );
-						LLSelectMgr::getInstance()->selectionSetObjectDescription( childGetText("desc") );
+						LLSelectMgr::getInstance()->selectionSetObjectDescription( getChild<LLUICtrl>("desc")->getValue().asString() );
 
 						LLSelectMgr::getInstance()->deselectAll();
 					}
@@ -232,10 +232,10 @@ void LLPreview::refreshFromItem()
 		LLUIString title = getString("Title", args);
 		setTitle(title.getString());
 	}
-	childSetText("desc",item->getDescription());
+	getChild<LLUICtrl>("desc")->setValue(item->getDescription());
 
 	BOOL can_agent_manipulate = item->getPermissions().allowModifyBy(gAgent.getID());
-	childSetEnabled("desc",can_agent_manipulate);
+	getChildView("desc")->setEnabled(can_agent_manipulate);
 }
 
 // static 
diff --git a/indra/newview/llpreviewanim.cpp b/indra/newview/llpreviewanim.cpp
index 262961b73b2..a59ed53889a 100644
--- a/indra/newview/llpreviewanim.cpp
+++ b/indra/newview/llpreviewanim.cpp
@@ -60,8 +60,8 @@ void LLPreviewAnim::endAnimCallback( void *userdata )
 	delete handlep; // done with the handle
 	if (self)
 	{
-		self->childSetValue("Anim play btn", FALSE);
-		self->childSetValue("Anim audition btn", FALSE);
+		self->getChild<LLUICtrl>("Anim play btn")->setValue(FALSE);
+		self->getChild<LLUICtrl>("Anim audition btn")->setValue(FALSE);
 	}
 }
 
@@ -72,14 +72,14 @@ BOOL LLPreviewAnim::postBuild()
 	if(item)
 	{
 		gAgentAvatarp->createMotion(item->getAssetUUID()); // preload the animation
-		childSetText("desc", item->getDescription());
+		getChild<LLUICtrl>("desc")->setValue(item->getDescription());
 	}
 
 	childSetAction("Anim play btn",playAnim, this);
 	childSetAction("Anim audition btn",auditionAnim, this);
 
 	childSetCommitCallback("desc", LLPreview::onText, this);
-	childSetPrevalidate("desc", &LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 	
 	return LLPreview::postBuild();
 }
@@ -121,7 +121,7 @@ void LLPreviewAnim::playAnim( void *userdata )
 			btn->toggleState();
 		}
 		
-		if (self->childGetValue("Anim play btn").asBoolean() ) 
+		if (self->getChild<LLUICtrl>("Anim play btn")->getValue().asBoolean() ) 
 		{
 			self->mPauseRequest = NULL;
 			gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START);
@@ -155,7 +155,7 @@ void LLPreviewAnim::auditionAnim( void *userdata )
 			btn->toggleState();
 		}
 		
-		if (self->childGetValue("Anim audition btn").asBoolean() ) 
+		if (self->getChild<LLUICtrl>("Anim audition btn")->getValue().asBoolean() ) 
 		{
 			self->mPauseRequest = NULL;
 			gAgentAvatarp->startMotion(item->getAssetUUID());
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index 6f9d8a76234..6ef7c85e31b 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -482,11 +482,11 @@ BOOL LLPreviewGesture::postBuild()
 
 	if (item) 
 	{
-		childSetText("desc", item->getDescription());
-		childSetPrevalidate("desc", &LLTextValidate::validateASCIIPrintableNoPipe);
+		getChild<LLUICtrl>("desc")->setValue(item->getDescription());
+		getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 		
-		childSetText("name", item->getName());
-		childSetPrevalidate("name", &LLTextValidate::validateASCIIPrintableNoPipe);
+		getChild<LLUICtrl>("name")->setValue(item->getName());
+		getChild<LLLineEditor>("name")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 	}
 
 	return LLPreview::postBuild();
@@ -628,7 +628,7 @@ void LLPreviewGesture::refresh()
 	if (mPreviewGesture || !is_complete)
 	{
 		
-		childSetEnabled("desc", FALSE);
+		getChildView("desc")->setEnabled(FALSE);
 		//mDescEditor->setEnabled(FALSE);
 		mTriggerEditor->setEnabled(FALSE);
 		mReplaceText->setEnabled(FALSE);
@@ -659,7 +659,7 @@ void LLPreviewGesture::refresh()
 
 	BOOL modifiable = item->getPermissions().allowModifyBy(gAgent.getID());
 
-	childSetEnabled("desc", modifiable);
+	getChildView("desc")->setEnabled(modifiable);
 	mTriggerEditor->setEnabled(TRUE);
 	mLibraryList->setEnabled(modifiable);
 	mStepList->setEnabled(modifiable);
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index fb7ac0d86b4..ee86d3a2c6e 100644
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -91,20 +91,20 @@ BOOL LLPreviewNotecard::postBuild()
 	ed->makePristine();
 
 	childSetAction("Save", onClickSave, this);
-	childSetVisible("lock", FALSE);	
+	getChildView("lock")->setVisible( FALSE);	
 
 	childSetAction("Delete", onClickDelete, this);
-	childSetEnabled("Delete", false);
+	getChildView("Delete")->setEnabled(false);
 
 	const LLInventoryItem* item = getItem();
 
 	childSetCommitCallback("desc", LLPreview::onText, this);
 	if (item)
 	{
-		childSetText("desc", item->getDescription());
-		childSetEnabled("Delete", true);
+		getChild<LLUICtrl>("desc")->setValue(item->getDescription());
+		getChildView("Delete")->setEnabled(true);
 	}
-	childSetPrevalidate("desc", &LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 
 	return LLPreview::postBuild();
 }
@@ -120,10 +120,10 @@ void LLPreviewNotecard::setEnabled( BOOL enabled )
 
 	LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor");
 
-	childSetEnabled("Notecard Editor", enabled);
-	childSetVisible("lock", !enabled);
-	childSetEnabled("desc", enabled);
-	childSetEnabled("Save", enabled && editor && (!editor->isPristine()));
+	getChildView("Notecard Editor")->setEnabled(enabled);
+	getChildView("lock")->setVisible( !enabled);
+	getChildView("desc")->setEnabled(enabled);
+	getChildView("Save")->setEnabled(enabled && editor && (!editor->isPristine()));
 }
 
 
@@ -132,7 +132,7 @@ void LLPreviewNotecard::draw()
 	LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor");
 	BOOL changed = !editor->isPristine();
 
-	childSetEnabled("Save", changed && getEnabled());
+	getChildView("Save")->setEnabled(changed && getEnabled());
 	
 	LLPreview::draw();
 }
@@ -283,7 +283,7 @@ void LLPreviewNotecard::loadAsset()
 								GP_OBJECT_MANIPULATE))
 		{
 			editor->setEnabled(FALSE);
-			childSetVisible("lock", TRUE);
+			getChildView("lock")->setVisible( TRUE);
 		}
 	}
 	else
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 7b926f468dd..73845e2772f 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -219,7 +219,7 @@ void LLFloaterScriptSearch::onBtnSearch(void *userdata)
 void LLFloaterScriptSearch::handleBtnSearch()
 {
 	LLCheckBoxCtrl* caseChk = getChild<LLCheckBoxCtrl>("case_text");
-	mEditorCore->mEditor->selectNext(childGetText("search_text"), caseChk->get());
+	mEditorCore->mEditor->selectNext(getChild<LLUICtrl>("search_text")->getValue().asString(), caseChk->get());
 }
 
 // static 
@@ -232,7 +232,7 @@ void LLFloaterScriptSearch::onBtnReplace(void *userdata)
 void LLFloaterScriptSearch::handleBtnReplace()
 {
 	LLCheckBoxCtrl* caseChk = getChild<LLCheckBoxCtrl>("case_text");
-	mEditorCore->mEditor->replaceText(childGetText("search_text"), childGetText("replace_text"), caseChk->get());
+	mEditorCore->mEditor->replaceText(getChild<LLUICtrl>("search_text")->getValue().asString(), getChild<LLUICtrl>("replace_text")->getValue().asString(), caseChk->get());
 }
 
 // static 
@@ -245,7 +245,7 @@ void LLFloaterScriptSearch::onBtnReplaceAll(void *userdata)
 void LLFloaterScriptSearch::handleBtnReplaceAll()
 {
 	LLCheckBoxCtrl* caseChk = getChild<LLCheckBoxCtrl>("case_text");
-	mEditorCore->mEditor->replaceTextAll(childGetText("search_text"), childGetText("replace_text"), caseChk->get());
+	mEditorCore->mEditor->replaceTextAll(getChild<LLUICtrl>("search_text")->getValue().asString(), getChild<LLUICtrl>("replace_text")->getValue().asString(), caseChk->get());
 }
 
 
@@ -457,7 +457,7 @@ bool LLScriptEdCore::hasChanged()
 void LLScriptEdCore::draw()
 {
 	BOOL script_changed	= hasChanged();
-	childSetEnabled("Save_btn",	script_changed);
+	getChildView("Save_btn")->setEnabled(script_changed);
 
 	if( mEditor->hasFocus() )
 	{
@@ -469,11 +469,11 @@ void LLScriptEdCore::draw()
 		args["[LINE]"] = llformat ("%d", line);
 		args["[COLUMN]"] = llformat ("%d", column);
 		cursor_pos = LLTrans::getString("CursorPos", args);
-		childSetText("line_col", cursor_pos);
+		getChild<LLUICtrl>("line_col")->setValue(cursor_pos);
 	}
 	else
 	{
-		childSetText("line_col", LLStringUtil::null);
+		getChild<LLUICtrl>("line_col")->setValue(LLStringUtil::null);
 	}
 
 	updateDynamicHelp();
@@ -666,7 +666,7 @@ void LLScriptEdCore::onBtnDynamicHelp()
 		if (parent)
 			parent->addDependentFloater(live_help_floater, TRUE);
 		live_help_floater->childSetCommitCallback("lock_check", onCheckLock, this);
-		live_help_floater->childSetValue("lock_check", gSavedSettings.getBOOL("ScriptHelpFollowsCursor"));
+		live_help_floater->getChild<LLUICtrl>("lock_check")->setValue(gSavedSettings.getBOOL("ScriptHelpFollowsCursor"));
 		live_help_floater->childSetCommitCallback("history_combo", onHelpComboCommit, this);
 		live_help_floater->childSetAction("back_btn", onClickBack, this);
 		live_help_floater->childSetAction("fwd_btn", onClickForward, this);
@@ -959,10 +959,10 @@ BOOL LLPreviewLSL::postBuild()
 	llassert(item);
 	if (item)
 	{
-		childSetText("desc", item->getDescription());
+		getChild<LLUICtrl>("desc")->setValue(item->getDescription());
 	}
 	childSetCommitCallback("desc", LLPreview::onText, this);
-	childSetPrevalidate("desc", &LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 
 	return LLPreview::postBuild();
 }
@@ -1040,8 +1040,8 @@ void LLPreviewLSL::loadAsset()
 			mScriptEd->mFunctions->setEnabled(FALSE);
 			mAssetStatus = PREVIEW_ASSET_LOADED;
 		}
-		childSetVisible("lock", !is_modifiable);
-		mScriptEd->childSetEnabled("Insert...", is_modifiable);
+		getChildView("lock")->setVisible( !is_modifiable);
+		mScriptEd->getChildView("Insert...")->setEnabled(is_modifiable);
 	}
 	else
 	{
@@ -1429,14 +1429,14 @@ LLLiveLSLEditor::LLLiveLSLEditor(const LLSD& key) :
 BOOL LLLiveLSLEditor::postBuild()
 {
 	childSetCommitCallback("running", LLLiveLSLEditor::onRunningCheckboxClicked, this);
-	childSetEnabled("running", FALSE);
+	getChildView("running")->setEnabled(FALSE);
 
 	childSetAction("Reset",&LLLiveLSLEditor::onReset,this);
-	childSetEnabled("Reset", TRUE);
+	getChildView("Reset")->setEnabled(TRUE);
 
 	mMonoCheckbox =	getChild<LLCheckBoxCtrl>("mono");
 	childSetCommitCallback("mono", &LLLiveLSLEditor::onMonoCheckboxClicked, this);
-	childSetEnabled("mono", FALSE);
+	getChildView("mono")->setEnabled(FALSE);
 
 	mScriptEd->mEditor->makePristine();
 	mScriptEd->mEditor->setFocus(TRUE);
diff --git a/indra/newview/llpreviewsound.cpp b/indra/newview/llpreviewsound.cpp
index 44b828854bd..d9bcf5fba66 100644
--- a/indra/newview/llpreviewsound.cpp
+++ b/indra/newview/llpreviewsound.cpp
@@ -60,7 +60,7 @@ BOOL	LLPreviewSound::postBuild()
 	const LLInventoryItem* item = getItem();
 	if (item)
 	{
-		childSetText("desc", item->getDescription());
+		getChild<LLUICtrl>("desc")->setValue(item->getDescription());
 		if (gAudiop)
 			gAudiop->preloadSound(item->getAssetUUID()); // preload the sound
 	}
@@ -75,7 +75,7 @@ BOOL	LLPreviewSound::postBuild()
 	button->setSoundFlags(LLView::SILENT);
 
 	childSetCommitCallback("desc", LLPreview::onText, this);
-	childSetPrevalidate("desc", &LLTextValidate::validateASCIIPrintableNoPipe);	
+	getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);	
 
 	return LLPreview::postBuild();
 }
diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp
index 7fdc5c8b5f6..c1cb386556f 100644
--- a/indra/newview/llpreviewtexture.cpp
+++ b/indra/newview/llpreviewtexture.cpp
@@ -105,7 +105,7 @@ BOOL LLPreviewTexture::postBuild()
 	{
 		getChild<LLButton>("Keep")->setLabel(getString("Copy"));
 		childSetAction("Keep",LLPreview::onBtnCopyToInv,this);
-		childSetVisible("Discard", false);
+		getChildView("Discard")->setVisible( false);
 	}
 	else if (mShowKeepDiscard)
 	{
@@ -114,13 +114,13 @@ BOOL LLPreviewTexture::postBuild()
 	}
 	else
 	{
-		childSetVisible("Keep", false);
-		childSetVisible("Discard", false);
+		getChildView("Keep")->setVisible( false);
+		getChildView("Discard")->setVisible( false);
 	}
 	
 	childSetAction("save_tex_btn", LLPreviewTexture::onSaveAsBtn, this);
-	childSetVisible("save_tex_btn", true);
-	childSetEnabled("save_tex_btn", canSaveAs());
+	getChildView("save_tex_btn")->setVisible( true);
+	getChildView("save_tex_btn")->setEnabled(canSaveAs());
 	
 	if (!mCopyToInv) 
 	{
@@ -129,8 +129,8 @@ BOOL LLPreviewTexture::postBuild()
 		if (item)
 		{
 			childSetCommitCallback("desc", LLPreview::onText, this);
-			childSetText("desc", item->getDescription());
-			childSetPrevalidate("desc", &LLTextValidate::validateASCIIPrintableNoPipe);
+			getChild<LLUICtrl>("desc")->setValue(item->getDescription());
+			getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 		}
 	}
 	
@@ -289,8 +289,7 @@ void LLPreviewTexture::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
 	LLPreview::reshape(width, height, called_from_parent);
 
-	LLRect dim_rect;
-	childGetRect("dimensions", dim_rect);
+	LLRect dim_rect(getChildView("dimensions")->getRect());
 
 	S32 horiz_pad = 2 * (LLPANEL_BORDER_WIDTH + PREVIEW_PAD) + PREVIEW_RESIZE_HANDLE_SIZE;
 
@@ -412,12 +411,11 @@ void LLPreviewTexture::updateDimensions()
 	
 	mUpdateDimensions = FALSE;
 
-	childSetTextArg("dimensions", "[WIDTH]", llformat("%d", mImage->getFullWidth()));
-	childSetTextArg("dimensions", "[HEIGHT]", llformat("%d", mImage->getFullHeight()));
+	getChild<LLUICtrl>("dimensions")->setTextArg("[WIDTH]", llformat("%d", mImage->getFullWidth()));
+	getChild<LLUICtrl>("dimensions")->setTextArg("[HEIGHT]", llformat("%d", mImage->getFullHeight()));
 
 	
-	LLRect dim_rect;
-	childGetRect("dimensions", dim_rect);
+	LLRect dim_rect(getChildView("dimensions")->getRect());
 
 	S32 horiz_pad = 2 * (LLPANEL_BORDER_WIDTH + PREVIEW_PAD) + PREVIEW_RESIZE_HANDLE_SIZE;
 
@@ -491,9 +489,8 @@ void LLPreviewTexture::updateDimensions()
 
 	// Hide the aspect ratio label if the window is too narrow
 	// Assumes the label should be to the right of the dimensions
-	LLRect aspect_label_rect;
-	childGetRect("aspect_ratio", aspect_label_rect);
-	childSetVisible("aspect_ratio", dim_rect.mRight < aspect_label_rect.mLeft);
+	LLRect aspect_label_rect(getChildView("aspect_ratio")->getRect());
+	getChildView("aspect_ratio")->setVisible( dim_rect.mRight < aspect_label_rect.mLeft);
 }
 
 
@@ -550,7 +547,7 @@ void LLPreviewTexture::loadAsset()
 	mAssetStatus = PREVIEW_ASSET_LOADING;
 	mUpdateDimensions = TRUE;
 	updateDimensions();
-	childSetEnabled("save_tex_btn", canSaveAs());
+	getChildView("save_tex_btn")->setEnabled(canSaveAs());
 }
 
 LLPreview::EAssetStatus LLPreviewTexture::getAssetStatus()
diff --git a/indra/newview/llsaveoutfitcombobtn.cpp b/indra/newview/llsaveoutfitcombobtn.cpp
index 9518b0cbb32..e2f5aee56d5 100644
--- a/indra/newview/llsaveoutfitcombobtn.cpp
+++ b/indra/newview/llsaveoutfitcombobtn.cpp
@@ -94,5 +94,5 @@ void LLSaveOutfitComboBtn::setMenuItemEnabled(const std::string& item, bool enab
 
 void LLSaveOutfitComboBtn::setSaveBtnEnabled(bool enabled)
 {
-	mParent->childSetEnabled(SAVE_BTN, enabled);
+	mParent->getChildView(SAVE_BTN)->setEnabled(enabled);
 }
diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp
index 36d581a41a9..d715c47631c 100644
--- a/indra/newview/llscrollingpanelparam.cpp
+++ b/indra/newview/llscrollingpanelparam.cpp
@@ -79,17 +79,17 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param
 	
 	mHintMin->setAllowsUpdates( FALSE );
 	mHintMax->setAllowsUpdates( FALSE );
-	childSetValue("param slider", weightToPercent(param->getWeight()));
+	getChild<LLUICtrl>("param slider")->setValue(weightToPercent(param->getWeight()));
 
 	std::string display_name = LLTrans::getString(param->getDisplayName());
-	childSetLabelArg("param slider", "[DESC]", display_name);
-	childSetEnabled("param slider", mAllowModify);
+	getChild<LLUICtrl>("param slider")->setLabelArg("[DESC]", display_name);
+	getChildView("param slider")->setEnabled(mAllowModify);
 	childSetCommitCallback("param slider", LLScrollingPanelParam::onSliderMoved, this);
 
 	std::string min_name = LLTrans::getString(param->getMinDisplayName());
 	std::string max_name = LLTrans::getString(param->getMaxDisplayName());
-	childSetValue("min param text", min_name);
-	childSetValue("max param text", max_name);
+	getChild<LLUICtrl>("min param text")->setValue(min_name);
+	getChild<LLUICtrl>("max param text")->setValue(max_name);
 
 	LLButton* less = getChild<LLButton>("less");
 	if (less)
@@ -126,14 +126,14 @@ void LLScrollingPanelParam::updatePanel(BOOL allow_modify)
 		return;
 	}
 	F32 current_weight = mWearable->getVisualParamWeight( param->getID() );
-	childSetValue("param slider", weightToPercent( current_weight ) );
+	getChild<LLUICtrl>("param slider")->setValue(weightToPercent( current_weight ) );
 	mHintMin->requestUpdate( sUpdateDelayFrames++ );
 	mHintMax->requestUpdate( sUpdateDelayFrames++ );
 
 	mAllowModify = allow_modify;
-	childSetEnabled("param slider", mAllowModify);
-	childSetEnabled("less", mAllowModify);
-	childSetEnabled("more", mAllowModify);
+	getChildView("param slider")->setEnabled(mAllowModify);
+	getChildView("less")->setEnabled(mAllowModify);
+	getChildView("more")->setEnabled(mAllowModify);
 }
 
 void LLScrollingPanelParam::setVisible( BOOL visible )
@@ -159,16 +159,16 @@ void LLScrollingPanelParam::draw()
 		return;
 	}
 	
-	childSetVisible("less", mHintMin->getVisible());
-	childSetVisible("more", mHintMax->getVisible());
+	getChildView("less")->setVisible( mHintMin->getVisible());
+	getChildView("more")->setVisible( mHintMax->getVisible());
 
 	// hide borders if texture has been loaded
-	childSetVisible("left_border", !mHintMin->getVisible());
-	childSetVisible("right_border", !mHintMax->getVisible());
+	getChildView("left_border")->setVisible( !mHintMin->getVisible());
+	getChildView("right_border")->setVisible( !mHintMax->getVisible());
 
 	// Draw all the children except for the labels
-	childSetVisible( "min param text", FALSE );
-	childSetVisible( "max param text", FALSE );
+	getChildView("min param text")->setVisible( FALSE );
+	getChildView("max param text")->setVisible( FALSE );
 	LLPanel::draw();
 
 	// Draw the hints over the "less" and "more" buttons.
@@ -190,10 +190,10 @@ void LLScrollingPanelParam::draw()
 
 
 	// Draw labels on top of the buttons
-	childSetVisible( "min param text", TRUE );
+	getChildView("min param text")->setVisible( TRUE );
 	drawChild(getChild<LLView>("min param text"));
 
-	childSetVisible( "max param text", TRUE );
+	getChildView("max param text")->setVisible( TRUE );
 	drawChild(getChild<LLView>("max param text"));
 }
 
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index 7a7ffb99838..6b5672414e8 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -484,8 +484,8 @@ void LLSidepanelAppearance::inventoryFetched()
 
 void LLSidepanelAppearance::setWearablesLoading(bool val)
 {
-	childSetVisible("wearables_loading_indicator", val);
-	childSetVisible("edit_outfit_btn", !val);
+	getChildView("wearables_loading_indicator")->setVisible( val);
+	getChildView("edit_outfit_btn")->setVisible( !val);
 
 	if (!val)
 	{
diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp
index d9870e81c5e..56bb7167b6f 100644
--- a/indra/newview/llsidepaneliteminfo.cpp
+++ b/indra/newview/llsidepaneliteminfo.cpp
@@ -110,9 +110,9 @@ BOOL LLSidepanelItemInfo::postBuild()
 {
 	LLSidepanelInventorySubpanel::postBuild();
 
-	childSetPrevalidate("LabelItemName",&LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("LabelItemName")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 	getChild<LLUICtrl>("LabelItemName")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitName,this));
-	childSetPrevalidate("LabelItemDesc",&LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("LabelItemDesc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
 	getChild<LLUICtrl>("LabelItemDesc")->setCommitCallback(boost::bind(&LLSidepanelItemInfo:: onCommitDescription, this));
 	// Creator information
 	getChild<LLUICtrl>("BtnCreator")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onClickCreator,this));
@@ -193,7 +193,7 @@ void LLSidepanelItemInfo::refresh()
 
 		for(size_t t=0; t<LL_ARRAY_SIZE(no_item_names); ++t)
 		{
-			childSetEnabled(no_item_names[t],false);
+			getChildView(no_item_names[t])->setEnabled(false);
 		}
 		
 		const std::string hide_names[]={
@@ -205,7 +205,7 @@ void LLSidepanelItemInfo::refresh()
 		};
 		for(size_t t=0; t<LL_ARRAY_SIZE(hide_names); ++t)
 		{
-			childSetVisible(hide_names[t],false);
+			getChildView(hide_names[t])->setVisible(false);
 		}
 	}
 
@@ -217,7 +217,7 @@ void LLSidepanelItemInfo::refresh()
 		};
 		for(size_t t=0; t<LL_ARRAY_SIZE(no_edit_mode_names); ++t)
 		{
-			childSetEnabled(no_edit_mode_names[t],false);
+			getChildView(no_edit_mode_names[t])->setEnabled(false);
 		}
 	}
 
@@ -265,13 +265,13 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 											   GP_OBJECT_MANIPULATE)
 		&& is_obj_modify && is_complete && not_in_trash;
 
-	childSetEnabled("LabelItemNameTitle",TRUE);
-	childSetEnabled("LabelItemName",is_modifiable && !is_calling_card); // for now, don't allow rename of calling cards
-	childSetText("LabelItemName",item->getName());
-	childSetEnabled("LabelItemDescTitle",TRUE);
-	childSetEnabled("LabelItemDesc",is_modifiable);
-	childSetVisible("IconLocked",!is_modifiable);
-	childSetText("LabelItemDesc",item->getDescription());
+	getChildView("LabelItemNameTitle")->setEnabled(TRUE);
+	getChildView("LabelItemName")->setEnabled(is_modifiable && !is_calling_card); // for now, don't allow rename of calling cards
+	getChild<LLUICtrl>("LabelItemName")->setValue(item->getName());
+	getChildView("LabelItemDescTitle")->setEnabled(TRUE);
+	getChildView("LabelItemDesc")->setEnabled(is_modifiable);
+	getChildView("IconLocked")->setVisible(!is_modifiable);
+	getChild<LLUICtrl>("LabelItemDesc")->setValue(item->getDescription());
 
 	//////////////////
 	// CREATOR NAME //
@@ -283,17 +283,17 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	{
 		std::string name;
 		gCacheName->getFullName(item->getCreatorUUID(), name);
-		childSetEnabled("BtnCreator",TRUE);
-		childSetEnabled("LabelCreatorTitle",TRUE);
-		childSetEnabled("LabelCreatorName",TRUE);
-		childSetText("LabelCreatorName",name);
+		getChildView("BtnCreator")->setEnabled(TRUE);
+		getChildView("LabelCreatorTitle")->setEnabled(TRUE);
+		getChildView("LabelCreatorName")->setEnabled(TRUE);
+		getChild<LLUICtrl>("LabelCreatorName")->setValue(name);
 	}
 	else
 	{
-		childSetEnabled("BtnCreator",FALSE);
-		childSetEnabled("LabelCreatorTitle",FALSE);
-		childSetEnabled("LabelCreatorName",FALSE);
-		childSetText("LabelCreatorName",getString("unknown"));
+		getChildView("BtnCreator")->setEnabled(FALSE);
+		getChildView("LabelCreatorTitle")->setEnabled(FALSE);
+		getChildView("LabelCreatorName")->setEnabled(FALSE);
+		getChild<LLUICtrl>("LabelCreatorName")->setValue(getString("unknown"));
 	}
 
 	////////////////
@@ -310,17 +310,17 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 		{
 			gCacheName->getFullName(perm.getOwner(), name);
 		}
-		childSetEnabled("BtnOwner",TRUE);
-		childSetEnabled("LabelOwnerTitle",TRUE);
-		childSetEnabled("LabelOwnerName",TRUE);
-		childSetText("LabelOwnerName",name);
+		getChildView("BtnOwner")->setEnabled(TRUE);
+		getChildView("LabelOwnerTitle")->setEnabled(TRUE);
+		getChildView("LabelOwnerName")->setEnabled(TRUE);
+		getChild<LLUICtrl>("LabelOwnerName")->setValue(name);
 	}
 	else
 	{
-		childSetEnabled("BtnOwner",FALSE);
-		childSetEnabled("LabelOwnerTitle",FALSE);
-		childSetEnabled("LabelOwnerName",FALSE);
-		childSetText("LabelOwnerName",getString("public"));
+		getChildView("BtnOwner")->setEnabled(FALSE);
+		getChildView("LabelOwnerTitle")->setEnabled(FALSE);
+		getChildView("LabelOwnerName")->setEnabled(FALSE);
+		getChild<LLUICtrl>("LabelOwnerName")->setValue(getString("public"));
 	}
 	
 	////////////
@@ -329,11 +329,11 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 
 	if (object)
 	{
-		childSetText("origin",getString("origin_inworld"));
+		getChild<LLUICtrl>("origin")->setValue(getString("origin_inworld"));
 	}
 	else
 	{
-		childSetText("origin",getString("origin_inventory"));
+		getChild<LLUICtrl>("origin")->setValue(getString("origin_inventory"));
 	}
 
 	//////////////////
@@ -343,7 +343,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	time_t time_utc = item->getCreationDate();
 	if (0 == time_utc)
 	{
-		childSetText("LabelAcquiredDate",getString("unknown"));
+		getChild<LLUICtrl>("LabelAcquiredDate")->setValue(getString("unknown"));
 	}
 	else
 	{
@@ -351,7 +351,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 		LLSD substitution;
 		substitution["datetime"] = (S32) time_utc;
 		LLStringUtil::format (timeStr, substitution);
-		childSetText ("LabelAcquiredDate", timeStr);
+		getChild<LLUICtrl>("LabelAcquiredDate")->setValue(timeStr);
 	}
 	
 	//////////////////////////////////////
@@ -394,12 +394,12 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	{
 		for(size_t t=0; t<LL_ARRAY_SIZE(perm_and_sale_items); ++t)
 		{
-			childSetVisible(perm_and_sale_items[t],false);
+			getChildView(perm_and_sale_items[t])->setVisible(false);
 		}
 		
 		for(size_t t=0; t<LL_ARRAY_SIZE(debug_items); ++t)
 		{
-			childSetVisible(debug_items[t],false);
+			getChildView(debug_items[t])->setVisible(false);
 		}
 		return;
 	}
@@ -407,7 +407,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	{
 		for(size_t t=0; t<LL_ARRAY_SIZE(perm_and_sale_items); ++t)
 		{
-			childSetVisible(perm_and_sale_items[t],true);
+			getChildView(perm_and_sale_items[t])->setVisible(true);
 		}
 	}
 
@@ -416,11 +416,11 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	///////////////////////
 	if(can_agent_manipulate)
 	{
-		childSetText("OwnerLabel",getString("you_can"));
+		getChild<LLUICtrl>("OwnerLabel")->setValue(getString("you_can"));
 	}
 	else
 	{
-		childSetText("OwnerLabel",getString("owner_can"));
+		getChild<LLUICtrl>("OwnerLabel")->setValue(getString("owner_can"));
 	}
 
 	U32 base_mask		= perm.getMaskBase();
@@ -429,13 +429,13 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	U32 everyone_mask	= perm.getMaskEveryone();
 	U32 next_owner_mask	= perm.getMaskNextOwner();
 
-	childSetEnabled("OwnerLabel",TRUE);
-	childSetEnabled("CheckOwnerModify",FALSE);
-	childSetValue("CheckOwnerModify",LLSD((BOOL)(owner_mask & PERM_MODIFY)));
-	childSetEnabled("CheckOwnerCopy",FALSE);
-	childSetValue("CheckOwnerCopy",LLSD((BOOL)(owner_mask & PERM_COPY)));
-	childSetEnabled("CheckOwnerTransfer",FALSE);
-	childSetValue("CheckOwnerTransfer",LLSD((BOOL)(owner_mask & PERM_TRANSFER)));
+	getChildView("OwnerLabel")->setEnabled(TRUE);
+	getChildView("CheckOwnerModify")->setEnabled(FALSE);
+	getChild<LLUICtrl>("CheckOwnerModify")->setValue(LLSD((BOOL)(owner_mask & PERM_MODIFY)));
+	getChildView("CheckOwnerCopy")->setEnabled(FALSE);
+	getChild<LLUICtrl>("CheckOwnerCopy")->setValue(LLSD((BOOL)(owner_mask & PERM_COPY)));
+	getChildView("CheckOwnerTransfer")->setEnabled(FALSE);
+	getChild<LLUICtrl>("CheckOwnerTransfer")->setValue(LLSD((BOOL)(owner_mask & PERM_TRANSFER)));
 
 	///////////////////////
 	// DEBUG PERMISSIONS //
@@ -459,39 +459,39 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 
 		perm_string = "B: ";
 		perm_string += mask_to_string(base_mask);
-		childSetText("BaseMaskDebug",perm_string);
-		childSetVisible("BaseMaskDebug",TRUE);
+		getChild<LLUICtrl>("BaseMaskDebug")->setValue(perm_string);
+		getChildView("BaseMaskDebug")->setVisible(TRUE);
 		
 		perm_string = "O: ";
 		perm_string += mask_to_string(owner_mask);
-		childSetText("OwnerMaskDebug",perm_string);
-		childSetVisible("OwnerMaskDebug",TRUE);
+		getChild<LLUICtrl>("OwnerMaskDebug")->setValue(perm_string);
+		getChildView("OwnerMaskDebug")->setVisible(TRUE);
 		
 		perm_string = "G";
 		perm_string += overwrite_group ? "*: " : ": ";
 		perm_string += mask_to_string(group_mask);
-		childSetText("GroupMaskDebug",perm_string);
-		childSetVisible("GroupMaskDebug",TRUE);
+		getChild<LLUICtrl>("GroupMaskDebug")->setValue(perm_string);
+		getChildView("GroupMaskDebug")->setVisible(TRUE);
 		
 		perm_string = "E";
 		perm_string += overwrite_everyone ? "*: " : ": ";
 		perm_string += mask_to_string(everyone_mask);
-		childSetText("EveryoneMaskDebug",perm_string);
-		childSetVisible("EveryoneMaskDebug",TRUE);
+		getChild<LLUICtrl>("EveryoneMaskDebug")->setValue(perm_string);
+		getChildView("EveryoneMaskDebug")->setVisible(TRUE);
 		
 		perm_string = "N";
 		perm_string += slam_perm ? "*: " : ": ";
 		perm_string += mask_to_string(next_owner_mask);
-		childSetText("NextMaskDebug",perm_string);
-		childSetVisible("NextMaskDebug",TRUE);
+		getChild<LLUICtrl>("NextMaskDebug")->setValue(perm_string);
+		getChildView("NextMaskDebug")->setVisible(TRUE);
 	}
 	else
 	{
-		childSetVisible("BaseMaskDebug",FALSE);
-		childSetVisible("OwnerMaskDebug",FALSE);
-		childSetVisible("GroupMaskDebug",FALSE);
-		childSetVisible("EveryoneMaskDebug",FALSE);
-		childSetVisible("NextMaskDebug",FALSE);
+		getChildView("BaseMaskDebug")->setVisible(FALSE);
+		getChildView("OwnerMaskDebug")->setVisible(FALSE);
+		getChildView("GroupMaskDebug")->setVisible(FALSE);
+		getChildView("EveryoneMaskDebug")->setVisible(FALSE);
+		getChildView("NextMaskDebug")->setVisible(FALSE);
 	}
 
 	/////////////
@@ -501,18 +501,18 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	// Check for ability to change values.
 	if (is_link || cannot_restrict_permissions)
 	{
-		childSetEnabled("CheckShareWithGroup",FALSE);
-		childSetEnabled("CheckEveryoneCopy",FALSE);
+		getChildView("CheckShareWithGroup")->setEnabled(FALSE);
+		getChildView("CheckEveryoneCopy")->setEnabled(FALSE);
 	}
 	else if (is_obj_modify && can_agent_manipulate)
 	{
-		childSetEnabled("CheckShareWithGroup",TRUE);
-		childSetEnabled("CheckEveryoneCopy",(owner_mask & PERM_COPY) && (owner_mask & PERM_TRANSFER));
+		getChildView("CheckShareWithGroup")->setEnabled(TRUE);
+		getChildView("CheckEveryoneCopy")->setEnabled((owner_mask & PERM_COPY) && (owner_mask & PERM_TRANSFER));
 	}
 	else
 	{
-		childSetEnabled("CheckShareWithGroup",FALSE);
-		childSetEnabled("CheckEveryoneCopy",FALSE);
+		getChildView("CheckShareWithGroup")->setEnabled(FALSE);
+		getChildView("CheckEveryoneCopy")->setEnabled(FALSE);
 	}
 
 	// Set values.
@@ -522,7 +522,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 
 	if (is_group_copy && is_group_modify && is_group_move)
 	{
-		childSetValue("CheckShareWithGroup",LLSD((BOOL)TRUE));
+		getChild<LLUICtrl>("CheckShareWithGroup")->setValue(LLSD((BOOL)TRUE));
 
 		LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
 		if(ctl)
@@ -532,7 +532,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	}
 	else if (!is_group_copy && !is_group_modify && !is_group_move)
 	{
-		childSetValue("CheckShareWithGroup",LLSD((BOOL)FALSE));
+		getChild<LLUICtrl>("CheckShareWithGroup")->setValue(LLSD((BOOL)FALSE));
 		LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
 		if(ctl)
 		{
@@ -549,7 +549,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 		}
 	}
 	
-	childSetValue("CheckEveryoneCopy",LLSD((BOOL)(everyone_mask & PERM_COPY)));
+	getChild<LLUICtrl>("CheckEveryoneCopy")->setValue(LLSD((BOOL)(everyone_mask & PERM_COPY)));
 
 	///////////////
 	// SALE INFO //
@@ -561,48 +561,48 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
 	if (is_obj_modify && can_agent_sell 
 		&& gAgent.allowOperation(PERM_TRANSFER, perm, GP_OBJECT_MANIPULATE))
 	{
-		childSetEnabled("SaleLabel",is_complete);
-		childSetEnabled("CheckPurchase",is_complete);
+		getChildView("SaleLabel")->setEnabled(is_complete);
+		getChildView("CheckPurchase")->setEnabled(is_complete);
 
-		childSetEnabled("NextOwnerLabel",TRUE);
-		childSetEnabled("CheckNextOwnerModify",(base_mask & PERM_MODIFY) && !cannot_restrict_permissions);
-		childSetEnabled("CheckNextOwnerCopy",(base_mask & PERM_COPY) && !cannot_restrict_permissions);
-		childSetEnabled("CheckNextOwnerTransfer",(next_owner_mask & PERM_COPY) && !cannot_restrict_permissions);
+		getChildView("NextOwnerLabel")->setEnabled(TRUE);
+		getChildView("CheckNextOwnerModify")->setEnabled((base_mask & PERM_MODIFY) && !cannot_restrict_permissions);
+		getChildView("CheckNextOwnerCopy")->setEnabled((base_mask & PERM_COPY) && !cannot_restrict_permissions);
+		getChildView("CheckNextOwnerTransfer")->setEnabled((next_owner_mask & PERM_COPY) && !cannot_restrict_permissions);
 
-		childSetEnabled("TextPrice",is_complete && is_for_sale);
-		childSetEnabled("Edit Cost",is_complete && is_for_sale);
+		getChildView("TextPrice")->setEnabled(is_complete && is_for_sale);
+		getChildView("Edit Cost")->setEnabled(is_complete && is_for_sale);
 	}
 	else
 	{
-		childSetEnabled("SaleLabel",FALSE);
-		childSetEnabled("CheckPurchase",FALSE);
+		getChildView("SaleLabel")->setEnabled(FALSE);
+		getChildView("CheckPurchase")->setEnabled(FALSE);
 
-		childSetEnabled("NextOwnerLabel",FALSE);
-		childSetEnabled("CheckNextOwnerModify",FALSE);
-		childSetEnabled("CheckNextOwnerCopy",FALSE);
-		childSetEnabled("CheckNextOwnerTransfer",FALSE);
+		getChildView("NextOwnerLabel")->setEnabled(FALSE);
+		getChildView("CheckNextOwnerModify")->setEnabled(FALSE);
+		getChildView("CheckNextOwnerCopy")->setEnabled(FALSE);
+		getChildView("CheckNextOwnerTransfer")->setEnabled(FALSE);
 
-		childSetEnabled("TextPrice",FALSE);
-		childSetEnabled("Edit Cost",FALSE);
+		getChildView("TextPrice")->setEnabled(FALSE);
+		getChildView("Edit Cost")->setEnabled(FALSE);
 	}
 
 	// Set values.
-	childSetValue("CheckPurchase", is_for_sale);
-	childSetEnabled("combobox sale copy", is_for_sale);
-	childSetEnabled("Edit Cost", is_for_sale);
-	childSetValue("CheckNextOwnerModify",LLSD(BOOL(next_owner_mask & PERM_MODIFY)));
-	childSetValue("CheckNextOwnerCopy",LLSD(BOOL(next_owner_mask & PERM_COPY)));
-	childSetValue("CheckNextOwnerTransfer",LLSD(BOOL(next_owner_mask & PERM_TRANSFER)));
+	getChild<LLUICtrl>("CheckPurchase")->setValue(is_for_sale);
+	getChildView("combobox sale copy")->setEnabled(is_for_sale);
+	getChildView("Edit Cost")->setEnabled(is_for_sale);
+	getChild<LLUICtrl>("CheckNextOwnerModify")->setValue(LLSD(BOOL(next_owner_mask & PERM_MODIFY)));
+	getChild<LLUICtrl>("CheckNextOwnerCopy")->setValue(LLSD(BOOL(next_owner_mask & PERM_COPY)));
+	getChild<LLUICtrl>("CheckNextOwnerTransfer")->setValue(LLSD(BOOL(next_owner_mask & PERM_TRANSFER)));
 
 	if (is_for_sale)
 	{
 		S32 numerical_price;
 		numerical_price = sale_info.getSalePrice();
-		childSetText("Edit Cost",llformat("%d",numerical_price));
+		getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",numerical_price));
 	}
 	else
 	{
-		childSetText("Edit Cost",llformat("%d",0));
+		getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",0));
 	}
 }
 
@@ -823,10 +823,10 @@ void LLSidepanelItemInfo::updateSaleInfo()
 	LLSaleInfo sale_info(item->getSaleInfo());
 	if(!gAgent.allowOperation(PERM_TRANSFER, item->getPermissions(), GP_OBJECT_SET_SALE))
 	{
-		childSetValue("CheckPurchase",LLSD((BOOL)FALSE));
+		getChild<LLUICtrl>("CheckPurchase")->setValue(LLSD((BOOL)FALSE));
 	}
 
-	if((BOOL)childGetValue("CheckPurchase"))
+	if((BOOL)getChild<LLUICtrl>("CheckPurchase")->getValue())
 	{
 		// turn on sale info
 		LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_COPY;
diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp
index 3ab71eac64f..2755a1c3ae5 100644
--- a/indra/newview/llsidepaneltaskinfo.cpp
+++ b/indra/newview/llsidepaneltaskinfo.cpp
@@ -107,9 +107,9 @@ BOOL LLSidepanelTaskInfo::postBuild()
 	mLabelGroupName = getChild<LLNameBox>("Group Name Proxy");
 
 	childSetCommitCallback("Object Name",						LLSidepanelTaskInfo::onCommitName,this);
-	childSetPrevalidate("Object Name",							LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("Object Name")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
 	childSetCommitCallback("Object Description",				LLSidepanelTaskInfo::onCommitDesc,this);
-	childSetPrevalidate("Object Description",					LLTextValidate::validateASCIIPrintableNoPipe);
+	getChild<LLLineEditor>("Object Description")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
 	getChild<LLUICtrl>("button set group")->setCommitCallback(boost::bind(&LLSidepanelTaskInfo::onClickGroup,this));
 	childSetCommitCallback("checkbox share with group",			&LLSidepanelTaskInfo::onCommitGroupShare,this);
 	childSetAction("button deed",								&LLSidepanelTaskInfo::onClickDeedToGroup,this);
@@ -144,81 +144,81 @@ BOOL LLSidepanelTaskInfo::postBuild()
 
 void LLSidepanelTaskInfo::disableAll()
 {
-	childSetEnabled("perm_modify",						FALSE);
-	childSetText("perm_modify",							LLStringUtil::null);
-
-	childSetEnabled("Creator:",					   		FALSE);
-	childSetText("Creator Name",						LLStringUtil::null);
-	childSetEnabled("Creator Name",						FALSE);
-
-	childSetEnabled("Owner:",							FALSE);
-	childSetText("Owner Name",							LLStringUtil::null);
-	childSetEnabled("Owner Name",						FALSE);
-
-	childSetEnabled("Group:",							FALSE);
-	childSetText("Group Name",							LLStringUtil::null);
-	childSetEnabled("Group Name",						FALSE);
-	childSetEnabled("button set group",					FALSE);
-
-	childSetText("Object Name",							LLStringUtil::null);
-	childSetEnabled("Object Name",						FALSE);
-	childSetEnabled("Name:",						   	FALSE);
-	childSetText("Group Name",							LLStringUtil::null);
-	childSetEnabled("Group Name",						FALSE);
-	childSetEnabled("Description:",						FALSE);
-	childSetText("Object Description",					LLStringUtil::null);
-	childSetEnabled("Object Description",				FALSE);
-
-	childSetEnabled("Permissions:",						FALSE);
+	getChildView("perm_modify")->setEnabled(FALSE);
+	getChild<LLUICtrl>("perm_modify")->setValue(LLStringUtil::null);
+
+	getChildView("Creator:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Creator Name")->setValue(LLStringUtil::null);
+	getChildView("Creator Name")->setEnabled(FALSE);
+
+	getChildView("Owner:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Owner Name")->setValue(LLStringUtil::null);
+	getChildView("Owner Name")->setEnabled(FALSE);
+
+	getChildView("Group:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
+	getChildView("Group Name")->setEnabled(FALSE);
+	getChildView("button set group")->setEnabled(FALSE);
+
+	getChild<LLUICtrl>("Object Name")->setValue(LLStringUtil::null);
+	getChildView("Object Name")->setEnabled(FALSE);
+	getChildView("Name:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
+	getChildView("Group Name")->setEnabled(FALSE);
+	getChildView("Description:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Object Description")->setValue(LLStringUtil::null);
+	getChildView("Object Description")->setEnabled(FALSE);
+
+	getChildView("Permissions:")->setEnabled(FALSE);
 		
-	childSetValue("checkbox share with group",			FALSE);
-	childSetEnabled("checkbox share with group",	   	FALSE);
-	childSetEnabled("button deed",						FALSE);
+	getChild<LLUICtrl>("checkbox share with group")->setValue(FALSE);
+	getChildView("checkbox share with group")->setEnabled(FALSE);
+	getChildView("button deed")->setEnabled(FALSE);
 
-	childSetValue("checkbox allow everyone move",	   	FALSE);
-	childSetEnabled("checkbox allow everyone move",	   	FALSE);
-	childSetValue("checkbox allow everyone copy",	   	FALSE);
-	childSetEnabled("checkbox allow everyone copy",	   	FALSE);
+	getChild<LLUICtrl>("checkbox allow everyone move")->setValue(FALSE);
+	getChildView("checkbox allow everyone move")->setEnabled(FALSE);
+	getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(FALSE);
+	getChildView("checkbox allow everyone copy")->setEnabled(FALSE);
 
 	//Next owner can:
-	childSetEnabled("Next owner can:",					FALSE);
-	childSetValue("checkbox next owner can modify",		FALSE);
-	childSetEnabled("checkbox next owner can modify",  	FALSE);
-	childSetValue("checkbox next owner can copy",	   	FALSE);
-	childSetEnabled("checkbox next owner can copy",	   	FALSE);
-	childSetValue("checkbox next owner can transfer",  	FALSE);
-	childSetEnabled("checkbox next owner can transfer",	FALSE);
+	getChildView("Next owner can:")->setEnabled(FALSE);
+	getChild<LLUICtrl>("checkbox next owner can modify")->setValue(FALSE);
+	getChildView("checkbox next owner can modify")->setEnabled(FALSE);
+	getChild<LLUICtrl>("checkbox next owner can copy")->setValue(FALSE);
+	getChildView("checkbox next owner can copy")->setEnabled(FALSE);
+	getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(FALSE);
+	getChildView("checkbox next owner can transfer")->setEnabled(FALSE);
 
 	//checkbox for sale
-	childSetValue("checkbox for sale",					FALSE);
-	childSetEnabled("checkbox for sale",			   	FALSE);
+	getChild<LLUICtrl>("checkbox for sale")->setValue(FALSE);
+	getChildView("checkbox for sale")->setEnabled(FALSE);
 
 	//checkbox include in search
-	childSetValue("search_check",			 			FALSE);
-	childSetEnabled("search_check",			 			FALSE);
+	getChild<LLUICtrl>("search_check")->setValue(FALSE);
+	getChildView("search_check")->setEnabled(FALSE);
 		
 	LLComboBox*	combo_sale_type = getChild<LLComboBox>("sale type");
 	combo_sale_type->setValue(LLSaleInfo::FS_COPY);
 	combo_sale_type->setEnabled(FALSE);
 		
-	childSetEnabled("Cost",								FALSE);
-	childSetText("Cost",							   	getString("Cost Default"));
-	childSetText("Edit Cost",							LLStringUtil::null);
-	childSetEnabled("Edit Cost",					   	FALSE);
+	getChildView("Cost")->setEnabled(FALSE);
+	getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
+	getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
+	getChildView("Edit Cost")->setEnabled(FALSE);
 		
-	childSetEnabled("label click action",				FALSE);
+	getChildView("label click action")->setEnabled(FALSE);
 	LLComboBox*	combo_click_action = getChild<LLComboBox>("clickaction");
 	if (combo_click_action)
 	{
 		combo_click_action->setEnabled(FALSE);
 		combo_click_action->clear();
 	}
-	childSetVisible("B:",								FALSE);
-	childSetVisible("O:",								FALSE);
-	childSetVisible("G:",								FALSE);
-	childSetVisible("E:",								FALSE);
-	childSetVisible("N:",								FALSE);
-	childSetVisible("F:",								FALSE);
+	getChildView("B:")->setVisible(								FALSE);
+	getChildView("O:")->setVisible(								FALSE);
+	getChildView("G:")->setVisible(								FALSE);
+	getChildView("E:")->setVisible(								FALSE);
+	getChildView("N:")->setVisible(								FALSE);
+	getChildView("F:")->setVisible(								FALSE);
 	
 	mOpenBtn->setEnabled(FALSE);
 	mPayBtn->setEnabled(FALSE);
@@ -289,23 +289,23 @@ void LLSidepanelTaskInfo::refresh()
 	{
 		++string_index;
 	}
-	childSetEnabled("perm_modify", 			   			TRUE);
-	childSetText("perm_modify",							MODIFY_INFO_STRINGS[string_index]);
+	getChildView("perm_modify")->setEnabled(TRUE);
+	getChild<LLUICtrl>("perm_modify")->setValue(MODIFY_INFO_STRINGS[string_index]);
 
-	childSetEnabled("Permissions:", 					TRUE);
+	getChildView("Permissions:")->setEnabled(TRUE);
 	
 	// Update creator text field
-	childSetEnabled("Creator:", 						TRUE);
+	getChildView("Creator:")->setEnabled(TRUE);
 	BOOL creators_identical;
 	std::string creator_name;
 	creators_identical = LLSelectMgr::getInstance()->selectGetCreator(mCreatorID,
 																	  creator_name);
 
-	childSetText("Creator Name",						creator_name);
-	childSetEnabled("Creator Name", 					TRUE);
+	getChild<LLUICtrl>("Creator Name")->setValue(creator_name);
+	getChildView("Creator Name")->setEnabled(TRUE);
 
 	// Update owner text field
-	childSetEnabled("Owner:", 							TRUE);
+	getChildView("Owner:")->setEnabled(TRUE);
 
 	std::string owner_name;
 	const BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(mOwnerID, owner_name);
@@ -330,12 +330,12 @@ void LLSidepanelTaskInfo::refresh()
 			}
 		}
 	}
-	childSetText("Owner Name",						owner_name);
-	childSetEnabled("Owner Name", 					TRUE);
+	getChild<LLUICtrl>("Owner Name")->setValue(owner_name);
+	getChildView("Owner Name")->setEnabled(TRUE);
 
 	// update group text field
-	childSetEnabled("Group:", 						TRUE);
-	childSetText("Group Name", 						LLStringUtil::null);
+	getChildView("Group:")->setEnabled(TRUE);
+	getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
 	LLUUID group_id;
 	BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
 	if (groups_identical)
@@ -356,18 +356,18 @@ void LLSidepanelTaskInfo::refresh()
 		}
 	}
 	
-	childSetEnabled("button set group", owners_identical && (mOwnerID == gAgent.getID()));
+	getChildView("button set group")->setEnabled(owners_identical && (mOwnerID == gAgent.getID()));
 
-	childSetEnabled("Name:", 						TRUE);
+	getChildView("Name:")->setEnabled(TRUE);
 	LLLineEditor* LineEditorObjectName = getChild<LLLineEditor>("Object Name");
-	childSetEnabled("Description:", 				TRUE);
+	getChildView("Description:")->setEnabled(TRUE);
 	LLLineEditor* LineEditorObjectDesc = getChild<LLLineEditor>("Object Description");
 
 	if (is_one_object)
 	{
 		if (!LineEditorObjectName->hasFocus())
 		{
-			childSetText("Object Name",nodep->mName);
+			getChild<LLUICtrl>("Object Name")->setValue(nodep->mName);
 		}
 
 		if (LineEditorObjectDesc)
@@ -380,7 +380,7 @@ void LLSidepanelTaskInfo::refresh()
 	}
 	else
 	{
-		childSetText("Object Name",					LLStringUtil::null);
+		getChild<LLUICtrl>("Object Name")->setValue(LLStringUtil::null);
 		LineEditorObjectDesc->setText(LLStringUtil::null);
 	}
 
@@ -392,13 +392,13 @@ void LLSidepanelTaskInfo::refresh()
 	}
 	if (edit_name_desc)
 	{
-		childSetEnabled("Object Name", 				TRUE);
-		childSetEnabled("Object Description", 		TRUE);
+		getChildView("Object Name")->setEnabled(TRUE);
+		getChildView("Object Description")->setEnabled(TRUE);
 	}
 	else
 	{
-		childSetEnabled("Object Name", 				FALSE);
-		childSetEnabled("Object Description", 		FALSE);
+		getChildView("Object Name")->setEnabled(FALSE);
+		getChildView("Object Description")->setEnabled(FALSE);
 	}
 
 	S32 total_sale_price = 0;
@@ -420,9 +420,9 @@ void LLSidepanelTaskInfo::refresh()
 
 	if (!owners_identical)
 	{
-		childSetEnabled("Cost", 					FALSE);
-		childSetText("Edit Cost",					LLStringUtil::null);
-		childSetEnabled("Edit Cost", 				FALSE);
+		getChildView("Cost")->setEnabled(FALSE);
+		getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
+		getChildView("Edit Cost")->setEnabled(FALSE);
 	}
 	// You own these objects.
 	else if (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id,GP_OBJECT_SET_SALE)))
@@ -430,11 +430,11 @@ void LLSidepanelTaskInfo::refresh()
 		// If there are multiple items for sale then set text to PRICE PER UNIT.
 		if (num_for_sale > 1)
 		{
-			childSetText("Cost",					getString("Cost Per Unit"));
+			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Per Unit"));
 		}
 		else
 		{
-			childSetText("Cost",					getString("Cost Default"));
+			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 		}
 		
 		LLSpinCtrl *edit_price = getChild<LLSpinCtrl>("Edit Cost");
@@ -458,35 +458,35 @@ void LLSidepanelTaskInfo::refresh()
 		// The edit fields are only enabled if you can sell this object
 		// and the sale price is not mixed.
 		BOOL enable_edit = (num_for_sale && can_transfer) ? !is_for_sale_mixed : FALSE;
-		childSetEnabled("Cost",					enable_edit);
-		childSetEnabled("Edit Cost",			enable_edit);
+		getChildView("Cost")->setEnabled(enable_edit);
+		getChildView("Edit Cost")->setEnabled(enable_edit);
 	}
 	// Someone, not you, owns these objects.
 	else if (!public_owned)
 	{
-		childSetEnabled("Cost",					FALSE);
-		childSetEnabled("Edit Cost",			FALSE);
+		getChildView("Cost")->setEnabled(FALSE);
+		getChildView("Edit Cost")->setEnabled(FALSE);
 		
 		// Don't show a price if none of the items are for sale.
 		if (num_for_sale)
-			childSetText("Edit Cost",			llformat("%d",total_sale_price));
+			getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",total_sale_price));
 		else
-			childSetText("Edit Cost",			LLStringUtil::null);
+			getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
 
 		// If multiple items are for sale, set text to TOTAL PRICE.
 		if (num_for_sale > 1)
-			childSetText("Cost",				getString("Cost Total"));
+			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Total"));
 		else
-			childSetText("Cost",				getString("Cost Default"));
+			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 	}
 	// This is a public object.
 	else
 	{
-		childSetEnabled("Cost",					FALSE);
-		childSetText("Cost",					getString("Cost Default"));
+		getChildView("Cost")->setEnabled(FALSE);
+		getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 		
-		childSetText("Edit Cost",				LLStringUtil::null);
-		childSetEnabled("Edit Cost",			FALSE);
+		getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
+		getChildView("Edit Cost")->setEnabled(FALSE);
 	}
 
 	// Enable and disable the permissions checkboxes
@@ -528,20 +528,20 @@ void LLSidepanelTaskInfo::refresh()
 	{
 		if (valid_base_perms)
 		{
-			childSetText("B:",								"B: " + mask_to_string(base_mask_on));
-			childSetVisible("B:",							TRUE);
+			getChild<LLUICtrl>("B:")->setValue("B: " + mask_to_string(base_mask_on));
+			getChildView("B:")->setVisible(							TRUE);
 			
-			childSetText("O:",								"O: " + mask_to_string(owner_mask_on));
-			childSetVisible("O:",							TRUE);
+			getChild<LLUICtrl>("O:")->setValue("O: " + mask_to_string(owner_mask_on));
+			getChildView("O:")->setVisible(							TRUE);
 			
-			childSetText("G:",								"G: " + mask_to_string(group_mask_on));
-			childSetVisible("G:",							TRUE);
+			getChild<LLUICtrl>("G:")->setValue("G: " + mask_to_string(group_mask_on));
+			getChildView("G:")->setVisible(							TRUE);
 			
-			childSetText("E:",								"E: " + mask_to_string(everyone_mask_on));
-			childSetVisible("E:",							TRUE);
+			getChild<LLUICtrl>("E:")->setValue("E: " + mask_to_string(everyone_mask_on));
+			getChildView("E:")->setVisible(							TRUE);
 			
-			childSetText("N:",								"N: " + mask_to_string(next_owner_mask_on));
-			childSetVisible("N:",							TRUE);
+			getChild<LLUICtrl>("N:")->setValue("N: " + mask_to_string(next_owner_mask_on));
+			getChildView("N:")->setVisible(							TRUE);
 		}
 
 		U32 flag_mask = 0x0;
@@ -550,17 +550,17 @@ void LLSidepanelTaskInfo::refresh()
 		if (objectp->permCopy()) 		flag_mask |= PERM_COPY;
 		if (objectp->permTransfer()) 	flag_mask |= PERM_TRANSFER;
 
-		childSetText("F:",									"F:" + mask_to_string(flag_mask));
-		childSetVisible("F:",								TRUE);
+		getChild<LLUICtrl>("F:")->setValue("F:" + mask_to_string(flag_mask));
+		getChildView("F:")->setVisible(								TRUE);
 	}
 	else
 	{
-		childSetVisible("B:",								FALSE);
-		childSetVisible("O:",								FALSE);
-		childSetVisible("G:",								FALSE);
-		childSetVisible("E:",								FALSE);
-		childSetVisible("N:",								FALSE);
-		childSetVisible("F:",								FALSE);
+		getChildView("B:")->setVisible(								FALSE);
+		getChildView("O:")->setVisible(								FALSE);
+		getChildView("G:")->setVisible(								FALSE);
+		getChildView("E:")->setVisible(								FALSE);
+		getChildView("N:")->setVisible(								FALSE);
+		getChildView("F:")->setVisible(								FALSE);
 	}
 
 	BOOL has_change_perm_ability = FALSE;
@@ -580,65 +580,65 @@ void LLSidepanelTaskInfo::refresh()
 	if (!has_change_perm_ability && !has_change_sale_ability && !root_selected)
 	{
 		// ...must select root to choose permissions
-		childSetValue("perm_modify", 						getString("text modify warning"));
+		getChild<LLUICtrl>("perm_modify")->setValue(getString("text modify warning"));
 	}
 
 	if (has_change_perm_ability)
 	{
-		childSetEnabled("checkbox share with group",		TRUE);
-		childSetEnabled("checkbox allow everyone move",		owner_mask_on & PERM_MOVE);
-		childSetEnabled("checkbox allow everyone copy",		owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
+		getChildView("checkbox share with group")->setEnabled(TRUE);
+		getChildView("checkbox allow everyone move")->setEnabled(owner_mask_on & PERM_MOVE);
+		getChildView("checkbox allow everyone copy")->setEnabled(owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
 	}
 	else
 	{
-		childSetEnabled("checkbox share with group", 		FALSE);
-		childSetEnabled("checkbox allow everyone move", 	FALSE);
-		childSetEnabled("checkbox allow everyone copy", 	FALSE);
+		getChildView("checkbox share with group")->setEnabled(FALSE);
+		getChildView("checkbox allow everyone move")->setEnabled(FALSE);
+		getChildView("checkbox allow everyone copy")->setEnabled(FALSE);
 	}
 
 	if (has_change_sale_ability && (owner_mask_on & PERM_TRANSFER))
 	{
-		childSetEnabled("checkbox for sale", 				can_transfer || (!can_transfer && num_for_sale));
+		getChildView("checkbox for sale")->setEnabled(can_transfer || (!can_transfer && num_for_sale));
 		// Set the checkbox to tentative if the prices of each object selected
 		// are not the same.
-		childSetTentative("checkbox for sale", 				is_for_sale_mixed);
-		childSetEnabled("sale type", 						num_for_sale && can_transfer && !is_sale_price_mixed);
+		getChild<LLUICtrl>("checkbox for sale")->setTentative( 				is_for_sale_mixed);
+		getChildView("sale type")->setEnabled(num_for_sale && can_transfer && !is_sale_price_mixed);
 
-		childSetEnabled("Next owner can:", 					TRUE);
-		childSetEnabled("checkbox next owner can modify", 	base_mask_on & PERM_MODIFY);
-		childSetEnabled("checkbox next owner can copy", 	base_mask_on & PERM_COPY);
-		childSetEnabled("checkbox next owner can transfer", next_owner_mask_on & PERM_COPY);
+		getChildView("Next owner can:")->setEnabled(TRUE);
+		getChildView("checkbox next owner can modify")->setEnabled(base_mask_on & PERM_MODIFY);
+		getChildView("checkbox next owner can copy")->setEnabled(base_mask_on & PERM_COPY);
+		getChildView("checkbox next owner can transfer")->setEnabled(next_owner_mask_on & PERM_COPY);
 	}
 	else 
 	{
-		childSetEnabled("checkbox for sale",				FALSE);
-		childSetEnabled("sale type",						FALSE);
+		getChildView("checkbox for sale")->setEnabled(FALSE);
+		getChildView("sale type")->setEnabled(FALSE);
 
-		childSetEnabled("Next owner can:",					FALSE);
-		childSetEnabled("checkbox next owner can modify",	FALSE);
-		childSetEnabled("checkbox next owner can copy",		FALSE);
-		childSetEnabled("checkbox next owner can transfer",	FALSE);
+		getChildView("Next owner can:")->setEnabled(FALSE);
+		getChildView("checkbox next owner can modify")->setEnabled(FALSE);
+		getChildView("checkbox next owner can copy")->setEnabled(FALSE);
+		getChildView("checkbox next owner can transfer")->setEnabled(FALSE);
 	}
 
 	if (valid_group_perms)
 	{
 		if ((group_mask_on & PERM_COPY) && (group_mask_on & PERM_MODIFY) && (group_mask_on & PERM_MOVE))
 		{
-			childSetValue("checkbox share with group",		TRUE);
-			childSetTentative("checkbox share with group",	FALSE);
-			childSetEnabled("button deed",					gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
+			getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox share with group")->setTentative(	FALSE);
+			getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
 		}
 		else if ((group_mask_off & PERM_COPY) && (group_mask_off & PERM_MODIFY) && (group_mask_off & PERM_MOVE))
 		{
-			childSetValue("checkbox share with group",		FALSE);
-			childSetTentative("checkbox share with group",	FALSE);
-			childSetEnabled("button deed",					FALSE);
+			getChild<LLUICtrl>("checkbox share with group")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox share with group")->setTentative(	FALSE);
+			getChildView("button deed")->setEnabled(FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox share with group",		TRUE);
-			childSetTentative("checkbox share with group",	TRUE);
-			childSetEnabled("button deed",					gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
+			getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox share with group")->setTentative(	TRUE);
+			getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
 		}
 	}			
 
@@ -647,35 +647,35 @@ void LLSidepanelTaskInfo::refresh()
 		// Move
 		if (everyone_mask_on & PERM_MOVE)
 		{
-			childSetValue("checkbox allow everyone move",		TRUE);
-			childSetTentative("checkbox allow everyone move", 	FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	FALSE);
 		}
 		else if (everyone_mask_off & PERM_MOVE)
 		{
-			childSetValue("checkbox allow everyone move",		FALSE);
-			childSetTentative("checkbox allow everyone move", 	FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox allow everyone move",		TRUE);
-			childSetTentative("checkbox allow everyone move", 	TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	TRUE);
 		}
 
 		// Copy == everyone can't copy
 		if (everyone_mask_on & PERM_COPY)
 		{
-			childSetValue("checkbox allow everyone copy",		TRUE);
-			childSetTentative("checkbox allow everyone copy", 	!can_copy || !can_transfer);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( 	!can_copy || !can_transfer);
 		}
 		else if (everyone_mask_off & PERM_COPY)
 		{
-			childSetValue("checkbox allow everyone copy",		FALSE);
-			childSetTentative("checkbox allow everyone copy",	FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative(	FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox allow everyone copy",		TRUE);
-			childSetTentative("checkbox allow everyone copy",	TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative(	TRUE);
 		}
 	}
 
@@ -684,52 +684,52 @@ void LLSidepanelTaskInfo::refresh()
 		// Modify == next owner canot modify
 		if (next_owner_mask_on & PERM_MODIFY)
 		{
-			childSetValue("checkbox next owner can modify",		TRUE);
-			childSetTentative("checkbox next owner can modify",	FALSE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	FALSE);
 		}
 		else if (next_owner_mask_off & PERM_MODIFY)
 		{
-			childSetValue("checkbox next owner can modify",		FALSE);
-			childSetTentative("checkbox next owner can modify",	FALSE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox next owner can modify",		TRUE);
-			childSetTentative("checkbox next owner can modify",	TRUE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	TRUE);
 		}
 
 		// Copy == next owner cannot copy
 		if (next_owner_mask_on & PERM_COPY)
 		{			
-			childSetValue("checkbox next owner can copy",		TRUE);
-			childSetTentative("checkbox next owner can copy",	!can_copy);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	!can_copy);
 		}
 		else if (next_owner_mask_off & PERM_COPY)
 		{
-			childSetValue("checkbox next owner can copy",		FALSE);
-			childSetTentative("checkbox next owner can copy",	FALSE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox next owner can copy",		TRUE);
-			childSetTentative("checkbox next owner can copy",	TRUE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	TRUE);
 		}
 
 		// Transfer == next owner cannot transfer
 		if (next_owner_mask_on & PERM_TRANSFER)
 		{
-			childSetValue("checkbox next owner can transfer",	TRUE);
-			childSetTentative("checkbox next owner can transfer", !can_transfer);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( !can_transfer);
 		}
 		else if (next_owner_mask_off & PERM_TRANSFER)
 		{
-			childSetValue("checkbox next owner can transfer",	FALSE);
-			childSetTentative("checkbox next owner can transfer", FALSE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(FALSE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( FALSE);
 		}
 		else
 		{
-			childSetValue("checkbox next owner can transfer",	TRUE);
-			childSetTentative("checkbox next owner can transfer", TRUE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
+			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( TRUE);
 		}
 	}
 
@@ -751,7 +751,7 @@ void LLSidepanelTaskInfo::refresh()
 		combo_sale_type->setTentative(				TRUE); // unfortunately this doesn't do anything at the moment.
 	}
 
-	childSetValue("checkbox for sale", (num_for_sale != 0));
+	getChild<LLUICtrl>("checkbox for sale")->setValue((num_for_sale != 0));
 
 	// HACK: There are some old objects in world that are set for sale,
 	// but are no-transfer.  We need to let users turn for-sale off, but only
@@ -761,7 +761,7 @@ void LLSidepanelTaskInfo::refresh()
 	{
 		if (num_for_sale && has_change_sale_ability)
 		{
-			childSetEnabled("checkbox for sale", true);
+			getChildView("checkbox for sale")->setEnabled(true);
 		}
 	}
 	
@@ -769,9 +769,9 @@ void LLSidepanelTaskInfo::refresh()
 	const BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
 	bool include_in_search;
 	const BOOL all_include_in_search = LLSelectMgr::getInstance()->selectionGetIncludeInSearch(&include_in_search);
-	childSetEnabled("search_check", 				has_change_sale_ability && all_volume);
-	childSetValue("search_check", 					include_in_search);
-	childSetTentative("search_check", 				!all_include_in_search);
+	getChildView("search_check")->setEnabled(has_change_sale_ability && all_volume);
+	getChild<LLUICtrl>("search_check")->setValue(include_in_search);
+	getChild<LLUICtrl>("search_check")->setTentative( 				!all_include_in_search);
 
 	// Click action (touch, sit, buy)
 	U8 click_action = 0;
@@ -783,8 +783,8 @@ void LLSidepanelTaskInfo::refresh()
 			ComboClickAction->setCurrentByIndex((S32)click_action);
 		}
 	}
-	childSetEnabled("label click action",			is_perm_modify && all_volume);
-	childSetEnabled("clickaction",					is_perm_modify && all_volume);
+	getChildView("label click action")->setEnabled(is_perm_modify && all_volume);
+	getChildView("clickaction")->setEnabled(is_perm_modify && all_volume);
 
 	if (!getIsEditing())
 	{
@@ -810,7 +810,7 @@ void LLSidepanelTaskInfo::refresh()
 			};
 		for (size_t t=0; t<LL_ARRAY_SIZE(no_item_names); ++t)
 		{
-			childSetEnabled(no_item_names[t],		FALSE);
+			getChildView(no_item_names[t])->setEnabled(	FALSE);
 		}
 	}
 	updateVerbs();
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index c02559b2093..fc5937ea7de 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -235,7 +235,7 @@ BOOL LLStatusBar::postBuild()
 	mSGPacketLoss->mPerSec = FALSE;
 	addChild(mSGPacketLoss);
 
-	childSetActionTextbox("stat_btn", onClickStatGraph);
+	getChild<LLTextBox>("stat_btn")->setClickedCallback(onClickStatGraph);
 
 	mPanelVolumePulldown = new LLPanelVolumePulldown();
 	addChild(mPanelVolumePulldown);
@@ -300,15 +300,16 @@ void LLStatusBar::refresh()
 
 	if (LLHUDIcon::iconsNearby())
 	{
-		childGetRect( "scriptout", buttonRect );
+		LLView* script_out = getChildView("scriptout");
+		buttonRect = script_out->getRect();
 		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
-		childSetRect("scriptout",r);
-		childSetVisible("scriptout", true);
+		script_out->setShape(r);
+		script_out->setVisible( true);
 		x += buttonRect.getWidth();
 	}
 	else
 	{
-		childSetVisible("scriptout", false);
+		getChildView("scriptout")->setVisible( false);
 	}
 
 	if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK &&
@@ -317,24 +318,25 @@ void LLStatusBar::refresh()
 		// set visibility based on flashing
 		if( mHealthTimer->hasExpired() )
 		{
-			childSetVisible("health", true);
+			getChildView("health")->setVisible( true);
 		}
 		else
 		{
 			BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1;
-			childSetVisible("health", flash);
+			getChildView("health")->setVisible( flash);
 		}
 
 		// Health
-		childGetRect( "health", buttonRect );
+		LLView* healthp = getChildView("health");
+		buttonRect = healthp->getRect();
 		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
-		childSetRect("health", r);
+		healthp->setShape(r);
 		x += buttonRect.getWidth();
 	}
 
 	mSGBandwidth->setVisible(net_stats_visible);
 	mSGPacketLoss->setVisible(net_stats_visible);
-	childSetEnabled("stat_btn", net_stats_visible);
+	getChildView("stat_btn")->setEnabled(net_stats_visible);
 
 	// update the master volume button state
 	bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 0b02861b758..476b210ae69 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -226,7 +226,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id)
 			if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID()))
 			{
 				// no copy texture
-				childSetValue("apply_immediate_check", FALSE);
+				getChild<LLUICtrl>("apply_immediate_check")->setValue(FALSE);
 				mNoCopyTextureSelected = TRUE;
 			}
 			mInventoryPanel->setSelection(item_id, TAKE_FOCUS_NO);
@@ -236,7 +236,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id)
 
 void LLFloaterTexturePicker::setActive( BOOL active )					
 {
-	if (!active && childGetValue("Pipette").asBoolean())
+	if (!active && getChild<LLUICtrl>("Pipette")->getValue().asBoolean())
 	{
 		stopUsingPipette();
 	}
@@ -248,7 +248,7 @@ void LLFloaterTexturePicker::setCanApplyImmediately(BOOL b)
 	mCanApplyImmediately = b;
 	if (!mCanApplyImmediately)
 	{
-		childSetValue("apply_immediate_check", FALSE);
+		getChild<LLUICtrl>("apply_immediate_check")->setValue(FALSE);
 	}
 	updateFilterPermMask();
 }
@@ -403,7 +403,7 @@ BOOL LLFloaterTexturePicker::postBuild()
 
 
 	childSetCommitCallback("show_folders_check", onShowFolders, this);
-	childSetVisible("show_folders_check", FALSE);
+	getChildView("show_folders_check")->setVisible( FALSE);
 
 	mFilterEdit = getChild<LLFilterEditor>("inventory search editor");
 	mFilterEdit->setCommitCallback(boost::bind(&LLFloaterTexturePicker::onFilterEdit, this, _2));
@@ -442,12 +442,12 @@ BOOL LLFloaterTexturePicker::postBuild()
 
 	mNoCopyTextureSelected = FALSE;
 
-	childSetValue("apply_immediate_check", gSavedSettings.getBOOL("ApplyTextureImmediately"));
+	getChild<LLUICtrl>("apply_immediate_check")->setValue(gSavedSettings.getBOOL("ApplyTextureImmediately"));
 	childSetCommitCallback("apply_immediate_check", onApplyImmediateCheck, this);
 
 	if (!mCanApplyImmediately)
 	{
-		childSetEnabled("show_folders_check", FALSE);
+		getChildView("show_folders_check")->setEnabled(FALSE);
 	}
 
 	getChild<LLUICtrl>("Pipette")->setCommitCallback( boost::bind(&LLFloaterTexturePicker::onBtnPipette, this));
@@ -524,10 +524,10 @@ void LLFloaterTexturePicker::draw()
 	updateImageStats();
 
 	// if we're inactive, gray out "apply immediate" checkbox
-	childSetEnabled("show_folders_check", mActive && mCanApplyImmediately && !mNoCopyTextureSelected);
-	childSetEnabled("Select", mActive);
-	childSetEnabled("Pipette", mActive);
-	childSetValue("Pipette", LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
+	getChildView("show_folders_check")->setEnabled(mActive && mCanApplyImmediately && !mNoCopyTextureSelected);
+	getChildView("Select")->setEnabled(mActive);
+	getChildView("Pipette")->setEnabled(mActive);
+	getChild<LLUICtrl>("Pipette")->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
 
 	//BOOL allow_copy = FALSE;
 	if( mOwner ) 
@@ -544,9 +544,9 @@ void LLFloaterTexturePicker::draw()
 			mTentativeLabel->setVisible( FALSE  );
 		}
 
-		childSetEnabled("Default",  mImageAssetID != mOwner->getDefaultImageAssetID());
-		childSetEnabled("Blank",   mImageAssetID != mWhiteImageAssetID );
-		childSetEnabled("None", mOwner->getAllowNoTexture() && !mImageAssetID.isNull() );
+		getChildView("Default")->setEnabled(mImageAssetID != mOwner->getDefaultImageAssetID());
+		getChildView("Blank")->setEnabled(mImageAssetID != mWhiteImageAssetID );
+		getChildView("None")->setEnabled(mOwner->getAllowNoTexture() && !mImageAssetID.isNull() );
 
 		LLFloater::draw();
 
@@ -651,13 +651,13 @@ const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, BOOL co
 
 PermissionMask LLFloaterTexturePicker::getFilterPermMask()
 {
-	bool apply_immediate = childGetValue("apply_immediate_check").asBoolean();
+	bool apply_immediate = getChild<LLUICtrl>("apply_immediate_check")->getValue().asBoolean();
 	return apply_immediate ? mImmediateFilterPermMask : mNonImmediateFilterPermMask;
 }
 
 void LLFloaterTexturePicker::commitIfImmediateSet()
 {
-	bool apply_immediate = childGetValue("apply_immediate_check").asBoolean();
+	bool apply_immediate = getChild<LLUICtrl>("apply_immediate_check")->getValue().asBoolean();
 	if (!mNoCopyTextureSelected && apply_immediate && mOwner)
 	{
 		mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CHANGE);
@@ -730,7 +730,7 @@ void LLFloaterTexturePicker::onBtnSelect(void* userdata)
 
 void LLFloaterTexturePicker::onBtnPipette()
 {
-	BOOL pipette_active = childGetValue("Pipette").asBoolean();
+	BOOL pipette_active = getChild<LLUICtrl>("Pipette")->getValue().asBoolean();
 	pipette_active = !pipette_active;
 	if (pipette_active)
 	{
diff --git a/indra/newview/lltoastgroupnotifypanel.cpp b/indra/newview/lltoastgroupnotifypanel.cpp
index 7eac3867d5d..57b80fc7922 100644
--- a/indra/newview/lltoastgroupnotifypanel.cpp
+++ b/indra/newview/lltoastgroupnotifypanel.cpp
@@ -130,7 +130,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification
 		pAttachLink->setValue(payload["inventory_name"]);
 
 		mInventoryOffer = new LLOfferInfo(payload["inventory_offer"]);
-		childSetActionTextbox("attachment", boost::bind(
+		getChild<LLTextBox>("attachment")->setClickedCallback(boost::bind(
 				&LLToastGroupNotifyPanel::onClickAttachment, this));
 
 		LLUIImagePtr attachIconImg = LLInventoryIcon::getIcon(mInventoryOffer->mType,
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index 95c4f01e469..f9e7191b213 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -1561,7 +1561,7 @@ BOOL LLToolPie::pickRightMouseDownCallback()
 				mute_msg = LLTrans::getString("MuteObject2");
 			}
 			
-			gMenuHolder->childSetText("Object Mute", mute_msg);
+			gMenuHolder->getChild<LLUICtrl>("Object Mute")->setValue(mute_msg);
 			gMenuObject->show(x, y);
 
 			showVisualContextMenuEffect();
diff --git a/indra/newview/llviewchildren.cpp b/indra/newview/llviewchildren.cpp
index 41eafa871d0..b86e0ac4413 100644
--- a/indra/newview/llviewchildren.cpp
+++ b/indra/newview/llviewchildren.cpp
@@ -55,12 +55,12 @@ LLViewChildren::LLViewChildren(LLPanel& parent)
 
 void LLViewChildren::show(const std::string& id, bool visible)
 {
-	mParent.childSetVisible(id, visible);
+	mParent.getChildView(id)->setVisible(visible);
 }
 
 void LLViewChildren::enable(const std::string& id, bool enabled)
 {
-	mParent.childSetEnabled(id, enabled);
+	mParent.getChildView(id)->setEnabled(enabled);
 }
 
 void LLViewChildren::setText(
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index b3fc0df1bf1..82143f656dc 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -327,11 +327,11 @@ LLMenuParcelObserver::~LLMenuParcelObserver()
 
 void LLMenuParcelObserver::changed()
 {
-	gMenuHolder->childSetEnabled("Land Buy Pass", LLPanelLandGeneral::enableBuyPass(NULL));
+	gMenuHolder->getChildView("Land Buy Pass")->setEnabled(LLPanelLandGeneral::enableBuyPass(NULL));
 	
 	BOOL buyable = enable_buy_land(NULL);
-	gMenuHolder->childSetEnabled("Land Buy", buyable);
-	gMenuHolder->childSetEnabled("Buy Land...", buyable);
+	gMenuHolder->getChildView("Land Buy")->setEnabled(buyable);
+	gMenuHolder->getChildView("Buy Land...")->setEnabled(buyable);
 }
 
 
@@ -451,10 +451,10 @@ void init_menus()
 	// Assume L$10 for now, the server will tell us the real cost at login
 	// *TODO:Also fix cost in llfolderview.cpp for Inventory menus
 	const std::string upload_cost("10");
-	gMenuHolder->childSetLabelArg("Upload Image", "[COST]", upload_cost);
-	gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost);
-	gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost);
-	gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", upload_cost);
+	gMenuHolder->getChild<LLUICtrl>("Upload Image")->setLabelArg("[COST]", upload_cost);
+	gMenuHolder->getChild<LLUICtrl>("Upload Sound")->setLabelArg("[COST]", upload_cost);
+	gMenuHolder->getChild<LLUICtrl>("Upload Animation")->setLabelArg("[COST]", upload_cost);
+	gMenuHolder->getChild<LLUICtrl>("Bulk Upload")->setLabelArg("[COST]", upload_cost);
 
 	gAFKMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Away", TRUE);
 	gBusyMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Busy", TRUE);
@@ -2423,8 +2423,8 @@ class LLObjectEnableTouch : public view_listener_t
 		{
 			touch_text = userdata.asString();
 		}
-		gMenuHolder->childSetText("Object Touch", touch_text);
-		gMenuHolder->childSetText("Attachment Object Touch", touch_text);
+		gMenuHolder->getChild<LLUICtrl>("Object Touch")->setValue(touch_text);
+		gMenuHolder->getChild<LLUICtrl>("Attachment Object Touch")->setValue(touch_text);
 
 		return new_value;
 	}
@@ -7668,7 +7668,7 @@ class LLUploadCostCalculator : public view_listener_t
 	bool handleEvent(const LLSD& userdata)
 	{
 		std::string menu_name = userdata.asString();
-		gMenuHolder->childSetLabelArg(menu_name, "[COST]", mCostStr);
+		gMenuHolder->getChildView(menu_name)->setLabelArg("[COST]", mCostStr);
 
 		return true;
 	}
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 2b6eadcc040..6d447aeccae 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -5303,10 +5303,10 @@ void process_economy_data(LLMessageSystem *msg, void** /*user_data*/)
 
 	LL_INFOS_ONCE("Messaging") << "EconomyData message arrived; upload cost is L$" << upload_cost << LL_ENDL;
 
-	gMenuHolder->childSetLabelArg("Upload Image", "[COST]", llformat("%d", upload_cost));
-	gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", llformat("%d", upload_cost));
-	gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", llformat("%d", upload_cost));
-	gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", llformat("%d", upload_cost));
+	gMenuHolder->getChild<LLUICtrl>("Upload Image")->setLabelArg("[COST]", llformat("%d", upload_cost));
+	gMenuHolder->getChild<LLUICtrl>("Upload Sound")->setLabelArg("[COST]", llformat("%d", upload_cost));
+	gMenuHolder->getChild<LLUICtrl>("Upload Animation")->setLabelArg("[COST]", llformat("%d", upload_cost));
+	gMenuHolder->getChild<LLUICtrl>("Bulk Upload")->setLabelArg("[COST]", llformat("%d", upload_cost));
 }
 
 void notify_cautioned_script_question(const LLSD& notification, const LLSD& response, S32 orig_questions, BOOL granted)
-- 
GitLab


From fbd05e947829714d81278dfa0b138b22e32d56a7 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Fri, 30 Jul 2010 13:51:37 -0700
Subject: [PATCH 578/683] Fix for EXT-8339

Added a couple of new nav states to LLViewerMediaImpl: MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS and MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS.  These behave just like the corresponding states without the _SPURIOUS suffix, but will be used if the new navigate doesn't change the current URL of the impl.  This allows us to catch cases like the repro of this issue and discard the spurious navigate events.
---
 indra/newview/llviewermedia.cpp | 33 +++++++++++++++++++++++++++------
 indra/newview/llviewermedia.h   |  2 ++
 indra/newview/llvovolume.cpp    | 16 +++++++++++++---
 3 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 178d928f57e..55f180c0d98 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -2916,14 +2916,23 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
 		{
 			LL_DEBUGS("Media") << "MEDIA_EVENT_NAVIGATE_COMPLETE, uri is: " << plugin->getNavigateURI() << LL_ENDL;
 
+			std::string url = plugin->getNavigateURI();
 			if(getNavState() == MEDIANAVSTATE_BEGUN)
 			{
-				mCurrentMediaURL = plugin->getNavigateURI();
-				setNavState(MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED);
+				if(mCurrentMediaURL == url)
+				{
+					// This is a navigate that takes us to the same url as the previous navigate.
+					setNavState(MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS);
+				}
+				else
+				{
+					mCurrentMediaURL = url;
+					setNavState(MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED);
+				}
 			}
 			else if(getNavState() == MEDIANAVSTATE_SERVER_BEGUN)
 			{
-				mCurrentMediaURL = plugin->getNavigateURI();
+				mCurrentMediaURL = url;
 				setNavState(MEDIANAVSTATE_SERVER_COMPLETE_BEFORE_LOCATION_CHANGED);
 			}
 			else
@@ -2937,14 +2946,24 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
 		{
 			LL_DEBUGS("Media") << "MEDIA_EVENT_LOCATION_CHANGED, uri is: " << plugin->getLocation() << LL_ENDL;
 
+			std::string url = plugin->getLocation();
+
 			if(getNavState() == MEDIANAVSTATE_BEGUN)
 			{
-				mCurrentMediaURL = plugin->getLocation();
-				setNavState(MEDIANAVSTATE_FIRST_LOCATION_CHANGED);
+				if(mCurrentMediaURL == url)
+				{
+					// This is a navigate that takes us to the same url as the previous navigate.
+					setNavState(MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS);
+				}
+				else
+				{
+					mCurrentMediaURL = url;
+					setNavState(MEDIANAVSTATE_FIRST_LOCATION_CHANGED);
+				}
 			}
 			else if(getNavState() == MEDIANAVSTATE_SERVER_BEGUN)
 			{
-				mCurrentMediaURL = plugin->getLocation();
+				mCurrentMediaURL = url;
 				setNavState(MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED);
 			}
 			else
@@ -3223,7 +3242,9 @@ void LLViewerMediaImpl::setNavState(EMediaNavState state)
 		case MEDIANAVSTATE_NONE: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_NONE" << llendl; break;
 		case MEDIANAVSTATE_BEGUN: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_BEGUN" << llendl; break;
 		case MEDIANAVSTATE_FIRST_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_FIRST_LOCATION_CHANGED" << llendl; break;
+		case MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS" << llendl; break;
 		case MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED" << llendl; break;
+		case MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS" << llendl; break;
 		case MEDIANAVSTATE_SERVER_SENT: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_SENT" << llendl; break;
 		case MEDIANAVSTATE_SERVER_BEGUN: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_BEGUN" << llendl; break;
 		case MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED" << llendl; break;
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index ef9c07c6c78..f75f24fbf54 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -362,7 +362,9 @@ class LLViewerMediaImpl
 		MEDIANAVSTATE_NONE,										// State is outside what we need to track for navigation.
 		MEDIANAVSTATE_BEGUN,									// a MEDIA_EVENT_NAVIGATE_BEGIN has been received which was not server-directed
 		MEDIANAVSTATE_FIRST_LOCATION_CHANGED,					// first LOCATION_CHANGED event after a non-server-directed BEGIN
+		MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS,			// Same as above, but the new URL is identical to the previously navigated URL.
 		MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED,			// we received a NAVIGATE_COMPLETE event before the first LOCATION_CHANGED
+		MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS,// Same as above, but the new URL is identical to the previously navigated URL.
 		MEDIANAVSTATE_SERVER_SENT,								// server-directed nav has been requested, but MEDIA_EVENT_NAVIGATE_BEGIN hasn't been received yet
 		MEDIANAVSTATE_SERVER_BEGUN,								// MEDIA_EVENT_NAVIGATE_BEGIN has been received which was server-directed
 		MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED,			// first LOCATION_CHANGED event after a server-directed BEGIN
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 00d67a4ea93..a75ab95622a 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2082,14 +2082,19 @@ void LLVOVolume::mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin,
 				}
 				break;
 				
+				case LLViewerMediaImpl::MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS:
+					// This navigate didn't change the current URL.  
+					LL_DEBUGS("MediaOnAPrim") << "	NOT broadcasting navigate (spurious)" << LL_ENDL;
+				break;
+				
 				case LLViewerMediaImpl::MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED:
 					// This is the first location changed event after the start of a server-directed nav.  Don't broadcast it.
-					llinfos << "	NOT broadcasting navigate (server-directed)" << llendl;
+					LL_INFOS("MediaOnAPrim") << "	NOT broadcasting navigate (server-directed)" << LL_ENDL;
 				break;
 				
 				default:
 					// This is a subsequent location-changed due to a redirect.	 Don't broadcast.
-					llinfos << "	NOT broadcasting navigate (redirect)" << llendl;
+					LL_INFOS("MediaOnAPrim") << "	NOT broadcasting navigate (redirect)" << LL_ENDL;
 				break;
 			}
 		}
@@ -2106,9 +2111,14 @@ void LLVOVolume::mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin,
 				}
 				break;
 				
+				case LLViewerMediaImpl::MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS:
+					// This navigate didn't change the current URL.  
+					LL_DEBUGS("MediaOnAPrim") << "	NOT broadcasting navigate (spurious)" << LL_ENDL;
+				break;
+
 				case LLViewerMediaImpl::MEDIANAVSTATE_SERVER_COMPLETE_BEFORE_LOCATION_CHANGED:
 					// This is the the navigate complete event from a server-directed nav.  Don't broadcast it.
-					llinfos << "	NOT broadcasting navigate (server-directed)" << llendl;
+					LL_INFOS("MediaOnAPrim") << "	NOT broadcasting navigate (server-directed)" << LL_ENDL;
 				break;
 				
 				default:
-- 
GitLab


From b95ad3b5cec84387d20d2a1af08eeb090b54b134 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 15:17:32 -0700
Subject: [PATCH 579/683] further UI rendering performance improvements

---
 indra/llrender/llfontgl.cpp                   |  24 +-
 indra/llrender/llgl.cpp                       |   6 +-
 indra/llrender/llgl.h                         |   4 +-
 indra/llui/lllocalcliprect.cpp                |   6 +-
 indra/llui/lltextbase.cpp                     |  12 +-
 indra/llui/lltextbase.h                       |   2 +-
 indra/llui/lltexteditor.cpp                   |   7 +-
 indra/llui/llui.cpp                           | 390 +++++++++---------
 indra/llui/llui.h                             |   2 -
 indra/llui/llview.cpp                         |  38 +-
 indra/llui/llview.h                           |   1 -
 indra/newview/llspeakers.cpp                  |   5 +-
 indra/newview/llstatusbar.cpp                 |  89 ++--
 indra/newview/llstatusbar.h                   |   2 +
 indra/newview/llviewernetwork.cpp             |  22 +-
 indra/newview/llviewernetwork.h               |   3 +
 .../default/xui/en/panel_chat_header.xml      |  25 +-
 17 files changed, 331 insertions(+), 307 deletions(-)

diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 2240a2146c9..d6c062fc5e0 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -147,6 +147,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRect& rect
 S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, 
 					 ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_ellipses) const
 {
+	LLFastTimer _(FTM_RENDER_FONTS);
+
 	if(!sDisplayFont) //do not display texts
 	{
 		return wstr.length() ;
@@ -193,9 +195,6 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 	origin.mV[VX] -= llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
 	origin.mV[VY] -= llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
 
-	LLFastTimer t(FTM_RENDER_FONTS);
-
-	gGL.color4fv( color.mV );
 
 	S32 chars_drawn = 0;
 	S32 i;
@@ -286,6 +285,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 	LLVector2 uvs[GLYPH_BATCH_SIZE * 4];
 	LLColor4U colors[GLYPH_BATCH_SIZE * 4];
 
+	LLColor4U text_color(color);
+
+	S32 bitmap_num = -1;
 	S32 glyph_count = 0;
 	for (i = begin_offset; i < begin_offset + length; i++)
 	{
@@ -303,8 +305,13 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 			break;
 		}
 		// Per-glyph bitmap texture.
-		LLImageGL *image_gl = mFontFreetype->getFontBitmapCache()->getImageGL(fgi->mBitmapNum);
-		gGL.getTexUnit(0)->bind(image_gl);
+		S32 next_bitmap_num = fgi->mBitmapNum;
+		if (next_bitmap_num != bitmap_num)
+		{
+			bitmap_num = next_bitmap_num;
+			LLImageGL *font_image = font_bitmap_cache->getImageGL(bitmap_num);
+			gGL.getTexUnit(0)->bind(font_image);
+		}
 	
 		if ((start_x + scaled_max_pixels) < (cur_x + fgi->mXBearing + fgi->mWidth))
 		{
@@ -335,7 +342,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 			glyph_count = 0;
 		}
 
-		drawGlyph(glyph_count, vertices, uvs, colors, screen_rect, uv_rect, color, style_to_add, shadow, drop_shadow_strength);
+		drawGlyph(glyph_count, vertices, uvs, colors, screen_rect, uv_rect, text_color, style_to_add, shadow, drop_shadow_strength);
 
 		chars_drawn++;
 		cur_x += fgi->mXAdvance;
@@ -1145,7 +1152,6 @@ void LLFontGL::renderQuad(LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* c
 	colors_out[index] = color;
 }
 
-//FIXME: do colors out as well
 void LLFontGL::drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, U8 style, ShadowType shadow, F32 drop_shadow_strength) const
 {
 	F32 slant_offset;
@@ -1199,8 +1205,8 @@ void LLFontGL::drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_
 	}
 	else if (shadow == DROP_SHADOW)
 	{
-		LLColor4 shadow_color = LLFontGL::sShadowColor;
-		shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength;
+		LLColor4U shadow_color = LLFontGL::sShadowColor;
+		shadow_color.mV[VALPHA] = U8(color.mV[VALPHA] * drop_shadow_strength);
 		LLRectf screen_rect_shadow = screen_rect;
 		screen_rect_shadow.translate(1.f, -1.f);
 		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_shadow, uv_rect, shadow_color, slant_offset);
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 7ff68fe34b2..236594d6020 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -1122,7 +1122,7 @@ void clear_glerror()
 //
 
 // Static members
-std::map<LLGLenum, LLGLboolean> LLGLState::sStateMap;
+boost::unordered_map<LLGLenum, LLGLboolean> LLGLState::sStateMap;
 
 GLboolean LLGLDepthTest::sDepthEnabled = GL_FALSE; // OpenGL default
 GLenum LLGLDepthTest::sDepthFunc = GL_LESS; // OpenGL default
@@ -1170,7 +1170,7 @@ void LLGLState::resetTextureStates()
 void LLGLState::dumpStates() 
 {
 	LL_INFOS("RenderState") << "GL States:" << LL_ENDL;
-	for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
+	for (boost::unordered_map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
 		 iter != sStateMap.end(); ++iter)
 	{
 		LL_INFOS("RenderState") << llformat(" 0x%04x : %s",(S32)iter->first,iter->second?"TRUE":"FALSE") << LL_ENDL;
@@ -1206,7 +1206,7 @@ void LLGLState::checkStates(const std::string& msg)
 		}
 	}
 	
-	for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
+	for (boost::unordered_map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
 		 iter != sStateMap.end(); ++iter)
 	{
 		LLGLenum state = iter->first;
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 0c2da7dd089..c4f5d91e1ab 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -36,7 +36,7 @@
 // This file contains various stuff for handling gl extensions and other gl related stuff.
 
 #include <string>
-#include <map>
+#include <boost/unordered_map.hpp>
 #include <list>
 
 #include "llerror.h"
@@ -241,7 +241,7 @@ class LLGLState
 	static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0x0001);
 	
 protected:
-	static std::map<LLGLenum, LLGLboolean> sStateMap;
+	static boost::unordered_map<LLGLenum, LLGLboolean> sStateMap;
 	
 public:
 	enum { CURRENT_STATE = -2 };
diff --git a/indra/llui/lllocalcliprect.cpp b/indra/llui/lllocalcliprect.cpp
index 55329f64e45..805d5879f7e 100644
--- a/indra/llui/lllocalcliprect.cpp
+++ b/indra/llui/lllocalcliprect.cpp
@@ -45,9 +45,9 @@ LLScreenClipRect::LLScreenClipRect(const LLRect& rect, BOOL enabled)
 	if (mEnabled)
 	{
 		pushClipRect(rect);
+		mScissorState.setEnabled(!sClipRectStack.empty());
+		updateScissorRegion();
 	}
-	mScissorState.setEnabled(!sClipRectStack.empty());
-	updateScissorRegion();
 }
 
 LLScreenClipRect::~LLScreenClipRect()
@@ -55,8 +55,8 @@ LLScreenClipRect::~LLScreenClipRect()
 	if (mEnabled)
 	{
 		popClipRect();
+		updateScissorRegion();
 	}
-	updateScissorRegion();
 }
 
 //static 
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 4bcf7e69803..cde08c7b193 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1495,24 +1495,32 @@ void LLTextBase::getSegmentAndOffset( S32 startpos, segment_set_t::iterator* seg
 
 LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index)
 {
+	static LLPointer<LLIndexSegment> index_segment = new LLIndexSegment();
+
 	if (index > getLength()) { return mSegments.end(); }
 
 	// when there are no segments, we return the end iterator, which must be checked by caller
 	if (mSegments.size() <= 1) { return mSegments.begin(); }
 
 	//FIXME: avoid operator new somehow (without running into refcount problems)
-	segment_set_t::iterator it = mSegments.upper_bound(new LLIndexSegment(index));
+	index_segment->setStart(index);
+	index_segment->setEnd(index);
+	segment_set_t::iterator it = mSegments.upper_bound(index_segment);
 	return it;
 }
 
 LLTextBase::segment_set_t::const_iterator LLTextBase::getSegIterContaining(S32 index) const
 {
+	static LLPointer<LLIndexSegment> index_segment = new LLIndexSegment();
+
 	if (index > getLength()) { return mSegments.end(); }
 
 	// when there are no segments, we return the end iterator, which must be checked by caller
 	if (mSegments.size() <= 1) { return mSegments.begin(); }
 
-	LLTextBase::segment_set_t::const_iterator it =  mSegments.upper_bound(new LLIndexSegment(index));
+	index_segment->setStart(index);
+	index_segment->setEnd(index);
+	LLTextBase::segment_set_t::const_iterator it =  mSegments.upper_bound(index_segment);
 	return it;
 }
 
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 4b83d5effb2..db010d1cf60 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -163,7 +163,7 @@ class LLOnHoverChangeableTextSegment : public LLNormalTextSegment
 class LLIndexSegment : public LLTextSegment
 {
 public:
-	LLIndexSegment(S32 pos) : LLTextSegment(pos, pos) {}
+	LLIndexSegment() : LLTextSegment(0, 0) {}
 };
 
 class LLInlineViewSegment : public LLTextSegment
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 6781c23416a..482a53e4af8 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -461,8 +461,13 @@ S32 LLTextEditor::nextWordPos(S32 cursorPos) const
 
 const LLTextSegmentPtr	LLTextEditor::getPreviousSegment() const
 {
+	static LLPointer<LLIndexSegment> index_segment = new LLIndexSegment;
+
+	index_segment->setStart(mCursorPos);
+	index_segment->setEnd(mCursorPos);
+
 	// find segment index at character to left of cursor (or rightmost edge of selection)
-	segment_set_t::const_iterator it = mSegments.lower_bound(new LLIndexSegment(mCursorPos));
+	segment_set_t::const_iterator it = mSegments.lower_bound(index_segment);
 
 	if (it != mSegments.end())
 	{
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 7f9dca08d2e..ee308f575a4 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -466,7 +466,7 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border
 	gl_draw_scaled_image_with_border(x, y, width, height, image, color, solid_color, uv_rect, scale_rect);
 }
 
-void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color, BOOL solid_color, const LLRectf& uv_rect, const LLRectf& scale_rect)
+void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color, BOOL solid_color, const LLRectf& uv_outer_rect, const LLRectf& center_rect)
 {
 	stop_glerror();
 
@@ -476,36 +476,53 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
 		return;
 	}
 
+	// add in offset of current image to current ui translation
+	const LLVector3 ui_translation = gGL.getUITranslation() + LLVector3(x, y, 0.f);
+	const LLVector3 ui_scale = gGL.getUIScale();
+
+	F32 uv_width = uv_outer_rect.getWidth();
+	F32 uv_height = uv_outer_rect.getHeight();
+
 	// shrink scaling region to be proportional to clipped image region
-	LLRectf scale_rect_uv(
-		uv_rect.mLeft + (scale_rect.mLeft * uv_rect.getWidth()),
-		uv_rect.mBottom + (scale_rect.mTop * uv_rect.getHeight()),
-		uv_rect.mLeft + (scale_rect.mRight * uv_rect.getWidth()),
-		uv_rect.mBottom + (scale_rect.mBottom * uv_rect.getHeight()));
-
-	S32 image_natural_width = llround((F32)image->getWidth(0) * uv_rect.getWidth());
-	S32 image_natural_height = llround((F32)image->getHeight(0) * uv_rect.getHeight());
-
-	LLRect draw_rect(0, height, width, 0);
-	LLRect draw_scale_rect(llround(scale_rect_uv.mLeft * (F32)image->getWidth(0)),
-						llround(scale_rect_uv.mTop * (F32)image->getHeight(0)),
-						llround(scale_rect_uv.mRight * (F32)image->getWidth(0)),
-						llround(scale_rect_uv.mBottom * (F32)image->getHeight(0)));
-	// scale fixed region of image to drawn region
-	draw_scale_rect.mRight += width - image_natural_width;
-	draw_scale_rect.mTop += height - image_natural_height;
-
-	S32 border_shrink_width = llmax(0, draw_scale_rect.mLeft - draw_scale_rect.mRight);
-	S32 border_shrink_height = llmax(0, draw_scale_rect.mBottom - draw_scale_rect.mTop);
-
-	F32 shrink_width_ratio = scale_rect.getWidth() == 1.f ? 0.f : border_shrink_width / ((F32)image_natural_width * (1.f - scale_rect.getWidth()));
-	F32 shrink_height_ratio = scale_rect.getHeight() == 1.f ? 0.f : border_shrink_height / ((F32)image_natural_height * (1.f - scale_rect.getHeight()));
-
-	F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio);
-	draw_scale_rect.mLeft = llround((F32)draw_scale_rect.mLeft * shrink_scale);
-	draw_scale_rect.mTop = llround(lerp((F32)height, (F32)draw_scale_rect.mTop, shrink_scale));
-	draw_scale_rect.mRight = llround(lerp((F32)width, (F32)draw_scale_rect.mRight, shrink_scale));
-	draw_scale_rect.mBottom = llround((F32)draw_scale_rect.mBottom * shrink_scale);
+	LLRectf uv_center_rect(
+		uv_outer_rect.mLeft + (center_rect.mLeft * uv_width),
+		uv_outer_rect.mBottom + (center_rect.mTop * uv_height),
+		uv_outer_rect.mLeft + (center_rect.mRight * uv_width),
+		uv_outer_rect.mBottom + (center_rect.mBottom * uv_height));
+
+	F32 image_width = image->getWidth(0);
+	F32 image_height = image->getHeight(0);
+
+	S32 image_natural_width = llround(image_width * uv_width);
+	S32 image_natural_height = llround(image_height * uv_height);
+
+	LLRectf draw_center_rect(	uv_center_rect.mLeft * image_width,
+								uv_center_rect.mTop * image_height,
+								uv_center_rect.mRight * image_width,
+								uv_center_rect.mBottom * image_height);
+
+	{	// scale fixed region of image to drawn region
+		draw_center_rect.mRight += width - image_natural_width;
+		draw_center_rect.mTop += height - image_natural_height;
+
+		F32 border_shrink_width = llmax(0.f, draw_center_rect.mLeft - draw_center_rect.mRight);
+		F32 border_shrink_height = llmax(0.f, draw_center_rect.mBottom - draw_center_rect.mTop);
+
+		F32 shrink_width_ratio = center_rect.getWidth() == 1.f ? 0.f : border_shrink_width / ((F32)image_natural_width * (1.f - center_rect.getWidth()));
+		F32 shrink_height_ratio = center_rect.getHeight() == 1.f ? 0.f : border_shrink_height / ((F32)image_natural_height * (1.f - center_rect.getHeight()));
+
+		F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio);
+
+		draw_center_rect.mLeft = llround(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * shrink_scale * ui_scale.mV[VX]);
+		draw_center_rect.mTop = llround(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale * ui_scale.mV[VY]));
+		draw_center_rect.mRight = llround(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale * ui_scale.mV[VX]));
+		draw_center_rect.mBottom = llround(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * shrink_scale * ui_scale.mV[VY]);
+	}
+
+	LLRectf draw_outer_rect(ui_translation.mV[VX], 
+							ui_translation.mV[VY] + height * ui_scale.mV[VY], 
+							ui_translation.mV[VX] + width * ui_scale.mV[VX], 
+							ui_translation.mV[VY]);
 
 	LLGLSUIDefault gls_ui;
 	
@@ -515,136 +532,174 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
 		gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA);
 	}
 
-	gGL.pushUIMatrix();
-	{
-		gGL.translateUI((F32)x, (F32)y, 0.f);
+	gGL.getTexUnit(0)->bind(image);
 
-		gGL.getTexUnit(0)->bind(image);
+	gGL.color4fv(color.mV);
+	
+	const S32 NUM_VERTICES = 9 * 4; // 9 quads
+	LLVector2 uv[NUM_VERTICES];
+	LLVector3 pos[NUM_VERTICES];
 
-		gGL.color4fv(color.mV);
-		
-		gGL.begin(LLRender::QUADS);
-		{
-			// draw bottom left
-			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
-			gGL.vertex2i(0, 0);
+	S32 index = 0;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mBottom);
-			gGL.vertex2i(draw_scale_rect.mLeft, 0);
+	gGL.begin(LLRender::QUADS);
+	{
+		// draw bottom left
+		uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mBottom);
+		pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
-			gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mBottom);
-			gGL.vertex2i(0, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			// draw bottom middle
-			gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mBottom);
-			gGL.vertex2i(draw_scale_rect.mLeft, 0);
+		uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mBottom);
-			gGL.vertex2i(draw_scale_rect.mRight, 0);
+		// draw bottom middle
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
-			gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
-			gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			// draw bottom right
-			gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mBottom);
-			gGL.vertex2i(draw_scale_rect.mRight, 0);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
-			gGL.vertex2i(width, 0);
+		// draw bottom right
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mBottom);
-			gGL.vertex2i(width, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mBottom);
+		pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
-			gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			// draw left 
-			gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mBottom);
-			gGL.vertex2i(0, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
-			gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
+		// draw left 
+		uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
-			gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mTop);
-			gGL.vertex2i(0, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f);
+		index++;
 
-			// draw middle
-			gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
-			gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
-			gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
+		// draw middle
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
-			gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
-			gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f);
+		index++;
 
-			// draw right 
-			gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
-			gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mBottom);
-			gGL.vertex2i(width, draw_scale_rect.mBottom);
+		// draw right 
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mTop);
-			gGL.vertex2i(width, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom);
+		pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
-			gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f);
+		index++;
 
-			// draw top left
-			gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mTop);
-			gGL.vertex2i(0, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
-			gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
+		// draw top left
+		uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mTop);
-			gGL.vertex2i(draw_scale_rect.mLeft, height);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
-			gGL.vertex2i(0, height);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f);
+		index++;
 
-			// draw top middle
-			gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
-			gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mTop);
+		pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
-			gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
+		// draw top middle
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mTop);
-			gGL.vertex2i(draw_scale_rect.mRight, height);
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mTop);
-			gGL.vertex2i(draw_scale_rect.mLeft, height);
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f);
+		index++;
 
-			// draw top right
-			gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
-			gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
+		uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mTop);
-			gGL.vertex2i(width, draw_scale_rect.mTop);
+		// draw top right
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
-			gGL.vertex2i(width, height);
+		uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop);
+		pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f);
+		index++;
 
-			gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mTop);
-			gGL.vertex2i(draw_scale_rect.mRight, height);
-		}
-		gGL.end();
+		uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mTop);
+		pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mTop, 0.f);
+		index++;
+
+		uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop);
+		pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f);
+		index++;
+
+		gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES);
 	}
-	gGL.popUIMatrix();
+	gGL.end();
 
 	if (solid_color)
 	{
@@ -674,25 +729,36 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 
 	if (degrees == 0.f)
 	{
-		gGL.pushUIMatrix();
-		gGL.translateUI((F32)x, (F32)y, 0.f);
-			
+		const S32 NUM_VERTICES = 4; // 9 quads
+		LLVector2 uv[NUM_VERTICES];
+		LLVector3 pos[NUM_VERTICES];
+
 		gGL.begin(LLRender::QUADS);
 		{
-			gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
-			gGL.vertex2i(width, height );
+			LLVector3 ui_translation = gGL.getUITranslation();
+			ui_translation.mV[VX] += x;
+			ui_translation.mV[VY] += y;
+			S32 index = 0;
 
-			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
-			gGL.vertex2i(0, height );
+			uv[index] = LLVector2(uv_rect.mRight, uv_rect.mTop);
+			pos[index] = LLVector3(ui_translation.mV[VX] + width, ui_translation.mV[VY] + height, 0.f);
+			index++;
 
-			gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
-			gGL.vertex2i(0, 0);
+			uv[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop);
+			pos[index] = LLVector3(ui_translation.mV[VX], ui_translation.mV[VY] + height, 0.f);
+			index++;
 
-			gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
-			gGL.vertex2i(width, 0);
+			uv[index] = LLVector2(uv_rect.mLeft, uv_rect.mBottom);
+			pos[index] = LLVector3(ui_translation.mV[VX], ui_translation.mV[VY], 0.f);
+			index++;
+
+			uv[index] = LLVector2(uv_rect.mRight, uv_rect.mBottom);
+			pos[index] = LLVector3(ui_translation.mV[VX] + width, ui_translation.mV[VY], 0.f);
+			index++;
+
+			gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES);
 		}
 		gGL.end();
-		gGL.popUIMatrix();
 	}
 	else
 	{
@@ -761,25 +827,6 @@ void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LL
 	LLUI::setLineWidth(1.f);
 }
 
-
-void gl_rect_2d_xor(S32 left, S32 top, S32 right, S32 bottom)
-{
-	gGL.color4fv( LLColor4::white.mV );
-	glLogicOp( GL_XOR );
-	stop_glerror();
-
-	gGL.begin(LLRender::QUADS);
-		gGL.vertex2i(left, top);
-		gGL.vertex2i(left, bottom);
-		gGL.vertex2i(right, bottom);
-		gGL.vertex2i(right, top);
-	gGL.end();
-
-	glLogicOp( GL_COPY );
-	stop_glerror();
-}
-
-
 void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F32 start_angle, F32 end_angle)
 {
 	if (end_angle < start_angle)
@@ -1013,42 +1060,6 @@ void gl_washer_segment_2d(F32 outer_radius, F32 inner_radius, F32 start_radians,
 	gGL.end();
 }
 
-// Draws spokes around a circle.
-void gl_washer_spokes_2d(F32 outer_radius, F32 inner_radius, S32 count, const LLColor4& inner_color, const LLColor4& outer_color)
-{
-	const F32 DELTA = F_TWO_PI / count;
-	const F32 HALF_DELTA = DELTA * 0.5f;
-	const F32 SIN_DELTA = sin( DELTA );
-	const F32 COS_DELTA = cos( DELTA );
-
-	F32 x1 = outer_radius * cos( HALF_DELTA );
-	F32 y1 = outer_radius * sin( HALF_DELTA );
-	F32 x2 = inner_radius * cos( HALF_DELTA );
-	F32 y2 = inner_radius * sin( HALF_DELTA );
-
-	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
-	gGL.begin( LLRender::LINES  );
-	{
-		while( count-- )
-		{
-			gGL.color4fv(outer_color.mV);
-			gGL.vertex2f( x1, y1 );
-			gGL.color4fv(inner_color.mV);
-			gGL.vertex2f( x2, y2 );
-
-			F32 x1_new = x1 * COS_DELTA - y1 * SIN_DELTA;
-			y1 = x1 * SIN_DELTA +  y1 * COS_DELTA;
-			x1 = x1_new;
-
-			F32 x2_new = x2 * COS_DELTA - y2 * SIN_DELTA;
-			y2 = x2 * SIN_DELTA +  y2 * COS_DELTA;
-			x2 = x2_new;
-		}
-	}
-	gGL.end();
-}
-
 void gl_rect_2d_simple_tex( S32 width, S32 height )
 {
 	gGL.begin( LLRender::QUADS );
@@ -1236,6 +1247,7 @@ void gl_segmented_rect_2d_tex(const S32 left,
 	gGL.popUIMatrix();
 }
 
+//FIXME: rewrite to use scissor?
 void gl_segmented_rect_2d_fragment_tex(const S32 left, 
 									   const S32 top, 
 									   const S32 right, 
diff --git a/indra/llui/llui.h b/indra/llui/llui.h
index c18262ef76b..745d0ff662d 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -96,7 +96,6 @@ void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor
 void gl_corners_2d(S32 left, S32 top, S32 right, S32 bottom, S32 length, F32 max_frac);
 void gl_washer_2d(F32 outer_radius, F32 inner_radius, S32 steps, const LLColor4& inner_color, const LLColor4& outer_color);
 void gl_washer_segment_2d(F32 outer_radius, F32 inner_radius, F32 start_radians, F32 end_radians, S32 steps, const LLColor4& inner_color, const LLColor4& outer_color);
-void gl_washer_spokes_2d(F32 outer_radius, F32 inner_radius, S32 count, const LLColor4& inner_color, const LLColor4& outer_color);
 
 void gl_draw_image(S32 x, S32 y, LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f));
 void gl_draw_scaled_image(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f));
@@ -105,7 +104,6 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border_height, S32 width, S32 height, LLTexture* image, const LLColor4 &color, BOOL solid_color = FALSE, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f));
 void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4 &color, BOOL solid_color = FALSE, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f), const LLRectf& scale_rect = LLRectf(0.f, 1.f, 1.f, 0.f));
 
-void gl_rect_2d_xor(S32 left, S32 top, S32 right, S32 bottom);
 void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LLColor4& color, F32 phase = 0.f ); 
 
 void gl_rect_2d_simple_tex( S32 width, S32 height );
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 9e68277b0f0..4d3708302b7 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -403,28 +403,40 @@ bool LLCompareByTabOrder::operator() (const LLView* const a, const LLView* const
 	return (a_score == b_score) ? a < b : a_score < b_score;
 }
 
-bool LLView::trueToRoot(const boost::function<bool (const LLView*)>& predicate) const
+BOOL LLView::isInVisibleChain() const
 {
-	const LLView* cur_view = this;
-	while(cur_view)
+	BOOL visible = TRUE;
+
+	const LLView* viewp = this;
+	while(viewp)
 	{
-		if(!predicate(cur_view))
+		if (!viewp->getVisible())
 		{
-			return false;
+			visible = FALSE;
+			break;
 		}
-		cur_view = cur_view->getParent();
+		viewp = viewp->getParent();
 	}
-	return true;
-}
-
-BOOL LLView::isInVisibleChain() const
-{
-	return trueToRoot(&LLView::getVisible);
+	
+	return visible;
 }
 
 BOOL LLView::isInEnabledChain() const
 {
-	return trueToRoot(&LLView::getEnabled);
+	BOOL enabled = TRUE;
+
+	const LLView* viewp = this;
+	while(viewp)
+	{
+		if (!viewp->getEnabled())
+		{
+			enabled = FALSE;
+			break;
+		}
+		viewp = viewp->getParent();
+	}
+	
+	return enabled;
 }
 
 // virtual
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 745a1b6e74c..37f5232f91f 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -273,7 +273,6 @@ class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElem
 	S32 getDefaultTabGroup() const				{ return mDefaultTabGroup; }
 	S32 getLastTabGroup()						{ return mLastTabGroup; }
 
-	bool        trueToRoot(const boost::function<bool (const LLView*)>& predicate) const;
 	BOOL		isInVisibleChain() const;
 	BOOL		isInEnabledChain() const;
 
diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp
index bf00b47c214..5128ab6a183 100644
--- a/indra/newview/llspeakers.cpp
+++ b/indra/newview/llspeakers.cpp
@@ -74,7 +74,10 @@ LLSpeaker::LLSpeaker(const LLUUID& id, const std::string& name, const ESpeakerTy
 
 void LLSpeaker::lookupName()
 {
-	gCacheName->get(mID, FALSE, boost::bind(&LLSpeaker::onAvatarNameLookup, this, _1, _2, _3, _4));
+	if (mDisplayName.empty())
+	{
+		gCacheName->get(mID, FALSE, boost::bind(&LLSpeaker::onAvatarNameLookup, this, _1, _2, _3, _4));
+	}
 }
 
 void LLSpeaker::onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group)
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index fc5937ea7de..213925ecdf1 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -195,9 +195,6 @@ BOOL LLStatusBar::postBuild()
 
 	gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2));
 
-	childSetAction("scriptout", onClickScriptDebug, this);
-	childSetAction("health", onClickHealth, this);
-
 	// Adding Net Stat Graph
 	S32 x = getRect().getWidth() - 2;
 	S32 y = 0;
@@ -247,14 +244,17 @@ BOOL LLStatusBar::postBuild()
 	mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
 	mPanelNearByMedia->setVisible(FALSE);
 
+	mScriptOut = getChildView("scriptout");
+
 	return TRUE;
 }
 
 // Per-frame updates of visibility
 void LLStatusBar::refresh()
 {
-	bool net_stats_visible = gSavedSettings.getBOOL("ShowNetStats");
-	
+	static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false);
+	bool net_stats_visible = show_net_stats;
+
 	if (net_stats_visible)
 	{
 		// Adding Net Stat Meter back in
@@ -266,26 +266,30 @@ void LLStatusBar::refresh()
 		mSGBandwidth->setThreshold(2, bwtotal);
 	}
 	
-	// Get current UTC time, adjusted for the user's clock
-	// being off.
-	time_t utc_time;
-	utc_time = time_corrected();
-
-	std::string timeStr = getString("time");
-	LLSD substitution;
-	substitution["datetime"] = (S32) utc_time;
-	LLStringUtil::format (timeStr, substitution);
-	mTextTime->setText(timeStr);
-
-	// set the tooltip to have the date
-	std::string dtStr = getString("timeTooltip");
-	LLStringUtil::format (dtStr, substitution);
-	mTextTime->setToolTip (dtStr);
+	// update clock every 10 seconds
+	if(mClockUpdateTimer.getElapsedTimeF32() > 10.f)
+	{
+		mClockUpdateTimer.reset();
+
+		// Get current UTC time, adjusted for the user's clock
+		// being off.
+		time_t utc_time;
+		utc_time = time_corrected();
+
+		std::string timeStr = getString("time");
+		LLSD substitution;
+		substitution["datetime"] = (S32) utc_time;
+		LLStringUtil::format (timeStr, substitution);
+		mTextTime->setText(timeStr);
+
+		// set the tooltip to have the date
+		std::string dtStr = getString("timeTooltip");
+		LLStringUtil::format (dtStr, substitution);
+		mTextTime->setToolTip (dtStr);
+	}
 
 	LLRect r;
 	const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
-	S32 x = MENU_RIGHT + MENU_PARCEL_SPACING;
-	S32 y = 0;
 
 	// reshape menu bar to its content's width
 	if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
@@ -293,47 +297,6 @@ void LLStatusBar::refresh()
 		gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
 	}
 
-	LLViewerRegion *region = gAgent.getRegion();
-	LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
-
-	LLRect buttonRect;
-
-	if (LLHUDIcon::iconsNearby())
-	{
-		LLView* script_out = getChildView("scriptout");
-		buttonRect = script_out->getRect();
-		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
-		script_out->setShape(r);
-		script_out->setVisible( true);
-		x += buttonRect.getWidth();
-	}
-	else
-	{
-		getChildView("scriptout")->setVisible( false);
-	}
-
-	if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK &&
-		((region && region->getAllowDamage()) || (parcel && parcel->getAllowDamage())))
-	{
-		// set visibility based on flashing
-		if( mHealthTimer->hasExpired() )
-		{
-			getChildView("health")->setVisible( true);
-		}
-		else
-		{
-			BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1;
-			getChildView("health")->setVisible( flash);
-		}
-
-		// Health
-		LLView* healthp = getChildView("health");
-		buttonRect = healthp->getRect();
-		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
-		healthp->setShape(r);
-		x += buttonRect.getWidth();
-	}
-
 	mSGBandwidth->setVisible(net_stats_visible);
 	mSGPacketLoss->setVisible(net_stats_visible);
 	getChildView("stat_btn")->setEnabled(net_stats_visible);
diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h
index 32f29e9e1c8..2e2187bafe0 100644
--- a/indra/newview/llstatusbar.h
+++ b/indra/newview/llstatusbar.h
@@ -112,6 +112,8 @@ class LLStatusBar
 
 	LLButton	*mBtnVolume;
 	LLButton	*mMediaToggle;
+	LLView*		mScriptOut;
+	LLFrameTimer	mClockUpdateTimer;
 
 	S32				mBalance;
 	S32				mHealth;
diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp
index fec112b9e7e..1fac4d003d5 100644
--- a/indra/newview/llviewernetwork.cpp
+++ b/indra/newview/llviewernetwork.cpp
@@ -49,6 +49,7 @@ const char* DEFAULT_SLURL_BASE = "https://%s/region/";
 const char* DEFAULT_APP_SLURL_BASE = "x-grid-location-info://%s/app";
 
 LLGridManager::LLGridManager()
+:	mIsInProductionGrid(false)
 {
 	// by default, we use the 'grids.xml' file in the user settings directory
 	// this file is an LLSD file containing multiple grid definitions.
@@ -308,6 +309,10 @@ void LLGridManager::initialize(const std::string& grid_file)
 		addGrid(grid);		
 	}
 
+	gSavedSettings.getControl("CurrentGrid")->getSignal()->connect(boost::bind(&LLGridManager::updateIsInProductionGrid, this));
+	// since above only triggers on changes, trigger the callback manually to initialize state
+	updateIsInProductionGrid();
+
 	LL_DEBUGS("GridManager") << "Selected grid is " << mGrid << LL_ENDL;		
 	setGridChoice(mGrid);
 	if(mGridList[mGrid][GRID_LOGIN_URI_VALUE].isArray())
@@ -559,23 +564,30 @@ std::string LLGridManager::getLoginPage()
 	return mGridList[mGrid][GRID_LOGIN_PAGE_VALUE];
 }
 
-bool LLGridManager::isInProductionGrid()
+void LLGridManager::updateIsInProductionGrid()
 {
+	mIsInProductionGrid = false;
+
 	// *NOTE:Mani This used to compare GRID_INFO_AGNI to gGridChoice,
 	// but it seems that loginURI trumps that.
 	std::vector<std::string> uris;
 	getLoginURIs(uris);
-	if (uris.size() < 1)
+	if (uris.empty())
 	{
-		return 1;
+		mIsInProductionGrid = true;
+		return;
 	}
 	LLStringUtil::toLower(uris[0]);
 	if((uris[0].find("agni") != std::string::npos))
 	{
-		return true;
+		mIsInProductionGrid = true;
+		return;
 	}
+}
 
-	return false;
+bool LLGridManager::isInProductionGrid()
+{
+	return mIsInProductionGrid;
 }
 
 void LLGridManager::saveFavorites()
diff --git a/indra/newview/llviewernetwork.h b/indra/newview/llviewernetwork.h
index 8c3a15b7cf0..f6cbd57ac09 100644
--- a/indra/newview/llviewernetwork.h
+++ b/indra/newview/llviewernetwork.h
@@ -136,6 +136,8 @@ class LLGridManager : public LLSingleton<LLGridManager>
 
 protected:
 
+	void updateIsInProductionGrid();
+
 	// helper function for adding the predefined grids
 	void addSystemGrid(const std::string& label, 
 					   const std::string& name, 
@@ -148,6 +150,7 @@ class LLGridManager : public LLSingleton<LLGridManager>
 	std::string mGrid;
 	std::string mGridFile;
 	LLSD mGridList;
+	bool mIsInProductionGrid;
 };
 
 const S32 MAC_ADDRESS_BYTES = 6;
diff --git a/indra/newview/skins/default/xui/en/panel_chat_header.xml b/indra/newview/skins/default/xui/en/panel_chat_header.xml
index c98213f6c73..17e8d4d2df9 100644
--- a/indra/newview/skins/default/xui/en/panel_chat_header.xml
+++ b/indra/newview/skins/default/xui/en/panel_chat_header.xml
@@ -38,16 +38,17 @@
       use_ellipses="true"
       valign="bottom" 
       value="Ericag Vader" />
-    <text
-            font="SansSerifSmall"
-         follows="right"
-         halign="right"
-         height="13"
-         layout="topleft"
-         left_pad="5"
-     name="time_box"
-     right="-5"
-     top="8"
-         value="23:30"
-         width="110" />
+  <text
+    allow_scroll="false"
+    font="SansSerifSmall"
+    follows="right"
+    halign="right"
+    height="13"
+    layout="topleft"
+    left_pad="5"
+    name="time_box"
+    right="-5"
+    top="8"
+    value="23:30"
+    width="110" />
 </panel>
-- 
GitLab


From 6adbeb504d024653bca73e16a17efcac90bcfea0 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 16:07:08 -0700
Subject: [PATCH 580/683] fixed windows build

---
 indra/newview/llmediadataclient.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h
index 39614424125..25b55b4705f 100755
--- a/indra/newview/llmediadataclient.h
+++ b/indra/newview/llmediadataclient.h
@@ -75,6 +75,7 @@ class LLMediaDataClientObject : public LLRefCount
 	typedef LLPointer<LLMediaDataClientObject> ptr_t;
 };
 
+
 // This object creates a priority queue for requests.
 // Abstracts the Cap URL, the request, and the responder
 class LLMediaDataClient : public LLRefCount
@@ -282,9 +283,12 @@ class LLMediaDataClient : public LLRefCount
 	void setIsRunning(bool val) { mQueueTimerIsRunning = val; }
 		
 	bool mQueueTimerIsRunning;
-		
-};
 
+	template <typename T> friend typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type);
+	template <typename T> friend typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type);
+	template <typename T> friend void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type);
+
+};
 
 // MediaDataClient specific for the ObjectMedia cap
 class LLObjectMediaDataClient : public LLMediaDataClient
-- 
GitLab


From 4b3e4d2ab42e1748afc7f201809f2bf669a34908 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Fri, 30 Jul 2010 17:13:27 -0700
Subject: [PATCH 581/683] Fix for EXT-8533

When sending the MIME type probe, tell LLCurl to allow cookies in the response.  This works around an issue with some sites that will get into an infinite redirect loop when cookies are disabled.
---
 indra/newview/llviewermedia.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 55f180c0d98..99220e288c7 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -2308,6 +2308,8 @@ void LLViewerMediaImpl::navigateInternal()
 			// which is really not what we want.
 			LLSD headers = LLSD::emptyMap();
 			headers["Accept"] = "*/*";
+			// Allow cookies in the response, to prevent a redirect loop when accessing join.secondlife.com
+			headers["Cookie"] = "";
 			LLHTTPClient::getHeaderOnly( mMediaURL, new LLMimeDiscoveryResponder(this), headers, 10.0f);
 		}
 		else if("data" == scheme || "file" == scheme || "about" == scheme)
-- 
GitLab


From db7fb78b8b915d1ab1ae3af7a9ae4c3c4608525b Mon Sep 17 00:00:00 2001
From: Rick Pasetto <rick@lindenlab.com>
Date: Fri, 30 Jul 2010 17:30:53 -0700
Subject: [PATCH 582/683] fix for mac build

---
 indra/newview/llstatusbar.cpp | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 213925ecdf1..39f0f32205d 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -464,16 +464,6 @@ void LLStatusBar::onClickBuyCurrency()
 	LLBuyCurrencyHTML::openCurrencyFloater();
 }
 
-static void onClickHealth(void* )
-{
-	LLNotificationsUtil::add("NotSafe");
-}
-
-static void onClickScriptDebug(void*)
-{
-	LLFloaterScriptDebug::show(LLUUID::null);
-}
-
 void LLStatusBar::onMouseEnterVolume()
 {
 	LLButton* volbtn =  getChild<LLButton>( "volume_btn" );
-- 
GitLab


From 4e5767395a6c94625399517869a70f0dc79b9735 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Fri, 30 Jul 2010 17:33:00 -0700
Subject: [PATCH 583/683] Fix mac build.

---
 indra/newview/llmediadataclient.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h
index 25b55b4705f..f82eb2120b9 100755
--- a/indra/newview/llmediadataclient.h
+++ b/indra/newview/llmediadataclient.h
@@ -284,9 +284,9 @@ class LLMediaDataClient : public LLRefCount
 		
 	bool mQueueTimerIsRunning;
 
-	template <typename T> friend typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type);
-	template <typename T> friend typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type);
-	template <typename T> friend void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type);
+	template <typename T> friend typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY);
+	template <typename T> friend typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY);
+	template <typename T> friend void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY);
 
 };
 
-- 
GitLab


From 3caa8cb79b7014971438c1c6266e2e83bec2e021 Mon Sep 17 00:00:00 2001
From: Rick Pasetto <rick@lindenlab.com>
Date: Fri, 30 Jul 2010 17:33:41 -0700
Subject: [PATCH 584/683] fix for mac

---
 indra/newview/llstatusbar.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 39f0f32205d..a6bb4d4d5f9 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -111,8 +111,6 @@ const F32 ICON_TIMER_EXPIRY		= 3.f; // How long the balance and health icons sho
 const F32 ICON_FLASH_FREQUENCY	= 2.f;
 const S32 TEXT_HEIGHT = 18;
 
-static void onClickHealth(void*);
-static void onClickScriptDebug(void*);
 static void onClickVolume(void*);
 
 std::vector<std::string> LLStatusBar::sDays;
-- 
GitLab


From f4092f2b32308801cf3f034e031ab56b3161c878 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 17:41:41 -0700
Subject: [PATCH 585/683] optimizations in button rendering

---
 indra/llui/llbutton.cpp          | 12 +++++++-----
 indra/llui/llbutton.h            |  1 +
 indra/newview/llviewerwindow.cpp | 11 -----------
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index aeedf623791..5a4f0515fc3 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -120,6 +120,7 @@ LLButton::LLButton(const LLButton::Params& p)
 	mFlashing( FALSE ),
 	mCurGlowStrength(0.f),
 	mNeedsHighlight(FALSE),
+	mMouseOver(false),
 	mUnselectedLabel(p.label()),
 	mSelectedLabel(p.label_selected()),
 	mGLFont(p.font),
@@ -504,7 +505,11 @@ void LLButton::onMouseEnter(S32 x, S32 y, MASK mask)
 	LLUICtrl::onMouseEnter(x, y, mask);
 
 	if (isInEnabledChain())
+	{
 		mNeedsHighlight = TRUE;
+	}
+
+	mMouseOver = true;
 }
 
 void LLButton::onMouseLeave(S32 x, S32 y, MASK mask)
@@ -512,6 +517,7 @@ void LLButton::onMouseLeave(S32 x, S32 y, MASK mask)
 	LLUICtrl::onMouseLeave(x, y, mask);
 
 	mNeedsHighlight = FALSE;
+	mMouseOver = true;
 }
 
 void LLButton::setHighlight(bool b)
@@ -565,14 +571,10 @@ void LLButton::draw()
 	}
 
 	// Unselected image assignments
-	S32 local_mouse_x;
-	S32 local_mouse_y;
-	LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
-
 	bool enabled = isInEnabledChain();
 
 	bool pressed = pressed_by_keyboard 
-					|| (hasMouseCapture() && pointInView(local_mouse_x, local_mouse_y))
+					|| (hasMouseCapture() && mMouseOver)
 					|| mForcePressedState;
 	bool selected = getToggleState();
 	
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index f4af19b696e..5f25084b356 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -356,6 +356,7 @@ class LLButton
 	BOOL						mCommitOnReturn;
 	BOOL						mFadeWhenDisabled;
 	bool						mForcePressedState;
+	bool						mMouseOver;
 
 	LLFrameTimer				mFlashingTimer;
 };
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 00873a797cb..b36af7d95b0 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2482,17 +2482,6 @@ void LLViewerWindow::updateUI()
 	// only update mouse hover set when UI is visible (since we shouldn't send hover events to invisible UI
 	if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
 	{
-		// include all ancestors of captor_view as automatically having mouse
-		if (captor_view)
-		{
-			LLView* captor_parent_view = captor_view->getParent();
-			while(captor_parent_view)
-			{
-				mouse_hover_set.insert(captor_parent_view->getHandle());
-				captor_parent_view = captor_parent_view->getParent();
-			}
-		}
-
 		// aggregate visible views that contain mouse cursor in display order
 		LLPopupView::popup_list_t popups = mPopupView->getCurrentPopups();
 
-- 
GitLab


From 5b7031dd83bea0f3201fd45d55ef896227f399ce Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Fri, 30 Jul 2010 17:45:13 -0700
Subject: [PATCH 586/683] fixed windows build

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

diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp
index a577776ad05..1de9d1c9b0e 100755
--- a/indra/newview/llmediadataclient.cpp
+++ b/indra/newview/llmediadataclient.cpp
@@ -98,7 +98,7 @@ std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::request_queue
 std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &q);
 
 template <typename T>
-static typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY)
+static typename T::iterator find_matching_request(T &c, const LLMediaDataClient::Request *request, LLMediaDataClient::Request::Type match_type)
 {
 	for(typename T::iterator iter = c.begin(); iter != c.end(); ++iter)
 	{
@@ -112,7 +112,7 @@ static typename T::iterator find_matching_request(T &c, const LLMediaDataClient:
 }
 
 template <typename T>
-static typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY)
+static typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type)
 {
 	for(typename T::iterator iter = c.begin(); iter != c.end(); ++iter)
 	{
@@ -129,7 +129,7 @@ static typename T::iterator find_matching_request(T &c, const LLUUID &id, LLMedi
 // to other elements in the container (such as std::vector).
 // If the implementation is changed to use a container with this property, this will need to be revisited.
 template <typename T>
-static void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type = LLMediaDataClient::Request::ANY)
+static void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request::Type match_type)
 {
 	for(typename T::iterator iter = c.begin(); iter != c.end();)
 	{
-- 
GitLab


From 4bf7dd9d529a4e6a0d2132f9587182f483495e23 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Mon, 2 Aug 2010 19:04:32 +0300
Subject: [PATCH 587/683] EXT-6542 Localized the "none/none" in the About land
 floater.

This is an additional fix to the one made in rev. 6788ff579917.

Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/828/
---
 indra/newview/llpanellandmedia.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llpanellandmedia.cpp b/indra/newview/llpanellandmedia.cpp
index f0f386c5d17..240139d7149 100644
--- a/indra/newview/llpanellandmedia.cpp
+++ b/indra/newview/llpanellandmedia.cpp
@@ -145,7 +145,7 @@ void LLPanelLandMedia::refresh()
 		mMediaURLEdit->setText(parcel->getMediaURL());
 		mMediaURLEdit->setEnabled( FALSE );
 
-		getChild<LLUICtrl>("current_url")->setValue(parcel->getMediaCurrentURL());
+		childSetText("current_url", parcel->getMediaCurrentURL());
 
 		mMediaDescEdit->setText(parcel->getMediaDesc());
 		mMediaDescEdit->setEnabled( can_change_media );
@@ -157,7 +157,7 @@ void LLPanelLandMedia::refresh()
 		}
 		setMediaType(mime_type);
 		mMediaTypeCombo->setEnabled( can_change_media );
-		getChild<LLUICtrl>("mime_type")->setValue(mime_type);
+		childSetText("mime_type", mime_type);
 
 		mMediaUrlCheck->set( parcel->getObscureMedia() );
 		mMediaUrlCheck->setEnabled( can_change_media );
@@ -255,7 +255,7 @@ void LLPanelLandMedia::setMediaType(const std::string& mime_type)
 		// localizable - "none" for example (see EXT-6542)
 		mime_str = LLMIMETypes::getDefaultMimeTypeTranslation();
 	}
-	getChild<LLUICtrl>("mime_type")->setValue(mime_str);
+	childSetText("mime_type", mime_str);
 }
 
 void LLPanelLandMedia::setMediaURL(const std::string& media_url)
@@ -269,7 +269,7 @@ void LLPanelLandMedia::setMediaURL(const std::string& media_url)
 
 	mMediaURLEdit->onCommit();
 	// LLViewerParcelMedia::sendMediaNavigateMessage(media_url);
-	getChild<LLUICtrl>("current_url")->setValue(media_url);
+	childSetText("current_url", media_url);
 }
 std::string LLPanelLandMedia::getMediaURL()
 {
@@ -280,11 +280,11 @@ std::string LLPanelLandMedia::getMediaURL()
 void LLPanelLandMedia::onCommitType(LLUICtrl *ctrl, void *userdata)
 {
 	LLPanelLandMedia *self = (LLPanelLandMedia *)userdata;
-	std::string current_type = LLMIMETypes::widgetType(self->getChild<LLUICtrl>("mime_type")->getValue().asString());
+	std::string current_type = LLMIMETypes::widgetType(self->childGetText("mime_type"));
 	std::string new_type = self->mMediaTypeCombo->getValue();
 	if(current_type != new_type)
 	{
-		self->getChild<LLUICtrl>("mime_type")->setValue(LLMIMETypes::findDefaultMimeType(new_type));
+		self->childSetText("mime_type", LLMIMETypes::findDefaultMimeType(new_type));
 	}
 	onCommitAny(ctrl, userdata);
 
@@ -304,7 +304,7 @@ void LLPanelLandMedia::onCommitAny(LLUICtrl*, void *userdata)
 	// Extract data from UI
 	std::string media_url	= self->mMediaURLEdit->getText();
 	std::string media_desc	= self->mMediaDescEdit->getText();
-	std::string mime_type	= self->getChild<LLUICtrl>("mime_type")->getValue().asString();
+	std::string mime_type	= self->childGetText("mime_type");
 	U8 media_auto_scale		= self->mMediaAutoScaleCheck->get();
 	U8 media_loop           = self->mMediaLoopCheck->get();
 	U8 obscure_media		= self->mMediaUrlCheck->get();
@@ -313,7 +313,7 @@ void LLPanelLandMedia::onCommitAny(LLUICtrl*, void *userdata)
 	LLUUID media_id			= self->mMediaTextureCtrl->getImageAssetID();
 
 
-	self->getChild<LLUICtrl>("mime_type")->setValue(mime_type);
+	self->childSetText("mime_type", mime_type);
 
 	// Remove leading/trailing whitespace (common when copying/pasting)
 	LLStringUtil::trim(media_url);
@@ -354,7 +354,7 @@ void LLPanelLandMedia::onResetBtn(void *userdata)
 	LLParcel* parcel = self->mParcel->getParcel();
 	// LLViewerMedia::navigateHome();
 	self->refresh();
-	self->getChild<LLUICtrl>("current_url")->setValue(parcel->getMediaURL());
+	self->childSetText("current_url", parcel->getMediaURL());
 	// LLViewerParcelMedia::sendMediaNavigateMessage(parcel->getMediaURL());
 
 }
-- 
GitLab


From b8b7a61e9e732b16a56ae0bec3b9098ccfd28292 Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Mon, 2 Aug 2010 21:00:02 +0300
Subject: [PATCH 588/683] EXT-5609 FIXED Avoided showing script floater
 undocked if it was created in mouselook mode.

Commiting on behalf of Alex Productengine.

- Added check if floater is constructed in mouselook mode and added forcing dock state when floater is shown after constructing in mouselook mode.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/830/

--HG--
branch : product-engine
---
 indra/llui/lldockablefloater.cpp  | 15 +++++++++++++++
 indra/llui/lldockablefloater.h    |  7 +++++++
 indra/newview/llscriptfloater.cpp |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp
index 4f5fcddbf4c..f9983278d15 100644
--- a/indra/llui/lldockablefloater.cpp
+++ b/indra/llui/lldockablefloater.cpp
@@ -50,6 +50,7 @@ void LLDockableFloater::init(LLDockableFloater* thiz)
 	thiz->setCanDock(true);
 	thiz->setCanMinimize(TRUE);
 	thiz->setOverlapsScreenChannel(false);
+	thiz->mForceDocking = false;
 }
 
 LLDockableFloater::LLDockableFloater(LLDockControl* dockControl,
@@ -81,6 +82,12 @@ LLDockableFloater::~LLDockableFloater()
 
 BOOL LLDockableFloater::postBuild()
 {
+	// Remember we should force docking when the floater is opened for the first time
+	if (mIsDockedStateForcedCallback != NULL && mIsDockedStateForcedCallback())
+	{
+		mForceDocking = true;
+	}
+
 	mDockTongue = LLUI::getUIImage("windows/Flyout_Pointer.png");
 	LLFloater::setDocked(true);
 	return LLView::postBuild();
@@ -134,6 +141,14 @@ void LLDockableFloater::resetInstance()
 
 void LLDockableFloater::setVisible(BOOL visible)
 {
+	// Force docking if requested
+	if (visible && mForceDocking)
+	{
+		setCanDock(true);
+		setDocked(true);
+		mForceDocking = false;
+	}
+
 	if(visible && isDocked())
 	{
 		resetInstance();
diff --git a/indra/llui/lldockablefloater.h b/indra/llui/lldockablefloater.h
index 2b1ce99ae2e..054d59b984e 100644
--- a/indra/llui/lldockablefloater.h
+++ b/indra/llui/lldockablefloater.h
@@ -130,6 +130,10 @@ class LLDockableFloater : public LLFloater
 	void setDockControl(LLDockControl* dockControl);
 	const LLUIImagePtr& getDockTongue();
 
+	// Checks if docking should be forced.
+	// It may be useful e.g. if floater created in mouselook mode (see EXT-5609)
+	boost::function<BOOL ()> mIsDockedStateForcedCallback;
+
 private:
 	std::auto_ptr<LLDockControl> mDockControl;
 	LLUIImagePtr mDockTongue;
@@ -143,6 +147,9 @@ class LLDockableFloater : public LLFloater
 	bool mUseTongue;
 
 	bool mOverlapsScreenChannel;
+
+	// Force docking when the floater is being shown for the first time.
+	bool mForceDocking;
 };
 
 #endif /* LL_DOCKABLEFLOATER_H */
diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp
index 75797dae812..f1246599106 100644
--- a/indra/newview/llscriptfloater.cpp
+++ b/indra/newview/llscriptfloater.cpp
@@ -32,6 +32,7 @@
 
 #include "llviewerprecompiledheaders.h"
 #include "llscriptfloater.h"
+#include "llagentcamera.h"
 
 #include "llbottomtray.h"
 #include "llchannelmanager.h"
@@ -71,6 +72,7 @@ LLScriptFloater::LLScriptFloater(const LLSD& key)
 {
 	setMouseDownCallback(boost::bind(&LLScriptFloater::onMouseDown, this));
 	setOverlapsScreenChannel(true);
+	mIsDockedStateForcedCallback = boost::bind(&LLAgentCamera::cameraMouselook, &gAgentCamera);
 }
 
 bool LLScriptFloater::toggle(const LLUUID& notification_id)
-- 
GitLab


From 74ed51e77d7a44b845dcc12d1d7ad6a426caaa2d Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Mon, 2 Aug 2010 20:52:17 +0300
Subject: [PATCH 589/683] EXT-7676 FIXED Restored fix (47df1b3fd94e) reverted
 in merge 5b5cc4a8642d with slight modifications. - Replaced pointers passed
 to 'Add More' gear menu with LLHandle. - Removed storing 'Add More' panel
 sort order from settings because the order is changed each time the panel
 opens. - Replaced creating items comparator in LLPanelOutfitEdit::postBuild()
 with a static comparator in llwearableitemslist.cpp.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/826/.

--HG--
branch : product-engine
---
 indra/newview/app_settings/settings.xml |  11 --
 indra/newview/llpaneloutfitedit.cpp     | 212 +++++++++++++++++++++---
 indra/newview/llpaneloutfitedit.h       |   6 +-
 indra/newview/llwearableitemslist.cpp   |  53 +++++-
 indra/newview/llwearableitemslist.h     |  27 +++
 5 files changed, 272 insertions(+), 37 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ce22db97b49..bbf3f4fc75a 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -35,17 +35,6 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>AddWearableSortOrder</key>
-    <map>
-      <key>Comment</key>
-      <string>Specifies sort order for add wearable panel (0 = name, 1 = date, 2 = by type)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>U32</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
     <key>AgentPause</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 17e7965ab76..c7ac4af14c9 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -86,6 +86,11 @@ const U64 ALL_ITEMS_MASK = WEARABLE_MASK | ATTACHMENT_MASK;
 
 static const std::string REVERT_BTN("revert_btn");
 
+
+///////////////////////////////////////////////////////////////////////////////
+// LLShopURLDispatcher
+///////////////////////////////////////////////////////////////////////////////
+
 class LLShopURLDispatcher
 {
 public:
@@ -145,6 +150,10 @@ std::string LLShopURLDispatcher::resolveURL(LLAssetType::EType asset_type, ESex
 	return gSavedSettings.getString(setting_name);
 }
 
+///////////////////////////////////////////////////////////////////////////////
+// LLPanelOutfitEditGearMenu
+///////////////////////////////////////////////////////////////////////////////
+
 class LLPanelOutfitEditGearMenu
 {
 public:
@@ -160,7 +169,6 @@ class LLPanelOutfitEditGearMenu
 		if (menu)
 		{
 			populateCreateWearableSubmenus(menu);
-			menu->buildDrawLabels();
 		}
 
 		return menu;
@@ -209,6 +217,147 @@ class LLPanelOutfitEditGearMenu
 	}
 };
 
+///////////////////////////////////////////////////////////////////////////////
+// LLAddWearablesGearMenu
+///////////////////////////////////////////////////////////////////////////////
+
+class LLAddWearablesGearMenu : public LLInitClass<LLAddWearablesGearMenu>
+{
+public:
+	static LLMenuGL* create(LLWearableItemsList* flat_list, LLInventoryPanel* inventory_panel)
+	{
+		LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
+		LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
+
+		llassert(flat_list);
+		llassert(inventory_panel);
+
+		LLHandle<LLView> flat_list_handle = flat_list->getHandle();
+		LLHandle<LLPanel> inventory_panel_handle = inventory_panel->getHandle();
+
+		registrar.add("AddWearable.Gear.Sort", boost::bind(onSort, flat_list_handle, inventory_panel_handle, _2));
+		enable_registrar.add("AddWearable.Gear.Check", boost::bind(onCheck, flat_list_handle, inventory_panel_handle, _2));
+		enable_registrar.add("AddWearable.Gear.Visible", boost::bind(onVisible, inventory_panel_handle, _2));
+
+		LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(
+			"menu_add_wearable_gear.xml",
+			LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
+
+		return menu;
+	}
+
+private:
+	static void onSort(LLHandle<LLView> flat_list_handle,
+					   LLHandle<LLPanel> inventory_panel_handle,
+					   LLSD::String sort_order_str)
+	{
+		if (flat_list_handle.isDead() || inventory_panel_handle.isDead()) return;
+
+		LLWearableItemsList* flat_list = dynamic_cast<LLWearableItemsList*>(flat_list_handle.get());
+		LLInventoryPanel* inventory_panel = dynamic_cast<LLInventoryPanel*>(inventory_panel_handle.get());
+
+		if (!flat_list || !inventory_panel) return;
+
+		LLWearableItemsList::ESortOrder	sort_order;
+
+		if ("by_most_recent" == sort_order_str)
+		{
+			sort_order = LLWearableItemsList::E_SORT_BY_MOST_RECENT;
+		}
+		else if ("by_name" == sort_order_str)
+		{
+			sort_order = LLWearableItemsList::E_SORT_BY_NAME;
+		}
+		else if ("by_type" == sort_order_str)
+		{
+			sort_order = LLWearableItemsList::E_SORT_BY_TYPE_NAME;
+		}
+		else
+		{
+			llwarns << "Unrecognized sort order action" << llendl;
+			return;
+		}
+
+		if (inventory_panel->getVisible())
+		{
+			inventory_panel->setSortOrder(sort_order);
+		}
+		else
+		{
+			flat_list->setSortOrder(sort_order);
+		}
+	}
+
+	static bool onCheck(LLHandle<LLView> flat_list_handle,
+						LLHandle<LLPanel> inventory_panel_handle,
+						LLSD::String sort_order_str)
+	{
+		if (flat_list_handle.isDead() || inventory_panel_handle.isDead()) return false;
+
+		LLWearableItemsList* flat_list = dynamic_cast<LLWearableItemsList*>(flat_list_handle.get());
+		LLInventoryPanel* inventory_panel = dynamic_cast<LLInventoryPanel*>(inventory_panel_handle.get());
+
+		if (!inventory_panel || !flat_list) return false;
+
+		// Inventory panel uses its own sort order independent from
+		// flat list view so this flag is used to distinguish between
+		// currently visible "tree" or "flat" representation of inventory.
+		bool inventory_tree_visible = inventory_panel->getVisible();
+
+		if (inventory_tree_visible)
+		{
+			U32 sort_order = inventory_panel->getSortOrder();
+
+			if ("by_most_recent" == sort_order_str)
+			{
+				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & sort_order;
+			}
+			else if ("by_name" == sort_order_str)
+			{
+				// If inventory panel is not sorted by date then it is sorted by name.
+				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & ~sort_order;
+			}
+			llwarns << "Unrecognized inventory panel sort order" << llendl;
+		}
+		else
+		{
+			LLWearableItemsList::ESortOrder	sort_order = flat_list->getSortOrder();
+
+			if ("by_most_recent" == sort_order_str)
+			{
+				return LLWearableItemsList::E_SORT_BY_MOST_RECENT == sort_order;
+			}
+			else if ("by_name" == sort_order_str)
+			{
+				return LLWearableItemsList::E_SORT_BY_NAME == sort_order;
+			}
+			else if ("by_type" == sort_order_str)
+			{
+				return LLWearableItemsList::E_SORT_BY_TYPE_NAME == sort_order;
+			}
+			llwarns << "Unrecognized wearable list sort order" << llendl;
+		}
+		return false;
+	}
+
+	static bool onVisible(LLHandle<LLPanel> inventory_panel_handle,
+						  LLSD::String sort_order_str)
+	{
+		if (inventory_panel_handle.isDead()) return false;
+
+		LLInventoryPanel* inventory_panel = dynamic_cast<LLInventoryPanel*>(inventory_panel_handle.get());
+
+		// Enable sorting by type only for the flat list of items
+		// because inventory panel doesn't support this kind of sorting.
+		return ( "by_type" == sort_order_str )
+				&&	( !inventory_panel || !inventory_panel->getVisible() );
+	}
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// LLCOFDragAndDropObserver
+///////////////////////////////////////////////////////////////////////////////
+
 class LLCOFDragAndDropObserver : public LLInventoryAddItemByAssetObserver
 {
 public:
@@ -244,12 +393,17 @@ void LLCOFDragAndDropObserver::done()
 	LLAppearanceMgr::instance().updateAppearanceFromCOF();
 }
 
+///////////////////////////////////////////////////////////////////////////////
+// LLPanelOutfitEdit
+///////////////////////////////////////////////////////////////////////////////
+
 LLPanelOutfitEdit::LLPanelOutfitEdit()
 :	LLPanel(), 
 	mSearchFilter(NULL),
 	mCOFWearables(NULL),
 	mInventoryItemsPanel(NULL),
 	mGearMenu(NULL),
+	mAddWearablesGearMenu(NULL),
 	mCOFDragAndDropObserver(NULL),
 	mInitialized(false),
 	mAddWearablesPanel(NULL),
@@ -284,8 +438,6 @@ LLPanelOutfitEdit::~LLPanelOutfitEdit()
 
 	delete mCOFDragAndDropObserver;
 
-	delete mWearableListViewItemsComparator;
-
 	while (!mListViewItemTypes.empty()) {
 		delete mListViewItemTypes.back();
 		mListViewItemTypes.pop_back();
@@ -391,24 +543,11 @@ BOOL LLPanelOutfitEdit::postBuild()
 
 	childSetAction(REVERT_BTN, boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance()));
 
-	/*
-	 * By default AT_CLOTHING are sorted by (in in MY OUTFITS):
-	 *  - by type (types order determined in LLWearableType::EType)
-	 *  - each LLWearableType::EType by outer layer on top
-	 *
-	 * In Add More panel AT_CLOTHING should be sorted in a such way:
-	 *  - by type (types order determined in LLWearableType::EType)
-	 *  - each LLWearableType::EType by name (EXT-8205)
-	*/
-	mWearableListViewItemsComparator = new LLWearableItemTypeNameComparator();
-	mWearableListViewItemsComparator->setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANK_1, false, true);
-
 	mWearablesListViewPanel = getChild<LLPanel>("filtered_wearables_panel");
-	mWearableItemsList = getChild<LLInventoryItemsList>("list_view");
+	mWearableItemsList = getChild<LLWearableItemsList>("list_view");
 	mWearableItemsList->setCommitOnSelectionChange(true);
 	mWearableItemsList->setCommitCallback(boost::bind(&LLPanelOutfitEdit::updatePlusButton, this));
 	mWearableItemsList->setDoubleClickCallback(boost::bind(&LLPanelOutfitEdit::onPlusBtnClicked, this));
-	mWearableItemsList->setComparator(mWearableListViewItemsComparator);
 
 	mSaveComboBtn.reset(new LLSaveOutfitComboBtn(this));
 	return TRUE;
@@ -462,6 +601,17 @@ void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables)
 
 		showWearablesFilter();
 
+		/*
+		 * By default AT_CLOTHING are sorted by (in in MY OUTFITS):
+		 *  - by type (types order determined in LLWearableType::EType)
+		 *  - each LLWearableType::EType by outer layer on top
+		 *
+		 * In Add More panel AT_CLOTHING should be sorted in a such way:
+		 *  - by type (types order determined in LLWearableType::EType)
+		 *  - each LLWearableType::EType by name (EXT-8205)
+		*/
+		mWearableItemsList->setSortOrder(LLWearableItemsList::E_SORT_BY_TYPE_NAME);
+
 		// Reset mWearableItemsList position to top. See EXT-8180.
 		mWearableItemsList->goToTop();
 	}
@@ -1063,13 +1213,33 @@ void LLPanelOutfitEdit::resetAccordionState()
 
 void LLPanelOutfitEdit::onGearButtonClick(LLUICtrl* clicked_button)
 {
-	if(!mGearMenu)
+	LLMenuGL* menu = NULL;
+
+	if (mAddWearablesPanel->getVisible())
 	{
-		mGearMenu = LLPanelOutfitEditGearMenu::create();
+		if (!mAddWearablesGearMenu)
+		{
+			mAddWearablesGearMenu = LLAddWearablesGearMenu::create(mWearableItemsList, mInventoryItemsPanel);
+		}
+
+		menu = mAddWearablesGearMenu;
+	}
+	else
+	{
+		if (!mGearMenu)
+		{
+			mGearMenu = LLPanelOutfitEditGearMenu::create();
+		}
+
+		menu = mGearMenu;
 	}
 
-	S32 menu_y = mGearMenu->getRect().getHeight() + clicked_button->getRect().getHeight();
-	LLMenuGL::showPopup(clicked_button, mGearMenu, 0, menu_y);
+	if (!menu) return;
+
+	menu->arrangeAndClear(); // update menu height
+	S32 menu_y = menu->getRect().getHeight() + clicked_button->getRect().getHeight();
+	menu->buildDrawLabels();
+	LLMenuGL::showPopup(clicked_button, menu, 0, menu_y);
 }
 
 void LLPanelOutfitEdit::onAddMoreButtonClicked()
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index b3394e45a38..0b6926b83ec 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -43,8 +43,8 @@
 #include "llremoteparcelrequest.h"
 #include "llinventory.h"
 #include "llinventoryfunctions.h"
-#include "llinventoryitemslist.h"
 #include "llinventorymodel.h"
+#include "llwearableitemslist.h"
 
 class LLButton;
 class LLCOFWearables;
@@ -230,9 +230,8 @@ class LLPanelOutfitEdit : public LLPanel
 	LLComboBox*			mListViewFilterCmbBox;
 
 	LLFilteredWearableListManager* 	mWearableListManager;
-	LLInventoryItemsList* 			mWearableItemsList;
+	LLWearableItemsList* 			mWearableItemsList;
 	LLPanel*						mWearablesListViewPanel;
-	LLWearableItemTypeNameComparator* mWearableListViewItemsComparator;
 
 	LLCOFDragAndDropObserver* mCOFDragAndDropObserver;
 
@@ -241,6 +240,7 @@ class LLPanelOutfitEdit : public LLPanel
 
 	LLCOFWearables*		mCOFWearables;
 	LLMenuGL*			mGearMenu;
+	LLMenuGL*			mAddWearablesGearMenu;
 	bool				mInitialized;
 	std::auto_ptr<LLSaveOutfitComboBtn> mSaveComboBtn;
 
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 34f6fbebd62..c9130b56b48 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -583,11 +583,28 @@ bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType
 
 	return const_it->second.mSortWearableTypeByName;
 }
+
+/*virtual*/
+bool LLWearableItemCreationDateComparator::doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const
+{
+	time_t date1 = item1->getCreationDate();
+	time_t date2 = item2->getCreationDate();
+
+	if (date1 == date2)
+	{
+		return LLWearableItemNameComparator::doCompare(item1, item2);
+	}
+
+	return date1 > date2;
+}
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 
-static const LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
+static LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
+static const LLWearableItemTypeNameComparator WEARABLE_TYPE_LAYER_COMPARATOR;
+static const LLWearableItemNameComparator WEARABLE_NAME_COMPARATOR;
+static const LLWearableItemCreationDateComparator WEARABLE_CREATION_DATE_COMPARATOR;
 
 static const LLDefaultChildRegistry::Register<LLWearableItemsList> r("wearable_items_list");
 
@@ -599,7 +616,7 @@ LLWearableItemsList::Params::Params()
 LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p)
 :	LLInventoryItemsList(p)
 {
-	setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
+	setSortOrder(E_SORT_BY_TYPE_LAYER, false);
 	mIsStandalone = p.standalone;
 	if (mIsStandalone)
 	{
@@ -699,6 +716,38 @@ void LLWearableItemsList::onRightClick(S32 x, S32 y)
 	ContextMenu::instance().show(this, selected_uuids, x, y);
 }
 
+void LLWearableItemsList::setSortOrder(ESortOrder sort_order, bool sort_now)
+{
+	switch (sort_order)
+	{
+	case E_SORT_BY_MOST_RECENT:
+		setComparator(&WEARABLE_CREATION_DATE_COMPARATOR);
+		break;
+	case E_SORT_BY_NAME:
+		setComparator(&WEARABLE_NAME_COMPARATOR);
+		break;
+	case E_SORT_BY_TYPE_LAYER:
+		setComparator(&WEARABLE_TYPE_LAYER_COMPARATOR);
+		break;
+	case E_SORT_BY_TYPE_NAME:
+	{
+		WEARABLE_TYPE_NAME_COMPARATOR.setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANK_1, false, true);
+		setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
+		break;
+	}
+
+	// No "default:" to raise compiler warning
+	// if we're not handling something
+	}
+
+	mSortOrder = sort_order;
+
+	if (sort_now)
+	{
+		sort();
+	}
+}
+
 //////////////////////////////////////////////////////////////////////////
 /// ContextMenu
 //////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index 2e720d13bb8..81f1cd1b405 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -379,6 +379,19 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 	wearable_type_order_map_t mWearableOrder;
 };
 
+/**
+ * @class LLWearableItemCreationDateComparator
+ *
+ * Comparator for sorting wearable list items by creation date (newest go first).
+ */
+class LLWearableItemCreationDateComparator : public LLWearableItemNameComparator
+{
+	LOG_CLASS(LLWearableItemCreationDateComparator);
+
+protected:
+	/*virtual*/ bool doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const;
+};
+
 /**
  * @class LLWearableItemsList
  *
@@ -431,6 +444,14 @@ class LLWearableItemsList : public LLInventoryItemsList
 		Params();
 	};
 
+	typedef enum e_sort_order {
+		// Values should be compatible with InventorySortOrder setting.
+		E_SORT_BY_NAME			= 0,
+		E_SORT_BY_MOST_RECENT	= 1,
+		E_SORT_BY_TYPE_LAYER	= 2,
+		E_SORT_BY_TYPE_NAME 	= 3,
+	} ESortOrder;
+
 	virtual ~LLWearableItemsList();
 
 	/*virtual*/ void addNewItem(LLViewerInventoryItem* item, bool rearrange = true);
@@ -445,6 +466,10 @@ class LLWearableItemsList : public LLInventoryItemsList
 
 	bool isStandalone() const { return mIsStandalone; }
 
+	ESortOrder getSortOrder() const { return mSortOrder; }
+
+	void setSortOrder(ESortOrder sort_order, bool sort_now = true);
+
 protected:
 	friend class LLUICtrlFactory;
 	LLWearableItemsList(const LLWearableItemsList::Params& p);
@@ -453,6 +478,8 @@ class LLWearableItemsList : public LLInventoryItemsList
 
 	bool mIsStandalone;
 	bool mWornIndicationEnabled;
+
+	ESortOrder		mSortOrder;
 };
 
 #endif //LL_LLWEARABLEITEMSLIST_H
-- 
GitLab


From 48ccc7ccfbe3e94f9dd78ced588e0a76d03fe070 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Mon, 2 Aug 2010 22:26:49 +0300
Subject: [PATCH 590/683] Fixed build (unit tests linking errors).

--HG--
branch : product-engine
---
 indra/newview/tests/llslurl_test.cpp         | 5 +++++
 indra/newview/tests/llviewernetwork_test.cpp | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp
index 803020dc7a5..4db7efa0902 100644
--- a/indra/newview/tests/llslurl_test.cpp
+++ b/indra/newview/tests/llslurl_test.cpp
@@ -79,6 +79,11 @@ LLSD LLControlGroup::getLLSD(const std::string& name)
 	return LLSD();
 }
 
+LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name)
+{
+	ctrl_name_table_t::iterator iter = mNameTable.find(name);
+	return iter == mNameTable.end() ? LLPointer<LLControlVariable>() : iter->second;
+}
 
 LLControlGroup gSavedSettings("test");
 
diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp
index 5fba5eb69c3..98e4c994b0b 100644
--- a/indra/newview/tests/llviewernetwork_test.cpp
+++ b/indra/newview/tests/llviewernetwork_test.cpp
@@ -79,6 +79,11 @@ LLSD LLControlGroup::getLLSD(const std::string& name)
 	return LLSD();
 }
 
+LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name)
+{
+	ctrl_name_table_t::iterator iter = mNameTable.find(name);
+	return iter == mNameTable.end() ? LLPointer<LLControlVariable>() : iter->second;
+}
 
 LLControlGroup gSavedSettings("test");
 
-- 
GitLab


From 21e8a119cc96b226d7593de16ea7ae990d1da3d9 Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Mon, 2 Aug 2010 14:52:09 -0700
Subject: [PATCH 591/683] EXT-8540 - Implement mime type override for
 web_browser ctrl reviewed by Monroe

---
 indra/newview/llmediactrl.cpp   | 14 ++++++++------
 indra/newview/llmediactrl.h     |  5 ++++-
 indra/newview/llviewermedia.cpp |  3 ++-
 indra/newview/llviewermedia.h   |  3 ++-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 7a4ed74c4c7..d6d128eb297 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -67,7 +67,8 @@ LLMediaCtrl::Params::Params()
 	decouple_texture_size("decouple_texture_size", false),
 	texture_width("texture_width", 1024),
 	texture_height("texture_height", 1024),
-	caret_color("caret_color")
+	caret_color("caret_color"),
+	initial_mime_type("initial_mime_type")
 {
 	tab_stop(false);
 }
@@ -92,7 +93,8 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) :
 	mDecoupleTextureSize ( false ),
 	mTextureWidth ( 1024 ),
 	mTextureHeight ( 1024 ),
-	mClearCache(false)
+	mClearCache(false),
+	mHomePageMimeType(p.initial_mime_type)
 {
 	{
 		LLColor4 color = p.caret_color().get();
@@ -101,7 +103,7 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) :
 
 	setIgnoreUIScale(p.ignore_ui_scale);
 	
-	setHomePageUrl(p.start_url);
+	setHomePageUrl(p.start_url, p.initial_mime_type);
 	
 	setBorderVisible(p.border_visible);
 	
@@ -567,12 +569,12 @@ void LLMediaCtrl::navigateHome()
 
 ////////////////////////////////////////////////////////////////////////////////
 //
-void LLMediaCtrl::setHomePageUrl( const std::string urlIn )
+void LLMediaCtrl::setHomePageUrl( const std::string& urlIn, const std::string& mime_type )
 {
 	mHomePageUrl = urlIn;
 	if (mMediaSource)
 	{
-		mMediaSource->setHomeURL(mHomePageUrl);
+		mMediaSource->setHomeURL(mHomePageUrl, mime_type);
 	}
 }
 
@@ -616,7 +618,7 @@ bool LLMediaCtrl::ensureMediaSourceExists()
 		if ( mMediaSource )
 		{
 			mMediaSource->setUsedInUI(true);
-			mMediaSource->setHomeURL(mHomePageUrl);
+			mMediaSource->setHomeURL(mHomePageUrl, mHomePageMimeType);
 			mMediaSource->setVisible( getVisible() );
 			mMediaSource->addObserver( this );
 			mMediaSource->setBackgroundColor( getBackgroundColor() );
diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h
index 310492fe025..784b266d1f3 100644
--- a/indra/newview/llmediactrl.h
+++ b/indra/newview/llmediactrl.h
@@ -63,6 +63,8 @@ class LLMediaCtrl :
 								texture_height;
 		
 		Optional<LLUIColor>		caret_color;
+
+		Optional<std::string>	initial_mime_type;
 		
 		Params();
 	};
@@ -109,7 +111,7 @@ class LLMediaCtrl :
 		// because we control the page content.  See DEV-9530.  JC.
 		void setTrusted( bool valIn );
 
-		void setHomePageUrl( const std::string urlIn );
+		void setHomePageUrl( const std::string& urlIn, const std::string& mime_type = LLStringUtil::null );
 		std::string getHomePageUrl();
 
 		// set/clear URL to visit when a 404 page is reached
@@ -173,6 +175,7 @@ class LLMediaCtrl :
 		bool mForceUpdate;
 		bool mTrusted;
 		std::string mHomePageUrl;
+		std::string mHomePageMimeType;
 		std::string mCurrentNavUrl;
 		bool mIgnoreUIScale;
 		bool mAlwaysRefresh;
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 99220e288c7..77f7740449c 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -2196,7 +2196,8 @@ void LLViewerMediaImpl::navigateReload()
 //////////////////////////////////////////////////////////////////////////////////////////
 void LLViewerMediaImpl::navigateHome()
 {
-	navigateTo(mHomeURL, "", true, false);
+	bool rediscover_mimetype = mHomeMimeType.empty();
+	navigateTo(mHomeURL, mHomeMimeType, rediscover_mimetype, false);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index f75f24fbf54..01063aae06b 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -237,7 +237,7 @@ class LLViewerMediaImpl
 	std::string getCurrentMediaURL();
 	std::string getHomeURL() { return mHomeURL; }
 	std::string getMediaEntryURL() { return mMediaEntryURL; }
-    void setHomeURL(const std::string& home_url) { mHomeURL = home_url; };
+	void setHomeURL(const std::string& home_url, const std::string& mime_type = LLStringUtil::null) { mHomeURL = home_url; mHomeMimeType = mime_type;};
 	void clearCache();
 	std::string getMimeType() { return mMimeType; }
 	void scaleMouse(S32 *mouse_x, S32 *mouse_y);
@@ -401,6 +401,7 @@ class LLViewerMediaImpl
 	bool  mMovieImageHasMips;
 	std::string mMediaURL;			// The last media url set with NavigateTo
 	std::string mHomeURL;
+	std::string mHomeMimeType;		// forced mime type for home url
 	std::string mMimeType;
 	std::string mCurrentMediaURL;	// The most current media url from the plugin (via the "location changed" or "navigate complete" events).
 	std::string mCurrentMimeType;	// The MIME type that caused the currently loaded plugin to be loaded.
-- 
GitLab


From 0791fd3c227f64116d98260dc5bfaf3424b73bff Mon Sep 17 00:00:00 2001
From: Richard Nelson <none@none>
Date: Mon, 2 Aug 2010 18:54:31 -0700
Subject: [PATCH 592/683] EXT-8545 FIX  Button art and other images are
 positioned incorrectly when UI scale != 1.0

---
 indra/llui/llui.cpp | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index ee308f575a4..5d8b6287761 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -477,8 +477,8 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
 	}
 
 	// add in offset of current image to current ui translation
-	const LLVector3 ui_translation = gGL.getUITranslation() + LLVector3(x, y, 0.f);
 	const LLVector3 ui_scale = gGL.getUIScale();
+	const LLVector3 ui_translation = (gGL.getUITranslation() + LLVector3(x, y, 0.f)).scaledVec(ui_scale);
 
 	F32 uv_width = uv_outer_rect.getWidth();
 	F32 uv_height = uv_outer_rect.getHeight();
@@ -514,8 +514,8 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
 		F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio);
 
 		draw_center_rect.mLeft = llround(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * shrink_scale * ui_scale.mV[VX]);
-		draw_center_rect.mTop = llround(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale * ui_scale.mV[VY]));
-		draw_center_rect.mRight = llround(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale * ui_scale.mV[VX]));
+		draw_center_rect.mTop = llround(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale) * ui_scale.mV[VY]);
+		draw_center_rect.mRight = llround(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale) * ui_scale.mV[VX]);
 		draw_center_rect.mBottom = llround(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * shrink_scale * ui_scale.mV[VY]);
 	}
 
@@ -735,17 +735,21 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 
 		gGL.begin(LLRender::QUADS);
 		{
+			LLVector3 ui_scale = gGL.getUIScale();
 			LLVector3 ui_translation = gGL.getUITranslation();
 			ui_translation.mV[VX] += x;
 			ui_translation.mV[VY] += y;
+			ui_translation.scaleVec(ui_scale);
 			S32 index = 0;
+			S32 scaled_width = llround(width * ui_scale.mV[VX]);
+			S32 scaled_height = llround(height * ui_scale.mV[VY]);
 
 			uv[index] = LLVector2(uv_rect.mRight, uv_rect.mTop);
-			pos[index] = LLVector3(ui_translation.mV[VX] + width, ui_translation.mV[VY] + height, 0.f);
+			pos[index] = LLVector3(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY] + scaled_height, 0.f);
 			index++;
 
 			uv[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop);
-			pos[index] = LLVector3(ui_translation.mV[VX], ui_translation.mV[VY] + height, 0.f);
+			pos[index] = LLVector3(ui_translation.mV[VX], ui_translation.mV[VY] + scaled_height, 0.f);
 			index++;
 
 			uv[index] = LLVector2(uv_rect.mLeft, uv_rect.mBottom);
@@ -753,7 +757,7 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 			index++;
 
 			uv[index] = LLVector2(uv_rect.mRight, uv_rect.mBottom);
-			pos[index] = LLVector3(ui_translation.mV[VX] + width, ui_translation.mV[VY], 0.f);
+			pos[index] = LLVector3(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY], 0.f);
 			index++;
 
 			gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES);
-- 
GitLab


From 3212634ba81749e5dec0055ad9f6f8bdbd1407df Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 3 Aug 2010 12:13:50 -0700
Subject: [PATCH 593/683] fix for unit test asserts

---
 indra/newview/llmediadataclient.cpp | 30 +++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp
index 1de9d1c9b0e..ec185bc7905 100755
--- a/indra/newview/llmediadataclient.cpp
+++ b/indra/newview/llmediadataclient.cpp
@@ -265,13 +265,16 @@ void LLMediaDataClient::trackRequest(request_ptr_t request)
 {
 	request_set_t::iterator iter = mUnQueuedRequests.lower_bound(request);
 	
-	if(*iter == request)
+	if (iter != mUnQueuedRequests.end())
 	{
-		LL_WARNS("LLMediaDataClient") << "Tracking already tracked request: " << *request << LL_ENDL;
-	}
-	else
-	{
-		mUnQueuedRequests.insert(iter, request);
+		if(*iter == request)
+		{
+			LL_WARNS("LLMediaDataClient") << "Tracking already tracked request: " << *request << LL_ENDL;
+		}
+		else
+		{
+			mUnQueuedRequests.insert(iter, request);
+		}
 	}
 }
 
@@ -279,13 +282,16 @@ void LLMediaDataClient::stopTrackingRequest(request_ptr_t request)
 {
 	request_set_t::iterator iter = mUnQueuedRequests.find(request);
 	
-	if(*iter == request)
+	if (iter != mUnQueuedRequests.end())
 	{
-		mUnQueuedRequests.erase(iter);
-	}
-	else
-	{
-		LL_WARNS("LLMediaDataClient") << "Removing an untracked request: " << *request << LL_ENDL;
+		if(*iter == request)
+		{
+			mUnQueuedRequests.erase(iter);
+		}
+		else
+		{
+			LL_WARNS("LLMediaDataClient") << "Removing an untracked request: " << *request << LL_ENDL;
+		}
 	}
 }
 
-- 
GitLab


From 7e576a6a66ce0eabf5624c8b2d8d1fa9da1657b8 Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Tue, 3 Aug 2010 14:59:14 -0700
Subject: [PATCH 594/683] CT-575 WIP DE JA ES translation for set16 for Viewer
 2.1.1

---
 indra/newview/skins/default/xui/de/floater_preview_gesture.xml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/de/floater_preview_gesture.xml b/indra/newview/skins/default/xui/de/floater_preview_gesture.xml
index 6d3635fa8dc..c3c017ae973 100644
--- a/indra/newview/skins/default/xui/de/floater_preview_gesture.xml
+++ b/indra/newview/skins/default/xui/de/floater_preview_gesture.xml
@@ -64,7 +64,6 @@
 	</radio_group>
 	<check_box label="bis alle Animationen beendet sind" name="wait_anim_check"/>
 	<check_box label="Zeit in Sekunden:" name="wait_time_check"/>
-	<line_editor name="wait_time_editor"/>
 	<text name="help_label">
 		Alle Schritte werden gleichzeitig ausgeführt, wenn keine Pausen hinzugefügt wurden.
 	</text>
-- 
GitLab


From d3f6135dce4b6c9a2e5fa8561718a2e6cb6cf5b1 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 3 Aug 2010 18:26:47 -0600
Subject: [PATCH 595/683] fix for EXT-7399: 2.0.2 with http textures loads
 textures slower than 1.23.5 and     EXT-7397: decoding textures get stuck in
 REQ status

---
 indra/newview/lltexturefetch.cpp | 46 +++++++++-----------------------
 indra/newview/lltexturefetch.h   |  1 -
 2 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 846cba4a3bd..63bcdcda2dc 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -855,9 +855,9 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			// but probably not for Textures.
 			// Set the throttle to the entire bandwidth, assuming UDP packets will get priority
 			// when they are needed
-			//F32 max_bandwidth = mFetcher->mMaxBandwidth;
-			if (mFetcher->isHTTPThrottled(mDesiredSize))// ||
-				//mFetcher->getTextureBandwidth() > max_bandwidth)
+			F32 max_bandwidth = mFetcher->mMaxBandwidth;
+			if (mFetcher->isHTTPThrottled(mDesiredSize) ||
+				mFetcher->getTextureBandwidth() > max_bandwidth)
 			{
 				// Make normal priority and return (i.e. wait until there is room in the queue)
 				setPriority(LLWorkerThread::PRIORITY_NORMAL | mWorkPriority);
@@ -872,17 +872,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				cur_size = mFormattedImage->getDataSize(); // amount of data we already have
 				if (mFormattedImage->getDiscardLevel() == 0)
 				{
-					if(cur_size > 0)
-					{
-						// We already have all the data, just decode it
-						mLoadedDiscard = mFormattedImage->getDiscardLevel();
-						mState = DECODE_IMAGE;
-						return false;
-					}
-					else
-					{
-						return true ; //abort.
-					}
+					// We already have all the data, just decode it
+					mLoadedDiscard = mFormattedImage->getDiscardLevel();
+					mState = DECODE_IMAGE;
+					return false;
 				}
 			}
 			mRequestedSize = mDesiredSize;
@@ -899,7 +892,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				mGetReason.clear();
 				LL_DEBUGS("Texture") << "HTTP GET: " << mID << " Offset: " << offset
 									 << " Bytes: " << mRequestedSize
-									 << " Bandwidth(kbps): " << mFetcher->getTextureBandwidth() << "/" << mFetcher->mMaxBandwidth
+									 << " Bandwidth(kbps): " << mFetcher->getTextureBandwidth() << "/" << max_bandwidth
 									 << LL_ENDL;
 				setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
 				mState = WAIT_HTTP_REQ;	
@@ -989,17 +982,6 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				}
 			}
 			
-			llassert_always(mBufferSize == cur_size + mRequestedSize);
-			if(!mBufferSize)//no data received.
-			{
-				delete[] mBuffer; 
-				mBuffer = NULL;
-
-				//abort.
-				mState = DONE;
-				return true;
-			}
-
 			if (mFormattedImage.isNull())
 			{
 				// For now, create formatted image based on extension
@@ -1010,7 +992,8 @@ bool LLTextureFetchWorker::doWork(S32 param)
 					mFormattedImage = new LLImageJ2C; // default
 				}
 			}
-						
+			
+			llassert_always(mBufferSize == cur_size + mRequestedSize);
 			if (mHaveAllData && mRequestedDiscard == 0) //the image file is fully loaded.
 			{
 				mFileSize = mBufferSize;
@@ -1069,12 +1052,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 		
 		if (mFormattedImage->getDataSize() <= 0)
 		{
-			//llerrs << "Decode entered with invalid mFormattedImage. ID = " << mID << llendl;
-			
-			//abort, don't decode
-			mState = DONE;
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			return true;
+			llerrs << "Decode entered with invalid mFormattedImage. ID = " << mID << llendl;
 		}
 		if (mLoadedDiscard < 0)
 		{
@@ -1729,7 +1707,7 @@ bool LLTextureFetch::isHTTPThrottled(S32 requested_size)
 
 	if(mHTTPTextureQueue.size() >= MAX_HTTP_QUEUE_SIZE)//if the http queue is full.
 	{
-		if(!mHTTPThrottleFlag[type + 1])
+		if(!mHTTPThrottleFlag[TOTAL_TEXTURE_TYPES - 1])
 		{
 			for(S32 i = type + 1 ; i < TOTAL_TEXTURE_TYPES; i++) //block all requests with fetching size larger than this request.		
 			{
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index c31c38b04a5..bae2ceff723 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -141,7 +141,6 @@ class LLTextureFetch : public LLWorkerThread
 		SMALL_TEXTURE = 0 , //size <= 64 * 64
 		MEDIUM_TEXTURE,     //size <= 256 * 256
 		LARGE_TEXTURE,      //size > 256 * 256
-		DUMMY,
 		TOTAL_TEXTURE_TYPES
 	};
 	BOOL mHTTPThrottleFlag[TOTAL_TEXTURE_TYPES];
-- 
GitLab


From 26ef92c7fb6c6bccccb498dcf13af37d0f37b769 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Wed, 4 Aug 2010 11:45:47 +0300
Subject: [PATCH 596/683] EXT-8424 FIXED ([HARD CODED] ALL LANGS: \"More\" menu
 option is untranslated under Advanced menu (French viewer) > Shortcuts)

Set translated label from strings.xml

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/831/

--HG--
branch : product-engine
---
 indra/llui/llmenugl.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 12007f7b52c..46a7215707a 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -58,6 +58,7 @@
 #include "llbutton.h"
 #include "llfontgl.h"
 #include "llresmgr.h"
+#include "lltrans.h"
 #include "llui.h"
 
 #include "llstl.h"
@@ -2272,8 +2273,9 @@ void LLMenuGL::createSpilloverBranch()
 		// technically, you can't tear off spillover menus, but we're passing the handle
 		// along just to be safe
 		LLMenuGL::Params p;
+		std::string label = LLTrans::getString("More");
 		p.name("More");
-		p.label("More"); // *TODO: Translate
+		p.label(label);
 		p.bg_color(mBackgroundColor);
 		p.bg_visible(true);
 		p.can_tear_off(false);
@@ -2282,7 +2284,7 @@ void LLMenuGL::createSpilloverBranch()
 
 		LLMenuItemBranchGL::Params branch_params;
 		branch_params.name = "More";
-		branch_params.label = "More"; // *TODO: Translate
+		branch_params.label = label;
 		branch_params.branch = mSpilloverMenu;
 		branch_params.font.style = "italic";
 
-- 
GitLab


From dc1b42e31fe2ff9f7d20fdace7f74bb451918c5d Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Fri, 6 Aug 2010 16:00:03 +0300
Subject: [PATCH 597/683] EXT-8539 FIXED Fixed title of alpha mask not save if
 renaming it from 'Editing' panel.

Bug happened because name change was not explicitly  listed as sufficient reason to save a wearable. So saving failed for alpha masks with only names changed.
Other wearables didn't have this problem because they passed precondition even if only name was changed thanking to checks that included visualparams.

- Made name change explicitly a sufficient reason to proceed with saving a wearable.

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/840/

--HG--
branch : product-engine
---
 indra/newview/llagentwearables.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 6ee5a8b279e..6e3e54df2c0 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -388,7 +388,9 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32
 									const std::string new_name)
 {
 	LLWearable* old_wearable = getWearable(type, index);
-	if (old_wearable && (old_wearable->isDirty() || old_wearable->isOldVersion()))
+	if(!old_wearable) return;
+	bool name_changed = !new_name.empty() && (new_name != old_wearable->getName());
+	if (name_changed || old_wearable->isDirty() || old_wearable->isOldVersion())
 	{
 		LLUUID old_item_id = old_wearable->getItemID();
 		LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable);
@@ -404,12 +406,10 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32
 		if (item)
 		{
 			std::string item_name = item->getName();
-			bool name_changed = false;
-			if (!new_name.empty() && (new_name != item->getName()))
+			if (name_changed)
 			{
 				llinfos << "saveWearable changing name from "  << item->getName() << " to " << new_name << llendl;
 				item_name = new_name;
-				name_changed = true;
 			}
 			// Update existing inventory item
 			LLPointer<LLViewerInventoryItem> template_item =
-- 
GitLab


From 593a6f0bbf25877f7e3b7482d8644cf34840f923 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Fri, 6 Aug 2010 18:50:24 +0300
Subject: [PATCH 598/683] EXT-8207 FIXED (Unexpected camera zoom occures if
 scroll location history drop-down list by mouse wheel)

Added parameter for scroll list control that determines opaque of mouse scroll wheel event. Set this parameter to \"true\" in combobox of navigation panel.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/829/

--HG--
branch : product-engine
---
 indra/llui/llscrolllistctrl.cpp                           | 8 ++++++++
 indra/llui/llscrolllistctrl.h                             | 4 +++-
 .../newview/skins/default/xui/en/panel_navigation_bar.xml | 2 ++
 .../newview/skins/default/xui/en/widgets/scroll_list.xml  | 1 +
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index d4d161f2c99..bb43c19c2c2 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -135,6 +135,7 @@ LLScrollListCtrl::Params::Params()
 	search_column("search_column", 0),
 	sort_column("sort_column", -1),
 	sort_ascending("sort_ascending", true),
+	mouse_wheel_opaque("mouse_wheel_opaque", false),
 	commit_on_keyboard_movement("commit_on_keyboard_movement", true),
 	heading_height("heading_height"),
 	page_lines("page_lines", 0),
@@ -163,6 +164,7 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p)
 :	LLUICtrl(p),
 	mLineHeight(0),
 	mScrollLines(0),
+	mMouseWheelOpaque(p.mouse_wheel_opaque),
 	mPageLines(p.page_lines),
 	mMaxSelectable(0),
 	mAllowKeyboardMovement(TRUE),
@@ -1536,6 +1538,12 @@ BOOL LLScrollListCtrl::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	BOOL handled = FALSE;
 	// Pretend the mouse is over the scrollbar
 	handled = mScrollbar->handleScrollWheel( 0, 0, clicks );
+
+	if (mMouseWheelOpaque)
+	{
+		return TRUE;
+	}
+
 	return handled;
 }
 
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 1f0ef585dba..19cb7e2bfe3 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -102,7 +102,8 @@ class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler,
 	{
 		// behavioral flags
 		Optional<bool>	multi_select,
-						commit_on_keyboard_movement;
+						commit_on_keyboard_movement,
+						mouse_wheel_opaque;
 
 		// display flags
 		Optional<bool>	has_border,
@@ -449,6 +450,7 @@ class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler,
 	BOOL			mCommitOnSelectionChange;
 	BOOL			mSelectionChanged;
 	BOOL			mNeedsScroll;
+	BOOL			mMouseWheelOpaque;
 	BOOL			mCanSelect;
 	const BOOL		mDisplayColumnHeaders;
 	BOOL			mColumnsDirty;
diff --git a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
index 2c9d7e4b6a5..082d51ed3cc 100644
--- a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
@@ -97,6 +97,8 @@
 	     name="location_combo"
 	     top_delta="0"
 	     width="266">
+         <combo_list
+         mouse_wheel_opaque="true"/>
 	     <!-- *TODO: Delete.  Let the location_input use the correct art sizes.
 	        <location_input.add_landmark_button
 	         height="18"
diff --git a/indra/newview/skins/default/xui/en/widgets/scroll_list.xml b/indra/newview/skins/default/xui/en/widgets/scroll_list.xml
index 63166f32b7f..66167f5fadb 100644
--- a/indra/newview/skins/default/xui/en/widgets/scroll_list.xml
+++ b/indra/newview/skins/default/xui/en/widgets/scroll_list.xml
@@ -12,6 +12,7 @@
              draw_stripes="true"
              scroll_bar_bg_visible="false"
              scroll_bar_bg_color="black"
+             scroll_wheel_opaque="false"
              background_visible="true"
              heading_height="23"
              draw_border="false"
-- 
GitLab


From 5f9f6dcdec0de015e3c9a88afad6f4761c3c6527 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Fri, 6 Aug 2010 17:14:01 +0300
Subject: [PATCH 599/683] EXT-8577 WIP Context menu items for
 multi-attachments.

Done:
- 1. Dropped the obsolete "MultipleAttachments" setting.
- 2. Added an "Add" item to the following attachment-related context menus:
     * My Appearance (ex-My Outfits) context menu.
     * Edit Outfit -> Add More context menu.
     * Object in-world context menu.
     * Inventory context menu.
     * Object inspector gear menu.
- 3. Modified "Attach To / Attach To HUD" to perform the "add" instead of "replace" action.

TODO:
- Ability to attach multiple objects at once from the Add More panel (bulk attach).
- Make sure there's no memleak when you click Wear/Attach in the in-world object context menu
  and the callback isn't invoked (because e.g. avatar fails to get close enough to the object).

Issues:

0. I'm not sure whether LLAgentWearables::userAttachMultipleAttachments()
   should replace attachments or add them. Assumed the former.

1. I couldn't verify that adding objects from the object inspector menu works
   because I either could wear an object or see its inspector, not both.

2. > 1. Right-click on an object in your inventory and select "Wear".
   > VERIFY: Attaches the object and replaces whatever's there; asks for
   > confirmation before replacing an existing object.
   I think this is impossible to implement because we don't know in advance
   what point the object will be attached to, so we can't display a confirmation dialog.

Reviewed by Seraph at https://codereview.productengine.com/secondlife/r/843/

--HG--
branch : product-engine
---
 indra/newview/app_settings/settings.xml       | 11 ------
 indra/newview/llagentwearables.cpp            |  5 +--
 indra/newview/llappearancemgr.cpp             |  2 +-
 indra/newview/llinventorybridge.cpp           | 19 +++++++---
 indra/newview/llinventorybridge.h             |  3 +-
 indra/newview/llselectmgr.cpp                 |  9 +++--
 indra/newview/llselectmgr.h                   |  2 +-
 indra/newview/llviewerattachmenu.cpp          |  2 +-
 indra/newview/llviewermenu.cpp                | 36 +++++++++++++++----
 indra/newview/llwearableitemslist.cpp         | 18 ++++++++--
 .../xui/en/menu_inspect_object_gear.xml       |  9 +++++
 .../skins/default/xui/en/menu_object.xml      |  9 +++++
 .../xui/en/menu_wearable_list_item.xml        |  2 +-
 13 files changed, 89 insertions(+), 38 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index bbf3f4fc75a..4c52fb015fd 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -5373,17 +5373,6 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>MultipleAttachments</key>
-    <map>
-      <key>Comment</key>
-      <string>Allow multiple objects to be attached to a single attachment point.</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
    <key>MuteAmbient</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 6e3e54df2c0..337878cf96d 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -1885,10 +1885,7 @@ void LLAgentWearables::userAttachMultipleAttachments(LLInventoryModel::item_arra
 		msg->nextBlockFast(_PREHASH_ObjectData );
 		msg->addUUIDFast(_PREHASH_ItemID, item->getLinkedUUID());
 		msg->addUUIDFast(_PREHASH_OwnerID, item->getPermissions().getOwner());
-		if (gSavedSettings.getBOOL("MultipleAttachments"))
-			msg->addU8Fast(_PREHASH_AttachmentPt, 0 | ATTACHMENT_ADD );
-		else
-			msg->addU8Fast(_PREHASH_AttachmentPt, 0 );	// Wear at the previous or default attachment point
+		msg->addU8Fast(_PREHASH_AttachmentPt, 0 );	// Wear at the previous or default attachment point
 		pack_permissions_slam(msg, item->getFlags(), item->getPermissions());
 		msg->addStringFast(_PREHASH_Name, item->getName());
 		msg->addStringFast(_PREHASH_Description, item->getDescription());
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 296a580106c..cecb2ee6ad6 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1012,7 +1012,7 @@ bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, bool do_up
 		addCOFItemLink(item_to_wear, do_update, cb);
 		break;
 	case LLAssetType::AT_OBJECT:
-		rez_attachment(item_to_wear, NULL);
+		rez_attachment(item_to_wear, NULL, replace);
 		break;
 	default: return false;;
 	}
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 38f3521b2da..7e710ce8e1d 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3936,7 +3936,7 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 		item = (LLViewerInventoryItem*)gInventory.getItem(object_id);
 		if(item && gInventory.isObjectDescendentOf(object_id, gInventory.getRootFolderID()))
 		{
-			rez_attachment(item, NULL);
+			rez_attachment(item, NULL, true); // Replace if "Wear"ing.
 		}
 		else if(item && item->isFinished())
 		{
@@ -3952,6 +3952,10 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 		}
 		gFocusMgr.setKeyboardFocus(NULL);
 	}
+	else if ("wear_add" == action)
+	{
+		LLAppearanceMgr::instance().wearItemOnAvatar(mUUID, true, false); // Don't replace if adding.
+	}
 	else if (isRemoveAction(action))
 	{
 		LLInventoryItem* item = gInventory.getItem(mUUID);
@@ -3998,7 +4002,7 @@ std::string LLObjectBridge::getLabelSuffix() const
 	}
 }
 
-void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment)
+void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment, bool replace)
 {
 	LLSD payload;
 	payload["item_id"] = item->getLinkedUUID(); // Wear the base object in case this is a link.
@@ -4017,9 +4021,14 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach
 		}
 	}
 
+	if (!replace)
+	{
+		attach_pt |= ATTACHMENT_ADD;
+	}
+
 	payload["attachment_point"] = attach_pt;
 
-	if (!gSavedSettings.getBOOL("MultipleAttachments") &&
+	if (replace &&
 		(attachment && attachment->getNumObjects() > 0))
 	{
 		LLNotificationsUtil::add("ReplaceAttachment", LLSD(), payload, confirm_replace_attachment_rez);
@@ -4048,8 +4057,6 @@ bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& respon
 		if (itemp)
 		{
 			U8 attachment_pt = notification["payload"]["attachment_point"].asInteger();
-			if (gSavedSettings.getBOOL("MultipleAttachments"))
-				attachment_pt |= ATTACHMENT_ADD;
 
 			LLMessageSystem* msg = gMessageSystem;
 			msg->newMessageFast(_PREHASH_RezSingleAttachmentFromInv);
@@ -4106,6 +4113,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 			{
 				items.push_back(std::string("Wearable And Object Separator"));
 				items.push_back(std::string("Wearable And Object Wear"));
+				items.push_back(std::string("Wearable Add"));
 				items.push_back(std::string("Attach To"));
 				items.push_back(std::string("Attach To HUD"));
 				// commented out for DEV-32347
@@ -4114,6 +4122,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 				if (!gAgentAvatarp->canAttachMoreObjects())
 				{
 					disabled_items.push_back(std::string("Wearable And Object Wear"));
+					disabled_items.push_back(std::string("Wearable Add"));
 					disabled_items.push_back(std::string("Attach To"));
 					disabled_items.push_back(std::string("Attach To HUD"));
 				}
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index 91055eb9060..00e8b0fb086 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -594,7 +594,8 @@ class LLRecentInventoryBridgeBuilder : public LLInventoryFVBridgeBuilder
 };
 
 void rez_attachment(LLViewerInventoryItem* item, 
-					LLViewerJointAttachment* attachment);
+					LLViewerJointAttachment* attachment,
+					bool replace = false);
 
 // Move items from an in-world object's "Contents" folder to a specified
 // folder in agent inventory.
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 050b87bbe0f..21f8485e90b 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3615,7 +3615,7 @@ void LLSelectMgr::selectionSetObjectSaleInfo(const LLSaleInfo& sale_info)
 // Attachments
 //----------------------------------------------------------------------
 
-void LLSelectMgr::sendAttach(U8 attachment_point)
+void LLSelectMgr::sendAttach(U8 attachment_point, bool replace)
 {
 	LLViewerObject* attach_object = mSelectedObjects->getFirstRootObject();
 
@@ -3629,9 +3629,12 @@ void LLSelectMgr::sendAttach(U8 attachment_point)
 	if (0 == attachment_point ||
 		get_if_there(gAgentAvatarp->mAttachmentPoints, (S32)attachment_point, (LLViewerJointAttachment*)NULL))
 	{
-
-		if (gSavedSettings.getBOOL("MultipleAttachments"))
+		if (!replace || attachment_point != 0)
+		{
+			// If we know the attachment point then we got here by clicking an
+			// "Attach to..." context menu item, so we should add, not replace.
 			attachment_point |= ATTACHMENT_ADD;
+		}
 
 		sendListToRegions(
 			"ObjectAttach",
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 668c04cf159..4c64c77b839 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -612,7 +612,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	// verification only, if it doesn't match region info then sale is
 	// canceled
 	void sendBuy(const LLUUID& buyer_id, const LLUUID& category_id, const LLSaleInfo sale_info);
-	void sendAttach(U8 attachment_point);
+	void sendAttach(U8 attachment_point, bool replace);
 	void sendDetach();
 	void sendDropAttachment();
 	void sendLink();
diff --git a/indra/newview/llviewerattachmenu.cpp b/indra/newview/llviewerattachmenu.cpp
index f683bd8674d..5b3c4ea7732 100644
--- a/indra/newview/llviewerattachmenu.cpp
+++ b/indra/newview/llviewerattachmenu.cpp
@@ -122,7 +122,7 @@ void LLViewerAttachMenu::attachObjects(const uuid_vec_t& items, const std::strin
 		LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getLinkedItem(id);
 		if(item && gInventory.isObjectDescendentOf(id, gInventory.getRootFolderID()))
 		{
-			rez_attachment(item, attachmentp);
+			rez_attachment(item, attachmentp); // don't replace if called from an "Attach To..." menu
 		}
 		else if(item && item->isFinished())
 		{
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index a83980dc23e..92195f0a4da 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -5852,6 +5852,7 @@ void handle_buy_land()
 class LLObjectAttachToAvatar : public view_listener_t
 {
 public:
+	LLObjectAttachToAvatar(bool replace) : mReplace(replace) {}
 	static void setObjectSelection(LLObjectSelectionHandle selection) { sObjectSelection = selection; }
 
 private:
@@ -5865,22 +5866,38 @@ class LLObjectAttachToAvatar : public view_listener_t
 			LLViewerJointAttachment* attachment_point = NULL;
 			if (index > 0)
 				attachment_point = get_if_there(gAgentAvatarp->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL);
-			confirm_replace_attachment(0, attachment_point);
+			confirmReplaceAttachment(0, attachment_point);
 		}
 		return true;
 	}
 
+	static void onNearAttachObject(BOOL success, void *user_data);
+	void confirmReplaceAttachment(S32 option, LLViewerJointAttachment* attachment_point);
+
+	struct CallbackData
+	{
+		CallbackData(LLViewerJointAttachment* point, bool replace) : mAttachmentPoint(point), mReplace(replace) {}
+
+		LLViewerJointAttachment*	mAttachmentPoint;
+		bool						mReplace;
+	};
+
 protected:
 	static LLObjectSelectionHandle sObjectSelection;
+	bool mReplace;
 };
 
 LLObjectSelectionHandle LLObjectAttachToAvatar::sObjectSelection;
 
-void near_attach_object(BOOL success, void *user_data)
+// static
+void LLObjectAttachToAvatar::onNearAttachObject(BOOL success, void *user_data)
 {
+	if (!user_data) return;
+	CallbackData* cb_data = static_cast<CallbackData*>(user_data);
+
 	if (success)
 	{
-		const LLViewerJointAttachment *attachment = (LLViewerJointAttachment *)user_data;
+		const LLViewerJointAttachment *attachment = cb_data->mAttachmentPoint;
 		
 		U8 attachment_id = 0;
 		if (attachment)
@@ -5900,12 +5917,15 @@ void near_attach_object(BOOL success, void *user_data)
 			// interpret 0 as "default location"
 			attachment_id = 0;
 		}
-		LLSelectMgr::getInstance()->sendAttach(attachment_id);
+		LLSelectMgr::getInstance()->sendAttach(attachment_id, cb_data->mReplace);
 	}		
 	LLObjectAttachToAvatar::setObjectSelection(NULL);
+
+	delete cb_data;
 }
 
-void confirm_replace_attachment(S32 option, void* user_data)
+// static
+void LLObjectAttachToAvatar::confirmReplaceAttachment(S32 option, LLViewerJointAttachment* attachment_point)
 {
 	if (option == 0/*YES*/)
 	{
@@ -5930,7 +5950,8 @@ void confirm_replace_attachment(S32 option, void* user_data)
 			delta = delta * 0.5f;
 			walkToSpot -= delta;
 
-			gAgent.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(walkToSpot), "Attach", NULL, near_attach_object, user_data, stop_distance);
+			CallbackData* user_data = new CallbackData(attachment_point, mReplace); // *TODO: leak if the callback isn't called?
+			gAgent.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(walkToSpot), "Attach", NULL, onNearAttachObject, user_data, stop_distance);
 			gAgentCamera.clearFocusObject();
 		}
 	}
@@ -8115,7 +8136,8 @@ void initialize_menus()
 	commit.add("Object.Touch", boost::bind(&handle_object_touch));
 	commit.add("Object.SitOrStand", boost::bind(&handle_object_sit_or_stand));
 	commit.add("Object.Delete", boost::bind(&handle_object_delete));
-	view_listener_t::addMenu(new LLObjectAttachToAvatar(), "Object.AttachToAvatar");
+	view_listener_t::addMenu(new LLObjectAttachToAvatar(true), "Object.AttachToAvatar");
+	view_listener_t::addMenu(new LLObjectAttachToAvatar(false), "Object.AttachAddToAvatar");
 	view_listener_t::addMenu(new LLObjectReturn(), "Object.Return");
 	view_listener_t::addMenu(new LLObjectReportAbuse(), "Object.ReportAbuse");
 	view_listener_t::addMenu(new LLObjectMute(), "Object.Mute");
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index c9130b56b48..194213f880e 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -863,12 +863,13 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 	} // for
 
 	bool standalone = mParent ? mParent->isStandalone() : false;
+	bool wear_add_visible = mask & (MASK_CLOTHING|MASK_ATTACHMENT) && n_worn == 0 && can_be_worn && (n_already_worn != 0 || mask & MASK_ATTACHMENT);
 
 	// *TODO: eliminate multiple traversals over the menu items
 	setMenuItemVisible(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0 && can_be_worn);
 	setMenuItemEnabled(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0);
-	setMenuItemVisible(menu, "wear_add",			mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0 && can_be_worn);
-	setMenuItemEnabled(menu, "wear_add",			n_items == 1 && canAddWearable(ids.front()) && n_already_worn != 0);
+	setMenuItemVisible(menu, "wear_add",			wear_add_visible);
+	setMenuItemEnabled(menu, "wear_add",			n_items == 1 && canAddWearable(ids.front()));
 	setMenuItemVisible(menu, "wear_replace",		n_worn == 0 && n_already_worn != 0 && can_be_worn);
 	//visible only when one item selected and this item is worn
 	setMenuItemVisible(menu, "edit",				!standalone && mask & (MASK_CLOTHING|MASK_BODYPART) && n_worn == n_items && n_worn == 1);
@@ -984,7 +985,18 @@ bool LLWearableItemsList::ContextMenu::canAddWearable(const LLUUID& item_id)
 	// TODO: investigate wearables may not be loaded at this point EXT-8231
 
 	LLViewerInventoryItem* item = gInventory.getItem(item_id);
-	if (!item || item->getType() != LLAssetType::AT_CLOTHING)
+	if (!item)
+	{
+		return false;
+	}
+
+	if (item->getType() == LLAssetType::AT_OBJECT)
+	{
+		// *TODO: is this the right check?
+		return isAgentAvatarValid() && gAgentAvatarp->canAttachMoreObjects();
+	}
+
+	if (item->getType() != LLAssetType::AT_CLOTHING)
 	{
 		return false;
 	}
diff --git a/indra/newview/skins/default/xui/en/menu_inspect_object_gear.xml b/indra/newview/skins/default/xui/en/menu_inspect_object_gear.xml
index 8ec76898196..76f68c6d4ba 100644
--- a/indra/newview/skins/default/xui/en/menu_inspect_object_gear.xml
+++ b/indra/newview/skins/default/xui/en/menu_inspect_object_gear.xml
@@ -88,6 +88,15 @@
     <menu_item_call.on_visible
      function="Object.EnableWear" />
   </menu_item_call>  
+  <menu_item_call
+   label="Add"
+   layout="topleft"
+   name="add">
+    <menu_item_call.on_click
+     function="Object.AttachAddToAvatar" />
+    <menu_item_call.on_visible
+     function="Object.EnableWear" />
+  </menu_item_call>
   <menu_item_call
    label="Report"
    layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/menu_object.xml b/indra/newview/skins/default/xui/en/menu_object.xml
index b6cc222e968..31f70d99caa 100644
--- a/indra/newview/skins/default/xui/en/menu_object.xml
+++ b/indra/newview/skins/default/xui/en/menu_object.xml
@@ -83,6 +83,15 @@
             <menu_item_call.on_enable
              function="Object.EnableWear" />
    </menu_item_call>
+   <menu_item_call
+      enabled="false"
+      label="Add"
+      name="Add">
+            <menu_item_call.on_click
+             function="Object.AttachAddToAvatar" />
+            <menu_item_call.on_enable
+             function="Object.EnableWear" />
+   </menu_item_call>
    <context_menu
          label="Attach  â–¶"
          name="Object Attach" />
diff --git a/indra/newview/skins/default/xui/en/menu_wearable_list_item.xml b/indra/newview/skins/default/xui/en/menu_wearable_list_item.xml
index 8af2e1eaca4..5feac53c336 100644
--- a/indra/newview/skins/default/xui/en/menu_wearable_list_item.xml
+++ b/indra/newview/skins/default/xui/en/menu_wearable_list_item.xml
@@ -13,7 +13,7 @@
      layout="topleft"
      name="wear_wear">
         <on_click
-         function="Wearable.Add" />
+         function="Wearable.Wear" />
     </menu_item_call>
     <menu_item_call
      label="Add"
-- 
GitLab


From 9a247000e475e401394ee5f2d30d159625242985 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Fri, 6 Aug 2010 20:25:57 +0300
Subject: [PATCH 600/683] Fixed erroneously unrenamed parameter name

--HG--
branch : product-engine
---
 indra/newview/skins/default/xui/en/widgets/scroll_list.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/widgets/scroll_list.xml b/indra/newview/skins/default/xui/en/widgets/scroll_list.xml
index 66167f5fadb..dd936758079 100644
--- a/indra/newview/skins/default/xui/en/widgets/scroll_list.xml
+++ b/indra/newview/skins/default/xui/en/widgets/scroll_list.xml
@@ -12,7 +12,7 @@
              draw_stripes="true"
              scroll_bar_bg_visible="false"
              scroll_bar_bg_color="black"
-             scroll_wheel_opaque="false"
+             mouse_wheel_opaque="false"
              background_visible="true"
              heading_height="23"
              draw_border="false"
-- 
GitLab


From ea5f5f0af7c299837343f4612142fbef7aeb3687 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Wed, 4 Aug 2010 19:34:55 +0300
Subject: [PATCH 601/683] Backed out changeset: b81927151a18. Fix of EXT-3981
 reverted to fix EXT-4379.

--HG--
branch : product-engine
---
 indra/newview/llfolderview.cpp     |  3 +--
 indra/newview/llfolderview.h       |  2 --
 indra/newview/llinventorypanel.cpp | 15 ---------------
 indra/newview/llinventorypanel.h   |  4 ----
 4 files changed, 1 insertion(+), 23 deletions(-)

diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index d3d52e20f78..be15ab7b988 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -184,7 +184,6 @@ LLFolderView::LLFolderView(const Params& p)
 	mSourceID(p.task_id),
 	mRenameItem( NULL ),
 	mNeedsScroll( FALSE ),
-	mEnableScroll( true ),
 	mUseLabelSuffix(p.use_label_suffix),
 	mPinningSelectedItem(FALSE),
 	mNeedsAutoSelect( FALSE ),
@@ -1980,7 +1979,7 @@ void LLFolderView::deleteAllChildren()
 
 void LLFolderView::scrollToShowSelection()
 {
-	if (mEnableScroll && mSelectedItems.size())
+	if (mSelectedItems.size())
 	{
 		mNeedsScroll = TRUE;
 	}
diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h
index f1d39a41ae0..a7763e8eeb4 100644
--- a/indra/newview/llfolderview.h
+++ b/indra/newview/llfolderview.h
@@ -274,7 +274,6 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
 	void dumpSelectionInformation();
 
 	virtual S32	notify(const LLSD& info) ;
-	void setEnableScroll(bool enable_scroll) { mEnableScroll = enable_scroll; }
 	
 	bool useLabelSuffix() { return mUseLabelSuffix; }
 private:
@@ -309,7 +308,6 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
 	LLLineEditor*					mRenamer;
 
 	BOOL							mNeedsScroll;
-	bool							mEnableScroll;
 	BOOL							mPinningSelectedItem;
 	LLRect							mScrollConstraintRect;
 	BOOL							mNeedsAutoSelect;
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index ac92f416243..3683585321d 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -706,21 +706,6 @@ BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 	return handled;
 }
 
-// virtual
-void LLInventoryPanel::onMouseEnter(S32 x, S32 y, MASK mask)
-{
-	LLPanel::onMouseEnter(x, y, mask);
-	// don't auto-scroll a list when cursor is over Inventory. See EXT-3981.
-	mFolderRoot->setEnableScroll(false);
-}
-
-// virtual
-void LLInventoryPanel::onMouseLeave(S32 x, S32 y, MASK mask)
-{
-	LLPanel::onMouseLeave(x, y, mask);
-	mFolderRoot->setEnableScroll(true);
-}
-
 void LLInventoryPanel::onFocusLost()
 {
 	// inventory no longer handles cut/copy/paste/delete
diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h
index c9e317f816f..4db995b0c4b 100644
--- a/indra/newview/llinventorypanel.h
+++ b/indra/newview/llinventorypanel.h
@@ -121,10 +121,6 @@ class LLInventoryPanel : public LLPanel
 								   void* cargo_data,
 								   EAcceptance* accept,
 								   std::string& tooltip_msg);
-
-	void onMouseEnter(S32 x, S32 y, MASK mask);
-	void onMouseLeave(S32 x, S32 y, MASK mask);
-
 	// LLUICtrl methods
 	 /*virtual*/ void onFocusLost();
 	 /*virtual*/ void onFocusReceived();
-- 
GitLab


From a97af8da85c0996911b935c36594db14ffba0d71 Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Wed, 4 Aug 2010 12:51:12 -0700
Subject: [PATCH 602/683] CT-575 WIP PT translation for set16 for Viewer 2.1.1

---
 .../newview/skins/default/xui/fr/strings.xml  | 98 ++-----------------
 1 file changed, 8 insertions(+), 90 deletions(-)

diff --git a/indra/newview/skins/default/xui/fr/strings.xml b/indra/newview/skins/default/xui/fr/strings.xml
index 1204d3325aa..c2a0e173ed9 100644
--- a/indra/newview/skins/default/xui/fr/strings.xml
+++ b/indra/newview/skins/default/xui/fr/strings.xml
@@ -415,7 +415,7 @@
 		image targa
 	</string>
 	<string name="trash">
-		Corbeille
+		Poubelle
 	</string>
 	<string name="jpeg image">
 		image jpeg
@@ -663,9 +663,6 @@
 	<string name="worldmap_offline">
 		Hors ligne
 	</string>
-	<string name="worldmap_item_tooltip_format">
-		[AREA] m² [PRICE] L$
-	</string>
 	<string name="worldmap_results_none_found">
 		Aucun résultat.
 	</string>
@@ -1064,7 +1061,6 @@
 	<string name="AnimFlagStop" value=" Arrêter l&apos;animation :"/>
 	<string name="AnimFlagStart" value=" Démarrer l&apos;animation :"/>
 	<string name="Wave" value=" Faire signe"/>
-	<string name="GestureActionNone" value="Aucune"/>
 	<string name="HelloAvatar" value=" Bonjour, avatar !"/>
 	<string name="ViewAllGestures" value="  Tout afficher &gt;&gt;"/>
 	<string name="GetMoreGestures" value="Plus &gt;&gt;"/>
@@ -1127,7 +1123,7 @@
 		Parties du corps
 	</string>
 	<string name="InvFolder Trash">
-		Corbeille
+		Poubelle
 	</string>
 	<string name="InvFolder Photo Album">
 		Albums photo
@@ -1147,12 +1143,12 @@
 	<string name="InvFolder Favorite">
 		Favoris
 	</string>
+	<string name="InvFolder favorite">
+		Favoris
+	</string>
 	<string name="InvFolder Current Outfit">
 		Tenue actuelle
 	</string>
-	<string name="InvFolder Initial Outfits">
-		Tenues initiales
-	</string>
 	<string name="InvFolder My Outfits">
 		Mes tenues
 	</string>
@@ -1472,7 +1468,6 @@
 	<string name="SummaryForTheWeek" value="Récapitulatif de la semaine, début le "/>
 	<string name="NextStipendDay" value="Prochaine prime le "/>
 	<string name="GroupIndividualShare" value="                      Groupe    Part individuelle"/>
-	<string name="GroupColumn" value="Groupe"/>
 	<string name="Balance">
 		Solde
 	</string>
@@ -1692,12 +1687,6 @@
 	<string name="BusyModeResponseDefault">
 		Le résident auquel vous avez envoyé un message est en mode Occupé, ce qui signifie qu&apos;il a demandé à ne pas être dérangé.  Votre message restera affiché dans son panneau IM afin qu&apos;il puisse le lire ultérieurement.
 	</string>
-	<string name="NoOutfits">
-		Aucune tenue n&apos;est actuellement en votre possession. Essayez [secondlife:///app/search/all Rechercher].
-	</string>
-	<string name="NoOutfitsTabsMatched">
-		Vous n&apos;avez pas trouvé ce que vous cherchiez ? Essayez [secondlife:///app/search/all/Rechercher [SEARCH_TERM]].
-	</string>
 	<string name="MuteByName">
 		(par nom)
 	</string>
@@ -3687,9 +3676,6 @@ Si ce message persiste, veuillez aller sur la page [SUPPORT_SITE].
 	<string name="group_role_owners">
 		Propriétaires
 	</string>
-	<string name="group_member_status_online">
-		En ligne
-	</string>
 	<string name="uploading_abuse_report">
 		Chargement en cours... 
 
@@ -3743,15 +3729,9 @@ de l&apos;infraction signalée
 	<string name="Invalid Wearable">
 		Objet à porter non valide
 	</string>
-	<string name="New Gesture">
-		Nouveau geste
-	</string>
 	<string name="New Script">
 		Nouveau script
 	</string>
-	<string name="New Note">
-		Nouvelle note
-	</string>
 	<string name="New Folder">
 		Nouveau dossier
 	</string>
@@ -3780,7 +3760,7 @@ de l&apos;infraction signalée
 		Homme - Demander pardon
 	</string>
 	<string name="Male - Get lost">
-		Homme - Get lost
+		Homme - Dire d&apos;aller au diable
 	</string>
 	<string name="Male - Blow kiss">
 		Homme - Envoyer un baiser
@@ -3809,20 +3789,11 @@ de l&apos;infraction signalée
 	<string name="Male - Wow">
 		Homme - Ouah !
 	</string>
-	<string name="Female - Chuckle">
-		Femme - Glousser
-	</string>
-	<string name="Female - Cry">
-		Femme - Pleurer
-	</string>
-	<string name="Female - Embarrassed">
-		Femme - Gêne
-	</string>
 	<string name="Female - Excuse me">
 		Femme - Demander pardon
 	</string>
 	<string name="Female - Get lost">
-		Femme - Get lost
+		Femme - Dire d&apos;aller au diable
 	</string>
 	<string name="Female - Blow kiss">
 		Femme - Envoyer un baiser
@@ -3836,21 +3807,9 @@ de l&apos;infraction signalée
 	<string name="Female - Hey">
 		Femme - Hé !
 	</string>
-	<string name="Female - Hey baby">
-		Femme - Hey baby
-	</string>
 	<string name="Female - Laugh">
 		Femme - Rire
 	</string>
-	<string name="Female - Looking good">
-		Femme - Looking good
-	</string>
-	<string name="Female - Over here">
-		Femme - Over here
-	</string>
-	<string name="Female - Please">
-		Femme - Please
-	</string>
 	<string name="Female - Repulsed">
 		Femme - Dégoût
 	</string>
@@ -3900,46 +3859,5 @@ de l&apos;infraction signalée
 	<string name="dateTimePM">
 		PM
 	</string>
-	<string name="LocalEstimateUSD">
-		[AMOUNT] US$
-	</string>
-	<string name="Membership">
-		Inscription
-	</string>
-	<string name="Roles">
-		Rôles
-	</string>
-	<string name="Group Identity">
-		Identité du groupe
-	</string>
-	<string name="Parcel Management">
-		Gestion des parcelles
-	</string>
-	<string name="Parcel Identity">
-		Identité des parcelles
-	</string>
-	<string name="Parcel Settings">
-		Paramètres des parcelles
-	</string>
-	<string name="Parcel Powers">
-		Pouvoirs sur les parcelles
-	</string>
-	<string name="Parcel Access">
-		Accès aux parcelles
-	</string>
-	<string name="Parcel Content">
-		Contenu des parcelles
-	</string>
-	<string name="Object Management">
-		Gestion des objets
-	</string>
-	<string name="Accounting">
-		Comptabilité
-	</string>
-	<string name="Notices">
-		Notices
-	</string>
-	<string name="Chat">
-		Chat
-	</string>
+	<string name="LocalEstimateUSD">[AMOUNT] US$</string> 
 </strings>
-- 
GitLab


From 96ae6ecc0a374b90e61dd4101655c900cb83d773 Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Wed, 4 Aug 2010 15:35:13 -0700
Subject: [PATCH 603/683] CT-575 WIP FR translation for set16 for Viewer 2.1.1

---
 .../xui/fr/floater_preview_gesture.xml        |  4 +-
 .../skins/default/xui/fr/notifications.xml    |  2 +-
 .../default/xui/fr/panel_group_notices.xml    |  2 +-
 .../default/xui/fr/panel_nearby_media.xml     |  2 +-
 .../newview/skins/default/xui/fr/strings.xml  | 90 ++++++++++++++++++-
 5 files changed, 91 insertions(+), 9 deletions(-)

diff --git a/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml b/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
index 82f5bac0471..e7c7385fc87 100644
--- a/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
+++ b/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
@@ -13,13 +13,13 @@
 		Attendre :
 	</floater.string>
 	<floater.string name="stop_txt">
-		Arrêter
+		Stop
 	</floater.string>
 	<floater.string name="preview_txt">
 		Prévisualiser
 	</floater.string>
 	<floater.string name="none_text">
-		- Aucun choix -
+		-- Aucune --
 	</floater.string>
 	<floater.string name="Title">
 		Geste : [NAME]
diff --git a/indra/newview/skins/default/xui/fr/notifications.xml b/indra/newview/skins/default/xui/fr/notifications.xml
index c1321b71ea8..6cfc2b5c666 100644
--- a/indra/newview/skins/default/xui/fr/notifications.xml
+++ b/indra/newview/skins/default/xui/fr/notifications.xml
@@ -1683,7 +1683,7 @@ Publier cette petite annonce maintenant pour [AMOUNT] L$ ?
 		<usetemplate name="okcancelbuttons" notext="Annuler" yestext="OK"/>
 	</notification>
 	<notification label="Envoyer un message à la région" name="MessageRegion">
-		Saisissez un message qui sera envoyé à tous les résidents présents dans cette région.
+		Saisissez une message qui sera envoyé à tous les résidents présents dans cette région.
 		<form name="form">
 			<input name="message"/>
 			<button name="OK" text="OK"/>
diff --git a/indra/newview/skins/default/xui/fr/panel_group_notices.xml b/indra/newview/skins/default/xui/fr/panel_group_notices.xml
index 3364dd9dbc3..bcf2cc8ec98 100644
--- a/indra/newview/skins/default/xui/fr/panel_group_notices.xml
+++ b/indra/newview/skins/default/xui/fr/panel_group_notices.xml
@@ -21,7 +21,7 @@ Vous pouvez désactiver la réception des notices dans l&apos;onglet Général.
 	<text name="notice_list_none_found">
 		Aucun résultat
 	</text>
-	<button label="Nouv. notice" label_selected="Créer une notice" name="create_new_notice" tool_tip="Créer une notice"/>
+	<button label="Nouvelle notice" label_selected="Créer une notice" name="create_new_notice" tool_tip="Créer une notice"/>
 	<button label="Rafraîchir" label_selected="Rafraîchir la liste" name="refresh_notices" tool_tip="Actualiser la liste des notices"/>
 	<panel label="Créer une notice" name="panel_create_new_notice">
 		<text name="lbl">
diff --git a/indra/newview/skins/default/xui/fr/panel_nearby_media.xml b/indra/newview/skins/default/xui/fr/panel_nearby_media.xml
index 66bfd01a2aa..d19a4770077 100644
--- a/indra/newview/skins/default/xui/fr/panel_nearby_media.xml
+++ b/indra/newview/skins/default/xui/fr/panel_nearby_media.xml
@@ -27,7 +27,7 @@
 			Médias proches
 		</text>
 		<text name="show_text">
-			Voir :
+			Afficher :
 		</text>
 		<combo_box name="show_combo">
 			<combo_box.item label="Tout" name="All"/>
diff --git a/indra/newview/skins/default/xui/fr/strings.xml b/indra/newview/skins/default/xui/fr/strings.xml
index c2a0e173ed9..6cab902ab6c 100644
--- a/indra/newview/skins/default/xui/fr/strings.xml
+++ b/indra/newview/skins/default/xui/fr/strings.xml
@@ -663,6 +663,9 @@
 	<string name="worldmap_offline">
 		Hors ligne
 	</string>
+	<string name="worldmap_item_tooltip_format">
+		[AREA] m² [PRICE] L$
+	</string>
 	<string name="worldmap_results_none_found">
 		Aucun résultat.
 	</string>
@@ -1061,6 +1064,7 @@
 	<string name="AnimFlagStop" value=" Arrêter l&apos;animation :"/>
 	<string name="AnimFlagStart" value=" Démarrer l&apos;animation :"/>
 	<string name="Wave" value=" Faire signe"/>
+	<string name="GestureActionNone" value="Aucune"/>
 	<string name="HelloAvatar" value=" Bonjour, avatar !"/>
 	<string name="ViewAllGestures" value="  Tout afficher &gt;&gt;"/>
 	<string name="GetMoreGestures" value="Plus &gt;&gt;"/>
@@ -1143,12 +1147,12 @@
 	<string name="InvFolder Favorite">
 		Favoris
 	</string>
-	<string name="InvFolder favorite">
-		Favoris
-	</string>
 	<string name="InvFolder Current Outfit">
 		Tenue actuelle
 	</string>
+	<string name="InvFolder Initial Outfits">
+		Tenues initiales
+	</string>
 	<string name="InvFolder My Outfits">
 		Mes tenues
 	</string>
@@ -1468,6 +1472,7 @@
 	<string name="SummaryForTheWeek" value="Récapitulatif de la semaine, début le "/>
 	<string name="NextStipendDay" value="Prochaine prime le "/>
 	<string name="GroupIndividualShare" value="                      Groupe    Part individuelle"/>
+	<string name="GroupColumn" value="Groupe"/>
 	<string name="Balance">
 		Solde
 	</string>
@@ -1687,6 +1692,12 @@
 	<string name="BusyModeResponseDefault">
 		Le résident auquel vous avez envoyé un message est en mode Occupé, ce qui signifie qu&apos;il a demandé à ne pas être dérangé.  Votre message restera affiché dans son panneau IM afin qu&apos;il puisse le lire ultérieurement.
 	</string>
+	<string name="NoOutfits">
+		Aucune tenue n&apos;est actuellement en votre possession. Essayez [secondlife:///app/search/all Rechercher].
+	</string>
+	<string name="NoOutfitsTabsMatched">
+		Vous n&apos;avez pas trouvé ce que vous cherchiez ? Essayez [secondlife:///app/search/all/Rechercher [SEARCH_TERM]].
+	</string>
 	<string name="MuteByName">
 		(par nom)
 	</string>
@@ -3676,6 +3687,9 @@ Si ce message persiste, veuillez aller sur la page [SUPPORT_SITE].
 	<string name="group_role_owners">
 		Propriétaires
 	</string>
+	<string name="group_member_status_online">
+		En ligne
+	</string>
 	<string name="uploading_abuse_report">
 		Chargement en cours... 
 
@@ -3729,9 +3743,15 @@ de l&apos;infraction signalée
 	<string name="Invalid Wearable">
 		Objet à porter non valide
 	</string>
+	<string name="New Gesture">
+		Nouveau geste
+	</string>
 	<string name="New Script">
 		Nouveau script
 	</string>
+	<string name="New Note">
+		Nouvelle note
+	</string>
 	<string name="New Folder">
 		Nouveau dossier
 	</string>
@@ -3789,6 +3809,15 @@ de l&apos;infraction signalée
 	<string name="Male - Wow">
 		Homme - Ouah !
 	</string>
+	<string name="Female - Chuckle">
+		Femme - Glousser
+	</string>
+	<string name="Female - Cry">
+		Femme - Pleurer
+	</string>
+	<string name="Female - Embarrassed">
+		Femme - Gêne
+	</string>
 	<string name="Female - Excuse me">
 		Femme - Demander pardon
 	</string>
@@ -3807,9 +3836,21 @@ de l&apos;infraction signalée
 	<string name="Female - Hey">
 		Femme - Hé !
 	</string>
+	<string name="Female - Hey baby">
+		Femme - Hey baby
+	</string>
 	<string name="Female - Laugh">
 		Femme - Rire
 	</string>
+	<string name="Female - Looking good">
+		Femme - Looking good
+	</string>
+	<string name="Female - Over here">
+		Femme - Over here
+	</string>
+	<string name="Female - Please">
+		Femme - Please
+	</string>
 	<string name="Female - Repulsed">
 		Femme - Dégoût
 	</string>
@@ -3859,5 +3900,46 @@ de l&apos;infraction signalée
 	<string name="dateTimePM">
 		PM
 	</string>
-	<string name="LocalEstimateUSD">[AMOUNT] US$</string> 
+	<string name="LocalEstimateUSD">
+		[AMOUNT] US$
+	</string>
+	<string name="Membership">
+		Inscription
+	</string>
+	<string name="Roles">
+		Rôles
+	</string>
+	<string name="Group Identity">
+		Identité du groupe
+	</string>
+	<string name="Parcel Management">
+		Gestion des parcelles
+	</string>
+	<string name="Parcel Identity">
+		Identité des parcelles
+	</string>
+	<string name="Parcel Settings">
+		Paramètres des parcelles
+	</string>
+	<string name="Parcel Powers">
+		Pouvoirs sur les parcelles
+	</string>
+	<string name="Parcel Access">
+		Accès aux parcelles
+	</string>
+	<string name="Parcel Content">
+		Contenu des parcelles
+	</string>
+	<string name="Object Management">
+		Gestion des objets
+	</string>
+	<string name="Accounting">
+		Comptabilité
+	</string>
+	<string name="Notices">
+		Notices
+	</string>
+	<string name="Chat">
+		Chat
+	</string>
 </strings>
-- 
GitLab


From bb69ec1c5681d940c5dce6c4703c89243dfb2427 Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Wed, 4 Aug 2010 21:13:11 +0300
Subject: [PATCH 604/683] EXT-7511 FIXED Fixed item selection cropping in Edit
 Outfit

Restored changeset which was lost after merge 58571b4e704b.

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/780/
---
 indra/newview/llinventorylistitem.cpp | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/indra/newview/llinventorylistitem.cpp b/indra/newview/llinventorylistitem.cpp
index b1f5b3be2fd..2546390fcbf 100644
--- a/indra/newview/llinventorylistitem.cpp
+++ b/indra/newview/llinventorylistitem.cpp
@@ -237,17 +237,6 @@ const std::string& LLPanelInventoryListItemBase::getDescription() const
 	return inv_item->getDescription();
 }
 
-time_t LLPanelInventoryListItemBase::getCreationDate() const
-{
-	LLViewerInventoryItem* inv_item = getItem();
-	if (NULL == inv_item)
-	{
-		return 0;
-	}
-
-	return inv_item->getCreationDate();
-}
-
 LLViewerInventoryItem* LLPanelInventoryListItemBase::getItem() const
 {
 	return gInventory.getItem(mInventoryItemUUID);
-- 
GitLab


From 84d073ad34443b5cdc213b380d7ceb9ef2f66600 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 5 Aug 2010 13:31:19 +0100
Subject: [PATCH 605/683] fix a merge conflict I forgot to commit earlier.

---
 indra/newview/llpaneloutfitedit.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 0e9b3516ea6..8b88a848cf7 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -1321,7 +1321,15 @@ void LLPanelOutfitEdit::getSelectedItemsUUID(uuid_vec_t& uuid_list)
 
 void LLPanelOutfitEdit::onCOFChanged()
 {
+	//the panel is only updated when is visible to a user
+
+	// BAP - this check has to be removed because otherwise item name
+	// changes made when the panel is not visible will not be
+	// propagated to the panel.
+	// if (!isInVisibleChain()) return;
+
 	update();
+}
 
 void LLPanelOutfitEdit::updateWearablesPanelVerbButtons()
 {
@@ -1347,11 +1355,6 @@ void LLPanelOutfitEdit::saveListSelection()
 
 		if(!selected_ids.size()) return;
 
-	// BAP - this check has to be removed because otherwise item name
-	// changes made when the panel is not visible will not be
-	// propagated to the panel.
-	// if (!isInVisibleChain()) return;
-
 		for (std::set<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
 		{
 			mWearableItemsList->selectItemByUUID(*item_id, true);
-- 
GitLab


From 9c038eab0a03be8e8510ea4044de2df56cb5ed9e Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Thu, 5 Aug 2010 11:04:56 -0700
Subject: [PATCH 606/683] CT-575 WIP IT translation for set16 for Viewer 2.1.1

---
 .../skins/default/xui/it/floater_preview_gesture.xml   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/indra/newview/skins/default/xui/it/floater_preview_gesture.xml b/indra/newview/skins/default/xui/it/floater_preview_gesture.xml
index 7e29db63367..9c4006b4e6d 100644
--- a/indra/newview/skins/default/xui/it/floater_preview_gesture.xml
+++ b/indra/newview/skins/default/xui/it/floater_preview_gesture.xml
@@ -30,15 +30,15 @@
 	<text name="trigger_label">
 		Parole chiave:
 	</text>
-	<text name="replace_text" tool_tip="Sostituisci le parole chiave con questi termini. Per esempio, sostituire la parola chiave &apos;salve&apos; con &apos;ciao&apos; modificherà la chat &apos;Volevo solo dire salve&apos; in &apos;Volevo solo dire ciao&apos; e avvierà la gesture!">
+	<text left="208" name="replace_text" tool_tip="Sostituisci le parole chiave con questi termini. Per esempio, sostituire la parola chiave &apos;salve&apos; con &apos;ciao&apos; modificherà la chat &apos;Volevo solo dire salve&apos; in &apos;Volevo solo dire ciao&apos; e avvierà la gesture!">
 		Sostituisci con:
 	</text>
 	<line_editor name="replace_editor" tool_tip="Sostituisci le parole chiave con questi termini. Per esempio, sostituire la parola chiave &apos;salve&apos; con &apos;ciao&apos; modificherà la chat &apos;Volevo solo dire salve&apos; in &apos;Volevo solo dire ciao&apos; e avvierà la gesture!"/>
 	<text name="key_label">
 		Scorciatoia da tastiera:
 	</text>
-	<combo_box label="Nessuno" name="modifier_combo" />
-	<combo_box label="Nessuno" name="key_combo" />
+	<combo_box label="Nessuno" left="156" name="modifier_combo" width="76"/>
+	<combo_box label="Nessuno" left_delta="80" name="key_combo" width="76"/>
 	<text name="library_label">
 		Libreria:
 	</text>
@@ -62,9 +62,9 @@
 		<radio_item label="Attiva" name="start"/>
 		<radio_item label="Ferma" name="stop"/>
 	</radio_group>
-	<check_box label="finché le animazioni sono eseguite" name="wait_anim_check"/>
+	<check_box label="finché le animazioni sono eseguite" left="226" name="wait_anim_check"/>
 	<check_box label="durata in secondi:" name="wait_time_check"/>
-	<line_editor name="wait_time_editor"/>
+	<line_editor left_delta="114" name="wait_time_editor"/>
 	<text name="help_label">
 		Tutte le fasi avvengono contemporaneamente, a meno che non aggiungi fasi di attesa.
 	</text>
-- 
GitLab


From 129e31373eaef9cbd74451bfeb4ad62b64d17250 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 6 Aug 2010 11:57:03 -0500
Subject: [PATCH 607/683] Better < operator for LLVolumeFace::VertexData

---
 indra/llmath/llvolume.cpp | 40 ++++++++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 0976487cbde..bba0a6d089d 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2055,22 +2055,48 @@ void LLVolumeFace::VertexData::setNormal(const LLVector4a& norm)
 
 bool LLVolumeFace::VertexData::operator<(const LLVolumeFace::VertexData& rhs)const
 {
-	if (mData[POSITION].notEqual3(rhs.getPosition()))
+	const F32* lp = this->getPosition().getF32();
+	const F32* rp = rhs.getPosition().getF32();
+
+	if (lp[0] != rp[0])
+	{
+		return lp[0] < rp[0];
+	}
+
+	if (rp[1] != lp[1])
+	{
+		return lp[1] < rp[1];
+	}
+
+	if (rp[2] != lp[2])
+	{
+		return lp[2] < rp[2];
+	}
+
+	lp = getNormal().getF32();
+	rp = rhs.getNormal().getF32();
+
+	if (lp[0] != rp[0])
+	{
+		return lp[0] < rp[0];
+	}
+
+	if (rp[1] != lp[1])
 	{
-		return mData[POSITION].less3(rhs.getPosition());
+		return lp[1] < rp[1];
 	}
 
-	if (mData[NORMAL].notEqual3(rhs.getNormal()))
+	if (rp[2] != lp[2])
 	{
-		return mData[NORMAL].less3(rhs.getNormal());
+		return lp[2] < rp[2];
 	}
 
-	if (mTexCoord != rhs.mTexCoord)
+	if (mTexCoord.mV[0] != rhs.mTexCoord.mV[0])
 	{
-		return mTexCoord < rhs.mTexCoord;
+		return mTexCoord.mV[0] < rhs.mTexCoord.mV[0];
 	}
 
-	return false;
+	return mTexCoord.mV[1] < rhs.mTexCoord.mV[1];
 }
 
 bool LLVolumeFace::VertexData::operator==(const LLVolumeFace::VertexData& rhs)const
-- 
GitLab


From 5ae6fcb94340f72ad14d99cc4fb9afd2431ced45 Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Fri, 6 Aug 2010 11:17:45 -0700
Subject: [PATCH 608/683] CT-575 WIP FR linguistic

---
 .../newview/skins/default/xui/fr/floater_preview_gesture.xml  | 4 ++--
 indra/newview/skins/default/xui/fr/panel_nearby_media.xml     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml b/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
index e7c7385fc87..82f5bac0471 100644
--- a/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
+++ b/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
@@ -13,13 +13,13 @@
 		Attendre :
 	</floater.string>
 	<floater.string name="stop_txt">
-		Stop
+		Arrêter
 	</floater.string>
 	<floater.string name="preview_txt">
 		Prévisualiser
 	</floater.string>
 	<floater.string name="none_text">
-		-- Aucune --
+		- Aucun choix -
 	</floater.string>
 	<floater.string name="Title">
 		Geste : [NAME]
diff --git a/indra/newview/skins/default/xui/fr/panel_nearby_media.xml b/indra/newview/skins/default/xui/fr/panel_nearby_media.xml
index d19a4770077..66bfd01a2aa 100644
--- a/indra/newview/skins/default/xui/fr/panel_nearby_media.xml
+++ b/indra/newview/skins/default/xui/fr/panel_nearby_media.xml
@@ -27,7 +27,7 @@
 			Médias proches
 		</text>
 		<text name="show_text">
-			Afficher :
+			Voir :
 		</text>
 		<combo_box name="show_combo">
 			<combo_box.item label="Tout" name="All"/>
-- 
GitLab


From 403485b29eb1150942225738d13290313086353c Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Fri, 6 Aug 2010 22:34:10 +0300
Subject: [PATCH 609/683] EXT-3981 FIXED Disabled folder view automatic
 scrolling while background fetch is in progress.

Reviewed by Loren Shih at https://codereview.productengine.com/secondlife/r/835/.

--HG--
branch : product-engine
---
 indra/newview/llfolderview.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index be15ab7b988..49d80a02491 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -561,7 +561,9 @@ void LLFolderView::addToSelectionList(LLFolderViewItem* item)
 
 void LLFolderView::removeFromSelectionList(LLFolderViewItem* item)
 {
-	if (mSelectedItems.size())
+	// If items are filtered while background fetch is in progress
+	// scrollbar resets to the first filtered item. See EXT-3981.
+	if (!LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && mSelectedItems.size())
 	{
 		mSelectedItems.back()->setIsCurSelection(FALSE);
 	}
-- 
GitLab


From ff6eccd32db0cf57e16db8941b25a12dbb64b9fa Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Fri, 6 Aug 2010 22:34:18 +0300
Subject: [PATCH 610/683] EXT-4379 FIXED tab_stop parameter initialization that
 prevented inventory panel from passing focus to folder view's scroll
 container.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/823/.

--HG--
branch : product-engine
---
 indra/llui/lluictrl.cpp            | 1 +
 indra/newview/llinventorypanel.cpp | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp
index ff330f863a8..c91e225fd29 100644
--- a/indra/llui/lluictrl.cpp
+++ b/indra/llui/lluictrl.cpp
@@ -101,6 +101,7 @@ LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel)
 :	LLView(p),
 	mTentative(FALSE),
 	mIsChrome(FALSE),
+	mTabStop(FALSE),
     mViewModel(viewmodel),
 	mControlVariable(NULL),
 	mEnabledControlVariable(NULL),
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 3683585321d..770bc02b40d 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -175,6 +175,9 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params)
 		setSortOrder(gSavedSettings.getU32(DEFAULT_SORT_ORDER));
 	}
 	mFolderRoot->setSortOrder(getFilter()->getSortOrder());
+
+	// Initialize base class params.
+	LLPanel::initFromParams(params);
 }
 
 LLInventoryPanel::~LLInventoryPanel()
-- 
GitLab


From b93474301489d2192cc9b7c8a675b55f49c9577b Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Mon, 9 Aug 2010 15:14:45 +0300
Subject: [PATCH 611/683] EXT-8010 ADDITIONAL FIX Fixed problems with avatar
 links underlining.

There were two problems:

1. Underlining broke when avatar's first and second name were on different lines.
2. There was no underline on hover for avatar miniinspector links in plaintext IM.

- First problem was caused by calling LLOnHoverChangeableTextSegment::draw() for the same segment twice- for first and second name that were
on different lines, while handleHover() was called only once. So handleHover() was called -> text was underlined -> first part of segment was
drawn underlined -> its draw set style back to normal -> second part of segment was drawn without underlining.

Fixed this by setting style back to normal only when drawing the last part of the segment.

- Second problem was caused by unusual way of appending link to text in chat history.

Changed it so that LLTextBase::appendText() now receives link not inside style params, but directly.
Also added "/inspect" ending to check in LLUrlEntryAgent::underlineOnHoverOnly().

Reviewed by Richard Nelson at https://codereview.productengine.com/secondlife/r/833/

--HG--
branch : product-engine
---
 indra/llui/lltextbase.cpp       |  5 ++++-
 indra/llui/llurlentry.cpp       |  2 +-
 indra/newview/llchathistory.cpp |  5 +++--
 indra/newview/llstylemap.cpp    | 12 ++----------
 4 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index cde08c7b193..3792f18c975 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -2723,7 +2723,10 @@ LLOnHoverChangeableTextSegment::LLOnHoverChangeableTextSegment( LLStyleConstSP s
 F32 LLOnHoverChangeableTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect)
 {
 	F32 result = LLNormalTextSegment::draw(start, end, selection_start, selection_end, draw_rect);
-	mStyle = mNormalStyle;
+	if (end == mEnd - mStart)
+	{
+		mStyle = mNormalStyle;
+	}
 	return result;
 }
 
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 17d211fb36e..bf7b25910fe 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -366,7 +366,7 @@ std::string LLUrlEntryAgent::getTooltip(const std::string &string) const
 bool LLUrlEntryAgent::underlineOnHoverOnly(const std::string &string) const
 {
 	std::string url = getUrl(string);
-	return LLStringUtil::endsWith(url, "/about");
+	return LLStringUtil::endsWith(url, "/about") || LLStringUtil::endsWith(url, "/inspect");
 }
 
 std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 7c33923f044..7204e6c39cc 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -699,8 +699,9 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
 			{
 				LLStyle::Params link_params(style_params);
 				link_params.overwriteFrom(LLStyleMap::instance().lookupAgent(chat.mFromID));
-				// Convert the name to a hotlink and add to message.
-				mEditor->appendText(chat.mFromName + delimiter, false, link_params);
+				// Add link to avatar's inspector and delimiter to message.
+				mEditor->appendText(link_params.link_href, false, style_params);
+				mEditor->appendText(delimiter, false, style_params);
 			}
 			else
 			{
diff --git a/indra/newview/llstylemap.cpp b/indra/newview/llstylemap.cpp
index 8fab3bb361f..b3d7dddde88 100644
--- a/indra/newview/llstylemap.cpp
+++ b/indra/newview/llstylemap.cpp
@@ -46,20 +46,12 @@ const LLStyle::Params &LLStyleMap::lookupAgent(const LLUUID &source)
 	if (mMap.find(source) == mMap.end())
 	{
 		LLStyle::Params style_params;
-		if (source != LLUUID::null && source != gAgent.getID() )
+		if (source != LLUUID::null)
 		{
 			style_params.color.control = "HTMLLinkColor";
 			style_params.readonly_color.control = "HTMLLinkColor";
-			style_params.link_href = 
-					LLSLURL("agent", source, "inspect").getSLURLString();
+			style_params.link_href = LLSLURL("agent", source, "inspect").getSLURLString();
 		}
-		else
-		{
-			// Make the resident's own name white and don't make the name clickable.
-			style_params.color = LLColor4::white;
-			style_params.readonly_color = LLColor4::white;
-		}
-
 		mMap[source] = style_params;
 	}
 	return mMap[source];
-- 
GitLab


From ed5212f0e9795f00cbed9e674b58c53059605e64 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Mon, 9 Aug 2010 15:23:00 +0300
Subject: [PATCH 612/683] EXT-7593 FIXED Added passing focus to the selected
 outfit tab when My Outfits tab is open. - Removed "tab_stop" from outfit tabs
 to prevent passing focus to a tab chosen by default from
 LLUICtrl::focusFirstItem(). Besides the order of passing focus between outfit
 tabs by pressing "Tab" was undetermined. - Had to remove const from the
 return of LLAccordionCtrl::getSelectedTab() to use the returned pointer for
 setting focus.

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/846/.

--HG--
branch : product-engine
---
 indra/llui/llaccordionctrl.h                                | 2 +-
 indra/newview/lloutfitslist.cpp                             | 6 ++++++
 indra/newview/skins/default/xui/en/outfit_accordion_tab.xml | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/indra/llui/llaccordionctrl.h b/indra/llui/llaccordionctrl.h
index f26a380e5f7..6fc9ca86a3d 100644
--- a/indra/llui/llaccordionctrl.h
+++ b/indra/llui/llaccordionctrl.h
@@ -139,7 +139,7 @@ class LLAccordionCtrl: public LLPanel
 	 */
 	const LLAccordionCtrlTab* getExpandedTab() const;
 
-	const LLAccordionCtrlTab* getSelectedTab() const { return mSelectedTab; }
+	LLAccordionCtrlTab* getSelectedTab() const { return mSelectedTab; }
 
 	bool getFitParent() const {return mFitParent;}
 
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index f921bca6232..8422b97b3a2 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -403,6 +403,12 @@ void LLOutfitsList::onOpen(const LLSD& /*info*/)
 
 		mIsInitialized = true;
 	}
+
+	LLAccordionCtrlTab* selected_tab = mAccordion->getSelectedTab();
+	if (!selected_tab) return;
+
+	// Pass focus to the selected outfit tab.
+	selected_tab->showAndFocusHeader();
 }
 
 void LLOutfitsList::refreshList(const LLUUID& category_id)
diff --git a/indra/newview/skins/default/xui/en/outfit_accordion_tab.xml b/indra/newview/skins/default/xui/en/outfit_accordion_tab.xml
index 06bd1e9ff44..20ff492c0f3 100644
--- a/indra/newview/skins/default/xui/en/outfit_accordion_tab.xml
+++ b/indra/newview/skins/default/xui/en/outfit_accordion_tab.xml
@@ -9,6 +9,7 @@
  layout="topleft"
  name="Mockup Tab"
  selection_enabled="true"
+ tab_stop="false"
  title="Mockup Tab"
  translate="false"
  width="0">
-- 
GitLab


From 953e0a619abba8d85faf8bf3e59d59e344bfc566 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Mon, 9 Aug 2010 18:10:36 +0300
Subject: [PATCH 613/683] EXT-8577 FIXED Context menu items for
 multi-attachments

Changes:
* Implemented bulk-add from My Appearance SP.
* Made sure there's no memleak when you click Wear/Attach in the in-world object context menu
  and the callback isn't invoked (because e.g. avatar fails to get close enough to the object).
  I stated that in comments.

Reviewed by Seraph at https://codereview.productengine.com/secondlife/r/844/

--HG--
branch : product-engine
---
 indra/newview/llviewermenu.cpp        |  3 +-
 indra/newview/llvoavatar.cpp          |  9 +++++
 indra/newview/llvoavatar.h            |  1 +
 indra/newview/llwearableitemslist.cpp | 56 ++++++++++++++++++++-------
 indra/newview/llwearableitemslist.h   |  2 +-
 5 files changed, 56 insertions(+), 15 deletions(-)

diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 92195f0a4da..a289a0eb7a8 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -5950,7 +5950,8 @@ void LLObjectAttachToAvatar::confirmReplaceAttachment(S32 option, LLViewerJointA
 			delta = delta * 0.5f;
 			walkToSpot -= delta;
 
-			CallbackData* user_data = new CallbackData(attachment_point, mReplace); // *TODO: leak if the callback isn't called?
+			// The callback will be called even if avatar fails to get close enough to the object, so we won't get a memory leak.
+			CallbackData* user_data = new CallbackData(attachment_point, mReplace);
 			gAgent.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(walkToSpot), "Attach", NULL, onNearAttachObject, user_data, stop_distance);
 			gAgentCamera.clearFocusObject();
 		}
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 298ac28ca89..6392aad2488 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -5641,6 +5641,15 @@ BOOL LLVOAvatar::canAttachMoreObjects() const
 	return (getNumAttachments() < MAX_AGENT_ATTACHMENTS);
 }
 
+//-----------------------------------------------------------------------------
+// canAttachMoreObjects()
+// Returns true if we can attach <n> more objects.
+//-----------------------------------------------------------------------------
+BOOL LLVOAvatar::canAttachMoreObjects(U32 n) const
+{
+	return (getNumAttachments() + n) <= MAX_AGENT_ATTACHMENTS;
+}
+
 //-----------------------------------------------------------------------------
 // lazyAttach()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 5de08e8e27f..3f603dda8b6 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -687,6 +687,7 @@ class LLVOAvatar :
 	void 				rebuildHUD();
 	void 				resetHUDAttachments();
 	BOOL				canAttachMoreObjects() const;
+	BOOL				canAttachMoreObjects(U32 n) const;
 protected:
 	U32					getNumAttachments() const; // O(N), not O(1)
 
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 194213f880e..e2a5489fcfc 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -869,7 +869,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 	setMenuItemVisible(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0 && can_be_worn);
 	setMenuItemEnabled(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0);
 	setMenuItemVisible(menu, "wear_add",			wear_add_visible);
-	setMenuItemEnabled(menu, "wear_add",			n_items == 1 && canAddWearable(ids.front()));
+	setMenuItemEnabled(menu, "wear_add",			canAddWearables(ids));
 	setMenuItemVisible(menu, "wear_replace",		n_worn == 0 && n_already_worn != 0 && can_be_worn);
 	//visible only when one item selected and this item is worn
 	setMenuItemVisible(menu, "edit",				!standalone && mask & (MASK_CLOTHING|MASK_BODYPART) && n_worn == n_items && n_worn == 1);
@@ -978,31 +978,61 @@ void LLWearableItemsList::ContextMenu::createNewWearable(const LLUUID& item_id)
 	LLAgentWearables::createWearable(item->getWearableType(), true);
 }
 
-// Can we wear another wearable of the given item's wearable type?
+// Returns true if all the given objects and clothes can be added.
 // static
-bool LLWearableItemsList::ContextMenu::canAddWearable(const LLUUID& item_id)
+bool LLWearableItemsList::ContextMenu::canAddWearables(const uuid_vec_t& item_ids)
 {
 	// TODO: investigate wearables may not be loaded at this point EXT-8231
 
-	LLViewerInventoryItem* item = gInventory.getItem(item_id);
-	if (!item)
+	U32 n_objects = 0;
+	boost::unordered_map<LLWearableType::EType, U32> clothes_by_type;
+
+	// Count given clothes (by wearable type) and objects.
+	for (uuid_vec_t::const_iterator it = item_ids.begin(); it != item_ids.end(); ++it)
 	{
-		return false;
+		LLViewerInventoryItem* item = gInventory.getItem(*it);
+		if (!item)
+		{
+			return false;
+		}
+
+		if (item->getType() == LLAssetType::AT_OBJECT)
+		{
+			++n_objects;
+		}
+		else if (item->getType() == LLAssetType::AT_CLOTHING)
+		{
+			++clothes_by_type[item->getWearableType()];
+		}
+		else
+		{
+			llwarns << "Unexpected wearable type" << llendl;
+			return false;
+		}
 	}
 
-	if (item->getType() == LLAssetType::AT_OBJECT)
+	// Check whether we can add all the objects.
+	if (!isAgentAvatarValid() || !gAgentAvatarp->canAttachMoreObjects(n_objects))
 	{
-		// *TODO: is this the right check?
-		return isAgentAvatarValid() && gAgentAvatarp->canAttachMoreObjects();
+		return false;
 	}
 
-	if (item->getType() != LLAssetType::AT_CLOTHING)
+	// Check whether we can add all the clothes.
+	boost::unordered_map<LLWearableType::EType, U32>::const_iterator m_it;
+	for (m_it = clothes_by_type.begin(); m_it != clothes_by_type.end(); ++m_it)
 	{
-		return false;
+		LLWearableType::EType w_type	= m_it->first;
+		U32 n_clothes					= m_it->second;
+
+		U32 wearable_count = gAgentWearables.getWearableCount(w_type);
+		if ((wearable_count + n_clothes) > LLAgentWearables::MAX_CLOTHING_PER_TYPE)
+		{
+			return false;
+		}
+
 	}
 
-	U32 wearable_count = gAgentWearables.getWearableCount(item->getWearableType());
-	return wearable_count < LLAgentWearables::MAX_CLOTHING_PER_TYPE;
+	return true;
 }
 
 // EOF
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index 81f1cd1b405..d7970e08389 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -431,7 +431,7 @@ class LLWearableItemsList : public LLInventoryItemsList
 		static void setMenuItemEnabled(LLContextMenu* menu, const std::string& name, bool val);
 		static void updateMask(U32& mask, LLAssetType::EType at);
 		static void createNewWearable(const LLUUID& item_id);
-		static bool canAddWearable(const LLUUID& item_id);
+		static bool canAddWearables(const uuid_vec_t& item_ids);
 
 		LLWearableItemsList*	mParent;
 	};
-- 
GitLab


From 20bdbd487e9c64ce553ad68d467b1100342fe6a1 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Mon, 9 Aug 2010 21:14:07 +0300
Subject: [PATCH 614/683] EXT-8628 FIXED Crash in
 LLVOAvatarSelf::getAttachedPointName().

The crash was reproducible only on startup. Apparently, gAgentAvatarp was not valid at that point.
Worked around by checking gAgentAvatarp for being valid.

I didn't investigate what the root cause of the problem was (probably the new multi-attachments implementation), I just needed my viewer to work.

Reviewed by Seraph at https://codereview.productengine.com/secondlife/r/847/

--HG--
branch : product-engine
---
 indra/newview/llinventorybridge.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 7e710ce8e1d..53622f71887 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3989,6 +3989,11 @@ std::string LLObjectBridge::getLabelSuffix() const
 {
 	if (get_is_item_worn(mUUID))
 	{
+		if (!isAgentAvatarValid())
+		{
+			return LLItemBridge::getLabelSuffix() + LLTrans::getString("worn");
+		}
+
 		std::string attachment_point_name = gAgentAvatarp->getAttachedPointName(mUUID);
 
 		// e.g. "(worn on ...)" / "(attached to ...)"
-- 
GitLab


From c815848ceed857dbc240e35693d44714004af18b Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Mon, 9 Aug 2010 15:06:26 -0700
Subject: [PATCH 615/683] CT-575 WIP PL global edit part 1/2; PL DA set 16
 translation for 2.1.1; FR linguistic

---
 indra/newview/skins/default/xui/fr/notifications.xml      | 2 +-
 .../newview/skins/default/xui/fr/panel_group_notices.xml  | 2 +-
 indra/newview/skins/default/xui/fr/strings.xml            | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/indra/newview/skins/default/xui/fr/notifications.xml b/indra/newview/skins/default/xui/fr/notifications.xml
index 6cfc2b5c666..c1321b71ea8 100644
--- a/indra/newview/skins/default/xui/fr/notifications.xml
+++ b/indra/newview/skins/default/xui/fr/notifications.xml
@@ -1683,7 +1683,7 @@ Publier cette petite annonce maintenant pour [AMOUNT] L$ ?
 		<usetemplate name="okcancelbuttons" notext="Annuler" yestext="OK"/>
 	</notification>
 	<notification label="Envoyer un message à la région" name="MessageRegion">
-		Saisissez une message qui sera envoyé à tous les résidents présents dans cette région.
+		Saisissez un message qui sera envoyé à tous les résidents présents dans cette région.
 		<form name="form">
 			<input name="message"/>
 			<button name="OK" text="OK"/>
diff --git a/indra/newview/skins/default/xui/fr/panel_group_notices.xml b/indra/newview/skins/default/xui/fr/panel_group_notices.xml
index bcf2cc8ec98..3364dd9dbc3 100644
--- a/indra/newview/skins/default/xui/fr/panel_group_notices.xml
+++ b/indra/newview/skins/default/xui/fr/panel_group_notices.xml
@@ -21,7 +21,7 @@ Vous pouvez désactiver la réception des notices dans l&apos;onglet Général.
 	<text name="notice_list_none_found">
 		Aucun résultat
 	</text>
-	<button label="Nouvelle notice" label_selected="Créer une notice" name="create_new_notice" tool_tip="Créer une notice"/>
+	<button label="Nouv. notice" label_selected="Créer une notice" name="create_new_notice" tool_tip="Créer une notice"/>
 	<button label="Rafraîchir" label_selected="Rafraîchir la liste" name="refresh_notices" tool_tip="Actualiser la liste des notices"/>
 	<panel label="Créer une notice" name="panel_create_new_notice">
 		<text name="lbl">
diff --git a/indra/newview/skins/default/xui/fr/strings.xml b/indra/newview/skins/default/xui/fr/strings.xml
index 6cab902ab6c..1204d3325aa 100644
--- a/indra/newview/skins/default/xui/fr/strings.xml
+++ b/indra/newview/skins/default/xui/fr/strings.xml
@@ -415,7 +415,7 @@
 		image targa
 	</string>
 	<string name="trash">
-		Poubelle
+		Corbeille
 	</string>
 	<string name="jpeg image">
 		image jpeg
@@ -1127,7 +1127,7 @@
 		Parties du corps
 	</string>
 	<string name="InvFolder Trash">
-		Poubelle
+		Corbeille
 	</string>
 	<string name="InvFolder Photo Album">
 		Albums photo
@@ -3780,7 +3780,7 @@ de l&apos;infraction signalée
 		Homme - Demander pardon
 	</string>
 	<string name="Male - Get lost">
-		Homme - Dire d&apos;aller au diable
+		Homme - Get lost
 	</string>
 	<string name="Male - Blow kiss">
 		Homme - Envoyer un baiser
@@ -3822,7 +3822,7 @@ de l&apos;infraction signalée
 		Femme - Demander pardon
 	</string>
 	<string name="Female - Get lost">
-		Femme - Dire d&apos;aller au diable
+		Femme - Get lost
 	</string>
 	<string name="Female - Blow kiss">
 		Femme - Envoyer un baiser
-- 
GitLab


From 73b9d9115411cd1f3c5b1f322b8bd7d7df4749ac Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 9 Aug 2010 17:07:34 -0600
Subject: [PATCH 616/683] EXT-8596: FIXED: crash at
 LLTextureFetchWorker::doWork(int) [secondlife-bin lltexturefetch.cpp] line
 1061

---
 indra/newview/lltexturefetch.cpp | 36 +++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 63bcdcda2dc..45a36dc545e 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -872,10 +872,17 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				cur_size = mFormattedImage->getDataSize(); // amount of data we already have
 				if (mFormattedImage->getDiscardLevel() == 0)
 				{
-					// We already have all the data, just decode it
-					mLoadedDiscard = mFormattedImage->getDiscardLevel();
-					mState = DECODE_IMAGE;
-					return false;
+					if(cur_size > 0)
+					{
+						// We already have all the data, just decode it
+						mLoadedDiscard = mFormattedImage->getDiscardLevel();
+						mState = DECODE_IMAGE;
+						return false;
+					}
+					else
+					{
+						return true ; //abort.
+					}
 				}
 			}
 			mRequestedSize = mDesiredSize;
@@ -982,6 +989,17 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				}
 			}
 			
+			llassert_always(mBufferSize == cur_size + mRequestedSize);
+			if(!mBufferSize)//no data received.
+			{
+				delete[] mBuffer; 
+				mBuffer = NULL;
+
+				//abort.
+				mState = DONE;
+				return true;
+			}
+
 			if (mFormattedImage.isNull())
 			{
 				// For now, create formatted image based on extension
@@ -992,8 +1010,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 					mFormattedImage = new LLImageJ2C; // default
 				}
 			}
-			
-			llassert_always(mBufferSize == cur_size + mRequestedSize);
+						
 			if (mHaveAllData && mRequestedDiscard == 0) //the image file is fully loaded.
 			{
 				mFileSize = mBufferSize;
@@ -1052,7 +1069,12 @@ bool LLTextureFetchWorker::doWork(S32 param)
 		
 		if (mFormattedImage->getDataSize() <= 0)
 		{
-			llerrs << "Decode entered with invalid mFormattedImage. ID = " << mID << llendl;
+			//llerrs << "Decode entered with invalid mFormattedImage. ID = " << mID << llendl;
+			
+			//abort, don't decode
+			mState = DONE;
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			return true;
 		}
 		if (mLoadedDiscard < 0)
 		{
-- 
GitLab


From 60b12a24d4a6061a3fe22a433cb8852002a8e857 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Mon, 9 Aug 2010 16:39:06 -0700
Subject: [PATCH 617/683] Patch on a fix for the llmediadataclient.cpp unit
 test.

My refactor of LLMediaDataClient caused a crash in the windows unit test.  Change set 92fd90bd795a fixed the crash, but broke the code in question.  This changeset should make the code behave correctly, while removing some premature optimization that I now think didn't properly in the first place.
---
 indra/newview/llmediadataclient.cpp | 30 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp
index ec185bc7905..075f0ba3ec7 100755
--- a/indra/newview/llmediadataclient.cpp
+++ b/indra/newview/llmediadataclient.cpp
@@ -263,18 +263,15 @@ void LLMediaDataClient::pushBack(request_ptr_t request)
 
 void LLMediaDataClient::trackRequest(request_ptr_t request)
 {
-	request_set_t::iterator iter = mUnQueuedRequests.lower_bound(request);
+	request_set_t::iterator iter = mUnQueuedRequests.find(request);
 	
-	if (iter != mUnQueuedRequests.end())
+	if(iter != mUnQueuedRequests.end())
 	{
-		if(*iter == request)
-		{
-			LL_WARNS("LLMediaDataClient") << "Tracking already tracked request: " << *request << LL_ENDL;
-		}
-		else
-		{
-			mUnQueuedRequests.insert(iter, request);
-		}
+		LL_WARNS("LLMediaDataClient") << "Tracking already tracked request: " << *request << LL_ENDL;
+	}
+	else
+	{
+		mUnQueuedRequests.insert(request);
 	}
 }
 
@@ -284,14 +281,11 @@ void LLMediaDataClient::stopTrackingRequest(request_ptr_t request)
 	
 	if (iter != mUnQueuedRequests.end())
 	{
-		if(*iter == request)
-		{
-			mUnQueuedRequests.erase(iter);
-		}
-		else
-		{
-			LL_WARNS("LLMediaDataClient") << "Removing an untracked request: " << *request << LL_ENDL;
-		}
+		mUnQueuedRequests.erase(iter);
+	}
+	else
+	{
+		LL_WARNS("LLMediaDataClient") << "Removing an untracked request: " << *request << LL_ENDL;
 	}
 }
 
-- 
GitLab


From b9ec8e094a89715fc46e1a8173c34f6f1ea8ee67 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 10 Aug 2010 09:13:41 -0500
Subject: [PATCH 618/683] Fix for crash when deferred rendering enabled and
 toggling wireframe. (transplanted from
 3886dff9a2829c7a8957d2cc48742e0678ec06a6)

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

diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index a289a0eb7a8..40bf62acc92 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1083,6 +1083,8 @@ class LLAdvancedToggleWireframe : public view_listener_t
 	bool handleEvent(const LLSD& userdata)
 	{
 		gUseWireframe = !(gUseWireframe);
+		LLPipeline::updateRenderDeferred();
+		gPipeline.resetVertexBuffers();
 		return true;
 	}
 };
-- 
GitLab


From 61d43d205c70481a66f596e7263411bb20bdb0b9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 10 Aug 2010 09:13:41 -0500
Subject: [PATCH 619/683] Fix for crash when deferred rendering enabled and
 toggling wireframe.

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

diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index c4a66499e64..5922834ae8b 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1087,6 +1087,8 @@ class LLAdvancedToggleWireframe : public view_listener_t
 	bool handleEvent(const LLSD& userdata)
 	{
 		gUseWireframe = !(gUseWireframe);
+		LLPipeline::updateRenderDeferred();
+		gPipeline.resetVertexBuffers();
 		return true;
 	}
 };
-- 
GitLab


From 7ca0d115a189a8c0768c8d29a3f5d1ed1c80d4a9 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Tue, 10 Aug 2010 17:39:03 +0300
Subject: [PATCH 620/683] Backed out changeset: e1e225cd1deb

--HG--
branch : product-engine
---
 indra/newview/llfolderview.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index 49d80a02491..be15ab7b988 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -561,9 +561,7 @@ void LLFolderView::addToSelectionList(LLFolderViewItem* item)
 
 void LLFolderView::removeFromSelectionList(LLFolderViewItem* item)
 {
-	// If items are filtered while background fetch is in progress
-	// scrollbar resets to the first filtered item. See EXT-3981.
-	if (!LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && mSelectedItems.size())
+	if (mSelectedItems.size())
 	{
 		mSelectedItems.back()->setIsCurSelection(FALSE);
 	}
-- 
GitLab


From 8db6d855ec552657a6390f93af1f29d96b819bde Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Tue, 10 Aug 2010 18:21:12 +0300
Subject: [PATCH 621/683] EXT-3981 FIXED changeset e1e225cd1deb. Disabled
 folder view automatic scrolling while background fetch is in progress.

Reviewed by Loren Shih at https://codereview.productengine.com/secondlife/r/835/.

--HG--
branch : product-engine
---
 indra/newview/llfolderview.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index be15ab7b988..e8891d1cc53 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -1979,7 +1979,9 @@ void LLFolderView::deleteAllChildren()
 
 void LLFolderView::scrollToShowSelection()
 {
-	if (mSelectedItems.size())
+	// If items are filtered while background fetch is in progress
+	// scrollbar resets to the first filtered item. See EXT-3981.
+	if (!LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && mSelectedItems.size())
 	{
 		mNeedsScroll = TRUE;
 	}
-- 
GitLab


From 4b8d41214bb4c3a13050956fcf6f4aaee571e52a Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Tue, 10 Aug 2010 19:16:18 +0300
Subject: [PATCH 622/683] EXT-8255 FIXED Added confirmation dialog when
 removing items.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/849/

--HG--
branch : product-engine
---
 indra/newview/llfolderview.cpp                      | 12 ++++++++++++
 indra/newview/llfolderview.h                        |  2 ++
 .../newview/skins/default/xui/en/notifications.xml  | 13 +++++++++++++
 indra/newview/skins/default/xui/en/strings.xml      |  4 ++++
 4 files changed, 31 insertions(+)

diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index e8891d1cc53..ab36a761534 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -62,6 +62,7 @@
 #include "llviewerwindow.h"
 #include "llvoavatar.h"
 #include "llfloaterproperties.h"
+#include "llnotificationsutil.h"
 
 // Linden library includes
 #include "lldbstrings.h"
@@ -1024,6 +1025,17 @@ void LLFolderView::closeRenamer( void )
 
 void LLFolderView::removeSelectedItems( void )
 {
+	if (mSelectedItems.empty()) return;
+	LLSD args;
+	args["QUESTION"] = LLTrans::getString(mSelectedItems.size() > 1 ? "DeleteItems" :  "DeleteItem");
+	LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLFolderView::onItemsRemovalConfirmation, this, _1, _2));
+}
+
+void LLFolderView::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response)
+{
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	if (option != 0) return; // canceled
+
 	if(getVisible() && getEnabled())
 	{
 		// just in case we're removing the renaming item.
diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h
index a7763e8eeb4..f5f229a6029 100644
--- a/indra/newview/llfolderview.h
+++ b/indra/newview/llfolderview.h
@@ -293,6 +293,8 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
 	
 	BOOL addNoOptions(LLMenuGL* menu) const;
 
+	void onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response);
+
 protected:
 	LLHandle<LLView>					mPopupMenuHandle;
 	
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 3576462cca5..609a9b09be4 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -4021,6 +4021,19 @@ Are you sure you want to quit?
      <unique/>
   </notification>
 
+  <notification
+   icon="alertmodal.tga"
+   name="DeleteItems"
+   type="alertmodal">
+    [QUESTION]
+    <usetemplate
+     ignoretext="Confirm before deleting items"
+     name="okcancelignore"
+     notext="Cancel"
+     yestext="OK"/>
+    <unique/>
+  </notification>
+
   <notification
    icon="alertmodal.tga"
    name="HelpReportAbuseEmailLL"
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 9941732c30a..2aa34b746bd 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -3258,4 +3258,8 @@ Abuse Report</string>
   <string name="Notices">Notices</string>
   <string name="Chat">Chat</string>
 
+  <!-- Question strings for delete items notifications -->
+  <string name="DeleteItems">Delete selected items?</string>
+  <string name="DeleteItem">Delete selected item?</string>
+
   </strings>
-- 
GitLab


From 2143a8f722c294533d3e222f918a56cbc43a81fd Mon Sep 17 00:00:00 2001
From: "Nyx (Neal Orman)" <nyx@lindenlab.com>
Date: Wed, 11 Aug 2010 10:53:43 -0400
Subject: [PATCH 623/683] CTS-201 FIX update mesh viewer to build and run on
 linux

Added a lot of checking to deal with the fact that the code may encounter a
stub convexDecomposition library. Additionally updated the linux stub to fix the
automated build so our beta testers can finally have a linux build.

Unrelated fix: added upload mesh to the top level upload menu.

Code reviewed by Vir.
---
 indra/newview/skins/default/xui/en/menu_viewer.xml | 12 ++++++++++++
 install.xml                                        |  4 ++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index c95e27155a6..5a9b5356fd7 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -883,6 +883,18 @@
                  function="Upload.CalculateCosts"
                  parameter="Upload Animation" />
             </menu_item_call>
+            <menu_item_call
+           label="Model..."
+           layout="topleft"
+           name="Upload Model">
+            <menu_item_call.on_click
+             function="File.UploadModel"
+             parameter="" />
+            <menu_item_call.on_enable
+             function="File.EnableUploadModel" />
+            <menu_item_call.on_visible
+            function="File.MeshEnabled"/>
+            </menu_item_call>
             <menu_item_call
              label="Bulk (L$[COST] per file)..."
              layout="topleft"
diff --git a/install.xml b/install.xml
index 4f8e7bff263..ae3c4178a6e 100644
--- a/install.xml
+++ b/install.xml
@@ -1058,9 +1058,9 @@ anguage Infrstructure (CLI) international standard</string>
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>33dee1d84d006a5339cf6ba4096b8bd9</string>
+            <string>54c95551cc9f792a889e2c54d3af7767</string>
             <key>url</key>
-            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100721.tar.bz2</uri>
+            <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100810.tar.bz2</uri>
           </map>
           <key>darwin</key>
           <map>
-- 
GitLab


From 111f3c3865e09b647438af68a4e4c615f1e64020 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 11 Aug 2010 10:32:06 -0500
Subject: [PATCH 624/683] Added tracking of mesh memory/bandwidth usage.

Reviewed by Nyx.
---
 indra/newview/llviewerwindow.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 67dbe3e52be..d32f82867dc 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -507,6 +507,23 @@ class LLDebugText
 			
 			ypos += y_inc;
 
+			addText(xpos, ypos, llformat("%.3f MB Mesh Data Received", LLMeshRepository::sBytesReceived/(1024.f*1024.f)));
+			
+			ypos += y_inc;
+			
+			addText(xpos, ypos, llformat("%d/%d Mesh HTTP Requests/Retries", LLMeshRepository::sHTTPRequestCount,
+				LLMeshRepository::sHTTPRetryCount));
+			
+			ypos += y_inc;
+
+			addText(xpos, ypos, llformat("%.3f/%.3f MB Mesh Cache Read/Write ", LLMeshRepository::sCacheBytesRead/(1024.f*1024.f), LLMeshRepository::sCacheBytesWritten/(1024.f*1024.f)));
+
+			ypos += y_inc;
+
+			addText(xpos, ypos, llformat("%.3f MB Mesh Memory Cache", LLMeshRepository::sBytesResident/(1024.f*1024.f)));
+
+			ypos += y_inc;
+
 			LLVertexBuffer::sBindCount = LLImageGL::sBindCount = 
 				LLVertexBuffer::sSetCount = LLImageGL::sUniqueCount = 
 				gPipeline.mNumVisibleNodes = LLPipeline::sVisibleLightCount = 0;
-- 
GitLab


From b02d7c1777870d780a5822da9bfce15fbed763af Mon Sep 17 00:00:00 2001
From: "Nyx (Neal Orman)" <nyx@lindenlab.com>
Date: Wed, 11 Aug 2010 11:49:05 -0400
Subject: [PATCH 625/683] CTS-201 FIX Get linux mesh viewer building on team
 city

made a mistake packaging up stub vertex decomposition package. updated the
package and updated install.xml. Pushing fix, will monitor team city to verify
the new package fixes the issue.
---
 install.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/install.xml b/install.xml
index ae3c4178a6e..a6a94e817b0 100644
--- a/install.xml
+++ b/install.xml
@@ -1058,7 +1058,7 @@ anguage Infrstructure (CLI) international standard</string>
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>54c95551cc9f792a889e2c54d3af7767</string>
+            <string>15e239121d88eee6089b62b1c9beca28</string>
             <key>url</key>
             <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-linux-20100810.tar.bz2</uri>
           </map>
-- 
GitLab


From d4f12f2630d41b0dc534c0d3d0d8ae7b3881c680 Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Wed, 11 Aug 2010 20:39:34 +0300
Subject: [PATCH 626/683] EXT-8425 FIXED Translated names of "Home" and "Esc"
 keys shown in shortcuts.

Each key has KEY (typedef of U8) represantation which is paired with text version of key.
To get strings corresponding to keys LLKeyboard::stringFromKey() is used.

- Added translation of keys into LLKeyboard::stringFromKey().

- Added corresponding strings into strings.xml.

- Changed LLTrans::getKeyboardString() so that it correctly process key names that are not found in strings.xml(returns English name instead of "MissingString").

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/845/

--HG--
branch : product-engine
---
 indra/llwindow/llkeyboard.cpp                  |  7 +++++++
 indra/llxuixml/lltrans.h                       | 11 ++++++-----
 indra/newview/skins/default/xui/en/strings.xml |  3 +++
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp
index 16cbf815e0b..8f26f980d15 100644
--- a/indra/llwindow/llkeyboard.cpp
+++ b/indra/llwindow/llkeyboard.cpp
@@ -343,6 +343,13 @@ std::string LLKeyboard::stringFromKey(KEY key)
 		buffer[1] = '\0';
 		res = std::string(buffer);
 	}
+
+	LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator;
+	if (trans != NULL)
+	{
+		res = trans(res.c_str());
+	}
+
 	return res;
 }
 
diff --git a/indra/llxuixml/lltrans.h b/indra/llxuixml/lltrans.h
index 856b9e04fc7..6c8d28b346a 100644
--- a/indra/llxuixml/lltrans.h
+++ b/indra/llxuixml/lltrans.h
@@ -103,11 +103,12 @@ class LLTrans
 		return findString(result, xml_desc, empty);
 	}
 
-        static std::string getKeyboardString(const char* keystring)
-        {
-                // These map directly - no need to specialize
-                return getString( ll_safe_string(keystring) );
-        }
+	static std::string getKeyboardString(const char* keystring)
+	{
+		std::string key_str(keystring);
+		std::string trans_str;
+		return findString(trans_str, "Key_" + key_str) ? trans_str : key_str; 
+	}
 
 	// get the default args
 	static const LLStringUtil::format_map_t& getDefaultArgs()
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 2aa34b746bd..7a292ab943f 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -2282,6 +2282,9 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 	<string name="accel-win-alt">Alt+</string>
 	<string name="accel-win-shift">Shift+</string>
 
+	<string name="Key_Esc">Esc</string>
+	<string name="Key_Home">Home</string>
+
 	<!-- Previews -->
 	<string name="FileSaved">File Saved</string>
 	<string name="Receiving">Receiving</string>
-- 
GitLab


From 6867e1135127eb1f1fac19303161b9ee7039e5cd Mon Sep 17 00:00:00 2001
From: Dessie Linden <dessie@lindenlab.com>
Date: Wed, 11 Aug 2010 11:14:59 -0700
Subject: [PATCH 627/683] Updated viewer patch number & channel

---
 indra/llcommon/llversionserver.h              | 2 +-
 indra/llcommon/llversionviewer.h              | 4 ++--
 indra/newview/English.lproj/InfoPlist.strings | 4 ++--
 indra/newview/Info-SecondLife.plist           | 2 +-
 indra/newview/res/viewerRes.rc                | 8 ++++----
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/indra/llcommon/llversionserver.h b/indra/llcommon/llversionserver.h
index 87fe7001e0d..ddda9fb6af6 100644
--- a/indra/llcommon/llversionserver.h
+++ b/indra/llcommon/llversionserver.h
@@ -36,7 +36,7 @@
 const S32 LL_VERSION_MAJOR = 2;
 const S32 LL_VERSION_MINOR = 1;
 const S32 LL_VERSION_PATCH = 0;
-const S32 LL_VERSION_BUILD = 0;
+const S32 LL_VERSION_BUILD = 13828;
 
 const char * const LL_CHANNEL = "Second Life Server";
 
diff --git a/indra/llcommon/llversionviewer.h b/indra/llcommon/llversionviewer.h
index c430a60ff0a..adc23ed9af5 100644
--- a/indra/llcommon/llversionviewer.h
+++ b/indra/llcommon/llversionviewer.h
@@ -36,8 +36,8 @@
 const S32 LL_VERSION_MAJOR = 2;
 const S32 LL_VERSION_MINOR = 1;
 const S32 LL_VERSION_PATCH = 1;
-const S32 LL_VERSION_BUILD = 0;
+const S32 LL_VERSION_BUILD = 13828;
 
-const char * const LL_CHANNEL = "Second Life Developer";
+const char * const LL_CHANNEL = "Second Life Release";
 
 #endif
diff --git a/indra/newview/English.lproj/InfoPlist.strings b/indra/newview/English.lproj/InfoPlist.strings
index fc531f93d40..5c7cacedec0 100644
--- a/indra/newview/English.lproj/InfoPlist.strings
+++ b/indra/newview/English.lproj/InfoPlist.strings
@@ -2,6 +2,6 @@
 
 CFBundleName = "Second Life";
 
-CFBundleShortVersionString = "Second Life version 2.1.0.0";
-CFBundleGetInfoString = "Second Life version 2.1.0.0, Copyright 2004-2009 Linden Research, Inc.";
+CFBundleShortVersionString = "Second Life version 2.1.0.13828";
+CFBundleGetInfoString = "Second Life version 2.1.0.13828, Copyright 2004-2009 Linden Research, Inc.";
 
diff --git a/indra/newview/Info-SecondLife.plist b/indra/newview/Info-SecondLife.plist
index 9bc95f9b95d..f7b11b217c9 100644
--- a/indra/newview/Info-SecondLife.plist
+++ b/indra/newview/Info-SecondLife.plist
@@ -60,7 +60,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>2.1.0.0</string>
+	<string>2.1.0.13828</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
 </dict>
diff --git a/indra/newview/res/viewerRes.rc b/indra/newview/res/viewerRes.rc
index df2fb2a6ea9..9bafc287058 100644
--- a/indra/newview/res/viewerRes.rc
+++ b/indra/newview/res/viewerRes.rc
@@ -129,8 +129,8 @@ TOOLSIT                 CURSOR                  "toolsit.cur"
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,1,0,0
- PRODUCTVERSION 2,1,0,0
+ FILEVERSION 2,1,0,13828
+ PRODUCTVERSION 2,1,0,13828
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -147,12 +147,12 @@ BEGIN
         BEGIN
             VALUE "CompanyName", "Linden Lab"
             VALUE "FileDescription", "Second Life"
-            VALUE "FileVersion", "2.1.0.0"
+            VALUE "FileVersion", "2.1.0.13828"
             VALUE "InternalName", "Second Life"
             VALUE "LegalCopyright", "Copyright © 2001-2008, Linden Research, Inc."
             VALUE "OriginalFilename", "SecondLife.exe"
             VALUE "ProductName", "Second Life"
-            VALUE "ProductVersion", "2.1.0.0"
+            VALUE "ProductVersion", "2.1.0.13828"
         END
     END
     BLOCK "VarFileInfo"
-- 
GitLab


From e383c723099097076d487c663815bdd902fe18b7 Mon Sep 17 00:00:00 2001
From: Dessie Linden <dessie@lindenlab.com>
Date: Wed, 11 Aug 2010 14:04:27 -0700
Subject: [PATCH 628/683] Changed channel info back to Second Life Developer

---
 indra/llcommon/llversionviewer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llcommon/llversionviewer.h b/indra/llcommon/llversionviewer.h
index adc23ed9af5..b10d07b2a18 100644
--- a/indra/llcommon/llversionviewer.h
+++ b/indra/llcommon/llversionviewer.h
@@ -38,6 +38,6 @@ const S32 LL_VERSION_MINOR = 1;
 const S32 LL_VERSION_PATCH = 1;
 const S32 LL_VERSION_BUILD = 13828;
 
-const char * const LL_CHANNEL = "Second Life Release";
+const char * const LL_CHANNEL = "Second Life Developer";
 
 #endif
-- 
GitLab


From c33bec017744020104832439ba2a00716348a78d Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 11 Aug 2010 17:20:51 -0500
Subject: [PATCH 629/683] Get rid of mesh mem cache and fix looping bug on
 loading unavailable LODs.

Reviewed by Nyx.
---
 indra/newview/llviewerwindow.cpp | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index d32f82867dc..b1def5b2c88 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -520,10 +520,6 @@ class LLDebugText
 
 			ypos += y_inc;
 
-			addText(xpos, ypos, llformat("%.3f MB Mesh Memory Cache", LLMeshRepository::sBytesResident/(1024.f*1024.f)));
-
-			ypos += y_inc;
-
 			LLVertexBuffer::sBindCount = LLImageGL::sBindCount = 
 				LLVertexBuffer::sSetCount = LLImageGL::sUniqueCount = 
 				gPipeline.mNumVisibleNodes = LLPipeline::sVisibleLightCount = 0;
-- 
GitLab


From 91c1545f906bf3bfca6b1311bfedb1af1b3353f1 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 11 Aug 2010 17:43:36 -0500
Subject: [PATCH 630/683] Added mesh bytes received to viewer stats.

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

diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 930c608e35b..9280b74df00 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -64,6 +64,7 @@
 #include "llworld.h"
 #include "llfeaturemanager.h"
 #include "llviewernetwork.h"
+#include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived
 
 
 class StatAttributes
@@ -799,6 +800,7 @@ void send_stats()
 	download["world_kbytes"] = gTotalWorldBytes / 1024.0;
 	download["object_kbytes"] = gTotalObjectBytes / 1024.0;
 	download["texture_kbytes"] = gTotalTextureBytes / 1024.0;
+	download["mesh_kbytes"] = LLMeshRepository::sBytesReceived/1024.0;
 
 	LLSD &in = body["stats"]["net"]["in"];
 
-- 
GitLab


From ba7995fc525e72e56e80d6a5559bf58b6a38711a Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 11 Aug 2010 19:32:00 -0600
Subject: [PATCH 631/683] Automated merge with
 ssh://hg.lindenlab.com/q/viewer-release

---
 indra/newview/lltexturefetch.cpp | 129 ++++++++-----------------------
 indra/newview/lltexturefetch.h   |  14 +---
 2 files changed, 36 insertions(+), 107 deletions(-)

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 846cba4a3bd..f4899d0d5d6 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -54,6 +54,7 @@
 #include "llviewertexturelist.h"
 #include "llviewertexture.h"
 #include "llviewerregion.h"
+#include "llviewerstats.h"
 #include "llworld.h"
 
 //////////////////////////////////////////////////////////////////////////////
@@ -150,7 +151,7 @@ class LLTextureFetchWorker : public LLWorkerClass
 	~LLTextureFetchWorker();
 	void relese() { --mActiveCount; }
 
-	void callbackHttpGet(const LLChannelDescriptors& channels,
+	S32 callbackHttpGet(const LLChannelDescriptors& channels,
 						 const LLIOPipe::buffer_ptr_t& buffer,
 						 bool partial, bool success);
 	void callbackCacheRead(bool success, LLImageFormatted* image,
@@ -335,8 +336,9 @@ class HTTPGetResponder : public LLCurl::Responder
 				worker->setGetStatus(status, reason);
 // 				llwarns << "CURL GET FAILED, status:" << status << " reason:" << reason << llendl;
 			}
-			mFetcher->removeFromHTTPQueue(mID);
-			worker->callbackHttpGet(channels, buffer, partial, success);
+			
+			S32 data_size = worker->callbackHttpGet(channels, buffer, partial, success);
+			mFetcher->removeFromHTTPQueue(mID, data_size);
 		}
 		else
 		{
@@ -850,19 +852,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
 	{
 		if(mCanUseHTTP)
 		{
-			// *TODO: Integrate this with llviewerthrottle
-			// Note: LLViewerThrottle uses dynamic throttling which makes sense for UDP,
-			// but probably not for Textures.
-			// Set the throttle to the entire bandwidth, assuming UDP packets will get priority
-			// when they are needed
-			//F32 max_bandwidth = mFetcher->mMaxBandwidth;
-			if (mFetcher->isHTTPThrottled(mDesiredSize))// ||
-				//mFetcher->getTextureBandwidth() > max_bandwidth)
-			{
-				// Make normal priority and return (i.e. wait until there is room in the queue)
-				setPriority(LLWorkerThread::PRIORITY_NORMAL | mWorkPriority);
-				return false;
-			}
+			//NOTE:
+			//it seems ok to let sim control the UDP traffic
+			//so there is no throttle for http here.
+			//
 			
 			mFetcher->removeFromNetworkQueue(this, false);
 			
@@ -979,6 +972,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 					else
 					{
 						resetFormattedData();
+						mState = DONE;
 						return true; // failed
 					}
 				}
@@ -1271,8 +1265,7 @@ bool LLTextureFetchWorker::deleteOK()
 
 	if ((haveWork() &&
 		 // not ok to delete from these states
-		 ((mState == WAIT_HTTP_REQ) ||
-		  (mState >= WRITE_TO_CACHE && mState <= WAIT_ON_WRITE))))
+		 ((mState >= WRITE_TO_CACHE && mState <= WAIT_ON_WRITE))))
 	{
 		delete_ok = false;
 	}
@@ -1351,29 +1344,29 @@ bool LLTextureFetchWorker::processSimulatorPackets()
 
 //////////////////////////////////////////////////////////////////////////////
 
-void LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
+S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
 										   const LLIOPipe::buffer_ptr_t& buffer,
 										   bool partial, bool success)
 {
+	S32 data_size = 0 ;
+
 	LLMutexLock lock(&mWorkMutex);
 
 	if (mState != WAIT_HTTP_REQ)
 	{
 		llwarns << "callbackHttpGet for unrequested fetch worker: " << mID
 				<< " req=" << mSentRequest << " state= " << mState << llendl;
-		return;
+		return data_size;
 	}
 	if (mLoaded)
 	{
 		llwarns << "Duplicate callback for " << mID.asString() << llendl;
-		return; // ignore duplicate callback
+		return data_size ; // ignore duplicate callback
 	}
 	if (success)
 	{
 		// get length of stream:
-		S32 data_size = buffer->countAfter(channels.in(), NULL);
-
-		gTextureList.sTextureBits += data_size * 8; // Approximate - does not include header bits
+		data_size = buffer->countAfter(channels.in(), NULL);		
 	
 		LL_DEBUGS("Texture") << "HTTP RECEIVED: " << mID.asString() << " Bytes: " << data_size << LL_ENDL;
 		if (data_size > 0)
@@ -1410,6 +1403,8 @@ void LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
 	}
 	mLoaded = TRUE;
 	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+
+	return data_size ;
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -1528,15 +1523,11 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
 	  mTextureCache(cache),
 	  mImageDecodeThread(imagedecodethread),
 	  mTextureBandwidth(0),
+	  mHTTPTextureBits(0),
 	  mCurlGetRequest(NULL)
 {
 	mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
 	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), gSavedSettings.getU32("TextureLoggingThreshold"));
-	
-	for(S32 i = 0 ; i < TOTAL_TEXTURE_TYPES; i++)
-	{
-		mHTTPThrottleFlag[i] = FALSE ;
-	}
 }
 
 LLTextureFetch::~LLTextureFetch()
@@ -1678,69 +1669,11 @@ void LLTextureFetch::addToHTTPQueue(const LLUUID& id)
 	mHTTPTextureQueue.insert(id);
 }
 
-void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id)
+void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32 received_size)
 {
 	LLMutexLock lock(&mNetworkQueueMutex);
 	mHTTPTextureQueue.erase(id);
-}
-
-void LLTextureFetch::clearHTTPThrottleFlag()
-{
-	static const F32 WAIT_TIME = 0.3f ; //seconds.
-	static LLFrameTimer timer ;
-
-	if(timer.getElapsedTimeF32() < WAIT_TIME) //wait for WAIT_TIME
-	{
-		return ;
-	}
-	timer.reset() ;
-
-	LLMutexLock lock(&mNetworkQueueMutex);
-	for(S32 i = 0 ; i < TOTAL_TEXTURE_TYPES; i++)//reset the http throttle flags.
-	{
-		mHTTPThrottleFlag[i] = FALSE ;
-	}
-}
-
-//check if need to throttle this fetching request.
-//rule: if a request can not be inserted into the http queue due to a full queue,
-//      block all future insertions of requests with larger fetching size requirement.
-//because:
-//      later insertions are usually at lower priorities; and
-//      small textures need chance to be fetched.
-bool LLTextureFetch::isHTTPThrottled(S32 requested_size)
-{
-	static const S32 SMALL_TEXTURE_MAX_SIZE = 64 * 64 * 4 ;
-	static const S32 MEDIUM_TEXTURE_MAX_SIZE = 256 * 256 * 4 ;
-	static const U32 MAX_HTTP_QUEUE_SIZE = 8 ;
-
-	//determine the class of the texture: SMALL, MEDIUM, or LARGE.
-	S32 type = LARGE_TEXTURE ;
-	if(requested_size <= SMALL_TEXTURE_MAX_SIZE)
-	{
-		type = SMALL_TEXTURE ;
-	}
-	else if(requested_size <= MEDIUM_TEXTURE_MAX_SIZE)
-	{
-		type = MEDIUM_TEXTURE ;
-	}
-
-	LLMutexLock lock(&mNetworkQueueMutex);
-
-	if(mHTTPTextureQueue.size() >= MAX_HTTP_QUEUE_SIZE)//if the http queue is full.
-	{
-		if(!mHTTPThrottleFlag[type + 1])
-		{
-			for(S32 i = type + 1 ; i < TOTAL_TEXTURE_TYPES; i++) //block all requests with fetching size larger than this request.		
-			{
-				mHTTPThrottleFlag[i] = TRUE ;			
-			}
-		}
-		
-		return true ;
-	}
-
-	return mHTTPThrottleFlag[type] ; //true if this request can not be inserted to the http queue.
+	mHTTPTextureBits += received_size * 8; // Approximate - does not include header bits	
 }
 
 void LLTextureFetch::deleteRequest(const LLUUID& id, bool cancel)
@@ -1888,12 +1821,19 @@ bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority)
 //virtual
 S32 LLTextureFetch::update(U32 max_time_ms)
 {
-	S32 res;
-	
 	static LLCachedControl<F32> band_width(gSavedSettings,"ThrottleBandwidthKBPS");
-	mMaxBandwidth = band_width ;
-	
-	res = LLWorkerThread::update(max_time_ms);
+
+	{
+		mNetworkQueueMutex.lock() ;
+		mMaxBandwidth = band_width ;
+
+		gTextureList.sTextureBits += mHTTPTextureBits ;
+		mHTTPTextureBits = 0 ;
+
+		mNetworkQueueMutex.unlock() ;
+	}
+
+	S32 res = LLWorkerThread::update(max_time_ms);
 	
 	if (!mDebugPause)
 	{
@@ -1909,7 +1849,6 @@ S32 LLTextureFetch::update(U32 max_time_ms)
 			lldebugs << "processed: " << processed << " messages." << llendl;
 		}
 	}
-	clearHTTPThrottleFlag();
 
 	return res;
 }
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index c31c38b04a5..2024165e7e6 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -94,9 +94,7 @@ class LLTextureFetch : public LLWorkerThread
 	void addToNetworkQueue(LLTextureFetchWorker* worker);
 	void removeFromNetworkQueue(LLTextureFetchWorker* worker, bool cancel);
 	void addToHTTPQueue(const LLUUID& id);
-	void removeFromHTTPQueue(const LLUUID& id);
-	bool isHTTPThrottled(S32 requested_size);
-	void clearHTTPThrottleFlag();
+	void removeFromHTTPQueue(const LLUUID& id, S32 received_size = 0);
 	void removeRequest(LLTextureFetchWorker* worker, bool cancel);
 	// Called from worker thread (during doWork)
 	void processCurlRequests();	
@@ -136,15 +134,7 @@ class LLTextureFetch : public LLWorkerThread
 	F32 mMaxBandwidth;
 	LLTextureInfo mTextureInfo;
 
-	enum
-	{
-		SMALL_TEXTURE = 0 , //size <= 64 * 64
-		MEDIUM_TEXTURE,     //size <= 256 * 256
-		LARGE_TEXTURE,      //size > 256 * 256
-		DUMMY,
-		TOTAL_TEXTURE_TYPES
-	};
-	BOOL mHTTPThrottleFlag[TOTAL_TEXTURE_TYPES];
+	U32 mHTTPTextureBits;
 };
 
 #endif // LL_LLTEXTUREFETCH_H
-- 
GitLab


From 6a920e23277c10c27b6a2241084cffe5b40c58f7 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Thu, 12 Aug 2010 13:19:23 +0300
Subject: [PATCH 632/683] EXT-7951 FIXED (Mini-Location panel appearance design
 issues)

- Added callback on show\hide Mini Location Panel event. This callback sets proper initial minimized position depending on state (shown or hidded) Mini Location Panel. Also callback shifts vertically already minimized floaters so that they don't overlap Mini Location Panel

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/851/

--HG--
branch : product-engine
---
 indra/llui/llfloater.cpp            | 14 ++++++++++++++
 indra/llui/llfloater.h              |  3 +++
 indra/newview/llpaneltopinfobar.cpp | 23 +++++++++++++++++++++++
 indra/newview/llpaneltopinfobar.h   |  5 +++++
 4 files changed, 45 insertions(+)

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 22d6f6ca52d..838f93d3f9f 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -2285,6 +2285,7 @@ void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom)
 	S32 floater_header_size = default_params.header_height;
 	static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
 	LLRect snap_rect_local = getLocalSnapRect();
+	snap_rect_local.mTop += mMinimizePositionVOffset;
 	for(S32 col = snap_rect_local.mLeft;
 		col < snap_rect_local.getWidth() - minimized_width;
 		col += minimized_width)
@@ -2382,6 +2383,19 @@ BOOL LLFloaterView::allChildrenClosed()
 	return true;
 }
 
+void LLFloaterView::shiftFloaters(S32 x_offset, S32 y_offset)
+{
+	for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
+	{
+		LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
+
+		if (floaterp && floaterp->isMinimized())
+		{
+			floaterp->translate(x_offset, y_offset);
+		}
+	}
+}
+
 void LLFloaterView::refresh()
 {
 	// Constrain children to be entirely on the screen
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 42f422f91cb..e7d365238b8 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -455,6 +455,7 @@ class LLFloaterView : public LLUICtrl
 	// Given a child of gFloaterView, make sure this view can fit entirely onscreen.
 	void			adjustToFitScreen(LLFloater* floater, BOOL allow_partial_outside);
 
+	void			setMinimizePositionVerticalOffset(S32 offset) { mMinimizePositionVOffset = offset; }
 	void			getMinimizePosition( S32 *left, S32 *bottom);
 	void			restoreAll();		// un-minimize all floaters
 	typedef std::set<LLView*> skip_list_t;
@@ -471,6 +472,7 @@ class LLFloaterView : public LLUICtrl
 	// attempt to close all floaters
 	void			closeAllChildren(bool app_quitting);
 	BOOL			allChildrenClosed();
+	void			shiftFloaters(S32 x_offset, S32 y_offset);
 
 	LLFloater* getFrontmost() const;
 	LLFloater* getBackmost() const;
@@ -490,6 +492,7 @@ class LLFloaterView : public LLUICtrl
 	BOOL			mFocusCycleMode;
 	S32				mSnapOffsetBottom;
 	S32				mSnapOffsetRight;
+	S32				mMinimizePositionVOffset;
 };
 
 //
diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp
index 68dc1cdf71c..e73d1fb7c28 100644
--- a/indra/newview/llpaneltopinfobar.cpp
+++ b/indra/newview/llpaneltopinfobar.cpp
@@ -161,6 +161,8 @@ BOOL LLPanelTopInfoBar::postBuild()
 	mParcelMgrConnection = LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(
 			boost::bind(&LLPanelTopInfoBar::onAgentParcelChange, this));
 
+	setVisibleCallback(boost::bind(&LLPanelTopInfoBar::onVisibilityChange, this, _2));
+
 	return TRUE;
 }
 
@@ -174,6 +176,27 @@ void LLPanelTopInfoBar::onNavBarShowParcelPropertiesCtrlChanged()
 	setParcelInfoText(new_text);
 }
 
+// when panel is shown, all minimized floaters should be shifted downwards to prevent overlapping of
+// PanelTopInfoBar. See EXT-7951.
+void LLPanelTopInfoBar::onVisibilityChange(const LLSD& show)
+{
+	// this height is used as a vertical offset for ALREADY MINIMIZED floaters
+	// when PanelTopInfoBar visibility changes
+	S32 height = getRect().getHeight();
+
+	// this vertical offset is used for a start minimize position of floaters that
+	// are NOT MIMIMIZED YET
+	S32 minimize_pos_offset = 0;
+
+	if (show.asBoolean())
+	{
+		height = minimize_pos_offset = -height;
+	}
+
+	gFloaterView->shiftFloaters(0, height);
+	gFloaterView->setMinimizePositionVerticalOffset(minimize_pos_offset);
+}
+
 void LLPanelTopInfoBar::draw()
 {
 	updateParcelInfoText();
diff --git a/indra/newview/llpaneltopinfobar.h b/indra/newview/llpaneltopinfobar.h
index 6e6fbc08abd..0603ee744f6 100644
--- a/indra/newview/llpaneltopinfobar.h
+++ b/indra/newview/llpaneltopinfobar.h
@@ -58,6 +58,11 @@ class LLPanelTopInfoBar : public LLPanel, public LLSingleton<LLPanelTopInfoBar>,
 	 */
 	void handleLoginComplete();
 
+	/**
+	 * Called when the top info bar gets shown or hidden
+	 */
+	void onVisibilityChange(const LLSD& show);
+
 private:
 	class LLParcelChangeObserver;
 
-- 
GitLab


From dd9a3c4bdd01d9659d6337c803f9aaae19251a28 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Thu, 12 Aug 2010 13:20:52 +0300
Subject: [PATCH 633/683] EXT-8599 FIXED (Search Floater - \"loading\" and
 \"Done\" text in lower left is cut-off)

- Added height parameters and removed unnecessary bottom parameter

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/852/

--HG--
branch : product-engine
---
 indra/newview/skins/default/xui/en/floater_search.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/skins/default/xui/en/floater_search.xml b/indra/newview/skins/default/xui/en/floater_search.xml
index 49b3b581136..354f1de85e1 100644
--- a/indra/newview/skins/default/xui/en/floater_search.xml
+++ b/indra/newview/skins/default/xui/en/floater_search.xml
@@ -22,7 +22,7 @@
         Done
     </floater.string>
     <layout_stack
-     bottom="595"
+     height="580"
      follows="left|right|top|bottom"
      layout="topleft"
      left="10"
@@ -30,6 +30,7 @@
      top="20"
      width="630">
         <layout_panel
+         height="570"
          layout="topleft"
          left_delta="0"
          top_delta="0"
@@ -37,13 +38,12 @@
          user_resize="false"
          width="630">
             <web_browser
-             bottom="-10"
              follows="left|right|top|bottom"
              layout="topleft"
              left="0"
              name="browser"
              top="0"
-             height="555"
+             height="540"
              width="630" />
             <text
              follows="bottom|left"
@@ -51,7 +51,7 @@
              layout="topleft"
              left_delta="0"
              name="status_text"
-             top_pad="7"
+             top_pad="10"
              width="150" />
             <text
              visible="false"
-- 
GitLab


From 81f727849a9644bef21038663964d97f51564155 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Thu, 12 Aug 2010 13:48:36 +0300
Subject: [PATCH 634/683] EXT-8205 FIXED (Items in \"Add more\" panel are not
 sorted by name)

- Modified LLWearableItemTypeNameComparator so that it can be more reusable and adjustable

- Set LLWearableItemTypeNameComparator for WearableItemsList ('List view' of 'Add More' panel) due to sort clothings by name

- Modified and applied patch form https://codereview.productengine.com/secondlife/r/620/diff/2/#index_header. This patch was discarded because specification was changed

Restored diff after bad merge at 13817

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/765/

--HG--
branch : product-engine
---
 indra/newview/llpaneloutfitedit.cpp   | 332 ++++----------------------
 indra/newview/llpaneloutfitedit.h     |  17 +-
 indra/newview/llwearableitemslist.cpp | 142 ++---------
 indra/newview/llwearableitemslist.h   |  53 +---
 4 files changed, 88 insertions(+), 456 deletions(-)

diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 0464aa377ee..d76a5c586ff 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -42,7 +42,6 @@
 #include "lloutfitobserver.h"
 #include "llcofwearables.h"
 #include "llfilteredwearablelist.h"
-#include "llfolderviewitem.h"
 #include "llinventory.h"
 #include "llinventoryitemslist.h"
 #include "llviewercontrol.h"
@@ -86,11 +85,6 @@ const U64 ALL_ITEMS_MASK = WEARABLE_MASK | ATTACHMENT_MASK;
 
 static const std::string REVERT_BTN("revert_btn");
 
-
-///////////////////////////////////////////////////////////////////////////////
-// LLShopURLDispatcher
-///////////////////////////////////////////////////////////////////////////////
-
 class LLShopURLDispatcher
 {
 public:
@@ -150,10 +144,6 @@ std::string LLShopURLDispatcher::resolveURL(LLAssetType::EType asset_type, ESex
 	return gSavedSettings.getString(setting_name);
 }
 
-///////////////////////////////////////////////////////////////////////////////
-// LLPanelOutfitEditGearMenu
-///////////////////////////////////////////////////////////////////////////////
-
 class LLPanelOutfitEditGearMenu
 {
 public:
@@ -169,6 +159,7 @@ class LLPanelOutfitEditGearMenu
 		if (menu)
 		{
 			populateCreateWearableSubmenus(menu);
+			menu->buildDrawLabels();
 		}
 
 		return menu;
@@ -217,147 +208,6 @@ class LLPanelOutfitEditGearMenu
 	}
 };
 
-///////////////////////////////////////////////////////////////////////////////
-// LLAddWearablesGearMenu
-///////////////////////////////////////////////////////////////////////////////
-
-class LLAddWearablesGearMenu : public LLInitClass<LLAddWearablesGearMenu>
-{
-public:
-	static LLMenuGL* create(LLWearableItemsList* flat_list, LLInventoryPanel* inventory_panel)
-	{
-		LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
-		LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
-
-		llassert(flat_list);
-		llassert(inventory_panel);
-
-		LLHandle<LLView> flat_list_handle = flat_list->getHandle();
-		LLHandle<LLPanel> inventory_panel_handle = inventory_panel->getHandle();
-
-		registrar.add("AddWearable.Gear.Sort", boost::bind(onSort, flat_list_handle, inventory_panel_handle, _2));
-		enable_registrar.add("AddWearable.Gear.Check", boost::bind(onCheck, flat_list_handle, inventory_panel_handle, _2));
-		enable_registrar.add("AddWearable.Gear.Visible", boost::bind(onVisible, inventory_panel_handle, _2));
-
-		LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(
-			"menu_add_wearable_gear.xml",
-			LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
-
-		return menu;
-	}
-
-private:
-	static void onSort(LLHandle<LLView> flat_list_handle,
-					   LLHandle<LLPanel> inventory_panel_handle,
-					   LLSD::String sort_order_str)
-	{
-		if (flat_list_handle.isDead() || inventory_panel_handle.isDead()) return;
-
-		LLWearableItemsList* flat_list = dynamic_cast<LLWearableItemsList*>(flat_list_handle.get());
-		LLInventoryPanel* inventory_panel = dynamic_cast<LLInventoryPanel*>(inventory_panel_handle.get());
-
-		if (!flat_list || !inventory_panel) return;
-
-		LLWearableItemsList::ESortOrder	sort_order;
-
-		if ("by_most_recent" == sort_order_str)
-		{
-			sort_order = LLWearableItemsList::E_SORT_BY_MOST_RECENT;
-		}
-		else if ("by_name" == sort_order_str)
-		{
-			sort_order = LLWearableItemsList::E_SORT_BY_NAME;
-		}
-		else if ("by_type" == sort_order_str)
-		{
-			sort_order = LLWearableItemsList::E_SORT_BY_TYPE_NAME;
-		}
-		else
-		{
-			llwarns << "Unrecognized sort order action" << llendl;
-			return;
-		}
-
-		if (inventory_panel->getVisible())
-		{
-			inventory_panel->setSortOrder(sort_order);
-		}
-		else
-		{
-			flat_list->setSortOrder(sort_order);
-		}
-	}
-
-	static bool onCheck(LLHandle<LLView> flat_list_handle,
-						LLHandle<LLPanel> inventory_panel_handle,
-						LLSD::String sort_order_str)
-	{
-		if (flat_list_handle.isDead() || inventory_panel_handle.isDead()) return false;
-
-		LLWearableItemsList* flat_list = dynamic_cast<LLWearableItemsList*>(flat_list_handle.get());
-		LLInventoryPanel* inventory_panel = dynamic_cast<LLInventoryPanel*>(inventory_panel_handle.get());
-
-		if (!inventory_panel || !flat_list) return false;
-
-		// Inventory panel uses its own sort order independent from
-		// flat list view so this flag is used to distinguish between
-		// currently visible "tree" or "flat" representation of inventory.
-		bool inventory_tree_visible = inventory_panel->getVisible();
-
-		if (inventory_tree_visible)
-		{
-			U32 sort_order = inventory_panel->getSortOrder();
-
-			if ("by_most_recent" == sort_order_str)
-			{
-				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & sort_order;
-			}
-			else if ("by_name" == sort_order_str)
-			{
-				// If inventory panel is not sorted by date then it is sorted by name.
-				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & ~sort_order;
-			}
-			llwarns << "Unrecognized inventory panel sort order" << llendl;
-		}
-		else
-		{
-			LLWearableItemsList::ESortOrder	sort_order = flat_list->getSortOrder();
-
-			if ("by_most_recent" == sort_order_str)
-			{
-				return LLWearableItemsList::E_SORT_BY_MOST_RECENT == sort_order;
-			}
-			else if ("by_name" == sort_order_str)
-			{
-				return LLWearableItemsList::E_SORT_BY_NAME == sort_order;
-			}
-			else if ("by_type" == sort_order_str)
-			{
-				return LLWearableItemsList::E_SORT_BY_TYPE_NAME == sort_order;
-			}
-			llwarns << "Unrecognized wearable list sort order" << llendl;
-		}
-		return false;
-	}
-
-	static bool onVisible(LLHandle<LLPanel> inventory_panel_handle,
-						  LLSD::String sort_order_str)
-	{
-		if (inventory_panel_handle.isDead()) return false;
-
-		LLInventoryPanel* inventory_panel = dynamic_cast<LLInventoryPanel*>(inventory_panel_handle.get());
-
-		// Enable sorting by type only for the flat list of items
-		// because inventory panel doesn't support this kind of sorting.
-		return ( "by_type" == sort_order_str )
-				&&	( !inventory_panel || !inventory_panel->getVisible() );
-	}
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// LLCOFDragAndDropObserver
-///////////////////////////////////////////////////////////////////////////////
-
 class LLCOFDragAndDropObserver : public LLInventoryAddItemByAssetObserver
 {
 public:
@@ -393,17 +243,12 @@ void LLCOFDragAndDropObserver::done()
 	LLAppearanceMgr::instance().updateAppearanceFromCOF();
 }
 
-///////////////////////////////////////////////////////////////////////////////
-// LLPanelOutfitEdit
-///////////////////////////////////////////////////////////////////////////////
-
 LLPanelOutfitEdit::LLPanelOutfitEdit()
 :	LLPanel(), 
 	mSearchFilter(NULL),
 	mCOFWearables(NULL),
 	mInventoryItemsPanel(NULL),
 	mGearMenu(NULL),
-	mAddWearablesGearMenu(NULL),
 	mCOFDragAndDropObserver(NULL),
 	mInitialized(false),
 	mAddWearablesPanel(NULL),
@@ -456,7 +301,7 @@ BOOL LLPanelOutfitEdit::postBuild()
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.All"), new LLFindNonLinksByMask(ALL_ITEMS_MASK)));
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Clothing"), new LLIsTypeActual(LLAssetType::AT_CLOTHING)));
 	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Bodyparts"), new LLIsTypeActual(LLAssetType::AT_BODYPART)));
-	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindNonLinksByMask(ATTACHMENT_MASK)));;
+	mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindByMask(ATTACHMENT_MASK)));;
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("shape"), new LLFindActualWearablesOfType(LLWearableType::WT_SHAPE)));
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("skin"), new LLFindActualWearablesOfType(LLWearableType::WT_SKIN)));
 	mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("hair"), new LLFindActualWearablesOfType(LLWearableType::WT_HAIR)));
@@ -481,9 +326,7 @@ BOOL LLPanelOutfitEdit::postBuild()
 
 	childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL);
 	childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL);
-	childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL);
 	childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL);
-	childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL);
 	childSetCommitCallback("wearables_gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
 	childSetCommitCallback("gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
 	childSetCommitCallback("shop_btn_1", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL);
@@ -543,12 +386,26 @@ BOOL LLPanelOutfitEdit::postBuild()
 
 	childSetAction(REVERT_BTN, boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance()));
 
+	/*
+	 * By default AT_CLOTHING are sorted by (in in MY OUTFITS):
+	 *  - by type (types order determined in LLWearableType::EType)
+	 *  - each LLWearableType::EType by outer layer on top
+	 *
+	 * In Add More panel AT_CLOTHING should be sorted in a such way:
+	 *  - by type (types order determined in LLWearableType::EType)
+	 *  - each LLWearableType::EType by name (EXT-8205)
+	*/
+	mWearableListViewItemsComparator = new LLWearableItemTypeNameComparator();
+	mWearableListViewItemsComparator->setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANG_1, false, true);
+
 	mWearablesListViewPanel = getChild<LLPanel>("filtered_wearables_panel");
-	mWearableItemsList = getChild<LLWearableItemsList>("list_view");
+	mWearableItemsList = getChild<LLInventoryItemsList>("list_view");
 	mWearableItemsList->setCommitOnSelectionChange(true);
 	mWearableItemsList->setCommitCallback(boost::bind(&LLPanelOutfitEdit::updatePlusButton, this));
 	mWearableItemsList->setDoubleClickCallback(boost::bind(&LLPanelOutfitEdit::onPlusBtnClicked, this));
 
+	mWearableItemsList->setComparator(mWearableListViewItemsComparator);
+
 	mSaveComboBtn.reset(new LLSaveOutfitComboBtn(this));
 	return TRUE;
 }
@@ -586,46 +443,35 @@ void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables)
 {
 	mAddWearablesPanel->setVisible(show_add_wearables);
 	
-	getChild<LLUICtrl>("show_add_wearables_btn")->setValue(show_add_wearables);
+	childSetValue("show_add_wearables_btn", show_add_wearables);
 
 	updateFiltersVisibility();
-	getChildView("filter_button")->setVisible( show_add_wearables);
+	childSetVisible("filter_button", show_add_wearables);
 
 	//search filter should be disabled
 	if (!show_add_wearables)
 	{
-		getChild<LLUICtrl>("filter_button")->setValue(false);
+		childSetValue("filter_button", false);
 
 		mFolderViewFilterCmbBox->setVisible(false);
 		mListViewFilterCmbBox->setVisible(false);
 
 		showWearablesFilter();
 
-		/*
-		 * By default AT_CLOTHING are sorted by (in in MY OUTFITS):
-		 *  - by type (types order determined in LLWearableType::EType)
-		 *  - each LLWearableType::EType by outer layer on top
-		 *
-		 * In Add More panel AT_CLOTHING should be sorted in a such way:
-		 *  - by type (types order determined in LLWearableType::EType)
-		 *  - each LLWearableType::EType by name (EXT-8205)
-		*/
-		mWearableItemsList->setSortOrder(LLWearableItemsList::E_SORT_BY_TYPE_NAME);
-
 		// Reset mWearableItemsList position to top. See EXT-8180.
 		mWearableItemsList->goToTop();
 	}
 
 	//switching button bars
-	getChildView("no_add_wearables_button_bar")->setVisible( !show_add_wearables);
-	getChildView("add_wearables_button_bar")->setVisible( show_add_wearables);
+	childSetVisible("no_add_wearables_button_bar", !show_add_wearables);
+	childSetVisible("add_wearables_button_bar", show_add_wearables);
 }
 
 void LLPanelOutfitEdit::showWearablesFilter()
 {
-	bool filter_visible = getChild<LLUICtrl>("filter_button")->getValue();
+	bool filter_visible = childGetValue("filter_button");
 
-	getChildView("filter_panel")->setVisible( filter_visible);
+	childSetVisible("filter_panel", filter_visible);
 
 	if(!filter_visible)
 	{
@@ -642,7 +488,9 @@ void LLPanelOutfitEdit::showWearablesListView()
 {
 	if(switchPanels(mInventoryItemsPanel, mWearablesListViewPanel))
 	{
-		updateWearablesPanelVerbButtons();
+		mFolderViewBtn->setToggleState(FALSE);
+		mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
+		mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
 		updateFiltersVisibility();
 	}
 	mListViewBtn->setToggleState(TRUE);
@@ -652,7 +500,9 @@ void LLPanelOutfitEdit::showWearablesFolderView()
 {
 	if(switchPanels(mWearablesListViewPanel, mInventoryItemsPanel))
 	{
-		updateWearablesPanelVerbButtons();
+		mListViewBtn->setToggleState(FALSE);
+		mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
+		mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
 		updateFiltersVisibility();
 	}
 	mFolderViewBtn->setToggleState(TRUE);
@@ -793,17 +643,8 @@ void LLPanelOutfitEdit::onShopButtonClicked()
 	if (isAgentAvatarValid())
 	{
 		// try to get wearable type from 'Add More' panel first (EXT-7639)
-		selection_info_t selection_info = getAddMorePanelSelectionType();
-
-		LLWearableType::EType type = selection_info.first;
+		LLWearableType::EType type = getAddMorePanelSelectionType();
 
-		if (selection_info.second > 1)
-		{
-			// the second argument is not important in this case: generic market place will be opened
-			url = url_resolver.resolveURL(LLWearableType::WT_NONE, SEX_FEMALE);
-		}
-		else
-		{
 		if (type == LLWearableType::WT_NONE)
 		{
 			type = getCOFWearablesSelectionType();
@@ -819,9 +660,7 @@ void LLPanelOutfitEdit::onShopButtonClicked()
 
 		if (url.empty())
 		{
-				url = url_resolver.resolveURL(
-						mCOFWearables->getExpandedAccordionAssetType(), sex);
-			}
+			url = url_resolver.resolveURL(mCOFWearables->getExpandedAccordionAssetType(), sex);
 		}
 	}
 	else
@@ -860,9 +699,9 @@ LLWearableType::EType LLPanelOutfitEdit::getCOFWearablesSelectionType() const
 	return type;
 }
 
-LLPanelOutfitEdit::selection_info_t LLPanelOutfitEdit::getAddMorePanelSelectionType() const
+LLWearableType::EType LLPanelOutfitEdit::getAddMorePanelSelectionType() const
 {
-	selection_info_t result = std::make_pair(LLWearableType::WT_NONE, 0);
+	LLWearableType::EType type = LLWearableType::WT_NONE;
 
 	if (mAddWearablesPanel != NULL && mAddWearablesPanel->getVisible())
 	{
@@ -870,11 +709,9 @@ LLPanelOutfitEdit::selection_info_t LLPanelOutfitEdit::getAddMorePanelSelectionT
 		{
 			std::set<LLUUID> selected_uuids = mInventoryItemsPanel->getRootFolder()->getSelectionList();
 
-			result.second = selected_uuids.size();
-
-			if (result.second == 1)
+			if (selected_uuids.size() == 1)
 			{
-				result.first = getWearableTypeByItemUUID(*(selected_uuids.begin()));
+				type = getWearableTypeByItemUUID(*(selected_uuids.begin()));
 			}
 		}
 		else if (mWearableItemsList != NULL && mWearableItemsList->getVisible())
@@ -882,16 +719,14 @@ LLPanelOutfitEdit::selection_info_t LLPanelOutfitEdit::getAddMorePanelSelectionT
 			std::vector<LLUUID> selected_uuids;
 			mWearableItemsList->getSelectedUUIDs(selected_uuids);
 
-			result.second = selected_uuids.size();
-
-			if (result.second == 1)
+			if (selected_uuids.size() == 1)
 			{
-				result.first = getWearableTypeByItemUUID(selected_uuids.front());
+				type = getWearableTypeByItemUUID(selected_uuids.front());
 			}
 		}
 	}
 
-	return result;
+	return type;
 }
 
 LLWearableType::EType LLPanelOutfitEdit::getWearableTypeByItemUUID(const LLUUID& item_uuid) const
@@ -928,7 +763,7 @@ void LLPanelOutfitEdit::updatePlusButton()
 	}
 
 	// If any of the selected items are not wearable (due to already being worn OR being of the wrong type), disable the add button.
-	uuid_vec_t::iterator unwearable_item = std::find_if(selected_items.begin(), selected_items.end(), !boost::bind(&get_can_item_be_worn, _1));
+	uuid_vec_t::iterator unwearable_item = std::find_if(selected_items.begin(), selected_items.end(), !boost::bind(& get_can_item_be_worn, _1));
 	bool can_add = ( unwearable_item == selected_items.end() );
 
 	mPlusBtn->setEnabled(can_add);
@@ -1176,7 +1011,7 @@ void LLPanelOutfitEdit::updateVerbs()
 	bool has_baseoutfit = LLAppearanceMgr::getInstance()->getBaseOutfitUUID().notNull();
 
 	mSaveComboBtn->setSaveBtnEnabled(!outfit_locked && outfit_is_dirty);
-	getChildView(REVERT_BTN)->setEnabled(outfit_is_dirty && has_baseoutfit);
+	childSetEnabled(REVERT_BTN, outfit_is_dirty && has_baseoutfit);
 
 	mSaveComboBtn->setMenuItemEnabled("save_outfit", !outfit_locked && outfit_is_dirty);
 
@@ -1213,33 +1048,13 @@ void LLPanelOutfitEdit::resetAccordionState()
 
 void LLPanelOutfitEdit::onGearButtonClick(LLUICtrl* clicked_button)
 {
-	LLMenuGL* menu = NULL;
-
-	if (mAddWearablesPanel->getVisible())
+	if(!mGearMenu)
 	{
-		if (!mAddWearablesGearMenu)
-		{
-			mAddWearablesGearMenu = LLAddWearablesGearMenu::create(mWearableItemsList, mInventoryItemsPanel);
-		}
-
-		menu = mAddWearablesGearMenu;
-	}
-	else
-	{
-		if (!mGearMenu)
-		{
-			mGearMenu = LLPanelOutfitEditGearMenu::create();
-		}
-
-		menu = mGearMenu;
+		mGearMenu = LLPanelOutfitEditGearMenu::create();
 	}
 
-	if (!menu) return;
-
-	menu->arrangeAndClear(); // update menu height
-	S32 menu_y = menu->getRect().getHeight() + clicked_button->getRect().getHeight();
-	menu->buildDrawLabels();
-	LLMenuGL::showPopup(clicked_button, menu, 0, menu_y);
+	S32 menu_y = mGearMenu->getRect().getHeight() + clicked_button->getRect().getHeight();
+	LLMenuGL::showPopup(clicked_button, mGearMenu, 0, menu_y);
 }
 
 void LLPanelOutfitEdit::onAddMoreButtonClicked()
@@ -1331,62 +1146,5 @@ void LLPanelOutfitEdit::onCOFChanged()
 	update();
 }
 
-void LLPanelOutfitEdit::updateWearablesPanelVerbButtons()
-{
-	if(mWearablesListViewPanel->getVisible())
-	{
-		mFolderViewBtn->setToggleState(FALSE);
-		mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
-		mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
-	}
-	else if(mInventoryItemsPanel->getVisible())
-	{
-		mListViewBtn->setToggleState(FALSE);
-		mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
-		mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
-	}
-}
-
-void LLPanelOutfitEdit::saveListSelection()
-{
-	if(mWearablesListViewPanel->getVisible())
-	{
-		std::set<LLUUID> selected_ids = mInventoryItemsPanel->getRootFolder()->getSelectionList();
-
-		if(!selected_ids.size()) return;
-
-		for (std::set<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
-		{
-			mWearableItemsList->selectItemByUUID(*item_id, true);
-		}
-		mWearableItemsList->scrollToShowFirstSelectedItem();
-	}
-	else if(mInventoryItemsPanel->getVisible())
-	{
-		std::vector<LLUUID> selected_ids;
-		mWearableItemsList->getSelectedUUIDs(selected_ids);
-
-		if(!selected_ids.size()) return;
-
-		mInventoryItemsPanel->clearSelection();
-		LLFolderView* root = mInventoryItemsPanel->getRootFolder();
-
-		if(!root) return;
-
-		for(std::vector<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
-		{
-			LLFolderViewItem* item = root->getItemByID(*item_id);
-			if (!item) continue;
-
-			LLFolderViewFolder* parent = item->getParentFolder();
-			if(parent)
-			{
-				parent->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP);
-			}
-			mInventoryItemsPanel->getRootFolder()->changeSelection(item, TRUE);
-		}
-		mInventoryItemsPanel->getRootFolder()->scrollToShowSelection();
-	}
-}
 
 // EOF
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index 871ed8d7ec4..784c2bcad14 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -43,8 +43,8 @@
 #include "llremoteparcelrequest.h"
 #include "llinventory.h"
 #include "llinventoryfunctions.h"
+#include "llinventoryitemslist.h"
 #include "llinventorymodel.h"
-#include "llwearableitemslist.h"
 
 class LLButton;
 class LLCOFWearables;
@@ -201,17 +201,8 @@ class LLPanelOutfitEdit : public LLPanel
 	void getCurrentItemUUID(LLUUID& selected_id);
 	void onCOFChanged();
 
-	/**
-	 * Method preserves selection while switching between folder/list view modes
-	*/
-	void saveListSelection();
-
-	void updateWearablesPanelVerbButtons();
-
-	typedef std::pair<LLWearableType::EType, size_t> selection_info_t;
-
 	LLWearableType::EType getCOFWearablesSelectionType() const;
-	selection_info_t getAddMorePanelSelectionType() const;
+	LLWearableType::EType getAddMorePanelSelectionType() const;
 	LLWearableType::EType getWearableTypeByItemUUID(const LLUUID& item_uuid) const;
 
 	LLTextBox*			mCurrentOutfitName;
@@ -230,8 +221,9 @@ class LLPanelOutfitEdit : public LLPanel
 	LLComboBox*			mListViewFilterCmbBox;
 
 	LLFilteredWearableListManager* 	mWearableListManager;
-	LLWearableItemsList* 			mWearableItemsList;
+	LLInventoryItemsList* 			mWearableItemsList;
 	LLPanel*						mWearablesListViewPanel;
+	LLWearableItemTypeNameComparator* mWearableListViewItemsComparator;
 
 	LLCOFDragAndDropObserver* mCOFDragAndDropObserver;
 
@@ -240,7 +232,6 @@ class LLPanelOutfitEdit : public LLPanel
 
 	LLCOFWearables*		mCOFWearables;
 	LLMenuGL*			mGearMenu;
-	LLMenuGL*			mAddWearablesGearMenu;
 	bool				mInitialized;
 	std::auto_ptr<LLSaveOutfitComboBtn> mSaveComboBtn;
 
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index e2a5489fcfc..5e23965f625 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -478,9 +478,9 @@ LLWearableItemTypeNameComparator::LLWearableItemTypeNameComparator()
 	// 1. CLOTHING - sorted by name
 	// 2. OBJECT   - sorted by type
 	// 3. BODYPART - sorted by name
-	mWearableOrder[LLAssetType::AT_CLOTHING] = LLWearableTypeOrder(ORDER_RANK_1, false, false);
-	mWearableOrder[LLAssetType::AT_OBJECT]   = LLWearableTypeOrder(ORDER_RANK_2, true, true);
-	mWearableOrder[LLAssetType::AT_BODYPART] = LLWearableTypeOrder(ORDER_RANK_3, false, true);
+	mWearableOrder[LLAssetType::AT_CLOTHING] = LLWearableTypeOrder(ORDER_RANG_1, false, false);
+	mWearableOrder[LLAssetType::AT_OBJECT]   = LLWearableTypeOrder(ORDER_RANG_2, true, true);
+	mWearableOrder[LLAssetType::AT_BODYPART] = LLWearableTypeOrder(ORDER_RANG_3, false, true);
 }
 
 void LLWearableItemTypeNameComparator::setOrder(LLAssetType::EType items_of_type,  LLWearableItemTypeNameComparator::ETypeListOrder order_priority, bool sort_asset_items_by_name, bool sort_wearable_items_by_name)
@@ -527,6 +527,8 @@ bool LLWearableItemTypeNameComparator::doCompare(const LLPanelInventoryListItemB
 	const LLWearableType::EType item_wearable_type2 = wearable_item2->getWearableType();
 
 	if (item_wearable_type1 != item_wearable_type2)
+		// If items are of different LLWearableType::EType types they are compared
+		// by LLWearableType::EType. types order determined in LLWearableType::EType.
 	{
 		// If items are of different LLWearableType::EType types they are compared
 		// by LLWearableType::EType. types order determined in LLWearableType::EType.
@@ -549,10 +551,11 @@ LLWearableItemTypeNameComparator::ETypeListOrder LLWearableItemTypeNameComparato
 {
 	wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type);
 
+
 	if(const_it == mWearableOrder.end())
 	{
 		llwarns<<"Absent information about order rang of items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
-		return ORDER_RANK_UNKNOWN;
+		return ORDER_RANG_UNKNOWN;
 	}
 
 	return const_it->second.mOrderPriority;
@@ -562,49 +565,37 @@ bool LLWearableItemTypeNameComparator::sortAssetTypeByName(LLAssetType::EType it
 {
 	wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type);
 
+
 	if(const_it == mWearableOrder.end())
 	{
 		llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
 		return true;
 	}
 
+
 	return const_it->second.mSortAssetTypeByName;
-	}
+}
+
 
 bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType item_type) const
 {
 	wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type);
 
+
 	if(const_it == mWearableOrder.end())
 	{
 		llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
 		return true;
-}
-
-	return const_it->second.mSortWearableTypeByName;
-}
-
-/*virtual*/
-bool LLWearableItemCreationDateComparator::doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const
-{
-	time_t date1 = item1->getCreationDate();
-	time_t date2 = item2->getCreationDate();
-
-	if (date1 == date2)
-	{
-		return LLWearableItemNameComparator::doCompare(item1, item2);
 	}
 
-	return date1 > date2;
+
+	return const_it->second.mSortWearableTypeByName;
 }
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 
-static LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
-static const LLWearableItemTypeNameComparator WEARABLE_TYPE_LAYER_COMPARATOR;
-static const LLWearableItemNameComparator WEARABLE_NAME_COMPARATOR;
-static const LLWearableItemCreationDateComparator WEARABLE_CREATION_DATE_COMPARATOR;
+static const LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
 
 static const LLDefaultChildRegistry::Register<LLWearableItemsList> r("wearable_items_list");
 
@@ -616,7 +607,7 @@ LLWearableItemsList::Params::Params()
 LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p)
 :	LLInventoryItemsList(p)
 {
-	setSortOrder(E_SORT_BY_TYPE_LAYER, false);
+	setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
 	mIsStandalone = p.standalone;
 	if (mIsStandalone)
 	{
@@ -716,38 +707,6 @@ void LLWearableItemsList::onRightClick(S32 x, S32 y)
 	ContextMenu::instance().show(this, selected_uuids, x, y);
 }
 
-void LLWearableItemsList::setSortOrder(ESortOrder sort_order, bool sort_now)
-{
-	switch (sort_order)
-	{
-	case E_SORT_BY_MOST_RECENT:
-		setComparator(&WEARABLE_CREATION_DATE_COMPARATOR);
-		break;
-	case E_SORT_BY_NAME:
-		setComparator(&WEARABLE_NAME_COMPARATOR);
-		break;
-	case E_SORT_BY_TYPE_LAYER:
-		setComparator(&WEARABLE_TYPE_LAYER_COMPARATOR);
-		break;
-	case E_SORT_BY_TYPE_NAME:
-	{
-		WEARABLE_TYPE_NAME_COMPARATOR.setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANK_1, false, true);
-		setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
-		break;
-	}
-
-	// No "default:" to raise compiler warning
-	// if we're not handling something
-	}
-
-	mSortOrder = sort_order;
-
-	if (sort_now)
-	{
-		sort();
-	}
-}
-
 //////////////////////////////////////////////////////////////////////////
 /// ContextMenu
 //////////////////////////////////////////////////////////////////////////
@@ -818,8 +777,6 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 	U32 n_links = 0;				// number of links among the selected items
 	U32 n_editable = 0;				// number of editable items among the selected ones
 
-	bool can_be_worn = true;
-
 	for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
 	{
 		LLUUID id = *it;
@@ -855,22 +812,16 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 		{
 			++n_already_worn;
 		}
-
-		if (can_be_worn)
-		{
-			can_be_worn = get_can_item_be_worn(item->getLinkedUUID());
-		}
 	} // for
 
 	bool standalone = mParent ? mParent->isStandalone() : false;
-	bool wear_add_visible = mask & (MASK_CLOTHING|MASK_ATTACHMENT) && n_worn == 0 && can_be_worn && (n_already_worn != 0 || mask & MASK_ATTACHMENT);
 
 	// *TODO: eliminate multiple traversals over the menu items
-	setMenuItemVisible(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0 && can_be_worn);
+	setMenuItemVisible(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0);
 	setMenuItemEnabled(menu, "wear_wear", 			n_already_worn == 0 && n_worn == 0);
-	setMenuItemVisible(menu, "wear_add",			wear_add_visible);
-	setMenuItemEnabled(menu, "wear_add",			canAddWearables(ids));
-	setMenuItemVisible(menu, "wear_replace",		n_worn == 0 && n_already_worn != 0 && can_be_worn);
+	setMenuItemVisible(menu, "wear_add",			mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0);
+	setMenuItemEnabled(menu, "wear_add",			n_items == 1 && canAddWearable(ids.front()) && n_already_worn != 0);
+	setMenuItemVisible(menu, "wear_replace",		n_worn == 0 && n_already_worn != 0);
 	//visible only when one item selected and this item is worn
 	setMenuItemVisible(menu, "edit",				!standalone && mask & (MASK_CLOTHING|MASK_BODYPART) && n_worn == n_items && n_worn == 1);
 	setMenuItemEnabled(menu, "edit",				n_editable == 1 && n_worn == 1 && n_items == 1);
@@ -978,61 +929,20 @@ void LLWearableItemsList::ContextMenu::createNewWearable(const LLUUID& item_id)
 	LLAgentWearables::createWearable(item->getWearableType(), true);
 }
 
-// Returns true if all the given objects and clothes can be added.
+// Can we wear another wearable of the given item's wearable type?
 // static
-bool LLWearableItemsList::ContextMenu::canAddWearables(const uuid_vec_t& item_ids)
+bool LLWearableItemsList::ContextMenu::canAddWearable(const LLUUID& item_id)
 {
 	// TODO: investigate wearables may not be loaded at this point EXT-8231
 
-	U32 n_objects = 0;
-	boost::unordered_map<LLWearableType::EType, U32> clothes_by_type;
-
-	// Count given clothes (by wearable type) and objects.
-	for (uuid_vec_t::const_iterator it = item_ids.begin(); it != item_ids.end(); ++it)
-	{
-		LLViewerInventoryItem* item = gInventory.getItem(*it);
-		if (!item)
-		{
-			return false;
-		}
-
-		if (item->getType() == LLAssetType::AT_OBJECT)
-		{
-			++n_objects;
-		}
-		else if (item->getType() == LLAssetType::AT_CLOTHING)
-		{
-			++clothes_by_type[item->getWearableType()];
-		}
-		else
-		{
-			llwarns << "Unexpected wearable type" << llendl;
-			return false;
-		}
-	}
-
-	// Check whether we can add all the objects.
-	if (!isAgentAvatarValid() || !gAgentAvatarp->canAttachMoreObjects(n_objects))
+	LLViewerInventoryItem* item = gInventory.getItem(item_id);
+	if (!item || item->getType() != LLAssetType::AT_CLOTHING)
 	{
 		return false;
 	}
 
-	// Check whether we can add all the clothes.
-	boost::unordered_map<LLWearableType::EType, U32>::const_iterator m_it;
-	for (m_it = clothes_by_type.begin(); m_it != clothes_by_type.end(); ++m_it)
-	{
-		LLWearableType::EType w_type	= m_it->first;
-		U32 n_clothes					= m_it->second;
-
-		U32 wearable_count = gAgentWearables.getWearableCount(w_type);
-		if ((wearable_count + n_clothes) > LLAgentWearables::MAX_CLOTHING_PER_TYPE)
-		{
-			return false;
-		}
-
-	}
-
-	return true;
+	U32 wearable_count = gAgentWearables.getWearableCount(item->getWearableType());
+	return wearable_count < LLAgentWearables::MAX_CLOTHING_PER_TYPE;
 }
 
 // EOF
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index d7970e08389..237ba1af437 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -313,10 +313,10 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 
 	enum ETypeListOrder
 	{
-		ORDER_RANK_1 = 1,
-		ORDER_RANK_2,
-		ORDER_RANK_3,
-		ORDER_RANK_UNKNOWN
+		ORDER_RANG_1 = 1,
+		ORDER_RANG_2,
+		ORDER_RANG_3,
+		ORDER_RANG_UNKNOWN
 	};
 
 	void setOrder(LLAssetType::EType items_of_type, ETypeListOrder order_priority, bool sort_items_by_name, bool sort_wearable_items_by_name);
@@ -325,28 +325,28 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 	/**
 	 * All information about sort order is stored in mWearableOrder map
 	 *
-	 * mWearableOrder :      KYES              VALUES
+	 * mWearableOrder :      KEYES              VALUES
 	 *                  [LLAssetType] [struct LLWearableTypeOrder]
 	 *
 	 *---------------------------------------------------------------------------------------------
-	 * I. Determines order (ORDER_RANK) in which items of LLAssetType should be displayed in list.
+	 * I. Determines order (ORDER_RANG) in which items of LLAssetType should be displayed in list.
 	 *     For example by spec in MY OUTFITS the order is:
-	 *     1. AT_CLOTHING (ORDER_RANK_1)
-	 *     2. AT_OBJECT   (ORDER_RANK_2)
-	 *     3. AT_BODYPART (ORDER_RANK_3)
+	 *     1. AT_CLOTHING (ORDER_RANG_1)
+	 *     2. AT_OBJECT   (ORDER_RANG_2)
+	 *     3. AT_BODYPART (ORDER_RANG_3)
 	 *
 	 * II.Items of each type(LLAssetType) are sorted by name or type(LLWearableType)
 	 *     For example by spec in MY OUTFITS the order within each items type(LLAssetType) is:
 	 *     1. AT_OBJECTS (abc order)
 	 *     2. AT_CLOTHINGS
-	 *         - by type (types order determined in LLWearableType::EType)
-	 *         - outer layer on top
+	 *       - by type (types order determined in LLWearableType::EType)
+	 *       - outer layer on top
 	 *     3. AT_BODYPARTS  (abc order)
 	 *---------------------------------------------------------------------------------------------
 	 *
 	 * For each LLAssetType (KEYS in mWearableOrder) the information about:
 	 *
-	 *                                             I.  ORDER_RANK (the flag is LLWearableTypeOrder::mOrderPriority)
+	 *                                             I.  ORDER_RANG (the flag is LLWearableTypeOrder::mOrderPriority)
 	 *
 	 *                                             II. whether items of this LLAssetType type should be ordered
 	 *                                                 by name or by LLWearableType::EType (the flag is LLWearableTypeOrder::mSortAssetTypeByName)
@@ -379,19 +379,6 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 	wearable_type_order_map_t mWearableOrder;
 };
 
-/**
- * @class LLWearableItemCreationDateComparator
- *
- * Comparator for sorting wearable list items by creation date (newest go first).
- */
-class LLWearableItemCreationDateComparator : public LLWearableItemNameComparator
-{
-	LOG_CLASS(LLWearableItemCreationDateComparator);
-
-protected:
-	/*virtual*/ bool doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const;
-};
-
 /**
  * @class LLWearableItemsList
  *
@@ -431,7 +418,7 @@ class LLWearableItemsList : public LLInventoryItemsList
 		static void setMenuItemEnabled(LLContextMenu* menu, const std::string& name, bool val);
 		static void updateMask(U32& mask, LLAssetType::EType at);
 		static void createNewWearable(const LLUUID& item_id);
-		static bool canAddWearables(const uuid_vec_t& item_ids);
+		static bool canAddWearable(const LLUUID& item_id);
 
 		LLWearableItemsList*	mParent;
 	};
@@ -444,14 +431,6 @@ class LLWearableItemsList : public LLInventoryItemsList
 		Params();
 	};
 
-	typedef enum e_sort_order {
-		// Values should be compatible with InventorySortOrder setting.
-		E_SORT_BY_NAME			= 0,
-		E_SORT_BY_MOST_RECENT	= 1,
-		E_SORT_BY_TYPE_LAYER	= 2,
-		E_SORT_BY_TYPE_NAME 	= 3,
-	} ESortOrder;
-
 	virtual ~LLWearableItemsList();
 
 	/*virtual*/ void addNewItem(LLViewerInventoryItem* item, bool rearrange = true);
@@ -466,10 +445,6 @@ class LLWearableItemsList : public LLInventoryItemsList
 
 	bool isStandalone() const { return mIsStandalone; }
 
-	ESortOrder getSortOrder() const { return mSortOrder; }
-
-	void setSortOrder(ESortOrder sort_order, bool sort_now = true);
-
 protected:
 	friend class LLUICtrlFactory;
 	LLWearableItemsList(const LLWearableItemsList::Params& p);
@@ -478,8 +453,6 @@ class LLWearableItemsList : public LLInventoryItemsList
 
 	bool mIsStandalone;
 	bool mWornIndicationEnabled;
-
-	ESortOrder		mSortOrder;
 };
 
 #endif //LL_LLWEARABLEITEMSLIST_H
-- 
GitLab


From 845317cb360cf095a37d2da11c4f26759b330c60 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Thu, 12 Aug 2010 15:56:51 +0300
Subject: [PATCH 635/683] EXT-8628 FIXED Crash in
 LLVOAvatarSelf::getAttachedPointName().

The crash was reproducible only on startup. Apparently, gAgentAvatarp was not valid at that point.
Worked around by checking gAgentAvatarp for being valid.

I didn't investigate what the root cause of the problem was (probably the new multi-attachments implementation), I just needed my viewer to work.

Reviewed by Seraph at https://codereview.productengine.com/secondlife/r/847/.

--HG--
branch : product-engine
---
 indra/newview/llinventorybridge.cpp | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 53622f71887..9bbc6514b4c 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3936,7 +3936,7 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 		item = (LLViewerInventoryItem*)gInventory.getItem(object_id);
 		if(item && gInventory.isObjectDescendentOf(object_id, gInventory.getRootFolderID()))
 		{
-			rez_attachment(item, NULL, true); // Replace if "Wear"ing.
+			rez_attachment(item, NULL);
 		}
 		else if(item && item->isFinished())
 		{
@@ -3952,10 +3952,6 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 		}
 		gFocusMgr.setKeyboardFocus(NULL);
 	}
-	else if ("wear_add" == action)
-	{
-		LLAppearanceMgr::instance().wearItemOnAvatar(mUUID, true, false); // Don't replace if adding.
-	}
 	else if (isRemoveAction(action))
 	{
 		LLInventoryItem* item = gInventory.getItem(mUUID);
@@ -4007,7 +4003,7 @@ std::string LLObjectBridge::getLabelSuffix() const
 	}
 }
 
-void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment, bool replace)
+void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment)
 {
 	LLSD payload;
 	payload["item_id"] = item->getLinkedUUID(); // Wear the base object in case this is a link.
@@ -4026,14 +4022,9 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach
 		}
 	}
 
-	if (!replace)
-	{
-		attach_pt |= ATTACHMENT_ADD;
-	}
-
 	payload["attachment_point"] = attach_pt;
 
-	if (replace &&
+	if (!gSavedSettings.getBOOL("MultipleAttachments") &&
 		(attachment && attachment->getNumObjects() > 0))
 	{
 		LLNotificationsUtil::add("ReplaceAttachment", LLSD(), payload, confirm_replace_attachment_rez);
@@ -4062,6 +4053,8 @@ bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& respon
 		if (itemp)
 		{
 			U8 attachment_pt = notification["payload"]["attachment_point"].asInteger();
+			if (gSavedSettings.getBOOL("MultipleAttachments"))
+				attachment_pt |= ATTACHMENT_ADD;
 
 			LLMessageSystem* msg = gMessageSystem;
 			msg->newMessageFast(_PREHASH_RezSingleAttachmentFromInv);
@@ -4118,7 +4111,6 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 			{
 				items.push_back(std::string("Wearable And Object Separator"));
 				items.push_back(std::string("Wearable And Object Wear"));
-				items.push_back(std::string("Wearable Add"));
 				items.push_back(std::string("Attach To"));
 				items.push_back(std::string("Attach To HUD"));
 				// commented out for DEV-32347
@@ -4127,7 +4119,6 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 				if (!gAgentAvatarp->canAttachMoreObjects())
 				{
 					disabled_items.push_back(std::string("Wearable And Object Wear"));
-					disabled_items.push_back(std::string("Wearable Add"));
 					disabled_items.push_back(std::string("Attach To"));
 					disabled_items.push_back(std::string("Attach To HUD"));
 				}
-- 
GitLab


From b619184d418bec1cdd2f4e0820ebbb05a7e19a02 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 12 Aug 2010 14:12:54 +0100
Subject: [PATCH 636/683] EXT-8589 FIXED Nothing happens if choose 'Invite to
 Group' from avatar's 3D context menu

The groups-chooser was auto-closing when the IW selection was lost, which in the case of right-clicking on (other) avatars is immediately.  The 'hg blame' is lost in merge-fubarism so I can't track why this behaviour was ever introduced, but I can think or (or find) no reason to autoclose in this case - the groups picker dialog doesn't even use the current selection, let alone care if it's lost.
---
 indra/newview/llfloatergroups.cpp | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp
index 0bd8215e5cd..307c937f6e5 100644
--- a/indra/newview/llfloatergroups.cpp
+++ b/indra/newview/llfloatergroups.cpp
@@ -47,7 +47,6 @@
 #include "llbutton.h"
 #include "llgroupactions.h"
 #include "llscrolllistctrl.h"
-#include "llselectmgr.h"
 #include "lltextbox.h"
 #include "lluictrlfactory.h"
 #include "lltrans.h"
@@ -90,15 +89,13 @@ BOOL LLFloaterGroupPicker::postBuild()
 		list_ctrl->setContextMenu(LLScrollListCtrl::MENU_GROUP);
 	}
 	
-	LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterGroupPicker::onBtnCancel, this));
-
 	childSetAction("OK", onBtnOK, this);
 
 	childSetAction("Cancel", onBtnCancel, this);
 
 	setDefaultBtn("OK");
 
-	getChildView("OK")->setEnabled(TRUE);
+	childEnable("OK");
 
 	return TRUE;
 }
@@ -179,8 +176,8 @@ void LLPanelGroups::reset()
 	{
 		group_list->operateOnAll(LLCtrlListInterface::OP_DELETE);
 	}
-	getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.count()));
-	getChild<LLUICtrl>("groupcount")->setTextArg("[MAX]", llformat("%d",MAX_AGENT_GROUPS));
+	childSetTextArg("groupcount", "[COUNT]", llformat("%d",gAgent.mGroups.count()));
+	childSetTextArg("groupcount", "[MAX]", llformat("%d",MAX_AGENT_GROUPS));
 
 	init_group_list(getChild<LLScrollListCtrl>("group list"), gAgent.getGroupID());
 	enableButtons();
@@ -190,8 +187,8 @@ BOOL LLPanelGroups::postBuild()
 {
 	childSetCommitCallback("group list", onGroupList, this);
 
-	getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.count()));
-	getChild<LLUICtrl>("groupcount")->setTextArg("[MAX]", llformat("%d",MAX_AGENT_GROUPS));
+	childSetTextArg("groupcount", "[COUNT]", llformat("%d",gAgent.mGroups.count()));
+	childSetTextArg("groupcount", "[MAX]", llformat("%d",MAX_AGENT_GROUPS));
 
 	LLScrollListCtrl *list = getChild<LLScrollListCtrl>("group list");
 	if (list)
@@ -231,25 +228,25 @@ void LLPanelGroups::enableButtons()
 
 	if(group_id != gAgent.getGroupID())
 	{
-		getChildView("Activate")->setEnabled(TRUE);
+		childEnable("Activate");
 	}
 	else
 	{
-		getChildView("Activate")->setEnabled(FALSE);
+		childDisable("Activate");
 	}
 	if (group_id.notNull())
 	{
-		getChildView("Info")->setEnabled(TRUE);
-		getChildView("IM")->setEnabled(TRUE);
-		getChildView("Leave")->setEnabled(TRUE);
+		childEnable("Info");
+		childEnable("IM");
+		childEnable("Leave");
 	}
 	else
 	{
-		getChildView("Info")->setEnabled(FALSE);
-		getChildView("IM")->setEnabled(FALSE);
-		getChildView("Leave")->setEnabled(FALSE);
+		childDisable("Info");
+		childDisable("IM");
+		childDisable("Leave");
 	}
-	getChildView("Create")->setEnabled(gAgent.canJoinGroups());
+	childSetEnabled("Create", gAgent.canJoinGroups());
 }
 
 
-- 
GitLab


From acab27b04e8fd649476d28abda4de2c2e390d274 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Thu, 12 Aug 2010 16:13:48 +0300
Subject: [PATCH 637/683] EXT-8629 FIXED Enable the Wear button in My Outfits
 for outfits that are subsets of the current outfit.

We allowed wearing any outfit that contains non-worn items.
Now it appears to be wrong, therefore and I changed condition so that
we allow wearing any outfit (or folder) that contains the full set of body parts.

Reviewed by Sergey Litovchuk at https://codereview.productengine.com/secondlife/r/855/

--HG--
branch : product-engine
---
 indra/newview/llappearancemgr.cpp | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index cecb2ee6ad6..6fdd71bfbfa 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1012,7 +1012,7 @@ bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, bool do_up
 		addCOFItemLink(item_to_wear, do_update, cb);
 		break;
 	case LLAssetType::AT_OBJECT:
-		rez_attachment(item_to_wear, NULL, replace);
+		rez_attachment(item_to_wear, NULL);
 		break;
 	default: return false;;
 	}
@@ -1305,16 +1305,8 @@ bool LLAppearanceMgr::getCanReplaceCOF(const LLUUID& outfit_cat_id)
 		return false;
 	}
 
-	// Check whether the outfit contains any non-worn wearables.
-	LLInventoryModel::cat_array_t cats;
-	LLInventoryModel::item_array_t items;
-	LLFindWearablesEx not_worn(/*is_worn=*/ false, /*include_body_parts=*/ true);
-	gInventory.collectDescendentsIf(outfit_cat_id,
-		cats,
-		items,
-		LLInventoryModel::EXCLUDE_TRASH,
-		not_worn);
-	return items.size() > 0;
+	// Check whether the outfit contains the full set of body parts (shape+skin+hair+eyes).
+	return getCanMakeFolderIntoOutfit(outfit_cat_id);
 }
 
 void LLAppearanceMgr::purgeBaseOutfitLink(const LLUUID& category)
@@ -1836,9 +1828,9 @@ void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool
 	llinfos << "wearInventoryCategory( " << category->getName()
 			 << " )" << llendl;
 
-	callAfterCategoryFetch(category->getUUID(),boost::bind(&LLAppearanceMgr::wearCategoryFinal,
-														   &LLAppearanceMgr::instance(),
-														   category->getUUID(), copy, append));
+	callAfterCategoryFetch(category->getUUID(), boost::bind(&LLAppearanceMgr::wearCategoryFinal,
+															&LLAppearanceMgr::instance(),
+															category->getUUID(), copy, append));
 }
 
 void LLAppearanceMgr::wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append)
-- 
GitLab


From 0355910ba5b0ed56aabcf290f940987ad5aec1b4 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Thu, 12 Aug 2010 16:16:57 +0300
Subject: [PATCH 638/683] EXT-8473 FIXED Fixed renaming inventory items without
 hitting Enter.

Problem:

The bug was caused by the fix of EXT-6682 that prematurely forgets the item
being renamed (by resetting mRenameItem) whenever the renamer input field loses focus.
That's why we couldn't actually finish renaming item.

Fix:

The code is quite messy, but I'll try to explain.

There are three cases when we should hide the renamer:
1) ESC key is hit (just hide).
2) ENTER key is hit (rename, then hide).
3) renamer loses focus (rename, then hide).

In the first two cases we manually remove the renamer from the popups
list -- by calling gViewerWindow->removePopup(mRenamer).
In the third case that's done automatically.
So, in all cases the onRenamerLost() pop-up is called that hides the renamer
and only *then* resets mRenameItem.
Not only this approach fixes the bug -- I hope it's a bit more straightforward too.

Reviewed by Seraph at https://codereview.productengine.com/secondlife/r/854/

--HG--
branch : product-engine
---
 indra/newview/llfolderview.cpp | 67 ++++++++++++----------------------
 indra/newview/llfolderview.h   |  6 +--
 2 files changed, 26 insertions(+), 47 deletions(-)

diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index ab36a761534..81f00af9486 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -62,7 +62,6 @@
 #include "llviewerwindow.h"
 #include "llvoavatar.h"
 #include "llfloaterproperties.h"
-#include "llnotificationsutil.h"
 
 // Linden library includes
 #include "lldbstrings.h"
@@ -105,7 +104,6 @@ void copy_selected_item(void* user_data);
 void open_selected_items(void* user_data);
 void properties_selected_items(void* user_data);
 void paste_items(void* user_data);
-void renamer_focus_lost( LLFocusableElement* handler, void* user_data );
 
 
 //---------------------------------------------------------------------------
@@ -185,6 +183,7 @@ LLFolderView::LLFolderView(const Params& p)
 	mSourceID(p.task_id),
 	mRenameItem( NULL ),
 	mNeedsScroll( FALSE ),
+	mEnableScroll( true ),
 	mUseLabelSuffix(p.use_label_suffix),
 	mPinningSelectedItem(FALSE),
 	mNeedsAutoSelect( FALSE ),
@@ -250,7 +249,7 @@ LLFolderView::LLFolderView(const Params& p)
 	text_p.name(std::string(p.name));
 	text_p.font(font);
 	text_p.visible(false);
-	text_p.parse_urls(true);
+	text_p.allow_html(true);
 	text_p.wrap(true); // allow multiline text. See EXT-7564, EXT-7047
 	// set text padding the same as in People panel. EXT-7047, EXT-4837
 	text_p.h_pad(STATUS_TEXT_HPAD);
@@ -275,6 +274,8 @@ LLFolderView::LLFolderView(const Params& p)
 // Destroys the object
 LLFolderView::~LLFolderView( void )
 {
+	closeRenamer();
+
 	// The release focus call can potentially call the
 	// scrollcontainer, which can potentially be called with a partly
 	// destroyed scollcontainer. Just null it out here, and no worries
@@ -290,8 +291,6 @@ LLFolderView::~LLFolderView( void )
 
 	LLView::deleteViewByHandle(mPopupMenuHandle);
 
-	gViewerWindow->removePopup(mRenamer);
-
 	mAutoOpenItems.removeAllNodes();
 	clearSelection();
 	mItems.clear();
@@ -998,12 +997,7 @@ void LLFolderView::finishRenamingItem( void )
 		mRenameItem->rename( mRenamer->getText() );
 	}
 
-	gViewerWindow->removePopup(mRenamer);
-
-	if( mRenameItem )
-	{
-		setSelectionFromRoot( mRenameItem, TRUE );
-	}
+	closeRenamer();
 
 	// List is re-sorted alphabeticly, so scroll to make sure the selected item is visible.
 	scrollToShowSelection();
@@ -1011,31 +1005,15 @@ void LLFolderView::finishRenamingItem( void )
 
 void LLFolderView::closeRenamer( void )
 {
-	// will commit current name (which could be same as original name)
-	mRenamer->setFocus( FALSE );
-	mRenamer->setVisible( FALSE );
-	gViewerWindow->removePopup(mRenamer);
-
-	if( mRenameItem )
+	if (mRenamer && mRenamer->getVisible())
 	{
-		setSelectionFromRoot( mRenameItem, TRUE );
-		mRenameItem = NULL;
+		// Triggers onRenamerLost() that actually closes the renamer.
+		gViewerWindow->removePopup(mRenamer);
 	}
 }
 
 void LLFolderView::removeSelectedItems( void )
 {
-	if (mSelectedItems.empty()) return;
-	LLSD args;
-	args["QUESTION"] = LLTrans::getString(mSelectedItems.size() > 1 ? "DeleteItems" :  "DeleteItem");
-	LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLFolderView::onItemsRemovalConfirmation, this, _1, _2));
-}
-
-void LLFolderView::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response)
-{
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	if (option != 0) return; // canceled
-
 	if(getVisible() && getEnabled())
 	{
 		// just in case we're removing the renaming item.
@@ -1455,8 +1433,7 @@ void LLFolderView::startRenamingSelectedItem( void )
 		mRenamer->setVisible( TRUE );
 		// set focus will fail unless item is visible
 		mRenamer->setFocus( TRUE );
-		mRenamer->setTopLostCallback(boost::bind(&LLFolderView::onRenamerLost, this, _1));
-		mRenamer->setFocusLostCallback(boost::bind(&LLFolderView::onRenamerLost, this, _1));
+		mRenamer->setTopLostCallback(boost::bind(&LLFolderView::onRenamerLost, this));
 		gViewerWindow->addPopup(mRenamer);
 	}
 }
@@ -1977,10 +1954,7 @@ BOOL LLFolderView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 
 void LLFolderView::deleteAllChildren()
 {
-	if(mRenamer == gFocusMgr.getTopCtrl())
-	{
-		gViewerWindow->removePopup(mRenamer);
-	}
+	closeRenamer();
 	LLView::deleteViewByHandle(mPopupMenuHandle);
 	mPopupMenuHandle = LLHandle<LLView>();
 	mRenamer = NULL;
@@ -1991,9 +1965,7 @@ void LLFolderView::deleteAllChildren()
 
 void LLFolderView::scrollToShowSelection()
 {
-	// If items are filtered while background fetch is in progress
-	// scrollbar resets to the first filtered item. See EXT-3981.
-	if (!LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && mSelectedItems.size())
+	if (mEnableScroll && mSelectedItems.size())
 	{
 		mNeedsScroll = TRUE;
 	}
@@ -2465,13 +2437,20 @@ S32	LLFolderView::notify(const LLSD& info)
 /// Local function definitions
 ///----------------------------------------------------------------------------
 
-void LLFolderView::onRenamerLost( LLFocusableElement* renamer)
+void LLFolderView::onRenamerLost()
 {
-	mRenameItem = NULL;
-	LLUICtrl* uictrl = dynamic_cast<LLUICtrl*>(renamer);
-	if (uictrl)
+	if (mRenamer && mRenamer->getVisible())
 	{
-		uictrl->setVisible(FALSE);
+		mRenamer->setVisible(FALSE);
+
+		// will commit current name (which could be same as original name)
+		mRenamer->setFocus(FALSE);
+	}
+
+	if( mRenameItem )
+	{
+		setSelectionFromRoot( mRenameItem, TRUE );
+		mRenameItem = NULL;
 	}
 }
 
diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h
index f5f229a6029..31352d04bfe 100644
--- a/indra/newview/llfolderview.h
+++ b/indra/newview/llfolderview.h
@@ -274,6 +274,7 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
 	void dumpSelectionInformation();
 
 	virtual S32	notify(const LLSD& info) ;
+	void setEnableScroll(bool enable_scroll) { mEnableScroll = enable_scroll; }
 	
 	bool useLabelSuffix() { return mUseLabelSuffix; }
 private:
@@ -283,7 +284,7 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
 	LLScrollContainer* mScrollContainer;  // NULL if this is not a child of a scroll container.
 
 	void commitRename( const LLSD& data );
-	void onRenamerLost( LLFocusableElement* renamer);
+	void onRenamerLost();
 
 	void finishRenamingItem( void );
 	void closeRenamer( void );
@@ -293,8 +294,6 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
 	
 	BOOL addNoOptions(LLMenuGL* menu) const;
 
-	void onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response);
-
 protected:
 	LLHandle<LLView>					mPopupMenuHandle;
 	
@@ -310,6 +309,7 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
 	LLLineEditor*					mRenamer;
 
 	BOOL							mNeedsScroll;
+	bool							mEnableScroll;
 	BOOL							mPinningSelectedItem;
 	LLRect							mScrollConstraintRect;
 	BOOL							mNeedsAutoSelect;
-- 
GitLab


From a49a4e84a03adb63e4cb4a7ee3ad9202b3aa5361 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 12 Aug 2010 14:20:33 +0100
Subject: [PATCH 639/683] Fix a bunch of typos in new enums, one of which was
 causing a build failure.

---
 indra/newview/llpaneloutfitedit.cpp   |  2 +-
 indra/newview/llwearableitemslist.cpp |  8 ++++----
 indra/newview/llwearableitemslist.h   | 20 ++++++++++----------
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index c567f006a9c..cfd31b68292 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -553,7 +553,7 @@ BOOL LLPanelOutfitEdit::postBuild()
 	 *  - each LLWearableType::EType by name (EXT-8205)
 	*/
 	mWearableListViewItemsComparator = new LLWearableItemTypeNameComparator();
-	mWearableListViewItemsComparator->setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANG_1, false, true);
+	mWearableListViewItemsComparator->setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANK_1, false, true);
 
 	mWearablesListViewPanel = getChild<LLPanel>("filtered_wearables_panel");
 	mWearableItemsList = getChild<LLWearableItemsList>("list_view");
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 76ecd28b522..4d916db7149 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -478,9 +478,9 @@ LLWearableItemTypeNameComparator::LLWearableItemTypeNameComparator()
 	// 1. CLOTHING - sorted by name
 	// 2. OBJECT   - sorted by type
 	// 3. BODYPART - sorted by name
-	mWearableOrder[LLAssetType::AT_CLOTHING] = LLWearableTypeOrder(ORDER_RANG_1, false, false);
-	mWearableOrder[LLAssetType::AT_OBJECT]   = LLWearableTypeOrder(ORDER_RANG_2, true, true);
-	mWearableOrder[LLAssetType::AT_BODYPART] = LLWearableTypeOrder(ORDER_RANG_3, false, true);
+	mWearableOrder[LLAssetType::AT_CLOTHING] = LLWearableTypeOrder(ORDER_RANK_1, false, false);
+	mWearableOrder[LLAssetType::AT_OBJECT]   = LLWearableTypeOrder(ORDER_RANK_2, true, true);
+	mWearableOrder[LLAssetType::AT_BODYPART] = LLWearableTypeOrder(ORDER_RANK_3, false, true);
 }
 
 void LLWearableItemTypeNameComparator::setOrder(LLAssetType::EType items_of_type,  LLWearableItemTypeNameComparator::ETypeListOrder order_priority, bool sort_asset_items_by_name, bool sort_wearable_items_by_name)
@@ -555,7 +555,7 @@ LLWearableItemTypeNameComparator::ETypeListOrder LLWearableItemTypeNameComparato
 	if(const_it == mWearableOrder.end())
 	{
 		llwarns<<"Absent information about order rang of items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
-		return ORDER_RANG_UNKNOWN;
+		return ORDER_RANK_UNKNOWN;
 	}
 
 	return const_it->second.mOrderPriority;
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index 06b449c6e4b..b5e64abad0c 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -313,10 +313,10 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 
 	enum ETypeListOrder
 	{
-		ORDER_RANG_1 = 1,
-		ORDER_RANG_2,
-		ORDER_RANG_3,
-		ORDER_RANG_UNKNOWN
+		ORDER_RANK_1 = 1,
+		ORDER_RANK_2,
+		ORDER_RANK_3,
+		ORDER_RANK_UNKNOWN
 	};
 
 	void setOrder(LLAssetType::EType items_of_type, ETypeListOrder order_priority, bool sort_items_by_name, bool sort_wearable_items_by_name);
@@ -325,15 +325,15 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 	/**
 	 * All information about sort order is stored in mWearableOrder map
 	 *
-	 * mWearableOrder :      KEYES              VALUES
+	 * mWearableOrder :      KEYS              VALUES
 	 *                  [LLAssetType] [struct LLWearableTypeOrder]
 	 *
 	 *---------------------------------------------------------------------------------------------
-	 * I. Determines order (ORDER_RANG) in which items of LLAssetType should be displayed in list.
+	 * I. Determines order (ORDER_RANK) in which items of LLAssetType should be displayed in list.
 	 *     For example by spec in MY OUTFITS the order is:
-	 *     1. AT_CLOTHING (ORDER_RANG_1)
-	 *     2. AT_OBJECT   (ORDER_RANG_2)
-	 *     3. AT_BODYPART (ORDER_RANG_3)
+	 *     1. AT_CLOTHING (ORDER_RANK_1)
+	 *     2. AT_OBJECT   (ORDER_RANK_2)
+	 *     3. AT_BODYPART (ORDER_RANK_3)
 	 *
 	 * II.Items of each type(LLAssetType) are sorted by name or type(LLWearableType)
 	 *     For example by spec in MY OUTFITS the order within each items type(LLAssetType) is:
@@ -346,7 +346,7 @@ class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
 	 *
 	 * For each LLAssetType (KEYS in mWearableOrder) the information about:
 	 *
-	 *                                             I.  ORDER_RANG (the flag is LLWearableTypeOrder::mOrderPriority)
+	 *                                             I.  ORDER_RANK (the flag is LLWearableTypeOrder::mOrderPriority)
 	 *
 	 *                                             II. whether items of this LLAssetType type should be ordered
 	 *                                                 by name or by LLWearableType::EType (the flag is LLWearableTypeOrder::mSortAssetTypeByName)
-- 
GitLab


From 26b0d657f5a2c054aae6e1a1a9a4382bb2c984db Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Thu, 12 Aug 2010 11:00:39 -0400
Subject: [PATCH 640/683] DEV-52580 WIP: disallow multiple links to the same
 attachment in updateAppearanceFromCOF()

---
 indra/newview/llappearancemgr.cpp | 88 +++++++++++++++++--------------
 indra/newview/llappearancemgr.h   |  6 ++-
 2 files changed, 54 insertions(+), 40 deletions(-)

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index cecb2ee6ad6..5a076845da2 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1012,7 +1012,7 @@ bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, bool do_up
 		addCOFItemLink(item_to_wear, do_update, cb);
 		break;
 	case LLAssetType::AT_OBJECT:
-		rez_attachment(item_to_wear, NULL, replace);
+		rez_attachment(item_to_wear, NULL);
 		break;
 	default: return false;;
 	}
@@ -1608,46 +1608,56 @@ void item_array_diff(LLInventoryModel::item_array_t& full_list,
 	}
 }
 
-void LLAppearanceMgr::enforceItemCountLimits()
+S32 LLAppearanceMgr::findExcessOrDuplicateItems(const LLUUID& cat_id,
+												 LLAssetType::EType type,
+												 S32 max_items,
+												 LLInventoryModel::item_array_t& items_to_kill)
 {
-	S32 purge_count = 0;
-	
-	LLInventoryModel::item_array_t body_items;
-	getDescendentsOfAssetType(getCOF(), body_items, LLAssetType::AT_BODYPART, false);
-	LLInventoryModel::item_array_t curr_body_items = body_items;
-	removeDuplicateItems(body_items);
-	filterWearableItems(body_items, 1);
-	LLInventoryModel::item_array_t kill_body_items;
-	item_array_diff(curr_body_items,body_items,kill_body_items);
-	for (LLInventoryModel::item_array_t::iterator it = kill_body_items.begin();
-		 it != kill_body_items.end();
-		 ++it)
+	S32 to_kill_count = 0;
+
+	LLInventoryModel::item_array_t items;
+	getDescendentsOfAssetType(cat_id, items, type, false);
+	LLInventoryModel::item_array_t curr_items = items;
+	removeDuplicateItems(items);
+	if (max_items > 0)
 	{
-		LLViewerInventoryItem *item = *it;
-		llinfos << "purging dup body part " << item->getName() << llendl;
-		gInventory.purgeObject(item->getUUID());
-		purge_count++;
+		filterWearableItems(items, max_items);
 	}
-	
-	LLInventoryModel::item_array_t wear_items;
-	getDescendentsOfAssetType(getCOF(), wear_items, LLAssetType::AT_CLOTHING, false);
-	LLInventoryModel::item_array_t curr_wear_items = wear_items;
-	removeDuplicateItems(wear_items);
-	filterWearableItems(wear_items, LLAgentWearables::MAX_CLOTHING_PER_TYPE);
-	LLInventoryModel::item_array_t kill_wear_items;
-	item_array_diff(curr_wear_items,wear_items,kill_wear_items);
-	for (LLInventoryModel::item_array_t::iterator it = kill_wear_items.begin();
-		 it != kill_wear_items.end();
+	LLInventoryModel::item_array_t kill_items;
+	item_array_diff(curr_items,items,kill_items);
+	for (LLInventoryModel::item_array_t::iterator it = kill_items.begin();
+		 it != kill_items.end();
 		 ++it)
 	{
-		LLViewerInventoryItem *item = *it;
-		llinfos << "purging excess clothing item " << item->getName() << llendl;
-		gInventory.purgeObject(item->getUUID());
-		purge_count++;
+		items_to_kill.push_back(*it);
+		to_kill_count++;
 	}
+	return to_kill_count;
+}
+	
+												 
+void LLAppearanceMgr::enforceItemRestrictions()
+{
+	S32 purge_count = 0;
+	LLInventoryModel::item_array_t items_to_kill;
 
-	if (purge_count>0)
+	purge_count += findExcessOrDuplicateItems(getCOF(),LLAssetType::AT_BODYPART,
+											  1, items_to_kill);
+	purge_count += findExcessOrDuplicateItems(getCOF(),LLAssetType::AT_CLOTHING,
+											  LLAgentWearables::MAX_CLOTHING_PER_TYPE, items_to_kill);
+	purge_count += findExcessOrDuplicateItems(getCOF(),LLAssetType::AT_OBJECT,
+											  -1, items_to_kill);
+
+	if (items_to_kill.size()>0)
 	{
+		for (LLInventoryModel::item_array_t::iterator it = items_to_kill.begin();
+			 it != items_to_kill.end();
+			 ++it)
+		{
+			LLViewerInventoryItem *item = *it;
+			llinfos << "purging duplicate or excess item " << item->getName() << llendl;
+			gInventory.purgeObject(item->getUUID());
+		}
 		gInventory.notifyObservers();
 	}
 }
@@ -1670,7 +1680,7 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering)
 
 	// Remove duplicate or excess wearables. Should normally be enforced at the UI level, but
 	// this should catch anything that gets through.
-	enforceItemCountLimits();
+	enforceItemRestrictions();
 	
 	// update dirty flag to see if the state of the COF matches
 	// the saved outfit stored as a folder link
@@ -1836,9 +1846,9 @@ void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool
 	llinfos << "wearInventoryCategory( " << category->getName()
 			 << " )" << llendl;
 
-	callAfterCategoryFetch(category->getUUID(),boost::bind(&LLAppearanceMgr::wearCategoryFinal,
-														   &LLAppearanceMgr::instance(),
-														   category->getUUID(), copy, append));
+	callAfterCategoryFetch(category->getUUID(), boost::bind(&LLAppearanceMgr::wearCategoryFinal,
+															&LLAppearanceMgr::instance(),
+															category->getUUID(), copy, append));
 }
 
 void LLAppearanceMgr::wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append)
@@ -2741,8 +2751,8 @@ bool LLAppearanceMgr::isLinkInCOF(const LLUUID& obj_id)
 	 LLInventoryModel::item_array_t items;
 	 LLLinkedItemIDMatches find_links(gInventory.getLinkedItemID(obj_id));
 	 gInventory.collectDescendentsIf(LLAppearanceMgr::instance().getCOF(),
-	 cats,
-	 items,
+									 cats,
+									 items,
 	 LLInventoryModel::EXCLUDE_TRASH,
 	 find_links);
 
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index eb495bd2746..796ac5c572e 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -66,7 +66,11 @@ class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr>
 	void renameOutfit(const LLUUID& outfit_id);
 	void takeOffOutfit(const LLUUID& cat_id);
 	void addCategoryToCurrentOutfit(const LLUUID& cat_id);
-	void enforceItemCountLimits();
+	S32 findExcessOrDuplicateItems(const LLUUID& cat_id,
+								   LLAssetType::EType type,
+								   S32 max_items,
+								   LLInventoryModel::item_array_t& items_to_kill);
+	void enforceItemRestrictions();
 
 	// Copy all items and the src category itself.
 	void shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id,
-- 
GitLab


From ddd7a3ebb58fb56fe100b4fe2dc0e5e8076948d6 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 12 Aug 2010 11:40:54 -0500
Subject: [PATCH 641/683] Make rigged attachments respect "Show me in
 mouselook" option.

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

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index c7e77fd6ba9..ef1d2ec1c52 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -38,6 +38,7 @@
 #include "llvoavatar.h"
 #include "m3math.h"
 
+#include "llagent.h" //for gAgent.needsRenderAvatar()
 #include "lldrawable.h"
 #include "lldrawpoolbump.h"
 #include "llface.h"
@@ -1274,6 +1275,11 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSk
 
 void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 {
+	if (avatar->isSelf() && !gAgent.needsRenderAvatar())
+	{
+		return;
+	}
+
 	for (U32 i = 0; i < mRiggedFace[type].size(); ++i)
 	{
 		LLFace* face = mRiggedFace[type][i];
-- 
GitLab


From 8348480edeb2ee52cf8f17880d311e60de7ea8f2 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 12 Aug 2010 15:11:05 -0500
Subject: [PATCH 642/683] Make it possible to set a face to 100% transparent
 without scripts or other hackery.

---
 indra/newview/skins/default/xui/en/floater_tools.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index 8a6cae9bb17..b0e8f29a0a0 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -2439,7 +2439,7 @@ even though the user gets a free copy.
              initial_value="0"
              layout="topleft"
              left_delta="0"
-             max_val="90"
+             max_val="100"
              name="ColorTrans"
              top_pad="4"
              width="80" />
-- 
GitLab


From 340a729d55983110a85cfc55f1ce0a952bfe15b4 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 12 Aug 2010 17:05:40 -0500
Subject: [PATCH 643/683] Vertex buffer cleanup, adding water shader to simple
 rigged attachments.

Reviewed by Nyx.
---
 indra/llrender/llvertexbuffer.cpp   | 232 ++++------------------------
 indra/llrender/llvertexbuffer.h     |  20 +--
 indra/newview/lldrawpoolavatar.cpp  |  32 ++--
 indra/newview/llviewershadermgr.cpp |  25 +++
 indra/newview/llviewershadermgr.h   |   5 +
 indra/newview/llvosurfacepatch.cpp  |  22 +--
 indra/newview/llvovolume.cpp        |   6 +-
 indra/newview/llvowlsky.cpp         |   2 +-
 8 files changed, 105 insertions(+), 239 deletions(-)

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 9783435e2fb..71620feed37 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -68,11 +68,8 @@ S32	LLVertexBuffer::sWeight4Loc = -1;
 
 std::vector<U32> LLVertexBuffer::sDeleteList;
 
-#define LL_ALIGNED_VB 1
 
-#if LL_ALIGNED_VB
-
-S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
+S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] =
 {
 	sizeof(LLVector4), // TYPE_VERTEX,
 	sizeof(LLVector4), // TYPE_NORMAL,
@@ -87,25 +84,6 @@ S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
 	sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
 };
 
-#else
-
-S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
-{
-	sizeof(LLVector3), // TYPE_VERTEX,
-	sizeof(LLVector3), // TYPE_NORMAL,
-	sizeof(LLVector2), // TYPE_TEXCOORD0,
-	sizeof(LLVector2), // TYPE_TEXCOORD1,
-	sizeof(LLVector2), // TYPE_TEXCOORD2,
-	sizeof(LLVector2), // TYPE_TEXCOORD3,
-	sizeof(LLColor4U), // TYPE_COLOR,
-	sizeof(LLVector3), // TYPE_BINORMAL,
-	sizeof(F32),	   // TYPE_WEIGHT,
-	sizeof(LLVector4), // TYPE_WEIGHT4,
-	sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
-};
-
-#endif
-
 U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = 
 {
 	GL_TRIANGLES,
@@ -460,19 +438,22 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
 		mUsage = 0;
 	}
 
-	S32 stride = calcStride(typemask, mOffsets);
+	//zero out offsets
+	for (U32 i = 0; i < TYPE_MAX; i++)
+	{
+		mOffsets[i] = 0;
+	}
 
 	mTypeMask = typemask;
-	mStride = stride;
+	mSize = 0;
 	mAlignedOffset = 0;
 	mAlignedIndexOffset = 0;
 
 	sCount++;
 }
 
-#if LL_ALIGNED_VB
 //static
-S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets, S32 num_vertices)
+S32 LLVertexBuffer::calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices)
 {
 	S32 offset = 0;
 	for (S32 i=0; i<TYPE_MAX; i++)
@@ -483,7 +464,7 @@ S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets, S32 num_vertic
 			if (offsets)
 			{
 				offsets[i] = offset;
-				offset += LLVertexBuffer::sTypeOffsets[i]*num_vertices;
+				offset += LLVertexBuffer::sTypeSize[i]*num_vertices;
 				offset = (offset + 0xF) & ~0xF;
 			}
 		}
@@ -492,38 +473,27 @@ S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets, S32 num_vertic
 	return offset+16;
 }
 
-S32 LLVertexBuffer::getSize() const
-{
-	return mStride;
-}
-
-#else
-//static
-S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets, S32 num_vertices)
+//static 
+S32 LLVertexBuffer::calcVertexSize(const U32& typemask)
 {
-	S32 stride = 0;
-	for (S32 i=0; i<TYPE_MAX; i++)
+	S32 size = 0;
+	for (S32 i = 0; i < TYPE_MAX; i++)
 	{
 		U32 mask = 1<<i;
 		if (typemask & mask)
 		{
-			if (offsets)
-			{
-				offsets[i] = stride;
-			}
-			stride += sTypeOffsets[i];
+			size += LLVertexBuffer::sTypeSize[i];
 		}
 	}
 
-	return stride;
+	return size;
 }
 
 S32 LLVertexBuffer::getSize() const
-{ 
-	return mNumVerts*mStride; 
+{
+	return mSize;
 }
 
-#endif
 // protected, use unref()
 //virtual
 LLVertexBuffer::~LLVertexBuffer()
@@ -634,7 +604,6 @@ void LLVertexBuffer::createGLBuffer()
 		static int gl_buffer_idx = 0;
 		mGLBuffer = ++gl_buffer_idx;
 		mMappedData = (U8*) ll_aligned_malloc_16(size);
-		memset(mMappedData, 0, size);
 	}
 }
 
@@ -756,10 +725,7 @@ void LLVertexBuffer::updateNumVerts(S32 nverts)
 		}
 		mNumVerts = nverts;
 	}
-#if LL_ALIGNED_VB
-	mStride = calcStride(mTypeMask, mOffsets, mNumVerts);
-#endif
-
+	mSize = calcOffsets(mTypeMask, mOffsets, mNumVerts);
 }
 
 void LLVertexBuffer::updateNumIndices(S32 nindices)
@@ -1027,8 +993,6 @@ void LLVertexBuffer::unmapBuffer()
 
 //----------------------------------------------------------------------------
 
-#if LL_ALIGNED_VB
-
 template <class T,S32 type> struct VertexBufferStrider
 {
 	typedef LLStrider<T> strider_t;
@@ -1051,7 +1015,7 @@ template <class T,S32 type> struct VertexBufferStrider
 		}
 		else if (vbo.hasDataType(type))
 		{
-			S32 stride = LLVertexBuffer::sTypeOffsets[type];
+			S32 stride = LLVertexBuffer::sTypeSize[type];
 			strider = (T*)(vbo.getMappedData() + vbo.getOffset(type)+index*stride);
 			strider.setStride(stride);
 			return TRUE;
@@ -1064,45 +1028,6 @@ template <class T,S32 type> struct VertexBufferStrider
 	}
 };
 
-#else
-
-template <class T,S32 type> struct VertexBufferStrider
-{
-	typedef LLStrider<T> strider_t;
-	static bool get(LLVertexBuffer& vbo, 
-					strider_t& strider, 
-					S32 index)
-	{
-		if (vbo.mapBuffer() == NULL)
-		{
-			llwarns << "mapBuffer failed!" << llendl;
-			return FALSE;
-		}
-
-		if (type == LLVertexBuffer::TYPE_INDEX)
-		{
-			S32 stride = sizeof(T);
-			strider = (T*)(vbo.getMappedIndices() + index*stride);
-			strider.setStride(0);
-			return TRUE;
-		}
-		else if (vbo.hasDataType(type))
-		{
-			S32 stride = vbo.getStride();
-			strider = (T*)(vbo.getMappedData() + vbo.getOffset(type) + index*stride);
-			strider.setStride(stride);
-			return TRUE;
-		}
-		else
-		{
-			llerrs << "VertexBufferStrider could not find valid vertex data." << llendl;
-		}
-		return FALSE;
-	}
-};
-
-#endif
-
 bool LLVertexBuffer::getVertexStrider(LLStrider<LLVector3>& strider, S32 index)
 {
 	return VertexBufferStrider<LLVector3,TYPE_VERTEX>::get(*this, strider, index);
@@ -1154,25 +1079,6 @@ bool LLVertexBuffer::getClothWeightStrider(LLStrider<LLVector4>& strider, S32 in
 	return VertexBufferStrider<LLVector4,TYPE_CLOTHWEIGHT>::get(*this, strider, index);
 }
 
-void LLVertexBuffer::setStride(S32 type, S32 new_stride)
-{
-	LLMemType mt2(LLMemType::MTYPE_VERTEX_SET_STRIDE);
-	if (mNumVerts)
-	{
-		llerrs << "LLVertexBuffer::setOffset called with mNumVerts = " << mNumVerts << llendl;
-	}
-	// This code assumes that setStride() will only be called once per VBO per type.
-	S32 delta = new_stride - sTypeOffsets[type];
-	for (S32 i=type+1; i<TYPE_MAX; i++)
-	{
-		if (mTypeMask & (1<<i))
-		{
-			mOffsets[i] += delta;
-		}
-	}
-	mStride += delta;
-}
-
 //----------------------------------------------------------------------------
 
 // Set for rendering
@@ -1364,8 +1270,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 	}
 }
 
-#if LL_ALIGNED_VB
-
 // virtual (default)
 void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
 {
@@ -1380,139 +1284,63 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
 
 	if (data_mask & MAP_NORMAL)
 	{
-		glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
-	}
-	if (data_mask & MAP_TEXCOORD3)
-	{
-		glClientActiveTextureARB(GL_TEXTURE3_ARB);
-		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD3], (void*)(base + mOffsets[TYPE_TEXCOORD3]));
-		glClientActiveTextureARB(GL_TEXTURE0_ARB);
-	}
-	if (data_mask & MAP_TEXCOORD2)
-	{
-		glClientActiveTextureARB(GL_TEXTURE2_ARB);
-		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD2], (void*)(base + mOffsets[TYPE_TEXCOORD2]));
-		glClientActiveTextureARB(GL_TEXTURE0_ARB);
-	}
-	if (data_mask & MAP_TEXCOORD1)
-	{
-		glClientActiveTextureARB(GL_TEXTURE1_ARB);
-		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
-		glClientActiveTextureARB(GL_TEXTURE0_ARB);
-	}
-	if (data_mask & MAP_BINORMAL)
-	{
-		glClientActiveTextureARB(GL_TEXTURE2_ARB);
-		glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
-		glClientActiveTextureARB(GL_TEXTURE0_ARB);
-	}
-	if (data_mask & MAP_TEXCOORD0)
-	{
-		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
-	}
-	if (data_mask & MAP_COLOR)
-	{
-		glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeOffsets[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
-	}
-	
-	if (data_mask & MAP_WEIGHT)
-	{
-		glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeOffsets[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT]));
-	}
-
-	if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
-	{
-		glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeOffsets[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4]));
-	}
-
-	if (data_mask & MAP_CLOTHWEIGHT)
-	{
-		glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  LLVertexBuffer::sTypeOffsets[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
-	}
-	if (data_mask & MAP_VERTEX)
-	{
-		glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_VERTEX], (void*)(base + 0));
-	}
-
-	llglassertok();
-}
-
-#else
-
-// virtual (default)
-void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
-{
-	LLMemType mt2(LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER);
-	stop_glerror();
-	U8* base = useVBOs() ? NULL : mMappedData;
-	S32 stride = mStride;
-
-	if ((data_mask & mTypeMask) != data_mask)
-	{
-		llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl;
-	}
-
-	if (data_mask & MAP_NORMAL)
-	{
-		glNormalPointer(GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_NORMAL]));
+		glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
 	}
 	if (data_mask & MAP_TEXCOORD3)
 	{
 		glClientActiveTextureARB(GL_TEXTURE3_ARB);
-		glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD3]));
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD3], (void*)(base + mOffsets[TYPE_TEXCOORD3]));
 		glClientActiveTextureARB(GL_TEXTURE0_ARB);
 	}
 	if (data_mask & MAP_TEXCOORD2)
 	{
 		glClientActiveTextureARB(GL_TEXTURE2_ARB);
-		glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD2]));
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD2], (void*)(base + mOffsets[TYPE_TEXCOORD2]));
 		glClientActiveTextureARB(GL_TEXTURE0_ARB);
 	}
 	if (data_mask & MAP_TEXCOORD1)
 	{
 		glClientActiveTextureARB(GL_TEXTURE1_ARB);
-		glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD1]));
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
 		glClientActiveTextureARB(GL_TEXTURE0_ARB);
 	}
 	if (data_mask & MAP_BINORMAL)
 	{
 		glClientActiveTextureARB(GL_TEXTURE2_ARB);
-		glTexCoordPointer(3,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_BINORMAL]));
+		glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
 		glClientActiveTextureARB(GL_TEXTURE0_ARB);
 	}
 	if (data_mask & MAP_TEXCOORD0)
 	{
-		glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
 	}
 	if (data_mask & MAP_COLOR)
 	{
-		glColorPointer(4, GL_UNSIGNED_BYTE, stride, (void*)(base + mOffsets[TYPE_COLOR]));
+		glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeSize[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
 	}
 	
 	if (data_mask & MAP_WEIGHT)
 	{
-		glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, stride, (void*)(base + mOffsets[TYPE_WEIGHT]));
+		glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT]));
 	}
 
 	if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
 	{
-		glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, stride, (void*)(base+mOffsets[TYPE_WEIGHT4]));
+		glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4]));
 	}
 
 	if (data_mask & MAP_CLOTHWEIGHT)
 	{
-		glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  stride, (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
+		glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
 	}
 	if (data_mask & MAP_VERTEX)
 	{
-		glVertexPointer(3,GL_FLOAT, stride, (void*)(base + 0));
+		glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0));
 	}
 
 	llglassertok();
 }
 
-#endif
-
 void LLVertexBuffer::markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count)
 {
 	// TODO: use GL_APPLE_flush_buffer_range here
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 715309b64a2..bcd4b9f8289 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -74,7 +74,7 @@ class LLVBOPool : public LLGLNamePool
 
 
 //============================================================================
-// base class
+// base class 
 
 class LLVertexBuffer : public LLRefCount
 {
@@ -106,11 +106,14 @@ class LLVertexBuffer : public LLRefCount
 	static void unbind(); //unbind any bound vertex buffer
 
 	//get the size of a vertex with the given typemask
-	//if offsets is not NULL, its contents will be filled
-	//with the offset of each vertex component in the buffer, 
+	static S32 calcVertexSize(const U32& typemask);
+
+	//get the size of a buffer with the given typemask and vertex count
+	//fill offsets with the offset of each vertex component array into the buffer
 	// indexed by the following enum
-	static S32 calcStride(const U32& typemask, S32* offsets = NULL, S32 num_vertices = 0); 										
+	static S32 calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices);		
 
+	
 	enum {
 		TYPE_VERTEX,
 		TYPE_NORMAL,
@@ -199,8 +202,7 @@ class LLVertexBuffer : public LLRefCount
 	S32 getRequestedIndices() const			{ return mRequestedNumIndices; }
 
 	U8* getIndicesPointer() const			{ return useVBOs() ? (U8*) mAlignedIndexOffset : mMappedIndexData; }
-	U8* getVerticesPointer() const			{ return useVBOs() ? NULL : mMappedData; }
-	S32 getStride() const					{ return mStride; }
+	U8* getVerticesPointer() const			{ return useVBOs() ? (U8*) mAlignedOffset : mMappedData; }
 	U32 getTypeMask() const					{ return mTypeMask; }
 	BOOL hasDataType(S32 type) const		{ return ((1 << type) & getTypeMask()) ? TRUE : FALSE; }
 	S32 getSize() const;
@@ -210,8 +212,6 @@ class LLVertexBuffer : public LLRefCount
 	S32 getOffset(S32 type) const			{ return mOffsets[type]; }
 	S32 getUsage() const					{ return mUsage; }
 
-	void setStride(S32 type, S32 new_stride);
-	
 	void markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count);
 
 	void draw(U32 mode, U32 count, U32 indices_offset) const;
@@ -231,7 +231,7 @@ class LLVertexBuffer : public LLRefCount
 
 	ptrdiff_t mAlignedOffset;
 	ptrdiff_t mAlignedIndexOffset;
-	S32		mStride;
+	S32		mSize;
 	U32		mTypeMask;
 	S32		mUsage;			// GL usage
 	U32		mGLBuffer;		// GL VBO handle
@@ -270,7 +270,7 @@ class LLVertexBuffer : public LLRefCount
 	typedef std::list<LLVertexBuffer*> buffer_list_t;
 		
 	static BOOL sEnableVBOs;
-	static S32 sTypeOffsets[TYPE_MAX];
+	static S32 sTypeSize[TYPE_MAX];
 	static U32 sGLMode[LLRender::NUM_MODES];
 	static U32 sGLRenderBuffer;
 	static U32 sGLRenderIndices;
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index ef1d2ec1c52..1788a3da3d9 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -814,17 +814,25 @@ void LLDrawPoolAvatar::endSkinned()
 #if LL_MESH_ENABLED
 void LLDrawPoolAvatar::beginRiggedSimple()
 {
-	sVertexProgram = &gSkinnedObjectSimpleProgram;
+	if (LLPipeline::sUnderWaterRender)
+	{
+		sVertexProgram = &gSkinnedObjectSimpleWaterProgram;
+	}
+	else
+	{
+		sVertexProgram = &gSkinnedObjectSimpleProgram;
+	}
+
 	sDiffuseChannel = 0;
-	gSkinnedObjectSimpleProgram.bind();
-	LLVertexBuffer::sWeight4Loc = gSkinnedObjectSimpleProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+	sVertexProgram->bind();
+	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
 void LLDrawPoolAvatar::endRiggedSimple()
 {
-	sVertexProgram = NULL;
 	LLVertexBuffer::unbind();
-	gSkinnedObjectSimpleProgram.unbind();
+	sVertexProgram->unbind();
+	sVertexProgram = NULL;
 	LLVertexBuffer::sWeight4Loc = -1;
 }
 
@@ -1596,25 +1604,25 @@ void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
 {
 	if (sRenderingSkinned)
 	{
-		U8* base = useVBOs() ? NULL : mMappedData;
+		U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData;
 
-		glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_VERTEX], (void*)(base + 0));
-		glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
-		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+		glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_VERTEX], (void*)(base + 0));
+		glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
+		glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
 		
 		set_vertex_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], 
-						LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_WEIGHT], (F32*)(base + mOffsets[TYPE_WEIGHT]));
+						LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_WEIGHT], (F32*)(base + mOffsets[TYPE_WEIGHT]));
 
 		if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_BUMP)
 		{
 			set_binormals(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL],
-				LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_BINORMAL], (LLVector3*)(base + mOffsets[TYPE_BINORMAL]));
+				LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_BINORMAL], (LLVector3*)(base + mOffsets[TYPE_BINORMAL]));
 		}
 	
 		if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)
 		{
 			set_vertex_clothing_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], 
-				LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_CLOTHWEIGHT], (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
+				LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_CLOTHWEIGHT], (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
 		}
 	}
 	else
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 49eeffe2289..e8877664927 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -83,6 +83,11 @@ LLGLSLShader		gSkinnedObjectFullbrightProgram;
 LLGLSLShader		gSkinnedObjectFullbrightShinyProgram;
 LLGLSLShader		gSkinnedObjectShinySimpleProgram;
 
+LLGLSLShader		gSkinnedObjectSimpleWaterProgram;
+//LLGLSLShader		gSkinnedObjectFullbrightProgram;
+//LLGLSLShader		gSkinnedObjectFullbrightShinyProgram;
+//LLGLSLShader		gSkinnedObjectShinySimpleProgram;
+
 //environment shaders
 LLGLSLShader		gTerrainProgram;
 LLGLSLShader		gTerrainWaterProgram;
@@ -159,6 +164,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gObjectFullbrightProgram);
 	mShaderList.push_back(&gObjectFullbrightShinyProgram);
 	mShaderList.push_back(&gSkinnedObjectSimpleProgram);
+	mShaderList.push_back(&gSkinnedObjectSimpleWaterProgram);
 	mShaderList.push_back(&gSkinnedObjectFullbrightProgram);
 	mShaderList.push_back(&gSkinnedObjectFullbrightShinyProgram);
 	mShaderList.push_back(&gSkinnedObjectShinySimpleProgram);
@@ -570,6 +576,7 @@ void LLViewerShaderMgr::unloadShaders()
 	gObjectShinyWaterProgram.unload();
 
 	gSkinnedObjectSimpleProgram.unload();
+	gSkinnedObjectSimpleWaterProgram.unload();
 	gSkinnedObjectFullbrightProgram.unload();
 	gSkinnedObjectFullbrightShinyProgram.unload();
 	gSkinnedObjectShinySimpleProgram.unload();
@@ -1299,6 +1306,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		gObjectFullbrightProgram.unload();
 		gObjectFullbrightWaterProgram.unload();
 		gSkinnedObjectSimpleProgram.unload();
+		gSkinnedObjectSimpleWaterProgram.unload();
 		gSkinnedObjectFullbrightProgram.unload();
 		gSkinnedObjectFullbrightShinyProgram.unload();
 		gSkinnedObjectShinySimpleProgram.unload();
@@ -1428,6 +1436,23 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		success = gSkinnedObjectSimpleProgram.createShader(NULL, NULL);
 	}
 
+	if (success)
+	{
+		gSkinnedObjectSimpleWaterProgram.mName = "Skinned Simple Water Shader";
+		gSkinnedObjectSimpleWaterProgram.mFeatures.calculatesLighting = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasAtmospherics = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasLighting = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasWaterFog = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectSimpleWaterProgram.mShaderFiles.clear();
+		gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectSimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectSimpleWaterProgram.createShader(NULL, NULL);
+	}
+
 	if (success)
 	{
 		gSkinnedObjectFullbrightProgram.mName = "Skinned Fullbright Shader";
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index da16a384279..99787f3c0a8 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -319,6 +319,11 @@ extern LLGLSLShader			gSkinnedObjectFullbrightProgram;
 extern LLGLSLShader			gSkinnedObjectFullbrightShinyProgram;
 extern LLGLSLShader			gSkinnedObjectShinySimpleProgram;
 
+extern LLGLSLShader			gSkinnedObjectSimpleWaterProgram;
+//extern LLGLSLShader			gSkinnedObjectFullbrightProgram;
+//extern LLGLSLShader			gSkinnedObjectFullbrightShinyProgram;
+//extern LLGLSLShader			gSkinnedObjectShinySimpleProgram;
+
 //environment shaders
 extern LLGLSLShader			gTerrainProgram;
 extern LLGLSLShader			gTerrainWaterProgram;
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp
index 02e7e7e60fc..63f662c5a19 100644
--- a/indra/newview/llvosurfacepatch.cpp
+++ b/indra/newview/llvosurfacepatch.cpp
@@ -77,58 +77,58 @@ class LLVertexBufferTerrain : public LLVertexBuffer
 
 		if (data_mask & MAP_NORMAL)
 		{
-			glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
+			glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
 		}
 		if (data_mask & MAP_TEXCOORD3)
 		{ //substitute tex coord 0 for tex coord 3
 			glClientActiveTextureARB(GL_TEXTURE3_ARB);
-			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
 			glClientActiveTextureARB(GL_TEXTURE0_ARB);
 		}
 		if (data_mask & MAP_TEXCOORD2)
 		{ //substitute tex coord 0 for tex coord 2
 			glClientActiveTextureARB(GL_TEXTURE2_ARB);
-			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
 			glClientActiveTextureARB(GL_TEXTURE0_ARB);
 		}
 		if (data_mask & MAP_TEXCOORD1)
 		{
 			glClientActiveTextureARB(GL_TEXTURE1_ARB);
-			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
+			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
 			glClientActiveTextureARB(GL_TEXTURE0_ARB);
 		}
 		if (data_mask & MAP_BINORMAL)
 		{
 			glClientActiveTextureARB(GL_TEXTURE2_ARB);
-			glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
+			glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
 			glClientActiveTextureARB(GL_TEXTURE0_ARB);
 		}
 		if (data_mask & MAP_TEXCOORD0)
 		{
-			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
+			glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
 		}
 		if (data_mask & MAP_COLOR)
 		{
-			glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeOffsets[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
+			glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeSize[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
 		}
 		
 		if (data_mask & MAP_WEIGHT)
 		{
-			glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeOffsets[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT]));
+			glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT]));
 		}
 
 		if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
 		{
-			glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeOffsets[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4]));
+			glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], (void*)(base+mOffsets[TYPE_WEIGHT4]));
 		}
 
 		if (data_mask & MAP_CLOTHWEIGHT)
 		{
-			glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  LLVertexBuffer::sTypeOffsets[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
+			glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
 		}
 		if (data_mask & MAP_VERTEX)
 		{
-			glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeOffsets[TYPE_VERTEX], (void*)(base + 0));
+			glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0));
 		}
 	}
 };
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index b69fd3f90b5..6fa97b66885 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3494,8 +3494,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 	std::vector<LLFace*> alpha_faces;
 	U32 useage = group->mSpatialPartition->mBufferUsage;
 
-	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcStride(group->mSpatialPartition->mVertexDataMask);
-	U32 max_total = (gSavedSettings.getS32("RenderMaxNodeSize")*1024)/LLVertexBuffer::calcStride(group->mSpatialPartition->mVertexDataMask);
+	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcVertexSize(group->mSpatialPartition->mVertexDataMask);
+	U32 max_total = (gSavedSettings.getS32("RenderMaxNodeSize")*1024)/LLVertexBuffer::calcVertexSize(group->mSpatialPartition->mVertexDataMask);
 	max_vertices = llmin(max_vertices, (U32) 65535);
 
 	U32 cur_total = 0;
@@ -3894,7 +3894,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort)
 {
 	//calculate maximum number of vertices to store in a single buffer
-	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcStride(group->mSpatialPartition->mVertexDataMask);
+	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcVertexSize(group->mSpatialPartition->mVertexDataMask);
 	max_vertices = llmin(max_vertices, (U32) 65535);
 
 	if (!distance_sort)
diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp
index 1749ccef94b..9398bf425ec 100644
--- a/indra/newview/llvowlsky.cpp
+++ b/indra/newview/llvowlsky.cpp
@@ -338,7 +338,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
 	{
 		const U32 max_buffer_bytes = gSavedSettings.getS32("RenderMaxVBOSize")*1024;
 		const U32 data_mask = LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK;
-		const U32 max_verts = max_buffer_bytes / LLVertexBuffer::calcStride(data_mask);
+		const U32 max_verts = max_buffer_bytes / LLVertexBuffer::calcVertexSize(data_mask);
 
 		const U32 total_stacks = getNumStacks();
 
-- 
GitLab


From 32dfebb348ddb39ffd7900b96d200d471bf9655d Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 12 Aug 2010 21:52:22 -0600
Subject: [PATCH 644/683] Fix for EXT-8578: Blurry image in profile never
 resolves - texture queue problem?

---
 indra/newview/llviewertexture.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 9d4f6fdd0c5..9b3243a1bc5 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -814,7 +814,7 @@ void LLViewerTexture::generateGLTexture()
 LLImageGL* LLViewerTexture::getGLTexture() const
 {
 	llassert(mGLTexturep.notNull()) ;
-	
+
 	return mGLTexturep ;
 }
 
@@ -1489,8 +1489,13 @@ void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height)
 //virtual
 void LLViewerFetchedTexture::processTextureStats()
 {
-	if(mFullyLoaded)
+	if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0) //force to refetch the texture.
 	{
+		mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel) ;
+	}
+
+	if(mFullyLoaded)
+	{		
 		if(mDesiredDiscardLevel <= mMinDesiredDiscardLevel)//already loaded
 		{
 			return ;
@@ -2131,7 +2136,7 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so
 void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry::source_callback_list_t* callback_list)
 {
 	if(!callback_list)
-{
+	{
 		mPauseLoadedCallBacks = FALSE ;
 		return ;
 	}
@@ -2160,7 +2165,7 @@ void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry:
 void LLViewerFetchedTexture::pauseLoadedCallbacks(const LLLoadedCallbackEntry::source_callback_list_t* callback_list)
 {
 	if(!callback_list)
-{
+	{
 		return ;
 	}
 
-- 
GitLab


From f7ff9c2aa4a7229d6d5f0c4a293f42fd26164d7b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 13 Aug 2010 12:25:59 +0100
Subject: [PATCH 645/683] trivial comment changes while I was in this code.

---
 indra/newview/llagentcamera.cpp | 18 +++---------------
 indra/newview/llvoavatar.cpp    |  2 +-
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 4dc78e9a1d2..e97e152a386 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1149,10 +1149,9 @@ void LLAgentCamera::updateCamera()
 	static LLFastTimer::DeclareTimer ftm("Camera");
 	LLFastTimer t(ftm);
 
-	//Ventrella - changed camera_skyward to the new global "mCameraUpVector"
+	// - changed camera_skyward to the new global "mCameraUpVector"
 	mCameraUpVector = LLVector3::z_axis;
 	//LLVector3	camera_skyward(0.f, 0.f, 1.f);
-	//end Ventrella
 
 	U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode;
 
@@ -1162,10 +1161,8 @@ void LLAgentCamera::updateCamera()
 		gAgentAvatarp->isSitting() &&
 		camera_mode == CAMERA_MODE_MOUSELOOK)
 	{
-		//Ventrella
 		//changed camera_skyward to the new global "mCameraUpVector"
 		mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation();
-		//end Ventrella
 	}
 
 	if (cameraThirdPerson() && mFocusOnAvatar && LLFollowCamMgr::getActiveFollowCamParams())
@@ -1173,13 +1170,11 @@ void LLAgentCamera::updateCamera()
 		changeCameraToFollow();
 	}
 
-	//Ventrella
 	//NOTE - this needs to be integrated into a general upVector system here within llAgent. 
 	if ( camera_mode == CAMERA_MODE_FOLLOW && mFocusOnAvatar )
 	{
 		mCameraUpVector = mFollowCam.getUpVector();
 	}
-	//end Ventrella
 
 	if (mSitCameraEnabled)
 	{
@@ -1256,7 +1251,6 @@ void LLAgentCamera::updateCamera()
 	// lerp camera focus offset
 	mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(CAMERA_FOCUS_HALF_LIFE));
 
-	//Ventrella
 	if ( mCameraMode == CAMERA_MODE_FOLLOW )
 	{
 		if (isAgentAvatarValid())
@@ -1283,7 +1277,6 @@ void LLAgentCamera::updateCamera()
 			}
 		}
 	}
-	// end Ventrella
 
 	BOOL hit_limit;
 	LLVector3d camera_pos_global;
@@ -1414,10 +1407,8 @@ void LLAgentCamera::updateCamera()
 
 	// Move the camera
 
-	//Ventrella
 	LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent);
 	//LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent);
-	//end Ventrella
 	
 	// Change FOV
 	LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor));
@@ -1532,12 +1523,11 @@ LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal()
 		clearFocusObject();
 	}
 
-	// Ventrella
 	if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
 	{
 		mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedFocus());
 		return mFocusTargetGlobal;
-	}// End Ventrella 
+	}
 	else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
 	{
 		LLVector3d at_axis(1.0, 0.0, 0.0);
@@ -1706,11 +1696,10 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 	LLVector3d camera_position_global;
 
-	// Ventrella 
 	if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
 	{
 		camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition());
-	}// End Ventrella
+	}
 	else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
 	{
 		if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull())
@@ -2130,7 +2119,6 @@ void LLAgentCamera::changeCameraToDefault()
 }
 
 
-// Ventrella
 //-----------------------------------------------------------------------------
 // changeCameraToFollow()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index a0690fc3023..455900eb3af 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2753,7 +2753,7 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
 {
 	// update chat bubble
 	//--------------------------------------------------------------------
-	// draw text label over characters head
+	// draw text label over character's head
 	//--------------------------------------------------------------------
 	if (mChatTimer.getElapsedTimeF32() > BUBBLE_CHAT_TIME)
 	{
-- 
GitLab


From 2f77724a48b51a97091a0e27f20767cfb14e78e5 Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Fri, 13 Aug 2010 11:12:51 -0400
Subject: [PATCH 646/683] EXT-8650 Can wear multiple copies of no-copy item via
 object links * EXT-8688 Automatically detach same object is detected *
 EXT-8689 Cleanup detachAttachmentIntoInventory code

When an object arrives as an attachment, if it's already attached then it's automatically detached.
---
 indra/newview/llappearancemgr.cpp         | 32 ++++++-------------
 indra/newview/llinventorybridge.cpp       | 27 ++--------------
 indra/newview/llviewerjointattachment.cpp | 37 ++++++++++-----------
 indra/newview/llvoavatarself.cpp          | 39 ++++++++++++++++++-----
 indra/newview/llvoavatarself.h            |  1 +
 5 files changed, 63 insertions(+), 73 deletions(-)

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 6fdd71bfbfa..21a635e7389 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2496,29 +2496,17 @@ void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove)
 
 	switch (item_to_remove->getType())
 	{
-	case LLAssetType::AT_CLOTHING:
-		if (get_is_item_worn(id_to_remove))
-		{
-			//*TODO move here the exact removing code from LLWearableBridge::removeItemFromAvatar in the future
-			LLWearableBridge::removeItemFromAvatar(item_to_remove);
-		}
-		break;
-	case LLAssetType::AT_OBJECT:
-		gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
-		gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
-		gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-		gMessageSystem->addUUIDFast(_PREHASH_ItemID, item_to_remove->getLinkedUUID());
-		gMessageSystem->sendReliable( gAgent.getRegion()->getHost());
-
-		{
-			// this object might have been selected, so let the selection manager know it's gone now
-			LLViewerObject *found_obj = gObjectList.findObject(item_to_remove->getLinkedUUID());
-			if (found_obj)
+		case LLAssetType::AT_CLOTHING:
+			if (get_is_item_worn(id_to_remove))
 			{
-				LLSelectMgr::getInstance()->remove(found_obj);
-			};
-		}
-	default: break;
+				//*TODO move here the exact removing code from LLWearableBridge::removeItemFromAvatar in the future
+				LLWearableBridge::removeItemFromAvatar(item_to_remove);
+			}
+			break;
+		case LLAssetType::AT_OBJECT:
+			LLVOAvatarSelf::detachAttachmentIntoInventory(item_to_remove->getLinkedUUID());
+		default:
+			break;
 	}
 
 	// *HACK: Force to remove garbage from COF.
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 9bbc6514b4c..66bf325f044 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3957,18 +3957,7 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 		LLInventoryItem* item = gInventory.getItem(mUUID);
 		if(item)
 		{
-			gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
-			gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
-			gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-			gMessageSystem->addUUIDFast(_PREHASH_ItemID, item->getLinkedUUID());
-			gMessageSystem->sendReliable( gAgent.getRegion()->getHost());
-
-			// this object might have been selected, so let the selection manager know it's gone now
-			LLViewerObject *found_obj = gObjectList.findObject(item->getLinkedUUID());
-			if (found_obj)
-			{
-				LLSelectMgr::getInstance()->remove(found_obj);
-			}
+			LLVOAvatarSelf::detachAttachmentIntoInventory(item->getLinkedUUID());
 		}
 	}
 	else LLItemBridge::performAction(model, action);
@@ -4321,19 +4310,7 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, LLUUID category_
 				LLViewerInventoryItem *obj_item = obj_item_array.get(i);
 				if (get_is_item_worn(obj_item->getUUID()))
 				{
-					gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
-					gMessageSystem->nextBlockFast(_PREHASH_ObjectData );
-					gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
-					gMessageSystem->addUUIDFast(_PREHASH_ItemID, obj_item->getLinkedUUID() );
-					
-					gMessageSystem->sendReliable( gAgent.getRegion()->getHost() );
-					
-					// this object might have been selected, so let the selection manager know it's gone now
-					LLViewerObject *found_obj = gObjectList.findObject( obj_item->getLinkedUUID());
-					if (found_obj)
-					{
-						LLSelectMgr::getInstance()->remove(found_obj);
-					}
+					LLVOAvatarSelf::detachAttachmentIntoInventory(obj_item->getLinkedUUID());
 				}
 			}
 		}
diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp
index 2b4b78d82d7..c9335366cdd 100644
--- a/indra/newview/llviewerjointattachment.cpp
+++ b/indra/newview/llviewerjointattachment.cpp
@@ -35,12 +35,11 @@
 #include "llviewerjointattachment.h"
 
 #include "llagentconstants.h"
-
 #include "llviewercontrol.h"
 #include "lldrawable.h"
 #include "llgl.h"
 #include "llrender.h"
-#include "llvoavatar.h"
+#include "llvoavatarself.h"
 #include "llvolume.h"
 #include "pipeline.h"
 #include "llspatialpartition.h"
@@ -164,6 +163,9 @@ void LLViewerJointAttachment::setupDrawable(LLViewerObject *object)
 //-----------------------------------------------------------------------------
 BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
 {
+	object->extractAttachmentItemID();
+
+	// Same object reattached
 	if (isObjectAttached(object))
 	{
 		llinfos << "(same object re-attached)" << llendl;
@@ -171,20 +173,19 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
 		// Pass through anyway to let setupDrawable()
 		// re-connect object to the joint correctly
 	}
-
-	// Find the inventory item ID of the attached object
-	LLNameValue* item_id_nv = object->getNVPair("AttachItemID");
-	if( item_id_nv )
+	
+	// Two instances of the same inventory item attached --
+	// Request detach, and kill the object in the meantime.
+	if (getAttachedObject(object->getAttachmentItemID()))
 	{
-		const char* s = item_id_nv->getString();
-		if( s )
-		{
-			LLUUID item_id;
-			item_id.set(s);
-			object->setItemID(item_id);
-			lldebugs << "getNVPair( AttachItemID ) = " << item_id << llendl;
-		}
+		llinfos << "(same object re-attached)" << llendl;
+		object->markDead();
+
+		// If this happens to be attached to self, then detach.
+		LLVOAvatarSelf::detachAttachmentIntoInventory(object->getAttachmentItemID());
+		return FALSE;
 	}
+
 	mAttachedObjects.push_back(object);
 	setupDrawable(object);
 	
@@ -207,7 +208,7 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
 	}
 	calcLOD();
 	mUpdateXform = TRUE;
-
+	
 	return TRUE;
 }
 
@@ -303,7 +304,7 @@ void LLViewerJointAttachment::removeObject(LLViewerObject *object)
 	{
 		mUpdateXform = FALSE;
 	}
-	object->setItemID(LLUUID::null);
+	object->setAttachmentItemID(LLUUID::null);
 }
 
 //-----------------------------------------------------------------------------
@@ -429,7 +430,7 @@ const LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &o
 		 ++iter)
 	{
 		const LLViewerObject* attached_object = (*iter);
-		if (attached_object->getItemID() == object_id)
+		if (attached_object->getAttachmentItemID() == object_id)
 		{
 			return attached_object;
 		}
@@ -444,7 +445,7 @@ LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &object_
 		 ++iter)
 	{
 		LLViewerObject* attached_object = (*iter);
-		if (attached_object->getItemID() == object_id)
+		if (attached_object->getAttachmentItemID() == object_id)
 		{
 			return attached_object;
 		}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index bddde08ca98..09e50dcb90c 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -1067,7 +1067,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view
 	// Should just be the last object added
 	if (attachment->isObjectAttached(viewer_object))
 	{
-		const LLUUID& attachment_id = viewer_object->getItemID();
+		const LLUUID& attachment_id = viewer_object->getAttachmentItemID();
 		LLAppearanceMgr::instance().registerAttachment(attachment_id);
 	}
 
@@ -1077,7 +1077,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view
 //virtual
 BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 {
-	const LLUUID attachment_id = viewer_object->getItemID();
+	const LLUUID attachment_id = viewer_object->getAttachmentItemID();
 	if (LLVOAvatar::detachObject(viewer_object))
 	{
 		// the simulator should automatically handle permission revocation
@@ -1115,6 +1115,29 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 	return FALSE;
 }
 
+// static
+BOOL LLVOAvatarSelf::detachAttachmentIntoInventory(const LLUUID &item_id)
+{
+	LLInventoryItem* item = gInventory.getItem(item_id);
+	if (item)
+	{
+		gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
+		gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+		gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+		gMessageSystem->addUUIDFast(_PREHASH_ItemID, item_id);
+		gMessageSystem->sendReliable(gAgent.getRegion()->getHost());
+		
+		// this object might have been selected, so let the selection manager know it's gone now
+		LLViewerObject *found_obj = gObjectList.findObject(item_id);
+		if (found_obj)
+		{
+			LLSelectMgr::getInstance()->remove(found_obj);
+		}
+		return TRUE;
+	}
+	return FALSE;
+}
+
 U32 LLVOAvatarSelf::getNumWearables(LLVOAvatarDefines::ETextureIndex i) const
 {
 	LLWearableType::EType type = LLVOAvatarDictionary::getInstance()->getTEWearableType(i);
@@ -1625,15 +1648,15 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
 					if (isSelf())
 					{
 						if (gAgentAvatarp->isUsingBakedTextures())
-					{
-						requestLayerSetUpdate(type);
-					}
+						{
+							requestLayerSetUpdate(type);
+						}
 						else
-					{
-						LLVisualParamHint::requestHintUpdates();
+						{
+							LLVisualParamHint::requestHintUpdates();
+						}
 					}
 				}
-				}
 				else
 				{					
 					tex->setLoadedCallback(onLocalTextureLoaded, desired_discard, TRUE, FALSE, new LLAvatarTexData(getID(), type), NULL);
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index 630afe7a0fa..37d24d138fa 100644
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -295,6 +295,7 @@ class LLVOAvatarSelf :
 	const std::string   getAttachedPointName(const LLUUID& inv_item_id) const;
 	/*virtual*/ const LLViewerJointAttachment *attachObject(LLViewerObject *viewer_object);
 	/*virtual*/ BOOL 	detachObject(LLViewerObject *viewer_object);
+	static BOOL			detachAttachmentIntoInventory(const LLUUID& item_id);
 
 	//--------------------------------------------------------------------
 	// HUDs
-- 
GitLab


From 6b53458b8477e542ddc5cc1f9fb41cc4a98819b1 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Fri, 13 Aug 2010 18:13:37 +0300
Subject: [PATCH 647/683] EXT-8662 FIXED Crash on renaming incomplete inventory
 items.

I couldn't reproduce this problem, but from what I've seen in the crash
reporter, this is a very old bug affecting viewers 1.2x and 2.x.
When user tries to rename an incomplete inventory item, viewer crashes.

The fix is to disallow renaming incomplete items.

Reviewed by Seraph at https://codereview.productengine.com/secondlife/r/857/

--HG--
branch : product-engine
---
 indra/newview/llinventorybridge.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 9bbc6514b4c..4e1274645f1 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -1270,6 +1270,12 @@ BOOL LLItemBridge::isItemRenameable() const
 		{
 			return FALSE;
 		}
+
+		if (!item->isFinished()) // EXT-8662
+		{
+			return FALSE;
+		}
+
 		return (item->getPermissions().allowModifyBy(gAgent.getID()));
 	}
 	return FALSE;
-- 
GitLab


From 21ba693ad4ab8f7341c346fedfc2d7668a437eb1 Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Fri, 13 Aug 2010 11:26:22 -0400
Subject: [PATCH 648/683] EXT-8650 Can wear multiple copies of no-copy item via
 object links * EXT-8661 Take out unused mRegisteredAttachments in
 LLAppearanceMgr

Removed unused mRegisteredAttachments.  Not sure what this was used for, but it's no longer used.
---
 indra/newview/llappearancemgr.cpp | 15 ---------------
 indra/newview/llappearancemgr.h   |  2 --
 2 files changed, 17 deletions(-)

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 21a635e7389..5c713e60f9e 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2646,7 +2646,6 @@ void LLAppearanceMgr::setAttachmentInvLinkEnable(bool val)
 	mAttachmentInvLinkEnabled = val;
 }
 
-// BAP TODO - mRegisteredAttachments is currently maintained but not used for anything.  Consider yanking.
 void dumpAttachmentSet(const std::set<LLUUID>& atts, const std::string& msg)
 {
        llinfos << msg << llendl;
@@ -2666,7 +2665,6 @@ void dumpAttachmentSet(const std::set<LLUUID>& atts, const std::string& msg)
 
 void LLAppearanceMgr::registerAttachment(const LLUUID& item_id)
 {
-       mRegisteredAttachments.insert(item_id);
 	   gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
 
 	   if (mAttachmentInvLinkEnabled)
@@ -2684,7 +2682,6 @@ void LLAppearanceMgr::registerAttachment(const LLUUID& item_id)
 
 void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id)
 {
-       mRegisteredAttachments.erase(item_id);
 	   gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
 
 	   if (mAttachmentInvLinkEnabled)
@@ -2697,18 +2694,6 @@ void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id)
 	   }
 }
 
-void LLAppearanceMgr::linkRegisteredAttachments()
-{
-	for (std::set<LLUUID>::iterator it = mRegisteredAttachments.begin();
-		 it != mRegisteredAttachments.end();
-		 ++it)
-	{
-		LLUUID item_id = *it;
-		addCOFItemLink(item_id, false);
-	}
-	mRegisteredAttachments.clear();
-}
-
 BOOL LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const
 {
 	return gInventory.isObjectDescendentOf(obj_id, getCOF());
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index eb495bd2746..73b05ff7cd7 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -119,7 +119,6 @@ class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr>
 	void unregisterAttachment(const LLUUID& item_id);
 	void registerAttachment(const LLUUID& item_id);
 	void setAttachmentInvLinkEnable(bool val);
-	void linkRegisteredAttachments();
 
 	// utility function for bulk linking.
 	void linkAll(const LLUUID& category,
@@ -206,7 +205,6 @@ class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr>
 
 	void setOutfitLocked(bool locked);
 
-	std::set<LLUUID> mRegisteredAttachments;
 	bool mAttachmentInvLinkEnabled;
 	bool mOutfitIsDirty;
 	bool mIsInUpdateAppearanceFromCOF; // to detect recursive calls.
-- 
GitLab


From 6b0de5a0007fc038021155146d11480215fd472d Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Fri, 13 Aug 2010 19:33:18 +0300
Subject: [PATCH 649/683] EXT-8536 FIXED Fixed wrong behaviour of
 slidercontrol's lineeditor revert on escape.

Though bug description mentioned only appearance, bug reproduced for all slidercontrols. The cause of returning on escape to old value
instead of last commited one was that on commit slidercontrol set text for it's lineeditor which was the same as the one currently typed
into lineeditor(and it seems logical). But LLLineEditor::setText() has check at it's beginning which compares text which is being set to the
one which is already there. If this check succeeds, we exit the method and thus saving of value for revert is not reached. That's why when revert happened
on escape older value then the last commited was set in lineeditor.

- Added additional call of setText() in sliderctrl to force changes in currently set text so that on next call with "real" text saving of reverted value was reached.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/856/

--HG--
branch : product-engine
---
 indra/llui/llsliderctrl.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp
index 04958075db8..1c410cc1aa5 100644
--- a/indra/llui/llsliderctrl.cpp
+++ b/indra/llui/llsliderctrl.cpp
@@ -235,6 +235,10 @@ void LLSliderCtrl::updateText()
 		std::string text = llformat(format.c_str(), displayed_value);
 		if( mEditor )
 		{
+			// Setting editor text here to "" before using actual text is here because if text which
+			// is set is the same as the one which is actually typed into lineeditor, LLLineEditor::setText()
+			// will exit at it's beginning, so text for revert on escape won't be saved. (EXT-8536)
+			mEditor->setText( LLStringUtil::null );
 			mEditor->setText( text );
 		}
 		else
-- 
GitLab


From 9dcea327605870637e4a45823a1cd3540ef98d69 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Fri, 13 Aug 2010 14:33:30 -0400
Subject: [PATCH 650/683] DEV-52580 FIX

---
 indra/newview/llinventorybridge.cpp | 43 +++++++++++-----------
 indra/newview/llvoavatarself.cpp    | 56 ++++++++++++++++++++++++-----
 indra/newview/llvoavatarself.h      |  7 ++++
 3 files changed, 76 insertions(+), 30 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 53622f71887..531d4c3ee9a 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3936,7 +3936,7 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 		item = (LLViewerInventoryItem*)gInventory.getItem(object_id);
 		if(item && gInventory.isObjectDescendentOf(object_id, gInventory.getRootFolderID()))
 		{
-			rez_attachment(item, NULL, true); // Replace if "Wear"ing.
+			rez_attachment(item, NULL);
 		}
 		else if(item && item->isFinished())
 		{
@@ -3952,10 +3952,6 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 		}
 		gFocusMgr.setKeyboardFocus(NULL);
 	}
-	else if ("wear_add" == action)
-	{
-		LLAppearanceMgr::instance().wearItemOnAvatar(mUUID, true, false); // Don't replace if adding.
-	}
 	else if (isRemoveAction(action))
 	{
 		LLInventoryItem* item = gInventory.getItem(mUUID);
@@ -3989,11 +3985,6 @@ std::string LLObjectBridge::getLabelSuffix() const
 {
 	if (get_is_item_worn(mUUID))
 	{
-		if (!isAgentAvatarValid())
-		{
-			return LLItemBridge::getLabelSuffix() + LLTrans::getString("worn");
-		}
-
 		std::string attachment_point_name = gAgentAvatarp->getAttachedPointName(mUUID);
 
 		// e.g. "(worn on ...)" / "(attached to ...)"
@@ -4007,10 +3998,19 @@ std::string LLObjectBridge::getLabelSuffix() const
 	}
 }
 
-void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment, bool replace)
+void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment)
 {
-	LLSD payload;
-	payload["item_id"] = item->getLinkedUUID(); // Wear the base object in case this is a link.
+	const LLUUID& item_id = item->getLinkedUUID();
+
+	// Check for duplicate request.
+	if (isAgentAvatarValid() &&
+		(gAgentAvatarp->attachmentWasRequested(item_id) ||
+		 gAgentAvatarp->isWearingAttachment(item_id)))
+	{
+		llwarns << "duplicate attachment request, ignoring" << llendl;
+		return;
+	}
+	gAgentAvatarp->addAttachmentRequest(item_id);
 
 	S32 attach_pt = 0;
 	if (isAgentAvatarValid() && attachment)
@@ -4026,14 +4026,11 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach
 		}
 	}
 
-	if (!replace)
-	{
-		attach_pt |= ATTACHMENT_ADD;
-	}
-
+	LLSD payload;
+	payload["item_id"] = item_id; // Wear the base object in case this is a link.
 	payload["attachment_point"] = attach_pt;
 
-	if (replace &&
+	if (!gSavedSettings.getBOOL("MultipleAttachments") &&
 		(attachment && attachment->getNumObjects() > 0))
 	{
 		LLNotificationsUtil::add("ReplaceAttachment", LLSD(), payload, confirm_replace_attachment_rez);
@@ -4057,11 +4054,15 @@ bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& respon
 	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
 	if (option == 0/*YES*/)
 	{
-		LLViewerInventoryItem* itemp = gInventory.getItem(notification["payload"]["item_id"].asUUID());
+		LLUUID item_id = notification["payload"]["item_id"].asUUID();
+		LLViewerInventoryItem* itemp = gInventory.getItem(item_id);
 
 		if (itemp)
 		{
 			U8 attachment_pt = notification["payload"]["attachment_point"].asInteger();
+			
+			if (gSavedSettings.getBOOL("MultipleAttachments"))
+				attachment_pt |= ATTACHMENT_ADD;
 
 			LLMessageSystem* msg = gMessageSystem;
 			msg->newMessageFast(_PREHASH_RezSingleAttachmentFromInv);
@@ -4118,7 +4119,6 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 			{
 				items.push_back(std::string("Wearable And Object Separator"));
 				items.push_back(std::string("Wearable And Object Wear"));
-				items.push_back(std::string("Wearable Add"));
 				items.push_back(std::string("Attach To"));
 				items.push_back(std::string("Attach To HUD"));
 				// commented out for DEV-32347
@@ -4127,7 +4127,6 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 				if (!gAgentAvatarp->canAttachMoreObjects())
 				{
 					disabled_items.push_back(std::string("Wearable And Object Wear"));
-					disabled_items.push_back(std::string("Wearable Add"));
 					disabled_items.push_back(std::string("Attach To"));
 					disabled_items.push_back(std::string("Attach To HUD"));
 				}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index bddde08ca98..7e6591a194f 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -1015,6 +1015,44 @@ BOOL LLVOAvatarSelf::isWearingAttachment(const LLUUID& inv_item_id) const
 	return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+BOOL LLVOAvatarSelf::attachmentWasRequested(const LLUUID& inv_item_id) const
+{
+	const F32 REQUEST_EXPIRATION_SECONDS = 5.0;  // any request older than this is ignored/removed.
+	std::map<LLUUID,LLTimer>::iterator it = mAttachmentRequests.find(inv_item_id);
+	if (it != mAttachmentRequests.end())
+	{
+		const LLTimer& request_time = it->second;
+		F32 request_time_elapsed = request_time.getElapsedTimeF32();
+		if (request_time_elapsed > REQUEST_EXPIRATION_SECONDS)
+		{
+			mAttachmentRequests.erase(it);
+			return FALSE;
+		}
+		else
+		{
+			return TRUE;
+		}
+	}
+	else
+	{
+		return FALSE;
+	}
+}
+
+//-----------------------------------------------------------------------------
+void LLVOAvatarSelf::addAttachmentRequest(const LLUUID& inv_item_id)
+{
+	LLTimer current_time;
+	mAttachmentRequests[inv_item_id] = current_time;
+}
+
+//-----------------------------------------------------------------------------
+void LLVOAvatarSelf::removeAttachmentRequest(const LLUUID& inv_item_id)
+{
+	mAttachmentRequests.erase(inv_item_id);
+}
+
 //-----------------------------------------------------------------------------
 // getWornAttachment()
 //-----------------------------------------------------------------------------
@@ -1067,8 +1105,10 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view
 	// Should just be the last object added
 	if (attachment->isObjectAttached(viewer_object))
 	{
-		const LLUUID& attachment_id = viewer_object->getItemID();
+		const LLUUID& attachment_id = viewer_object->getAttachmentItemID();
 		LLAppearanceMgr::instance().registerAttachment(attachment_id);
+		// Clear any pending requests once the attachment arrives.
+		removeAttachmentRequest(attachment_id);
 	}
 
 	return attachment;
@@ -1077,7 +1117,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view
 //virtual
 BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 {
-	const LLUUID attachment_id = viewer_object->getItemID();
+	const LLUUID attachment_id = viewer_object->getAttachmentItemID();
 	if (LLVOAvatar::detachObject(viewer_object))
 	{
 		// the simulator should automatically handle permission revocation
@@ -1625,15 +1665,15 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
 					if (isSelf())
 					{
 						if (gAgentAvatarp->isUsingBakedTextures())
-					{
-						requestLayerSetUpdate(type);
-					}
+						{
+							requestLayerSetUpdate(type);
+						}
 						else
-					{
-						LLVisualParamHint::requestHintUpdates();
+						{
+							LLVisualParamHint::requestHintUpdates();
+						}
 					}
 				}
-				}
 				else
 				{					
 					tex->setLoadedCallback(onLocalTextureLoaded, desired_discard, TRUE, FALSE, new LLAvatarTexData(getID(), type), NULL);
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index 630afe7a0fa..b129ffd9866 100644
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -291,11 +291,18 @@ class LLVOAvatarSelf :
 public:
 	void 				updateAttachmentVisibility(U32 camera_mode);
 	BOOL 				isWearingAttachment(const LLUUID& inv_item_id) const;
+	BOOL				attachmentWasRequested(const LLUUID& inv_item_id) const;
+	void				addAttachmentRequest(const LLUUID& inv_item_id);
+	void				removeAttachmentRequest(const LLUUID& inv_item_id);
 	LLViewerObject* 	getWornAttachment(const LLUUID& inv_item_id);
 	const std::string   getAttachedPointName(const LLUUID& inv_item_id) const;
 	/*virtual*/ const LLViewerJointAttachment *attachObject(LLViewerObject *viewer_object);
 	/*virtual*/ BOOL 	detachObject(LLViewerObject *viewer_object);
 
+private:
+	// Track attachments that have been requested but have not arrived yet.
+	mutable std::map<LLUUID,LLTimer> mAttachmentRequests;
+
 	//--------------------------------------------------------------------
 	// HUDs
 	//--------------------------------------------------------------------
-- 
GitLab


From 62943202a7c4334ce7b7be96f8f64133444ee925 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 13 Aug 2010 14:42:07 -0500
Subject: [PATCH 651/683] Make rigged attachments respect under water
 rendering.

Reviewed by Nyx.
---
 indra/llrender/llglslshader.cpp     |  12 ++-
 indra/newview/lldrawpoolavatar.cpp  |  70 +++++++++++++++---
 indra/newview/llviewershadermgr.cpp | 110 ++++++++++++++++++++++------
 indra/newview/llviewershadermgr.h   |   6 +-
 4 files changed, 162 insertions(+), 36 deletions(-)

diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 9256e3959cd..f59bac8c3cc 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -709,7 +709,15 @@ GLint LLGLSLShader::getUniformLocation(const string& uniform)
 		std::map<string, GLint>::iterator iter = mUniformMap.find(uniform);
 		if (iter != mUniformMap.end())
 		{
-			llassert(iter->second == glGetUniformLocationARB(mProgramObject, uniform.c_str()));
+			if (gDebugGL)
+			{
+				stop_glerror();
+				if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.c_str()))
+				{
+					llerrs << "Uniform does not match." << llendl;
+				}
+				stop_glerror();
+			}
 			return iter->second;
 		}
 	}
@@ -900,7 +908,9 @@ void LLGLSLShader::uniformMatrix4fv(const string& uniform, U32 count, GLboolean
 				
 	if (location >= 0)
 	{
+		stop_glerror();
 		glUniformMatrix4fvARB(location, count, transpose, v);
+		stop_glerror();
 	}
 }
 
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 1788a3da3d9..af082eea3e3 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -838,7 +838,14 @@ void LLDrawPoolAvatar::endRiggedSimple()
 
 void LLDrawPoolAvatar::beginRiggedAlpha()
 {
-	sVertexProgram = &gSkinnedObjectSimpleProgram;
+	if (LLPipeline::sUnderWaterRender)
+	{
+		sVertexProgram = &gSkinnedObjectSimpleWaterProgram;
+	}
+	else
+	{
+		sVertexProgram = &gSkinnedObjectSimpleProgram;
+	}
 	sDiffuseChannel = 0;
 	sVertexProgram->bind();
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
@@ -855,7 +862,14 @@ void LLDrawPoolAvatar::endRiggedAlpha()
 
 void LLDrawPoolAvatar::beginRiggedFullbrightAlpha()
 {
-	sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	if (LLPipeline::sUnderWaterRender)
+	{
+		sVertexProgram = &gSkinnedObjectFullbrightWaterProgram;
+	}
+	else
+	{
+		sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	}
 	sDiffuseChannel = 0;
 	sVertexProgram->bind();
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
@@ -871,7 +885,14 @@ void LLDrawPoolAvatar::endRiggedFullbrightAlpha()
 
 void LLDrawPoolAvatar::beginRiggedGlow()
 {
-	sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	if (LLPipeline::sUnderWaterRender)
+	{
+		sVertexProgram = &gSkinnedObjectFullbrightWaterProgram;
+	}
+	else
+	{
+		sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	}
 	sDiffuseChannel = 0;
 	sVertexProgram->bind();
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
@@ -887,23 +908,37 @@ void LLDrawPoolAvatar::endRiggedGlow()
 
 void LLDrawPoolAvatar::beginRiggedFullbright()
 {
-	sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	if (LLPipeline::sUnderWaterRender)
+	{
+		sVertexProgram = &gSkinnedObjectFullbrightWaterProgram;
+	}
+	else
+	{
+		sVertexProgram = &gSkinnedObjectFullbrightProgram;
+	}
 	sDiffuseChannel = 0;
-	gSkinnedObjectFullbrightProgram.bind();
+	sVertexProgram->bind();
 	LLVertexBuffer::sWeight4Loc = gSkinnedObjectFullbrightProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
 void LLDrawPoolAvatar::endRiggedFullbright()
 {
-	sVertexProgram = NULL;
 	LLVertexBuffer::unbind();
-	gSkinnedObjectFullbrightProgram.unbind();
+	sVertexProgram->unbind();
+	sVertexProgram = NULL;
 	LLVertexBuffer::sWeight4Loc = -1;
 }
 
 void LLDrawPoolAvatar::beginRiggedShinySimple()
 {
-	sVertexProgram = &gSkinnedObjectShinySimpleProgram;
+	if (LLPipeline::sUnderWaterRender)
+	{
+		sVertexProgram = &gSkinnedObjectShinySimpleWaterProgram;
+	}
+	else
+	{
+		sVertexProgram = &gSkinnedObjectShinySimpleProgram;
+	}
 	sVertexProgram->bind();
 	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
@@ -920,7 +955,14 @@ void LLDrawPoolAvatar::endRiggedShinySimple()
 
 void LLDrawPoolAvatar::beginRiggedFullbrightShiny()
 {
-	sVertexProgram = &gSkinnedObjectFullbrightShinyProgram;
+	if (LLPipeline::sUnderWaterRender)
+	{
+		sVertexProgram = &gSkinnedObjectFullbrightShinyWaterProgram;
+	}
+	else
+	{
+		sVertexProgram = &gSkinnedObjectFullbrightShinyProgram;
+	}
 	sVertexProgram->bind();
 	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
 	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
@@ -1288,6 +1330,8 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 		return;
 	}
 
+	stop_glerror();
+
 	for (U32 i = 0; i < mRiggedFace[type].size(); ++i)
 	{
 		LLFace* face = mRiggedFace[type][i];
@@ -1324,9 +1368,13 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 			continue;
 		}
 
+		stop_glerror();
+
 		const LLVolumeFace& vol_face = volume->getVolumeFace(te);
 		updateRiggedFaceVertexBuffer(face, skin, volume, vol_face);
 		
+		stop_glerror();
+
 		U32 data_mask = rigged_data_mask[type];
 
 		LLVertexBuffer* buff = face->mVertexBuffer;
@@ -1345,6 +1393,8 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 				}
 			}
 			
+			stop_glerror();
+
 			LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", 
 				skin->mJointNames.size(),
 				FALSE,
@@ -1354,6 +1404,8 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 				FALSE,
 				(GLfloat*) mat[0].mMatrix);
 
+			stop_glerror();
+
 			buff->setBuffer(data_mask);
 
 			U16 start = face->getGeomStart();
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index e8877664927..20e43332092 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -84,9 +84,9 @@ LLGLSLShader		gSkinnedObjectFullbrightShinyProgram;
 LLGLSLShader		gSkinnedObjectShinySimpleProgram;
 
 LLGLSLShader		gSkinnedObjectSimpleWaterProgram;
-//LLGLSLShader		gSkinnedObjectFullbrightProgram;
-//LLGLSLShader		gSkinnedObjectFullbrightShinyProgram;
-//LLGLSLShader		gSkinnedObjectShinySimpleProgram;
+LLGLSLShader		gSkinnedObjectFullbrightWaterProgram;
+LLGLSLShader		gSkinnedObjectFullbrightShinyWaterProgram;
+LLGLSLShader		gSkinnedObjectShinySimpleWaterProgram;
 
 //environment shaders
 LLGLSLShader		gTerrainProgram;
@@ -164,10 +164,13 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gObjectFullbrightProgram);
 	mShaderList.push_back(&gObjectFullbrightShinyProgram);
 	mShaderList.push_back(&gSkinnedObjectSimpleProgram);
-	mShaderList.push_back(&gSkinnedObjectSimpleWaterProgram);
 	mShaderList.push_back(&gSkinnedObjectFullbrightProgram);
 	mShaderList.push_back(&gSkinnedObjectFullbrightShinyProgram);
 	mShaderList.push_back(&gSkinnedObjectShinySimpleProgram);
+	mShaderList.push_back(&gSkinnedObjectSimpleWaterProgram);
+	mShaderList.push_back(&gSkinnedObjectFullbrightWaterProgram);
+	mShaderList.push_back(&gSkinnedObjectFullbrightShinyWaterProgram);
+	mShaderList.push_back(&gSkinnedObjectShinySimpleWaterProgram);
 	mShaderList.push_back(&gTerrainProgram);
 	mShaderList.push_back(&gTerrainWaterProgram);
 	mShaderList.push_back(&gObjectSimpleWaterProgram);
@@ -576,11 +579,15 @@ void LLViewerShaderMgr::unloadShaders()
 	gObjectShinyWaterProgram.unload();
 
 	gSkinnedObjectSimpleProgram.unload();
-	gSkinnedObjectSimpleWaterProgram.unload();
 	gSkinnedObjectFullbrightProgram.unload();
 	gSkinnedObjectFullbrightShinyProgram.unload();
 	gSkinnedObjectShinySimpleProgram.unload();
 	
+	gSkinnedObjectSimpleWaterProgram.unload();
+	gSkinnedObjectFullbrightWaterProgram.unload();
+	gSkinnedObjectFullbrightShinyWaterProgram.unload();
+	gSkinnedObjectShinySimpleWaterProgram.unload();
+	
 
 	gWaterProgram.unload();
 	gUnderWaterProgram.unload();
@@ -1306,10 +1313,13 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		gObjectFullbrightProgram.unload();
 		gObjectFullbrightWaterProgram.unload();
 		gSkinnedObjectSimpleProgram.unload();
-		gSkinnedObjectSimpleWaterProgram.unload();
 		gSkinnedObjectFullbrightProgram.unload();
 		gSkinnedObjectFullbrightShinyProgram.unload();
 		gSkinnedObjectShinySimpleProgram.unload();
+		gSkinnedObjectSimpleWaterProgram.unload();
+		gSkinnedObjectFullbrightWaterProgram.unload();
+		gSkinnedObjectFullbrightShinyWaterProgram.unload();
+		gSkinnedObjectShinySimpleWaterProgram.unload();
 	
 		return FALSE;
 	}
@@ -1436,23 +1446,6 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		success = gSkinnedObjectSimpleProgram.createShader(NULL, NULL);
 	}
 
-	if (success)
-	{
-		gSkinnedObjectSimpleWaterProgram.mName = "Skinned Simple Water Shader";
-		gSkinnedObjectSimpleWaterProgram.mFeatures.calculatesLighting = true;
-		gSkinnedObjectSimpleWaterProgram.mFeatures.calculatesAtmospherics = true;
-		gSkinnedObjectSimpleWaterProgram.mFeatures.hasGamma = true;
-		gSkinnedObjectSimpleWaterProgram.mFeatures.hasAtmospherics = true;
-		gSkinnedObjectSimpleWaterProgram.mFeatures.hasLighting = true;
-		gSkinnedObjectSimpleWaterProgram.mFeatures.hasWaterFog = true;
-		gSkinnedObjectSimpleWaterProgram.mFeatures.hasObjectSkinning = true;
-		gSkinnedObjectSimpleWaterProgram.mShaderFiles.clear();
-		gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
-		gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gSkinnedObjectSimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
-		success = gSkinnedObjectSimpleWaterProgram.createShader(NULL, NULL);
-	}
-
 	if (success)
 	{
 		gSkinnedObjectFullbrightProgram.mName = "Skinned Fullbright Shader";
@@ -1500,6 +1493,77 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		success = gSkinnedObjectShinySimpleProgram.createShader(NULL, &mShinyUniforms);
 	}
 
+	if (success)
+	{
+		gSkinnedObjectSimpleWaterProgram.mName = "Skinned Simple Water Shader";
+		gSkinnedObjectSimpleWaterProgram.mFeatures.calculatesLighting = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasAtmospherics = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasLighting = true;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasWaterFog = true;
+		gSkinnedObjectSimpleWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
+		gSkinnedObjectSimpleWaterProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectSimpleWaterProgram.mShaderFiles.clear();
+		gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectSimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectSimpleWaterProgram.createShader(NULL, NULL);
+	}
+
+	if (success)
+	{
+		gSkinnedObjectFullbrightWaterProgram.mName = "Skinned Fullbright Water Shader";
+		gSkinnedObjectFullbrightWaterProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectFullbrightWaterProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectFullbrightWaterProgram.mFeatures.hasTransport = true;
+		gSkinnedObjectFullbrightWaterProgram.mFeatures.isFullbright = true;
+		gSkinnedObjectFullbrightWaterProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectFullbrightWaterProgram.mFeatures.hasWaterFog = true;
+		gSkinnedObjectFullbrightWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
+		gSkinnedObjectFullbrightWaterProgram.mShaderFiles.clear();
+		gSkinnedObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectFullbrightWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectFullbrightWaterProgram.createShader(NULL, NULL);
+	}
+
+	if (success)
+	{
+		gSkinnedObjectFullbrightShinyWaterProgram.mName = "Skinned Fullbright Shiny Water Shader";
+		gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasTransport = true;
+		gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.isShiny = true;
+		gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.isFullbright = true;
+		gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasWaterFog = true;
+		gSkinnedObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
+		gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.clear();
+		gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectFullbrightShinyWaterProgram.createShader(NULL, &mShinyUniforms);
+	}
+
+	if (success)
+	{
+		gSkinnedObjectShinySimpleWaterProgram.mName = "Skinned Shiny Simple Water Shader";
+		gSkinnedObjectShinySimpleWaterProgram.mFeatures.calculatesLighting = true;
+		gSkinnedObjectShinySimpleWaterProgram.mFeatures.calculatesAtmospherics = true;
+		gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasGamma = true;
+		gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasAtmospherics = true;
+		gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasObjectSkinning = true;
+		gSkinnedObjectShinySimpleWaterProgram.mFeatures.isShiny = true;
+		gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasWaterFog = true;
+		gSkinnedObjectShinySimpleWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
+		gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.clear();
+		gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
+		gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectShinySimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		success = gSkinnedObjectShinySimpleWaterProgram.createShader(NULL, &mShinyUniforms);
+	}
+
 	if( !success )
 	{
 		mVertexShaderLevel[SHADER_OBJECT] = 0;
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index 99787f3c0a8..b6fa86081c9 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -320,9 +320,9 @@ extern LLGLSLShader			gSkinnedObjectFullbrightShinyProgram;
 extern LLGLSLShader			gSkinnedObjectShinySimpleProgram;
 
 extern LLGLSLShader			gSkinnedObjectSimpleWaterProgram;
-//extern LLGLSLShader			gSkinnedObjectFullbrightProgram;
-//extern LLGLSLShader			gSkinnedObjectFullbrightShinyProgram;
-//extern LLGLSLShader			gSkinnedObjectShinySimpleProgram;
+extern LLGLSLShader			gSkinnedObjectFullbrightWaterProgram;
+extern LLGLSLShader			gSkinnedObjectFullbrightShinyWaterProgram;
+extern LLGLSLShader			gSkinnedObjectShinySimpleWaterProgram;
 
 //environment shaders
 extern LLGLSLShader			gTerrainProgram;
-- 
GitLab


From 671609239f63bc6dc293a0580e6f1b8e48239b26 Mon Sep 17 00:00:00 2001
From: jwolk <none@none>
Date: Fri, 13 Aug 2010 17:30:09 -0700
Subject: [PATCH 652/683] Added new UI to show linked set cost and object cost.
  Changed terminology in edit tools.  Updated request payload when requesting
 object cost. Paired with davep

---
 indra/newview/llfloatertools.cpp              |  44 +++++--
 indra/newview/llselectmgr.cpp                 |  23 ----
 indra/newview/llviewerobjectlist.cpp          | 123 +++++++++++++++---
 indra/newview/llviewerobjectlist.h            |   3 +-
 .../skins/default/xui/en/floater_tools.xml    |  68 +++++++++-
 5 files changed, 206 insertions(+), 55 deletions(-)

diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp
index 03c9bd4e4fd..c84ce12f802 100644
--- a/indra/newview/llfloatertools.cpp
+++ b/indra/newview/llfloatertools.cpp
@@ -419,14 +419,38 @@ void LLFloaterTools::refresh()
 
 	// Refresh object and prim count labels
 	LLLocale locale(LLLocale::USER_LOCALE);
-	
-	F32 obj_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectCost();
-	F32 link_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedLinksetCost();
-
-	childSetTextArg("obj_count",  "[COUNT]", llformat("%.1f", obj_cost));	
-	childSetTextArg("prim_count", "[COUNT]", llformat("%.1f", link_cost));
 
-	// calculate selection rendering cost
+	// Get the number of objects selected
+	std::string root_object_count_string;
+	std::string object_count_string;
+
+	LLResMgr::getInstance()->getIntegerString(
+		root_object_count_string,
+		LLSelectMgr::getInstance()->getSelection()->getRootObjectCount());
+	LLResMgr::getInstance()->getIntegerString(
+		object_count_string,
+		LLSelectMgr::getInstance()->getSelection()->getObjectCount());
+
+	F32 obj_cost =
+		LLSelectMgr::getInstance()->getSelection()->getSelectedObjectCost();
+	F32 link_cost =
+		LLSelectMgr::getInstance()->getSelection()->getSelectedLinksetCost();
+
+	// Update the text for the counts
+	childSetTextArg(
+		"linked_set_count",
+		"[COUNT]",
+		root_object_count_string);
+	childSetTextArg("object_count", "[COUNT]", object_count_string);
+
+	// Update the text for the resource costs
+	childSetTextArg(
+		"linked_set_cost",
+		"[COST]",
+		llformat("%.1f", link_cost));
+	childSetTextArg("object_cost", "[COST]", llformat("%.1f", obj_cost));
+
+	// Display rendering cost if needed
 	if (sShowObjectCost)
 	{
 		std::string prim_cost_string;
@@ -437,8 +461,10 @@ void LLFloaterTools::refresh()
 
 	// disable the object and prim counts if nothing selected
 	bool have_selection = ! LLSelectMgr::getInstance()->getSelection()->isEmpty();
-	childSetEnabled("obj_count", have_selection);
-	childSetEnabled("prim_count", have_selection);
+	childSetEnabled("linked_set_count", have_selection);
+	childSetEnabled("object_count", have_selection);
+	childSetEnabled("linked_set_cost", have_selection);
+	childSetEnabled("object_cost", have_selection);
 	childSetEnabled("RenderingCost", have_selection && sShowObjectCost);
 
 	// Refresh child tabs
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 6aadf0afd26..42f09f7396b 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -6182,29 +6182,6 @@ S32 LLObjectSelection::getObjectCount(BOOL mesh_adjust)
 	cleanupNodes();
 	S32 count = mList.size();
 
-#if LL_MESH_ENABLED
-	if (mesh_adjust)
-	{
-		for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
-		{
-			LLSelectNode* node = *iter;
-			LLViewerObject* object = node->getObject();
-			
-			if (object && object->getVolume())
-			{
-				LLVOVolume* vobj = (LLVOVolume*) object;
-				if (vobj->isMesh())
-				{
-					LLUUID mesh_id = vobj->getVolume()->getParams().getSculptID();
-					U32 cost = gMeshRepo.getResourceCost(mesh_id);
-					count += cost-1;
-				}
-			}
-
-		}
-	}
-#endif
-
 	return count;
 }
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 900aa3ce12e..e6f1d8e728f 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -660,17 +660,86 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
 class LLObjectCostResponder : public LLCurl::Responder
 {
 public:
+	LLObjectCostResponder(const LLSD& object_ids)
+		: mObjectIDs(object_ids)
+	{
+	}
+
+	// Clear's the global object list's pending
+	// request list for all objects requested
+	void clear_object_list_pending_requests()
+	{
+		// TODO*: No more hard coding
+		for (
+			LLSD::array_iterator iter = mObjectIDs.beginArray();
+			iter != mObjectIDs.endArray();
+			++iter)
+		{
+			gObjectList.onObjectCostFetchFailure(iter->asUUID());
+		}
+	}
+
+	void error(U32 statusNum, const std::string& reason)
+	{
+		lldebugs
+			<< "Transport error requesting object cost "
+			<< "HTTP status: " << statusNum << ", reason: "
+			<< reason << "." << llendl;
+
+		// TODO*: Error message to user
+		// For now just clear the request from the pending list
+		clear_object_list_pending_requests();
+	}
+
 	void result(const LLSD& content)
 	{
-		for (LLSD::map_const_iterator iter = content.beginMap(); iter != content.endMap(); ++iter)
+		if ( !content.isMap() || content.has("error") )
+		{
+			// Improper response or the request had an error,
+			// show an error to the user?
+			lldebugs
+				<< "Application level error when fetching object "
+				<< "cost.  Message: " << content["error"]["message"].asString()
+				<< ", identifier: " << content["error"]["identifier"].asString()
+				<< llendl;
+
+			// TODO*: Adaptively adjust request size if the
+			// service says we've requested too many and retry
+
+			// TODO*: Error message if not retrying
+			clear_object_list_pending_requests();
+			return;
+		}
+
+		// Success, grab the resource cost and linked set costs
+		// for an object if one was returned
+		for (
+			LLSD::array_iterator iter = mObjectIDs.beginArray();
+			iter != mObjectIDs.endArray();
+			++iter)
 		{
-			LLUUID object_id = LLUUID(iter->first);
-			F32 link_cost = iter->second["LinksetResourceCost"].asReal();
-			F32 prim_cost = iter->second["PrimResourceCost"].asReal();
+			LLUUID object_id = iter->asUUID();
 
-			gObjectList.updateObjectCost(object_id, prim_cost, link_cost);
+			// Check to see if the request contains data for the object
+			if ( content.has(iter->asString()) )
+			{
+				F32 link_cost =
+					content[iter->asString()]["linked_set_resource_cost"].asReal();
+				F32 object_cost =
+					content[iter->asString()]["resource_cost"].asReal();
+
+				gObjectList.updateObjectCost(object_id, object_cost, link_cost);
+			}
+			else
+			{
+				// TODO*: Give user feedback about the missing data?
+				gObjectList.onObjectCostFetchFailure(object_id);
+			}
 		}
 	}
+
+private:
+	LLSD mObjectIDs;
 };
 
 void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
@@ -769,7 +838,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 		}
 	}
 
-	//issue http request for stale object physics costs
+	// issue http request for stale object physics costs
 	if (!mStaleObjectCost.empty())
 	{
 		LLViewerRegion* regionp = gAgent.getRegion();
@@ -781,21 +850,40 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 			if (!url.empty())
 			{
 				LLSD id_list;
-				U32 idx = 0;
-				for (std::set<LLUUID>::iterator iter = mStaleObjectCost.begin(); iter != mStaleObjectCost.end(); ++iter)
+				U32 object_index = 0;
+
+				for (
+					std::set<LLUUID>::iterator iter = mStaleObjectCost.begin();
+					iter != mStaleObjectCost.end();
+					++iter)
 				{
-					if (mPendingObjectCost.find(*iter) == mPendingObjectCost.end())
+					// Check to see if a request for this object
+					// has already been made.
+					if ( mPendingObjectCost.find(*iter) ==
+						 mPendingObjectCost.end() )
 					{
+						// Why is this line here if
+						// we set mPendingObjectCost to be
+						// mStaleObjectCost below?
 						mPendingObjectCost.insert(*iter);
-						id_list[idx++] = *iter;
+						id_list[object_index++] = *iter;
 					}
 				}
-				mPendingObjectCost = mStaleObjectCost;
+
+				// id_list should now contain all
+				// requests in mStaleObjectCost before, so clear
+				// it now
 				mStaleObjectCost.clear();
 
-				if (id_list.size() > 0)
+				if ( id_list.size() > 0 )
 				{
-					LLHTTPClient::post(url, id_list, new LLObjectCostResponder());
+					LLSD post_data = LLSD::emptyMap();
+
+					post_data["object_ids"] = id_list;
+					LLHTTPClient::post(
+						url,
+						post_data,
+						new LLObjectCostResponder(id_list));
 				}
 			}
 			else
@@ -1099,18 +1187,23 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object)
 	mStaleObjectCost.insert(object->getID());
 }
 
-void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 prim_cost, F32 link_cost)
+void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 object_cost, F32 link_cost)
 {
 	mPendingObjectCost.erase(object_id);
 
 	LLViewerObject* object = findObject(object_id);
 	if (object)
 	{
-		object->setObjectCost(prim_cost);
+		object->setObjectCost(object_cost);
 		object->setLinksetCost(link_cost);
 	}
 }
 
+void LLViewerObjectList::onObjectCostFetchFailure(LLUUID object_id)
+{
+	mPendingObjectCost.erase(object_id);
+}
+
 void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 {
 	// This is called when we shift our origin when we cross region boundaries...
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 4064a68eb21..0f58e543ac0 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -92,7 +92,8 @@ class LLViewerObjectList
 	void update(LLAgent &agent, LLWorld &world);
 
 	void updateObjectCost(LLViewerObject* object);
-	void updateObjectCost(LLUUID object_id, F32 prim_cost, F32 link_cost);
+	void updateObjectCost(LLUUID object_id, F32 object_cost, F32 link_cost);
+	void onObjectCostFetchFailure(LLUUID object_id);
 
 	void shiftObjects(const LLVector3 &offset);
 
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index b0e8f29a0a0..bbb90eba6e0 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -730,11 +730,25 @@
      follows="left|top"
      halign="right"
      layout="topleft"
-     right="-10"
-     name="obj_count"
+     right="-100"
+     name="linked_set_count"
      top_pad="5"
-     width="143">
-        Objects: [COUNT]
+     width="80">
+        Linked Sets: [COUNT]
+    </text>
+    <text
+    text_color="LtGray_50"
+     type="string"
+     length="1"
+     height="10"
+     follows="left"
+     halign="right"
+     layout="topleft"
+	 top_delta="0"
+     right="-10"
+     name="linked_set_cost"
+     width="80">
+        Cost: [COST]
     </text>
     <text
     text_color="LtGray_50"
@@ -743,11 +757,51 @@
      follows="left|top"
      halign="right"
      layout="topleft"
+	 top_pad="5"
+     right="-100"
+     name="object_count"
+     width="80">
+        Objects: [COUNT]
+    </text>
+    <text
+    text_color="LtGray_50"
+     type="string"
+     length="1"
+     follows="left"
+     halign="right"
+     layout="topleft"
+	 top_delta="0"
      right="-10"
-     name="prim_count"
-     width="143">
-        Prims: [COUNT]
+     name="object_cost"
+     width="80">
+        Cost: [COST]
     </text>
+    <!-- <text -->
+    <!-- text_color="LtGray_50" -->
+    <!--  type="string" -->
+    <!--  length="1" -->
+    <!--  height="10" -->
+    <!--  follows="left|top" -->
+    <!--  halign="right" -->
+    <!--  layout="topleft" -->
+    <!--  right="-10" -->
+    <!--  name="obj_count" -->
+    <!--  top_pad="5" -->
+    <!--  width="143"> -->
+    <!--     Objects: [COUNT] -->
+    <!-- </text> -->
+    <!-- <text -->
+    <!-- text_color="LtGray_50" -->
+    <!--  type="string" -->
+    <!--  length="1" -->
+    <!--  follows="left|top" -->
+    <!--  halign="right" -->
+    <!--  layout="topleft" -->
+    <!--  right="-10" -->
+    <!--  name="prim_count" -->
+    <!--  width="143"> -->
+    <!--     Prims: [COUNT] -->
+    <!-- </text> -->
     <tab_container
      follows="left|top"
      height="610"
-- 
GitLab


From 9d5a3d7a2d830c07dd6b79534fdbe7c782b30afe Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 13 Aug 2010 19:35:03 -0500
Subject: [PATCH 653/683] Better support for curious mixtures
 fullbright/shiny/water with rigged attachments, deferred rendering, and not.

---
 indra/llrender/llshadermgr.cpp      |  9 ++++++++-
 indra/newview/lldrawpoolbump.cpp    |  2 +-
 indra/newview/lldrawpoolsimple.cpp  |  6 ------
 indra/newview/llviewershadermgr.cpp | 26 ++++++++++++++++++++++++--
 indra/newview/llviewershadermgr.h   |  1 +
 indra/newview/llvovolume.cpp        | 11 +++++++++--
 6 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 0f54ebeb690..9eb5668d88b 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -234,7 +234,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
 	else if (features->isFullbright)
 	{
 	
-		if (features->hasWaterFog)
+		if (features->isShiny && features->hasWaterFog)
+		{
+			if (!shader->attachObject("lighting/lightFullbrightShinyWaterF.glsl"))
+			{
+				return FALSE;
+			}
+		}
+		else if (features->hasWaterFog)
 		{
 			if (!shader->attachObject("lighting/lightFullbrightWaterF.glsl"))
 			{
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 20097e29fec..0b0297d2b82 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -501,7 +501,7 @@ void LLDrawPoolBump::beginFullbrightShiny()
 	
 	if (LLPipeline::sUnderWaterRender)
 	{
-		shader = &gObjectShinyWaterProgram;
+		shader = &gObjectFullbrightShinyWaterProgram;
 	}
 	else
 	{
diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index 91191287cd9..30d1ffc7831 100644
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -149,12 +149,6 @@ void LLDrawPoolSimple::render(S32 pass)
 		LLFastTimer t(FTM_RENDER_SIMPLE);
 		gPipeline.enableLightsDynamic();
 		renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask());
-
-		if (LLPipeline::sRenderDeferred)
-		{ //if deferred rendering is enabled, bump faces aren't reigstered as simple
-			//render bump faces here as simple so bump faces will appear under water
-			renderTexture(LLRenderPass::PASS_BUMP, getVertexDataMask());
-		}
 	}
 }
 
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 20e43332092..f0f83ec6e40 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -74,6 +74,7 @@ LLGLSLShader		gObjectFullbrightProgram;
 LLGLSLShader		gObjectFullbrightWaterProgram;
 
 LLGLSLShader		gObjectFullbrightShinyProgram;
+LLGLSLShader		gObjectFullbrightShinyWaterProgram;
 LLGLSLShader		gObjectShinyProgram;
 LLGLSLShader		gObjectShinyWaterProgram;
 
@@ -163,6 +164,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gObjectSimpleProgram);
 	mShaderList.push_back(&gObjectFullbrightProgram);
 	mShaderList.push_back(&gObjectFullbrightShinyProgram);
+	mShaderList.push_back(&gObjectFullbrightShinyWaterProgram);
 	mShaderList.push_back(&gSkinnedObjectSimpleProgram);
 	mShaderList.push_back(&gSkinnedObjectFullbrightProgram);
 	mShaderList.push_back(&gSkinnedObjectFullbrightShinyProgram);
@@ -576,6 +578,7 @@ void LLViewerShaderMgr::unloadShaders()
 
 	gObjectShinyProgram.unload();
 	gObjectFullbrightShinyProgram.unload();
+	gObjectFullbrightShinyWaterProgram.unload();
 	gObjectShinyWaterProgram.unload();
 
 	gSkinnedObjectSimpleProgram.unload();
@@ -685,7 +688,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders()
 	// (in order of shader function call depth for reference purposes, deepest level first)
 
 	shaders.clear();
-	shaders.reserve(12);
+	shaders.reserve(13);
 	shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl",		mVertexShaderLevel[SHADER_WINDLIGHT] ) );
 	shaders.push_back( make_pair( "windlight/gammaF.glsl",					mVertexShaderLevel[SHADER_WINDLIGHT]) );
 	shaders.push_back( make_pair( "windlight/atmosphericsF.glsl",			mVertexShaderLevel[SHADER_WINDLIGHT] ) );
@@ -698,6 +701,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders()
 	shaders.push_back( make_pair( "lighting/lightShinyF.glsl",				mVertexShaderLevel[SHADER_LIGHTING] ) );
 	shaders.push_back( make_pair( "lighting/lightFullbrightShinyF.glsl",	mVertexShaderLevel[SHADER_LIGHTING] ) );
 	shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl",			mVertexShaderLevel[SHADER_LIGHTING] ) );
+	shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) );
 	
 	for (U32 i = 0; i < shaders.size(); i++)
 	{
@@ -1307,6 +1311,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 	{
 		gObjectShinyProgram.unload();
 		gObjectFullbrightShinyProgram.unload();
+		gObjectFullbrightShinyWaterProgram.unload();
 		gObjectShinyWaterProgram.unload();
 		gObjectSimpleProgram.unload();
 		gObjectSimpleWaterProgram.unload();
@@ -1430,6 +1435,23 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		success = gObjectFullbrightShinyProgram.createShader(NULL, &mShinyUniforms);
 	}
 
+	if (success)
+	{
+		gObjectFullbrightShinyWaterProgram.mName = "Fullbright Shiny Water Shader";
+		gObjectFullbrightShinyWaterProgram.mFeatures.calculatesAtmospherics = true;
+		gObjectFullbrightShinyWaterProgram.mFeatures.isFullbright = true;
+		gObjectFullbrightShinyWaterProgram.mFeatures.isShiny = true;
+		gObjectFullbrightShinyWaterProgram.mFeatures.hasGamma = true;
+		gObjectFullbrightShinyWaterProgram.mFeatures.hasTransport = true;
+		gObjectFullbrightShinyWaterProgram.mFeatures.hasWaterFog = true;
+		gObjectFullbrightShinyWaterProgram.mShaderFiles.clear();
+		gObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB));
+		gObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
+		gObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
+		success = gObjectFullbrightShinyWaterProgram.createShader(NULL, &mShinyUniforms);
+	}
+
 	if (success)
 	{
 		gSkinnedObjectSimpleProgram.mName = "Skinned Simple Shader";
@@ -1541,7 +1563,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
 		gSkinnedObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
 		gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.clear();
 		gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB));
-		gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gSkinnedObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
 		success = gSkinnedObjectFullbrightShinyWaterProgram.createShader(NULL, &mShinyUniforms);
 	}
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index b6fa86081c9..7962854cae7 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -311,6 +311,7 @@ extern LLGLSLShader			gObjectSimpleLODProgram;
 extern LLGLSLShader			gObjectFullbrightLODProgram;
 
 extern LLGLSLShader			gObjectFullbrightShinyProgram;
+extern LLGLSLShader			gObjectFullbrightShinyWaterProgram;
 extern LLGLSLShader			gObjectShinyProgram;
 extern LLGLSLShader			gObjectShinyWaterProgram;
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 6fa97b66885..1397b646232 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3546,7 +3546,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 					facep->mLastVertexBuffer = NULL;
 				}
 				
-			facep->setState(LLFace::RIGGED);
+				facep->setState(LLFace::RIGGED);
 				
 				//get drawpool of avatar with rigged face
 				LLDrawPoolAvatar* pool = get_avatar_drawpool(vobj);
@@ -3585,7 +3585,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 						}
 						else
 						{
-							pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SHINY);
+							if (LLPipeline::sRenderDeferred)
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SIMPLE);
+							}
+							else
+							{
+								pool->addRiggedFace(facep, LLDrawPoolAvatar::RIGGED_SHINY);
+							}
 						}
 					}
 					else
-- 
GitLab


From 30f9bc7c9ce9f652c3ccd6ce005f34a6c1ac124d Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Mon, 16 Aug 2010 12:36:55 -0700
Subject: [PATCH 654/683] CT-575 FR linguistic

---
 indra/newview/skins/default/xui/fr/floater_postcard.xml     | 2 +-
 .../skins/default/xui/fr/floater_preview_gesture.xml        | 2 +-
 indra/newview/skins/default/xui/fr/floater_tools.xml        | 4 ++--
 indra/newview/skins/default/xui/fr/menu_picks.xml           | 2 +-
 indra/newview/skins/default/xui/fr/notifications.xml        | 6 +++---
 indra/newview/skins/default/xui/fr/panel_pick_info.xml      | 2 +-
 indra/newview/skins/default/xui/fr/panel_script_ed.xml      | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/indra/newview/skins/default/xui/fr/floater_postcard.xml b/indra/newview/skins/default/xui/fr/floater_postcard.xml
index 91a943ef159..a4b0675fe47 100644
--- a/indra/newview/skins/default/xui/fr/floater_postcard.xml
+++ b/indra/newview/skins/default/xui/fr/floater_postcard.xml
@@ -24,7 +24,7 @@
 	<check_box label="Contenu adulte" name="mature_check" tool_tip="Cette carte postale est à caractère adulte."/>
 	<button label="?" name="publish_help_btn"/>
 	<text_editor name="msg_form">
-		Saisir ici votre message.
+		Saisir ici votre message
 	</text_editor>
 	<text name="fine_print">
 		Si le destinataire s&apos;inscrit sur [SECOND_LIFE], vous recevrez un bonus.
diff --git a/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml b/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
index 82f5bac0471..de8d25a494c 100644
--- a/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
+++ b/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml
@@ -19,7 +19,7 @@
 		Prévisualiser
 	</floater.string>
 	<floater.string name="none_text">
-		- Aucun choix -
+		-Aucun choix-
 	</floater.string>
 	<floater.string name="Title">
 		Geste : [NAME]
diff --git a/indra/newview/skins/default/xui/fr/floater_tools.xml b/indra/newview/skins/default/xui/fr/floater_tools.xml
index 92f02ad1fae..b0c8636ea30 100644
--- a/indra/newview/skins/default/xui/fr/floater_tools.xml
+++ b/indra/newview/skins/default/xui/fr/floater_tools.xml
@@ -48,8 +48,8 @@
 		Glissez pour déplacer, Maj-glissez pour copier.
 	</text>
 	<radio_group name="focus_radio_group">
-		<radio_item label="Zoom" name="radio zoom"/>
-		<radio_item label="Orbite (Ctrl)" name="radio orbit"/>
+		<radio_item label="Zoomer" name="radio zoom"/>
+		<radio_item label="Faire tourner la caméra (Ctrl)" name="radio orbit"/>
 		<radio_item label="Faire un panoramique (Ctrl+Maj)" name="radio pan"/>
 	</radio_group>
 	<radio_group name="move_radio_group">
diff --git a/indra/newview/skins/default/xui/fr/menu_picks.xml b/indra/newview/skins/default/xui/fr/menu_picks.xml
index adb1cec8f56..7d7174d43cc 100644
--- a/indra/newview/skins/default/xui/fr/menu_picks.xml
+++ b/indra/newview/skins/default/xui/fr/menu_picks.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Picks">
 	<menu_item_call label="Infos" name="pick_info"/>
-	<menu_item_call label="Éditer" name="pick_edit"/>
+	<menu_item_call label="Modifier" name="pick_edit"/>
 	<menu_item_call label="Téléporter" name="pick_teleport"/>
 	<menu_item_call label="Carte" name="pick_map"/>
 	<menu_item_call label="Supprimer" name="pick_delete"/>
diff --git a/indra/newview/skins/default/xui/fr/notifications.xml b/indra/newview/skins/default/xui/fr/notifications.xml
index c1321b71ea8..259ac4cee63 100644
--- a/indra/newview/skins/default/xui/fr/notifications.xml
+++ b/indra/newview/skins/default/xui/fr/notifications.xml
@@ -909,7 +909,7 @@ Fusionner le terrain ?
 	</notification>
 	<notification name="CannotSaveToAssetStore">
 		Impossible de sauvegarder le fichier [NAME] dans la base de données centrale.
-Cette erreur est généralement temporaire. Veuillez éditer et sauvegarder l&apos;élément endossable à nouveau d&apos;ici quelques minutes.
+Cette erreur est généralement temporaire. Veuillez modifier et sauvegarder l&apos;élément endossable à nouveau d&apos;ici quelques minutes.
 	</notification>
 	<notification name="YouHaveBeenLoggedOut">
 		Zut. Vous avez été déconnecté(e) de [SECOND_LIFE]
@@ -1917,7 +1917,7 @@ Liez-la à partir d&apos;une page web pour permettre aux autres résidents d&apo
 		<usetemplate name="okcancelbuttons" notext="Non" yestext="Oui"/>
 	</notification>
 	<notification name="WLNoEditDefault">
-		Vous ne pouvez pas éditer ou supprimer un préréglage par défaut.
+		Vous ne pouvez pas modifier ou supprimer un préréglage par défaut.
 	</notification>
 	<notification name="WLMissingSky">
 		Une dossier semble manquer au Cycle du jour : [SKY].
@@ -1953,7 +1953,7 @@ Liez-la à partir d&apos;une page web pour permettre aux autres résidents d&apo
 		Ce préréglage existe déjà !
 	</notification>
 	<notification name="WaterNoEditDefault">
-		Vous ne pouvez pas éditer ou supprimer un préréglage par défaut.
+		Vous ne pouvez pas modifier ou supprimer un préréglage par défaut.
 	</notification>
 	<notification name="ChatterBoxSessionStartError">
 		Impossible de démarrer une nouvelle session de chat avec [RECIPIENT].
diff --git a/indra/newview/skins/default/xui/fr/panel_pick_info.xml b/indra/newview/skins/default/xui/fr/panel_pick_info.xml
index e9572caac76..3ca1e9a21b8 100644
--- a/indra/newview/skins/default/xui/fr/panel_pick_info.xml
+++ b/indra/newview/skins/default/xui/fr/panel_pick_info.xml
@@ -11,6 +11,6 @@
 	<panel name="buttons">
 		<button label="Téléporter" name="teleport_btn"/>
 		<button label="Carte" name="show_on_map_btn"/>
-		<button label="Éditer" name="edit_btn"/>
+		<button label="Modifier" name="edit_btn"/>
 	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/fr/panel_script_ed.xml b/indra/newview/skins/default/xui/fr/panel_script_ed.xml
index ea161ecae85..3b3b676aa15 100644
--- a/indra/newview/skins/default/xui/fr/panel_script_ed.xml
+++ b/indra/newview/skins/default/xui/fr/panel_script_ed.xml
@@ -25,7 +25,7 @@
 			<menu_item_call label="Enregistrer" name="Save"/>
 			<menu_item_call label="Annuler tous les changements" name="Revert All Changes"/>
 		</menu>
-		<menu label="Éditer" name="Edit">
+		<menu label="Modifier" name="Edit">
 			<menu_item_call label="Annuler" name="Undo"/>
 			<menu_item_call label="Refaire" name="Redo"/>
 			<menu_item_call label="Couper" name="Cut"/>
-- 
GitLab


From a6a7f293caa4b5bd0292834a53db01200c3b3081 Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Mon, 16 Aug 2010 13:12:19 -0700
Subject: [PATCH 655/683] EXT-8370 FIX en_xui_change resizing for IT truncation

---
 .../default/xui/en/floater_preview_gesture.xml   | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/indra/newview/skins/default/xui/en/floater_preview_gesture.xml b/indra/newview/skins/default/xui/en/floater_preview_gesture.xml
index 691472633ed..19034019883 100644
--- a/indra/newview/skins/default/xui/en/floater_preview_gesture.xml
+++ b/indra/newview/skins/default/xui/en/floater_preview_gesture.xml
@@ -96,19 +96,19 @@
      name="replace_text"
      tool_tip="Replace the trigger word(s) with these words. For example, trigger &apos;hello&apos; replace with &apos;howdy&apos; will turn the chat &apos;I wanted to say hello&apos; into &apos;I wanted to say howdy&apos; as well as playing the gesture!"
      top_pad="10"
-     width="200">
+     width="210">
         Replace with:
     </text>
     <line_editor
      follows="left|top"
      height="20"
      layout="topleft"
-     left_delta="89"
+     left_delta="99"
      max_length="31"
      name="replace_editor"
      tool_tip="Replace the trigger word(s) with these words. For example, trigger &apos;hello&apos; replace with &apos;howdy&apos; will turn the chat &apos;I wanted to say hello&apos; into &apos;I wanted to say howdy&apos; as well as playing the gesture"
      top_delta="-4"
-     width="175" />
+     width="165" />
     <text
      type="string"
      length="1"
@@ -120,25 +120,25 @@
      font.style="BOLD"
      name="key_label"
      top_pad="10"
-     width="100">
+     width="150">
         Shortcut Key:
     </text>
     <combo_box
      height="20"
      label="None"
      layout="topleft"
-     left_delta="89"
+     left_delta="154"
      name="modifier_combo"
      top_delta="-4"
-     width="75" />
+     width="55" />
     <combo_box
      height="20"
      label="None"
      layout="topleft"
-     left_pad="10"
+     left_pad="4"
      name="key_combo"
      top_delta="0"
-     width="75" />
+     width="50" />
     <text
      type="string"
      length="1"
-- 
GitLab


From 6be8313c9777a48ccf60ff8006c0223bed79de69 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Mon, 16 Aug 2010 23:23:48 +0300
Subject: [PATCH 656/683] EXT-8636 FIXED updating wearables (worn) prefix in
 'My Outfits' list. - Fixed LLOutfitsList COF changes handler to update worn
 status of items removed from COF. Now they are updated based on the
 differences in original items' ids in COF. - Fixed 'My Outfits' items worn
 status check to update depending on whether the item is linked in COF or not.
 This is a kind of workaround to fix updating attachments' worn status because
 LLAppearanceMgr::updateAppearanceFromCOF is triggered erlier than new
 attachment links are fetched. When dumpItemArray(obj_items,"asset_dump:
 obj_item") is called from LLAppearanceMgr::updateAppearanceFromCOF, all
 attachment links have empty asset ids.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/859/.

--HG--
branch : product-engine
---
 indra/newview/lloutfitslist.cpp       | 48 ++++++++++++++++++---------
 indra/newview/lloutfitslist.h         |  4 +++
 indra/newview/llwearableitemslist.cpp | 10 ++++--
 indra/newview/llwearableitemslist.h   |  3 +-
 4 files changed, 44 insertions(+), 21 deletions(-)

diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index 2b6c80bac80..a471158c3d4 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -1055,25 +1055,37 @@ void LLOutfitsList::onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y)
 
 void LLOutfitsList::onCOFChanged()
 {
-	LLInventoryModel::changed_items_t changed_linked_items;
+	LLInventoryModel::cat_array_t cat_array;
+	LLInventoryModel::item_array_t item_array;
 
-	const LLInventoryModel::changed_items_t& changed_items = gInventory.getChangedIDs();
-	for (LLInventoryModel::changed_items_t::const_iterator iter = changed_items.begin();
-		 iter != changed_items.end();
-		 ++iter)
+	// Collect current COF items
+	gInventory.collectDescendents(
+		LLAppearanceMgr::instance().getCOF(),
+		cat_array,
+		item_array,
+		LLInventoryModel::EXCLUDE_TRASH);
+
+	uuid_vec_t vnew;
+	uuid_vec_t vadded;
+	uuid_vec_t vremoved;
+
+	// From gInventory we get the UUIDs of links that are currently in COF.
+	// These links UUIDs are not the same UUIDs that we have in each wearable items list.
+	// So we collect base items' UUIDs to find them or links that point to them in wearable
+	// items lists and update their worn state there.
+	for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin();
+		iter != item_array.end();
+		++iter)
 	{
-		LLViewerInventoryItem* item = gInventory.getItem(*iter);
-		if (item)
-		{
-			// From gInventory we get the UUIDs of new links added to COF
-			// or removed from COF. These links UUIDs are not the same UUIDs
-			// that we have in each wearable items list. So we collect base items
-			// UUIDs to find all items or links that point to same base items in wearable
-			// items lists and update their worn state there.
-			changed_linked_items.insert(item->getLinkedUUID());
-		}
+		vnew.push_back((*iter)->getLinkedUUID());
 	}
 
+	// We need to update only items that were added or removed from COF.
+	LLCommonUtils::computeDifference(vnew, mCOFLinkedItems, vadded, vremoved);
+
+	// Store the ids of items currently linked from COF.
+	mCOFLinkedItems = vnew;
+
 	for (outfits_map_t::iterator iter = mOutfitsMap.begin();
 			iter != mOutfitsMap.end();
 			++iter)
@@ -1084,9 +1096,13 @@ void LLOutfitsList::onCOFChanged()
 		LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView());
 		if (!list) continue;
 
+		// Append removed ids to added ids because we should update all of them.
+		vadded.reserve(vadded.size() + vremoved.size());
+		vadded.insert(vadded.end(), vremoved.begin(), vremoved.end());
+
 		// Every list updates the labels of changed items  or
 		// the links that point to these items.
-		list->updateChangedItems(changed_linked_items);
+		list->updateChangedItems(vadded);
 	}
 }
 
diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h
index 206854b2326..4613bdfeb9b 100644
--- a/indra/newview/lloutfitslist.h
+++ b/indra/newview/lloutfitslist.h
@@ -214,6 +214,10 @@ class LLOutfitsList : public LLPanelAppearanceTab
 	typedef outfits_map_t::value_type					outfits_map_value_t;
 	outfits_map_t					mOutfitsMap;
 
+	// IDs of original items which are worn and linked in COF.
+	// Used to monitor COF changes for updating items worn state. See EXT-8636.
+	uuid_vec_t						mCOFLinkedItems;
+
 	LLOutfitListGearMenu*			mGearMenu;
 	LLListContextMenu*				mOutfitMenu;
 
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 5e23965f625..bff4b9bcbd1 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -124,7 +124,11 @@ void LLPanelWearableOutfitItem::updateItem(const std::string& name,
 {
 	std::string search_label = name;
 
-	if (mWornIndicationEnabled && get_is_item_worn(mInventoryItemUUID))
+	// Updating item's worn status depending on whether it is linked in COF or not.
+	// We don't use get_is_item_worn() here because this update is triggered by
+	// an inventory observer upon link in COF beind added or removed so actual
+	// worn status of a linked item may still remain unchanged.
+	if (mWornIndicationEnabled && LLAppearanceMgr::instance().isLinkInCOF(mInventoryItemUUID))
 	{
 		search_label += LLTrans::getString("worn");
 		item_state = IS_WORN;
@@ -659,7 +663,7 @@ void LLWearableItemsList::updateList(const LLUUID& category_id)
 	refreshList(item_array);
 }
 
-void LLWearableItemsList::updateChangedItems(const LLInventoryModel::changed_items_t& changed_items_uuids)
+void LLWearableItemsList::updateChangedItems(const uuid_vec_t& changed_items_uuids)
 {
 	// nothing to update
 	if (changed_items_uuids.empty()) return;
@@ -681,7 +685,7 @@ void LLWearableItemsList::updateChangedItems(const LLInventoryModel::changed_ite
 
 		LLUUID linked_uuid = inv_item->getLinkedUUID();
 
-		for (LLInventoryModel::changed_items_t::const_iterator iter = changed_items_uuids.begin();
+		for (uuid_vec_t::const_iterator iter = changed_items_uuids.begin();
 				iter != changed_items_uuids.end();
 				++iter)
 		{
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index 237ba1af437..ac4eac4764f 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -39,7 +39,6 @@
 // newview
 #include "llinventoryitemslist.h"
 #include "llinventorylistitem.h"
-#include "llinventorymodel.h"
 #include "lllistcontextmenu.h"
 #include "llwearabletype.h"
 
@@ -441,7 +440,7 @@ class LLWearableItemsList : public LLInventoryItemsList
 	 * Update items that match UUIDs from changed_items_uuids
 	 * or links that point at such items.
 	 */
-	void updateChangedItems(const LLInventoryModel::changed_items_t& changed_items_uuids);
+	void updateChangedItems(const uuid_vec_t& changed_items_uuids);
 
 	bool isStandalone() const { return mIsStandalone; }
 
-- 
GitLab


From 32b8891504556665e02b2cd9beaf2f12f70aa4e1 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Tue, 17 Aug 2010 17:09:23 +0300
Subject: [PATCH 657/683] EXT-7083 FIXED initializing the viewer preferred
 maturity with the value received from the server on login.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/863/.

--HG--
branch : product-engine
---
 indra/newview/llstartup.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 2475870b178..3aad39bcbfc 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -118,6 +118,7 @@
 #include "llinventorybridge.h"
 #include "llinventorymodel.h"
 #include "llinventorymodelbackgroundfetch.h"
+#include "llfriendcard.h"
 #include "llkeyboard.h"
 #include "llloginhandler.h"			// gLoginHandler, SLURL support
 #include "lllogininstance.h" // Host the login module.
@@ -127,6 +128,7 @@
 #include "llfloaterevent.h"
 #include "llpanelclassified.h"
 #include "llpanelpick.h"
+#include "llpanelplace.h"
 #include "llpanelgrouplandmoney.h"
 #include "llpanelgroupnotices.h"
 #include "llpreview.h"
@@ -1644,6 +1646,12 @@ bool idle_startup()
 		//all categories loaded. lets create "My Favorites" category
 		gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE,true);
 
+		// Checks whether "Friends" and "Friends/All" folders exist in "Calling Cards" folder,
+		// fetches their contents if needed and synchronizes it with buddies list.
+		// If the folders are not found they are created.
+		LLFriendCardsManager::instance().syncFriendCardsFolders();
+
+
 		// set up callbacks
 		llinfos << "Registering Callbacks" << llendl;
 		LLMessageSystem* msg = gMessageSystem;
@@ -2925,9 +2933,8 @@ bool process_login_success_response()
 	text = response["agent_region_access"].asString();
 	if (!text.empty())
 	{
-		U32 preferredMaturity =
-			llmin((U32)LLAgent::convertTextToMaturity(text[0]),
-			      gSavedSettings.getU32("PreferredMaturity"));
+		U32 preferredMaturity = (U32)LLAgent::convertTextToMaturity(text[0]);
+
 		gSavedSettings.setU32("PreferredMaturity", preferredMaturity);
 	}
 	// During the AO transition, this flag will be true. Then the flag will
@@ -3140,13 +3147,6 @@ bool process_login_success_response()
 		}
 	}
 
-	// Set the location of the snapshot sharing config endpoint
-	std::string snapshot_config_url = response["snapshot_config_url"];
-	if(!snapshot_config_url.empty())
-	{
-		gSavedSettings.setString("SnapshotConfigURL", snapshot_config_url);
-	}
-
 	// Start the process of fetching the OpenID session cookie for this user login
 	std::string openid_url = response["openid_url"];
 	if(!openid_url.empty())
-- 
GitLab


From 2683006ff4a8325bc884a2861220b08964e7eaad Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Tue, 17 Aug 2010 17:10:13 +0300
Subject: [PATCH 658/683] EXT-8425 ADDITIONAL FIX Fixed broken translation of
 accelerators which was introduced by fix of this bug in changeset
 14331:11122e1fc5cf.

Removed "Key_" prefix from new key strings and from function that finds them, because it broke translation of old accelerator strings.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/861/

--HG--
branch : product-engine
---
 indra/llxuixml/lltrans.h                       | 2 +-
 indra/newview/skins/default/xui/en/strings.xml | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/llxuixml/lltrans.h b/indra/llxuixml/lltrans.h
index 6c8d28b346a..84eeef0aceb 100644
--- a/indra/llxuixml/lltrans.h
+++ b/indra/llxuixml/lltrans.h
@@ -107,7 +107,7 @@ class LLTrans
 	{
 		std::string key_str(keystring);
 		std::string trans_str;
-		return findString(trans_str, "Key_" + key_str) ? trans_str : key_str; 
+		return findString(trans_str, key_str) ? trans_str : key_str; 
 	}
 
 	// get the default args
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 7a292ab943f..04d8c53d97a 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -2282,8 +2282,8 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 	<string name="accel-win-alt">Alt+</string>
 	<string name="accel-win-shift">Shift+</string>
 
-	<string name="Key_Esc">Esc</string>
-	<string name="Key_Home">Home</string>
+	<string name="Esc">Esc</string>
+	<string name="Home">Home</string>
 
 	<!-- Previews -->
 	<string name="FileSaved">File Saved</string>
-- 
GitLab


From 2d9b36535904c31d1fa6d1cf19fa7137424785d4 Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Tue, 17 Aug 2010 11:56:40 -0700
Subject: [PATCH 659/683] CT-575 WIP Polish global translation edit

---
 .../default/xui/pl/floater_bulk_perms.xml     |   4 +-
 .../skins/default/xui/pl/floater_pay.xml      |   2 +-
 .../default/xui/pl/floater_pay_object.xml     |   4 +-
 .../default/xui/pl/floater_post_process.xml   |   2 +-
 .../skins/default/xui/pl/floater_postcard.xml |   8 +-
 .../xui/pl/floater_preview_gesture.xml        |   2 +-
 .../xui/pl/floater_preview_gesture_info.xml   |   2 +-
 .../pl/floater_preview_gesture_shortcut.xml   |   2 +-
 .../xui/pl/floater_preview_gesture_steps.xml  |   2 +-
 .../default/xui/pl/floater_preview_sound.xml  |   2 +-
 .../default/xui/pl/floater_report_abuse.xml   |   6 +-
 .../default/xui/pl/floater_script_search.xml  |   2 +-
 .../default/xui/pl/floater_sell_land.xml      |  12 +-
 .../skins/default/xui/pl/floater_stats.xml    |  14 +-
 .../skins/default/xui/pl/floater_tools.xml    |  30 +-
 .../default/xui/pl/floater_top_objects.xml    |   8 +-
 .../xui/pl/floater_windlight_options.xml      |   6 +-
 .../default/xui/pl/floater_world_map.xml      |  20 +-
 .../skins/default/xui/pl/inspect_avatar.xml   |   4 +-
 .../skins/default/xui/pl/inspect_group.xml    |   2 +-
 .../skins/default/xui/pl/inspect_object.xml   |   2 +-
 .../default/xui/pl/menu_attachment_other.xml  |   6 +-
 .../default/xui/pl/menu_attachment_self.xml   |   6 +-
 .../skins/default/xui/pl/menu_avatar_icon.xml |   2 +-
 .../default/xui/pl/menu_avatar_other.xml      |   6 +-
 .../skins/default/xui/pl/menu_avatar_self.xml |  12 +-
 .../skins/default/xui/pl/menu_bottomtray.xml  |   8 +-
 .../skins/default/xui/pl/menu_cof_gear.xml    |   2 +-
 .../skins/default/xui/pl/menu_favorites.xml   |   2 +-
 .../skins/default/xui/pl/menu_group_plus.xml  |   4 +-
 .../default/xui/pl/menu_imchiclet_group.xml   |   2 +-
 .../default/xui/pl/menu_imchiclet_p2p.xml     |   4 +-
 .../xui/pl/menu_inspect_avatar_gear.xml       |   6 +-
 .../default/xui/pl/menu_inspect_self_gear.xml |   6 +-
 .../skins/default/xui/pl/menu_inventory.xml   |  14 +-
 .../default/xui/pl/menu_inventory_add.xml     |   6 +-
 .../xui/pl/menu_inventory_gear_default.xml    |   2 +-
 .../skins/default/xui/pl/menu_land.xml        |   2 +-
 .../skins/default/xui/pl/menu_login.xml       |   4 +-
 .../skins/default/xui/pl/menu_navbar.xml      |   4 +-
 .../skins/default/xui/pl/menu_outfit_gear.xml |   4 +-
 .../default/xui/pl/menu_participant_list.xml  |   4 +-
 .../default/xui/pl/menu_people_groups.xml     |   2 +-
 .../xui/pl/menu_people_groups_view_sort.xml   |   4 +-
 .../default/xui/pl/menu_people_nearby.xml     |   6 +-
 .../xui/pl/menu_people_nearby_multiselect.xml |   4 +-
 .../skins/default/xui/pl/menu_picks_plus.xml  |   2 +-
 .../skins/default/xui/pl/menu_place.xml       |   4 +-
 .../default/xui/pl/menu_place_add_button.xml  |   2 +-
 .../xui/pl/menu_places_gear_folder.xml        |   2 +-
 .../xui/pl/menu_places_gear_landmark.xml      |   4 +-
 .../skins/default/xui/pl/menu_slurl.xml       |   4 +-
 .../xui/pl/menu_teleport_history_gear.xml     |   2 +-
 .../skins/default/xui/pl/menu_text_editor.xml |   2 +-
 .../skins/default/xui/pl/menu_url_agent.xml   |   2 +-
 .../skins/default/xui/pl/menu_url_group.xml   |   4 +-
 .../default/xui/pl/menu_url_inventory.xml     |   2 +-
 .../skins/default/xui/pl/menu_url_parcel.xml  |   2 +-
 .../skins/default/xui/pl/menu_url_slurl.xml   |   2 +-
 .../default/xui/pl/menu_url_teleport.xml      |   2 +-
 .../skins/default/xui/pl/menu_viewer.xml      | 358 +++++-----
 .../skins/default/xui/pl/mime_types_mac.xml   |   8 +-
 .../skins/default/xui/pl/notifications.xml    | 120 ++--
 .../xui/pl/panel_active_object_row.xml        |   4 +-
 .../xui/pl/panel_adhoc_control_panel.xml      |   4 +-
 .../default/xui/pl/panel_audio_device.xml     |  10 +-
 .../xui/pl/panel_block_list_sidetray.xml      |   6 +-
 .../skins/default/xui/pl/panel_bottomtray.xml |  12 +-
 .../default/xui/pl/panel_bottomtray_lite.xml  |   2 +-
 .../skins/default/xui/pl/panel_edit_alpha.xml |  10 +-
 .../default/xui/pl/panel_edit_classified.xml  |  10 +-
 .../default/xui/pl/panel_edit_profile.xml     |   4 +-
 .../default/xui/pl/panel_edit_wearable.xml    |   8 +-
 .../skins/default/xui/pl/panel_friends.xml    |   4 +-
 .../xui/pl/panel_group_control_panel.xml      |   4 +-
 .../default/xui/pl/panel_group_general.xml    |   8 +-
 .../xui/pl/panel_group_info_sidetray.xml      |   4 +-
 .../default/xui/pl/panel_group_invite.xml     |   6 +-
 .../default/xui/pl/panel_group_land_money.xml |  16 +-
 .../default/xui/pl/panel_group_notices.xml    |   8 +-
 .../default/xui/pl/panel_group_notify.xml     |   2 +-
 .../default/xui/pl/panel_group_roles.xml      |  40 +-
 .../skins/default/xui/pl/panel_groups.xml     |   2 +-
 .../default/xui/pl/panel_im_control_panel.xml |   2 +-
 .../default/xui/pl/panel_landmark_info.xml    |   8 +-
 .../skins/default/xui/pl/panel_login.xml      |   2 +-
 .../xui/pl/panel_media_settings_general.xml   |  10 +-
 .../pl/panel_media_settings_permissions.xml   |   8 +-
 .../skins/default/xui/pl/panel_my_profile.xml |   8 +-
 .../default/xui/pl/panel_nearby_chat_bar.xml  |   2 +-
 .../default/xui/pl/panel_nearby_media.xml     |   8 +-
 .../default/xui/pl/panel_outfit_edit.xml      |   2 +-
 .../panel_outfits_inventory_gear_default.xml  |  10 +-
 .../skins/default/xui/pl/panel_people.xml     |  18 +-
 .../default/xui/pl/panel_place_profile.xml    |   8 +-
 .../xui/pl/panel_preferences_advanced.xml     |   8 +-
 .../xui/pl/panel_preferences_alerts.xml       |   2 +-
 .../xui/pl/panel_preferences_general.xml      |  14 +-
 .../xui/pl/panel_preferences_graphics1.xml    |  16 +-
 .../xui/pl/panel_preferences_privacy.xml      |   4 +-
 .../xui/pl/panel_preferences_setup.xml        |   8 +-
 .../xui/pl/panel_preferences_sound.xml        |  14 +-
 .../xui/pl/panel_prim_media_controls.xml      |  12 +-
 .../skins/default/xui/pl/panel_profile.xml    |   4 +-
 .../default/xui/pl/panel_region_covenant.xml  |   2 +-
 .../default/xui/pl/panel_region_estate.xml    |   8 +-
 .../default/xui/pl/panel_region_general.xml   |   6 +-
 .../xui/pl/panel_region_general_layout.xml    |   6 +-
 .../default/xui/pl/panel_region_terrain.xml   |   6 +-
 .../default/xui/pl/panel_region_texture.xml   |   4 +-
 .../skins/default/xui/pl/panel_script_ed.xml  |   4 +-
 .../xui/pl/panel_script_limits_my_avatar.xml  |   4 +-
 .../pl/panel_script_limits_region_memory.xml  |   4 +-
 .../skins/default/xui/pl/panel_side_tray.xml  |   4 +-
 .../xui/pl/panel_stand_stop_flying.xml        |   2 +-
 .../skins/default/xui/pl/panel_status_bar.xml |   6 +-
 .../skins/default/xui/pl/role_actions.xml     |  76 +--
 .../default/xui/pl/sidepanel_appearance.xml   |   4 +-
 .../default/xui/pl/sidepanel_item_info.xml    |   4 +-
 .../default/xui/pl/sidepanel_task_info.xml    |   2 +-
 .../newview/skins/default/xui/pl/strings.xml  | 630 +++++++++---------
 .../skins/default/xui/pl/teleport_strings.xml |  14 +-
 122 files changed, 949 insertions(+), 949 deletions(-)

diff --git a/indra/newview/skins/default/xui/pl/floater_bulk_perms.xml b/indra/newview/skins/default/xui/pl/floater_bulk_perms.xml
index ed2e037d3c0..0f49061002e 100644
--- a/indra/newview/skins/default/xui/pl/floater_bulk_perms.xml
+++ b/indra/newview/skins/default/xui/pl/floater_bulk_perms.xml
@@ -18,8 +18,8 @@
 	<icon name="icon_bodypart" tool_tip="Części Ciała"/>
 	<check_box label="Ubranie" name="check_clothing"/>
 	<icon name="icon_clothing" tool_tip="Ubranie"/>
-	<check_box label="Gestury" name="check_gesture"/>
-	<icon name="icon_gesture" tool_tip="Gestury"/>
+	<check_box label="Gesturki" name="check_gesture"/>
+	<icon name="icon_gesture" tool_tip="Gesturki"/>
 	<check_box label="Noty" name="check_notecard"/>
 	<icon name="icon_notecard" tool_tip="Noty"/>
 	<check_box label="Obiekty" name="check_object"/>
diff --git a/indra/newview/skins/default/xui/pl/floater_pay.xml b/indra/newview/skins/default/xui/pl/floater_pay.xml
index dccb7ed2bb8..c9243fda65b 100644
--- a/indra/newview/skins/default/xui/pl/floater_pay.xml
+++ b/indra/newview/skins/default/xui/pl/floater_pay.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <floater name="Give Money" title="">
 	<string name="payee_group">
-		Zapłać Grupie
+		Zapłać grupie
 	</string>
 	<string name="payee_resident">
 		Zapłać Rezydentowi
diff --git a/indra/newview/skins/default/xui/pl/floater_pay_object.xml b/indra/newview/skins/default/xui/pl/floater_pay_object.xml
index d0c69a6c21a..19032b3e5de 100644
--- a/indra/newview/skins/default/xui/pl/floater_pay_object.xml
+++ b/indra/newview/skins/default/xui/pl/floater_pay_object.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <floater name="Give Money" title="">
 	<string halign="left" name="payee_group" width="100">
-		Zapłać Grupie
+		Zapłać grupie
 	</string>
 	<string halign="left" name="payee_resident" width="120">
 		Zapłać Rezydentowi
@@ -11,7 +11,7 @@
 		[FIRST] [LAST]
 	</text>
 	<text halign="left" left="5" name="object_name_label" width="95">
-		Poprzez Obiekt:
+		Poprzez obiekt:
 	</text>
 	<icon name="icon_object" tool_tip="Obiekt"/>
 	<text left="105" name="object_name_text">
diff --git a/indra/newview/skins/default/xui/pl/floater_post_process.xml b/indra/newview/skins/default/xui/pl/floater_post_process.xml
index a3515915bf7..e3dce849331 100644
--- a/indra/newview/skins/default/xui/pl/floater_post_process.xml
+++ b/indra/newview/skins/default/xui/pl/floater_post_process.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <floater name="Post-Process Floater" title="USTAWIENIA PRZETWARZANIA KOŃCOWEGO">
 	<tab_container name="Post-Process Tabs">
-		<panel label="Kolor Filtru" name="wmiColorFilterPanel">
+		<panel label="Kolor filtra" name="wmiColorFilterPanel">
 			<check_box label="Udostępnij" name="wmiColorFilterToggle" />
 			<text name="wmiColorFilterBrightnessText">
 				Jasność
diff --git a/indra/newview/skins/default/xui/pl/floater_postcard.xml b/indra/newview/skins/default/xui/pl/floater_postcard.xml
index 095974aa613..fe796c6fa00 100644
--- a/indra/newview/skins/default/xui/pl/floater_postcard.xml
+++ b/indra/newview/skins/default/xui/pl/floater_postcard.xml
@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <floater name="Postcard" title="WYŚLIJ POCZTÓWKĘ (EMAIL)">
 	<text name="to_label">
-		Email Odbiorcy:
+		Email odbiorcy:
 	</text>
 	<text name="from_label">
-		Twój Email:
+		Twój email:
 	</text>
 	<text name="name_label">
-		Twoje Dane:
+		Twoje dane:
 	</text>
 	<text name="subject_label">
 		Temat:
@@ -20,7 +20,7 @@
 		Wpisz treść swojej wiadomości tutaj
 	</text_editor>
 	<text name="fine_print">
-		Jeżeli Odbiorca tej pocztówki dołączy do [SECOND_LIFE], otrzymasz bonus.
+		Jeżeli odbiorca tej pocztówki dołączy do [SECOND_LIFE], otrzymasz bonus.
 	</text>
 	<button label="Anuluj" name="cancel_btn"/>
 	<button label="Wyślij" name="send_btn"/>
diff --git a/indra/newview/skins/default/xui/pl/floater_preview_gesture.xml b/indra/newview/skins/default/xui/pl/floater_preview_gesture.xml
index 9ae63031b6a..81712256669 100644
--- a/indra/newview/skins/default/xui/pl/floater_preview_gesture.xml
+++ b/indra/newview/skins/default/xui/pl/floater_preview_gesture.xml
@@ -67,7 +67,7 @@
 	<text name="help_label">
 		Wszystkie etapy nastąpią razem, chyba, że dodasz pauzy.
 	</text>
-	<check_box label="Aktywny" name="active_check" tool_tip="Aktywne gesty można włączać używając przypisanej frazy w czacie albo używając przypisanego klawisza skrótowego. W przypaku konfliktu przypisań gesty zazwyczaj nie będą działać."/>
+	<check_box label="Aktywna" name="active_check" tool_tip="Aktywne gesturki można włączać używając przypisanej frazy w czacie albo używając przypisanego klawisza skrótowego. W przypaku konfliktu przypisań gesty zazwyczaj nie będą działać."/>
 	<button label="Pokaż" name="preview_btn"/>
 	<button label="Zapisz" name="save_btn"/>
 </floater>
diff --git a/indra/newview/skins/default/xui/pl/floater_preview_gesture_info.xml b/indra/newview/skins/default/xui/pl/floater_preview_gesture_info.xml
index d31cada96d4..a041472f68f 100644
--- a/indra/newview/skins/default/xui/pl/floater_preview_gesture_info.xml
+++ b/indra/newview/skins/default/xui/pl/floater_preview_gesture_info.xml
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="Gesture" title="GEST"/>
+<floater name="Gesture" title="GESTURKI"/>
diff --git a/indra/newview/skins/default/xui/pl/floater_preview_gesture_shortcut.xml b/indra/newview/skins/default/xui/pl/floater_preview_gesture_shortcut.xml
index d33b799476e..9692fca9cd7 100644
--- a/indra/newview/skins/default/xui/pl/floater_preview_gesture_shortcut.xml
+++ b/indra/newview/skins/default/xui/pl/floater_preview_gesture_shortcut.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="Gesture" title="GESTY">
+<floater name="Gesture" title="GESTURKI">
 	<text name="trigger_label">
 		Czat:
 	</text>
diff --git a/indra/newview/skins/default/xui/pl/floater_preview_gesture_steps.xml b/indra/newview/skins/default/xui/pl/floater_preview_gesture_steps.xml
index 6592d9dad0f..a041472f68f 100644
--- a/indra/newview/skins/default/xui/pl/floater_preview_gesture_steps.xml
+++ b/indra/newview/skins/default/xui/pl/floater_preview_gesture_steps.xml
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="Gesture" title="GESTY"/>
+<floater name="Gesture" title="GESTURKI"/>
diff --git a/indra/newview/skins/default/xui/pl/floater_preview_sound.xml b/indra/newview/skins/default/xui/pl/floater_preview_sound.xml
index d02b3ca75ee..3825fe742e4 100644
--- a/indra/newview/skins/default/xui/pl/floater_preview_sound.xml
+++ b/indra/newview/skins/default/xui/pl/floater_preview_sound.xml
@@ -7,5 +7,5 @@
 		Opis:
 	</text>
 	<button label="Odtwarzaj" label_selected="Odtwarzaj" left_delta="-136" name="Sound play btn" tool_tip="Dźwięk będzie słyszalny przez wszystkich." width="130"/>
-	<button label="Odtwarzaj Lokalnie" label_selected="Odtwarzaj lokalnie" name="Sound audition btn" tool_tip="Dźwięk będzie słyszalny tylko dla Ciebie."/>
+	<button label="Odtwarzaj lokalnie" label_selected="Odtwarzaj lokalnie" name="Sound audition btn" tool_tip="Dźwięk będzie słyszalny tylko dla Ciebie."/>
 </floater>
diff --git a/indra/newview/skins/default/xui/pl/floater_report_abuse.xml b/indra/newview/skins/default/xui/pl/floater_report_abuse.xml
index a6f8ba6c11d..a5b96601b88 100644
--- a/indra/newview/skins/default/xui/pl/floater_report_abuse.xml
+++ b/indra/newview/skins/default/xui/pl/floater_report_abuse.xml
@@ -27,7 +27,7 @@
 	</text>
 	<button label="" label_selected="" name="pick_btn" tool_tip="Wybór obiektu - wybierz obiekt, którego dotyczy raport"/>
 	<text name="object_name_label">
-		Nazwa Obiektu:
+		Nazwa obiektu:
 	</text>
 	<text name="object_name">
 		Consetetur Sadipscing
@@ -67,8 +67,8 @@
 		<combo_box.item label="Prześladowanie &gt; Znieważanie Słowne" name="Harassment__Verbal_abuse"/>
 		<combo_box.item label="Nieprzyzwoitość &gt; Obraźliwa treść lub postępowanie" name="Indecency__Broadly_offensive_content_or_conduct"/>
 		<combo_box.item label="Nieprzyzwoitość &gt; Niestosowne imię awatara" name="Indecency__Inappropriate_avatar_name"/>
-		<combo_box.item label="Nieprzyzwoitość &gt; Obraźliwa treść i postępowanie w Regionie &apos;PG&apos;" name="Indecency__Mature_content_in_PG_region"/>
-		<combo_box.item label="Nieprzyzwoitość &gt; Obraźliwa treść i postępowanie w Regionie &apos;Mature&apos;" name="Indecency__Inappropriate_content_in_Mature_region"/>
+		<combo_box.item label="Nieprzyzwoitość &gt; Obraźliwa treść i postępowanie w Regionie &apos;General&apos;" name="Indecency__Mature_content_in_PG_region"/>
+		<combo_box.item label="Nieprzyzwoitość &gt; Obraźliwa treść i postępowanie w Regionie &apos;Moderate&apos;" name="Indecency__Inappropriate_content_in_Mature_region"/>
 		<combo_box.item label="Naruszenie własności intelektualnej &gt; usunięcie treści" name="Intellectual_property_infringement_Content_Removal"/>
 		<combo_box.item label="Naruszenie własności intelektualnej &gt; CopyBot albo nadużycie przywilejów" name="Intellectual_property_infringement_CopyBot_or_Permissions_Exploit"/>
 		<combo_box.item label="Nietolerancja" name="Intolerance"/>
diff --git a/indra/newview/skins/default/xui/pl/floater_script_search.xml b/indra/newview/skins/default/xui/pl/floater_script_search.xml
index cb010daee4e..901d61a1377 100644
--- a/indra/newview/skins/default/xui/pl/floater_script_search.xml
+++ b/indra/newview/skins/default/xui/pl/floater_script_search.xml
@@ -3,7 +3,7 @@
 	<check_box label="CapsLoock nieaktywny" name="case_text"/>
 	<button label="Szukaj" label_selected="Szukaj" name="search_btn"/>
 	<button label="Zamień" label_selected="Zamień" name="replace_btn"/>
-	<button label="Zamień Wszystko" label_selected="Zamień wszystko" name="replace_all_btn"/>
+	<button label="Zamień wszystko" label_selected="Zamień wszystko" name="replace_all_btn"/>
 	<text name="txt">
 		Szukaj
 	</text>
diff --git a/indra/newview/skins/default/xui/pl/floater_sell_land.xml b/indra/newview/skins/default/xui/pl/floater_sell_land.xml
index eb1ed74797e..528e5a416b7 100644
--- a/indra/newview/skins/default/xui/pl/floater_sell_land.xml
+++ b/indra/newview/skins/default/xui/pl/floater_sell_land.xml
@@ -15,13 +15,13 @@
 				[AREA] m²
 			</text>
 			<text name="info_action">
-				Aby sprzedać tą Posiadłość:
+				Aby sprzedać tą posiadłość:
 			</text>
 			<text name="price_label">
 				1. Ustal cenÄ™:
 			</text>
 			<text name="price_text">
-				Wybierz właściwą cenę za tą Posiadłość.
+				Wybierz właściwą cenę za tą posiadłość.
 			</text>
 			<text name="price_ld">
 				L$
@@ -33,7 +33,7 @@
 				(L$[PER_METER] za m²)
 			</text>
 			<text name="sell_to_label">
-				2. Sprzedaj Posiadłość:
+				2. Sprzedaj posiadłość:
 			</text>
 			<text name="sell_to_text">
 				Wybierz sprzedaż dla kogokolwiek albo dla wybranego kupca.
@@ -45,14 +45,14 @@
 			</combo_box>
 			<button label="Wybierz" name="sell_to_select_agent"/>
 			<text name="sell_objects_label">
-				3. Obiekty sprzedawane razem z Posiadłością?
+				3. Obiekty sprzedawane razem z posiadłością?
 			</text>
 			<text name="sell_objects_text">
-				Przekazywalne obiekty właściciela Posiadłości zmienią właściciela.
+				Przekazywalne obiekty właściciela posiadłości zmienią właściciela.
 			</text>
 			<radio_group name="sell_objects">
 				<radio_item label="Nie, zatrzymaj obiekty" name="no"/>
-				<radio_item label="Tak, sprzedaj obiekty razem z Posiadłością" name="yes"/>
+				<radio_item label="Tak, sprzedaj obiekty razem z posiadłością" name="yes"/>
 			</radio_group>
 			<button label="Pokaż Obiekty" name="show_objects"/>
 			<text name="nag_message_label">
diff --git a/indra/newview/skins/default/xui/pl/floater_stats.xml b/indra/newview/skins/default/xui/pl/floater_stats.xml
index ee5fba4d635..886a30e5d9d 100644
--- a/indra/newview/skins/default/xui/pl/floater_stats.xml
+++ b/indra/newview/skins/default/xui/pl/floater_stats.xml
@@ -30,18 +30,18 @@
 					<stat_bar label="Tesktura" name="texturekbitstat"/>
 					<stat_bar label="Asset" name="assetkbitstat"/>
 					<stat_bar label="Podkład" name="layerskbitstat"/>
-					<stat_bar label="Aktualna Ilość Wewnętrzna" name="actualinkbitstat"/>
-					<stat_bar label="Aktualna Ilość Zewnętrzna" name="actualoutkbitstat"/>
+					<stat_bar label="Aktualna ilość wewnętrzna" name="actualinkbitstat"/>
+					<stat_bar label="Aktualna ilość zewnętrzna" name="actualoutkbitstat"/>
 					<stat_bar label="VFS Pending Ops" name="vfspendingoperations"/>
 				</stat_view>
 			</stat_view>
 			<stat_view label="Symulator" name="sim">
-				<stat_bar label="Czas Rozszerzenia" name="simtimedilation"/>
-				<stat_bar label="Ilość Obrazów/Sec na Symulatorze (Sim FPS)" name="simfps"/>
-				<stat_bar label="Fizyka Obrazów/Sec" name="simphysicsfps"/>
-				<stat_view label="Szczegóły Fizyki" name="physicsdetail">
+				<stat_bar label="Czas rozszerzenia" name="simtimedilation"/>
+				<stat_bar label="Ilość obrazów/Sec na symulatorze (Sim FPS)" name="simfps"/>
+				<stat_bar label="Fizyka obrazów/Sec" name="simphysicsfps"/>
+				<stat_view label="Szczegóły fizyki" name="physicsdetail">
 					<stat_bar label="Pinned objects" name="physicspinnedtasks"/>
-					<stat_bar label="Niskie LOD Obiektów" name="physicslodtasks"/>
+					<stat_bar label="Niskie LOD obiektów" name="physicslodtasks"/>
 					<stat_bar label="Alokacja pamięci" name="physicsmemoryallocated"/>
 					<stat_bar label="Aktualizacja agentów/Sek" name="simagentups"/>
 					<stat_bar label="Główni agenci" name="simmainagents"/>
diff --git a/indra/newview/skins/default/xui/pl/floater_tools.xml b/indra/newview/skins/default/xui/pl/floater_tools.xml
index 7e97297bca2..817a72efd96 100644
--- a/indra/newview/skins/default/xui/pl/floater_tools.xml
+++ b/indra/newview/skins/default/xui/pl/floater_tools.xml
@@ -22,7 +22,7 @@
 		Kliknij in-world by zacząć budować
 	</floater.string>
 	<floater.string name="status_selectland">
-		Edytowanie Terenu:
+		Edytowanie terenu:
 	</floater.string>
 	<floater.string name="grid_screen_text">
 		Widok
@@ -71,7 +71,7 @@
 	<text label="RozciÄ…gnij 2 strony" name="checkbox uniform label">
 		RozciÄ…gnij 2 strony
 	</text>
-	<check_box initial_value="true" label="RozciÄ…gnij TeksturÄ™" name="checkbox stretch textures"/>
+	<check_box initial_value="true" label="RozciÄ…gnij teksturÄ™" name="checkbox stretch textures"/>
 	<check_box initial_value="true" label="Użyj siatki" name="checkbox snap to grid"/>
 	<combo_box name="combobox grid mode" tool_tip="Wybierz rodzaj linijki siatki dla pozycjonowania obiektu">
 		<combo_box.item label="Åšwiat" name="World"/>
@@ -218,11 +218,11 @@
 				<check_box label="Przesuń" name="checkbox allow everyone move"/>
 				<check_box label="Kopiuj" name="checkbox allow everyone copy"/>
 				<text name="Next owner can:">
-					Następny Właściciel:
+					Następny właściciel:
 				</text>
 				<check_box label="Zmienia" name="checkbox next owner can modify"/>
 				<check_box label="Kopiuje" name="checkbox next owner can copy"/>
-				<check_box label="Oddaje/Sprzedaje" name="checkbox next owner can transfer" tool_tip="Następny Właściciel może oddawać lub sprzedawać ten obiekt"/>
+				<check_box label="Oddaje/Sprzedaje" name="checkbox next owner can transfer" tool_tip="Następny właściciel może oddawać lub sprzedawać ten obiekt"/>
 				<text name="B:">
 					B:
 				</text>
@@ -299,7 +299,7 @@
 			<spinner name="Scale 1"/>
 			<spinner name="Skew"/>
 			<text name="Hollow Shape">
-				Kształt Wydrążenia
+				Kształt wydrążenia
 			</text>
 			<combo_box name="hole">
 				<combo_box.item label="Domyślny" name="Default"/>
@@ -399,7 +399,7 @@
 			<texture_picker label="Tekstura" name="texture control" tool_tip="Kliknij by wybrać obraz"/>
 			<color_swatch label="Kolor" name="colorswatch" tool_tip="Kliknij aby wybrać kolor"/>
 			<text left="170" name="color trans" width="99">
-				Przezroczystość%
+				Przezroczystość %
 			</text>
 			<spinner left="170" name="ColorTrans"/>
 			<text left="170" name="glow label">
@@ -431,9 +431,9 @@
 				<combo_box.item label="Najjaśniejsza" name="Brightness"/>
 				<combo_box.item label="Najciemniejsza" name="Darkness"/>
 				<combo_box.item label="Drewniano-ziarnista" name="woodgrain"/>
-				<combo_box.item label="Kory Drzewa" name="bark"/>
+				<combo_box.item label="Kory drzewa" name="bark"/>
 				<combo_box.item label="Cegieł" name="bricks"/>
-				<combo_box.item label="Planszy Szachowej" name="checker"/>
+				<combo_box.item label="Planszy szachowej" name="checker"/>
 				<combo_box.item label="Betonu" name="concrete"/>
 				<combo_box.item label="PÅ‚ytki/Kafelki" name="crustytile"/>
 				<combo_box.item label="Kamienia" name="cutstone"/>
@@ -441,7 +441,7 @@
 				<combo_box.item label="Żwiru" name="gravel"/>
 				<combo_box.item label="Skamieliny" name="petridish"/>
 				<combo_box.item label="Brzegu" name="siding"/>
-				<combo_box.item label="PÅ‚ytki Kamiennej" name="stonetile"/>
+				<combo_box.item label="PÅ‚ytki kamiennej" name="stonetile"/>
 				<combo_box.item label="Stucco" name="stucco"/>
 				<combo_box.item label="Suction" name="suction"/>
 				<combo_box.item label="Fali" name="weave"/>
@@ -478,7 +478,7 @@
 	</tab_container>
 	<panel name="land info panel">
 		<text name="label_parcel_info">
-			Informacje o Posiadłości
+			Informacje o posiadłości
 		</text>
 		<text name="label_area_price">
 			Cena: L$[PRICE] za [AREA] m²
@@ -487,16 +487,16 @@
 			Obszar: [AREA] m²
 		</text>
 		<button label="O Posiadłości" label_selected="O Posiadłości" name="button about land"/>
-		<check_box label="Pokaż Właścicieli" name="checkbox show owners" tool_tip="Pokoloruj Posiadłości zgodnie z przynależnością do Właściciela:   Zielony = Twoja Posiadłość  Morski = Posiadłość Twojej Grupy  Czerwony = Posiadłości innych  Żółty = Na sprzedaż  Fioletowy = Na aukcję  Szary = Publiczna"/>
+		<check_box label="Pokaż właścicieli" name="checkbox show owners" tool_tip="Pokoloruj posiadłości zgodnie z przynależnością do właściciela:   Zielony = Twoja posiadłość  Morski = posiadłość Twojej grupy  Czerwony = posiadłości innych  Żółty = Na sprzedaż  Fioletowy = Na aukcję  Szary = Publiczna"/>
 		<text name="label_parcel_modify">
-			Modyfikuj Posiadłość
+			Modyfikuj posiadłość
 		</text>
 		<button label="Podziel" label_selected="Podziel" name="button subdivide land"/>
 		<button label="ZÅ‚Ä…cz" label_selected="ZÅ‚Ä…cz" name="button join land"/>
 		<text name="label_parcel_trans">
-			Transakcje na Posiadłości
+			Transakcje na posiadłości
 		</text>
-		<button label="Kup Posiadłość" label_selected="Kup Posiadłość" name="button buy land"/>
-		<button label="Porzuć Posiadłość" label_selected="Porzuć Posiadłość" name="button abandon land"/>
+		<button label="Kup posiadłość" label_selected="Kup posiadłość" name="button buy land"/>
+		<button label="Porzuć posiadłość" label_selected="Porzuć posiadłość" name="button abandon land"/>
 	</panel>
 </floater>
diff --git a/indra/newview/skins/default/xui/pl/floater_top_objects.xml b/indra/newview/skins/default/xui/pl/floater_top_objects.xml
index 6afbce7e106..2b06ae9f782 100644
--- a/indra/newview/skins/default/xui/pl/floater_top_objects.xml
+++ b/indra/newview/skins/default/xui/pl/floater_top_objects.xml
@@ -10,7 +10,7 @@
 		Czas
 	</floater.string>
 	<floater.string name="scripts_mono_time_label">
-		Mono Time
+		Czas Mono
 	</floater.string>
 	<floater.string name="top_colliders_title">
 		Główne kolizje
@@ -33,7 +33,7 @@
 		<scroll_list.columns label="Właściciel" name="owner"/>
 		<scroll_list.columns label="Miejsce" name="location"/>
 		<scroll_list.columns label="Czas" name="time"/>
-		<scroll_list.columns label="Mono Time" name="mono_time"/>
+		<scroll_list.columns label="Czas Mono" name="mono_time"/>
 		<scroll_list.columns label="URL" name="URLs"/>
 	</scroll_list>
 	<text name="id_text">
@@ -51,6 +51,6 @@
 	<button label="Odśwież" name="refresh_btn"/>
 	<button label="Zwróć wybrane" name="return_selected_btn"/>
 	<button label="Zwróć wszystko" name="return_all_btn"/>
-	<button label="Deaktywuj wybrane" name="disable_selected_btn"/>
-	<button label="Deaktywuj wszystko" name="disable_all_btn"/>
+	<button label="Dezaktywuj wybrane" name="disable_selected_btn"/>
+	<button label="Dezaktywuj wszystko" name="disable_all_btn"/>
 </floater>
diff --git a/indra/newview/skins/default/xui/pl/floater_windlight_options.xml b/indra/newview/skins/default/xui/pl/floater_windlight_options.xml
index 49e523fae8b..930e9044648 100644
--- a/indra/newview/skins/default/xui/pl/floater_windlight_options.xml
+++ b/indra/newview/skins/default/xui/pl/floater_windlight_options.xml
@@ -77,7 +77,7 @@
 		</panel>
 		<panel label="ŚWIATŁO" name="Lighting">
 			<text name="SLCText">
-				Kolor słońca/księżyca
+				Kolor Słońca/Księżyca
 			</text>
 			<button label="?" name="WLSunlightColorHelp"/>
 			<text name="BHText">
@@ -97,7 +97,7 @@
 			<slider label="" name="WLSunlightB"/>
 			<slider label="" name="WLSunlightI"/>
 			<text name="TODText">
-				Pozycja słońca/księżyca
+				Pozycja Słońca/Księżyca
 			</text>
 			<button label="?" name="WLTimeOfDayHelp"/>
 			<slider label="" name="WLSunAngle"/>
@@ -127,7 +127,7 @@
 			<button label="?" name="WLEastAngleHelp"/>
 			<slider label="" name="WLEastAngle"/>
 			<text name="SunGlowText">
-				Blask słońca
+				Blask Słońca
 			</text>
 			<button label="?" name="WLSunGlowHelp"/>
 			<slider label="Ostrość" name="WLGlowB"/>
diff --git a/indra/newview/skins/default/xui/pl/floater_world_map.xml b/indra/newview/skins/default/xui/pl/floater_world_map.xml
index 5bf394f45ab..4f533373658 100644
--- a/indra/newview/skins/default/xui/pl/floater_world_map.xml
+++ b/indra/newview/skins/default/xui/pl/floater_world_map.xml
@@ -17,13 +17,13 @@
 			Infohub
 		</text>
 		<text name="land_sale_label">
-			Sprzedaż Posiadłości
+			Sprzedaż posiadłości
 		</text>
 		<text name="auction_label">
-			aukcja Posiadłości
+			Aukcja posiadłości
 		</text>
 		<text name="by_owner_label">
-			przez Właściciela
+			przez właściciela
 		</text>
 		<button name="Go Home" tool_tip="Teleportuj do mojego Miejsca Startowego"/>
 		<text name="Home_label">
@@ -33,11 +33,11 @@
 			Wydarzenia:
 		</text>
 		<text name="pg_label">
-			Ogólne
+			General
 		</text>
 		<check_box initial_value="true" name="events_mature_chk"/>
 		<text name="events_mature_label">
-			Moderuj
+			Moderate
 		</text>
 		<text name="events_adult_label">
 			Adult
@@ -49,13 +49,13 @@
 		</text>
 	</panel>
 	<panel name="layout_panel_4">
-		<combo_box label="Dostępni Znajomi" name="friend combo" tool_tip="Pokaż znajomych na mapie">
-			<combo_box.item label="Moi Dostępni Znajomi" name="item1"/>
+		<combo_box label="Dostępni znajomi" name="friend combo" tool_tip="Pokaż znajomych na mapie">
+			<combo_box.item label="Moi dostępni znajomi" name="item1"/>
 		</combo_box>
-		<combo_box label="Zapisane Miejsca" name="landmark combo" tool_tip="Pokaż zapisane miejsce na mapie">
-			<combo_box.item label="Zapisane Miejsca" name="item1"/>
+		<combo_box label="Zapisane miejsca" name="landmark combo" tool_tip="Pokaż zapisane miejsce na mapie">
+			<combo_box.item label="Zapisane miejsca" name="item1"/>
 		</combo_box>
-		<search_editor label="Regiony Według Nazwy" name="location" tool_tip="Wpisz nazwę regionu"/>
+		<search_editor label="Regiony według nazwy" name="location" tool_tip="Wpisz nazwę regionu"/>
 		<button label="Znajdź" name="DoSearch" tool_tip="Szukaj regionu"/>
 		<button name="Clear" tool_tip="Wyczyść zapamiętane linie oraz zresetuj mapę"/>
 		<text name="events_label">
diff --git a/indra/newview/skins/default/xui/pl/inspect_avatar.xml b/indra/newview/skins/default/xui/pl/inspect_avatar.xml
index 3ee0b976eb7..778e500bc02 100644
--- a/indra/newview/skins/default/xui/pl/inspect_avatar.xml
+++ b/indra/newview/skins/default/xui/pl/inspect_avatar.xml
@@ -10,8 +10,8 @@
 	<string name="Details">
 		[SL_PROFILE]
 	</string>
-	<slider name="volume_slider" tool_tip="Posiom Głośności" value="0.5"/>
-	<button label="Dodaj Znajomość" name="add_friend_btn"/>
+	<slider name="volume_slider" tool_tip="Poziom głośności" value="0.5"/>
+	<button label="Dodaj znajomość" name="add_friend_btn"/>
 	<button label="IM" name="im_btn"/>
 	<button label="Profil" name="view_profile_btn"/>
 	<panel name="moderator_panel">
diff --git a/indra/newview/skins/default/xui/pl/inspect_group.xml b/indra/newview/skins/default/xui/pl/inspect_group.xml
index 0a2a62ce74b..63c79acc8c1 100644
--- a/indra/newview/skins/default/xui/pl/inspect_group.xml
+++ b/indra/newview/skins/default/xui/pl/inspect_group.xml
@@ -18,5 +18,5 @@
 	</string>
 	<button label="Dołącz" name="join_btn"/>
 	<button label="Opuść" name="leave_btn"/>
-	<button label="Zobacz Profil" name="view_profile_btn"/>
+	<button label="Zobacz profil" name="view_profile_btn"/>
 </floater>
diff --git a/indra/newview/skins/default/xui/pl/inspect_object.xml b/indra/newview/skins/default/xui/pl/inspect_object.xml
index 4217731ef70..23d8ce77004 100644
--- a/indra/newview/skins/default/xui/pl/inspect_object.xml
+++ b/indra/newview/skins/default/xui/pl/inspect_object.xml
@@ -8,7 +8,7 @@
 		Przez [CREATOR]
 	</string>
 	<string name="CreatorAndOwner">
-		Kreator [CREATOR]
+		Twórca [CREATOR]
 Właściciel [OWNER]
 	</string>
 	<string name="Price">
diff --git a/indra/newview/skins/default/xui/pl/menu_attachment_other.xml b/indra/newview/skins/default/xui/pl/menu_attachment_other.xml
index 8a3269a9232..aacdad97e3e 100644
--- a/indra/newview/skins/default/xui/pl/menu_attachment_other.xml
+++ b/indra/newview/skins/default/xui/pl/menu_attachment_other.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <!-- *NOTE: See also menu_avatar_other.xml -->
 <context_menu name="Avatar Pie">
-	<menu_item_call label="Zobacz Profil" name="Profile..."/>
-	<menu_item_call label="Dodaj Znajomość" name="Add Friend"/>
+	<menu_item_call label="Zobacz profil" name="Profile..."/>
+	<menu_item_call label="Dodaj znajomość" name="Add Friend"/>
 	<menu_item_call label="IM" name="Send IM..."/>
 	<menu_item_call label="Zadzwoń" name="Call"/>
-	<menu_item_call label="ZaproÅ› do Grupy" name="Invite..."/>
+	<menu_item_call label="ZaproÅ› do grupy" name="Invite..."/>
 	<menu_item_call label="Zablokuj" name="Avatar Mute"/>
 	<menu_item_call label="Raport" name="abuse"/>
 	<menu_item_call label="Unieruchom" name="Freeze..."/>
diff --git a/indra/newview/skins/default/xui/pl/menu_attachment_self.xml b/indra/newview/skins/default/xui/pl/menu_attachment_self.xml
index 39fe83ad2ff..cdc01f286c1 100644
--- a/indra/newview/skins/default/xui/pl/menu_attachment_self.xml
+++ b/indra/newview/skins/default/xui/pl/menu_attachment_self.xml
@@ -7,9 +7,9 @@
 	<menu_item_call label="Zmień strój" name="Change Outfit"/>
 	<menu_item_call label="Edytuj mój strój" name="Edit Outfit"/>
 	<menu_item_call label="Edytuj mój kształt" name="Edit My Shape"/>
-	<menu_item_call label="Moi Znajomi" name="Friends..."/>
-	<menu_item_call label="Moje Grupy" name="Groups..."/>
-	<menu_item_call label="Mój Profil" name="Profile..."/>
+	<menu_item_call label="Moi znajomi" name="Friends..."/>
+	<menu_item_call label="Moje grupy" name="Groups..."/>
+	<menu_item_call label="Mój profil" name="Profile..."/>
 	<menu_item_call label="Debugowanie  tekstur" name="Debug..."/>
 	<menu_item_call label="Opuść" name="Drop"/>
 </context_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_avatar_icon.xml b/indra/newview/skins/default/xui/pl/menu_avatar_icon.xml
index c9ad275a267..e8d2b14231f 100644
--- a/indra/newview/skins/default/xui/pl/menu_avatar_icon.xml
+++ b/indra/newview/skins/default/xui/pl/menu_avatar_icon.xml
@@ -2,6 +2,6 @@
 <menu name="Avatar Icon Menu">
 	<menu_item_call label="Profil" name="Show Profile"/>
 	<menu_item_call label="Czat/IM..." name="Send IM"/>
-	<menu_item_call label="Dodaj Znajomość..." name="Add Friend"/>
+	<menu_item_call label="Dodaj znajomość..." name="Add Friend"/>
 	<menu_item_call label="Usuń..." name="Remove Friend"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_avatar_other.xml b/indra/newview/skins/default/xui/pl/menu_avatar_other.xml
index 9a1603e212a..dcf7921badc 100644
--- a/indra/newview/skins/default/xui/pl/menu_avatar_other.xml
+++ b/indra/newview/skins/default/xui/pl/menu_avatar_other.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <!-- *NOTE: See also menu_attachment_other.xml -->
 <context_menu name="Avatar Pie">
-	<menu_item_call label="Zobacz Profil" name="Profile..."/>
-	<menu_item_call label="Dodaj Znajomość" name="Add Friend"/>
+	<menu_item_call label="Zobacz profil" name="Profile..."/>
+	<menu_item_call label="Dodaj znajomość" name="Add Friend"/>
 	<menu_item_call label="IM" name="Send IM..."/>
 	<menu_item_call label="Zadzwoń" name="Call"/>
-	<menu_item_call label="ZaproÅ› do Grupy" name="Invite..."/>
+	<menu_item_call label="ZaproÅ› do grupy" name="Invite..."/>
 	<menu_item_call label="Zablokuj" name="Avatar Mute"/>
 	<menu_item_call label="Raport" name="abuse"/>
 	<menu_item_call label="Unieruchom" name="Freeze..."/>
diff --git a/indra/newview/skins/default/xui/pl/menu_avatar_self.xml b/indra/newview/skins/default/xui/pl/menu_avatar_self.xml
index aa415db6ead..1091eaa7fbc 100644
--- a/indra/newview/skins/default/xui/pl/menu_avatar_self.xml
+++ b/indra/newview/skins/default/xui/pl/menu_avatar_self.xml
@@ -3,7 +3,7 @@
 	<menu_item_call label="Wstań" name="Stand Up"/>
 	<context_menu label="Zdejmij  â–¶" name="Take Off &gt;">
 		<context_menu label="Ubrania  â–¶" name="Clothes &gt;">
-			<menu_item_call label="KoszulkÄ™" name="Shirt"/>
+			<menu_item_call label="KoszulÄ™" name="Shirt"/>
 			<menu_item_call label="Spodnie" name="Pants"/>
 			<menu_item_call label="Spódnicę" name="Skirt"/>
 			<menu_item_call label="Buty" name="Shoes"/>
@@ -13,18 +13,18 @@
 			<menu_item_call label="Podkoszulek" name="Self Undershirt"/>
 			<menu_item_call label="BieliznÄ™" name="Self Underpants"/>
 			<menu_item_call label="Tatuaż" name="Self Tattoo"/>
-			<menu_item_call label="Ubranie Przezroczyste" name="Self Alpha"/>
+			<menu_item_call label="Ubranie alpha" name="Self Alpha"/>
 			<menu_item_call label="Wszystko" name="All Clothes"/>
 		</context_menu>
 		<context_menu label="HUD  â–¶" name="Object Detach HUD"/>
 		<context_menu label="Odłącz ▶" name="Object Detach"/>
-		<menu_item_call label="Odłącz Wszystko" name="Detach All"/>
+		<menu_item_call label="Odłącz wszystko" name="Detach All"/>
 	</context_menu>
 	<menu_item_call label="Zmień strój" name="Chenge Outfit"/>
 	<menu_item_call label="Edytuj mój strój" name="Edit Outfit"/>
 	<menu_item_call label="Edytuj mój kształt" name="Edit My Shape"/>
-	<menu_item_call label="Moi Znajomi" name="Friends..."/>
-	<menu_item_call label="Moje Grupy" name="Groups..."/>
-	<menu_item_call label="Mój Profil" name="Profile..."/>
+	<menu_item_call label="Moi znajomi" name="Friends..."/>
+	<menu_item_call label="Moje grupy" name="Groups..."/>
+	<menu_item_call label="Mój profil" name="Profile..."/>
 	<menu_item_call label="Debugowanie tekstur" name="Debug..."/>
 </context_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_bottomtray.xml b/indra/newview/skins/default/xui/pl/menu_bottomtray.xml
index 7e1b37f2dd3..a4a6ea484df 100644
--- a/indra/newview/skins/default/xui/pl/menu_bottomtray.xml
+++ b/indra/newview/skins/default/xui/pl/menu_bottomtray.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="hide_camera_move_controls_menu">
-	<menu_item_check label="Przycisk Gestur" name="ShowGestureButton"/>
-	<menu_item_check label="Przycisk Ruchu" name="ShowMoveButton"/>
-	<menu_item_check label="Przycisk Widoku" name="ShowCameraButton"/>
-	<menu_item_check label="Przycisk Zdjęć" name="ShowSnapshotButton"/>
+	<menu_item_check label="Przycisk gesturki" name="ShowGestureButton"/>
+	<menu_item_check label="Przycisk ruchu" name="ShowMoveButton"/>
+	<menu_item_check label="Przycisk widoku" name="ShowCameraButton"/>
+	<menu_item_check label="Przycisk zdjęć" name="ShowSnapshotButton"/>
 	<menu_item_check label="Schowek" name="ShowSidebarButton"/>
 	<menu_item_check label="Buduj" name="ShowBuildButton"/>
 	<menu_item_check label="Szukaj" name="ShowSearchButton"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_cof_gear.xml b/indra/newview/skins/default/xui/pl/menu_cof_gear.xml
index e8aaa2cf827..9fba39be1ac 100644
--- a/indra/newview/skins/default/xui/pl/menu_cof_gear.xml
+++ b/indra/newview/skins/default/xui/pl/menu_cof_gear.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="Gear COF">
-	<menu label="Nowe Ubranie" name="COF.Gear.New_Clothes"/>
+	<menu label="Nowe ubranie" name="COF.Gear.New_Clothes"/>
 	<menu label="Nowe części ciała" name="COF.Geear.New_Body_Parts"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_favorites.xml b/indra/newview/skins/default/xui/pl/menu_favorites.xml
index cbacaf4beba..7310ff5c276 100644
--- a/indra/newview/skins/default/xui/pl/menu_favorites.xml
+++ b/indra/newview/skins/default/xui/pl/menu_favorites.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="Popup">
 	<menu_item_call label="Teleportuj" name="Teleport To Landmark"/>
-	<menu_item_call label="Zobacz/Edytuj Ulubione Miejsce" name="Landmark Open"/>
+	<menu_item_call label="Zobacz/Edytuj Ulubione miejsce" name="Landmark Open"/>
 	<menu_item_call label="Kopiuj SLurl" name="Copy slurl"/>
 	<menu_item_call label="Pokaż na mapie" name="Show On Map"/>
 	<menu_item_call label="Kopiuj" name="Landmark Copy"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_group_plus.xml b/indra/newview/skins/default/xui/pl/menu_group_plus.xml
index 9d3859081e7..83be4d38c51 100644
--- a/indra/newview/skins/default/xui/pl/menu_group_plus.xml
+++ b/indra/newview/skins/default/xui/pl/menu_group_plus.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="menu_group_plus">
-	<menu_item_call label="Dołącz do Grupy..." name="item_join"/>
-	<menu_item_call label="Nowa Grupa..." name="item_new"/>
+	<menu_item_call label="Dołącz do grupy..." name="item_join"/>
+	<menu_item_call label="Nowa grupa..." name="item_new"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_imchiclet_group.xml b/indra/newview/skins/default/xui/pl/menu_imchiclet_group.xml
index c53f72c043a..2b9a362123b 100644
--- a/indra/newview/skins/default/xui/pl/menu_imchiclet_group.xml
+++ b/indra/newview/skins/default/xui/pl/menu_imchiclet_group.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="IMChiclet Group Menu">
-	<menu_item_call label="O Grupie" name="Show Profile"/>
+	<menu_item_call label="O grupie" name="Show Profile"/>
 	<menu_item_call label="Pokaż sesję" name="Chat"/>
 	<menu_item_call label="Zakończ rozmowę" name="End Session"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_imchiclet_p2p.xml b/indra/newview/skins/default/xui/pl/menu_imchiclet_p2p.xml
index c0c812c0a77..8924d6db3e1 100644
--- a/indra/newview/skins/default/xui/pl/menu_imchiclet_p2p.xml
+++ b/indra/newview/skins/default/xui/pl/menu_imchiclet_p2p.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="IMChiclet P2P Menu">
-	<menu_item_call label="Zobacz Profil" name="Show Profile"/>
-	<menu_item_call label="Dodaj Znajomość" name="Add Friend"/>
+	<menu_item_call label="Zobacz profil" name="Show Profile"/>
+	<menu_item_call label="Dodaj znajomość" name="Add Friend"/>
 	<menu_item_call label="Pokaż sesję" name="Send IM"/>
 	<menu_item_call label="Zakończ rozmowę" name="End Session"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_inspect_avatar_gear.xml b/indra/newview/skins/default/xui/pl/menu_inspect_avatar_gear.xml
index 9a102e14163..5c27d53d906 100644
--- a/indra/newview/skins/default/xui/pl/menu_inspect_avatar_gear.xml
+++ b/indra/newview/skins/default/xui/pl/menu_inspect_avatar_gear.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu name="Gear Menu">
-	<menu_item_call label="Zobacz Profil" name="view_profile"/>
-	<menu_item_call label="Dodaj Znajomość" name="add_friend"/>
+	<menu_item_call label="Zobacz profil" name="view_profile"/>
+	<menu_item_call label="Dodaj znajomość" name="add_friend"/>
 	<menu_item_call label="IM" name="im"/>
 	<menu_item_call label="Zadzwoń" name="call"/>
 	<menu_item_call label="Teleportuj" name="teleport"/>
-	<menu_item_call label="ZaproÅ› do Grupy" name="invite_to_group"/>
+	<menu_item_call label="ZaproÅ› do grupy" name="invite_to_group"/>
 	<menu_item_call label="Zablokuj" name="block"/>
 	<menu_item_call label="Odblokuj" name="unblock"/>
 	<menu_item_call label="Raport" name="report"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_inspect_self_gear.xml b/indra/newview/skins/default/xui/pl/menu_inspect_self_gear.xml
index 2ea37026639..6d6377dbc31 100644
--- a/indra/newview/skins/default/xui/pl/menu_inspect_self_gear.xml
+++ b/indra/newview/skins/default/xui/pl/menu_inspect_self_gear.xml
@@ -2,8 +2,8 @@
 <menu name="Gear Menu">
 	<menu_item_call label="Wstań" name="stand_up"/>
 	<menu_item_call label="Zmień strój" name="change_outfit"/>
-	<menu_item_call label="Mój Profil" name="my_profile"/>
-	<menu_item_call label="Moi Znajomi" name="my_friends"/>
-	<menu_item_call label="Moje Grupy" name="my_groups"/>
+	<menu_item_call label="Mój profil" name="my_profile"/>
+	<menu_item_call label="Moi znajomi" name="my_friends"/>
+	<menu_item_call label="Moje grupy" name="my_groups"/>
 	<menu_item_call label="Debugowanie tekstur" name="Debug..."/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_inventory.xml b/indra/newview/skins/default/xui/pl/menu_inventory.xml
index f1f7d0d8552..e47ffa0e188 100644
--- a/indra/newview/skins/default/xui/pl/menu_inventory.xml
+++ b/indra/newview/skins/default/xui/pl/menu_inventory.xml
@@ -8,13 +8,13 @@
 	<menu_item_call label="Zmień nazwę" name="Task Rename"/>
 	<menu_item_call label="Usuń" name="Task Remove"/>
 	<menu_item_call label="Opróżnij Kosz" name="Empty Trash"/>
-	<menu_item_call label="Opróżnij Folder Zgubione i Odnalezione" name="Empty Lost And Found"/>
+	<menu_item_call label="Opróżnij Folder Zgubione i odnalezione" name="Empty Lost And Found"/>
 	<menu_item_call label="Nowy folder" name="New Folder"/>
 	<menu_item_call label="Nowy skrypt" name="New Script"/>
 	<menu_item_call label="Nowa nota" name="New Note"/>
-	<menu_item_call label="Nowy gest" name="New Gesture"/>
+	<menu_item_call label="Nowa gesturka" name="New Gesture"/>
 	<menu label="Nowe Ubranie" name="New Clothes">
-		<menu_item_call label="Nowa koszulka" name="New Shirt"/>
+		<menu_item_call label="Nowa koszula" name="New Shirt"/>
 		<menu_item_call label="Nowe spodnie" name="New Pants"/>
 		<menu_item_call label="Nowe buty" name="New Shoes"/>
 		<menu_item_call label="Nowe skarpety" name="New Socks"/>
@@ -23,7 +23,7 @@
 		<menu_item_call label="Nowe rękawiczki" name="New Gloves"/>
 		<menu_item_call label="Nowy podkoszulek" name="New Undershirt"/>
 		<menu_item_call label="Nowa bielizna" name="New Underpants"/>
-		<menu_item_call label="Nowa maska Alpha" name="New Alpha Mask"/>
+		<menu_item_call label="Nowa maska alpha" name="New Alpha Mask"/>
 		<menu_item_call label="Nowy tatuaż" name="New Tattoo"/>
 	</menu>
 	<menu label="Nowa Część Ciała" name="New Body Parts">
@@ -39,7 +39,7 @@
 		<menu_item_call label="Spodnie" name="Pants"/>
 		<menu_item_call label="Kształt" name="Shape"/>
 		<menu_item_call label="Buty" name="Shoes"/>
-		<menu_item_call label="Koszulka" name="Shirt"/>
+		<menu_item_call label="Koszula" name="Shirt"/>
 		<menu_item_call label="Spódnica" name="Skirt"/>
 		<menu_item_call label="Bielizna" name="Underpants"/>
 		<menu_item_call label="Podkoszulek" name="Undershirt"/>
@@ -61,7 +61,7 @@
 	<menu_item_call label="Wklej jako link" name="Paste As Link"/>
 	<menu_item_call label="Usuń" name="Remove Link"/>
 	<menu_item_call label="Usuń" name="Delete"/>
-	<menu_item_call label="Skasuj Folder Systemu" name="Delete System Folder"/>
+	<menu_item_call label="Skasuj folder systemu" name="Delete System Folder"/>
 	<menu_item_call label="Rozpocznij konferencjÄ™ czatowÄ…" name="Conference Chat Folder"/>
 	<menu_item_call label="Odtwarzaj" name="Sound Play"/>
 	<menu_item_call label="O Miejscu" name="About Landmark"/>
@@ -76,7 +76,7 @@
 	<menu_item_call label="Odłącz od siebie" name="Detach From Yourself"/>
 	<menu_item_call label="Załóż" name="Wearable And Object Wear"/>
 	<menu label="Dołącz do" name="Attach To"/>
-	<menu label="Dołącz do Załączników HUD" name="Attach To HUD"/>
+	<menu label="Dołącz do załączników HUD" name="Attach To HUD"/>
 	<menu_item_call label="Edytuj" name="Wearable Edit"/>
 	<menu_item_call label="Dodaj" name="Wearable Add"/>
 	<menu_item_call label="Zdejmij" name="Take Off"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_inventory_add.xml b/indra/newview/skins/default/xui/pl/menu_inventory_add.xml
index 8f520113c06..4a56586aafc 100644
--- a/indra/newview/skins/default/xui/pl/menu_inventory_add.xml
+++ b/indra/newview/skins/default/xui/pl/menu_inventory_add.xml
@@ -10,9 +10,9 @@
 	<menu_item_call label="Nowy folder" name="New Folder"/>
 	<menu_item_call label="Nowy skrypt" name="New Script"/>
 	<menu_item_call label="Nowa nota" name="New Note"/>
-	<menu_item_call label="Nowy gest" name="New Gesture"/>
+	<menu_item_call label="Nowa gesturka" name="New Gesture"/>
 	<menu label="Nowe Ubranie" name="New Clothes">
-		<menu_item_call label="Nowa koszulka" name="New Shirt"/>
+		<menu_item_call label="Nowa koszula" name="New Shirt"/>
 		<menu_item_call label="Nowe spodnie" name="New Pants"/>
 		<menu_item_call label="Nowe buty" name="New Shoes"/>
 		<menu_item_call label="Nowe skarpetki" name="New Socks"/>
@@ -21,7 +21,7 @@
 		<menu_item_call label="Nowe rękawiczki" name="New Gloves"/>
 		<menu_item_call label="Nowy podkoszulek" name="New Undershirt"/>
 		<menu_item_call label="Nowa bielizna" name="New Underpants"/>
-		<menu_item_call label="Nowe ubranie Przezroczyste" name="New Alpha"/>
+		<menu_item_call label="Nowa maska alpha" name="New Alpha"/>
 		<menu_item_call label="Nowy tatuaż" name="New Tattoo"/>
 	</menu>
 	<menu label="Nowa Część Ciała" name="New Body Parts">
diff --git a/indra/newview/skins/default/xui/pl/menu_inventory_gear_default.xml b/indra/newview/skins/default/xui/pl/menu_inventory_gear_default.xml
index 382a7506cca..d110a2f02e1 100644
--- a/indra/newview/skins/default/xui/pl/menu_inventory_gear_default.xml
+++ b/indra/newview/skins/default/xui/pl/menu_inventory_gear_default.xml
@@ -6,7 +6,7 @@
 	<menu_item_call label="Pokaż filtry" name="show_filters"/>
 	<menu_item_call label="Zresetuj filtry" name="reset_filters"/>
 	<menu_item_call label="Zamknij wszystkie foldery" name="close_folders"/>
-	<menu_item_call label="Opróżnij Zagubione i Odnalezione" name="empty_lostnfound"/>
+	<menu_item_call label="Opróżnij Zagubione i odnalezione" name="empty_lostnfound"/>
 	<menu_item_call label="Zapisz teksturÄ™ jako" name="Save Texture As"/>
 	<menu_item_call label="Udostępnij" name="Share"/>
 	<menu_item_call label="Znajdź oryginał" name="Find Original"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_land.xml b/indra/newview/skins/default/xui/pl/menu_land.xml
index 1e1ce73089c..cbfecaee568 100644
--- a/indra/newview/skins/default/xui/pl/menu_land.xml
+++ b/indra/newview/skins/default/xui/pl/menu_land.xml
@@ -2,7 +2,7 @@
 <context_menu name="Land Pie">
 	<menu_item_call label="O Posiadłości" name="Place Information..."/>
 	<menu_item_call label="Usiądź tutaj" name="Sit Here"/>
-	<menu_item_call label="Kup Posiadłość" name="Land Buy"/>
+	<menu_item_call label="Kup posiadłość" name="Land Buy"/>
 	<menu_item_call label="Kup przepustkÄ™" name="Land Buy Pass"/>
 	<menu_item_call label="Buduj" name="Create"/>
 	<menu_item_call label="Edytuj teren" name="Edit Terrain"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_login.xml b/indra/newview/skins/default/xui/pl/menu_login.xml
index 810862dfd96..0dd6117b854 100644
--- a/indra/newview/skins/default/xui/pl/menu_login.xml
+++ b/indra/newview/skins/default/xui/pl/menu_login.xml
@@ -8,7 +8,7 @@
 		<menu_item_call label="[SECOND_LIFE]: Pomoc" name="Second Life Help"/>
 		<menu_item_call label="O [APP_NAME]" name="About Second Life"/>
 	</menu>
-	<menu_item_check label="Pokaż Ustawienia Debugowania" name="Show Debug Menu"/>
+	<menu_item_check label="Pokaż ustawienia debugowania" name="Show Debug Menu"/>
 	<menu label="Debug" name="Debug">
 		<menu_item_call label="Ustawienia debugowania" name="Debug Settings"/>
 		<menu_item_call label="Ustawienia UI/kolor" name="UI/Color Settings"/>
@@ -17,7 +17,7 @@
 		<menu_item_call label="Wyświetl TOS" name="TOS"/>
 		<menu_item_call label="Wyświetl wiadomość krytyczną" name="Critical"/>
 		<menu_item_call label="Test przeglÄ…darki internetowej" name="Web Browser Test"/>
-		<menu_item_check label="Pokaż Siatkę" name="Show Grid Picker"/>
+		<menu_item_check label="Pokaż siatkę" name="Show Grid Picker"/>
 		<menu_item_call label="Pokaż konsolę Zawiadomień" name="Show Notifications Console"/>
 	</menu>
 </menu_bar>
diff --git a/indra/newview/skins/default/xui/pl/menu_navbar.xml b/indra/newview/skins/default/xui/pl/menu_navbar.xml
index f38b805ee22..1d434670eee 100644
--- a/indra/newview/skins/default/xui/pl/menu_navbar.xml
+++ b/indra/newview/skins/default/xui/pl/menu_navbar.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="Navbar Menu">
 	<menu_item_check label="Pokaż współrzędne" name="Show Coordinates"/>
-	<menu_item_check label="Pokaż właściwości Posiadłości" name="Show Parcel Properties"/>
-	<menu_item_call label="Ulubione Miejsce" name="Landmark"/>
+	<menu_item_check label="Pokaż właściwości posiadłości" name="Show Parcel Properties"/>
+	<menu_item_call label="Landmark" name="Landmark"/>
 	<menu_item_call label="Wytnij" name="Cut"/>
 	<menu_item_call label="Kopiuj" name="Copy"/>
 	<menu_item_call label="Wklej" name="Paste"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_outfit_gear.xml b/indra/newview/skins/default/xui/pl/menu_outfit_gear.xml
index ed754e36a7d..1a70e76ec7c 100644
--- a/indra/newview/skins/default/xui/pl/menu_outfit_gear.xml
+++ b/indra/newview/skins/default/xui/pl/menu_outfit_gear.xml
@@ -10,10 +10,10 @@
 		<menu_item_call label="Nowe skarpetki" name="New Socks"/>
 		<menu_item_call label="Nowa kurtka" name="New Jacket"/>
 		<menu_item_call label="Nowa spódnica" name="New Skirt"/>
-		<menu_item_call label="Nowe  rękawiczki" name="New Gloves"/>
+		<menu_item_call label="Nowe rękawiczki" name="New Gloves"/>
 		<menu_item_call label="Nowa podkoszulka" name="New Undershirt"/>
 		<menu_item_call label="Nowa bielizna" name="New Underpants"/>
-		<menu_item_call label="Nowe alpha" name="New Alpha"/>
+		<menu_item_call label="Nowa maska alpha" name="New Alpha"/>
 		<menu_item_call label="Nowy tatuaż" name="New Tattoo"/>
 	</menu>
 	<menu label="Nowe części ciała" name="New Body Parts">
diff --git a/indra/newview/skins/default/xui/pl/menu_participant_list.xml b/indra/newview/skins/default/xui/pl/menu_participant_list.xml
index 59b4fec6b0d..fd6d4dcc3c4 100644
--- a/indra/newview/skins/default/xui/pl/menu_participant_list.xml
+++ b/indra/newview/skins/default/xui/pl/menu_participant_list.xml
@@ -2,8 +2,8 @@
 <context_menu name="Participant List Context Menu">
 	<menu_item_check label="Sortuj według imienia" name="SortByName"/>
 	<menu_item_check label="Sortuj według ostatniego mówcy" name="SortByRecentSpeakers"/>
-	<menu_item_call label="Zobacz Profil" name="View Profile"/>
-	<menu_item_call label="Dodaj Znajomość" name="Add Friend"/>
+	<menu_item_call label="Zobacz profil" name="View Profile"/>
+	<menu_item_call label="Dodaj znajomość" name="Add Friend"/>
 	<menu_item_call label="IM" name="IM"/>
 	<menu_item_call label="Zadzwoń" name="Call"/>
 	<menu_item_call label="Udostępnij" name="Share"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_people_groups.xml b/indra/newview/skins/default/xui/pl/menu_people_groups.xml
index 567482dcda3..ace5ebf8884 100644
--- a/indra/newview/skins/default/xui/pl/menu_people_groups.xml
+++ b/indra/newview/skins/default/xui/pl/menu_people_groups.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="menu_group_plus">
-	<menu_item_call label="Zobacz Info" name="View Info"/>
+	<menu_item_call label="Zobacz info" name="View Info"/>
 	<menu_item_call label="Czat" name="Chat"/>
 	<menu_item_call label="Rozmowa" name="Call"/>
 	<menu_item_call label="Aktywuj" name="Activate"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_people_groups_view_sort.xml b/indra/newview/skins/default/xui/pl/menu_people_groups_view_sort.xml
index 4be60d9b833..c70ea2315f4 100644
--- a/indra/newview/skins/default/xui/pl/menu_people_groups_view_sort.xml
+++ b/indra/newview/skins/default/xui/pl/menu_people_groups_view_sort.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="menu_group_plus">
-	<menu_item_check label="Wyświetlaj ikonki Grupy" name="Display Group Icons"/>
-	<menu_item_call label="Opuść zaznaczone Grupy" name="Leave Selected Group"/>
+	<menu_item_check label="Wyświetlaj ikonki grupy" name="Display Group Icons"/>
+	<menu_item_call label="Opuść zaznaczone grupy" name="Leave Selected Group"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_people_nearby.xml b/indra/newview/skins/default/xui/pl/menu_people_nearby.xml
index afe3a5200b8..a8cc6b4a604 100644
--- a/indra/newview/skins/default/xui/pl/menu_people_nearby.xml
+++ b/indra/newview/skins/default/xui/pl/menu_people_nearby.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Avatar Context Menu">
-	<menu_item_call label="Zobacz Profil" name="View Profile"/>
-	<menu_item_call label="Dodaj Znajomość" name="Add Friend"/>
-	<menu_item_call label="Usuń z listy Znajomych" name="Remove Friend"/>
+	<menu_item_call label="Zobacz profil" name="View Profile"/>
+	<menu_item_call label="Dodaj znajomość" name="Add Friend"/>
+	<menu_item_call label="Usuń z listy znajomych" name="Remove Friend"/>
 	<menu_item_call label="IM" name="IM"/>
 	<menu_item_call label="Zadzwoń" name="Call"/>
 	<menu_item_call label="Mapa" name="Map"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_people_nearby_multiselect.xml b/indra/newview/skins/default/xui/pl/menu_people_nearby_multiselect.xml
index bc89402a963..c924185c6fa 100644
--- a/indra/newview/skins/default/xui/pl/menu_people_nearby_multiselect.xml
+++ b/indra/newview/skins/default/xui/pl/menu_people_nearby_multiselect.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Multi-Selected People Context Menu">
-	<menu_item_call label="Dodaj Znajomych" name="Add Friends"/>
-	<menu_item_call label="Usuń Znajomych" name="Remove Friend"/>
+	<menu_item_call label="Dodaj znajomych" name="Add Friends"/>
+	<menu_item_call label="Usuń znajomych" name="Remove Friend"/>
 	<menu_item_call label="IM" name="IM"/>
 	<menu_item_call label="Zadzwoń" name="Call"/>
 	<menu_item_call label="Udostępnij" name="Share"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_picks_plus.xml b/indra/newview/skins/default/xui/pl/menu_picks_plus.xml
index 8f196612a8b..e9c00f51a97 100644
--- a/indra/newview/skins/default/xui/pl/menu_picks_plus.xml
+++ b/indra/newview/skins/default/xui/pl/menu_picks_plus.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <toggleable_menu name="picks_plus_menu">
 	<menu_item_call label="Stwórz" name="create_pick"/>
-	<menu_item_call label="Nowa Reklama" name="create_classified"/>
+	<menu_item_call label="Nowa reklama" name="create_classified"/>
 </toggleable_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_place.xml b/indra/newview/skins/default/xui/pl/menu_place.xml
index 312bfc6bb01..c3b72d6abbd 100644
--- a/indra/newview/skins/default/xui/pl/menu_place.xml
+++ b/indra/newview/skins/default/xui/pl/menu_place.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <toggleable_menu name="place_overflow_menu">
-	<menu_item_call label="Zapisz Landmark" name="landmark"/>
+	<menu_item_call label="Zapisz landmark" name="landmark"/>
 	<menu_item_call label="Utwórz" name="pick"/>
-	<menu_item_call label="Kup PrzepustkÄ™" name="pass"/>
+	<menu_item_call label="Kup przepustkÄ™" name="pass"/>
 	<menu_item_call label="Edytuj" name="edit"/>
 </toggleable_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_place_add_button.xml b/indra/newview/skins/default/xui/pl/menu_place_add_button.xml
index 6175671fb9f..3d0c1c87fb1 100644
--- a/indra/newview/skins/default/xui/pl/menu_place_add_button.xml
+++ b/indra/newview/skins/default/xui/pl/menu_place_add_button.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="menu_folder_gear">
 	<menu_item_call label="Dodaj folder" name="add_folder"/>
-	<menu_item_call label="Dodaj do Landmarków" name="add_landmark"/>
+	<menu_item_call label="Dodaj do landmarków" name="add_landmark"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_places_gear_folder.xml b/indra/newview/skins/default/xui/pl/menu_places_gear_folder.xml
index d17b6c1033a..65417cef221 100644
--- a/indra/newview/skins/default/xui/pl/menu_places_gear_folder.xml
+++ b/indra/newview/skins/default/xui/pl/menu_places_gear_folder.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="menu_folder_gear">
-	<menu_item_call label="Dodaj do Landmarków" name="add_landmark"/>
+	<menu_item_call label="Dodaj do landmarków" name="add_landmark"/>
 	<menu_item_call label="Dodaj folder" name="add_folder"/>
 	<menu_item_call label="Wytnij" name="cut"/>
 	<menu_item_call label="Kopiuj" name="copy_folder"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_places_gear_landmark.xml b/indra/newview/skins/default/xui/pl/menu_places_gear_landmark.xml
index 0720aea8aac..36787dd0aa8 100644
--- a/indra/newview/skins/default/xui/pl/menu_places_gear_landmark.xml
+++ b/indra/newview/skins/default/xui/pl/menu_places_gear_landmark.xml
@@ -3,10 +3,10 @@
 	<menu_item_call label="Teleportuj" name="teleport"/>
 	<menu_item_call label="Więcej informacji" name="more_info"/>
 	<menu_item_call label="Pokaż na mapie" name="show_on_map"/>
-	<menu_item_call label="Dodaj do Landmarków" name="add_landmark"/>
+	<menu_item_call label="Dodaj do landmarków" name="add_landmark"/>
 	<menu_item_call label="Dodaj folder" name="add_folder"/>
 	<menu_item_call label="Wytnij" name="cut"/>
-	<menu_item_call label="Kopiuj Landmark" name="copy_landmark"/>
+	<menu_item_call label="Kopiuj landmark" name="copy_landmark"/>
 	<menu_item_call label="Kopiuj SLurl" name="copy_slurl"/>
 	<menu_item_call label="Wklej" name="paste"/>
 	<menu_item_call label="Zmień nazwę" name="rename"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_slurl.xml b/indra/newview/skins/default/xui/pl/menu_slurl.xml
index 719959df6a0..862f538aa77 100644
--- a/indra/newview/skins/default/xui/pl/menu_slurl.xml
+++ b/indra/newview/skins/default/xui/pl/menu_slurl.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="Popup">
-	<menu_item_call label="O Miejscu" name="about_url"/>
-	<menu_item_call label="Teleportuj do Miejsca" name="teleport_to_url"/>
+	<menu_item_call label="O miejscu" name="about_url"/>
+	<menu_item_call label="Teleportuj do miejsca" name="teleport_to_url"/>
 	<menu_item_call label="Mapa" name="show_on_map"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_teleport_history_gear.xml b/indra/newview/skins/default/xui/pl/menu_teleport_history_gear.xml
index 2161963a615..0e58592d46a 100644
--- a/indra/newview/skins/default/xui/pl/menu_teleport_history_gear.xml
+++ b/indra/newview/skins/default/xui/pl/menu_teleport_history_gear.xml
@@ -2,5 +2,5 @@
 <menu name="Teleport History Gear Context Menu">
 	<menu_item_call label="Rozwiń wszystkie foldery" name="Expand all folders"/>
 	<menu_item_call label="Schowaj wszystkie foldery" name="Collapse all folders"/>
-	<menu_item_call label="Wyczyść Historię Teleportacji" name="Clear Teleport History"/>
+	<menu_item_call label="Wyczyść historię teleportacji" name="Clear Teleport History"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_text_editor.xml b/indra/newview/skins/default/xui/pl/menu_text_editor.xml
index 4529246b561..812f87bc1a3 100644
--- a/indra/newview/skins/default/xui/pl/menu_text_editor.xml
+++ b/indra/newview/skins/default/xui/pl/menu_text_editor.xml
@@ -4,5 +4,5 @@
 	<menu_item_call label="Kopiuj" name="Copy"/>
 	<menu_item_call label="Wklej" name="Paste"/>
 	<menu_item_call label="Usuń" name="Delete"/>
-	<menu_item_call label="Zaznacz Wszystko" name="Select All"/>
+	<menu_item_call label="Zaznacz wszystko" name="Select All"/>
 </context_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_url_agent.xml b/indra/newview/skins/default/xui/pl/menu_url_agent.xml
index 7c90e6582dd..db729be725f 100644
--- a/indra/newview/skins/default/xui/pl/menu_url_agent.xml
+++ b/indra/newview/skins/default/xui/pl/menu_url_agent.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Url Popup">
-	<menu_item_call label="Pokaż Profil Rezydenta" name="show_agent"/>
+	<menu_item_call label="Pokaż profil Rezydenta" name="show_agent"/>
 	<menu_item_call label="Kopiuj nazwÄ™ do schowka" name="url_copy_label"/>
 	<menu_item_call label="Kopiuj SLurl do schowka" name="url_copy"/>
 </context_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_url_group.xml b/indra/newview/skins/default/xui/pl/menu_url_group.xml
index 109f96e5625..f340b3296aa 100644
--- a/indra/newview/skins/default/xui/pl/menu_url_group.xml
+++ b/indra/newview/skins/default/xui/pl/menu_url_group.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Url Popup">
-	<menu_item_call label="Pokaż szczegóły o Grupie" name="show_group"/>
-	<menu_item_call label="Kopiuj GrupÄ™ do schowka" name="url_copy_label"/>
+	<menu_item_call label="Pokaż szczegóły o grupie" name="show_group"/>
+	<menu_item_call label="Kopiuj grupÄ™ do schowka" name="url_copy_label"/>
 	<menu_item_call label="Kopiuj SLurl do schowka" name="url_copy"/>
 </context_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_url_inventory.xml b/indra/newview/skins/default/xui/pl/menu_url_inventory.xml
index ce3309cba02..e36fa0dd2ba 100644
--- a/indra/newview/skins/default/xui/pl/menu_url_inventory.xml
+++ b/indra/newview/skins/default/xui/pl/menu_url_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Url Popup">
-	<menu_item_call label="Pokaż obiekt w Szafie" name="show_item"/>
+	<menu_item_call label="Pokaż obiekt w szafie" name="show_item"/>
 	<menu_item_call label="Kopiuj nazwÄ™ do schowka" name="url_copy_label"/>
 	<menu_item_call label="Kopiuj SLurl do schowka" name="url_copy"/>
 </context_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_url_parcel.xml b/indra/newview/skins/default/xui/pl/menu_url_parcel.xml
index 43b945b8beb..1b8dd621372 100644
--- a/indra/newview/skins/default/xui/pl/menu_url_parcel.xml
+++ b/indra/newview/skins/default/xui/pl/menu_url_parcel.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Url Popup">
-	<menu_item_call label="Pokaż szczegóły o Miejscu" name="show_parcel"/>
+	<menu_item_call label="Pokaż szczegóły o miejscu" name="show_parcel"/>
 	<menu_item_call label="Pokaż na mapie" name="show_on_map"/>
 	<menu_item_call label="Kopiuj SLurl do schowka" name="url_copy"/>
 </context_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_url_slurl.xml b/indra/newview/skins/default/xui/pl/menu_url_slurl.xml
index 456146d8e56..4d4a5b4c4d9 100644
--- a/indra/newview/skins/default/xui/pl/menu_url_slurl.xml
+++ b/indra/newview/skins/default/xui/pl/menu_url_slurl.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Url Popup">
-	<menu_item_call label="Pokaż szczegóły o Miejscu" name="show_place"/>
+	<menu_item_call label="Pokaż szczegóły o miejscu" name="show_place"/>
 	<menu_item_call label="Pokaż na mapie" name="show_on_map"/>
 	<menu_item_call label="Teleportuj do miejsca" name="teleport_to_location"/>
 	<menu_item_call label="Kopiuj SLurl do schowka" name="url_copy"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_url_teleport.xml b/indra/newview/skins/default/xui/pl/menu_url_teleport.xml
index 7376fb3afc4..e2255469300 100644
--- a/indra/newview/skins/default/xui/pl/menu_url_teleport.xml
+++ b/indra/newview/skins/default/xui/pl/menu_url_teleport.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <context_menu name="Url Popup">
 	<menu_item_call label="Teleportuj do tego miejsca" name="teleport"/>
-	<menu_item_call label="Pokaż na Mapie" name="show_on_map"/>
+	<menu_item_call label="Pokaż na mapie" name="show_on_map"/>
 	<menu_item_call label="Kopiuj SLurl do schowka" name="url_copy"/>
 </context_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_viewer.xml b/indra/newview/skins/default/xui/pl/menu_viewer.xml
index 97a94584c45..a71961ada79 100644
--- a/indra/newview/skins/default/xui/pl/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/pl/menu_viewer.xml
@@ -2,49 +2,49 @@
 <menu_bar name="Main Menu">
 	<menu label="Ja" name="Me">
 		<menu_item_call label="Ustawienia" name="Preferences"/>
-		<menu_item_call label="Moja Tablica" name="Manage My Account"/>
+		<menu_item_call label="Dashboard" name="Manage My Account"/>
 		<menu_item_call label="Kup L$" name="Buy and Sell L$"/>
 		<menu_item_call label="Mój Profil" name="Profile"/>
 		<menu_item_call label="Zmień strój" name="ChangeOutfit"/>
 		<menu_item_check label="Moja Szafa" name="Inventory"/>
 		<menu_item_check label="Moja Szafa" name="ShowSidetrayInventory"/>
-		<menu_item_check label="Moje Gesty" name="Gestures"/>
+		<menu_item_check label="Moje gesturki" name="Gestures"/>
 		<menu_item_check label="Mój głos" name="ShowVoice"/>
 		<menu label="Mój Status" name="Status">
-			<menu_item_call label="Tryb Oddalenia" name="Set Away"/>
-			<menu_item_call label="Tryb Pracy" name="Set Busy"/>
+			<menu_item_call label="Tryb oddalenia" name="Set Away"/>
+			<menu_item_call label="Tryb pracy" name="Set Busy"/>
 		</menu>
-		<menu_item_call label="Zażądaj Statusu Administratora" name="Request Admin Options"/>
-		<menu_item_call label="Wyłącz Status Administratora" name="Leave Admin Options"/>
+		<menu_item_call label="Zażądaj statusu administratora" name="Request Admin Options"/>
+		<menu_item_call label="Wyłącz atatus administratora" name="Leave Admin Options"/>
 		<menu_item_call label="Wyłącz [APP_NAME]" name="Quit"/>
 	</menu>
 	<menu label="Komunikacja" name="Communicate">
 		<menu_item_call label="Znajomi" name="My Friends"/>
 		<menu_item_call label="Grupy" name="My Groups"/>
-		<menu_item_check label="Czat Lokalny" name="Nearby Chat"/>
-		<menu_item_call label="Osoby w Pobliżu" name="Active Speakers"/>
+		<menu_item_check label="Czat lokalny" name="Nearby Chat"/>
+		<menu_item_call label="Osoby w pobliżu" name="Active Speakers"/>
 	</menu>
 	<menu label="Åšwiat" name="World">
 		<menu_item_check label="Mini-Mapa" name="Mini-Map"/>
 		<menu_item_check label="Mapa Åšwiata" name="World Map"/>
-		<menu_item_call label="Zrób Zdjęcie" name="Take Snapshot"/>
-		<menu_item_call label="Zapamiętaj to Miejsce" name="Create Landmark Here"/>
+		<menu_item_call label="Zrób zdjęcie" name="Take Snapshot"/>
+		<menu_item_call label="Zapamiętaj to miejsce (LM)" name="Create Landmark Here"/>
 		<menu label="Miejsce" name="Land">
 			<menu_item_call label="Profil miejsca" name="Place Profile"/>
-			<menu_item_call label="O Posiadłości" name="About Land"/>
+			<menu_item_call label="O posiadłości" name="About Land"/>
 			<menu_item_call label="Region/MajÄ…tek" name="Region/Estate"/>
 		</menu>
-		<menu_item_call label="Kup Posiadłość" name="Buy Land"/>
-		<menu_item_call label="Moje Posiadłości" name="My Land"/>
+		<menu_item_call label="Kup posiadłość" name="Buy Land"/>
+		<menu_item_call label="Moje posiadłości" name="My Land"/>
 		<menu label="Pokaż" name="LandShow">
-			<menu_item_check label="Ustawienia Ruchu" name="Movement Controls"/>
-			<menu_item_check label="Zobacz Ustawienia" name="Camera Controls"/>
-			<menu_item_check label="Linie Bana" name="Ban Lines"/>
+			<menu_item_check label="Ustawienia ruchu" name="Movement Controls"/>
+			<menu_item_check label="Zobacz ustawienia" name="Camera Controls"/>
+			<menu_item_check label="Linie bana" name="Ban Lines"/>
 			<menu_item_check label="Emitery" name="beacons"/>
-			<menu_item_check label="Granice Posiadłości" name="Property Lines"/>
-			<menu_item_check label="Właściciele Posiadłości" name="Land Owners"/>
+			<menu_item_check label="Granice posiadłości" name="Property Lines"/>
+			<menu_item_check label="Właściciele posiadłości" name="Land Owners"/>
 			<menu_item_check label="Współrzędne" name="Coordinates"/>
-			<menu_item_check label="Właściwości Posiadłości" name="Parcel Properties"/>
+			<menu_item_check label="Właściwości posiadłości" name="Parcel Properties"/>
 		</menu>
 		<menu_item_call label="Teleportuj do Miejsca Startu" name="Teleport Home"/>
 		<menu_item_call label="Ustaw Miejsce Startu" name="Set Home to Here"/>
@@ -53,57 +53,57 @@
 			<menu_item_call label="Południe" name="Noon"/>
 			<menu_item_call label="Zachód Słońca" name="Sunset"/>
 			<menu_item_call label="Północ" name="Midnight"/>
-			<menu_item_call label="Używaj Czasu Regionu" name="Revert to Region Default"/>
-			<menu_item_call label="Edytor Åšrodowiska" name="Environment Editor"/>
+			<menu_item_call label="Używaj czasu Regionu" name="Revert to Region Default"/>
+			<menu_item_call label="Edytor środowiska" name="Environment Editor"/>
 		</menu>
 	</menu>
 	<menu label="Buduj" name="BuildTools">
 		<menu_item_check label="Buduj" name="Show Build Tools"/>
-		<menu label="Wybierz Narzędzie Budowania" name="Select Tool">
-			<menu_item_call label="Narzędzie Ogniskowej" name="Focus"/>
-			<menu_item_call label="Narzędzie Ruchu" name="Move"/>
-			<menu_item_call label="Narzędzie Edycji" name="Edit"/>
-			<menu_item_call label="Stwórz Narzędzie" name="Create"/>
-			<menu_item_call label="Narzędzie Posiadłości" name="Land"/>
+		<menu label="Wybierz narzędzie budowania" name="Select Tool">
+			<menu_item_call label="Narzędzie ogniskowej" name="Focus"/>
+			<menu_item_call label="Narzędzie ruchu" name="Move"/>
+			<menu_item_call label="Narzędzie edycji" name="Edit"/>
+			<menu_item_call label="Stwórz narzędzie" name="Create"/>
+			<menu_item_call label="Narzędzie posiadłości" name="Land"/>
 		</menu>
 		<menu_item_call label="Linkuj" name="Link"/>
 		<menu_item_call label="Rozlinkuj" name="Unlink"/>
-		<menu_item_check label="Edytuj Zgrupowane Obiekty" name="Edit Linked Parts"/>
-		<menu label="Wybierz Zlinkowane Części" name="Select Linked Parts">
-			<menu_item_call label="Wybierz Następną Część" name="Select Next Part"/>
-			<menu_item_call label="Zaznacz Poprzednią Część" name="Select Previous Part"/>
-			<menu_item_call label="Uwzględnij Następną Część" name="Include Next Part"/>
-			<menu_item_call label="Uwzględnij Poprzednią Część" name="Include Previous Part"/>
+		<menu_item_check label="Edytuj zlinkowane obiekty" name="Edit Linked Parts"/>
+		<menu label="Wybierz zlinkowane części" name="Select Linked Parts">
+			<menu_item_call label="Wybierz następną część" name="Select Next Part"/>
+			<menu_item_call label="Zaznacz poprzednią część" name="Select Previous Part"/>
+			<menu_item_call label="Uwzględnij następną część" name="Include Next Part"/>
+			<menu_item_call label="Uwzględnij poprzednią część" name="Include Previous Part"/>
 		</menu>
-		<menu_item_call label="Ogniskowa Selekcji" name="Focus on Selection"/>
-		<menu_item_call label="Przybliż do Selekcji" name="Zoom to Selection"/>
+		<menu_item_call label="Ogniskowa selekcji" name="Focus on Selection"/>
+		<menu_item_call label="Przybliż do selekcji" name="Zoom to Selection"/>
 		<menu label="Obiekt" name="Object">
 			<menu_item_call label="Kup" name="Menu Object Buy"/>
 			<menu_item_call label="Weź" name="Menu Object Take"/>
-			<menu_item_call label="Weź Kopię" name="Take Copy"/>
-			<menu_item_call label="Zapisz Obiekt do Szafy" name="Save Object Back to My Inventory"/>
-			<menu_item_call label="Zapisz do Treści Obiektu" name="Save Object Back to Object Contents"/>
+			<menu_item_call label="Weź kopię" name="Take Copy"/>
+			<menu_item_call label="Zapisz obiekt do Szafy" name="Save Object Back to My Inventory"/>
+			<menu_item_call label="Zapisz do treści obiektu" name="Save Object Back to Object Contents"/>
 		</menu>
 		<menu label="Skrypty" name="Scripts">
-			<menu_item_call label="Zrekompiluj Skrypt w Selekcji (Mono)" name="Mono"/>
-			<menu_item_call label="Zrekompiluj Skrypty" name="LSL"/>
-			<menu_item_call label="Reset Skryptów" name="Reset Scripts"/>
-			<menu_item_call label="Ustaw Uruchamienie Skryptów" name="Set Scripts to Running"/>
-			<menu_item_call label="Wstrzymaj Działanie Skryptów w Selekcji" name="Set Scripts to Not Running"/>
+			<menu_item_call label="Zrekompiluj skrypt w selekcji (Mono)" name="Mono"/>
+			<menu_item_call label="Zrekompiluj skrypty" name="LSL"/>
+			<menu_item_call label="Reset skryptów" name="Reset Scripts"/>
+			<menu_item_call label="Ustaw uruchamienie skryptów" name="Set Scripts to Running"/>
+			<menu_item_call label="Wstrzymaj działanie skryptów w selekcji" name="Set Scripts to Not Running"/>
 		</menu>
 		<menu label="Opcje" name="Options">
 			<menu_item_call label="Ustaw domyślne pozwolenia ładowania" name="perm prefs"/>
-			<menu_item_check label="Pokaż Zaawansowane Pozwolenia" name="DebugPermissions"/>
-			<menu_item_check label="Wybierz Tylko Moje Obiekty" name="Select Only My Objects"/>
-			<menu_item_check label="Wybierz Tylko Obiekty Przesuwalne" name="Select Only Movable Objects"/>
-			<menu_item_check label="Wybierz przez Otoczenie" name="Select By Surrounding"/>
-			<menu_item_check label="Zobacz UkrytÄ… SelekcjÄ™" name="Show Hidden Selection"/>
-			<menu_item_check label="Pokaż Promień Emitera dla Selekcji" name="Show Light Radius for Selection"/>
-			<menu_item_check label="Pokaż Emiter Selekcji" name="Show Selection Beam"/>
-			<menu_item_check label="Uruchom SiatkÄ™" name="Snap to Grid"/>
-			<menu_item_call label="PrzeciÄ…gnij Obiekt do Siatki" name="Snap Object XY to Grid"/>
-			<menu_item_call label="Wybierz Zaznaczenie Siatki" name="Use Selection for Grid"/>
-			<menu_item_call label="Opcje Siatki" name="Grid Options"/>
+			<menu_item_check label="Pokaż zaawansowane pozwolenia" name="DebugPermissions"/>
+			<menu_item_check label="Wybierz tylko moje obiekty" name="Select Only My Objects"/>
+			<menu_item_check label="Wybierz tylko obiekty przesuwalne" name="Select Only Movable Objects"/>
+			<menu_item_check label="Wybierz przez otoczenie" name="Select By Surrounding"/>
+			<menu_item_check label="Zobacz ukrytÄ… selekcjÄ™" name="Show Hidden Selection"/>
+			<menu_item_check label="Pokaż promień emitera dla selekcji" name="Show Light Radius for Selection"/>
+			<menu_item_check label="Pokaż emiter selekcji" name="Show Selection Beam"/>
+			<menu_item_check label="Uruchom siatkÄ™" name="Snap to Grid"/>
+			<menu_item_call label="PrzeciÄ…gnij obiekt do siatki" name="Snap Object XY to Grid"/>
+			<menu_item_call label="Wybierz zaznaczenie siatki" name="Use Selection for Grid"/>
+			<menu_item_call label="Opcje siatki" name="Grid Options"/>
 		</menu>
 		<menu label="Załaduj" name="Upload">
 			<menu_item_call label="teksturÄ™ (L$[COST])..." name="Upload Image"/>
@@ -115,39 +115,39 @@
 	<menu label="Pomoc" name="Help">
 		<menu_item_call label="[SECOND_LIFE] Portal Pomocy" name="Second Life Help"/>
 		<menu_item_call label="Złóż Raport o Nadużyciu" name="Report Abuse"/>
-		<menu_item_call label="Zgłoś Błędy Klienta" name="Report Bug"/>
+		<menu_item_call label="Zgłoś błędy klienta" name="Report Bug"/>
 		<menu_item_call label="O [APP_NAME]" name="About Second Life"/>
 	</menu>
 	<menu label="Zaawansowane" name="Advanced">
 		<menu_item_check label="Pokaż menu Zaawansowane" name="Show Advanced Menu"/>
-		<menu_item_call label="Zatrzymaj Wszystkie Animacje" name="Stop Animating My Avatar"/>
-		<menu_item_call label="Odswież Wyświetlanie Tekstur" name="Rebake Texture"/>
-		<menu_item_call label="Domyślne Ustawienia Rozmiaru Interfejsu" name="Set UI Size to Default"/>
-		<menu_item_call label="Ustaw Rozmiar Interfejsu..." name="Set Window Size..."/>
-		<menu_item_check label="Ogranicz Dystans Selekcji" name="Limit Select Distance"/>
-		<menu_item_check label="Wyłącz Ograniczenia Zasięgu Kamery" name="Disable Camera Distance"/>
-		<menu_item_check label="Wysoka Rozdzielczość Zdjęć" name="HighResSnapshot"/>
-		<menu_item_check label="Zapisuj Zdjęcia na Dysk Twardy bez Efektu Dźwiękowego" name="QuietSnapshotsToDisk"/>
-		<menu_item_check label="Skompresuj Zdjęcie na Dysk Twardy" name="CompressSnapshotsToDisk"/>
+		<menu_item_call label="Zatrzymaj wszystkie animacje" name="Stop Animating My Avatar"/>
+		<menu_item_call label="Odswież wyświetlanie tekstur" name="Rebake Texture"/>
+		<menu_item_call label="Domyślne ustawienia rozmiaru interfejsu" name="Set UI Size to Default"/>
+		<menu_item_call label="Ustaw rozmiar interfejsu..." name="Set Window Size..."/>
+		<menu_item_check label="Ogranicz dystans selekcji" name="Limit Select Distance"/>
+		<menu_item_check label="Wyłącz ograniczenia zasięgu kamery" name="Disable Camera Distance"/>
+		<menu_item_check label="Wysoka rozdzielczość zdjęć" name="HighResSnapshot"/>
+		<menu_item_check label="Zapisuj zdjęcia na dysk twardy bez efektu dźwiękowego" name="QuietSnapshotsToDisk"/>
+		<menu_item_check label="Skompresuj zdjęcie na dysk twardy" name="CompressSnapshotsToDisk"/>
 		<menu label="Narzędzia" name="Performance Tools">
-			<menu_item_call label="Pomiar Lagów" name="Lag Meter"/>
+			<menu_item_call label="Pomiar lagów" name="Lag Meter"/>
 			<menu_item_check label="Statystyki" name="Statistics Bar"/>
-			<menu_item_check label="Pokaż Wartość Renderowania Awatara" name="Avatar Rendering Cost"/>
+			<menu_item_check label="Pokaż wartość renderowania awatara" name="Avatar Rendering Cost"/>
 		</menu>
-		<menu label="Podkreślanie i Widoczność" name="Highlighting and Visibility">
-			<menu_item_check label="Efekt Emiterów" name="Cheesy Beacon"/>
-			<menu_item_check label="Ukryj CzÄ…steczki" name="Hide Particles"/>
-			<menu_item_check label="Ukryj Zaznaczone" name="Hide Selected"/>
-			<menu_item_check label="Pokaż Przeźroczyste Obiekty" name="Highlight Transparent"/>
-			<menu_item_check label="Pokaż Załączniki HUD" name="Show HUD Attachments"/>
-			<menu_item_check label="Pokaż Celownik Myszki" name="ShowCrosshairs"/>
+		<menu label="Podkreślanie i widoczność" name="Highlighting and Visibility">
+			<menu_item_check label="Efekt emiterów" name="Cheesy Beacon"/>
+			<menu_item_check label="Ukryj czÄ…steczki" name="Hide Particles"/>
+			<menu_item_check label="Ukryj zaznaczone" name="Hide Selected"/>
+			<menu_item_check label="Pokaż przeźroczyste obiekty" name="Highlight Transparent"/>
+			<menu_item_check label="Pokaż załączniki HUD" name="Show HUD Attachments"/>
+			<menu_item_check label="Pokaż celownik myszki" name="ShowCrosshairs"/>
 		</menu>
-		<menu label="Rodzaje Renderowania" name="Rendering Types">
+		<menu label="Rodzaje renderowania" name="Rendering Types">
 			<menu_item_check label="Podstawowe" name="Simple"/>
-			<menu_item_check label="Maska Przezroczysta" name="Alpha"/>
+			<menu_item_check label="Maska alpha" name="Alpha"/>
 			<menu_item_check label="Drzewo" name="Tree"/>
 			<menu_item_check label="Awatary" name="Character"/>
-			<menu_item_check label="PÅ‚aszczyzna Powierzchni" name="SurfacePath"/>
+			<menu_item_check label="PÅ‚aszczyzna powierzchni" name="SurfacePath"/>
 			<menu_item_check label="Niebo" name="Sky"/>
 			<menu_item_check label="Woda" name="Water"/>
 			<menu_item_check label="Ziemia" name="Ground"/>
@@ -157,163 +157,163 @@
 			<menu_item_check label="CzÄ…steczki" name="Particles"/>
 			<menu_item_check label="Zderzenie" name="Bump"/>
 		</menu>
-		<menu label="Opcje Renderowania" name="Rendering Features">
+		<menu label="Opcje renderowania" name="Rendering Features">
 			<menu_item_check label="UI" name="UI"/>
 			<menu_item_check label="Zaznaczone" name="Selected"/>
 			<menu_item_check label="Podświetlenie" name="Highlighted"/>
-			<menu_item_check label="Tekstury Dynamiczne" name="Dynamic Textures"/>
-			<menu_item_check label="Cień Stopy" name="Foot Shadows"/>
+			<menu_item_check label="Tekstury dynamiczne" name="Dynamic Textures"/>
+			<menu_item_check label="Cień stopy" name="Foot Shadows"/>
 			<menu_item_check label="Mgła" name="Fog"/>
-			<menu_item_check label="Obiekty Elastyczne" name="Flexible Objects"/>
+			<menu_item_check label="Obiekty elastyczne" name="Flexible Objects"/>
 		</menu>
-		<menu_item_check label="Uruchom Wiele Wątków" name="Run Multiple Threads"/>
-		<menu_item_check label="Use Plugin Read Thread" name="Use Plugin Read Thread"/>
-		<menu_item_call label="Wyczyść Bufor Danych Grupy" name="ClearGroupCache"/>
-		<menu_item_check label="Wygładzanie Ruchu Myszki" name="Mouse Smoothing"/>
+		<menu_item_check label="Uruchom wiele wątków" name="Run Multiple Threads"/>
+		<menu_item_check label="Użyj plugin Read Thread" name="Use Plugin Read Thread"/>
+		<menu_item_call label="Wyczyść bufor danych grupy" name="ClearGroupCache"/>
+		<menu_item_check label="Wygładzanie ruchu myszki" name="Mouse Smoothing"/>
 		<menu label="Skróty" name="Shortcuts">
 			<menu_item_call label="Obraz (L$[COST])..." name="Upload Image"/>
 			<menu_item_check label="Szukaj" name="Search"/>
-			<menu_item_call label="Zwolnij Klawisze" name="Release Keys"/>
-			<menu_item_call label="Domyślne Ustawienia Rozmiaru Interfejsu" name="Set UI Size to Default"/>
+			<menu_item_call label="Zwolnij klawisze" name="Release Keys"/>
+			<menu_item_call label="Domyślne ustawienia rozmiaru interfejsu" name="Set UI Size to Default"/>
 			<menu_item_check label="Pokaż menu Zaawansowane" name="Show Advanced Menu - legacy shortcut"/>
 			<menu_item_check label="Biegnij" name="Always Run"/>
-			<menu_item_check label="Zacznij Latać" name="Fly"/>
-			<menu_item_call label="Zamknij Okno" name="Close Window"/>
-			<menu_item_call label="Zamknij Wszystkie Okna" name="Close All Windows"/>
-			<menu_item_call label="Zapisz Zdjęcie na Dysk Twardy" name="Snapshot to Disk"/>
-			<menu_item_call label="Widok Panoramiczny" name="Mouselook"/>
-			<menu_item_check label="Wolna Kamera" name="Joystick Flycam"/>
-			<menu_item_call label="Reset Widoku" name="Reset View"/>
-			<menu_item_call label="Zobacz Ostatniego Rozmówcę" name="Look at Last Chatter"/>
-			<menu label="Wybierz Narzędzie Budowania" name="Select Tool">
-				<menu_item_call label="Narzędzie Ogniskowej" name="Focus"/>
-				<menu_item_call label="Narzędzie Ruchu" name="Move"/>
-				<menu_item_call label="Narzędzie Edycji" name="Edit"/>
-				<menu_item_call label="Stwórz Narzędzie" name="Create"/>
-				<menu_item_call label="Narzędzia Posiadłości" name="Land"/>
+			<menu_item_check label="Zacznij latać" name="Fly"/>
+			<menu_item_call label="Zamknij okno" name="Close Window"/>
+			<menu_item_call label="Zamknij wszystkie okna" name="Close All Windows"/>
+			<menu_item_call label="Zapisz zdjęcie na dysk twardy" name="Snapshot to Disk"/>
+			<menu_item_call label="Widok panoramiczny" name="Mouselook"/>
+			<menu_item_check label="Wolna kamera" name="Joystick Flycam"/>
+			<menu_item_call label="Reset widoku" name="Reset View"/>
+			<menu_item_call label="Zobacz ostatniego rozmówcę" name="Look at Last Chatter"/>
+			<menu label="Wybierz narzędzie budowania" name="Select Tool">
+				<menu_item_call label="Narzędzie ogniskowej" name="Focus"/>
+				<menu_item_call label="Narzędzie ruchu" name="Move"/>
+				<menu_item_call label="Narzędzie edycji" name="Edit"/>
+				<menu_item_call label="Stwórz narzędzie" name="Create"/>
+				<menu_item_call label="Narzędzia posiadłości" name="Land"/>
 			</menu>
 			<menu_item_call label="Przybliż" name="Zoom In"/>
-			<menu_item_call label="Domyślne Przybliżenie" name="Zoom Default"/>
+			<menu_item_call label="Domyślne przybliżenie" name="Zoom Default"/>
 			<menu_item_call label="Oddal" name="Zoom Out"/>
 		</menu>
-		<menu_item_call label="Pokaż Ustawienia Debugowania" name="Debug Settings"/>
-		<menu_item_check label="Pokaż Menu Progresu" name="Debug Mode"/>
+		<menu_item_call label="Pokaż ustawienia debugowania" name="Debug Settings"/>
+		<menu_item_check label="Pokaż menu progresu" name="Debug Mode"/>
 	</menu>
-	<menu label="Postęp..." name="Develop">
+	<menu label="Rozwinięcie..." name="Develop">
 		<menu label="Konsola" name="Consoles">
-			<menu_item_check label="Konsola Tekstur" name="Texture Console"/>
-			<menu_item_check label="Debugowanie Zdarzeń Konsoli" name="Debug Console"/>
-			<menu_item_call label="Konsola Powiadomień" name="Notifications"/>
-			<menu_item_check label="Konsola Rozmiaru Tekstury" name="Texture Size"/>
-			<menu_item_check label="Konsola Kategorii Tekstur" name="Texture Category"/>
-			<menu_item_check label="Szybkie Timery" name="Fast Timers"/>
+			<menu_item_check label="Konsola tekstur" name="Texture Console"/>
+			<menu_item_check label="Debugowanie zdarzeń konsoli" name="Debug Console"/>
+			<menu_item_call label="Konsola powiadomień" name="Notifications"/>
+			<menu_item_check label="Konsola rozmiaru tekstury" name="Texture Size"/>
+			<menu_item_check label="Konsola kategorii tekstur" name="Texture Category"/>
+			<menu_item_check label="Szybkie timery" name="Fast Timers"/>
 			<menu_item_check label="Pamięć" name="Memory"/>
-			<menu_item_call label="Info Regionu do Debugowania Konsoli" name="Region Info to Debug Console"/>
+			<menu_item_call label="Info Regionu do debugowania konsoli" name="Region Info to Debug Console"/>
 			<menu_item_check label="Kamera" name="Camera"/>
 			<menu_item_check label="Wiatr" name="Wind"/>
 			<menu_item_check label="Znak" name="Badge"/>
 		</menu>
-		<menu label="Pokaż Informacje" name="Display Info">
-			<menu_item_check label="Pokaż Czas" name="Show Time"/>
-			<menu_item_check label="Pokaż Informacje o Renderowaniu" name="Show Render Info"/>
-			<menu_item_check label="Pokaż Kolor pod Kursorem" name="Show Color Under Cursor"/>
-			<menu_item_check label="Pokaż Aktualizacje Obiektów" name="Show Updates"/>
+		<menu label="Pokaż informacje" name="Display Info">
+			<menu_item_check label="Pokaż czas" name="Show Time"/>
+			<menu_item_check label="Pokaż informacje o renderowaniu" name="Show Render Info"/>
+			<menu_item_check label="Pokaż kolor pod kursorem" name="Show Color Under Cursor"/>
+			<menu_item_check label="Pokaż aktualizacje obiektów" name="Show Updates"/>
 		</menu>
-		<menu label="Reset Błędu" name="Force Errors">
-			<menu_item_call label="Aktywacja Punktu Załamania" name="Force Breakpoint"/>
-			<menu_item_call label="Reset Błędów LL" name="Force LLError And Crash"/>
-			<menu_item_call label="Reset Błędów Pamięci" name="Force Bad Memory Access"/>
-			<menu_item_call label="Reset Pętli" name="Force Infinite Loop"/>
-			<menu_item_call label="Reset Sterowników" name="Force Driver Carsh"/>
-			<menu_item_call label="WyjÄ…tek Programu" name="Force Software Exception"/>
-			<menu_item_call label="Uruchom Rozłączenie" name="Force Disconnect Viewer"/>
-			<menu_item_call label="Symulacja Wycieku Pamięci" name="Memory Leaking Simulation"/>
+		<menu label="Reset błędu" name="Force Errors">
+			<menu_item_call label="Aktywacja punktu załamania" name="Force Breakpoint"/>
+			<menu_item_call label="Reset błędów LL" name="Force LLError And Crash"/>
+			<menu_item_call label="Reset błędów pamięci" name="Force Bad Memory Access"/>
+			<menu_item_call label="Reset pętli" name="Force Infinite Loop"/>
+			<menu_item_call label="Reset sterowników" name="Force Driver Carsh"/>
+			<menu_item_call label="WyjÄ…tek programu" name="Force Software Exception"/>
+			<menu_item_call label="Uruchom rozłączenie" name="Force Disconnect Viewer"/>
+			<menu_item_call label="Symulacja wycieku pamięci" name="Memory Leaking Simulation"/>
 		</menu>
-		<menu label="Test Renderowania" name="Render Tests">
-			<menu_item_check label="Kamera Poza Zasiegiem" name="Camera Offset"/>
-			<menu_item_check label="Losowa Ilość Klatek" name="Randomize Framerate"/>
-			<menu_item_check label="Test Klatki Obrazu" name="Frame Test"/>
+		<menu label="Test renderowania" name="Render Tests">
+			<menu_item_check label="Kamera poza zasiegiem" name="Camera Offset"/>
+			<menu_item_check label="Losowa ilość klatek" name="Randomize Framerate"/>
+			<menu_item_check label="Test klatki obrazu" name="Frame Test"/>
 		</menu>
 		<menu label="Renderowanie" name="Rendering">
 			<menu_item_check label="Osie" name="Axes"/>
-			<menu_item_check label="Tryb Obrazu Szkieletowego" name="Wireframe"/>
-			<menu_item_check label="Globalne Oświetlenie" name="Global Illumination"/>
-			<menu_item_check label="Tekstury Animacji" name="Animation Textures"/>
-			<menu_item_check label="Wyłącz Tekstury" name="Disable Textures"/>
-			<menu_item_check label="Renderowania Załączonego Światła" name="Render Attached Lights"/>
-			<menu_item_check label="Renderowanie Załączonych Cząsteczek" name="Render Attached Particles"/>
-			<menu_item_check label="Wyświetlaj Obiekty Odblaskowe" name="Hover Glow Objects"/>
+			<menu_item_check label="Tryb obrazu szkieletowego" name="Wireframe"/>
+			<menu_item_check label="Globalne oświetlenie" name="Global Illumination"/>
+			<menu_item_check label="Tekstury animacji" name="Animation Textures"/>
+			<menu_item_check label="Wyłącz tekstury" name="Disable Textures"/>
+			<menu_item_check label="Renderowania załączonego światła" name="Render Attached Lights"/>
+			<menu_item_check label="Renderowanie załączonych cząsteczek" name="Render Attached Particles"/>
+			<menu_item_check label="Wyświetlaj obiekty odblaskowe" name="Hover Glow Objects"/>
 		</menu>
 		<menu label="Sieć" name="Network">
-			<menu_item_check label="Zatrzymaj Awatara" name="AgentPause"/>
-			<menu_item_call label="Upuść Pakiet Pamięci" name="Drop a Packet"/>
+			<menu_item_check label="Zatrzymaj awatara" name="AgentPause"/>
+			<menu_item_call label="Upuść pakiet pamięci" name="Drop a Packet"/>
 		</menu>
-		<menu_item_call label="Zderzenia, Popchnięcia &amp;  Uderzenia" name="Bumps, Pushes &amp;amp; Hits"/>
+		<menu_item_call label="Zderzenia, popchnięcia &amp;  uderzenia" name="Bumps, Pushes &amp;amp; Hits"/>
 		<menu label="Åšwiat" name="World">
-			<menu_item_check label="Domyślne Ustawienia Środowiska Regionu" name="Sim Sun Override"/>
-			<menu_item_check label="Efekty Emiterów" name="Cheesy Beacon"/>
-			<menu_item_check label="Ustalona Pogoda" name="Fixed Weather"/>
-			<menu_item_call label="Zachowaj Bufor Pamięci Obiektów Regionu" name="Dump Region Object Cache"/>
+			<menu_item_check label="Domyślne ustawienia środowiska Regionu" name="Sim Sun Override"/>
+			<menu_item_check label="Efekty emiterów" name="Cheesy Beacon"/>
+			<menu_item_check label="Ustalona pogoda" name="Fixed Weather"/>
+			<menu_item_call label="Zachowaj bufor pamięci obiektów regionu" name="Dump Region Object Cache"/>
 		</menu>
 		<menu label="UI" name="UI">
-			<menu_item_call label="Test PrzeglÄ…darki Internetowej" name="Web Browser Test"/>
-			<menu_item_call label="Drukuj Zaznaczone Informacje o Obiekcie" name="Print Selected Object Info"/>
-			<menu_item_call label="Statystyki Pamięci" name="Memory Stats"/>
-			<menu_item_check label="Kliknij Podójnie by Uruchomić Auto-Pilota" name="Double-ClickAuto-Pilot"/>
-			<menu_item_check label="Debugowanie Zdarzeń Klikania" name="Debug Clicks"/>
-			<menu_item_check label="Debugowanie Zdarzeń Myszy" name="Debug Mouse Events"/>
+			<menu_item_call label="Test przeglÄ…darki internetowej" name="Web Browser Test"/>
+			<menu_item_call label="Drukuj zaznaczone informacje o obiekcie" name="Print Selected Object Info"/>
+			<menu_item_call label="Statystyki pamięci" name="Memory Stats"/>
+			<menu_item_check label="Kliknij podójnie by uruchomić auto-pilota" name="Double-ClickAuto-Pilot"/>
+			<menu_item_check label="Debugowanie zdarzeń klikania" name="Debug Clicks"/>
+			<menu_item_check label="Debugowanie zdarzeń myszy" name="Debug Mouse Events"/>
 		</menu>
 		<menu label="XUI" name="XUI">
-			<menu_item_call label="Załaduj Ustawienia Koloru" name="Reload Color Settings"/>
-			<menu_item_call label="Pokaż Test Czcionki" name="Show Font Test"/>
+			<menu_item_call label="Załaduj ustawienia koloru" name="Reload Color Settings"/>
+			<menu_item_call label="Pokaż test czcionki" name="Show Font Test"/>
 			<menu_item_call label="Załaduj z XML" name="Load from XML"/>
 			<menu_item_call label="Zapisz jako XML" name="Save to XML"/>
-			<menu_item_check label="Pokaż Nazwy XUI" name="Show XUI Names"/>
-			<menu_item_call label="Wyślij Wiadomość (IM) Testową" name="Send Test IMs"/>
+			<menu_item_check label="Pokaż nazwy XUI" name="Show XUI Names"/>
+			<menu_item_call label="Wyślij wiadomość (IM) testową" name="Send Test IMs"/>
 		</menu>
 		<menu label="Awatar" name="Character">
-			<menu label="Grab Baked Texture" name="Grab Baked Texture">
-				<menu_item_call label="Tęczówka Oka" name="Iris"/>
+			<menu label="Przesuń bakowaną teksturę" name="Grab Baked Texture">
+				<menu_item_call label="Tęczówka oka" name="Iris"/>
 				<menu_item_call label="GÅ‚owa" name="Head"/>
-				<menu_item_call label="Górna Część Ciała" name="Upper Body"/>
-				<menu_item_call label="Dolna Część Ciała" name="Lower Body"/>
+				<menu_item_call label="Górna część ciała" name="Upper Body"/>
+				<menu_item_call label="Dolna część ciała" name="Lower Body"/>
 				<menu_item_call label="Spódnica" name="Skirt"/>
 			</menu>
-			<menu label="Testy Postaci" name="Character Tests">
-				<menu_item_call label="Przesuń Geometrię Postaci" name="Toggle Character Geometry"/>
-				<menu_item_check label="Pozwól na Zaznaczanie Awatarów" name="Allow Select Avatar"/>
+			<menu label="Testy postaci" name="Character Tests">
+				<menu_item_call label="Przesuń geometrię postaci" name="Toggle Character Geometry"/>
+				<menu_item_check label="Pozwól na zaznaczanie awatarów" name="Allow Select Avatar"/>
 			</menu>
-			<menu_item_call label="Powrót do Domyślnych Parametrów" name="Force Params to Default"/>
-			<menu_item_check label="Info o Animacji" name="Animation Info"/>
-			<menu_item_check label="Wolne Animacje" name="Slow Motion Animations"/>
-			<menu_item_check label="Wyłącz Poziom Detalu" name="Disable LOD"/>
-			<menu_item_check label="Pokaż Szczegóły Kolizji" name="Show Collision Skeleton"/>
-			<menu_item_check label="Wyświetl Cel Aganta" name="Display Agent Target"/>
-			<menu_item_call label="Debugowanie Tekstur Awatara" name="Debug Avatar Textures"/>
+			<menu_item_call label="Powrót do domyślnych parametrów" name="Force Params to Default"/>
+			<menu_item_check label="Info o animacji" name="Animation Info"/>
+			<menu_item_check label="Wolne animacje" name="Slow Motion Animations"/>
+			<menu_item_check label="Wyłącz poziom detalu" name="Disable LOD"/>
+			<menu_item_check label="Pokaż szczegóły kolizji" name="Show Collision Skeleton"/>
+			<menu_item_check label="Wyświetl cel agenta" name="Display Agent Target"/>
+			<menu_item_call label="Debugowanie tekstur awatara" name="Debug Avatar Textures"/>
 		</menu>
 		<menu_item_check label="Tekstury HTTP" name="HTTP Textures"/>
 		<menu_item_check label="Aktywacja okna konsoli podczas następnego uruchomienia" name="Console Window"/>
-		<menu_item_check label="Pokaż Menu Administratora" name="View Admin Options"/>
-		<menu_item_call label="Uzyskaj Status Administratora" name="Request Admin Options"/>
-		<menu_item_call label="Opuść Status Administratora" name="Leave Admin Options"/>
+		<menu_item_check label="Pokaż menu administratora" name="View Admin Options"/>
+		<menu_item_call label="Uzyskaj status administratora" name="Request Admin Options"/>
+		<menu_item_call label="Opuść status administratora" name="Leave Admin Options"/>
 	</menu>
 	<menu label="Administrator" name="Admin">
 		<menu label="Object">
-			<menu_item_call label="Weź Kopię" name="Take Copy"/>
-			<menu_item_call label="Reset Właściciela" name="Force Owner To Me"/>
-			<menu_item_call label="Reset Przyzwolenia Właściciela" name="Force Owner Permissive"/>
+			<menu_item_call label="Weź kopię" name="Take Copy"/>
+			<menu_item_call label="Reset właściciela" name="Force Owner To Me"/>
+			<menu_item_call label="Reset przyzwolenia właściciela" name="Force Owner Permissive"/>
 			<menu_item_call label="Usuń" name="Delete"/>
 			<menu_item_call label="Zablokuj" name="Lock"/>
 		</menu>
 		<menu label="Posiadłość" name="Parcel">
-			<menu_item_call label="Reset Właściciela" name="Owner To Me"/>
-			<menu_item_call label="Ustawienia Treści Lindenów" name="Set to Linden Content"/>
-			<menu_item_call label="Odzyskaj Posiadłość Publiczną" name="Claim Public Land"/>
+			<menu_item_call label="Reset właściciela" name="Owner To Me"/>
+			<menu_item_call label="Ustawienia treści Lindenów" name="Set to Linden Content"/>
+			<menu_item_call label="Odzyskaj posiadłość publiczną" name="Claim Public Land"/>
 		</menu>
 		<menu label="Region" name="Region">
-			<menu_item_call label="Zachowaj Tymczasowo BazÄ™ Asset" name="Dump Temp Asset Data"/>
-			<menu_item_call label="Zachowaj Ustawienie Regionu" name="Save Region State"/>
+			<menu_item_call label="Zachowaj tymczasowo bazÄ™ asset" name="Dump Temp Asset Data"/>
+			<menu_item_call label="Zachowaj ustawienie Regionu" name="Save Region State"/>
 		</menu>
-		<menu_item_call label="Boskie Nadzędzia" name="God Tools"/>
+		<menu_item_call label="Boskie narzędzia" name="God Tools"/>
 	</menu>
 </menu_bar>
diff --git a/indra/newview/skins/default/xui/pl/mime_types_mac.xml b/indra/newview/skins/default/xui/pl/mime_types_mac.xml
index ae860249bb8..7213b26165a 100644
--- a/indra/newview/skins/default/xui/pl/mime_types_mac.xml
+++ b/indra/newview/skins/default/xui/pl/mime_types_mac.xml
@@ -19,7 +19,7 @@
 			To miejsce posiada zawartość filmową
 		</tooltip>
 		<playtip name="movie_playtip">
-			OglÄ…daj Film
+			OglÄ…daj film
 		</playtip>
 	</widgetset>
 	<widgetset name="image">
@@ -46,7 +46,7 @@
 	</widgetset>
 	<scheme name="rtsp">
 		<label name="rtsp_label">
-			Synchroniczne Strumienie Medialne
+			Synchroniczne strumienie mediów
 		</label>
 	</scheme>
 	<mimetype name="blank">
@@ -111,7 +111,7 @@
 	</mimetype>
 	<mimetype name="application/xhtml+xml">
 		<label name="application/xhtml+xml_label">
-			Strona Internetowa (XHTML)
+			Strona internetowa (XHTML)
 		</label>
 	</mimetype>
 	<mimetype name="application/x-director">
@@ -171,7 +171,7 @@
 	</mimetype>
 	<mimetype name="text/html">
 		<label name="text/html_label">
-			Strona Internetowa
+			Strona internetowa
 		</label>
 	</mimetype>
 	<mimetype name="text/plain">
diff --git a/indra/newview/skins/default/xui/pl/notifications.xml b/indra/newview/skins/default/xui/pl/notifications.xml
index 14718e8f6fb..75b6f5be0d7 100644
--- a/indra/newview/skins/default/xui/pl/notifications.xml
+++ b/indra/newview/skins/default/xui/pl/notifications.xml
@@ -78,7 +78,7 @@ Sprawdź stan swojego połączenia sieciowego.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="MessageTemplateNotFound">
-		Wzór komunikatu dla [PATH] nie odnaleziony.
+		Wzór komunikatu dla [PATH] nie został odnaleziony.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="WearableSave">
@@ -103,7 +103,7 @@ Wybierz pojedynczy obiekt i spróbuj jeszcze raz.
 	</notification>
 	<notification name="SaveClothingBodyChanges">
 		Zapisać wszystkie zmiany dotyczące ubrania/cześci ciała?
-		<usetemplate canceltext="Anuluj" name="yesnocancelbuttons" notext="Nie Zapisuj" yestext="Zapisz"/>
+		<usetemplate canceltext="Anuluj" name="yesnocancelbuttons" notext="Nie zapisuj" yestext="Zapisz"/>
 	</notification>
 	<notification name="FriendsAndGroupsOnly">
 		Osoby spoza listy znajomych, których rozmowy głosowe i IM są ignorowane, nie wiedzą o tym.
@@ -128,14 +128,14 @@ Czy chcesz dać prawa modyfikacji wybranym osobom?
 		<usetemplate name="okcancelbuttons" notext="Nie" yestext="Tak"/>
 	</notification>
 	<notification name="UnableToCreateGroup">
-		Założenie grupy niemożliwe.
+		Założenie grupy nie jest możliwe.
 [MESSAGE]
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="PanelGroupApply">
 		[NEEDS_APPLY_MESSAGE]
 [WANT_APPLY_MESSAGE]
-		<usetemplate canceltext="Anuluj" name="yesnocancelbuttons" notext="Ignoruj Zmiany" yestext="Zastosuj Zmiany"/>
+		<usetemplate canceltext="Anuluj" name="yesnocancelbuttons" notext="Ignoruj zmiany" yestext="Zastosuj zmiany"/>
 	</notification>
 	<notification name="MustSpecifyGroupNoticeSubject">
 		Aby wysłać ogłoszenie do grupy musisz nadać mu tytuł.
@@ -181,7 +181,7 @@ Chcesz kontynuować?
 	<notification name="JoinGroupNoCost">
 		Dołączasz do grupy [NAME].
 Czy chcesz kontynuować?
-		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="Zaakceptuj"/>
+		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="Akceptuj"/>
 	</notification>
 	<notification name="JoinGroupCannotAfford">
 		Członkostwo w tej grupie kosztuje [COST]L$
@@ -272,7 +272,7 @@ Skrypty muszą pozostać aktywne dla prawidłowego działania broni.
 	<notification name="MultipleFacesSelected">
 		Obecnie zaznaczono wiele powierzchni.
 Jeśli działanie będzie kontynuowane, oddzielne media będą ustawione na wielu powierzchniach obiektu. 
-W celu umieszczenia mediów tylko na jednej powierzchni skorzystaj z Wybierz Powierzchnię i kliknij na wybranej powierzchni obiektu oraz kliknij Dodaj.
+W celu umieszczenia mediów tylko na jednej powierzchni skorzystaj z Wybierz powierzchnię i kliknij na wybranej powierzchni obiektu oraz kliknij Dodaj.
 		<usetemplate ignoretext="Media zostanÄ… ustawione na wielu zaznaczonych powierzchniach" name="okcancelignore" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="MustBeInParcel">
@@ -343,11 +343,11 @@ Czy na pewno chcesz kontynuować?
 		<usetemplate ignoretext="Potwierdź przed usunięciem mediów z obiektu" name="okcancelignore" notext="Nie" yestext="Tak"/>
 	</notification>
 	<notification name="ClassifiedSave">
-		Zapisać zmiany w Reklamie [NAME]?
+		Zapisać zmiany w reklamie [NAME]?
 		<usetemplate canceltext="Anuluj" name="yesnocancelbuttons" notext="Nie Zapisuj" yestext="Zapisz"/>
 	</notification>
 	<notification name="ClassifiedInsufficientFunds">
-		Nie posiadasz wystarczających środków aby dodać Reklamę.
+		Nie posiadasz wystarczających środków aby dodać reklamę.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="DeleteAvatarPick">
@@ -386,27 +386,27 @@ Pamiętaj: Opcja ta wyczyszcza bufor danych.
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="SaveChanges">
-		Zapisać Zmiany?
-		<usetemplate canceltext="Anuluj" name="yesnocancelbuttons" notext="Nie Zapisuj" yestext="Zapisz"/>
+		Zapisać zmiany?
+		<usetemplate canceltext="Anuluj" name="yesnocancelbuttons" notext="Nie zapisuj" yestext="Zapisz"/>
 	</notification>
 	<notification name="GestureSaveFailedTooManySteps">
-		Nie można zapisać gestu.
-Ten gest ma zbyt wiele etapów.
+		Nie można zapisać gesturki.
+Ta gesturka ma zbyt wiele etapów.
 Usuń kilka etapów i zapisz jeszcze raz.
 	</notification>
 	<notification name="GestureSaveFailedTryAgain">
-		Zapis gestu nie powiódł się. Spróbuj jeszcze raz za kilka minut.
+		Zapis gesturki nie powiódł się. Spróbuj jeszcze raz za kilka minut.
 	</notification>
 	<notification name="GestureSaveFailedObjectNotFound">
-		Nie można zapisać gestu ponieważ obiekt lub szafa powiązanego obiektu nie został znaleziony.
+		Nie można zapisać gesturki ponieważ obiekt lub szafa powiązanego obiektu nie został znaleziony.
 Obiekt może znajdować się zbyt daleko albo został usunięty.
 	</notification>
 	<notification name="GestureSaveFailedReason">
-		Nie można zapisać gestu z następującego powodu: [REASON]. Spróbuj zapisać jeszcze raz później.
+		Nie można zapisać gesturki z następującego powodu: [REASON]. Spróbuj zapisać jeszcze raz później.
 	</notification>
 	<notification name="SaveNotecardFailObjectNotFound">
 		Nie można zapisać notki ponieważ obiekt lub szafa powiązanego obiektu nie został znaleziony.
-Obiekt może znajdować się zbyt daleko albo został usuniety.
+Obiekt może znajdować się zbyt daleko albo został usunięty.
 	</notification>
 	<notification name="SaveNotecardFailReason">
 		Nie można zapisać notki z następującego powodu: [REASON]. Spróbuj zapisać jeszcze raz później.
@@ -422,19 +422,19 @@ Czy chcesz załadować ostatnią wersję zapisaną na serwerze?
 	</notification>
 	<notification name="SaveScriptFailObjectNotFound">
 		Nie można zapisać skryptu ponieważ obiekt w którym się zawiera nie został znaleziony.
-Obiekt może znajdować się zbyt daleko albo został usuniety.
+Obiekt może znajdować się zbyt daleko albo został usunięty.
 	</notification>
 	<notification name="SaveBytecodeFailReason">
 		Nie można zapisać skompilowanego skryptu z następującego powodu: [REASON]. Spróbuj zapisać jeszcze raz póżniej.
 	</notification>
 	<notification name="StartRegionEmpty">
 		Oops, Twoje miejsce startu nie zostało określone.
-Wpisz proszÄ™ nazwÄ™ regionu w lokalizacjÄ™ startu w polu Lokalizacja Startu lub wybierz Moja Ostatnia Lokalizacja albo Miejsce Startu.
+Wpisz proszÄ™ nazwÄ™ regionu w lokalizacjÄ™ startu w polu Lokalizacja Startu lub wybierz Moja ostatnia lokalizacja albo Miejsce Startu.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="CouldNotStartStopScript">
 		Nie można uruchomić lub zatrzymać skryptu ponieważ obiekt w którym się zawiera nie został znaleziony.
-Obiekt może znajdować się zbyt daleko albo został usuniety.
+Obiekt może znajdować się zbyt daleko albo został usunięty.
 	</notification>
 	<notification name="CannotDownloadFile">
 		Nie można załadować pliku
@@ -453,7 +453,7 @@ Po więcej info, odwiedź stronę [_URL] .
 	</notification>
 	<notification name="UnknownGPU">
 		Twój system jest wyposażony w kartę graficzną, która nie jest rozpoznana przez [APP_NAME].
-Zdarza się to częstow w przypadku nowego sprzętu, który nie był testowany z [APP_NAME].  Prawdopodobnie wystarczy dostosowanie ustawień grafiki aby działanie było poprawne.
+Zdarza się to często w przypadku nowego sprzętu, który nie był testowany z [APP_NAME].  Prawdopodobnie wystarczy dostosowanie ustawień grafiki aby działanie było poprawne.
 (Ja &gt; Właściwości &gt; Grafika).
 		<form name="form">
 			<ignore name="ignore" text="Karta graficzna nie została zidentyfikowana."/>
@@ -461,7 +461,7 @@ Zdarza się to częstow w przypadku nowego sprzętu, który nie był testowany z
 	</notification>
 	<notification name="DisplaySettingsNoShaders">
 		[APP_NAME] zawiesił się podczas inicjalizacji sterowników graficznych.
-Jakość grafiki została zmniejszona - może pomoże.
+Jakość grafiki została zmniejszona - może to pomóc.
 Pewne funkcje graficzne zostały wyłączone. Zalecamy aktualizcje sterowników graficznych.
 Możesz podnieść jakość grafiki pod Ustawienia &gt; Grafika.
 	</notification>
@@ -972,7 +972,7 @@ ze wszystkich posiadłości w tym symulatorze?
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="BlankClassifiedName">
-		Musisz nadać tytuł Twojej Reklamie.
+		Musisz nadać tytuł Twojej reklamie.
 	</notification>
 	<notification name="MinClassifiedPrice">
 		Minimalna cena za publikacjÄ™ wynosi [MIN_PRICE]L$.
@@ -1106,7 +1106,7 @@ Możesz normalnie używać [SECOND_LIFE], inni użytkownicy będą Cię widzieli
 
 Jeżeli używasz [SECOND_LIFE] po raz pierwszy to musisz stworzyć konto żeby móc się zalogować.
 Czy chcesz przejść na stronę [http://join.secondlife.com secondlife.com] żeby stworzyć nowe konto?
-		<usetemplate name="okcancelbuttons" notext="Kontynuuj" yestext="Nowe Konto..."/>
+		<usetemplate name="okcancelbuttons" notext="Kontynuuj" yestext="Nowe konto..."/>
 	</notification>
 	<notification name="LoginPacketNeverReceived">
 		Problemy z połączeniem. Problem może być spowodowany Twoim połączeniem z Internetem albo może istnieć po stronie [SECOND_LIFE_GRID].
@@ -1223,14 +1223,14 @@ Zamień teksturę [TEXTURE_NUM] na 24-o bitową teksturę o wymiarze 512x512 lub
 [MAX_AGENTS] [LIST_TYPE] limit przekroczony o [NUM_EXCESS].
 	</notification>
 	<notification name="MaxAllowedGroupsOnRegion">
-		Możesz mieć maksymalnie [MAX_GROUPS] Dozwolonych Grup.
+		Możesz mieć maksymalnie [MAX_GROUPS] dozwolonych grup.
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="Ustal"/>
 	</notification>
 	<notification name="MaxManagersOnRegion">
-		Możesz mieć maksymalnie [MAX_MANAGER] Zarządców Majątku.
+		Możesz mieć maksymalnie [MAX_MANAGER] zarządców Majątku.
 	</notification>
 	<notification name="OwnerCanNotBeDenied">
-		Nie możesz dodać właściciela majątku do listy &apos;Nieporządanych Rezydentów (banów)&apos; majątku.
+		Nie możesz dodać właściciela majątku do listy &apos;Niepożądanych Rezydentów (banów)&apos; majątku.
 	</notification>
 	<notification name="CanNotChangeAppearanceUntilLoaded">
 		Nie możesz zmienić wyglądu podczas ładowania ubrań i kształtów.
@@ -1239,7 +1239,7 @@ Zamień teksturę [TEXTURE_NUM] na 24-o bitową teksturę o wymiarze 512x512 lub
 		Tytuł Twojej reklamy musi zaczynać się od litery (A-Z) albo cyfry. Znaki przestankowe są niedozwolone.
 	</notification>
 	<notification name="CantSetBuyObject">
-		Nie możesz wybrać Kup Obiekt ponieważ obiekt nie jest na sprzedaż.
+		Nie możesz wybrać Kup obiekt ponieważ obiekt nie jest na sprzedaż.
 Wybierz obiekt na sprzedaż i spróbuj jeszcze raz.
 	</notification>
 	<notification name="FinishedRawDownload">
@@ -1307,7 +1307,7 @@ Pobrać i zapisać w folderze Aplikacji?
 		<usetemplate name="okcancelbuttons" notext="Kontynuuj" yestext="Załaduj"/>
 	</notification>
 	<notification name="DeedObjectToGroup">
-		Przekazanie tego obiektu spowoduje, że Grupa:
+		Przekazanie tego obiektu spowoduje, że grupa:
 * Otrzyma L$ zapłacone temu obiektowi
 		<usetemplate ignoretext="Proszę potwierdzić decyzję przed przepisaniem obiektu do grupy" name="okcancelignore" notext="Anuluj" yestext="Przekaż"/>
 	</notification>
@@ -1329,15 +1329,15 @@ Pobrać i zapisać w folderze Aplikacji?
 	</notification>
 	<notification name="WebLaunchPublicIssue">
 		Odwiedź [SECOND_LIFE] katalog publicznych problemów, gdzie możesz zgłaszać błędy i inne problemy.
-		<usetemplate ignoretext="Uruchom przeglądarkę internetową by wysłać Błędy Klienta" name="okcancelignore" notext="Anuluj" yestext="OK"/>
+		<usetemplate ignoretext="Uruchom przeglądarkę internetową by wysłać Błędy klienta" name="okcancelignore" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="WebLaunchSupportWiki">
 		Otwórz oficjalny blog Lindenów żeby zobaczyć nowe wiadomości i informacje.
 		<usetemplate ignoretext="Uruchom przeglądarkę internetową by zobaczyć blog" name="okcancelignore" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="WebLaunchLSLGuide">
-		Czy chcesz otworzyć samouczek Języka Skryptowania?
-		<usetemplate ignoretext="Uruchom przeglądarkę internetową by samouczek Języka Skryptowania" name="okcancelignore" notext="Anuluj" yestext="OK"/>
+		Czy chcesz otworzyć samouczek Języka skryptowania?
+		<usetemplate ignoretext="Uruchom przeglądarkę internetową by samouczek Języka skryptowania" name="okcancelignore" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="WebLaunchLSLWiki">
 		Czy napewno chcesz odwiedzić portal LSL Portal?
@@ -1385,7 +1385,7 @@ Chcesz opuścić grupę?
 		Tryb Pracy jest włączony.
 Czat i IM będą ukryte. Wysłane IM będą otrzymywały Twoją odpowiedź Trybu Pracy. Propozycje teleportacji będą odrzucone.
 Dodatkowo, wszystkie podarowane dla Ciebie obiekty będą automatycznie zapisywane w folderze &quot;Kosz&quot; w Twojej szafie.
-		<usetemplate ignoretext="Status zmieniony na Tryb Pracy" name="okignore" yestext="OK"/>
+		<usetemplate ignoretext="Status zmieniony na Tryb pracy" name="okignore" yestext="OK"/>
 	</notification>
 	<notification name="JoinedTooManyGroupsMember">
 		Należysz już do maksymalnej ilości grup. Opuść proszę przynajmniej jedną grupę żeby przyjąć członkostwo w tej grupie, albo odmów.
@@ -1466,7 +1466,7 @@ Dodatkowo, wszystkie podarowane dla Ciebie obiekty będą automatycznie zapisywa
 	</notification>
 	<notification name="TeleportToClassified">
 		Teleportuj do [CLASSIFIED]?
-		<usetemplate ignoretext="Potwierdź, że chcesz teleportować się do lokalizacji z Reklamy" name="okcancelignore" notext="Anuluj" yestext="Teleportuj"/>
+		<usetemplate ignoretext="Potwierdź, że chcesz teleportować się do lokalizacji z reklamy" name="okcancelignore" notext="Anuluj" yestext="Teleportuj"/>
 	</notification>
 	<notification name="TeleportToHistoryEntry">
 		Teleportuj do [HISTORY_ENTRY]?
@@ -1489,7 +1489,7 @@ Kontynuować?
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification label="Zmiana Dostępu do Majątku Lindenów" name="ChangeLindenAccess">
-		Dokonujesz zmiany w liście dostępu Regionu Głównego należącego do Lindenów (Regiony Główne, Teen Grid, Orientacja).
+		Dokonujesz zmiany w liście dostępu Regionu głównego należącego do Lindenów (Regiony Główne, Teen Grid, Orientacja).
 
 Żądana operacja jest wyjątkowo niebezpieczna dla wszystkich Rezydentów przebywających w regionie i powinna być używana wyłącznie w celu zablokowania opcji pozwalającej na przeniesienie obiektów/L$ do/z sieci.
 Dodatkowo, zmiany dokonane w Regionie Głównym mogą spowodować problemy przestrzeni serwerowej innych regionów.
@@ -1560,7 +1560,7 @@ Skorzystaj z [SECOND_LIFE]:Pomoc by uzyskać więcej informacji na temat dostęp
 
 W celu uzyskania dostępu do tego regiony zmień proszę swój status ustawień wieku. Będziesz mógł/mogła szukać i mieć dostęp do treści [REGIONMATURITY]. W celu cofnięcia zmian wybierz z menu Ja &gt; Ustawienia &gt; Ogólne.
 		<form name="form">
-			<button name="OK" text="Zmień Ustawienia"/>
+			<button name="OK" text="Zmień ustawienia"/>
 			<button default="true" name="Cancel" text="Zamknij"/>
 			<ignore name="ignore" text="Moje ustawienia wieku nie dopuszczajÄ… do regionu"/>
 		</form>
@@ -1693,7 +1693,7 @@ Wybierz pojedynczy obiekt i spróbuj jeszcze raz.
 Zostaniesz właścicielem tego obiektu z następującymi prawami:
  Modyfikacje: [MODIFYPERM]
  Kopiowanie: [COPYPERM]
- Odsprzedawanie i Oddawanie: [RESELLPERM]
+ Odsprzedawanie i oddawanie: [RESELLPERM]
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="BuyOriginalNoOwner">
@@ -1701,7 +1701,7 @@ Zostaniesz właścicielem tego obiektu z następującymi prawami:
 Zostaniesz właścicielem tego obiektu z następującymi prawami:
  Modyfikacje: [MODIFYPERM]
  Kopiowanie: [COPYPERM]
- Odsprzedawanie i Oddawanie: [RESELLPERM]
+ Odsprzedawanie i oddawanie: [RESELLPERM]
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="BuyCopy">
@@ -1709,7 +1709,7 @@ Zostaniesz właścicielem tego obiektu z następującymi prawami:
 Obiekt zostanie skopiowany do Twojej szafy z następującymi prawami:
  Modyfikacje: [MODIFYPERM]
  Kopiowanie: [COPYPERM]
- Odsprzedawanie i Oddawanie: [RESELLPERM]
+ Odsprzedawanie i oddawanie: [RESELLPERM]
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="BuyCopyNoOwner">
@@ -1717,7 +1717,7 @@ Obiekt zostanie skopiowany do Twojej szafy z następującymi prawami:
 Obiekt zostanie skopiowany do Twojej szafy z następującymi prawami:
  Modyfikacje: [MODIFYPERM]
  Kopiowanie: [COPYPERM]
- Odsprzedawanie i Oddawanie: [RESELLPERM]
+ Odsprzedawanie i oddawanie: [RESELLPERM]
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="BuyContents">
@@ -1770,7 +1770,7 @@ Przenieść obiekty szafy?
 		<usetemplate ignoretext="Uprzedź przed przeniesieniem zawartości niekopiowalnej z obiektu, która może uszkodzić skrypty obiektu" name="okcancelignore" notext="Anuluj" yestext="OK"/>
 	</notification>
 	<notification name="ClickActionNotPayable">
-		Uwaga: Opcja Zapłać Obiektowi została wybrana, ale żeby ta opcja działała musi być dodany skrypt z funkcją money().
+		Uwaga: Opcja Zapłać obiektowi została wybrana, ale żeby ta opcja działała musi być dodany skrypt z funkcją money().
 		<form name="form">
 			<ignore name="ignore" text="Opcja Zapłać Obiektowi została aktywowana podczas budowania obiektów bez skryptu z funkcją money()."/>
 		</form>
@@ -1836,18 +1836,18 @@ Linden Lab
 Chcesz go zamienić na wybrany obiekt?
 		<form name="form">
 			<ignore name="ignore" save_option="true" text="Obecnie masz już dołączony obiekt do tej części Twojego ciała.Chcesz go zamienić na wybrany obiekt?"/>
-			<button ignore="Zamień Automatycznie" name="Yes" text="OK"/>
-			<button ignore="Nie Zamieniaj" name="No" text="Anuluj"/>
+			<button ignore="Zamień automatycznie" name="Yes" text="OK"/>
+			<button ignore="Nie zamieniaj" name="No" text="Anuluj"/>
 		</form>
 	</notification>
 	<notification label="Ostrzeżenie Trybu Pracy" name="BusyModePay">
-		Jesteś w Trybie Pracy co oznacza, że nie dostaniesz żadnych obiektów w zamian za tą opłatę.
+		Jesteś w Trybie pracy co oznacza, że nie dostaniesz żadnych obiektów w zamian za tą opłatę.
 
-Chcesz wyłączyć Tryb Pracy przed zakończeniem tej tranzakcji?
+Chcesz wyłączyć Tryb pracy przed zakończeniem tej tranzakcji?
 		<form name="form">
 			<ignore name="ignore" save_option="true" text="Jesteś w Trybie Pracy co oznacza, że nie dostaniesz żadnych obiektów w zamian za tą opłatę. Chcesz wyłączyć Tryb Pracy przed zakończeniem tej transakcji?"/>
-			<button ignore="Zawsz wyłączaj Tryb Pracy" name="Yes" text="OK"/>
-			<button ignore="Nie wyłączaj Trybu Pracy" name="No" text="Anuluj"/>
+			<button ignore="Zawsz wyłączaj tryb pracy" name="Yes" text="OK"/>
+			<button ignore="Nie wyłączaj trybu pracy" name="No" text="Anuluj"/>
 		</form>
 	</notification>
 	<notification name="ConfirmDeleteProtectedCategory">
@@ -1871,8 +1871,8 @@ Chcesz wyłączyć Tryb Pracy przed zakończeniem tej tranzakcji?
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="Tak"/>
 	</notification>
 	<notification name="ConfirmEmptyLostAndFound">
-		Na pewno chcesz permanentnie usunąć zawartość Twojego foldera Zgubione i Odnalezione?
-		<usetemplate ignoretext="Potwierdź przed usunięciem zawartości foldera Zagubione i Odnalezione" name="okcancelignore" notext="Nie" yestext="Tak"/>
+		Na pewno chcesz permanentnie usunąć zawartość Twojego foldera Zgubione i odnalezione?
+		<usetemplate ignoretext="Potwierdź przed usunięciem zawartości foldera Zagubione i odnalezione" name="okcancelignore" notext="Nie" yestext="Tak"/>
 	</notification>
 	<notification name="CopySLURL">
 		Następujący link SLURL został skopiowany do schowka:
@@ -1898,14 +1898,14 @@ Zamieść go na stronie internetowej żeby umożliwić innym łatwy dostęp do t
 		Ten plik cyklu dziennego używa brakującego pliku nieba: [SKY].
 	</notification>
 	<notification name="PPSaveEffectAlert">
-		Efekt Post-Procesu już istnieje. Chcesz zapisać nowy na jego miejsce?
+		Efekt post-procesu już istnieje. Chcesz zapisać nowy na jego miejsce?
 		<usetemplate name="okcancelbuttons" notext="Nie" yestext="Tak"/>
 	</notification>
 	<notification name="NewSkyPreset">
 		Nazwij nowe niebo.
 		<form name="form">
 			<input name="message">
-				Nowe Ustawienie
+				Nowe ustawienie
 			</input>
 			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Anuluj"/>
@@ -1918,7 +1918,7 @@ Zamieść go na stronie internetowej żeby umożliwić innym łatwy dostęp do t
 		Nazwij nowe ustawienie wody.
 		<form name="form">
 			<input name="message">
-				Nowe Ustawienie
+				Nowe ustawienie
 			</input>
 			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Anuluj"/>
@@ -1987,10 +1987,10 @@ Zamieść go na stronie internetowej żeby umożliwić innym łatwy dostęp do t
 		Anulowane
 	</notification>
 	<notification name="CancelledSit">
-		Siadanie Anulowane
+		Siadanie anulowane
 	</notification>
 	<notification name="CancelledAttach">
-		Dołączenie Anulowane
+		Dołączenie anulowane
 	</notification>
 	<notification name="ReplacedMissingWearable">
 		Barkujące ubranie/części ciała zastąpiono domyślnymi obiektami.
@@ -2027,7 +2027,7 @@ Zamieść go na stronie internetowej żeby umożliwić innym łatwy dostęp do t
 		Gesturka [NAME] nie znaleziony w bazie danych.
 	</notification>
 	<notification name="UnableToLoadGesture">
-		Ładowanie gestu [NAME] nie powiodło się.
+		Ładowanie gesturki [NAME] nie powiodło się.
 	</notification>
 	<notification name="LandmarkMissing">
 		Miejsce (LM) nie znalezione w bazie danych.
@@ -2041,7 +2041,7 @@ Spróbuj jeszcze raz.
 Ponieważ to ma wpływ na wpisywane hasło, możesz chcieć go wyłączyć.
 	</notification>
 	<notification name="NotecardMissing">
-		Notka nie znaleziona w bazie danych.
+		Notka nie została znaleziona w bazie danych.
 	</notification>
 	<notification name="NotecardNoPermissions">
 		Nie masz pozwolenia na zobaczenie notki.
@@ -2131,7 +2131,7 @@ Spróbuj wybrać mniejszy obszar.
 		Pewne frazy podczas wyszukiwania zostały usunięte w związku z restrykcjami zawartymi w Standardach Społecznościowych (Community Standards).
 	</notification>
 	<notification name="NoContentToSearch">
-		Proszę wybrać przynajmiej jeden z podanych rodzajów treści jaką zawiera region podczas wyszukiwania (&apos;PG&apos;, &apos;Mature&apos;, lub &apos;Adult&apos;).
+		Proszę wybrać przynajmiej jeden z podanych rodzajów treści jaką zawiera region podczas wyszukiwania (&apos;General&apos;, &apos;Moderate&apos;, lub &apos;Adult&apos;).
 	</notification>
 	<notification name="GroupVote">
 		[NAME] zaprasza do głosowania nad propozycją:
@@ -2148,7 +2148,7 @@ Spróbuj wybrać mniejszy obszar.
 		[MESSAGE]
 	</notification>
 	<notification name="EventNotification">
-		Zawiadomienie o Imprezie:
+		Zawiadomienie o imprezie:
 
 [NAME]
 [DATE]
@@ -2167,12 +2167,12 @@ Spróbuj wybrać mniejszy obszar.
 		</form>
 	</notification>
 	<notification name="DeactivatedGesturesTrigger">
-		Zablokowane gesty z jednakowym aktywowaniem:
+		Zablokowane gesturki z jednakowym aktywowaniem:
 [NAMES]
 	</notification>
 	<notification name="NoQuickTime">
 		Wygląda na to, że QuickTime z Apple nie jest zainstalowany na Twoim komputerze.
-Jeżeli chcesz odtwarzać media na tej posiadłości które używają QuickTime idź do [http://www.apple.com/quicktime QuickTime site] i zainstaluj odtwarzacz.
+Jeżeli chcesz odtwarzać media na tej posiadłości które używają QuickTime idź do [http://www.apple.com/quicktime strona QuickTime] i zainstaluj odtwarzacz.
 	</notification>
 	<notification name="NoPlugin">
 		Nie znaleziono wtyczki mediów dla &quot;[MIME_TYPE]&quot; typu mime.  Media tego typu będą niedostępne.
@@ -2584,7 +2584,7 @@ Wybierz Zaakceptuj żeby zacząć czat albo Odmów żeby nie przyjąć zaproszen
 		Nie masz dostępu do posiadłości, nie należysz do właściwej grupy.
 	</notification>
 	<notification name="Cannot enter parcel: banned">
-		Masz wzbroniny dostęp to tej posiadłości (ban).
+		Masz wzbroniony wstęp na tą posiadłości (ban).
 	</notification>
 	<notification name="Cannot enter parcel: not on access list">
 		Nie masz dostępu do posiadłości, nie jesteś na liście dostępu.
diff --git a/indra/newview/skins/default/xui/pl/panel_active_object_row.xml b/indra/newview/skins/default/xui/pl/panel_active_object_row.xml
index 57dc8a3dd7f..ab1d8d70072 100644
--- a/indra/newview/skins/default/xui/pl/panel_active_object_row.xml
+++ b/indra/newview/skins/default/xui/pl/panel_active_object_row.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="panel_activeim_row">
 	<string name="unknown_obj">
-		Nieznany Obiekt
+		Nieznany obiekt
 	</string>
 	<text name="object_name">
-		Nienazwany Obiekt
+		Nienazwany obiekt
 	</text>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_adhoc_control_panel.xml b/indra/newview/skins/default/xui/pl/panel_adhoc_control_panel.xml
index 6cd47c6ce78..ba0c85e4ef4 100644
--- a/indra/newview/skins/default/xui/pl/panel_adhoc_control_panel.xml
+++ b/indra/newview/skins/default/xui/pl/panel_adhoc_control_panel.xml
@@ -5,10 +5,10 @@
 			<button label="Dzwoń" name="call_btn"/>
 		</layout_panel>
 		<layout_panel name="end_call_btn_panel">
-			<button label="Zakończ Rozmowe" name="end_call_btn"/>
+			<button label="Zakończ rozmowę" name="end_call_btn"/>
 		</layout_panel>
 		<layout_panel name="voice_ctrls_btn_panel">
-			<button label="Przełączniki Głosu" name="voice_ctrls_btn"/>
+			<button label="Przełączniki głosu" name="voice_ctrls_btn"/>
 		</layout_panel>
 	</layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_audio_device.xml b/indra/newview/skins/default/xui/pl/panel_audio_device.xml
index fa8dde77eb1..9074296bd53 100644
--- a/indra/newview/skins/default/xui/pl/panel_audio_device.xml
+++ b/indra/newview/skins/default/xui/pl/panel_audio_device.xml
@@ -1,19 +1,19 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <panel name="device_settings">
 	<text name="Audio Devices">
-		UrzÄ…dzenia Audio
+		UrzÄ…dzenia audio
 	</text>
 	<text name="Input device (microphone):">
-		Urządzenia Wejściowe (mikrofon):
+		Urządzenia wejściowe (mikrofon):
 	</text>
 	<text name="Output device (speakers):">
-		Urządzenia Wyjściowe (głośniki):
+		Urządzenia wyjściowe (głośniki):
 	</text>
 	<text name="Input level:">
-		Poziom Wejścia
+		Poziom wejścia
 	</text>
 	<text_editor name="voice_intro_text1">
-		Użyj suwaka by dostosować jak głośno Cię słychać dla innych Rezydentów. W celu przetestowania poziomu wejścia, zacznij mówić do mikrofonu.
+		Za pomocą suwaka ustaw poziom głośności Twojego mówienia dla innych Rezydentów. W celu przetestowania poziomu wejścia, zacznij mówić do mikrofonu.
 	</text_editor>
 	<volume_slider name="mic_volume_slider"
 	     tool_tip="By zmienić poziom głośności użyj suwaka" />
diff --git a/indra/newview/skins/default/xui/pl/panel_block_list_sidetray.xml b/indra/newview/skins/default/xui/pl/panel_block_list_sidetray.xml
index 122d834bdd4..62cb392ba74 100644
--- a/indra/newview/skins/default/xui/pl/panel_block_list_sidetray.xml
+++ b/indra/newview/skins/default/xui/pl/panel_block_list_sidetray.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="block_list_panel">
 	<text name="title_text">
-		Lista Blokad
+		Lista blokad
 	</text>
-	<scroll_list name="blocked" tool_tip="Lista Zablokowanych Osób"/>
+	<scroll_list name="blocked" tool_tip="Lista zablokowanych osób"/>
 	<button label="Zablokuj Rezydenta..." label_selected="Zablokuj Rezydenta..." name="Block resident..." tool_tip="Wybierz Rezydenta aby zablokować"/>
 	<button label="Zablokuj obiekt według nazwy..." label_selected="Zablokuj obiekt według nazwy..." name="Block object by name..."/>
-	<button label="Odblokuj" label_selected="Odblokuj" name="Unblock" tool_tip="Usuń Rezydenta lub Obiekt z Listy Zablokowanych"/>
+	<button label="Odblokuj" label_selected="Odblokuj" name="Unblock" tool_tip="Usuń Rezydenta lub obiekt z listy zablokowanych"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_bottomtray.xml b/indra/newview/skins/default/xui/pl/panel_bottomtray.xml
index cf73ae53dd2..a0f4eb5244e 100644
--- a/indra/newview/skins/default/xui/pl/panel_bottomtray.xml
+++ b/indra/newview/skins/default/xui/pl/panel_bottomtray.xml
@@ -9,22 +9,22 @@
 			</talk_button>
 		</layout_panel>
 		<layout_panel name="gesture_panel">
-			<gesture_combo_list label="Gestury" name="Gesture" tool_tip="Pokazuje/Ukrywa gestury"/>
+			<gesture_combo_list label="Gesturki" name="Gesture" tool_tip="Pokazuje/Ukrywa gesturki"/>
 		</layout_panel>
 		<layout_panel name="movement_panel">
-			<button label="Ruch" name="movement_btn" tool_tip="Pokaż/Ukryj Ustawienia Ruchu"/>
+			<button label="Ruch" name="movement_btn" tool_tip="Pokaż/Ukryj ustawienia ruchu"/>
 		</layout_panel>
 		<layout_panel name="cam_panel">
-			<button label="Widok" name="camera_btn" tool_tip="Pokaż/Ukryj Ustawienia Kamery"/>
+			<button label="Widok" name="camera_btn" tool_tip="Pokaż/Ukryj ustawienia kamery"/>
 		</layout_panel>
 		<layout_panel name="snapshot_panel">
-			<button label="" name="snapshots" tool_tip="Zrób Zdjęcie"/>
+			<button label="" name="snapshots" tool_tip="Zrób zdjęcie"/>
 		</layout_panel>
 		<layout_panel name="sidebar_btn_panel">
-			<button label="Schowek" name="sidebar_btn" tool_tip="Pokazuje/ukrywa Schowek"/>
+			<button label="Schowek" name="sidebar_btn" tool_tip="Pokazuje/ukrywa schowek"/>
 		</layout_panel>
 		<layout_panel name="build_btn_panel">
-			<button label="Buduj" name="build_btn" tool_tip="Pokazuje/ukrywa Narzędzia Budowania"/>
+			<button label="Buduj" name="build_btn" tool_tip="Pokazuje/ukrywa narzędzia budowania"/>
 		</layout_panel>
 		<layout_panel name="search_btn_panel">
 			<button label="Szukaj" name="search_btn" tool_tip="Pokazuje/ukrywa Szukaj"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_bottomtray_lite.xml b/indra/newview/skins/default/xui/pl/panel_bottomtray_lite.xml
index 77d2e86b7e2..e32c12a8eec 100644
--- a/indra/newview/skins/default/xui/pl/panel_bottomtray_lite.xml
+++ b/indra/newview/skins/default/xui/pl/panel_bottomtray_lite.xml
@@ -2,7 +2,7 @@
 <panel name="bottom_tray_lite">
 	<layout_stack name="toolbar_stack_lite">
 		<layout_panel name="gesture_panel">
-			<gesture_combo_list label="Gest" name="Gest" tool_tip="Pokaż/ukryj gestury"/>
+			<gesture_combo_list label="Gesturki" name="Gesturki" tool_tip="Pokaż/ukryj gesturki"/>
 		</layout_panel>
 	</layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_alpha.xml b/indra/newview/skins/default/xui/pl/panel_edit_alpha.xml
index ac2739633ee..a22d4b04827 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_alpha.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_alpha.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_alpha_panel">
 	<panel name="avatar_alpha_color_panel">
-		<texture_picker label="Alpha Dolnej Części Ciała" name="Lower Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Alpha Górnej Części Ciała" name="Upper Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Alpha Głowy" name="Head Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Alpha Oka" name="Eye Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Alpha Włosów" name="Hair Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Alpha dolnej części ciała" name="Lower Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Alpha górnej części ciała" name="Upper Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Alpha głowy" name="Head Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Alpha oka" name="Eye Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Alpha włosów" name="Hair Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
 	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_classified.xml b/indra/newview/skins/default/xui/pl/panel_edit_classified.xml
index 6395d5c59ae..07f9b3a13f9 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_classified.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_classified.xml
@@ -10,7 +10,7 @@
 		Zapisz
 	</string>
 	<text name="title">
-		Edytuj ReklamÄ™
+		Edytuj reklamÄ™
 	</text>
 	<scroll_container name="profile_scroll">
 		<panel name="scroll_content_panel">
@@ -31,10 +31,10 @@
 			</text>
 			<button label="Ustaw na bieżącą lokalizację" name="set_to_curr_location_btn"/>
 			<text name="category_label" value="Kategoria:"/>
-			<text name="content_type_label" value="Typ Zawartości:"/>
-			<icons_combo_box label="Treść Ogólna" name="content_type">
-				<icons_combo_box.item label="Moderuj Treść" name="mature_ci" value="Mature"/>
-				<icons_combo_box.item label="Treść Ogólna" name="pg_ci" value="PG"/>
+			<text name="content_type_label" value="Typ zawartości:"/>
+			<icons_combo_box label="Treść General" name="content_type">
+				<icons_combo_box.item label="Treść Moderate" name="mature_ci" value="Mature"/>
+				<icons_combo_box.item label="Treść General" name="pg_ci" value="PG"/>
 			</icons_combo_box>
 			<text name="price_for_listing_label" value="Cena za wyświetlenie:"/>
 			<spinner label="L$" name="price_for_listing" tool_tip="Cena za umieszczenie reklamy." value="50"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_profile.xml b/indra/newview/skins/default/xui/pl/panel_edit_profile.xml
index edd74157512..c9790f5eba4 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_profile.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_profile.xml
@@ -33,8 +33,8 @@
 					WWW:
 				</text>
 				<check_box label="Pokaż w wyszukiwarce" name="show_in_search_checkbox"/>
-				<text name="title_acc_status_text" value="Moje Konto:"/>
-				<text name="my_account_link" value="[[URL] idź do Dashboard]"/>
+				<text name="title_acc_status_text" value="Moje konto:"/>
+				<text name="my_account_link" value="[[URL] idź do dashboard]"/>
 				<text name="acc_status_text" value="Rezydent. Brak danych konta."/>
 				<text name="title_partner_text" value="Partner:"/>
 				<text name="partner_edit_link" value="[[URL] Edytuj]"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_wearable.xml b/indra/newview/skins/default/xui/pl/panel_edit_wearable.xml
index 194b26a97ea..da2c26f02b7 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_wearable.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_wearable.xml
@@ -40,7 +40,7 @@
 		Edycja bielizny
 	</string>
 	<string name="edit_alpha_title">
-		Edycja maski Alpha
+		Edycja maski alpha
 	</string>
 	<string name="edit_tattoo_title">
 		Edycja tatuażu
@@ -73,7 +73,7 @@
 		Kurtka:
 	</string>
 	<string name="skirt_desc_text">
-		spódnica:
+		Spódnica:
 	</string>
 	<string name="gloves_desc_text">
 		Rękawiczki:
@@ -85,13 +85,13 @@
 		Bielizna:
 	</string>
 	<string name="alpha_desc_text">
-		Maska Alpha:
+		Maska alpha:
 	</string>
 	<string name="tattoo_desc_text">
 		Tatuaż:
 	</string>
 	<labeled_back_button label="Zapisz" name="back_btn" tool_tip="Powrót do edycji stroju"/>
-	<text name="edit_wearable_title" value="Edycja Kształtu"/>
+	<text name="edit_wearable_title" value="Edycja kształtu"/>
 	<panel label="Koszula" name="wearable_type_panel">
 		<text name="description_text" value="Kształt:"/>
 		<radio_group name="sex_radio">
diff --git a/indra/newview/skins/default/xui/pl/panel_friends.xml b/indra/newview/skins/default/xui/pl/panel_friends.xml
index fca0dad3803..9d8dc69a351 100644
--- a/indra/newview/skins/default/xui/pl/panel_friends.xml
+++ b/indra/newview/skins/default/xui/pl/panel_friends.xml
@@ -3,11 +3,11 @@
 	<string name="Multiple">
 		Znajomi
 	</string>
-	<scroll_list name="friend_list" tool_tip="By wybrać wielu znajomych za jednym razem przetrzymaj klawisz shift lub control">
+	<scroll_list name="friend_list" tool_tip="Aby wybrać wielu znajomych za jednym razem przetrzymaj klawisz Shift lub Control">
 		<column name="icon_online_status" tool_tip="Status dostępności"/>
 		<column label="ImiÄ™" name="friend_name" tool_tip="ImiÄ™"/>
 		<column name="icon_visible_online" tool_tip="Ta osoba może widzieć czy jesteś w Second Life"/>
-		<column name="icon_visible_map" tool_tip="Ta osoba może zlokalizować Cię na mapie"/>
+		<column name="icon_visible_map" tool_tip="Ta osoba może zlokalizować Ciebie na mapie"/>
 		<column name="icon_edit_mine" tool_tip="Ta osoba może edytować, usunąć lub wziąć Twoje obiekty"/>
 		<column name="icon_edit_theirs" tool_tip="Możesz edytować obiekty tej osoby"/>
 	</scroll_list>
diff --git a/indra/newview/skins/default/xui/pl/panel_group_control_panel.xml b/indra/newview/skins/default/xui/pl/panel_group_control_panel.xml
index b57ec8f2e69..4e373cdf8f7 100644
--- a/indra/newview/skins/default/xui/pl/panel_group_control_panel.xml
+++ b/indra/newview/skins/default/xui/pl/panel_group_control_panel.xml
@@ -8,10 +8,10 @@
 			<button label="Dzwoń" name="call_btn"/>
 		</layout_panel>
 		<layout_panel name="end_call_btn_panel">
-			<button label="Zakończ Rozmowę" name="end_call_btn"/>
+			<button label="Zakończ rozmowę" name="end_call_btn"/>
 		</layout_panel>
 		<layout_panel name="voice_ctrls_btn_panel">
-			<button label="Przełączniki Głosu" name="voice_ctrls_btn"/>
+			<button label="Przełączniki głosu" name="voice_ctrls_btn"/>
 		</layout_panel>
 	</layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_group_general.xml b/indra/newview/skins/default/xui/pl/panel_group_general.xml
index 43f0103ab78..a4d76badf0d 100644
--- a/indra/newview/skins/default/xui/pl/panel_group_general.xml
+++ b/indra/newview/skins/default/xui/pl/panel_group_general.xml
@@ -23,7 +23,7 @@ By otrzymać pomoc i dodatkowe wskazówki przesuń kursor na przyciski.
 		<button label="DOŁĄCZ TERAZ!" name="btn_join"/>
 	</panel>
 	<text_editor name="charter">
-		Status Grupy
+		Status grupy
 	</text_editor>
 	<name_list name="visible_members">
 		<name_list.columns label="Członek" name="name"/>
@@ -34,7 +34,7 @@ By otrzymać pomoc i dodatkowe wskazówki przesuń kursor na przyciski.
 		ja
 	</text>
 	<text name="active_title_label">
-		Mój Aktywny Tytuł:
+		Mój aktywny tytuł:
 	</text>
 	<combo_box name="active_title" tool_tip="Ustaw tytuł który wyświetla się kiedy grupa jest aktywna."/>
 	<check_box label="Otrzymuj grupowe ogłoszenia" name="receive_notices" tool_tip="Zaznacz jeżeli chcesz otrzymywać ogłoszenia z tej grupy.   Anuluj z zaznaczenia, jeżeli nie chcesz otrzymywać żadnych ogłoszeń z tej grupy."/>
@@ -50,8 +50,8 @@ By otrzymać pomoc i dodatkowe wskazówki przesuń kursor na przyciski.
 			<combo_item name="select_mature">
 				- Wybierz klasyfikacjÄ™ wieku -
 			</combo_item>
-			<combo_box.item label="Treść &apos;Mature&apos;" name="mature"/>
-			<combo_box.item label="Treść &apos;PG&apos;" name="pg"/>
+			<combo_box.item label="Treść &apos;Moderate&apos;" name="mature"/>
+			<combo_box.item label="Treść &apos;General&apos;" name="pg"/>
 		</combo_box>
 		<check_box initial_value="true" label="Wyświetlaj w wyszukiwarce" name="show_in_group_list" tool_tip="Udostępnij info o grupie w wyszukiwarce"/>
 	</panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_group_info_sidetray.xml b/indra/newview/skins/default/xui/pl/panel_group_info_sidetray.xml
index 509c2893cf4..e637588cf0b 100644
--- a/indra/newview/skins/default/xui/pl/panel_group_info_sidetray.xml
+++ b/indra/newview/skins/default/xui/pl/panel_group_info_sidetray.xml
@@ -27,9 +27,9 @@
 		</layout_panel>
 		<layout_panel name="button_row">
 			<button label="Czat" name="btn_chat"/>
-			<button label="Konferencja GÅ‚osowa" name="btn_call" tool_tip="Konferencja GÅ‚osowa"/>
+			<button label="Konferencja głosowa" name="btn_call" tool_tip="Konferencja głosowa"/>
 			<button label="Zapisz" label_selected="Zapisz" name="btn_apply"/>
-			<button label="Stwórz nową Grupę" name="btn_create" tool_tip="Stwórz nową Grupę"/>
+			<button label="Stwórz nową grupę" name="btn_create" tool_tip="Stwórz nową grupę"/>
 		</layout_panel>
 	</layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_group_invite.xml b/indra/newview/skins/default/xui/pl/panel_group_invite.xml
index e520c06944f..1822551e868 100644
--- a/indra/newview/skins/default/xui/pl/panel_group_invite.xml
+++ b/indra/newview/skins/default/xui/pl/panel_group_invite.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Zaproszenie do Grupy" name="invite_panel">
 	<panel.string name="confirm_invite_owner_str">
-		Jesteś pewny, że chcesz wybrać nowych właścieli grupy? Ta decyzja jest ostateczna!
+		Jesteś pewny/a, że chcesz wybrać nowych właścieli grupy? Ta decyzja jest ostateczna!
 	</panel.string>
 	<panel.string name="loading">
 		(Å‚adowanie...)
@@ -18,10 +18,10 @@
 	<text name="role_text">
 		Wybierz rolę dla nowego członka:
 	</text>
-	<combo_box name="role_name" tool_tip="Wybierz z listy Role, które możesz przypisać Członkom"/>
+	<combo_box name="role_name" tool_tip="Wybierz z listy Role, które możesz przypisać członkom"/>
 	<button label="Wyślij Zaproszenia" name="ok_button"/>
 	<button label="Anuluj" name="cancel_button"/>
 	<string name="GroupInvitation">
-		Zaproszenie do Grupy
+		Zaproszenie do grupy
 	</string>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_group_land_money.xml b/indra/newview/skins/default/xui/pl/panel_group_land_money.xml
index acceb887110..d29393de2dd 100644
--- a/indra/newview/skins/default/xui/pl/panel_group_land_money.xml
+++ b/indra/newview/skins/default/xui/pl/panel_group_land_money.xml
@@ -1,16 +1,16 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Posiadłości i L$" name="land_money_tab">
 	<panel.string name="help_text">
-		Ostrzeżenie pojawia się kiedy Łączna Powierzchnia Posiadłości jest mniejsza lub = Kontrybucjom
+		Ostrzeżenie pojawia się kiedy łączna powierzchnia posiadłości jest mniejsza lub = Kontrybucjom
 	</panel.string>
 	<panel.string name="cant_view_group_land_text">
-		Nie masz pozwolenia na oglądanie Posiadłości Grupy.
+		Nie masz pozwolenia na oglądanie posiadłości grupy.
 	</panel.string>
 	<panel.string name="epmty_view_group_land_text">
 		Brak wstępu
 	</panel.string>
 	<panel.string name="cant_view_group_accounting_text">
-		Nie masz dostępu do konta, finansów Grupy.
+		Nie masz dostępu do konta, finansów grupy.
 	</panel.string>
 	<panel.string name="loading_txt">
 		Ładowanie...
@@ -33,19 +33,19 @@
 		</text>
 		<button label="Mapa" label_selected="Mapa" name="map_button"/>
 		<text name="total_land_in_use_label">
-			Używane Posiadłości:
+			Używane posiadłości:
 		</text>
 		<text name="total_land_in_use_value">
 			[AREA] m²
 		</text>
 		<text name="land_available_label">
-			Dostępne Posiadłości:
+			Dostępne posiadłości:
 		</text>
 		<text name="land_available_value">
 			[AREA] m²
 		</text>
 		<text name="your_contribution_label">
-			Twoje Kontrybucje:
+			Twoje kontrybucje:
 		</text>
 		<text name="your_contribution_units">
 			m²
@@ -54,10 +54,10 @@
 			([AMOUNT] max)
 		</text>
 		<text name="group_over_limit_text">
-			Należy zwięszyć kredyt na używanie Posiadłości.
+			Należy zwięszyć kredyt na używanie posiadłości.
 		</text>
 		<text name="group_money_heading">
-			L$ Grupy
+			L$ grupy
 		</text>
 	</panel>
 	<tab_container name="group_money_tab_container">
diff --git a/indra/newview/skins/default/xui/pl/panel_group_notices.xml b/indra/newview/skins/default/xui/pl/panel_group_notices.xml
index 1d727148e9d..5b62d138804 100644
--- a/indra/newview/skins/default/xui/pl/panel_group_notices.xml
+++ b/indra/newview/skins/default/xui/pl/panel_group_notices.xml
@@ -19,11 +19,11 @@ Limit dzienny ogłoszeń dla grupy wynosi 200.
 	<text name="notice_list_none_found">
 		Nie znaleziono
 	</text>
-	<button label="Stwórz Ogłoszenie" label_selected="Stwórz Nowe Ogłoszenie" name="create_new_notice" tool_tip="Stwórz Ogłoszenie"/>
+	<button label="Stwórz Ogłoszenie" label_selected="Stwórz nowe ogłoszenie" name="create_new_notice" tool_tip="Stwórz ogłoszenie"/>
 	<button label="Odśwież" label_selected="Odśwież Listę" name="refresh_notices" tool_tip="Użyj Odśwież by zobaczyć czy nowe ogłoszenia zostały wysłane."/>
-	<panel label="Stwórz Nowe Ogłoszenie" name="panel_create_new_notice">
+	<panel label="Stwórz nowe ogłoszenie" name="panel_create_new_notice">
 		<text name="lbl">
-			Stwórz Ogłoszenie
+			Stwórz ogłoszenie
 		</text>
 		<text name="lbl3">
 			Temat:
@@ -55,6 +55,6 @@ Limit dzienny ogłoszeń dla grupy wynosi 200.
 		<text name="lbl4">
 			Treść:
 		</text>
-		<button label="Otwórz Załącznik" label_selected="Otwórz Załącznik" name="open_attachment"/>
+		<button label="Otwórz załącznik" label_selected="Otwórz załącznik" name="open_attachment"/>
 	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_group_notify.xml b/indra/newview/skins/default/xui/pl/panel_group_notify.xml
index d81c3f68f2b..d27a81217a4 100644
--- a/indra/newview/skins/default/xui/pl/panel_group_notify.xml
+++ b/indra/newview/skins/default/xui/pl/panel_group_notify.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="instant_message" name="panel_group_notify">
 	<panel label="header" name="header">
-		<text name="title" value="ImiÄ™ Nadawcy / Nazwa Grupy"/>
+		<text name="title" value="ImiÄ™ nadawcy / Nazwa grupy"/>
 	</panel>
 	<text name="attachment" value="Załącznik"/>
 	<button label="OK" name="btn_ok"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_group_roles.xml b/indra/newview/skins/default/xui/pl/panel_group_roles.xml
index 55266948639..9e9c79d26aa 100644
--- a/indra/newview/skins/default/xui/pl/panel_group_roles.xml
+++ b/indra/newview/skins/default/xui/pl/panel_group_roles.xml
@@ -9,20 +9,20 @@
 	<tab_container name="roles_tab_container">
 		<panel label="CZŁONKOWIE" name="members_sub_tab" tool_tip="Członkowie">
 			<panel.string name="help_text">
-				Możesz dodawać i usuwać Funkcje przypisane do Członków.
-Możesz wybrać wielu Członków naciskając Ctrl i klikając na ich imionach.
+				Możesz dodawać i usuwać funkcje przypisane do członków.
+Możesz wybrać wielu członków naciskając Ctrl i klikając na ich imionach.
 			</panel.string>
 			<panel.string name="donation_area">
 				[AREA] m²
 			</panel.string>
-			<filter_editor label="Filtruj Członków" name="filter_input"/>
+			<filter_editor label="Filtruj członków" name="filter_input"/>
 			<name_list name="member_list">
 				<name_list.columns label="Członek" name="name"/>
 				<name_list.columns label="Dotacje" name="donated"/>
 				<name_list.columns label="Status" name="online"/>
 			</name_list>
-			<button label="ZaproÅ› do Grupy" name="member_invite"/>
-			<button label="Usuń z Grupy" name="member_eject"/>
+			<button label="ZaproÅ› do grupy" name="member_invite"/>
+			<button label="Usuń z grupy" name="member_eject"/>
 		</panel>
 		<panel label="FUNKCJE" name="roles_sub_tab">
 			<panel.string name="help_text">
@@ -37,22 +37,22 @@ jedną lub wiele funkcji. Każda grupa może posiadać maksymalnie 10 funkcji,
 			<panel.string name="power_folder_icon">
 				Inv_FolderClosed
 			</panel.string>
-			<filter_editor label="Filtruj Funkcje" name="filter_input"/>
+			<filter_editor label="Filtruj funkcje" name="filter_input"/>
 			<scroll_list name="role_list">
 				<scroll_list.columns label="Funkcja" name="name"/>
 				<scroll_list.columns label="Tytuł" name="title"/>
 				<scroll_list.columns label="#" name="members"/>
 			</scroll_list>
-			<button label="Stwórz Nową Funkcję" name="role_create"/>
-			<button label="Usuń Funkcję" name="role_delete"/>
+			<button label="Stwórz nową funkcję" name="role_create"/>
+			<button label="Usuń funkcję" name="role_delete"/>
 		</panel>
 		<panel label="PRZYWILEJE" name="actions_sub_tab" tool_tip="Możesz sprawdzić szczegóły dotyczące dangego przywileju oraz jakie funkcje oraz jacy członkowie posiadają prawo korzystania z niego.">
 			<panel.string name="help_text">
-				Przywileje pozwalają Członkom przypisanym do Funkcji na wykonywanie różnych zadań.
-Istnieje wiele Przywilei.
+				Przywileje pozwalają członkom przypisanym do funkcji na wykonywanie różnych zadań.
+Istnieje wiele przywilejów.
 			</panel.string>
-			<filter_editor label="Filtruj Przywileje" name="filter_input"/>
-			<scroll_list name="action_list" tool_tip="Wybierz przywilej by zobaczyć szczegóły">
+			<filter_editor label="Filtruj przywileje" name="filter_input"/>
+			<scroll_list name="action_list" tool_tip="Wybierz przywilej aby zobaczyć szczegóły">
 				<scroll_list.columns label="" name="icon"/>
 				<scroll_list.columns label="" name="action"/>
 			</scroll_list>
@@ -69,18 +69,18 @@ Istnieje wiele Przywilei.
 		<text name="static2">
 			Przywileje
 		</text>
-		<scroll_list name="member_allowed_actions" tool_tip="By zobaczyć szczegóły, wybierz zakładkę Przywileje">
+		<scroll_list name="member_allowed_actions" tool_tip="Aby zobaczyć szczegóły, wybierz zakładkę Przywileje">
 			<scroll_list.columns label="" name="icon"/>
 			<scroll_list.columns label="" name="action"/>
 		</scroll_list>
 	</panel>
 	<panel name="roles_footer">
 		<text name="static">
-			Nazwa Funkcji
+			Nazwa funkcji
 		</text>
 		<line_editor name="role_name"/>
 		<text name="static3">
-			Nazwa Funkcji
+			Nazwa funkcji
 		</text>
 		<line_editor name="role_title"/>
 		<text name="static2">
@@ -88,13 +88,13 @@ Istnieje wiele Przywilei.
 		</text>
 		<text_editor name="role_description"/>
 		<text name="static4">
-			Przypisane Funkcje
+			Przypisane funkcje
 		</text>
-		<check_box label="Opcja widoczności jest aktywna" name="role_visible_in_list" tool_tip="Opcja ta pozwala określić widoczność członków pełniących tę funkcję dla ludzi spoza Grupy."/>
+		<check_box label="Opcja widoczności jest aktywna" name="role_visible_in_list" tool_tip="Opcja ta pozwala określić widoczność członków pełniących tę funkcję dla ludzi spoza grupy."/>
 		<text name="static5" tool_tip="Przywileje przypisane do wybranej Funkcji.">
-			Przypisane Przywileje
+			Przypisane przywileje
 		</text>
-		<scroll_list name="role_allowed_actions" tool_tip="By zobaczyć szczegóły dozwolonych przywilejów wybierz zakładkę Przywileje">
+		<scroll_list name="role_allowed_actions" tool_tip="Aby zobaczyć szczegóły dozwolonych przywilejów wybierz zakładkę Przywileje">
 			<scroll_list.columns label="" name="icon"/>
 			<scroll_list.columns label="" name="checkbox"/>
 			<scroll_list.columns label="" name="action"/>
@@ -102,7 +102,7 @@ Istnieje wiele Przywilei.
 	</panel>
 	<panel name="actions_footer">
 		<text_editor name="action_description">
-			Przywilej &apos;Usuń Członka z Grupy&apos;. Tylko Właściciel może usunąć innego Właściciela.
+			Przywilej &apos;Usuń członka z grupy&apos;. Tylko właściciel może usunąć innego właściciela.
 		</text_editor>
 		<text name="static2">
 			Funkcje z tym przywilejem
diff --git a/indra/newview/skins/default/xui/pl/panel_groups.xml b/indra/newview/skins/default/xui/pl/panel_groups.xml
index 9df90fc7971..671d8fd2f02 100644
--- a/indra/newview/skins/default/xui/pl/panel_groups.xml
+++ b/indra/newview/skins/default/xui/pl/panel_groups.xml
@@ -10,7 +10,7 @@
 		Należysz do [COUNT] grup (maksimum to [MAX]).
 	</text>
 	<button label="Czat/IM" name="IM" tool_tip="Rozpocznij sesjÄ™ czatu (IM)" />
-	<button label="O Grupie" name="Info" />
+	<button label="O grupie" name="Info" />
 	<button label="Wybierz" name="Activate" />
 	<button label="Opuść" name="Leave" />
 	<button label="Stwórz..." name="Create" />
diff --git a/indra/newview/skins/default/xui/pl/panel_im_control_panel.xml b/indra/newview/skins/default/xui/pl/panel_im_control_panel.xml
index 84d19824407..4aadd3b93b2 100644
--- a/indra/newview/skins/default/xui/pl/panel_im_control_panel.xml
+++ b/indra/newview/skins/default/xui/pl/panel_im_control_panel.xml
@@ -23,7 +23,7 @@
 			<button label="Zakończ rozmowę" name="end_call_btn"/>
 		</layout_panel>
 		<layout_panel name="voice_ctrls_btn_panel">
-			<button label="Przełączniki Głosu" name="voice_ctrls_btn"/>
+			<button label="Przełączniki głosu" name="voice_ctrls_btn"/>
 		</layout_panel>
 	</layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_landmark_info.xml b/indra/newview/skins/default/xui/pl/panel_landmark_info.xml
index 64479176fa1..3370f6f58eb 100644
--- a/indra/newview/skins/default/xui/pl/panel_landmark_info.xml
+++ b/indra/newview/skins/default/xui/pl/panel_landmark_info.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="landmark_info">
-	<string name="title_create_landmark" value="Zapamiętaj Miejsce"/>
-	<string name="title_edit_landmark" value="Edytuj Zapamiętane Miejsce"/>
-	<string name="title_landmark" value="Zapamiętane Miejsce (LM)"/>
+	<string name="title_create_landmark" value="Zapamiętaj miejsce (LM)"/>
+	<string name="title_edit_landmark" value="Edytuj landmarki"/>
+	<string name="title_landmark" value="Landmarki (LM)"/>
 	<string name="not_available" value="(N\A)"/>
 	<string name="unknown" value="(nieznane)"/>
 	<string name="public" value="(publiczne)"/>
@@ -19,7 +19,7 @@
 		[wkday,datetime,local] [mth,datetime,local] [day,datetime,local] [hour,datetime,local]:[min,datetime,local]:[second,datetime,local] [year,datetime,local]
 	</string>
 	<button name="back_btn" tool_tip="Cofnij"/>
-	<text name="title" value="Profil Miejsca"/>
+	<text name="title" value="Profil miejsca"/>
 	<scroll_container name="place_scroll">
 		<panel name="scrolling_panel">
 			<text name="maturity_value" value="nieznany"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_login.xml b/indra/newview/skins/default/xui/pl/panel_login.xml
index 5e4955c28c0..b5899f1009f 100644
--- a/indra/newview/skins/default/xui/pl/panel_login.xml
+++ b/indra/newview/skins/default/xui/pl/panel_login.xml
@@ -15,7 +15,7 @@
 			<text name="password_text">
 				Hasło:
 			</text>
-			<check_box label="Zapamiętaj Hasło" name="remember_check"/>
+			<check_box label="Zapamiętaj hasło" name="remember_check"/>
 			<button label="Połącz" name="connect_btn"/>
 			<text name="start_location_text">
 				Rozpocznij w:
diff --git a/indra/newview/skins/default/xui/pl/panel_media_settings_general.xml b/indra/newview/skins/default/xui/pl/panel_media_settings_general.xml
index 03b063ddfe2..914a2aee730 100644
--- a/indra/newview/skins/default/xui/pl/panel_media_settings_general.xml
+++ b/indra/newview/skins/default/xui/pl/panel_media_settings_general.xml
@@ -1,24 +1,24 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Ogólne" name="Media Settings General">
 	<text name="home_label">
-		Strona Domowa:
+		Strona domowa:
 	</text>
 	<text name="home_fails_whitelist_label">
-		(ta strona nie została zaakceptowana przez filtr listy dostępowej)
+		(ta strona nie została zaakceptowana przez filtr listy dostępowej (Biała Lista)
 	</text>
 	<line_editor name="home_url" tool_tip="Strona domowa dla źródla mediów"/>
 	<text name="preview_label">
 		Pokaż
 	</text>
 	<text name="current_url_label">
-		Obecna Strona:
+		Obecna strona:
 	</text>
 	<text name="current_url" tool_tip="The current page for this media source" value=""/>
 	<button label="Zresetuj" name="current_url_reset_btn"/>
 	<check_box initial_value="false" label="Pętla" name="auto_loop"/>
-	<check_box initial_value="false" label="Interakcja Kliknięcia" name="first_click_interact"/>
+	<check_box initial_value="false" label="Interakcja kliknięcia" name="first_click_interact"/>
 	<check_box initial_value="false" label="Autopowiększenie" name="auto_zoom"/>
-	<check_box initial_value="false" label="Automatyczne Odtwarzanie Mediów" name="auto_play"/>
+	<check_box initial_value="false" label="Automatyczne odtwarzanie mediów" name="auto_play"/>
 	<text name="media_setting_note">
 		Pamiętaj: Rezydenci mogą zmienić to ustawienie
 	</text>
diff --git a/indra/newview/skins/default/xui/pl/panel_media_settings_permissions.xml b/indra/newview/skins/default/xui/pl/panel_media_settings_permissions.xml
index 6b93981accb..a87c29d7b38 100644
--- a/indra/newview/skins/default/xui/pl/panel_media_settings_permissions.xml
+++ b/indra/newview/skins/default/xui/pl/panel_media_settings_permissions.xml
@@ -15,15 +15,15 @@
 		Właściciel
 	</text>
 	<check_box initial_value="false" label="Pozwól na nawigację &amp; interaktywność" name="perms_owner_interact"/>
-	<check_box initial_value="false" label="Pokaż Pasek Kontroli" name="perms_owner_control"/>
+	<check_box initial_value="false" label="Pokaż pasek kontroli" name="perms_owner_control"/>
 	<text name="group_label">
 		Grupa:
 	</text>
-	<check_box initial_value="false" label="Pozwól na nawigację &amp; Interaktywność" name="perms_group_interact"/>
-	<check_box initial_value="false" label="Pokaż Pasek Kontroli" name="perms_group_control"/>
+	<check_box initial_value="false" label="Pozwól na nawigację &amp; interaktywność" name="perms_group_interact"/>
+	<check_box initial_value="false" label="Pokaż pasek kontroli" name="perms_group_control"/>
 	<text name="anyone_label">
 		Każdy
 	</text>
 	<check_box initial_value="false" label="Pozwól na nawigację &amp; interaktywność" name="perms_anyone_interact"/>
-	<check_box initial_value="false" label="Pokaż Pasek Kontroli" name="perms_anyone_control"/>
+	<check_box initial_value="false" label="Pokaż pasek kontroli" name="perms_anyone_control"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_my_profile.xml b/indra/newview/skins/default/xui/pl/panel_my_profile.xml
index 7ca762b8257..fefab15af06 100644
--- a/indra/newview/skins/default/xui/pl/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/pl/panel_my_profile.xml
@@ -10,11 +10,11 @@
 			<scroll_container name="profile_scroll">
 				<panel name="scroll_content_panel">
 					<panel name="second_life_image_panel">
-						<icon label="" name="2nd_life_edit_icon" tool_tip="Kliknij przycisk Edytuj Profil by zmienić zdjęcie"/>
+						<icon label="" name="2nd_life_edit_icon" tool_tip="Kliknij przycisk Edytuj profil by zmienić zdjęcie"/>
 						<text name="title_sl_descr_text" value="[SECOND_LIFE]:"/>
 					</panel>
 					<panel name="first_life_image_panel">
-						<icon label="" name="real_world_edit_icon" tool_tip="Kliknij przycisk Edytuj Profil by zmienić zdjęcie"/>
+						<icon label="" name="real_world_edit_icon" tool_tip="Kliknij przycisk Edytuj profil by zmienić zdjęcie"/>
 						<text name="title_rw_descr_text" value="Życie#1:"/>
 					</panel>
 					<text name="title_member_text" value="Urodziny:"/>
@@ -28,8 +28,8 @@
 			</scroll_container>
 		</layout_panel>
 		<layout_panel name="profile_me_buttons_panel">
-			<button label="Edytuj Profil" name="edit_profile_btn" tool_tip="Edytuj swoje dane"/>
-			<button label="Edytuj Wygląd" name="edit_appearance_btn" tool_tip="Stwórz/edytuj swój wygląd: dane fizyczne, ubrania itp."/>
+			<button label="Edytuj profil" name="edit_profile_btn" tool_tip="Edytuj swoje dane"/>
+			<button label="Edytuj wygląd" name="edit_appearance_btn" tool_tip="Stwórz/edytuj swój wygląd: dane fizyczne, ubrania itp."/>
 		</layout_panel>
 	</layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_nearby_chat_bar.xml b/indra/newview/skins/default/xui/pl/panel_nearby_chat_bar.xml
index 2d1decd9604..63cf96b5710 100644
--- a/indra/newview/skins/default/xui/pl/panel_nearby_chat_bar.xml
+++ b/indra/newview/skins/default/xui/pl/panel_nearby_chat_bar.xml
@@ -7,5 +7,5 @@
 		320
 	</string>
 	<line_editor label="Kliknij tutaj aby rozmawiać." name="chat_box" tool_tip="Naciśnij Enter aby mówić, Ctrl + Enter aby krzyknąć"/>
-	<button name="show_nearby_chat" tool_tip="Pokazuje/ukrywa pobliski Czat"/>
+	<button name="show_nearby_chat" tool_tip="Pokazuje/ukrywa pobliski czat"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_nearby_media.xml b/indra/newview/skins/default/xui/pl/panel_nearby_media.xml
index a78ab4d6f83..c9f951f7c6a 100644
--- a/indra/newview/skins/default/xui/pl/panel_nearby_media.xml
+++ b/indra/newview/skins/default/xui/pl/panel_nearby_media.xml
@@ -7,10 +7,10 @@
 		&lt;empty&gt;
 	</string>
 	<string name="parcel_media_name">
-		Strumień Mediów Posiadłości
+		Strumień mediów posiadłości
 	</string>
 	<string name="parcel_audio_name">
-		Strumień Audio Posiadłości
+		Strumień audio posiadłości
 	</string>
 	<string name="playing_suffix">
 		(odtwarzanie)
@@ -31,8 +31,8 @@
 		</text>
 		<combo_box name="show_combo">
 			<combo_box.item label="Wszystkie" name="All"/>
-			<combo_box.item label="Na obecnej Parceli" name="WithinParcel"/>
-			<combo_box.item label="Poza Posiadłością" name="OutsideParcel"/>
+			<combo_box.item label="Na obecnej posiadłości" name="WithinParcel"/>
+			<combo_box.item label="Poza posiadłością" name="OutsideParcel"/>
 			<combo_box.item label="Na innych awatarach" name="OnOthers"/>
 		</combo_box>
 		<scroll_list name="media_list">
diff --git a/indra/newview/skins/default/xui/pl/panel_outfit_edit.xml b/indra/newview/skins/default/xui/pl/panel_outfit_edit.xml
index 2c5e2a3f612..31502cccba5 100644
--- a/indra/newview/skins/default/xui/pl/panel_outfit_edit.xml
+++ b/indra/newview/skins/default/xui/pl/panel_outfit_edit.xml
@@ -30,7 +30,7 @@
 					<button label="Dodaj..." name="show_add_wearables_btn" tool_tip="Otwórz/Zamknij"/>
 				</layout_panel>
 				<layout_panel name="filter_panel">
-					<filter_editor label="Filtruj częśći stroju w Szafie" name="look_item_filter"/>
+					<filter_editor label="Filtruj części stroju w Szafie" name="look_item_filter"/>
 				</layout_panel>
 			</layout_stack>
 		</layout_panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_outfits_inventory_gear_default.xml b/indra/newview/skins/default/xui/pl/panel_outfits_inventory_gear_default.xml
index 5b77c390ca0..2f8c008f98e 100644
--- a/indra/newview/skins/default/xui/pl/panel_outfits_inventory_gear_default.xml
+++ b/indra/newview/skins/default/xui/pl/panel_outfits_inventory_gear_default.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="menu_gear_default">
-	<menu_item_call label="ZastÄ…p Obecne Ubranie" name="wear"/>
-	<menu_item_call label="Dodaj do Obecnego Ubrania" name="add"/>
-	<menu_item_call label="Usuń z Obecnego Ubrania" name="remove"/>
+	<menu_item_call label="Zastąp obecny strój" name="wear"/>
+	<menu_item_call label="Dodaj do obecnego stroju" name="add"/>
+	<menu_item_call label="Usuń z obecnego stroju" name="remove"/>
 	<menu_item_call label="Zmień nazwę" name="rename"/>
-	<menu_item_call label="Usuń Link" name="remove_link"/>
-	<menu_item_call label="Usuń Ubranie" name="delete"/>
+	<menu_item_call label="Usuń link" name="remove_link"/>
+	<menu_item_call label="Usuń strój" name="delete"/>
 </menu>
diff --git a/indra/newview/skins/default/xui/pl/panel_people.xml b/indra/newview/skins/default/xui/pl/panel_people.xml
index 50fc0ba8af6..19df36c9ee9 100644
--- a/indra/newview/skins/default/xui/pl/panel_people.xml
+++ b/indra/newview/skins/default/xui/pl/panel_people.xml
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <!-- Side tray panel -->
 <panel label="Ludzie" name="people_panel">
-	<string name="no_recent_people" value="Brak ostatnich rozmówców. Chcesz spotkać ludzi? Spróbuj [secondlife:///app/search/people Search] or the [secondlife:///app/worldmap Mapa Świata]."/>
+	<string name="no_recent_people" value="Brak ostatnich rozmówców. Chcesz spotkać ludzi? Spróbuj [secondlife:///app/search/people Szukaj] or the [secondlife:///app/worldmap Mapa Świata]."/>
 	<string name="no_filtered_recent_people" value="Nie znaleziono tego czego szukasz? Spróbuj [secondlife:///app/search/groups/[SEARCH_TERM] Szukaj]."/>
-	<string name="no_one_near" value="Nie ma nikogo w pobliżu. Chcesz spotkać ludzi? Spróbuj[secondlife:///app/search/people Search] lub [secondlife:///app/worldmap Mapa Świata]."/>
+	<string name="no_one_near" value="Nie ma nikogo w pobliżu. Chcesz spotkać ludzi? Spróbuj [secondlife:///app/search/people Szukaj] lub [secondlife:///app/worldmap Mapa Świata]."/>
 	<string name="no_one_filtered_near" value="Nie znaleziono tego czego szukasz? Spróbuj [secondlife:///app/search/groups/[SEARCH_TERM] Szukaj]."/>
-	<string name="no_friends_online" value="Brak dostępnych Znajomych"/>
-	<string name="no_friends" value="Brak Znajomych"/>
+	<string name="no_friends_online" value="Brak dostępnych znajomych"/>
+	<string name="no_friends" value="Brak znajomych"/>
 	<string name="no_friends_msg">
 		Wyszukaj znajomych [secondlife:///app/search/people Szukaj] lub kliknij prawym przyciskiem na Rezydenta aby zaproponować mu znajomość.
 Chcesz spotkać ludzi? Spróbuj [secondlife:///app/worldmap Mapa Świata].
@@ -14,8 +14,8 @@ Chcesz spotkać ludzi? Spróbuj [secondlife:///app/worldmap Mapa Świata].
 	<string name="no_filtered_friends_msg">
 		Nie znaleziono tego czego szukasz? Spróbuj [secondlife:///app/search/groups/[SEARCH_TERM] Szukaj].
 	</string>
-	<string name="people_filter_label" value="Filtruj Ludzi"/>
-	<string name="groups_filter_label" value="Filtruj Grupy"/>
+	<string name="people_filter_label" value="Filtruj ludzi"/>
+	<string name="groups_filter_label" value="Filtruj grupy"/>
 	<string name="no_filtered_groups_msg" value="Nie znaleziono tego czego szukasz? Spróbuj [secondlife:///app/search/groups/[SEARCH_TERM] Szukaj]."/>
 	<string name="no_groups_msg" value="Chcesz dołączyć do grup? Spróbuj [secondlife:///app/search/groups Szukaj]."/>
 	<filter_editor label="Filtr" name="filter_input"/>
@@ -23,7 +23,7 @@ Chcesz spotkać ludzi? Spróbuj [secondlife:///app/worldmap Mapa Świata].
 		<panel label="W POBLIŻU" name="nearby_panel">
 			<panel label="bottom_panel" name="bottom_panel">
 				<button name="nearby_view_sort_btn" tool_tip="Opcje"/>
-				<button name="add_friend_btn" tool_tip="Dodaj wybranego Rezydenta do Znajomych"/>
+				<button name="add_friend_btn" tool_tip="Dodaj wybranego Rezydenta do znajomych"/>
 			</panel>
 		</panel>
 		<panel label="ZNAJOMI" name="friends_panel">
@@ -47,7 +47,7 @@ Chcesz spotkać ludzi? Spróbuj [secondlife:///app/worldmap Mapa Świata].
 		<panel label="OSTATNIE" name="recent_panel">
 			<panel label="bottom_panel" name="bottom_panel">
 				<button name="recent_viewsort_btn" tool_tip="Opcje"/>
-				<button name="add_friend_btn" tool_tip="Dodaj wybranego Rezydenta do Znajomych"/>
+				<button name="add_friend_btn" tool_tip="Dodaj wybranego Rezydenta do znajomych"/>
 			</panel>
 		</panel>
 	</tab_container>
@@ -59,6 +59,6 @@ Chcesz spotkać ludzi? Spróbuj [secondlife:///app/worldmap Mapa Świata].
 		<button label="Teleportuj" name="teleport_btn" tool_tip="Zaproponuj teleportacjÄ™" width="70"/>
 		<button label="Profil grupy" name="group_info_btn" tool_tip="Pokaż informacje o grupie" width="69"/>
 		<button label="Konferencja Grupowa" name="chat_btn" tool_tip="Rozpocznij konferencÄ™" width="124"/>
-		<button label="Rozmowa GÅ‚osowa" name="group_call_btn" tool_tip="Rozmowa GÅ‚osowa w tej Grupie" width="108"/>
+		<button label="Rozmowa Głosowa" name="group_call_btn" tool_tip="Rozmowa głosowa w tej grupie" width="108"/>
 	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_place_profile.xml b/indra/newview/skins/default/xui/pl/panel_place_profile.xml
index 3714a141db8..7a71a100349 100644
--- a/indra/newview/skins/default/xui/pl/panel_place_profile.xml
+++ b/indra/newview/skins/default/xui/pl/panel_place_profile.xml
@@ -11,8 +11,8 @@
 	<string name="unknown" value="(nieznany)"/>
 	<string name="public" value="(publiczny)"/>
 	<string name="none_text" value="(żaden)"/>
-	<string name="sale_pending_text" value="(Sprzedaż w Toku Realizacji)"/>
-	<string name="group_owned_text" value="(Własność Grupy)"/>
+	<string name="sale_pending_text" value="(Sprzedaż w toku realizacji)"/>
+	<string name="group_owned_text" value="(Własność grupy)"/>
 	<string name="price_text" value="L$"/>
 	<string name="area_text" value="m²"/>
 	<string name="all_residents_text" value="Każdemu"/>
@@ -52,7 +52,7 @@
 					<panel name="parcel_characteristics_panel">
 						<text name="rating_label" value="Rodzaj:"/>
 						<text name="rating_value" value="nieznane"/>
-						<text name="voice_label" value="Komunikacja GÅ‚osowa:"/>
+						<text name="voice_label" value="Komunikacja głosowa:"/>
 						<text name="voice_value" value="WÅ‚Ä…czone"/>
 						<text name="fly_label" value="Lataj:"/>
 						<text name="fly_value" value="WÅ‚Ä…czone"/>
@@ -92,7 +92,7 @@
 						<text name="covenant_label" value="Umowa:"/>
 					</panel>
 				</accordion_tab>
-				<accordion_tab name="sales_tab" title="Na Sprzedaż">
+				<accordion_tab name="sales_tab" title="Na sprzedaż">
 					<panel name="sales_panel">
 						<text name="sales_price_label" value="Cena:"/>
 						<text name="area_label" value="Powierzchnia:"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_advanced.xml b/indra/newview/skins/default/xui/pl/panel_preferences_advanced.xml
index de4fa10b731..b267610d333 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_advanced.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_advanced.xml
@@ -16,9 +16,9 @@
 	<check_box initial_value="prawda" label="Schowek" name="appearance_sidebar_positioning" tool_tip="Użyj automatycznego pozycjonowania kamery dla schowka"/>
 	<check_box label="Pokaż w trybie widoku panoramicznego" name="first_person_avatar_visible"/>
 	<check_box label="Aktywacja klawiszy strzałek do poruszania awatarem" name="arrow_keys_move_avatar_check"/>
-	<check_box label="kliknij-kliknij-przytrzymaj, aby uruchomić" name="tap_tap_hold_to_run"/>
+	<check_box label="Kliknij-kliknij-przytrzymaj, aby uruchomić" name="tap_tap_hold_to_run"/>
 	<check_box label="Poruszaj ustami awatara kiedy używana jest komunikacja głosowa" name="enable_lip_sync"/>
-	<check_box label="Czat Chmurkowy" name="bubble_text_chat"/>
+	<check_box label="Czat chmurkowy" name="bubble_text_chat"/>
 	<slider label="Intensywność" name="bubble_chat_opacity"/>
 	<color_swatch name="background" tool_tip="Wybierz kolor czatu w chmurce"/>
 	<text name="UI Size:">
@@ -31,7 +31,7 @@
 	</radio_group>
 	<check_box label="Włącz/Wyłącz głos:" name="push_to_talk_toggle_check" tool_tip="Jeżeli jesteś w trybie mówienia, w celu aktywacji lub deaktywacji swojego mikrofonu wybierz i wyłącz przycisk Mów tylko raz. Jeżeli nie jesteś w trybie mówienia, mikrofon przesyła Twój głos tylko w momencie aktywacji pełnej przycisku Mów."/>
 	<line_editor label="Naciśnij Mów by rozpocząć komunikację głosową" name="modifier_combo"/>
-	<button label="wybierz Klawisz" name="set_voice_hotkey_button"/>
-	<button label="Środkowy Przycisk Myszki" name="set_voice_middlemouse_button" tool_tip="Zresetuj do środkowego przycisku myszy"/>
+	<button label="Wybierz klawisz" name="set_voice_hotkey_button"/>
+	<button label="Środkowy przycisk myszki" name="set_voice_middlemouse_button" tool_tip="Zresetuj do środkowego przycisku myszy"/>
 	<button label="Inne urzÄ…dzenia" name="joystick_setup_button"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_alerts.xml b/indra/newview/skins/default/xui/pl/panel_preferences_alerts.xml
index e843342aa2b..d53a99e8c10 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_alerts.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_alerts.xml
@@ -4,7 +4,7 @@
 		Powiadom mnie:
 	</text>
 	<check_box label="Kiedy wydajÄ™ lub otrzymujÄ™ L$" name="notify_money_change_checkbox"/>
-	<check_box label="Kiedy moi Znajomi zalogowujÄ… siÄ™ i wylogowujÄ…" name="friends_online_notify_checkbox"/>
+	<check_box label="Kiedy moi znajomi zalogowujÄ… siÄ™ i wylogowujÄ…" name="friends_online_notify_checkbox"/>
 	<text name="show_label">
 		Zawsze pokazuj:
 	</text>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_general.xml b/indra/newview/skins/default/xui/pl/panel_preferences_general.xml
index e7134f23c33..69686bcdbc2 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_general.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_general.xml
@@ -24,16 +24,16 @@
 	</text>
 	<text name="maturity_desired_textbox"/>
 	<combo_box name="maturity_desired_combobox">
-		<combo_box.item label="&apos;PG&apos;, &apos;Mature&apos; oraz &apos;Adult&apos;" name="Desired_Adult"/>
-		<combo_box.item label="&apos;PG&apos; i &apos;Mature&apos;" name="Desired_Mature"/>
-		<combo_box.item label="&apos;PG&apos;" name="Desired_PG"/>
+		<combo_box.item label="&apos;General&apos;, &apos;Mature&apos; oraz &apos;Adult&apos;" name="Desired_Adult"/>
+		<combo_box.item label="&apos;General&apos; i &apos;Mature&apos;" name="Desired_Mature"/>
+		<combo_box.item label="&apos;General&apos;" name="Desired_PG"/>
 	</combo_box>
 	<text name="start_location_textbox">
 		Miejsce Startu:
 	</text>
 	<combo_box name="start_location_combo">
-		<combo_box.item label="Ostatnie Miejsce" name="MyLastLocation" tool_tip="Domyślnie loguj mnie do ostatnio odwiedzonego miejsca."/>
-		<combo_box.item label="Mój Start" name="MyHome" tool_tip="Domyślnie loguj mnie do mojego miejsca startu."/>
+		<combo_box.item label="Ostatnie Miejsce" name="MyLastLocation" tool_tip="Domyślnie loguj mnie w ostatnio odwiedzonym miejscu."/>
+		<combo_box.item label="Mój Start" name="MyHome" tool_tip="Domyślnie loguj mnie w moim Miejscu Startu."/>
 	</combo_box>
 	<check_box initial_value="true" label="Pokaż przy zalogowaniu" name="show_location_checkbox"/>
 	<text name="name_tags_textbox">
@@ -45,8 +45,8 @@
 		<radio_item label="Pokaż w skrócie" name="radio3" value="2"/>
 	</radio_group>
 	<check_box label="Wyświetl moje imię:" name="show_my_name_checkbox1"/>
-	<check_box initial_value="true" label="Używaj Małych Imion Awatarów" name="small_avatar_names_checkbox"/>
-	<check_box label="Wyświetl Tytuł Grupowy" name="show_all_title_checkbox1"/>
+	<check_box initial_value="true" label="Używaj małych imion awatarów" name="small_avatar_names_checkbox"/>
+	<check_box label="Wyświetl tytuł grupowy" name="show_all_title_checkbox1"/>
 	<text name="effects_color_textbox">
 		Kolor moich efektów:
 	</text>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml
index 99b3074fcb3..e60d540066d 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml
@@ -26,23 +26,23 @@
 		<text name="ShadersText">
 			Cieniowanie pixeli (shadery):
 		</text>
-		<check_box initial_value="true" label="Mapowanie Wypukłości i Połysk" name="BumpShiny"/>
-		<check_box initial_value="true" label="Podstawowe Shadery" name="BasicShaders" tool_tip="Wyłączenie tej opcji może naprawić błędy niektórych sterowników graficznych."/>
-		<check_box initial_value="true" label="Shadery Atmosfery" name="WindLightUseAtmosShaders"/>
+		<check_box initial_value="true" label="Mapowanie wypukłości i połysk" name="BumpShiny"/>
+		<check_box initial_value="true" label="Podstawowe shadery" name="BasicShaders" tool_tip="Wyłączenie tej opcji może naprawić błędy niektórych sterowników graficznych."/>
+		<check_box initial_value="true" label="Shadery atmosfery" name="WindLightUseAtmosShaders"/>
 		<check_box initial_value="true" label="Refleksy w wodzie" name="Reflections"/>
 		<text name="ReflectionDetailText">
 			Ustawienia refleksów:
 		</text>
 		<radio_group name="ReflectionDetailRadio">
 			<radio_item label="Teren i drzewa" name="0"/>
-			<radio_item label="Obiekty Statyczne" name="1"/>
-			<radio_item label="Awatary i Obiekty" name="2"/>
+			<radio_item label="Obiekty statyczne" name="1"/>
+			<radio_item label="Awatary i obiekty" name="2"/>
 			<radio_item label="Wszystko" name="3"/>
 		</radio_group>
 		<text name="AvatarRenderingText">
 			Rendering awatarów
 		</text>
-		<check_box initial_value="true" label="Impostoryzacja Awatarowa" name="AvatarImpostors"/>
+		<check_box initial_value="true" label="Impostoryzacja awatarowa" name="AvatarImpostors"/>
 		<check_box initial_value="true" label="Rendering awatara przez GPU" name="AvatarVertexProgram"/>
 		<check_box initial_value="true" label="Oddzielne warstwy ubrań" name="AvatarCloth"/>
 		<slider label="Pole widzenia:" name="DrawDistance"/>
@@ -51,7 +51,7 @@
 		</text>
 		<slider label="Liczba czÄ…steczek:" name="MaxParticleCount"/>
 		<slider label="Max. # awatarów bez impostoryzacji:" name="MaxNumberAvatarDrawn"/>
-		<slider label="Jakość Post-Procesu:" name="RenderPostProcess"/>
+		<slider label="Jakość post-procesu:" name="RenderPostProcess"/>
 		<text name="MeshDetailText">
 			Szczególy obiektów:
 		</text>
@@ -87,7 +87,7 @@
 		</text>
 		<radio_group name="LightingDetailRadio">
 			<radio_item label="Tylko Słońce i Księżyc" name="SunMoon" value="0"/>
-			<radio_item label="Tylko Bliskie Światła" name="LocalLights" value="1"/>
+			<radio_item label="Tylko bliskie światła" name="LocalLights" value="1"/>
 		</radio_group>
 		<text name="TerrainDetailText">
 			Szczegóły terenu:
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/pl/panel_preferences_privacy.xml
index 9504019f791..fd9cdd6ff0a 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_privacy.xml
@@ -10,7 +10,7 @@
 	<check_box label="Mój status online jest dostępny tylko dla znajomych i grup do których należę" name="online_visibility"/>
 	<check_box label="Możliwość wysyłania wiadomości prywatnej (IM) oraz rozmowy głosowej tylko dla znajomych i grup do których należę" name="voice_call_friends_only_check"/>
 	<check_box label="Wyłącz mikrofon po zakończeniu rozmowy głosowej" name="auto_disengage_mic_check"/>
-	<check_box label="Akceptuj Ciasteczka" name="cookies_enabled"/>
+	<check_box label="Akceptuj ciasteczka" name="cookies_enabled"/>
 	<text name="Logs:">
 		Logi:
 	</text>
@@ -21,5 +21,5 @@
 		Lokalizacja zapisu:
 	</text>
 	<button label="PrzeglÄ…daj" label_selected="PrzeglÄ…daj" name="log_path_button"/>
-	<button label="Lista Zablokowanych" name="block_list"/>
+	<button label="Lista zablokowanych" name="block_list"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_setup.xml b/indra/newview/skins/default/xui/pl/panel_preferences_setup.xml
index 98fdffeb50d..b6578d21cad 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_setup.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_setup.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Ustawienia" name="Input panel">
-	<button label="Ustawienia Joysticka" name="joystick_setup_button"/>
+	<button label="Ustawienia joysticka" name="joystick_setup_button"/>
 	<text name="Mouselook:">
 		Widok panoramiczny:
 	</text>
 	<text name=" Mouse Sensitivity">
-		Czułość Myszki
+		Czułość myszki
 	</text>
 	<slider name="mouse_sensitivity"/>
 	<check_box label="Zmień klawisze myszki" name="invert_mouse"/>
@@ -41,9 +41,9 @@
 	<check_box label="Zezwalaj na wtyczki" name="browser_plugins_enabled"/>
 	<check_box label="Akceptuj ciasteczka z Internetu" name="cookies_enabled"/>
 	<check_box label="Zezwalaj na Javascript" name="browser_javascript_enabled"/>
-	<check_box label="Używaj Serwera Proxy" name="web_proxy_enabled"/>
+	<check_box label="Używaj serwera proxy" name="web_proxy_enabled"/>
 	<text name="Proxy location">
-		Lokalizacja Proxy:
+		Lokalizacja proxy:
 	</text>
 	<line_editor name="web_proxy_editor" tool_tip="Nazwa lub IP proxy, którego chcesz użyć"/>
 	<spinner label="Numer portu:" name="web_proxy_port"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_sound.xml b/indra/newview/skins/default/xui/pl/panel_preferences_sound.xml
index b0d02179fd4..eaf9ae809b3 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_sound.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_sound.xml
@@ -9,22 +9,22 @@
 	<check_box label="Odtwarzaj media audio" name="music_enabled"/>
 	<slider label="Media" name="Media Volume"/>
 	<check_box label="Odtwarzaj media" name="enable_media"/>
-	<slider label="Komunikacja GÅ‚osowa" name="Voice Volume"/>
+	<slider label="Komunikacja głosowa" name="Voice Volume"/>
 	<check_box label="Pozwól na rozmowy głosowe" name="enable_voice_check"/>
-	<check_box label="Automatycznie odtwarzaj media" name="media_auto_play_btn" tool_tip="Zaznacz tę funkcję by uruchomić automatyczne uruchamianie mediów" value="true"/>
+	<check_box label="Automatycznie odtwarzaj media" name="media_auto_play_btn" tool_tip="Zaznacz tę funkcję aby uruchomić automatyczne uruchamianie mediów" value="true"/>
 	<check_box label="Uruchom media załączone do innych awatarów" name="media_show_on_others_btn" tool_tip="Odznacz tę funkcję by ukryć media załączone to awatarów w publiżu" value="true"/>
 	<text name="voice_chat_settings">
-		Ustawienia Komunikacji GÅ‚osowej
+		Ustawienia komunikacji głosowej
 	</text>
 	<text name="Listen from">
 		Odtwarzaj z:
 	</text>
 	<radio_group name="ear_location">
-		<radio_item label="Pozycji kamery" name="0"/>
-		<radio_item label="Pozycji Awatara" name="1"/>
+		<radio_item label="pozycji kamery" name="0"/>
+		<radio_item label="pozycji awatara" name="1"/>
 	</radio_group>
-	<button label="Wejściowe/Wyjściowe Urządzenia" name="device_settings_btn"/>
-	<panel label="Ustawienia Sprzętowe" name="device_settings_panel">
+	<button label="Wejściowe/Wyjściowe urządzenia" name="device_settings_btn"/>
+	<panel label="Ustawienia sprzętowe" name="device_settings_panel">
 		<panel.string name="default_text">
 			Domyślne
 		</panel.string>
diff --git a/indra/newview/skins/default/xui/pl/panel_prim_media_controls.xml b/indra/newview/skins/default/xui/pl/panel_prim_media_controls.xml
index f10ce5ea4d0..a1a9be92426 100644
--- a/indra/newview/skins/default/xui/pl/panel_prim_media_controls.xml
+++ b/indra/newview/skins/default/xui/pl/panel_prim_media_controls.xml
@@ -25,7 +25,7 @@
 			<button name="fwd_btn" tool_tip="Przejdź do następnego"/>
 		</layout_panel>
 		<layout_panel name="home">
-			<button name="home_btn" tool_tip="Strona Domowa"/>
+			<button name="home_btn" tool_tip="Strona domowa"/>
 		</layout_panel>
 		<layout_panel name="media_stop">
 			<button name="media_stop_btn" tool_tip="Zatrzymaj media"/>
@@ -37,13 +37,13 @@
 			<button name="stop_btn" tool_tip="Zatrzymaj wczytywanie"/>
 		</layout_panel>
 		<layout_panel name="play">
-			<button name="play_btn" tool_tip="Odtwarzaj Media"/>
+			<button name="play_btn" tool_tip="Odtwarzaj media"/>
 		</layout_panel>
 		<layout_panel name="pause">
 			<button name="pause_btn" tool_tip="Wstrzymaj media"/>
 		</layout_panel>
 		<layout_panel name="media_address">
-			<line_editor name="media_address_url" tool_tip="URL Mediów"/>
+			<line_editor name="media_address_url" tool_tip="URL mediów"/>
 			<layout_stack name="media_address_url_icons">
 				<layout_panel>
 					<icon name="media_whitelist_flag" tool_tip="Biała Lista aktywna"/>
@@ -63,14 +63,14 @@
 			<button name="skip_forward_btn" tool_tip="Przewiń do przodu"/>
 		</layout_panel>
 		<layout_panel name="media_volume">
-			<button name="media_mute_button" tool_tip="Wycisz Media"/>
-			<slider name="volume_slider" tool_tip="Głośność Mediów"/>
+			<button name="media_mute_button" tool_tip="Wycisz media"/>
+			<slider name="volume_slider" tool_tip="Głośność mediów"/>
 		</layout_panel>
 		<layout_panel name="zoom_frame">
 			<button name="zoom_frame_btn" tool_tip="Przybliż do mediów"/>
 		</layout_panel>
 		<layout_panel name="close">
-			<button name="close_btn" tool_tip="Oddal"/>
+			<button name="close_btn" tool_tip="Oddal od mediów"/>
 		</layout_panel>
 		<layout_panel name="new_window">
 			<button name="new_window_btn" tool_tip="Otwórz URL w przeglądarce"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_profile.xml b/indra/newview/skins/default/xui/pl/panel_profile.xml
index 766ed948227..97c2fdd417b 100644
--- a/indra/newview/skins/default/xui/pl/panel_profile.xml
+++ b/indra/newview/skins/default/xui/pl/panel_profile.xml
@@ -34,8 +34,8 @@
 			<button label="▼" name="overflow_btn" tool_tip="Zapłać lub udostępnij obiekty Rezydentowi"/>
 		</layout_panel>
 		<layout_panel name="profile_me_buttons_panel">
-			<button label="Edytuj Profil" name="edit_profile_btn" tool_tip="Edytuj swoje dane"/>
-			<button label="Edytuj Wygląd" name="edit_appearance_btn" tool_tip="Stwórz/edytuj swój wygląd: dane fizyczne, ubranie..."/>
+			<button label="Edytuj profil" name="edit_profile_btn" tool_tip="Edytuj swoje dane"/>
+			<button label="Edytuj wygląd" name="edit_appearance_btn" tool_tip="Stwórz/edytuj swój wygląd: dane fizyczne, ubranie..."/>
 		</layout_panel>
 	</layout_stack>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_region_covenant.xml b/indra/newview/skins/default/xui/pl/panel_region_covenant.xml
index 2b37dd96b72..932e3631abf 100644
--- a/indra/newview/skins/default/xui/pl/panel_region_covenant.xml
+++ b/indra/newview/skins/default/xui/pl/panel_region_covenant.xml
@@ -19,7 +19,7 @@
 		Umowa:
 	</text>
 	<text name="covenant_timestamp_text">
-		Ostatnia Modyfikacja Wed Dec 31 16:00:00 1969
+		Ostatnia modyfikacja Wed Dec 31 16:00:00 1969
 	</text>
 	<button label="?" name="covenant_help"/>
 	<text_editor name="covenant_editor">
diff --git a/indra/newview/skins/default/xui/pl/panel_region_estate.xml b/indra/newview/skins/default/xui/pl/panel_region_estate.xml
index a7962747387..1b64827725a 100644
--- a/indra/newview/skins/default/xui/pl/panel_region_estate.xml
+++ b/indra/newview/skins/default/xui/pl/panel_region_estate.xml
@@ -29,10 +29,10 @@
 	<check_box label="Rezydenci, którzy dokonali weryfikacji wieku" name="limit_age_verified" tool_tip="Zbanuj Rezydentów, którzy nie zweryfikowali swojego wieku. Odwiedź stronę [SUPPORT_SITE] po więcej informacji."/>
 	<check_box label="Rozmowy dozwolone" name="voice_chat_check"/>
 	<button label="?" name="voice_chat_help"/>
-	<check_box label="Teleportacja Dozwolona" name="allow_direct_teleport"/>
+	<check_box label="Teleportacja dozwolona" name="allow_direct_teleport"/>
 	<button label="?" name="allow_direct_teleport_help"/>
 	<text name="abuse_email_text">
-		Email reporty o nadużyciach do:
+		Wysyłaj (email) reporty o nadużyciach do:
 	</text>
 	<line_editor name="abuse_email_address"/>
 	<string name="email_unsupported">
@@ -41,7 +41,7 @@
 	<button label="?" name="abuse_email_address_help"/>
 	<button label="Zastosuj" name="apply_btn"/>
 	<button label="Wyrzuć Rezydenta z Majątku..." name="kick_user_from_estate_btn"/>
-	<button label="Wyślij Wiadomość do Majątku..." name="message_estate_btn"/>
+	<button label="Wyślij wiadomość do Majątku..." name="message_estate_btn"/>
 	<text name="estate_manager_label">
 		ZarzÄ…dcy MajÄ…tku:
 	</text>
@@ -57,7 +57,7 @@
 	<button label="Usuń..." name="remove_allowed_avatar_btn"/>
 	<button label="Dodaj..." name="add_allowed_avatar_btn"/>
 	<text name="allow_group_label">
-		Dozwolone Grupy:
+		Dozwolone grupy:
 	</text>
 	<button label="?" name="allow_group_help"/>
 	<name_list name="allowed_group_name_list"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_region_general.xml b/indra/newview/skins/default/xui/pl/panel_region_general.xml
index 1410a2a8829..601571f62ee 100644
--- a/indra/newview/skins/default/xui/pl/panel_region_general.xml
+++ b/indra/newview/skins/default/xui/pl/panel_region_general.xml
@@ -25,15 +25,15 @@
 	<check_box label="Odsprzedaż dozwolona" name="allow_land_resell_check"/>
 	<check_box label="Łączenie/Dzielenie dozwolone" name="allow_parcel_changes_check"/>
 	<check_box label="Zablokuj wyszukiwanie" name="block_parcel_search_check" tool_tip="Pozwól na wyświetlanie nazwy regionu i posiadłości w wynikach wyszukiwania"/>
-	<spinner label="Limit Gości" name="agent_limit_spin"/>
+	<spinner label="Limit gości" name="agent_limit_spin"/>
 	<spinner label="Ekstra obiekty" name="object_bonus_spin"/>
 	<text label="Ograniczenia wieku" name="access_text">
 		Rodzaj:
 	</text>
 	<icons_combo_box label="&apos;Mature&apos;" name="access_combo">
 		<icons_combo_box.item label="&apos;Adult&apos;" name="Adult" value="42"/>
-		<icons_combo_box.item label="&apos;Mature&apos;" name="Mature" value="21"/>
-		<icons_combo_box.item label="&apos;PG&apos;" name="PG" value="13"/>
+		<icons_combo_box.item label="&apos;Moderate&apos;" name="Mature" value="21"/>
+		<icons_combo_box.item label="&apos;General&apos;" name="PG" value="13"/>
 	</icons_combo_box>
 	<button label="Zastosuj" name="apply_btn"/>
 	<button label="Teleportuj do Miejsca Startu jednego Rezydenta..." name="kick_btn"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_region_general_layout.xml b/indra/newview/skins/default/xui/pl/panel_region_general_layout.xml
index ffa8f1e18ad..84d7d7ab629 100644
--- a/indra/newview/skins/default/xui/pl/panel_region_general_layout.xml
+++ b/indra/newview/skins/default/xui/pl/panel_region_general_layout.xml
@@ -25,15 +25,15 @@
 	<check_box label="Odsprzedaż dozwolona" name="allow_land_resell_check"/>
 	<check_box label="Łączenie/Dzielenie dozwolone" name="allow_parcel_changes_check"/>
 	<check_box label="Zablokuj wyszukiwanie" name="block_parcel_search_check" tool_tip="Pozwól na wyświetlanie nazwy Regionu i Posiadłości w wynikach wyszukiwania"/>
-	<spinner label="Limit Gości" name="agent_limit_spin"/>
+	<spinner label="Limit gości" name="agent_limit_spin"/>
 	<spinner label="Ekstra obiekty" name="object_bonus_spin"/>
 	<text label="Restrykcje wieku" name="access_text">
 		Rodzaj:
 	</text>
 	<combo_box label="Moderuj" name="access_combo">
 		<combo_box.item label="Adult" name="Adult"/>
-		<combo_box.item label="Moderuj" name="Mature"/>
-		<combo_box.item label="Ogólne" name="PG"/>
+		<combo_box.item label="Moderate" name="Mature"/>
+		<combo_box.item label="General" name="PG"/>
 	</combo_box>
 	<button label="Zastosuj" name="apply_btn"/>
 	<button label="Teleportuj do Miejsca Startu jednego Rezydenta..." name="kick_btn"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_region_terrain.xml b/indra/newview/skins/default/xui/pl/panel_region_terrain.xml
index 917ae917740..f22b4a59897 100644
--- a/indra/newview/skins/default/xui/pl/panel_region_terrain.xml
+++ b/indra/newview/skins/default/xui/pl/panel_region_terrain.xml
@@ -19,12 +19,12 @@
 	<slider label="Pora doby" name="sun_hour_slider" />
 	<button label="Zastosuj" name="apply_btn" />
 	<button label="Zapisz surowy teren..." name="download_raw_btn"
-	     tool_tip="Dostępne tylko dla Właścicieli Majątku, nie dla Zarządców" />
+	     tool_tip="Dostępne tylko dla właścicieli Majątku, nie dla zarządców" />
 	<button label="?" name="download_raw_help" />
 	<button label="Załaduj surowy teren..." name="upload_raw_btn"
-	     tool_tip="Dostępne tylko dla Właścicieli Majątku, nie dla Zarządców" />
+	     tool_tip="Dostępne tylko dla właścicieli Majątku, nie dla zarządców" />
 	<button label="?" name="upload_raw_help" />
-	<button label="Ustal Teren" name="bake_terrain_btn"
+	<button label="Ustal teren" name="bake_terrain_btn"
 	     tool_tip="Zapamiętaj obecny teren jako punkt odniesienia dla limitów podnoszenia i opuszczania" />
 	<button label="?" name="bake_terrain_help" />
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_region_texture.xml b/indra/newview/skins/default/xui/pl/panel_region_texture.xml
index 156f3db63f6..c6ed2457f1c 100644
--- a/indra/newview/skins/default/xui/pl/panel_region_texture.xml
+++ b/indra/newview/skins/default/xui/pl/panel_region_texture.xml
@@ -7,7 +7,7 @@
 		brak danych
 	</text>
 	<text name="detail_texture_text">
-		Tekstury Terenu (24-bitowe 512x512 pliki .tga wymagane)
+		Tekstury terenu (24-bitowe 512x512 pliki .tga wymagane)
 	</text>
 	<text name="height_text_lbl">
 		1 (Dół)
@@ -22,7 +22,7 @@
 		4 (Góra)
 	</text>
 	<text name="height_text_lbl5">
-		Zakres Poziomów dla Tekstury
+		Zakres poziomów dla tekstury
 	</text>
 	<text name="height_text_lbl6">
 		Północny-Zachód
diff --git a/indra/newview/skins/default/xui/pl/panel_script_ed.xml b/indra/newview/skins/default/xui/pl/panel_script_ed.xml
index 09c3d8ad041..fa89a3f7276 100644
--- a/indra/newview/skins/default/xui/pl/panel_script_ed.xml
+++ b/indra/newview/skins/default/xui/pl/panel_script_ed.xml
@@ -27,11 +27,11 @@
 		</menu>
 		<menu label="Edytuj" name="Edit">
 			<menu_item_call label="Cofnij" name="Undo"/>
-			<menu_item_call label="Do Przodu" name="Redo"/>
+			<menu_item_call label="Do przodu" name="Redo"/>
 			<menu_item_call label="Wytnij" name="Cut"/>
 			<menu_item_call label="Kopiuj" name="Copy"/>
 			<menu_item_call label="Wklej" name="Paste"/>
-			<menu_item_call label="Wybierz Wszystko" name="Select All"/>
+			<menu_item_call label="Wybierz wszystko" name="Select All"/>
 			<menu_item_call label="Odznacz" name="Deselect"/>
 			<menu_item_call label="Znajdź / Zamień..." name="Search / Replace..."/>
 		</menu>
diff --git a/indra/newview/skins/default/xui/pl/panel_script_limits_my_avatar.xml b/indra/newview/skins/default/xui/pl/panel_script_limits_my_avatar.xml
index e1863517a24..a52d8aed3df 100644
--- a/indra/newview/skins/default/xui/pl/panel_script_limits_my_avatar.xml
+++ b/indra/newview/skins/default/xui/pl/panel_script_limits_my_avatar.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="MÓJ AWATAR" name="script_limits_my_avatar_panel">
 	<text name="script_memory">
-		Zużycie Skryptów przez Awatara
+		Zużycie skryptów przez awatara
 	</text>
 	<text name="loading_text">
 		Ładowanie...
@@ -9,7 +9,7 @@
 	<scroll_list name="scripts_list">
 		<scroll_list.columns label="Rozmiar (kb)" name="size"/>
 		<scroll_list.columns label="URL" name="urls"/>
-		<scroll_list.columns label="Nazwa Obiektu" name="name"/>
+		<scroll_list.columns label="Nazwa obiektu" name="name"/>
 		<scroll_list.columns label="Lokalizacja" name="location"/>
 	</scroll_list>
 	<button label="Odśwież listę" name="refresh_list_btn"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_script_limits_region_memory.xml b/indra/newview/skins/default/xui/pl/panel_script_limits_region_memory.xml
index 1419a9c9f61..070f025087c 100644
--- a/indra/newview/skins/default/xui/pl/panel_script_limits_region_memory.xml
+++ b/indra/newview/skins/default/xui/pl/panel_script_limits_region_memory.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="PAMIĘĆ REGIONU" name="script_limits_region_memory_panel">
 	<text name="script_memory">
-		Pamięć Skryptu Parceli
+		Pamięć skryptu na posiadłości
 	</text>
 	<text name="loading_text">
 		Ładowanie...
@@ -9,7 +9,7 @@
 	<scroll_list name="scripts_list">
 		<scroll_list.columns label="Rozmiar (kb)" name="size"/>
 		<scroll_list.columns label="URL" name="urls"/>
-		<scroll_list.columns label="Nazwa Obiektu" name="name"/>
+		<scroll_list.columns label="Nazwa obiektu" name="name"/>
 		<scroll_list.columns label="Właściciel" name="owner"/>
 		<scroll_list.columns label="Parcela" name="parcel"/>
 		<scroll_list.columns label="Lokalizacja" name="location"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_side_tray.xml b/indra/newview/skins/default/xui/pl/panel_side_tray.xml
index f34fd0e108d..ff4ca23a4d5 100644
--- a/indra/newview/skins/default/xui/pl/panel_side_tray.xml
+++ b/indra/newview/skins/default/xui/pl/panel_side_tray.xml
@@ -2,7 +2,7 @@
 <!-- Side tray cannot show background because it is always
 	partially on screen to hold tab buttons. -->
 <side_tray name="sidebar">
-	<sidetray_tab description="Przełącz Panel Boczny" name="sidebar_openclose" tab_title="Przełącz Panel Boczny"/>
+	<sidetray_tab description="Przełącz schowek" name="sidebar_openclose" tab_title="Przełącz schowek"/>
 	<sidetray_tab description="Miejsce Startu." name="sidebar_home" tab_title="Home">
 		<panel label="miejsce startu" name="panel_home"/>
 	</sidetray_tab>
@@ -24,6 +24,6 @@
 		<panel label="Edytuj SzafÄ™" name="sidepanel_inventory"/>
 	</sidetray_tab>
 	<sidetray_tab description="Zmień swój obecny wygląd i ubranie." name="sidebar_appearance" tab_title="My Appearance">
-		<panel label="Edytuj WyglÄ…d" name="sidepanel_appearance"/>
+		<panel label="Edytuj wyglÄ…d" name="sidepanel_appearance"/>
 	</sidetray_tab>
 </side_tray>
diff --git a/indra/newview/skins/default/xui/pl/panel_stand_stop_flying.xml b/indra/newview/skins/default/xui/pl/panel_stand_stop_flying.xml
index 0f99f3911ce..9f7f7f1238a 100644
--- a/indra/newview/skins/default/xui/pl/panel_stand_stop_flying.xml
+++ b/indra/newview/skins/default/xui/pl/panel_stand_stop_flying.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <!-- Width and height of this panel should be synchronized with "panel_modes" in the floater_moveview.xml-->
 <panel name="panel_stand_stop_flying">
-	<button label="Wstań" name="stand_btn" tool_tip="Kliknij tutaj by wstać."/>
+	<button label="Wstań" name="stand_btn" tool_tip="Kliknij tutaj aby wstać."/>
 	<button label="Zatrzymaj latanie" name="stop_fly_btn" tool_tip="Zatrzymaj latanie"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_status_bar.xml b/indra/newview/skins/default/xui/pl/panel_status_bar.xml
index 241848c280d..5e97dd89611 100644
--- a/indra/newview/skins/default/xui/pl/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/pl/panel_status_bar.xml
@@ -25,9 +25,9 @@
 		<text name="balance" tool_tip="Mój bilans" value="L$20"/>
 		<button label="Kup L$" name="buyL" tool_tip="Kliknij aby kupić więcej L$"/>
 	</panel>
-	<text name="TimeText" tool_tip="Obecny Czas (Pacyficzny)">
+	<text name="TimeText" tool_tip="Obecny czas (Pacyficzny)">
 		24:00 AM PST
 	</text>
-	<button name="media_toggle_btn" tool_tip="Start/Stop Wszystkie Media (Muzyka, Video, WWW)"/>
-	<button name="volume_btn" tool_tip="Regulacja Głośności"/>
+	<button name="media_toggle_btn" tool_tip="Start/Stop wszystkie media (Muzyka, Video, WWW)"/>
+	<button name="volume_btn" tool_tip="Regulacja głośności"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/role_actions.xml b/indra/newview/skins/default/xui/pl/role_actions.xml
index ccfa5f222ed..53530fff5ed 100644
--- a/indra/newview/skins/default/xui/pl/role_actions.xml
+++ b/indra/newview/skins/default/xui/pl/role_actions.xml
@@ -1,27 +1,27 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <role_actions>
-	<action_set description="Przywileje pozwajające na dodawanie i usuwanie Członków oraz pozwalają nowym Członkom na dodawanie się bez zaproszenia." name="Membership">
-		<action description="Zapraszanie do Grupy" longdescription="Zapraszanie nowych Ludzi do Grupy używając przycisku &apos;Zaproś&apos; w sekcji Ról  &gt; Członkowie" name="member invite"/>
-		<action description="Usuwanie z Grupy" longdescription="Usuwanie Członków z Grupy używając &apos;Usuń z Grupy&apos;; pod Członkowie &gt; Członkowie. Właściciel może usunąć każdego za wyjątkiem innego Właściciela. Jeżeli nie jesteś Właścicielem możesz tylko usuwać Członków w Funkcji Każdy i tylko wtedy kiedy nie mają żadnej innej Funkcji. Aby odebrać Członkowi Funkcję musisz mieć Przywilej &apos;Odbieranie Funkcji&apos;." name="member eject"/>
+	<action_set description="Przywileje pozwajające na dodawanie i usuwanie członków oraz pozwalają nowym członkom na dodawanie się bez zaproszenia." name="Membership">
+		<action description="Zapraszanie do grupy" longdescription="Zapraszanie nowych ludzi do grupy używając przycisku &apos;Zaproś&apos; w sekcji Ról  &gt; Członkowie" name="member invite"/>
+		<action description="Usuwanie z grupy" longdescription="Usuwanie członków z grupy używając &apos;Usuń z Grupy&apos;; pod Członkowie &gt; Członkowie. Właściciel może usunąć każdego za wyjątkiem innego Właściciela. Jeżeli nie jesteś Właścicielem możesz tylko usuwać Członków w Funkcji Każdy i tylko wtedy kiedy nie mają żadnej innej Funkcji. Aby odebrać Członkowi Funkcję musisz mieć Przywilej &apos;Odbieranie Funkcji&apos;." name="member eject"/>
 		<action description="Selekcja opcji &apos;Wolne Zapisy&apos; i wybór &apos;Opłaty Wstępnej&apos;" longdescription="Selekcja opcji &apos;Wolne Zapisy&apos; (pozwala nowym Członkom na dodawanie się bez zaproszenia) i wybór &apos;Opłaty Wstępnej&apos; w Ustawieniach Grupy w sekcji Ogólne." name="member options"/>
 	</action_set>
-	<action_set description="Przywileje pozwalające na dodawanie, usuwanie i edycję Funkcji w Grupie, oraz na nadawanie i odbieranie Funkcji, oraz na przypisywanie Przywilejów do Funkcji." name="Roles">
-		<action description="Dodawanie Funkcji" longdescription="Dodawanie nowych Funkcji pod Członkowie &gt; Funkcje." name="role create"/>
-		<action description="Usuwanie Funkcji" longdescription="Usuń Funkcje w zakładce Funkcje &gt; Funkcje" name="role delete"/>
-		<action description="Zmiany nazw Funkcji, Tytułów i Opisów i widoczność Członków w Informacjach o Grupie" longdescription="Zmiany nazw Funkcji, Tytułów i Opisów i wybór czy Członkowie z daną Rolą są widoczni Informacji o Grupie w dolnej części sekcji Funkcji &gt; Funkcje po wybraniu Funkcje." name="role properties"/>
-		<action description="Przypisywanie Członków do posiadanych Funkcji" longdescription="Przypisywanie Członków do Funkcji w sekcji Przypisane Funkcje pod Członkowie &gt; Członkowie. Członek z tym Przywilejem może dodawać Członków do Funkcji które sam już posiada." name="role assign member limited"/>
-		<action description="Przypisywanie Członków do wszystkich Funkcji" longdescription="Przypisywanie Członków do wszystkich Funkcji w sekcji Przypisane Funkcje pod Członkowie &gt; Członkowie. *UWAGA* Członek w Funkcji z tym Przywilejem może przypisać siebie i innych Członków nie będących Właścicielami do Funkcji dających więcej Przywilejów niż posiadane obecnie potencjalnie dające możliwości zbliżone do możliwości Właściciela. Udzielaj tego Przywileju z rozwagą." name="role assign member"/>
-		<action description="Odbieranie Funkcji" longdescription="Odbieranie Funkcji w sekcji Przypisane Funkcje pod Członkowie &gt; Członkowie. Funkcja Właściciela nie może być odebrana." name="role remove member"/>
-		<action description="Dodawanie i Usuwanie Przywilejów z Funkcji" longdescription="Dodawanie i Usuwanie Przywilejów z Funkcji w sekcji Przwileje pod Członkowie &gt; Funkcje. *UWAGA* Członek w Funkcji z tym Przywilejem może przypisać sobie i innym Członkom nie będącym Właścicielami wszystkie Przywileje potencjalnie dające możliwości zbliżone do możliwości Właściciela. Udzielaj tego Przywileju z rozwagą." name="role change actions"/>
+	<action_set description="Przywileje pozwalające na dodawanie, usuwanie i edycję funkcji w grupie, oraz na nadawanie i odbieranie funkcji, oraz na przypisywanie Przywilejów do Funkcji." name="Roles">
+		<action description="Dodawanie funkcji" longdescription="Dodawanie nowych funkcji pod Członkowie &gt; Funkcje." name="role create"/>
+		<action description="Usuwanie funkcji" longdescription="Usuń Funkcje w zakładce Funkcje &gt; Funkcje" name="role delete"/>
+		<action description="Zmiany nazw funkcji, tytułów i opisów i widoczność członków w informacjach o grupie" longdescription="Zmiany nazw Funkcji, Tytułów i Opisów i wybór czy Członkowie z daną Rolą są widoczni Informacji o Grupie w dolnej części sekcji Funkcji &gt; Funkcje po wybraniu Funkcje." name="role properties"/>
+		<action description="Przypisywanie członków do posiadanych funkcji" longdescription="Przypisywanie Członków do Funkcji w sekcji Przypisane Funkcje pod Członkowie &gt; Członkowie. Członek z tym Przywilejem może dodawać Członków do Funkcji które sam już posiada." name="role assign member limited"/>
+		<action description="Przypisywanie członków do wszystkich funkcji" longdescription="Przypisywanie Członków do wszystkich Funkcji w sekcji Przypisane Funkcje pod Członkowie &gt; Członkowie. *UWAGA* Członek w Funkcji z tym Przywilejem może przypisać siebie i innych Członków nie będących Właścicielami do Funkcji dających więcej Przywilejów niż posiadane obecnie potencjalnie dające możliwości zbliżone do możliwości Właściciela. Udzielaj tego Przywileju z rozwagą." name="role assign member"/>
+		<action description="Odbieranie funkcji" longdescription="Odbieranie Funkcji w sekcji Przypisane Funkcje pod Członkowie &gt; Członkowie. Funkcja Właściciela nie może być odebrana." name="role remove member"/>
+		<action description="Dodawanie i usuwanie przywilejów z funkcji" longdescription="Dodawanie i Usuwanie Przywilejów z Funkcji w sekcji Przwileje pod Członkowie &gt; Funkcje. *UWAGA* Członek w Funkcji z tym Przywilejem może przypisać sobie i innym Członkom nie będącym Właścicielami wszystkie Przywileje potencjalnie dające możliwości zbliżone do możliwości Właściciela. Udzielaj tego Przywileju z rozwagą." name="role change actions"/>
 	</action_set>
 	<action_set description="Przywileje pozwalające na edycję atrybutów Grupy takich jak widoczność w wyszukiwarce, status i insygnia." name="Group Identity">
-		<action description="Zmiany Statusu Grupy, Insygniów, &apos;Widoczność w Wyszukiwarce&apos; i widoczność Członków w Informacjach o Grupie." longdescription="Zmiany Statusu Grupy, Insygniów, i Widoczność w Wyszukiwarce. Dostęp poprzez ustawienia Ogólne." name="group change identity"/>
+		<action description="Zmiany statusu grupy, insygniów, &apos;Widoczność w Wyszukiwarce&apos; i widoczność Członków w Informacjach o Grupie." longdescription="Zmiany Statusu Grupy, Insygniów, i Widoczność w Wyszukiwarce. Dostęp poprzez ustawienia Ogólne." name="group change identity"/>
 	</action_set>
-	<action_set description="Przywileje pozwalające na przypisywanie, modyfikacje i sprzedaż Posiadłości Grupy. Aby zobaczyć okno O Posiadłości wybierz grunt prawym klawiszem myszki i wybierz &apos;O Posiadłości&apos; albo wybierz ikonę &apos;i&apos; w głównym menu." name="Parcel Management">
-		<action description="Przypisywanie i kupowanie Posiadłości dla Grupy" longdescription="Przypisywanie i kupowanie Posiadłości dla Grupy. Dostęp poprzez O Posiadlości &gt; ustawienia Ogólne." name="land deed"/>
-		<action description="Oddawanie Posiadłości do Linden Lab" longdescription="Oddawanie Posiadłości do Linden Lab. *UWAGA* Członek w Funkcji z tym Przywilejem może porzucać Posiadlości Grupy poprzez O Posiadlości &gt; ustawienia Ogólne oddając Posiadłości za darmo do Linden Labs! Udzielaj tego Przywileju z rozwagą." name="land release"/>
-		<action description="Sprzedaż Posiadłości" longdescription="Sprzedaż Posiadłości. *UWAGA* Członek w Funkcji z tym Przywilejem może sprzedawać Posiadlości Grupy poprzez O Posiadlości &gt; ustawienia Ogólne! Udzielaj tego Przywileju z rozwagą." name="land set sale info"/>
-		<action description="Podział i Łączenie Posiadłości" longdescription="Podział i Łączenie Posiadłości. Dostęp poprzez wybranie gruntu prawym klawiszem myszki, &apos;Edycja Terenu&apos;, i przesuwanie myszką po gruncie wybierając obszar. Aby podzielić wybierz obszar i naciśnij &apos;Podziel&apos;. Aby połączyć wybierz dwie albo więcej sąsiadujące Posiadłości i naciśnij &apos;Połącz&apos;." name="land divide join"/>
+	<action_set description="Przywileje pozwalające na przypisywanie, modyfikacje i sprzedaż posiadłości grupy. Aby zobaczyć okno O Posiadłości wybierz grunt prawym klawiszem myszki i wybierz &apos;O Posiadłości&apos; albo wybierz ikonę &apos;i&apos; w głównym menu." name="Parcel Management">
+		<action description="Przypisywanie i kupowanie posiadłości dla grupy" longdescription="Przypisywanie i kupowanie Posiadłości dla Grupy. Dostęp poprzez O Posiadlości &gt; ustawienia Ogólne." name="land deed"/>
+		<action description="Oddawanie posiadłości do Linden Lab" longdescription="Oddawanie Posiadłości do Linden Lab. *UWAGA* Członek w Funkcji z tym Przywilejem może porzucać Posiadlości Grupy poprzez O Posiadlości &gt; ustawienia Ogólne oddając Posiadłości za darmo do Linden Labs! Udzielaj tego Przywileju z rozwagą." name="land release"/>
+		<action description="Sprzedaż posiadłości" longdescription="Sprzedaż Posiadłości. *UWAGA* Członek w Funkcji z tym Przywilejem może sprzedawać Posiadlości Grupy poprzez O Posiadlości &gt; ustawienia Ogólne! Udzielaj tego Przywileju z rozwagą." name="land set sale info"/>
+		<action description="Podział i łączenie posiadłości" longdescription="Podział i Łączenie Posiadłości. Dostęp poprzez wybranie gruntu prawym klawiszem myszki, &apos;Edycja Terenu&apos;, i przesuwanie myszką po gruncie wybierając obszar. Aby podzielić wybierz obszar i naciśnij &apos;Podziel&apos;. Aby połączyć wybierz dwie albo więcej sąsiadujące Posiadłości i naciśnij &apos;Połącz&apos;." name="land divide join"/>
 	</action_set>
 	<action_set description="Przywileje pozwalające na zmianę nazwy Posiadłości, widoczność w wyszukiwarce, widoczność w wyszukiwarce, wybór miejsce lądowania i zmianę ustawień teleportacji (TP)." name="Parcel Identity">
 		<action description="Selekcja opcji &apos;Pokazuj w szukaniu miejsc&apos; i wybór kategorii" longdescription="Selekcja opcji &apos;Pokazuj w szukaniu miejsc&apos; i wybór kategorii Posiadłości pod O Posiadłości &gt; Opcje." name="land find places"/>
@@ -33,44 +33,44 @@
 		<action description="Selekcja opcji &apos;Edycja Terenu&apos;" longdescription="Selekcja opcji &apos;Edycja Terenu&apos;. *UWAGA* O Posiadłości &gt; Opcje &gt; Edycja Terenu pozwala każdemu na formowanie gruntów Twojej Posiadłości oraz na przemieszczanie roślin z Linden Labs. Udzielaj tego Przywileju z rozwagą. Selekcja opcji Edycji Terenu jest dostępna poprzez O Posiadłości &gt; Opcje." name="land edit"/>
 		<action description="Dodatkowe ustawienia O Posiadłości &gt; Opcje" longdescription="Selekcja opcji &apos;Bezpieczeństwo (brak uszkodzeń)&apos; &apos;Latanie&apos;, opcje dla innych Rezydentów: &apos;Tworzenie Obiektów&apos;; &apos;Edycja Terenu&apos;, &apos;Zapamiętywanie Miejsca (LM)&apos;, i &apos;Skrypty&apos; na Posiadłościach Grupy pod O Posiadłości &gt; Opcje." name="land options"/>
 	</action_set>
-	<action_set description="Przywileje pozwalające Członkom na omijanie ograniczeń na Posiadłościach Grupy." name="Parcel Powers">
-		<action description="Pozwól na Edycję Terenu" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zawsze edytować teren na Posiadłościach Grupy." name="land allow edit land"/>
-		<action description="Pozwól na Latanie" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zawsze latać na Posiadłościach Grupy." name="land allow fly"/>
-		<action description="Pozwól na Tworzenie Obiektów" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zawsze tworzyć obiekty na Posiadłościach Grupy." name="land allow create"/>
-		<action description="Pozwól na Zapamiętywanie Miejsc (LM)" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zawsze zapamiętywać miejsca (LM) na Posiadłościach Grupy." name="land allow landmark"/>
-		<action description="Pozwól na wybór Miejsca Startu na Posiadłościach Grupy" longdescription="Członkowie w Funkcji z tym Przywilejem mogą używać menu Świat &gt; Zapamiętaj Miejsce &gt; Miejsce Startu na Posiadłości przypisanej Grupie." name="land allow set home"/>
+	<action_set description="Przywileje pozwalające członkom na omijanie ograniczeń na Posiadłościach Grupy." name="Parcel Powers">
+		<action description="Pozwól na edycję terenu" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zawsze edytować teren na Posiadłościach Grupy." name="land allow edit land"/>
+		<action description="Pozwól na latanie" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zawsze latać na Posiadłościach Grupy." name="land allow fly"/>
+		<action description="Pozwól na tworzenie obiektów" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zawsze tworzyć obiekty na Posiadłościach Grupy." name="land allow create"/>
+		<action description="Pozwól na zapamiętywanie miejsc (LM)" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zawsze zapamiętywać miejsca (LM) na Posiadłościach Grupy." name="land allow landmark"/>
+		<action description="Pozwól na wybór Miejsca Startu na posiadłościach grupy" longdescription="Członkowie w Funkcji z tym Przywilejem mogą używać menu Świat &gt; Zapamiętaj Miejsce &gt; Miejsce Startu na Posiadłości przypisanej Grupie." name="land allow set home"/>
 	</action_set>
 	<action_set description="Przywileje pozwalające na dawanie i odbieranie dostępu do Posiadłości Grupy zawierające możliwości unieruchomiania i wyrzucania Rezydentów." name="Parcel Access">
-		<action description="Zarządzanie Listą Dostępu do Posiadłości" longdescription="Zarządzanie Listą Dostępu do Posiadłości pod O Posiadłości &gt; Dostęp." name="land manage allowed"/>
-		<action description="Zarządzanie Listą Usuniętych z Posiadłości (Bany)" longdescription="Zarządzanie Listą Dostępu do Posiadłości pod O Posiadłości &gt; Dostęp." name="land manage banned"/>
+		<action description="Zarządzanie listą dostępu do posiadłości" longdescription="Zarządzanie Listą Dostępu do Posiadłości pod O Posiadłości &gt; Dostęp." name="land manage allowed"/>
+		<action description="Zarządzanie listą usuniętych z posiadłości (Bany)" longdescription="Zarządzanie Listą Dostępu do Posiadłości pod O Posiadłości &gt; Dostęp." name="land manage banned"/>
 		<action description="Selekcja opcji &apos;Wstęp Płatny&apos;" longdescription="Selekcja opcji &apos;Wstęp Płatny&apos;; pod O Posiadłości &gt; Dostęp." name="land manage passes"/>
-		<action description="Wyrzucanie i unieruchamianie Rezydentów na Posiadłościach" longdescription="Członkowie w Funkcji z tym Przywilejem mogą wpływać na niepożądanych na Posiadłościach Grupy Rezydentów wybierając ich prawym klawiszem myszki i wybierając &apos;;Wyrzuć&apos; albo &apos;Unieruchom&apos;." name="land admin"/>
+		<action description="Wyrzucanie i unieruchamianie Rezydentów na posiadłościach" longdescription="Członkowie w Funkcji z tym Przywilejem mogą wpływać na niepożądanych na Posiadłościach Grupy Rezydentów wybierając ich prawym klawiszem myszki i wybierając &apos;;Wyrzuć&apos; albo &apos;Unieruchom&apos;." name="land admin"/>
 	</action_set>
 	<action_set description="Przywileje pozwalające na odsyłanie obiektów i przemieszczanie roślin z Linden Lab. Użyteczne przy porządkowaniu i przemieszczaniu roślinności. *UWAGA* Odsyłanie obiektów jest nieodwracalne." name="Parcel Content">
-		<action description="Odsyłanie obiektów należących do Grupy" longdescription="Odsyłanie obiektów należących do Grupy pod O Posiadłości &gt; Obiekty." name="land return group owned"/>
-		<action description="Odsyłanie obiektów przypisanych do Grupy" longdescription="Odsyłanie obiektów przypisanych do Grupy pod O Posiadłości &gt; Obiekty." name="land return group set"/>
-		<action description="Odsyłanie obiektów nie przypisanych do Grupy" longdescription="Odsyłanie obiektów nie przypisanych do Grupy pod O Posiadłości &gt; Obiekty." name="land return non group"/>
+		<action description="Odsyłanie obiektów należących do grupy" longdescription="Odsyłanie obiektów należących do Grupy pod O Posiadłości &gt; Obiekty." name="land return group owned"/>
+		<action description="Odsyłanie obiektów przypisanych do grupy" longdescription="Odsyłanie obiektów przypisanych do Grupy pod O Posiadłości &gt; Obiekty." name="land return group set"/>
+		<action description="Odsyłanie obiektów nie przypisanych do grupy" longdescription="Odsyłanie obiektów nie przypisanych do Grupy pod O Posiadłości &gt; Obiekty." name="land return non group"/>
 		<action description="Ogrodnictwo używając roślin z Linden Lab" longdescription="Możliwość przemieszczenia roślin z Linden Lab. Obiekty te mogą zostać odnalezione w Twojej Szafie, w folderze Biblioteka &gt; Folderze Obiektów lub mogą zostać stworzone dzięki aktywacji Narzędzi Edycji." name="land gardening"/>
 	</action_set>
 	<action_set description="Przywileje pozwalające na odsyłanie obiektów i przemieszczenia roślin z Linden Lab. Użyteczne przy porządkowaniu i przemieszczenia roślinności. *UWAGA* Odsyłanie obiektów jest nieodwracalne." name="Object Management">
-		<action description="Przypisywanie obiektów do Grupy" longdescription="Przypisywanie obiektów do Grupy w Narzędziach Edycji &gt; Ogólne" name="object deed"/>
+		<action description="Przypisywanie obiektów do grupy" longdescription="Przypisywanie obiektów do Grupy w Narzędziach Edycji &gt; Ogólne" name="object deed"/>
 		<action description="Manipulowanie (wklejanie, kopiowanie, modyfikacja) obiektami należącymi do Grupy" longdescription="Manipulowanie (wklejanie, kopiowanie, modyfikacja) obiektami należącymi do Grupy w Narzędziach Edycji &gt; Ogólne" name="object manipulate"/>
-		<action description="Sprzedaż obiektów należących do Grupy" longdescription="Sprzedaż obiektów należących do Grupy pod Narzędzia Edycji &gt; Ogólne." name="object set sale"/>
+		<action description="Sprzedaż obiektów należących do grupy" longdescription="Sprzedaż obiektów należących do Grupy pod Narzędzia Edycji &gt; Ogólne." name="object set sale"/>
 	</action_set>
 	<action_set description="Przywileje pozwalające na wybór opłat grupowych, otrzymywanie dochodu i ograniczanie dostępu do historii konta grupy." name="Accounting">
 		<action description="Opłaty grupowe i dochód grupowy" longdescription="Członkowie w Funkcji z tym Przywilejem będą automatycznie wnosić opłaty grupowe i będą otrzymywać dochód grupowy. Tzn. będą codziennie otrzymywać część dochodu ze sprzedaży Posiadłości Grupy oraz będą partycypować w kosztach ogłoszeń itp." name="accounting accountable"/>
 	</action_set>
 	<action_set description="Przywileje pozwalające na wysyłanie, odbieranie i czytanie Notek Grupy." name="Notices">
-		<action description="Wysyłanie Notek" longdescription="Członkowie w Funkcji z tym Przywilejem mogą wysyłać Notki wybierając O Grupie &gt; Notek." name="notices send"/>
-		<action description="Odbieranie Notek i dostęp do dawniejszych Notek" longdescription="Członkowie w Funkcji z tym Przywilejem mogą odbierać nowe i czytać dawniejsze Notki wybierając O Grupie &gt; Notki." name="notices receive"/>
+		<action description="Wysyłanie notek" longdescription="Członkowie w Funkcji z tym Przywilejem mogą wysyłać Notki wybierając O Grupie &gt; Notek." name="notices send"/>
+		<action description="Odbieranie notek i dostęp do dawniejszych notek" longdescription="Członkowie w Funkcji z tym Przywilejem mogą odbierać nowe i czytać dawniejsze Notki wybierając O Grupie &gt; Notki." name="notices receive"/>
 	</action_set>
 	<action_set description="Przywileje pozwalające na zgłaszanie Propozycji, głosowanie nad Propozycjami i śledzenie historii głosowania." name="Proposals">
-		<action description="Zgłaszanie Propozycji" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zgłaszać Propozycje do głosowania wybierając O Grupie &gt; Propozycje." name="proposal start"/>
-		<action description="Głosowanie nad Propozycjami" longdescription="Członkowie w Funkcji z tym Przywilejem mogą głosować nad Propozycjami zgłoszonymi do głosowania wybierając O Grupie &gt; Propozycje." name="proposal vote"/>
+		<action description="Zgłaszanie propozycji" longdescription="Członkowie w Funkcji z tym Przywilejem mogą zgłaszać Propozycje do głosowania wybierając O Grupie &gt; Propozycje." name="proposal start"/>
+		<action description="Głosowanie nad propozycjami" longdescription="Członkowie w Funkcji z tym Przywilejem mogą głosować nad Propozycjami zgłoszonymi do głosowania wybierając O Grupie &gt; Propozycje." name="proposal vote"/>
 	</action_set>
 	<action_set description="Przywileje kontrolujÄ…ce czat i rozmowy grupowe." name="Chat">
-		<action description="Dostęp do Czatu Grupowego" longdescription="Członkowie w Funkcji z tym Przywilejem mogą uczestniczyć w czacie i rozmowach grupowych." name="join group chat"/>
-		<action description="Dostęp do Rozmów Grupowych" longdescription="Członkowie w Funkcji z tym Przywilejem mogą uczestniczyć w rozmowach grupowych. UWAGA: Dostęp do Czatu Grupowego jest wymagany dla rozmów grupowych." name="join voice chat"/>
-		<action description="Moderator Czatu Grupowego" longdescription="Członkowie w Funkcji z tym Przywilejem mogą kontrolować dostęp do czatu i rozmów grupowych." name="moderate group chat"/>
+		<action description="Dostęp do czatu grupowego" longdescription="Członkowie w Funkcji z tym Przywilejem mogą uczestniczyć w czacie i rozmowach grupowych." name="join group chat"/>
+		<action description="Dostęp do rozmów grupowych" longdescription="Członkowie w Funkcji z tym Przywilejem mogą uczestniczyć w rozmowach grupowych. UWAGA: Dostęp do Czatu Grupowego jest wymagany dla rozmów grupowych." name="join voice chat"/>
+		<action description="Moderator czatu grupowego" longdescription="Członkowie w Funkcji z tym Przywilejem mogą kontrolować dostęp do czatu i rozmów grupowych." name="moderate group chat"/>
 	</action_set>
 </role_actions>
diff --git a/indra/newview/skins/default/xui/pl/sidepanel_appearance.xml b/indra/newview/skins/default/xui/pl/sidepanel_appearance.xml
index 2fc07aaaca3..cea903769c1 100644
--- a/indra/newview/skins/default/xui/pl/sidepanel_appearance.xml
+++ b/indra/newview/skins/default/xui/pl/sidepanel_appearance.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Ubrania" name="appearance panel">
-	<string name="No Outfit" value="Bez Ubrania"/>
+	<string name="No Outfit" value="Bez stroju"/>
 	<string name="Unsaved Changes" value="Zmiany niezachowane"/>
 	<string name="Now Wearing" value="Obecnie założone..."/>
 	<string name="Changing outfits" value="Zmiana stroju"/>
@@ -12,5 +12,5 @@
 		</text>
 		<button label="" name="edit_outfit_btn" tool_tip="Edytuj ten strój"/>
 	</panel>
-	<filter_editor label="PrzeglÄ…daj Ubrania" name="Filter"/>
+	<filter_editor label="PrzeglÄ…daj stroje" name="Filter"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/sidepanel_item_info.xml b/indra/newview/skins/default/xui/pl/sidepanel_item_info.xml
index 3282926bcd7..e39bbd75c5d 100644
--- a/indra/newview/skins/default/xui/pl/sidepanel_item_info.xml
+++ b/indra/newview/skins/default/xui/pl/sidepanel_item_info.xml
@@ -58,11 +58,11 @@
 			</text>
 			<check_box label="Udostępnij" name="CheckShareWithGroup" tool_tip="Pozwól wszystkim członkom ustawionej grupy na dzielenie prawa do modyfikacji dla tego obiektu. Musisz przypisać obiekt grupie aby aktywować ograniczenia wynikające z roli."/>
 			<text name="NextOwnerLabel">
-				Następny Właściciel:
+				Następny właściciel:
 			</text>
 			<check_box label="Modyfikuje" name="CheckNextOwnerModify"/>
 			<check_box label="Kopiuje" name="CheckNextOwnerCopy"/>
-			<check_box label="Sprzedaje/Oddaje" name="CheckNextOwnerTransfer" tool_tip="Następny Właściciel może oddawać lub sprzedawać ten obiekt"/>
+			<check_box label="Sprzedaje/Oddaje" name="CheckNextOwnerTransfer" tool_tip="Następny właściciel może oddawać lub sprzedawać ten obiekt"/>
 		</panel>
 		<check_box label="Na sprzedaż" name="CheckPurchase"/>
 		<combo_box name="combobox sale copy">
diff --git a/indra/newview/skins/default/xui/pl/sidepanel_task_info.xml b/indra/newview/skins/default/xui/pl/sidepanel_task_info.xml
index 84b5471e492..d8cf456c646 100644
--- a/indra/newview/skins/default/xui/pl/sidepanel_task_info.xml
+++ b/indra/newview/skins/default/xui/pl/sidepanel_task_info.xml
@@ -83,7 +83,7 @@
 			<check_box label="Kopiuj" name="checkbox allow everyone copy"/>
 			<check_box label="Przesuń" name="checkbox allow everyone move"/>
 			<text name="GroupLabel">
-				Groupie:
+				Grupie:
 			</text>
 			<check_box label="Udostępnij" name="checkbox share with group" tool_tip="Udostępnij prawa do modyfikacji tego obiektu wszystkim członkom, którzy posiadają przywilej modyfikacji obiektów grupy. By ograniczyć, przypisz obiekt do grupy."/>
 			<text name="NextOwnerLabel">
diff --git a/indra/newview/skins/default/xui/pl/strings.xml b/indra/newview/skins/default/xui/pl/strings.xml
index e4423dc5ce1..e2689720bfb 100644
--- a/indra/newview/skins/default/xui/pl/strings.xml
+++ b/indra/newview/skins/default/xui/pl/strings.xml
@@ -50,7 +50,7 @@
 		Ładowanie świata...
 	</string>
 	<string name="LoginInitializingBrowser">
-		Inicjalizacja PrzeglÄ…darki Internetu...
+		Inicjalizacja przeglÄ…darki internetowej...
 	</string>
 	<string name="LoginInitializingMultimedia">
 		Inicjalizacja multimediów...
@@ -62,22 +62,22 @@
 		Weryfikacja bufora danych na dysku (może trwać od 60 do 90 sekund)...
 	</string>
 	<string name="LoginProcessingResponse">
-		Przetwarzanie Odpowiedzi...
+		Przetwarzanie odpowiedzi...
 	</string>
 	<string name="LoginInitializingWorld">
-		Inicjalizacja świata...
+		Inicjacja świata...
 	</string>
 	<string name="LoginDecodingImages">
 		Przetwarzanie obrazów...
 	</string>
 	<string name="LoginInitializingQuicktime">
-		Inicjalizacja QuickTime...
+		Inicjacja QuickTime...
 	</string>
 	<string name="LoginQuicktimeNotFound">
-		QuickTime nie został znaleziony - inicjalizacja przerwana.
+		QuickTime nie został znaleziony - inicjacja przerwana.
 	</string>
 	<string name="LoginQuicktimeOK">
-		QuickTime zainicjalizowany.
+		QuickTime zainicjowany.
 	</string>
 	<string name="LoginWaitingForRegionHandshake">
 		Oczekiwanie na połączenie z regionem...
@@ -113,7 +113,7 @@
 		Logowanie nie powiodło się.
 	</string>
 	<string name="Quit">
-		Wyłącz Program
+		Wyłącz program
 	</string>
 	<string name="AgentLostConnection">
 		Ten region może mieć problemy. Sprawdź podłączenie do Internetu.
@@ -152,28 +152,28 @@
 		(Grupa)
 	</string>
 	<string name="TooltipForSaleL$">
-		Na Sprzedaż: L$[AMOUNT]
+		Na sprzedaż: L$[AMOUNT]
 	</string>
 	<string name="TooltipFlagGroupBuild">
-		Budowanie Grupowe
+		Budowanie grupowe
 	</string>
 	<string name="TooltipFlagNoBuild">
-		Budowanie Zabronione
+		Budowanie zabronione
 	</string>
 	<string name="TooltipFlagNoEdit">
-		Edycja Zabroniona
+		Edycja zabroniona
 	</string>
 	<string name="TooltipFlagNotSafe">
-		Niebezpieczny Obszar
+		Niebezpieczny obszar
 	</string>
 	<string name="TooltipFlagNoFly">
-		Latanie Zabronione
+		Latanie zabronione
 	</string>
 	<string name="TooltipFlagGroupScripts">
-		Skrypty Grupowe
+		Skrypty grupowe
 	</string>
 	<string name="TooltipFlagNoScripts">
-		Skrypty Zabronione
+		Skrypty zabronione
 	</string>
 	<string name="TooltipLand">
 		Posiadłość:
@@ -183,10 +183,10 @@
 	</string>
 	<string name="TooltipPrice" value="L$[AMOUNT]:"/>
 	<string name="TooltipHttpUrl">
-		Kliknij by zobaczyć zawartość tej strony internetowej
+		Kliknij aby zobaczyć zawartość tej strony internetowej
 	</string>
 	<string name="TooltipSLURL">
-		Kliknij by zobaczyć szczegóły tego miejsca
+		Kliknij aby zobaczyć szczegóły tego miejsca
 	</string>
 	<string name="TooltipAgentUrl">
 		Kliknij aby zobaczyc profil Rezydenta
@@ -210,35 +210,35 @@
 		Kliknij aby wysłać temu Rezydentowi zaproszenie do Znajomych
 	</string>
 	<string name="TooltipGroupUrl">
-		Kliknij by zobaczyć opis tej grupy
+		Kliknij aby zobaczyć opis tej grupy
 	</string>
 	<string name="TooltipEventUrl">
-		Klinij by zobaczyć szczegóły tego wydarzenia
+		Klinij aby zobaczyć szczegóły tego wydarzenia
 	</string>
 	<string name="TooltipClassifiedUrl">
-		Kliknij by zobaczyć tę reklamę
+		Kliknij aby zobaczyć tę reklamę
 	</string>
 	<string name="TooltipParcelUrl">
-		Kliknij by zobaczyć opis tej posiadłości
+		Kliknij aby zobaczyć opis tej posiadłości
 	</string>
 	<string name="TooltipTeleportUrl">
-		Kliknij by teleportować się do tego miejsca
+		Kliknij aby teleportować się do tego miejsca
 	</string>
 	<string name="TooltipObjectIMUrl">
-		Kliknij by zobaczyć opis tego obiektu
+		Kliknij aby zobaczyć opis tego obiektu
 	</string>
 	<string name="TooltipMapUrl">
-		Kliknij by zobaczyć to miejsce na mapie
+		Kliknij aby zobaczyć to miejsce na mapie
 	</string>
 	<string name="TooltipSLAPP">
-		Kliknij by uruchomić secondlife:// command
+		Kliknij aby uruchomić secondlife:// command
 	</string>
 	<string name="CurrentURL" value=" Obecny Adres: [CurrentURL]"/>
 	<string name="SLurlLabelTeleport">
 		Teleportuj do
 	</string>
 	<string name="SLurlLabelShowOnMap">
-		Pokaż na Mapie
+		Pokaż na mapie
 	</string>
 	<string name="SLappAgentMute">
 		Zablokuj
@@ -286,13 +286,13 @@
 		Wyszukiwanie...
 	</string>
 	<string name="NoneFound">
-		Nieodnaleziono.
+		Nie odnaleziono.
 	</string>
 	<string name="RetrievingData">
 		Odzyskiwanie danych...
 	</string>
 	<string name="ReleaseNotes">
-		O Tej Wersji
+		O tej wersji
 	</string>
 	<string name="RELEASE_NOTES_BASE_URL">
 		http://wiki.secondlife.com/wiki/Release_Notes/
@@ -310,7 +310,7 @@
 		(brak danych)
 	</string>
 	<string name="AvalineCaller">
-		Avaline Caller [ORDER]
+		Avaline [ORDER]
 	</string>
 	<string name="AssetErrorNone">
 		OK
@@ -322,7 +322,7 @@
 		Pobieranie danych: brak pliku
 	</string>
 	<string name="AssetErrorNotInDatabase">
-		Pobieranie danych: dane nie znalezione w bazie danych
+		Pobieranie danych: dane nie zostały znalezione w bazie danych
 	</string>
 	<string name="AssetErrorEOF">
 		Koniec pliku
@@ -364,22 +364,22 @@
 		ubrania
 	</string>
 	<string name="object">
-		obieku
+		obiek
 	</string>
 	<string name="note card">
 		notatki
 	</string>
 	<string name="folder">
-		folderu
+		folder
 	</string>
 	<string name="root">
 		podstawy
 	</string>
 	<string name="lsl2 script">
-		skryptu LSL2
+		skrypt LSL2
 	</string>
 	<string name="lsl bytecode">
-		kodu LSL
+		kod LSL
 	</string>
 	<string name="tga texture">
 		tekstury typu tga
@@ -391,22 +391,22 @@
 		zdjęcia
 	</string>
 	<string name="lost and found">
-		Zgubione i Odnalezione
+		Zgubione i odnalezione
 	</string>
 	<string name="targa image">
-		obrau typu targa
+		obraz typu targa
 	</string>
 	<string name="trash">
 		Kosz
 	</string>
 	<string name="jpeg image">
-		obrazu typu jpeg
+		obraz typu jpg
 	</string>
 	<string name="animation">
-		animacji
+		animacja
 	</string>
 	<string name="gesture">
-		gesturki
+		gesturka
 	</string>
 	<string name="simstate">
 		simstate
@@ -442,16 +442,16 @@
 		Salto
 	</string>
 	<string name="anim_express_laugh">
-		Åšmiech do Rozpuku
+		Åšmiech do rozpuku
 	</string>
 	<string name="anim_express_toothsmile">
-		Wielki Uśmiech
+		Wielki uśmiech
 	</string>
 	<string name="anim_blowkiss">
 		Całusek
 	</string>
 	<string name="anim_express_bored">
-		Ale Nudy!
+		Ale nudy!
 	</string>
 	<string name="anim_bow">
 		Ukłon
@@ -460,7 +460,7 @@
 		Oklaski
 	</string>
 	<string name="anim_courtbow">
-		Dworski Ukłon
+		Dworski ukłon
 	</string>
 	<string name="anim_express_cry">
 		PÅ‚acz
@@ -499,10 +499,10 @@
 		Zakłopotanie
 	</string>
 	<string name="anim_angry_fingerwag">
-		Grożenie Paluszkiem
+		Grożenie paluszkiem
 	</string>
 	<string name="anim_fist_pump">
-		Udało sie!
+		Udało się!
 	</string>
 	<string name="anim_yoga_float">
 		Yoga
@@ -517,7 +517,7 @@
 		Radocha
 	</string>
 	<string name="anim_kissmybutt">
-		Pocałuj Mnie Gdzieś
+		Pocałuj mnie gdzieś
 	</string>
 	<string name="anim_express_kiss">
 		Pocałunek
@@ -538,40 +538,40 @@
 		Nie-nie-nie
 	</string>
 	<string name="anim_punch_onetwo">
-		Za Ciosem Cios
+		Za ciosem cios
 	</string>
 	<string name="anim_express_open_mouth">
-		Szczęka Opada
+		Szczęka opada
 	</string>
 	<string name="anim_peace">
 		Pokój
 	</string>
 	<string name="anim_point_you">
-		Wskazuj na Innych
+		Wskazuj na innych
 	</string>
 	<string name="anim_point_me">
-		Wskazuj na Siebie
+		Wskazuj na siebie
 	</string>
 	<string name="anim_punch_l">
-		Uderz z Lewej
+		Uderz z lewej
 	</string>
 	<string name="anim_punch_r">
-		Uderz z Prawej
+		Uderz z prawej
 	</string>
 	<string name="anim_rps_countdown">
-		KPN Licz
+		KPN licz
 	</string>
 	<string name="anim_rps_paper">
-		KPN Papier
+		KPN papier
 	</string>
 	<string name="anim_rps_rock">
-		KPN Kamień
+		KPN kamień
 	</string>
 	<string name="anim_rps_scissors">
-		KPN Nożyce
+		KPN nożyce
 	</string>
 	<string name="anim_express_repulsed">
-		Odrzuca Mnie
+		Odrzuca mnie
 	</string>
 	<string name="anim_kick_roundhouse_r">
 		Kopniak
@@ -586,7 +586,7 @@
 		Krzycz
 	</string>
 	<string name="anim_express_shrug">
-		Wzrusz Ramionami
+		Wzrusz ramionami
 	</string>
 	<string name="anim_express_smile">
 		Uśmiechaj się
@@ -595,22 +595,22 @@
 		Pal
 	</string>
 	<string name="anim_smoke_inhale">
-		Pal i ZaciÄ…gaj siÄ™
+		Pal i zaciÄ…gaj siÄ™
 	</string>
 	<string name="anim_smoke_throw_down">
-		Rzuć Papierosa
+		Rzuć papierosa
 	</string>
 	<string name="anim_express_surprise">
 		Zaskoczenie
 	</string>
 	<string name="anim_sword_strike_r">
-		Uderz Mieczem
+		Uderz mieczem
 	</string>
 	<string name="anim_angry_tantrum">
 		Wściekłość
 	</string>
 	<string name="anim_express_tongue_out">
-		Pokaż Język
+		Pokaż język
 	</string>
 	<string name="anim_hello">
 		Pomachaj
@@ -622,10 +622,10 @@
 		Zagwiżdż
 	</string>
 	<string name="anim_express_wink">
-		Puść Oko
+		Puść oko
 	</string>
 	<string name="anim_wink_hollywood">
-		Puść Oko (Hollywood)
+		Puść oko (Hollywood)
 	</string>
 	<string name="anim_express_worry">
 		Zmartwienie
@@ -640,13 +640,13 @@
 		Ładowanie...
 	</string>
 	<string name="worldmap_offline">
-		Mapa Świata jest Niedostępna
+		Mapa Świata jest niedostępna
 	</string>
 	<string name="worldmap_item_tooltip_format">
 		[AREA] m² L$[PRICE]
 	</string>
 	<string name="worldmap_results_none_found">
-		Miejsce Nieodnalezione.
+		Miejsce nieodnalezione.
 	</string>
 	<string name="Ok">
 		OK
@@ -664,7 +664,7 @@
 		krzyczy:
 	</string>
 	<string name="ringing">
-		Łączenie z rozmowami głosem w świecie...
+		Łączenie z rozmowami głosem w Świecie...
 	</string>
 	<string name="connected">
 		Połączenie uzyskane.
@@ -703,7 +703,7 @@
 		Usuń prawo własności (zmień na publiczne)
 	</string>
 	<string name="LinkAndDelink">
-		Łącz / odłącz z innymi obiektów
+		Łącz / rozłącz z innymi obiektami
 	</string>
 	<string name="AddAndRemoveJoints">
 		Dodaj / usuń połączenia z innymi obiektami
@@ -718,10 +718,10 @@
 		Kontroluj kamerÄ™
 	</string>
 	<string name="SIM_ACCESS_PG">
-		&apos;PG&apos;
+		&apos;General&apos;
 	</string>
 	<string name="SIM_ACCESS_MATURE">
-		&apos;Mature&apos;
+		&apos;Moderate&apos;
 	</string>
 	<string name="SIM_ACCESS_ADULT">
 		&apos;Adult&apos;
@@ -742,7 +742,7 @@
 		Mainland / Region
 	</string>
 	<string name="all_files">
-		Wszystkie Pliki
+		Wszystkie pliki
 	</string>
 	<string name="sound_files">
 		Dźwięki
@@ -760,16 +760,16 @@
 		Załaduj
 	</string>
 	<string name="targa_image_files">
-		Obrazy Targa
+		Obrazy targa
 	</string>
 	<string name="bitmap_image_files">
-		Obrazy Bitmap
+		Obrazy bitmap
 	</string>
 	<string name="avi_movie_file">
 		Pliki filmowe AVI
 	</string>
 	<string name="xaf_animation_file">
-		Plik Animacji XAF
+		Plik animacji XAF
 	</string>
 	<string name="xml_file">
 		Plik XML
@@ -778,13 +778,13 @@
 		Plik RAW
 	</string>
 	<string name="compressed_image_files">
-		Obrazy Skomprensowane
+		Obrazy skomprensowane
 	</string>
 	<string name="load_files">
 		Załaduj pliki
 	</string>
 	<string name="choose_the_directory">
-		Wybierz Katalog
+		Wybierz katalog
 	</string>
 	<string name="AvatarSetNotAway">
 		Ustaw Nie Åšpij
@@ -838,7 +838,7 @@
 		Spódnica
 	</string>
 	<string name="alpha">
-		Ubranie Przezroczyste
+		Ubranie Alpha
 	</string>
 	<string name="tattoo">
 		Tatuaż
@@ -850,37 +850,37 @@
 		żadne
 	</string>
 	<string name="shirt_not_worn">
-		Koszula niezałożona
+		Koszula nie jest założona
 	</string>
 	<string name="pants_not_worn">
-		Spodnie niezałożone
+		Spodnie nie są założone
 	</string>
 	<string name="shoes_not_worn">
-		Buty niezałożone
+		Buty nie są założone
 	</string>
 	<string name="socks_not_worn">
-		Skarpetki niezałożone
+		Skarpetki nie są założone
 	</string>
 	<string name="jacket_not_worn">
-		Kurtka niezałożona
+		Kurtka nie jest założona
 	</string>
 	<string name="gloves_not_worn">
-		Rękawiczki niezałożone
+		Rękawiczki nie są założone
 	</string>
 	<string name="undershirt_not_worn">
-		Podkoszulek niezałożony
+		Podkoszulek nie jest założony
 	</string>
 	<string name="underpants_not_worn">
-		Bielizna niezałożona
+		Bielizna nie jest założona
 	</string>
 	<string name="skirt_not_worn">
-		Spódnica niezałożona
+		Spódnica nie jest założona
 	</string>
 	<string name="alpha_not_worn">
-		Alpha niezałożone
+		Alpha nie jest założone
 	</string>
 	<string name="tattoo_not_worn">
-		Tatuaż niezałożony
+		Tatuaż nie jest założony
 	</string>
 	<string name="invalid_not_worn">
 		nieważny
@@ -943,10 +943,10 @@
 		OK
 	</string>
 	<string name="GroupNotifyGroupNotice">
-		Ogłoszenie Grupowe
+		Ogłoszenie grupowe
 	</string>
 	<string name="GroupNotifyGroupNotices">
-		Ogłoszenia Grupowe
+		Ogłoszenia grupowe
 	</string>
 	<string name="GroupNotifySentBy">
 		Wysłane przez
@@ -955,40 +955,40 @@
 		Załączone:
 	</string>
 	<string name="GroupNotifyViewPastNotices">
-		Zobacz poprzednie zawiadomienia lub otrzymanen wiadomości tutaj.
+		Zobacz poprzednie zawiadomienia lub otrzymane wiadomości tutaj.
 	</string>
 	<string name="GroupNotifyOpenAttachment">
-		Otwórz Załącznik
+		Otwórz załącznik
 	</string>
 	<string name="GroupNotifySaveAttachment">
-		Zapisz Załącznik
+		Zapisz załącznik
 	</string>
 	<string name="TeleportOffer">
 		Oferta teleportacji
 	</string>
 	<string name="StartUpNotifications">
-		Nowe zawiadomienia zostały wysłane kiedy byłeś w trybie oddalenia...
+		Nowe zawiadomienia zostały wysłane kiedy byłeś/byłaś w trybie oddalenia...
 	</string>
 	<string name="OverflowInfoChannelString">
 		Masz jeszcze [%d] powiadomień
 	</string>
 	<string name="BodyPartsRightArm">
-		Prawe RamiÄ™
+		Prawe ramiÄ™
 	</string>
 	<string name="BodyPartsHead">
 		GÅ‚owa
 	</string>
 	<string name="BodyPartsLeftArm">
-		Lewe RamiÄ™
+		Lewe ramiÄ™
 	</string>
 	<string name="BodyPartsLeftLeg">
-		Lewa Noga
+		Lewa noga
 	</string>
 	<string name="BodyPartsTorso">
 		Tułów
 	</string>
 	<string name="BodyPartsRightLeg">
-		Prawa Noga
+		Prawa noga
 	</string>
 	<string name="GraphicsQualityLow">
 		Niska
@@ -1000,7 +1000,7 @@
 		Wysoka
 	</string>
 	<string name="LeaveMouselook">
-		Wybierz ESC by powrócić do trybu widoku normalne
+		Wybierz ESC aby powrócić do trybu widoku normalnego
 	</string>
 	<string name="InventoryNoMatchingItems">
 		Nie znaleziono tego czego szukasz? Spróbuj [secondlife:///app/search/all/[SEARCH_TERM] Szukaj].
@@ -1031,18 +1031,18 @@
 	<string name="Chat" value=" Czat :"/>
 	<string name="Sound" value=" Dźwięk :"/>
 	<string name="Wait" value=" --- Zaczekaj :"/>
-	<string name="AnimFlagStop" value=" Zatrzymaj AnimacjÄ™ :"/>
-	<string name="AnimFlagStart" value=" Rozpocznij AnimacjÄ™ :"/>
+	<string name="AnimFlagStop" value=" Zatrzymaj animacjÄ™ :"/>
+	<string name="AnimFlagStart" value=" Rozpocznij animacjÄ™ :"/>
 	<string name="Wave" value=" Wave"/>
 	<string name="GestureActionNone" value="Żadne"/>
 	<string name="HelloAvatar" value=" Witaj, Awatarze!"/>
-	<string name="ViewAllGestures" value="  Zobacz Wszystkie &gt;&gt;"/>
+	<string name="ViewAllGestures" value="  Zobacz wszystkie &gt;&gt;"/>
 	<string name="GetMoreGestures" value="Więcej gesturek &gt;&gt;"/>
 	<string name="Animations" value=" Animacje,"/>
 	<string name="Calling Cards" value=" Wizytówki,"/>
 	<string name="Clothing" value=" Ubrania,"/>
 	<string name="Gestures" value=" Gesturki,"/>
-	<string name="Landmarks" value=" Ulubione Miejsca,"/>
+	<string name="Landmarks" value=" Ulubione miejsca,"/>
 	<string name="Notecards" value=" Notki,"/>
 	<string name="Objects" value=" Obiekty,"/>
 	<string name="Scripts" value=" Skrypty,"/>
@@ -1055,7 +1055,7 @@
 		Moja Szafa
 	</string>
 	<string name="InvFolder My Favorites">
-		Moje Ulubione
+		Moje ulubione
 	</string>
 	<string name="InvFolder Library">
 		Biblioteka
@@ -1070,7 +1070,7 @@
 		Wizytówki
 	</string>
 	<string name="InvFolder Landmarks">
-		Ulubione Miejsca
+		Landmarki
 	</string>
 	<string name="InvFolder Scripts">
 		Skrypty
@@ -1085,28 +1085,28 @@
 		Noty
 	</string>
 	<string name="InvFolder New Folder">
-		Nowy Folder
+		Nowy folder
 	</string>
 	<string name="InvFolder Inventory">
 		Szafa
 	</string>
 	<string name="InvFolder Uncompressed Images">
-		Nieskompresowane Obrazy
+		Nieskompresowane obrazy
 	</string>
 	<string name="InvFolder Body Parts">
-		Części Ciała
+		Części ciała
 	</string>
 	<string name="InvFolder Trash">
 		Kosz
 	</string>
 	<string name="InvFolder Photo Album">
-		Album ze Zdjęciami
+		Album ze zdjęciami
 	</string>
 	<string name="InvFolder Lost And Found">
-		Zagubione i Odnalezione
+		Zagubione i odnalezione
 	</string>
 	<string name="InvFolder Uncompressed Sounds">
-		Nieskompresowane Dźwięki
+		Nieskompresowane dźwięki
 	</string>
 	<string name="InvFolder Animations">
 		Animacje
@@ -1115,13 +1115,13 @@
 		Gesturki
 	</string>
 	<string name="InvFolder Current Outfit">
-		Obecne Ubranie
+		Obecny strój
 	</string>
 	<string name="InvFolder Initial Outfits">
 		PoczÄ…tkowe stroje
 	</string>
 	<string name="InvFolder My Outfits">
-		Moje Ubranie
+		Moje stroje
 	</string>
 	<string name="InvFolder Accessories">
 		Akcesoria
@@ -1169,34 +1169,34 @@
 		Ctrl
 	</string>
 	<string name="Chest">
-		Klatka Piersiowa
+		Klatka piersiowa
 	</string>
 	<string name="Skull">
 		Czaszka
 	</string>
 	<string name="Left Shoulder">
-		Lewe RamiÄ™
+		Lewe ramiÄ™
 	</string>
 	<string name="Right Shoulder">
-		Prawe RamiÄ™
+		Prawe ramiÄ™
 	</string>
 	<string name="Left Hand">
-		Lewa Dłoń
+		Lewa dłoń
 	</string>
 	<string name="Right Hand">
-		Prawa Dłoń
+		Prawa dłoń
 	</string>
 	<string name="Left Foot">
-		Lewa Stopa
+		Lewa stopa
 	</string>
 	<string name="Right Foot">
-		Prawa Stopa
+		Prawa stopa
 	</string>
 	<string name="Spine">
 		Kręgosłup
 	</string>
 	<string name="Pelvis">
-		Mednica
+		Miednica
 	</string>
 	<string name="Mouth">
 		Usta
@@ -1205,16 +1205,16 @@
 		Szczęka
 	</string>
 	<string name="Left Ear">
-		Lewe Ucho
+		Lewe ucho
 	</string>
 	<string name="Right Ear">
-		Prawe Ucho
+		Prawe ucho
 	</string>
 	<string name="Left Eyeball">
-		Lewe Oko
+		Lewe oko
 	</string>
 	<string name="Right Eyeball">
-		Prawe Oko
+		Prawe oko
 	</string>
 	<string name="Nose">
 		Nos
@@ -1223,40 +1223,40 @@
 		P RamiÄ™
 	</string>
 	<string name="R Forearm">
-		P PrzedramiÄ™
+		P przedramiÄ™
 	</string>
 	<string name="L Upper Arm">
-		L RamiÄ™
+		L ramiÄ™
 	</string>
 	<string name="L Forearm">
-		L PrzedramiÄ™
+		L przedramiÄ™
 	</string>
 	<string name="Right Hip">
-		Prawe Biodro
+		Prawe biodro
 	</string>
 	<string name="R Upper Leg">
-		P Udo
+		P udo
 	</string>
 	<string name="R Lower Leg">
-		P Dolna Noga
+		P dolna noga
 	</string>
 	<string name="Left Hip">
-		Lewe Biodro
+		Lewe biodro
 	</string>
 	<string name="L Upper Leg">
-		L Udo
+		L udo
 	</string>
 	<string name="L Lower Leg">
-		L Dolna Noga
+		L dolna noga
 	</string>
 	<string name="Stomach">
 		Brzuch
 	</string>
 	<string name="Left Pec">
-		Left Pec
+		Lewy Pec
 	</string>
 	<string name="Right Pec">
-		Right Pec
+		Prawy Pec
 	</string>
 	<string name="YearsMonthsOld">
 		[AGEYEARS] [AGEMONTHS]
@@ -1328,49 +1328,49 @@
 		Proces
 	</string>
 	<string name="AcctTypeCharterMember">
-		Wyróżniony Członek
+		Wyróżniony członek
 	</string>
 	<string name="AcctTypeEmployee">
 		Pracownik Linden Lab
 	</string>
 	<string name="PaymentInfoUsed">
-		Dane Konta Używane
+		Dane konta używane
 	</string>
 	<string name="PaymentInfoOnFile">
-		Dane PÅ‚atnicze na Koncie
+		Dane płatnicze na koncie
 	</string>
 	<string name="NoPaymentInfoOnFile">
-		Brak Danych na Koncie
+		Brak danych na koncie
 	</string>
 	<string name="AgeVerified">
-		Weryfikacja Wieku Przeprowadzona
+		Weryfikacja wieku przeprowadzona
 	</string>
 	<string name="NotAgeVerified">
-		Brak Weryfikacji Wieku
+		Brak weryfikacji wieku
 	</string>
 	<string name="Center 2">
 		Åšrodek 2
 	</string>
 	<string name="Top Right">
-		Prawa Góra
+		Prawa góra
 	</string>
 	<string name="Top">
 		Góra
 	</string>
 	<string name="Top Left">
-		Lewa Góra
+		Lewa góra
 	</string>
 	<string name="Center">
 		Åšrodek
 	</string>
 	<string name="Bottom Left">
-		Lewy Dół
+		Lewy dół
 	</string>
 	<string name="Bottom">
 		Dół
 	</string>
 	<string name="Bottom Right">
-		Prawy Dół
+		Prawy dół
 	</string>
 	<string name="CompileQueueDownloadedCompiling">
 		Pobieranie zakończone, rozpoczęcie kompilacji
@@ -1391,7 +1391,7 @@
 		Nieznany błąd podczas próby pobierania
 	</string>
 	<string name="CompileQueueTitle">
-		Postęp Rekompilacji
+		Postęp rekompilacji
 	</string>
 	<string name="CompileQueueStart">
 		rekompiluj
@@ -1403,13 +1403,13 @@
 		zresetuj
 	</string>
 	<string name="RunQueueTitle">
-		Ustaw Uruchomiaj Progres
+		Ustaw uruchomiaj progres
 	</string>
 	<string name="RunQueueStart">
 		ustaw uruchom
 	</string>
 	<string name="NotRunQueueTitle">
-		Ustaw Nie Uruchamiaj Progres
+		Ustaw nie uruchamiaj progres
 	</string>
 	<string name="NotRunQueueStart">
 		ustaw nie uruchamiaj
@@ -1427,7 +1427,7 @@
 		Skrypt (obiekt poza zasięgiem)
 	</string>
 	<string name="GodToolsObjectOwnedBy">
-		Obiekt [OBJECT] należący [OWNER]
+		Obiekt [OBJECT] należący do [OWNER]
 	</string>
 	<string name="GroupsNone">
 		żadne
@@ -1483,10 +1483,10 @@
 		Grupy mające dostęp: ([ALLOWEDGROUPS], max [MAXACCESS])
 	</string>
 	<string name="ScriptLimitsParcelScriptMemory">
-		Pamięć Skryptów Parceli
+		Pamięć skryptów Posiadłości
 	</string>
 	<string name="ScriptLimitsParcelsOwned">
-		Parcele: [PARCELS]
+		Posiadłości: [PARCELS]
 	</string>
 	<string name="ScriptLimitsMemoryUsed">
 		Pamięć wykorzystana: [COUNT] kb z [MAX] kb; [AVAILABLE] kb pozostało
@@ -1495,7 +1495,7 @@
 		Pamięć wykorzystana: [COUNT] kb
 	</string>
 	<string name="ScriptLimitsParcelScriptURLs">
-		Skrypty URL Parceli
+		Skrypty URL Posiadłości
 	</string>
 	<string name="ScriptLimitsURLsUsed">
 		URL: [COUNT] z [MAX]; [AVAILABLE] dostępne
@@ -1516,7 +1516,7 @@
 		Wyszukiwanie informacji...
 	</string>
 	<string name="ScriptLimitsRequestDontOwnParcel">
-		Nie masz pozwolenia na sprawdzenie parceli.
+		Nie masz pozwolenia na sprawdzenie pasiadłości.
 	</string>
 	<string name="SITTING_ON">
 		Usiądź na
@@ -1528,22 +1528,22 @@
 		GÅ‚owa
 	</string>
 	<string name="ATTACH_LSHOULDER">
-		Lewe RamiÄ™
+		Lewe ramiÄ™
 	</string>
 	<string name="ATTACH_RSHOULDER">
-		RamiÄ™ Prawe
+		Prawe ramiÄ™
 	</string>
 	<string name="ATTACH_LHAND">
-		Ręka Lewa
+		Lewa ręka
 	</string>
 	<string name="ATTACH_RHAND">
-		Prawa Ręka
+		Prawa ręka
 	</string>
 	<string name="ATTACH_LFOOT">
-		Lewa Stopa
+		Lewa stopa
 	</string>
 	<string name="ATTACH_RFOOT">
-		Stopa Prawa
+		Prawa stopa
 	</string>
 	<string name="ATTACH_BACK">
 		Plecy
@@ -1558,22 +1558,22 @@
 		Podbródek
 	</string>
 	<string name="ATTACH_LEAR">
-		Ucho Lewe
+		Ucho lewe
 	</string>
 	<string name="ATTACH_REAR">
-		Prawe Ucho
+		Prawe ucho
 	</string>
 	<string name="ATTACH_LEYE">
-		Lewe Oko
+		Lewe oko
 	</string>
 	<string name="ATTACH_REYE">
-		Prawe Oko
+		Prawe oko
 	</string>
 	<string name="ATTACH_NOSE">
 		Nos
 	</string>
 	<string name="ATTACH_RUARM">
-		Ramię P Górne
+		Prawe górne ramię
 	</string>
 	<string name="ATTACH_RLARM">
 		Prawe dolne ramiÄ™
@@ -1588,19 +1588,19 @@
 		Biodro prawe
 	</string>
 	<string name="ATTACH_RULEG">
-		P Górna Noga
+		Prawa górna noga
 	</string>
 	<string name="ATTACH_RLLEG">
-		Noga P Dolna
+		Prawa dolna noga
 	</string>
 	<string name="ATTACH_LHIP">
-		Biodro Lewe
+		Biodro lewe
 	</string>
 	<string name="ATTACH_LULEG">
-		L Górna Noga
+		Lewa gorna noga
 	</string>
 	<string name="ATTACH_LLLEG">
-		Noga L Dolna
+		Lewa dolna noga
 	</string>
 	<string name="ATTACH_BELLY">
 		Brzuch
@@ -1612,28 +1612,28 @@
 		Lewa klatka
 	</string>
 	<string name="ATTACH_HUD_CENTER_2">
-		HUD Åšrodek 2
+		HUD środek 2
 	</string>
 	<string name="ATTACH_HUD_TOP_RIGHT">
-		HUD P Górny
+		HUD prawy górny
 	</string>
 	<string name="ATTACH_HUD_TOP_CENTER">
-		HUD Środek Górny
+		HUD środek górny
 	</string>
 	<string name="ATTACH_HUD_TOP_LEFT">
-		HUD L Góra
+		HUD lewa gora
 	</string>
 	<string name="ATTACH_HUD_CENTER_1">
-		HUD Åšrodek 1
+		HUD środek 1
 	</string>
 	<string name="ATTACH_HUD_BOTTOM_LEFT">
-		HUD Dolna L Strona
+		HUD lewa dolna strona
 	</string>
 	<string name="ATTACH_HUD_BOTTOM">
-		HUD Dolny
+		HUD dolny
 	</string>
 	<string name="ATTACH_HUD_BOTTOM_RIGHT">
-		HUD Dolna P Strona
+		HUD prawa dolna strona
 	</string>
 	<string name="Bad attachment point">
 		Nieprawidłowy punkt załączenia
@@ -1648,10 +1648,10 @@
 		Zawartość obiektu
 	</string>
 	<string name="PanelContentsNewScript">
-		Nowy Skrypt
+		Nowy skrypt
 	</string>
 	<string name="BusyModeResponseDefault">
-		Rezydent, do którego wysłałeś wiadomość prywatną znajduje się w trybie pracy. Oznacza to, iż Twoja wiadomość zostanie zapisana do przeglądnięcia poźniej.
+		Rezydent, do którego wysłałeś wiadomość prywatną znajduje się w trybie pracy. Oznacza to, iż Twoja wiadomość zostanie zapisana do przejrzenia poźniej.
 	</string>
 	<string name="NoOutfits">
 		Nie posiadasz jeszcze żadnych strojów. Spróbuj [secondlife:///app/search/all/ Szukaj]
@@ -1678,13 +1678,13 @@
 		Brak umowy dla tego majÄ…tku.
 	</string>
 	<string name="RegionNoCovenantOtherOwner">
-		Brak umowy dla tego majątku. Każda posiadłość w tym majątku została sprzedana przez Właściciela majątku nie Linden Lab. Skontaktuj się z właścicielem majątku w celu uzuskania szczegółów sprzedaży.
+		Brak umowy dla tego majątku. Każda posiadłość w tym majątku została sprzedana przez właściciela majątku nie Linden Lab. Skontaktuj się z właścicielem majątku w celu uzuskania szczegółów sprzedaży.
 	</string>
 	<string name="covenant_last_modified" value="Ostatnio modyfikowano:"/>
 	<string name="none_text" value=" (żadne) "/>
 	<string name="never_text" value=" (nigdy) "/>
 	<string name="GroupOwned">
-		Własność Grupy
+		Własność grupy
 	</string>
 	<string name="Public">
 		Publiczny
@@ -1768,7 +1768,7 @@
 		Zawartość
 	</string>
 	<string name="AcquiredItems">
-		Zdobyte Obiekty
+		Zdobyte obiekty
 	</string>
 	<string name="Cancel">
 		Anuluj
@@ -1814,7 +1814,7 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 		Shift+
 	</string>
 	<string name="FileSaved">
-		Zapisane Pliki
+		Zapisane pliki
 	</string>
 	<string name="Receiving">
 		Otrzymane
@@ -1832,13 +1832,13 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 		PDT
 	</string>
 	<string name="Forward">
-		Do Przodu
+		Do przodu
 	</string>
 	<string name="Left">
-		W Lewo
+		W lewo
 	</string>
 	<string name="Right">
-		W Prawo
+		W prawo
 	</string>
 	<string name="Back">
 		Wróć
@@ -1856,10 +1856,10 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 		Wschód
 	</string>
 	<string name="Up">
-		W Górę
+		W górę
 	</string>
 	<string name="Down">
-		W Dół
+		W dół
 	</string>
 	<string name="Any Category">
 		Każda Kategoria
@@ -1868,7 +1868,7 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 		Zakupy
 	</string>
 	<string name="Land Rental">
-		Wynajem Ziemi
+		Wynajem ziemi
 	</string>
 	<string name="Property Rental">
 		Wynajem Posiadłości
@@ -1877,7 +1877,7 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 		Specjalne Oferty
 	</string>
 	<string name="New Products">
-		Nowe Produkty
+		Nowe produkty
 	</string>
 	<string name="Employment">
 		Praca
@@ -1895,7 +1895,7 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 		Żadne
 	</string>
 	<string name="Linden Location">
-		Linden Lokacja
+		Linden Lokalizacja
 	</string>
 	<string name="Adult">
 		&apos;Adult&apos;
@@ -1919,7 +1919,7 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 		Przyjazne dla nowych
 	</string>
 	<string name="Parks&amp;Nature">
-		Park i Natura
+		Parki i Natura
 	</string>
 	<string name="Residential">
 		Mieszkalna
@@ -1937,10 +1937,10 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh
 		Ty
 	</string>
 	<string name="Multiple Media">
-		Multi Media
+		Multimedia
 	</string>
 	<string name="Play Media">
-		Uruchom/Zatrzymaj Media
+		Uruchom/Zatrzymaj media
 	</string>
 	<string name="MBCmdLineError">
 		Podczas realizacji podanej komendy, wystąpił błąd.
@@ -1958,14 +1958,14 @@ Jeżeli nadal otrzymujesz ten komunikat, uruchom swój komputer ponownie.
 Jeżeli problem nadal występuje, proponujemy całkowite odinstalowanie aplikacji [APP_NAME] oraz ponowną jej instalację.
 	</string>
 	<string name="MBFatalError">
-		BÅ‚Ä…d Krytyczny
+		BÅ‚Ä…d krytyczny
 	</string>
 	<string name="MBRequiresAltiVec">
 		Aplikacja [APP_NAME] wymaga procesora z AltiVec (wersja G4 lub starsza).
 	</string>
 	<string name="MBAlreadyRunning">
 		Aplikacja [APP_NAME] została już uruchomiona.
-Sprawdź czy Twój pasek aplikacji nie ma zminimaliwoanych okien programu.
+Sprawdź czy Twój pasek aplikacji nie ma zminimalizowanych okien programu.
 Jeżeli nadal otrzymujesz ten komunikat, uruchom swój komputer ponownie.
 	</string>
 	<string name="MBFrozenCrashed">
@@ -1977,7 +1977,7 @@ Czy chcesz wysłać raport na temat zawieszenia?
 	</string>
 	<string name="MBNoDirectX">
 		Aplikacja [APP_NAME] nie wykryła oprogramowania DirectX 9.0b lub wersji nowszej.
-[APP_NAME] używa oprogramowaniau DirectX w celu detekcji dysku twardego i/lub nieaktualizowanych dysków twardych, które mogą przyczynić się do obniżenia stabilności, wydajności systemoweu oraz zawieszeń. Jeżeli chcesz uruchomić aplikację [APP_NAME] bez problemów, doradzamy korzystanie z uruchomionym oprogramowaniem min. DirectX 9.0b.
+[APP_NAME] używa oprogramowaniau DirectX w celu wykrycia dysku twardego i/lub nieaktualizowanych dysków twardych, które mogą przyczynić się do obniżenia stabilności, wydajności systemowej oraz zawieszeń. Jeżeli chcesz uruchomić aplikację [APP_NAME] bez problemów, doradzamy korzystanie z uruchomionym oprogramowaniem min. DirectX 9.0b.
 
 Czy chcesz kontynuować?
 	</string>
@@ -1995,7 +1995,7 @@ Prosimy o pobranie najnowszej wersji ze strony internetowej: www.secondlife.com.
 		BÅ‚Ä…d
 	</string>
 	<string name="MBFullScreenErr">
-		Niemożliwość uruchomienia trybu pełnoekranowego w proporcji [WIDTH] x [HEIGHT].
+		Nie można uruchomić trybu pełnoekranowego w proporcji [WIDTH] x [HEIGHT].
 Uruchomione w oknie.
 	</string>
 	<string name="MBDestroyWinFailed">
@@ -2014,11 +2014,11 @@ Uruchomione w oknie.
 		Brak otrzymania formatu pikselowego opisu
 	</string>
 	<string name="MBTrueColorWindow">
-		Aplikacja [APP_NAME] wymaga ustawienia Koloru na (32-bit) do uruchomienia.
+		Aplikacja [APP_NAME] wymaga ustawienia koloru na (32-bit) do uruchomienia.
 Sprawdź swoje ustawienia dla wyświetlacza i ustaw tryb koloru na 32-bity.
 	</string>
 	<string name="MBAlpha">
-		Aplikacja [APP_NAME] nie może zostać uruchomiona z powodu niemożliwości dostania się na kanał 8 bitowy alpha. Najcześciej jest to spowodowane błędami sterowników karty video.
+		Aplikacja [APP_NAME] nie może zostać uruchomiona, ponieważ nie jest możliwe dostanie się na kanał 8 bitowy alpha. Najcześciej jest to spowodowane błędami sterowników karty video.
 Upewnij się, że posiadasz najnowsze aktualizacje sterowników karty video.
 Dodatkowo, sprawdź czy Twój monitor posiada poprawną konfigurację koloru (32-bity) w Panelu Kontroli &gt; Display &gt; Ustawienia.
 Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
@@ -2068,34 +2068,34 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Pasemka
 	</string>
 	<string name="Beady Eyes">
-		Oczy Załzawione
+		Oczy załzawione
 	</string>
 	<string name="Belly Size">
-		Rozmiar Brzucha
+		Rozmiar brzucha
 	</string>
 	<string name="Big">
 		Duży
 	</string>
 	<string name="Big Butt">
-		Duży Pośladek
+		Duży pośladek
 	</string>
 	<string name="Big Hair Back">
-		Duże Włosy: z tyłu
+		Duże włosy: z tyłu
 	</string>
 	<string name="Big Hair Front">
-		Duże Włosy: z przodu
+		Duże włosy: z przodu
 	</string>
 	<string name="Big Hair Top">
-		Duże Włosy: z góry
+		Duże włosy: z góry
 	</string>
 	<string name="Big Head">
-		Duża Głowa
+		Duża głowa
 	</string>
 	<string name="Big Pectorals">
-		Duże Mięśnie Piersiowe
+		Duże mięśnie piersiowe
 	</string>
 	<string name="Big Spikes">
-		Duże Kolce
+		Duże kolce
 	</string>
 	<string name="Black">
 		Czarne
@@ -2104,7 +2104,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Blond
 	</string>
 	<string name="Blonde Hair">
-		WÅ‚osy Blond
+		WÅ‚osy blond
 	</string>
 	<string name="Blush">
 		Rumieniec
@@ -2125,10 +2125,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Piegi
 	</string>
 	<string name="Body Thick">
-		Zagęszczenie Ciała
+		Zagęszczenie ciała
 	</string>
 	<string name="Body Thickness">
-		Grubość Ciała
+		Grubość ciała
 	</string>
 	<string name="Body Thin">
 		Szczupłość
@@ -2155,25 +2155,25 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Rozmiar czoła
 	</string>
 	<string name="Bug Eyes">
-		Bug Eyes
+		Wytrzeszcz oczu
 	</string>
 	<string name="Bugged Eyes">
-		Bugged Eyes
+		Wytrzeszczone oczy
 	</string>
 	<string name="Bulbous">
 		Bulwiasty
 	</string>
 	<string name="Bulbous Nose">
-		Bulwiasty Nos
+		Bulwiasty nos
 	</string>
 	<string name="Bushy Eyebrows">
-		Bujne Brwi
+		Bujne brwi
 	</string>
 	<string name="Bushy Hair">
-		Bujne WÅ‚osy
+		Bujne włosy
 	</string>
 	<string name="Butt Size">
-		Rozmiar Pośladków
+		Rozmiar pośladków
 	</string>
 	<string name="bustle skirt">
 		Bustle Skirt
@@ -2224,7 +2224,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Rozszczepienie
 	</string>
 	<string name="Close Set Eyes">
-		Close Set Eyes
+		Oczy blisko ustawione
 	</string>
 	<string name="Closed">
 		Zamknięte
@@ -2236,10 +2236,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Zamknięte z przodu
 	</string>
 	<string name="Closed Left">
-		Lewe Oko zamknięte
+		Lewe oko zamknięte
 	</string>
 	<string name="Closed Right">
-		Prawe Oko zamknięte
+		Prawe oko zamknięte
 	</string>
 	<string name="Coin Purse">
 		Coin Purse
@@ -2251,10 +2251,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Kołnierz z przodu
 	</string>
 	<string name="Corner Down">
-		Corner Down
+		Kącik w dół
 	</string>
 	<string name="Corner Up">
-		Corner Up
+		Kącik w górę
 	</string>
 	<string name="Creased">
 		Pognieciony
@@ -2263,7 +2263,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Skrzywienie nosa
 	</string>
 	<string name="Cuff Flare">
-		Cuff Flare
+		Szeroki rękaw
 	</string>
 	<string name="Dark">
 		Ciemne
@@ -2278,7 +2278,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Glębokie
 	</string>
 	<string name="Default Heels">
-		Domyślne Buty na Obcasie
+		Domyślne buty na obcasie
 	</string>
 	<string name="Dense">
 		Gęstość
@@ -2347,13 +2347,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Długość rzęs
 	</string>
 	<string name="Eyeliner">
-		Eyeliner
+		Kredka do oczu
 	</string>
 	<string name="Eyeliner Color">
-		Kolor Eyeliner&apos;a
+		Kolor kredki do oczu&apos;a
 	</string>
 	<string name="Eyes Bugged">
-		Eyes Bugged
+		Wytrzeszczone oczy
 	</string>
 	<string name="Face Shear">
 		Usunięcie twarzy
@@ -2362,7 +2362,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Detale twarzy
 	</string>
 	<string name="Far Set Eyes">
-		Far Set Eyes
+		Oczy szeroko rozstawione
 	</string>
 	<string name="Fat Lips">
 		Grube usta
@@ -2371,7 +2371,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Kobieta
 	</string>
 	<string name="Fingerless">
-		Fingerless
+		Bez palców
 	</string>
 	<string name="Fingers">
 		Palce
@@ -2404,7 +2404,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Piegi
 	</string>
 	<string name="Front Fringe">
-		Przednia Grzywka
+		Przednia grzywka
 	</string>
 	<string name="Full Back">
 		Gęstość włosów po bokach
@@ -2497,13 +2497,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Wysokie obcasy
 	</string>
 	<string name="High Jaw">
-		High Jaw
+		Wysoka szczęka
 	</string>
 	<string name="High Platforms">
-		High Platforms
+		Wysokie obcasy
 	</string>
 	<string name="High and Tight">
-		High and Tight
+		Wysokie i wÄ…skie
 	</string>
 	<string name="Higher">
 		Wyżej
@@ -2524,7 +2524,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Wewnętrzna intensywność cienia
 	</string>
 	<string name="Inner Eye Corner">
-		Wenwętrzny bok oka
+		Wewnętrzny bok oka
 	</string>
 	<string name="Inner Eye Shadow">
 		Wewnętrzny cień oka
@@ -2539,25 +2539,25 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Zmarszczki na kurtce
 	</string>
 	<string name="Jaw Angle">
-		Jaw Angle
+		Kąt szczęki
 	</string>
 	<string name="Jaw Jut">
-		Jaw Jut
+		Wystająca szczęka
 	</string>
 	<string name="Jaw Shape">
-		Jaw Shape
+		Kształt szczęki
 	</string>
 	<string name="Join">
 		ZÅ‚Ä…cz
 	</string>
 	<string name="Jowls">
-		Jowls
+		Dolna część policzka
 	</string>
 	<string name="Knee Angle">
 		KÄ…t kolana
 	</string>
 	<string name="Knock Kneed">
-		Knock Kneed
+		Iksowate nogi
 	</string>
 	<string name="Large">
 		Duże
@@ -2566,7 +2566,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Duże dłonie
 	</string>
 	<string name="Left Part">
-		Left Part
+		Lewa część
 	</string>
 	<string name="Leg Length">
 		Długość nogi
@@ -2584,13 +2584,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Less Curtains
 	</string>
 	<string name="Less Freckles">
-		Mniej Piegów
+		Mniej piegów
 	</string>
 	<string name="Less Full">
-		Mniej Pełne
+		Mniej pełne
 	</string>
 	<string name="Less Gravity">
-		Mniej Ciężaru
+		Mniej ciężaru
 	</string>
 	<string name="Less Love">
 		Less Love
@@ -2602,7 +2602,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Mniej umięśnienia
 	</string>
 	<string name="Less Rosy">
-		Less Rosy
+		Mniej zaróżowione
 	</string>
 	<string name="Less Round">
 		Mniej zaaokrÄ…glone
@@ -2623,7 +2623,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Lżejsze
 	</string>
 	<string name="Lip Cleft">
-		Szerokość Rozszczepienia górnej wargi
+		Szerokość rozszczepienia górnej wargi
 	</string>
 	<string name="Lip Cleft Depth">
 		Głębokość rozszczepienia górnej wargi
@@ -2701,7 +2701,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Niska szczęka
 	</string>
 	<string name="Low Platforms">
-		Low Platforms
+		Niskie obcasy
 	</string>
 	<string name="Low and Loose">
 		Niskie i luźne
@@ -2710,10 +2710,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Niżej
 	</string>
 	<string name="Lower Bridge">
-		Lower Bridge
+		Dolny mostek
 	</string>
 	<string name="Lower Cheeks">
-		Lower Cheeks
+		Niższe policzki
 	</string>
 	<string name="Male">
 		Mężczyzna
@@ -2725,7 +2725,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Więcej
 	</string>
 	<string name="More Blush">
-		More Blush
+		Bardziej zarumienione
 	</string>
 	<string name="More Body Fat">
 		Więcej zawartości tkanki tłuszczowej
@@ -2734,13 +2734,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		More Curtains
 	</string>
 	<string name="More Eyeshadow">
-		More Eyeshadow
+		Ciemniejszy cień oczu
 	</string>
 	<string name="More Freckles">
 		Więcej piegów
 	</string>
 	<string name="More Full">
-		More Full
+		Bardziej pełne
 	</string>
 	<string name="More Gravity">
 		Więcej ciężaru
@@ -2761,7 +2761,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Więcej umięśnienia
 	</string>
 	<string name="More Rosy">
-		More Rosy
+		Bardziej zaróżowione
 	</string>
 	<string name="More Round">
 		Więcej zaokrąglenia
@@ -2770,7 +2770,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		More Saddle
 	</string>
 	<string name="More Sloped">
-		More Sloped
+		Bardziej spadziste
 	</string>
 	<string name="More Square">
 		Więcej kwadratowy
@@ -2779,7 +2779,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Więcej górnej wargi
 	</string>
 	<string name="More Vertical">
-		More Vertical
+		Bardziej pionowe
 	</string>
 	<string name="More Volume">
 		Więcej objętości
@@ -2791,10 +2791,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		WÄ…sy
 	</string>
 	<string name="Mouth Corner">
-		KÄ…ciki Ust
+		KÄ…ciki ust
 	</string>
 	<string name="Mouth Position">
-		Pozycja Ust
+		Pozycja ust
 	</string>
 	<string name="Mowhawk">
 		Mowhawk
@@ -2815,13 +2815,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		WÄ…skie
 	</string>
 	<string name="Narrow Back">
-		Wąski Tył
+		Wąski tył
 	</string>
 	<string name="Narrow Front">
-		Wąski Przód
+		Wąski przód
 	</string>
 	<string name="Narrow Lips">
-		WÄ…skie Usta
+		WÄ…skie usta
 	</string>
 	<string name="Natural">
 		Naturalne
@@ -2833,10 +2833,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Grubość karku
 	</string>
 	<string name="No Blush">
-		No Blush
+		Brak rumieńca
 	</string>
 	<string name="No Eyeliner">
-		Brak Eyeliner&apos;s
+		Brak kredki do oczu&apos;s
 	</string>
 	<string name="No Eyeshadow">
 		Brak cienia pod powiekÄ…
@@ -2938,7 +2938,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Zewnętrzny cień
 	</string>
 	<string name="Overbite">
-		Overbite
+		Przodozgryz górny
 	</string>
 	<string name="Package">
 		Package
@@ -2947,13 +2947,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Pomalowane paznokcie
 	</string>
 	<string name="Pale">
-		Pale
+		Blady
 	</string>
 	<string name="Pants Crotch">
 		Krocze spodni
 	</string>
 	<string name="Pants Fit">
-		Pants Fit
+		Dopasowanie spodni
 	</string>
 	<string name="Pants Length">
 		Długość spodni
@@ -2968,7 +2968,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Część
 	</string>
 	<string name="Part Bangs">
-		Part Bangs
+		Część grzywki
 	</string>
 	<string name="Pectorals">
 		Mięśnie klatki piersiowej
@@ -2977,7 +2977,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Pigment
 	</string>
 	<string name="Pigtails">
-		Pigtails
+		Warkocz
 	</string>
 	<string name="Pink">
 		Różowe
@@ -2986,16 +2986,16 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Róż
 	</string>
 	<string name="Platform Height">
-		Platform Height
+		Wysokie obcasy
 	</string>
 	<string name="Platform Width">
-		Platform Width
+		Szerokie obcasy
 	</string>
 	<string name="Pointy">
 		Pointy
 	</string>
 	<string name="Pointy Heels">
-		Pointy Heels
+		Obcasy pointy
 	</string>
 	<string name="Ponytail">
 		Kucyk
@@ -3004,22 +3004,22 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Poofy Skirt
 	</string>
 	<string name="Pop Left Eye">
-		Pop Left Eye
+		Wybałuszone lewe oko
 	</string>
 	<string name="Pop Right Eye">
-		Pop Right Eye
+		Wybałuszone prawe oko
 	</string>
 	<string name="Puffy">
-		Puffy
+		Opuchnięty
 	</string>
 	<string name="Puffy Eyelids">
-		Spuchnięte Powieki
+		Spuchnięte powieki
 	</string>
 	<string name="Rainbow Color">
-		Kolor Tęczy
+		Kolor tęczy
 	</string>
 	<string name="Red Hair">
-		Czerwone WÅ‚osy
+		Czerwone włosy
 	</string>
 	<string name="Regular">
 		Regularne
@@ -3040,13 +3040,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Rudy
 	</string>
 	<string name="Rumpled Hair">
-		Włosy w Nieładzie
+		Włosy w nieładzie
 	</string>
 	<string name="Saddle Bags">
 		Saddle Bags
 	</string>
 	<string name="Scrawny Leg">
-		Scrawny Leg
+		Koścista noga
 	</string>
 	<string name="Separate">
 		Odzielne
@@ -3085,13 +3085,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Przesuń w prawo
 	</string>
 	<string name="Shirt Bottom">
-		Dolna Część Koszulki
+		Dolna część koszuli
 	</string>
 	<string name="Shirt Fit">
-		Shirt Fit
+		Dopasowanie koszuli
 	</string>
 	<string name="Shirt Wrinkles">
-		Zmarszczki na koszulce
+		Zmarszczki na koszuli
 	</string>
 	<string name="Shoe Height">
 		Wysokość buta
@@ -3109,13 +3109,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Krótki kark
 	</string>
 	<string name="Short Pigtails">
-		Short Pigtails
+		Krótkie warkoczyki
 	</string>
 	<string name="Short Ponytail">
-		Krótki Kucyk
+		Krótki kucyk
 	</string>
 	<string name="Short Sideburns">
-		Krótkie Baczki
+		Krótkie baczki
 	</string>
 	<string name="Short Torso">
 		Krótki tułów
@@ -3133,19 +3133,19 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Baczki
 	</string>
 	<string name="Sides Hair">
-		Boczne WÅ‚osy
+		Boczne włosy
 	</string>
 	<string name="Sides Hair Down">
-		Boczne Włosy w Dół
+		Boczne włosy w dół
 	</string>
 	<string name="Sides Hair Up">
-		Boczne Włosy do Góry
+		Boczne włosy do góry
 	</string>
 	<string name="Skinny Neck">
-		Smukły Kark
+		Smukły kark
 	</string>
 	<string name="Skirt Fit">
-		Skirt Fit
+		Dopasowanie spódnicy
 	</string>
 	<string name="Skirt Length">
 		Długość spódnicy
@@ -3157,19 +3157,19 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Długość rękawów
 	</string>
 	<string name="Sleeve Looseness">
-		Luźność rękawów
+		Luźne rękawy
 	</string>
 	<string name="Slit Back">
-		Slit: Back
+		Rozcięcie: tył
 	</string>
 	<string name="Slit Front">
-		Slit: Front
+		Rozcięcie: przód
 	</string>
 	<string name="Slit Left">
-		Slit: Left
+		Rozcięcie: po prawej
 	</string>
 	<string name="Slit Right">
-		Slit: Right
+		Rozcięcie: po lewej
 	</string>
 	<string name="Small">
 		Małe
@@ -3190,13 +3190,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Długość skarpetek
 	</string>
 	<string name="Soulpatch">
-		Soulpatch
+		Zarost na dolnej wardze
 	</string>
 	<string name="Sparse">
-		Sparse
+		Rzadki
 	</string>
 	<string name="Spiked Hair">
-		Kolczaste WÅ‚osy
+		Kolczaste włosy
 	</string>
 	<string name="Square">
 		Kwadratowe
@@ -3211,13 +3211,13 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Rozciągnięta głowa
 	</string>
 	<string name="Sunken">
-		Sunken
+		Zapadnięte
 	</string>
 	<string name="Sunken Chest">
-		Sunken Chest
+		Zapadnięta klatka piersiowa
 	</string>
 	<string name="Sunken Eyes">
-		Sunken Eyes
+		Zapadnięte oczy
 	</string>
 	<string name="Sweep Back">
 		Sweep Back
@@ -3229,10 +3229,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Wysokość
 	</string>
 	<string name="Taper Back">
-		Taper Back
+		Zwężenie do przodu
 	</string>
 	<string name="Taper Front">
-		Taper Front
+		Zwężenie do tyłu
 	</string>
 	<string name="Thick Heels">
 		Grube obcasy
@@ -3295,7 +3295,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Uncreased
 	</string>
 	<string name="Underbite">
-		Underbite
+		Przodozgryz
 	</string>
 	<string name="Unnatural">
 		Nienaturalne
@@ -3322,7 +3322,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Wysokość talii
 	</string>
 	<string name="Well-Fed">
-		Well-Fed
+		Dobrze odżywiony
 	</string>
 	<string name="White Hair">
 		Białe włosy
@@ -3346,10 +3346,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Zmarszczki
 	</string>
 	<string name="LocationCtrlAddLandmarkTooltip">
-		Dodaj do Zapisanych Miejsc
+		Dodaj do landmarków
 	</string>
 	<string name="LocationCtrlEditLandmarkTooltip">
-		Edytuj Zapisane Miejsca
+		Edytuj Landmarki
 	</string>
 	<string name="LocationCtrlInfoBtnTooltip">
 		Zobacz więcej szczegółów na temat obecnej lokalizacji
@@ -3445,7 +3445,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Rozmowa głosowa...
 	</string>
 	<string name="connected-im">
-		Połączono, kliknij Zakończ Rozmowe aby się rozłączyć
+		Połączono, kliknij Zakończ rozmowę aby się rozłączyć
 	</string>
 	<string name="hang_up-im">
 		Rozmowa głosowa zakończona
@@ -3517,7 +3517,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		[SOURCES] powiedział/a coś nowego
 	</string>
 	<string name="session_initialization_timed_out_error">
-		Inicjalizacja sesji wygasła
+		Inicjacja sesji wygasła
 	</string>
 	<string name="voice_morphing_url">
 		http://secondlife.com/landing/voicemorphing
@@ -3538,7 +3538,7 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].
 		Zapłacono [AMOUNT]L$ [REASON].
 	</string>
 	<string name="for a parcel of land">
-		za posiadłość
+		za Posiadłość
 	</string>
 	<string name="for a land access pass">
 		za przepustkę na Posiadłość
@@ -3627,7 +3627,7 @@ Raport o Nadużyciu
 		Nowa spódnica
 	</string>
 	<string name="New Alpha">
-		Nowa Alpha
+		Nowa alpha
 	</string>
 	<string name="New Tattoo">
 		Nowy tatuaż
@@ -3636,7 +3636,7 @@ Raport o Nadużyciu
 		Nieaktualne ubranie/część ciała
 	</string>
 	<string name="New Gesture">
-		Nowy gest
+		Nowa gesturka
 	</string>
 	<string name="New Script">
 		Nowy skrypt
@@ -3675,7 +3675,7 @@ Raport o Nadużyciu
 		Mężczyzna - Get lost
 	</string>
 	<string name="Male - Blow kiss">
-		Mężczyzna - Blow kiss
+		Mężczyzna - Całusek
 	</string>
 	<string name="Male - Boo">
 		Mężczyzna - Boo
@@ -3717,7 +3717,7 @@ Raport o Nadużyciu
 		Kobieta - Get lost
 	</string>
 	<string name="Female - Blow kiss">
-		Kobieta - Blow kiss
+		Kobieta - Całusek
 	</string>
 	<string name="Female - Boo">
 		Kobieta - Boo
@@ -3802,7 +3802,7 @@ Raport o Nadużyciu
 		Funkcje
 	</string>
 	<string name="Group Identity">
-		Status Grupy
+		Status grupy
 	</string>
 	<string name="Parcel Management">
 		Parcel Management
diff --git a/indra/newview/skins/default/xui/pl/teleport_strings.xml b/indra/newview/skins/default/xui/pl/teleport_strings.xml
index 6c4723dd7ec..57fb55bf4ca 100644
--- a/indra/newview/skins/default/xui/pl/teleport_strings.xml
+++ b/indra/newview/skins/default/xui/pl/teleport_strings.xml
@@ -2,12 +2,12 @@
 <teleport_messages>
 	<message_set name="errors">
 		<message name="invalid_tport">
-			Przepraszamy, ale pojawił się błąd podczas Twojej próby teleportacji. By ponowić teleportację, wyloguj się i zaloguj ponownie.
-Jeżeli nadal otrzymujesz komunikat błędu teleportacji, sprawdź [SUPPORT_SITE].
+			Przepraszamy, ale pojawił się błąd podczas Twojej próby teleportacji. Aby ponowić teleportację, wyloguj się i zaloguj ponownie.
+Jeżeli nadal otrzymujesz komunikat o błędzie teleportacji, sprawdź [SUPPORT_SITE].
 		</message>
 		<message name="invalid_region_handoff">
-			Przepraszamy, ale pojawił się błąd podczas próby zmiany regionu. By ponowić próbę przejścia na drugi region, wyloguj się i zaloguj ponownie.
-Jeżeli nadal otrzymujesz komunikat błędu podczas przejścia na drugi region, sprawdź [SUPPORT_SITE].
+			Przepraszamy, ale pojawił się błąd podczas próby zmiany regionu. Aby ponowić próbę przejścia na drugi region, wyloguj się i zaloguj ponownie.
+Jeżeli nadal otrzymujesz komunikat o błędzie podczas przejścia na drugi region, sprawdź [SUPPORT_SITE].
 		</message>
 		<message name="blocked_tport">
 			Przepraszamy, teleportacja jest chwilowo niedostępna. Spróbuj jeszcze raz.
@@ -26,7 +26,7 @@ Jeśli nadal nie możesz się teleportować wyloguj się i ponownie zaloguj.
 			Czekamy na Twoje akcesoria. Możesz poczekać kilka minut lub zrobić relog przed następną próbą teleportacji.
 		</message>
 		<message name="too_many_uploads_tport">
-			Obecnie ten region ma problemy z ładowaniem obiektów w związku z czym teleportacja bardzo sie opóznia.
+			Obecnie ten region ma problemy z ładowaniem obiektów, w związku z czym teleportacja bardzo sie opóźnia.
 Spróbuj jeszcze raz za kilka minut albo teleportuj się do mniej zatłoczonego miejsca.
 		</message>
 		<message name="expired_tport">
@@ -36,7 +36,7 @@ Spróbuj jeszcze raz za kilka minut albo teleportuj się do mniej zatłoczonego
 			Przepraszamy, ale nie udało się przeprowadzić zmiany regionu wystarczająco szybko. Spróbuj jeszcze raz za kilka minut.
 		</message>
 		<message name="no_host">
-			Nie możemy znaleść miejsca docelowego. To miejsce może być chwilowo nieosiągalne albo przestało istnieć.
+			Nie możemy znaleźć miejsca docelowego. To miejsce może być chwilowo nieosiągalne albo przestało istnieć.
 Spróbuj jeszcze raz za kilka minut.
 		</message>
 		<message name="no_inventory_host">
@@ -57,7 +57,7 @@ Spróbuj jeszcze raz za kilka minut.
 			Wysyłanie do miejsca startu.
 		</message>
 		<message name="sending_landmark">
-			Lokalizowanie zapamiętanego miejsca (LM).
+			Lokalizowanie landmarka(LM).
 		</message>
 		<message name="completing">
 			Finalizowanie teleportacji.
-- 
GitLab


From b27c892bc560831d912d98156d904b5cd2713c66 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Tue, 17 Aug 2010 22:34:50 +0300
Subject: [PATCH 660/683] EXT-8357 FIXED ESC key sometimes failing to de-focus
 the sidebar.

I've found out that the only case when pressing ESC doesn't transfer focus from side tray to game area is
when a flat list view (people, groups, teleport history, etc) is focused.
So, I fixed LLFlatListView to handle pressing ESC as expected.

Reviewed by Sergey Litovchuk at https://codereview.productengine.com/secondlife/r/862/

--HG--
branch : product-engine
---
 indra/llui/llflatlistview.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index 70558f8eb81..8de44455de0 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -669,6 +669,14 @@ BOOL LLFlatListView::handleKeyHere(KEY key, MASK mask)
 			}
 			break;
 		}
+		case KEY_ESCAPE:
+		{
+			if (mask == MASK_NONE)
+			{
+				setFocus(FALSE); // pass focus to the game area (EXT-8357)
+			}
+			break;
+		}
 		default:
 			break;
 	}
-- 
GitLab


From b2792c336cd56c9eef153cdfff6662edeac7b922 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Tue, 17 Aug 2010 22:40:28 +0300
Subject: [PATCH 661/683] EXT-8564 FIXED Ability to take off wearables via
 "Wearing" Tab of My Outfits.

Added Take Off / Detach options to the Wearing tab context menu.

Reviewed by Sergey Litovchuk at https://codereview.productengine.com/secondlife/r/864/

--HG--
branch : product-engine
---
 indra/newview/llpanelwearing.cpp              | 51 ++++++++++++++++++-
 .../skins/default/xui/en/menu_wearing_tab.xml | 18 +++++++
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp
index b8852890add..fd7ca39c72a 100644
--- a/indra/newview/llpanelwearing.cpp
+++ b/indra/newview/llpanelwearing.cpp
@@ -87,9 +87,58 @@ class LLWearingContextMenu : public LLListContextMenu
 	{
 		LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
 
+		functor_t take_off = boost::bind(&LLAppearanceMgr::removeItemFromAvatar, LLAppearanceMgr::getInstance(), _1);
+
 		registrar.add("Wearing.Edit", boost::bind(&edit_outfit));
+		registrar.add("Wearing.TakeOff", boost::bind(handleMultiple, take_off, mUUIDs));
+		registrar.add("Wearing.Detach", boost::bind(handleMultiple, take_off, mUUIDs));
+
+		LLContextMenu* menu = createFromFile("menu_wearing_tab.xml");
+
+		updateMenuItemsVisibility(menu);
 
-		return createFromFile("menu_wearing_tab.xml");
+		return menu;
+	}
+
+	void updateMenuItemsVisibility(LLContextMenu* menu)
+	{
+		bool bp_selected			= false;	// true if body parts selected
+		bool clothes_selected		= false;
+		bool attachments_selected	= false;
+
+		// See what types of wearables are selected.
+		for (uuid_vec_t::const_iterator it = mUUIDs.begin(); it != mUUIDs.end(); ++it)
+		{
+			LLViewerInventoryItem* item = gInventory.getItem(*it);
+
+			if (!item)
+			{
+				llwarns << "Invalid item" << llendl;
+				continue;
+			}
+
+			LLAssetType::EType type = item->getType();
+			if (type == LLAssetType::AT_CLOTHING)
+			{
+				clothes_selected = true;
+			}
+			else if (type == LLAssetType::AT_BODYPART)
+			{
+				bp_selected = true;
+			}
+			else if (type == LLAssetType::AT_OBJECT)
+			{
+				attachments_selected = true;
+			}
+		}
+
+		// Enable/disable some menu items depending on the selection.
+		bool allow_detach = !bp_selected && !clothes_selected && attachments_selected;
+		bool allow_take_off = !bp_selected && clothes_selected && !attachments_selected;
+
+		menu->setItemVisible("take_off",	allow_take_off);
+		menu->setItemVisible("detach",		allow_detach);
+		menu->setItemVisible("edit_outfit_separator", allow_take_off || allow_detach);
 	}
 };
 
diff --git a/indra/newview/skins/default/xui/en/menu_wearing_tab.xml b/indra/newview/skins/default/xui/en/menu_wearing_tab.xml
index 85505f99727..2d54e696013 100644
--- a/indra/newview/skins/default/xui/en/menu_wearing_tab.xml
+++ b/indra/newview/skins/default/xui/en/menu_wearing_tab.xml
@@ -2,6 +2,24 @@
 <context_menu
  layout="topleft"
  name="Wearing">
+    <menu_item_call
+     label="Take Off"
+     layout="topleft"
+     name="take_off">
+        <on_click
+         function="Wearing.TakeOff" />
+    </menu_item_call>
+    <menu_item_call
+     label="Detach"
+     layout="topleft"
+     name="detach">
+        <on_click
+         function="Wearing.Detach"
+         parameter="detach"/>
+    </menu_item_call>
+    <menu_item_separator
+     layout="topleft"
+     name="edit_outfit_separator" />
     <menu_item_call
      label="Edit Outfit"
      layout="topleft"
-- 
GitLab


From a84b44bc141319bb99796492d44e67bfd1b2fba9 Mon Sep 17 00:00:00 2001
From: Eli Linden <eli@lindenlab.com>
Date: Tue, 17 Aug 2010 13:02:46 -0700
Subject: [PATCH 662/683] CT-575 PL linguistic

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

diff --git a/indra/newview/skins/default/xui/pl/notifications.xml b/indra/newview/skins/default/xui/pl/notifications.xml
index 75b6f5be0d7..7fcd7b5e04d 100644
--- a/indra/newview/skins/default/xui/pl/notifications.xml
+++ b/indra/newview/skins/default/xui/pl/notifications.xml
@@ -67,8 +67,8 @@ Szczegóły błędu: Błąd o nazwie &apos;[_NAME]&apos; nie został odnaleziony
 		[MESSAGE]
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="Tak"/>
 	</notification>
-	<notification name="BadInstallation">
-		Podczas aktualizacji [APP_NAME] wystąpił błąd. Proszę odwiedzić stronę [http://get.secondlife.com download the latest version] by ściągnąć najnowszą wersje klienta.
+	<notification name="BadInstallation">		
+		Podczas aktualizacji [APP_NAME] wystąpił błąd. Proszę odwiedzić stronę [http://get.secondlife.com pobierz najnowsza wersję] aby ściągnąć ostatnią wersję klienta.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="LoginFailedNoNetwork">
-- 
GitLab


From 7c10d5025bdfb14e771ae2308d8a4a4641606b0a Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Wed, 18 Aug 2010 12:10:25 +0300
Subject: [PATCH 663/683] EXT-7951 FIXED (Mini-Location panel appearance design
 issues: Replaced dark icons with light ones)

- Replaced dark icons with light ones

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/858/

--HG--
branch : product-engine
---
 .../newview/skins/default/xui/en/panel_topinfo_bar.xml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/indra/newview/skins/default/xui/en/panel_topinfo_bar.xml b/indra/newview/skins/default/xui/en/panel_topinfo_bar.xml
index d8f4297e0cc..30d3064e143 100644
--- a/indra/newview/skins/default/xui/en/panel_topinfo_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_topinfo_bar.xml
@@ -36,7 +36,7 @@
     enabled="true"
     follows="right|top"
     height="18"
-    image_name="Parcel_VoiceNo_Light"
+    image_name="Parcel_VoiceNo_Dark"
     name="voice_icon"
     top="1"
     visible="false"
@@ -45,7 +45,7 @@
   <icon
     follows="right|top"
     height="18"
-    image_name="Parcel_FlyNo_Light"
+    image_name="Parcel_FlyNo_Dark"
     name="fly_icon"
     top="1"
     visible="false"
@@ -54,7 +54,7 @@
   <icon
     follows="right|top"
     height="18"
-    image_name="Parcel_PushNo_Light"
+    image_name="Parcel_PushNo_Dark"
     name="push_icon"
     top="1"
     visible="false"
@@ -63,7 +63,7 @@
   <icon
     follows="right|top"
     height="18"
-    image_name="Parcel_BuildNo_Light"
+    image_name="Parcel_BuildNo_Dark"
     name="build_icon"
     top="1"
     visible="false"
@@ -72,7 +72,7 @@
   <icon
     follows="right|top"
     height="18"
-    image_name="Parcel_ScriptsNo_Light"
+    image_name="Parcel_ScriptsNo_Dark"
     name="scripts_icon"
     top="1"
     visible="false"
-- 
GitLab


From 1435a9cff9e7eca67605890ce85a359099964df5 Mon Sep 17 00:00:00 2001
From: "Nyx (Neal Orman)" <nyx@lindenlab.com>
Date: Wed, 18 Aug 2010 10:46:40 -0400
Subject: [PATCH 664/683] EXT-8542 FIX (?) Avatar goes nude on teleport /
 outfit change

Believed fix, but having difficulty reproducing to verify.
changed logic in switching avatar textures so that we don't use the local
baked texture until we have at least the lowest LOD for each clothing texture.

Will ask Dan to help verify the fix.

Code reviewed by Seraph
---
 indra/newview/lltexlayer.cpp |   4 +
 indra/newview/llvoavatar.cpp | 244 ++++++++++++++++++++++++++++-------
 2 files changed, 204 insertions(+), 44 deletions(-)

diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index 1feb987682f..d8b9bc2329f 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -581,6 +581,10 @@ void LLTexLayerSetBuffer::doUpdate()
 	}
 
 	restartUpdateTimer();
+
+	// need to swtich to using this layerset if this is the first update
+	// after getting the lowest LOD
+	mTexLayerSet->getAvatar()->updateMeshTextures();
 	
 	// Print out notification that we uploaded this texture.
 	if (gSavedSettings.getBOOL("DebugAvatarRezTime"))
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 6392aad2488..c6883380009 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -702,8 +702,10 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 		mBakedTextureDatas[i].mTextureIndex = LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)i);
 	}
 
-	mDirtyMesh = 2;	// Dirty geometry, need to regenerate.
+	mDirtyMesh = TRUE;	// Dirty geometry, need to regenerate.
 	mMeshTexturesDirty = FALSE;
+	mShadow0Facep = NULL;
+	mShadow1Facep = NULL;
 	mHeadp = NULL;
 
 	mIsBuilt = FALSE;
@@ -739,6 +741,12 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 
 	mRippleTimeLast = 0.f;
 
+	mShadowImagep = LLViewerTextureManager::getFetchedTextureFromFile("foot_shadow.j2c");
+	
+	// GL NOT ACTIVE HERE
+	//gGL.getTexUnit(0)->bind(mShadowImagep.get());
+	//mShadowImagep->setAddressMode(LLTexUnit::TAM_CLAMP);
+	
 	mInAir = FALSE;
 
 	mStepOnLand = TRUE;
@@ -1967,7 +1975,7 @@ void LLVOAvatar::updateMeshData()
 			}
 			if(num_vertices < 1)//skip empty meshes
 			{
-				continue ;
+				break ;
 			}
 			if(last_v_num > 0)//put the last inserted part into next vertex buffer.
 			{
@@ -1989,8 +1997,6 @@ void LLVOAvatar::updateMeshData()
 			// resize immediately
 			facep->setSize(num_vertices, num_indices);
 
-			bool terse_update = false;
-
 			if(facep->mVertexBuffer.isNull())
 			{
 				facep->mVertexBuffer = new LLVertexBufferAvatar();
@@ -1998,16 +2004,8 @@ void LLVOAvatar::updateMeshData()
 			}
 			else
 			{
-				if (facep->mVertexBuffer->getRequestedIndices() == num_indices &&
-					facep->mVertexBuffer->getRequestedVerts() == num_vertices)
-				{
-					terse_update = true;
-				}
-				else
-				{
 				facep->mVertexBuffer->resizeBuffer(num_vertices, num_indices) ;
 			}
-			}
 		
 			facep->setGeomIndex(0);
 			facep->setIndicesIndex(0);
@@ -2021,7 +2019,7 @@ void LLVOAvatar::updateMeshData()
 
 			for(S32 k = j ; k < part_index ; k++)
 			{
-				mMeshLOD[k]->updateFaceData(facep, mAdjustedPixelArea, k == MESH_ID_HAIR, terse_update);
+				mMeshLOD[k]->updateFaceData(facep, mAdjustedPixelArea, k == MESH_ID_HAIR);
 			}
 
 			stop_glerror();
@@ -2431,6 +2429,12 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 	LLJoint::sNumUpdates = 0;
 	LLJoint::sNumTouches = 0;
 
+	// *NOTE: this is necessary for the floating name text above your head.
+	if (mDrawable.notNull())
+	{
+		gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_SHADOW, TRUE);
+	}
+
 	BOOL visible = isVisible() || mNeedsAnimUpdate;
 
 	// update attachments positions
@@ -3783,20 +3787,13 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 		return num_indices;
 	}
 
-	LLFace* face = mDrawable->getFace(0);
-
-	bool needs_rebuild = !face || face->mVertexBuffer.isNull() || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY);
-
-	if (needs_rebuild || mDirtyMesh)
+	if (mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
-		if (needs_rebuild || mDirtyMesh >= 2 || mVisibilityRank <= 4)
-		{
 		updateMeshData();
-			mDirtyMesh = 0;
+		mDirtyMesh = FALSE;
 		mNeedsSkin = TRUE;
 		mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
 	}
-	}
 
 	if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0)
 	{
@@ -4043,6 +4040,54 @@ U32 LLVOAvatar::renderRigid()
 	return num_indices;
 }
 
+U32 LLVOAvatar::renderFootShadows()
+{
+	U32 num_indices = 0;
+
+	if (!mIsBuilt)
+	{
+		return 0;
+	}
+
+	if (isSelf() && (!gAgent.needsRenderAvatar() || !gAgent.needsRenderHead()))
+	{
+		return 0;
+	}
+	
+	if (!mIsBuilt)
+	{
+		return 0;
+	}
+	
+	// Don't render foot shadows if your lower body is completely invisible.
+	// (non-humanoid avatars rule!)
+	if (!isTextureVisible(TEX_LOWER_BAKED))
+	{
+		return 0;
+	}
+
+	// Update the shadow, tractor, and text label geometry.
+	if (mDrawable->isState(LLDrawable::REBUILD_SHADOW) && !isImpostor())
+	{
+		updateShadowFaces();
+		mDrawable->clearState(LLDrawable::REBUILD_SHADOW);
+	}
+
+	U32 foot_mask = LLVertexBuffer::MAP_VERTEX |
+					LLVertexBuffer::MAP_TEXCOORD0;
+
+	LLGLDepthTest test(GL_TRUE, GL_FALSE);
+	//render foot shadows
+	LLGLEnable blend(GL_BLEND);
+	gGL.getTexUnit(0)->bind(mShadowImagep, TRUE);
+	glColor4fv(mShadow0Facep->getRenderColor().mV);
+	mShadow0Facep->renderIndexed(foot_mask);
+	glColor4fv(mShadow1Facep->getRenderColor().mV);
+	mShadow1Facep->renderIndexed(foot_mask);
+	
+	return num_indices;
+}
+
 U32 LLVOAvatar::renderImpostor(LLColor4U color, S32 diffuse_channel)
 {
 	if (!mImpostor.isComplete())
@@ -4168,6 +4213,11 @@ void LLVOAvatar::updateTextures()
 	{
 		setDebugText(llformat("%4.0f:%4.0f", fsqrtf(mMinPixelArea),fsqrtf(mMaxPixelArea)));
 	}	
+	
+	if( render_avatar )
+	{
+		mShadowImagep->addTextureStats(mPixelArea);
+	}
 }
 
 
@@ -5434,7 +5484,7 @@ BOOL LLVOAvatar::updateJointLODs()
  		if (res)
 		{
 			sNumLODChangesThisFrame++;
-			dirtyMesh(2);
+			dirtyMesh();
 			return TRUE;
 		}
 	}
@@ -5458,9 +5508,18 @@ LLDrawable *LLVOAvatar::createDrawable(LLPipeline *pipeline)
 	mDrawable->addFace(poolp, NULL);
 	mDrawable->setRenderType(LLPipeline::RENDER_TYPE_AVATAR);
 	
+	LLFace *facep;
+
+	// Add faces for the foot shadows
+	facep = mDrawable->addFace((LLFacePool*) NULL, mShadowImagep);
+	mShadow0Facep = facep;
+
+	facep = mDrawable->addFace((LLFacePool*) NULL, mShadowImagep);
+	mShadow1Facep = facep;
+
 	mNumInitFaces = mDrawable->getNumFaces() ;
 
-	dirtyMesh(2);
+	dirtyMesh();
 	return mDrawable;
 }
 
@@ -5499,6 +5558,107 @@ BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable)
 	return TRUE;
 }
 
+//-----------------------------------------------------------------------------
+// updateShadowFaces()
+//-----------------------------------------------------------------------------
+void LLVOAvatar::updateShadowFaces()
+{
+	LLFace *face0p = mShadow0Facep;
+	LLFace *face1p = mShadow1Facep;
+
+	//
+	// render avatar shadows
+	//
+	if (mInAir || mUpdatePeriod >= IMPOSTOR_PERIOD)
+	{
+		face0p->setSize(0, 0);
+		face1p->setSize(0, 0);
+		return;
+	}
+
+	LLSprite sprite(mShadowImagep.notNull() ? mShadowImagep->getID() : LLUUID::null);
+	sprite.setFollow(FALSE);
+	const F32 cos_angle = gSky.getSunDirection().mV[2];
+	F32 cos_elev = sqrt(1 - cos_angle * cos_angle);
+	if (cos_angle < 0) cos_elev = -cos_elev;
+	sprite.setSize(0.4f + cos_elev * 0.8f, 0.3f);
+	LLVector3 sun_vec = gSky.mVOSkyp ? gSky.mVOSkyp->getToSun() : LLVector3(0.f, 0.f, 0.f);
+
+	if (mShadowImagep->hasGLTexture())
+	{
+		LLVector3 normal;
+		LLVector3d shadow_pos;
+		LLVector3 shadow_pos_agent;
+		F32 foot_height;
+
+		if (mFootLeftp)
+		{
+			LLVector3 joint_world_pos = mFootLeftp->getWorldPosition();
+			// this only does a ray straight down from the foot, as our client-side ray-tracing is very limited now
+			// but we make an explicit ray trace call in expectation of future improvements
+			resolveRayCollisionAgent(gAgent.getPosGlobalFromAgent(joint_world_pos), 
+									 gAgent.getPosGlobalFromAgent(gSky.getSunDirection() + joint_world_pos), shadow_pos, normal);
+			shadow_pos_agent = gAgent.getPosAgentFromGlobal(shadow_pos);
+			foot_height = joint_world_pos.mV[VZ] - shadow_pos_agent.mV[VZ];
+
+			// Pull sprite in direction of surface normal
+			shadow_pos_agent += normal * SHADOW_OFFSET_AMT;
+
+			// Render sprite
+			sprite.setNormal(normal);
+			if (isSelf() && gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+			{
+				sprite.setColor(0.f, 0.f, 0.f, 0.f);
+			}
+			else
+			{
+				sprite.setColor(0.f, 0.f, 0.f, clamp_rescale(foot_height, MIN_SHADOW_HEIGHT, MAX_SHADOW_HEIGHT, 0.5f, 0.f));
+			}
+			sprite.setPosition(shadow_pos_agent);
+
+			LLVector3 foot_to_knee = mKneeLeftp->getWorldPosition() - joint_world_pos;
+			//foot_to_knee.normalize();
+			foot_to_knee -= projected_vec(foot_to_knee, sun_vec);
+			sprite.setYaw(azimuth(sun_vec - foot_to_knee));
+		
+			sprite.updateFace(*face0p);
+		}
+
+		if (mFootRightp)
+		{
+			LLVector3 joint_world_pos = mFootRightp->getWorldPosition();
+			// this only does a ray straight down from the foot, as our client-side ray-tracing is very limited now
+			// but we make an explicit ray trace call in expectation of future improvements
+			resolveRayCollisionAgent(gAgent.getPosGlobalFromAgent(joint_world_pos), 
+									 gAgent.getPosGlobalFromAgent(gSky.getSunDirection() + joint_world_pos), shadow_pos, normal);
+			shadow_pos_agent = gAgent.getPosAgentFromGlobal(shadow_pos);
+			foot_height = joint_world_pos.mV[VZ] - shadow_pos_agent.mV[VZ];
+
+			// Pull sprite in direction of surface normal
+			shadow_pos_agent += normal * SHADOW_OFFSET_AMT;
+
+			// Render sprite
+			sprite.setNormal(normal);
+			if (isSelf() && gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+			{
+				sprite.setColor(0.f, 0.f, 0.f, 0.f);
+			}
+			else
+			{
+				sprite.setColor(0.f, 0.f, 0.f, clamp_rescale(foot_height, MIN_SHADOW_HEIGHT, MAX_SHADOW_HEIGHT, 0.5f, 0.f));
+			}
+			sprite.setPosition(shadow_pos_agent);
+
+			LLVector3 foot_to_knee = mKneeRightp->getWorldPosition() - joint_world_pos;
+			//foot_to_knee.normalize();
+			foot_to_knee -= projected_vec(foot_to_knee, sun_vec);
+			sprite.setYaw(azimuth(sun_vec - foot_to_knee));
+	
+			sprite.updateFace(*face1p);
+		}
+	}
+}
+
 //-----------------------------------------------------------------------------
 // updateSexDependentLayerSets()
 //-----------------------------------------------------------------------------
@@ -5514,12 +5674,9 @@ void LLVOAvatar::updateSexDependentLayerSets( BOOL upload_bake )
 //-----------------------------------------------------------------------------
 void LLVOAvatar::dirtyMesh()
 {
-	dirtyMesh(1);
-}
-void LLVOAvatar::dirtyMesh(S32 priority)
-{
-	mDirtyMesh = llmax(mDirtyMesh, priority);
+	mDirtyMesh = TRUE;
 }
+
 //-----------------------------------------------------------------------------
 // hideSkirt()
 //-----------------------------------------------------------------------------
@@ -5553,6 +5710,7 @@ BOOL LLVOAvatar::setParent(LLViewerObject* parent)
 
 void LLVOAvatar::addChild(LLViewerObject *childp)
 {
+	childp->extractAttachmentItemID(); // find the inventory item this object is associated with.
 	LLViewerObject::addChild(childp);
 	if (childp->mDrawable)
 	{
@@ -5641,15 +5799,6 @@ BOOL LLVOAvatar::canAttachMoreObjects() const
 	return (getNumAttachments() < MAX_AGENT_ATTACHMENTS);
 }
 
-//-----------------------------------------------------------------------------
-// canAttachMoreObjects()
-// Returns true if we can attach <n> more objects.
-//-----------------------------------------------------------------------------
-BOOL LLVOAvatar::canAttachMoreObjects(U32 n) const
-{
-	return (getNumAttachments() + n) <= MAX_AGENT_ATTACHMENTS;
-}
-
 //-----------------------------------------------------------------------------
 // lazyAttach()
 //-----------------------------------------------------------------------------
@@ -6102,10 +6251,14 @@ void LLVOAvatar::updateMeshTextures()
 			// When an avatar is changing clothes and not in Appearance mode,
 			// use the last-known good baked texture until it finish the first
 			// render of the new layerset.
+
+			const BOOL layerset_invalid = !mBakedTextureDatas[i].mTexLayerSet 
+										  || !mBakedTextureDatas[i].mTexLayerSet->getComposite()->isInitialized()
+										  || !mBakedTextureDatas[i].mTexLayerSet->isLocalTextureDataAvailable();
+
 			use_lkg_baked_layer[i] = (!is_layer_baked[i] 
 									  && (mBakedTextureDatas[i].mLastTextureIndex != IMG_DEFAULT_AVATAR) 
-									  && mBakedTextureDatas[i].mTexLayerSet 
-									  && !mBakedTextureDatas[i].mTexLayerSet->getComposite()->isInitialized());
+									  && layerset_invalid);
 			if (use_lkg_baked_layer[i])
 			{
 				mBakedTextureDatas[i].mTexLayerSet->setUpdatesEnabled(TRUE);
@@ -7793,15 +7946,18 @@ BOOL LLVOAvatar::updateLOD()
 	BOOL res = updateJointLODs();
 
 	LLFace* facep = mDrawable->getFace(0);
-	if (facep->mVertexBuffer.isNull())
+	if (facep->mVertexBuffer.isNull() ||
+		(LLVertexBuffer::sEnableVBOs &&
+		((facep->mVertexBuffer->getUsage() == GL_STATIC_DRAW ? TRUE : FALSE) !=
+		 (facep->getPool()->getVertexShaderLevel() > 0 ? TRUE : FALSE))))
 	{
-		dirtyMesh(2);
+		mDirtyMesh = TRUE;
 	}
 
-	if (mDirtyMesh >= 2 || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
+	if (mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
 	{	//LOD changed or new mesh created, allocate new vertex buffer if needed
 		updateMeshData();
-		mDirtyMesh = 0;
+		mDirtyMesh = FALSE;
 		mNeedsSkin = TRUE;
 		mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
 	}
-- 
GitLab


From 247ca1660bf4029d4e5bb701654433f14c785ab5 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 18 Aug 2010 11:33:01 -0600
Subject: [PATCH 665/683] EXT-8673: FIXED: UDP texture loading is slower in 2.x
 viewers than 1.23.5 Improved the following: 1, make sure the texture callback
 queue is properly handled and cleaned in time; 2, estimate the LLVOTree pixel
 area more accurately; 3, eliminate the possibility of back and forth
 stopping/restarting a texture fetching

---
 indra/newview/app_settings/settings.xml | 183 +++++++++---------------
 indra/newview/llface.cpp                |  65 ++++-----
 indra/newview/llface.h                  |   3 +-
 indra/newview/lltexturefetch.cpp        |   2 +-
 indra/newview/llviewertexture.cpp       | 136 ++++++++++++------
 indra/newview/llviewertexture.h         |   2 +
 indra/newview/llvoavatarself.cpp        |  21 +--
 indra/newview/llvotree.cpp              |  33 +++--
 indra/newview/llwearable.cpp            |   7 +-
 9 files changed, 236 insertions(+), 216 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4c52fb015fd..2130713d50c 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1741,6 +1741,17 @@
 		<key>Value</key>
 		<integer>0</integer>
 	</map>
+  <key>DebugAvatarLocalTexLoadedTime</key>
+  <map>
+    <key>Comment</key>
+    <string>Display time for loading avatar local textures.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>0</integer>
+  </map>
     <key>DebugBeaconLineWidth</key>
     <map>
       <key>Comment</key>
@@ -5373,6 +5384,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>MultipleAttachments</key>
+    <map>
+      <key>Comment</key>
+      <string>Allow multiple objects to be attached to a single attachment point.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>0</integer>
+    </map>
    <key>MuteAmbient</key>
     <map>
       <key>Comment</key>
@@ -6737,7 +6759,7 @@
     <key>Type</key>
     <string>U32</string>
     <key>Value</key>
-    <integer>200</integer>
+    <integer>60</integer>
   </map>
   <key>RenderSSAOFactor</key>
   <map>
@@ -7112,64 +7134,6 @@
     <real>0.01</real>
   </map>
 
-  <key>RenderShadowBiasError</key>
-  <map>
-    <key>Comment</key>
-    <string>Error scale for shadow bias (based on altitude).</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>F32</string>
-    <key>Value</key>
-    <real>0</real>
-  </map>
-  <key>RenderShadowOffsetError</key>
-  <map>
-    <key>Comment</key>
-    <string>Error scale for shadow offset (based on altitude).</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>F32</string>
-    <key>Value</key>
-    <real>0</real>
-  </map>
-  
-  <key>RenderSpotLightsInNondeferred</key>
-  <map>
-    <key>Comment</key>
-    <string>Whether to support projectors as spotlights when Lighting and Shadows is disabled</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>Boolean</string>
-    <key>Value</key>
-    <integer>0</integer>
-  </map>
-
-  <key>RenderSpotShadowBias</key>
-  <map>
-    <key>Comment</key>
-    <string>Bias value for shadows (prevent shadow acne).</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>F32</string>
-    <key>Value</key>
-    <real>0.0</real>
-  </map>
-  <key>RenderSpotShadowOffset</key>
-  <map>
-    <key>Comment</key>
-    <string>Offset value for shadows (prevent shadow acne).</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>F32</string>
-    <key>Value</key>
-    <real>0.04</real>
-  </map>
-
   <key>RenderShadowResolutionScale</key>
   <map>
     <key>Comment</key>
@@ -7182,6 +7146,8 @@
     <real>1.0</real>
   </map>
 
+
+
   <key>RenderDeferredTreeShadowBias</key>
   <map>
     <key>Comment</key>
@@ -7303,7 +7269,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>8</real>
+    <real>1</real>
   </map>
 
   <key>RenderDeferred</key>
@@ -7318,6 +7284,18 @@
     <integer>0</integer>
   </map>
 
+  <key>RenderDeferredShadow</key>
+  <map>
+    <key>Comment</key>
+    <string>Enable shadows in deferred renderer.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>1</integer>
+  </map>
+
   <key>RenderDeferredGI</key>
   <map>
     <key>Comment</key>
@@ -7330,10 +7308,10 @@
     <integer>0</integer>
   </map>
 
-  <key>RenderDeferredSun</key>
+  <key>RenderDeferredSunShadow</key>
   <map>
     <key>Comment</key>
-    <string>Execute sunlight shader in deferred renderer.</string>
+    <string>Generate shadows from the sun.</string>
     <key>Persist</key>
     <integer>1</integer>
     <key>Type</key>
@@ -7342,10 +7320,10 @@
     <integer>1</integer>
   </map>
 
-  <key>RenderDeferredAtmospheric</key>
+  <key>RenderDeferredSun</key>
   <map>
     <key>Comment</key>
-    <string>Execute atmospheric shader in deferred renderer.</string>
+    <string>Execute sunlight shader in deferred renderer.</string>
     <key>Persist</key>
     <integer>1</integer>
     <key>Type</key>
@@ -7354,10 +7332,10 @@
     <integer>1</integer>
   </map>
 
-  <key>RenderDeferredSSAO</key>
+  <key>RenderDeferredAtmospheric</key>
   <map>
     <key>Comment</key>
-    <string>Execute screen space ambient occlusion shader in deferred renderer.</string>
+    <string>Execute atmospheric shader in deferred renderer.</string>
     <key>Persist</key>
     <integer>1</integer>
     <key>Type</key>
@@ -7616,10 +7594,10 @@
       <key>Value</key>
       <real>256.0</real>
     </map>
-    <key>RenderAutoMaskAlphaNonDeferred</key>
+    <key>RenderFastAlpha</key>
     <map>
       <key>Comment</key>
-      <string>Use alpha masks where appropriate, in the non-deferred (non-'Lighting and Shadows') graphics mode</string>
+      <string>Use lossy alpha rendering optimization (opaque/nonexistent small alpha faces).</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -7627,17 +7605,6 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>RenderAutoMaskAlphaDeferred</key>
-    <map>
-      <key>Comment</key>
-      <string>Use alpha masks where appropriate, in the deferred ('Lighting and Shadows') graphics mode</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>1</integer>
-    </map>
     <key>RenderFastUI</key>
     <map>
       <key>Comment</key>
@@ -7899,6 +7866,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>RenderLightingDetail</key>
+    <map>
+      <key>Comment</key>
+      <string>Amount of detail for lighting objects/avatars/terrain (0=sun/moon only, 1=enable local lights)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>S32</string>
+      <key>Value</key>
+      <integer>1</integer>
+    </map>
     <key>RenderMaxPartCount</key>
     <map>
       <key>Comment</key>
@@ -7998,18 +7976,6 @@
       <key>Value</key>
       <integer>2</integer>
     </map>
-    <key>RenderShadowDetail</key>
-    <map>
-      <key>Comment</key>
-      <string>Detail of shadows.</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <integer>2</integer>
-    </map>
-
     <key>RenderReflectionRes</key>
     <map>
       <key>Comment</key>
@@ -8140,7 +8106,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>1</integer>
+      <integer>0</integer>
     </map>
     <key>RenderUIBuffer</key>
     <map>
@@ -8296,6 +8262,17 @@
       <key>Value</key>
       <integer>512</integer>
     </map>
+    <key>RenderWaterReflections</key>
+    <map>
+      <key>Comment</key>
+      <string>Reflect the environment in the water.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>0</integer>
+    </map>
     <key>RotateRight</key>
     <map>
       <key>Comment</key>
@@ -9495,28 +9472,6 @@
       <key>Value</key>
       <integer>75</integer>
     </map>
-    <key>SnapshotSharingEnabled</key>
-    <map>
-      <key>Comment</key>
-      <string>Enable uploading of snapshots to a web service.</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
-    <key>SnapshotConfigURL</key>
-    <map>
-      <key>Comment</key>
-      <string>URL to fetch Snapshot Sharing configuration data from.</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>String</string>
-      <key>Value</key>
-      <string>http://photos.apps.staging.avatarsunited.com/viewer_config</string>
-    </map>
     <key>SnapshotTextureLastResolution</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index cfe8b4c9a47..db3d90e0a03 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -862,26 +862,6 @@ void LLFace::updateRebuildFlags()
 	}
 }
 
-
-bool LLFace::canRenderAsMask()
-{
-	const LLTextureEntry* te = getTextureEntry();
-	return (
-		(
-		 (LLPipeline::sRenderDeferred && LLPipeline::sAutoMaskAlphaDeferred) ||
-		 
-		 (!LLPipeline::sRenderDeferred && LLPipeline::sAutoMaskAlphaNonDeferred)		 
-		 ) // do we want masks at all?
-		&&
-		(te->getColor().mV[3] == 1.0f) && // can't treat as mask if we have face alpha
-		!(LLPipeline::sRenderDeferred && te->getFullbright()) && // hack: alpha masking renders fullbright faces invisible in deferred rendering mode, need to figure out why - for now, avoid
-		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask
-
-		getTexture()->getIsAlphaMask() // texture actually qualifies for masking (lazily recalculated but expensive)
-		);
-}
-
-
 static LLFastTimer::DeclareTimer FTM_FACE_GET_GEOM("Face Geom");
 
 BOOL LLFace::getGeometryVolume(const LLVolume& volume,
@@ -1412,24 +1392,13 @@ F32 LLFace::getTextureVirtualSize()
 		face_area =  mPixelArea / llclamp(texel_area, 0.015625f, 128.f);
 	}
 
-	if(face_area > LLViewerTexture::sMaxSmallImageSize)
+	face_area = LLFace::adjustPixelArea(mImportanceToCamera, face_area) ;
+	if(face_area > LLViewerTexture::sMinLargeImageSize) //if is large image, shrink face_area by considering the partial overlapping.
 	{
-		if(mImportanceToCamera < LEAST_IMPORTANCE) //if the face is not important, do not load hi-res.
-		{
-			static const F32 MAX_LEAST_IMPORTANCE_IMAGE_SIZE = 128.0f * 128.0f ;
-			face_area = llmin(face_area * 0.5f, MAX_LEAST_IMPORTANCE_IMAGE_SIZE) ;
-		}
-		else if(face_area > LLViewerTexture::sMinLargeImageSize) //if is large image, shrink face_area by considering the partial overlapping.
-		{
-			if(mImportanceToCamera < LEAST_IMPORTANCE_FOR_LARGE_IMAGE)//if the face is not important, do not load hi-res.
-			{
-				face_area = LLViewerTexture::sMinLargeImageSize ;
-			}	
-			else if(mTexture.notNull() && mTexture->isLargeImage())
-			{		
-				face_area *= adjustPartialOverlapPixelArea(cos_angle_to_view_dir, radius );
-			}			
-		}
+		if(mImportanceToCamera > LEAST_IMPORTANCE_FOR_LARGE_IMAGE && mTexture.notNull() && mTexture->isLargeImage())
+		{		
+			face_area *= adjustPartialOverlapPixelArea(cos_angle_to_view_dir, radius );
+		}	
 	}
 
 	setVirtualSize(face_area) ;
@@ -1556,6 +1525,28 @@ F32 LLFace::calcImportanceToCamera(F32 cos_angle_to_view_dir, F32 dist)
 	return importance ;
 }
 
+//static 
+F32 LLFace::adjustPixelArea(F32 importance, F32 pixel_area)
+{
+	if(pixel_area > LLViewerTexture::sMaxSmallImageSize)
+	{
+		if(importance < LEAST_IMPORTANCE) //if the face is not important, do not load hi-res.
+		{
+			static const F32 MAX_LEAST_IMPORTANCE_IMAGE_SIZE = 128.0f * 128.0f ;
+			pixel_area = llmin(pixel_area * 0.5f, MAX_LEAST_IMPORTANCE_IMAGE_SIZE) ;
+		}
+		else if(pixel_area > LLViewerTexture::sMinLargeImageSize) //if is large image, shrink face_area by considering the partial overlapping.
+		{
+			if(importance < LEAST_IMPORTANCE_FOR_LARGE_IMAGE)//if the face is not important, do not load hi-res.
+			{
+				pixel_area = LLViewerTexture::sMinLargeImageSize ;
+			}				
+		}
+	}
+
+	return pixel_area ;
+}
+
 BOOL LLFace::verify(const U32* indices_array) const
 {
 	BOOL ok = TRUE;
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index b20ecfe2b8e..8f17bc31781 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -138,10 +138,10 @@ class LLFace
 	void			unsetFaceColor(); // switch back to material color
 	const LLColor4&	getFaceColor() const { return mFaceColor; } 
 	const LLColor4& getRenderColor() const;
+	
 
 	//for volumes
 	void updateRebuildFlags();
-	bool canRenderAsMask(); // logic helper
 	BOOL getGeometryVolume(const LLVolume& volume,
 						const S32 &f,
 						const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
@@ -214,6 +214,7 @@ class LLFace
 	BOOL        calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) ;
 public:
 	static F32  calcImportanceToCamera(F32 to_view_dir, F32 dist);
+	static F32 LLFace::adjustPixelArea(F32 importance, F32 pixel_area) ;
 
 public:
 	
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index f4899d0d5d6..bd0a43cd547 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -597,7 +597,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			return true; // abort
 		}
 	}
-	if(mImagePriority < 1.0f)
+	if(mImagePriority < F_ALMOST_ZERO)
 	{
 		if (mState == INIT || mState == LOAD_FROM_NETWORK || mState == LOAD_FROM_SIMULATOR)
 		{
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 9b3243a1bc5..7a0f77a7e46 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1489,59 +1489,63 @@ void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height)
 //virtual
 void LLViewerFetchedTexture::processTextureStats()
 {
-	if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0) //force to refetch the texture.
-	{
-		mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel) ;
-	}
-
 	if(mFullyLoaded)
 	{		
-		if(mDesiredDiscardLevel <= mMinDesiredDiscardLevel)//already loaded
+		if(mDesiredDiscardLevel > mMinDesiredDiscardLevel)//need to load more
 		{
-			return ;
+			mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ;
+			mFullyLoaded = FALSE ;
 		}
-		mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ;
-		mFullyLoaded = FALSE ;
-		return ;
-	}
-
-	updateVirtualSize() ;
-	
-	static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes");
-	
-	if (textures_fullres)
-	{
-		mDesiredDiscardLevel = 0;
-	}
-	else if(!mFullWidth || !mFullHeight)
-	{
-		mDesiredDiscardLevel = 	getMaxDiscardLevel() ;
 	}
 	else
-	{	
-		if(!mKnownDrawWidth || !mKnownDrawHeight || mFullWidth <= mKnownDrawWidth || mFullHeight <= mKnownDrawHeight)
+	{
+		updateVirtualSize() ;
+		
+		static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes");
+		
+		if (textures_fullres)
 		{
-			if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT)
+			mDesiredDiscardLevel = 0;
+		}
+		else if(!mFullWidth || !mFullHeight)
+		{
+			mDesiredDiscardLevel = 	getMaxDiscardLevel() ;
+		}
+		else
+		{	
+			if(!mKnownDrawWidth || !mKnownDrawHeight || mFullWidth <= mKnownDrawWidth || mFullHeight <= mKnownDrawHeight)
 			{
-				mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048
+				if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT)
+				{
+					mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048
+				}
+				else
+				{
+					mDesiredDiscardLevel = 0;
+				}
 			}
-			else
+			else if(mKnownDrawSizeChanged)//known draw size is set
+			{			
+				mDesiredDiscardLevel = (S8)llmin(log((F32)mFullWidth / mKnownDrawWidth) / log_2, 
+													 log((F32)mFullHeight / mKnownDrawHeight) / log_2) ;
+				mDesiredDiscardLevel = 	llclamp(mDesiredDiscardLevel, (S8)0, (S8)getMaxDiscardLevel()) ;
+				mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ;
+			}
+			mKnownDrawSizeChanged = FALSE ;
+		
+			if(getDiscardLevel() >= 0 && (getDiscardLevel() <= mDesiredDiscardLevel))
 			{
-				mDesiredDiscardLevel = 0;
+				mFullyLoaded = TRUE ;
 			}
 		}
-		else if(mKnownDrawSizeChanged)//known draw size is set
-		{			
-			mDesiredDiscardLevel = (S8)llmin(log((F32)mFullWidth / mKnownDrawWidth) / log_2, 
-					                             log((F32)mFullHeight / mKnownDrawHeight) / log_2) ;
-			mDesiredDiscardLevel = 	llclamp(mDesiredDiscardLevel, (S8)0, (S8)getMaxDiscardLevel()) ;
-			mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ;
-		}
-		mKnownDrawSizeChanged = FALSE ;
-		
-		if(getDiscardLevel() >= 0 && (getDiscardLevel() <= mDesiredDiscardLevel))
+	}
+
+	if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0) //force to refetch the texture.
+	{
+		mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel) ;
+		if(getDiscardLevel() < 0 || getDiscardLevel() > mDesiredDiscardLevel)
 		{
-			mFullyLoaded = TRUE ;
+			mFullyLoaded = FALSE ;
 		}
 	}
 }
@@ -1724,6 +1728,11 @@ void LLViewerFetchedTexture::setDecodePriority(F32 priority)
 	llassert(!mInImageList); 
     
 	mDecodePriority = priority;
+
+	if(mDecodePriority < F_ALMOST_ZERO)
+	{
+		mStopFetchingTimer.reset() ;
+	}
 }
 
 void LLViewerFetchedTexture::setAdditionalDecodePriority(F32 priority)
@@ -1915,7 +1924,12 @@ bool LLViewerFetchedTexture::updateFetch()
 // 				llinfos << "Calling updateRequestPriority() with decode_priority = 0.0f" << llendl;
 // 				calcDecodePriority();
 // 			}
-			LLAppViewer::getTextureFetch()->updateRequestPriority(mID, decode_priority);
+			static const F32 MAX_HOLD_TIME = 5.0f ; //seconds to wait before canceling fecthing if decode_priority is 0.f.
+			if(decode_priority > 0.0f || mStopFetchingTimer.getElapsedTimeF32() > MAX_HOLD_TIME)
+			{
+				mStopFetchingTimer.reset() ;
+				LLAppViewer::getTextureFetch()->updateRequestPriority(mID, decode_priority);
+			}
 		}
 	}
 
@@ -2075,6 +2089,36 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call
 	}
 }
 
+void LLViewerFetchedTexture::clearCallbackEntryList()
+{
+	if(mLoadedCallbackList.empty())
+	{
+		return ;
+	}
+
+	for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
+			iter != mLoadedCallbackList.end(); )
+	{
+		LLLoadedCallbackEntry *entryp = *iter;
+			
+		// We never finished loading the image.  Indicate failure.
+		// Note: this allows mLoadedCallbackUserData to be cleaned up.
+		entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData);
+		iter = mLoadedCallbackList.erase(iter) ;
+		delete entryp;
+	}
+	gTextureList.mCallbackList.erase(this);
+		
+	mMinDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1;
+	mLoadedCallbackDesiredDiscardLevel = S8_MAX ;
+	if(mForceToSaveRawImage)
+	{
+		destroySavedRawImage() ;
+	}
+
+	return ;
+}
+
 void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::source_callback_list_t* callback_list)
 {
 	if(mLoadedCallbackList.empty() || !callback_list)
@@ -2082,7 +2126,7 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so
 		return ;
 	}
 
-	S32 desired_discard = INVALID_DISCARD_LEVEL ;
+	S32 desired_discard = S8_MAX ;
 	S32 desired_raw_discard = INVALID_DISCARD_LEVEL ;
 	for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
 			iter != mLoadedCallbackList.end(); )
@@ -2652,6 +2696,12 @@ void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard, bool from_
 }
 void LLViewerFetchedTexture::destroySavedRawImage()
 {
+	clearCallbackEntryList() ;
+	//if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0 && mDesiredSavedRawDiscardLevel < getDiscardLevel())
+	//{
+	//	return ; //can not destroy the saved raw image before it is fully fetched, otherwise causing callbacks hanging there.
+	//}
+
 	mSavedRawImage = NULL ;
 	mForceToSaveRawImage  = FALSE ;
 	mSavedRawDiscardLevel = -1 ;
@@ -2902,7 +2952,7 @@ BOOL LLViewerLODTexture::isUpdateFrozen()
 void LLViewerLODTexture::processTextureStats()
 {
 	updateVirtualSize() ;
-
+	
 	static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes");
 	
 	if (textures_fullres)
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 1f0d760daf6..6adfd2bae41 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -392,6 +392,7 @@ class LLViewerFetchedTexture : public LLViewerTexture
 	void unpauseLoadedCallbacks(const LLLoadedCallbackEntry::source_callback_list_t* callback_list);
 	bool doLoadedCallbacks();
 	void deleteCallbackEntry(const LLLoadedCallbackEntry::source_callback_list_t* callback_list);
+	void clearCallbackEntryList() ;
 
 	void addToCreateTexture();
 
@@ -562,6 +563,7 @@ class LLViewerFetchedTexture : public LLViewerTexture
 
 	// Timers
 	LLFrameTimer mLastPacketTimer;		// Time since last packet.
+	LLFrameTimer mStopFetchingTimer;	// Time since mDecodePriority == 0.f.
 
 	BOOL  mInImageList;				// TRUE if image is in list (in which case don't reset priority!)
 	BOOL  mNeedsCreateTexture;	
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index bddde08ca98..338b3155cc4 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -1067,7 +1067,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view
 	// Should just be the last object added
 	if (attachment->isObjectAttached(viewer_object))
 	{
-		const LLUUID& attachment_id = viewer_object->getItemID();
+		const LLUUID& attachment_id = viewer_object->getAttachmentItemID();
 		LLAppearanceMgr::instance().registerAttachment(attachment_id);
 	}
 
@@ -1077,7 +1077,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view
 //virtual
 BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 {
-	const LLUUID attachment_id = viewer_object->getItemID();
+	const LLUUID attachment_id = viewer_object->getAttachmentItemID();
 	if (LLVOAvatar::detachObject(viewer_object))
 	{
 		// the simulator should automatically handle permission revocation
@@ -1625,15 +1625,15 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
 					if (isSelf())
 					{
 						if (gAgentAvatarp->isUsingBakedTextures())
-					{
-						requestLayerSetUpdate(type);
-					}
+						{
+							requestLayerSetUpdate(type);
+						}
 						else
-					{
-						LLVisualParamHint::requestHintUpdates();
+						{
+							LLVisualParamHint::requestHintUpdates();
+						}
 					}
 				}
-				}
 				else
 				{					
 					tex->setLoadedCallback(onLocalTextureLoaded, desired_discard, TRUE, FALSE, new LLAvatarTexData(getID(), type), NULL);
@@ -2145,6 +2145,11 @@ void LLVOAvatarSelf::setNewBakedTexture( ETextureIndex te, const LLUUID& uuid )
 
 void LLVOAvatarSelf::outputRezDiagnostics() const
 {
+	if(!gSavedSettings.getBOOL("DebugAvatarLocalTexLoadedTime"))
+	{
+		return ;
+	}
+
 	const F32 final_time = mDebugSelfLoadTimer.getElapsedTimeF32();
 	llinfos << "REZTIME: Myself rez stats:" << llendl;
 	llinfos << "\t Time from avatar creation to load wearables: " << (S32)mDebugTimeWearablesLoaded << llendl;
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 0efe6682be6..9c08c0eec11 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -448,22 +448,35 @@ void LLVOTree::render(LLAgent &agent)
 
 void LLVOTree::setPixelAreaAndAngle(LLAgent &agent)
 {
-	// First calculate values as for any other object (for mAppAngle)
-	LLViewerObject::setPixelAreaAndAngle(agent);
-
-	// Re-calculate mPixelArea accurately
+	LLVector3 center = getPositionAgent();//center of tree.
+	LLVector3 viewer_pos_agent = gAgentCamera.getCameraPositionAgent();
+	LLVector3 lookAt = center - viewer_pos_agent;
+	F32 dist = lookAt.normVec() ;	
+	F32 cos_angle_to_view_dir = lookAt * LLViewerCamera::getInstance()->getXAxis() ;	
 	
-	// This should be the camera's center, as soon as we move to all region-local.
-	LLVector3 relative_position = getPositionAgent() - gAgentCamera.getCameraPositionAgent();
-	F32 range_squared = relative_position.lengthSquared() ;				
+	F32 range = dist - getMinScale()/2;
+	if (range < F_ALMOST_ZERO || isHUDAttachment())		// range == zero
+	{
+		mAppAngle = 180.f;
+	}
+	else
+	{
+		mAppAngle = (F32) atan2( getMaxScale(), range) * RAD_TO_DEG;		
+	}
 
 	F32 max_scale = mBillboardScale * getMaxScale();
 	F32 area = max_scale * (max_scale*mBillboardRatio);
-
 	// Compute pixels per meter at the given range
-	F32 pixels_per_meter = LLViewerCamera::getInstance()->getViewHeightInPixels() / tan(LLViewerCamera::getInstance()->getView());
+	F32 pixels_per_meter = LLViewerCamera::getInstance()->getViewHeightInPixels() / (tan(LLViewerCamera::getInstance()->getView()) * dist);
+	mPixelArea = pixels_per_meter * pixels_per_meter * area ;	
+
+	F32 importance = LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist) ;
+	mPixelArea = LLFace::adjustPixelArea(importance, mPixelArea) ;
+	if (mPixelArea > LLViewerCamera::getInstance()->getScreenPixelArea())
+	{
+		mAppAngle = 180.f;
+	}
 
-	mPixelArea = (pixels_per_meter) * (pixels_per_meter) * area / range_squared;
 #if 0
 	// mAppAngle is a bit of voodoo;
 	// use the one calculated LLViewerObject::setPixelAreaAndAngle above
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index c5042ca0165..1209b60679f 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -52,6 +52,7 @@
 #include "llvoavatarself.h"
 #include "llvoavatardefines.h"
 #include "llwearable.h"
+#include "llviewercontrol.h"
 
 using namespace LLVOAvatarDefines;
 
@@ -444,8 +445,10 @@ BOOL LLWearable::importFile( LLFILE* file )
 			delete mSavedTEMap[te];
 		}
 
-		image->setLoadedCallback(LLVOAvatarSelf::debugOnTimingLocalTexLoaded,0,TRUE,FALSE, new LLVOAvatarSelf::LLAvatarTexData(id, (LLVOAvatarDefines::ETextureIndex)te), NULL);
-
+		if(gSavedSettings.getBOOL("DebugAvatarLocalTexLoadedTime"))
+		{
+			image->setLoadedCallback(LLVOAvatarSelf::debugOnTimingLocalTexLoaded,0,TRUE,FALSE, new LLVOAvatarSelf::LLAvatarTexData(id, (LLVOAvatarDefines::ETextureIndex)te), NULL);
+		}
 		LLUUID textureid(text_buffer);
 		mTEMap[te] = new LLLocalTextureObject(image, textureid);
 		mSavedTEMap[te] = new LLLocalTextureObject(image, textureid);
-- 
GitLab


From ebab718f32b58ca5a718e8db549ca9d36550bdcf Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 18 Aug 2010 15:32:40 -0600
Subject: [PATCH 666/683] fixed for EXT-8963: investigate if Advanced > Run
 Multiple Threads should be on. Removed "Run Multiple Threads" from the menu
 because we are not using it.

---
 indra/newview/app_settings/settings.xml       |  11 --
 indra/newview/llappviewer.cpp                 |  74 ++-----
 .../skins/default/xui/en/menu_viewer.xml      | 186 ++++--------------
 3 files changed, 55 insertions(+), 216 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 2130713d50c..51ed26505ef 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -8295,17 +8295,6 @@
       <key>Value</key>
       <real>1.0</real>
     </map>
-    <key>RunMultipleThreads</key>
-    <map>
-      <key>Comment</key>
-      <string>If TRUE keep background threads active during render</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
     <key>SafeMode</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index d222d94ec60..d6ecb2f1681 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -961,11 +961,6 @@ static LLFastTimer::DeclareTimer FTM_LFS("LFS Thread");
 static LLFastTimer::DeclareTimer FTM_PAUSE_THREADS("Pause Threads");
 static LLFastTimer::DeclareTimer FTM_IDLE("Idle");
 static LLFastTimer::DeclareTimer FTM_PUMP("Pump");
-static LLFastTimer::DeclareTimer FTM_PUMP_ARES("Ares");
-static LLFastTimer::DeclareTimer FTM_PUMP_SERVICE("Service");
-static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback");
-static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot");
-static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update");
 
 bool LLAppViewer::mainLoop()
 {
@@ -1075,20 +1070,10 @@ bool LLAppViewer::mainLoop()
 						LLMemType mt_ip(LLMemType::MTYPE_IDLE_PUMP);
 						pingMainloopTimeout("Main:ServicePump");				
 						LLFastTimer t4(FTM_PUMP);
-						{
-							LLFastTimer t(FTM_PUMP_ARES);
-							gAres->process();
-						}
-						{
-							LLFastTimer t(FTM_PUMP_SERVICE);
-							// this pump is necessary to make the login screen show up
-							gServicePump->pump();
-
-							{
-								LLFastTimer t(FTM_SERVICE_CALLBACK);
-								gServicePump->callback();
-							}
-						}
+						gAres->process();
+						// this pump is necessary to make the login screen show up
+						gServicePump->pump();
+						gServicePump->callback();
 					}
 					
 					resumeMainloopTimeout();
@@ -1123,8 +1108,7 @@ bool LLAppViewer::mainLoop()
 			{
 				LLMemType mt_sleep(LLMemType::MTYPE_SLEEP);
 				LLFastTimer t2(FTM_SLEEP);
-				bool run_multiple_threads = gSavedSettings.getBOOL("RunMultipleThreads");
-
+				
 				// yield some time to the os based on command line option
 				if(mYieldTime >= 0)
 				{
@@ -1162,9 +1146,7 @@ bool LLAppViewer::mainLoop()
 				}
 
 				static const F64 FRAME_SLOW_THRESHOLD = 0.5; //2 frames per seconds				
-				const F64 min_frame_time = 0.0; //(.0333 - .0010); // max video frame rate = 30 fps
-				const F64 min_idle_time = 0.0; //(.0010); // min idle time = 1 ms
-				const F64 max_idle_time = run_multiple_threads ? min_idle_time : llmin(.005*10.0*gFrameTimeSeconds, 0.005); // 5 ms a second
+				const F64 max_idle_time = llmin(.005*10.0*gFrameTimeSeconds, 0.005); // 5 ms a second
 				idleTimer.reset();
 				bool is_slow = (frameTimer.getElapsedTimeF64() > FRAME_SLOW_THRESHOLD) ;
 				S32 total_work_pending = 0;
@@ -1202,34 +1184,24 @@ bool LLAppViewer::mainLoop()
 
 					total_work_pending += work_pending ;
 					total_io_pending += io_pending ;
-					F64 frame_time = frameTimer.getElapsedTimeF64();
-					F64 idle_time = idleTimer.getElapsedTimeF64();
-					if (frame_time >= min_frame_time &&
-						idle_time >= min_idle_time &&
-						(!work_pending || idle_time >= max_idle_time))
+					
+					if (!work_pending || idleTimer.getElapsedTimeF64() >= max_idle_time)
 					{
 						break;
 					}
 				}
 
-				 // Prevent the worker threads from running while rendering.
-				// if (LLThread::processorCount()==1) //pause() should only be required when on a single processor client...
-				if (run_multiple_threads == FALSE)
+				if(!total_work_pending) //pause texture fetching threads if nothing to process.
 				{
-					//LLFastTimer ftm(FTM_PAUSE_THREADS); //not necessary.
-	 				
-					if(!total_work_pending) //pause texture fetching threads if nothing to process.
-					{
-						LLAppViewer::getTextureCache()->pause();
-						LLAppViewer::getImageDecodeThread()->pause();
-						LLAppViewer::getTextureFetch()->pause(); 
-					}
-					if(!total_io_pending) //pause file threads if nothing to process.
-					{
-						LLVFSThread::sLocal->pause(); 
-						LLLFSThread::sLocal->pause(); 
-					}
-				}					
+					LLAppViewer::getTextureCache()->pause();
+					LLAppViewer::getImageDecodeThread()->pause();
+					LLAppViewer::getTextureFetch()->pause(); 
+				}
+				if(!total_io_pending) //pause file threads if nothing to process.
+				{
+					LLVFSThread::sLocal->pause(); 
+					LLLFSThread::sLocal->pause(); 
+				}									
 
 				if ((LLStartUp::getStartupState() >= STATE_CLEANUP) &&
 					(frameTimer.getElapsedTimeF64() > FRAME_STALL_THRESHOLD))
@@ -3581,12 +3553,9 @@ void LLAppViewer::idle()
 			gAgent.moveYaw(-1.f);
 		}
 
-		{
-			LLFastTimer t(FTM_AGENT_AUTOPILOT);
-			// Handle automatic walking towards points
-			gAgentPilot.updateTarget();
-			gAgent.autoPilot(&yaw);
-		}
+	    // Handle automatic walking towards points
+	    gAgentPilot.updateTarget();
+	    gAgent.autoPilot(&yaw);
     
 	    static LLFrameTimer agent_update_timer;
 	    static U32 				last_control_flags;
@@ -3597,7 +3566,6 @@ void LLAppViewer::idle()
 		    
 	    if (flags_changed || (agent_update_time > (1.0f / (F32) AGENT_UPDATES_PER_SECOND)))
 	    {
-		    LLFastTimer t(FTM_AGENT_UPDATE);
 		    // Send avatar and camera info
 		    last_control_flags = gAgent.getControlFlags();
 		    send_agent_update(TRUE);
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 52cf24333f2..2f6ecd8a34e 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -29,9 +29,7 @@
             <menu_item_call.on_click
              function="BuyCurrency" />
         </menu_item_call>
-
         <menu_item_separator/>
-
         <menu_item_call
          label="My Profile"
          name="Profile">
@@ -126,9 +124,7 @@
             <menu_item_call.on_click
              function="Advanced.LeaveAdminStatus" />
         </menu_item_call>
-
         <menu_item_separator/>
-
         <menu_item_call
          label="Exit [APP_NAME]"
          name="Quit"
@@ -157,9 +153,7 @@
              function="SideTray.PanelPeopleTab"
              parameter="groups_panel" />
         </menu_item_call>
-
         <menu_item_separator/>
-
         <!--menu_item_call
          label="Chat"
          name="Chat">
@@ -257,9 +251,7 @@
              parameter="region_info" />
         </menu_item_call>
         </menu>
-
         <menu_item_separator/>
-
         <menu_item_call
              label="Buy This Land"
              name="Buy Land">
@@ -356,9 +348,7 @@
                control="NavBarShowParcelProperties" />
           </menu_item_check>
         </menu>
-
         <menu_item_separator/>
-
 	    <menu_item_call
 	     label="Teleport Home"
 	     name="Teleport Home"
@@ -397,9 +387,7 @@
              parameter="ShowNavbarFavoritesPanel" />
         </menu_item_check>
         <menu_item_separator/>-->
-
         <menu_item_separator/>
-
     <menu
          create_jump_keys="true"
          label="Sun"
@@ -442,9 +430,7 @@
                  function="World.EnvSettings"
                  parameter="default" />
             </menu_item_call>
-
             <menu_item_separator/>
-
             <menu_item_call
              label="Environment Editor"
              name="Environment Editor">
@@ -593,7 +579,6 @@
             </menu_item_call>
         </menu>
         <menu_item_separator/>
-
         <menu_item_call
            label="Focus on Selection"
            name="Focus on Selection"
@@ -614,9 +599,7 @@
           <menu_item_call.on_enable
              function="Tools.SomethingSelectedNoHUD" />
         </menu_item_call>
-
         <menu_item_separator/>
-
         <menu
          create_jump_keys="true"
          label="Object"
@@ -718,9 +701,7 @@
                function="EditableSelected" />
           </menu_item_call>
         </menu>
-
         <menu_item_separator/>
-
         <menu
          create_jump_keys="true"
          label="Options"
@@ -736,9 +717,7 @@
 				 function="ToggleControl"
 				 parameter="DebugPermissions" />
 			</menu_item_check>
-
             <menu_item_separator/>
-
             <menu_item_check
                  label="Select Only My Objects"
                  name="Select Only My Objects">
@@ -765,9 +744,7 @@
                     <menu_item_check.on_click
                      function="Tools.SelectBySurrounding" />
             </menu_item_check>
-
           <menu_item_separator/>
-
                 <menu_item_check
                  label="Show Hidden Selection"
                  name="Show Hidden Selection">
@@ -793,9 +770,7 @@
                      function="ToggleControl"
                      parameter="ShowSelectionBeam" />
                 </menu_item_check>
-
         <menu_item_separator/>
-
                 <menu_item_check
                  label="Snap to Grid"
                  name="Snap to Grid"
@@ -919,9 +894,7 @@
              function="Floater.Show"
              parameter="hud" />
         </menu_item_call>-->
-
         <menu_item_separator/>
-
         <menu_item_call
              label="Report Abuse"
              name="Report Abuse">
@@ -935,9 +908,7 @@
                  function="ShowHelp"
                  parameter="report_bug" />
             </menu_item_call>
-
         <menu_item_separator/>
-
         <menu_item_call
          label="About [APP_NAME]"
          name="About Second Life">
@@ -951,6 +922,17 @@
      name="Advanced"
      tear_off="true"
      visible="false">
+        <menu_item_check
+         label="Show Advanced Menu"
+         name="Show Advanced Menu"
+         shortcut="control|alt|shift|D">
+          <on_check
+           function="CheckControl"
+           parameter="UseDebugMenus" />
+          <on_click
+           function="ToggleControl"
+           parameter="UseDebugMenus" />
+        </menu_item_check>
         <menu_item_call
          label="Stop Animating Me"
          name="Stop Animating My Avatar">
@@ -977,9 +959,7 @@
            function="Floater.Show"
            parameter="window_size" />
         </menu_item_call>
-
         <menu_item_separator/>
-
         <menu_item_check
          label="Limit Select Distance"
          name="Limit Select Distance">
@@ -1000,9 +980,7 @@
              function="ToggleControl"
              parameter="DisableCameraConstraints" />
         </menu_item_check>
-
         <menu_item_separator/>
-
         <menu_item_check
          label="High-res Snapshot"
          name="HighResSnapshot">
@@ -1033,9 +1011,7 @@
              function="ToggleControl"
              parameter="CompressSnapshotsToDisk" />
         </menu_item_check>
-
         <menu_item_separator/>
-
         <menu
          create_jump_keys="true"
          label="Performance Tools"
@@ -1148,9 +1124,7 @@
                 <menu_item_check.on_click
                  function="View.ShowHoverTips" />
             </menu_item_check>
-
             <menu_item_separator/>
-
             <menu_item_check
              label="Show Land Tooltips"
              name="Land Tips">
@@ -1419,17 +1393,7 @@
                  function="Advanced.ToggleFeature"
                  parameter="flexible" />
             </menu_item_check>
-        </menu>
-        <menu_item_check
-         label="Run Multiple Threads"
-         name="Run Multiple Threads">
-            <menu_item_check.on_check
-             function="CheckControl"
-             parameter="RunMultipleThreads" />
-            <menu_item_check.on_click
-             function="ToggleControl"
-             parameter="RunMultipleThreads" />
-        </menu_item_check>
+        </menu>        
         <menu_item_check
          label="Use Plugin Read Thread"
          name="Use Plugin Read Thread">
@@ -1457,9 +1421,7 @@
              function="ToggleControl"
              parameter="MouseSmooth" />
         </menu_item_check>
-
         <menu_item_separator/>
-
         <menu
          label="Shortcuts"
          name="Shortcuts"
@@ -1503,9 +1465,19 @@
                 <menu_item_call.on_click
                  function="View.DefaultUISize" />
             </menu_item_call>
-
+            <!-- This second, alternative shortcut for Show Advanced Menu is for backward compatibility.  The main shortcut has been changed so it's Linux-friendly, where the old shortcut is typically eaten by the window manager. -->
+            <menu_item_check
+               label="Show Advanced Menu - legacy shortcut"
+               name="Show Advanced Menu - legacy shortcut"
+               shortcut="control|alt|D">
+              <on_check
+		 function="CheckControl"
+		 parameter="UseDebugMenus" />
+              <on_click
+		 function="ToggleControl"
+		 parameter="UseDebugMenus" />
+            </menu_item_check>
             <menu_item_separator/>
-
             <menu_item_check
              label="Always Run"
              name="Always Run"
@@ -1526,9 +1498,7 @@
                 <menu_item_check.on_enable
                  function="Agent.enableFlying" />
             </menu_item_check>
-
             <menu_item_separator/>
-
             <menu_item_call
              label="Close Window"
              name="Close Window"
@@ -1547,9 +1517,7 @@
                 <menu_item_call.on_enable
                  function="File.EnableCloseAllWindows" />
             </menu_item_call>
-
             <menu_item_separator/>
-
             <menu_item_call
              label="Snapshot to Disk"
              name="Snapshot to Disk"
@@ -1558,9 +1526,7 @@
                 <menu_item_call.on_click
                  function="File.TakeSnapshotToDisk" />
             </menu_item_call>
-
             <menu_item_separator/>
-
             <menu_item_call
              label="Mouselook"
              name="Mouselook"
@@ -1597,9 +1563,7 @@
                 <menu_item_call.on_enable
                  function="View.EnableLastChatter" />
             </menu_item_call>
-
             <menu_item_separator/>
-
             <menu
              create_jump_keys="true"
              label="Select Build Tool"
@@ -1646,9 +1610,7 @@
                      parameter="land" />
                 </menu_item_call>
             </menu>
-
             <menu_item_separator/>
-
             <menu_item_call
              label="Zoom In"
              name="Zoom In"
@@ -1670,27 +1632,8 @@
                 <menu_item_call.on_click
                  function="View.ZoomOut" />
             </menu_item_call>
-            <menu_item_separator
-             visible="false"/>
-            <!-- Made invisible to avoid a dissonance: menu item toggle menu where it is located. EXT-8069.
-              Can't be removed to keep sortcut workable.
-            -->
-            <menu_item_check
-             label="Show Advanced Menu"
-             name="Show Advanced Menu"
-             shortcut="control|alt|D"
-             visible="false">
-                <on_check
-                 function="CheckControl"
-                 parameter="UseDebugMenus" />
-                <on_click
-                 function="ToggleControl"
-                 parameter="UseDebugMenus" />
-        </menu_item_check>
-        </menu> <!--Shortcuts-->
-
+        </menu>
         <menu_item_separator/>
-
         <menu_item_call
          label="Show Debug Settings"
          name="Debug Settings">
@@ -1709,7 +1652,6 @@
              function="ToggleControl"
              parameter="QAMode" />
         </menu_item_check>
-    
     </menu>
     <menu
      create_jump_keys="true"
@@ -1800,9 +1742,7 @@
                  function="Advanced.ToggleConsole"
                  parameter="memory view" />
             </menu_item_check>
-
             <menu_item_separator/>
-
             <menu_item_call
              label="Region Info to Debug Console"
              name="Region Info to Debug Console">
@@ -1824,9 +1764,7 @@
                  function="Advanced.DumpInfoToConsole"
                  parameter="capabilities" />
             </menu_item_call>
-
             <menu_item_separator/>
-
             <menu_item_check
              label="Camera"
              name="Camera">
@@ -1914,9 +1852,7 @@
                  function="ToggleControl"
                  parameter="DebugShowColor" />
             </menu_item_check>
-
             <menu_item_separator/>
-
             <menu_item_check
              label="Show Updates to Objects"
              name="Show Updates"
@@ -1928,9 +1864,7 @@
                  function="Advanced.ToggleShowObjectUpdates" />
             </menu_item_check>
         </menu>
-
         <menu_item_separator/>
-
         <menu
          create_jump_keys="true"
          label="Force an Error"
@@ -2224,12 +2158,9 @@
             <menu_item_check.on_enable
                  function="Advanced.EnableRenderFBO" />
            </menu_item_check>
-
-          <menu_item_separator />
-
           <menu_item_check
-                       label="Lighting and Shadows"
-                       name="Lighting and Shadows">
+                       label="Deferred Rendering"
+                       name="Deferred Rendering">
             <menu_item_check.on_check
              function="CheckControl"
              parameter="RenderDeferred" />
@@ -2240,31 +2171,7 @@
                  function="Advanced.EnableRenderDeferred" />
           </menu_item_check>
           <menu_item_check
-                       label="   Shadows from Sun/Moon/Projectors"
-                       name="Shadows from Sun/Moon/Projectors">
-            <menu_item_check.on_check
-             function="Advanced.CheckRenderShadowOption"
-             parameter="RenderShadowDetail" />
-            <menu_item_check.on_click
-             function="Advanced.ClickRenderShadowOption"
-             parameter="RenderShadowDetail" />
-            <menu_item_check.on_enable
-                 function="Advanced.EnableRenderDeferredOptions" />
-          </menu_item_check>
-          <menu_item_check
-                   label="   SSAO and Shadow Smoothing"
-                   name="SSAO and Shadow Smoothing">
-            <menu_item_check.on_check
-             function="CheckControl"
-             parameter="RenderDeferredSSAO" />
-            <menu_item_check.on_click
-             function="ToggleControl"
-             parameter="RenderDeferredSSAO" />
-            <menu_item_check.on_enable
-                 function="Advanced.EnableRenderDeferredOptions" />
-          </menu_item_check>
-          <menu_item_check
-                   label="   Global Illumination (experimental)"
+                   label="Global Illumination"
                    name="Global Illumination">
             <menu_item_check.on_check
              function="CheckControl"
@@ -2273,11 +2180,9 @@
              function="ToggleControl"
              parameter="RenderDeferredGI" />
             <menu_item_check.on_enable
-                 function="Advanced.EnableRenderDeferredOptions" />
+                 function="Advanced.EnableRenderDeferredGI" />
           </menu_item_check>
-
           <menu_item_separator />
-
           <menu_item_check
              label="Debug GL"
              name="Debug GL">
@@ -2299,24 +2204,14 @@
                  parameter="RenderDebugPipeline" />
             </menu_item_check>
             <menu_item_check
-             label="Automatic Alpha Masks (deferred)"
-             name="Automatic Alpha Masks (deferred)">
-                <menu_item_check.on_check
-                 function="CheckControl"
-                 parameter="RenderAutoMaskAlphaDeferred" />
-                <menu_item_check.on_click
-                 function="ToggleControl"
-                 parameter="RenderAutoMaskAlphaDeferred" />
-            </menu_item_check>
-            <menu_item_check
-             label="Automatic Alpha Masks (non-deferred)"
-             name="Automatic Alpha Masks (non-deferred)">
+             label="Fast Alpha"
+             name="Fast Alpha">
                 <menu_item_check.on_check
                  function="CheckControl"
-                 parameter="RenderAutoMaskAlphaNonDeferred" />
+                 parameter="RenderFastAlpha" />
                 <menu_item_check.on_click
                  function="ToggleControl"
-                 parameter="RenderAutoMaskAlphaNonDeferred" />
+                 parameter="RenderFastAlpha" />
             </menu_item_check>
             <menu_item_check
              label="Animation Textures"
@@ -2359,7 +2254,7 @@
                parameter="AuditTexture" />
             </menu_item_check>
             <menu_item_check
-             label="Texture Atlas (experimental)"
+             label="Texture Atlas"
              name="Texture Atlas">
               <menu_item_check.on_check
                function="CheckControl"
@@ -2415,9 +2310,7 @@
                  function="ToggleControl"
                  parameter="AgentPause" />
             </menu_item_check>
-
             <menu_item_separator/>
-
             <menu_item_call
              label="Enable Message Log"
              name="Enable Message Log">
@@ -2430,9 +2323,7 @@
                 <menu_item_call.on_click
                  function="Advanced.DisableMessageLog" />
             </menu_item_call>
-
             <menu_item_separator/>
-
             <menu_item_check
              label="Velocity Interpolate Objects"
              name="Velocity Interpolate Objects">
@@ -2453,9 +2344,7 @@
                  function="ToggleControl"
                  parameter="PingInterpolate" />
             </menu_item_check>
-
             <menu_item_separator/>
-
             <menu_item_call
              label="Drop a Packet"
              name="Drop a Packet"
@@ -2643,7 +2532,6 @@
             </menu_item_check>
 
             <menu_item_separator />
-
             <menu_item_check
              label="Debug SelectMgr"
              name="Debug SelectMgr">
@@ -2989,9 +2877,7 @@
                  function="Advanced.DumpAvatarLocalTextures" />
             </menu_item_call>
         </menu>
-
         <menu_item_separator/>
-
         <menu_item_check
          label="HTTP Textures"
          name="HTTP Textures">
@@ -3028,9 +2914,7 @@
              function="ToggleControl"
              parameter="ShowConsoleWindow" />
         </menu_item_check>
-
         <menu_item_separator/>
-
         <menu_item_check
          label="Show Admin Menu"
          name="View Admin Options">
@@ -3365,9 +3249,7 @@
                      name="PublicIssueTrackerHelp_url"
                      parameter="WebLaunchPublicIssueHelp,http://wiki.secondlife.com/wiki/Issue_tracker" />
                 </menu_item_call>
-
                 <menu_item_separator/>
-
                 <menu_item_call
                  label="Bug Reporting 101"
                  name="Bug Reporing 101">
-- 
GitLab


From 8dd194c873883795a9fe88b83e1f58b6ba7ed198 Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Thu, 19 Aug 2010 15:09:07 +0300
Subject: [PATCH 667/683] EXT-8635 FIXED Replaced "no matches found" with
 "Loading..." in the My Outfits tab.

Set no items text to "Loading..." when creating the wearable items list and to "There are no items in this outfit" when category is complete.
"Outhfit" is there, because wearable items list nay be empty only for them. This string was introduced, because the only situation when there are
no items shown in outfit tab is for empty outfit- because even when applying filter either all items from outfit will be shown or outfit tab won't be shown at all.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/865/

--HG--
branch : product-engine
---
 indra/newview/llwearableitemslist.cpp          | 6 ++++++
 indra/newview/skins/default/xui/en/strings.xml | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index abe629ffe4b..9f7ea68e870 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -636,6 +636,7 @@ LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p)
 		setRightMouseDownCallback(boost::bind(&LLWearableItemsList::onRightClick, this, _2, _3));
 	}
 	mWornIndicationEnabled = p.worn_indication_enabled;
+	setNoItemsCommentText(LLTrans::getString("LoadingData"));
 }
 
 // virtual
@@ -677,6 +678,11 @@ void LLWearableItemsList::updateList(const LLUUID& category_id)
 		LLInventoryModel::EXCLUDE_TRASH,
 		collector);
 
+	if(item_array.empty() && gInventory.isCategoryComplete(category_id))
+	{
+		setNoItemsCommentText(LLTrans::getString("EmptyOutfitText"));
+	}
+
 	refreshList(item_array);
 }
 
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 04d8c53d97a..676bef2d0be 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -3265,4 +3265,6 @@ Abuse Report</string>
   <string name="DeleteItems">Delete selected items?</string>
   <string name="DeleteItem">Delete selected item?</string>
 
+  <string name="EmptyOutfitText">There are no items in this outfit</string>
+
   </strings>
-- 
GitLab


From dd053785fae6ae784f9d74f1ae8dc7b155ee283f Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Thu, 19 Aug 2010 15:11:37 +0300
Subject: [PATCH 668/683] EXT-8658 FIXED Made only online participants of Adhoc
 chat to be shown shown in Recent Tab.

Used previously commented code which adds only online paricipants instead of current code that added all.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/860/

--HG--
branch : product-engine
---
 indra/newview/llimview.cpp | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index cd35ec5d39c..41e505cc58b 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -1021,19 +1021,6 @@ void LLIMModel::sendMessage(const std::string& utf8_text,
 
 	if (is_not_group_id)
 	{
-			
-#if 0
-		//use this code to add only online members	
-		LLIMSpeakerMgr* speaker_mgr = LLIMModel::getInstance()->getSpeakerManager(im_session_id);
-		LLSpeakerMgr::speaker_list_t speaker_list;
-		speaker_mgr->getSpeakerList(&speaker_list, true);
-		for(LLSpeakerMgr::speaker_list_t::iterator it = speaker_list.begin(); it != speaker_list.end(); it++)
-		{
-			const LLPointer<LLSpeaker>& speakerp = *it;
-
-			LLRecentPeople::instance().add(speakerp->mID);
-		}
-#else
 		LLIMModel::LLIMSession* session = LLIMModel::getInstance()->findIMSession(im_session_id);
 		if( session == 0)//??? shouldn't really happen
 		{
@@ -1048,16 +1035,20 @@ void LLIMModel::sendMessage(const std::string& utf8_text,
 			// Concrete participants will be added into this list once they sent message in chat.
 			if (IM_SESSION_INVITE == dialog) return;
 
-			// implemented adding of all participants of an outgoing to Recent People List. See EXT-5694.
-			for(uuid_vec_t::iterator it = session->mInitialTargetIDs.begin();
-				it!=session->mInitialTargetIDs.end();++it)
+			// Add only online members to recent (EXT-8658)
+			LLIMSpeakerMgr* speaker_mgr = LLIMModel::getInstance()->getSpeakerManager(im_session_id);
+			LLSpeakerMgr::speaker_list_t speaker_list;
+			if(speaker_mgr != NULL)
+			{
+				speaker_mgr->getSpeakerList(&speaker_list, true);
+			}
+			for(LLSpeakerMgr::speaker_list_t::iterator it = speaker_list.begin(); it != speaker_list.end(); it++)
 			{
-				const LLUUID id = *it;
+				const LLPointer<LLSpeaker>& speakerp = *it;
 
-				LLRecentPeople::instance().add(id);
+				LLRecentPeople::instance().add(speakerp->mID);
 			}
 		}
-#endif
 	}
 
 	
-- 
GitLab


From 2fea1d5d33ec1b41a3cfa4307a1bfa58d8014f88 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 19 Aug 2010 12:25:15 -0500
Subject: [PATCH 669/683] Integrate SIMD API from oreh/server-trunk-oreh

---
 indra/cmake/00-Common.cmake                  |    1 +
 indra/llcharacter/llkeyframemotion.cpp       |    2 +-
 indra/llmath/CMakeLists.txt                  |  246 +--
 indra/llmath/llcamera.cpp                    |    2 +-
 indra/llmath/llmath.h                        | 1034 +++++-----
 indra/llmath/lloctree.h                      |   19 +-
 indra/llmath/llquantize.h                    |  310 +--
 indra/llmath/llquaternion.cpp                | 1921 +++++++++---------
 indra/llmath/llquaternion.h                  | 1184 +++++------
 indra/llmath/llvolume.cpp                    |  123 +-
 indra/llmath/tests/v2math_test.cpp           |    6 +-
 indra/llmath/tests/v3color_test.cpp          |    6 +-
 indra/llmath/tests/v3dmath_test.cpp          |    2 +-
 indra/llmath/tests/v3math_test.cpp           |    4 +-
 indra/llmath/tests/v4color_test.cpp          |    4 +-
 indra/llmath/tests/v4coloru_test.cpp         |    2 +-
 indra/llmath/tests/v4math_test.cpp           |    4 +-
 indra/llmath/v2math.cpp                      |    2 +-
 indra/llmath/v2math.h                        |    8 +-
 indra/llmath/v3color.h                       |   10 +-
 indra/llmath/v3dmath.h                       |   10 +-
 indra/llmath/v3math.h                        |   10 +-
 indra/llmath/v4color.h                       |    8 +-
 indra/llmath/v4coloru.h                      |    4 +-
 indra/llmath/v4math.h                        |    8 +-
 indra/llmessage/llsdmessagebuilder.cpp       |    1 +
 indra/llmessage/lltemplatemessagebuilder.cpp |    1 +
 indra/llmessage/lltemplatemessagereader.cpp  |    1 +
 indra/llrender/llrender.cpp                  |    4 +-
 indra/newview/llagent.cpp                    |    2 +-
 indra/newview/lldrawable.cpp                 |   10 +-
 indra/newview/lldrawpoolavatar.cpp           |  190 +-
 indra/newview/lldrawpoolavatar.h             |    3 +-
 indra/newview/llface.cpp                     |   29 +-
 indra/newview/llface.h                       |    3 +-
 indra/newview/llflexibleobject.cpp           |    2 +-
 indra/newview/llhudicon.cpp                  |    2 +-
 indra/newview/llpanelnearbymedia.cpp         |    2 +-
 indra/newview/llpanelprimmediacontrols.cpp   |    4 +-
 indra/newview/llselectmgr.cpp                |    6 +-
 indra/newview/llspatialpartition.cpp         |   44 +-
 indra/newview/llviewercamera.cpp             |    2 +-
 indra/newview/llviewerjointmesh.cpp          |   10 +-
 indra/newview/llviewerjoystick.cpp           |    2 +-
 indra/newview/llviewermedia.cpp              |    2 +-
 indra/newview/llviewerobject.cpp             |    2 +-
 indra/newview/llviewerpartsim.cpp            |    4 +-
 indra/newview/llviewertexture.cpp            |    2 +-
 indra/newview/llvoavatar.cpp                 |   22 +-
 indra/newview/llvoavatar.h                   |    3 +
 indra/newview/llvograss.cpp                  |    2 +-
 indra/newview/llvosurfacepatch.cpp           |    4 +-
 indra/newview/llvotextbubble.cpp             |    4 +-
 indra/newview/llvotree.cpp                   |    6 +-
 indra/newview/llvovolume.cpp                 |   16 +-
 indra/newview/llworld.cpp                    |    4 +-
 indra/newview/pipeline.cpp                   |   14 +-
 57 files changed, 2731 insertions(+), 2602 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 2c7bb77758a..f10a61e1e77 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -68,6 +68,7 @@ if (WINDOWS)
    
     add_definitions(
       /Zc:wchar_t-
+      /arch:SSE2
       )
   endif (MSVC80 OR MSVC90)
   
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index 7bc9e97eb16..bce272082e5 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -1151,7 +1151,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
 			constraint->mPositions[joint_num] = new_pos;
 		}
 		constraint->mFixupDistanceRMS *= 1.f / (constraint->mTotalLength * (F32)(shared_data->mChainLength - 1));
-		constraint->mFixupDistanceRMS = fsqrtf(constraint->mFixupDistanceRMS);
+		constraint->mFixupDistanceRMS = (F32) sqrt(constraint->mFixupDistanceRMS);
 
 		//reset old joint rots
 		for (joint_num = 0; joint_num <= shared_data->mChainLength; joint_num++)
diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt
index dda07133d59..8d85765eb8d 100644
--- a/indra/llmath/CMakeLists.txt
+++ b/indra/llmath/CMakeLists.txt
@@ -1,118 +1,128 @@
-# -*- cmake -*-
-
-project(llmath)
-
-include(00-Common)
-include(LLCommon)
-
-include_directories(
-    ${LLCOMMON_INCLUDE_DIRS}
-    )
-
-set(llmath_SOURCE_FILES
-    llbbox.cpp
-    llbboxlocal.cpp
-    llcamera.cpp
-    llcoordframe.cpp
-    llline.cpp
-    llmodularmath.cpp
-    llperlin.cpp
-    llquaternion.cpp
-    llrect.cpp
-    llsphere.cpp
-    llvolume.cpp
-    llvolumemgr.cpp
-    llvolumeoctree.cpp
-    llsdutil_math.cpp
-    m3math.cpp
-    m4math.cpp
-    raytrace.cpp
-    v2math.cpp
-    v3color.cpp
-    v3dmath.cpp
-    v3math.cpp
-    v4color.cpp
-    v4coloru.cpp
-    v4math.cpp
-    xform.cpp
-    )
-
-set(llmath_HEADER_FILES
-    CMakeLists.txt
-
-    camera.h
-    coordframe.h
-    llbbox.h
-    llbboxlocal.h
-    llcamera.h
-    llcoord.h
-    llcoordframe.h
-    llinterp.h
-    llline.h
-    llmath.h
-    llmodularmath.h
-    lloctree.h
-    llperlin.h
-    llplane.h
-    llquantize.h
-    llquaternion.h
-    llrect.h
-    llsphere.h
-    lltreenode.h
-    llv4math.h
-    llv4matrix3.h
-    llv4matrix4.h
-    llv4vector3.h
-    llvector4a.h
-    llmatrix4a.h
-    llvolume.h
-    llvolumemgr.h
-    llvolumeoctree.h
-    llsdutil_math.h
-    m3math.h
-    m4math.h
-    raytrace.h
-    v2math.h
-    v3color.h
-    v3dmath.h
-    v3math.h
-    v4color.h
-    v4coloru.h
-    v4math.h
-    xform.h
-    )
-
-set_source_files_properties(${llmath_HEADER_FILES}
-                            PROPERTIES HEADER_FILE_ONLY TRUE)
-
-list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES})
-
-add_library (llmath ${llmath_SOURCE_FILES})
-
-# Add tests
-if (LL_TESTS)
-  include(LLAddBuildTest)
-  # UNIT TESTS
-  SET(llmath_TEST_SOURCE_FILES
-    llbboxlocal.cpp
-    llmodularmath.cpp
-    llrect.cpp
-    v2math.cpp
-    v3color.cpp
-    v4color.cpp
-    v4coloru.cpp
-    )
-  LL_ADD_PROJECT_UNIT_TESTS(llmath "${llmath_TEST_SOURCE_FILES}")
-
-  # 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(llbbox llbbox.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(llquaternion llquaternion.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(mathmisc "" "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(m3math "" "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(v3dmath v3dmath.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(v3math v3math.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(v4math v4math.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(xform xform.cpp "${test_libs}")
-endif (LL_TESTS)
+# -*- cmake -*-
+
+project(llmath)
+
+include(00-Common)
+include(LLCommon)
+
+include_directories(
+    ${LLCOMMON_INCLUDE_DIRS}
+    )
+
+set(llmath_SOURCE_FILES
+    llbbox.cpp
+    llbboxlocal.cpp
+    llcamera.cpp
+    llcoordframe.cpp
+    llline.cpp
+    llmatrix3a.cpp
+    llmodularmath.cpp
+    llperlin.cpp
+    llquaternion.cpp
+    llrect.cpp
+    llsphere.cpp
+    llvector4a.cpp
+    llvolume.cpp
+    llvolumemgr.cpp
+    llvolumeoctree.cpp
+    llsdutil_math.cpp
+    m3math.cpp
+    m4math.cpp
+    raytrace.cpp
+    v2math.cpp
+    v3color.cpp
+    v3dmath.cpp
+    v3math.cpp
+    v4color.cpp
+    v4coloru.cpp
+    v4math.cpp
+    xform.cpp
+    )
+
+set(llmath_HEADER_FILES
+    CMakeLists.txt
+
+    camera.h
+    coordframe.h
+    llbbox.h
+    llbboxlocal.h
+    llcamera.h
+    llcoord.h
+    llcoordframe.h
+    llinterp.h
+    llline.h
+    llmath.h
+    llmatrix3a.h
+    llmatrix3a.inl
+    llmodularmath.h
+    lloctree.h
+    llperlin.h
+    llplane.h
+    llquantize.h
+    llquaternion.h
+    llquaternion2.h
+    llquaternion2.inl
+    llrect.h
+    llsimdmath.h
+    llsimdtypes.h
+    llsimdtypes.inl
+    llsphere.h
+    lltreenode.h
+    llvector4a.h
+    llvector4a.inl
+    llvector4logical.h
+    llv4math.h
+    llv4matrix3.h
+    llv4matrix4.h
+    llv4vector3.h
+    llvolume.h
+    llvolumemgr.h
+    llvolumeoctree.h
+    llsdutil_math.h
+    m3math.h
+    m4math.h
+    raytrace.h
+    v2math.h
+    v3color.h
+    v3dmath.h
+    v3math.h
+    v4color.h
+    v4coloru.h
+    v4math.h
+    xform.h
+    )
+
+set_source_files_properties(${llmath_HEADER_FILES}
+                            PROPERTIES HEADER_FILE_ONLY TRUE)
+
+list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES})
+
+add_library (llmath ${llmath_SOURCE_FILES})
+
+# Add tests
+if (LL_TESTS)
+  include(LLAddBuildTest)
+  # UNIT TESTS
+  SET(llmath_TEST_SOURCE_FILES
+    llbboxlocal.cpp
+    llmodularmath.cpp
+    llrect.cpp
+    v2math.cpp
+    v3color.cpp
+    v4color.cpp
+    v4coloru.cpp
+    )
+  LL_ADD_PROJECT_UNIT_TESTS(llmath "${llmath_TEST_SOURCE_FILES}")
+
+  # 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(llbbox llbbox.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(llquaternion llquaternion.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(mathmisc "" "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(m3math "" "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(v3dmath v3dmath.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(v3math v3math.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(v4math v4math.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(xform xform.cpp "${test_libs}")
+endif (LL_TESTS)
diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp
index 6b56e4870ed..beb5c486242 100644
--- a/indra/llmath/llcamera.cpp
+++ b/indra/llmath/llcamera.cpp
@@ -77,7 +77,7 @@ const LLCamera& LLCamera::operator=(const LLCamera& rhs)
 {
 	memcpy(this, &rhs, sizeof(LLCamera));
 	alignPlanes();
-	LLVector4a::memcpyNonAliased16((F32*) mAgentPlanes, (F32*) rhs.mAgentPlanes, 4*7);
+	LLVector4a::memcpyNonAliased16((F32*) mAgentPlanes, (F32*) rhs.mAgentPlanes, 4*7*sizeof(F32));
 	return *this;
 }
 
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index c3c15e13748..742bbc47511 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -1,525 +1,509 @@
-/** 
- * @file llmath.h
- * @brief Useful math constants and macros.
- *
- * $LicenseInfo:firstyear=2000&license=viewergpl$
- * 
- * Copyright (c) 2000-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LLMATH_H
-#define LLMATH_H
-
-#include <cmath>
-#include <cstdlib>
-#include <complex>
-#include "lldefs.h"
-//#include "llstl.h" // *TODO: Remove when LLString is gone
-//#include "llstring.h" // *TODO: Remove when LLString is gone
-// lltut.h uses is_approx_equal_fraction(). This was moved to its own header
-// file in llcommon so we can use lltut.h for llcommon tests without making
-// llcommon depend on llmath.
-#include "is_approx_equal_fraction.h"
-
-// work around for Windows & older gcc non-standard function names.
-#if LL_WINDOWS
-#include <float.h>
-#define llisnan(val)	_isnan(val)
-#define llfinite(val)	_finite(val)
-#elif (LL_LINUX && __GNUC__ <= 2)
-#define llisnan(val)	isnan(val)
-#define llfinite(val)	isfinite(val)
-#elif LL_SOLARIS
-#define llisnan(val)    isnan(val)
-#define llfinite(val)   (val <= std::numeric_limits<double>::max())
-#else
-#define llisnan(val)	std::isnan(val)
-#define llfinite(val)	std::isfinite(val)
-#endif
-
-// Single Precision Floating Point Routines
-#ifndef sqrtf
-#define sqrtf(x)	((F32)sqrt((F64)(x)))
-#endif
-#ifndef fsqrtf
-#define fsqrtf(x)	sqrtf(x)
-#endif
-
-#ifndef cosf
-#define cosf(x)		((F32)cos((F64)(x)))
-#endif
-#ifndef sinf
-#define sinf(x)		((F32)sin((F64)(x)))
-#endif
-#ifndef tanf
-#define tanf(x)		((F32)tan((F64)(x)))
-#endif
-#ifndef acosf
-#define acosf(x)	((F32)acos((F64)(x)))
-#endif
-
-#ifndef powf
-#define powf(x,y)	((F32)pow((F64)(x),(F64)(y)))
-#endif
-#ifndef expf
-#define expf(x)		((F32)exp((F64)(x)))
-#endif
-
-const F32	GRAVITY			= -9.8f;
-
-// mathematical constants
-const F32	F_PI		= 3.1415926535897932384626433832795f;
-const F32	F_TWO_PI	= 6.283185307179586476925286766559f;
-const F32	F_PI_BY_TWO	= 1.5707963267948966192313216916398f;
-const F32	F_SQRT_TWO_PI = 2.506628274631000502415765284811f;
-const F32	F_E			= 2.71828182845904523536f;
-const F32	F_SQRT2		= 1.4142135623730950488016887242097f;
-const F32	F_SQRT3		= 1.73205080756888288657986402541f;
-const F32	OO_SQRT2	= 0.7071067811865475244008443621049f;
-const F32	DEG_TO_RAD	= 0.017453292519943295769236907684886f;
-const F32	RAD_TO_DEG	= 57.295779513082320876798154814105f;
-const F32	F_APPROXIMATELY_ZERO = 0.00001f;
-const F32	F_LN2		= 0.69314718056f;
-const F32	OO_LN2		= 1.4426950408889634073599246810019f;
-
-const F32	F_ALMOST_ZERO	= 0.0001f;
-const F32	F_ALMOST_ONE	= 1.0f - F_ALMOST_ZERO;
-
-// BUG: Eliminate in favor of F_APPROXIMATELY_ZERO above?
-const F32 FP_MAG_THRESHOLD = 0.0000001f;
-
-// TODO: Replace with logic like is_approx_equal
-inline BOOL is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f < F_APPROXIMATELY_ZERO); }
-
-// These functions work by interpreting sign+exp+mantissa as an unsigned
-// integer.
-// For example:
-// x = <sign>1 <exponent>00000010 <mantissa>00000000000000000000000
-// y = <sign>1 <exponent>00000001 <mantissa>11111111111111111111111
-//
-// interpreted as ints = 
-// x = 10000001000000000000000000000000
-// y = 10000000111111111111111111111111
-// which is clearly a different of 1 in the least significant bit
-// Values with the same exponent can be trivially shown to work.
-//
-// WARNING: Denormals of opposite sign do not work
-// x = <sign>1 <exponent>00000000 <mantissa>00000000000000000000001
-// y = <sign>0 <exponent>00000000 <mantissa>00000000000000000000001
-// Although these values differ by 2 in the LSB, the sign bit makes
-// the int comparison fail.
-//
-// WARNING: NaNs can compare equal
-// There is no special treatment of exceptional values like NaNs
-//
-// WARNING: Infinity is comparable with F32_MAX and negative 
-// infinity is comparable with F32_MIN
-
-inline BOOL is_approx_equal(F32 x, F32 y)
-{
-	const S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
-	return (std::abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
-}
-
-inline BOOL is_approx_equal(F64 x, F64 y)
-{
-	const S64 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
-	return (std::abs((S32) ((U64&)x - (U64&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
-}
-
-inline S32 llabs(const S32 a)
-{
-	return S32(std::labs(a));
-}
-
-inline F32 llabs(const F32 a)
-{
-	return F32(std::fabs(a));
-}
-
-inline F64 llabs(const F64 a)
-{
-	return F64(std::fabs(a));
-}
-
-inline S32 lltrunc( F32 f )
-{
-#if LL_WINDOWS && !defined( __INTEL_COMPILER )
-		// Avoids changing the floating point control word.
-		// Add or subtract 0.5 - epsilon and then round
-		const static U32 zpfp[] = { 0xBEFFFFFF, 0x3EFFFFFF };
-		S32 result;
-		__asm {
-			fld		f
-			mov		eax,	f
-			shr		eax,	29
-			and		eax,	4
-			fadd	dword ptr [zpfp + eax]
-			fistp	result
-		}
-		return result;
-#else
-		return (S32)f;
-#endif
-}
-
-inline S32 lltrunc( F64 f )
-{
-	return (S32)f;
-}
-
-inline S32 llfloor( F32 f )
-{
-#if LL_WINDOWS && !defined( __INTEL_COMPILER )
-		// Avoids changing the floating point control word.
-		// Accurate (unlike Stereopsis version) for all values between S32_MIN and S32_MAX and slightly faster than Stereopsis version.
-		// Add -(0.5 - epsilon) and then round
-		const U32 zpfp = 0xBEFFFFFF;
-		S32 result;
-		__asm { 
-			fld		f
-			fadd	dword ptr [zpfp]
-			fistp	result
-		}
-		return result;
-#else
-		return (S32)floorf(f);
-#endif
-}
-
-
-inline S32 llceil( F32 f )
-{
-	// This could probably be optimized, but this works.
-	return (S32)ceil(f);
-}
-
-
-#ifndef BOGUS_ROUND
-// Use this round.  Does an arithmetic round (0.5 always rounds up)
-inline S32 llround(const F32 val)
-{
-	return llfloor(val + 0.5f);
-}
-
-#else // BOGUS_ROUND
-// Old llround implementation - does banker's round (toward nearest even in the case of a 0.5.
-// Not using this because we don't have a consistent implementation on both platforms, use
-// llfloor(val + 0.5f), which is consistent on all platforms.
-inline S32 llround(const F32 val)
-{
-	#if LL_WINDOWS
-		// Note: assumes that the floating point control word is set to rounding mode (the default)
-		S32 ret_val;
-		_asm fld	val
-		_asm fistp	ret_val;
-		return ret_val;
-	#elif LL_LINUX
-		// Note: assumes that the floating point control word is set
-		// to rounding mode (the default)
-		S32 ret_val;
-		__asm__ __volatile__( "flds %1    \n\t"
-							  "fistpl %0  \n\t"
-							  : "=m" (ret_val)
-							  : "m" (val) );
-		return ret_val;
-	#else
-		return llfloor(val + 0.5f);
-	#endif
-}
-
-// A fast arithmentic round on intel, from Laurent de Soras http://ldesoras.free.fr
-inline int round_int(double x)
-{
-	const float round_to_nearest = 0.5f;
-	int i;
-	__asm
-	{
-		fld x
-		fadd st, st (0)
-		fadd round_to_nearest
-		fistp i
-		sar i, 1
-	}
-	return (i);
-}
-#endif // BOGUS_ROUND
-
-inline F32 llround( F32 val, F32 nearest )
-{
-	return F32(floor(val * (1.0f / nearest) + 0.5f)) * nearest;
-}
-
-inline F64 llround( F64 val, F64 nearest )
-{
-	return F64(floor(val * (1.0 / nearest) + 0.5)) * nearest;
-}
-
-// these provide minimum peak error
-//
-// avg  error = -0.013049 
-// peak error = -31.4 dB
-// RMS  error = -28.1 dB
-
-const F32 FAST_MAG_ALPHA = 0.960433870103f;
-const F32 FAST_MAG_BETA = 0.397824734759f;
-
-// these provide minimum RMS error
-//
-// avg  error = 0.000003 
-// peak error = -32.6 dB
-// RMS  error = -25.7 dB
-//
-//const F32 FAST_MAG_ALPHA = 0.948059448969f;
-//const F32 FAST_MAG_BETA = 0.392699081699f;
-
-inline F32 fastMagnitude(F32 a, F32 b)
-{ 
-	a = (a > 0) ? a : -a;
-	b = (b > 0) ? b : -b;
-	return(FAST_MAG_ALPHA * llmax(a,b) + FAST_MAG_BETA * llmin(a,b));
-}
-
-
-
-////////////////////
-//
-// Fast F32/S32 conversions
-//
-// Culled from www.stereopsis.com/FPU.html
-
-const F64 LL_DOUBLE_TO_FIX_MAGIC	= 68719476736.0*1.5;     //2^36 * 1.5,  (52-_shiftamt=36) uses limited precisicion to floor
-const S32 LL_SHIFT_AMOUNT			= 16;                    //16.16 fixed point representation,
-
-// Endian dependent code
-#ifdef LL_LITTLE_ENDIAN
-	#define LL_EXP_INDEX				1
-	#define LL_MAN_INDEX				0
-#else
-	#define LL_EXP_INDEX				0
-	#define LL_MAN_INDEX				1
-#endif
-
-/* Deprecated: use llround(), lltrunc(), or llfloor() instead
-// ================================================================================================
-// Real2Int
-// ================================================================================================
-inline S32 F64toS32(F64 val)
-{
-	val		= val + LL_DOUBLE_TO_FIX_MAGIC;
-	return ((S32*)&val)[LL_MAN_INDEX] >> LL_SHIFT_AMOUNT; 
-}
-
-// ================================================================================================
-// Real2Int
-// ================================================================================================
-inline S32 F32toS32(F32 val)
-{
-	return F64toS32 ((F64)val);
-}
-*/
-
-////////////////////////////////////////////////
-//
-// Fast exp and log
-//
-
-// Implementation of fast exp() approximation (from a paper by Nicol N. Schraudolph
-// http://www.inf.ethz.ch/~schraudo/pubs/exp.pdf
-static union
-{
-	double d;
-	struct
-	{
-#ifdef LL_LITTLE_ENDIAN
-		S32 j, i;
-#else
-		S32 i, j;
-#endif
-	} n;
-} LLECO; // not sure what the name means
-
-#define LL_EXP_A (1048576 * OO_LN2) // use 1512775 for integer
-#define LL_EXP_C (60801)			// this value of C good for -4 < y < 4
-
-#define LL_FAST_EXP(y) (LLECO.n.i = llround(F32(LL_EXP_A*(y))) + (1072693248 - LL_EXP_C), LLECO.d)
-
-
-
-inline F32 llfastpow(const F32 x, const F32 y)
-{
-	return (F32)(LL_FAST_EXP(y * log(x)));
-}
-
-
-inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
-{
-	// compute the power of ten
-	F32 bar = 1.f;
-	for (S32 i = 0; i < sig_figs; i++)
-	{
-		bar *= 10.f;
-	}
-
-	foo = (F32)llround(foo * bar);
-
-	// shift back
-	foo /= bar;
-	return foo;
-}
-
-inline F32 lerp(F32 a, F32 b, F32 u) 
-{
-	return a + ((b - a) * u);
-}
-
-inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)
-{
-	F32 a = x00 + (x01-x00)*u;
-	F32 b = x10 + (x11-x10)*u;
-	F32 r = a + (b-a)*v;
-	return r;
-}
-
-inline F32 ramp(F32 x, F32 a, F32 b)
-{
-	return (a == b) ? 0.0f : ((a - x) / (a - b));
-}
-
-inline F32 rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)
-{
-	return lerp(y1, y2, ramp(x, x1, x2));
-}
-
-inline F32 clamp_rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)
-{
-	if (y1 < y2)
-	{
-		return llclamp(rescale(x,x1,x2,y1,y2),y1,y2);
-	}
-	else
-	{
-		return llclamp(rescale(x,x1,x2,y1,y2),y2,y1);
-	}
-}
-
-
-inline F32 cubic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )
-{
-	if (x <= x0)
-		return s0;
-
-	if (x >= x1)
-		return s1;
-
-	F32 f = (x - x0) / (x1 - x0);
-
-	return	s0 + (s1 - s0) * (f * f) * (3.0f - 2.0f * f);
-}
-
-inline F32 cubic_step( F32 x )
-{
-	x = llclampf(x);
-
-	return	(x * x) * (3.0f - 2.0f * x);
-}
-
-inline F32 quadratic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )
-{
-	if (x <= x0)
-		return s0;
-
-	if (x >= x1)
-		return s1;
-
-	F32 f = (x - x0) / (x1 - x0);
-	F32 f_squared = f * f;
-
-	return	(s0 * (1.f - f_squared)) + ((s1 - s0) * f_squared);
-}
-
-inline F32 llsimple_angle(F32 angle)
-{
-	while(angle <= -F_PI)
-		angle += F_TWO_PI;
-	while(angle >  F_PI)
-		angle -= F_TWO_PI;
-	return angle;
-}
-
-//SDK - Renamed this to get_lower_power_two, since this is what this actually does.
-inline U32 get_lower_power_two(U32 val, U32 max_power_two)
-{
-	if(!max_power_two)
-	{
-		max_power_two = 1 << 31 ;
-	}
-	if(max_power_two & (max_power_two - 1))
-	{
-		return 0 ;
-	}
-
-	for(; val < max_power_two ; max_power_two >>= 1) ;
-	
-	return max_power_two ;
-}
-
-// calculate next highest power of two, limited by max_power_two
-// This is taken from a brilliant little code snipped on http://acius2.blogspot.com/2007/11/calculating-next-power-of-2.html
-// Basically we convert the binary to a solid string of 1's with the same
-// number of digits, then add one.  We subtract 1 initially to handle
-// the case where the number passed in is actually a power of two.
-// WARNING: this only works with 32 bit ints.
-inline U32 get_next_power_two(U32 val, U32 max_power_two)
-{
-	if(!max_power_two)
-	{
-		max_power_two = 1 << 31 ;
-	}
-
-	if(val >= max_power_two)
-	{
-		return max_power_two;
-	}
-
-	val--;
-	val = (val >> 1) | val;
-	val = (val >> 2) | val;
-	val = (val >> 4) | val;
-	val = (val >> 8) | val;
-	val = (val >> 16) | val;
-	val++;
-
-	return val;
-}
-
-//get the gaussian value given the linear distance from axis x and guassian value o
-inline F32 llgaussian(F32 x, F32 o)
-{
-	return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
-}
-
-#endif
+/** 
+ * @file llmath.h
+ * @brief Useful math constants and macros.
+ *
+ * $LicenseInfo:firstyear=2000&license=viewergpl$
+ * 
+ * Copyright (c) 2000-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LLMATH_H
+#define LLMATH_H
+
+#include <cmath>
+#include <cstdlib>
+#include "lldefs.h"
+//#include "llstl.h" // *TODO: Remove when LLString is gone
+//#include "llstring.h" // *TODO: Remove when LLString is gone
+// lltut.h uses is_approx_equal_fraction(). This was moved to its own header
+// file in llcommon so we can use lltut.h for llcommon tests without making
+// llcommon depend on llmath.
+#include "is_approx_equal_fraction.h"
+
+// work around for Windows & older gcc non-standard function names.
+#if LL_WINDOWS
+#include <float.h>
+#define llisnan(val)	_isnan(val)
+#define llfinite(val)	_finite(val)
+#elif (LL_LINUX && __GNUC__ <= 2)
+#define llisnan(val)	isnan(val)
+#define llfinite(val)	isfinite(val)
+#elif LL_SOLARIS
+#define llisnan(val)    isnan(val)
+#define llfinite(val)   (val <= std::numeric_limits<double>::max())
+#else
+#define llisnan(val)	std::isnan(val)
+#define llfinite(val)	std::isfinite(val)
+#endif
+
+// Single Precision Floating Point Routines
+// (There used to be more defined here, but they appeared to be redundant and 
+// were breaking some other includes. Removed by Falcon, reviewed by Andrew, 11/25/09)
+/*#ifndef tanf
+#define tanf(x)		((F32)tan((F64)(x)))
+#endif*/
+
+const F32	GRAVITY			= -9.8f;
+
+// mathematical constants
+const F32	F_PI		= 3.1415926535897932384626433832795f;
+const F32	F_TWO_PI	= 6.283185307179586476925286766559f;
+const F32	F_PI_BY_TWO	= 1.5707963267948966192313216916398f;
+const F32	F_SQRT_TWO_PI = 2.506628274631000502415765284811f;
+const F32	F_E			= 2.71828182845904523536f;
+const F32	F_SQRT2		= 1.4142135623730950488016887242097f;
+const F32	F_SQRT3		= 1.73205080756888288657986402541f;
+const F32	OO_SQRT2	= 0.7071067811865475244008443621049f;
+const F32	DEG_TO_RAD	= 0.017453292519943295769236907684886f;
+const F32	RAD_TO_DEG	= 57.295779513082320876798154814105f;
+const F32	F_APPROXIMATELY_ZERO = 0.00001f;
+const F32	F_LN2		= 0.69314718056f;
+const F32	OO_LN2		= 1.4426950408889634073599246810019f;
+
+const F32	F_ALMOST_ZERO	= 0.0001f;
+const F32	F_ALMOST_ONE	= 1.0f - F_ALMOST_ZERO;
+
+// BUG: Eliminate in favor of F_APPROXIMATELY_ZERO above?
+const F32 FP_MAG_THRESHOLD = 0.0000001f;
+
+// TODO: Replace with logic like is_approx_equal
+inline BOOL is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f < F_APPROXIMATELY_ZERO); }
+
+// These functions work by interpreting sign+exp+mantissa as an unsigned
+// integer.
+// For example:
+// x = <sign>1 <exponent>00000010 <mantissa>00000000000000000000000
+// y = <sign>1 <exponent>00000001 <mantissa>11111111111111111111111
+//
+// interpreted as ints = 
+// x = 10000001000000000000000000000000
+// y = 10000000111111111111111111111111
+// which is clearly a different of 1 in the least significant bit
+// Values with the same exponent can be trivially shown to work.
+//
+// WARNING: Denormals of opposite sign do not work
+// x = <sign>1 <exponent>00000000 <mantissa>00000000000000000000001
+// y = <sign>0 <exponent>00000000 <mantissa>00000000000000000000001
+// Although these values differ by 2 in the LSB, the sign bit makes
+// the int comparison fail.
+//
+// WARNING: NaNs can compare equal
+// There is no special treatment of exceptional values like NaNs
+//
+// WARNING: Infinity is comparable with F32_MAX and negative 
+// infinity is comparable with F32_MIN
+
+inline BOOL is_approx_equal(F32 x, F32 y)
+{
+	const S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
+	return (std::abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
+}
+
+inline BOOL is_approx_equal(F64 x, F64 y)
+{
+	const S64 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
+	return (std::abs((S32) ((U64&)x - (U64&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
+}
+
+inline S32 llabs(const S32 a)
+{
+	return S32(std::labs(a));
+}
+
+inline F32 llabs(const F32 a)
+{
+	return F32(std::fabs(a));
+}
+
+inline F64 llabs(const F64 a)
+{
+	return F64(std::fabs(a));
+}
+
+inline S32 lltrunc( F32 f )
+{
+#if LL_WINDOWS && !defined( __INTEL_COMPILER )
+		// Avoids changing the floating point control word.
+		// Add or subtract 0.5 - epsilon and then round
+		const static U32 zpfp[] = { 0xBEFFFFFF, 0x3EFFFFFF };
+		S32 result;
+		__asm {
+			fld		f
+			mov		eax,	f
+			shr		eax,	29
+			and		eax,	4
+			fadd	dword ptr [zpfp + eax]
+			fistp	result
+		}
+		return result;
+#else
+		return (S32)f;
+#endif
+}
+
+inline S32 lltrunc( F64 f )
+{
+	return (S32)f;
+}
+
+inline S32 llfloor( F32 f )
+{
+#if LL_WINDOWS && !defined( __INTEL_COMPILER )
+		// Avoids changing the floating point control word.
+		// Accurate (unlike Stereopsis version) for all values between S32_MIN and S32_MAX and slightly faster than Stereopsis version.
+		// Add -(0.5 - epsilon) and then round
+		const U32 zpfp = 0xBEFFFFFF;
+		S32 result;
+		__asm { 
+			fld		f
+			fadd	dword ptr [zpfp]
+			fistp	result
+		}
+		return result;
+#else
+		return (S32)floor(f);
+#endif
+}
+
+
+inline S32 llceil( F32 f )
+{
+	// This could probably be optimized, but this works.
+	return (S32)ceil(f);
+}
+
+
+#ifndef BOGUS_ROUND
+// Use this round.  Does an arithmetic round (0.5 always rounds up)
+inline S32 llround(const F32 val)
+{
+	return llfloor(val + 0.5f);
+}
+
+#else // BOGUS_ROUND
+// Old llround implementation - does banker's round (toward nearest even in the case of a 0.5.
+// Not using this because we don't have a consistent implementation on both platforms, use
+// llfloor(val + 0.5f), which is consistent on all platforms.
+inline S32 llround(const F32 val)
+{
+	#if LL_WINDOWS
+		// Note: assumes that the floating point control word is set to rounding mode (the default)
+		S32 ret_val;
+		_asm fld	val
+		_asm fistp	ret_val;
+		return ret_val;
+	#elif LL_LINUX
+		// Note: assumes that the floating point control word is set
+		// to rounding mode (the default)
+		S32 ret_val;
+		__asm__ __volatile__( "flds %1    \n\t"
+							  "fistpl %0  \n\t"
+							  : "=m" (ret_val)
+							  : "m" (val) );
+		return ret_val;
+	#else
+		return llfloor(val + 0.5f);
+	#endif
+}
+
+// A fast arithmentic round on intel, from Laurent de Soras http://ldesoras.free.fr
+inline int round_int(double x)
+{
+	const float round_to_nearest = 0.5f;
+	int i;
+	__asm
+	{
+		fld x
+		fadd st, st (0)
+		fadd round_to_nearest
+		fistp i
+		sar i, 1
+	}
+	return (i);
+}
+#endif // BOGUS_ROUND
+
+inline F32 llround( F32 val, F32 nearest )
+{
+	return F32(floor(val * (1.0f / nearest) + 0.5f)) * nearest;
+}
+
+inline F64 llround( F64 val, F64 nearest )
+{
+	return F64(floor(val * (1.0 / nearest) + 0.5)) * nearest;
+}
+
+// these provide minimum peak error
+//
+// avg  error = -0.013049 
+// peak error = -31.4 dB
+// RMS  error = -28.1 dB
+
+const F32 FAST_MAG_ALPHA = 0.960433870103f;
+const F32 FAST_MAG_BETA = 0.397824734759f;
+
+// these provide minimum RMS error
+//
+// avg  error = 0.000003 
+// peak error = -32.6 dB
+// RMS  error = -25.7 dB
+//
+//const F32 FAST_MAG_ALPHA = 0.948059448969f;
+//const F32 FAST_MAG_BETA = 0.392699081699f;
+
+inline F32 fastMagnitude(F32 a, F32 b)
+{ 
+	a = (a > 0) ? a : -a;
+	b = (b > 0) ? b : -b;
+	return(FAST_MAG_ALPHA * llmax(a,b) + FAST_MAG_BETA * llmin(a,b));
+}
+
+
+
+////////////////////
+//
+// Fast F32/S32 conversions
+//
+// Culled from www.stereopsis.com/FPU.html
+
+const F64 LL_DOUBLE_TO_FIX_MAGIC	= 68719476736.0*1.5;     //2^36 * 1.5,  (52-_shiftamt=36) uses limited precisicion to floor
+const S32 LL_SHIFT_AMOUNT			= 16;                    //16.16 fixed point representation,
+
+// Endian dependent code
+#ifdef LL_LITTLE_ENDIAN
+	#define LL_EXP_INDEX				1
+	#define LL_MAN_INDEX				0
+#else
+	#define LL_EXP_INDEX				0
+	#define LL_MAN_INDEX				1
+#endif
+
+/* Deprecated: use llround(), lltrunc(), or llfloor() instead
+// ================================================================================================
+// Real2Int
+// ================================================================================================
+inline S32 F64toS32(F64 val)
+{
+	val		= val + LL_DOUBLE_TO_FIX_MAGIC;
+	return ((S32*)&val)[LL_MAN_INDEX] >> LL_SHIFT_AMOUNT; 
+}
+
+// ================================================================================================
+// Real2Int
+// ================================================================================================
+inline S32 F32toS32(F32 val)
+{
+	return F64toS32 ((F64)val);
+}
+*/
+
+////////////////////////////////////////////////
+//
+// Fast exp and log
+//
+
+// Implementation of fast exp() approximation (from a paper by Nicol N. Schraudolph
+// http://www.inf.ethz.ch/~schraudo/pubs/exp.pdf
+static union
+{
+	double d;
+	struct
+	{
+#ifdef LL_LITTLE_ENDIAN
+		S32 j, i;
+#else
+		S32 i, j;
+#endif
+	} n;
+} LLECO; // not sure what the name means
+
+#define LL_EXP_A (1048576 * OO_LN2) // use 1512775 for integer
+#define LL_EXP_C (60801)			// this value of C good for -4 < y < 4
+
+#define LL_FAST_EXP(y) (LLECO.n.i = llround(F32(LL_EXP_A*(y))) + (1072693248 - LL_EXP_C), LLECO.d)
+
+
+
+inline F32 llfastpow(const F32 x, const F32 y)
+{
+	return (F32)(LL_FAST_EXP(y * log(x)));
+}
+
+
+inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
+{
+	// compute the power of ten
+	F32 bar = 1.f;
+	for (S32 i = 0; i < sig_figs; i++)
+	{
+		bar *= 10.f;
+	}
+
+	//F32 new_foo = (F32)llround(foo * bar);
+	// the llround() implementation sucks.  Don't us it.
+
+	F32 sign = (foo > 0.f) ? 1.f : -1.f;
+	F32 new_foo = F32( S64(foo * bar + sign * 0.5f));
+	new_foo /= bar;
+
+	return new_foo;
+}
+
+inline F32 lerp(F32 a, F32 b, F32 u) 
+{
+	return a + ((b - a) * u);
+}
+
+inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)
+{
+	F32 a = x00 + (x01-x00)*u;
+	F32 b = x10 + (x11-x10)*u;
+	F32 r = a + (b-a)*v;
+	return r;
+}
+
+inline F32 ramp(F32 x, F32 a, F32 b)
+{
+	return (a == b) ? 0.0f : ((a - x) / (a - b));
+}
+
+inline F32 rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)
+{
+	return lerp(y1, y2, ramp(x, x1, x2));
+}
+
+inline F32 clamp_rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)
+{
+	if (y1 < y2)
+	{
+		return llclamp(rescale(x,x1,x2,y1,y2),y1,y2);
+	}
+	else
+	{
+		return llclamp(rescale(x,x1,x2,y1,y2),y2,y1);
+	}
+}
+
+
+inline F32 cubic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )
+{
+	if (x <= x0)
+		return s0;
+
+	if (x >= x1)
+		return s1;
+
+	F32 f = (x - x0) / (x1 - x0);
+
+	return	s0 + (s1 - s0) * (f * f) * (3.0f - 2.0f * f);
+}
+
+inline F32 cubic_step( F32 x )
+{
+	x = llclampf(x);
+
+	return	(x * x) * (3.0f - 2.0f * x);
+}
+
+inline F32 quadratic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )
+{
+	if (x <= x0)
+		return s0;
+
+	if (x >= x1)
+		return s1;
+
+	F32 f = (x - x0) / (x1 - x0);
+	F32 f_squared = f * f;
+
+	return	(s0 * (1.f - f_squared)) + ((s1 - s0) * f_squared);
+}
+
+inline F32 llsimple_angle(F32 angle)
+{
+	while(angle <= -F_PI)
+		angle += F_TWO_PI;
+	while(angle >  F_PI)
+		angle -= F_TWO_PI;
+	return angle;
+}
+
+//SDK - Renamed this to get_lower_power_two, since this is what this actually does.
+inline U32 get_lower_power_two(U32 val, U32 max_power_two)
+{
+	if(!max_power_two)
+	{
+		max_power_two = 1 << 31 ;
+	}
+	if(max_power_two & (max_power_two - 1))
+	{
+		return 0 ;
+	}
+
+	for(; val < max_power_two ; max_power_two >>= 1) ;
+	
+	return max_power_two ;
+}
+
+// calculate next highest power of two, limited by max_power_two
+// This is taken from a brilliant little code snipped on http://acius2.blogspot.com/2007/11/calculating-next-power-of-2.html
+// Basically we convert the binary to a solid string of 1's with the same
+// number of digits, then add one.  We subtract 1 initially to handle
+// the case where the number passed in is actually a power of two.
+// WARNING: this only works with 32 bit ints.
+inline U32 get_next_power_two(U32 val, U32 max_power_two)
+{
+	if(!max_power_two)
+	{
+		max_power_two = 1 << 31 ;
+	}
+
+	if(val >= max_power_two)
+	{
+		return max_power_two;
+	}
+
+	val--;
+	val = (val >> 1) | val;
+	val = (val >> 2) | val;
+	val = (val >> 4) | val;
+	val = (val >> 8) | val;
+	val = (val >> 16) | val;
+	val++;
+
+	return val;
+}
+
+//get the gaussian value given the linear distance from axis x and guassian value o
+inline F32 llgaussian(F32 x, F32 o)
+{
+	return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
+}
+
+// Include simd math header
+#include "llsimdmath.h"
+
+#endif
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 59828ae5650..432e9fbcd8a 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -142,7 +142,7 @@ class LLOctreeNode : public LLTreeNode<T>
 	
 	S32 getOctant(const LLVector4a& pos) const			//get the octant pos is in
 	{
-		return pos.greaterThan4(mD[CENTER]).getComparisonMask() & 0x7;
+		return pos.greaterThan(mD[CENTER]).getGatheredBits() & 0x7;
 	}
 	
 	inline bool isInside(const LLVector4a& pos, const F32& rad) const
@@ -157,13 +157,13 @@ class LLOctreeNode : public LLTreeNode<T>
 
 	bool isInside(const LLVector4a& pos) const
 	{
-		S32 gt = pos.greaterThan4(mD[MAX]).getComparisonMask() & 0x7;
+		S32 gt = pos.greaterThan(mD[MAX]).getGatheredBits() & 0x7;
 		if (gt)
 		{
 			return false;
 		}
 
-		S32 lt = pos.lessEqual4(mD[MIN]).getComparisonMask() & 0x7;
+		S32 lt = pos.lessEqual(mD[MIN]).getGatheredBits() & 0x7;
 		if (lt)
 		{
 			return false;
@@ -206,13 +206,13 @@ class LLOctreeNode : public LLTreeNode<T>
 	{
 		const LLVector4a& pos = data->getPositionGroup();
 
-		LLVector4a gt = pos.greaterThan4(center);
+		LLVector4a gt = pos.greaterThan(center);
 
 		LLVector4a up;
-		up.mQ = _mm_and_ps(size.mQ, gt.mQ);
+		up = _mm_and_ps(size, gt);
 
 		LLVector4a down;
-		down.mQ = _mm_andnot_ps(gt.mQ, size.mQ);
+		down = _mm_andnot_ps(gt, size);
 
 		center.add(up);
 		center.sub(down);
@@ -326,9 +326,8 @@ class LLOctreeNode : public LLTreeNode<T>
 				LLVector4a val;
 				val.setSub(center, getCenter());
 				val.setAbs(val);
-				LLVector4a app_zero;
-				app_zero.mQ = F_APPROXIMATELY_ZERO_4A;
-				S32 lt = val.lessThan4(app_zero).getComparisonMask() & 0x7;
+								
+				S32 lt = val.lessThan(LLVector4a::getEpsilon()).getGatheredBits() & 0x7;
 
 				if( lt == 0x7 )
 				{
@@ -642,7 +641,7 @@ class LLOctreeRoot : public LLOctreeNode<T>
 		LLVector4a val;
 		val.setSub(v, BaseType::mD[BaseType::CENTER]);
 		val.setAbs(val);
-		S32 lt = val.lessThan4(MAX_MAG).getComparisonMask() & 0x7;
+		S32 lt = val.lessThan(MAX_MAG).getGatheredBits() & 0x7;
 
 		if (lt != 0x7)
 		{
diff --git a/indra/llmath/llquantize.h b/indra/llmath/llquantize.h
index 2192427f07b..000d8a060fe 100644
--- a/indra/llmath/llquantize.h
+++ b/indra/llmath/llquantize.h
@@ -1,152 +1,158 @@
-/** 
- * @file llquantize.h
- * @brief useful routines for quantizing floats to various length ints
- * and back out again
- *
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- * 
- * Copyright (c) 2001-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLQUANTIZE_H
-#define LL_LLQUANTIZE_H
-
-const U16 U16MAX = 65535;
-const F32 OOU16MAX = 1.f/(F32)(U16MAX);
-
-const U8 U8MAX = 255;
-const F32 OOU8MAX = 1.f/(F32)(U8MAX);
-
-const U8 FIRSTVALIDCHAR = 54;
-const U8 MAXSTRINGVAL = U8MAX - FIRSTVALIDCHAR; //we don't allow newline or null 
-
-
-inline U16 F32_to_U16_ROUND(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper);
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;
-	val /= (upper - lower);
-
-	// round the value.   Sreturn the U16
-	return (U16)(llround(val*U16MAX));
-}
-
-
-inline U16 F32_to_U16(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper);
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;
-	val /= (upper - lower);
-
-	// return the U16
-	return (U16)(llfloor(val*U16MAX));
-}
-
-inline F32 U16_to_F32(U16 ival, F32 lower, F32 upper)
-{
-	F32 val = ival*OOU16MAX;
-	F32 delta = (upper - lower);
-	val *= delta;
-	val += lower;
-
-	F32 max_error = delta*OOU16MAX;
-
-	// make sure that zero's come through as zero
-	if (fabsf(val) < max_error)
-		val = 0.f;
-
-	return val;
-}
-
-
-inline U8 F32_to_U8_ROUND(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper);
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;
-	val /= (upper - lower);
-
-	// return the rounded U8
-	return (U8)(llround(val*U8MAX));
-}
-
-
-inline U8 F32_to_U8(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper);
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;
-	val /= (upper - lower);
-
-	// return the U8
-	return (U8)(llfloor(val*U8MAX));
-}
-
-inline F32 U8_to_F32(U8 ival, F32 lower, F32 upper)
-{
-	F32 val = ival*OOU8MAX;
-	F32 delta = (upper - lower);
-	val *= delta;
-	val += lower;
-
-	F32 max_error = delta*OOU8MAX;
-
-	// make sure that zero's come through as zero
-	if (fabsf(val) < max_error)
-		val = 0.f;
-
-	return val;
-}
-
-inline U8 F32_TO_STRING(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper); //[lower, upper]
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;					//[0, upper-lower]
-	val /= (upper - lower);			//[0,1]
-	val = val * MAXSTRINGVAL;		//[0, MAXSTRINGVAL]
-	val = floor(val + 0.5f);		//[0, MAXSTRINGVAL]
-
-	U8 stringVal = (U8)(val) + FIRSTVALIDCHAR;			//[FIRSTVALIDCHAR, MAXSTRINGVAL + FIRSTVALIDCHAR]
-	return stringVal;
-}
-
-inline F32 STRING_TO_F32(U8 ival, F32 lower, F32 upper)
-{
-	// remove empty space left for NULL, newline, etc.
-	ival -= FIRSTVALIDCHAR;								//[0, MAXSTRINGVAL]
-
-	F32 val = (F32)ival * (1.f / (F32)MAXSTRINGVAL);	//[0, 1]
-	F32 delta = (upper - lower);
-	val *= delta;										//[0, upper - lower]
-	val += lower;										//[lower, upper]
-
-	return val;
-}
-
-#endif
+/** 
+ * @file llquantize.h
+ * @brief useful routines for quantizing floats to various length ints
+ * and back out again
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLQUANTIZE_H
+#define LL_LLQUANTIZE_H
+
+const U16 U16MAX = 65535;
+LL_ALIGN_16( const F32 F_U16MAX_4A[4] ) = { 65535.f, 65535.f, 65535.f, 65535.f };
+
+const F32 OOU16MAX = 1.f/(F32)(U16MAX);
+LL_ALIGN_16( const F32 F_OOU16MAX_4A[4] ) = { OOU16MAX, OOU16MAX, OOU16MAX, OOU16MAX };
+
+const U8 U8MAX = 255;
+LL_ALIGN_16( const F32 F_U8MAX_4A[4] ) = { 255.f, 255.f, 255.f, 255.f };
+
+const F32 OOU8MAX = 1.f/(F32)(U8MAX);
+LL_ALIGN_16( const F32 F_OOU8MAX_4A[4] ) = { OOU8MAX, OOU8MAX, OOU8MAX, OOU8MAX };
+
+const U8 FIRSTVALIDCHAR = 54;
+const U8 MAXSTRINGVAL = U8MAX - FIRSTVALIDCHAR; //we don't allow newline or null 
+
+
+inline U16 F32_to_U16_ROUND(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper);
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;
+	val /= (upper - lower);
+
+	// round the value.   Sreturn the U16
+	return (U16)(llround(val*U16MAX));
+}
+
+
+inline U16 F32_to_U16(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper);
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;
+	val /= (upper - lower);
+
+	// return the U16
+	return (U16)(llfloor(val*U16MAX));
+}
+
+inline F32 U16_to_F32(U16 ival, F32 lower, F32 upper)
+{
+	F32 val = ival*OOU16MAX;
+	F32 delta = (upper - lower);
+	val *= delta;
+	val += lower;
+
+	F32 max_error = delta*OOU16MAX;
+
+	// make sure that zero's come through as zero
+	if (fabsf(val) < max_error)
+		val = 0.f;
+
+	return val;
+}
+
+
+inline U8 F32_to_U8_ROUND(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper);
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;
+	val /= (upper - lower);
+
+	// return the rounded U8
+	return (U8)(llround(val*U8MAX));
+}
+
+
+inline U8 F32_to_U8(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper);
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;
+	val /= (upper - lower);
+
+	// return the U8
+	return (U8)(llfloor(val*U8MAX));
+}
+
+inline F32 U8_to_F32(U8 ival, F32 lower, F32 upper)
+{
+	F32 val = ival*OOU8MAX;
+	F32 delta = (upper - lower);
+	val *= delta;
+	val += lower;
+
+	F32 max_error = delta*OOU8MAX;
+
+	// make sure that zero's come through as zero
+	if (fabsf(val) < max_error)
+		val = 0.f;
+
+	return val;
+}
+
+inline U8 F32_TO_STRING(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper); //[lower, upper]
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;					//[0, upper-lower]
+	val /= (upper - lower);			//[0,1]
+	val = val * MAXSTRINGVAL;		//[0, MAXSTRINGVAL]
+	val = floor(val + 0.5f);		//[0, MAXSTRINGVAL]
+
+	U8 stringVal = (U8)(val) + FIRSTVALIDCHAR;			//[FIRSTVALIDCHAR, MAXSTRINGVAL + FIRSTVALIDCHAR]
+	return stringVal;
+}
+
+inline F32 STRING_TO_F32(U8 ival, F32 lower, F32 upper)
+{
+	// remove empty space left for NULL, newline, etc.
+	ival -= FIRSTVALIDCHAR;								//[0, MAXSTRINGVAL]
+
+	F32 val = (F32)ival * (1.f / (F32)MAXSTRINGVAL);	//[0, 1]
+	F32 delta = (upper - lower);
+	val *= delta;										//[0, upper - lower]
+	val += lower;										//[lower, upper]
+
+	return val;
+}
+
+#endif
diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp
index fdcc19d657b..efdc10e2c62 100644
--- a/indra/llmath/llquaternion.cpp
+++ b/indra/llmath/llquaternion.cpp
@@ -1,960 +1,961 @@
-/** 
- * @file llquaternion.cpp
- * @brief LLQuaternion class implementation.
- *
- * $LicenseInfo:firstyear=2000&license=viewergpl$
- * 
- * Copyright (c) 2000-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "llquaternion.h"
-
-#include "llmath.h"	// for F_PI
-//#include "vmath.h"
-#include "v3math.h"
-#include "v3dmath.h"
-#include "v4math.h"
-#include "m4math.h"
-#include "m3math.h"
-#include "llquantize.h"
-
-// WARNING: Don't use this for global const definitions!  using this
-// at the top of a *.cpp file might not give you what you think.
-const LLQuaternion LLQuaternion::DEFAULT;
- 
-// Constructors
-
-LLQuaternion::LLQuaternion(const LLMatrix4 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-}
-
-LLQuaternion::LLQuaternion(const LLMatrix3 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-}
-
-LLQuaternion::LLQuaternion(F32 angle, const LLVector4 &vec)
-{
-	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
-	v.normalize();
-
-	F32 c, s;
-	c = cosf(angle*0.5f);
-	s = sinf(angle*0.5f);
-
-	mQ[VX] = v.mV[VX] * s;
-	mQ[VY] = v.mV[VY] * s;
-	mQ[VZ] = v.mV[VZ] * s;
-	mQ[VW] = c;
-	normalize();
-}
-
-LLQuaternion::LLQuaternion(F32 angle, const LLVector3 &vec)
-{
-	LLVector3 v(vec);
-	v.normalize();
-
-	F32 c, s;
-	c = cosf(angle*0.5f);
-	s = sinf(angle*0.5f);
-
-	mQ[VX] = v.mV[VX] * s;
-	mQ[VY] = v.mV[VY] * s;
-	mQ[VZ] = v.mV[VZ] * s;
-	mQ[VW] = c;
-	normalize();
-}
-
-LLQuaternion::LLQuaternion(const LLVector3 &x_axis,
-						   const LLVector3 &y_axis,
-						   const LLVector3 &z_axis)
-{
-	LLMatrix3 mat;
-	mat.setRows(x_axis, y_axis, z_axis);
-	*this = mat.quaternion();
-	normalize();
-}
-
-// Quatizations
-void	LLQuaternion::quantize16(F32 lower, F32 upper)
-{
-	F32 x = mQ[VX];
-	F32 y = mQ[VY];
-	F32 z = mQ[VZ];
-	F32 s = mQ[VS];
-
-	x = U16_to_F32(F32_to_U16_ROUND(x, lower, upper), lower, upper);
-	y = U16_to_F32(F32_to_U16_ROUND(y, lower, upper), lower, upper);
-	z = U16_to_F32(F32_to_U16_ROUND(z, lower, upper), lower, upper);
-	s = U16_to_F32(F32_to_U16_ROUND(s, lower, upper), lower, upper);
-
-	mQ[VX] = x;
-	mQ[VY] = y;
-	mQ[VZ] = z;
-	mQ[VS] = s;
-
-	normalize();
-}
-
-void	LLQuaternion::quantize8(F32 lower, F32 upper)
-{
-	mQ[VX] = U8_to_F32(F32_to_U8_ROUND(mQ[VX], lower, upper), lower, upper);
-	mQ[VY] = U8_to_F32(F32_to_U8_ROUND(mQ[VY], lower, upper), lower, upper);
-	mQ[VZ] = U8_to_F32(F32_to_U8_ROUND(mQ[VZ], lower, upper), lower, upper);
-	mQ[VS] = U8_to_F32(F32_to_U8_ROUND(mQ[VS], lower, upper), lower, upper);
-
-	normalize();
-}
-
-// LLVector3 Magnitude and Normalization Functions
-
-
-// Set LLQuaternion routines
-
-const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, F32 x, F32 y, F32 z)
-{
-	LLVector3 vec(x, y, z);
-	vec.normalize();
-
-	angle *= 0.5f;
-	F32 c, s;
-	c = cosf(angle);
-	s = sinf(angle);
-
-	mQ[VX] = vec.mV[VX]*s;
-	mQ[VY] = vec.mV[VY]*s;
-	mQ[VZ] = vec.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, const LLVector3 &vec)
-{
-	LLVector3 v(vec);
-	v.normalize();
-
-	angle *= 0.5f;
-	F32 c, s;
-	c = cosf(angle);
-	s = sinf(angle);
-
-	mQ[VX] = v.mV[VX]*s;
-	mQ[VY] = v.mV[VY]*s;
-	mQ[VZ] = v.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, const LLVector4 &vec)
-{
-	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
-	v.normalize();
-
-	F32 c, s;
-	c = cosf(angle*0.5f);
-	s = sinf(angle*0.5f);
-
-	mQ[VX] = v.mV[VX]*s;
-	mQ[VY] = v.mV[VY]*s;
-	mQ[VZ] = v.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setEulerAngles(F32 roll, F32 pitch, F32 yaw)
-{
-	LLMatrix3 rot_mat(roll, pitch, yaw);
-	rot_mat.orthogonalize();
-	*this = rot_mat.quaternion();
-		
-	normalize();
-	return (*this);
-}
-
-// deprecated
-const LLQuaternion&	LLQuaternion::set(const LLMatrix3 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-	return (*this);
-}
-
-// deprecated
-const LLQuaternion&	LLQuaternion::set(const LLMatrix4 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-	return (*this);
-}
-
-// deprecated
-const LLQuaternion&	LLQuaternion::setQuat(F32 angle, F32 x, F32 y, F32 z)
-{
-	LLVector3 vec(x, y, z);
-	vec.normalize();
-
-	angle *= 0.5f;
-	F32 c, s;
-	c = cosf(angle);
-	s = sinf(angle);
-
-	mQ[VX] = vec.mV[VX]*s;
-	mQ[VY] = vec.mV[VY]*s;
-	mQ[VZ] = vec.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-// deprecated
-const LLQuaternion&	LLQuaternion::setQuat(F32 angle, const LLVector3 &vec)
-{
-	LLVector3 v(vec);
-	v.normalize();
-
-	angle *= 0.5f;
-	F32 c, s;
-	c = cosf(angle);
-	s = sinf(angle);
-
-	mQ[VX] = v.mV[VX]*s;
-	mQ[VY] = v.mV[VY]*s;
-	mQ[VZ] = v.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setQuat(F32 angle, const LLVector4 &vec)
-{
-	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
-	v.normalize();
-
-	F32 c, s;
-	c = cosf(angle*0.5f);
-	s = sinf(angle*0.5f);
-
-	mQ[VX] = v.mV[VX]*s;
-	mQ[VY] = v.mV[VY]*s;
-	mQ[VZ] = v.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setQuat(F32 roll, F32 pitch, F32 yaw)
-{
-	LLMatrix3 rot_mat(roll, pitch, yaw);
-	rot_mat.orthogonalize();
-	*this = rot_mat.quaternion();
-		
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setQuat(const LLMatrix3 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setQuat(const LLMatrix4 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-	return (*this);
-//#if 1
-//	// NOTE: LLQuaternion's are actually inverted with respect to
-//	// the matrices, so this code also assumes inverted quaternions
-//	// (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
-//	// in reverse order (yaw,pitch,roll).
-//	F64 cosX = cos(roll);
-//    F64 cosY = cos(pitch);
-//    F64 cosZ = cos(yaw);
-//
-//    F64 sinX = sin(roll);
-//    F64 sinY = sin(pitch);
-//    F64 sinZ = sin(yaw);
-//
-//    mQ[VW] = (F32)sqrt(cosY*cosZ - sinX*sinY*sinZ + cosX*cosZ + cosX*cosY + 1.0)*.5;
-//	if (fabs(mQ[VW]) < F_APPROXIMATELY_ZERO)
-//	{
-//		// null rotation, any axis will do
-//		mQ[VX] = 0.0f;
-//		mQ[VY] = 1.0f;
-//		mQ[VZ] = 0.0f;
-//	}
-//	else
-//	{
-//		F32 inv_s = 1.0f / (4.0f * mQ[VW]);
-//		mQ[VX] = (F32)-(-sinX*cosY - cosX*sinY*sinZ - sinX*cosZ) * inv_s;
-//		mQ[VY] = (F32)-(-cosX*sinY*cosZ + sinX*sinZ - sinY) * inv_s;
-//		mQ[VZ] = (F32)-(-cosY*sinZ - sinX*sinY*cosZ - cosX*sinZ) * inv_s;		
-//	}
-//
-//#else // This only works on a certain subset of roll/pitch/yaw
-//	
-//	F64 cosX = cosf(roll/2.0);
-//    F64 cosY = cosf(pitch/2.0);
-//    F64 cosZ = cosf(yaw/2.0);
-//
-//    F64 sinX = sinf(roll/2.0);
-//    F64 sinY = sinf(pitch/2.0);
-//    F64 sinZ = sinf(yaw/2.0);
-//
-//    mQ[VW] = (F32)(cosX*cosY*cosZ + sinX*sinY*sinZ);
-//    mQ[VX] = (F32)(sinX*cosY*cosZ - cosX*sinY*sinZ);
-//    mQ[VY] = (F32)(cosX*sinY*cosZ + sinX*cosY*sinZ);
-//    mQ[VZ] = (F32)(cosX*cosY*sinZ - sinX*sinY*cosZ);
-//#endif
-//
-//	normalize();
-//	return (*this);
-}
-
-// SJB: This code is correct for a logicly stored (non-transposed) matrix;
-//		Our matrices are stored transposed, OpenGL style, so this generates the
-//		INVERSE matrix, or the CORRECT matrix form an INVERSE quaternion.
-//		Because we use similar logic in LLMatrix3::quaternion(),
-//		we are internally consistant so everything works OK :)
-LLMatrix3	LLQuaternion::getMatrix3(void) const
-{
-	LLMatrix3	mat;
-	F32		xx, xy, xz, xw, yy, yz, yw, zz, zw;
-
-    xx      = mQ[VX] * mQ[VX];
-    xy      = mQ[VX] * mQ[VY];
-    xz      = mQ[VX] * mQ[VZ];
-    xw      = mQ[VX] * mQ[VW];
-
-    yy      = mQ[VY] * mQ[VY];
-    yz      = mQ[VY] * mQ[VZ];
-    yw      = mQ[VY] * mQ[VW];
-
-    zz      = mQ[VZ] * mQ[VZ];
-    zw      = mQ[VZ] * mQ[VW];
-
-    mat.mMatrix[0][0]  = 1.f - 2.f * ( yy + zz );
-    mat.mMatrix[0][1]  =	   2.f * ( xy + zw );
-    mat.mMatrix[0][2]  =	   2.f * ( xz - yw );
-
-    mat.mMatrix[1][0]  =	   2.f * ( xy - zw );
-    mat.mMatrix[1][1]  = 1.f - 2.f * ( xx + zz );
-    mat.mMatrix[1][2]  =	   2.f * ( yz + xw );
-
-    mat.mMatrix[2][0]  =	   2.f * ( xz + yw );
-    mat.mMatrix[2][1]  =	   2.f * ( yz - xw );
-    mat.mMatrix[2][2]  = 1.f - 2.f * ( xx + yy );
-
-	return mat;
-}
-
-LLMatrix4	LLQuaternion::getMatrix4(void) const
-{
-	LLMatrix4	mat;
-	F32		xx, xy, xz, xw, yy, yz, yw, zz, zw;
-
-    xx      = mQ[VX] * mQ[VX];
-    xy      = mQ[VX] * mQ[VY];
-    xz      = mQ[VX] * mQ[VZ];
-    xw      = mQ[VX] * mQ[VW];
-
-    yy      = mQ[VY] * mQ[VY];
-    yz      = mQ[VY] * mQ[VZ];
-    yw      = mQ[VY] * mQ[VW];
-
-    zz      = mQ[VZ] * mQ[VZ];
-    zw      = mQ[VZ] * mQ[VW];
-
-    mat.mMatrix[0][0]  = 1.f - 2.f * ( yy + zz );
-    mat.mMatrix[0][1]  =	   2.f * ( xy + zw );
-    mat.mMatrix[0][2]  =	   2.f * ( xz - yw );
-
-    mat.mMatrix[1][0]  =	   2.f * ( xy - zw );
-    mat.mMatrix[1][1]  = 1.f - 2.f * ( xx + zz );
-    mat.mMatrix[1][2]  =	   2.f * ( yz + xw );
-
-    mat.mMatrix[2][0]  =	   2.f * ( xz + yw );
-    mat.mMatrix[2][1]  =	   2.f * ( yz - xw );
-    mat.mMatrix[2][2]  = 1.f - 2.f * ( xx + yy );
-
-	// TODO -- should we set the translation portion to zero?
-
-	return mat;
-}
-
-
-
-
-// Other useful methods
-
-
-// calculate the shortest rotation from a to b
-void LLQuaternion::shortestArc(const LLVector3 &a, const LLVector3 &b)
-{
-	// Make a local copy of both vectors.
-	LLVector3 vec_a = a;
-	LLVector3 vec_b = b;
-
-	// Make sure neither vector is zero length.  Also normalize
-	// the vectors while we are at it.
-	F32 vec_a_mag = vec_a.normalize();
-	F32 vec_b_mag = vec_b.normalize();
-	if (vec_a_mag < F_APPROXIMATELY_ZERO ||
-		vec_b_mag < F_APPROXIMATELY_ZERO)
-	{
-		// Can't calculate a rotation from this.
-		// Just return ZERO_ROTATION instead.
-		loadIdentity();
-		return;
-	}
-
-	// Create an axis to rotate around, and the cos of the angle to rotate.
-	LLVector3 axis = vec_a % vec_b;
-	F32 cos_theta  = vec_a * vec_b;
-
-	// Check the angle between the vectors to see if they are parallel or anti-parallel.
-	if (cos_theta > 1.0 - F_APPROXIMATELY_ZERO)
-	{
-		// a and b are parallel.  No rotation is necessary.
-		loadIdentity();
-	}
-	else if (cos_theta < -1.0 + F_APPROXIMATELY_ZERO)
-	{
-		// a and b are anti-parallel.
-		// Rotate 180 degrees around some orthogonal axis.
-		// Find the projection of the x-axis onto a, and try
-		// using the vector between the projection and the x-axis
-		// as the orthogonal axis.
-		LLVector3 proj = vec_a.mV[VX] / (vec_a * vec_a) * vec_a;
-		LLVector3 ortho_axis(1.f, 0.f, 0.f);
-		ortho_axis -= proj;
-		
-		// Turn this into an orthonormal axis.
-		F32 ortho_length = ortho_axis.normalize();
-		// If the axis' length is 0, then our guess at an orthogonal axis
-		// was wrong (a is parallel to the x-axis).
-		if (ortho_length < F_APPROXIMATELY_ZERO)
-		{
-			// Use the z-axis instead.
-			ortho_axis.setVec(0.f, 0.f, 1.f);
-		}
-
-		// Construct a quaternion from this orthonormal axis.
-		mQ[VX] = ortho_axis.mV[VX];
-		mQ[VY] = ortho_axis.mV[VY];
-		mQ[VZ] = ortho_axis.mV[VZ];
-		mQ[VW] = 0.f;
-	}
-	else
-	{
-		// a and b are NOT parallel or anti-parallel.
-		// Return the rotation between these vectors.
-		F32 theta = (F32)acos(cos_theta);
-
-		setAngleAxis(theta, axis);
-	}
-}
-
-// constrains rotation to a cone angle specified in radians
-const LLQuaternion &LLQuaternion::constrain(F32 radians)
-{
-	const F32 cos_angle_lim = cosf( radians/2 );	// mQ[VW] limit
-	const F32 sin_angle_lim = sinf( radians/2 );	// rotation axis length	limit
-
-	if (mQ[VW] < 0.f)
-	{
-		mQ[VX] *= -1.f;
-		mQ[VY] *= -1.f;
-		mQ[VZ] *= -1.f;
-		mQ[VW] *= -1.f;
-	}
-
-	// if rotation angle is greater than limit (cos is less than limit)
-	if( mQ[VW] < cos_angle_lim )
-	{
-		mQ[VW] = cos_angle_lim;
-		F32 axis_len = sqrtf( mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] ); // sin(theta/2)
-		F32 axis_mult_fact = sin_angle_lim / axis_len;
-		mQ[VX] *= axis_mult_fact;
-		mQ[VY] *= axis_mult_fact;
-		mQ[VZ] *= axis_mult_fact;
-	}
-
-	return *this;
-}
-
-// Operators
-
-std::ostream& operator<<(std::ostream &s, const LLQuaternion &a)
-{
-	s << "{ " 
-		<< a.mQ[VX] << ", " << a.mQ[VY] << ", " << a.mQ[VZ] << ", " << a.mQ[VW] 
-	<< " }";
-	return s;
-}
-
-
-// Does NOT renormalize the result
-LLQuaternion	operator*(const LLQuaternion &a, const LLQuaternion &b)
-{
-//	LLQuaternion::mMultCount++;
-
-	LLQuaternion q(
-		b.mQ[3] * a.mQ[0] + b.mQ[0] * a.mQ[3] + b.mQ[1] * a.mQ[2] - b.mQ[2] * a.mQ[1],
-		b.mQ[3] * a.mQ[1] + b.mQ[1] * a.mQ[3] + b.mQ[2] * a.mQ[0] - b.mQ[0] * a.mQ[2],
-		b.mQ[3] * a.mQ[2] + b.mQ[2] * a.mQ[3] + b.mQ[0] * a.mQ[1] - b.mQ[1] * a.mQ[0],
-		b.mQ[3] * a.mQ[3] - b.mQ[0] * a.mQ[0] - b.mQ[1] * a.mQ[1] - b.mQ[2] * a.mQ[2]
-	);
-	return q;
-}
-
-/*
-LLMatrix4	operator*(const LLMatrix4 &m, const LLQuaternion &q)
-{
-	LLMatrix4 qmat(q);
-	return (m*qmat);
-}
-*/
-
-
-
-LLVector4		operator*(const LLVector4 &a, const LLQuaternion &rot)
-{
-    F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
-    F32 rx =   rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
-    F32 ry =   rot.mQ[VW] * a.mV[VY] + rot.mQ[VZ] * a.mV[VX] - rot.mQ[VX] * a.mV[VZ];
-    F32 rz =   rot.mQ[VW] * a.mV[VZ] + rot.mQ[VX] * a.mV[VY] - rot.mQ[VY] * a.mV[VX];
-
-    F32 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
-    F32 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
-    F32 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
-
-    return LLVector4(nx, ny, nz, a.mV[VW]);
-}
-
-LLVector3		operator*(const LLVector3 &a, const LLQuaternion &rot)
-{
-    F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
-    F32 rx =   rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
-    F32 ry =   rot.mQ[VW] * a.mV[VY] + rot.mQ[VZ] * a.mV[VX] - rot.mQ[VX] * a.mV[VZ];
-    F32 rz =   rot.mQ[VW] * a.mV[VZ] + rot.mQ[VX] * a.mV[VY] - rot.mQ[VY] * a.mV[VX];
-
-    F32 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
-    F32 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
-    F32 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
-
-    return LLVector3(nx, ny, nz);
-}
-
-LLVector3d		operator*(const LLVector3d &a, const LLQuaternion &rot)
-{
-    F64 rw = - rot.mQ[VX] * a.mdV[VX] - rot.mQ[VY] * a.mdV[VY] - rot.mQ[VZ] * a.mdV[VZ];
-    F64 rx =   rot.mQ[VW] * a.mdV[VX] + rot.mQ[VY] * a.mdV[VZ] - rot.mQ[VZ] * a.mdV[VY];
-    F64 ry =   rot.mQ[VW] * a.mdV[VY] + rot.mQ[VZ] * a.mdV[VX] - rot.mQ[VX] * a.mdV[VZ];
-    F64 rz =   rot.mQ[VW] * a.mdV[VZ] + rot.mQ[VX] * a.mdV[VY] - rot.mQ[VY] * a.mdV[VX];
-
-    F64 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
-    F64 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
-    F64 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
-
-    return LLVector3d(nx, ny, nz);
-}
-
-F32 dot(const LLQuaternion &a, const LLQuaternion &b)
-{
-	return a.mQ[VX] * b.mQ[VX] + 
-		   a.mQ[VY] * b.mQ[VY] + 
-		   a.mQ[VZ] * b.mQ[VZ] + 
-		   a.mQ[VW] * b.mQ[VW]; 
-}
-
-// DEMO HACK: This lerp is probably inocrrect now due intermediate normalization
-// it should look more like the lerp below
-#if 0
-// linear interpolation
-LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q)
-{
-	LLQuaternion r;
-	r = t * (q - p) + p;
-	r.normalize();
-	return r;
-}
-#endif
-
-// lerp from identity to q
-LLQuaternion lerp(F32 t, const LLQuaternion &q)
-{
-	LLQuaternion r;
-	r.mQ[VX] = t * q.mQ[VX];
-	r.mQ[VY] = t * q.mQ[VY];
-	r.mQ[VZ] = t * q.mQ[VZ];
-	r.mQ[VW] = t * (q.mQ[VZ] - 1.f) + 1.f;
-	r.normalize();
-	return r;
-}
-
-LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q)
-{
-	LLQuaternion r;
-	F32 inv_t;
-
-	inv_t = 1.f - t;
-
-	r.mQ[VX] = t * q.mQ[VX] + (inv_t * p.mQ[VX]);
-	r.mQ[VY] = t * q.mQ[VY] + (inv_t * p.mQ[VY]);
-	r.mQ[VZ] = t * q.mQ[VZ] + (inv_t * p.mQ[VZ]);
-	r.mQ[VW] = t * q.mQ[VW] + (inv_t * p.mQ[VW]);
-	r.normalize();
-	return r;
-}
-
-
-// spherical linear interpolation
-LLQuaternion slerp( F32 u, const LLQuaternion &a, const LLQuaternion &b )
-{
-	// cosine theta = dot product of a and b
-	F32 cos_t = a.mQ[0]*b.mQ[0] + a.mQ[1]*b.mQ[1] + a.mQ[2]*b.mQ[2] + a.mQ[3]*b.mQ[3];
-	
-	// if b is on opposite hemisphere from a, use -a instead
-	int bflip;
- 	if (cos_t < 0.0f)
-	{
-		cos_t = -cos_t;
-		bflip = TRUE;
-	}
-	else
-		bflip = FALSE;
-
-	// if B is (within precision limits) the same as A,
-	// just linear interpolate between A and B.
-	F32 alpha;	// interpolant
-	F32 beta;		// 1 - interpolant
-	if (1.0f - cos_t < 0.00001f)
-	{
-		beta = 1.0f - u;
-		alpha = u;
- 	}
-	else
-	{
- 		F32 theta = acosf(cos_t);
- 		F32 sin_t = sinf(theta);
- 		beta = sinf(theta - u*theta) / sin_t;
- 		alpha = sinf(u*theta) / sin_t;
- 	}
-
-	if (bflip)
-		beta = -beta;
-
-	// interpolate
-	LLQuaternion ret;
-	ret.mQ[0] = beta*a.mQ[0] + alpha*b.mQ[0];
- 	ret.mQ[1] = beta*a.mQ[1] + alpha*b.mQ[1];
- 	ret.mQ[2] = beta*a.mQ[2] + alpha*b.mQ[2];
- 	ret.mQ[3] = beta*a.mQ[3] + alpha*b.mQ[3];
-
-	return ret;
-}
-
-// lerp whenever possible
-LLQuaternion nlerp(F32 t, const LLQuaternion &a, const LLQuaternion &b)
-{
-	if (dot(a, b) < 0.f)
-	{
-		return slerp(t, a, b);
-	}
-	else
-	{
-		return lerp(t, a, b);
-	}
-}
-
-LLQuaternion nlerp(F32 t, const LLQuaternion &q)
-{
-	if (q.mQ[VW] < 0.f)
-	{
-		return slerp(t, q);
-	}
-	else
-	{
-		return lerp(t, q);
-	}
-}
-
-// slerp from identity quaternion to another quaternion
-LLQuaternion slerp(F32 t, const LLQuaternion &q)
-{
-	F32 c = q.mQ[VW];
-	if (1.0f == t  ||  1.0f == c)
-	{
-		// the trivial cases
-		return q;
-	}
-
-	LLQuaternion r;
-	F32 s, angle, stq, stp;
-
-	s = (F32) sqrt(1.f - c*c);
-
-    if (c < 0.0f)
-    {
-        // when c < 0.0 then theta > PI/2 
-        // since quat and -quat are the same rotation we invert one of  
-        // p or q to reduce unecessary spins
-        // A equivalent way to do it is to convert acos(c) as if it had 
-		// been negative, and to negate stp 
-        angle   = (F32) acos(-c); 
-        stp     = -(F32) sin(angle * (1.f - t));
-        stq     = (F32) sin(angle * t);
-    }   
-    else
-    {
-		angle 	= (F32) acos(c);
-        stp     = (F32) sin(angle * (1.f - t));
-        stq     = (F32) sin(angle * t);
-    }
-
-	r.mQ[VX] = (q.mQ[VX] * stq) / s;
-	r.mQ[VY] = (q.mQ[VY] * stq) / s;
-	r.mQ[VZ] = (q.mQ[VZ] * stq) / s;
-	r.mQ[VW] = (stp + q.mQ[VW] * stq) / s;
-
-	return r;
-}
-
-LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order)
-{
-	LLQuaternion xQ( xRot*DEG_TO_RAD, LLVector3(1.0f, 0.0f, 0.0f) );
-	LLQuaternion yQ( yRot*DEG_TO_RAD, LLVector3(0.0f, 1.0f, 0.0f) );
-	LLQuaternion zQ( zRot*DEG_TO_RAD, LLVector3(0.0f, 0.0f, 1.0f) );
-	LLQuaternion ret;
-	switch( order )
-	{
-	case LLQuaternion::XYZ:
-		ret = xQ * yQ * zQ;
-		break;
-	case LLQuaternion::YZX:
-		ret = yQ * zQ * xQ;
-		break;
-	case LLQuaternion::ZXY:
-		ret = zQ * xQ * yQ;
-		break;
-	case LLQuaternion::XZY:
-		ret = xQ * zQ * yQ;
-		break;
-	case LLQuaternion::YXZ:
-		ret = yQ * xQ * zQ;
-		break;
-	case LLQuaternion::ZYX:
-		ret = zQ * yQ * xQ;
-		break;
-	}
-	return ret;
-}
-
-const char *OrderToString( const LLQuaternion::Order order )
-{
-	const char *p = NULL;
-	switch( order )
-	{
-	default:
-	case LLQuaternion::XYZ:
-		p = "XYZ";
-		break;
-	case LLQuaternion::YZX:
-		p = "YZX";
-		break;
-	case LLQuaternion::ZXY:
-		p = "ZXY";
-		break;
-	case LLQuaternion::XZY:
-		p = "XZY";
-		break;
-	case LLQuaternion::YXZ:
-		p = "YXZ";
-		break;
-	case LLQuaternion::ZYX:
-		p = "ZYX";
-		break;
-	}
-	return p;
-}
-
-LLQuaternion::Order StringToOrder( const char *str )
-{
-	if (strncmp(str, "XYZ", 3)==0 || strncmp(str, "xyz", 3)==0)
-		return LLQuaternion::XYZ;
-
-	if (strncmp(str, "YZX", 3)==0 || strncmp(str, "yzx", 3)==0)
-		return LLQuaternion::YZX;
-
-	if (strncmp(str, "ZXY", 3)==0 || strncmp(str, "zxy", 3)==0)
-		return LLQuaternion::ZXY;
-
-	if (strncmp(str, "XZY", 3)==0 || strncmp(str, "xzy", 3)==0)
-		return LLQuaternion::XZY;
-
-	if (strncmp(str, "YXZ", 3)==0 || strncmp(str, "yxz", 3)==0)
-		return LLQuaternion::YXZ;
-
-	if (strncmp(str, "ZYX", 3)==0 || strncmp(str, "zyx", 3)==0)
-		return LLQuaternion::ZYX;
-
-	return LLQuaternion::XYZ;
-}
-
-void LLQuaternion::getAngleAxis(F32* angle, LLVector3 &vec) const
-{
-	F32 cos_a = mQ[VW];
-	if (cos_a > 1.0f) cos_a = 1.0f;
-	if (cos_a < -1.0f) cos_a = -1.0f;
-
-    F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
-
-    if ( fabs( sin_a ) < 0.0005f )
-		sin_a = 1.0f;
-	else
-		sin_a = 1.f/sin_a;
-
-    F32 temp_angle = 2.0f * (F32) acos( cos_a );
-	if (temp_angle > F_PI)
-	{
-		// The (angle,axis) pair should never have angles outside [PI, -PI]
-		// since we want the _shortest_ (angle,axis) solution.
-		// Since acos is defined for [0, PI], and we multiply by 2.0, we
-		// can push the angle outside the acceptible range.
-		// When this happens we set the angle to the other portion of a 
-		// full 2PI rotation, and negate the axis, which reverses the 
-		// direction of the rotation (by the right-hand rule).
-		*angle = 2.f * F_PI - temp_angle;
-    	vec.mV[VX] = - mQ[VX] * sin_a;
-    	vec.mV[VY] = - mQ[VY] * sin_a;
-    	vec.mV[VZ] = - mQ[VZ] * sin_a;
-	}
-	else
-	{
-		*angle = temp_angle;
-    	vec.mV[VX] = mQ[VX] * sin_a;
-    	vec.mV[VY] = mQ[VY] * sin_a;
-    	vec.mV[VZ] = mQ[VZ] * sin_a;
-	}
-}
-
-
-// quaternion does not need to be normalized
-void LLQuaternion::getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) const
-{
-	LLMatrix3 rot_mat(*this);
-	rot_mat.orthogonalize();
-	rot_mat.getEulerAngles(roll, pitch, yaw);
-
-//	// NOTE: LLQuaternion's are actually inverted with respect to
-//	// the matrices, so this code also assumes inverted quaternions
-//	// (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
-//	// in reverse order (yaw,pitch,roll).
-//	F32 x = -mQ[VX], y = -mQ[VY], z = -mQ[VZ], w = mQ[VW];
-//	F64 m20 = 2.0*(x*z-y*w);
-//	if (1.0f - fabsf(m20) < F_APPROXIMATELY_ZERO)
-//	{
-//		*roll = 0.0f;
-//		*pitch = (F32)asin(m20);
-//		*yaw = (F32)atan2(2.0*(x*y-z*w), 1.0 - 2.0*(x*x+z*z));
-//	}
-//	else
-//	{
-//		*roll  = (F32)atan2(-2.0*(y*z+x*w), 1.0-2.0*(x*x+y*y));
-//		*pitch = (F32)asin(m20);
-//		*yaw   = (F32)atan2(-2.0*(x*y+z*w), 1.0-2.0*(y*y+z*z));
-//	}
-}
-
-// Saves space by using the fact that our quaternions are normalized
-LLVector3 LLQuaternion::packToVector3() const
-{
-	if( mQ[VW] >= 0 )
-	{
-		return LLVector3( mQ[VX], mQ[VY], mQ[VZ] );
-	}
-	else
-	{
-		return LLVector3( -mQ[VX], -mQ[VY], -mQ[VZ] );
-	}
-}
-
-// Saves space by using the fact that our quaternions are normalized
-void LLQuaternion::unpackFromVector3( const LLVector3& vec )
-{
-	mQ[VX] = vec.mV[VX];
-	mQ[VY] = vec.mV[VY];
-	mQ[VZ] = vec.mV[VZ];
-	F32 t = 1.f - vec.magVecSquared();
-	if( t > 0 )
-	{
-		mQ[VW] = sqrt( t );
-	}
-	else
-	{
-		// Need this to avoid trying to find the square root of a negative number due
-		// to floating point error.
-		mQ[VW] = 0;
-	}
-}
-
-BOOL LLQuaternion::parseQuat(const std::string& buf, LLQuaternion* value)
-{
-	if( buf.empty() || value == NULL)
-	{
-		return FALSE;
-	}
-
-	LLQuaternion quat;
-	S32 count = sscanf( buf.c_str(), "%f %f %f %f", quat.mQ + 0, quat.mQ + 1, quat.mQ + 2, quat.mQ + 3 );
-	if( 4 == count )
-	{
-		value->set( quat );
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-
-// End
+/** 
+ * @file llquaternion.cpp
+ * @brief LLQuaternion class implementation.
+ *
+ * $LicenseInfo:firstyear=2000&license=viewergpl$
+ * 
+ * Copyright (c) 2000-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+
+#include "llmath.h"	// for F_PI
+
+#include "llquaternion.h"
+
+//#include "vmath.h"
+#include "v3math.h"
+#include "v3dmath.h"
+#include "v4math.h"
+#include "m4math.h"
+#include "m3math.h"
+#include "llquantize.h"
+
+// WARNING: Don't use this for global const definitions!  using this
+// at the top of a *.cpp file might not give you what you think.
+const LLQuaternion LLQuaternion::DEFAULT;
+ 
+// Constructors
+
+LLQuaternion::LLQuaternion(const LLMatrix4 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+}
+
+LLQuaternion::LLQuaternion(const LLMatrix3 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+}
+
+LLQuaternion::LLQuaternion(F32 angle, const LLVector4 &vec)
+{
+	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
+	v.normalize();
+
+	F32 c, s;
+	c = cosf(angle*0.5f);
+	s = sinf(angle*0.5f);
+
+	mQ[VX] = v.mV[VX] * s;
+	mQ[VY] = v.mV[VY] * s;
+	mQ[VZ] = v.mV[VZ] * s;
+	mQ[VW] = c;
+	normalize();
+}
+
+LLQuaternion::LLQuaternion(F32 angle, const LLVector3 &vec)
+{
+	LLVector3 v(vec);
+	v.normalize();
+
+	F32 c, s;
+	c = cosf(angle*0.5f);
+	s = sinf(angle*0.5f);
+
+	mQ[VX] = v.mV[VX] * s;
+	mQ[VY] = v.mV[VY] * s;
+	mQ[VZ] = v.mV[VZ] * s;
+	mQ[VW] = c;
+	normalize();
+}
+
+LLQuaternion::LLQuaternion(const LLVector3 &x_axis,
+						   const LLVector3 &y_axis,
+						   const LLVector3 &z_axis)
+{
+	LLMatrix3 mat;
+	mat.setRows(x_axis, y_axis, z_axis);
+	*this = mat.quaternion();
+	normalize();
+}
+
+// Quatizations
+void	LLQuaternion::quantize16(F32 lower, F32 upper)
+{
+	F32 x = mQ[VX];
+	F32 y = mQ[VY];
+	F32 z = mQ[VZ];
+	F32 s = mQ[VS];
+
+	x = U16_to_F32(F32_to_U16_ROUND(x, lower, upper), lower, upper);
+	y = U16_to_F32(F32_to_U16_ROUND(y, lower, upper), lower, upper);
+	z = U16_to_F32(F32_to_U16_ROUND(z, lower, upper), lower, upper);
+	s = U16_to_F32(F32_to_U16_ROUND(s, lower, upper), lower, upper);
+
+	mQ[VX] = x;
+	mQ[VY] = y;
+	mQ[VZ] = z;
+	mQ[VS] = s;
+
+	normalize();
+}
+
+void	LLQuaternion::quantize8(F32 lower, F32 upper)
+{
+	mQ[VX] = U8_to_F32(F32_to_U8_ROUND(mQ[VX], lower, upper), lower, upper);
+	mQ[VY] = U8_to_F32(F32_to_U8_ROUND(mQ[VY], lower, upper), lower, upper);
+	mQ[VZ] = U8_to_F32(F32_to_U8_ROUND(mQ[VZ], lower, upper), lower, upper);
+	mQ[VS] = U8_to_F32(F32_to_U8_ROUND(mQ[VS], lower, upper), lower, upper);
+
+	normalize();
+}
+
+// LLVector3 Magnitude and Normalization Functions
+
+
+// Set LLQuaternion routines
+
+const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, F32 x, F32 y, F32 z)
+{
+	LLVector3 vec(x, y, z);
+	vec.normalize();
+
+	angle *= 0.5f;
+	F32 c, s;
+	c = cosf(angle);
+	s = sinf(angle);
+
+	mQ[VX] = vec.mV[VX]*s;
+	mQ[VY] = vec.mV[VY]*s;
+	mQ[VZ] = vec.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, const LLVector3 &vec)
+{
+	LLVector3 v(vec);
+	v.normalize();
+
+	angle *= 0.5f;
+	F32 c, s;
+	c = cosf(angle);
+	s = sinf(angle);
+
+	mQ[VX] = v.mV[VX]*s;
+	mQ[VY] = v.mV[VY]*s;
+	mQ[VZ] = v.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, const LLVector4 &vec)
+{
+	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
+	v.normalize();
+
+	F32 c, s;
+	c = cosf(angle*0.5f);
+	s = sinf(angle*0.5f);
+
+	mQ[VX] = v.mV[VX]*s;
+	mQ[VY] = v.mV[VY]*s;
+	mQ[VZ] = v.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setEulerAngles(F32 roll, F32 pitch, F32 yaw)
+{
+	LLMatrix3 rot_mat(roll, pitch, yaw);
+	rot_mat.orthogonalize();
+	*this = rot_mat.quaternion();
+		
+	normalize();
+	return (*this);
+}
+
+// deprecated
+const LLQuaternion&	LLQuaternion::set(const LLMatrix3 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+	return (*this);
+}
+
+// deprecated
+const LLQuaternion&	LLQuaternion::set(const LLMatrix4 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+	return (*this);
+}
+
+// deprecated
+const LLQuaternion&	LLQuaternion::setQuat(F32 angle, F32 x, F32 y, F32 z)
+{
+	LLVector3 vec(x, y, z);
+	vec.normalize();
+
+	angle *= 0.5f;
+	F32 c, s;
+	c = cosf(angle);
+	s = sinf(angle);
+
+	mQ[VX] = vec.mV[VX]*s;
+	mQ[VY] = vec.mV[VY]*s;
+	mQ[VZ] = vec.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+// deprecated
+const LLQuaternion&	LLQuaternion::setQuat(F32 angle, const LLVector3 &vec)
+{
+	LLVector3 v(vec);
+	v.normalize();
+
+	angle *= 0.5f;
+	F32 c, s;
+	c = cosf(angle);
+	s = sinf(angle);
+
+	mQ[VX] = v.mV[VX]*s;
+	mQ[VY] = v.mV[VY]*s;
+	mQ[VZ] = v.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setQuat(F32 angle, const LLVector4 &vec)
+{
+	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
+	v.normalize();
+
+	F32 c, s;
+	c = cosf(angle*0.5f);
+	s = sinf(angle*0.5f);
+
+	mQ[VX] = v.mV[VX]*s;
+	mQ[VY] = v.mV[VY]*s;
+	mQ[VZ] = v.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setQuat(F32 roll, F32 pitch, F32 yaw)
+{
+	LLMatrix3 rot_mat(roll, pitch, yaw);
+	rot_mat.orthogonalize();
+	*this = rot_mat.quaternion();
+		
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setQuat(const LLMatrix3 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setQuat(const LLMatrix4 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+	return (*this);
+//#if 1
+//	// NOTE: LLQuaternion's are actually inverted with respect to
+//	// the matrices, so this code also assumes inverted quaternions
+//	// (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
+//	// in reverse order (yaw,pitch,roll).
+//	F64 cosX = cos(roll);
+//    F64 cosY = cos(pitch);
+//    F64 cosZ = cos(yaw);
+//
+//    F64 sinX = sin(roll);
+//    F64 sinY = sin(pitch);
+//    F64 sinZ = sin(yaw);
+//
+//    mQ[VW] = (F32)sqrt(cosY*cosZ - sinX*sinY*sinZ + cosX*cosZ + cosX*cosY + 1.0)*.5;
+//	if (fabs(mQ[VW]) < F_APPROXIMATELY_ZERO)
+//	{
+//		// null rotation, any axis will do
+//		mQ[VX] = 0.0f;
+//		mQ[VY] = 1.0f;
+//		mQ[VZ] = 0.0f;
+//	}
+//	else
+//	{
+//		F32 inv_s = 1.0f / (4.0f * mQ[VW]);
+//		mQ[VX] = (F32)-(-sinX*cosY - cosX*sinY*sinZ - sinX*cosZ) * inv_s;
+//		mQ[VY] = (F32)-(-cosX*sinY*cosZ + sinX*sinZ - sinY) * inv_s;
+//		mQ[VZ] = (F32)-(-cosY*sinZ - sinX*sinY*cosZ - cosX*sinZ) * inv_s;		
+//	}
+//
+//#else // This only works on a certain subset of roll/pitch/yaw
+//	
+//	F64 cosX = cosf(roll/2.0);
+//    F64 cosY = cosf(pitch/2.0);
+//    F64 cosZ = cosf(yaw/2.0);
+//
+//    F64 sinX = sinf(roll/2.0);
+//    F64 sinY = sinf(pitch/2.0);
+//    F64 sinZ = sinf(yaw/2.0);
+//
+//    mQ[VW] = (F32)(cosX*cosY*cosZ + sinX*sinY*sinZ);
+//    mQ[VX] = (F32)(sinX*cosY*cosZ - cosX*sinY*sinZ);
+//    mQ[VY] = (F32)(cosX*sinY*cosZ + sinX*cosY*sinZ);
+//    mQ[VZ] = (F32)(cosX*cosY*sinZ - sinX*sinY*cosZ);
+//#endif
+//
+//	normalize();
+//	return (*this);
+}
+
+// SJB: This code is correct for a logicly stored (non-transposed) matrix;
+//		Our matrices are stored transposed, OpenGL style, so this generates the
+//		INVERSE matrix, or the CORRECT matrix form an INVERSE quaternion.
+//		Because we use similar logic in LLMatrix3::quaternion(),
+//		we are internally consistant so everything works OK :)
+LLMatrix3	LLQuaternion::getMatrix3(void) const
+{
+	LLMatrix3	mat;
+	F32		xx, xy, xz, xw, yy, yz, yw, zz, zw;
+
+    xx      = mQ[VX] * mQ[VX];
+    xy      = mQ[VX] * mQ[VY];
+    xz      = mQ[VX] * mQ[VZ];
+    xw      = mQ[VX] * mQ[VW];
+
+    yy      = mQ[VY] * mQ[VY];
+    yz      = mQ[VY] * mQ[VZ];
+    yw      = mQ[VY] * mQ[VW];
+
+    zz      = mQ[VZ] * mQ[VZ];
+    zw      = mQ[VZ] * mQ[VW];
+
+    mat.mMatrix[0][0]  = 1.f - 2.f * ( yy + zz );
+    mat.mMatrix[0][1]  =	   2.f * ( xy + zw );
+    mat.mMatrix[0][2]  =	   2.f * ( xz - yw );
+
+    mat.mMatrix[1][0]  =	   2.f * ( xy - zw );
+    mat.mMatrix[1][1]  = 1.f - 2.f * ( xx + zz );
+    mat.mMatrix[1][2]  =	   2.f * ( yz + xw );
+
+    mat.mMatrix[2][0]  =	   2.f * ( xz + yw );
+    mat.mMatrix[2][1]  =	   2.f * ( yz - xw );
+    mat.mMatrix[2][2]  = 1.f - 2.f * ( xx + yy );
+
+	return mat;
+}
+
+LLMatrix4	LLQuaternion::getMatrix4(void) const
+{
+	LLMatrix4	mat;
+	F32		xx, xy, xz, xw, yy, yz, yw, zz, zw;
+
+    xx      = mQ[VX] * mQ[VX];
+    xy      = mQ[VX] * mQ[VY];
+    xz      = mQ[VX] * mQ[VZ];
+    xw      = mQ[VX] * mQ[VW];
+
+    yy      = mQ[VY] * mQ[VY];
+    yz      = mQ[VY] * mQ[VZ];
+    yw      = mQ[VY] * mQ[VW];
+
+    zz      = mQ[VZ] * mQ[VZ];
+    zw      = mQ[VZ] * mQ[VW];
+
+    mat.mMatrix[0][0]  = 1.f - 2.f * ( yy + zz );
+    mat.mMatrix[0][1]  =	   2.f * ( xy + zw );
+    mat.mMatrix[0][2]  =	   2.f * ( xz - yw );
+
+    mat.mMatrix[1][0]  =	   2.f * ( xy - zw );
+    mat.mMatrix[1][1]  = 1.f - 2.f * ( xx + zz );
+    mat.mMatrix[1][2]  =	   2.f * ( yz + xw );
+
+    mat.mMatrix[2][0]  =	   2.f * ( xz + yw );
+    mat.mMatrix[2][1]  =	   2.f * ( yz - xw );
+    mat.mMatrix[2][2]  = 1.f - 2.f * ( xx + yy );
+
+	// TODO -- should we set the translation portion to zero?
+
+	return mat;
+}
+
+
+
+
+// Other useful methods
+
+
+// calculate the shortest rotation from a to b
+void LLQuaternion::shortestArc(const LLVector3 &a, const LLVector3 &b)
+{
+	// Make a local copy of both vectors.
+	LLVector3 vec_a = a;
+	LLVector3 vec_b = b;
+
+	// Make sure neither vector is zero length.  Also normalize
+	// the vectors while we are at it.
+	F32 vec_a_mag = vec_a.normalize();
+	F32 vec_b_mag = vec_b.normalize();
+	if (vec_a_mag < F_APPROXIMATELY_ZERO ||
+		vec_b_mag < F_APPROXIMATELY_ZERO)
+	{
+		// Can't calculate a rotation from this.
+		// Just return ZERO_ROTATION instead.
+		loadIdentity();
+		return;
+	}
+
+	// Create an axis to rotate around, and the cos of the angle to rotate.
+	LLVector3 axis = vec_a % vec_b;
+	F32 cos_theta  = vec_a * vec_b;
+
+	// Check the angle between the vectors to see if they are parallel or anti-parallel.
+	if (cos_theta > 1.0 - F_APPROXIMATELY_ZERO)
+	{
+		// a and b are parallel.  No rotation is necessary.
+		loadIdentity();
+	}
+	else if (cos_theta < -1.0 + F_APPROXIMATELY_ZERO)
+	{
+		// a and b are anti-parallel.
+		// Rotate 180 degrees around some orthogonal axis.
+		// Find the projection of the x-axis onto a, and try
+		// using the vector between the projection and the x-axis
+		// as the orthogonal axis.
+		LLVector3 proj = vec_a.mV[VX] / (vec_a * vec_a) * vec_a;
+		LLVector3 ortho_axis(1.f, 0.f, 0.f);
+		ortho_axis -= proj;
+		
+		// Turn this into an orthonormal axis.
+		F32 ortho_length = ortho_axis.normalize();
+		// If the axis' length is 0, then our guess at an orthogonal axis
+		// was wrong (a is parallel to the x-axis).
+		if (ortho_length < F_APPROXIMATELY_ZERO)
+		{
+			// Use the z-axis instead.
+			ortho_axis.setVec(0.f, 0.f, 1.f);
+		}
+
+		// Construct a quaternion from this orthonormal axis.
+		mQ[VX] = ortho_axis.mV[VX];
+		mQ[VY] = ortho_axis.mV[VY];
+		mQ[VZ] = ortho_axis.mV[VZ];
+		mQ[VW] = 0.f;
+	}
+	else
+	{
+		// a and b are NOT parallel or anti-parallel.
+		// Return the rotation between these vectors.
+		F32 theta = (F32)acos(cos_theta);
+
+		setAngleAxis(theta, axis);
+	}
+}
+
+// constrains rotation to a cone angle specified in radians
+const LLQuaternion &LLQuaternion::constrain(F32 radians)
+{
+	const F32 cos_angle_lim = cosf( radians/2 );	// mQ[VW] limit
+	const F32 sin_angle_lim = sinf( radians/2 );	// rotation axis length	limit
+
+	if (mQ[VW] < 0.f)
+	{
+		mQ[VX] *= -1.f;
+		mQ[VY] *= -1.f;
+		mQ[VZ] *= -1.f;
+		mQ[VW] *= -1.f;
+	}
+
+	// if rotation angle is greater than limit (cos is less than limit)
+	if( mQ[VW] < cos_angle_lim )
+	{
+		mQ[VW] = cos_angle_lim;
+		F32 axis_len = sqrtf( mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] ); // sin(theta/2)
+		F32 axis_mult_fact = sin_angle_lim / axis_len;
+		mQ[VX] *= axis_mult_fact;
+		mQ[VY] *= axis_mult_fact;
+		mQ[VZ] *= axis_mult_fact;
+	}
+
+	return *this;
+}
+
+// Operators
+
+std::ostream& operator<<(std::ostream &s, const LLQuaternion &a)
+{
+	s << "{ " 
+		<< a.mQ[VX] << ", " << a.mQ[VY] << ", " << a.mQ[VZ] << ", " << a.mQ[VW] 
+	<< " }";
+	return s;
+}
+
+
+// Does NOT renormalize the result
+LLQuaternion	operator*(const LLQuaternion &a, const LLQuaternion &b)
+{
+//	LLQuaternion::mMultCount++;
+
+	LLQuaternion q(
+		b.mQ[3] * a.mQ[0] + b.mQ[0] * a.mQ[3] + b.mQ[1] * a.mQ[2] - b.mQ[2] * a.mQ[1],
+		b.mQ[3] * a.mQ[1] + b.mQ[1] * a.mQ[3] + b.mQ[2] * a.mQ[0] - b.mQ[0] * a.mQ[2],
+		b.mQ[3] * a.mQ[2] + b.mQ[2] * a.mQ[3] + b.mQ[0] * a.mQ[1] - b.mQ[1] * a.mQ[0],
+		b.mQ[3] * a.mQ[3] - b.mQ[0] * a.mQ[0] - b.mQ[1] * a.mQ[1] - b.mQ[2] * a.mQ[2]
+	);
+	return q;
+}
+
+/*
+LLMatrix4	operator*(const LLMatrix4 &m, const LLQuaternion &q)
+{
+	LLMatrix4 qmat(q);
+	return (m*qmat);
+}
+*/
+
+
+
+LLVector4		operator*(const LLVector4 &a, const LLQuaternion &rot)
+{
+    F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
+    F32 rx =   rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
+    F32 ry =   rot.mQ[VW] * a.mV[VY] + rot.mQ[VZ] * a.mV[VX] - rot.mQ[VX] * a.mV[VZ];
+    F32 rz =   rot.mQ[VW] * a.mV[VZ] + rot.mQ[VX] * a.mV[VY] - rot.mQ[VY] * a.mV[VX];
+
+    F32 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
+    F32 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
+    F32 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
+
+    return LLVector4(nx, ny, nz, a.mV[VW]);
+}
+
+LLVector3		operator*(const LLVector3 &a, const LLQuaternion &rot)
+{
+    F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
+    F32 rx =   rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
+    F32 ry =   rot.mQ[VW] * a.mV[VY] + rot.mQ[VZ] * a.mV[VX] - rot.mQ[VX] * a.mV[VZ];
+    F32 rz =   rot.mQ[VW] * a.mV[VZ] + rot.mQ[VX] * a.mV[VY] - rot.mQ[VY] * a.mV[VX];
+
+    F32 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
+    F32 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
+    F32 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
+
+    return LLVector3(nx, ny, nz);
+}
+
+LLVector3d		operator*(const LLVector3d &a, const LLQuaternion &rot)
+{
+    F64 rw = - rot.mQ[VX] * a.mdV[VX] - rot.mQ[VY] * a.mdV[VY] - rot.mQ[VZ] * a.mdV[VZ];
+    F64 rx =   rot.mQ[VW] * a.mdV[VX] + rot.mQ[VY] * a.mdV[VZ] - rot.mQ[VZ] * a.mdV[VY];
+    F64 ry =   rot.mQ[VW] * a.mdV[VY] + rot.mQ[VZ] * a.mdV[VX] - rot.mQ[VX] * a.mdV[VZ];
+    F64 rz =   rot.mQ[VW] * a.mdV[VZ] + rot.mQ[VX] * a.mdV[VY] - rot.mQ[VY] * a.mdV[VX];
+
+    F64 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
+    F64 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
+    F64 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
+
+    return LLVector3d(nx, ny, nz);
+}
+
+F32 dot(const LLQuaternion &a, const LLQuaternion &b)
+{
+	return a.mQ[VX] * b.mQ[VX] + 
+		   a.mQ[VY] * b.mQ[VY] + 
+		   a.mQ[VZ] * b.mQ[VZ] + 
+		   a.mQ[VW] * b.mQ[VW]; 
+}
+
+// DEMO HACK: This lerp is probably inocrrect now due intermediate normalization
+// it should look more like the lerp below
+#if 0
+// linear interpolation
+LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q)
+{
+	LLQuaternion r;
+	r = t * (q - p) + p;
+	r.normalize();
+	return r;
+}
+#endif
+
+// lerp from identity to q
+LLQuaternion lerp(F32 t, const LLQuaternion &q)
+{
+	LLQuaternion r;
+	r.mQ[VX] = t * q.mQ[VX];
+	r.mQ[VY] = t * q.mQ[VY];
+	r.mQ[VZ] = t * q.mQ[VZ];
+	r.mQ[VW] = t * (q.mQ[VZ] - 1.f) + 1.f;
+	r.normalize();
+	return r;
+}
+
+LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q)
+{
+	LLQuaternion r;
+	F32 inv_t;
+
+	inv_t = 1.f - t;
+
+	r.mQ[VX] = t * q.mQ[VX] + (inv_t * p.mQ[VX]);
+	r.mQ[VY] = t * q.mQ[VY] + (inv_t * p.mQ[VY]);
+	r.mQ[VZ] = t * q.mQ[VZ] + (inv_t * p.mQ[VZ]);
+	r.mQ[VW] = t * q.mQ[VW] + (inv_t * p.mQ[VW]);
+	r.normalize();
+	return r;
+}
+
+
+// spherical linear interpolation
+LLQuaternion slerp( F32 u, const LLQuaternion &a, const LLQuaternion &b )
+{
+	// cosine theta = dot product of a and b
+	F32 cos_t = a.mQ[0]*b.mQ[0] + a.mQ[1]*b.mQ[1] + a.mQ[2]*b.mQ[2] + a.mQ[3]*b.mQ[3];
+	
+	// if b is on opposite hemisphere from a, use -a instead
+	int bflip;
+ 	if (cos_t < 0.0f)
+	{
+		cos_t = -cos_t;
+		bflip = TRUE;
+	}
+	else
+		bflip = FALSE;
+
+	// if B is (within precision limits) the same as A,
+	// just linear interpolate between A and B.
+	F32 alpha;	// interpolant
+	F32 beta;		// 1 - interpolant
+	if (1.0f - cos_t < 0.00001f)
+	{
+		beta = 1.0f - u;
+		alpha = u;
+ 	}
+	else
+	{
+ 		F32 theta = acosf(cos_t);
+ 		F32 sin_t = sinf(theta);
+ 		beta = sinf(theta - u*theta) / sin_t;
+ 		alpha = sinf(u*theta) / sin_t;
+ 	}
+
+	if (bflip)
+		beta = -beta;
+
+	// interpolate
+	LLQuaternion ret;
+	ret.mQ[0] = beta*a.mQ[0] + alpha*b.mQ[0];
+ 	ret.mQ[1] = beta*a.mQ[1] + alpha*b.mQ[1];
+ 	ret.mQ[2] = beta*a.mQ[2] + alpha*b.mQ[2];
+ 	ret.mQ[3] = beta*a.mQ[3] + alpha*b.mQ[3];
+
+	return ret;
+}
+
+// lerp whenever possible
+LLQuaternion nlerp(F32 t, const LLQuaternion &a, const LLQuaternion &b)
+{
+	if (dot(a, b) < 0.f)
+	{
+		return slerp(t, a, b);
+	}
+	else
+	{
+		return lerp(t, a, b);
+	}
+}
+
+LLQuaternion nlerp(F32 t, const LLQuaternion &q)
+{
+	if (q.mQ[VW] < 0.f)
+	{
+		return slerp(t, q);
+	}
+	else
+	{
+		return lerp(t, q);
+	}
+}
+
+// slerp from identity quaternion to another quaternion
+LLQuaternion slerp(F32 t, const LLQuaternion &q)
+{
+	F32 c = q.mQ[VW];
+	if (1.0f == t  ||  1.0f == c)
+	{
+		// the trivial cases
+		return q;
+	}
+
+	LLQuaternion r;
+	F32 s, angle, stq, stp;
+
+	s = (F32) sqrt(1.f - c*c);
+
+    if (c < 0.0f)
+    {
+        // when c < 0.0 then theta > PI/2 
+        // since quat and -quat are the same rotation we invert one of  
+        // p or q to reduce unecessary spins
+        // A equivalent way to do it is to convert acos(c) as if it had 
+		// been negative, and to negate stp 
+        angle   = (F32) acos(-c); 
+        stp     = -(F32) sin(angle * (1.f - t));
+        stq     = (F32) sin(angle * t);
+    }   
+    else
+    {
+		angle 	= (F32) acos(c);
+        stp     = (F32) sin(angle * (1.f - t));
+        stq     = (F32) sin(angle * t);
+    }
+
+	r.mQ[VX] = (q.mQ[VX] * stq) / s;
+	r.mQ[VY] = (q.mQ[VY] * stq) / s;
+	r.mQ[VZ] = (q.mQ[VZ] * stq) / s;
+	r.mQ[VW] = (stp + q.mQ[VW] * stq) / s;
+
+	return r;
+}
+
+LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order)
+{
+	LLQuaternion xQ( xRot*DEG_TO_RAD, LLVector3(1.0f, 0.0f, 0.0f) );
+	LLQuaternion yQ( yRot*DEG_TO_RAD, LLVector3(0.0f, 1.0f, 0.0f) );
+	LLQuaternion zQ( zRot*DEG_TO_RAD, LLVector3(0.0f, 0.0f, 1.0f) );
+	LLQuaternion ret;
+	switch( order )
+	{
+	case LLQuaternion::XYZ:
+		ret = xQ * yQ * zQ;
+		break;
+	case LLQuaternion::YZX:
+		ret = yQ * zQ * xQ;
+		break;
+	case LLQuaternion::ZXY:
+		ret = zQ * xQ * yQ;
+		break;
+	case LLQuaternion::XZY:
+		ret = xQ * zQ * yQ;
+		break;
+	case LLQuaternion::YXZ:
+		ret = yQ * xQ * zQ;
+		break;
+	case LLQuaternion::ZYX:
+		ret = zQ * yQ * xQ;
+		break;
+	}
+	return ret;
+}
+
+const char *OrderToString( const LLQuaternion::Order order )
+{
+	const char *p = NULL;
+	switch( order )
+	{
+	default:
+	case LLQuaternion::XYZ:
+		p = "XYZ";
+		break;
+	case LLQuaternion::YZX:
+		p = "YZX";
+		break;
+	case LLQuaternion::ZXY:
+		p = "ZXY";
+		break;
+	case LLQuaternion::XZY:
+		p = "XZY";
+		break;
+	case LLQuaternion::YXZ:
+		p = "YXZ";
+		break;
+	case LLQuaternion::ZYX:
+		p = "ZYX";
+		break;
+	}
+	return p;
+}
+
+LLQuaternion::Order StringToOrder( const char *str )
+{
+	if (strncmp(str, "XYZ", 3)==0 || strncmp(str, "xyz", 3)==0)
+		return LLQuaternion::XYZ;
+
+	if (strncmp(str, "YZX", 3)==0 || strncmp(str, "yzx", 3)==0)
+		return LLQuaternion::YZX;
+
+	if (strncmp(str, "ZXY", 3)==0 || strncmp(str, "zxy", 3)==0)
+		return LLQuaternion::ZXY;
+
+	if (strncmp(str, "XZY", 3)==0 || strncmp(str, "xzy", 3)==0)
+		return LLQuaternion::XZY;
+
+	if (strncmp(str, "YXZ", 3)==0 || strncmp(str, "yxz", 3)==0)
+		return LLQuaternion::YXZ;
+
+	if (strncmp(str, "ZYX", 3)==0 || strncmp(str, "zyx", 3)==0)
+		return LLQuaternion::ZYX;
+
+	return LLQuaternion::XYZ;
+}
+
+void LLQuaternion::getAngleAxis(F32* angle, LLVector3 &vec) const
+{
+	F32 cos_a = mQ[VW];
+	if (cos_a > 1.0f) cos_a = 1.0f;
+	if (cos_a < -1.0f) cos_a = -1.0f;
+
+    F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
+
+    if ( fabs( sin_a ) < 0.0005f )
+		sin_a = 1.0f;
+	else
+		sin_a = 1.f/sin_a;
+
+    F32 temp_angle = 2.0f * (F32) acos( cos_a );
+	if (temp_angle > F_PI)
+	{
+		// The (angle,axis) pair should never have angles outside [PI, -PI]
+		// since we want the _shortest_ (angle,axis) solution.
+		// Since acos is defined for [0, PI], and we multiply by 2.0, we
+		// can push the angle outside the acceptible range.
+		// When this happens we set the angle to the other portion of a 
+		// full 2PI rotation, and negate the axis, which reverses the 
+		// direction of the rotation (by the right-hand rule).
+		*angle = 2.f * F_PI - temp_angle;
+    	vec.mV[VX] = - mQ[VX] * sin_a;
+    	vec.mV[VY] = - mQ[VY] * sin_a;
+    	vec.mV[VZ] = - mQ[VZ] * sin_a;
+	}
+	else
+	{
+		*angle = temp_angle;
+    	vec.mV[VX] = mQ[VX] * sin_a;
+    	vec.mV[VY] = mQ[VY] * sin_a;
+    	vec.mV[VZ] = mQ[VZ] * sin_a;
+	}
+}
+
+
+// quaternion does not need to be normalized
+void LLQuaternion::getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) const
+{
+	LLMatrix3 rot_mat(*this);
+	rot_mat.orthogonalize();
+	rot_mat.getEulerAngles(roll, pitch, yaw);
+
+//	// NOTE: LLQuaternion's are actually inverted with respect to
+//	// the matrices, so this code also assumes inverted quaternions
+//	// (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
+//	// in reverse order (yaw,pitch,roll).
+//	F32 x = -mQ[VX], y = -mQ[VY], z = -mQ[VZ], w = mQ[VW];
+//	F64 m20 = 2.0*(x*z-y*w);
+//	if (1.0f - fabsf(m20) < F_APPROXIMATELY_ZERO)
+//	{
+//		*roll = 0.0f;
+//		*pitch = (F32)asin(m20);
+//		*yaw = (F32)atan2(2.0*(x*y-z*w), 1.0 - 2.0*(x*x+z*z));
+//	}
+//	else
+//	{
+//		*roll  = (F32)atan2(-2.0*(y*z+x*w), 1.0-2.0*(x*x+y*y));
+//		*pitch = (F32)asin(m20);
+//		*yaw   = (F32)atan2(-2.0*(x*y+z*w), 1.0-2.0*(y*y+z*z));
+//	}
+}
+
+// Saves space by using the fact that our quaternions are normalized
+LLVector3 LLQuaternion::packToVector3() const
+{
+	if( mQ[VW] >= 0 )
+	{
+		return LLVector3( mQ[VX], mQ[VY], mQ[VZ] );
+	}
+	else
+	{
+		return LLVector3( -mQ[VX], -mQ[VY], -mQ[VZ] );
+	}
+}
+
+// Saves space by using the fact that our quaternions are normalized
+void LLQuaternion::unpackFromVector3( const LLVector3& vec )
+{
+	mQ[VX] = vec.mV[VX];
+	mQ[VY] = vec.mV[VY];
+	mQ[VZ] = vec.mV[VZ];
+	F32 t = 1.f - vec.magVecSquared();
+	if( t > 0 )
+	{
+		mQ[VW] = sqrt( t );
+	}
+	else
+	{
+		// Need this to avoid trying to find the square root of a negative number due
+		// to floating point error.
+		mQ[VW] = 0;
+	}
+}
+
+BOOL LLQuaternion::parseQuat(const std::string& buf, LLQuaternion* value)
+{
+	if( buf.empty() || value == NULL)
+	{
+		return FALSE;
+	}
+
+	LLQuaternion quat;
+	S32 count = sscanf( buf.c_str(), "%f %f %f %f", quat.mQ + 0, quat.mQ + 1, quat.mQ + 2, quat.mQ + 3 );
+	if( 4 == count )
+	{
+		value->set( quat );
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+
+// End
diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h
index 0769f29f235..bbd4326483b 100644
--- a/indra/llmath/llquaternion.h
+++ b/indra/llmath/llquaternion.h
@@ -1,590 +1,594 @@
-/** 
- * @file llquaternion.h
- * @brief LLQuaternion class header file.
- *
- * $LicenseInfo:firstyear=2000&license=viewergpl$
- * 
- * Copyright (c) 2000-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LLQUATERNION_H
-#define LLQUATERNION_H
-
-#include "llmath.h"
-
-class LLVector4;
-class LLVector3;
-class LLVector3d;
-class LLMatrix4;
-class LLMatrix3;
-
-//	NOTA BENE: Quaternion code is written assuming Unit Quaternions!!!!
-//			   Moreover, it is written assuming that all vectors and matricies
-//			   passed as arguments are normalized and unitary respectively.
-//			   VERY VERY VERY VERY BAD THINGS will happen if these assumptions fail.
-
-static const U32 LENGTHOFQUAT = 4;
-
-class LLQuaternion
-{
-public:
-	F32 mQ[LENGTHOFQUAT];
-
-	static const LLQuaternion DEFAULT;
-
-	LLQuaternion();									// Initializes Quaternion to (0,0,0,1)
-	explicit LLQuaternion(const LLMatrix4 &mat);				// Initializes Quaternion from Matrix4
-	explicit LLQuaternion(const LLMatrix3 &mat);				// Initializes Quaternion from Matrix3
-	LLQuaternion(F32 x, F32 y, F32 z, F32 w);		// Initializes Quaternion to normalize(x, y, z, w)
-	LLQuaternion(F32 angle, const LLVector4 &vec);	// Initializes Quaternion to axis_angle2quat(angle, vec)
-	LLQuaternion(F32 angle, const LLVector3 &vec);	// Initializes Quaternion to axis_angle2quat(angle, vec)
-	LLQuaternion(const F32 *q);						// Initializes Quaternion to normalize(x, y, z, w)
-	LLQuaternion(const LLVector3 &x_axis,
-				 const LLVector3 &y_axis,
-				 const LLVector3 &z_axis);			// Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis]
-
-	BOOL isIdentity() const;
-	BOOL isNotIdentity() const;
-	BOOL isFinite() const;									// checks to see if all values of LLQuaternion are finite
-	void quantize16(F32 lower, F32 upper);					// changes the vector to reflect quatization
-	void quantize8(F32 lower, F32 upper);							// changes the vector to reflect quatization
-	void loadIdentity();											// Loads the quaternion that represents the identity rotation
-
-	const LLQuaternion&	set(F32 x, F32 y, F32 z, F32 w);		// Sets Quaternion to normalize(x, y, z, w)
-	const LLQuaternion&	set(const LLQuaternion &quat);			// Copies Quaternion
-	const LLQuaternion&	set(const F32 *q);						// Sets Quaternion to normalize(quat[VX], quat[VY], quat[VZ], quat[VW])
-	const LLQuaternion&	set(const LLMatrix3 &mat);				// Sets Quaternion to mat2quat(mat)
-	const LLQuaternion&	set(const LLMatrix4 &mat);				// Sets Quaternion to mat2quat(mat)
-
-	const LLQuaternion&	setAngleAxis(F32 angle, F32 x, F32 y, F32 z);	// Sets Quaternion to axis_angle2quat(angle, x, y, z)
-	const LLQuaternion&	setAngleAxis(F32 angle, const LLVector3 &vec);	// Sets Quaternion to axis_angle2quat(angle, vec)
-	const LLQuaternion&	setAngleAxis(F32 angle, const LLVector4 &vec);	// Sets Quaternion to axis_angle2quat(angle, vec)
-	const LLQuaternion&	setEulerAngles(F32 roll, F32 pitch, F32 yaw);	// Sets Quaternion to euler2quat(pitch, yaw, roll)
-
-	const LLQuaternion&	setQuatInit(F32 x, F32 y, F32 z, F32 w);	// deprecated
-	const LLQuaternion&	setQuat(const LLQuaternion &quat);			// deprecated
-	const LLQuaternion&	setQuat(const F32 *q);						// deprecated
-	const LLQuaternion&	setQuat(const LLMatrix3 &mat);				// deprecated
-	const LLQuaternion&	setQuat(const LLMatrix4 &mat);				// deprecated
-	const LLQuaternion&	setQuat(F32 angle, F32 x, F32 y, F32 z);	// deprecated
-	const LLQuaternion&	setQuat(F32 angle, const LLVector3 &vec);	// deprecated
-	const LLQuaternion&	setQuat(F32 angle, const LLVector4 &vec);	// deprecated
-	const LLQuaternion&	setQuat(F32 roll, F32 pitch, F32 yaw);		// deprecated
-
-	LLMatrix4	getMatrix4(void) const;							// Returns the Matrix4 equivalent of Quaternion
-	LLMatrix3	getMatrix3(void) const;							// Returns the Matrix3 equivalent of Quaternion
-	void		getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const;	// returns rotation in radians about axis x,y,z
-	void		getAngleAxis(F32* angle, LLVector3 &vec) const;
-	void		getEulerAngles(F32 *roll, F32* pitch, F32 *yaw) const;
-
-	F32	normalize();	// Normalizes Quaternion and returns magnitude
-	F32	normQuat();		// deprecated
-
-	const LLQuaternion&	conjugate(void);	// Conjugates Quaternion and returns result
-	const LLQuaternion&	conjQuat(void);		// deprecated
-
-	// Other useful methods
-	const LLQuaternion&	transpose();		// transpose (same as conjugate)
-	const LLQuaternion&	transQuat();		// deprecated
-
-	void			shortestArc(const LLVector3 &a, const LLVector3 &b);	// shortest rotation from a to b
-	const LLQuaternion& constrain(F32 radians);						// constrains rotation to a cone angle specified in radians
-
-	// Standard operators
-	friend std::ostream& operator<<(std::ostream &s, const LLQuaternion &a);					// Prints a
-	friend LLQuaternion operator+(const LLQuaternion &a, const LLQuaternion &b);	// Addition
-	friend LLQuaternion operator-(const LLQuaternion &a, const LLQuaternion &b);	// Subtraction
-	friend LLQuaternion operator-(const LLQuaternion &a);							// Negation
-	friend LLQuaternion operator*(F32 a, const LLQuaternion &q);					// Scale
-	friend LLQuaternion operator*(const LLQuaternion &q, F32 b);					// Scale
-	friend LLQuaternion operator*(const LLQuaternion &a, const LLQuaternion &b);	// Returns a * b
-	friend LLQuaternion operator~(const LLQuaternion &a);							// Returns a* (Conjugate of a)
-	bool operator==(const LLQuaternion &b) const;			// Returns a == b
-	bool operator!=(const LLQuaternion &b) const;			// Returns a != b
-
-	friend const LLQuaternion& operator*=(LLQuaternion &a, const LLQuaternion &b);	// Returns a * b
-
-	friend LLVector4 operator*(const LLVector4 &a, const LLQuaternion &rot);		// Rotates a by rot
-	friend LLVector3 operator*(const LLVector3 &a, const LLQuaternion &rot);		// Rotates a by rot
-	friend LLVector3d operator*(const LLVector3d &a, const LLQuaternion &rot);		// Rotates a by rot
-
-	// Non-standard operators
-	friend F32 dot(const LLQuaternion &a, const LLQuaternion &b);
-	friend LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q);		// linear interpolation (t = 0 to 1) from p to q
-	friend LLQuaternion lerp(F32 t, const LLQuaternion &q);								// linear interpolation (t = 0 to 1) from identity to q
-	friend LLQuaternion slerp(F32 t, const LLQuaternion &p, const LLQuaternion &q); 	// spherical linear interpolation from p to q
-	friend LLQuaternion slerp(F32 t, const LLQuaternion &q);							// spherical linear interpolation from identity to q
-	friend LLQuaternion nlerp(F32 t, const LLQuaternion &p, const LLQuaternion &q); 	// normalized linear interpolation from p to q
-	friend LLQuaternion nlerp(F32 t, const LLQuaternion &q); 							// normalized linear interpolation from p to q
-
-	LLVector3	packToVector3() const;						// Saves space by using the fact that our quaternions are normalized
-	void		unpackFromVector3(const LLVector3& vec);	// Saves space by using the fact that our quaternions are normalized
-
-	enum Order {
-		XYZ = 0,
-		YZX = 1,
-		ZXY = 2,
-		XZY = 3,
-		YXZ = 4,
-		ZYX = 5
-	};
-	// Creates a quaternions from maya's rotation representation,
-	// which is 3 rotations (in DEGREES) in the specified order
-	friend LLQuaternion mayaQ(F32 x, F32 y, F32 z, Order order);
-
-	// Conversions between Order and strings like "xyz" or "ZYX"
-	friend const char *OrderToString( const Order order );
-	friend Order StringToOrder( const char *str );
-
-	static BOOL parseQuat(const std::string& buf, LLQuaternion* value);
-
-	// For debugging, only
-	//static U32 mMultCount;
-};
-
-// checker
-inline BOOL	LLQuaternion::isFinite() const
-{
-	return (llfinite(mQ[VX]) && llfinite(mQ[VY]) && llfinite(mQ[VZ]) && llfinite(mQ[VS]));
-}
-
-inline BOOL LLQuaternion::isIdentity() const
-{
-	return 
-		( mQ[VX] == 0.f ) &&
-		( mQ[VY] == 0.f ) &&
-		( mQ[VZ] == 0.f ) &&
-		( mQ[VS] == 1.f );
-}
-
-inline BOOL LLQuaternion::isNotIdentity() const
-{
-	return 
-		( mQ[VX] != 0.f ) ||
-		( mQ[VY] != 0.f ) ||
-		( mQ[VZ] != 0.f ) ||
-		( mQ[VS] != 1.f );
-}
-
-
-
-inline LLQuaternion::LLQuaternion(void)
-{
-	mQ[VX] = 0.f;
-	mQ[VY] = 0.f;
-	mQ[VZ] = 0.f;
-	mQ[VS] = 1.f;
-}
-
-inline LLQuaternion::LLQuaternion(F32 x, F32 y, F32 z, F32 w)
-{
-	mQ[VX] = x;
-	mQ[VY] = y;
-	mQ[VZ] = z;
-	mQ[VS] = w;
-
-	//RN: don't normalize this case as its used mainly for temporaries during calculations
-	//normalize();
-	/*
-	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
-	mag -= 1.f;
-	mag = fabs(mag);
-	llassert(mag < 10.f*FP_MAG_THRESHOLD);
-	*/
-}
-
-inline LLQuaternion::LLQuaternion(const F32 *q)
-{
-	mQ[VX] = q[VX];
-	mQ[VY] = q[VY];
-	mQ[VZ] = q[VZ];
-	mQ[VS] = q[VW];
-
-	normalize();
-	/*
-	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
-	mag -= 1.f;
-	mag = fabs(mag);
-	llassert(mag < FP_MAG_THRESHOLD);
-	*/
-}
-
-
-inline void LLQuaternion::loadIdentity()
-{
-	mQ[VX] = 0.0f;
-	mQ[VY] = 0.0f;
-	mQ[VZ] = 0.0f;
-	mQ[VW] = 1.0f;
-}
-
-
-inline const LLQuaternion&	LLQuaternion::set(F32 x, F32 y, F32 z, F32 w)
-{
-	mQ[VX] = x;
-	mQ[VY] = y;
-	mQ[VZ] = z;
-	mQ[VS] = w;
-	normalize();
-	return (*this);
-}
-
-inline const LLQuaternion&	LLQuaternion::set(const LLQuaternion &quat)
-{
-	mQ[VX] = quat.mQ[VX];
-	mQ[VY] = quat.mQ[VY];
-	mQ[VZ] = quat.mQ[VZ];
-	mQ[VW] = quat.mQ[VW];
-	normalize();
-	return (*this);
-}
-
-inline const LLQuaternion&	LLQuaternion::set(const F32 *q)
-{
-	mQ[VX] = q[VX];
-	mQ[VY] = q[VY];
-	mQ[VZ] = q[VZ];
-	mQ[VS] = q[VW];
-	normalize();
-	return (*this);
-}
-
-
-// deprecated
-inline const LLQuaternion&	LLQuaternion::setQuatInit(F32 x, F32 y, F32 z, F32 w)
-{
-	mQ[VX] = x;
-	mQ[VY] = y;
-	mQ[VZ] = z;
-	mQ[VS] = w;
-	normalize();
-	return (*this);
-}
-
-// deprecated
-inline const LLQuaternion&	LLQuaternion::setQuat(const LLQuaternion &quat)
-{
-	mQ[VX] = quat.mQ[VX];
-	mQ[VY] = quat.mQ[VY];
-	mQ[VZ] = quat.mQ[VZ];
-	mQ[VW] = quat.mQ[VW];
-	normalize();
-	return (*this);
-}
-
-// deprecated
-inline const LLQuaternion&	LLQuaternion::setQuat(const F32 *q)
-{
-	mQ[VX] = q[VX];
-	mQ[VY] = q[VY];
-	mQ[VZ] = q[VZ];
-	mQ[VS] = q[VW];
-	normalize();
-	return (*this);
-}
-
-// There may be a cheaper way that avoids the sqrt.
-// Does sin_a = VX*VX + VY*VY + VZ*VZ?
-// Copied from Matrix and Quaternion FAQ 1.12
-inline void LLQuaternion::getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const
-{
-	F32 cos_a = mQ[VW];
-	if (cos_a > 1.0f) cos_a = 1.0f;
-	if (cos_a < -1.0f) cos_a = -1.0f;
-
-    F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
-
-    if ( fabs( sin_a ) < 0.0005f )
-		sin_a = 1.0f;
-	else
-		sin_a = 1.f/sin_a;
-
-    F32 temp_angle = 2.0f * (F32) acos( cos_a );
-	if (temp_angle > F_PI)
-	{
-		// The (angle,axis) pair should never have angles outside [PI, -PI]
-		// since we want the _shortest_ (angle,axis) solution.
-		// Since acos is defined for [0, PI], and we multiply by 2.0, we
-		// can push the angle outside the acceptible range.
-		// When this happens we set the angle to the other portion of a 
-		// full 2PI rotation, and negate the axis, which reverses the 
-		// direction of the rotation (by the right-hand rule).
-		*angle = 2.f * F_PI - temp_angle;
-    	*x = - mQ[VX] * sin_a;
-    	*y = - mQ[VY] * sin_a;
-    	*z = - mQ[VZ] * sin_a;
-	}
-	else
-	{
-		*angle = temp_angle;
-    	*x = mQ[VX] * sin_a;
-    	*y = mQ[VY] * sin_a;
-    	*z = mQ[VZ] * sin_a;
-	}
-}
-
-inline const LLQuaternion& LLQuaternion::conjugate()
-{
-	mQ[VX] *= -1.f;
-	mQ[VY] *= -1.f;
-	mQ[VZ] *= -1.f;
-	return (*this);
-}
-
-inline const LLQuaternion& LLQuaternion::conjQuat()
-{
-	mQ[VX] *= -1.f;
-	mQ[VY] *= -1.f;
-	mQ[VZ] *= -1.f;
-	return (*this);
-}
-
-// Transpose
-inline const LLQuaternion& LLQuaternion::transpose()
-{
-	mQ[VX] *= -1.f;
-	mQ[VY] *= -1.f;
-	mQ[VZ] *= -1.f;
-	return (*this);
-}
-
-// deprecated
-inline const LLQuaternion& LLQuaternion::transQuat()
-{
-	mQ[VX] *= -1.f;
-	mQ[VY] *= -1.f;
-	mQ[VZ] *= -1.f;
-	return (*this);
-}
-
-
-inline LLQuaternion 	operator+(const LLQuaternion &a, const LLQuaternion &b)
-{
-	return LLQuaternion( 
-		a.mQ[VX] + b.mQ[VX],
-		a.mQ[VY] + b.mQ[VY],
-		a.mQ[VZ] + b.mQ[VZ],
-		a.mQ[VW] + b.mQ[VW] );
-}
-
-
-inline LLQuaternion 	operator-(const LLQuaternion &a, const LLQuaternion &b)
-{
-	return LLQuaternion( 
-		a.mQ[VX] - b.mQ[VX],
-		a.mQ[VY] - b.mQ[VY],
-		a.mQ[VZ] - b.mQ[VZ],
-		a.mQ[VW] - b.mQ[VW] );
-}
-
-
-inline LLQuaternion 	operator-(const LLQuaternion &a)
-{
-	return LLQuaternion(
-		-a.mQ[VX],
-		-a.mQ[VY],
-		-a.mQ[VZ],
-		-a.mQ[VW] );
-}
-
-
-inline LLQuaternion 	operator*(F32 a, const LLQuaternion &q)
-{
-	return LLQuaternion(
-		a * q.mQ[VX],
-		a * q.mQ[VY],
-		a * q.mQ[VZ],
-		a * q.mQ[VW] );
-}
-
-
-inline LLQuaternion 	operator*(const LLQuaternion &q, F32 a)
-{
-	return LLQuaternion(
-		a * q.mQ[VX],
-		a * q.mQ[VY],
-		a * q.mQ[VZ],
-		a * q.mQ[VW] );
-}
-
-inline LLQuaternion	operator~(const LLQuaternion &a)
-{
-	LLQuaternion q(a);
-	q.conjQuat();
-	return q;
-}
-
-inline bool	LLQuaternion::operator==(const LLQuaternion &b) const
-{
-	return (  (mQ[VX] == b.mQ[VX])
-			&&(mQ[VY] == b.mQ[VY])
-			&&(mQ[VZ] == b.mQ[VZ])
-			&&(mQ[VS] == b.mQ[VS]));
-}
-
-inline bool	LLQuaternion::operator!=(const LLQuaternion &b) const
-{
-	return (  (mQ[VX] != b.mQ[VX])
-			||(mQ[VY] != b.mQ[VY])
-			||(mQ[VZ] != b.mQ[VZ])
-			||(mQ[VS] != b.mQ[VS]));
-}
-
-inline const LLQuaternion&	operator*=(LLQuaternion &a, const LLQuaternion &b)
-{
-#if 1
-	LLQuaternion q(
-		b.mQ[3] * a.mQ[0] + b.mQ[0] * a.mQ[3] + b.mQ[1] * a.mQ[2] - b.mQ[2] * a.mQ[1],
-		b.mQ[3] * a.mQ[1] + b.mQ[1] * a.mQ[3] + b.mQ[2] * a.mQ[0] - b.mQ[0] * a.mQ[2],
-		b.mQ[3] * a.mQ[2] + b.mQ[2] * a.mQ[3] + b.mQ[0] * a.mQ[1] - b.mQ[1] * a.mQ[0],
-		b.mQ[3] * a.mQ[3] - b.mQ[0] * a.mQ[0] - b.mQ[1] * a.mQ[1] - b.mQ[2] * a.mQ[2]
-	);
-	a = q;
-#else
-	a = a * b;
-#endif
-	return a;
-}
-
-const F32 ONE_PART_IN_A_MILLION = 0.000001f;
-
-inline F32	LLQuaternion::normalize()
-{
-	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
-
-	if (mag > FP_MAG_THRESHOLD)
-	{
-		// Floating point error can prevent some quaternions from achieving
-		// exact unity length.  When trying to renormalize such quaternions we
-		// can oscillate between multiple quantized states.  To prevent such
-		// drifts we only renomalize if the length is far enough from unity.
-		if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
-		{
-			F32 oomag = 1.f/mag;
-			mQ[VX] *= oomag;
-			mQ[VY] *= oomag;
-			mQ[VZ] *= oomag;
-			mQ[VS] *= oomag;
-		}
-	}
-	else
-	{
-		// we were given a very bad quaternion so we set it to identity
-		mQ[VX] = 0.f;
-		mQ[VY] = 0.f;
-		mQ[VZ] = 0.f;
-		mQ[VS] = 1.f;
-	}
-
-	return mag;
-}
-
-// deprecated
-inline F32	LLQuaternion::normQuat()
-{
-	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
-
-	if (mag > FP_MAG_THRESHOLD)
-	{
-		if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
-		{
-			// only renormalize if length not close enough to 1.0 already
-			F32 oomag = 1.f/mag;
-			mQ[VX] *= oomag;
-			mQ[VY] *= oomag;
-			mQ[VZ] *= oomag;
-			mQ[VS] *= oomag;
-		}
-	}
-	else
-	{
-		mQ[VX] = 0.f;
-		mQ[VY] = 0.f;
-		mQ[VZ] = 0.f;
-		mQ[VS] = 1.f;
-	}
-
-	return mag;
-}
-
-LLQuaternion::Order StringToOrder( const char *str );
-
-// Some notes about Quaternions
-
-// What is a Quaternion?
-// ---------------------
-// A quaternion is a point in 4-dimensional complex space.
-// Q = { Qx, Qy, Qz, Qw }
-// 
-//
-// Why Quaternions?
-// ----------------
-// The set of quaternions that make up the the 4-D unit sphere 
-// can be mapped to the set of all rotations in 3-D space.  Sometimes
-// it is easier to describe/manipulate rotations in quaternion space
-// than rotation-matrix space.
-//
-//
-// How Quaternions?
-// ----------------
-// In order to take advantage of quaternions we need to know how to
-// go from rotation-matricies to quaternions and back.  We also have
-// to agree what variety of rotations we're generating.
-// 
-// Consider the equation...   v' = v * R 
-//
-// There are two ways to think about rotations of vectors.
-// 1) v' is the same vector in a different reference frame
-// 2) v' is a new vector in the same reference frame
-//
-// bookmark -- which way are we using?
-// 
-// 
-// Quaternion from Angle-Axis:
-// ---------------------------
-// Suppose we wanted to represent a rotation of some angle (theta) 
-// about some axis ({Ax, Ay, Az})...
-//
-// axis of rotation = {Ax, Ay, Az} 
-// angle_of_rotation = theta
-//
-// s = sin(0.5 * theta)
-// c = cos(0.5 * theta)
-// Q = { s * Ax, s * Ay, s * Az, c }
-//
-//
-// 3x3 Matrix from Quaternion
-// --------------------------
-//
-//     |                                                                    |
-//     | 1 - 2 * (y^2 + z^2)   2 * (x * y + z * w)     2 * (y * w - x * z)  |
-//     |                                                                    |
-// M = | 2 * (x * y - z * w)   1 - 2 * (x^2 + z^2)     2 * (y * z + x * w)  |
-//     |                                                                    |
-//     | 2 * (x * z + y * w)   2 * (y * z - x * w)     1 - 2 * (x^2 + y^2)  |
-//     |                                                                    |
-
-#endif
+/** 
+ * @file llquaternion.h
+ * @brief LLQuaternion class header file.
+ *
+ * $LicenseInfo:firstyear=2000&license=viewergpl$
+ * 
+ * Copyright (c) 2000-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LLQUATERNION_H
+#define LLQUATERNION_H
+
+#include <iostream>
+
+#ifndef LLMATH_H //enforce specific include order to avoid tangling inline dependencies
+#error "Please include llmath.h first."
+#endif
+
+class LLVector4;
+class LLVector3;
+class LLVector3d;
+class LLMatrix4;
+class LLMatrix3;
+
+//	NOTA BENE: Quaternion code is written assuming Unit Quaternions!!!!
+//			   Moreover, it is written assuming that all vectors and matricies
+//			   passed as arguments are normalized and unitary respectively.
+//			   VERY VERY VERY VERY BAD THINGS will happen if these assumptions fail.
+
+static const U32 LENGTHOFQUAT = 4;
+
+class LLQuaternion
+{
+public:
+	F32 mQ[LENGTHOFQUAT];
+
+	static const LLQuaternion DEFAULT;
+
+	LLQuaternion();									// Initializes Quaternion to (0,0,0,1)
+	explicit LLQuaternion(const LLMatrix4 &mat);				// Initializes Quaternion from Matrix4
+	explicit LLQuaternion(const LLMatrix3 &mat);				// Initializes Quaternion from Matrix3
+	LLQuaternion(F32 x, F32 y, F32 z, F32 w);		// Initializes Quaternion to normalize(x, y, z, w)
+	LLQuaternion(F32 angle, const LLVector4 &vec);	// Initializes Quaternion to axis_angle2quat(angle, vec)
+	LLQuaternion(F32 angle, const LLVector3 &vec);	// Initializes Quaternion to axis_angle2quat(angle, vec)
+	LLQuaternion(const F32 *q);						// Initializes Quaternion to normalize(x, y, z, w)
+	LLQuaternion(const LLVector3 &x_axis,
+				 const LLVector3 &y_axis,
+				 const LLVector3 &z_axis);			// Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis]
+
+	BOOL isIdentity() const;
+	BOOL isNotIdentity() const;
+	BOOL isFinite() const;									// checks to see if all values of LLQuaternion are finite
+	void quantize16(F32 lower, F32 upper);					// changes the vector to reflect quatization
+	void quantize8(F32 lower, F32 upper);							// changes the vector to reflect quatization
+	void loadIdentity();											// Loads the quaternion that represents the identity rotation
+
+	const LLQuaternion&	set(F32 x, F32 y, F32 z, F32 w);		// Sets Quaternion to normalize(x, y, z, w)
+	const LLQuaternion&	set(const LLQuaternion &quat);			// Copies Quaternion
+	const LLQuaternion&	set(const F32 *q);						// Sets Quaternion to normalize(quat[VX], quat[VY], quat[VZ], quat[VW])
+	const LLQuaternion&	set(const LLMatrix3 &mat);				// Sets Quaternion to mat2quat(mat)
+	const LLQuaternion&	set(const LLMatrix4 &mat);				// Sets Quaternion to mat2quat(mat)
+
+	const LLQuaternion&	setAngleAxis(F32 angle, F32 x, F32 y, F32 z);	// Sets Quaternion to axis_angle2quat(angle, x, y, z)
+	const LLQuaternion&	setAngleAxis(F32 angle, const LLVector3 &vec);	// Sets Quaternion to axis_angle2quat(angle, vec)
+	const LLQuaternion&	setAngleAxis(F32 angle, const LLVector4 &vec);	// Sets Quaternion to axis_angle2quat(angle, vec)
+	const LLQuaternion&	setEulerAngles(F32 roll, F32 pitch, F32 yaw);	// Sets Quaternion to euler2quat(pitch, yaw, roll)
+
+	const LLQuaternion&	setQuatInit(F32 x, F32 y, F32 z, F32 w);	// deprecated
+	const LLQuaternion&	setQuat(const LLQuaternion &quat);			// deprecated
+	const LLQuaternion&	setQuat(const F32 *q);						// deprecated
+	const LLQuaternion&	setQuat(const LLMatrix3 &mat);				// deprecated
+	const LLQuaternion&	setQuat(const LLMatrix4 &mat);				// deprecated
+	const LLQuaternion&	setQuat(F32 angle, F32 x, F32 y, F32 z);	// deprecated
+	const LLQuaternion&	setQuat(F32 angle, const LLVector3 &vec);	// deprecated
+	const LLQuaternion&	setQuat(F32 angle, const LLVector4 &vec);	// deprecated
+	const LLQuaternion&	setQuat(F32 roll, F32 pitch, F32 yaw);		// deprecated
+
+	LLMatrix4	getMatrix4(void) const;							// Returns the Matrix4 equivalent of Quaternion
+	LLMatrix3	getMatrix3(void) const;							// Returns the Matrix3 equivalent of Quaternion
+	void		getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const;	// returns rotation in radians about axis x,y,z
+	void		getAngleAxis(F32* angle, LLVector3 &vec) const;
+	void		getEulerAngles(F32 *roll, F32* pitch, F32 *yaw) const;
+
+	F32	normalize();	// Normalizes Quaternion and returns magnitude
+	F32	normQuat();		// deprecated
+
+	const LLQuaternion&	conjugate(void);	// Conjugates Quaternion and returns result
+	const LLQuaternion&	conjQuat(void);		// deprecated
+
+	// Other useful methods
+	const LLQuaternion&	transpose();		// transpose (same as conjugate)
+	const LLQuaternion&	transQuat();		// deprecated
+
+	void			shortestArc(const LLVector3 &a, const LLVector3 &b);	// shortest rotation from a to b
+	const LLQuaternion& constrain(F32 radians);						// constrains rotation to a cone angle specified in radians
+
+	// Standard operators
+	friend std::ostream& operator<<(std::ostream &s, const LLQuaternion &a);					// Prints a
+	friend LLQuaternion operator+(const LLQuaternion &a, const LLQuaternion &b);	// Addition
+	friend LLQuaternion operator-(const LLQuaternion &a, const LLQuaternion &b);	// Subtraction
+	friend LLQuaternion operator-(const LLQuaternion &a);							// Negation
+	friend LLQuaternion operator*(F32 a, const LLQuaternion &q);					// Scale
+	friend LLQuaternion operator*(const LLQuaternion &q, F32 b);					// Scale
+	friend LLQuaternion operator*(const LLQuaternion &a, const LLQuaternion &b);	// Returns a * b
+	friend LLQuaternion operator~(const LLQuaternion &a);							// Returns a* (Conjugate of a)
+	bool operator==(const LLQuaternion &b) const;			// Returns a == b
+	bool operator!=(const LLQuaternion &b) const;			// Returns a != b
+
+	friend const LLQuaternion& operator*=(LLQuaternion &a, const LLQuaternion &b);	// Returns a * b
+
+	friend LLVector4 operator*(const LLVector4 &a, const LLQuaternion &rot);		// Rotates a by rot
+	friend LLVector3 operator*(const LLVector3 &a, const LLQuaternion &rot);		// Rotates a by rot
+	friend LLVector3d operator*(const LLVector3d &a, const LLQuaternion &rot);		// Rotates a by rot
+
+	// Non-standard operators
+	friend F32 dot(const LLQuaternion &a, const LLQuaternion &b);
+	friend LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q);		// linear interpolation (t = 0 to 1) from p to q
+	friend LLQuaternion lerp(F32 t, const LLQuaternion &q);								// linear interpolation (t = 0 to 1) from identity to q
+	friend LLQuaternion slerp(F32 t, const LLQuaternion &p, const LLQuaternion &q); 	// spherical linear interpolation from p to q
+	friend LLQuaternion slerp(F32 t, const LLQuaternion &q);							// spherical linear interpolation from identity to q
+	friend LLQuaternion nlerp(F32 t, const LLQuaternion &p, const LLQuaternion &q); 	// normalized linear interpolation from p to q
+	friend LLQuaternion nlerp(F32 t, const LLQuaternion &q); 							// normalized linear interpolation from p to q
+
+	LLVector3	packToVector3() const;						// Saves space by using the fact that our quaternions are normalized
+	void		unpackFromVector3(const LLVector3& vec);	// Saves space by using the fact that our quaternions are normalized
+
+	enum Order {
+		XYZ = 0,
+		YZX = 1,
+		ZXY = 2,
+		XZY = 3,
+		YXZ = 4,
+		ZYX = 5
+	};
+	// Creates a quaternions from maya's rotation representation,
+	// which is 3 rotations (in DEGREES) in the specified order
+	friend LLQuaternion mayaQ(F32 x, F32 y, F32 z, Order order);
+
+	// Conversions between Order and strings like "xyz" or "ZYX"
+	friend const char *OrderToString( const Order order );
+	friend Order StringToOrder( const char *str );
+
+	static BOOL parseQuat(const std::string& buf, LLQuaternion* value);
+
+	// For debugging, only
+	//static U32 mMultCount;
+};
+
+// checker
+inline BOOL	LLQuaternion::isFinite() const
+{
+	return (llfinite(mQ[VX]) && llfinite(mQ[VY]) && llfinite(mQ[VZ]) && llfinite(mQ[VS]));
+}
+
+inline BOOL LLQuaternion::isIdentity() const
+{
+	return 
+		( mQ[VX] == 0.f ) &&
+		( mQ[VY] == 0.f ) &&
+		( mQ[VZ] == 0.f ) &&
+		( mQ[VS] == 1.f );
+}
+
+inline BOOL LLQuaternion::isNotIdentity() const
+{
+	return 
+		( mQ[VX] != 0.f ) ||
+		( mQ[VY] != 0.f ) ||
+		( mQ[VZ] != 0.f ) ||
+		( mQ[VS] != 1.f );
+}
+
+
+
+inline LLQuaternion::LLQuaternion(void)
+{
+	mQ[VX] = 0.f;
+	mQ[VY] = 0.f;
+	mQ[VZ] = 0.f;
+	mQ[VS] = 1.f;
+}
+
+inline LLQuaternion::LLQuaternion(F32 x, F32 y, F32 z, F32 w)
+{
+	mQ[VX] = x;
+	mQ[VY] = y;
+	mQ[VZ] = z;
+	mQ[VS] = w;
+
+	//RN: don't normalize this case as its used mainly for temporaries during calculations
+	//normalize();
+	/*
+	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
+	mag -= 1.f;
+	mag = fabs(mag);
+	llassert(mag < 10.f*FP_MAG_THRESHOLD);
+	*/
+}
+
+inline LLQuaternion::LLQuaternion(const F32 *q)
+{
+	mQ[VX] = q[VX];
+	mQ[VY] = q[VY];
+	mQ[VZ] = q[VZ];
+	mQ[VS] = q[VW];
+
+	normalize();
+	/*
+	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
+	mag -= 1.f;
+	mag = fabs(mag);
+	llassert(mag < FP_MAG_THRESHOLD);
+	*/
+}
+
+
+inline void LLQuaternion::loadIdentity()
+{
+	mQ[VX] = 0.0f;
+	mQ[VY] = 0.0f;
+	mQ[VZ] = 0.0f;
+	mQ[VW] = 1.0f;
+}
+
+
+inline const LLQuaternion&	LLQuaternion::set(F32 x, F32 y, F32 z, F32 w)
+{
+	mQ[VX] = x;
+	mQ[VY] = y;
+	mQ[VZ] = z;
+	mQ[VS] = w;
+	normalize();
+	return (*this);
+}
+
+inline const LLQuaternion&	LLQuaternion::set(const LLQuaternion &quat)
+{
+	mQ[VX] = quat.mQ[VX];
+	mQ[VY] = quat.mQ[VY];
+	mQ[VZ] = quat.mQ[VZ];
+	mQ[VW] = quat.mQ[VW];
+	normalize();
+	return (*this);
+}
+
+inline const LLQuaternion&	LLQuaternion::set(const F32 *q)
+{
+	mQ[VX] = q[VX];
+	mQ[VY] = q[VY];
+	mQ[VZ] = q[VZ];
+	mQ[VS] = q[VW];
+	normalize();
+	return (*this);
+}
+
+
+// deprecated
+inline const LLQuaternion&	LLQuaternion::setQuatInit(F32 x, F32 y, F32 z, F32 w)
+{
+	mQ[VX] = x;
+	mQ[VY] = y;
+	mQ[VZ] = z;
+	mQ[VS] = w;
+	normalize();
+	return (*this);
+}
+
+// deprecated
+inline const LLQuaternion&	LLQuaternion::setQuat(const LLQuaternion &quat)
+{
+	mQ[VX] = quat.mQ[VX];
+	mQ[VY] = quat.mQ[VY];
+	mQ[VZ] = quat.mQ[VZ];
+	mQ[VW] = quat.mQ[VW];
+	normalize();
+	return (*this);
+}
+
+// deprecated
+inline const LLQuaternion&	LLQuaternion::setQuat(const F32 *q)
+{
+	mQ[VX] = q[VX];
+	mQ[VY] = q[VY];
+	mQ[VZ] = q[VZ];
+	mQ[VS] = q[VW];
+	normalize();
+	return (*this);
+}
+
+// There may be a cheaper way that avoids the sqrt.
+// Does sin_a = VX*VX + VY*VY + VZ*VZ?
+// Copied from Matrix and Quaternion FAQ 1.12
+inline void LLQuaternion::getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const
+{
+	F32 cos_a = mQ[VW];
+	if (cos_a > 1.0f) cos_a = 1.0f;
+	if (cos_a < -1.0f) cos_a = -1.0f;
+
+    F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
+
+    if ( fabs( sin_a ) < 0.0005f )
+		sin_a = 1.0f;
+	else
+		sin_a = 1.f/sin_a;
+
+    F32 temp_angle = 2.0f * (F32) acos( cos_a );
+	if (temp_angle > F_PI)
+	{
+		// The (angle,axis) pair should never have angles outside [PI, -PI]
+		// since we want the _shortest_ (angle,axis) solution.
+		// Since acos is defined for [0, PI], and we multiply by 2.0, we
+		// can push the angle outside the acceptible range.
+		// When this happens we set the angle to the other portion of a 
+		// full 2PI rotation, and negate the axis, which reverses the 
+		// direction of the rotation (by the right-hand rule).
+		*angle = 2.f * F_PI - temp_angle;
+    	*x = - mQ[VX] * sin_a;
+    	*y = - mQ[VY] * sin_a;
+    	*z = - mQ[VZ] * sin_a;
+	}
+	else
+	{
+		*angle = temp_angle;
+    	*x = mQ[VX] * sin_a;
+    	*y = mQ[VY] * sin_a;
+    	*z = mQ[VZ] * sin_a;
+	}
+}
+
+inline const LLQuaternion& LLQuaternion::conjugate()
+{
+	mQ[VX] *= -1.f;
+	mQ[VY] *= -1.f;
+	mQ[VZ] *= -1.f;
+	return (*this);
+}
+
+inline const LLQuaternion& LLQuaternion::conjQuat()
+{
+	mQ[VX] *= -1.f;
+	mQ[VY] *= -1.f;
+	mQ[VZ] *= -1.f;
+	return (*this);
+}
+
+// Transpose
+inline const LLQuaternion& LLQuaternion::transpose()
+{
+	mQ[VX] *= -1.f;
+	mQ[VY] *= -1.f;
+	mQ[VZ] *= -1.f;
+	return (*this);
+}
+
+// deprecated
+inline const LLQuaternion& LLQuaternion::transQuat()
+{
+	mQ[VX] *= -1.f;
+	mQ[VY] *= -1.f;
+	mQ[VZ] *= -1.f;
+	return (*this);
+}
+
+
+inline LLQuaternion 	operator+(const LLQuaternion &a, const LLQuaternion &b)
+{
+	return LLQuaternion( 
+		a.mQ[VX] + b.mQ[VX],
+		a.mQ[VY] + b.mQ[VY],
+		a.mQ[VZ] + b.mQ[VZ],
+		a.mQ[VW] + b.mQ[VW] );
+}
+
+
+inline LLQuaternion 	operator-(const LLQuaternion &a, const LLQuaternion &b)
+{
+	return LLQuaternion( 
+		a.mQ[VX] - b.mQ[VX],
+		a.mQ[VY] - b.mQ[VY],
+		a.mQ[VZ] - b.mQ[VZ],
+		a.mQ[VW] - b.mQ[VW] );
+}
+
+
+inline LLQuaternion 	operator-(const LLQuaternion &a)
+{
+	return LLQuaternion(
+		-a.mQ[VX],
+		-a.mQ[VY],
+		-a.mQ[VZ],
+		-a.mQ[VW] );
+}
+
+
+inline LLQuaternion 	operator*(F32 a, const LLQuaternion &q)
+{
+	return LLQuaternion(
+		a * q.mQ[VX],
+		a * q.mQ[VY],
+		a * q.mQ[VZ],
+		a * q.mQ[VW] );
+}
+
+
+inline LLQuaternion 	operator*(const LLQuaternion &q, F32 a)
+{
+	return LLQuaternion(
+		a * q.mQ[VX],
+		a * q.mQ[VY],
+		a * q.mQ[VZ],
+		a * q.mQ[VW] );
+}
+
+inline LLQuaternion	operator~(const LLQuaternion &a)
+{
+	LLQuaternion q(a);
+	q.conjQuat();
+	return q;
+}
+
+inline bool	LLQuaternion::operator==(const LLQuaternion &b) const
+{
+	return (  (mQ[VX] == b.mQ[VX])
+			&&(mQ[VY] == b.mQ[VY])
+			&&(mQ[VZ] == b.mQ[VZ])
+			&&(mQ[VS] == b.mQ[VS]));
+}
+
+inline bool	LLQuaternion::operator!=(const LLQuaternion &b) const
+{
+	return (  (mQ[VX] != b.mQ[VX])
+			||(mQ[VY] != b.mQ[VY])
+			||(mQ[VZ] != b.mQ[VZ])
+			||(mQ[VS] != b.mQ[VS]));
+}
+
+inline const LLQuaternion&	operator*=(LLQuaternion &a, const LLQuaternion &b)
+{
+#if 1
+	LLQuaternion q(
+		b.mQ[3] * a.mQ[0] + b.mQ[0] * a.mQ[3] + b.mQ[1] * a.mQ[2] - b.mQ[2] * a.mQ[1],
+		b.mQ[3] * a.mQ[1] + b.mQ[1] * a.mQ[3] + b.mQ[2] * a.mQ[0] - b.mQ[0] * a.mQ[2],
+		b.mQ[3] * a.mQ[2] + b.mQ[2] * a.mQ[3] + b.mQ[0] * a.mQ[1] - b.mQ[1] * a.mQ[0],
+		b.mQ[3] * a.mQ[3] - b.mQ[0] * a.mQ[0] - b.mQ[1] * a.mQ[1] - b.mQ[2] * a.mQ[2]
+	);
+	a = q;
+#else
+	a = a * b;
+#endif
+	return a;
+}
+
+const F32 ONE_PART_IN_A_MILLION = 0.000001f;
+
+inline F32	LLQuaternion::normalize()
+{
+	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
+
+	if (mag > FP_MAG_THRESHOLD)
+	{
+		// Floating point error can prevent some quaternions from achieving
+		// exact unity length.  When trying to renormalize such quaternions we
+		// can oscillate between multiple quantized states.  To prevent such
+		// drifts we only renomalize if the length is far enough from unity.
+		if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
+		{
+			F32 oomag = 1.f/mag;
+			mQ[VX] *= oomag;
+			mQ[VY] *= oomag;
+			mQ[VZ] *= oomag;
+			mQ[VS] *= oomag;
+		}
+	}
+	else
+	{
+		// we were given a very bad quaternion so we set it to identity
+		mQ[VX] = 0.f;
+		mQ[VY] = 0.f;
+		mQ[VZ] = 0.f;
+		mQ[VS] = 1.f;
+	}
+
+	return mag;
+}
+
+// deprecated
+inline F32	LLQuaternion::normQuat()
+{
+	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
+
+	if (mag > FP_MAG_THRESHOLD)
+	{
+		if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
+		{
+			// only renormalize if length not close enough to 1.0 already
+			F32 oomag = 1.f/mag;
+			mQ[VX] *= oomag;
+			mQ[VY] *= oomag;
+			mQ[VZ] *= oomag;
+			mQ[VS] *= oomag;
+		}
+	}
+	else
+	{
+		mQ[VX] = 0.f;
+		mQ[VY] = 0.f;
+		mQ[VZ] = 0.f;
+		mQ[VS] = 1.f;
+	}
+
+	return mag;
+}
+
+LLQuaternion::Order StringToOrder( const char *str );
+
+// Some notes about Quaternions
+
+// What is a Quaternion?
+// ---------------------
+// A quaternion is a point in 4-dimensional complex space.
+// Q = { Qx, Qy, Qz, Qw }
+// 
+//
+// Why Quaternions?
+// ----------------
+// The set of quaternions that make up the the 4-D unit sphere 
+// can be mapped to the set of all rotations in 3-D space.  Sometimes
+// it is easier to describe/manipulate rotations in quaternion space
+// than rotation-matrix space.
+//
+//
+// How Quaternions?
+// ----------------
+// In order to take advantage of quaternions we need to know how to
+// go from rotation-matricies to quaternions and back.  We also have
+// to agree what variety of rotations we're generating.
+// 
+// Consider the equation...   v' = v * R 
+//
+// There are two ways to think about rotations of vectors.
+// 1) v' is the same vector in a different reference frame
+// 2) v' is a new vector in the same reference frame
+//
+// bookmark -- which way are we using?
+// 
+// 
+// Quaternion from Angle-Axis:
+// ---------------------------
+// Suppose we wanted to represent a rotation of some angle (theta) 
+// about some axis ({Ax, Ay, Az})...
+//
+// axis of rotation = {Ax, Ay, Az} 
+// angle_of_rotation = theta
+//
+// s = sin(0.5 * theta)
+// c = cos(0.5 * theta)
+// Q = { s * Ax, s * Ay, s * Az, c }
+//
+//
+// 3x3 Matrix from Quaternion
+// --------------------------
+//
+//     |                                                                    |
+//     | 1 - 2 * (y^2 + z^2)   2 * (x * y + z * w)     2 * (y * w - x * z)  |
+//     |                                                                    |
+// M = | 2 * (x * y - z * w)   1 - 2 * (x^2 + z^2)     2 * (y * z + x * w)  |
+//     |                                                                    |
+//     | 2 * (x * z + y * w)   2 * (y * z - x * w)     1 - 2 * (x^2 + y^2)  |
+//     |                                                                    |
+
+#endif
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index bba0a6d089d..ab9f8c4c240 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -45,7 +45,7 @@
 #include "v4math.h"
 #include "m4math.h"
 #include "m3math.h"
-#include "llmatrix4a.h"
+#include "llmatrix3a.h"
 #include "lloctree.h"
 #include "lldarray.h"
 #include "llvolume.h"
@@ -53,6 +53,7 @@
 #include "llstl.h"
 #include "llsdserialize.h"
 #include "llvector4a.h"
+#include "llmatrix4a.h"
 
 #define DEBUG_SILHOUETTE_BINORMALS 0
 #define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette
@@ -161,7 +162,7 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 	LLVector4a det;
 	det.setAllDot3(edge1, pvec);
 	
-	if (det.greaterEqual4(LLVector4a::getApproximatelyZero()).getComparisonMask() & 0x7)
+	if (det.greaterEqual(LLVector4a::getEpsilon()).getGatheredBits() & 0x7)
 	{
 		/* calculate distance from vert0 to ray origin */
 		LLVector4a tvec;
@@ -171,8 +172,8 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 		LLVector4a u;
 		u.setAllDot3(tvec,pvec);
 
-		if ((u.greaterEqual4(LLVector4a::getZero()).getComparisonMask() & 0x7) &&
-			(u.lessEqual4(det).getComparisonMask() & 0x7))
+		if ((u.greaterEqual(LLVector4a::getZero()).getGatheredBits() & 0x7) &&
+			(u.lessEqual(det).getGatheredBits() & 0x7))
 		{
 			/* prepare to test V parameter */
 			LLVector4a qvec;
@@ -188,8 +189,8 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
 			LLVector4a sum_uv;
 			sum_uv.setAdd(u, v);
 
-			S32 v_gequal = v.greaterEqual4(LLVector4a::getZero()).getComparisonMask() & 0x7;
-			S32 sum_lequal = sum_uv.lessEqual4(det).getComparisonMask() & 0x7;
+			S32 v_gequal = v.greaterEqual(LLVector4a::getZero()).getGatheredBits() & 0x7;
+			S32 sum_lequal = sum_uv.lessEqual(det).getGatheredBits() & 0x7;
 
 			if (v_gequal  && sum_lequal)
 			{
@@ -230,7 +231,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v
 	pvec.setCross3(dir, edge2);
 
 	/* if determinant is near zero, ray lies in plane of triangle */
-	F32 det = edge1.dot3(pvec);
+	F32 det = edge1.dot3(pvec).getF32();
 
 	
 	if (det > -F_APPROXIMATELY_ZERO && det < F_APPROXIMATELY_ZERO)
@@ -245,7 +246,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v
 	tvec.setSub(orig, vert0);
 	
 	/* calculate U parameter and test bounds */
-	u = (tvec.dot3(pvec)) * inv_det;
+	u = (tvec.dot3(pvec).getF32()) * inv_det;
 	if (u < 0.f || u > 1.f)
 	{
 		return FALSE;
@@ -255,7 +256,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v
 	tvec.sub(edge1);
 		
 	/* calculate V parameter and test bounds */
-	v = (dir.dot3(tvec)) * inv_det;
+	v = (dir.dot3(tvec).getF32()) * inv_det;
 	
 	if (v < 0.f || u + v > 1.f)
 	{
@@ -263,7 +264,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v
 	}
 
 	/* calculate t, ray intersects triangle */
-	t = (edge2.dot3(tvec)) * inv_det;
+	t = (edge2.dot3(tvec).getF32()) * inv_det;
 	
 	intersection_a = u;
 	intersection_b = v;
@@ -326,20 +327,20 @@ class LLVolumeOctreeRebound : public LLOctreeTravelerDepthFirst<LLVolumeTriangle
 				//stretch by triangles in node
 				tri = *iter;
 				
-				min.setMin(*tri->mV[0]);
-				min.setMin(*tri->mV[1]);
-				min.setMin(*tri->mV[2]);
+				min.setMin(min, *tri->mV[0]);
+				min.setMin(min, *tri->mV[1]);
+				min.setMin(min, *tri->mV[2]);
 
-				max.setMax(*tri->mV[0]);
-				max.setMax(*tri->mV[1]);
-				max.setMax(*tri->mV[2]);
+				max.setMax(max, *tri->mV[0]);
+				max.setMax(max, *tri->mV[1]);
+				max.setMax(max, *tri->mV[2]);
 			}
 
 			for (S32 i = 0; i < branch->getChildCount(); ++i)
 			{  //stretch by child extents
 				LLVolumeOctreeListener* child = (LLVolumeOctreeListener*) branch->getChild(i)->getListener(0);
-				min.setMin(child->mExtents[0]);
-				max.setMax(child->mExtents[1]);
+				min.setMin(min, child->mExtents[0]);
+				max.setMax(min, child->mExtents[1]);
 			}
 		}
 		else if (branch->getChildCount() != 0)
@@ -352,8 +353,8 @@ class LLVolumeOctreeRebound : public LLOctreeTravelerDepthFirst<LLVolumeTriangle
 			for (S32 i = 1; i < branch->getChildCount(); ++i)
 			{  //stretch by child extents
 				child = (LLVolumeOctreeListener*) branch->getChild(i)->getListener(0);
-				min.setMin(child->mExtents[0]);
-				max.setMax(child->mExtents[1]);
+				min.setMin(min, child->mExtents[0]);
+				max.setMax(max, child->mExtents[1]);
 			}
 		}
 		else
@@ -2011,7 +2012,7 @@ const LLVolumeFace::VertexData& LLVolumeFace::VertexData::operator=(const LLVolu
 	if (this != &rhs)
 	{
 		init();
-		LLVector4a::memcpyNonAliased16((F32*) mData, (F32*) rhs.mData, 8);
+		LLVector4a::memcpyNonAliased16((F32*) mData, (F32*) rhs.mData, 8*sizeof(F32));
 		mTexCoord = rhs.mTexCoord;
 	}
 	return *this;
@@ -2055,8 +2056,8 @@ void LLVolumeFace::VertexData::setNormal(const LLVector4a& norm)
 
 bool LLVolumeFace::VertexData::operator<(const LLVolumeFace::VertexData& rhs)const
 {
-	const F32* lp = this->getPosition().getF32();
-	const F32* rp = rhs.getPosition().getF32();
+	const F32* lp = this->getPosition().getF32ptr();
+	const F32* rp = rhs.getPosition().getF32ptr();
 
 	if (lp[0] != rp[0])
 	{
@@ -2073,8 +2074,8 @@ bool LLVolumeFace::VertexData::operator<(const LLVolumeFace::VertexData& rhs)con
 		return lp[2] < rp[2];
 	}
 
-	lp = getNormal().getF32();
-	rp = rhs.getNormal().getF32();
+	lp = getNormal().getF32ptr();
+	rp = rhs.getNormal().getF32ptr();
 
 	if (lp[0] != rp[0])
 	{
@@ -2101,23 +2102,23 @@ bool LLVolumeFace::VertexData::operator<(const LLVolumeFace::VertexData& rhs)con
 
 bool LLVolumeFace::VertexData::operator==(const LLVolumeFace::VertexData& rhs)const
 {
-	return mData[POSITION].equal3(rhs.getPosition()) &&
-			mData[NORMAL].equal3(rhs.getNormal()) &&
+	return mData[POSITION].equals3(rhs.getPosition()) &&
+			mData[NORMAL].equals3(rhs.getNormal()) &&
 			mTexCoord == rhs.mTexCoord;
 }
 
 bool LLVolumeFace::VertexData::compareNormal(const LLVolumeFace::VertexData& rhs, F32 angle_cutoff) const
 {
 	bool retval = false;
-	if (rhs.mData[POSITION].equal3(mData[POSITION]) && rhs.mTexCoord == mTexCoord)
+	if (rhs.mData[POSITION].equals3(mData[POSITION]) && rhs.mTexCoord == mTexCoord)
 	{
 		if (angle_cutoff > 1.f)
 		{
-			retval = (mData[NORMAL].equal3(rhs.mData[NORMAL]));
+			retval = (mData[NORMAL].equals3(rhs.mData[NORMAL]));
 		}
 		else
 		{
-			F32 cur_angle = rhs.mData[NORMAL].dot3(mData[NORMAL]);
+			F32 cur_angle = rhs.mData[NORMAL].dot3(mData[NORMAL]).getF32();
 			retval = cur_angle > angle_cutoff;
 		}
 	}
@@ -2331,8 +2332,8 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 				}
 				else
 				{
-					min.setMin(*pos_out);
-					max.setMax(*pos_out);
+					min.setMin(min, *pos_out);
+					max.setMax(max, *pos_out);
 				}
 
 				pos_out++;
@@ -2944,7 +2945,7 @@ void sculpt_calc_mesh_resolution(U16 width, U16 height, U8 type, F32 detail, S32
 		ratio = (F32) width / (F32) height;
 
 	
-	s = (S32)fsqrtf(((F32)vertices / ratio));
+	s = (S32)(F32) sqrt(((F32)vertices / ratio));
 
 	s = llmax(s, 4);              // no degenerate sizes, please
 	t = vertices / s;
@@ -5280,16 +5281,15 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 
 	freeData();
 	
-	LLVector4a::memcpyNonAliased16((F32*) mExtents, (F32*) src.mExtents, 12);
+	LLVector4a::memcpyNonAliased16((F32*) mExtents, (F32*) src.mExtents, 12*sizeof(F32));
 
 	resizeVertices(src.mNumVertices);
 	resizeIndices(src.mNumIndices);
 
 	if (mNumVertices)
 	{
-		S32 vert_size = mNumVertices*4;
+		S32 vert_size = mNumVertices*4*sizeof(F32);
 		S32 tc_size = (mNumVertices*8+0xF) & ~0xF;
-		tc_size /= 4;
 			
 		LLVector4a::memcpyNonAliased16((F32*) mPositions, (F32*) src.mPositions, vert_size);
 		LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) src.mNormals, vert_size);
@@ -5322,8 +5322,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 	if (mNumIndices)
 	{
 		S32 idx_size = (mNumIndices*2+0xF) & ~0xF;
-		idx_size /= 4;
-
+		
 		LLVector4a::memcpyNonAliased16((F32*) mIndices, (F32*) src.mIndices, idx_size);
 	}
 	
@@ -5388,9 +5387,9 @@ void LLVolumeFace::getVertexData(U16 index, LLVolumeFace::VertexData& cv)
 
 bool LLVolumeFace::VertexMapData::operator==(const LLVolumeFace::VertexData& rhs) const
 {
-	return getPosition().equal3(rhs.getPosition()) &&
+	return getPosition().equals3(rhs.getPosition()) &&
 		mTexCoord == rhs.mTexCoord &&
-		getNormal().equal3(rhs.getNormal());
+		getNormal().equals3(rhs.getNormal());
 }
 
 bool LLVolumeFace::VertexMapData::ComparePosition::operator()(const LLVector3& a, const LLVector3& b) const
@@ -5423,7 +5422,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 		getVertexData(index, cv);
 		
 		BOOL found = FALSE;
-		VertexMapData::PointMap::iterator point_iter = point_map.find(LLVector3(cv.getPosition().getF32()));
+		VertexMapData::PointMap::iterator point_iter = point_map.find(LLVector3(cv.getPosition().getF32ptr()));
 		if (point_iter != point_map.end())
 		{ //duplicate point might exist
 			for (U32 j = 0; j < point_iter->second.size(); ++j)
@@ -5455,7 +5454,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 			}
 			else
 			{
-				point_map[LLVector3(d.getPosition().getF32())].push_back(d);
+				point_map[LLVector3(d.getPosition().getF32ptr())].push_back(d);
 			}
 		}
 	}
@@ -5491,12 +5490,12 @@ void LLVolumeFace::createOctree()
 		tri->mIndex[2] = mIndices[i+2];
 
 		LLVector4a min = v0;
-		min.setMin(v1);
-		min.setMin(v2);
+		min.setMin(min, v1);
+		min.setMin(min, v2);
 
 		LLVector4a max = v0;
-		max.setMax(v1);
-		max.setMax(v2);
+		max.setMax(max, v1);
+		max.setMax(max, v2);
 
 		LLVector4a center;
 		center.setAdd(min, max);
@@ -5507,7 +5506,7 @@ void LLVolumeFace::createOctree()
 		LLVector4a size;
 		size.setSub(max,min);
 		
-		tri->mRadius = size.length3() * 0.5f;
+		tri->mRadius = size.getLength3().getF32() * 0.5f;
 		
 		mOctree->insert(tri);
 	}
@@ -5655,12 +5654,13 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
 
 				if (gx == 0 && gy == 0)
 				{
-					min = max = newVert.getPosition();
+					min = newVert.getPosition();
+					max = min;
 				}
 				else
 				{
-					min.setMin(newVert.getPosition());
-					max.setMax(newVert.getPosition());
+					min.setMin(min, newVert.getPosition());
+					max.setMax(max, newVert.getPosition());
 				}
 			}
 		}
@@ -5795,7 +5795,8 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 		
 		if (i == 0)
 		{
-			min = max = pos[i];
+			max = pos[i];
+			min = max;
 			min_uv = max_uv = tc[i];
 		}
 		else
@@ -5848,8 +5849,8 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 		
 	for (S32 i = 0; i < num_vertices; i++)
 	{
-		binorm[i].load4a((F32*) &binormal.mQ);
-		norm[i].load4a((F32*) &normal.mQ);
+		binorm[i].load4a(binormal.getF32ptr());
+		norm[i].load4a(normal.getF32ptr());
 	}
 
 	if (partial_build)
@@ -6186,7 +6187,7 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 	LLVector4a* dst = (LLVector4a*) ll_aligned_malloc_16(new_size);
 	if (mPositions)
 	{
-		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mPositions, old_size/4);
+		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mPositions, old_size);
 		ll_aligned_free_16(mPositions);
 	}
 	mPositions = dst;
@@ -6195,7 +6196,7 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 	dst = (LLVector4a*) ll_aligned_malloc_16(new_size);
 	if (mNormals)
 	{
-		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mNormals, old_size/4);
+		LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mNormals, old_size);
 		ll_aligned_free_16(mNormals);
 	}
 	mNormals = dst;
@@ -6209,7 +6210,7 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
 		LLVector2* dst = (LLVector2*) ll_aligned_malloc_16(new_size);
 		if (mTexCoords)
 		{
-			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mTexCoords, old_size/4);
+			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mTexCoords, old_size);
 			ll_aligned_free_16(mTexCoords);
 		}
 	}
@@ -6268,7 +6269,7 @@ void LLVolumeFace::pushIndex(const U16& idx)
 		U16* dst = (U16*) ll_aligned_malloc_16(new_size);
 		if (mIndices)
 		{
-			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mIndices, old_size/4);
+			LLVector4a::memcpyNonAliased16((F32*) dst, (F32*) mIndices, old_size);
 			ll_aligned_free_16(mIndices);
 		}
 		mIndices = dst;
@@ -6319,9 +6320,9 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 
 	if (mNumVertices > 0)
 	{ //copy old buffers
-		LLVector4a::memcpyNonAliased16((F32*) new_pos, (F32*) mPositions, mNumVertices*4);
-		LLVector4a::memcpyNonAliased16((F32*) new_norm, (F32*) mNormals, mNumVertices*4);
-		LLVector4a::memcpyNonAliased16((F32*) new_tc, (F32*) mTexCoords, mNumVertices*2);
+		LLVector4a::memcpyNonAliased16((F32*) new_pos, (F32*) mPositions, mNumVertices*4*sizeof(F32));
+		LLVector4a::memcpyNonAliased16((F32*) new_norm, (F32*) mNormals, mNumVertices*4*sizeof(F32));
+		LLVector4a::memcpyNonAliased16((F32*) new_tc, (F32*) mTexCoords, mNumVertices*2*sizeof(F32));
 	}
 
 	//free old buffer space
@@ -6382,7 +6383,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
 	if (mNumIndices > 0)
 	{ //copy old index buffer
 		S32 old_size = (mNumIndices*2+0xF) & ~0xF;
-		LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, old_size/4);
+		LLVector4a::memcpyNonAliased16((F32*) new_indices, (F32*) mIndices, old_size);
 	}
 
 	//free old index buffer
diff --git a/indra/llmath/tests/v2math_test.cpp b/indra/llmath/tests/v2math_test.cpp
index 4660fcb9552..c745b9989e1 100644
--- a/indra/llmath/tests/v2math_test.cpp
+++ b/indra/llmath/tests/v2math_test.cpp
@@ -91,7 +91,7 @@ namespace tut
 		F32 x = 2.2345f, y = 3.5678f ;
 		LLVector2 vec2(x,y);
 		ensure("magVecSquared:Fail ", is_approx_equal(vec2.magVecSquared(), (x*x + y*y)));
-		ensure("magVec:Fail ", is_approx_equal(vec2.magVec(), fsqrtf(x*x + y*y)));
+		ensure("magVec:Fail ", is_approx_equal(vec2.magVec(), (F32) sqrt(x*x + y*y)));
 	}
 
 	template<> template<>
@@ -413,7 +413,7 @@ namespace tut
 		ensure_equals("dist_vec_squared values are not equal",val2, val1);
 
 		val1 = 	dist_vec(vec2, vec3);
-		val2 = fsqrtf((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2));
+		val2 = (F32) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2));
 		ensure_equals("dist_vec values are not equal",val2, val1);
 	}
 
@@ -437,7 +437,7 @@ namespace tut
 		LLVector2 vec2(x1, y1);
 
 		F32 vecMag = vec2.normVec();
-		F32 mag = fsqrtf(x1*x1 + y1*y1);
+		F32 mag = (F32) sqrt(x1*x1 + y1*y1);
 
 		F32 oomag = 1.f / mag;
 		val1 = x1 * oomag;
diff --git a/indra/llmath/tests/v3color_test.cpp b/indra/llmath/tests/v3color_test.cpp
index 316b6e392f9..0efba8e9f3d 100644
--- a/indra/llmath/tests/v3color_test.cpp
+++ b/indra/llmath/tests/v3color_test.cpp
@@ -99,7 +99,7 @@ namespace tut
 		F32 r = 2.3436212f, g = 1231.f, b = 4.7849321232f;
 		LLColor3 llcolor3(r,g,b);
 		ensure("magVecSquared:Fail ", is_approx_equal(llcolor3.magVecSquared(), (r*r + g*g + b*b)));
-		ensure("magVec:Fail ", is_approx_equal(llcolor3.magVec(), fsqrtf(r*r + g*g + b*b)));
+		ensure("magVec:Fail ", is_approx_equal(llcolor3.magVec(), (F32) sqrt(r*r + g*g + b*b)));
 	}
 
 	template<> template<>
@@ -109,7 +109,7 @@ namespace tut
 		F32 val1, val2,val3;
 		LLColor3 llcolor3(r,g,b);
 		F32 vecMag = llcolor3.normVec();
-		F32 mag = fsqrtf(r*r + g*g + b*b);
+		F32 mag = (F32) sqrt(r*r + g*g + b*b);
 		F32 oomag = 1.f / mag;
 		val1 = r * oomag;
 		val2 = g * oomag;
@@ -292,7 +292,7 @@ namespace tut
 		F32 r1 =1.f, g1 = 2.f,b1 = 1.2f, r2 = -2.3f, g2 = 1.11f, b2 = 1234.234f;
 		LLColor3 llcolor3(r1,g1,b1),llcolor3a(r2,g2,b2);
 		F32 val = distVec(llcolor3,llcolor3a);
-		ensure("distVec failed ", is_approx_equal(fsqrtf((r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2)) ,val));
+		ensure("distVec failed ", is_approx_equal((F32) sqrt((r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2)) ,val));
 		
 		F32 val1 = distVec_squared(llcolor3,llcolor3a);
 		ensure("distVec_squared failed ", is_approx_equal(((r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2)) ,val1));
diff --git a/indra/llmath/tests/v3dmath_test.cpp b/indra/llmath/tests/v3dmath_test.cpp
index e7c949186c2..894b6200f5d 100644
--- a/indra/llmath/tests/v3dmath_test.cpp
+++ b/indra/llmath/tests/v3dmath_test.cpp
@@ -409,7 +409,7 @@ namespace tut
 		LLVector3d vec3D(x,y,z);
 		F64 res = (x*x + y*y + z*z) - vec3D.magVecSquared();
 		ensure("1:magVecSquared:Fail ", ((-F_APPROXIMATELY_ZERO <= res)&& (res <=F_APPROXIMATELY_ZERO)));
-		res = fsqrtf(x*x + y*y + z*z) - vec3D.magVec();
+		res = (F32) sqrt(x*x + y*y + z*z) - vec3D.magVec();
 		ensure("2:magVec: Fail ", ((-F_APPROXIMATELY_ZERO <= res)&& (res <=F_APPROXIMATELY_ZERO)));	
 	}
 
diff --git a/indra/llmath/tests/v3math_test.cpp b/indra/llmath/tests/v3math_test.cpp
index 7faf076243f..d5c8dd2f9cd 100644
--- a/indra/llmath/tests/v3math_test.cpp
+++ b/indra/llmath/tests/v3math_test.cpp
@@ -155,7 +155,7 @@ namespace tut
 		F32 x = 2.32f, y = 1.212f, z = -.12f;
 		LLVector3 vec3(x,y,z);		
 		ensure("1:magVecSquared:Fail ", is_approx_equal(vec3.magVecSquared(), (x*x + y*y + z*z)));
-		ensure("2:magVec:Fail ", is_approx_equal(vec3.magVec(), fsqrtf(x*x + y*y + z*z)));
+		ensure("2:magVec:Fail ", is_approx_equal(vec3.magVec(), (F32) sqrt(x*x + y*y + z*z)));
 	}
 
 	template<> template<>
@@ -515,7 +515,7 @@ namespace tut
 		F32 val1,val2;
 		LLVector3 vec3(x1,y1,z1),vec3a(x2,y2,z2);
 		val1 = dist_vec(vec3,vec3a);
-		val2 = fsqrtf((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
+		val2 = (F32) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
 		ensure_equals("1:dist_vec: Fail ",val2, val1);
 		val1 = dist_vec_squared(vec3,vec3a);
 		val2 =((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
diff --git a/indra/llmath/tests/v4color_test.cpp b/indra/llmath/tests/v4color_test.cpp
index 33921e0f0f6..636446027aa 100644
--- a/indra/llmath/tests/v4color_test.cpp
+++ b/indra/llmath/tests/v4color_test.cpp
@@ -161,7 +161,7 @@ namespace tut
 		F32 r = 0x20, g = 0xFFFF, b = 0xFF;
 		LLColor4 llcolor4(r,g,b);
 		ensure("magVecSquared:Fail ", is_approx_equal(llcolor4.magVecSquared(), (r*r + g*g + b*b)));
-		ensure("magVec:Fail ", is_approx_equal(llcolor4.magVec(), fsqrtf(r*r + g*g + b*b)));
+		ensure("magVec:Fail ", is_approx_equal(llcolor4.magVec(), (F32) sqrt(r*r + g*g + b*b)));
 	}
 
 	template<> template<>
@@ -170,7 +170,7 @@ namespace tut
 		F32 r = 0x20, g = 0xFFFF, b = 0xFF;
 		LLColor4 llcolor4(r,g,b);
 		F32 vecMag = llcolor4.normVec();
-		F32 mag = fsqrtf(r*r + g*g + b*b);
+		F32 mag = (F32) sqrt(r*r + g*g + b*b);
 		F32 oomag = 1.f / mag;
 		F32 val1 = r * oomag, val2 = g * oomag,	val3 = b * oomag;
 		ensure("1:normVec failed ", (is_approx_equal(val1, llcolor4.mV[0]) && is_approx_equal(val2, llcolor4.mV[1]) && is_approx_equal(val3, llcolor4.mV[2]) && is_approx_equal(vecMag, mag)));
diff --git a/indra/llmath/tests/v4coloru_test.cpp b/indra/llmath/tests/v4coloru_test.cpp
index 9f71cfc8cc7..b3dbfece34b 100644
--- a/indra/llmath/tests/v4coloru_test.cpp
+++ b/indra/llmath/tests/v4coloru_test.cpp
@@ -141,7 +141,7 @@ namespace tut
 		U8 r = 0x12, g = 0xFF, b = 0xAF;
 		LLColor4U llcolor4u(r,g,b);
 		ensure("magVecSquared:Fail ", is_approx_equal(llcolor4u.magVecSquared(), (F32)(r*r + g*g + b*b)));
-		ensure("magVec:Fail ", is_approx_equal(llcolor4u.magVec(), fsqrtf(r*r + g*g + b*b)));
+		ensure("magVec:Fail ", is_approx_equal(llcolor4u.magVec(), (F32) sqrt((F32) (r*r + g*g + b*b))));
 	}
 
 	template<> template<>
diff --git a/indra/llmath/tests/v4math_test.cpp b/indra/llmath/tests/v4math_test.cpp
index fe051c27e97..e919c90efa7 100644
--- a/indra/llmath/tests/v4math_test.cpp
+++ b/indra/llmath/tests/v4math_test.cpp
@@ -102,7 +102,7 @@ namespace tut
 	{
 		F32 x = 10.f, y = -2.3f, z = -.023f;
 		LLVector4 vec4(x,y,z);
-		ensure("magVec:Fail ", is_approx_equal(vec4.magVec(), fsqrtf(x*x + y*y + z*z)));
+		ensure("magVec:Fail ", is_approx_equal(vec4.magVec(), (F32) sqrt(x*x + y*y + z*z)));
 		ensure("magVecSquared:Fail ", is_approx_equal(vec4.magVecSquared(), (x*x + y*y + z*z)));
 	}
 
@@ -343,7 +343,7 @@ namespace tut
 		F32 val1,val2;
 		LLVector4 vec4(x1,y1,z1),vec4a(x2,y2,z2);
 		val1 = dist_vec(vec4,vec4a);
-		val2 = fsqrtf((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
+		val2 = (F32) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
 		ensure_equals("dist_vec: Fail ",val2, val1);
 		val1 = dist_vec_squared(vec4,vec4a);
 		val2 =((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
diff --git a/indra/llmath/v2math.cpp b/indra/llmath/v2math.cpp
index 220336e0c2a..2603127f75c 100644
--- a/indra/llmath/v2math.cpp
+++ b/indra/llmath/v2math.cpp
@@ -92,7 +92,7 @@ F32	dist_vec(const LLVector2 &a, const LLVector2 &b)
 {
 	F32 x = a.mV[0] - b.mV[0];
 	F32 y = a.mV[1] - b.mV[1];
-	return fsqrtf( x*x + y*y );
+	return (F32) sqrt( x*x + y*y );
 }
 
 F32	dist_vec_squared(const LLVector2 &a, const LLVector2 &b)
diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h
index ae26c85ce4c..35fd1b60482 100644
--- a/indra/llmath/v2math.h
+++ b/indra/llmath/v2math.h
@@ -225,7 +225,7 @@ inline void	LLVector2::setVec(const F32 *vec)
 
 inline F32 LLVector2::length(void) const
 {
-	return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]);
+	return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]);
 }
 
 inline F32 LLVector2::lengthSquared(void) const
@@ -235,7 +235,7 @@ inline F32 LLVector2::lengthSquared(void) const
 
 inline F32		LLVector2::normalize(void)
 {
-	F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]);
+	F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]);
 	F32 oomag;
 
 	if (mag > FP_MAG_THRESHOLD)
@@ -262,7 +262,7 @@ inline bool LLVector2::isFinite() const
 // deprecated
 inline F32		LLVector2::magVec(void) const
 {
-	return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]);
+	return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]);
 }
 
 // deprecated
@@ -274,7 +274,7 @@ inline F32		LLVector2::magVecSquared(void) const
 // deprecated
 inline F32		LLVector2::normVec(void)
 {
-	F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]);
+	F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]);
 	F32 oomag;
 
 	if (mag > FP_MAG_THRESHOLD)
diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h
index 1915d80502c..95a3de8b622 100644
--- a/indra/llmath/v3color.h
+++ b/indra/llmath/v3color.h
@@ -284,7 +284,7 @@ inline F32		LLColor3::brightness(void) const
 
 inline F32		LLColor3::length(void) const
 {
-	return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+	return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
 }
 
 inline F32		LLColor3::lengthSquared(void) const
@@ -294,7 +294,7 @@ inline F32		LLColor3::lengthSquared(void) const
 
 inline F32		LLColor3::normalize(void)
 {
-	F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+	F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
 	F32 oomag;
 
 	if (mag)
@@ -310,7 +310,7 @@ inline F32		LLColor3::normalize(void)
 // deprecated
 inline F32		LLColor3::magVec(void) const
 {
-	return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+	return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
 }
 
 // deprecated
@@ -322,7 +322,7 @@ inline F32		LLColor3::magVecSquared(void) const
 // deprecated
 inline F32		LLColor3::normVec(void)
 {
-	F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+	F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
 	F32 oomag;
 
 	if (mag)
@@ -444,7 +444,7 @@ inline F32		distVec(const LLColor3 &a, const LLColor3 &b)
 	F32 x = a.mV[0] - b.mV[0];
 	F32 y = a.mV[1] - b.mV[1];
 	F32 z = a.mV[2] - b.mV[2];
-	return fsqrtf( x*x + y*y + z*z );
+	return (F32) sqrt( x*x + y*y + z*z );
 }
 
 inline F32		distVec_squared(const LLColor3 &a, const LLColor3 &b)
diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h
index 6ab31e8a41b..ab253de0643 100644
--- a/indra/llmath/v3dmath.h
+++ b/indra/llmath/v3dmath.h
@@ -240,7 +240,7 @@ inline const LLVector3d&	LLVector3d::setVec(const F64 *vec)
 
 inline F64 LLVector3d::normVec(void)
 {
-	F64 mag = fsqrtf(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+	F64 mag = (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
 	F64 oomag;
 
 	if (mag > FP_MAG_THRESHOLD)
@@ -262,7 +262,7 @@ inline F64 LLVector3d::normVec(void)
 
 inline F64 LLVector3d::normalize(void)
 {
-	F64 mag = fsqrtf(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+	F64 mag = (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
 	F64 oomag;
 
 	if (mag > FP_MAG_THRESHOLD)
@@ -286,7 +286,7 @@ inline F64 LLVector3d::normalize(void)
 
 inline F64	LLVector3d::magVec(void) const
 {
-	return fsqrtf(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+	return (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
 }
 
 inline F64	LLVector3d::magVecSquared(void) const
@@ -296,7 +296,7 @@ inline F64	LLVector3d::magVecSquared(void) const
 
 inline F64	LLVector3d::length(void) const
 {
-	return fsqrtf(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+	return (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
 }
 
 inline F64	LLVector3d::lengthSquared(void) const
@@ -406,7 +406,7 @@ inline F64	dist_vec(const LLVector3d &a, const LLVector3d &b)
 	F64 x = a.mdV[0] - b.mdV[0];
 	F64 y = a.mdV[1] - b.mdV[1];
 	F64 z = a.mdV[2] - b.mdV[2];
-	return fsqrtf( x*x + y*y + z*z );
+	return (F32) sqrt( x*x + y*y + z*z );
 }
 
 inline F64	dist_vec_squared(const LLVector3d &a, const LLVector3d &b)
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index 75c860a91eb..5d483a87532 100644
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -282,7 +282,7 @@ inline void	LLVector3::setVec(const F32 *vec)
 
 inline F32 LLVector3::normalize(void)
 {
-	F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+	F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
 	F32 oomag;
 
 	if (mag > FP_MAG_THRESHOLD)
@@ -305,7 +305,7 @@ inline F32 LLVector3::normalize(void)
 // deprecated
 inline F32 LLVector3::normVec(void)
 {
-	F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+	F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
 	F32 oomag;
 
 	if (mag > FP_MAG_THRESHOLD)
@@ -329,7 +329,7 @@ inline F32 LLVector3::normVec(void)
 
 inline F32	LLVector3::length(void) const
 {
-	return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+	return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
 }
 
 inline F32	LLVector3::lengthSquared(void) const
@@ -339,7 +339,7 @@ inline F32	LLVector3::lengthSquared(void) const
 
 inline F32	LLVector3::magVec(void) const
 {
-	return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+	return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
 }
 
 inline F32	LLVector3::magVecSquared(void) const
@@ -473,7 +473,7 @@ inline F32	dist_vec(const LLVector3 &a, const LLVector3 &b)
 	F32 x = a.mV[0] - b.mV[0];
 	F32 y = a.mV[1] - b.mV[1];
 	F32 z = a.mV[2] - b.mV[2];
-	return fsqrtf( x*x + y*y + z*z );
+	return (F32) sqrt( x*x + y*y + z*z );
 }
 
 inline F32	dist_vec_squared(const LLVector3 &a, const LLVector3 &b)
diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h
index 6b63b976b02..dd92e1cc634 100644
--- a/indra/llmath/v4color.h
+++ b/indra/llmath/v4color.h
@@ -392,7 +392,7 @@ inline const LLColor4&	LLColor4::setAlpha(F32 a)
 
 inline F32		LLColor4::length(void) const
 {
-	return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+	return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
 }
 
 inline F32		LLColor4::lengthSquared(void) const
@@ -402,7 +402,7 @@ inline F32		LLColor4::lengthSquared(void) const
 
 inline F32		LLColor4::normalize(void)
 {
-	F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+	F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
 	F32 oomag;
 
 	if (mag)
@@ -418,7 +418,7 @@ inline F32		LLColor4::normalize(void)
 // deprecated
 inline F32		LLColor4::magVec(void) const
 {
-	return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+	return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
 }
 
 // deprecated
@@ -430,7 +430,7 @@ inline F32		LLColor4::magVecSquared(void) const
 // deprecated
 inline F32		LLColor4::normVec(void)
 {
-	F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+	F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
 	F32 oomag;
 
 	if (mag)
diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h
index 4ec5a345ebc..08245403a12 100644
--- a/indra/llmath/v4coloru.h
+++ b/indra/llmath/v4coloru.h
@@ -300,7 +300,7 @@ inline const LLColor4U&	LLColor4U::setAlpha(U8 a)
 
 inline F32		LLColor4U::length(void) const
 {
-	return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] );
+	return (F32) sqrt( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] );
 }
 
 inline F32		LLColor4U::lengthSquared(void) const
@@ -311,7 +311,7 @@ inline F32		LLColor4U::lengthSquared(void) const
 // deprecated
 inline F32		LLColor4U::magVec(void) const
 {
-	return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] );
+	return (F32) sqrt( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] );
 }
 
 // deprecated
diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h
index 4c82e6b629f..72a477ed20d 100644
--- a/indra/llmath/v4math.h
+++ b/indra/llmath/v4math.h
@@ -321,7 +321,7 @@ inline void	LLVector4::setVec(const F32 *vec)
 
 inline F32		LLVector4::length(void) const
 {
-	return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+	return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
 }
 
 inline F32		LLVector4::lengthSquared(void) const
@@ -331,7 +331,7 @@ inline F32		LLVector4::lengthSquared(void) const
 
 inline F32		LLVector4::magVec(void) const
 {
-	return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+	return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
 }
 
 inline F32		LLVector4::magVecSquared(void) const
@@ -463,7 +463,7 @@ inline LLVector4 lerp(const LLVector4 &a, const LLVector4 &b, F32 u)
 
 inline F32		LLVector4::normalize(void)
 {
-	F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+	F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
 	F32 oomag;
 
 	if (mag > FP_MAG_THRESHOLD)
@@ -486,7 +486,7 @@ inline F32		LLVector4::normalize(void)
 // deprecated
 inline F32		LLVector4::normVec(void)
 {
-	F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+	F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
 	F32 oomag;
 
 	if (mag > FP_MAG_THRESHOLD)
diff --git a/indra/llmessage/llsdmessagebuilder.cpp b/indra/llmessage/llsdmessagebuilder.cpp
index 6e41b03895c..2680dd0b77e 100755
--- a/indra/llmessage/llsdmessagebuilder.cpp
+++ b/indra/llmessage/llsdmessagebuilder.cpp
@@ -35,6 +35,7 @@
 #include "llsdmessagebuilder.h"
 
 #include "llmessagetemplate.h"
+#include "llmath.h"
 #include "llquaternion.h"
 #include "llsdutil.h"
 #include "llsdutil_math.h"
diff --git a/indra/llmessage/lltemplatemessagebuilder.cpp b/indra/llmessage/lltemplatemessagebuilder.cpp
index fa02456d90c..6f9707ed57b 100644
--- a/indra/llmessage/lltemplatemessagebuilder.cpp
+++ b/indra/llmessage/lltemplatemessagebuilder.cpp
@@ -35,6 +35,7 @@
 #include "lltemplatemessagebuilder.h"
 
 #include "llmessagetemplate.h"
+#include "llmath.h"
 #include "llquaternion.h"
 #include "u64.h"
 #include "v3dmath.h"
diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp
index 8f56cf25217..2b67e9f6fa7 100644
--- a/indra/llmessage/lltemplatemessagereader.cpp
+++ b/indra/llmessage/lltemplatemessagereader.cpp
@@ -36,6 +36,7 @@
 #include "llfasttimer.h"
 #include "llmessagebuilder.h"
 #include "llmessagetemplate.h"
+#include "llmath.h"
 #include "llquaternion.h"
 #include "message.h"
 #include "u64.h"
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 70601663e65..2b1a9bbf945 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -924,7 +924,7 @@ LLVector3 LLRender::getUITranslation()
 	{
 		llerrs << "UI offset stack empty." << llendl;
 	}
-	return LLVector3(mUIOffset[mUIStackDepth-1].getF32());
+	return LLVector3(mUIOffset[mUIStackDepth-1].getF32ptr());
 }
 
 LLVector3 LLRender::getUIScale()
@@ -933,7 +933,7 @@ LLVector3 LLRender::getUIScale()
 	{
 		llerrs << "UI scale stack empty." << llendl;
 	}
-	return LLVector3(mUIScale[mUIStackDepth-1].getF32());
+	return LLVector3(mUIScale[mUIStackDepth-1].getF32ptr());
 }
 
 
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 72d51540ef1..5fae5b893f6 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -1210,7 +1210,7 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s
 	else
 	{
 		// Guess at a reasonable stop distance.
-		mAutoPilotStopDistance = fsqrtf( distance );
+		mAutoPilotStopDistance = (F32) sqrt( distance );
 		if (mAutoPilotStopDistance < 0.5f) 
 		{
 			mAutoPilotStopDistance = 0.5f;
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 8d0a06378fc..68f52e04bc5 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -743,7 +743,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 		}
 		else
 		{
-			pos = LLVector3(getPositionGroup().getF32());
+			pos = LLVector3(getPositionGroup().getF32ptr());
 		}
 
 		pos -= camera.getOrigin();	
@@ -824,7 +824,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 		for (S32 i = 0; i < getNumFaces(); i++)
 		{
 			LLFace *facep = getFace(i);
-			facep->mCenterAgent += LLVector3(shift_vector.getF32());
+			facep->mCenterAgent += LLVector3(shift_vector.getF32ptr());
 			facep->mExtents[0].add(shift_vector);
 			facep->mExtents[1].add(shift_vector);
 			
@@ -1153,13 +1153,13 @@ void LLSpatialBridge::updateSpatialExtents()
 		LLVector4a max;
 		max.setAdd(center, delta);
 
-		newMin.setMin(min);
-		newMax.setMax(max);
+		newMin.setMin(newMin, min);
+		newMax.setMax(newMax, max);
 	}
 	
 	LLVector4a diagonal;
 	diagonal.setSub(newMax, newMin);
-	mRadius = diagonal.length3() * 0.5f;
+	mRadius = diagonal.getLength3().getF32() * 0.5f;
 	
 	mPositionGroup->setAdd(newMin,newMax);
 	mPositionGroup->mul(0.5f);
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index af082eea3e3..d698624c15b 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -37,6 +37,7 @@
 
 #include "llvoavatar.h"
 #include "m3math.h"
+#include "llmatrix4a.h"
 
 #include "llagent.h" //for gAgent.needsRenderAvatar()
 #include "lldrawable.h"
@@ -495,7 +496,7 @@ S32 LLDrawPoolAvatar::getNumPasses()
 	}
 	else
 	{
-		return 3;
+		return 4;
 	}
 #else
 	if (LLPipeline::sImpostorRender)
@@ -814,26 +815,46 @@ void LLDrawPoolAvatar::endSkinned()
 #if LL_MESH_ENABLED
 void LLDrawPoolAvatar::beginRiggedSimple()
 {
-	if (LLPipeline::sUnderWaterRender)
+	if (sShaderLevel > 0)
 	{
-		sVertexProgram = &gSkinnedObjectSimpleWaterProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			sVertexProgram = &gSkinnedObjectSimpleWaterProgram;
+		}
+		else
+		{
+			sVertexProgram = &gSkinnedObjectSimpleProgram;
+		}
 	}
 	else
 	{
-		sVertexProgram = &gSkinnedObjectSimpleProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			sVertexProgram = &gObjectSimpleWaterProgram;
+		}
+		else
+		{
+			sVertexProgram = &gObjectSimpleProgram;
+		}
 	}
 
-	sDiffuseChannel = 0;
-	sVertexProgram->bind();
-	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+	if (sShaderLevel > 0 || gPipeline.canUseVertexShaders())
+	{
+		sDiffuseChannel = 0;
+		sVertexProgram->bind();
+		LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+	}
 }
 
 void LLDrawPoolAvatar::endRiggedSimple()
 {
 	LLVertexBuffer::unbind();
-	sVertexProgram->unbind();
-	sVertexProgram = NULL;
-	LLVertexBuffer::sWeight4Loc = -1;
+	if (sShaderLevel > 0 || gPipeline.canUseVertexShaders())
+	{
+		sVertexProgram->unbind();
+		sVertexProgram = NULL;
+		LLVertexBuffer::sWeight4Loc = -1;
+	}
 }
 
 void LLDrawPoolAvatar::beginRiggedAlpha()
@@ -1281,8 +1302,10 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 }
 
 #if LL_MESH_ENABLED
-void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face)
+void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace* face, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face)
 {
+	LLVertexBuffer* buffer = face->mVertexBuffer;
+
 	U32 data_mask = 0;
 	for (U32 i = 0; i < face->mRiggedIndex.size(); ++i)
 	{
@@ -1292,17 +1315,23 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSk
 		}
 	}
 
-	LLVertexBuffer* buff = face->mVertexBuffer;
-
-	if (!buff || 
-		buff->getTypeMask() != data_mask ||
-		buff->getRequestedVerts() != vol_face.mNumVertices)
+	if (!buffer || 
+		buffer->getTypeMask() != data_mask ||
+		buffer->getRequestedVerts() != vol_face.mNumVertices)
 	{
 		face->setGeomIndex(0);
 		face->setIndicesIndex(0);
 		face->setSize(vol_face.mNumVertices, vol_face.mNumIndices, true);
 
-		face->mVertexBuffer = new LLVertexBuffer(data_mask, 0);
+		if (sShaderLevel > 0)
+		{
+			face->mVertexBuffer = new LLVertexBuffer(data_mask, GL_DYNAMIC_DRAW_ARB);
+		}
+		else
+		{
+			face->mVertexBuffer = new LLVertexBuffer(data_mask, GL_STREAM_DRAW_ARB);
+		}
+
 		face->mVertexBuffer->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), true);
 
 		U16 offset = 0;
@@ -1319,7 +1348,83 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSk
 		LLMatrix3 mat_normal(mat3);				
 
 		face->getGeometryVolume(*volume, face->getTEOffset(), mat_vert, mat_normal, offset, true);
-		buff = face->mVertexBuffer;
+		buffer = face->mVertexBuffer;
+	}
+
+	if (sShaderLevel <= 0 && face->mLastSkinTime < avatar->getLastSkinTime())
+	{ //perform software vertex skinning for this face
+		LLStrider<LLVector3> position;
+		LLStrider<LLVector3> normal;
+
+		buffer->getVertexStrider(position);
+		buffer->getNormalStrider(normal);
+
+		LLVector4a* pos = (LLVector4a*) position.get();
+		LLVector4a* norm = (LLVector4a*) normal.get();
+		
+		//build matrix palette
+		LLMatrix4a mp[64];
+		LLMatrix4* mat = (LLMatrix4*) mp;
+
+		for (U32 j = 0; j < skin->mJointNames.size(); ++j)
+		{
+			LLJoint* joint = avatar->getJoint(skin->mJointNames[j]);
+			if (joint)
+			{
+				mat[j] = skin->mInvBindMatrix[j];
+				mat[j] *= joint->getWorldMatrix();
+			}
+		}
+
+		LLVector4a* weight = vol_face.mWeights;
+
+		LLMatrix4a bind_shape_matrix;
+		bind_shape_matrix.loadu(skin->mBindShapeMatrix);
+
+		for (U32 j = 0; j < buffer->getRequestedVerts(); ++j)
+		{
+			LLMatrix4a final_mat;
+			final_mat.clear();
+
+			S32 idx[4];
+
+			LLVector4 wght;
+
+			F32 scale = 0.f;
+			for (U32 k = 0; k < 4; k++)
+			{
+				F32 w = weight[j][k];
+
+				idx[k] = (S32) floorf(w);
+				wght[k] = w - floorf(w);
+				scale += wght[k];
+			}
+
+			wght *= 1.f/scale;
+
+			for (U32 k = 0; k < 4; k++)
+			{
+				F32 w = wght[k];
+
+				LLMatrix4a src;
+				src.setMul(mp[idx[k]], w);
+
+				final_mat.add(src);
+			}
+
+			
+			LLVector4a& v = vol_face.mPositions[j];
+			LLVector4a t;
+			LLVector4a dst;
+			bind_shape_matrix.affineTransform(v, t);
+			final_mat.affineTransform(t, dst);
+			pos[j] = dst;
+
+			LLVector4a& n = vol_face.mNormals[j];
+			bind_shape_matrix.rotate(n, t);
+			final_mat.rotate(t, dst);
+			norm[j] = dst;
+		}
 	}
 }
 
@@ -1371,7 +1476,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 		stop_glerror();
 
 		const LLVolumeFace& vol_face = volume->getVolumeFace(te);
-		updateRiggedFaceVertexBuffer(face, skin, volume, vol_face);
+		updateRiggedFaceVertexBuffer(avatar, face, skin, volume, vol_face);
 		
 		stop_glerror();
 
@@ -1381,30 +1486,37 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 
 		if (buff)
 		{
-			LLMatrix4 mat[64];
+			if (sShaderLevel > 0)
+			{ //upload matrix palette to shader
+				LLMatrix4 mat[64];
 
-			for (U32 i = 0; i < skin->mJointNames.size(); ++i)
-			{
-				LLJoint* joint = avatar->getJoint(skin->mJointNames[i]);
-				if (joint)
+				for (U32 i = 0; i < skin->mJointNames.size(); ++i)
 				{
-					mat[i] = skin->mInvBindMatrix[i];
-					mat[i] *= joint->getWorldMatrix();
+					LLJoint* joint = avatar->getJoint(skin->mJointNames[i]);
+					if (joint)
+					{
+						mat[i] = skin->mInvBindMatrix[i];
+						mat[i] *= joint->getWorldMatrix();
+					}
 				}
+				
+				stop_glerror();
+
+				LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", 
+					skin->mJointNames.size(),
+					FALSE,
+					(GLfloat*) mat[0].mMatrix);
+				LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette[0]", 
+					skin->mJointNames.size(),
+					FALSE,
+					(GLfloat*) mat[0].mMatrix);
+
+				stop_glerror();
+			}
+			else
+			{
+				data_mask &= ~LLVertexBuffer::MAP_WEIGHT4;
 			}
-			
-			stop_glerror();
-
-			LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", 
-				skin->mJointNames.size(),
-				FALSE,
-				(GLfloat*) mat[0].mMatrix);
-			LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette[0]", 
-				skin->mJointNames.size(),
-				FALSE,
-				(GLfloat*) mat[0].mMatrix);
-
-			stop_glerror();
 
 			buff->setBuffer(data_mask);
 
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index b01394534b3..d08ae045160 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -138,7 +138,8 @@ class LLDrawPoolAvatar : public LLFacePool
 	void endDeferredRiggedSimple();
 	void endDeferredRiggedBump();
 		
-	void updateRiggedFaceVertexBuffer(LLFace* facep, 
+	void updateRiggedFaceVertexBuffer(LLVOAvatar* avatar,
+									  LLFace* facep, 
 									  const LLMeshSkinInfo* skin, 
 									  LLVolume* volume,
 									  const LLVolumeFace& vol_face);
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 8533f9710c8..5d7d3387a44 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -106,8 +106,8 @@ void planarProjection(LLVector2 &tc, const LLVector4a& normal,
 	LLVector4a tangent;
 	tangent.setCross3(binormal,normal);
 
-	tc.mV[1] = -((tangent.dot3(vec))*2 - 0.5f);
-	tc.mV[0] = 1.0f+((binormal.dot3(vec))*2 - 0.5f);
+	tc.mV[1] = -((tangent.dot3(vec).getF32())*2 - 0.5f);
+	tc.mV[0] = 1.0f+((binormal.dot3(vec).getF32())*2 - 0.5f);
 }
 
 void sphericalProjection(LLVector2 &tc, const LLVector4a& normal,
@@ -156,6 +156,7 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
 
 	mLastUpdateTime = gFrameTimeSeconds;
 	mLastMoveTime = 0.f;
+	mLastSkinTime = gFrameTimeSeconds;
 	mVSize = 0.f;
 	mPixelArea = 16.f;
 	mState      = GLOBAL;
@@ -828,8 +829,8 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
 			LLVector4a max;
 			max.setAdd(center, delta);
 
-			newMin.setMin(min);
-			newMax.setMax(max);
+			newMin.setMin(newMin,min);
+			newMax.setMax(newMax,max);
 		}
 
 		if (!mDrawablep->isActive())
@@ -844,11 +845,11 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
 		t.mul(0.5f);
 
 		//VECTORIZE THIS
-		mCenterLocal.set(t.getF32());
+		mCenterLocal.set(t.getF32ptr());
 		
 		t.setSub(newMax,newMin);
 		t.mul(0.5f);
-		mBoundingSphereRadius = t.length3();
+		mBoundingSphereRadius = t.getLength3().getF32();
 
 		updateCenterAgent();
 	}
@@ -1313,7 +1314,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 				{
 					if (!do_xform)
 					{
-						LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, num_vertices*2);
+						LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, num_vertices*2*sizeof(F32));
 					}
 					else
 					{
@@ -1529,13 +1530,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 					if (mDrawablep->isActive())
 					{
 						LLVector3 t;
-						t.set(binormal.getF32());
+						t.set(binormal.getF32ptr());
 						t *= bump_quat;
 						binormal.load3(t.mV);
 					}
 
 					binormal.normalize3fast();
-					tc += LLVector2( bump_s_primary_light_ray.dot3(tangent), bump_t_primary_light_ray.dot3(binormal) );
+					tc += LLVector2( bump_s_primary_light_ray.dot3(tangent).getF32(), bump_t_primary_light_ray.dot3(binormal).getF32() );
 					
 					*tex_coords2++ = tc;
 				}	
@@ -1583,7 +1584,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	
 	if (rebuild_weights && vf.mWeights)
 	{
-		LLVector4a::memcpyNonAliased16((F32*) weights, (F32*) vf.mWeights, num_vertices*4);
+		LLVector4a::memcpyNonAliased16((F32*) weights, (F32*) vf.mWeights, num_vertices*4*sizeof(F32));
 	}
 
 	if (rebuild_color)
@@ -1705,21 +1706,21 @@ BOOL LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius)
 
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
 
-	F32 size_squared = size.dot3(size);
+	F32 size_squared = size.dot3(size).getF32();
 	LLVector4a lookAt;
 	LLVector4a t;
 	t.load3(camera->getOrigin().mV);
 	lookAt.setSub(center, t);
-	F32 dist = lookAt.length3();
+	F32 dist = lookAt.getLength3().getF32();
 	lookAt.normalize3fast() ;	
 
 	//get area of circle around node
-	F32 app_angle = atanf(fsqrtf(size_squared) / dist);
+	F32 app_angle = atanf((F32) sqrt(size_squared) / dist);
 	radius = app_angle*LLDrawable::sCurPixelAngle;
 	mPixelArea = radius*radius * 3.14159f;
 	LLVector4a x_axis;
 	x_axis.load3(camera->getXAxis().mV);
-	cos_angle_to_view_dir = lookAt.dot3(x_axis);
+	cos_angle_to_view_dir = lookAt.dot3(x_axis).getF32();
 
 	//if has media, check if the face is out of the view frustum.	
 	if(hasMedia())
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index b6a67c7fc43..a7d78893507 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -240,6 +240,7 @@ class LLFace
 	LLPointer<LLVertexBuffer> mVertexBuffer;
 	LLPointer<LLVertexBuffer> mLastVertexBuffer;
 	F32			mLastUpdateTime;
+	F32			mLastSkinTime;
 	F32			mLastMoveTime;
 	LLMatrix4*	mTextureMatrix;
 	LLDrawInfo* mDrawInfo;
@@ -274,7 +275,7 @@ class LLFace
 
 	S32			mReferenceIndex;
 	std::vector<S32> mRiggedIndex;
-	 
+	
 	F32			mVSize;
 	F32			mPixelArea;
 
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 8be4e347488..62336b03bf5 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -100,7 +100,7 @@ void LLVolumeImplFlexible::onParameterChanged(U16 param_type, LLNetworkData *dat
 void LLVolumeImplFlexible::onShift(const LLVector4a &shift_vector)
 {	
 	//VECTORIZE THIS
-	LLVector3 shift(shift_vector.getF32());
+	LLVector3 shift(shift_vector.getF32ptr());
 	for (int section = 0; section < (1<<FLEXIBLE_OBJECT_MAX_SECTIONS)+1; ++section)
 	{
 		mSection[section].mPosition += shift;	
diff --git a/indra/newview/llhudicon.cpp b/indra/newview/llhudicon.cpp
index 63040904dff..e5da871d034 100644
--- a/indra/newview/llhudicon.cpp
+++ b/indra/newview/llhudicon.cpp
@@ -302,7 +302,7 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
 		{
 			dir.mul(t);
 			starta.add(dir);
-			*intersection = LLVector3((F32*) &starta.mQ);
+			*intersection = LLVector3(starta.getF32ptr());
 		}
 		return TRUE;
 	}
diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp
index 7f4609b83ea..adeb401b77b 100644
--- a/indra/newview/llpanelnearbymedia.cpp
+++ b/indra/newview/llpanelnearbymedia.cpp
@@ -362,7 +362,7 @@ void LLPanelNearByMedia::updateListItem(LLScrollListItem* item, LLViewerMediaImp
 		debug_str += llformat("%g/", (float)impl->getInterest());
 		
 		// proximity distance is actually distance squared -- display it as straight distance.
-		debug_str += llformat("%g/", fsqrtf(impl->getProximityDistance()));
+		debug_str += llformat("%g/", (F32) sqrt(impl->getProximityDistance()));
 		
 		//			s += llformat("%g/", (float)impl->getCPUUsage());
 		//			s += llformat("%g/", (float)impl->getApproximateTextureInterest());
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index 98fbebbc5d2..d84ac2e4c88 100644
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -576,8 +576,8 @@ void LLPanelPrimMediaControls::updateShape()
 			const LLVolumeFace& vf = volume->getVolumeFace(mTargetObjectFace);
 			
 			LLVector3 ext[2];
-			ext[0].set(vf.mExtents[0].getF32());
-			ext[1].set(vf.mExtents[1].getF32());
+			ext[0].set(vf.mExtents[0].getF32ptr());
+			ext[1].set(vf.mExtents[1].getF32ptr());
 			
 			LLVector3 center = (ext[0]+ext[1])*0.5f;
 			LLVector3 size = (ext[1]-ext[0])*0.5f;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 42f09f7396b..92903a6aa95 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1124,13 +1124,13 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
 			size.setSub(max_extents, min_extents);
 			size.mul(0.5f);
 
-			mGridOrigin.set(center.getF32());
+			mGridOrigin.set(center.getF32ptr());
 			LLDrawable* drawable = first_grid_object->mDrawable;
 			if (drawable && drawable->isActive())
 			{
 				mGridOrigin = mGridOrigin * first_grid_object->getRenderMatrix();
 			}
-			mGridScale.set(size.getF32());
+			mGridScale.set(size.getF32ptr());
 		}
 	}
 	else // GRID_MODE_WORLD or just plain default
@@ -3543,7 +3543,7 @@ void LLSelectMgr::deselectAllIfTooFar()
 		{
 			if (mDebugSelectMgr)
 			{
-				llinfos << "Selection manager: auto-deselecting, select_dist = " << fsqrtf(select_dist_sq) << llendl;
+				llinfos << "Selection manager: auto-deselecting, select_dist = " << (F32) sqrt(select_dist_sq) << llendl;
 				llinfos << "agent pos global = " << gAgent.getPositionGlobal() << llendl;
 				llinfos << "selection pos global = " << selectionCenter << llendl;
 			}
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 2335c7bb8e6..e55ec033563 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -231,7 +231,7 @@ U8* get_box_fan_indices(LLCamera* camera, const LLVector4a& center)
 	LLVector4a origin;
 	origin.load3(camera->getOrigin().mV);
 
-	S32 cypher = center.greaterThan4(origin).getComparisonMask() & 0x7;
+	S32 cypher = center.greaterThan(origin).getGatheredBits() & 0x7;
 	
 	return sOcclusionIndices+cypher*8;
 }
@@ -253,7 +253,7 @@ void LLSpatialGroup::buildOcclusion()
 	r2.splat(0.25f);
 	r2.add(mBounds[1]);
 
-	r.setMin(r2);
+	r.setMin(r, r2);
 
 	LLVector4a* v = mOcclusionVerts;
 	const LLVector4a& c = mBounds[0];
@@ -775,8 +775,8 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& ma
 	}
 	else
 	{
-		minOut.setMin(newMin);
-		maxOut.setMax(newMax);
+		minOut.setMin(minOut, newMin);
+		maxOut.setMax(maxOut, newMax);
 	}
 		
 	return TRUE;
@@ -1220,8 +1220,8 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 #endif
 	if (!getData().empty())
 	{
-		mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].length3() :
-						(F32) mOctreeNode->getSize().length3();
+		mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].getLength3().getF32() :
+						(F32) mOctreeNode->getSize().getLength3().getF32();
 		mDistance = mSpatialPartition->calcDistance(this, camera);
 		mPixelArea = mSpatialPartition->calcPixelArea(this, camera);
 	}
@@ -1241,7 +1241,7 @@ F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera)
 	{
 		LLVector4a v = eye;
 
-		dist = eye.length3();
+		dist = eye.getLength3().getF32();
 		eye.normalize3fast();
 
 		if (!group->isState(LLSpatialGroup::ALPHA_DIRTY))
@@ -1253,7 +1253,7 @@ F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera)
 				LLVector4a diff;
 				diff.setSub(view_angle, *group->mLastUpdateViewAngle);
 
-				if (diff.length3() > 0.64f)
+				if (diff.getLength3().getF32() > 0.64f)
 				{
 					*group->mViewAngle = view_angle;
 					*group->mLastUpdateViewAngle = view_angle;
@@ -1279,11 +1279,11 @@ F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera)
 		t.mul(group->mObjectBounds[1]);
 		v.sub(t);
 		
-		group->mDepth = v.dot3(ata);
+		group->mDepth = v.dot3(ata).getF32();
 	}
 	else
 	{
-		dist = eye.length3();
+		dist = eye.getLength3().getF32();
 	}
 
 	if (dist < 16.f)
@@ -1497,8 +1497,8 @@ BOOL LLSpatialGroup::rebound()
 			const LLVector4a& max = group->mExtents[1];
 			const LLVector4a& min = group->mExtents[0];
 
-			newMax.setMax(max);
-			newMin.setMin(min);
+			newMax.setMax(newMax, max);
+			newMin.setMin(newMin, min);
 		}
 
 		boundObjects(FALSE, newMin, newMax);
@@ -2196,8 +2196,8 @@ BOOL LLSpatialPartition::getVisibleExtents(LLCamera& camera, LLVector3& visMin,
 	LLOctreeCullVisExtents vis(&camera, visMina, visMaxa);
 	vis.traverse(mOctree);
 
-	visMin.set(visMina.getF32());
-	visMax.set(visMaxa.getF32());
+	visMin.set(visMina.getF32ptr());
+	visMax.set(visMaxa.getF32ptr());
 	return vis.mEmpty;
 }
 
@@ -2280,13 +2280,13 @@ BOOL earlyFail(LLCamera* camera, LLSpatialGroup* group)
 	LLVector4a max;
 	max.setAdd(c,r);
 	
-	S32 lt = e.lessThan4(min).getComparisonMask() & 0x7;
+	S32 lt = e.lessThan(min).getGatheredBits() & 0x7;
 	if (lt)
 	{
 		return FALSE;
 	}
 
-	S32 gt = e.greaterThan4(max).getComparisonMask() & 0x7;
+	S32 gt = e.greaterThan(max).getGatheredBits() & 0x7;
 	if (gt)
 	{
 		return FALSE;
@@ -2745,8 +2745,8 @@ void renderNormals(LLDrawable* drawablep)
 				p.setAdd(face.mPositions[j], n);
 				
 				gGL.color4f(1,1,1,1);
-				gGL.vertex3fv(face.mPositions[j].getF32());
-				gGL.vertex3fv(p.getF32());
+				gGL.vertex3fv(face.mPositions[j].getF32ptr());
+				gGL.vertex3fv(p.getF32ptr());
 				
 				if (face.mBinormals)
 				{
@@ -2754,8 +2754,8 @@ void renderNormals(LLDrawable* drawablep)
 					p.setAdd(face.mPositions[j], n);
 				
 					gGL.color4f(0,1,1,1);
-					gGL.vertex3fv(face.mPositions[j].getF32());
-					gGL.vertex3fv(p.getF32());
+					gGL.vertex3fv(face.mPositions[j].getF32ptr());
+					gGL.vertex3fv(p.getF32ptr());
 				}	
 			}
 
@@ -3024,8 +3024,8 @@ class LLRenderOctreeRaycast : public LLOctreeTriangleRayIntersect
 		LLVolumeOctreeListener* vl = (LLVolumeOctreeListener*) branch->getListener(0);
 
 		LLVector3 center, size;
-		center.set(vl->mBounds[0].getF32());
-		size.set(vl->mBounds[1].getF32());
+		center.set(vl->mBounds[0].getF32ptr());
+		size.set(vl->mBounds[1].getF32ptr());
 
 		drawBoxOutline(center, size);
 	}
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index cef7c4abbbf..917185ed040 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -810,7 +810,7 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts)
 				render_mata.affineTransform(t, vec);
 			}
 
-			BOOL in_frustum = pointInFrustum(LLVector3(vec.getF32())) > 0;
+			BOOL in_frustum = pointInFrustum(LLVector3(vec.getF32ptr())) > 0;
 
 			if (( !in_frustum && all_verts) ||
 				 (in_frustum && !all_verts))
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 9e35b5cc51c..0a181e09bbc 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -726,8 +726,8 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 			
 			U32 words = num_verts*4;
 
-			LLVector4a::memcpyNonAliased16(v, (F32*) mMesh->getCoords(), words);
-			LLVector4a::memcpyNonAliased16(n, (F32*) mMesh->getNormals(), words);
+			LLVector4a::memcpyNonAliased16(v, (F32*) mMesh->getCoords(), words*sizeof(F32));
+			LLVector4a::memcpyNonAliased16(n, (F32*) mMesh->getNormals(), words*sizeof(F32));
 						
 			
 			if (!terse_update)
@@ -740,9 +740,9 @@ 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);
-				LLVector4a::memcpyNonAliased16(vw, (F32*) mMesh->getWeights(), num_verts);	
-				LLVector4a::memcpyNonAliased16(cw, (F32*) mMesh->getClothingWeights(), num_verts*4);	
+				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));	
 			}
 
 			const U32 idx_count = mMesh->getNumFaces()*3;
diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index 79d8fc7df90..16a6022b868 100644
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -764,7 +764,7 @@ void LLViewerJoystick::moveAvatar(bool reset)
 	sDelta[RX_I] += (cur_delta[RX_I] - sDelta[RX_I]) * time * feather;
 	sDelta[RY_I] += (cur_delta[RY_I] - sDelta[RY_I]) * time * feather;
 	
-	handleRun(fsqrtf(sDelta[Z_I]*sDelta[Z_I] + sDelta[X_I]*sDelta[X_I]));
+	handleRun((F32) sqrt(sDelta[Z_I]*sDelta[Z_I] + sDelta[X_I]*sDelta[X_I]));
 	
 	// Allow forward/backward movement some priority
 	if (dom_axis == Z_I)
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 178d928f57e..303f339f7d3 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -865,7 +865,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 				
 				// Set the low priority size for downsampling to approximately the size the texture is displayed at.
 				{
-					F32 approximate_interest_dimension = fsqrtf(pimpl->getInterest());
+					F32 approximate_interest_dimension = (F32) sqrt(pimpl->getInterest());
 					
 					pimpl->setLowPrioritySizeLimit(llround(approximate_interest_dimension));
 				}
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 2b89deaa53d..9587fbafb18 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2973,7 +2973,7 @@ F32 LLViewerObject::getBinRadius()
 		const LLVector4a* ext = mDrawable->getSpatialExtents();
 		LLVector4a diff;
 		diff.setSub(ext[1], ext[0]);
-		return diff.length3();
+		return diff.getLength3().getF32();
 	}
 	
 	return getScale().magVec();
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index 41848e8b7ad..4759454ee79 100644
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -161,8 +161,8 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 bo
 
 	if (group != NULL)
 	{
-		LLVector3 center(group->mOctreeNode->getCenter().getF32());
-		LLVector3 size(group->mOctreeNode->getSize().getF32());
+		LLVector3 center(group->mOctreeNode->getCenter().getF32ptr());
+		LLVector3 size(group->mOctreeNode->getSize().getF32ptr());
 		size += LLVector3(0.01f, 0.01f, 0.01f);
 		mMinObjPos = center - size;
 		mMaxObjPos = center + size;
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 719c5b0da54..d50efe89ddb 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1580,7 +1580,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
 
 	S32 cur_discard = getCurrentDiscardLevelForFetching();
 	bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel));
-	F32 pixel_priority = fsqrtf(mMaxVirtualSize);
+	F32 pixel_priority = (F32) sqrt(mMaxVirtualSize);
 
 	F32 priority = 0.f;
 
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index abf22b5e5a2..e50d0fce491 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -675,6 +675,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 	mTexHairColor( NULL ),
 	mTexEyeColor( NULL ),
 	mNeedsSkin(FALSE),
+	mLastSkinTime(0.f),
 	mUpdatePeriod(1),
 	mFullyLoaded(FALSE),
 	mPreviousFullyLoaded(FALSE),
@@ -1356,7 +1357,7 @@ void LLVOAvatar::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
 	if (isImpostor() && !needsImpostorUpdate())
 	{
 		LLVector3 delta = getRenderPosition() -
-			((LLVector3(mDrawable->getPositionGroup().getF32())-mImpostorOffset));
+			((LLVector3(mDrawable->getPositionGroup().getF32ptr())-mImpostorOffset));
 		
 		newMin.load3( (mLastAnimExtents[0] + delta).mV);
 		newMax.load3( (mLastAnimExtents[1] + delta).mV);
@@ -1364,12 +1365,12 @@ void LLVOAvatar::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
 	else
 	{
 		getSpatialExtents(newMin,newMax);
-		mLastAnimExtents[0].set(newMin.getF32());
-		mLastAnimExtents[1].set(newMax.getF32());
+		mLastAnimExtents[0].set(newMin.getF32ptr());
+		mLastAnimExtents[1].set(newMax.getF32ptr());
 		LLVector4a pos_group;
 		pos_group.setAdd(newMin,newMax);
 		pos_group.mul(0.5f);
-		mImpostorOffset = LLVector3(pos_group.getF32())-getRenderPosition();
+		mImpostorOffset = LLVector3(pos_group.getF32ptr())-getRenderPosition();
 		mDrawable->setPositionGroup(pos_group);
 	}
 }
@@ -1435,7 +1436,7 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
 						distance.setSub(ext[1], ext[0]);
 						LLVector4a max_span(max_attachment_span);
 
-						S32 lt = distance.lessThan4(max_span).getComparisonMask() & 0x7;
+						S32 lt = distance.lessThan(max_span).getGatheredBits() & 0x7;
 						
 						// Only add the prim to spatial extents calculations if it isn't a megaprim.
 						// max_attachment_span calculated at the start of the function 
@@ -2533,14 +2534,14 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 				getSpatialExtents(ext[0], ext[1]);
 				LLVector4a diff;
 				diff.setSub(ext[1], mImpostorExtents[1]);
-				if (diff.length3() > 0.05f)
+				if (diff.getLength3().getF32() > 0.05f)
 				{
 					mNeedsImpostorUpdate = TRUE;
 				}
 				else
 				{
 					diff.setSub(ext[0], mImpostorExtents[0]);
-					if (diff.length3() > 0.05f)
+					if (diff.getLength3().getF32() > 0.05f)
 					{
 						mNeedsImpostorUpdate = TRUE;
 					}
@@ -3887,7 +3888,8 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 				mMeshLOD[MESH_ID_HAIR]->updateJointGeometry();
 			}
 			mNeedsSkin = FALSE;
-			
+			mLastSkinTime = gFrameTimeSeconds;
+
 			LLVertexBuffer* vb = mDrawable->getFace(0)->mVertexBuffer;
 			if (vb)
 			{
@@ -4231,7 +4233,7 @@ void LLVOAvatar::updateTextures()
 
 	if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
 	{
-		setDebugText(llformat("%4.0f:%4.0f", fsqrtf(mMinPixelArea),fsqrtf(mMaxPixelArea)));
+		setDebugText(llformat("%4.0f:%4.0f", (F32) sqrt(mMinPixelArea),(F32) sqrt(mMaxPixelArea)));
 	}	
 }
 
@@ -5443,7 +5445,7 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent)
 	}
 	else
 	{
-		F32 radius = size.length3();
+		F32 radius = size.getLength3().getF32();
 		mAppAngle = (F32) atan2( radius, range) * RAD_TO_DEG;
 	}
 
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 95b0665f7de..94b564fc8f1 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -345,6 +345,7 @@ class LLVOAvatar :
 	U32 		renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
 	U32 		renderRigid();
 	U32 		renderSkinned(EAvatarRenderPass pass);
+	F32			getLastSkinTime() { return mLastSkinTime; }
 	U32			renderSkinnedAttachments();
 	U32 		renderTransparent(BOOL first_pass);
 	void 		renderCollisionVolumes();
@@ -357,6 +358,8 @@ class LLVOAvatar :
 	bool		shouldAlphaMask();
 
 	BOOL 		mNeedsSkin; // avatar has been animated and verts have not been updated
+	F32			mLastSkinTime; //value of gFrameTimeSeconds at last skin update
+
 	S32	 		mUpdatePeriod;
 	S32  		mNumInitFaces; //number of faces generated when creating the avatar drawable, does not inculde splitted faces due to long vertex buffer.
 
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index fe1e36cbe8c..65829b213e5 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -328,7 +328,7 @@ void LLVOGrass::updateTextures()
 	{
 		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
 		{
-			setDebugText(llformat("%4.0f", fsqrtf(mPixelArea)));
+			setDebugText(llformat("%4.0f", (F32) sqrt(mPixelArea)));
 		}
 		getTEImage(0)->addTextureStats(mPixelArea);
 	}
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp
index 63f662c5a19..c047758a59d 100644
--- a/indra/newview/llvosurfacepatch.cpp
+++ b/indra/newview/llvosurfacepatch.cpp
@@ -999,8 +999,8 @@ BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector3& start, const LLVect
 	const LLVector4a* exta = mDrawable->getSpatialExtents();
 
 	LLVector3 ext[2];
-	ext[0].set(exta[0].getF32());
-	ext[1].set(exta[1].getF32());
+	ext[0].set(exta[0].getF32ptr());
+	ext[1].set(exta[1].getF32ptr());
 
 	F32 rad = (delta*tdelta).magVecSquared();
 
diff --git a/indra/newview/llvotextbubble.cpp b/indra/newview/llvotextbubble.cpp
index 339da3c0bf9..e790373d027 100644
--- a/indra/newview/llvotextbubble.cpp
+++ b/indra/newview/llvotextbubble.cpp
@@ -254,8 +254,8 @@ void LLVOTextBubble::getGeometry(S32 idx,
 	LLVector2* dst_tc = (LLVector2*) texcoordsp.get();
 	LLVector2* src_tc = (LLVector2*) face.mTexCoords;
 
-	LLVector4a::memcpyNonAliased16((F32*) dst_norm, (F32*) src_norm, face.mNumVertices*4);
-	LLVector4a::memcpyNonAliased16((F32*) dst_tc, (F32*) src_tc, face.mNumVertices*2);
+	LLVector4a::memcpyNonAliased16((F32*) dst_norm, (F32*) src_norm, face.mNumVertices*4*sizeof(F32));
+	LLVector4a::memcpyNonAliased16((F32*) dst_tc, (F32*) src_tc, face.mNumVertices*2*sizeof(F32));
 	
 	
 	for (U32 i = 0; i < face.mNumVertices; i++)
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index eb790b04cc6..e3b4efb9dd8 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -472,7 +472,7 @@ void LLVOTree::updateTextures()
 	{
 		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
 		{
-			setDebugText(llformat("%4.0f", fsqrtf(mPixelArea)));
+			setDebugText(llformat("%4.0f", (F32) sqrt(mPixelArea)));
 		}
 		mTreeImagep->addTextureStats(mPixelArea);
 	}
@@ -1278,8 +1278,8 @@ BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end
 
 	//VECTORIZE THIS
 	LLVector3 ext[2];
-	ext[0].set(exta[0].getF32());
-	ext[1].set(exta[1].getF32());
+	ext[0].set(exta[0].getF32ptr());
+	ext[1].set(exta[1].getF32ptr());
 	
 	LLVector3 center = (ext[1]+ext[0])*0.5f;
 	LLVector3 size = (ext[1]-ext[0]);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 1397b646232..128fd151426 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -696,7 +696,7 @@ void LLVOVolume::updateTextureVirtualSize()
 		const LLTextureEntry *te = face->getTextureEntry();
 		LLViewerTexture *imagep = face->getTexture();
 		if (!imagep || !te ||			
-			face->mExtents[0].equal3(face->mExtents[1]))
+			face->mExtents[0].equals3(face->mExtents[1]))
 		{
 			continue;
 		}
@@ -820,15 +820,15 @@ void LLVOVolume::updateTextureVirtualSize()
 	
 	if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
 	{
-		setDebugText(llformat("%.0f:%.0f", fsqrtf(min_vsize),fsqrtf(max_vsize)));
+		setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize)));
 	}
  	else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY))
  	{
- 		setDebugText(llformat("%.0f:%.0f", fsqrtf(min_vsize),fsqrtf(max_vsize)));
+ 		setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize)));
  	}
 	else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_FACE_AREA))
 	{
-		setDebugText(llformat("%.0f:%.0f", fsqrtf(min_vsize),fsqrtf(max_vsize)));
+		setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize)));
 	}
 
 	if (mPixelArea == 0)
@@ -1355,8 +1355,8 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
 			}
 			else
 			{
-				min.setMin(face->mExtents[0]);
-				max.setMax(face->mExtents[1]);
+				min.setMin(min, face->mExtents[0]);
+				max.setMax(max, face->mExtents[1]);
 			}
 		}
 	}
@@ -1864,7 +1864,7 @@ LLVector3 LLVOVolume::getApproximateFaceNormal(U8 face_id)
 			result.add(face.mNormals[i]);
 		}
 
-		LLVector3 ret((F32*) &result.mQ);
+		LLVector3 ret(result.getF32ptr());
 		ret = volumeDirectionToAgent(ret);
 		ret.normVec();
 	}
@@ -3075,7 +3075,7 @@ F32 LLVOVolume::getBinRadius()
 		LLVector4a rad;
 		rad.setSub(ext[1], ext[0]);
 		
-		radius = rad.length3()*0.5f;
+		radius = rad.getLength3().getF32()*0.5f;
 	}
 	else if (mDrawable->isStatic())
 	{
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index a1e4df8a66d..53eca0d08e5 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -591,7 +591,7 @@ void LLWorld::updateVisibilities()
 		region_list_t::iterator curiter = iter++;
 		LLViewerRegion* regionp = *curiter;
 		F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ();
-		F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared);
+		F32 radius = 0.5f*(F32) sqrt(height * height + diagonal_squared);
 		if (!regionp->getLand().hasZData()
 			|| LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius))
 		{
@@ -612,7 +612,7 @@ void LLWorld::updateVisibilities()
 		}
 
 		F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ();
-		F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared);
+		F32 radius = 0.5f*(F32) sqrt(height * height + diagonal_squared);
 		if (LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius))
 		{
 			regionp->calculateCameraDistance();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index fec7da1dd0d..b0a7b1ce836 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1522,7 +1522,7 @@ F32 LLPipeline::calcPixelArea(const LLVector4a& center, const LLVector4a& size,
 
 	LLVector4a lookAt;
 	lookAt.setSub(center, origin);
-	F32 dist = lookAt.length3();
+	F32 dist = lookAt.getLength3().getF32();
 
 	//ramp down distance for nearby objects
 	//shrink dist by dist/16.
@@ -1534,7 +1534,7 @@ F32 LLPipeline::calcPixelArea(const LLVector4a& center, const LLVector4a& size,
 	}
 
 	//get area of circle around node
-	F32 app_angle = atanf(size.length3()/dist);
+	F32 app_angle = atanf(size.getLength3().getF32()/dist);
 	F32 radius = app_angle*LLDrawable::sCurPixelAngle;
 	return radius*radius * F_PI;
 }
@@ -4671,7 +4671,7 @@ static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_
 	{
 		return max_dist;
 	}
-	F32 dist = fsqrtf(dist2);
+	F32 dist = (F32) sqrt(dist2);
 	dist *= 1.f / inten;
 	dist -= radius;
 	if (selected)
@@ -6980,7 +6980,7 @@ void LLPipeline::renderDeferredLighting()
 
 					LLVector4a center;
 					center.load3(drawablep->getPositionAgent().mV);
-					const F32* c = center.getF32();
+					const F32* c = center.getF32ptr();
 					F32 s = volume->getLightRadius()*1.5f;
 
 					LLColor3 col = volume->getLightColor();
@@ -7078,7 +7078,7 @@ void LLPipeline::renderDeferredLighting()
 
 					LLVector4a center;
 					center.load3(drawablep->getPositionAgent().mV);
-					const F32* c = center.getF32();
+					const F32* c = center.getF32ptr();
 					F32 s = volume->getLightRadius()*1.5f;
 
 					sVisibleLightCount++;
@@ -9184,8 +9184,8 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	up.mul(up);
 	up.normalize3fast();
 
-	tdim.mV[0] = fabsf(half_height.dot3(left));
-	tdim.mV[1] = fabsf(half_height.dot3(up));
+	tdim.mV[0] = fabsf(half_height.dot3(left).getF32());
+	tdim.mV[1] = fabsf(half_height.dot3(up).getF32());
 
 	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
-- 
GitLab


From 45df2d70f018512055ed15fa52c9efd3d8e833e8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 19 Aug 2010 13:08:57 -0500
Subject: [PATCH 670/683] More line endings.

---
 indra/cmake/00-Common.cmake   |    2 +-
 indra/llmath/CMakeLists.txt   |  256 ++---
 indra/llmath/llmath.h         | 1018 ++++++++---------
 indra/llmath/llquantize.h     |  316 +++---
 indra/llmath/llquaternion.cpp | 1922 ++++++++++++++++-----------------
 indra/llmath/llquaternion.h   | 1188 ++++++++++----------
 6 files changed, 2351 insertions(+), 2351 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index f10a61e1e77..8262462ced4 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -68,7 +68,7 @@ if (WINDOWS)
    
     add_definitions(
       /Zc:wchar_t-
-      /arch:SSE2
+      /arch:SSE2
       )
   endif (MSVC80 OR MSVC90)
   
diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt
index 8d85765eb8d..9dadad7dd34 100644
--- a/indra/llmath/CMakeLists.txt
+++ b/indra/llmath/CMakeLists.txt
@@ -1,128 +1,128 @@
-# -*- cmake -*-
-
-project(llmath)
-
-include(00-Common)
-include(LLCommon)
-
-include_directories(
-    ${LLCOMMON_INCLUDE_DIRS}
-    )
-
-set(llmath_SOURCE_FILES
-    llbbox.cpp
-    llbboxlocal.cpp
-    llcamera.cpp
-    llcoordframe.cpp
-    llline.cpp
-    llmatrix3a.cpp
-    llmodularmath.cpp
-    llperlin.cpp
-    llquaternion.cpp
-    llrect.cpp
-    llsphere.cpp
-    llvector4a.cpp
-    llvolume.cpp
-    llvolumemgr.cpp
-    llvolumeoctree.cpp
-    llsdutil_math.cpp
-    m3math.cpp
-    m4math.cpp
-    raytrace.cpp
-    v2math.cpp
-    v3color.cpp
-    v3dmath.cpp
-    v3math.cpp
-    v4color.cpp
-    v4coloru.cpp
-    v4math.cpp
-    xform.cpp
-    )
-
-set(llmath_HEADER_FILES
-    CMakeLists.txt
-
-    camera.h
-    coordframe.h
-    llbbox.h
-    llbboxlocal.h
-    llcamera.h
-    llcoord.h
-    llcoordframe.h
-    llinterp.h
-    llline.h
-    llmath.h
-    llmatrix3a.h
-    llmatrix3a.inl
-    llmodularmath.h
-    lloctree.h
-    llperlin.h
-    llplane.h
-    llquantize.h
-    llquaternion.h
-    llquaternion2.h
-    llquaternion2.inl
-    llrect.h
-    llsimdmath.h
-    llsimdtypes.h
-    llsimdtypes.inl
-    llsphere.h
-    lltreenode.h
-    llvector4a.h
-    llvector4a.inl
-    llvector4logical.h
-    llv4math.h
-    llv4matrix3.h
-    llv4matrix4.h
-    llv4vector3.h
-    llvolume.h
-    llvolumemgr.h
-    llvolumeoctree.h
-    llsdutil_math.h
-    m3math.h
-    m4math.h
-    raytrace.h
-    v2math.h
-    v3color.h
-    v3dmath.h
-    v3math.h
-    v4color.h
-    v4coloru.h
-    v4math.h
-    xform.h
-    )
-
-set_source_files_properties(${llmath_HEADER_FILES}
-                            PROPERTIES HEADER_FILE_ONLY TRUE)
-
-list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES})
-
-add_library (llmath ${llmath_SOURCE_FILES})
-
-# Add tests
-if (LL_TESTS)
-  include(LLAddBuildTest)
-  # UNIT TESTS
-  SET(llmath_TEST_SOURCE_FILES
-    llbboxlocal.cpp
-    llmodularmath.cpp
-    llrect.cpp
-    v2math.cpp
-    v3color.cpp
-    v4color.cpp
-    v4coloru.cpp
-    )
-  LL_ADD_PROJECT_UNIT_TESTS(llmath "${llmath_TEST_SOURCE_FILES}")
-
-  # 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(llbbox llbbox.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(llquaternion llquaternion.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(mathmisc "" "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(m3math "" "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(v3dmath v3dmath.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(v3math v3math.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(v4math v4math.cpp "${test_libs}")
-  LL_ADD_INTEGRATION_TEST(xform xform.cpp "${test_libs}")
-endif (LL_TESTS)
+# -*- cmake -*-
+
+project(llmath)
+
+include(00-Common)
+include(LLCommon)
+
+include_directories(
+    ${LLCOMMON_INCLUDE_DIRS}
+    )
+
+set(llmath_SOURCE_FILES
+    llbbox.cpp
+    llbboxlocal.cpp
+    llcamera.cpp
+    llcoordframe.cpp
+    llline.cpp
+    llmatrix3a.cpp
+    llmodularmath.cpp
+    llperlin.cpp
+    llquaternion.cpp
+    llrect.cpp
+    llsphere.cpp
+    llvector4a.cpp
+    llvolume.cpp
+    llvolumemgr.cpp
+    llvolumeoctree.cpp
+    llsdutil_math.cpp
+    m3math.cpp
+    m4math.cpp
+    raytrace.cpp
+    v2math.cpp
+    v3color.cpp
+    v3dmath.cpp
+    v3math.cpp
+    v4color.cpp
+    v4coloru.cpp
+    v4math.cpp
+    xform.cpp
+    )
+
+set(llmath_HEADER_FILES
+    CMakeLists.txt
+
+    camera.h
+    coordframe.h
+    llbbox.h
+    llbboxlocal.h
+    llcamera.h
+    llcoord.h
+    llcoordframe.h
+    llinterp.h
+    llline.h
+    llmath.h
+    llmatrix3a.h
+    llmatrix3a.inl
+    llmodularmath.h
+    lloctree.h
+    llperlin.h
+    llplane.h
+    llquantize.h
+    llquaternion.h
+    llquaternion2.h
+    llquaternion2.inl
+    llrect.h
+    llsimdmath.h
+    llsimdtypes.h
+    llsimdtypes.inl
+    llsphere.h
+    lltreenode.h
+    llvector4a.h
+    llvector4a.inl
+    llvector4logical.h
+    llv4math.h
+    llv4matrix3.h
+    llv4matrix4.h
+    llv4vector3.h
+    llvolume.h
+    llvolumemgr.h
+    llvolumeoctree.h
+    llsdutil_math.h
+    m3math.h
+    m4math.h
+    raytrace.h
+    v2math.h
+    v3color.h
+    v3dmath.h
+    v3math.h
+    v4color.h
+    v4coloru.h
+    v4math.h
+    xform.h
+    )
+
+set_source_files_properties(${llmath_HEADER_FILES}
+                            PROPERTIES HEADER_FILE_ONLY TRUE)
+
+list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES})
+
+add_library (llmath ${llmath_SOURCE_FILES})
+
+# Add tests
+if (LL_TESTS)
+  include(LLAddBuildTest)
+  # UNIT TESTS
+  SET(llmath_TEST_SOURCE_FILES
+    llbboxlocal.cpp
+    llmodularmath.cpp
+    llrect.cpp
+    v2math.cpp
+    v3color.cpp
+    v4color.cpp
+    v4coloru.cpp
+    )
+  LL_ADD_PROJECT_UNIT_TESTS(llmath "${llmath_TEST_SOURCE_FILES}")
+
+  # 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(llbbox llbbox.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(llquaternion llquaternion.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(mathmisc "" "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(m3math "" "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(v3dmath v3dmath.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(v3math v3math.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(v4math v4math.cpp "${test_libs}")
+  LL_ADD_INTEGRATION_TEST(xform xform.cpp "${test_libs}")
+endif (LL_TESTS)
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index 742bbc47511..e572381b1a2 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -1,509 +1,509 @@
-/** 
- * @file llmath.h
- * @brief Useful math constants and macros.
- *
- * $LicenseInfo:firstyear=2000&license=viewergpl$
- * 
- * Copyright (c) 2000-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LLMATH_H
-#define LLMATH_H
-
-#include <cmath>
-#include <cstdlib>
-#include "lldefs.h"
-//#include "llstl.h" // *TODO: Remove when LLString is gone
-//#include "llstring.h" // *TODO: Remove when LLString is gone
-// lltut.h uses is_approx_equal_fraction(). This was moved to its own header
-// file in llcommon so we can use lltut.h for llcommon tests without making
-// llcommon depend on llmath.
-#include "is_approx_equal_fraction.h"
-
-// work around for Windows & older gcc non-standard function names.
-#if LL_WINDOWS
-#include <float.h>
-#define llisnan(val)	_isnan(val)
-#define llfinite(val)	_finite(val)
-#elif (LL_LINUX && __GNUC__ <= 2)
-#define llisnan(val)	isnan(val)
-#define llfinite(val)	isfinite(val)
-#elif LL_SOLARIS
-#define llisnan(val)    isnan(val)
-#define llfinite(val)   (val <= std::numeric_limits<double>::max())
-#else
-#define llisnan(val)	std::isnan(val)
-#define llfinite(val)	std::isfinite(val)
-#endif
-
-// Single Precision Floating Point Routines
-// (There used to be more defined here, but they appeared to be redundant and 
-// were breaking some other includes. Removed by Falcon, reviewed by Andrew, 11/25/09)
-/*#ifndef tanf
-#define tanf(x)		((F32)tan((F64)(x)))
-#endif*/
-
-const F32	GRAVITY			= -9.8f;
-
-// mathematical constants
-const F32	F_PI		= 3.1415926535897932384626433832795f;
-const F32	F_TWO_PI	= 6.283185307179586476925286766559f;
-const F32	F_PI_BY_TWO	= 1.5707963267948966192313216916398f;
-const F32	F_SQRT_TWO_PI = 2.506628274631000502415765284811f;
-const F32	F_E			= 2.71828182845904523536f;
-const F32	F_SQRT2		= 1.4142135623730950488016887242097f;
-const F32	F_SQRT3		= 1.73205080756888288657986402541f;
-const F32	OO_SQRT2	= 0.7071067811865475244008443621049f;
-const F32	DEG_TO_RAD	= 0.017453292519943295769236907684886f;
-const F32	RAD_TO_DEG	= 57.295779513082320876798154814105f;
-const F32	F_APPROXIMATELY_ZERO = 0.00001f;
-const F32	F_LN2		= 0.69314718056f;
-const F32	OO_LN2		= 1.4426950408889634073599246810019f;
-
-const F32	F_ALMOST_ZERO	= 0.0001f;
-const F32	F_ALMOST_ONE	= 1.0f - F_ALMOST_ZERO;
-
-// BUG: Eliminate in favor of F_APPROXIMATELY_ZERO above?
-const F32 FP_MAG_THRESHOLD = 0.0000001f;
-
-// TODO: Replace with logic like is_approx_equal
-inline BOOL is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f < F_APPROXIMATELY_ZERO); }
-
-// These functions work by interpreting sign+exp+mantissa as an unsigned
-// integer.
-// For example:
-// x = <sign>1 <exponent>00000010 <mantissa>00000000000000000000000
-// y = <sign>1 <exponent>00000001 <mantissa>11111111111111111111111
-//
-// interpreted as ints = 
-// x = 10000001000000000000000000000000
-// y = 10000000111111111111111111111111
-// which is clearly a different of 1 in the least significant bit
-// Values with the same exponent can be trivially shown to work.
-//
-// WARNING: Denormals of opposite sign do not work
-// x = <sign>1 <exponent>00000000 <mantissa>00000000000000000000001
-// y = <sign>0 <exponent>00000000 <mantissa>00000000000000000000001
-// Although these values differ by 2 in the LSB, the sign bit makes
-// the int comparison fail.
-//
-// WARNING: NaNs can compare equal
-// There is no special treatment of exceptional values like NaNs
-//
-// WARNING: Infinity is comparable with F32_MAX and negative 
-// infinity is comparable with F32_MIN
-
-inline BOOL is_approx_equal(F32 x, F32 y)
-{
-	const S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
-	return (std::abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
-}
-
-inline BOOL is_approx_equal(F64 x, F64 y)
-{
-	const S64 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
-	return (std::abs((S32) ((U64&)x - (U64&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
-}
-
-inline S32 llabs(const S32 a)
-{
-	return S32(std::labs(a));
-}
-
-inline F32 llabs(const F32 a)
-{
-	return F32(std::fabs(a));
-}
-
-inline F64 llabs(const F64 a)
-{
-	return F64(std::fabs(a));
-}
-
-inline S32 lltrunc( F32 f )
-{
-#if LL_WINDOWS && !defined( __INTEL_COMPILER )
-		// Avoids changing the floating point control word.
-		// Add or subtract 0.5 - epsilon and then round
-		const static U32 zpfp[] = { 0xBEFFFFFF, 0x3EFFFFFF };
-		S32 result;
-		__asm {
-			fld		f
-			mov		eax,	f
-			shr		eax,	29
-			and		eax,	4
-			fadd	dword ptr [zpfp + eax]
-			fistp	result
-		}
-		return result;
-#else
-		return (S32)f;
-#endif
-}
-
-inline S32 lltrunc( F64 f )
-{
-	return (S32)f;
-}
-
-inline S32 llfloor( F32 f )
-{
-#if LL_WINDOWS && !defined( __INTEL_COMPILER )
-		// Avoids changing the floating point control word.
-		// Accurate (unlike Stereopsis version) for all values between S32_MIN and S32_MAX and slightly faster than Stereopsis version.
-		// Add -(0.5 - epsilon) and then round
-		const U32 zpfp = 0xBEFFFFFF;
-		S32 result;
-		__asm { 
-			fld		f
-			fadd	dword ptr [zpfp]
-			fistp	result
-		}
-		return result;
-#else
-		return (S32)floor(f);
-#endif
-}
-
-
-inline S32 llceil( F32 f )
-{
-	// This could probably be optimized, but this works.
-	return (S32)ceil(f);
-}
-
-
-#ifndef BOGUS_ROUND
-// Use this round.  Does an arithmetic round (0.5 always rounds up)
-inline S32 llround(const F32 val)
-{
-	return llfloor(val + 0.5f);
-}
-
-#else // BOGUS_ROUND
-// Old llround implementation - does banker's round (toward nearest even in the case of a 0.5.
-// Not using this because we don't have a consistent implementation on both platforms, use
-// llfloor(val + 0.5f), which is consistent on all platforms.
-inline S32 llround(const F32 val)
-{
-	#if LL_WINDOWS
-		// Note: assumes that the floating point control word is set to rounding mode (the default)
-		S32 ret_val;
-		_asm fld	val
-		_asm fistp	ret_val;
-		return ret_val;
-	#elif LL_LINUX
-		// Note: assumes that the floating point control word is set
-		// to rounding mode (the default)
-		S32 ret_val;
-		__asm__ __volatile__( "flds %1    \n\t"
-							  "fistpl %0  \n\t"
-							  : "=m" (ret_val)
-							  : "m" (val) );
-		return ret_val;
-	#else
-		return llfloor(val + 0.5f);
-	#endif
-}
-
-// A fast arithmentic round on intel, from Laurent de Soras http://ldesoras.free.fr
-inline int round_int(double x)
-{
-	const float round_to_nearest = 0.5f;
-	int i;
-	__asm
-	{
-		fld x
-		fadd st, st (0)
-		fadd round_to_nearest
-		fistp i
-		sar i, 1
-	}
-	return (i);
-}
-#endif // BOGUS_ROUND
-
-inline F32 llround( F32 val, F32 nearest )
-{
-	return F32(floor(val * (1.0f / nearest) + 0.5f)) * nearest;
-}
-
-inline F64 llround( F64 val, F64 nearest )
-{
-	return F64(floor(val * (1.0 / nearest) + 0.5)) * nearest;
-}
-
-// these provide minimum peak error
-//
-// avg  error = -0.013049 
-// peak error = -31.4 dB
-// RMS  error = -28.1 dB
-
-const F32 FAST_MAG_ALPHA = 0.960433870103f;
-const F32 FAST_MAG_BETA = 0.397824734759f;
-
-// these provide minimum RMS error
-//
-// avg  error = 0.000003 
-// peak error = -32.6 dB
-// RMS  error = -25.7 dB
-//
-//const F32 FAST_MAG_ALPHA = 0.948059448969f;
-//const F32 FAST_MAG_BETA = 0.392699081699f;
-
-inline F32 fastMagnitude(F32 a, F32 b)
-{ 
-	a = (a > 0) ? a : -a;
-	b = (b > 0) ? b : -b;
-	return(FAST_MAG_ALPHA * llmax(a,b) + FAST_MAG_BETA * llmin(a,b));
-}
-
-
-
-////////////////////
-//
-// Fast F32/S32 conversions
-//
-// Culled from www.stereopsis.com/FPU.html
-
-const F64 LL_DOUBLE_TO_FIX_MAGIC	= 68719476736.0*1.5;     //2^36 * 1.5,  (52-_shiftamt=36) uses limited precisicion to floor
-const S32 LL_SHIFT_AMOUNT			= 16;                    //16.16 fixed point representation,
-
-// Endian dependent code
-#ifdef LL_LITTLE_ENDIAN
-	#define LL_EXP_INDEX				1
-	#define LL_MAN_INDEX				0
-#else
-	#define LL_EXP_INDEX				0
-	#define LL_MAN_INDEX				1
-#endif
-
-/* Deprecated: use llround(), lltrunc(), or llfloor() instead
-// ================================================================================================
-// Real2Int
-// ================================================================================================
-inline S32 F64toS32(F64 val)
-{
-	val		= val + LL_DOUBLE_TO_FIX_MAGIC;
-	return ((S32*)&val)[LL_MAN_INDEX] >> LL_SHIFT_AMOUNT; 
-}
-
-// ================================================================================================
-// Real2Int
-// ================================================================================================
-inline S32 F32toS32(F32 val)
-{
-	return F64toS32 ((F64)val);
-}
-*/
-
-////////////////////////////////////////////////
-//
-// Fast exp and log
-//
-
-// Implementation of fast exp() approximation (from a paper by Nicol N. Schraudolph
-// http://www.inf.ethz.ch/~schraudo/pubs/exp.pdf
-static union
-{
-	double d;
-	struct
-	{
-#ifdef LL_LITTLE_ENDIAN
-		S32 j, i;
-#else
-		S32 i, j;
-#endif
-	} n;
-} LLECO; // not sure what the name means
-
-#define LL_EXP_A (1048576 * OO_LN2) // use 1512775 for integer
-#define LL_EXP_C (60801)			// this value of C good for -4 < y < 4
-
-#define LL_FAST_EXP(y) (LLECO.n.i = llround(F32(LL_EXP_A*(y))) + (1072693248 - LL_EXP_C), LLECO.d)
-
-
-
-inline F32 llfastpow(const F32 x, const F32 y)
-{
-	return (F32)(LL_FAST_EXP(y * log(x)));
-}
-
-
-inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
-{
-	// compute the power of ten
-	F32 bar = 1.f;
-	for (S32 i = 0; i < sig_figs; i++)
-	{
-		bar *= 10.f;
-	}
-
-	//F32 new_foo = (F32)llround(foo * bar);
-	// the llround() implementation sucks.  Don't us it.
-
-	F32 sign = (foo > 0.f) ? 1.f : -1.f;
-	F32 new_foo = F32( S64(foo * bar + sign * 0.5f));
-	new_foo /= bar;
-
-	return new_foo;
-}
-
-inline F32 lerp(F32 a, F32 b, F32 u) 
-{
-	return a + ((b - a) * u);
-}
-
-inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)
-{
-	F32 a = x00 + (x01-x00)*u;
-	F32 b = x10 + (x11-x10)*u;
-	F32 r = a + (b-a)*v;
-	return r;
-}
-
-inline F32 ramp(F32 x, F32 a, F32 b)
-{
-	return (a == b) ? 0.0f : ((a - x) / (a - b));
-}
-
-inline F32 rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)
-{
-	return lerp(y1, y2, ramp(x, x1, x2));
-}
-
-inline F32 clamp_rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)
-{
-	if (y1 < y2)
-	{
-		return llclamp(rescale(x,x1,x2,y1,y2),y1,y2);
-	}
-	else
-	{
-		return llclamp(rescale(x,x1,x2,y1,y2),y2,y1);
-	}
-}
-
-
-inline F32 cubic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )
-{
-	if (x <= x0)
-		return s0;
-
-	if (x >= x1)
-		return s1;
-
-	F32 f = (x - x0) / (x1 - x0);
-
-	return	s0 + (s1 - s0) * (f * f) * (3.0f - 2.0f * f);
-}
-
-inline F32 cubic_step( F32 x )
-{
-	x = llclampf(x);
-
-	return	(x * x) * (3.0f - 2.0f * x);
-}
-
-inline F32 quadratic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )
-{
-	if (x <= x0)
-		return s0;
-
-	if (x >= x1)
-		return s1;
-
-	F32 f = (x - x0) / (x1 - x0);
-	F32 f_squared = f * f;
-
-	return	(s0 * (1.f - f_squared)) + ((s1 - s0) * f_squared);
-}
-
-inline F32 llsimple_angle(F32 angle)
-{
-	while(angle <= -F_PI)
-		angle += F_TWO_PI;
-	while(angle >  F_PI)
-		angle -= F_TWO_PI;
-	return angle;
-}
-
-//SDK - Renamed this to get_lower_power_two, since this is what this actually does.
-inline U32 get_lower_power_two(U32 val, U32 max_power_two)
-{
-	if(!max_power_two)
-	{
-		max_power_two = 1 << 31 ;
-	}
-	if(max_power_two & (max_power_two - 1))
-	{
-		return 0 ;
-	}
-
-	for(; val < max_power_two ; max_power_two >>= 1) ;
-	
-	return max_power_two ;
-}
-
-// calculate next highest power of two, limited by max_power_two
-// This is taken from a brilliant little code snipped on http://acius2.blogspot.com/2007/11/calculating-next-power-of-2.html
-// Basically we convert the binary to a solid string of 1's with the same
-// number of digits, then add one.  We subtract 1 initially to handle
-// the case where the number passed in is actually a power of two.
-// WARNING: this only works with 32 bit ints.
-inline U32 get_next_power_two(U32 val, U32 max_power_two)
-{
-	if(!max_power_two)
-	{
-		max_power_two = 1 << 31 ;
-	}
-
-	if(val >= max_power_two)
-	{
-		return max_power_two;
-	}
-
-	val--;
-	val = (val >> 1) | val;
-	val = (val >> 2) | val;
-	val = (val >> 4) | val;
-	val = (val >> 8) | val;
-	val = (val >> 16) | val;
-	val++;
-
-	return val;
-}
-
-//get the gaussian value given the linear distance from axis x and guassian value o
-inline F32 llgaussian(F32 x, F32 o)
-{
-	return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
-}
-
-// Include simd math header
-#include "llsimdmath.h"
-
-#endif
+/** 
+ * @file llmath.h
+ * @brief Useful math constants and macros.
+ *
+ * $LicenseInfo:firstyear=2000&license=viewergpl$
+ * 
+ * Copyright (c) 2000-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LLMATH_H
+#define LLMATH_H
+
+#include <cmath>
+#include <cstdlib>
+#include "lldefs.h"
+//#include "llstl.h" // *TODO: Remove when LLString is gone
+//#include "llstring.h" // *TODO: Remove when LLString is gone
+// lltut.h uses is_approx_equal_fraction(). This was moved to its own header
+// file in llcommon so we can use lltut.h for llcommon tests without making
+// llcommon depend on llmath.
+#include "is_approx_equal_fraction.h"
+
+// work around for Windows & older gcc non-standard function names.
+#if LL_WINDOWS
+#include <float.h>
+#define llisnan(val)	_isnan(val)
+#define llfinite(val)	_finite(val)
+#elif (LL_LINUX && __GNUC__ <= 2)
+#define llisnan(val)	isnan(val)
+#define llfinite(val)	isfinite(val)
+#elif LL_SOLARIS
+#define llisnan(val)    isnan(val)
+#define llfinite(val)   (val <= std::numeric_limits<double>::max())
+#else
+#define llisnan(val)	std::isnan(val)
+#define llfinite(val)	std::isfinite(val)
+#endif
+
+// Single Precision Floating Point Routines
+// (There used to be more defined here, but they appeared to be redundant and 
+// were breaking some other includes. Removed by Falcon, reviewed by Andrew, 11/25/09)
+/*#ifndef tanf
+#define tanf(x)		((F32)tan((F64)(x)))
+#endif*/
+
+const F32	GRAVITY			= -9.8f;
+
+// mathematical constants
+const F32	F_PI		= 3.1415926535897932384626433832795f;
+const F32	F_TWO_PI	= 6.283185307179586476925286766559f;
+const F32	F_PI_BY_TWO	= 1.5707963267948966192313216916398f;
+const F32	F_SQRT_TWO_PI = 2.506628274631000502415765284811f;
+const F32	F_E			= 2.71828182845904523536f;
+const F32	F_SQRT2		= 1.4142135623730950488016887242097f;
+const F32	F_SQRT3		= 1.73205080756888288657986402541f;
+const F32	OO_SQRT2	= 0.7071067811865475244008443621049f;
+const F32	DEG_TO_RAD	= 0.017453292519943295769236907684886f;
+const F32	RAD_TO_DEG	= 57.295779513082320876798154814105f;
+const F32	F_APPROXIMATELY_ZERO = 0.00001f;
+const F32	F_LN2		= 0.69314718056f;
+const F32	OO_LN2		= 1.4426950408889634073599246810019f;
+
+const F32	F_ALMOST_ZERO	= 0.0001f;
+const F32	F_ALMOST_ONE	= 1.0f - F_ALMOST_ZERO;
+
+// BUG: Eliminate in favor of F_APPROXIMATELY_ZERO above?
+const F32 FP_MAG_THRESHOLD = 0.0000001f;
+
+// TODO: Replace with logic like is_approx_equal
+inline BOOL is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f < F_APPROXIMATELY_ZERO); }
+
+// These functions work by interpreting sign+exp+mantissa as an unsigned
+// integer.
+// For example:
+// x = <sign>1 <exponent>00000010 <mantissa>00000000000000000000000
+// y = <sign>1 <exponent>00000001 <mantissa>11111111111111111111111
+//
+// interpreted as ints = 
+// x = 10000001000000000000000000000000
+// y = 10000000111111111111111111111111
+// which is clearly a different of 1 in the least significant bit
+// Values with the same exponent can be trivially shown to work.
+//
+// WARNING: Denormals of opposite sign do not work
+// x = <sign>1 <exponent>00000000 <mantissa>00000000000000000000001
+// y = <sign>0 <exponent>00000000 <mantissa>00000000000000000000001
+// Although these values differ by 2 in the LSB, the sign bit makes
+// the int comparison fail.
+//
+// WARNING: NaNs can compare equal
+// There is no special treatment of exceptional values like NaNs
+//
+// WARNING: Infinity is comparable with F32_MAX and negative 
+// infinity is comparable with F32_MIN
+
+inline BOOL is_approx_equal(F32 x, F32 y)
+{
+	const S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
+	return (std::abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
+}
+
+inline BOOL is_approx_equal(F64 x, F64 y)
+{
+	const S64 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
+	return (std::abs((S32) ((U64&)x - (U64&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
+}
+
+inline S32 llabs(const S32 a)
+{
+	return S32(std::labs(a));
+}
+
+inline F32 llabs(const F32 a)
+{
+	return F32(std::fabs(a));
+}
+
+inline F64 llabs(const F64 a)
+{
+	return F64(std::fabs(a));
+}
+
+inline S32 lltrunc( F32 f )
+{
+#if LL_WINDOWS && !defined( __INTEL_COMPILER )
+		// Avoids changing the floating point control word.
+		// Add or subtract 0.5 - epsilon and then round
+		const static U32 zpfp[] = { 0xBEFFFFFF, 0x3EFFFFFF };
+		S32 result;
+		__asm {
+			fld		f
+			mov		eax,	f
+			shr		eax,	29
+			and		eax,	4
+			fadd	dword ptr [zpfp + eax]
+			fistp	result
+		}
+		return result;
+#else
+		return (S32)f;
+#endif
+}
+
+inline S32 lltrunc( F64 f )
+{
+	return (S32)f;
+}
+
+inline S32 llfloor( F32 f )
+{
+#if LL_WINDOWS && !defined( __INTEL_COMPILER )
+		// Avoids changing the floating point control word.
+		// Accurate (unlike Stereopsis version) for all values between S32_MIN and S32_MAX and slightly faster than Stereopsis version.
+		// Add -(0.5 - epsilon) and then round
+		const U32 zpfp = 0xBEFFFFFF;
+		S32 result;
+		__asm { 
+			fld		f
+			fadd	dword ptr [zpfp]
+			fistp	result
+		}
+		return result;
+#else
+		return (S32)floor(f);
+#endif
+}
+
+
+inline S32 llceil( F32 f )
+{
+	// This could probably be optimized, but this works.
+	return (S32)ceil(f);
+}
+
+
+#ifndef BOGUS_ROUND
+// Use this round.  Does an arithmetic round (0.5 always rounds up)
+inline S32 llround(const F32 val)
+{
+	return llfloor(val + 0.5f);
+}
+
+#else // BOGUS_ROUND
+// Old llround implementation - does banker's round (toward nearest even in the case of a 0.5.
+// Not using this because we don't have a consistent implementation on both platforms, use
+// llfloor(val + 0.5f), which is consistent on all platforms.
+inline S32 llround(const F32 val)
+{
+	#if LL_WINDOWS
+		// Note: assumes that the floating point control word is set to rounding mode (the default)
+		S32 ret_val;
+		_asm fld	val
+		_asm fistp	ret_val;
+		return ret_val;
+	#elif LL_LINUX
+		// Note: assumes that the floating point control word is set
+		// to rounding mode (the default)
+		S32 ret_val;
+		__asm__ __volatile__( "flds %1    \n\t"
+							  "fistpl %0  \n\t"
+							  : "=m" (ret_val)
+							  : "m" (val) );
+		return ret_val;
+	#else
+		return llfloor(val + 0.5f);
+	#endif
+}
+
+// A fast arithmentic round on intel, from Laurent de Soras http://ldesoras.free.fr
+inline int round_int(double x)
+{
+	const float round_to_nearest = 0.5f;
+	int i;
+	__asm
+	{
+		fld x
+		fadd st, st (0)
+		fadd round_to_nearest
+		fistp i
+		sar i, 1
+	}
+	return (i);
+}
+#endif // BOGUS_ROUND
+
+inline F32 llround( F32 val, F32 nearest )
+{
+	return F32(floor(val * (1.0f / nearest) + 0.5f)) * nearest;
+}
+
+inline F64 llround( F64 val, F64 nearest )
+{
+	return F64(floor(val * (1.0 / nearest) + 0.5)) * nearest;
+}
+
+// these provide minimum peak error
+//
+// avg  error = -0.013049 
+// peak error = -31.4 dB
+// RMS  error = -28.1 dB
+
+const F32 FAST_MAG_ALPHA = 0.960433870103f;
+const F32 FAST_MAG_BETA = 0.397824734759f;
+
+// these provide minimum RMS error
+//
+// avg  error = 0.000003 
+// peak error = -32.6 dB
+// RMS  error = -25.7 dB
+//
+//const F32 FAST_MAG_ALPHA = 0.948059448969f;
+//const F32 FAST_MAG_BETA = 0.392699081699f;
+
+inline F32 fastMagnitude(F32 a, F32 b)
+{ 
+	a = (a > 0) ? a : -a;
+	b = (b > 0) ? b : -b;
+	return(FAST_MAG_ALPHA * llmax(a,b) + FAST_MAG_BETA * llmin(a,b));
+}
+
+
+
+////////////////////
+//
+// Fast F32/S32 conversions
+//
+// Culled from www.stereopsis.com/FPU.html
+
+const F64 LL_DOUBLE_TO_FIX_MAGIC	= 68719476736.0*1.5;     //2^36 * 1.5,  (52-_shiftamt=36) uses limited precisicion to floor
+const S32 LL_SHIFT_AMOUNT			= 16;                    //16.16 fixed point representation,
+
+// Endian dependent code
+#ifdef LL_LITTLE_ENDIAN
+	#define LL_EXP_INDEX				1
+	#define LL_MAN_INDEX				0
+#else
+	#define LL_EXP_INDEX				0
+	#define LL_MAN_INDEX				1
+#endif
+
+/* Deprecated: use llround(), lltrunc(), or llfloor() instead
+// ================================================================================================
+// Real2Int
+// ================================================================================================
+inline S32 F64toS32(F64 val)
+{
+	val		= val + LL_DOUBLE_TO_FIX_MAGIC;
+	return ((S32*)&val)[LL_MAN_INDEX] >> LL_SHIFT_AMOUNT; 
+}
+
+// ================================================================================================
+// Real2Int
+// ================================================================================================
+inline S32 F32toS32(F32 val)
+{
+	return F64toS32 ((F64)val);
+}
+*/
+
+////////////////////////////////////////////////
+//
+// Fast exp and log
+//
+
+// Implementation of fast exp() approximation (from a paper by Nicol N. Schraudolph
+// http://www.inf.ethz.ch/~schraudo/pubs/exp.pdf
+static union
+{
+	double d;
+	struct
+	{
+#ifdef LL_LITTLE_ENDIAN
+		S32 j, i;
+#else
+		S32 i, j;
+#endif
+	} n;
+} LLECO; // not sure what the name means
+
+#define LL_EXP_A (1048576 * OO_LN2) // use 1512775 for integer
+#define LL_EXP_C (60801)			// this value of C good for -4 < y < 4
+
+#define LL_FAST_EXP(y) (LLECO.n.i = llround(F32(LL_EXP_A*(y))) + (1072693248 - LL_EXP_C), LLECO.d)
+
+
+
+inline F32 llfastpow(const F32 x, const F32 y)
+{
+	return (F32)(LL_FAST_EXP(y * log(x)));
+}
+
+
+inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
+{
+	// compute the power of ten
+	F32 bar = 1.f;
+	for (S32 i = 0; i < sig_figs; i++)
+	{
+		bar *= 10.f;
+	}
+
+	//F32 new_foo = (F32)llround(foo * bar);
+	// the llround() implementation sucks.  Don't us it.
+
+	F32 sign = (foo > 0.f) ? 1.f : -1.f;
+	F32 new_foo = F32( S64(foo * bar + sign * 0.5f));
+	new_foo /= bar;
+
+	return new_foo;
+}
+
+inline F32 lerp(F32 a, F32 b, F32 u) 
+{
+	return a + ((b - a) * u);
+}
+
+inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)
+{
+	F32 a = x00 + (x01-x00)*u;
+	F32 b = x10 + (x11-x10)*u;
+	F32 r = a + (b-a)*v;
+	return r;
+}
+
+inline F32 ramp(F32 x, F32 a, F32 b)
+{
+	return (a == b) ? 0.0f : ((a - x) / (a - b));
+}
+
+inline F32 rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)
+{
+	return lerp(y1, y2, ramp(x, x1, x2));
+}
+
+inline F32 clamp_rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)
+{
+	if (y1 < y2)
+	{
+		return llclamp(rescale(x,x1,x2,y1,y2),y1,y2);
+	}
+	else
+	{
+		return llclamp(rescale(x,x1,x2,y1,y2),y2,y1);
+	}
+}
+
+
+inline F32 cubic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )
+{
+	if (x <= x0)
+		return s0;
+
+	if (x >= x1)
+		return s1;
+
+	F32 f = (x - x0) / (x1 - x0);
+
+	return	s0 + (s1 - s0) * (f * f) * (3.0f - 2.0f * f);
+}
+
+inline F32 cubic_step( F32 x )
+{
+	x = llclampf(x);
+
+	return	(x * x) * (3.0f - 2.0f * x);
+}
+
+inline F32 quadratic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )
+{
+	if (x <= x0)
+		return s0;
+
+	if (x >= x1)
+		return s1;
+
+	F32 f = (x - x0) / (x1 - x0);
+	F32 f_squared = f * f;
+
+	return	(s0 * (1.f - f_squared)) + ((s1 - s0) * f_squared);
+}
+
+inline F32 llsimple_angle(F32 angle)
+{
+	while(angle <= -F_PI)
+		angle += F_TWO_PI;
+	while(angle >  F_PI)
+		angle -= F_TWO_PI;
+	return angle;
+}
+
+//SDK - Renamed this to get_lower_power_two, since this is what this actually does.
+inline U32 get_lower_power_two(U32 val, U32 max_power_two)
+{
+	if(!max_power_two)
+	{
+		max_power_two = 1 << 31 ;
+	}
+	if(max_power_two & (max_power_two - 1))
+	{
+		return 0 ;
+	}
+
+	for(; val < max_power_two ; max_power_two >>= 1) ;
+	
+	return max_power_two ;
+}
+
+// calculate next highest power of two, limited by max_power_two
+// This is taken from a brilliant little code snipped on http://acius2.blogspot.com/2007/11/calculating-next-power-of-2.html
+// Basically we convert the binary to a solid string of 1's with the same
+// number of digits, then add one.  We subtract 1 initially to handle
+// the case where the number passed in is actually a power of two.
+// WARNING: this only works with 32 bit ints.
+inline U32 get_next_power_two(U32 val, U32 max_power_two)
+{
+	if(!max_power_two)
+	{
+		max_power_two = 1 << 31 ;
+	}
+
+	if(val >= max_power_two)
+	{
+		return max_power_two;
+	}
+
+	val--;
+	val = (val >> 1) | val;
+	val = (val >> 2) | val;
+	val = (val >> 4) | val;
+	val = (val >> 8) | val;
+	val = (val >> 16) | val;
+	val++;
+
+	return val;
+}
+
+//get the gaussian value given the linear distance from axis x and guassian value o
+inline F32 llgaussian(F32 x, F32 o)
+{
+	return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
+}
+
+// Include simd math header
+#include "llsimdmath.h"
+
+#endif
diff --git a/indra/llmath/llquantize.h b/indra/llmath/llquantize.h
index 000d8a060fe..c043f7f7525 100644
--- a/indra/llmath/llquantize.h
+++ b/indra/llmath/llquantize.h
@@ -1,158 +1,158 @@
-/** 
- * @file llquantize.h
- * @brief useful routines for quantizing floats to various length ints
- * and back out again
- *
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- * 
- * Copyright (c) 2001-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLQUANTIZE_H
-#define LL_LLQUANTIZE_H
-
-const U16 U16MAX = 65535;
-LL_ALIGN_16( const F32 F_U16MAX_4A[4] ) = { 65535.f, 65535.f, 65535.f, 65535.f };
-
-const F32 OOU16MAX = 1.f/(F32)(U16MAX);
-LL_ALIGN_16( const F32 F_OOU16MAX_4A[4] ) = { OOU16MAX, OOU16MAX, OOU16MAX, OOU16MAX };
-
-const U8 U8MAX = 255;
-LL_ALIGN_16( const F32 F_U8MAX_4A[4] ) = { 255.f, 255.f, 255.f, 255.f };
-
-const F32 OOU8MAX = 1.f/(F32)(U8MAX);
-LL_ALIGN_16( const F32 F_OOU8MAX_4A[4] ) = { OOU8MAX, OOU8MAX, OOU8MAX, OOU8MAX };
-
-const U8 FIRSTVALIDCHAR = 54;
-const U8 MAXSTRINGVAL = U8MAX - FIRSTVALIDCHAR; //we don't allow newline or null 
-
-
-inline U16 F32_to_U16_ROUND(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper);
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;
-	val /= (upper - lower);
-
-	// round the value.   Sreturn the U16
-	return (U16)(llround(val*U16MAX));
-}
-
-
-inline U16 F32_to_U16(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper);
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;
-	val /= (upper - lower);
-
-	// return the U16
-	return (U16)(llfloor(val*U16MAX));
-}
-
-inline F32 U16_to_F32(U16 ival, F32 lower, F32 upper)
-{
-	F32 val = ival*OOU16MAX;
-	F32 delta = (upper - lower);
-	val *= delta;
-	val += lower;
-
-	F32 max_error = delta*OOU16MAX;
-
-	// make sure that zero's come through as zero
-	if (fabsf(val) < max_error)
-		val = 0.f;
-
-	return val;
-}
-
-
-inline U8 F32_to_U8_ROUND(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper);
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;
-	val /= (upper - lower);
-
-	// return the rounded U8
-	return (U8)(llround(val*U8MAX));
-}
-
-
-inline U8 F32_to_U8(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper);
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;
-	val /= (upper - lower);
-
-	// return the U8
-	return (U8)(llfloor(val*U8MAX));
-}
-
-inline F32 U8_to_F32(U8 ival, F32 lower, F32 upper)
-{
-	F32 val = ival*OOU8MAX;
-	F32 delta = (upper - lower);
-	val *= delta;
-	val += lower;
-
-	F32 max_error = delta*OOU8MAX;
-
-	// make sure that zero's come through as zero
-	if (fabsf(val) < max_error)
-		val = 0.f;
-
-	return val;
-}
-
-inline U8 F32_TO_STRING(F32 val, F32 lower, F32 upper)
-{
-	val = llclamp(val, lower, upper); //[lower, upper]
-	// make sure that the value is positive and normalized to <0, 1>
-	val -= lower;					//[0, upper-lower]
-	val /= (upper - lower);			//[0,1]
-	val = val * MAXSTRINGVAL;		//[0, MAXSTRINGVAL]
-	val = floor(val + 0.5f);		//[0, MAXSTRINGVAL]
-
-	U8 stringVal = (U8)(val) + FIRSTVALIDCHAR;			//[FIRSTVALIDCHAR, MAXSTRINGVAL + FIRSTVALIDCHAR]
-	return stringVal;
-}
-
-inline F32 STRING_TO_F32(U8 ival, F32 lower, F32 upper)
-{
-	// remove empty space left for NULL, newline, etc.
-	ival -= FIRSTVALIDCHAR;								//[0, MAXSTRINGVAL]
-
-	F32 val = (F32)ival * (1.f / (F32)MAXSTRINGVAL);	//[0, 1]
-	F32 delta = (upper - lower);
-	val *= delta;										//[0, upper - lower]
-	val += lower;										//[lower, upper]
-
-	return val;
-}
-
-#endif
+/** 
+ * @file llquantize.h
+ * @brief useful routines for quantizing floats to various length ints
+ * and back out again
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLQUANTIZE_H
+#define LL_LLQUANTIZE_H
+
+const U16 U16MAX = 65535;
+LL_ALIGN_16( const F32 F_U16MAX_4A[4] ) = { 65535.f, 65535.f, 65535.f, 65535.f };
+
+const F32 OOU16MAX = 1.f/(F32)(U16MAX);
+LL_ALIGN_16( const F32 F_OOU16MAX_4A[4] ) = { OOU16MAX, OOU16MAX, OOU16MAX, OOU16MAX };
+
+const U8 U8MAX = 255;
+LL_ALIGN_16( const F32 F_U8MAX_4A[4] ) = { 255.f, 255.f, 255.f, 255.f };
+
+const F32 OOU8MAX = 1.f/(F32)(U8MAX);
+LL_ALIGN_16( const F32 F_OOU8MAX_4A[4] ) = { OOU8MAX, OOU8MAX, OOU8MAX, OOU8MAX };
+
+const U8 FIRSTVALIDCHAR = 54;
+const U8 MAXSTRINGVAL = U8MAX - FIRSTVALIDCHAR; //we don't allow newline or null 
+
+
+inline U16 F32_to_U16_ROUND(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper);
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;
+	val /= (upper - lower);
+
+	// round the value.   Sreturn the U16
+	return (U16)(llround(val*U16MAX));
+}
+
+
+inline U16 F32_to_U16(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper);
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;
+	val /= (upper - lower);
+
+	// return the U16
+	return (U16)(llfloor(val*U16MAX));
+}
+
+inline F32 U16_to_F32(U16 ival, F32 lower, F32 upper)
+{
+	F32 val = ival*OOU16MAX;
+	F32 delta = (upper - lower);
+	val *= delta;
+	val += lower;
+
+	F32 max_error = delta*OOU16MAX;
+
+	// make sure that zero's come through as zero
+	if (fabsf(val) < max_error)
+		val = 0.f;
+
+	return val;
+}
+
+
+inline U8 F32_to_U8_ROUND(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper);
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;
+	val /= (upper - lower);
+
+	// return the rounded U8
+	return (U8)(llround(val*U8MAX));
+}
+
+
+inline U8 F32_to_U8(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper);
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;
+	val /= (upper - lower);
+
+	// return the U8
+	return (U8)(llfloor(val*U8MAX));
+}
+
+inline F32 U8_to_F32(U8 ival, F32 lower, F32 upper)
+{
+	F32 val = ival*OOU8MAX;
+	F32 delta = (upper - lower);
+	val *= delta;
+	val += lower;
+
+	F32 max_error = delta*OOU8MAX;
+
+	// make sure that zero's come through as zero
+	if (fabsf(val) < max_error)
+		val = 0.f;
+
+	return val;
+}
+
+inline U8 F32_TO_STRING(F32 val, F32 lower, F32 upper)
+{
+	val = llclamp(val, lower, upper); //[lower, upper]
+	// make sure that the value is positive and normalized to <0, 1>
+	val -= lower;					//[0, upper-lower]
+	val /= (upper - lower);			//[0,1]
+	val = val * MAXSTRINGVAL;		//[0, MAXSTRINGVAL]
+	val = floor(val + 0.5f);		//[0, MAXSTRINGVAL]
+
+	U8 stringVal = (U8)(val) + FIRSTVALIDCHAR;			//[FIRSTVALIDCHAR, MAXSTRINGVAL + FIRSTVALIDCHAR]
+	return stringVal;
+}
+
+inline F32 STRING_TO_F32(U8 ival, F32 lower, F32 upper)
+{
+	// remove empty space left for NULL, newline, etc.
+	ival -= FIRSTVALIDCHAR;								//[0, MAXSTRINGVAL]
+
+	F32 val = (F32)ival * (1.f / (F32)MAXSTRINGVAL);	//[0, 1]
+	F32 delta = (upper - lower);
+	val *= delta;										//[0, upper - lower]
+	val += lower;										//[lower, upper]
+
+	return val;
+}
+
+#endif
diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp
index efdc10e2c62..73c5f4505eb 100644
--- a/indra/llmath/llquaternion.cpp
+++ b/indra/llmath/llquaternion.cpp
@@ -1,961 +1,961 @@
-/** 
- * @file llquaternion.cpp
- * @brief LLQuaternion class implementation.
- *
- * $LicenseInfo:firstyear=2000&license=viewergpl$
- * 
- * Copyright (c) 2000-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "llmath.h"	// for F_PI
-
-#include "llquaternion.h"
-
-//#include "vmath.h"
-#include "v3math.h"
-#include "v3dmath.h"
-#include "v4math.h"
-#include "m4math.h"
-#include "m3math.h"
-#include "llquantize.h"
-
-// WARNING: Don't use this for global const definitions!  using this
-// at the top of a *.cpp file might not give you what you think.
-const LLQuaternion LLQuaternion::DEFAULT;
- 
-// Constructors
-
-LLQuaternion::LLQuaternion(const LLMatrix4 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-}
-
-LLQuaternion::LLQuaternion(const LLMatrix3 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-}
-
-LLQuaternion::LLQuaternion(F32 angle, const LLVector4 &vec)
-{
-	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
-	v.normalize();
-
-	F32 c, s;
-	c = cosf(angle*0.5f);
-	s = sinf(angle*0.5f);
-
-	mQ[VX] = v.mV[VX] * s;
-	mQ[VY] = v.mV[VY] * s;
-	mQ[VZ] = v.mV[VZ] * s;
-	mQ[VW] = c;
-	normalize();
-}
-
-LLQuaternion::LLQuaternion(F32 angle, const LLVector3 &vec)
-{
-	LLVector3 v(vec);
-	v.normalize();
-
-	F32 c, s;
-	c = cosf(angle*0.5f);
-	s = sinf(angle*0.5f);
-
-	mQ[VX] = v.mV[VX] * s;
-	mQ[VY] = v.mV[VY] * s;
-	mQ[VZ] = v.mV[VZ] * s;
-	mQ[VW] = c;
-	normalize();
-}
-
-LLQuaternion::LLQuaternion(const LLVector3 &x_axis,
-						   const LLVector3 &y_axis,
-						   const LLVector3 &z_axis)
-{
-	LLMatrix3 mat;
-	mat.setRows(x_axis, y_axis, z_axis);
-	*this = mat.quaternion();
-	normalize();
-}
-
-// Quatizations
-void	LLQuaternion::quantize16(F32 lower, F32 upper)
-{
-	F32 x = mQ[VX];
-	F32 y = mQ[VY];
-	F32 z = mQ[VZ];
-	F32 s = mQ[VS];
-
-	x = U16_to_F32(F32_to_U16_ROUND(x, lower, upper), lower, upper);
-	y = U16_to_F32(F32_to_U16_ROUND(y, lower, upper), lower, upper);
-	z = U16_to_F32(F32_to_U16_ROUND(z, lower, upper), lower, upper);
-	s = U16_to_F32(F32_to_U16_ROUND(s, lower, upper), lower, upper);
-
-	mQ[VX] = x;
-	mQ[VY] = y;
-	mQ[VZ] = z;
-	mQ[VS] = s;
-
-	normalize();
-}
-
-void	LLQuaternion::quantize8(F32 lower, F32 upper)
-{
-	mQ[VX] = U8_to_F32(F32_to_U8_ROUND(mQ[VX], lower, upper), lower, upper);
-	mQ[VY] = U8_to_F32(F32_to_U8_ROUND(mQ[VY], lower, upper), lower, upper);
-	mQ[VZ] = U8_to_F32(F32_to_U8_ROUND(mQ[VZ], lower, upper), lower, upper);
-	mQ[VS] = U8_to_F32(F32_to_U8_ROUND(mQ[VS], lower, upper), lower, upper);
-
-	normalize();
-}
-
-// LLVector3 Magnitude and Normalization Functions
-
-
-// Set LLQuaternion routines
-
-const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, F32 x, F32 y, F32 z)
-{
-	LLVector3 vec(x, y, z);
-	vec.normalize();
-
-	angle *= 0.5f;
-	F32 c, s;
-	c = cosf(angle);
-	s = sinf(angle);
-
-	mQ[VX] = vec.mV[VX]*s;
-	mQ[VY] = vec.mV[VY]*s;
-	mQ[VZ] = vec.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, const LLVector3 &vec)
-{
-	LLVector3 v(vec);
-	v.normalize();
-
-	angle *= 0.5f;
-	F32 c, s;
-	c = cosf(angle);
-	s = sinf(angle);
-
-	mQ[VX] = v.mV[VX]*s;
-	mQ[VY] = v.mV[VY]*s;
-	mQ[VZ] = v.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, const LLVector4 &vec)
-{
-	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
-	v.normalize();
-
-	F32 c, s;
-	c = cosf(angle*0.5f);
-	s = sinf(angle*0.5f);
-
-	mQ[VX] = v.mV[VX]*s;
-	mQ[VY] = v.mV[VY]*s;
-	mQ[VZ] = v.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setEulerAngles(F32 roll, F32 pitch, F32 yaw)
-{
-	LLMatrix3 rot_mat(roll, pitch, yaw);
-	rot_mat.orthogonalize();
-	*this = rot_mat.quaternion();
-		
-	normalize();
-	return (*this);
-}
-
-// deprecated
-const LLQuaternion&	LLQuaternion::set(const LLMatrix3 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-	return (*this);
-}
-
-// deprecated
-const LLQuaternion&	LLQuaternion::set(const LLMatrix4 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-	return (*this);
-}
-
-// deprecated
-const LLQuaternion&	LLQuaternion::setQuat(F32 angle, F32 x, F32 y, F32 z)
-{
-	LLVector3 vec(x, y, z);
-	vec.normalize();
-
-	angle *= 0.5f;
-	F32 c, s;
-	c = cosf(angle);
-	s = sinf(angle);
-
-	mQ[VX] = vec.mV[VX]*s;
-	mQ[VY] = vec.mV[VY]*s;
-	mQ[VZ] = vec.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-// deprecated
-const LLQuaternion&	LLQuaternion::setQuat(F32 angle, const LLVector3 &vec)
-{
-	LLVector3 v(vec);
-	v.normalize();
-
-	angle *= 0.5f;
-	F32 c, s;
-	c = cosf(angle);
-	s = sinf(angle);
-
-	mQ[VX] = v.mV[VX]*s;
-	mQ[VY] = v.mV[VY]*s;
-	mQ[VZ] = v.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setQuat(F32 angle, const LLVector4 &vec)
-{
-	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
-	v.normalize();
-
-	F32 c, s;
-	c = cosf(angle*0.5f);
-	s = sinf(angle*0.5f);
-
-	mQ[VX] = v.mV[VX]*s;
-	mQ[VY] = v.mV[VY]*s;
-	mQ[VZ] = v.mV[VZ]*s;
-	mQ[VW] = c;
-
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setQuat(F32 roll, F32 pitch, F32 yaw)
-{
-	LLMatrix3 rot_mat(roll, pitch, yaw);
-	rot_mat.orthogonalize();
-	*this = rot_mat.quaternion();
-		
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setQuat(const LLMatrix3 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-	return (*this);
-}
-
-const LLQuaternion&	LLQuaternion::setQuat(const LLMatrix4 &mat)
-{
-	*this = mat.quaternion();
-	normalize();
-	return (*this);
-//#if 1
-//	// NOTE: LLQuaternion's are actually inverted with respect to
-//	// the matrices, so this code also assumes inverted quaternions
-//	// (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
-//	// in reverse order (yaw,pitch,roll).
-//	F64 cosX = cos(roll);
-//    F64 cosY = cos(pitch);
-//    F64 cosZ = cos(yaw);
-//
-//    F64 sinX = sin(roll);
-//    F64 sinY = sin(pitch);
-//    F64 sinZ = sin(yaw);
-//
-//    mQ[VW] = (F32)sqrt(cosY*cosZ - sinX*sinY*sinZ + cosX*cosZ + cosX*cosY + 1.0)*.5;
-//	if (fabs(mQ[VW]) < F_APPROXIMATELY_ZERO)
-//	{
-//		// null rotation, any axis will do
-//		mQ[VX] = 0.0f;
-//		mQ[VY] = 1.0f;
-//		mQ[VZ] = 0.0f;
-//	}
-//	else
-//	{
-//		F32 inv_s = 1.0f / (4.0f * mQ[VW]);
-//		mQ[VX] = (F32)-(-sinX*cosY - cosX*sinY*sinZ - sinX*cosZ) * inv_s;
-//		mQ[VY] = (F32)-(-cosX*sinY*cosZ + sinX*sinZ - sinY) * inv_s;
-//		mQ[VZ] = (F32)-(-cosY*sinZ - sinX*sinY*cosZ - cosX*sinZ) * inv_s;		
-//	}
-//
-//#else // This only works on a certain subset of roll/pitch/yaw
-//	
-//	F64 cosX = cosf(roll/2.0);
-//    F64 cosY = cosf(pitch/2.0);
-//    F64 cosZ = cosf(yaw/2.0);
-//
-//    F64 sinX = sinf(roll/2.0);
-//    F64 sinY = sinf(pitch/2.0);
-//    F64 sinZ = sinf(yaw/2.0);
-//
-//    mQ[VW] = (F32)(cosX*cosY*cosZ + sinX*sinY*sinZ);
-//    mQ[VX] = (F32)(sinX*cosY*cosZ - cosX*sinY*sinZ);
-//    mQ[VY] = (F32)(cosX*sinY*cosZ + sinX*cosY*sinZ);
-//    mQ[VZ] = (F32)(cosX*cosY*sinZ - sinX*sinY*cosZ);
-//#endif
-//
-//	normalize();
-//	return (*this);
-}
-
-// SJB: This code is correct for a logicly stored (non-transposed) matrix;
-//		Our matrices are stored transposed, OpenGL style, so this generates the
-//		INVERSE matrix, or the CORRECT matrix form an INVERSE quaternion.
-//		Because we use similar logic in LLMatrix3::quaternion(),
-//		we are internally consistant so everything works OK :)
-LLMatrix3	LLQuaternion::getMatrix3(void) const
-{
-	LLMatrix3	mat;
-	F32		xx, xy, xz, xw, yy, yz, yw, zz, zw;
-
-    xx      = mQ[VX] * mQ[VX];
-    xy      = mQ[VX] * mQ[VY];
-    xz      = mQ[VX] * mQ[VZ];
-    xw      = mQ[VX] * mQ[VW];
-
-    yy      = mQ[VY] * mQ[VY];
-    yz      = mQ[VY] * mQ[VZ];
-    yw      = mQ[VY] * mQ[VW];
-
-    zz      = mQ[VZ] * mQ[VZ];
-    zw      = mQ[VZ] * mQ[VW];
-
-    mat.mMatrix[0][0]  = 1.f - 2.f * ( yy + zz );
-    mat.mMatrix[0][1]  =	   2.f * ( xy + zw );
-    mat.mMatrix[0][2]  =	   2.f * ( xz - yw );
-
-    mat.mMatrix[1][0]  =	   2.f * ( xy - zw );
-    mat.mMatrix[1][1]  = 1.f - 2.f * ( xx + zz );
-    mat.mMatrix[1][2]  =	   2.f * ( yz + xw );
-
-    mat.mMatrix[2][0]  =	   2.f * ( xz + yw );
-    mat.mMatrix[2][1]  =	   2.f * ( yz - xw );
-    mat.mMatrix[2][2]  = 1.f - 2.f * ( xx + yy );
-
-	return mat;
-}
-
-LLMatrix4	LLQuaternion::getMatrix4(void) const
-{
-	LLMatrix4	mat;
-	F32		xx, xy, xz, xw, yy, yz, yw, zz, zw;
-
-    xx      = mQ[VX] * mQ[VX];
-    xy      = mQ[VX] * mQ[VY];
-    xz      = mQ[VX] * mQ[VZ];
-    xw      = mQ[VX] * mQ[VW];
-
-    yy      = mQ[VY] * mQ[VY];
-    yz      = mQ[VY] * mQ[VZ];
-    yw      = mQ[VY] * mQ[VW];
-
-    zz      = mQ[VZ] * mQ[VZ];
-    zw      = mQ[VZ] * mQ[VW];
-
-    mat.mMatrix[0][0]  = 1.f - 2.f * ( yy + zz );
-    mat.mMatrix[0][1]  =	   2.f * ( xy + zw );
-    mat.mMatrix[0][2]  =	   2.f * ( xz - yw );
-
-    mat.mMatrix[1][0]  =	   2.f * ( xy - zw );
-    mat.mMatrix[1][1]  = 1.f - 2.f * ( xx + zz );
-    mat.mMatrix[1][2]  =	   2.f * ( yz + xw );
-
-    mat.mMatrix[2][0]  =	   2.f * ( xz + yw );
-    mat.mMatrix[2][1]  =	   2.f * ( yz - xw );
-    mat.mMatrix[2][2]  = 1.f - 2.f * ( xx + yy );
-
-	// TODO -- should we set the translation portion to zero?
-
-	return mat;
-}
-
-
-
-
-// Other useful methods
-
-
-// calculate the shortest rotation from a to b
-void LLQuaternion::shortestArc(const LLVector3 &a, const LLVector3 &b)
-{
-	// Make a local copy of both vectors.
-	LLVector3 vec_a = a;
-	LLVector3 vec_b = b;
-
-	// Make sure neither vector is zero length.  Also normalize
-	// the vectors while we are at it.
-	F32 vec_a_mag = vec_a.normalize();
-	F32 vec_b_mag = vec_b.normalize();
-	if (vec_a_mag < F_APPROXIMATELY_ZERO ||
-		vec_b_mag < F_APPROXIMATELY_ZERO)
-	{
-		// Can't calculate a rotation from this.
-		// Just return ZERO_ROTATION instead.
-		loadIdentity();
-		return;
-	}
-
-	// Create an axis to rotate around, and the cos of the angle to rotate.
-	LLVector3 axis = vec_a % vec_b;
-	F32 cos_theta  = vec_a * vec_b;
-
-	// Check the angle between the vectors to see if they are parallel or anti-parallel.
-	if (cos_theta > 1.0 - F_APPROXIMATELY_ZERO)
-	{
-		// a and b are parallel.  No rotation is necessary.
-		loadIdentity();
-	}
-	else if (cos_theta < -1.0 + F_APPROXIMATELY_ZERO)
-	{
-		// a and b are anti-parallel.
-		// Rotate 180 degrees around some orthogonal axis.
-		// Find the projection of the x-axis onto a, and try
-		// using the vector between the projection and the x-axis
-		// as the orthogonal axis.
-		LLVector3 proj = vec_a.mV[VX] / (vec_a * vec_a) * vec_a;
-		LLVector3 ortho_axis(1.f, 0.f, 0.f);
-		ortho_axis -= proj;
-		
-		// Turn this into an orthonormal axis.
-		F32 ortho_length = ortho_axis.normalize();
-		// If the axis' length is 0, then our guess at an orthogonal axis
-		// was wrong (a is parallel to the x-axis).
-		if (ortho_length < F_APPROXIMATELY_ZERO)
-		{
-			// Use the z-axis instead.
-			ortho_axis.setVec(0.f, 0.f, 1.f);
-		}
-
-		// Construct a quaternion from this orthonormal axis.
-		mQ[VX] = ortho_axis.mV[VX];
-		mQ[VY] = ortho_axis.mV[VY];
-		mQ[VZ] = ortho_axis.mV[VZ];
-		mQ[VW] = 0.f;
-	}
-	else
-	{
-		// a and b are NOT parallel or anti-parallel.
-		// Return the rotation between these vectors.
-		F32 theta = (F32)acos(cos_theta);
-
-		setAngleAxis(theta, axis);
-	}
-}
-
-// constrains rotation to a cone angle specified in radians
-const LLQuaternion &LLQuaternion::constrain(F32 radians)
-{
-	const F32 cos_angle_lim = cosf( radians/2 );	// mQ[VW] limit
-	const F32 sin_angle_lim = sinf( radians/2 );	// rotation axis length	limit
-
-	if (mQ[VW] < 0.f)
-	{
-		mQ[VX] *= -1.f;
-		mQ[VY] *= -1.f;
-		mQ[VZ] *= -1.f;
-		mQ[VW] *= -1.f;
-	}
-
-	// if rotation angle is greater than limit (cos is less than limit)
-	if( mQ[VW] < cos_angle_lim )
-	{
-		mQ[VW] = cos_angle_lim;
-		F32 axis_len = sqrtf( mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] ); // sin(theta/2)
-		F32 axis_mult_fact = sin_angle_lim / axis_len;
-		mQ[VX] *= axis_mult_fact;
-		mQ[VY] *= axis_mult_fact;
-		mQ[VZ] *= axis_mult_fact;
-	}
-
-	return *this;
-}
-
-// Operators
-
-std::ostream& operator<<(std::ostream &s, const LLQuaternion &a)
-{
-	s << "{ " 
-		<< a.mQ[VX] << ", " << a.mQ[VY] << ", " << a.mQ[VZ] << ", " << a.mQ[VW] 
-	<< " }";
-	return s;
-}
-
-
-// Does NOT renormalize the result
-LLQuaternion	operator*(const LLQuaternion &a, const LLQuaternion &b)
-{
-//	LLQuaternion::mMultCount++;
-
-	LLQuaternion q(
-		b.mQ[3] * a.mQ[0] + b.mQ[0] * a.mQ[3] + b.mQ[1] * a.mQ[2] - b.mQ[2] * a.mQ[1],
-		b.mQ[3] * a.mQ[1] + b.mQ[1] * a.mQ[3] + b.mQ[2] * a.mQ[0] - b.mQ[0] * a.mQ[2],
-		b.mQ[3] * a.mQ[2] + b.mQ[2] * a.mQ[3] + b.mQ[0] * a.mQ[1] - b.mQ[1] * a.mQ[0],
-		b.mQ[3] * a.mQ[3] - b.mQ[0] * a.mQ[0] - b.mQ[1] * a.mQ[1] - b.mQ[2] * a.mQ[2]
-	);
-	return q;
-}
-
-/*
-LLMatrix4	operator*(const LLMatrix4 &m, const LLQuaternion &q)
-{
-	LLMatrix4 qmat(q);
-	return (m*qmat);
-}
-*/
-
-
-
-LLVector4		operator*(const LLVector4 &a, const LLQuaternion &rot)
-{
-    F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
-    F32 rx =   rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
-    F32 ry =   rot.mQ[VW] * a.mV[VY] + rot.mQ[VZ] * a.mV[VX] - rot.mQ[VX] * a.mV[VZ];
-    F32 rz =   rot.mQ[VW] * a.mV[VZ] + rot.mQ[VX] * a.mV[VY] - rot.mQ[VY] * a.mV[VX];
-
-    F32 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
-    F32 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
-    F32 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
-
-    return LLVector4(nx, ny, nz, a.mV[VW]);
-}
-
-LLVector3		operator*(const LLVector3 &a, const LLQuaternion &rot)
-{
-    F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
-    F32 rx =   rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
-    F32 ry =   rot.mQ[VW] * a.mV[VY] + rot.mQ[VZ] * a.mV[VX] - rot.mQ[VX] * a.mV[VZ];
-    F32 rz =   rot.mQ[VW] * a.mV[VZ] + rot.mQ[VX] * a.mV[VY] - rot.mQ[VY] * a.mV[VX];
-
-    F32 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
-    F32 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
-    F32 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
-
-    return LLVector3(nx, ny, nz);
-}
-
-LLVector3d		operator*(const LLVector3d &a, const LLQuaternion &rot)
-{
-    F64 rw = - rot.mQ[VX] * a.mdV[VX] - rot.mQ[VY] * a.mdV[VY] - rot.mQ[VZ] * a.mdV[VZ];
-    F64 rx =   rot.mQ[VW] * a.mdV[VX] + rot.mQ[VY] * a.mdV[VZ] - rot.mQ[VZ] * a.mdV[VY];
-    F64 ry =   rot.mQ[VW] * a.mdV[VY] + rot.mQ[VZ] * a.mdV[VX] - rot.mQ[VX] * a.mdV[VZ];
-    F64 rz =   rot.mQ[VW] * a.mdV[VZ] + rot.mQ[VX] * a.mdV[VY] - rot.mQ[VY] * a.mdV[VX];
-
-    F64 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
-    F64 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
-    F64 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
-
-    return LLVector3d(nx, ny, nz);
-}
-
-F32 dot(const LLQuaternion &a, const LLQuaternion &b)
-{
-	return a.mQ[VX] * b.mQ[VX] + 
-		   a.mQ[VY] * b.mQ[VY] + 
-		   a.mQ[VZ] * b.mQ[VZ] + 
-		   a.mQ[VW] * b.mQ[VW]; 
-}
-
-// DEMO HACK: This lerp is probably inocrrect now due intermediate normalization
-// it should look more like the lerp below
-#if 0
-// linear interpolation
-LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q)
-{
-	LLQuaternion r;
-	r = t * (q - p) + p;
-	r.normalize();
-	return r;
-}
-#endif
-
-// lerp from identity to q
-LLQuaternion lerp(F32 t, const LLQuaternion &q)
-{
-	LLQuaternion r;
-	r.mQ[VX] = t * q.mQ[VX];
-	r.mQ[VY] = t * q.mQ[VY];
-	r.mQ[VZ] = t * q.mQ[VZ];
-	r.mQ[VW] = t * (q.mQ[VZ] - 1.f) + 1.f;
-	r.normalize();
-	return r;
-}
-
-LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q)
-{
-	LLQuaternion r;
-	F32 inv_t;
-
-	inv_t = 1.f - t;
-
-	r.mQ[VX] = t * q.mQ[VX] + (inv_t * p.mQ[VX]);
-	r.mQ[VY] = t * q.mQ[VY] + (inv_t * p.mQ[VY]);
-	r.mQ[VZ] = t * q.mQ[VZ] + (inv_t * p.mQ[VZ]);
-	r.mQ[VW] = t * q.mQ[VW] + (inv_t * p.mQ[VW]);
-	r.normalize();
-	return r;
-}
-
-
-// spherical linear interpolation
-LLQuaternion slerp( F32 u, const LLQuaternion &a, const LLQuaternion &b )
-{
-	// cosine theta = dot product of a and b
-	F32 cos_t = a.mQ[0]*b.mQ[0] + a.mQ[1]*b.mQ[1] + a.mQ[2]*b.mQ[2] + a.mQ[3]*b.mQ[3];
-	
-	// if b is on opposite hemisphere from a, use -a instead
-	int bflip;
- 	if (cos_t < 0.0f)
-	{
-		cos_t = -cos_t;
-		bflip = TRUE;
-	}
-	else
-		bflip = FALSE;
-
-	// if B is (within precision limits) the same as A,
-	// just linear interpolate between A and B.
-	F32 alpha;	// interpolant
-	F32 beta;		// 1 - interpolant
-	if (1.0f - cos_t < 0.00001f)
-	{
-		beta = 1.0f - u;
-		alpha = u;
- 	}
-	else
-	{
- 		F32 theta = acosf(cos_t);
- 		F32 sin_t = sinf(theta);
- 		beta = sinf(theta - u*theta) / sin_t;
- 		alpha = sinf(u*theta) / sin_t;
- 	}
-
-	if (bflip)
-		beta = -beta;
-
-	// interpolate
-	LLQuaternion ret;
-	ret.mQ[0] = beta*a.mQ[0] + alpha*b.mQ[0];
- 	ret.mQ[1] = beta*a.mQ[1] + alpha*b.mQ[1];
- 	ret.mQ[2] = beta*a.mQ[2] + alpha*b.mQ[2];
- 	ret.mQ[3] = beta*a.mQ[3] + alpha*b.mQ[3];
-
-	return ret;
-}
-
-// lerp whenever possible
-LLQuaternion nlerp(F32 t, const LLQuaternion &a, const LLQuaternion &b)
-{
-	if (dot(a, b) < 0.f)
-	{
-		return slerp(t, a, b);
-	}
-	else
-	{
-		return lerp(t, a, b);
-	}
-}
-
-LLQuaternion nlerp(F32 t, const LLQuaternion &q)
-{
-	if (q.mQ[VW] < 0.f)
-	{
-		return slerp(t, q);
-	}
-	else
-	{
-		return lerp(t, q);
-	}
-}
-
-// slerp from identity quaternion to another quaternion
-LLQuaternion slerp(F32 t, const LLQuaternion &q)
-{
-	F32 c = q.mQ[VW];
-	if (1.0f == t  ||  1.0f == c)
-	{
-		// the trivial cases
-		return q;
-	}
-
-	LLQuaternion r;
-	F32 s, angle, stq, stp;
-
-	s = (F32) sqrt(1.f - c*c);
-
-    if (c < 0.0f)
-    {
-        // when c < 0.0 then theta > PI/2 
-        // since quat and -quat are the same rotation we invert one of  
-        // p or q to reduce unecessary spins
-        // A equivalent way to do it is to convert acos(c) as if it had 
-		// been negative, and to negate stp 
-        angle   = (F32) acos(-c); 
-        stp     = -(F32) sin(angle * (1.f - t));
-        stq     = (F32) sin(angle * t);
-    }   
-    else
-    {
-		angle 	= (F32) acos(c);
-        stp     = (F32) sin(angle * (1.f - t));
-        stq     = (F32) sin(angle * t);
-    }
-
-	r.mQ[VX] = (q.mQ[VX] * stq) / s;
-	r.mQ[VY] = (q.mQ[VY] * stq) / s;
-	r.mQ[VZ] = (q.mQ[VZ] * stq) / s;
-	r.mQ[VW] = (stp + q.mQ[VW] * stq) / s;
-
-	return r;
-}
-
-LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order)
-{
-	LLQuaternion xQ( xRot*DEG_TO_RAD, LLVector3(1.0f, 0.0f, 0.0f) );
-	LLQuaternion yQ( yRot*DEG_TO_RAD, LLVector3(0.0f, 1.0f, 0.0f) );
-	LLQuaternion zQ( zRot*DEG_TO_RAD, LLVector3(0.0f, 0.0f, 1.0f) );
-	LLQuaternion ret;
-	switch( order )
-	{
-	case LLQuaternion::XYZ:
-		ret = xQ * yQ * zQ;
-		break;
-	case LLQuaternion::YZX:
-		ret = yQ * zQ * xQ;
-		break;
-	case LLQuaternion::ZXY:
-		ret = zQ * xQ * yQ;
-		break;
-	case LLQuaternion::XZY:
-		ret = xQ * zQ * yQ;
-		break;
-	case LLQuaternion::YXZ:
-		ret = yQ * xQ * zQ;
-		break;
-	case LLQuaternion::ZYX:
-		ret = zQ * yQ * xQ;
-		break;
-	}
-	return ret;
-}
-
-const char *OrderToString( const LLQuaternion::Order order )
-{
-	const char *p = NULL;
-	switch( order )
-	{
-	default:
-	case LLQuaternion::XYZ:
-		p = "XYZ";
-		break;
-	case LLQuaternion::YZX:
-		p = "YZX";
-		break;
-	case LLQuaternion::ZXY:
-		p = "ZXY";
-		break;
-	case LLQuaternion::XZY:
-		p = "XZY";
-		break;
-	case LLQuaternion::YXZ:
-		p = "YXZ";
-		break;
-	case LLQuaternion::ZYX:
-		p = "ZYX";
-		break;
-	}
-	return p;
-}
-
-LLQuaternion::Order StringToOrder( const char *str )
-{
-	if (strncmp(str, "XYZ", 3)==0 || strncmp(str, "xyz", 3)==0)
-		return LLQuaternion::XYZ;
-
-	if (strncmp(str, "YZX", 3)==0 || strncmp(str, "yzx", 3)==0)
-		return LLQuaternion::YZX;
-
-	if (strncmp(str, "ZXY", 3)==0 || strncmp(str, "zxy", 3)==0)
-		return LLQuaternion::ZXY;
-
-	if (strncmp(str, "XZY", 3)==0 || strncmp(str, "xzy", 3)==0)
-		return LLQuaternion::XZY;
-
-	if (strncmp(str, "YXZ", 3)==0 || strncmp(str, "yxz", 3)==0)
-		return LLQuaternion::YXZ;
-
-	if (strncmp(str, "ZYX", 3)==0 || strncmp(str, "zyx", 3)==0)
-		return LLQuaternion::ZYX;
-
-	return LLQuaternion::XYZ;
-}
-
-void LLQuaternion::getAngleAxis(F32* angle, LLVector3 &vec) const
-{
-	F32 cos_a = mQ[VW];
-	if (cos_a > 1.0f) cos_a = 1.0f;
-	if (cos_a < -1.0f) cos_a = -1.0f;
-
-    F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
-
-    if ( fabs( sin_a ) < 0.0005f )
-		sin_a = 1.0f;
-	else
-		sin_a = 1.f/sin_a;
-
-    F32 temp_angle = 2.0f * (F32) acos( cos_a );
-	if (temp_angle > F_PI)
-	{
-		// The (angle,axis) pair should never have angles outside [PI, -PI]
-		// since we want the _shortest_ (angle,axis) solution.
-		// Since acos is defined for [0, PI], and we multiply by 2.0, we
-		// can push the angle outside the acceptible range.
-		// When this happens we set the angle to the other portion of a 
-		// full 2PI rotation, and negate the axis, which reverses the 
-		// direction of the rotation (by the right-hand rule).
-		*angle = 2.f * F_PI - temp_angle;
-    	vec.mV[VX] = - mQ[VX] * sin_a;
-    	vec.mV[VY] = - mQ[VY] * sin_a;
-    	vec.mV[VZ] = - mQ[VZ] * sin_a;
-	}
-	else
-	{
-		*angle = temp_angle;
-    	vec.mV[VX] = mQ[VX] * sin_a;
-    	vec.mV[VY] = mQ[VY] * sin_a;
-    	vec.mV[VZ] = mQ[VZ] * sin_a;
-	}
-}
-
-
-// quaternion does not need to be normalized
-void LLQuaternion::getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) const
-{
-	LLMatrix3 rot_mat(*this);
-	rot_mat.orthogonalize();
-	rot_mat.getEulerAngles(roll, pitch, yaw);
-
-//	// NOTE: LLQuaternion's are actually inverted with respect to
-//	// the matrices, so this code also assumes inverted quaternions
-//	// (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
-//	// in reverse order (yaw,pitch,roll).
-//	F32 x = -mQ[VX], y = -mQ[VY], z = -mQ[VZ], w = mQ[VW];
-//	F64 m20 = 2.0*(x*z-y*w);
-//	if (1.0f - fabsf(m20) < F_APPROXIMATELY_ZERO)
-//	{
-//		*roll = 0.0f;
-//		*pitch = (F32)asin(m20);
-//		*yaw = (F32)atan2(2.0*(x*y-z*w), 1.0 - 2.0*(x*x+z*z));
-//	}
-//	else
-//	{
-//		*roll  = (F32)atan2(-2.0*(y*z+x*w), 1.0-2.0*(x*x+y*y));
-//		*pitch = (F32)asin(m20);
-//		*yaw   = (F32)atan2(-2.0*(x*y+z*w), 1.0-2.0*(y*y+z*z));
-//	}
-}
-
-// Saves space by using the fact that our quaternions are normalized
-LLVector3 LLQuaternion::packToVector3() const
-{
-	if( mQ[VW] >= 0 )
-	{
-		return LLVector3( mQ[VX], mQ[VY], mQ[VZ] );
-	}
-	else
-	{
-		return LLVector3( -mQ[VX], -mQ[VY], -mQ[VZ] );
-	}
-}
-
-// Saves space by using the fact that our quaternions are normalized
-void LLQuaternion::unpackFromVector3( const LLVector3& vec )
-{
-	mQ[VX] = vec.mV[VX];
-	mQ[VY] = vec.mV[VY];
-	mQ[VZ] = vec.mV[VZ];
-	F32 t = 1.f - vec.magVecSquared();
-	if( t > 0 )
-	{
-		mQ[VW] = sqrt( t );
-	}
-	else
-	{
-		// Need this to avoid trying to find the square root of a negative number due
-		// to floating point error.
-		mQ[VW] = 0;
-	}
-}
-
-BOOL LLQuaternion::parseQuat(const std::string& buf, LLQuaternion* value)
-{
-	if( buf.empty() || value == NULL)
-	{
-		return FALSE;
-	}
-
-	LLQuaternion quat;
-	S32 count = sscanf( buf.c_str(), "%f %f %f %f", quat.mQ + 0, quat.mQ + 1, quat.mQ + 2, quat.mQ + 3 );
-	if( 4 == count )
-	{
-		value->set( quat );
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-
-// End
+/** 
+ * @file llquaternion.cpp
+ * @brief LLQuaternion class implementation.
+ *
+ * $LicenseInfo:firstyear=2000&license=viewergpl$
+ * 
+ * Copyright (c) 2000-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+
+#include "llmath.h"	// for F_PI
+
+#include "llquaternion.h"
+
+//#include "vmath.h"
+#include "v3math.h"
+#include "v3dmath.h"
+#include "v4math.h"
+#include "m4math.h"
+#include "m3math.h"
+#include "llquantize.h"
+
+// WARNING: Don't use this for global const definitions!  using this
+// at the top of a *.cpp file might not give you what you think.
+const LLQuaternion LLQuaternion::DEFAULT;
+ 
+// Constructors
+
+LLQuaternion::LLQuaternion(const LLMatrix4 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+}
+
+LLQuaternion::LLQuaternion(const LLMatrix3 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+}
+
+LLQuaternion::LLQuaternion(F32 angle, const LLVector4 &vec)
+{
+	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
+	v.normalize();
+
+	F32 c, s;
+	c = cosf(angle*0.5f);
+	s = sinf(angle*0.5f);
+
+	mQ[VX] = v.mV[VX] * s;
+	mQ[VY] = v.mV[VY] * s;
+	mQ[VZ] = v.mV[VZ] * s;
+	mQ[VW] = c;
+	normalize();
+}
+
+LLQuaternion::LLQuaternion(F32 angle, const LLVector3 &vec)
+{
+	LLVector3 v(vec);
+	v.normalize();
+
+	F32 c, s;
+	c = cosf(angle*0.5f);
+	s = sinf(angle*0.5f);
+
+	mQ[VX] = v.mV[VX] * s;
+	mQ[VY] = v.mV[VY] * s;
+	mQ[VZ] = v.mV[VZ] * s;
+	mQ[VW] = c;
+	normalize();
+}
+
+LLQuaternion::LLQuaternion(const LLVector3 &x_axis,
+						   const LLVector3 &y_axis,
+						   const LLVector3 &z_axis)
+{
+	LLMatrix3 mat;
+	mat.setRows(x_axis, y_axis, z_axis);
+	*this = mat.quaternion();
+	normalize();
+}
+
+// Quatizations
+void	LLQuaternion::quantize16(F32 lower, F32 upper)
+{
+	F32 x = mQ[VX];
+	F32 y = mQ[VY];
+	F32 z = mQ[VZ];
+	F32 s = mQ[VS];
+
+	x = U16_to_F32(F32_to_U16_ROUND(x, lower, upper), lower, upper);
+	y = U16_to_F32(F32_to_U16_ROUND(y, lower, upper), lower, upper);
+	z = U16_to_F32(F32_to_U16_ROUND(z, lower, upper), lower, upper);
+	s = U16_to_F32(F32_to_U16_ROUND(s, lower, upper), lower, upper);
+
+	mQ[VX] = x;
+	mQ[VY] = y;
+	mQ[VZ] = z;
+	mQ[VS] = s;
+
+	normalize();
+}
+
+void	LLQuaternion::quantize8(F32 lower, F32 upper)
+{
+	mQ[VX] = U8_to_F32(F32_to_U8_ROUND(mQ[VX], lower, upper), lower, upper);
+	mQ[VY] = U8_to_F32(F32_to_U8_ROUND(mQ[VY], lower, upper), lower, upper);
+	mQ[VZ] = U8_to_F32(F32_to_U8_ROUND(mQ[VZ], lower, upper), lower, upper);
+	mQ[VS] = U8_to_F32(F32_to_U8_ROUND(mQ[VS], lower, upper), lower, upper);
+
+	normalize();
+}
+
+// LLVector3 Magnitude and Normalization Functions
+
+
+// Set LLQuaternion routines
+
+const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, F32 x, F32 y, F32 z)
+{
+	LLVector3 vec(x, y, z);
+	vec.normalize();
+
+	angle *= 0.5f;
+	F32 c, s;
+	c = cosf(angle);
+	s = sinf(angle);
+
+	mQ[VX] = vec.mV[VX]*s;
+	mQ[VY] = vec.mV[VY]*s;
+	mQ[VZ] = vec.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, const LLVector3 &vec)
+{
+	LLVector3 v(vec);
+	v.normalize();
+
+	angle *= 0.5f;
+	F32 c, s;
+	c = cosf(angle);
+	s = sinf(angle);
+
+	mQ[VX] = v.mV[VX]*s;
+	mQ[VY] = v.mV[VY]*s;
+	mQ[VZ] = v.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setAngleAxis(F32 angle, const LLVector4 &vec)
+{
+	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
+	v.normalize();
+
+	F32 c, s;
+	c = cosf(angle*0.5f);
+	s = sinf(angle*0.5f);
+
+	mQ[VX] = v.mV[VX]*s;
+	mQ[VY] = v.mV[VY]*s;
+	mQ[VZ] = v.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setEulerAngles(F32 roll, F32 pitch, F32 yaw)
+{
+	LLMatrix3 rot_mat(roll, pitch, yaw);
+	rot_mat.orthogonalize();
+	*this = rot_mat.quaternion();
+		
+	normalize();
+	return (*this);
+}
+
+// deprecated
+const LLQuaternion&	LLQuaternion::set(const LLMatrix3 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+	return (*this);
+}
+
+// deprecated
+const LLQuaternion&	LLQuaternion::set(const LLMatrix4 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+	return (*this);
+}
+
+// deprecated
+const LLQuaternion&	LLQuaternion::setQuat(F32 angle, F32 x, F32 y, F32 z)
+{
+	LLVector3 vec(x, y, z);
+	vec.normalize();
+
+	angle *= 0.5f;
+	F32 c, s;
+	c = cosf(angle);
+	s = sinf(angle);
+
+	mQ[VX] = vec.mV[VX]*s;
+	mQ[VY] = vec.mV[VY]*s;
+	mQ[VZ] = vec.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+// deprecated
+const LLQuaternion&	LLQuaternion::setQuat(F32 angle, const LLVector3 &vec)
+{
+	LLVector3 v(vec);
+	v.normalize();
+
+	angle *= 0.5f;
+	F32 c, s;
+	c = cosf(angle);
+	s = sinf(angle);
+
+	mQ[VX] = v.mV[VX]*s;
+	mQ[VY] = v.mV[VY]*s;
+	mQ[VZ] = v.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setQuat(F32 angle, const LLVector4 &vec)
+{
+	LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
+	v.normalize();
+
+	F32 c, s;
+	c = cosf(angle*0.5f);
+	s = sinf(angle*0.5f);
+
+	mQ[VX] = v.mV[VX]*s;
+	mQ[VY] = v.mV[VY]*s;
+	mQ[VZ] = v.mV[VZ]*s;
+	mQ[VW] = c;
+
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setQuat(F32 roll, F32 pitch, F32 yaw)
+{
+	LLMatrix3 rot_mat(roll, pitch, yaw);
+	rot_mat.orthogonalize();
+	*this = rot_mat.quaternion();
+		
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setQuat(const LLMatrix3 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+	return (*this);
+}
+
+const LLQuaternion&	LLQuaternion::setQuat(const LLMatrix4 &mat)
+{
+	*this = mat.quaternion();
+	normalize();
+	return (*this);
+//#if 1
+//	// NOTE: LLQuaternion's are actually inverted with respect to
+//	// the matrices, so this code also assumes inverted quaternions
+//	// (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
+//	// in reverse order (yaw,pitch,roll).
+//	F64 cosX = cos(roll);
+//    F64 cosY = cos(pitch);
+//    F64 cosZ = cos(yaw);
+//
+//    F64 sinX = sin(roll);
+//    F64 sinY = sin(pitch);
+//    F64 sinZ = sin(yaw);
+//
+//    mQ[VW] = (F32)sqrt(cosY*cosZ - sinX*sinY*sinZ + cosX*cosZ + cosX*cosY + 1.0)*.5;
+//	if (fabs(mQ[VW]) < F_APPROXIMATELY_ZERO)
+//	{
+//		// null rotation, any axis will do
+//		mQ[VX] = 0.0f;
+//		mQ[VY] = 1.0f;
+//		mQ[VZ] = 0.0f;
+//	}
+//	else
+//	{
+//		F32 inv_s = 1.0f / (4.0f * mQ[VW]);
+//		mQ[VX] = (F32)-(-sinX*cosY - cosX*sinY*sinZ - sinX*cosZ) * inv_s;
+//		mQ[VY] = (F32)-(-cosX*sinY*cosZ + sinX*sinZ - sinY) * inv_s;
+//		mQ[VZ] = (F32)-(-cosY*sinZ - sinX*sinY*cosZ - cosX*sinZ) * inv_s;		
+//	}
+//
+//#else // This only works on a certain subset of roll/pitch/yaw
+//	
+//	F64 cosX = cosf(roll/2.0);
+//    F64 cosY = cosf(pitch/2.0);
+//    F64 cosZ = cosf(yaw/2.0);
+//
+//    F64 sinX = sinf(roll/2.0);
+//    F64 sinY = sinf(pitch/2.0);
+//    F64 sinZ = sinf(yaw/2.0);
+//
+//    mQ[VW] = (F32)(cosX*cosY*cosZ + sinX*sinY*sinZ);
+//    mQ[VX] = (F32)(sinX*cosY*cosZ - cosX*sinY*sinZ);
+//    mQ[VY] = (F32)(cosX*sinY*cosZ + sinX*cosY*sinZ);
+//    mQ[VZ] = (F32)(cosX*cosY*sinZ - sinX*sinY*cosZ);
+//#endif
+//
+//	normalize();
+//	return (*this);
+}
+
+// SJB: This code is correct for a logicly stored (non-transposed) matrix;
+//		Our matrices are stored transposed, OpenGL style, so this generates the
+//		INVERSE matrix, or the CORRECT matrix form an INVERSE quaternion.
+//		Because we use similar logic in LLMatrix3::quaternion(),
+//		we are internally consistant so everything works OK :)
+LLMatrix3	LLQuaternion::getMatrix3(void) const
+{
+	LLMatrix3	mat;
+	F32		xx, xy, xz, xw, yy, yz, yw, zz, zw;
+
+    xx      = mQ[VX] * mQ[VX];
+    xy      = mQ[VX] * mQ[VY];
+    xz      = mQ[VX] * mQ[VZ];
+    xw      = mQ[VX] * mQ[VW];
+
+    yy      = mQ[VY] * mQ[VY];
+    yz      = mQ[VY] * mQ[VZ];
+    yw      = mQ[VY] * mQ[VW];
+
+    zz      = mQ[VZ] * mQ[VZ];
+    zw      = mQ[VZ] * mQ[VW];
+
+    mat.mMatrix[0][0]  = 1.f - 2.f * ( yy + zz );
+    mat.mMatrix[0][1]  =	   2.f * ( xy + zw );
+    mat.mMatrix[0][2]  =	   2.f * ( xz - yw );
+
+    mat.mMatrix[1][0]  =	   2.f * ( xy - zw );
+    mat.mMatrix[1][1]  = 1.f - 2.f * ( xx + zz );
+    mat.mMatrix[1][2]  =	   2.f * ( yz + xw );
+
+    mat.mMatrix[2][0]  =	   2.f * ( xz + yw );
+    mat.mMatrix[2][1]  =	   2.f * ( yz - xw );
+    mat.mMatrix[2][2]  = 1.f - 2.f * ( xx + yy );
+
+	return mat;
+}
+
+LLMatrix4	LLQuaternion::getMatrix4(void) const
+{
+	LLMatrix4	mat;
+	F32		xx, xy, xz, xw, yy, yz, yw, zz, zw;
+
+    xx      = mQ[VX] * mQ[VX];
+    xy      = mQ[VX] * mQ[VY];
+    xz      = mQ[VX] * mQ[VZ];
+    xw      = mQ[VX] * mQ[VW];
+
+    yy      = mQ[VY] * mQ[VY];
+    yz      = mQ[VY] * mQ[VZ];
+    yw      = mQ[VY] * mQ[VW];
+
+    zz      = mQ[VZ] * mQ[VZ];
+    zw      = mQ[VZ] * mQ[VW];
+
+    mat.mMatrix[0][0]  = 1.f - 2.f * ( yy + zz );
+    mat.mMatrix[0][1]  =	   2.f * ( xy + zw );
+    mat.mMatrix[0][2]  =	   2.f * ( xz - yw );
+
+    mat.mMatrix[1][0]  =	   2.f * ( xy - zw );
+    mat.mMatrix[1][1]  = 1.f - 2.f * ( xx + zz );
+    mat.mMatrix[1][2]  =	   2.f * ( yz + xw );
+
+    mat.mMatrix[2][0]  =	   2.f * ( xz + yw );
+    mat.mMatrix[2][1]  =	   2.f * ( yz - xw );
+    mat.mMatrix[2][2]  = 1.f - 2.f * ( xx + yy );
+
+	// TODO -- should we set the translation portion to zero?
+
+	return mat;
+}
+
+
+
+
+// Other useful methods
+
+
+// calculate the shortest rotation from a to b
+void LLQuaternion::shortestArc(const LLVector3 &a, const LLVector3 &b)
+{
+	// Make a local copy of both vectors.
+	LLVector3 vec_a = a;
+	LLVector3 vec_b = b;
+
+	// Make sure neither vector is zero length.  Also normalize
+	// the vectors while we are at it.
+	F32 vec_a_mag = vec_a.normalize();
+	F32 vec_b_mag = vec_b.normalize();
+	if (vec_a_mag < F_APPROXIMATELY_ZERO ||
+		vec_b_mag < F_APPROXIMATELY_ZERO)
+	{
+		// Can't calculate a rotation from this.
+		// Just return ZERO_ROTATION instead.
+		loadIdentity();
+		return;
+	}
+
+	// Create an axis to rotate around, and the cos of the angle to rotate.
+	LLVector3 axis = vec_a % vec_b;
+	F32 cos_theta  = vec_a * vec_b;
+
+	// Check the angle between the vectors to see if they are parallel or anti-parallel.
+	if (cos_theta > 1.0 - F_APPROXIMATELY_ZERO)
+	{
+		// a and b are parallel.  No rotation is necessary.
+		loadIdentity();
+	}
+	else if (cos_theta < -1.0 + F_APPROXIMATELY_ZERO)
+	{
+		// a and b are anti-parallel.
+		// Rotate 180 degrees around some orthogonal axis.
+		// Find the projection of the x-axis onto a, and try
+		// using the vector between the projection and the x-axis
+		// as the orthogonal axis.
+		LLVector3 proj = vec_a.mV[VX] / (vec_a * vec_a) * vec_a;
+		LLVector3 ortho_axis(1.f, 0.f, 0.f);
+		ortho_axis -= proj;
+		
+		// Turn this into an orthonormal axis.
+		F32 ortho_length = ortho_axis.normalize();
+		// If the axis' length is 0, then our guess at an orthogonal axis
+		// was wrong (a is parallel to the x-axis).
+		if (ortho_length < F_APPROXIMATELY_ZERO)
+		{
+			// Use the z-axis instead.
+			ortho_axis.setVec(0.f, 0.f, 1.f);
+		}
+
+		// Construct a quaternion from this orthonormal axis.
+		mQ[VX] = ortho_axis.mV[VX];
+		mQ[VY] = ortho_axis.mV[VY];
+		mQ[VZ] = ortho_axis.mV[VZ];
+		mQ[VW] = 0.f;
+	}
+	else
+	{
+		// a and b are NOT parallel or anti-parallel.
+		// Return the rotation between these vectors.
+		F32 theta = (F32)acos(cos_theta);
+
+		setAngleAxis(theta, axis);
+	}
+}
+
+// constrains rotation to a cone angle specified in radians
+const LLQuaternion &LLQuaternion::constrain(F32 radians)
+{
+	const F32 cos_angle_lim = cosf( radians/2 );	// mQ[VW] limit
+	const F32 sin_angle_lim = sinf( radians/2 );	// rotation axis length	limit
+
+	if (mQ[VW] < 0.f)
+	{
+		mQ[VX] *= -1.f;
+		mQ[VY] *= -1.f;
+		mQ[VZ] *= -1.f;
+		mQ[VW] *= -1.f;
+	}
+
+	// if rotation angle is greater than limit (cos is less than limit)
+	if( mQ[VW] < cos_angle_lim )
+	{
+		mQ[VW] = cos_angle_lim;
+		F32 axis_len = sqrtf( mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] ); // sin(theta/2)
+		F32 axis_mult_fact = sin_angle_lim / axis_len;
+		mQ[VX] *= axis_mult_fact;
+		mQ[VY] *= axis_mult_fact;
+		mQ[VZ] *= axis_mult_fact;
+	}
+
+	return *this;
+}
+
+// Operators
+
+std::ostream& operator<<(std::ostream &s, const LLQuaternion &a)
+{
+	s << "{ " 
+		<< a.mQ[VX] << ", " << a.mQ[VY] << ", " << a.mQ[VZ] << ", " << a.mQ[VW] 
+	<< " }";
+	return s;
+}
+
+
+// Does NOT renormalize the result
+LLQuaternion	operator*(const LLQuaternion &a, const LLQuaternion &b)
+{
+//	LLQuaternion::mMultCount++;
+
+	LLQuaternion q(
+		b.mQ[3] * a.mQ[0] + b.mQ[0] * a.mQ[3] + b.mQ[1] * a.mQ[2] - b.mQ[2] * a.mQ[1],
+		b.mQ[3] * a.mQ[1] + b.mQ[1] * a.mQ[3] + b.mQ[2] * a.mQ[0] - b.mQ[0] * a.mQ[2],
+		b.mQ[3] * a.mQ[2] + b.mQ[2] * a.mQ[3] + b.mQ[0] * a.mQ[1] - b.mQ[1] * a.mQ[0],
+		b.mQ[3] * a.mQ[3] - b.mQ[0] * a.mQ[0] - b.mQ[1] * a.mQ[1] - b.mQ[2] * a.mQ[2]
+	);
+	return q;
+}
+
+/*
+LLMatrix4	operator*(const LLMatrix4 &m, const LLQuaternion &q)
+{
+	LLMatrix4 qmat(q);
+	return (m*qmat);
+}
+*/
+
+
+
+LLVector4		operator*(const LLVector4 &a, const LLQuaternion &rot)
+{
+    F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
+    F32 rx =   rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
+    F32 ry =   rot.mQ[VW] * a.mV[VY] + rot.mQ[VZ] * a.mV[VX] - rot.mQ[VX] * a.mV[VZ];
+    F32 rz =   rot.mQ[VW] * a.mV[VZ] + rot.mQ[VX] * a.mV[VY] - rot.mQ[VY] * a.mV[VX];
+
+    F32 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
+    F32 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
+    F32 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
+
+    return LLVector4(nx, ny, nz, a.mV[VW]);
+}
+
+LLVector3		operator*(const LLVector3 &a, const LLQuaternion &rot)
+{
+    F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
+    F32 rx =   rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
+    F32 ry =   rot.mQ[VW] * a.mV[VY] + rot.mQ[VZ] * a.mV[VX] - rot.mQ[VX] * a.mV[VZ];
+    F32 rz =   rot.mQ[VW] * a.mV[VZ] + rot.mQ[VX] * a.mV[VY] - rot.mQ[VY] * a.mV[VX];
+
+    F32 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
+    F32 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
+    F32 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
+
+    return LLVector3(nx, ny, nz);
+}
+
+LLVector3d		operator*(const LLVector3d &a, const LLQuaternion &rot)
+{
+    F64 rw = - rot.mQ[VX] * a.mdV[VX] - rot.mQ[VY] * a.mdV[VY] - rot.mQ[VZ] * a.mdV[VZ];
+    F64 rx =   rot.mQ[VW] * a.mdV[VX] + rot.mQ[VY] * a.mdV[VZ] - rot.mQ[VZ] * a.mdV[VY];
+    F64 ry =   rot.mQ[VW] * a.mdV[VY] + rot.mQ[VZ] * a.mdV[VX] - rot.mQ[VX] * a.mdV[VZ];
+    F64 rz =   rot.mQ[VW] * a.mdV[VZ] + rot.mQ[VX] * a.mdV[VY] - rot.mQ[VY] * a.mdV[VX];
+
+    F64 nx = - rw * rot.mQ[VX] +  rx * rot.mQ[VW] - ry * rot.mQ[VZ] + rz * rot.mQ[VY];
+    F64 ny = - rw * rot.mQ[VY] +  ry * rot.mQ[VW] - rz * rot.mQ[VX] + rx * rot.mQ[VZ];
+    F64 nz = - rw * rot.mQ[VZ] +  rz * rot.mQ[VW] - rx * rot.mQ[VY] + ry * rot.mQ[VX];
+
+    return LLVector3d(nx, ny, nz);
+}
+
+F32 dot(const LLQuaternion &a, const LLQuaternion &b)
+{
+	return a.mQ[VX] * b.mQ[VX] + 
+		   a.mQ[VY] * b.mQ[VY] + 
+		   a.mQ[VZ] * b.mQ[VZ] + 
+		   a.mQ[VW] * b.mQ[VW]; 
+}
+
+// DEMO HACK: This lerp is probably inocrrect now due intermediate normalization
+// it should look more like the lerp below
+#if 0
+// linear interpolation
+LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q)
+{
+	LLQuaternion r;
+	r = t * (q - p) + p;
+	r.normalize();
+	return r;
+}
+#endif
+
+// lerp from identity to q
+LLQuaternion lerp(F32 t, const LLQuaternion &q)
+{
+	LLQuaternion r;
+	r.mQ[VX] = t * q.mQ[VX];
+	r.mQ[VY] = t * q.mQ[VY];
+	r.mQ[VZ] = t * q.mQ[VZ];
+	r.mQ[VW] = t * (q.mQ[VZ] - 1.f) + 1.f;
+	r.normalize();
+	return r;
+}
+
+LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q)
+{
+	LLQuaternion r;
+	F32 inv_t;
+
+	inv_t = 1.f - t;
+
+	r.mQ[VX] = t * q.mQ[VX] + (inv_t * p.mQ[VX]);
+	r.mQ[VY] = t * q.mQ[VY] + (inv_t * p.mQ[VY]);
+	r.mQ[VZ] = t * q.mQ[VZ] + (inv_t * p.mQ[VZ]);
+	r.mQ[VW] = t * q.mQ[VW] + (inv_t * p.mQ[VW]);
+	r.normalize();
+	return r;
+}
+
+
+// spherical linear interpolation
+LLQuaternion slerp( F32 u, const LLQuaternion &a, const LLQuaternion &b )
+{
+	// cosine theta = dot product of a and b
+	F32 cos_t = a.mQ[0]*b.mQ[0] + a.mQ[1]*b.mQ[1] + a.mQ[2]*b.mQ[2] + a.mQ[3]*b.mQ[3];
+	
+	// if b is on opposite hemisphere from a, use -a instead
+	int bflip;
+ 	if (cos_t < 0.0f)
+	{
+		cos_t = -cos_t;
+		bflip = TRUE;
+	}
+	else
+		bflip = FALSE;
+
+	// if B is (within precision limits) the same as A,
+	// just linear interpolate between A and B.
+	F32 alpha;	// interpolant
+	F32 beta;		// 1 - interpolant
+	if (1.0f - cos_t < 0.00001f)
+	{
+		beta = 1.0f - u;
+		alpha = u;
+ 	}
+	else
+	{
+ 		F32 theta = acosf(cos_t);
+ 		F32 sin_t = sinf(theta);
+ 		beta = sinf(theta - u*theta) / sin_t;
+ 		alpha = sinf(u*theta) / sin_t;
+ 	}
+
+	if (bflip)
+		beta = -beta;
+
+	// interpolate
+	LLQuaternion ret;
+	ret.mQ[0] = beta*a.mQ[0] + alpha*b.mQ[0];
+ 	ret.mQ[1] = beta*a.mQ[1] + alpha*b.mQ[1];
+ 	ret.mQ[2] = beta*a.mQ[2] + alpha*b.mQ[2];
+ 	ret.mQ[3] = beta*a.mQ[3] + alpha*b.mQ[3];
+
+	return ret;
+}
+
+// lerp whenever possible
+LLQuaternion nlerp(F32 t, const LLQuaternion &a, const LLQuaternion &b)
+{
+	if (dot(a, b) < 0.f)
+	{
+		return slerp(t, a, b);
+	}
+	else
+	{
+		return lerp(t, a, b);
+	}
+}
+
+LLQuaternion nlerp(F32 t, const LLQuaternion &q)
+{
+	if (q.mQ[VW] < 0.f)
+	{
+		return slerp(t, q);
+	}
+	else
+	{
+		return lerp(t, q);
+	}
+}
+
+// slerp from identity quaternion to another quaternion
+LLQuaternion slerp(F32 t, const LLQuaternion &q)
+{
+	F32 c = q.mQ[VW];
+	if (1.0f == t  ||  1.0f == c)
+	{
+		// the trivial cases
+		return q;
+	}
+
+	LLQuaternion r;
+	F32 s, angle, stq, stp;
+
+	s = (F32) sqrt(1.f - c*c);
+
+    if (c < 0.0f)
+    {
+        // when c < 0.0 then theta > PI/2 
+        // since quat and -quat are the same rotation we invert one of  
+        // p or q to reduce unecessary spins
+        // A equivalent way to do it is to convert acos(c) as if it had 
+		// been negative, and to negate stp 
+        angle   = (F32) acos(-c); 
+        stp     = -(F32) sin(angle * (1.f - t));
+        stq     = (F32) sin(angle * t);
+    }   
+    else
+    {
+		angle 	= (F32) acos(c);
+        stp     = (F32) sin(angle * (1.f - t));
+        stq     = (F32) sin(angle * t);
+    }
+
+	r.mQ[VX] = (q.mQ[VX] * stq) / s;
+	r.mQ[VY] = (q.mQ[VY] * stq) / s;
+	r.mQ[VZ] = (q.mQ[VZ] * stq) / s;
+	r.mQ[VW] = (stp + q.mQ[VW] * stq) / s;
+
+	return r;
+}
+
+LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order)
+{
+	LLQuaternion xQ( xRot*DEG_TO_RAD, LLVector3(1.0f, 0.0f, 0.0f) );
+	LLQuaternion yQ( yRot*DEG_TO_RAD, LLVector3(0.0f, 1.0f, 0.0f) );
+	LLQuaternion zQ( zRot*DEG_TO_RAD, LLVector3(0.0f, 0.0f, 1.0f) );
+	LLQuaternion ret;
+	switch( order )
+	{
+	case LLQuaternion::XYZ:
+		ret = xQ * yQ * zQ;
+		break;
+	case LLQuaternion::YZX:
+		ret = yQ * zQ * xQ;
+		break;
+	case LLQuaternion::ZXY:
+		ret = zQ * xQ * yQ;
+		break;
+	case LLQuaternion::XZY:
+		ret = xQ * zQ * yQ;
+		break;
+	case LLQuaternion::YXZ:
+		ret = yQ * xQ * zQ;
+		break;
+	case LLQuaternion::ZYX:
+		ret = zQ * yQ * xQ;
+		break;
+	}
+	return ret;
+}
+
+const char *OrderToString( const LLQuaternion::Order order )
+{
+	const char *p = NULL;
+	switch( order )
+	{
+	default:
+	case LLQuaternion::XYZ:
+		p = "XYZ";
+		break;
+	case LLQuaternion::YZX:
+		p = "YZX";
+		break;
+	case LLQuaternion::ZXY:
+		p = "ZXY";
+		break;
+	case LLQuaternion::XZY:
+		p = "XZY";
+		break;
+	case LLQuaternion::YXZ:
+		p = "YXZ";
+		break;
+	case LLQuaternion::ZYX:
+		p = "ZYX";
+		break;
+	}
+	return p;
+}
+
+LLQuaternion::Order StringToOrder( const char *str )
+{
+	if (strncmp(str, "XYZ", 3)==0 || strncmp(str, "xyz", 3)==0)
+		return LLQuaternion::XYZ;
+
+	if (strncmp(str, "YZX", 3)==0 || strncmp(str, "yzx", 3)==0)
+		return LLQuaternion::YZX;
+
+	if (strncmp(str, "ZXY", 3)==0 || strncmp(str, "zxy", 3)==0)
+		return LLQuaternion::ZXY;
+
+	if (strncmp(str, "XZY", 3)==0 || strncmp(str, "xzy", 3)==0)
+		return LLQuaternion::XZY;
+
+	if (strncmp(str, "YXZ", 3)==0 || strncmp(str, "yxz", 3)==0)
+		return LLQuaternion::YXZ;
+
+	if (strncmp(str, "ZYX", 3)==0 || strncmp(str, "zyx", 3)==0)
+		return LLQuaternion::ZYX;
+
+	return LLQuaternion::XYZ;
+}
+
+void LLQuaternion::getAngleAxis(F32* angle, LLVector3 &vec) const
+{
+	F32 cos_a = mQ[VW];
+	if (cos_a > 1.0f) cos_a = 1.0f;
+	if (cos_a < -1.0f) cos_a = -1.0f;
+
+    F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
+
+    if ( fabs( sin_a ) < 0.0005f )
+		sin_a = 1.0f;
+	else
+		sin_a = 1.f/sin_a;
+
+    F32 temp_angle = 2.0f * (F32) acos( cos_a );
+	if (temp_angle > F_PI)
+	{
+		// The (angle,axis) pair should never have angles outside [PI, -PI]
+		// since we want the _shortest_ (angle,axis) solution.
+		// Since acos is defined for [0, PI], and we multiply by 2.0, we
+		// can push the angle outside the acceptible range.
+		// When this happens we set the angle to the other portion of a 
+		// full 2PI rotation, and negate the axis, which reverses the 
+		// direction of the rotation (by the right-hand rule).
+		*angle = 2.f * F_PI - temp_angle;
+    	vec.mV[VX] = - mQ[VX] * sin_a;
+    	vec.mV[VY] = - mQ[VY] * sin_a;
+    	vec.mV[VZ] = - mQ[VZ] * sin_a;
+	}
+	else
+	{
+		*angle = temp_angle;
+    	vec.mV[VX] = mQ[VX] * sin_a;
+    	vec.mV[VY] = mQ[VY] * sin_a;
+    	vec.mV[VZ] = mQ[VZ] * sin_a;
+	}
+}
+
+
+// quaternion does not need to be normalized
+void LLQuaternion::getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) const
+{
+	LLMatrix3 rot_mat(*this);
+	rot_mat.orthogonalize();
+	rot_mat.getEulerAngles(roll, pitch, yaw);
+
+//	// NOTE: LLQuaternion's are actually inverted with respect to
+//	// the matrices, so this code also assumes inverted quaternions
+//	// (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
+//	// in reverse order (yaw,pitch,roll).
+//	F32 x = -mQ[VX], y = -mQ[VY], z = -mQ[VZ], w = mQ[VW];
+//	F64 m20 = 2.0*(x*z-y*w);
+//	if (1.0f - fabsf(m20) < F_APPROXIMATELY_ZERO)
+//	{
+//		*roll = 0.0f;
+//		*pitch = (F32)asin(m20);
+//		*yaw = (F32)atan2(2.0*(x*y-z*w), 1.0 - 2.0*(x*x+z*z));
+//	}
+//	else
+//	{
+//		*roll  = (F32)atan2(-2.0*(y*z+x*w), 1.0-2.0*(x*x+y*y));
+//		*pitch = (F32)asin(m20);
+//		*yaw   = (F32)atan2(-2.0*(x*y+z*w), 1.0-2.0*(y*y+z*z));
+//	}
+}
+
+// Saves space by using the fact that our quaternions are normalized
+LLVector3 LLQuaternion::packToVector3() const
+{
+	if( mQ[VW] >= 0 )
+	{
+		return LLVector3( mQ[VX], mQ[VY], mQ[VZ] );
+	}
+	else
+	{
+		return LLVector3( -mQ[VX], -mQ[VY], -mQ[VZ] );
+	}
+}
+
+// Saves space by using the fact that our quaternions are normalized
+void LLQuaternion::unpackFromVector3( const LLVector3& vec )
+{
+	mQ[VX] = vec.mV[VX];
+	mQ[VY] = vec.mV[VY];
+	mQ[VZ] = vec.mV[VZ];
+	F32 t = 1.f - vec.magVecSquared();
+	if( t > 0 )
+	{
+		mQ[VW] = sqrt( t );
+	}
+	else
+	{
+		// Need this to avoid trying to find the square root of a negative number due
+		// to floating point error.
+		mQ[VW] = 0;
+	}
+}
+
+BOOL LLQuaternion::parseQuat(const std::string& buf, LLQuaternion* value)
+{
+	if( buf.empty() || value == NULL)
+	{
+		return FALSE;
+	}
+
+	LLQuaternion quat;
+	S32 count = sscanf( buf.c_str(), "%f %f %f %f", quat.mQ + 0, quat.mQ + 1, quat.mQ + 2, quat.mQ + 3 );
+	if( 4 == count )
+	{
+		value->set( quat );
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+
+// End
diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h
index bbd4326483b..a7bb09fae31 100644
--- a/indra/llmath/llquaternion.h
+++ b/indra/llmath/llquaternion.h
@@ -1,594 +1,594 @@
-/** 
- * @file llquaternion.h
- * @brief LLQuaternion class header file.
- *
- * $LicenseInfo:firstyear=2000&license=viewergpl$
- * 
- * Copyright (c) 2000-2009, Linden Research, Inc.
- * 
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab.  Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- * 
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- * 
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- * 
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
-
-#ifndef LLQUATERNION_H
-#define LLQUATERNION_H
-
-#include <iostream>
-
-#ifndef LLMATH_H //enforce specific include order to avoid tangling inline dependencies
-#error "Please include llmath.h first."
-#endif
-
-class LLVector4;
-class LLVector3;
-class LLVector3d;
-class LLMatrix4;
-class LLMatrix3;
-
-//	NOTA BENE: Quaternion code is written assuming Unit Quaternions!!!!
-//			   Moreover, it is written assuming that all vectors and matricies
-//			   passed as arguments are normalized and unitary respectively.
-//			   VERY VERY VERY VERY BAD THINGS will happen if these assumptions fail.
-
-static const U32 LENGTHOFQUAT = 4;
-
-class LLQuaternion
-{
-public:
-	F32 mQ[LENGTHOFQUAT];
-
-	static const LLQuaternion DEFAULT;
-
-	LLQuaternion();									// Initializes Quaternion to (0,0,0,1)
-	explicit LLQuaternion(const LLMatrix4 &mat);				// Initializes Quaternion from Matrix4
-	explicit LLQuaternion(const LLMatrix3 &mat);				// Initializes Quaternion from Matrix3
-	LLQuaternion(F32 x, F32 y, F32 z, F32 w);		// Initializes Quaternion to normalize(x, y, z, w)
-	LLQuaternion(F32 angle, const LLVector4 &vec);	// Initializes Quaternion to axis_angle2quat(angle, vec)
-	LLQuaternion(F32 angle, const LLVector3 &vec);	// Initializes Quaternion to axis_angle2quat(angle, vec)
-	LLQuaternion(const F32 *q);						// Initializes Quaternion to normalize(x, y, z, w)
-	LLQuaternion(const LLVector3 &x_axis,
-				 const LLVector3 &y_axis,
-				 const LLVector3 &z_axis);			// Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis]
-
-	BOOL isIdentity() const;
-	BOOL isNotIdentity() const;
-	BOOL isFinite() const;									// checks to see if all values of LLQuaternion are finite
-	void quantize16(F32 lower, F32 upper);					// changes the vector to reflect quatization
-	void quantize8(F32 lower, F32 upper);							// changes the vector to reflect quatization
-	void loadIdentity();											// Loads the quaternion that represents the identity rotation
-
-	const LLQuaternion&	set(F32 x, F32 y, F32 z, F32 w);		// Sets Quaternion to normalize(x, y, z, w)
-	const LLQuaternion&	set(const LLQuaternion &quat);			// Copies Quaternion
-	const LLQuaternion&	set(const F32 *q);						// Sets Quaternion to normalize(quat[VX], quat[VY], quat[VZ], quat[VW])
-	const LLQuaternion&	set(const LLMatrix3 &mat);				// Sets Quaternion to mat2quat(mat)
-	const LLQuaternion&	set(const LLMatrix4 &mat);				// Sets Quaternion to mat2quat(mat)
-
-	const LLQuaternion&	setAngleAxis(F32 angle, F32 x, F32 y, F32 z);	// Sets Quaternion to axis_angle2quat(angle, x, y, z)
-	const LLQuaternion&	setAngleAxis(F32 angle, const LLVector3 &vec);	// Sets Quaternion to axis_angle2quat(angle, vec)
-	const LLQuaternion&	setAngleAxis(F32 angle, const LLVector4 &vec);	// Sets Quaternion to axis_angle2quat(angle, vec)
-	const LLQuaternion&	setEulerAngles(F32 roll, F32 pitch, F32 yaw);	// Sets Quaternion to euler2quat(pitch, yaw, roll)
-
-	const LLQuaternion&	setQuatInit(F32 x, F32 y, F32 z, F32 w);	// deprecated
-	const LLQuaternion&	setQuat(const LLQuaternion &quat);			// deprecated
-	const LLQuaternion&	setQuat(const F32 *q);						// deprecated
-	const LLQuaternion&	setQuat(const LLMatrix3 &mat);				// deprecated
-	const LLQuaternion&	setQuat(const LLMatrix4 &mat);				// deprecated
-	const LLQuaternion&	setQuat(F32 angle, F32 x, F32 y, F32 z);	// deprecated
-	const LLQuaternion&	setQuat(F32 angle, const LLVector3 &vec);	// deprecated
-	const LLQuaternion&	setQuat(F32 angle, const LLVector4 &vec);	// deprecated
-	const LLQuaternion&	setQuat(F32 roll, F32 pitch, F32 yaw);		// deprecated
-
-	LLMatrix4	getMatrix4(void) const;							// Returns the Matrix4 equivalent of Quaternion
-	LLMatrix3	getMatrix3(void) const;							// Returns the Matrix3 equivalent of Quaternion
-	void		getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const;	// returns rotation in radians about axis x,y,z
-	void		getAngleAxis(F32* angle, LLVector3 &vec) const;
-	void		getEulerAngles(F32 *roll, F32* pitch, F32 *yaw) const;
-
-	F32	normalize();	// Normalizes Quaternion and returns magnitude
-	F32	normQuat();		// deprecated
-
-	const LLQuaternion&	conjugate(void);	// Conjugates Quaternion and returns result
-	const LLQuaternion&	conjQuat(void);		// deprecated
-
-	// Other useful methods
-	const LLQuaternion&	transpose();		// transpose (same as conjugate)
-	const LLQuaternion&	transQuat();		// deprecated
-
-	void			shortestArc(const LLVector3 &a, const LLVector3 &b);	// shortest rotation from a to b
-	const LLQuaternion& constrain(F32 radians);						// constrains rotation to a cone angle specified in radians
-
-	// Standard operators
-	friend std::ostream& operator<<(std::ostream &s, const LLQuaternion &a);					// Prints a
-	friend LLQuaternion operator+(const LLQuaternion &a, const LLQuaternion &b);	// Addition
-	friend LLQuaternion operator-(const LLQuaternion &a, const LLQuaternion &b);	// Subtraction
-	friend LLQuaternion operator-(const LLQuaternion &a);							// Negation
-	friend LLQuaternion operator*(F32 a, const LLQuaternion &q);					// Scale
-	friend LLQuaternion operator*(const LLQuaternion &q, F32 b);					// Scale
-	friend LLQuaternion operator*(const LLQuaternion &a, const LLQuaternion &b);	// Returns a * b
-	friend LLQuaternion operator~(const LLQuaternion &a);							// Returns a* (Conjugate of a)
-	bool operator==(const LLQuaternion &b) const;			// Returns a == b
-	bool operator!=(const LLQuaternion &b) const;			// Returns a != b
-
-	friend const LLQuaternion& operator*=(LLQuaternion &a, const LLQuaternion &b);	// Returns a * b
-
-	friend LLVector4 operator*(const LLVector4 &a, const LLQuaternion &rot);		// Rotates a by rot
-	friend LLVector3 operator*(const LLVector3 &a, const LLQuaternion &rot);		// Rotates a by rot
-	friend LLVector3d operator*(const LLVector3d &a, const LLQuaternion &rot);		// Rotates a by rot
-
-	// Non-standard operators
-	friend F32 dot(const LLQuaternion &a, const LLQuaternion &b);
-	friend LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q);		// linear interpolation (t = 0 to 1) from p to q
-	friend LLQuaternion lerp(F32 t, const LLQuaternion &q);								// linear interpolation (t = 0 to 1) from identity to q
-	friend LLQuaternion slerp(F32 t, const LLQuaternion &p, const LLQuaternion &q); 	// spherical linear interpolation from p to q
-	friend LLQuaternion slerp(F32 t, const LLQuaternion &q);							// spherical linear interpolation from identity to q
-	friend LLQuaternion nlerp(F32 t, const LLQuaternion &p, const LLQuaternion &q); 	// normalized linear interpolation from p to q
-	friend LLQuaternion nlerp(F32 t, const LLQuaternion &q); 							// normalized linear interpolation from p to q
-
-	LLVector3	packToVector3() const;						// Saves space by using the fact that our quaternions are normalized
-	void		unpackFromVector3(const LLVector3& vec);	// Saves space by using the fact that our quaternions are normalized
-
-	enum Order {
-		XYZ = 0,
-		YZX = 1,
-		ZXY = 2,
-		XZY = 3,
-		YXZ = 4,
-		ZYX = 5
-	};
-	// Creates a quaternions from maya's rotation representation,
-	// which is 3 rotations (in DEGREES) in the specified order
-	friend LLQuaternion mayaQ(F32 x, F32 y, F32 z, Order order);
-
-	// Conversions between Order and strings like "xyz" or "ZYX"
-	friend const char *OrderToString( const Order order );
-	friend Order StringToOrder( const char *str );
-
-	static BOOL parseQuat(const std::string& buf, LLQuaternion* value);
-
-	// For debugging, only
-	//static U32 mMultCount;
-};
-
-// checker
-inline BOOL	LLQuaternion::isFinite() const
-{
-	return (llfinite(mQ[VX]) && llfinite(mQ[VY]) && llfinite(mQ[VZ]) && llfinite(mQ[VS]));
-}
-
-inline BOOL LLQuaternion::isIdentity() const
-{
-	return 
-		( mQ[VX] == 0.f ) &&
-		( mQ[VY] == 0.f ) &&
-		( mQ[VZ] == 0.f ) &&
-		( mQ[VS] == 1.f );
-}
-
-inline BOOL LLQuaternion::isNotIdentity() const
-{
-	return 
-		( mQ[VX] != 0.f ) ||
-		( mQ[VY] != 0.f ) ||
-		( mQ[VZ] != 0.f ) ||
-		( mQ[VS] != 1.f );
-}
-
-
-
-inline LLQuaternion::LLQuaternion(void)
-{
-	mQ[VX] = 0.f;
-	mQ[VY] = 0.f;
-	mQ[VZ] = 0.f;
-	mQ[VS] = 1.f;
-}
-
-inline LLQuaternion::LLQuaternion(F32 x, F32 y, F32 z, F32 w)
-{
-	mQ[VX] = x;
-	mQ[VY] = y;
-	mQ[VZ] = z;
-	mQ[VS] = w;
-
-	//RN: don't normalize this case as its used mainly for temporaries during calculations
-	//normalize();
-	/*
-	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
-	mag -= 1.f;
-	mag = fabs(mag);
-	llassert(mag < 10.f*FP_MAG_THRESHOLD);
-	*/
-}
-
-inline LLQuaternion::LLQuaternion(const F32 *q)
-{
-	mQ[VX] = q[VX];
-	mQ[VY] = q[VY];
-	mQ[VZ] = q[VZ];
-	mQ[VS] = q[VW];
-
-	normalize();
-	/*
-	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
-	mag -= 1.f;
-	mag = fabs(mag);
-	llassert(mag < FP_MAG_THRESHOLD);
-	*/
-}
-
-
-inline void LLQuaternion::loadIdentity()
-{
-	mQ[VX] = 0.0f;
-	mQ[VY] = 0.0f;
-	mQ[VZ] = 0.0f;
-	mQ[VW] = 1.0f;
-}
-
-
-inline const LLQuaternion&	LLQuaternion::set(F32 x, F32 y, F32 z, F32 w)
-{
-	mQ[VX] = x;
-	mQ[VY] = y;
-	mQ[VZ] = z;
-	mQ[VS] = w;
-	normalize();
-	return (*this);
-}
-
-inline const LLQuaternion&	LLQuaternion::set(const LLQuaternion &quat)
-{
-	mQ[VX] = quat.mQ[VX];
-	mQ[VY] = quat.mQ[VY];
-	mQ[VZ] = quat.mQ[VZ];
-	mQ[VW] = quat.mQ[VW];
-	normalize();
-	return (*this);
-}
-
-inline const LLQuaternion&	LLQuaternion::set(const F32 *q)
-{
-	mQ[VX] = q[VX];
-	mQ[VY] = q[VY];
-	mQ[VZ] = q[VZ];
-	mQ[VS] = q[VW];
-	normalize();
-	return (*this);
-}
-
-
-// deprecated
-inline const LLQuaternion&	LLQuaternion::setQuatInit(F32 x, F32 y, F32 z, F32 w)
-{
-	mQ[VX] = x;
-	mQ[VY] = y;
-	mQ[VZ] = z;
-	mQ[VS] = w;
-	normalize();
-	return (*this);
-}
-
-// deprecated
-inline const LLQuaternion&	LLQuaternion::setQuat(const LLQuaternion &quat)
-{
-	mQ[VX] = quat.mQ[VX];
-	mQ[VY] = quat.mQ[VY];
-	mQ[VZ] = quat.mQ[VZ];
-	mQ[VW] = quat.mQ[VW];
-	normalize();
-	return (*this);
-}
-
-// deprecated
-inline const LLQuaternion&	LLQuaternion::setQuat(const F32 *q)
-{
-	mQ[VX] = q[VX];
-	mQ[VY] = q[VY];
-	mQ[VZ] = q[VZ];
-	mQ[VS] = q[VW];
-	normalize();
-	return (*this);
-}
-
-// There may be a cheaper way that avoids the sqrt.
-// Does sin_a = VX*VX + VY*VY + VZ*VZ?
-// Copied from Matrix and Quaternion FAQ 1.12
-inline void LLQuaternion::getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const
-{
-	F32 cos_a = mQ[VW];
-	if (cos_a > 1.0f) cos_a = 1.0f;
-	if (cos_a < -1.0f) cos_a = -1.0f;
-
-    F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
-
-    if ( fabs( sin_a ) < 0.0005f )
-		sin_a = 1.0f;
-	else
-		sin_a = 1.f/sin_a;
-
-    F32 temp_angle = 2.0f * (F32) acos( cos_a );
-	if (temp_angle > F_PI)
-	{
-		// The (angle,axis) pair should never have angles outside [PI, -PI]
-		// since we want the _shortest_ (angle,axis) solution.
-		// Since acos is defined for [0, PI], and we multiply by 2.0, we
-		// can push the angle outside the acceptible range.
-		// When this happens we set the angle to the other portion of a 
-		// full 2PI rotation, and negate the axis, which reverses the 
-		// direction of the rotation (by the right-hand rule).
-		*angle = 2.f * F_PI - temp_angle;
-    	*x = - mQ[VX] * sin_a;
-    	*y = - mQ[VY] * sin_a;
-    	*z = - mQ[VZ] * sin_a;
-	}
-	else
-	{
-		*angle = temp_angle;
-    	*x = mQ[VX] * sin_a;
-    	*y = mQ[VY] * sin_a;
-    	*z = mQ[VZ] * sin_a;
-	}
-}
-
-inline const LLQuaternion& LLQuaternion::conjugate()
-{
-	mQ[VX] *= -1.f;
-	mQ[VY] *= -1.f;
-	mQ[VZ] *= -1.f;
-	return (*this);
-}
-
-inline const LLQuaternion& LLQuaternion::conjQuat()
-{
-	mQ[VX] *= -1.f;
-	mQ[VY] *= -1.f;
-	mQ[VZ] *= -1.f;
-	return (*this);
-}
-
-// Transpose
-inline const LLQuaternion& LLQuaternion::transpose()
-{
-	mQ[VX] *= -1.f;
-	mQ[VY] *= -1.f;
-	mQ[VZ] *= -1.f;
-	return (*this);
-}
-
-// deprecated
-inline const LLQuaternion& LLQuaternion::transQuat()
-{
-	mQ[VX] *= -1.f;
-	mQ[VY] *= -1.f;
-	mQ[VZ] *= -1.f;
-	return (*this);
-}
-
-
-inline LLQuaternion 	operator+(const LLQuaternion &a, const LLQuaternion &b)
-{
-	return LLQuaternion( 
-		a.mQ[VX] + b.mQ[VX],
-		a.mQ[VY] + b.mQ[VY],
-		a.mQ[VZ] + b.mQ[VZ],
-		a.mQ[VW] + b.mQ[VW] );
-}
-
-
-inline LLQuaternion 	operator-(const LLQuaternion &a, const LLQuaternion &b)
-{
-	return LLQuaternion( 
-		a.mQ[VX] - b.mQ[VX],
-		a.mQ[VY] - b.mQ[VY],
-		a.mQ[VZ] - b.mQ[VZ],
-		a.mQ[VW] - b.mQ[VW] );
-}
-
-
-inline LLQuaternion 	operator-(const LLQuaternion &a)
-{
-	return LLQuaternion(
-		-a.mQ[VX],
-		-a.mQ[VY],
-		-a.mQ[VZ],
-		-a.mQ[VW] );
-}
-
-
-inline LLQuaternion 	operator*(F32 a, const LLQuaternion &q)
-{
-	return LLQuaternion(
-		a * q.mQ[VX],
-		a * q.mQ[VY],
-		a * q.mQ[VZ],
-		a * q.mQ[VW] );
-}
-
-
-inline LLQuaternion 	operator*(const LLQuaternion &q, F32 a)
-{
-	return LLQuaternion(
-		a * q.mQ[VX],
-		a * q.mQ[VY],
-		a * q.mQ[VZ],
-		a * q.mQ[VW] );
-}
-
-inline LLQuaternion	operator~(const LLQuaternion &a)
-{
-	LLQuaternion q(a);
-	q.conjQuat();
-	return q;
-}
-
-inline bool	LLQuaternion::operator==(const LLQuaternion &b) const
-{
-	return (  (mQ[VX] == b.mQ[VX])
-			&&(mQ[VY] == b.mQ[VY])
-			&&(mQ[VZ] == b.mQ[VZ])
-			&&(mQ[VS] == b.mQ[VS]));
-}
-
-inline bool	LLQuaternion::operator!=(const LLQuaternion &b) const
-{
-	return (  (mQ[VX] != b.mQ[VX])
-			||(mQ[VY] != b.mQ[VY])
-			||(mQ[VZ] != b.mQ[VZ])
-			||(mQ[VS] != b.mQ[VS]));
-}
-
-inline const LLQuaternion&	operator*=(LLQuaternion &a, const LLQuaternion &b)
-{
-#if 1
-	LLQuaternion q(
-		b.mQ[3] * a.mQ[0] + b.mQ[0] * a.mQ[3] + b.mQ[1] * a.mQ[2] - b.mQ[2] * a.mQ[1],
-		b.mQ[3] * a.mQ[1] + b.mQ[1] * a.mQ[3] + b.mQ[2] * a.mQ[0] - b.mQ[0] * a.mQ[2],
-		b.mQ[3] * a.mQ[2] + b.mQ[2] * a.mQ[3] + b.mQ[0] * a.mQ[1] - b.mQ[1] * a.mQ[0],
-		b.mQ[3] * a.mQ[3] - b.mQ[0] * a.mQ[0] - b.mQ[1] * a.mQ[1] - b.mQ[2] * a.mQ[2]
-	);
-	a = q;
-#else
-	a = a * b;
-#endif
-	return a;
-}
-
-const F32 ONE_PART_IN_A_MILLION = 0.000001f;
-
-inline F32	LLQuaternion::normalize()
-{
-	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
-
-	if (mag > FP_MAG_THRESHOLD)
-	{
-		// Floating point error can prevent some quaternions from achieving
-		// exact unity length.  When trying to renormalize such quaternions we
-		// can oscillate between multiple quantized states.  To prevent such
-		// drifts we only renomalize if the length is far enough from unity.
-		if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
-		{
-			F32 oomag = 1.f/mag;
-			mQ[VX] *= oomag;
-			mQ[VY] *= oomag;
-			mQ[VZ] *= oomag;
-			mQ[VS] *= oomag;
-		}
-	}
-	else
-	{
-		// we were given a very bad quaternion so we set it to identity
-		mQ[VX] = 0.f;
-		mQ[VY] = 0.f;
-		mQ[VZ] = 0.f;
-		mQ[VS] = 1.f;
-	}
-
-	return mag;
-}
-
-// deprecated
-inline F32	LLQuaternion::normQuat()
-{
-	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
-
-	if (mag > FP_MAG_THRESHOLD)
-	{
-		if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
-		{
-			// only renormalize if length not close enough to 1.0 already
-			F32 oomag = 1.f/mag;
-			mQ[VX] *= oomag;
-			mQ[VY] *= oomag;
-			mQ[VZ] *= oomag;
-			mQ[VS] *= oomag;
-		}
-	}
-	else
-	{
-		mQ[VX] = 0.f;
-		mQ[VY] = 0.f;
-		mQ[VZ] = 0.f;
-		mQ[VS] = 1.f;
-	}
-
-	return mag;
-}
-
-LLQuaternion::Order StringToOrder( const char *str );
-
-// Some notes about Quaternions
-
-// What is a Quaternion?
-// ---------------------
-// A quaternion is a point in 4-dimensional complex space.
-// Q = { Qx, Qy, Qz, Qw }
-// 
-//
-// Why Quaternions?
-// ----------------
-// The set of quaternions that make up the the 4-D unit sphere 
-// can be mapped to the set of all rotations in 3-D space.  Sometimes
-// it is easier to describe/manipulate rotations in quaternion space
-// than rotation-matrix space.
-//
-//
-// How Quaternions?
-// ----------------
-// In order to take advantage of quaternions we need to know how to
-// go from rotation-matricies to quaternions and back.  We also have
-// to agree what variety of rotations we're generating.
-// 
-// Consider the equation...   v' = v * R 
-//
-// There are two ways to think about rotations of vectors.
-// 1) v' is the same vector in a different reference frame
-// 2) v' is a new vector in the same reference frame
-//
-// bookmark -- which way are we using?
-// 
-// 
-// Quaternion from Angle-Axis:
-// ---------------------------
-// Suppose we wanted to represent a rotation of some angle (theta) 
-// about some axis ({Ax, Ay, Az})...
-//
-// axis of rotation = {Ax, Ay, Az} 
-// angle_of_rotation = theta
-//
-// s = sin(0.5 * theta)
-// c = cos(0.5 * theta)
-// Q = { s * Ax, s * Ay, s * Az, c }
-//
-//
-// 3x3 Matrix from Quaternion
-// --------------------------
-//
-//     |                                                                    |
-//     | 1 - 2 * (y^2 + z^2)   2 * (x * y + z * w)     2 * (y * w - x * z)  |
-//     |                                                                    |
-// M = | 2 * (x * y - z * w)   1 - 2 * (x^2 + z^2)     2 * (y * z + x * w)  |
-//     |                                                                    |
-//     | 2 * (x * z + y * w)   2 * (y * z - x * w)     1 - 2 * (x^2 + y^2)  |
-//     |                                                                    |
-
-#endif
+/** 
+ * @file llquaternion.h
+ * @brief LLQuaternion class header file.
+ *
+ * $LicenseInfo:firstyear=2000&license=viewergpl$
+ * 
+ * Copyright (c) 2000-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LLQUATERNION_H
+#define LLQUATERNION_H
+
+#include <iostream>
+
+#ifndef LLMATH_H //enforce specific include order to avoid tangling inline dependencies
+#error "Please include llmath.h first."
+#endif
+
+class LLVector4;
+class LLVector3;
+class LLVector3d;
+class LLMatrix4;
+class LLMatrix3;
+
+//	NOTA BENE: Quaternion code is written assuming Unit Quaternions!!!!
+//			   Moreover, it is written assuming that all vectors and matricies
+//			   passed as arguments are normalized and unitary respectively.
+//			   VERY VERY VERY VERY BAD THINGS will happen if these assumptions fail.
+
+static const U32 LENGTHOFQUAT = 4;
+
+class LLQuaternion
+{
+public:
+	F32 mQ[LENGTHOFQUAT];
+
+	static const LLQuaternion DEFAULT;
+
+	LLQuaternion();									// Initializes Quaternion to (0,0,0,1)
+	explicit LLQuaternion(const LLMatrix4 &mat);				// Initializes Quaternion from Matrix4
+	explicit LLQuaternion(const LLMatrix3 &mat);				// Initializes Quaternion from Matrix3
+	LLQuaternion(F32 x, F32 y, F32 z, F32 w);		// Initializes Quaternion to normalize(x, y, z, w)
+	LLQuaternion(F32 angle, const LLVector4 &vec);	// Initializes Quaternion to axis_angle2quat(angle, vec)
+	LLQuaternion(F32 angle, const LLVector3 &vec);	// Initializes Quaternion to axis_angle2quat(angle, vec)
+	LLQuaternion(const F32 *q);						// Initializes Quaternion to normalize(x, y, z, w)
+	LLQuaternion(const LLVector3 &x_axis,
+				 const LLVector3 &y_axis,
+				 const LLVector3 &z_axis);			// Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis]
+
+	BOOL isIdentity() const;
+	BOOL isNotIdentity() const;
+	BOOL isFinite() const;									// checks to see if all values of LLQuaternion are finite
+	void quantize16(F32 lower, F32 upper);					// changes the vector to reflect quatization
+	void quantize8(F32 lower, F32 upper);							// changes the vector to reflect quatization
+	void loadIdentity();											// Loads the quaternion that represents the identity rotation
+
+	const LLQuaternion&	set(F32 x, F32 y, F32 z, F32 w);		// Sets Quaternion to normalize(x, y, z, w)
+	const LLQuaternion&	set(const LLQuaternion &quat);			// Copies Quaternion
+	const LLQuaternion&	set(const F32 *q);						// Sets Quaternion to normalize(quat[VX], quat[VY], quat[VZ], quat[VW])
+	const LLQuaternion&	set(const LLMatrix3 &mat);				// Sets Quaternion to mat2quat(mat)
+	const LLQuaternion&	set(const LLMatrix4 &mat);				// Sets Quaternion to mat2quat(mat)
+
+	const LLQuaternion&	setAngleAxis(F32 angle, F32 x, F32 y, F32 z);	// Sets Quaternion to axis_angle2quat(angle, x, y, z)
+	const LLQuaternion&	setAngleAxis(F32 angle, const LLVector3 &vec);	// Sets Quaternion to axis_angle2quat(angle, vec)
+	const LLQuaternion&	setAngleAxis(F32 angle, const LLVector4 &vec);	// Sets Quaternion to axis_angle2quat(angle, vec)
+	const LLQuaternion&	setEulerAngles(F32 roll, F32 pitch, F32 yaw);	// Sets Quaternion to euler2quat(pitch, yaw, roll)
+
+	const LLQuaternion&	setQuatInit(F32 x, F32 y, F32 z, F32 w);	// deprecated
+	const LLQuaternion&	setQuat(const LLQuaternion &quat);			// deprecated
+	const LLQuaternion&	setQuat(const F32 *q);						// deprecated
+	const LLQuaternion&	setQuat(const LLMatrix3 &mat);				// deprecated
+	const LLQuaternion&	setQuat(const LLMatrix4 &mat);				// deprecated
+	const LLQuaternion&	setQuat(F32 angle, F32 x, F32 y, F32 z);	// deprecated
+	const LLQuaternion&	setQuat(F32 angle, const LLVector3 &vec);	// deprecated
+	const LLQuaternion&	setQuat(F32 angle, const LLVector4 &vec);	// deprecated
+	const LLQuaternion&	setQuat(F32 roll, F32 pitch, F32 yaw);		// deprecated
+
+	LLMatrix4	getMatrix4(void) const;							// Returns the Matrix4 equivalent of Quaternion
+	LLMatrix3	getMatrix3(void) const;							// Returns the Matrix3 equivalent of Quaternion
+	void		getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const;	// returns rotation in radians about axis x,y,z
+	void		getAngleAxis(F32* angle, LLVector3 &vec) const;
+	void		getEulerAngles(F32 *roll, F32* pitch, F32 *yaw) const;
+
+	F32	normalize();	// Normalizes Quaternion and returns magnitude
+	F32	normQuat();		// deprecated
+
+	const LLQuaternion&	conjugate(void);	// Conjugates Quaternion and returns result
+	const LLQuaternion&	conjQuat(void);		// deprecated
+
+	// Other useful methods
+	const LLQuaternion&	transpose();		// transpose (same as conjugate)
+	const LLQuaternion&	transQuat();		// deprecated
+
+	void			shortestArc(const LLVector3 &a, const LLVector3 &b);	// shortest rotation from a to b
+	const LLQuaternion& constrain(F32 radians);						// constrains rotation to a cone angle specified in radians
+
+	// Standard operators
+	friend std::ostream& operator<<(std::ostream &s, const LLQuaternion &a);					// Prints a
+	friend LLQuaternion operator+(const LLQuaternion &a, const LLQuaternion &b);	// Addition
+	friend LLQuaternion operator-(const LLQuaternion &a, const LLQuaternion &b);	// Subtraction
+	friend LLQuaternion operator-(const LLQuaternion &a);							// Negation
+	friend LLQuaternion operator*(F32 a, const LLQuaternion &q);					// Scale
+	friend LLQuaternion operator*(const LLQuaternion &q, F32 b);					// Scale
+	friend LLQuaternion operator*(const LLQuaternion &a, const LLQuaternion &b);	// Returns a * b
+	friend LLQuaternion operator~(const LLQuaternion &a);							// Returns a* (Conjugate of a)
+	bool operator==(const LLQuaternion &b) const;			// Returns a == b
+	bool operator!=(const LLQuaternion &b) const;			// Returns a != b
+
+	friend const LLQuaternion& operator*=(LLQuaternion &a, const LLQuaternion &b);	// Returns a * b
+
+	friend LLVector4 operator*(const LLVector4 &a, const LLQuaternion &rot);		// Rotates a by rot
+	friend LLVector3 operator*(const LLVector3 &a, const LLQuaternion &rot);		// Rotates a by rot
+	friend LLVector3d operator*(const LLVector3d &a, const LLQuaternion &rot);		// Rotates a by rot
+
+	// Non-standard operators
+	friend F32 dot(const LLQuaternion &a, const LLQuaternion &b);
+	friend LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q);		// linear interpolation (t = 0 to 1) from p to q
+	friend LLQuaternion lerp(F32 t, const LLQuaternion &q);								// linear interpolation (t = 0 to 1) from identity to q
+	friend LLQuaternion slerp(F32 t, const LLQuaternion &p, const LLQuaternion &q); 	// spherical linear interpolation from p to q
+	friend LLQuaternion slerp(F32 t, const LLQuaternion &q);							// spherical linear interpolation from identity to q
+	friend LLQuaternion nlerp(F32 t, const LLQuaternion &p, const LLQuaternion &q); 	// normalized linear interpolation from p to q
+	friend LLQuaternion nlerp(F32 t, const LLQuaternion &q); 							// normalized linear interpolation from p to q
+
+	LLVector3	packToVector3() const;						// Saves space by using the fact that our quaternions are normalized
+	void		unpackFromVector3(const LLVector3& vec);	// Saves space by using the fact that our quaternions are normalized
+
+	enum Order {
+		XYZ = 0,
+		YZX = 1,
+		ZXY = 2,
+		XZY = 3,
+		YXZ = 4,
+		ZYX = 5
+	};
+	// Creates a quaternions from maya's rotation representation,
+	// which is 3 rotations (in DEGREES) in the specified order
+	friend LLQuaternion mayaQ(F32 x, F32 y, F32 z, Order order);
+
+	// Conversions between Order and strings like "xyz" or "ZYX"
+	friend const char *OrderToString( const Order order );
+	friend Order StringToOrder( const char *str );
+
+	static BOOL parseQuat(const std::string& buf, LLQuaternion* value);
+
+	// For debugging, only
+	//static U32 mMultCount;
+};
+
+// checker
+inline BOOL	LLQuaternion::isFinite() const
+{
+	return (llfinite(mQ[VX]) && llfinite(mQ[VY]) && llfinite(mQ[VZ]) && llfinite(mQ[VS]));
+}
+
+inline BOOL LLQuaternion::isIdentity() const
+{
+	return 
+		( mQ[VX] == 0.f ) &&
+		( mQ[VY] == 0.f ) &&
+		( mQ[VZ] == 0.f ) &&
+		( mQ[VS] == 1.f );
+}
+
+inline BOOL LLQuaternion::isNotIdentity() const
+{
+	return 
+		( mQ[VX] != 0.f ) ||
+		( mQ[VY] != 0.f ) ||
+		( mQ[VZ] != 0.f ) ||
+		( mQ[VS] != 1.f );
+}
+
+
+
+inline LLQuaternion::LLQuaternion(void)
+{
+	mQ[VX] = 0.f;
+	mQ[VY] = 0.f;
+	mQ[VZ] = 0.f;
+	mQ[VS] = 1.f;
+}
+
+inline LLQuaternion::LLQuaternion(F32 x, F32 y, F32 z, F32 w)
+{
+	mQ[VX] = x;
+	mQ[VY] = y;
+	mQ[VZ] = z;
+	mQ[VS] = w;
+
+	//RN: don't normalize this case as its used mainly for temporaries during calculations
+	//normalize();
+	/*
+	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
+	mag -= 1.f;
+	mag = fabs(mag);
+	llassert(mag < 10.f*FP_MAG_THRESHOLD);
+	*/
+}
+
+inline LLQuaternion::LLQuaternion(const F32 *q)
+{
+	mQ[VX] = q[VX];
+	mQ[VY] = q[VY];
+	mQ[VZ] = q[VZ];
+	mQ[VS] = q[VW];
+
+	normalize();
+	/*
+	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
+	mag -= 1.f;
+	mag = fabs(mag);
+	llassert(mag < FP_MAG_THRESHOLD);
+	*/
+}
+
+
+inline void LLQuaternion::loadIdentity()
+{
+	mQ[VX] = 0.0f;
+	mQ[VY] = 0.0f;
+	mQ[VZ] = 0.0f;
+	mQ[VW] = 1.0f;
+}
+
+
+inline const LLQuaternion&	LLQuaternion::set(F32 x, F32 y, F32 z, F32 w)
+{
+	mQ[VX] = x;
+	mQ[VY] = y;
+	mQ[VZ] = z;
+	mQ[VS] = w;
+	normalize();
+	return (*this);
+}
+
+inline const LLQuaternion&	LLQuaternion::set(const LLQuaternion &quat)
+{
+	mQ[VX] = quat.mQ[VX];
+	mQ[VY] = quat.mQ[VY];
+	mQ[VZ] = quat.mQ[VZ];
+	mQ[VW] = quat.mQ[VW];
+	normalize();
+	return (*this);
+}
+
+inline const LLQuaternion&	LLQuaternion::set(const F32 *q)
+{
+	mQ[VX] = q[VX];
+	mQ[VY] = q[VY];
+	mQ[VZ] = q[VZ];
+	mQ[VS] = q[VW];
+	normalize();
+	return (*this);
+}
+
+
+// deprecated
+inline const LLQuaternion&	LLQuaternion::setQuatInit(F32 x, F32 y, F32 z, F32 w)
+{
+	mQ[VX] = x;
+	mQ[VY] = y;
+	mQ[VZ] = z;
+	mQ[VS] = w;
+	normalize();
+	return (*this);
+}
+
+// deprecated
+inline const LLQuaternion&	LLQuaternion::setQuat(const LLQuaternion &quat)
+{
+	mQ[VX] = quat.mQ[VX];
+	mQ[VY] = quat.mQ[VY];
+	mQ[VZ] = quat.mQ[VZ];
+	mQ[VW] = quat.mQ[VW];
+	normalize();
+	return (*this);
+}
+
+// deprecated
+inline const LLQuaternion&	LLQuaternion::setQuat(const F32 *q)
+{
+	mQ[VX] = q[VX];
+	mQ[VY] = q[VY];
+	mQ[VZ] = q[VZ];
+	mQ[VS] = q[VW];
+	normalize();
+	return (*this);
+}
+
+// There may be a cheaper way that avoids the sqrt.
+// Does sin_a = VX*VX + VY*VY + VZ*VZ?
+// Copied from Matrix and Quaternion FAQ 1.12
+inline void LLQuaternion::getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const
+{
+	F32 cos_a = mQ[VW];
+	if (cos_a > 1.0f) cos_a = 1.0f;
+	if (cos_a < -1.0f) cos_a = -1.0f;
+
+    F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
+
+    if ( fabs( sin_a ) < 0.0005f )
+		sin_a = 1.0f;
+	else
+		sin_a = 1.f/sin_a;
+
+    F32 temp_angle = 2.0f * (F32) acos( cos_a );
+	if (temp_angle > F_PI)
+	{
+		// The (angle,axis) pair should never have angles outside [PI, -PI]
+		// since we want the _shortest_ (angle,axis) solution.
+		// Since acos is defined for [0, PI], and we multiply by 2.0, we
+		// can push the angle outside the acceptible range.
+		// When this happens we set the angle to the other portion of a 
+		// full 2PI rotation, and negate the axis, which reverses the 
+		// direction of the rotation (by the right-hand rule).
+		*angle = 2.f * F_PI - temp_angle;
+    	*x = - mQ[VX] * sin_a;
+    	*y = - mQ[VY] * sin_a;
+    	*z = - mQ[VZ] * sin_a;
+	}
+	else
+	{
+		*angle = temp_angle;
+    	*x = mQ[VX] * sin_a;
+    	*y = mQ[VY] * sin_a;
+    	*z = mQ[VZ] * sin_a;
+	}
+}
+
+inline const LLQuaternion& LLQuaternion::conjugate()
+{
+	mQ[VX] *= -1.f;
+	mQ[VY] *= -1.f;
+	mQ[VZ] *= -1.f;
+	return (*this);
+}
+
+inline const LLQuaternion& LLQuaternion::conjQuat()
+{
+	mQ[VX] *= -1.f;
+	mQ[VY] *= -1.f;
+	mQ[VZ] *= -1.f;
+	return (*this);
+}
+
+// Transpose
+inline const LLQuaternion& LLQuaternion::transpose()
+{
+	mQ[VX] *= -1.f;
+	mQ[VY] *= -1.f;
+	mQ[VZ] *= -1.f;
+	return (*this);
+}
+
+// deprecated
+inline const LLQuaternion& LLQuaternion::transQuat()
+{
+	mQ[VX] *= -1.f;
+	mQ[VY] *= -1.f;
+	mQ[VZ] *= -1.f;
+	return (*this);
+}
+
+
+inline LLQuaternion 	operator+(const LLQuaternion &a, const LLQuaternion &b)
+{
+	return LLQuaternion( 
+		a.mQ[VX] + b.mQ[VX],
+		a.mQ[VY] + b.mQ[VY],
+		a.mQ[VZ] + b.mQ[VZ],
+		a.mQ[VW] + b.mQ[VW] );
+}
+
+
+inline LLQuaternion 	operator-(const LLQuaternion &a, const LLQuaternion &b)
+{
+	return LLQuaternion( 
+		a.mQ[VX] - b.mQ[VX],
+		a.mQ[VY] - b.mQ[VY],
+		a.mQ[VZ] - b.mQ[VZ],
+		a.mQ[VW] - b.mQ[VW] );
+}
+
+
+inline LLQuaternion 	operator-(const LLQuaternion &a)
+{
+	return LLQuaternion(
+		-a.mQ[VX],
+		-a.mQ[VY],
+		-a.mQ[VZ],
+		-a.mQ[VW] );
+}
+
+
+inline LLQuaternion 	operator*(F32 a, const LLQuaternion &q)
+{
+	return LLQuaternion(
+		a * q.mQ[VX],
+		a * q.mQ[VY],
+		a * q.mQ[VZ],
+		a * q.mQ[VW] );
+}
+
+
+inline LLQuaternion 	operator*(const LLQuaternion &q, F32 a)
+{
+	return LLQuaternion(
+		a * q.mQ[VX],
+		a * q.mQ[VY],
+		a * q.mQ[VZ],
+		a * q.mQ[VW] );
+}
+
+inline LLQuaternion	operator~(const LLQuaternion &a)
+{
+	LLQuaternion q(a);
+	q.conjQuat();
+	return q;
+}
+
+inline bool	LLQuaternion::operator==(const LLQuaternion &b) const
+{
+	return (  (mQ[VX] == b.mQ[VX])
+			&&(mQ[VY] == b.mQ[VY])
+			&&(mQ[VZ] == b.mQ[VZ])
+			&&(mQ[VS] == b.mQ[VS]));
+}
+
+inline bool	LLQuaternion::operator!=(const LLQuaternion &b) const
+{
+	return (  (mQ[VX] != b.mQ[VX])
+			||(mQ[VY] != b.mQ[VY])
+			||(mQ[VZ] != b.mQ[VZ])
+			||(mQ[VS] != b.mQ[VS]));
+}
+
+inline const LLQuaternion&	operator*=(LLQuaternion &a, const LLQuaternion &b)
+{
+#if 1
+	LLQuaternion q(
+		b.mQ[3] * a.mQ[0] + b.mQ[0] * a.mQ[3] + b.mQ[1] * a.mQ[2] - b.mQ[2] * a.mQ[1],
+		b.mQ[3] * a.mQ[1] + b.mQ[1] * a.mQ[3] + b.mQ[2] * a.mQ[0] - b.mQ[0] * a.mQ[2],
+		b.mQ[3] * a.mQ[2] + b.mQ[2] * a.mQ[3] + b.mQ[0] * a.mQ[1] - b.mQ[1] * a.mQ[0],
+		b.mQ[3] * a.mQ[3] - b.mQ[0] * a.mQ[0] - b.mQ[1] * a.mQ[1] - b.mQ[2] * a.mQ[2]
+	);
+	a = q;
+#else
+	a = a * b;
+#endif
+	return a;
+}
+
+const F32 ONE_PART_IN_A_MILLION = 0.000001f;
+
+inline F32	LLQuaternion::normalize()
+{
+	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
+
+	if (mag > FP_MAG_THRESHOLD)
+	{
+		// Floating point error can prevent some quaternions from achieving
+		// exact unity length.  When trying to renormalize such quaternions we
+		// can oscillate between multiple quantized states.  To prevent such
+		// drifts we only renomalize if the length is far enough from unity.
+		if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
+		{
+			F32 oomag = 1.f/mag;
+			mQ[VX] *= oomag;
+			mQ[VY] *= oomag;
+			mQ[VZ] *= oomag;
+			mQ[VS] *= oomag;
+		}
+	}
+	else
+	{
+		// we were given a very bad quaternion so we set it to identity
+		mQ[VX] = 0.f;
+		mQ[VY] = 0.f;
+		mQ[VZ] = 0.f;
+		mQ[VS] = 1.f;
+	}
+
+	return mag;
+}
+
+// deprecated
+inline F32	LLQuaternion::normQuat()
+{
+	F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
+
+	if (mag > FP_MAG_THRESHOLD)
+	{
+		if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
+		{
+			// only renormalize if length not close enough to 1.0 already
+			F32 oomag = 1.f/mag;
+			mQ[VX] *= oomag;
+			mQ[VY] *= oomag;
+			mQ[VZ] *= oomag;
+			mQ[VS] *= oomag;
+		}
+	}
+	else
+	{
+		mQ[VX] = 0.f;
+		mQ[VY] = 0.f;
+		mQ[VZ] = 0.f;
+		mQ[VS] = 1.f;
+	}
+
+	return mag;
+}
+
+LLQuaternion::Order StringToOrder( const char *str );
+
+// Some notes about Quaternions
+
+// What is a Quaternion?
+// ---------------------
+// A quaternion is a point in 4-dimensional complex space.
+// Q = { Qx, Qy, Qz, Qw }
+// 
+//
+// Why Quaternions?
+// ----------------
+// The set of quaternions that make up the the 4-D unit sphere 
+// can be mapped to the set of all rotations in 3-D space.  Sometimes
+// it is easier to describe/manipulate rotations in quaternion space
+// than rotation-matrix space.
+//
+//
+// How Quaternions?
+// ----------------
+// In order to take advantage of quaternions we need to know how to
+// go from rotation-matricies to quaternions and back.  We also have
+// to agree what variety of rotations we're generating.
+// 
+// Consider the equation...   v' = v * R 
+//
+// There are two ways to think about rotations of vectors.
+// 1) v' is the same vector in a different reference frame
+// 2) v' is a new vector in the same reference frame
+//
+// bookmark -- which way are we using?
+// 
+// 
+// Quaternion from Angle-Axis:
+// ---------------------------
+// Suppose we wanted to represent a rotation of some angle (theta) 
+// about some axis ({Ax, Ay, Az})...
+//
+// axis of rotation = {Ax, Ay, Az} 
+// angle_of_rotation = theta
+//
+// s = sin(0.5 * theta)
+// c = cos(0.5 * theta)
+// Q = { s * Ax, s * Ay, s * Az, c }
+//
+//
+// 3x3 Matrix from Quaternion
+// --------------------------
+//
+//     |                                                                    |
+//     | 1 - 2 * (y^2 + z^2)   2 * (x * y + z * w)     2 * (y * w - x * z)  |
+//     |                                                                    |
+// M = | 2 * (x * y - z * w)   1 - 2 * (x^2 + z^2)     2 * (y * z + x * w)  |
+//     |                                                                    |
+//     | 2 * (x * z + y * w)   2 * (y * z - x * w)     1 - 2 * (x^2 + y^2)  |
+//     |                                                                    |
+
+#endif
-- 
GitLab


From 314a89535791e1e5a0c3f4d901c9c1d16fb9b6cc Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 19 Aug 2010 16:48:15 -0500
Subject: [PATCH 671/683] Software fallback for avatar vertex skinning.

Reviewed by Nyx.
---
 indra/newview/lldrawpoolavatar.cpp | 200 +++++++++++++++++------------
 1 file changed, 115 insertions(+), 85 deletions(-)

diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index d698624c15b..ccc060f3fa2 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -490,14 +490,10 @@ S32 LLDrawPoolAvatar::getNumPasses()
 	{
 		return 8;
 	}
-	else if (getVertexShaderLevel() > 0)
+	else 
 	{
 		return 10;
 	}
-	else
-	{
-		return 4;
-	}
 #else
 	if (LLPipeline::sImpostorRender)
 	{
@@ -859,143 +855,168 @@ void LLDrawPoolAvatar::endRiggedSimple()
 
 void LLDrawPoolAvatar::beginRiggedAlpha()
 {
-	if (LLPipeline::sUnderWaterRender)
-	{
-		sVertexProgram = &gSkinnedObjectSimpleWaterProgram;
-	}
-	else
-	{
-		sVertexProgram = &gSkinnedObjectSimpleProgram;
-	}
-	sDiffuseChannel = 0;
-	sVertexProgram->bind();
-	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+	beginRiggedSimple();
 }
 
 void LLDrawPoolAvatar::endRiggedAlpha()
 {
-	sVertexProgram->unbind();
-	sVertexProgram = NULL;
-	LLVertexBuffer::unbind();
-	LLVertexBuffer::sWeight4Loc = -1;
+	endRiggedSimple();
 }
 
 
 void LLDrawPoolAvatar::beginRiggedFullbrightAlpha()
 {
-	if (LLPipeline::sUnderWaterRender)
-	{
-		sVertexProgram = &gSkinnedObjectFullbrightWaterProgram;
-	}
-	else
-	{
-		sVertexProgram = &gSkinnedObjectFullbrightProgram;
-	}
-	sDiffuseChannel = 0;
-	sVertexProgram->bind();
-	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+	beginRiggedFullbright();
 }
 
 void LLDrawPoolAvatar::endRiggedFullbrightAlpha()
 {
-	sVertexProgram->unbind();
-	sVertexProgram = NULL;
-	LLVertexBuffer::unbind();
-	LLVertexBuffer::sWeight4Loc = -1;
+	endRiggedFullbright();
 }
 
 void LLDrawPoolAvatar::beginRiggedGlow()
 {
-	if (LLPipeline::sUnderWaterRender)
-	{
-		sVertexProgram = &gSkinnedObjectFullbrightWaterProgram;
-	}
-	else
-	{
-		sVertexProgram = &gSkinnedObjectFullbrightProgram;
-	}
-	sDiffuseChannel = 0;
-	sVertexProgram->bind();
-	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+	beginRiggedFullbright();
 }
 
 void LLDrawPoolAvatar::endRiggedGlow()
 {
-	sVertexProgram->unbind();
-	sVertexProgram = NULL;
-	LLVertexBuffer::unbind();
-	LLVertexBuffer::sWeight4Loc = -1;
+	endRiggedFullbright();
 }
 
 void LLDrawPoolAvatar::beginRiggedFullbright()
 {
-	if (LLPipeline::sUnderWaterRender)
+	if (sShaderLevel > 0)
 	{
-		sVertexProgram = &gSkinnedObjectFullbrightWaterProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			sVertexProgram = &gSkinnedObjectFullbrightWaterProgram;
+		}
+		else
+		{
+			sVertexProgram = &gSkinnedObjectFullbrightProgram;
+		}
 	}
 	else
 	{
-		sVertexProgram = &gSkinnedObjectFullbrightProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			sVertexProgram = &gObjectFullbrightWaterProgram;
+		}
+		else
+		{
+			sVertexProgram = &gObjectFullbrightProgram;
+		}
+	}
+
+	if (sShaderLevel > 0 || gPipeline.canUseVertexShaders())
+	{
+		sDiffuseChannel = 0;
+		sVertexProgram->bind();
+		LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 	}
-	sDiffuseChannel = 0;
-	sVertexProgram->bind();
-	LLVertexBuffer::sWeight4Loc = gSkinnedObjectFullbrightProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
 void LLDrawPoolAvatar::endRiggedFullbright()
 {
 	LLVertexBuffer::unbind();
-	sVertexProgram->unbind();
-	sVertexProgram = NULL;
-	LLVertexBuffer::sWeight4Loc = -1;
+	if (sShaderLevel > 0 || gPipeline.canUseVertexShaders())
+	{
+		sVertexProgram->unbind();
+		sVertexProgram = NULL;
+		LLVertexBuffer::sWeight4Loc = -1;
+	}
 }
 
 void LLDrawPoolAvatar::beginRiggedShinySimple()
 {
-	if (LLPipeline::sUnderWaterRender)
+	if (sShaderLevel > 0)
 	{
-		sVertexProgram = &gSkinnedObjectShinySimpleWaterProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			sVertexProgram = &gSkinnedObjectShinySimpleWaterProgram;
+		}
+		else
+		{
+			sVertexProgram = &gSkinnedObjectShinySimpleProgram;
+		}
 	}
 	else
 	{
-		sVertexProgram = &gSkinnedObjectShinySimpleProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			sVertexProgram = &gObjectShinyWaterProgram;
+		}
+		else
+		{
+			sVertexProgram = &gObjectShinyProgram;
+		}
+	}
+
+	if (sShaderLevel > 0 || gPipeline.canUseVertexShaders())
+	{
+		sVertexProgram->bind();
+		LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
+		LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 	}
-	sVertexProgram->bind();
-	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
-	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
 void LLDrawPoolAvatar::endRiggedShinySimple()
 {
 	LLVertexBuffer::unbind();
-	LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
-	sVertexProgram->unbind();
-	sVertexProgram = NULL;
-	LLVertexBuffer::sWeight4Loc = -1;
+	if (sShaderLevel > 0 || gPipeline.canUseVertexShaders())
+	{
+		LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
+		sVertexProgram->unbind();
+		sVertexProgram = NULL;
+		LLVertexBuffer::sWeight4Loc = -1;
+	}
 }
 
 void LLDrawPoolAvatar::beginRiggedFullbrightShiny()
 {
-	if (LLPipeline::sUnderWaterRender)
+	if (sShaderLevel > 0)
 	{
-		sVertexProgram = &gSkinnedObjectFullbrightShinyWaterProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			sVertexProgram = &gSkinnedObjectFullbrightShinyWaterProgram;
+		}
+		else
+		{
+			sVertexProgram = &gSkinnedObjectFullbrightShinyProgram;
+		}
 	}
 	else
 	{
-		sVertexProgram = &gSkinnedObjectFullbrightShinyProgram;
+		if (LLPipeline::sUnderWaterRender)
+		{
+			sVertexProgram = &gObjectFullbrightShinyWaterProgram;
+		}
+		else
+		{
+			sVertexProgram = &gObjectFullbrightShinyProgram;
+		}
+	}
+
+
+	if (sShaderLevel > 0 || gPipeline.canUseVertexShaders())
+	{
+		sVertexProgram->bind();
+		LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
+		LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 	}
-	sVertexProgram->bind();
-	LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
-	LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
 }
 
 void LLDrawPoolAvatar::endRiggedFullbrightShiny()
 {
 	LLVertexBuffer::unbind();
-	LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
-	sVertexProgram->unbind();
-	sVertexProgram = NULL;
-	LLVertexBuffer::sWeight4Loc = -1;
+	if (sShaderLevel > 0 || gPipeline.canUseVertexShaders())
+	{
+		LLDrawPoolBump::unbindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false);
+		sVertexProgram->unbind();
+		sVertexProgram = NULL;
+		LLVertexBuffer::sWeight4Loc = -1;
+	}
 }
 
 
@@ -1356,11 +1377,17 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace*
 		LLStrider<LLVector3> position;
 		LLStrider<LLVector3> normal;
 
+		bool has_normal = buffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
 		buffer->getVertexStrider(position);
-		buffer->getNormalStrider(normal);
+
+		if (has_normal)
+		{
+			buffer->getNormalStrider(normal);
+		}
 
 		LLVector4a* pos = (LLVector4a*) position.get();
-		LLVector4a* norm = (LLVector4a*) normal.get();
+
+		LLVector4a* norm = has_normal ? (LLVector4a*) normal.get() : NULL;
 		
 		//build matrix palette
 		LLMatrix4a mp[64];
@@ -1420,10 +1447,13 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace*
 			final_mat.affineTransform(t, dst);
 			pos[j] = dst;
 
-			LLVector4a& n = vol_face.mNormals[j];
-			bind_shape_matrix.rotate(n, t);
-			final_mat.rotate(t, dst);
-			norm[j] = dst;
+			if (norm)
+			{
+				LLVector4a& n = vol_face.mNormals[j];
+				bind_shape_matrix.rotate(n, t);
+				final_mat.rotate(t, dst);
+				norm[j] = dst;
+			}
 		}
 	}
 }
-- 
GitLab


From 4075efaf0dd8842ece6f6a9890a686745310e2b5 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 19 Aug 2010 17:35:08 -0700
Subject: [PATCH 672/683] EXT-8525 FIX ellipsis are broken on the Favorites bar
 (trunk)

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

diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index d6c062fc5e0..6c5468edb69 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -399,7 +399,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
 		gGL.pushUIMatrix();
 		renderUTF8(std::string("..."), 
 				0,
-				cur_x / sScaleX, (F32)y,
+				(cur_x - origin.mV[VX]) / sScaleX, (F32)y,
 				color,
 				LEFT, valign,
 				style_to_add,
-- 
GitLab


From d53b6264850a5efe1e0182ab3629b99b86019d72 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Fri, 20 Aug 2010 12:38:54 -0700
Subject: [PATCH 673/683] fix gcc build error.

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

diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 7c60aabef72..7508cb3a275 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -213,8 +213,8 @@ class LLFace
 	F32         adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius );
 	BOOL        calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) ;
 public:
-	static F32  calcImportanceToCamera(F32 to_view_dir, F32 dist);
-	static F32 LLFace::adjustPixelArea(F32 importance, F32 pixel_area) ;
+	static F32 calcImportanceToCamera(F32 to_view_dir, F32 dist);
+	static F32 adjustPixelArea(F32 importance, F32 pixel_area) ;
 
 public:
 	
-- 
GitLab


From f263ee04441f5173a02974c51347f8bb3d23d29d Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 23 Aug 2010 11:32:58 -0600
Subject: [PATCH 674/683] added a toggle "LLGLManager::mDebugGPU" for debugging
 certain CPUs. added more debug code for EXT-6791: [crashhunters] Intel 965
 Crash in glCopyTexSubImage2D

---
 indra/llrender/llgl.cpp            |  89 +++++++++++--------------
 indra/llrender/llgl.h              |   9 ++-
 indra/llrender/llimagegl.cpp       | 101 ++++++-----------------------
 indra/newview/lldynamictexture.cpp |  18 +++--
 4 files changed, 77 insertions(+), 140 deletions(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 236594d6020..823208b095f 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -185,9 +185,6 @@ PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT =
 // GL_EXT_framebuffer_blit
 PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT = NULL;
 
-// GL_EXT_blend_func_separate
-PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT = NULL;
-
 // GL_ARB_draw_buffers
 PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB = NULL;
 
@@ -327,7 +324,6 @@ LLGLManager::LLGLManager() :
 	mHasCompressedTextures(FALSE),
 	mHasFramebufferObject(FALSE),
 	mHasFramebufferMultisample(FALSE),
-	mHasBlendFuncSeparate(FALSE),
 
 	mHasVertexBufferObject(FALSE),
 	mHasPBuffer(FALSE),
@@ -356,6 +352,8 @@ LLGLManager::LLGLManager() :
 
 	mHasSeparateSpecularColor(FALSE),
 
+	mDebugGPU(FALSE),
+
 	mDriverVersionMajor(1),
 	mDriverVersionMinor(0),
 	mDriverVersionRelease(0),
@@ -523,11 +521,23 @@ bool LLGLManager::initGL()
 		return false;
 	}
 	
+	setToDebugGPU();
 
 	initGLStates();
 	return true;
 }
 
+void LLGLManager::setToDebugGPU()
+{
+	//"MOBILE INTEL(R) 965 EXPRESS CHIP", 
+	if (mGLRenderer.find("INTEL") != std::string::npos && mGLRenderer.find("965") != std::string::npos)
+	{
+		mDebugGPU = TRUE ;
+	}
+
+	return ;
+}
+
 void LLGLManager::getGLInfo(LLSD& info)
 {
 	info["GLInfo"]["GLVendor"] = std::string((const char *)glGetString(GL_VENDOR));
@@ -636,11 +646,6 @@ void LLGLManager::initExtensions()
 	mHasDrawBuffers = TRUE;
 #else
 	mHasDrawBuffers = FALSE;
-# endif
-# if GL_EXT_blend_func_separate
-	mHasBlendFuncSeparate = TRUE;
-#else
-	mHasBlendFuncSeparate = FALSE;
 # endif
 	mHasMipMapGeneration = FALSE;
 	mHasSeparateSpecularColor = FALSE;
@@ -668,7 +673,6 @@ void LLGLManager::initExtensions()
 		&& ExtensionExists("GL_EXT_packed_depth_stencil", gGLHExts.mSysExts);
 	mHasFramebufferMultisample = mHasFramebufferObject && ExtensionExists("GL_EXT_framebuffer_multisample", gGLHExts.mSysExts);
 	mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts);
-	mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts);
 	mHasTextureRectangle = ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts);
 #if !LL_DARWIN
 	mHasPointParameters = !mIsATI && ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts);
@@ -692,7 +696,6 @@ void LLGLManager::initExtensions()
 		mHasFramebufferObject = FALSE;
 		mHasFramebufferMultisample = FALSE;
 		mHasDrawBuffers = FALSE;
-		mHasBlendFuncSeparate = FALSE;
 		mHasMipMapGeneration = FALSE;
 		mHasSeparateSpecularColor = FALSE;
 		mHasAnisotropic = FALSE;
@@ -717,7 +720,6 @@ void LLGLManager::initExtensions()
 		mHasShaderObjects = FALSE;
 		mHasVertexShader = FALSE;
 		mHasFragmentShader = FALSE;
-		mHasBlendFuncSeparate = FALSE;
 		LL_WARNS("RenderInit") << "GL extension support forced to SIMPLE level via LL_GL_BASICEXT" << LL_ENDL;
 	}
 	if (getenv("LL_GL_BLACKLIST"))	/* Flawfinder: ignore */
@@ -746,8 +748,7 @@ void LLGLManager::initExtensions()
 		if (strchr(blacklist,'r')) mHasDrawBuffers = FALSE;//S
 		if (strchr(blacklist,'s')) mHasFramebufferMultisample = FALSE;
 		if (strchr(blacklist,'t')) mHasTextureRectangle = FALSE;
-		if (strchr(blacklist,'u')) mHasBlendFuncSeparate = FALSE;//S
-		
+
 	}
 #endif // LL_LINUX || LL_SOLARIS
 	
@@ -795,14 +796,6 @@ void LLGLManager::initExtensions()
 	{
 		LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_fragment_shader" << LL_ENDL;
 	}
-	if (!mHasBlendFuncSeparate)
-	{
-		LL_INFOS("RenderInit") << "Couldn't initialize GL_EXT_blend_func_separate" << LL_ENDL;
-	}
-	if (!mHasDrawBuffers)
-	{
-		LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_draw_buffers" << LL_ENDL;
-	}
 
 	// Disable certain things due to known bugs
 	if (mIsIntel && mHasMipMapGeneration)
@@ -873,10 +866,6 @@ void LLGLManager::initExtensions()
 	{
 		glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDrawBuffersARB");
 	}
-	if (mHasBlendFuncSeparate)
-	{
-		glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlendFuncSeparateEXT");
-	}
 #if (!LL_LINUX && !LL_SOLARIS) || LL_LINUX_NV_GL_HEADERS
 	// This is expected to be a static symbol on Linux GL implementations, except if we use the nvidia headers - bah
 	glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)GLH_EXT_GET_PROC_ADDRESS("glDrawRangeElements");
@@ -1039,9 +1028,24 @@ void flush_glerror()
 	glGetError();
 }
 
-void do_assert_glerror()
+void assert_glerror()
 {
-	if (LL_UNLIKELY(!gGLManager.mInited))
+	if (!gGLActive)
+	{
+		//llwarns << "GL used while not active!" << llendl;
+
+		if (gDebugSession)
+		{
+			//ll_fail("GL used while not active");
+		}
+	}
+
+	if (gNoRender || !gDebugGL) 
+	{
+		return;
+	}
+	
+	if (!gGLManager.mInited)
 	{
 		LL_ERRS("RenderInit") << "GL not initialized" << LL_ENDL;
 	}
@@ -1049,9 +1053,10 @@ void do_assert_glerror()
 	GLenum error;
 	error = glGetError();
 	BOOL quit = FALSE;
-	while (LL_UNLIKELY(error))
+	while (error)
 	{
 		quit = TRUE;
+#ifndef LL_LINUX // *FIX: !  This should be an error for linux as well.
 		GLubyte const * gl_error_msg = gluErrorString(error);
 		if (NULL != gl_error_msg)
 		{
@@ -1075,6 +1080,7 @@ void do_assert_glerror()
 			}
 		}
 		error = glGetError();
+#endif
 	}
 
 	if (quit)
@@ -1090,25 +1096,6 @@ void do_assert_glerror()
 	}
 }
 
-void assert_glerror()
-{
-	if (!gGLActive)
-	{
-		//llwarns << "GL used while not active!" << llendl;
-
-		if (gDebugSession)
-		{
-			//ll_fail("GL used while not active");
-		}
-	}
-
-	if (!gNoRender && gDebugGL) 
-	{
-		do_assert_glerror();
-	}
-}
-	
-
 void clear_glerror()
 {
 	//  Create or update texture to be used with this data 
@@ -1122,7 +1109,7 @@ void clear_glerror()
 //
 
 // Static members
-boost::unordered_map<LLGLenum, LLGLboolean> LLGLState::sStateMap;
+std::map<LLGLenum, LLGLboolean> LLGLState::sStateMap;
 
 GLboolean LLGLDepthTest::sDepthEnabled = GL_FALSE; // OpenGL default
 GLenum LLGLDepthTest::sDepthFunc = GL_LESS; // OpenGL default
@@ -1170,7 +1157,7 @@ void LLGLState::resetTextureStates()
 void LLGLState::dumpStates() 
 {
 	LL_INFOS("RenderState") << "GL States:" << LL_ENDL;
-	for (boost::unordered_map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
+	for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
 		 iter != sStateMap.end(); ++iter)
 	{
 		LL_INFOS("RenderState") << llformat(" 0x%04x : %s",(S32)iter->first,iter->second?"TRUE":"FALSE") << LL_ENDL;
@@ -1206,7 +1193,7 @@ void LLGLState::checkStates(const std::string& msg)
 		}
 	}
 	
-	for (boost::unordered_map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
+	for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
 		 iter != sStateMap.end(); ++iter)
 	{
 		LLGLenum state = iter->first;
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index c4f5d91e1ab..620aa5bee04 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -36,7 +36,7 @@
 // This file contains various stuff for handling gl extensions and other gl related stuff.
 
 #include <string>
-#include <boost/unordered_map.hpp>
+#include <map>
 #include <list>
 
 #include "llerror.h"
@@ -87,7 +87,6 @@ class LLGLManager
 	BOOL mHasCompressedTextures;
 	BOOL mHasFramebufferObject;
 	BOOL mHasFramebufferMultisample;
-	BOOL mHasBlendFuncSeparate;
 	
 	// ARB Extensions
 	BOOL mHasVertexBufferObject;
@@ -120,6 +119,9 @@ class LLGLManager
 
 	// Misc extensions
 	BOOL mHasSeparateSpecularColor;
+
+	//whether this GPU is in the debug list.
+	BOOL mDebugGPU;
 	
 	S32 mDriverVersionMajor;
 	S32 mDriverVersionMinor;
@@ -148,6 +150,7 @@ class LLGLManager
 	void initExtensions();
 	void initGLStates();
 	void initGLImages();
+	void setToDebugGPU();
 };
 
 extern LLGLManager gGLManager;
@@ -241,7 +244,7 @@ class LLGLState
 	static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0x0001);
 	
 protected:
-	static boost::unordered_map<LLGLenum, LLGLboolean> sStateMap;
+	static std::map<LLGLenum, LLGLboolean> sStateMap;
 	
 public:
 	enum { CURRENT_STATE = -2 };
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 1a48c8a06cb..ee26f9819ce 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -150,12 +150,12 @@ void LLImageGL::checkTexSize(bool forced) const
 			if (gDebugSession)
 			{
 				gFailLog << "wrong texture size and discard level!" << 
-					mWidth << " Height: " << mHeight << " Current Level: " << mCurrentDiscardLevel << std::endl;
+					mWidth << " Height: " << mHeight << " Current Level: " << (S32)mCurrentDiscardLevel << std::endl;
 			}
 			else
 			{
 				llerrs << "wrong texture size and discard level: width: " << 
-					mWidth << " Height: " << mHeight << " Current Level: " << mCurrentDiscardLevel << llendl ;
+					mWidth << " Height: " << mHeight << " Current Level: " << (S32)mCurrentDiscardLevel << llendl ;
 			}
 		}
 
@@ -1057,8 +1057,12 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_
 {
 	if (gGL.getTexUnit(0)->bind(this, false, true))
 	{
-		checkTexSize(true) ;
-		llcallstacks << fb_x << " : " << fb_y << " : " << x_pos << " : " << y_pos << " : " << width << " : " << height << llcallstacksendl ;
+		if(gGLManager.mDebugGPU)
+		{
+			llinfos << "Calling glCopyTexSubImage2D(...)" << llendl ;
+			checkTexSize(true) ;
+			llcallstacks << fb_x << " : " << fb_y << " : " << x_pos << " : " << y_pos << " : " << width << " : " << height << llcallstacksendl ;
+		}
 
 		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height);
 		mGLTextureCreated = true;
@@ -1654,7 +1658,7 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
 	}
 }
 
-void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
+void LLImageGL::analyzeAlpha(const void* data_in, S32 w, S32 h)
 {
 	if(!mNeedsAlphaAndPickMask)
 	{
@@ -1662,91 +1666,26 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
 	}
 
 	U32 length = w * h;
-	U32 alphatotal = 0;
+	const GLubyte* current = ((const GLubyte*) data_in) + mAlphaOffset ;
 	
-	U32 sample[16];
-	memset(sample, 0, sizeof(U32)*16);
-
-	// generate histogram of quantized alpha.
-	// also add-in the histogram of a 2x2 box-sampled version.  The idea is
-	// this will mid-skew the data (and thus increase the chances of not
-	// being used as a mask) from high-frequency alpha maps which
-	// suffer the worst from aliasing when used as alpha masks.
-	if (w >= 2 && h >= 2)
-	{
-		llassert(w%2 == 0);
-		llassert(h%2 == 0);
-		const GLubyte* rowstart = ((const GLubyte*) data_in) + mAlphaOffset;
-		for (U32 y = 0; y < h; y+=2)
-		{
-			const GLubyte* current = rowstart;
-			for (U32 x = 0; x < w; x+=2)
-			{
-				const U32 s1 = current[0];
-				alphatotal += s1;
-				const U32 s2 = current[w * mAlphaStride];
-				alphatotal += s2;
-				current += mAlphaStride;
-				const U32 s3 = current[0];
-				alphatotal += s3;
-				const U32 s4 = current[w * mAlphaStride];
-				alphatotal += s4;
-				current += mAlphaStride;
-
-				++sample[s1/16];
-				++sample[s2/16];
-				++sample[s3/16];
-				++sample[s4/16];
-
-				const U32 asum = (s1+s2+s3+s4);
-				alphatotal += asum;
-				sample[asum/(16*4)] += 4;
-			}
-			
-			rowstart += 2 * w * mAlphaStride;
-		}
-		length *= 2; // we sampled everything twice, essentially
-	}
-	else
+	S32 sample[16];
+	memset(sample, 0, sizeof(S32)*16);
+
+	for (U32 i = 0; i < length; i++)
 	{
-		const GLubyte* current = ((const GLubyte*) data_in) + mAlphaOffset;
-		for (U32 i = 0; i < length; i++)
-		{
-			const U32 s1 = *current;
-			alphatotal += s1;
-			++sample[s1/16];
-			current += mAlphaStride;
-		}
+		++sample[*current/16];
+		current += mAlphaStride ;
 	}
-	
-	// if more than 1/16th of alpha samples are mid-range, this
-	// shouldn't be treated as a 1-bit mask
 
-	// also, if all of the alpha samples are clumped on one half
-	// of the range (but not at an absolute extreme), then consider
-	// this to be an intentional effect and don't treat as a mask.
-
-	U32 midrangetotal = 0;
+	U32 total = 0;
 	for (U32 i = 4; i < 11; i++)
 	{
-		midrangetotal += sample[i];
-	}
-	U32 lowerhalftotal = 0;
-	for (U32 i = 0; i < 8; i++)
-	{
-		lowerhalftotal += sample[i];
-	}
-	U32 upperhalftotal = 0;
-	for (U32 i = 8; i < 16; i++)
-	{
-		upperhalftotal += sample[i];
+		total += sample[i];
 	}
 
-	if (midrangetotal > length/16 || // lots of midrange, or
-	    (lowerhalftotal == length && alphatotal != 0) || // all close to transparent but not all totally transparent, or
-	    (upperhalftotal == length && alphatotal != 255*length)) // all close to opaque but not all totally opaque
+	if (total > length/16)
 	{
-		mIsMask = FALSE; // not suitable for masking
+		mIsMask = FALSE;
 	}
 	else
 	{
diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp
index bb4e6c7a3e5..48b07bcf51a 100644
--- a/indra/newview/lldynamictexture.cpp
+++ b/indra/newview/lldynamictexture.cpp
@@ -170,9 +170,12 @@ void LLViewerDynamicTexture::postRender(BOOL success)
 			if(!mGLTexturep->getHasGLTexture())
 			{
 				generateGLTexture() ;
-			}
-			llcallstacks << "class type: " << (S32)getType() << llcallstacksendl ;
+			}			
 
+			if(gGLManager.mDebugGPU)
+			{
+				LLGLState::dumpStates() ;
+			}
 			success = mGLTexturep->setSubImageFromFrameBuffer(0, 0, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight);
 		}
 	}
@@ -211,11 +214,16 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
 		{
 			LLViewerDynamicTexture *dynamicTexture = *iter;
 			if (dynamicTexture->needsRender())
-			{
+			{				
+				if(gGLManager.mDebugGPU)
+				{				
+					llinfos << "class type: " << (S32)dynamicTexture->getType() << llendl;
+					LLGLState::dumpStates() ;
+				}
+
 				glClear(GL_DEPTH_BUFFER_BIT);
 				gDepthDirty = TRUE;
-				
-				
+								
 				gGL.color4f(1,1,1,1);
 				dynamicTexture->preRender();	// Must be called outside of startRender()
 				result = FALSE;
-- 
GitLab


From beb965772c97f781aac5657a014c2b43909333b7 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 23 Aug 2010 16:16:41 -0600
Subject: [PATCH 675/683] fix for EXT-8730: crash at
 llrender/llimagegl.cpp(157) : error ERROR: checkTexSize: wrong texture size
 and discard level: width: 512 Height: 512 Current Level:

---
 indra/newview/lldynamictexture.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp
index 48b07bcf51a..a460a4f6184 100644
--- a/indra/newview/lldynamictexture.cpp
+++ b/indra/newview/lldynamictexture.cpp
@@ -167,10 +167,14 @@ void LLViewerDynamicTexture::postRender(BOOL success)
 			{
 				generateGLTexture() ;
 			}
-			if(!mGLTexturep->getHasGLTexture())
+			else if(!mGLTexturep->getHasGLTexture())
 			{
 				generateGLTexture() ;
 			}			
+			else if(mGLTexturep->getDiscardLevel() != 0)//do not know how it happens, but regenerate one if it does.
+			{
+				generateGLTexture() ;
+			}
 
 			if(gGLManager.mDebugGPU)
 			{
-- 
GitLab


From 6091c3a758b400039bb98d720256260b8e37ff88 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 23 Aug 2010 17:32:26 -0600
Subject: [PATCH 676/683] fix for EXT-8101: [crashhunters] crash in
 LLVOSky::calcAtmospherics()

---
 indra/newview/llvosky.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index d73850cb494..bb80988854e 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -975,7 +975,10 @@ void LLVOSky::calcAtmospherics(void)
 		}
 
 		temp2.mV[1] = llmax(0.f, lighty);
-		temp2.mV[1] = 1.f / temp2.mV[1];
+		if(temp2.mV[1] > 0.f)
+		{
+			temp2.mV[1] = 1.f / temp2.mV[1];
+		}
 		componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1]));
 
 		// Distance
-- 
GitLab


From fc7a3f6daab94331aab52983caee5c68db8cd772 Mon Sep 17 00:00:00 2001
From: convert-repo <none@none>
Date: Thu, 26 Aug 2010 04:47:49 +0000
Subject: [PATCH 677/683] update tags

---
 .hgtags | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 .hgtags

diff --git a/.hgtags b/.hgtags
new file mode 100644
index 00000000000..9bcc53fa343
--- /dev/null
+++ b/.hgtags
@@ -0,0 +1,24 @@
+003dd9461bfa479049afcc34545ab3431b147c7c v2start
+08398e650c222336bb2b6de0cd3bba944aef11b4 2-1rn1
+0962101bfa7df0643a6e625786025fe7f8a6dc97 2-1-beta-2
+12769e547e30067d494a6c01479a18107366ce2f beta-5
+17fc2908e9a1ef34a9f53a41a393caf5c3cac390 beta-3-5
+19547b909b404552593be5ec7c18241e062a6d65 2-1-1-beta-1
+1e2b517adc2ecb342cd3c865f2a6ccf82a3cf8d7 2-1-beta-3
+3469d90a115b900f8f250e137bbd9b684130f5d2 beta-4
+3e4b947f79d88c385e8218cbc0731cef0e42cfc4 2-1-beta-1
+434973a76ab2755f98ab55e1afc193e16692d5c5 2-1-1-beta-2
+46002088d9a4489e323b8d56131c680eaa21258c viewer-2-1-0-start
+4f777ffb99fefdc6497c61385c22688ff149c659 viewer-2-0-0
+52d96ad3d39be29147c5b2181b3bb46af6164f0e alpha-3
+668851b2ef0f8cf8df07a0fba429e4a6c1e70abb viewer-2-0-1
+7f16e79826d377f5f9f5b33dc721ab56d0d7dc8f alpha-4
+7f16e79826d377f5f9f5b33dc721ab56d0d7dc8f fork to viewer-20qa
+80bc6cff515118a36108967af49d3f8105c95bc9 viewer-2-0-2-start
+87bfaf8c76f9b22d9c65d4b315358861be87c863 2-1-1-release
+b03065d018b8a2e28b7de85b293a4c992cb4c12d 2-1-release
+b8419565906e4feb434426d8d9b17dd1458e24b2 alpha-6
+c6969fe44e58c542bfc6f1bd6c0be2fa860929ac 2-1-beta-4
+d2382d374139850efa5bb6adfb229e3e656cfc40 howard-demo
+d40ac9dd949cba6dab1cc386da6a2027690c2519 alpha-5
+d6781e22543acd7e21b967209f3c6e7003d380e3 fork to viewer-2-0
-- 
GitLab


From 71de5f622a7917f78823a7e7840194e1b0f8f070 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 26 Aug 2010 14:23:12 -0500
Subject: [PATCH 678/683] Add missing files from viewer-experimental

---
 indra/cmake/GLOD.cmake                        |    9 +
 indra/cmake/LLConvexDecomposition.cmake       |   16 +
 indra/llmath/llmatrix3a.cpp                   |  140 +
 indra/llmath/llmatrix3a.h                     |  134 +
 indra/llmath/llmatrix3a.inl                   |  125 +
 indra/llmath/llmatrix4a.h                     |  149 +
 indra/llmath/llquaternion2.h                  |  111 +
 indra/llmath/llquaternion2.inl                |  108 +
 indra/llmath/llsimdmath.h                     |   95 +
 indra/llmath/llsimdtypes.h                    |  130 +
 indra/llmath/llsimdtypes.inl                  |  163 +
 indra/llmath/llvector4a.cpp                   |  228 ++
 indra/llmath/llvector4a.h                     |  331 ++
 indra/llmath/llvector4a.inl                   |  599 +++
 indra/llmath/llvector4logical.h               |  130 +
 indra/llmath/llvolumeoctree.cpp               |  208 +
 indra/llmath/llvolumeoctree.h                 |  138 +
 indra/llprimitive/llmodel.cpp                 | 1695 +++++++++
 indra/llprimitive/llmodel.h                   |  179 +
 .../shaders/class1/avatar/objectSkinV.glsl    |   30 +
 .../class1/deferred/alphaSkinnedV.glsl        |   75 +
 .../class1/deferred/attachmentShadowF.glsl    |   16 +
 .../class1/deferred/attachmentShadowV.glsl    |   25 +
 .../shaders/class1/deferred/bumpSkinnedV.glsl |   37 +
 .../class1/deferred/diffuseSkinnedV.glsl      |   33 +
 .../lighting/lightFullbrightShinyWaterF.glsl  |   15 +
 .../objects/fullbrightShinySkinnedV.glsl      |   39 +
 .../class1/objects/fullbrightShinyWaterF.glsl |   13 +
 .../class1/objects/fullbrightSkinnedV.glsl    |   37 +
 .../class1/objects/shinySimpleSkinnedV.glsl   |   39 +
 .../class1/objects/simpleSkinnedV.glsl        |   39 +
 .../class2/deferred/alphaSkinnedV.glsl        |   84 +
 .../lighting/lightFullbrightShinyWaterF.glsl  |   29 +
 indra/newview/llfloaterimportcollada.cpp      | 1116 ++++++
 indra/newview/llfloaterimportcollada.h        |  143 +
 indra/newview/llfloatermodelpreview.cpp       | 3382 +++++++++++++++++
 indra/newview/llfloatermodelpreview.h         |  275 ++
 indra/newview/llmeshreduction.cpp             |  291 ++
 indra/newview/llmeshreduction.h               |   59 +
 indra/newview/llmeshrepository.cpp            | 2676 +++++++++++++
 indra/newview/llmeshrepository.h              |  471 +++
 41 files changed, 13612 insertions(+)
 create mode 100644 indra/cmake/GLOD.cmake
 create mode 100644 indra/cmake/LLConvexDecomposition.cmake
 create mode 100644 indra/llmath/llmatrix3a.cpp
 create mode 100644 indra/llmath/llmatrix3a.h
 create mode 100644 indra/llmath/llmatrix3a.inl
 create mode 100644 indra/llmath/llmatrix4a.h
 create mode 100644 indra/llmath/llquaternion2.h
 create mode 100644 indra/llmath/llquaternion2.inl
 create mode 100644 indra/llmath/llsimdmath.h
 create mode 100644 indra/llmath/llsimdtypes.h
 create mode 100644 indra/llmath/llsimdtypes.inl
 create mode 100644 indra/llmath/llvector4a.cpp
 create mode 100644 indra/llmath/llvector4a.h
 create mode 100644 indra/llmath/llvector4a.inl
 create mode 100644 indra/llmath/llvector4logical.h
 create mode 100644 indra/llmath/llvolumeoctree.cpp
 create mode 100644 indra/llmath/llvolumeoctree.h
 create mode 100644 indra/llprimitive/llmodel.cpp
 create mode 100644 indra/llprimitive/llmodel.h
 create mode 100644 indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/objects/fullbrightShinyWaterF.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterF.glsl
 create mode 100644 indra/newview/llfloaterimportcollada.cpp
 create mode 100644 indra/newview/llfloaterimportcollada.h
 create mode 100644 indra/newview/llfloatermodelpreview.cpp
 create mode 100644 indra/newview/llfloatermodelpreview.h
 create mode 100644 indra/newview/llmeshreduction.cpp
 create mode 100644 indra/newview/llmeshreduction.h
 create mode 100644 indra/newview/llmeshrepository.cpp
 create mode 100644 indra/newview/llmeshrepository.h

diff --git a/indra/cmake/GLOD.cmake b/indra/cmake/GLOD.cmake
new file mode 100644
index 00000000000..77221d55ede
--- /dev/null
+++ b/indra/cmake/GLOD.cmake
@@ -0,0 +1,9 @@
+# -*- cmake -*-
+include(Prebuilt)
+
+if (NOT STANDALONE)
+  use_prebuilt_binary(GLOD)
+endif (NOT STANDALONE)
+
+set(GLOD_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include)
+set(GLOD_LIBRARIES glod)
diff --git a/indra/cmake/LLConvexDecomposition.cmake b/indra/cmake/LLConvexDecomposition.cmake
new file mode 100644
index 00000000000..ae9dc3c17a9
--- /dev/null
+++ b/indra/cmake/LLConvexDecomposition.cmake
@@ -0,0 +1,16 @@
+# -*- cmake -*-
+include(Prebuilt)
+
+set(LLCONVEXDECOMP_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
+  
+if (INSTALL_PROPRIETARY AND NOT STANDALONE)
+  use_prebuilt_binary(llconvexdecomposition)
+  if (WINDOWS)
+    set(LLCONVEXDECOMP_LIBRARY llconvexdecomposition)
+  else (WINDOWS)
+    set(LLCONVEXDECOMP_LIBRARY llconvexdecompositionstub)
+  endif (WINDOWS)
+else (INSTALL_PROPRIETARY AND NOT STANDALONE)
+  use_prebuilt_binary(llconvexdecompositionstub)
+  set(LLCONVEXDECOMP_LIBRARY llconvexdecompositionstub)
+endif (INSTALL_PROPRIETARY AND NOT STANDALONE)
diff --git a/indra/llmath/llmatrix3a.cpp b/indra/llmath/llmatrix3a.cpp
new file mode 100644
index 00000000000..b7468f49149
--- /dev/null
+++ b/indra/llmath/llmatrix3a.cpp
@@ -0,0 +1,140 @@
+/** 
+ * @file llvector4a.cpp
+ * @brief SIMD vector implementation
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llmath.h"
+
+static LL_ALIGN_16(const F32 M_IDENT_3A[12]) = 
+												{	1.f, 0.f, 0.f, 0.f, // Column 1
+													0.f, 1.f, 0.f, 0.f, // Column 2
+													0.f, 0.f, 1.f, 0.f }; // Column 3
+
+extern const LLMatrix3a LL_M3A_IDENTITY = *reinterpret_cast<const LLMatrix3a*> (M_IDENT_3A);
+
+void LLMatrix3a::setMul( const LLMatrix3a& lhs, const LLMatrix3a& rhs )
+{
+	const LLVector4a col0 = lhs.getColumn(0);
+	const LLVector4a col1 = lhs.getColumn(1);
+	const LLVector4a col2 = lhs.getColumn(2);
+
+	for ( int i = 0; i < 3; i++ )
+	{
+		LLVector4a xxxx = _mm_load_ss( rhs.mColumns[i].getF32ptr() );
+		xxxx.splat<0>( xxxx );
+		xxxx.mul( col0 );
+
+		{
+			LLVector4a yyyy = _mm_load_ss( rhs.mColumns[i].getF32ptr() +  1 );
+			yyyy.splat<0>( yyyy );
+			yyyy.mul( col1 ); 
+			xxxx.add( yyyy );
+		}
+
+		{
+			LLVector4a zzzz = _mm_load_ss( rhs.mColumns[i].getF32ptr() +  2 );
+			zzzz.splat<0>( zzzz );
+			zzzz.mul( col2 );
+			xxxx.add( zzzz );
+		}
+
+		xxxx.store4a( mColumns[i].getF32ptr() );
+	}
+	
+}
+
+/*static */void LLMatrix3a::batchTransform( const LLMatrix3a& xform, const LLVector4a* src, int numVectors, LLVector4a* dst )
+{
+	const LLVector4a col0 = xform.getColumn(0);
+	const LLVector4a col1 = xform.getColumn(1);
+	const LLVector4a col2 = xform.getColumn(2);
+	const LLVector4a* maxAddr = src + numVectors;
+
+	if ( numVectors & 0x1 )
+	{
+		LLVector4a xxxx = _mm_load_ss( (const F32*)src );
+		LLVector4a yyyy = _mm_load_ss( (const F32*)src + 1 );
+		LLVector4a zzzz = _mm_load_ss( (const F32*)src + 2 );
+		xxxx.splat<0>( xxxx );
+		yyyy.splat<0>( yyyy );
+		zzzz.splat<0>( zzzz );
+		xxxx.mul( col0 );
+		yyyy.mul( col1 ); 
+		zzzz.mul( col2 );
+		xxxx.add( yyyy );
+		xxxx.add( zzzz );
+		xxxx.store4a( (F32*)dst );
+		src++;
+		dst++;
+	}
+
+
+	numVectors >>= 1;
+	while ( src < maxAddr )
+	{
+		_mm_prefetch( (const char*)(src + 32 ), _MM_HINT_NTA );
+		_mm_prefetch( (const char*)(dst + 32), _MM_HINT_NTA );
+		LLVector4a xxxx = _mm_load_ss( (const F32*)src );
+		LLVector4a xxxx1= _mm_load_ss( (const F32*)(src + 1) );
+
+		xxxx.splat<0>( xxxx );
+		xxxx1.splat<0>( xxxx1 );
+		xxxx.mul( col0 );
+		xxxx1.mul( col0 );
+
+		{
+			LLVector4a yyyy = _mm_load_ss( (const F32*)src + 1 );
+			LLVector4a yyyy1 = _mm_load_ss( (const F32*)(src + 1) + 1);
+			yyyy.splat<0>( yyyy );
+			yyyy1.splat<0>( yyyy1 );
+			yyyy.mul( col1 );
+			yyyy1.mul( col1 );
+			xxxx.add( yyyy );
+			xxxx1.add( yyyy1 );
+		}
+
+		{
+			LLVector4a zzzz = _mm_load_ss( (const F32*)(src) + 2 );
+			LLVector4a zzzz1 = _mm_load_ss( (const F32*)(++src) + 2 );
+			zzzz.splat<0>( zzzz );
+			zzzz1.splat<0>( zzzz1 );
+			zzzz.mul( col2 );
+			zzzz1.mul( col2 );
+			xxxx.add( zzzz );
+			xxxx1.add( zzzz1 );
+		}
+
+		xxxx.store4a(dst->getF32ptr());
+		src++;
+		dst++;
+
+		xxxx1.store4a((F32*)dst++);
+	}
+}
diff --git a/indra/llmath/llmatrix3a.h b/indra/llmath/llmatrix3a.h
new file mode 100644
index 00000000000..56327f9f6dc
--- /dev/null
+++ b/indra/llmath/llmatrix3a.h
@@ -0,0 +1,134 @@
+/** 
+ * @file llmatrix3a.h
+ * @brief LLMatrix3a class header file - memory aligned and vectorized 3x3 matrix
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef	LL_LLMATRIX3A_H
+#define	LL_LLMATRIX3A_H
+
+/////////////////////////////
+// LLMatrix3a, LLRotation
+/////////////////////////////
+// This class stores a 3x3 (technically 4x3) matrix in column-major order
+/////////////////////////////
+/////////////////////////////
+// These classes are intentionally minimal right now. If you need additional
+// functionality, please contact someone with SSE experience (e.g., Falcon or
+// Huseby).
+/////////////////////////////
+
+// LLMatrix3a is the base class for LLRotation, which should be used instead any time you're dealing with a 
+// rotation matrix.
+class LLMatrix3a
+{
+public:
+
+	// Utility function for quickly transforming an array of LLVector4a's
+	// For transforming a single LLVector4a, see LLVector4a::setRotated
+	static void batchTransform( const LLMatrix3a& xform, const LLVector4a* src, int numVectors, LLVector4a* dst );
+
+	// Utility function to obtain the identity matrix
+	static inline const LLMatrix3a& getIdentity();
+
+	//////////////////////////
+	// Ctors
+	//////////////////////////
+	
+	// Ctor
+	LLMatrix3a() {}
+
+	// Ctor for setting by columns
+	inline LLMatrix3a( const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2 );
+
+	//////////////////////////
+	// Get/Set
+	//////////////////////////
+
+	// Loads from an LLMatrix3
+	inline void loadu(const LLMatrix3& src);
+	
+	// Set rows
+	inline void setRows(const LLVector4a& r0, const LLVector4a& r1, const LLVector4a& r2);
+	
+	// Set columns
+	inline void setColumns(const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2);
+
+	// Get the read-only access to a specified column. Valid columns are 0-2, but the 
+	// function is unchecked. You've been warned.
+	inline const LLVector4a& getColumn(const U32 column) const;
+
+	/////////////////////////
+	// Matrix modification
+	/////////////////////////
+	
+	// Set this matrix to the product of lhs and rhs ( this = lhs * rhs )
+	void setMul( const LLMatrix3a& lhs, const LLMatrix3a& rhs );
+
+	// Set this matrix to the transpose of src
+	inline void setTranspose(const LLMatrix3a& src);
+
+	// Set this matrix to a*w + b*(1-w)
+	inline void setLerp(const LLMatrix3a& a, const LLMatrix3a& b, F32 w);
+
+	/////////////////////////
+	// Matrix inspection
+	/////////////////////////
+
+	// Sets all 4 elements in 'dest' to the determinant of this matrix.
+	// If you will be using the determinant in subsequent ops with LLVector4a, use this version
+	inline void getDeterminant( LLVector4a& dest ) const;
+
+	// Returns the determinant as an LLSimdScalar. Use this if you will be using the determinant
+	// primary for scalar operations.
+	inline LLSimdScalar getDeterminant() const;
+
+	// Returns nonzero if rows 0-2 and colums 0-2 contain no NaN or INF values. Row 3 is ignored
+	inline LLBool32 isFinite() const;
+
+	// Returns true if this matrix is equal to 'rhs' up to 'tolerance'
+	inline bool isApproximatelyEqual( const LLMatrix3a& rhs, F32 tolerance = F_APPROXIMATELY_ZERO ) const;
+
+protected:
+
+	LLVector4a mColumns[3];
+
+};
+
+class LLRotation : public LLMatrix3a
+{
+public:
+	
+	LLRotation() {}
+	
+	// Returns true if this rotation is orthonormal with det ~= 1
+	inline bool isOkRotation() const;		
+};
+
+#endif
diff --git a/indra/llmath/llmatrix3a.inl b/indra/llmath/llmatrix3a.inl
new file mode 100644
index 00000000000..65fd949f78c
--- /dev/null
+++ b/indra/llmath/llmatrix3a.inl
@@ -0,0 +1,125 @@
+/** 
+ * @file llmatrix3a.inl
+ * @brief LLMatrix3a inline definitions
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llmatrix3a.h"
+#include "m3math.h"
+
+inline LLMatrix3a::LLMatrix3a( const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2 )
+{
+	setColumns( c0, c1, c2 );
+}
+
+inline void LLMatrix3a::loadu(const LLMatrix3& src)
+{
+	mColumns[0].load3(src.mMatrix[0]);
+	mColumns[1].load3(src.mMatrix[1]);
+	mColumns[2].load3(src.mMatrix[2]);
+}
+
+inline void LLMatrix3a::setRows(const LLVector4a& r0, const LLVector4a& r1, const LLVector4a& r2)
+{
+	mColumns[0] = r0;
+	mColumns[1] = r1;
+	mColumns[2] = r2;
+	setTranspose( *this );
+}
+
+inline void LLMatrix3a::setColumns(const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2)
+{
+	mColumns[0] = c0;
+	mColumns[1] = c1;
+	mColumns[2] = c2;
+}
+
+inline void LLMatrix3a::setTranspose(const LLMatrix3a& src)
+{
+	const LLQuad srcCol0 = src.mColumns[0];
+	const LLQuad srcCol1 = src.mColumns[1];
+	const LLQuad unpacklo = _mm_unpacklo_ps( srcCol0, srcCol1 );
+	mColumns[0] = _mm_movelh_ps( unpacklo, src.mColumns[2] );
+	mColumns[1] = _mm_shuffle_ps( _mm_movehl_ps( srcCol0, unpacklo ), src.mColumns[2], _MM_SHUFFLE(0, 1, 1, 0) );
+	mColumns[2] = _mm_shuffle_ps( _mm_unpackhi_ps( srcCol0, srcCol1 ), src.mColumns[2], _MM_SHUFFLE(0, 2, 1, 0) );
+}
+
+inline const LLVector4a& LLMatrix3a::getColumn(const U32 column) const
+{
+	llassert( column < 3 );
+	return mColumns[column];
+}
+
+inline void LLMatrix3a::setLerp(const LLMatrix3a& a, const LLMatrix3a& b, F32 w)
+{
+	mColumns[0].setLerp( a.mColumns[0], b.mColumns[0], w );
+	mColumns[1].setLerp( a.mColumns[1], b.mColumns[1], w );
+	mColumns[2].setLerp( a.mColumns[2], b.mColumns[2], w );
+}
+
+inline LLBool32 LLMatrix3a::isFinite() const
+{
+	return mColumns[0].isFinite3() && mColumns[1].isFinite3() && mColumns[2].isFinite3();
+}
+
+inline void LLMatrix3a::getDeterminant( LLVector4a& dest ) const
+{
+	LLVector4a col1xcol2; col1xcol2.setCross3( mColumns[1], mColumns[2] );
+	dest.setAllDot3( col1xcol2, mColumns[0] );
+}
+
+inline LLSimdScalar LLMatrix3a::getDeterminant() const
+{
+	LLVector4a col1xcol2; col1xcol2.setCross3( mColumns[1], mColumns[2] );
+	return col1xcol2.dot3( mColumns[0] );
+}
+
+inline bool LLMatrix3a::isApproximatelyEqual( const LLMatrix3a& rhs, F32 tolerance /*= F_APPROXIMATELY_ZERO*/ ) const
+{
+	return rhs.getColumn(0).equals3(mColumns[0], tolerance) 
+		&& rhs.getColumn(1).equals3(mColumns[1], tolerance) 
+		&& rhs.getColumn(2).equals3(mColumns[2], tolerance); 
+}
+
+inline const LLMatrix3a& LLMatrix3a::getIdentity()
+{
+	extern const LLMatrix3a LL_M3A_IDENTITY;
+	return LL_M3A_IDENTITY;
+}
+
+inline bool LLRotation::isOkRotation() const
+{
+	LLMatrix3a transpose; transpose.setTranspose( *this );
+	LLMatrix3a product; product.setMul( *this, transpose );
+
+	LLSimdScalar detMinusOne = getDeterminant() - 1.f;
+
+	return product.isApproximatelyEqual( LLMatrix3a::getIdentity() ) && (detMinusOne.getAbs() < F_APPROXIMATELY_ZERO);
+}
+
diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h
new file mode 100644
index 00000000000..0ead045d040
--- /dev/null
+++ b/indra/llmath/llmatrix4a.h
@@ -0,0 +1,149 @@
+/** 
+ * @file llmatrix4a.h
+ * @brief LLMatrix4a class header file - memory aligned and vectorized 4x4 matrix
+ *
+ * $LicenseInfo:firstyear=2007&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef	LL_LLMATRIX4A_H
+#define	LL_LLMATRIX4A_H
+
+#include "llvector4a.h"
+#include "m4math.h"
+#include "m3math.h"
+
+class LLMatrix4a
+{
+public:
+	LLVector4a mMatrix[4];
+
+	inline void clear()
+	{
+		mMatrix[0].clear();
+		mMatrix[1].clear();
+		mMatrix[2].clear();
+		mMatrix[3].clear();
+	}
+
+	inline void loadu(const LLMatrix4& src)
+	{
+		mMatrix[0] = _mm_loadu_ps(src.mMatrix[0]);
+		mMatrix[1] = _mm_loadu_ps(src.mMatrix[1]);
+		mMatrix[2] = _mm_loadu_ps(src.mMatrix[2]);
+		mMatrix[3] = _mm_loadu_ps(src.mMatrix[3]);
+		
+	}
+
+	inline void loadu(const LLMatrix3& src)
+	{
+		mMatrix[0].load3(src.mMatrix[0]);
+		mMatrix[1].load3(src.mMatrix[1]);
+		mMatrix[2].load3(src.mMatrix[2]);
+		mMatrix[3].set(0,0,0,1.f);
+	}
+
+	inline void add(const LLMatrix4a& rhs)
+	{
+		mMatrix[0].add(rhs.mMatrix[0]);
+		mMatrix[1].add(rhs.mMatrix[1]);
+		mMatrix[2].add(rhs.mMatrix[2]);
+		mMatrix[3].add(rhs.mMatrix[3]);
+	}
+
+	inline void setRows(const LLVector4a& r0, const LLVector4a& r1, const LLVector4a& r2)
+	{
+		mMatrix[0] = r0;
+		mMatrix[1] = r1;
+		mMatrix[2] = r2;
+	}
+
+	inline void setMul(const LLMatrix4a& m, const F32 s)
+	{
+		mMatrix[0].setMul(m.mMatrix[0], s);
+		mMatrix[1].setMul(m.mMatrix[1], s);
+		mMatrix[2].setMul(m.mMatrix[2], s);
+		mMatrix[3].setMul(m.mMatrix[3], s);
+	}
+
+	inline void setLerp(const LLMatrix4a& a, const LLMatrix4a& b, F32 w)
+	{
+		LLVector4a d0,d1,d2,d3;
+		d0.setSub(b.mMatrix[0], a.mMatrix[0]);
+		d1.setSub(b.mMatrix[1], a.mMatrix[1]);
+		d2.setSub(b.mMatrix[2], a.mMatrix[2]);
+		d3.setSub(b.mMatrix[3], a.mMatrix[3]);
+
+		// this = a + d*w
+		
+		d0.mul(w);
+		d1.mul(w);
+		d2.mul(w);
+		d3.mul(w);
+
+		mMatrix[0].setAdd(a.mMatrix[0],d0);
+		mMatrix[1].setAdd(a.mMatrix[1],d1);
+		mMatrix[2].setAdd(a.mMatrix[2],d2);
+		mMatrix[3].setAdd(a.mMatrix[3],d3);
+	}
+
+	inline void rotate(const LLVector4a& v, LLVector4a& res)
+	{
+		res = _mm_shuffle_ps(v, v, _MM_SHUFFLE(0, 0, 0, 0));
+		res.mul(mMatrix[0]);
+		
+		LLVector4a y;
+		y = _mm_shuffle_ps(v, v, _MM_SHUFFLE(1, 1, 1, 1));
+		y.mul(mMatrix[1]);
+
+		LLVector4a z;
+		z = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 2, 2, 2));
+		z.mul(mMatrix[2]);
+
+		res.add(y);
+		res.add(z);
+	}
+
+	inline void affineTransform(const LLVector4a& v, LLVector4a& res)
+	{
+		LLVector4a x,y,z;
+
+		x = _mm_shuffle_ps(v, v, _MM_SHUFFLE(0, 0, 0, 0));
+		y = _mm_shuffle_ps(v, v, _MM_SHUFFLE(1, 1, 1, 1));
+		z = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 2, 2, 2));
+		
+		x.mul(mMatrix[0]);
+		y.mul(mMatrix[1]);
+		z.mul(mMatrix[2]);
+
+		x.add(y);
+		z.add(mMatrix[3]);
+		res.setAdd(x,z);
+	}
+};
+
+#endif
diff --git a/indra/llmath/llquaternion2.h b/indra/llmath/llquaternion2.h
new file mode 100644
index 00000000000..dbb4afe312d
--- /dev/null
+++ b/indra/llmath/llquaternion2.h
@@ -0,0 +1,111 @@
+/** 
+ * @file llquaternion2.h
+ * @brief LLQuaternion2 class header file - SIMD-enabled quaternion class
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef	LL_QUATERNION2_H
+#define	LL_QUATERNION2_H
+
+/////////////////////////////
+// LLQuaternion2
+/////////////////////////////
+// This class stores a quaternion x*i + y*j + z*k + w in <x, y, z, w> order
+// (i.e., w in high order element of vector)
+/////////////////////////////
+/////////////////////////////
+// These classes are intentionally minimal right now. If you need additional
+// functionality, please contact someone with SSE experience (e.g., Falcon or
+// Huseby).
+/////////////////////////////
+#include "llquaternion.h"
+
+class LLQuaternion2
+{
+public:
+
+	//////////////////////////
+	// Ctors
+	//////////////////////////
+	
+	// Ctor
+	LLQuaternion2() {}
+
+	// Ctor from LLQuaternion
+	explicit LLQuaternion2( const class LLQuaternion& quat );
+
+	//////////////////////////
+	// Get/Set
+	//////////////////////////
+
+	// Load from an LLQuaternion
+	inline void operator=( const LLQuaternion& quat )
+	{
+		mQ.loadua( quat.mQ );
+	}
+
+	// Return the internal LLVector4a representation of the quaternion
+	inline const LLVector4a& getVector4a() const;
+	inline LLVector4a& getVector4aRw();
+
+	/////////////////////////
+	// Quaternion modification
+	/////////////////////////
+	
+	// Set this quaternion to the conjugate of src
+	inline void setConjugate(const LLQuaternion2& src);
+
+	// Renormalizes the quaternion. Assumes it has nonzero length.
+	inline void normalize();
+
+	// Quantize this quaternion to 8 bit precision
+	inline void quantize8();
+
+	// Quantize this quaternion to 16 bit precision
+	inline void quantize16();
+
+	/////////////////////////
+	// Quaternion inspection
+	/////////////////////////
+
+	// Return true if this quaternion is equal to 'rhs'. 
+	// Note! Quaternions exhibit "double-cover", so any rotation has two equally valid
+	// quaternion representations and they will NOT compare equal.
+	inline bool equals(const LLQuaternion2& rhs, F32 tolerance = F_APPROXIMATELY_ZERO ) const;
+
+	// Return true if all components are finite and the quaternion is normalized
+	inline bool isOkRotation() const;
+
+protected:
+
+	LLVector4a mQ;
+
+};
+
+#endif
diff --git a/indra/llmath/llquaternion2.inl b/indra/llmath/llquaternion2.inl
new file mode 100644
index 00000000000..9a4274d6a4b
--- /dev/null
+++ b/indra/llmath/llquaternion2.inl
@@ -0,0 +1,108 @@
+/** 
+ * @file llquaternion2.inl
+ * @brief LLQuaternion2 inline definitions
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llquaternion2.h"
+
+static const LLQuad LL_V4A_PLUS_ONE = {1.f, 1.f, 1.f, 1.f};
+static const LLQuad LL_V4A_MINUS_ONE = {-1.f, -1.f, -1.f, -1.f};
+
+// Ctor from LLQuaternion
+inline LLQuaternion2::LLQuaternion2( const LLQuaternion& quat )
+{
+	mQ.set(quat.mQ[VX], quat.mQ[VY], quat.mQ[VZ], quat.mQ[VW]);
+}
+
+//////////////////////////
+// Get/Set
+//////////////////////////
+
+// Return the internal LLVector4a representation of the quaternion
+inline const LLVector4a& LLQuaternion2::getVector4a() const
+{
+	return mQ;
+}
+
+inline LLVector4a& LLQuaternion2::getVector4aRw()
+{
+	return mQ;
+}
+
+/////////////////////////
+// Quaternion modification
+/////////////////////////
+
+// Set this quaternion to the conjugate of src
+inline void LLQuaternion2::setConjugate(const LLQuaternion2& src)
+{
+	static LL_ALIGN_16( const U32 F_QUAT_INV_MASK_4A[4] ) = { 0x80000000, 0x80000000, 0x80000000, 0x00000000 };
+	mQ = _mm_xor_ps(src.mQ, *reinterpret_cast<const LLQuad*>(&F_QUAT_INV_MASK_4A));	
+}
+
+// Renormalizes the quaternion. Assumes it has nonzero length.
+inline void LLQuaternion2::normalize()
+{
+	mQ.normalize4();
+}
+
+// Quantize this quaternion to 8 bit precision
+inline void LLQuaternion2::quantize8()
+{
+	mQ.quantize8( LL_V4A_MINUS_ONE, LL_V4A_PLUS_ONE );
+	normalize();
+}
+
+// Quantize this quaternion to 16 bit precision
+inline void LLQuaternion2::quantize16()
+{
+	mQ.quantize16( LL_V4A_MINUS_ONE, LL_V4A_PLUS_ONE );
+	normalize();
+}
+
+
+/////////////////////////
+// Quaternion inspection
+/////////////////////////
+
+// Return true if this quaternion is equal to 'rhs'. 
+// Note! Quaternions exhibit "double-cover", so any rotation has two equally valid
+// quaternion representations and they will NOT compare equal.
+inline bool LLQuaternion2::equals(const LLQuaternion2 &rhs, F32 tolerance/* = F_APPROXIMATELY_ZERO*/) const
+{
+	return mQ.equals4(rhs.mQ, tolerance);
+}
+
+// Return true if all components are finite and the quaternion is normalized
+inline bool LLQuaternion2::isOkRotation() const
+{
+	return mQ.isFinite4() && mQ.isNormalized4();
+}
+
diff --git a/indra/llmath/llsimdmath.h b/indra/llmath/llsimdmath.h
new file mode 100644
index 00000000000..9377bfdb53d
--- /dev/null
+++ b/indra/llmath/llsimdmath.h
@@ -0,0 +1,95 @@
+/** 
+ * @file llsimdmath.h
+ * @brief Common header for SIMD-based math library (llvector4a, llmatrix3a, etc.)
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef	LL_SIMD_MATH_H
+#define	LL_SIMD_MATH_H
+
+#ifndef LLMATH_H
+#error "Please include llmath.h before this file."
+#endif
+
+#if ( ( LL_DARWIN || LL_LINUX ) && !(__SSE2__) ) || ( LL_WINDOWS && ( _M_IX86_FP < 2 ) )
+#error SSE2 not enabled. LLVector4a and related class will not compile.
+#endif
+
+template <typename T> T* LL_NEXT_ALIGNED_ADDRESS(T* address) 
+{ 
+	return reinterpret_cast<T*>(
+		(reinterpret_cast<U32>(address) + 0xF) & ~0xF);
+}
+
+template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address) 
+{ 
+	return reinterpret_cast<T*>(
+		(reinterpret_cast<U32>(address) + 0x3F) & ~0x3F);
+}
+
+#if LL_LINUX || LL_DARWIN
+
+#define			LL_ALIGN_PREFIX(x)
+#define			LL_ALIGN_POSTFIX(x)		__attribute__((aligned(x)))
+
+#elif LL_WINDOWS
+
+#define			LL_ALIGN_PREFIX(x)		__declspec(align(x))
+#define			LL_ALIGN_POSTFIX(x)
+
+#else
+#error "LL_ALIGN_PREFIX and LL_ALIGN_POSTFIX undefined"
+#endif
+
+#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16)
+
+
+
+#include <xmmintrin.h>
+#include <emmintrin.h>
+
+#include "llsimdtypes.h"
+#include "llsimdtypes.inl"
+
+class LLMatrix3a;
+class LLRotation;
+class LLMatrix3;
+
+#include "llquaternion.h"
+
+#include "llvector4logical.h"
+#include "llvector4a.h"
+#include "llmatrix3a.h"
+#include "llquaternion2.h"
+#include "llvector4a.inl"
+#include "llmatrix3a.inl"
+#include "llquaternion2.inl"
+
+
+#endif //LL_SIMD_MATH_H
diff --git a/indra/llmath/llsimdtypes.h b/indra/llmath/llsimdtypes.h
new file mode 100644
index 00000000000..82e318c8bf7
--- /dev/null
+++ b/indra/llmath/llsimdtypes.h
@@ -0,0 +1,130 @@
+/** 
+ * @file llsimdtypes.h
+ * @brief Declaration of basic SIMD math related types
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_SIMD_TYPES_H
+#define LL_SIMD_TYPES_H
+
+#ifndef LL_SIMD_MATH_H
+#error "Please include llmath.h before this file."
+#endif
+
+typedef __m128	LLQuad;
+
+
+#if LL_WINDOWS
+#pragma warning(push)
+#pragma warning( disable : 4800 3 ) // Disable warning about casting int to bool for this class.
+#if defined(_MSC_VER) && (_MSC_VER < 1500)
+// VC++ 2005 is missing these intrinsics
+// __forceinline is MSVC specific and attempts to override compiler inlining judgment. This is so
+// even in debug builds this call is a NOP.
+__forceinline const __m128 _mm_castsi128_ps( const __m128i a ) { return reinterpret_cast<const __m128&>(a); }
+__forceinline const __m128i _mm_castps_si128( const __m128 a ) { return reinterpret_cast<const __m128i&>(a); }
+#endif // _MSC_VER
+
+#endif // LL_WINDOWS
+
+class LLBool32
+{
+public:
+	inline LLBool32() {}
+	inline LLBool32(int rhs) : m_bool(rhs) {}
+	inline LLBool32(unsigned int rhs) : m_bool(rhs) {}
+	inline LLBool32(bool rhs) { m_bool = static_cast<const int>(rhs); }
+	inline LLBool32& operator= (bool rhs) { m_bool = (int)rhs; return *this; }
+	inline bool operator== (bool rhs) const { return static_cast<const bool&>(m_bool) == rhs; }
+	inline bool operator!= (bool rhs) const { return !operator==(rhs); }
+	inline operator bool() const { return static_cast<const bool&>(m_bool); }
+
+private:
+	int m_bool;
+};
+
+#if LL_WINDOWS
+#pragma warning(pop)
+#endif
+
+class LLSimdScalar
+{
+public:
+	inline LLSimdScalar() {}
+	inline LLSimdScalar(LLQuad q) 
+	{ 
+		mQ = q; 
+	}
+
+	inline LLSimdScalar(F32 f) 
+	{ 
+		mQ = _mm_set_ss(f); 
+	}
+
+	static inline const LLSimdScalar& getZero()
+	{
+		extern const LLQuad F_ZERO_4A;
+		return reinterpret_cast<const LLSimdScalar&>(F_ZERO_4A);
+	}
+
+	inline F32 getF32() const;
+
+	inline LLBool32 isApproximatelyEqual(const LLSimdScalar& rhs, F32 tolerance = F_APPROXIMATELY_ZERO) const;
+
+	inline LLSimdScalar getAbs() const;
+
+	inline void setMax( const LLSimdScalar& a, const LLSimdScalar& b );
+	
+	inline void setMin( const LLSimdScalar& a, const LLSimdScalar& b );
+
+	inline LLSimdScalar& operator=(F32 rhs);
+
+	inline LLSimdScalar& operator+=(const LLSimdScalar& rhs);
+
+	inline LLSimdScalar& operator-=(const LLSimdScalar& rhs);
+
+	inline LLSimdScalar& operator*=(const LLSimdScalar& rhs);
+
+	inline LLSimdScalar& operator/=(const LLSimdScalar& rhs);
+
+	inline operator LLQuad() const
+	{ 
+		return mQ; 
+	}
+	
+	inline const LLQuad& getQuad() const 
+	{ 
+		return mQ; 
+	}
+
+private:
+	LLQuad mQ;
+};
+
+#endif //LL_SIMD_TYPES_H
diff --git a/indra/llmath/llsimdtypes.inl b/indra/llmath/llsimdtypes.inl
new file mode 100644
index 00000000000..69c858e310e
--- /dev/null
+++ b/indra/llmath/llsimdtypes.inl
@@ -0,0 +1,163 @@
+/** 
+ * @file llsimdtypes.inl
+ * @brief Inlined definitions of basic SIMD math related types
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+
+
+
+//////////////////
+// LLSimdScalar
+//////////////////
+
+inline LLSimdScalar operator+(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	LLSimdScalar t(a);
+	t += b;
+	return t;
+}
+
+inline LLSimdScalar operator-(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	LLSimdScalar t(a);
+	t -= b;
+	return t;
+}
+
+inline LLSimdScalar operator*(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	LLSimdScalar t(a);
+	t *= b;
+	return t;
+}
+
+inline LLSimdScalar operator/(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	LLSimdScalar t(a);
+	t /= b;
+	return t;
+}
+
+inline LLSimdScalar operator-(const LLSimdScalar& a)
+{
+	static LL_ALIGN_16(const U32 signMask[4]) = {0x80000000, 0x80000000, 0x80000000, 0x80000000 };
+	return _mm_xor_ps(*reinterpret_cast<const LLQuad*>(signMask), a);
+}
+
+inline LLBool32 operator==(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	return _mm_comieq_ss(a, b);
+}
+
+inline LLBool32 operator!=(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	return _mm_comineq_ss(a, b);
+}
+
+inline LLBool32 operator<(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	return _mm_comilt_ss(a, b);
+}
+
+inline LLBool32 operator<=(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	return _mm_comile_ss(a, b);
+}
+
+inline LLBool32 operator>(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	return _mm_comigt_ss(a, b);
+}
+
+inline LLBool32 operator>=(const LLSimdScalar& a, const LLSimdScalar& b)
+{
+	return _mm_comige_ss(a, b);
+}
+
+inline LLBool32 LLSimdScalar::isApproximatelyEqual(const LLSimdScalar& rhs, F32 tolerance /* = F_APPROXIMATELY_ZERO */) const
+{
+	const LLSimdScalar tol( tolerance );
+	const LLSimdScalar diff = _mm_sub_ss( mQ, rhs.mQ );
+	const LLSimdScalar absDiff = diff.getAbs();
+	return absDiff <= tol;
+}
+
+inline void LLSimdScalar::setMax( const LLSimdScalar& a, const LLSimdScalar& b )
+{
+	mQ = _mm_max_ss( a, b );
+}
+
+inline void LLSimdScalar::setMin( const LLSimdScalar& a, const LLSimdScalar& b )
+{
+	mQ = _mm_min_ss( a, b );
+}
+
+inline LLSimdScalar& LLSimdScalar::operator=(F32 rhs) 
+{ 
+	mQ = _mm_set_ss(rhs); 
+	return *this; 
+}
+
+inline LLSimdScalar& LLSimdScalar::operator+=(const LLSimdScalar& rhs) 
+{
+	mQ = _mm_add_ss( mQ, rhs );
+	return *this;
+}
+
+inline LLSimdScalar& LLSimdScalar::operator-=(const LLSimdScalar& rhs)
+{
+	mQ = _mm_sub_ss( mQ, rhs );
+	return *this;
+}
+
+inline LLSimdScalar& LLSimdScalar::operator*=(const LLSimdScalar& rhs)
+{
+	mQ = _mm_mul_ss( mQ, rhs );
+	return *this;
+}
+
+inline LLSimdScalar& LLSimdScalar::operator/=(const LLSimdScalar& rhs)
+{
+	mQ = _mm_div_ss( mQ, rhs );
+	return *this;
+}
+
+inline LLSimdScalar LLSimdScalar::getAbs() const
+{
+	static const LL_ALIGN_16(U32 F_ABS_MASK_4A[4]) = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF };
+	return _mm_and_ps( mQ, *reinterpret_cast<const LLQuad*>(F_ABS_MASK_4A));
+}
+
+inline F32 LLSimdScalar::getF32() const
+{ 
+	F32 ret; 
+	_mm_store_ss(&ret, mQ); 
+	return ret; 
+}
diff --git a/indra/llmath/llvector4a.cpp b/indra/llmath/llvector4a.cpp
new file mode 100644
index 00000000000..b62c17302fa
--- /dev/null
+++ b/indra/llmath/llvector4a.cpp
@@ -0,0 +1,228 @@
+/** 
+ * @file llvector4a.cpp
+ * @brief SIMD vector implementation
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llmath.h"
+#include "llquantize.h"
+
+extern const LLQuad F_ZERO_4A		= { 0, 0, 0, 0 };
+extern const LLQuad F_APPROXIMATELY_ZERO_4A = { 
+	F_APPROXIMATELY_ZERO,
+	F_APPROXIMATELY_ZERO,
+	F_APPROXIMATELY_ZERO,
+	F_APPROXIMATELY_ZERO
+};
+
+extern const LLVector4a LL_V4A_ZERO = reinterpret_cast<const LLVector4a&> ( F_ZERO_4A );
+extern const LLVector4a LL_V4A_EPSILON = reinterpret_cast<const LLVector4a&> ( F_APPROXIMATELY_ZERO_4A );
+
+/*static */void LLVector4a::memcpyNonAliased16(F32* __restrict dst, const F32* __restrict src, size_t bytes)
+{
+	assert(src != NULL);
+	assert(dst != NULL);
+	assert(bytes > 0);
+	assert((bytes % sizeof(F32))== 0); 
+	
+	F32* end = dst + (bytes / sizeof(F32) );
+
+	if (bytes > 64)
+	{
+		F32* begin_64 = LL_NEXT_ALIGNED_ADDRESS_64(dst);
+		
+		//at least 64 (16*4) bytes before the end of the destination, switch to 16 byte copies
+		F32* end_64 = end-16;
+		
+		_mm_prefetch((char*)begin_64, _MM_HINT_NTA);
+		_mm_prefetch((char*)begin_64 + 64, _MM_HINT_NTA);
+		_mm_prefetch((char*)begin_64 + 128, _MM_HINT_NTA);
+		_mm_prefetch((char*)begin_64 + 192, _MM_HINT_NTA);
+		
+		while (dst < begin_64)
+		{
+			copy4a(dst, src);
+			dst += 4;
+			src += 4;
+		}
+		
+		while (dst < end_64)
+		{
+			_mm_prefetch((char*)src + 512, _MM_HINT_NTA);
+			_mm_prefetch((char*)dst + 512, _MM_HINT_NTA);
+			copy4a(dst, src);
+			copy4a(dst+4, src+4);
+			copy4a(dst+8, src+8);
+			copy4a(dst+12, src+12);
+			
+			dst += 16;
+			src += 16;
+		}
+	}
+
+	while (dst < end)
+	{
+		copy4a(dst, src);
+		dst += 4;
+		src += 4;
+	}
+}
+
+void LLVector4a::setRotated( const LLRotation& rot, const LLVector4a& vec )
+{
+	const LLVector4a col0 = rot.getColumn(0);
+	const LLVector4a col1 = rot.getColumn(1);
+	const LLVector4a col2 = rot.getColumn(2);
+
+	LLVector4a result = _mm_load_ss( vec.getF32ptr() );
+	result.splat<0>( result );
+	result.mul( col0 );
+
+	{
+		LLVector4a yyyy = _mm_load_ss( vec.getF32ptr() +  1 );
+		yyyy.splat<0>( yyyy );
+		yyyy.mul( col1 ); 
+		result.add( yyyy );
+	}
+
+	{
+		LLVector4a zzzz = _mm_load_ss( vec.getF32ptr() +  2 );
+		zzzz.splat<0>( zzzz );
+		zzzz.mul( col2 );
+		result.add( zzzz );
+	}
+
+	*this = result;
+}
+
+void LLVector4a::setRotated( const LLQuaternion2& quat, const LLVector4a& vec )
+{
+	const LLVector4a& quatVec = quat.getVector4a();
+	LLVector4a temp; temp.setCross3(quatVec, vec);
+	temp.add( temp );
+	
+	const LLVector4a realPart( quatVec.getScalarAt<3>() );
+	LLVector4a tempTimesReal; tempTimesReal.setMul( temp, realPart );
+
+	mQ = vec;
+	add( tempTimesReal );
+	
+	LLVector4a imagCrossTemp; imagCrossTemp.setCross3( quatVec, temp );
+	add(imagCrossTemp);
+}
+
+void LLVector4a::quantize8( const LLVector4a& low, const LLVector4a& high )
+{
+	LLVector4a val(mQ);
+	LLVector4a delta; delta.setSub( high, low );
+
+	{
+		val.clamp(low, high);
+		val.sub(low);
+
+		// 8-bit quantization means we can do with just 12 bits of reciprocal accuracy
+		const LLVector4a oneOverDelta = _mm_rcp_ps(delta.mQ);
+// 		{
+// 			static LL_ALIGN_16( const F32 F_TWO_4A[4] ) = { 2.f, 2.f, 2.f, 2.f };
+// 			LLVector4a two; two.load4a( F_TWO_4A );
+// 
+// 			// Here we use _mm_rcp_ps plus one round of newton-raphson
+// 			// We wish to find 'x' such that x = 1/delta
+// 			// As a first approximation, we take x0 = _mm_rcp_ps(delta)
+// 			// Then x1 = 2 * x0 - a * x0^2 or x1 = x0 * ( 2 - a * x0 )
+// 			// See Intel AP-803 http://ompf.org/!/Intel_application_note_AP-803.pdf
+// 			const LLVector4a recipApprox = _mm_rcp_ps(delta.mQ);
+// 			oneOverDelta.setMul( delta, recipApprox );
+// 			oneOverDelta.setSub( two, oneOverDelta );
+// 			oneOverDelta.mul( recipApprox );
+// 		}
+
+		val.mul(oneOverDelta);
+		val.mul(*reinterpret_cast<const LLVector4a*>(F_U8MAX_4A));
+	}
+
+	val = _mm_cvtepi32_ps(_mm_cvtps_epi32( val.mQ ));
+
+	{
+		val.mul(*reinterpret_cast<const LLVector4a*>(F_OOU8MAX_4A));
+		val.mul(delta);
+		val.add(low);
+	}
+
+	{
+		LLVector4a maxError; maxError.setMul(delta, *reinterpret_cast<const LLVector4a*>(F_OOU8MAX_4A));
+		LLVector4a absVal; absVal.setAbs( val );
+		setSelectWithMask( absVal.lessThan( maxError ), F_ZERO_4A, val );
+	}	
+}
+
+void LLVector4a::quantize16( const LLVector4a& low, const LLVector4a& high )
+{
+	LLVector4a val(mQ);
+	LLVector4a delta; delta.setSub( high, low );
+
+	{
+		val.clamp(low, high);
+		val.sub(low);
+
+		// 16-bit quantization means we need a round of Newton-Raphson
+		LLVector4a oneOverDelta;
+		{
+			static LL_ALIGN_16( const F32 F_TWO_4A[4] ) = { 2.f, 2.f, 2.f, 2.f };
+			LLVector4a two; two.load4a( F_TWO_4A );
+
+			// Here we use _mm_rcp_ps plus one round of newton-raphson
+			// We wish to find 'x' such that x = 1/delta
+			// As a first approximation, we take x0 = _mm_rcp_ps(delta)
+			// Then x1 = 2 * x0 - a * x0^2 or x1 = x0 * ( 2 - a * x0 )
+			// See Intel AP-803 http://ompf.org/!/Intel_application_note_AP-803.pdf
+			const LLVector4a recipApprox = _mm_rcp_ps(delta.mQ);
+			oneOverDelta.setMul( delta, recipApprox );
+			oneOverDelta.setSub( two, oneOverDelta );
+			oneOverDelta.mul( recipApprox );
+		}
+
+		val.mul(oneOverDelta);
+		val.mul(*reinterpret_cast<const LLVector4a*>(F_U16MAX_4A));
+	}
+
+	val = _mm_cvtepi32_ps(_mm_cvtps_epi32( val.mQ ));
+
+	{
+		val.mul(*reinterpret_cast<const LLVector4a*>(F_OOU16MAX_4A));
+		val.mul(delta);
+		val.add(low);
+	}
+
+	{
+		LLVector4a maxError; maxError.setMul(delta, *reinterpret_cast<const LLVector4a*>(F_OOU16MAX_4A));
+		LLVector4a absVal; absVal.setAbs( val );
+		setSelectWithMask( absVal.lessThan( maxError ), F_ZERO_4A, val );
+	}	
+}
diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h
new file mode 100644
index 00000000000..76a3e999ce5
--- /dev/null
+++ b/indra/llmath/llvector4a.h
@@ -0,0 +1,331 @@
+/** 
+ * @file llvector4a.h
+ * @brief LLVector4a class header file - memory aligned and vectorized 4 component vector
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef	LL_LLVECTOR4A_H
+#define	LL_LLVECTOR4A_H
+
+
+class LLRotation;
+
+#include <assert.h>
+#include "llpreprocessor.h"
+
+///////////////////////////////////
+// FIRST TIME USERS PLEASE READ
+//////////////////////////////////
+// This is just the beginning of LLVector4a. There are many more useful functions
+// yet to be implemented. For example, setNeg to negate a vector, rotate() to apply
+// a matrix rotation, various functions to manipulate only the X, Y, and Z elements
+// and many others (including a whole variety of accessors). So if you don't see a 
+// function here that you need, please contact Falcon or someone else with SSE 
+// experience (Richard, I think, has some and davep has a little as of the time 
+// of this writing, July 08, 2010) about getting it implemented before you resort to
+// LLVector3/LLVector4. 
+/////////////////////////////////
+
+class LLVector4a
+{
+public:
+
+	///////////////////////////////////
+	// STATIC METHODS
+	///////////////////////////////////
+	
+	// Call initClass() at startup to avoid 15,000+ cycle penalties from denormalized numbers
+	static void initClass()
+	{
+		_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
+		_MM_SET_ROUNDING_MODE(_MM_ROUND_NEAREST);
+	}
+
+	// Return a vector of all zeros
+	static inline const LLVector4a& getZero()
+	{
+		extern const LLVector4a LL_V4A_ZERO;
+		return LL_V4A_ZERO;
+	}
+
+	// Return a vector of all epsilon, where epsilon is a small float suitable for approximate equality checks
+	static inline const LLVector4a& getEpsilon()
+	{
+		extern const LLVector4a LL_V4A_EPSILON;
+		return LL_V4A_EPSILON;
+	}
+
+	// Copy 16 bytes from src to dst. Source and destination must be 16-byte aligned
+	static inline void copy4a(F32* dst, const F32* src)
+	{
+		_mm_store_ps(dst, _mm_load_ps(src));
+	}
+
+	// Copy words 16-byte blocks from src to dst. Source and destination must not overlap. 
+	static void memcpyNonAliased16(F32* __restrict dst, const F32* __restrict src, size_t bytes);
+
+	////////////////////////////////////
+	// CONSTRUCTORS 
+	////////////////////////////////////
+	
+	LLVector4a()
+	{ //DO NOT INITIALIZE -- The overhead is completely unnecessary
+	}
+	
+	LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f)
+	{
+		set(x,y,z,w);
+	}
+	
+	LLVector4a(F32 x)
+	{
+		splat(x);
+	}
+	
+	LLVector4a(const LLSimdScalar& x)
+	{
+		splat(x);
+	}
+
+	LLVector4a(LLQuad q)
+	{
+		mQ = q;
+	}
+
+	////////////////////////////////////
+	// LOAD/STORE
+	////////////////////////////////////
+	
+	// Load from 16-byte aligned src array (preferred method of loading)
+	inline void load4a(const F32* src);
+	
+	// Load from unaligned src array (NB: Significantly slower than load4a)
+	inline void loadua(const F32* src);
+	
+	// Load only three floats beginning at address 'src'. Slowest method.
+	inline void load3(const F32* src);
+	
+	// Store to a 16-byte aligned memory address
+	inline void store4a(F32* dst) const;
+	
+	////////////////////////////////////
+	// BASIC GET/SET 
+	////////////////////////////////////
+	
+	// Return a "this" as an F32 pointer. Do not use unless you have a very good reason.  (Not sure? Ask Falcon)
+	inline F32* getF32ptr();
+	
+	// Return a "this" as a const F32 pointer. Do not use unless you have a very good reason.  (Not sure? Ask Falcon)
+	inline const F32* const getF32ptr() const;
+	
+	// Read-only access a single float in this vector. Do not use in proximity to any function call that manipulates
+	// the data at the whole vector level or you will incur a substantial penalty. Consider using the splat functions instead
+	inline F32 operator[](const S32 idx) const;
+
+	// Prefer this method for read-only access to a single element. Prefer the templated version if the elem is known at compile time.
+	inline LLSimdScalar getScalarAt(const S32 idx) const;
+
+	// Prefer this method for read-only access to a single element. Prefer the templated version if the elem is known at compile time.
+	template <int N> LL_FORCE_INLINE LLSimdScalar getScalarAt() const;
+	template <> LL_FORCE_INLINE LLSimdScalar getScalarAt<0>() const;
+
+	// Set to an x, y, z and optional w provided
+	inline void set(F32 x, F32 y, F32 z, F32 w = 0.f);
+	
+	// Set to all zeros. This is preferred to using ::getZero()
+	inline void clear();
+	
+	// Set all elements to 'x'
+	inline void splat(const F32 x);
+
+	// Set all elements to 'x'
+	inline void splat(const LLSimdScalar& x);
+	
+	// Set all 4 elements to element N of src, with N known at compile time
+	template <int N> void splat(const LLVector4a& src);
+	
+	// Set all 4 elements to element i of v, with i NOT known at compile time
+	inline void splat(const LLVector4a& v, U32 i);
+	
+	// Select bits from sourceIfTrue and sourceIfFalse according to bits in mask
+	inline void setSelectWithMask( const LLVector4Logical& mask, const LLVector4a& sourceIfTrue, const LLVector4a& sourceIfFalse );
+	
+	////////////////////////////////////
+	// ALGEBRAIC
+	////////////////////////////////////
+	
+	// Set this to the element-wise (a + b)
+	inline void setAdd(const LLVector4a& a, const LLVector4a& b);
+	
+	// Set this to element-wise (a - b)
+	inline void setSub(const LLVector4a& a, const LLVector4a& b);
+	
+	// Set this to element-wise multiply (a * b)
+	inline void setMul(const LLVector4a& a, const LLVector4a& b);
+	
+	// Set this to element-wise quotient (a / b)
+	inline void setDiv(const LLVector4a& a, const LLVector4a& b);
+	
+	// Set this to the element-wise absolute value of src
+	inline void setAbs(const LLVector4a& src);
+	
+	// Add to each component in this vector the corresponding component in rhs
+	inline void add(const LLVector4a& rhs);
+	
+	// Subtract from each component in this vector the corresponding component in rhs
+	inline void sub(const LLVector4a& rhs);
+	
+	// Multiply each component in this vector by the corresponding component in rhs
+	inline void mul(const LLVector4a& rhs);
+	
+	// Divide each component in this vector by the corresponding component in rhs
+	inline void div(const LLVector4a& rhs);
+	
+	// Multiply this vector by x in a scalar fashion
+	inline void mul(const F32 x);
+
+	// Set this to (a x b) (geometric cross-product)
+	inline void setCross3(const LLVector4a& a, const LLVector4a& b);
+	
+	// Set all elements to the dot product of the x, y, and z elements in a and b
+	inline void setAllDot3(const LLVector4a& a, const LLVector4a& b);
+
+	// Set all elements to the dot product of the x, y, z, and w elements in a and b
+	inline void setAllDot4(const LLVector4a& a, const LLVector4a& b);
+
+	// Return the 3D dot product of this vector and b
+	inline LLSimdScalar dot3(const LLVector4a& b) const;
+
+	// Return the 4D dot product of this vector and b
+	inline LLSimdScalar dot4(const LLVector4a& b) const;
+
+	// Normalize this vector with respect to the x, y, and z components only. Accurate to 22 bites of precision. W component is destroyed
+	// Note that this does not consider zero length vectors!
+	inline void normalize3();
+
+	// Same as normalize3() but with respect to all 4 components
+	inline void normalize4();
+
+	// Same as normalize3(), but returns length as a SIMD scalar
+	inline LLSimdScalar normalize3withLength();
+
+	// Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed
+	// Note that this does not consider zero length vectors!
+	inline void normalize3fast();
+
+	// Return true if this vector is normalized with respect to x,y,z up to tolerance
+	inline LLBool32 isNormalized3( F32 tolerance = 1e-3 ) const;
+
+	// Return true if this vector is normalized with respect to all components up to tolerance
+	inline LLBool32 isNormalized4( F32 tolerance = 1e-3 ) const;
+
+	// Set all elements to the length of vector 'v' 
+	inline void setAllLength3( const LLVector4a& v );
+
+	// Get this vector's length
+	inline LLSimdScalar getLength3() const;
+	
+	// Set the components of this vector to the minimum of the corresponding components of lhs and rhs
+	inline void setMin(const LLVector4a& lhs, const LLVector4a& rhs);
+	
+	// Set the components of this vector to the maximum of the corresponding components of lhs and rhs
+	inline void setMax(const LLVector4a& lhs, const LLVector4a& rhs);
+	
+	// Clamps this vector to be within the component-wise range low to high (inclusive)
+	inline void clamp( const LLVector4a& low, const LLVector4a& high );
+
+	// Set this to  (c * lhs) + rhs * ( 1 - c)
+	inline void setLerp(const LLVector4a& lhs, const LLVector4a& rhs, F32 c);
+	
+	// Return true (nonzero) if x, y, z (and w for Finite4) are all finite floats
+	inline LLBool32 isFinite3() const;	
+	inline LLBool32 isFinite4() const;
+
+	// Set this vector to 'vec' rotated by the LLRotation or LLQuaternion2 provided
+	void setRotated( const LLRotation& rot, const LLVector4a& vec );
+	void setRotated( const class LLQuaternion2& quat, const LLVector4a& vec );
+
+	// Set this vector to 'vec' rotated by the INVERSE of the LLRotation or LLQuaternion2 provided
+	inline void setRotatedInv( const LLRotation& rot, const LLVector4a& vec );
+	inline void setRotatedInv( const class LLQuaternion2& quat, const LLVector4a& vec );
+
+	// Quantize this vector to 8 or 16 bit precision
+	void quantize8( const LLVector4a& low, const LLVector4a& high );
+	void quantize16( const LLVector4a& low, const LLVector4a& high );
+
+	////////////////////////////////////
+	// LOGICAL
+	////////////////////////////////////	
+	// The functions in this section will compare the elements in this vector
+	// to those in rhs and return an LLVector4Logical with all bits set in elements
+	// where the comparison was true and all bits unset in elements where the comparison
+	// was false. See llvector4logica.h
+	////////////////////////////////////
+	// WARNING: Other than equals3 and equals4, these functions do NOT account
+	// for floating point tolerance. You should include the appropriate tolerance
+	// in the inputs.
+	////////////////////////////////////
+	
+	inline LLVector4Logical greaterThan(const LLVector4a& rhs) const;
+
+	inline LLVector4Logical lessThan(const LLVector4a& rhs) const;
+	
+	inline LLVector4Logical greaterEqual(const LLVector4a& rhs) const;
+
+	inline LLVector4Logical lessEqual(const LLVector4a& rhs) const;
+	
+	inline LLVector4Logical equal(const LLVector4a& rhs) const;
+
+	// Returns true if this and rhs are componentwise equal up to the specified absolute tolerance
+	inline bool equals4(const LLVector4a& rhs, F32 tolerance = F_APPROXIMATELY_ZERO ) const;
+
+	inline bool equals3(const LLVector4a& rhs, F32 tolerance = F_APPROXIMATELY_ZERO ) const;
+
+	////////////////////////////////////
+	// OPERATORS
+	////////////////////////////////////	
+	
+	// Do NOT add aditional operators without consulting someone with SSE experience
+	inline const LLVector4a& operator= ( const LLVector4a& rhs );
+	
+	inline const LLVector4a& operator= ( const LLQuad& rhs );
+
+	inline operator LLQuad() const;	
+
+private:
+	LLQuad mQ;
+};
+
+inline void update_min_max(LLVector4a& min, LLVector4a& max, const LLVector4a& p)
+{
+	min.setMin(min, p);
+	max.setMax(max, p);
+}
+
+#endif
diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl
new file mode 100644
index 00000000000..e52b5508830
--- /dev/null
+++ b/indra/llmath/llvector4a.inl
@@ -0,0 +1,599 @@
+/** 
+ * @file llvector4a.inl
+ * @brief LLVector4a inline function implementations
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+////////////////////////////////////
+// LOAD/STORE
+////////////////////////////////////
+
+// Load from 16-byte aligned src array (preferred method of loading)
+inline void LLVector4a::load4a(const F32* src)
+{
+	mQ = _mm_load_ps(src);
+}
+
+// Load from unaligned src array (NB: Significantly slower than load4a)
+inline void LLVector4a::loadua(const F32* src)
+{
+	mQ = _mm_loadu_ps(src);
+}
+
+// Load only three floats beginning at address 'src'. Slowest method.
+inline void LLVector4a::load3(const F32* src)
+{
+	// mQ = { 0.f, src[2], src[1], src[0] } = { W, Z, Y, X }
+	// NB: This differs from the convention of { Z, Y, X, W }
+	mQ = _mm_set_ps(0.f, src[2], src[1], src[0]);
+}	
+
+// Store to a 16-byte aligned memory address
+inline void LLVector4a::store4a(F32* dst) const
+{
+	_mm_store_ps(dst, mQ);
+}
+
+////////////////////////////////////
+// BASIC GET/SET 
+////////////////////////////////////
+
+// Return a "this" as an F32 pointer. Do not use unless you have a very good reason.  (Not sure? Ask Falcon)
+F32* LLVector4a::getF32ptr()
+{
+	return (F32*) &mQ;
+}
+
+// Return a "this" as a const F32 pointer. Do not use unless you have a very good reason.  (Not sure? Ask Falcon)
+const F32* const LLVector4a::getF32ptr() const
+{
+	return (const F32* const) &mQ;
+}
+
+// Read-only access a single float in this vector. Do not use in proximity to any function call that manipulates
+// the data at the whole vector level or you will incur a substantial penalty. Consider using the splat functions instead
+inline F32 LLVector4a::operator[](const S32 idx) const
+{
+	return ((F32*)&mQ)[idx];
+}	
+
+// Prefer this method for read-only access to a single element. Prefer the templated version if the elem is known at compile time.
+inline LLSimdScalar LLVector4a::getScalarAt(const S32 idx) const
+{
+	// Return appropriate LLQuad. It will be cast to LLSimdScalar automatically (should be effectively a nop)
+	switch (idx)
+	{
+		case 0:
+			return mQ;
+		case 1:
+			return _mm_shuffle_ps(mQ, mQ, _MM_SHUFFLE(1, 1, 1, 1));
+		case 2:
+			return _mm_shuffle_ps(mQ, mQ, _MM_SHUFFLE(2, 2, 2, 2));
+		case 3:
+		default:
+			return _mm_shuffle_ps(mQ, mQ, _MM_SHUFFLE(3, 3, 3, 3));
+	}
+}
+
+// Prefer this method for read-only access to a single element. Prefer the templated version if the elem is known at compile time.
+template <int N> LL_FORCE_INLINE LLSimdScalar LLVector4a::getScalarAt() const
+{
+	return _mm_shuffle_ps(mQ, mQ, _MM_SHUFFLE(N, N, N, N));
+}
+
+template<> LL_FORCE_INLINE LLSimdScalar LLVector4a::getScalarAt<0>() const
+{
+	return mQ;
+}
+
+// Set to an x, y, z and optional w provided
+inline void LLVector4a::set(F32 x, F32 y, F32 z, F32 w)
+{
+	mQ = _mm_set_ps(w, z, y, x);
+}
+
+// Set to all zeros
+inline void LLVector4a::clear()
+{
+	mQ = LLVector4a::getZero().mQ;
+}
+
+inline void LLVector4a::splat(const F32 x)
+{
+	mQ = _mm_set1_ps(x);	
+}
+
+inline void LLVector4a::splat(const LLSimdScalar& x)
+{
+	mQ = _mm_shuffle_ps( x.getQuad(), x.getQuad(), _MM_SHUFFLE(0,0,0,0) );
+}
+
+// Set all 4 elements to element N of src, with N known at compile time
+template <int N> void LLVector4a::splat(const LLVector4a& src)
+{
+	mQ = _mm_shuffle_ps(src.mQ, src.mQ, _MM_SHUFFLE(N, N, N, N) );
+}
+
+// Set all 4 elements to element i of v, with i NOT known at compile time
+inline void LLVector4a::splat(const LLVector4a& v, U32 i)
+{
+	switch (i)
+	{
+		case 0:
+			mQ = _mm_shuffle_ps(v.mQ, v.mQ, _MM_SHUFFLE(0, 0, 0, 0));
+			break;
+		case 1:
+			mQ = _mm_shuffle_ps(v.mQ, v.mQ, _MM_SHUFFLE(1, 1, 1, 1));
+			break;
+		case 2:
+			mQ = _mm_shuffle_ps(v.mQ, v.mQ, _MM_SHUFFLE(2, 2, 2, 2));
+			break;
+		case 3:
+			mQ = _mm_shuffle_ps(v.mQ, v.mQ, _MM_SHUFFLE(3, 3, 3, 3));
+			break;
+	}
+}
+
+// Select bits from sourceIfTrue and sourceIfFalse according to bits in mask
+inline void LLVector4a::setSelectWithMask( const LLVector4Logical& mask, const LLVector4a& sourceIfTrue, const LLVector4a& sourceIfFalse )
+{
+	// ((( sourceIfTrue ^ sourceIfFalse ) & mask) ^ sourceIfFalse )
+	// E.g., sourceIfFalse = 1010b, sourceIfTrue = 0101b, mask = 1100b
+	// (sourceIfTrue ^ sourceIfFalse) = 1111b --> & mask = 1100b --> ^ sourceIfFalse = 0110b, 
+	// as expected (01 from sourceIfTrue, 10 from sourceIfFalse)
+	// Courtesy of Mark++, http://markplusplus.wordpress.com/2007/03/14/fast-sse-select-operation/
+	mQ = _mm_xor_ps( sourceIfFalse, _mm_and_ps( mask, _mm_xor_ps( sourceIfTrue, sourceIfFalse ) ) );
+}
+
+////////////////////////////////////
+// ALGEBRAIC
+////////////////////////////////////
+
+// Set this to the element-wise (a + b)
+inline void LLVector4a::setAdd(const LLVector4a& a, const LLVector4a& b)
+{
+	mQ = _mm_add_ps(a.mQ, b.mQ);
+}
+
+// Set this to element-wise (a - b)
+inline void LLVector4a::setSub(const LLVector4a& a, const LLVector4a& b)
+{
+	mQ = _mm_sub_ps(a.mQ, b.mQ);
+}
+
+// Set this to element-wise multiply (a * b)
+inline void LLVector4a::setMul(const LLVector4a& a, const LLVector4a& b)
+{
+	mQ = _mm_mul_ps(a.mQ, b.mQ);
+}
+
+// Set this to element-wise quotient (a / b)
+inline void LLVector4a::setDiv(const LLVector4a& a, const LLVector4a& b)
+{
+	mQ = _mm_div_ps( a.mQ, b.mQ );
+}
+
+// Set this to the element-wise absolute value of src
+inline void LLVector4a::setAbs(const LLVector4a& src)
+{
+	static const LL_ALIGN_16(U32 F_ABS_MASK_4A[4]) = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF };
+	mQ = _mm_and_ps(src.mQ, *reinterpret_cast<const LLQuad*>(F_ABS_MASK_4A));
+}
+
+// Add to each component in this vector the corresponding component in rhs
+inline void LLVector4a::add(const LLVector4a& rhs)
+{
+	mQ = _mm_add_ps(mQ, rhs.mQ);	
+}
+
+// Subtract from each component in this vector the corresponding component in rhs
+inline void LLVector4a::sub(const LLVector4a& rhs)
+{
+	mQ = _mm_sub_ps(mQ, rhs.mQ);
+}
+
+// Multiply each component in this vector by the corresponding component in rhs
+inline void LLVector4a::mul(const LLVector4a& rhs)
+{
+	mQ = _mm_mul_ps(mQ, rhs.mQ);	
+}
+
+// Divide each component in this vector by the corresponding component in rhs
+inline void LLVector4a::div(const LLVector4a& rhs)
+{
+	// TODO: Check accuracy, maybe add divFast
+	mQ = _mm_div_ps(mQ, rhs.mQ);
+}
+
+// Multiply this vector by x in a scalar fashion
+inline void LLVector4a::mul(const F32 x) 
+{
+	LLVector4a t;
+	t.splat(x);
+	
+	mQ = _mm_mul_ps(mQ, t.mQ);
+}
+
+// Set this to (a x b) (geometric cross-product)
+inline void LLVector4a::setCross3(const LLVector4a& a, const LLVector4a& b)
+{
+	// Vectors are stored in memory in w, z, y, x order from high to low
+	// Set vector1 = { a[W], a[X], a[Z], a[Y] }
+	const LLQuad vector1 = _mm_shuffle_ps( a.mQ, a.mQ, _MM_SHUFFLE( 3, 0, 2, 1 ));
+	// Set vector2 = { b[W], b[Y], b[X], b[Z] }
+	const LLQuad vector2 = _mm_shuffle_ps( b.mQ, b.mQ, _MM_SHUFFLE( 3, 1, 0, 2 ));
+	// mQ = { a[W]*b[W], a[X]*b[Y], a[Z]*b[X], a[Y]*b[Z] }
+	mQ = _mm_mul_ps( vector1, vector2 );
+	// vector3 = { a[W], a[Y], a[X], a[Z] }
+	const LLQuad vector3 = _mm_shuffle_ps( a.mQ, a.mQ, _MM_SHUFFLE( 3, 1, 0, 2 ));
+	// vector4 = { b[W], b[X], b[Z], b[Y] }
+	const LLQuad vector4 = _mm_shuffle_ps( b.mQ, b.mQ, _MM_SHUFFLE( 3, 0, 2, 1 ));
+	// mQ = { 0, a[X]*b[Y] - a[Y]*b[X], a[Z]*b[X] - a[X]*b[Z], a[Y]*b[Z] - a[Z]*b[Y] }
+	mQ = _mm_sub_ps( mQ, _mm_mul_ps( vector3, vector4 ));
+}
+
+/* This function works, but may be slightly slower than the one below on older machines
+ inline void LLVector4a::setAllDot3(const LLVector4a& a, const LLVector4a& b)
+ {
+ // ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }
+ const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );
+ // yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] }
+ const LLQuad wzxy = _mm_shuffle_ps( ab, ab, _MM_SHUFFLE(3, 2, 0, 1 ));
+ // xPlusY = { 2*a[W]*b[W], 2 * a[Z] * b[Z], a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y] }
+ const LLQuad xPlusY = _mm_add_ps(ab, wzxy);
+ // xPlusYSplat = { a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y], a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y] } 
+ const LLQuad xPlusYSplat = _mm_movelh_ps(xPlusY, xPlusY);
+ // zSplat = { a[Z]*b[Z], a[Z]*b[Z], a[Z]*b[Z], a[Z]*b[Z] }
+ const LLQuad zSplat = _mm_shuffle_ps( ab, ab, _MM_SHUFFLE( 2, 2, 2, 2 ));
+ // mQ = { a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }
+ mQ = _mm_add_ps(zSplat, xPlusYSplat);
+ }*/
+
+// Set all elements to the dot product of the x, y, and z elements in a and b
+inline void LLVector4a::setAllDot3(const LLVector4a& a, const LLVector4a& b)
+{
+	// ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }
+	const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );
+	// yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] }
+	const __m128i wzxy = _mm_shuffle_epi32(_mm_castps_si128(ab), _MM_SHUFFLE(3, 2, 0, 1 ));
+	// xPlusY = { 2*a[W]*b[W], 2 * a[Z] * b[Z], a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y] }
+	const LLQuad xPlusY = _mm_add_ps(ab, _mm_castsi128_ps(wzxy));
+	// xPlusYSplat = { a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y], a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y] } 
+	const LLQuad xPlusYSplat = _mm_movelh_ps(xPlusY, xPlusY);
+	// zSplat = { a[Z]*b[Z], a[Z]*b[Z], a[Z]*b[Z], a[Z]*b[Z] }
+	const __m128i zSplat = _mm_shuffle_epi32(_mm_castps_si128(ab), _MM_SHUFFLE( 2, 2, 2, 2 ));
+	// mQ = { a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }
+	mQ = _mm_add_ps(_mm_castsi128_ps(zSplat), xPlusYSplat);
+}
+
+// Set all elements to the dot product of the x, y, z, and w elements in a and b
+inline void LLVector4a::setAllDot4(const LLVector4a& a, const LLVector4a& b)
+{
+	// ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }
+	const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );
+	// yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] }
+	const __m128i zwxy = _mm_shuffle_epi32(_mm_castps_si128(ab), _MM_SHUFFLE(2, 3, 0, 1 ));
+	// zPlusWandXplusY = { a[W]*b[W] + a[Z]*b[Z], a[Z] * b[Z] + a[W]*b[W], a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y] }
+	const LLQuad zPlusWandXplusY = _mm_add_ps(ab, _mm_castsi128_ps(zwxy));
+	// xPlusYSplat = { a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y], a[Y]*b[Y] + a[X] * b[X], a[X] * b[X] + a[Y] * b[Y] } 
+	const LLQuad xPlusYSplat = _mm_movelh_ps(zPlusWandXplusY, zPlusWandXplusY);
+	const LLQuad zPlusWSplat = _mm_movehl_ps(zPlusWandXplusY, zPlusWandXplusY);
+
+	// mQ = { a[W]*b[W] + a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }
+	mQ = _mm_add_ps(xPlusYSplat, zPlusWSplat);
+}
+
+// Return the 3D dot product of this vector and b
+inline LLSimdScalar LLVector4a::dot3(const LLVector4a& b) const
+{
+	const LLQuad ab = _mm_mul_ps( mQ, b.mQ );
+	const LLQuad splatY = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128(ab), _MM_SHUFFLE(1, 1, 1, 1) ) );
+	const LLQuad splatZ = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128(ab), _MM_SHUFFLE(2, 2, 2, 2) ) );
+	const LLQuad xPlusY = _mm_add_ps( ab, splatY );
+	return _mm_add_ps( xPlusY, splatZ );	
+}
+
+// Return the 4D dot product of this vector and b
+inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const
+{
+	// ab = { w, z, y, x }
+ 	const LLQuad ab = _mm_mul_ps( mQ, b.mQ );
+ 	// upperProdsInLowerElems = { y, x, y, x }
+	const LLQuad upperProdsInLowerElems = _mm_movehl_ps( ab, ab );
+	// sumOfPairs = { w+y, z+x, 2y, 2x }
+ 	const LLQuad sumOfPairs = _mm_add_ps( upperProdsInLowerElems, ab );
+	// shuffled = { z+x, z+x, z+x, z+x }
+	const LLQuad shuffled = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128( sumOfPairs ), _MM_SHUFFLE(1, 1, 1, 1) ) );
+	return _mm_add_ss( sumOfPairs, shuffled );
+}
+
+// Normalize this vector with respect to the x, y, and z components only. Accurate to 22 bites of precision. W component is destroyed
+// Note that this does not consider zero length vectors!
+inline void LLVector4a::normalize3()
+{
+	// lenSqrd = a dot a
+	LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this );
+	// rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 }
+	const LLQuad rsqrt = _mm_rsqrt_ps(lenSqrd.mQ);
+	static const LLQuad half = { 0.5f, 0.5f, 0.5f, 0.5f };
+	static const LLQuad three = {3.f, 3.f, 3.f, 3.f };
+	// Now we do one round of Newton-Raphson approximation to get full accuracy
+	// According to the Newton-Raphson method, given a first 'w' for the root of f(x) = 1/x^2 - a (i.e., x = 1/sqrt(a))
+	// the next better approximation w[i+1] = w - f(w)/f'(w) = w - (1/w^2 - a)/(-2*w^(-3))
+	// w[i+1] = w + 0.5 * (1/w^2 - a) * w^3 = w + 0.5 * (w - a*w^3) = 1.5 * w - 0.5 * a * w^3
+	// = 0.5 * w * (3 - a*w^2)
+	// Our first approx is w = rsqrt. We need out = a * w[i+1] (this is the input vector 'a', not the 'a' from the above formula
+	// which is actually lenSqrd). So out = a * [0.5*rsqrt * (3 - lenSqrd*rsqrt*rsqrt)]
+	const LLQuad AtimesRsqrt = _mm_mul_ps( lenSqrd.mQ, rsqrt );
+	const LLQuad AtimesRsqrtTimesRsqrt = _mm_mul_ps( AtimesRsqrt, rsqrt );
+	const LLQuad threeMinusAtimesRsqrtTimesRsqrt = _mm_sub_ps(three, AtimesRsqrtTimesRsqrt );
+	const LLQuad nrApprox = _mm_mul_ps(half, _mm_mul_ps(rsqrt, threeMinusAtimesRsqrtTimesRsqrt));
+	mQ = _mm_mul_ps( mQ, nrApprox );
+}
+
+// Normalize this vector with respect to all components. Accurate to 22 bites of precision.
+// Note that this does not consider zero length vectors!
+inline void LLVector4a::normalize4()
+{
+	// lenSqrd = a dot a
+	LLVector4a lenSqrd; lenSqrd.setAllDot4( *this, *this );
+	// rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 }
+	const LLQuad rsqrt = _mm_rsqrt_ps(lenSqrd.mQ);
+	static const LLQuad half = { 0.5f, 0.5f, 0.5f, 0.5f };
+	static const LLQuad three = {3.f, 3.f, 3.f, 3.f };
+	// Now we do one round of Newton-Raphson approximation to get full accuracy
+	// According to the Newton-Raphson method, given a first 'w' for the root of f(x) = 1/x^2 - a (i.e., x = 1/sqrt(a))
+	// the next better approximation w[i+1] = w - f(w)/f'(w) = w - (1/w^2 - a)/(-2*w^(-3))
+	// w[i+1] = w + 0.5 * (1/w^2 - a) * w^3 = w + 0.5 * (w - a*w^3) = 1.5 * w - 0.5 * a * w^3
+	// = 0.5 * w * (3 - a*w^2)
+	// Our first approx is w = rsqrt. We need out = a * w[i+1] (this is the input vector 'a', not the 'a' from the above formula
+	// which is actually lenSqrd). So out = a * [0.5*rsqrt * (3 - lenSqrd*rsqrt*rsqrt)]
+	const LLQuad AtimesRsqrt = _mm_mul_ps( lenSqrd.mQ, rsqrt );
+	const LLQuad AtimesRsqrtTimesRsqrt = _mm_mul_ps( AtimesRsqrt, rsqrt );
+	const LLQuad threeMinusAtimesRsqrtTimesRsqrt = _mm_sub_ps(three, AtimesRsqrtTimesRsqrt );
+	const LLQuad nrApprox = _mm_mul_ps(half, _mm_mul_ps(rsqrt, threeMinusAtimesRsqrtTimesRsqrt));
+	mQ = _mm_mul_ps( mQ, nrApprox );
+}
+
+// Normalize this vector with respect to the x, y, and z components only. Accurate to 22 bites of precision. W component is destroyed
+// Note that this does not consider zero length vectors!
+inline LLSimdScalar LLVector4a::normalize3withLength()
+{
+	// lenSqrd = a dot a
+	LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this );
+	// rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 }
+	const LLQuad rsqrt = _mm_rsqrt_ps(lenSqrd.mQ);
+	static const LLQuad half = { 0.5f, 0.5f, 0.5f, 0.5f };
+	static const LLQuad three = {3.f, 3.f, 3.f, 3.f };
+	// Now we do one round of Newton-Raphson approximation to get full accuracy
+	// According to the Newton-Raphson method, given a first 'w' for the root of f(x) = 1/x^2 - a (i.e., x = 1/sqrt(a))
+	// the next better approximation w[i+1] = w - f(w)/f'(w) = w - (1/w^2 - a)/(-2*w^(-3))
+	// w[i+1] = w + 0.5 * (1/w^2 - a) * w^3 = w + 0.5 * (w - a*w^3) = 1.5 * w - 0.5 * a * w^3
+	// = 0.5 * w * (3 - a*w^2)
+	// Our first approx is w = rsqrt. We need out = a * w[i+1] (this is the input vector 'a', not the 'a' from the above formula
+	// which is actually lenSqrd). So out = a * [0.5*rsqrt * (3 - lenSqrd*rsqrt*rsqrt)]
+	const LLQuad AtimesRsqrt = _mm_mul_ps( lenSqrd.mQ, rsqrt );
+	const LLQuad AtimesRsqrtTimesRsqrt = _mm_mul_ps( AtimesRsqrt, rsqrt );
+	const LLQuad threeMinusAtimesRsqrtTimesRsqrt = _mm_sub_ps(three, AtimesRsqrtTimesRsqrt );
+	const LLQuad nrApprox = _mm_mul_ps(half, _mm_mul_ps(rsqrt, threeMinusAtimesRsqrtTimesRsqrt));
+	mQ = _mm_mul_ps( mQ, nrApprox );
+	return _mm_sqrt_ss(lenSqrd);
+}
+
+// Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed
+// Note that this does not consider zero length vectors!
+inline void LLVector4a::normalize3fast()
+{
+	LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this );
+	const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ);
+	mQ = _mm_mul_ps( mQ, approxRsqrt );
+}
+
+// Return true if this vector is normalized with respect to x,y,z up to tolerance
+inline LLBool32 LLVector4a::isNormalized3( F32 tolerance ) const
+{
+	static LL_ALIGN_16(const U32 ones[4]) = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 };
+	LLSimdScalar tol = _mm_load_ss( &tolerance );
+	tol = _mm_mul_ss( tol, tol );
+	LLVector4a lenSquared; lenSquared.setAllDot3( *this, *this );
+	lenSquared.sub( *reinterpret_cast<const LLVector4a*>(ones) );
+	lenSquared.setAbs(lenSquared);
+	return _mm_comile_ss( lenSquared, tol );		
+}
+
+// Return true if this vector is normalized with respect to all components up to tolerance
+inline LLBool32 LLVector4a::isNormalized4( F32 tolerance ) const
+{
+	static LL_ALIGN_16(const U32 ones[4]) = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 };
+	LLSimdScalar tol = _mm_load_ss( &tolerance );
+	tol = _mm_mul_ss( tol, tol );
+	LLVector4a lenSquared; lenSquared.setAllDot4( *this, *this );
+	lenSquared.sub( *reinterpret_cast<const LLVector4a*>(ones) );
+	lenSquared.setAbs(lenSquared);
+	return _mm_comile_ss( lenSquared, tol );		
+}
+
+// Set all elements to the length of vector 'v' 
+inline void LLVector4a::setAllLength3( const LLVector4a& v )
+{
+	LLVector4a lenSqrd;
+	lenSqrd.setAllDot3(v, v);
+	
+	mQ = _mm_sqrt_ps(lenSqrd.mQ);
+}
+
+// Get this vector's length
+inline LLSimdScalar LLVector4a::getLength3() const
+{
+	return _mm_sqrt_ss( dot3( (const LLVector4a)mQ ) );
+}
+
+// Set the components of this vector to the minimum of the corresponding components of lhs and rhs
+inline void LLVector4a::setMin(const LLVector4a& lhs, const LLVector4a& rhs)
+{
+	mQ = _mm_min_ps(lhs.mQ, rhs.mQ);
+}
+
+// Set the components of this vector to the maximum of the corresponding components of lhs and rhs
+inline void LLVector4a::setMax(const LLVector4a& lhs, const LLVector4a& rhs)
+{
+	mQ = _mm_max_ps(lhs.mQ, rhs.mQ);
+}
+
+// Set this to  (c * lhs) + rhs * ( 1 - c)
+inline void LLVector4a::setLerp(const LLVector4a& lhs, const LLVector4a& rhs, F32 c)
+{
+	LLVector4a a = lhs;
+	a.mul(c);
+	
+	LLVector4a b = rhs;
+	b.mul(1.f-c);
+	
+	setAdd(a, b);
+}
+
+inline LLBool32 LLVector4a::isFinite3() const
+{
+	static LL_ALIGN_16(const U32 nanOrInfMask[4]) = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 };
+	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 ));
+	return !equalityCheck.areAnySet( LLVector4Logical::MASK_XYZ );
+}
+	
+inline LLBool32 LLVector4a::isFinite4() const
+{
+	static LL_ALIGN_16(const U32 nanOrInfMask[4]) = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 };
+	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 ));
+	return !equalityCheck.areAnySet( LLVector4Logical::MASK_XYZW );
+}
+
+inline void LLVector4a::setRotatedInv( const LLRotation& rot, const LLVector4a& vec )
+{
+	LLRotation inv; inv.setTranspose( rot );
+	setRotated( inv, vec );
+}
+
+inline void LLVector4a::setRotatedInv( const LLQuaternion2& quat, const LLVector4a& vec )
+{
+	LLQuaternion2 invRot; invRot.setConjugate( quat );
+	setRotated(invRot, vec);
+}
+
+inline void LLVector4a::clamp( const LLVector4a& low, const LLVector4a& high )
+{
+	const LLVector4Logical highMask = greaterThan( high );
+	const LLVector4Logical lowMask = lessThan( low );
+
+	setSelectWithMask( highMask, high, *this );
+	setSelectWithMask( lowMask, low, *this );
+}
+
+
+////////////////////////////////////
+// LOGICAL
+////////////////////////////////////	
+// The functions in this section will compare the elements in this vector
+// to those in rhs and return an LLVector4Logical with all bits set in elements
+// where the comparison was true and all bits unset in elements where the comparison
+// was false. See llvector4logica.h
+////////////////////////////////////
+// WARNING: Other than equals3 and equals4, these functions do NOT account
+// for floating point tolerance. You should include the appropriate tolerance
+// in the inputs.
+////////////////////////////////////
+
+inline LLVector4Logical LLVector4a::greaterThan(const LLVector4a& rhs) const
+{	
+	return _mm_cmpgt_ps(mQ, rhs.mQ);
+}
+
+inline LLVector4Logical LLVector4a::lessThan(const LLVector4a& rhs) const
+{
+	return _mm_cmplt_ps(mQ, rhs.mQ);
+}
+
+inline LLVector4Logical LLVector4a::greaterEqual(const LLVector4a& rhs) const
+{
+	return _mm_cmpge_ps(mQ, rhs.mQ);
+}
+
+inline LLVector4Logical LLVector4a::lessEqual(const LLVector4a& rhs) const
+{
+	return _mm_cmple_ps(mQ, rhs.mQ);
+}
+
+inline LLVector4Logical LLVector4a::equal(const LLVector4a& rhs) const
+{
+	return _mm_cmpeq_ps(mQ, rhs.mQ);
+}
+
+// Returns true if this and rhs are componentwise equal up to the specified absolute tolerance
+inline bool LLVector4a::equals4(const LLVector4a& rhs, F32 tolerance ) const
+{
+	LLVector4a diff; diff.setSub( *this, rhs );
+	diff.setAbs( diff );
+	const LLQuad tol = _mm_set1_ps( tolerance );
+	const LLQuad cmp = _mm_cmplt_ps( diff, tol );
+	return (_mm_movemask_ps( cmp ) & LLVector4Logical::MASK_XYZW) == LLVector4Logical::MASK_XYZW;
+}
+
+inline bool LLVector4a::equals3(const LLVector4a& rhs, F32 tolerance ) const
+{
+	LLVector4a diff; diff.setSub( *this, rhs );
+	diff.setAbs( diff );
+	const LLQuad tol = _mm_set1_ps( tolerance );
+	const LLQuad t = _mm_cmplt_ps( diff, tol ); 
+	return (_mm_movemask_ps( t ) & LLVector4Logical::MASK_XYZ) == LLVector4Logical::MASK_XYZ;
+	
+}
+
+////////////////////////////////////
+// OPERATORS
+////////////////////////////////////	
+
+// Do NOT add aditional operators without consulting someone with SSE experience
+inline const LLVector4a& LLVector4a::operator= ( const LLVector4a& rhs )
+{
+	mQ = rhs.mQ;
+	return *this;
+}
+
+inline const LLVector4a& LLVector4a::operator= ( const LLQuad& rhs )
+{
+	mQ = rhs;
+	return *this;
+}
+
+inline LLVector4a::operator LLQuad() const
+{
+	return mQ;
+}
diff --git a/indra/llmath/llvector4logical.h b/indra/llmath/llvector4logical.h
new file mode 100644
index 00000000000..1c7ee1d79f9
--- /dev/null
+++ b/indra/llmath/llvector4logical.h
@@ -0,0 +1,130 @@
+/** 
+ * @file llvector4logical.h
+ * @brief LLVector4Logical class header file - Companion class to LLVector4a for logical and bit-twiddling operations
+ *
+ * $LicenseInfo:firstyear=2010&license=viewergpl$
+ * 
+ * Copyright (c) 2007-2010, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef	LL_VECTOR4LOGICAL_H
+#define	LL_VECTOR4LOGICAL_H
+
+
+////////////////////////////
+// LLVector4Logical
+////////////////////////////
+// This class is incomplete. If you need additional functionality,
+// for example setting/unsetting particular elements or performing
+// other boolean operations, feel free to implement. If you need
+// assistance in determining the most optimal implementation,
+// contact someone with SSE experience (Falcon, Richard, Davep, e.g.)
+////////////////////////////
+
+static LL_ALIGN_16(const U32 S_V4LOGICAL_MASK_TABLE[4*4]) =
+{
+	0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000,
+	0x00000000, 0xFFFFFFFF, 0x00000000, 0x00000000,
+	0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000000,
+	0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF
+};
+
+class LLVector4Logical
+{
+public:
+	
+	enum {
+		MASK_X = 1,
+		MASK_Y = 1 << 1,
+		MASK_Z = 1 << 2,
+		MASK_W = 1 << 3,
+		MASK_XYZ = MASK_X | MASK_Y | MASK_Z,
+		MASK_XYZW = MASK_XYZ | MASK_W
+	};
+	
+	// Empty default ctor
+	LLVector4Logical() {}
+	
+	LLVector4Logical( const LLQuad& quad )
+	{
+		mQ = quad;
+	}
+	
+	// Create and return a mask consisting of the lowest order bit of each element
+	inline U32 getGatheredBits() const
+	{
+		return _mm_movemask_ps(mQ);
+	};	
+	
+	// Invert this mask
+	inline LLVector4Logical& invert()
+	{
+		static const LL_ALIGN_16(U32 allOnes[4]) = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
+		mQ = _mm_andnot_ps( mQ, *(LLQuad*)(allOnes) );
+		return *this;
+	}
+	
+	inline LLBool32 areAllSet( U32 mask ) const
+	{
+		return ( getGatheredBits() & mask) == mask;
+	}
+	
+	inline LLBool32 areAllSet() const
+	{
+		return areAllSet( MASK_XYZW );
+	}
+		
+	inline LLBool32 areAnySet( U32 mask ) const
+	{
+		return getGatheredBits() & mask;
+	}
+	
+	inline LLBool32 areAnySet() const
+	{
+		return areAnySet( MASK_XYZW );
+	}
+	
+	inline operator LLQuad() const
+	{
+		return mQ;
+	}
+
+	inline void clear() 
+	{
+		mQ = _mm_setzero_ps();
+	}
+
+	template<int N> void setElement()
+	{
+		mQ = _mm_or_ps( mQ, *reinterpret_cast<const LLQuad*>(S_V4LOGICAL_MASK_TABLE + 4*N) );
+	}
+	
+private:
+	
+	LLQuad mQ;
+};
+
+#endif //LL_VECTOR4ALOGICAL_H
diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp
new file mode 100644
index 00000000000..194b1faf81f
--- /dev/null
+++ b/indra/llmath/llvolumeoctree.cpp
@@ -0,0 +1,208 @@
+/** 
+
+ * @file llvolumeoctree.cpp
+ *
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llvolumeoctree.h"
+#include "llvector4a.h"
+
+BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size)
+{
+	LLVector4a fAWdU;
+	LLVector4a dir;
+	LLVector4a diff;
+
+	dir.setSub(end, start);
+	dir.mul(0.5f);
+
+	diff.setAdd(end,start);
+	diff.mul(0.5f);
+	diff.sub(center);
+	fAWdU.setAbs(dir); 
+
+	LLVector4a rhs;
+	rhs.setAdd(size, fAWdU);
+
+	LLVector4a lhs;
+	lhs.setAbs(diff);
+
+	U32 grt = lhs.greaterThan(rhs).getGatheredBits();
+
+	if (grt & 0x7)
+	{
+		return false;
+	}
+	
+	LLVector4a f;
+	f.setCross3(dir, diff);
+	f.setAbs(f);
+
+	LLVector4a v0, v1;
+
+	v0 = _mm_shuffle_ps(size, size,_MM_SHUFFLE(3,0,0,1));
+	v1 = _mm_shuffle_ps(fAWdU, fAWdU, _MM_SHUFFLE(3,1,2,2));
+	lhs.setMul(v0, v1);
+
+	v0 = _mm_shuffle_ps(size, size, _MM_SHUFFLE(3,1,2,2));
+	v1 = _mm_shuffle_ps(fAWdU, fAWdU, _MM_SHUFFLE(3,0,0,1));
+	rhs.setMul(v0, v1);
+	rhs.add(lhs);
+	
+	grt = f.greaterThan(rhs).getGatheredBits();
+
+	return (grt & 0x7) ? false : true;
+}
+
+
+LLVolumeOctreeListener::LLVolumeOctreeListener(LLOctreeNode<LLVolumeTriangle>* node)
+{
+	node->addListener(this);
+
+	mBounds = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*4);
+	mExtents = mBounds+2;
+}
+
+LLVolumeOctreeListener::~LLVolumeOctreeListener()
+{
+	ll_aligned_free_16(mBounds);
+}
+	
+void LLVolumeOctreeListener::handleChildAddition(const LLOctreeNode<LLVolumeTriangle>* parent, 
+	LLOctreeNode<LLVolumeTriangle>* child)
+{
+	new LLVolumeOctreeListener(child);
+}
+
+
+LLOctreeTriangleRayIntersect::LLOctreeTriangleRayIntersect(const LLVector4a& start, const LLVector4a& dir, 
+							   const LLVolumeFace* face, F32* closest_t,
+							   LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
+   : mFace(face),
+     mStart(start),
+	 mDir(dir),
+	 mIntersection(intersection),
+	 mTexCoord(tex_coord),
+	 mNormal(normal),
+	 mBinormal(bi_normal),
+	 mClosestT(closest_t),
+	 mHitFace(false)
+{
+	mEnd.setAdd(mStart, mDir);
+}
+
+void LLOctreeTriangleRayIntersect::traverse(const LLOctreeNode<LLVolumeTriangle>* node)
+{
+	LLVolumeOctreeListener* vl = (LLVolumeOctreeListener*) node->getListener(0);
+
+	/*const F32* start = mStart.getF32();
+	const F32* end = mEnd.getF32();
+	const F32* center = vl->mBounds[0].getF32();
+	const F32* size = vl->mBounds[1].getF32();*/
+
+	//if (LLLineSegmentBoxIntersect(mStart.getF32(), mEnd.getF32(), vl->mBounds[0].getF32(), vl->mBounds[1].getF32()))
+	if (LLLineSegmentBoxIntersect(mStart, mEnd, vl->mBounds[0], vl->mBounds[1]))
+	{
+		node->accept(this);
+		for (S32 i = 0; i < node->getChildCount(); ++i)
+		{
+			traverse(node->getChild(i));
+		}
+	}
+}
+
+void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode<LLVolumeTriangle>* node)
+{
+	for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = 
+			node->getData().begin(); iter != node->getData().end(); ++iter)
+	{
+		const LLVolumeTriangle* tri = *iter;
+
+		F32 a, b, t;
+		
+		if (LLTriangleRayIntersect(*tri->mV[0], *tri->mV[1], *tri->mV[2],
+				mStart, mDir, a, b, t))
+		{
+			if ((t >= 0.f) &&      // if hit is after start
+				(t <= 1.f) &&      // and before end
+				(t < *mClosestT))   // and this hit is closer
+			{
+				*mClosestT = t;
+				mHitFace = true;
+
+				if (mIntersection != NULL)
+				{
+					LLVector4a intersect = mDir;
+					intersect.mul(*mClosestT);
+					intersect.add(mStart);
+					mIntersection->set(intersect.getF32ptr());
+				}
+
+
+				if (mTexCoord != NULL)
+				{
+					LLVector2* tc = (LLVector2*) mFace->mTexCoords;
+					*mTexCoord = ((1.f - a - b)  * tc[tri->mIndex[0]] +
+						a              * tc[tri->mIndex[1]] +
+						b              * tc[tri->mIndex[2]]);
+
+				}
+
+				if (mNormal != NULL)
+				{
+					LLVector4* norm = (LLVector4*) mFace->mNormals;
+
+					*mNormal    = ((1.f - a - b)  * LLVector3(norm[tri->mIndex[0]]) + 
+						a              * LLVector3(norm[tri->mIndex[1]]) +
+						b              * LLVector3(norm[tri->mIndex[2]]));
+				}
+
+				if (mBinormal != NULL)
+				{
+					LLVector4* binormal = (LLVector4*) mFace->mBinormals;
+					*mBinormal = ((1.f - a - b)  * LLVector3(binormal[tri->mIndex[0]]) + 
+							a              * LLVector3(binormal[tri->mIndex[1]]) +
+							b              * LLVector3(binormal[tri->mIndex[2]]));
+				}
+			}
+		}
+	}
+}
+
+const LLVector4a& LLVolumeTriangle::getPositionGroup() const
+{
+	return *mPositionGroup;
+}
+
+const F32& LLVolumeTriangle::getBinRadius() const
+{
+	return mRadius;
+}
+
+
diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h
new file mode 100644
index 00000000000..00316264987
--- /dev/null
+++ b/indra/llmath/llvolumeoctree.h
@@ -0,0 +1,138 @@
+/** 
+ * @file llvolumeoctree.h
+ * @brief LLVolume octree classes.
+ *
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLVOLUME_OCTREE_H
+#define LL_LLVOLUME_OCTREE_H
+
+#include "linden_common.h"
+#include "llmemory.h"
+
+#include "lloctree.h"
+#include "llvolume.h"
+#include "llvector4a.h"
+
+class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeTriangle>
+{
+public:
+	
+	LLVolumeOctreeListener(LLOctreeNode<LLVolumeTriangle>* node);
+	~LLVolumeOctreeListener();
+	
+	LLVolumeOctreeListener(const LLVolumeOctreeListener& rhs)
+	{
+		*this = rhs;
+	}
+
+	const LLVolumeOctreeListener& operator=(const LLVolumeOctreeListener& rhs)
+	{
+		llerrs << "Illegal operation!" << llendl;
+		return *this;
+	}
+
+	 //LISTENER FUNCTIONS
+	virtual void handleChildAddition(const LLOctreeNode<LLVolumeTriangle>* parent, 
+		LLOctreeNode<LLVolumeTriangle>* child);
+	virtual void handleStateChange(const LLTreeNode<LLVolumeTriangle>* node) { }
+	virtual void handleChildRemoval(const LLOctreeNode<LLVolumeTriangle>* parent, 
+			const LLOctreeNode<LLVolumeTriangle>* child) {	}
+	virtual void handleInsertion(const LLTreeNode<LLVolumeTriangle>* node, LLVolumeTriangle* tri) { }
+	virtual void handleRemoval(const LLTreeNode<LLVolumeTriangle>* node, LLVolumeTriangle* tri) { }
+	virtual void handleDestruction(const LLTreeNode<LLVolumeTriangle>* node) { }
+	
+
+public:
+	LLVector4a* mBounds; // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LLVector4a* mExtents; // extents (min, max) of this node and all its children
+};
+
+class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle>
+{
+public:
+	const LLVolumeFace* mFace;
+	LLVector4a mStart;
+	LLVector4a mDir;
+	LLVector4a mEnd;
+	LLVector3* mIntersection;
+	LLVector2* mTexCoord;
+	LLVector3* mNormal;
+	LLVector3* mBinormal;
+	F32* mClosestT;
+	bool mHitFace;
+
+	LLOctreeTriangleRayIntersect() { };
+
+	LLOctreeTriangleRayIntersect(const LLVector4a& start, const LLVector4a& dir, 
+								   const LLVolumeFace* face, F32* closest_t,
+								   LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal);
+
+	void traverse(const LLOctreeNode<LLVolumeTriangle>* node);
+
+	virtual void visit(const LLOctreeNode<LLVolumeTriangle>* node);
+};
+
+class LLVolumeTriangle : public LLRefCount
+{
+public:
+	LLVolumeTriangle()
+	{
+		mPositionGroup = (LLVector4a*) ll_aligned_malloc_16(16);
+	}
+
+	LLVolumeTriangle(const LLVolumeTriangle& rhs)
+	{
+		*this = rhs;
+	}
+
+	const LLVolumeTriangle& operator=(const LLVolumeTriangle& rhs)
+	{
+		llerrs << "Illegal operation!" << llendl;
+		return *this;
+	}
+
+	~LLVolumeTriangle()
+	{
+		ll_aligned_free_16(mPositionGroup);
+	}
+
+	const LLVector4a* mV[3];
+	U16 mIndex[3];
+
+	LLVector4a* mPositionGroup;
+
+	F32 mRadius;
+
+	virtual const LLVector4a& getPositionGroup() const;
+	virtual const F32& getBinRadius() const;
+};
+
+
+#endif
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
new file mode 100644
index 00000000000..82765c740fc
--- /dev/null
+++ b/indra/llprimitive/llmodel.cpp
@@ -0,0 +1,1695 @@
+/** 
+ * @file llmodel.cpp
+ * @brief Model handling implementation
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2007, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+
+#include "llmodel.h"
+#include "llsdserialize.h"
+#include "llvector4a.h"
+
+#include "dae.h"
+#include "dae/daeErrorHandler.h"
+#include "dom/domConstants.h"
+#include "dom/domMesh.h"
+#include "zlib/zlib.h"
+
+#if LL_MESH_ENABLED
+
+std::string model_names[] =
+{
+	"lowest_lod",
+	"low_lod",
+	"medium_lod",
+	"high_lod",
+	"physics_shape"
+};
+
+const int MODEL_NAMES_LENGTH = sizeof(model_names) / sizeof(std::string);
+
+LLModel::LLModel(LLVolumeParams& params, F32 detail)
+	: LLVolume(params, detail), mNormalizedScale(1,1,1), mNormalizedTranslation(0,0,0)
+{
+
+}
+
+void load_face_from_dom_inputs(LLVolumeFace& face, const domInputLocalOffset_Array& inputs, U32 min_idx, U32 max_idx)
+{
+	for (U32 j = 0; j < inputs.getCount(); ++j)
+	{
+		if (strcmp(COMMON_PROFILE_INPUT_VERTEX, inputs[j]->getSemantic()) == 0)
+		{ //found vertex array
+			const domURIFragmentType& uri = inputs[j]->getSource();
+			daeElementRef elem = uri.getElement();
+			domVertices* vertices = (domVertices*) elem.cast();
+
+			domInputLocal_Array& v_inp = vertices->getInput_array();
+			if (inputs[j]->getOffset() != 0)
+			{
+				llerrs << "WTF?" << llendl;
+			}
+
+			for (U32 k = 0; k < v_inp.getCount(); ++k)
+			{
+				if (strcmp(COMMON_PROFILE_INPUT_POSITION, v_inp[k]->getSemantic()) == 0)
+				{
+					const domURIFragmentType& uri = v_inp[k]->getSource();
+					
+					daeElementRef elem = uri.getElement();
+					domSource* src = (domSource*) elem.cast();
+
+					if (src->getTechnique_common()->getAccessor()->getStride() != 3)
+					{
+						llerrs << "WTF?" << llendl;
+					}
+
+					domListOfFloats& v = src->getFloat_array()->getValue();
+
+					LLVector4a min;
+					min.set(v[min_idx], v[min_idx+1], v[min_idx+2]);
+					LLVector4a max = min;
+
+					for (U32 j = min_idx; j <= max_idx; ++j)
+					{ //copy vertex array
+						face.mPositions[j-min_idx].set(v[j*3+0], v[j*3+1], v[j*3+2]);
+						update_min_max(min, max, face.mPositions[j-min_idx]);
+					}
+
+					face.mExtents[0] = min;
+					face.mExtents[1] = max;
+				}
+			}
+		}
+
+		if (strcmp(COMMON_PROFILE_INPUT_NORMAL, inputs[j]->getSemantic()) == 0)
+		{
+			//found normal array for this triangle list
+			const domURIFragmentType& uri = inputs[j]->getSource();
+			daeElementRef elem = uri.getElement();
+			domSource* src = (domSource*) elem.cast();
+			domListOfFloats& n = src->getFloat_array()->getValue();
+			
+			for (U32 j = min_idx; j <= max_idx; ++j)
+			{
+				LLVector4a* norm = (LLVector4a*) face.mNormals + (j-min_idx);
+				norm->set(n[j*3+0], n[j*3+1], n[j*3+2]);
+				norm->normalize3fast();
+			}
+		}
+		else if (strcmp(COMMON_PROFILE_INPUT_TEXCOORD, inputs[j]->getSemantic()) == 0)
+		{ //found texCoords
+			const domURIFragmentType& uri = inputs[j]->getSource();
+			daeElementRef elem = uri.getElement();
+			domSource* src = (domSource*) elem.cast();
+			domListOfFloats& u = src->getFloat_array()->getValue();
+			
+			for (U32 j = min_idx; j <= max_idx; ++j)
+			{
+				face.mTexCoords[j-min_idx].setVec(u[j*2+0], u[j*2+1]);
+			}
+		}
+	}
+}
+
+void get_dom_sources(const domInputLocalOffset_Array& inputs, S32& pos_offset, S32& tc_offset, S32& norm_offset, S32 &idx_stride,
+					 domSource* &pos_source, domSource* &tc_source, domSource* &norm_source)
+{
+	idx_stride = 0;
+
+	for (U32 j = 0; j < inputs.getCount(); ++j)
+	{
+		idx_stride = llmax((S32) inputs[j]->getOffset(), idx_stride);
+
+		if (strcmp(COMMON_PROFILE_INPUT_VERTEX, inputs[j]->getSemantic()) == 0)
+		{ //found vertex array
+			const domURIFragmentType& uri = inputs[j]->getSource();
+			daeElementRef elem = uri.getElement();
+			domVertices* vertices = (domVertices*) elem.cast();
+
+			domInputLocal_Array& v_inp = vertices->getInput_array();
+			
+			
+			for (U32 k = 0; k < v_inp.getCount(); ++k)
+			{
+				if (strcmp(COMMON_PROFILE_INPUT_POSITION, v_inp[k]->getSemantic()) == 0)
+				{
+					pos_offset = inputs[j]->getOffset();
+
+					const domURIFragmentType& uri = v_inp[k]->getSource();
+					daeElementRef elem = uri.getElement();
+					pos_source = (domSource*) elem.cast();
+				}
+				
+				if (strcmp(COMMON_PROFILE_INPUT_NORMAL, v_inp[k]->getSemantic()) == 0)
+				{
+					norm_offset = inputs[j]->getOffset();
+
+					const domURIFragmentType& uri = v_inp[k]->getSource();
+					daeElementRef elem = uri.getElement();
+					norm_source = (domSource*) elem.cast();
+				}
+			}
+		}
+
+		if (strcmp(COMMON_PROFILE_INPUT_NORMAL, inputs[j]->getSemantic()) == 0)
+		{
+			//found normal array for this triangle list
+			norm_offset = inputs[j]->getOffset();
+			const domURIFragmentType& uri = inputs[j]->getSource();
+			daeElementRef elem = uri.getElement();
+			norm_source = (domSource*) elem.cast();
+		}
+		else if (strcmp(COMMON_PROFILE_INPUT_TEXCOORD, inputs[j]->getSemantic()) == 0)
+		{ //found texCoords
+			tc_offset = inputs[j]->getOffset();
+			const domURIFragmentType& uri = inputs[j]->getSource();
+			daeElementRef elem = uri.getElement();
+			tc_source = (domSource*) elem.cast();
+		}
+	}
+
+	idx_stride += 1;
+}
+
+void load_face_from_dom_triangles(std::vector<LLVolumeFace>& face_list, std::vector<std::string>& materials, domTrianglesRef& tri)
+{
+	LLVolumeFace face;
+	std::vector<LLVolumeFace::VertexData> verts;
+	std::vector<U16> indices;
+	
+	const domInputLocalOffset_Array& inputs = tri->getInput_array();
+
+	S32 pos_offset = -1;
+	S32 tc_offset = -1;
+	S32 norm_offset = -1;
+
+	domSource* pos_source = NULL;
+	domSource* tc_source = NULL;
+	domSource* norm_source = NULL;
+
+	S32 idx_stride = 0;
+
+	get_dom_sources(inputs, pos_offset, tc_offset, norm_offset, idx_stride, pos_source, tc_source, norm_source);
+
+	domPRef p = tri->getP();
+	domListOfUInts& idx = p->getValue();
+	
+	domListOfFloats v;
+	domListOfFloats tc;
+	domListOfFloats n;
+
+	if (pos_source)
+	{
+		v = pos_source->getFloat_array()->getValue();
+		face.mExtents[0].set(v[0], v[1], v[2]);
+		face.mExtents[1].set(v[0], v[1], v[2]);
+	}
+
+	if (tc_source)
+	{
+		tc = tc_source->getFloat_array()->getValue();
+	}
+
+	if (norm_source)
+	{
+		n = norm_source->getFloat_array()->getValue();
+	}
+
+	
+	LLVolumeFace::VertexMapData::PointMap point_map;
+	
+	for (U32 i = 0; i < idx.getCount(); i += idx_stride)
+	{
+		LLVolumeFace::VertexData cv;
+		if (pos_source)
+		{
+			cv.setPosition(LLVector4a(v[idx[i+pos_offset]*3+0],
+								v[idx[i+pos_offset]*3+1],
+								v[idx[i+pos_offset]*3+2]));
+		}
+
+		if (tc_source)
+		{
+			cv.mTexCoord.setVec(tc[idx[i+tc_offset]*2+0],
+								tc[idx[i+tc_offset]*2+1]);
+		}
+
+		if (norm_source)
+		{
+			cv.setNormal(LLVector4a(n[idx[i+norm_offset]*3+0],
+								n[idx[i+norm_offset]*3+1],
+								n[idx[i+norm_offset]*3+2]));
+		}
+
+		
+		BOOL found = FALSE;
+			
+		LLVolumeFace::VertexMapData::PointMap::iterator point_iter;
+		point_iter = point_map.find(LLVector3(cv.getPosition().getF32ptr()));
+		
+		if (point_iter != point_map.end())
+		{
+			for (U32 j = 0; j < point_iter->second.size(); ++j)
+			{
+				if ((point_iter->second)[j] == cv)
+				{
+					found = TRUE;
+					indices.push_back((point_iter->second)[j].mIndex);
+					break;
+				}
+			}
+		}
+
+		if (!found)
+		{
+			update_min_max(face.mExtents[0], face.mExtents[1], cv.getPosition());
+			verts.push_back(cv);
+			if (verts.size() >= 65535)
+			{
+				llerrs << "Attempted to write model exceeding 16-bit index buffer limitation." << llendl;
+			}
+			U16 index = (U16) (verts.size()-1);
+			indices.push_back(index);
+
+			LLVolumeFace::VertexMapData d;
+			d.setPosition(cv.getPosition());
+			d.mTexCoord = cv.mTexCoord;
+			d.setNormal(cv.getNormal());
+			d.mIndex = index;
+			if (point_iter != point_map.end())
+			{
+				point_iter->second.push_back(d);
+			}
+			else
+			{
+				point_map[LLVector3(d.getPosition().getF32ptr())].push_back(d);
+			}
+		}
+
+		if (indices.size()%3 == 0 && verts.size() >= 65532)
+		{
+			face_list.push_back(face);
+			face_list.rbegin()->fillFromLegacyData(verts, indices);
+			face = LLVolumeFace();
+			point_map.clear();
+		}
+
+	}
+
+	if (!verts.empty())
+	{
+		std::string material;
+
+		if (tri->getMaterial())
+		{
+			material = std::string(tri->getMaterial());
+		}
+		
+		materials.push_back(material);
+		face_list.push_back(face);
+
+		face_list.rbegin()->fillFromLegacyData(verts, indices);
+	}
+
+}
+
+void load_face_from_dom_polylist(std::vector<LLVolumeFace>& face_list, std::vector<std::string>& materials, domPolylistRef& poly)
+{
+	domPRef p = poly->getP();
+	domListOfUInts& idx = p->getValue();
+
+	if (idx.getCount() == 0)
+	{
+		return;
+	}
+
+	const domInputLocalOffset_Array& inputs = poly->getInput_array();
+
+
+	domListOfUInts& vcount = poly->getVcount()->getValue();
+	
+	S32 pos_offset = -1;
+	S32 tc_offset = -1;
+	S32 norm_offset = -1;
+
+	domSource* pos_source = NULL;
+	domSource* tc_source = NULL;
+	domSource* norm_source = NULL;
+
+	S32 idx_stride = 0;
+
+	get_dom_sources(inputs, pos_offset, tc_offset, norm_offset, idx_stride, pos_source, tc_source, norm_source);
+
+	LLVolumeFace face;
+
+	std::vector<U16> indices;
+	std::vector<LLVolumeFace::VertexData> verts;
+
+	domListOfFloats v;
+	domListOfFloats tc;
+	domListOfFloats n;
+
+	if (pos_source)
+	{
+		v = pos_source->getFloat_array()->getValue();
+		face.mExtents[0].set(v[0], v[1], v[2]);
+		face.mExtents[1].set(v[0], v[1], v[2]);
+	}
+
+	if (tc_source)
+	{
+		tc = tc_source->getFloat_array()->getValue();
+	}
+
+	if (norm_source)
+	{
+		n = norm_source->getFloat_array()->getValue();
+	}
+	
+	LLVolumeFace::VertexMapData::PointMap point_map;
+
+	U32 cur_idx = 0;
+	for (U32 i = 0; i < vcount.getCount(); ++i)
+	{ //for each polygon
+		U32 first_index = 0;
+		U32 last_index = 0;
+		for (U32 j = 0; j < vcount[i]; ++j)
+		{ //for each vertex
+
+			LLVolumeFace::VertexData cv;
+
+			if (pos_source)
+			{
+				cv.getPosition().set(v[idx[cur_idx+pos_offset]*3+0],
+									v[idx[cur_idx+pos_offset]*3+1],
+									v[idx[cur_idx+pos_offset]*3+2]);
+			}
+
+			if (tc_source)
+			{
+				cv.mTexCoord.setVec(tc[idx[cur_idx+tc_offset]*2+0],
+									tc[idx[cur_idx+tc_offset]*2+1]);
+			}
+
+			if (norm_source)
+			{
+				cv.getNormal().set(n[idx[cur_idx+norm_offset]*3+0],
+									n[idx[cur_idx+norm_offset]*3+1],
+									n[idx[cur_idx+norm_offset]*3+2]);
+			}
+
+			cur_idx += idx_stride;
+			
+			BOOL found = FALSE;
+				
+			LLVolumeFace::VertexMapData::PointMap::iterator point_iter;
+			LLVector3 pos3(cv.getPosition().getF32ptr());
+			point_iter = point_map.find(pos3);
+			
+			if (point_iter != point_map.end())
+			{
+				for (U32 k = 0; k < point_iter->second.size(); ++k)
+				{
+					if ((point_iter->second)[k] == cv)
+					{
+						found = TRUE;
+						U32 index = (point_iter->second)[k].mIndex;
+						if (j == 0)
+						{
+							first_index = index;
+						}
+						else if (j == 1)
+						{
+							last_index = index;
+						}
+						else
+						{
+							indices.push_back(first_index);
+							indices.push_back(last_index);
+							indices.push_back(index);
+							last_index = index;
+						}
+
+						break;
+					}
+				}
+			}
+
+			if (!found)
+			{
+				update_min_max(face.mExtents[0], face.mExtents[1], cv.getPosition());
+				verts.push_back(cv);
+				if (verts.size() >= 65535)
+				{
+					llerrs << "Attempted to write model exceeding 16-bit index buffer limitation." << llendl;
+				}
+				U16 index = (U16) (verts.size()-1);
+			
+				if (j == 0)
+				{
+					first_index = index;
+				}
+				else if (j == 1)
+				{
+					last_index = index;
+				}
+				else
+				{
+					indices.push_back(first_index);
+					indices.push_back(last_index);
+					indices.push_back(index);
+					last_index = index;
+				}	
+
+				LLVolumeFace::VertexMapData d;
+				d.setPosition(cv.getPosition());
+				d.mTexCoord = cv.mTexCoord;
+				d.setNormal(cv.getNormal());
+				d.mIndex = index;
+				if (point_iter != point_map.end())
+				{
+					point_iter->second.push_back(d);
+				}
+				else
+				{
+					point_map[pos3].push_back(d);
+				}
+			}
+
+			if (indices.size()%3 == 0 && indices.size() >= 65532)
+			{
+				face_list.push_back(face);
+				face_list.rbegin()->fillFromLegacyData(verts, indices);
+				face = LLVolumeFace();
+				verts.clear();
+				indices.clear();
+				point_map.clear();
+			}
+		}
+	}
+
+	if (!verts.empty())
+	{
+		std::string material;
+
+		if (poly->getMaterial())
+		{
+			material = std::string(poly->getMaterial());
+		}
+		
+		materials.push_back(material);
+		face_list.push_back(face);
+		face_list.rbegin()->fillFromLegacyData(verts, indices);
+	}
+}
+
+void load_face_from_dom_polygons(std::vector<LLVolumeFace>& face_list, std::vector<std::string>& materials, domPolygonsRef& poly)
+{
+	LLVolumeFace face;
+	std::vector<U16> indices;
+	std::vector<LLVolumeFace::VertexData> verts;
+
+	const domInputLocalOffset_Array& inputs = poly->getInput_array();
+
+
+	S32 v_offset = -1;
+	S32 n_offset = -1;
+	S32 t_offset = -1;
+
+	domListOfFloats* v = NULL;
+	domListOfFloats* n = NULL;
+	domListOfFloats* t = NULL;
+	
+	U32 stride = 0;
+	for (U32 i = 0; i < inputs.getCount(); ++i)
+	{
+		stride = llmax((U32) inputs[i]->getOffset()+1, stride);
+
+		if (strcmp(COMMON_PROFILE_INPUT_VERTEX, inputs[i]->getSemantic()) == 0)
+		{ //found vertex array
+			v_offset = inputs[i]->getOffset();
+
+			const domURIFragmentType& uri = inputs[i]->getSource();
+			daeElementRef elem = uri.getElement();
+			domVertices* vertices = (domVertices*) elem.cast();
+
+			domInputLocal_Array& v_inp = vertices->getInput_array();
+
+			for (U32 k = 0; k < v_inp.getCount(); ++k)
+			{
+				if (strcmp(COMMON_PROFILE_INPUT_POSITION, v_inp[k]->getSemantic()) == 0)
+				{
+					const domURIFragmentType& uri = v_inp[k]->getSource();
+					daeElementRef elem = uri.getElement();
+					domSource* src = (domSource*) elem.cast();
+					v = &(src->getFloat_array()->getValue());
+				}
+			}
+		}
+		else if (strcmp(COMMON_PROFILE_INPUT_NORMAL, inputs[i]->getSemantic()) == 0)
+		{
+			n_offset = inputs[i]->getOffset();
+			//found normal array for this triangle list
+			const domURIFragmentType& uri = inputs[i]->getSource();
+			daeElementRef elem = uri.getElement();
+			domSource* src = (domSource*) elem.cast();
+			n = &(src->getFloat_array()->getValue());
+		}
+		else if (strcmp(COMMON_PROFILE_INPUT_TEXCOORD, inputs[i]->getSemantic()) == 0 && inputs[i]->getSet() == 0)
+		{ //found texCoords
+			t_offset = inputs[i]->getOffset();
+			const domURIFragmentType& uri = inputs[i]->getSource();
+			daeElementRef elem = uri.getElement();
+			domSource* src = (domSource*) elem.cast();
+			t = &(src->getFloat_array()->getValue());
+		}
+	}
+
+	domP_Array& ps = poly->getP_array();
+
+	//make a triangle list in <verts>
+	for (U32 i = 0; i < ps.getCount(); ++i)
+	{ //for each polygon
+		domListOfUInts& idx = ps[i]->getValue();
+		for (U32 j = 0; j < idx.getCount()/stride; ++j)
+		{ //for each vertex
+			if (j > 2)
+			{
+				U32 size = verts.size();
+				LLVolumeFace::VertexData v0 = verts[size-3];
+				LLVolumeFace::VertexData v1 = verts[size-1];
+
+				verts.push_back(v0);
+				verts.push_back(v1);
+			}
+
+			LLVolumeFace::VertexData vert;
+
+
+			if (v)
+			{
+				U32 v_idx = idx[j*stride+v_offset]*3;
+				vert.getPosition().set(v->get(v_idx),
+								v->get(v_idx+1),
+								v->get(v_idx+2));
+			}
+			
+			if (n)
+			{
+				U32 n_idx = idx[j*stride+n_offset]*3;
+				vert.getNormal().set(n->get(n_idx),
+								n->get(n_idx+1),
+								n->get(n_idx+2));
+			}
+
+			if (t)
+			{
+				U32 t_idx = idx[j*stride+t_offset]*2;
+				vert.mTexCoord.setVec(t->get(t_idx),
+								t->get(t_idx+1));								
+			}
+		
+			
+			verts.push_back(vert);
+		}
+	}
+
+	if (verts.empty())
+	{
+		return;
+	}
+
+	face.mExtents[0] = verts[0].getPosition();
+	face.mExtents[1] = verts[0].getPosition();
+	
+	//create a map of unique vertices to indices
+	std::map<LLVolumeFace::VertexData, U32> vert_idx;
+
+	U32 cur_idx = 0;
+	for (U32 i = 0; i < verts.size(); ++i)
+	{
+		std::map<LLVolumeFace::VertexData, U32>::iterator iter = vert_idx.find(verts[i]);
+		if (iter == vert_idx.end())
+		{
+			vert_idx[verts[i]] = cur_idx++;
+		}
+	}
+
+	//build vertex array from map
+	verts.resize(vert_idx.size());
+
+	for (std::map<LLVolumeFace::VertexData, U32>::iterator iter = vert_idx.begin(); iter != vert_idx.end(); ++iter)
+	{
+		verts[iter->second] = iter->first;
+		update_min_max(face.mExtents[0], face.mExtents[1], iter->first.getPosition());
+	}
+
+	//build index array from map
+	indices.resize(verts.size());
+
+	for (U32 i = 0; i < verts.size(); ++i)
+	{
+		indices[i] = vert_idx[verts[i]];
+	}
+
+
+    if (!verts.empty())
+	{
+		std::string material;
+
+		if (poly->getMaterial())
+		{
+			material = std::string(poly->getMaterial());
+		}
+
+		materials.push_back(material);
+		face_list.push_back(face);
+		face_list.rbegin()->fillFromLegacyData(verts, indices);
+	}
+}
+
+void LLModel::addVolumeFacesFromDomMesh(domMesh* mesh)
+{
+	domTriangles_Array& tris = mesh->getTriangles_array();
+		
+	for (U32 i = 0; i < tris.getCount(); ++i)
+	{
+		domTrianglesRef& tri = tris.get(i);
+
+		load_face_from_dom_triangles(mVolumeFaces, mMaterialList, tri);
+	}
+
+	domPolylist_Array& polys = mesh->getPolylist_array();
+	for (U32 i = 0; i < polys.getCount(); ++i)
+	{
+		domPolylistRef& poly = polys.get(i);
+
+		load_face_from_dom_polylist(mVolumeFaces, mMaterialList, poly);
+	}
+
+	domPolygons_Array& polygons = mesh->getPolygons_array();
+	for (U32 i = 0; i < polygons.getCount(); ++i)
+	{
+		domPolygonsRef& poly = polygons.get(i);
+
+		load_face_from_dom_polygons(mVolumeFaces, mMaterialList, poly);
+	}
+
+}
+
+BOOL LLModel::createVolumeFacesFromDomMesh(domMesh* mesh)
+{
+	if (mesh)
+	{
+		mVolumeFaces.clear();
+		mMaterialList.clear();
+
+		addVolumeFacesFromDomMesh(mesh);
+
+		if (getNumVolumeFaces() > 0)
+		{
+			optimizeVolumeFaces();
+			normalizeVolumeFaces();
+
+			if (getNumVolumeFaces() > 0)
+			{
+				return TRUE;
+			}
+		}
+	}
+	else
+	{	
+		llwarns << "no mesh found" << llendl;
+	}
+	
+	return FALSE;
+}
+
+
+BOOL LLModel::createVolumeFacesFromFile(const std::string& file_name)
+{
+	DAE dae;
+	domCOLLADA* dom = dae.open(file_name);
+	if (dom)
+	{
+		daeDatabase* db = dae.getDatabase();
+
+		daeInt count = db->getElementCount(NULL, COLLADA_TYPE_MESH);
+		
+		mVolumeFaces.clear();
+		mMaterialList.clear();
+
+		for (daeInt idx = 0; idx < count; ++idx)
+		{
+			domMesh* mesh = NULL;
+
+			db->getElement((daeElement**) &mesh, idx, NULL, COLLADA_TYPE_MESH);
+			
+			if (mesh)
+			{
+				addVolumeFacesFromDomMesh(mesh);
+			}
+		}
+
+		if (getNumVolumeFaces() > 0)
+		{
+			optimizeVolumeFaces();
+			normalizeVolumeFaces();
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
+
+void LLModel::optimizeVolumeFaces()
+{
+#if 0 //VECTORIZE ?
+	for (std::vector<LLVolumeFace>::iterator iter = mVolumeFaces.begin(); iter != mVolumeFaces.end(); )
+	{
+		std::vector<LLVolumeFace>::iterator cur_iter = iter++;
+		LLVolumeFace& face = *cur_iter;
+
+		for (S32 i = 0; i < (S32) face.mNumIndices; i += 3)
+		{ //remove zero area triangles
+			U16 i0 = face.mIndices[i+0];
+			U16 i1 = face.mIndices[i+1];
+			U16 i2 = face.mIndices[i+2];
+
+			if (i0 == i1 || 
+				i1 == i2 || 
+				i0 == i2)
+			{ //duplicate index in triangle, remove triangle
+				face.mIndices.erase(face.mIndices.begin()+i, face.mIndices.begin()+i+3);
+				i -= 3;
+			}
+			else
+			{ 
+				LLVolumeFace::VertexData& v0 = face.mVertices[i0];
+				LLVolumeFace::VertexData& v1 = face.mVertices[i1];
+				LLVolumeFace::VertexData& v2 = face.mVertices[i2];
+
+				if (v0.mPosition == v1.mPosition ||
+					v1.mPosition == v2.mPosition ||
+					v2.mPosition == v0.mPosition)
+				{ //zero area triangle, delete
+					face.mIndices.erase(face.mIndices.begin()+i, face.mIndices.begin()+i+3);
+					i-=3;
+				}
+			}
+		}
+
+		//remove unreference vertices
+		std::vector<bool> ref;
+		ref.resize(face.mNumVertices);
+
+		for (U32 i = 0; i < ref.size(); ++i)
+		{
+			ref[i] = false;
+		}
+
+		for (U32 i = 0; i < face.mNumIndices; ++i)
+		{ 
+			ref[face.mIndices[i]] = true;
+		}
+
+		U32 unref_count = 0;
+		for (U32 i = 0; i < ref.size(); ++i)
+		{
+			if (!ref[i])
+			{
+				//vertex is unreferenced
+				face.mVertices.erase(face.mVertices.begin()+(i-unref_count));
+				U16 idx = (U16) (i-unref_count);
+
+				for (U32 j = 0; j < face.mNumIndices; ++j)
+				{ //decrement every index array value greater than idx
+					if (face.mIndices[j] > idx)
+					{
+						--face.mIndices[j];
+					}
+				}
+				++unref_count;
+			}
+		}
+
+		if (face.mVertices.empty() || face.mIndices.empty())
+		{ //face is empty, remove it
+			iter = mVolumeFaces.erase(cur_iter);
+		}
+	}
+#endif
+}
+
+void LLModel::normalizeVolumeFaces()
+{
+
+	// ensure we don't have too many faces
+	if (mVolumeFaces.size() > LL_SCULPT_MESH_MAX_FACES)
+		mVolumeFaces.resize(LL_SCULPT_MESH_MAX_FACES);
+	
+	if (!mVolumeFaces.empty())
+	{
+		LLVector4a min, max;
+		
+		if (mVolumeFaces[0].mNumVertices <= 0)
+		{
+			llerrs << "WTF?" << llendl;
+		}
+
+		min = mVolumeFaces[0].mExtents[0];
+		max = mVolumeFaces[0].mExtents[1];
+
+		for (U32 i = 1; i < mVolumeFaces.size(); ++i)
+		{
+			LLVolumeFace& face = mVolumeFaces[i];
+
+			if (face.mNumVertices <= 0)
+			{
+				llerrs << "WTF?" << llendl;
+			}
+
+			update_min_max(min, max, face.mExtents[0]);
+			update_min_max(min, max, face.mExtents[1]);
+		}
+
+		LLVector4a trans;
+		trans.setAdd(min, max);
+		trans.mul(-0.5f);
+		LLVector4a size;
+		size.setSub(max, min);
+
+		F32 scale = 1.f/llmax(llmax(size[0], size[1]), size[2]);
+
+		for (U32 i = 0; i < mVolumeFaces.size(); ++i)
+		{
+			LLVolumeFace& face = mVolumeFaces[i];
+				
+			face.mExtents[0].add(trans);
+			face.mExtents[0].mul(scale);
+
+			face.mExtents[1].add(trans);
+			face.mExtents[1].mul(scale);
+
+			LLVector4a* pos = (LLVector4a*) face.mPositions;
+			for (U32 j = 0; j < face.mNumVertices; ++j)
+			{
+				pos[j].add(trans);
+				pos[j].mul(scale);
+			}
+		}
+
+		mNormalizedScale = LLVector3(1,1,1) / scale;
+		mNormalizedTranslation.set(trans.getF32ptr());
+		mNormalizedTranslation *= -1.f; 
+	}
+}
+
+void LLModel::getNormalizedScaleTranslation(LLVector3& scale_out, LLVector3& translation_out)
+{
+	scale_out = mNormalizedScale;
+	translation_out = mNormalizedTranslation;
+}
+
+void LLModel::setNumVolumeFaces(S32 count)
+{
+	mVolumeFaces.resize(count);
+}
+
+void LLModel::setVolumeFaceData(S32 f, 
+								LLStrider<LLVector3> pos, 
+								LLStrider<LLVector3> norm, 
+								LLStrider<LLVector2> tc, 
+								LLStrider<U16> ind, 
+								U32 num_verts, 
+								U32 num_indices)
+{
+	LLVolumeFace& face = mVolumeFaces[f];
+
+	face.resizeVertices(num_verts);
+	face.resizeIndices(num_indices);
+
+	LLVector4a::memcpyNonAliased16((F32*) face.mPositions, (F32*) pos.get(), num_verts*4*sizeof(F32));
+	LLVector4a::memcpyNonAliased16((F32*) face.mNormals, (F32*) norm.get(), num_verts*4*sizeof(F32));
+	LLVector4a::memcpyNonAliased16((F32*) face.mTexCoords, (F32*) tc.get(), num_verts*2*sizeof(F32));
+	U32 size = (num_indices*2+0xF)&~0xF;
+	LLVector4a::memcpyNonAliased16((F32*) face.mIndices, (F32*) ind.get(), size);
+}
+
+void LLModel::appendFaces(LLModel *model, LLMatrix4 &transform, LLMatrix4& norm_mat)
+{
+	if (mVolumeFaces.empty())
+	{
+		setNumVolumeFaces(1);
+	}
+
+	LLVolumeFace& face = mVolumeFaces[mVolumeFaces.size()-1];
+
+
+	for (S32 i = 0; i < model->getNumFaces(); ++i)
+	{
+		face.appendFace(model->getVolumeFace(i), transform, norm_mat);
+	}
+
+}
+
+void LLModel::appendFace(const LLVolumeFace& src_face, std::string src_material, LLMatrix4& mat, LLMatrix4& norm_mat)
+{
+	S32 rindex = getNumVolumeFaces()-1; 
+	if (rindex == -1 || 
+		mVolumeFaces[rindex].mNumVertices + src_face.mNumVertices >= 65536)
+	{ //empty or overflow will occur, append new face
+		LLVolumeFace cur_face;
+		cur_face.appendFace(src_face, mat, norm_mat);
+		addFace(cur_face);
+		mMaterialList.push_back(src_material);
+	}
+	else
+	{ //append to existing end face
+		mVolumeFaces.rbegin()->appendFace(src_face, mat, norm_mat);
+	}
+}
+
+void LLModel::addFace(const LLVolumeFace& face)
+{
+	if (face.mNumVertices == 0)
+	{
+		llerrs << "Cannot add empty face." << llendl;
+	}
+
+	mVolumeFaces.push_back(face);
+
+	if (mVolumeFaces.size() > MAX_MODEL_FACES)
+	{
+		llerrs << "Model prims cannot have more than " << MAX_MODEL_FACES << " faces!" << llendl;
+	}
+}
+
+
+void LLModel::smoothNormals(F32 angle_cutoff)
+{
+	//smooth normals for all faces by:
+	// 1 - Create faceted copy of face with no texture coordinates
+	// 2 - Weld vertices in faceted copy that are shared between triangles with less than "angle_cutoff" difference between normals
+	// 3 - Generate smoothed set of normals based on welding results
+	// 4 - Create faceted copy of face with texture coordinates
+	// 5 - Copy smoothed normals to faceted copy, using closest normal to triangle normal where more than one normal exists for a given position
+	// 6 - Remove redundant vertices from new faceted (now smooth) copy
+
+	angle_cutoff = cosf(angle_cutoff);
+	for (U32 j = 0; j < mVolumeFaces.size(); ++j)
+	{
+		LLVolumeFace& vol_face = mVolumeFaces[j];
+
+		//create faceted copy of current face with no texture coordinates (step 1)
+		LLVolumeFace faceted;
+
+		LLVector4a* src_pos = (LLVector4a*) vol_face.mPositions;
+		//LLVector4a* src_norm = (LLVector4a*) vol_face.mNormals;
+
+
+		//bake out triangles into temporary face, clearing normals and texture coordinates
+		for (U32 i = 0; i < vol_face.mNumIndices; ++i)
+		{
+			U32 idx = vol_face.mIndices[i];
+			LLVolumeFace::VertexData v;
+			v.setPosition(src_pos[idx]); 
+			v.getNormal().clear();
+			v.mTexCoord.clear();
+			faceted.pushVertex(v);
+			faceted.pushIndex(i);
+		}
+
+		//generate normals for temporary face
+		for (U32 i = 0; i < faceted.mNumIndices; i += 3)
+		{ //for each triangle
+			U16 i0 = faceted.mIndices[i+0];
+			U16 i1 = faceted.mIndices[i+1];
+			U16 i2 = faceted.mIndices[i+2];
+			
+			LLVector4a& p0 = faceted.mPositions[i0];
+			LLVector4a& p1 = faceted.mPositions[i1];
+			LLVector4a& p2 = faceted.mPositions[i2];
+
+			LLVector4a& n0 = faceted.mNormals[i0];
+			LLVector4a& n1 = faceted.mNormals[i1];
+			LLVector4a& n2 = faceted.mNormals[i2];
+
+			LLVector4a lhs, rhs;
+			lhs.setSub(p1, p0);
+			rhs.setSub(p2, p0);
+
+			n0.setCross3(lhs, rhs);
+			n0.normalize3fast();
+			n1 = n0;
+			n2 = n0;
+		}
+
+		//weld vertices in temporary face, respecting angle_cutoff (step 2)
+		faceted.optimize(angle_cutoff);
+
+		//generate normals for welded face based on new topology (step 3)
+
+		for (U32 i = 0; i < faceted.mNumVertices; i++)
+		{
+			faceted.mNormals[i].clear();
+		}
+
+		for (U32 i = 0; i < faceted.mNumIndices; i += 3)
+		{ //for each triangle
+			U16 i0 = faceted.mIndices[i+0];
+			U16 i1 = faceted.mIndices[i+1];
+			U16 i2 = faceted.mIndices[i+2];
+			
+			LLVector4a& p0 = faceted.mPositions[i0];
+			LLVector4a& p1 = faceted.mPositions[i1];
+			LLVector4a& p2 = faceted.mPositions[i2];
+
+			LLVector4a& n0 = faceted.mNormals[i0];
+			LLVector4a& n1 = faceted.mNormals[i1];
+			LLVector4a& n2 = faceted.mNormals[i2];
+
+			LLVector4a lhs, rhs;
+			lhs.setSub(p1, p0);
+			rhs.setSub(p2, p0);
+
+			LLVector4a n;
+			n.setCross3(lhs, rhs);
+
+			n0.add(n);
+			n1.add(n);
+			n2.add(n);
+		}
+
+		//normalize normals and build point map
+		LLVolumeFace::VertexMapData::PointMap point_map;
+
+		for (U32 i = 0; i < faceted.mNumVertices; ++i)
+		{
+			faceted.mNormals[i].normalize3fast();
+
+			LLVolumeFace::VertexMapData v;
+			v.setPosition(faceted.mPositions[i]);
+			v.setNormal(faceted.mNormals[i]);
+
+			point_map[LLVector3(v.getPosition().getF32ptr())].push_back(v);
+		}
+
+		//create faceted copy of current face with texture coordinates (step 4)
+		LLVolumeFace new_face;
+
+		//bake out triangles into new face
+		for (U32 i = 0; i < vol_face.mNumIndices; ++i)
+		{
+			U32 idx = vol_face.mIndices[i];
+			LLVolumeFace::VertexData v;
+			v.setPosition(vol_face.mPositions[idx]);
+			v.setNormal(vol_face.mNormals[idx]);
+			v.mTexCoord = vol_face.mTexCoords[idx];
+
+			new_face.pushVertex(v);
+			new_face.pushIndex(i);
+		}
+
+		//generate normals for new face
+		for (U32 i = 0; i < new_face.mNumIndices; i += 3)
+		{ //for each triangle
+			U16 i0 = new_face.mIndices[i+0];
+			U16 i1 = new_face.mIndices[i+1];
+			U16 i2 = new_face.mIndices[i+2];
+			
+			LLVector4a& p0 = new_face.mPositions[i0];
+			LLVector4a& p1 = new_face.mPositions[i1];
+			LLVector4a& p2 = new_face.mPositions[i2];
+
+			LLVector4a& n0 = new_face.mNormals[i0];
+			LLVector4a& n1 = new_face.mNormals[i1];
+			LLVector4a& n2 = new_face.mNormals[i2];
+
+			LLVector4a lhs, rhs;
+			lhs.setSub(p1, p0);
+			rhs.setSub(p2, p0);
+
+			n0.setCross3(lhs, rhs);
+			n0.normalize3fast();
+			n1 = n0;
+			n2 = n0;
+		}
+
+		//swap out normals in new_face with best match from point map (step 5)
+		for (U32 i = 0; i < new_face.mNumVertices; ++i)
+		{
+			//LLVolumeFace::VertexData v = new_face.mVertices[i];
+
+			LLVector4a ref_norm = new_face.mNormals[i];
+
+			LLVolumeFace::VertexMapData::PointMap::iterator iter = point_map.find(LLVector3(new_face.mPositions[i].getF32ptr()));
+
+			if (iter != point_map.end())
+			{
+				F32 best = -2.f;
+				for (U32 k = 0; k < iter->second.size(); ++k)
+				{
+					LLVector4a& n = iter->second[k].getNormal();
+
+					if (!iter->second[k].getPosition().equals3(new_face.mPositions[i]))
+					{
+						llerrs << "WTF?" << llendl;
+					}
+
+					F32 cur = n.dot3(ref_norm).getF32();
+
+					if (cur > best)
+					{
+						best = cur;
+						new_face.mNormals[i] = n;
+					}
+				}
+			}
+		}
+		
+		//remove redundant vertices from new face (step 6)
+		new_face.optimize();
+
+		mVolumeFaces[j] = new_face;
+	}
+}
+
+//static
+std::string LLModel::getElementLabel(daeElement *element)
+{ // try to get a decent label for this element
+	// if we have a name attribute, use it
+	std::string name = element->getAttribute("name");
+	if (name.length())
+	{
+		return name;
+	}
+
+	// if we have an ID attribute, use it
+	if (element->getID())
+	{
+		return std::string(element->getID());
+	}
+
+	// if we have a parent, use it
+	daeElement* parent = element->getParent();
+	if (parent)
+	{
+		// if parent has a name, use it
+		std::string name = parent->getAttribute("name");
+		if (name.length())
+		{
+			return name;
+		}
+
+		// if parent has an ID, use it
+		if (parent->getID())
+		{
+			return std::string(parent->getID());
+		}
+	}
+
+	// try to use our type
+	daeString element_name = element->getElementName();
+	if (element_name)
+	{
+		return std::string(element_name);
+	}
+
+	// if all else fails, use "object"
+	return std::string("object");
+}
+
+//static 
+LLModel* LLModel::loadModelFromDae(std::string filename)
+{
+	LLVolumeParams volume_params;
+	volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+	LLModel* ret = new LLModel(volume_params, 0.f); 
+	ret->createVolumeFacesFromFile(filename);
+	return ret;
+}
+
+//static 
+LLModel* LLModel::loadModelFromDomMesh(domMesh *mesh)
+{
+	LLVolumeParams volume_params;
+	volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+	LLModel* ret = new LLModel(volume_params, 0.f); 
+	ret->createVolumeFacesFromDomMesh(mesh);
+	ret->mLabel = getElementLabel(mesh);
+	return ret;
+}
+
+//static 
+LLSD LLModel::writeModel(std::string filename, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* impostor, LLModel::physics_shape& decomp, BOOL nowrite)
+{
+	std::ofstream os(filename.c_str(), std::ofstream::out | std::ofstream::binary);
+
+	LLSD header = writeModel(os, physics, high, medium, low, impostor, decomp, nowrite);
+
+	os.close();
+
+	return header;
+}
+
+//static
+LLSD LLModel::writeModel(std::ostream& ostr, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* impostor, LLModel::physics_shape& decomp, BOOL nowrite)
+{
+	LLSD mdl;
+
+	LLModel* model[] = 
+	{
+		impostor,
+		low,
+		medium,
+		high,
+		physics
+	};
+
+	bool skinning = high && !high->mSkinWeights.empty();
+
+	if (skinning)
+	{ //write skinning block
+		if (high->mJointList.size() != high->mInvBindMatrix.size())
+		{
+			llerrs << "WTF?" << llendl;
+		}
+
+		for (U32 i = 0; i < high->mJointList.size(); ++i)
+		{
+			mdl["skin"]["joint_names"][i] = high->mJointList[i];
+
+			for (U32 j = 0; j < 4; j++)
+			{
+				for (U32 k = 0; k < 4; k++)
+				{
+					mdl["skin"]["inverse_bind_matrix"][i][j*4+k] = high->mInvBindMatrix[i].mMatrix[j][k]; 
+				}
+			}
+		}
+
+		for (U32 i = 0; i < 4; i++)
+		{
+			for (U32 j = 0; j < 4; j++)
+			{
+				mdl["skin"]["bind_shape_matrix"][i*4+j] = high->mBindShapeMatrix.mMatrix[i][j];
+			}
+		}
+	}
+
+	if (!decomp.empty())
+	{
+		//write decomposition block
+		// ["decomposition"]["HullList"] -- list of 8 bit integers, each entry represents a hull with specified number of points
+		// ["decomposition"]["PositionDomain"]["Min"/"Max"]
+		// ["decomposition"]["Position"] -- list of 16-bit integers to be decoded to given domain, encoded 3D points
+	
+		//get minimum and maximum
+		LLVector3 min = decomp[0][0];
+		LLVector3 max = min;
+
+		LLSD::Binary hulls(decomp.size());
+
+		U32 total = 0;
+
+		for (U32 i = 0; i < decomp.size(); ++i)
+		{
+			U32 size = decomp[i].size();
+			total += size;
+			hulls[i] = (U8) size;
+
+			for (U32 j = 0; j < decomp[i].size(); ++j)
+			{
+				update_min_max(min, max, decomp[i][j]);
+			}
+		}
+
+		mdl["decomposition"]["Min"] = min.getValue();
+		mdl["decomposition"]["Max"] = max.getValue();
+		mdl["decomposition"]["HullList"] = hulls;
+		
+		LLSD::Binary p(total*3*2);
+
+		LLVector3 range = max-min;
+
+		U32 vert_idx = 0;
+		for (U32 i = 0; i < decomp.size(); ++i)
+		{
+			for (U32 j = 0; j < decomp[i].size(); ++j)
+			{
+				for (U32 k = 0; k < 3; k++)
+				{
+					//convert to 16-bit normalized across domain
+					U16 val = (U16) (((decomp[i][j].mV[k]-min.mV[k])/range.mV[k])*65535);
+
+					U8* buff = (U8*) &val;
+					//write to binary buffer
+					p[vert_idx++] = buff[0];
+					p[vert_idx++] = buff[1];
+
+					if (vert_idx > p.size())
+					{
+						llerrs << "WTF?" << llendl;
+					}
+				}
+			}
+		}
+
+		mdl["decomposition"]["Position"] = p;
+	}
+
+	for (U32 idx = 0; idx < MODEL_NAMES_LENGTH; ++idx)
+	{
+		if (model[idx] && model[idx]->getNumVolumeFaces() > 0)
+		{
+			LLVector3 min_pos = LLVector3(model[idx]->getVolumeFace(0).mPositions[0].getF32ptr());
+			LLVector3 max_pos = min_pos;
+
+			//find position domain
+			for (S32 i = 0; i < model[idx]->getNumVolumeFaces(); ++i)
+			{ //for each face
+				const LLVolumeFace& face = model[idx]->getVolumeFace(i);
+				for (U32 j = 0; j < face.mNumVertices; ++j)
+				{
+					update_min_max(min_pos, max_pos, face.mPositions[j].getF32ptr());
+				}
+			}
+
+			LLVector3 pos_range = max_pos - min_pos;
+
+			for (S32 i = 0; i < model[idx]->getNumVolumeFaces(); ++i)
+			{ //for each face
+				const LLVolumeFace& face = model[idx]->getVolumeFace(i);
+				if (!face.mNumVertices)
+				{ //don't export an empty face
+					continue;
+				}
+				LLSD::Binary verts(face.mNumVertices*3*2);
+				LLSD::Binary tc(face.mNumVertices*2*2);
+				LLSD::Binary normals(face.mNumVertices*3*2);
+				LLSD::Binary indices(face.mNumIndices*2);
+
+				U32 vert_idx = 0;
+				U32 norm_idx = 0;
+				U32 tc_idx = 0;
+			
+				LLVector2* ftc = (LLVector2*) face.mTexCoords;
+				LLVector2 min_tc = ftc[0];
+				LLVector2 max_tc = min_tc;
+	
+				//get texture coordinate domain
+				for (U32 j = 0; j < face.mNumVertices; ++j)
+				{
+					update_min_max(min_tc, max_tc, ftc[j]);
+				}
+
+				LLVector2 tc_range = max_tc - min_tc;
+
+				for (U32 j = 0; j < face.mNumVertices; ++j)
+				{ //for each vert
+		
+					F32* pos = face.mPositions[j].getF32ptr();
+					F32* norm = face.mNormals[j].getF32ptr();
+
+					//position + normal
+					for (U32 k = 0; k < 3; ++k)
+					{ //for each component
+
+						//convert to 16-bit normalized across domain
+						U16 val = (U16) (((pos[k]-min_pos.mV[k])/pos_range.mV[k])*65535);
+
+						U8* buff = (U8*) &val;
+						//write to binary buffer
+						verts[vert_idx++] = buff[0];
+						verts[vert_idx++] = buff[1];
+						
+						//convert to 16-bit normalized
+						val = (U16) ((norm[k]+1.f)*0.5f*65535);
+
+						//write to binary buffer
+						normals[norm_idx++] = buff[0];
+						normals[norm_idx++] = buff[1];
+					}
+
+					F32* src_tc = (F32*) face.mTexCoords[j].mV;
+
+					//texcoord
+					for (U32 k = 0; k < 2; ++k)
+					{ //for each component
+						//convert to 16-bit normalized
+						U16 val = (U16) ((src_tc[k]-min_tc.mV[k])/tc_range.mV[k]*65535);
+
+						U8* buff = (U8*) &val;
+						//write to binary buffer
+						tc[tc_idx++] = buff[0];
+						tc[tc_idx++] = buff[1];
+					}
+					
+				}
+
+				U32 idx_idx = 0;
+				for (U32 j = 0; j < face.mNumIndices; ++j)
+				{
+					U8* buff = (U8*) &(face.mIndices[j]);
+					indices[idx_idx++] = buff[0];
+					indices[idx_idx++] = buff[1];
+				}
+
+				//write out face data
+				mdl[model_names[idx]][i]["PositionDomain"]["Min"] = min_pos.getValue();
+				mdl[model_names[idx]][i]["PositionDomain"]["Max"] = max_pos.getValue();
+
+				mdl[model_names[idx]][i]["TexCoord0Domain"]["Min"] = min_tc.getValue();
+				mdl[model_names[idx]][i]["TexCoord0Domain"]["Max"] = max_tc.getValue();
+
+				mdl[model_names[idx]][i]["Position"] = verts;
+				mdl[model_names[idx]][i]["Normal"] = normals;
+				mdl[model_names[idx]][i]["TexCoord0"] = tc;
+				mdl[model_names[idx]][i]["TriangleList"] = indices;
+
+				if (skinning)
+				{
+					//write out skin weights
+
+					//each influence list entry is up to 4 24-bit values
+					// first 8 bits is bone index
+					// last 16 bits is bone influence weight
+					// a bone index of 0xFF signifies no more influences for this vertex
+
+					std::stringstream ostr;
+
+					for (U32 j = 0; j < face.mNumVertices; ++j)
+					{
+						LLVector3 pos(face.mPositions[j].getF32ptr());
+
+						weight_list& weights = high->getJointInfluences(pos);
+
+						if (weights.size() > 4)
+						{
+							llerrs << "WTF?" << llendl;
+						}
+
+						S32 count = 0;
+						for (weight_list::iterator iter = weights.begin(); iter != weights.end(); ++iter)
+						{
+							if (iter->mJointIdx < 255 && iter->mJointIdx >= 0)
+							{
+								U8 idx = (U8) iter->mJointIdx;
+								ostr.write((const char*) &idx, 1);
+
+								U16 influence = (U16) (iter->mWeight*65535);
+								ostr.write((const char*) &influence, 2);
+
+								++count;
+							}		
+						}
+						U8 end_list = 0xFF;
+						if (count < 4)
+						{
+							ostr.write((const char*) &end_list, 1);
+						}
+					}
+
+					//copy ostr to binary buffer
+					std::string data = ostr.str();
+					const U8* buff = (U8*) data.data();
+					U32 bytes = data.size();
+
+					LLSD::Binary w(bytes);
+					for (U32 j = 0; j < bytes; ++j)
+					{
+						w[j] = buff[j];
+					}
+
+					mdl[model_names[idx]][i]["Weights"] = w;
+				}
+			}
+		}
+	}
+	
+	return writeModelToStream(ostr, mdl, nowrite);
+}
+
+LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, BOOL nowrite)
+{
+	U32 bytes = 0;
+	
+	std::string::size_type cur_offset = 0;
+
+	LLSD header;
+
+	std::string skin;
+
+	if (mdl.has("skin"))
+	{ //write out skin block
+		skin = zip_llsd(mdl["skin"]);
+
+		U32 size = skin.size();
+		if (size > 0)
+		{
+			header["skin"]["offset"] = (LLSD::Integer) cur_offset;
+			header["skin"]["size"] = (LLSD::Integer) size;
+			cur_offset += size;
+			bytes += size;
+		}
+		else
+		{
+			llerrs << "WTF?" << llendl;
+		}
+	}
+
+	std::string decomposition;
+
+	if (mdl.has("decomposition"))
+	{ //write out convex decomposition
+		decomposition = zip_llsd(mdl["decomposition"]);
+
+		U32 size = decomposition.size();
+		if (size > 0)
+		{
+			header["decomposition"]["offset"] = (LLSD::Integer) cur_offset;
+			header["decomposition"]["size"] = (LLSD::Integer) size;
+			cur_offset += size;
+			bytes += size;
+		}
+	}
+
+	std::string out[MODEL_NAMES_LENGTH];
+
+	for (S32 i = 0; i < MODEL_NAMES_LENGTH; i++)
+	{
+		if (mdl.has(model_names[i]))
+		{
+			out[i] = zip_llsd(mdl[model_names[i]]);
+
+			U32 size = out[i].size();
+
+			header[model_names[i]]["offset"] = (LLSD::Integer) cur_offset;
+			header[model_names[i]]["size"] = (LLSD::Integer) size;
+			cur_offset += size;
+			bytes += size;
+		}
+		else
+		{
+			header[model_names[i]]["offset"] = -1;
+			header[model_names[i]]["size"] = 0;
+		}
+	}
+
+	if (!nowrite)
+	{
+		LLSDSerialize::serialize(header, ostr, LLSDSerialize::LLSD_BINARY);
+
+		if (!skin.empty())
+		{ //write skin block
+			ostr.write((const char*) skin.data(), header["skin"]["size"].asInteger());
+		}
+
+		if (!decomposition.empty())
+		{ //write decomposition block
+			ostr.write((const char*) decomposition.data(), header["decomposition"]["size"].asInteger());
+		}
+
+		for (S32 i = 0; i < MODEL_NAMES_LENGTH; i++)
+		{
+			if (!out[i].empty())
+			{
+				ostr.write((const char*) out[i].data(), header[model_names[i]]["size"].asInteger());
+			}
+		}
+	}
+	
+	return header;
+}
+
+//static 
+LLModel* LLModel::loadModelFromAsset(std::string filename, S32 lod)
+{
+	return NULL;
+}
+
+LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos)
+{
+	weight_map::iterator iter = mSkinWeights.find(pos);
+	
+	if (iter != mSkinWeights.end())
+	{
+		if ((iter->first - pos).magVec() > 0.1f)
+		{
+			llerrs << "WTF?" << llendl;
+		}
+
+		return iter->second;
+	}
+	else
+	{  //no exact match found, get closest point
+		iter = mSkinWeights.begin();
+		weight_map::iterator best = iter;
+
+		F32 min_dist = (iter->first - pos).magVecSquared();
+
+		while (++iter != mSkinWeights.end())
+		{
+			F32 dist = (iter->first - pos).magVecSquared();
+			if (dist < min_dist)
+			{
+				best = iter;
+				min_dist = dist;
+			}
+		}
+
+		return best->second;
+	}					
+}
+
+#endif
+
diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h
new file mode 100644
index 00000000000..a91c80d5b73
--- /dev/null
+++ b/indra/llprimitive/llmodel.h
@@ -0,0 +1,179 @@
+/** 
+ * @file llmodel.h
+ * @brief Model handling class definitions
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2007, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLMODEL_H
+#define LL_LLMODEL_H
+
+#include "llvolume.h"
+#include "v4math.h"
+#include "m4math.h"
+
+#if LL_MESH_ENABLED
+
+class daeElement;
+class domMesh;
+
+#define MAX_MODEL_FACES 8
+
+class LLModel : public LLVolume
+{
+public:
+
+	enum
+	{
+		LOD_IMPOSTOR = 0,
+		LOD_LOW,
+		LOD_MEDIUM,
+		LOD_HIGH,
+		LOD_PHYSICS,
+		NUM_LODS
+	};
+	
+	//physics shape is a vector of convex hulls
+	//each convex hull is a set of points
+	typedef  std::vector<std::vector<LLVector3> > physics_shape;
+	
+	LLModel(LLVolumeParams& params, F32 detail);
+	static LLSD writeModel(std::string filename, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* imposotr, LLModel::physics_shape& physics_shape, BOOL nowrite = FALSE);
+	static LLSD writeModel(std::ostream& ostr, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* imposotr, LLModel::physics_shape& physics_shape, BOOL nowrite = FALSE);
+	static LLSD writeModelToStream(std::ostream& ostr, LLSD& mdl, BOOL nowrite = FALSE);
+	static LLModel* loadModelFromAsset(std::string filename, S32 lod);
+	static LLModel* loadModelFromDae(std::string filename);
+	static LLModel* loadModelFromDomMesh(domMesh* mesh);
+	static std::string getElementLabel(daeElement* element);
+
+	void appendFaces(LLModel* model, LLMatrix4& transform, LLMatrix4& normal_transform);
+	void appendFace(const LLVolumeFace& src_face, std::string src_material, LLMatrix4& mat, LLMatrix4& norm_mat);
+
+	void setNumVolumeFaces(S32 count);
+	void setVolumeFaceData(S32 f, 
+						LLStrider<LLVector3> pos, 
+						LLStrider<LLVector3> norm, 
+						LLStrider<LLVector2> tc, 
+						LLStrider<U16> ind, 
+						U32 num_verts, 
+						U32 num_indices);
+
+	void smoothNormals(F32 angle_cutoff);
+
+	void addFace(const LLVolumeFace& face);
+
+	void normalizeVolumeFaces();
+	void optimizeVolumeFaces();
+
+
+	U32 getResourceCost();
+	void getNormalizedScaleTranslation(LLVector3& scale_out, LLVector3& translation_out);
+	std::vector<std::string> mMaterialList;
+
+	//data used for skin weights
+	class JointWeight
+	{
+	public:
+		S32 mJointIdx;
+		F32 mWeight;
+		
+		JointWeight()
+		{
+			mJointIdx = 0;
+			mWeight = 0.f;
+		}
+
+		JointWeight(S32 idx, F32 weight)
+			: mJointIdx(idx), mWeight(weight)
+		{
+		}
+
+		bool operator<(const JointWeight& rhs) const
+		{
+			if (mWeight == rhs.mWeight)
+			{
+				return mJointIdx < rhs.mJointIdx;
+			}
+
+			return mWeight < rhs.mWeight;
+		}
+
+	};
+
+	struct CompareWeightGreater
+	{
+		bool operator()(const JointWeight& lhs, const JointWeight& rhs)
+		{
+			return rhs < lhs; // strongest = first
+		}
+	};
+
+	//copy of position array for this model -- mPosition[idx].mV[X,Y,Z]
+	std::vector<LLVector3> mPosition;
+
+	//map of positions to skin weights --- mSkinWeights[pos].mV[0..4] == <joint_index>.<weight>
+	//joint_index corresponds to mJointList
+	typedef std::vector<JointWeight> weight_list;
+	typedef std::map<LLVector3, weight_list > weight_map;
+	weight_map mSkinWeights;
+
+	//get list of weight influences closest to given position
+	weight_list& getJointInfluences(const LLVector3& pos);
+
+	//should always be true that mJointList[mJointMap["foo"]] == "foo"
+
+	//map of joint names to joint index
+	std::map<std::string, U32> mJointMap;
+
+	//list of joint names
+	std::vector<std::string> mJointList;
+
+	LLMatrix4 mBindShapeMatrix;
+	std::vector<LLMatrix4> mInvBindMatrix;
+
+	std::string mLabel;
+
+	LLVector3 mNormalizedScale;
+	LLVector3 mNormalizedTranslation;
+
+	//physics shape
+	physics_shape mPhysicsShape;
+
+	LLVector3 mPhysicsCenter;
+	std::vector<LLVector3> mHullCenter;
+	U32 mPhysicsPoints;
+
+protected:
+	void addVolumeFacesFromDomMesh(domMesh* mesh);
+	virtual BOOL createVolumeFacesFromFile(const std::string& file_name);
+	virtual BOOL createVolumeFacesFromDomMesh(domMesh *mesh);
+};
+
+
+#endif
+
+#endif //LL_LLMODEL_H
diff --git a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl
new file mode 100644
index 00000000000..eef6556fba4
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl
@@ -0,0 +1,30 @@
+/** 
+ * @file objectSkinV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#version 120
+
+attribute vec4 object_weight;  
+
+uniform mat4 matrixPalette[64];
+
+mat4 getObjectSkinnedTransform()
+{
+	int i; 
+	
+	vec4 w = fract(object_weight);
+	vec4 index = floor(object_weight);
+	
+	float scale = 1.0/(w.x+w.y+w.z+w.w);
+	w *= scale;
+	
+	mat4 mat = matrixPalette[int(index.x)]*w.x;
+	mat += matrixPalette[int(index.y)]*w.y;
+	mat += matrixPalette[int(index.z)]*w.z;
+	mat += matrixPalette[int(index.w)]*w.w;
+		
+	return mat;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
new file mode 100644
index 00000000000..fde0e977138
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
@@ -0,0 +1,75 @@
+/** 
+ * @file alphaSkinnedV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+mat4 getObjectSkinnedTransform();
+void calcAtmospherics(vec3 inPositionEye);
+
+float calcDirectionalLight(vec3 n, vec3 l);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
+
+vec3 atmosAmbient(vec3 light);
+vec3 atmosAffectDirectionalLight(float lightIntensity);
+vec3 scaleDownLight(vec3 light);
+vec3 scaleUpLight(vec3 light);
+
+varying vec3 vary_position;
+varying vec3 vary_ambient;
+varying vec3 vary_directional;
+varying vec3 vary_normal;
+varying vec3 vary_light;
+
+void main()
+{
+	gl_TexCoord[0] = gl_MultiTexCoord0;
+				
+	vec4 pos;
+	vec3 norm;
+	
+	mat4 trans = getObjectSkinnedTransform();
+	trans = gl_ModelViewMatrix * trans;
+	
+	pos = trans * gl_Vertex;
+	
+	norm = gl_Vertex.xyz + gl_Normal.xyz;
+	norm = normalize(( trans*vec4(norm, 1.0) ).xyz-pos.xyz);
+	
+	gl_Position = gl_ProjectionMatrix * pos;
+	
+	vary_position = pos.xyz;
+	vary_normal = norm;	
+	
+	calcAtmospherics(pos.xyz);
+
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
+
+	// Collect normal lights (need to be divided by two, as we later multiply by 2)
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
+	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
+	col.rgb = scaleDownLight(col.rgb);
+	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
+	vary_light = gl_LightSource[0].position.xyz;
+	
+	vary_ambient = col.rgb*gl_Color.rgb;
+	vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
+	
+	col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
+	
+	gl_FrontColor = col;
+
+	gl_FogFragCoord = pos.z;
+}
+
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
new file mode 100644
index 00000000000..085ffddeece
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
@@ -0,0 +1,16 @@
+/** 
+ * @file avatarShadowF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+
+
+void main() 
+{
+	//gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a);
+	gl_FragColor = vec4(1,1,1,1);
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
new file mode 100644
index 00000000000..1626e21cd88
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
@@ -0,0 +1,25 @@
+/** 
+ * @file diffuseSkinnedV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#version 120
+
+mat4 getObjectSkinnedTransform();
+
+void main()
+{
+	//transform vertex
+	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+	
+	mat4 mat = getObjectSkinnedTransform();
+	
+	mat = gl_ModelViewMatrix * mat;
+	vec3 pos = (mat*gl_Vertex).xyz;
+	
+	gl_FrontColor = gl_Color;
+	
+	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
new file mode 100644
index 00000000000..d884f2e4a5d
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
@@ -0,0 +1,37 @@
+/** 
+ * @file bumpV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#version 120
+
+varying vec3 vary_mat0;
+varying vec3 vary_mat1;
+varying vec3 vary_mat2;
+
+mat4 getObjectSkinnedTransform();
+
+void main()
+{
+	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+	
+	mat4 mat = getObjectSkinnedTransform();
+	
+	mat = gl_ModelViewMatrix * mat;
+	
+	vec3 pos = (mat*gl_Vertex).xyz;
+	
+	
+	vec3 n = normalize((mat * vec4(gl_Normal.xyz+gl_Vertex.xyz, 1.0)).xyz-pos.xyz);
+	vec3 b = normalize((mat * vec4(gl_MultiTexCoord2.xyz+gl_Vertex.xyz, 1.0)).xyz-pos.xyz);
+	vec3 t = cross(b, n);
+	
+	vary_mat0 = vec3(t.x, b.x, n.x);
+	vary_mat1 = vec3(t.y, b.y, n.y);
+	vary_mat2 = vec3(t.z, b.z, n.z);
+	
+	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
new file mode 100644
index 00000000000..9a45c03237a
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
@@ -0,0 +1,33 @@
+/** 
+ * @file diffuseSkinnedV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#version 120
+
+varying vec3 vary_normal;
+
+mat4 getObjectSkinnedTransform();
+
+void main()
+{
+	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+	
+	mat4 mat = getObjectSkinnedTransform();
+	
+	mat = gl_ModelViewMatrix * mat;
+	vec3 pos = (mat*gl_Vertex).xyz;
+	
+	vec4 norm = gl_Vertex;
+	norm.xyz += gl_Normal.xyz;
+	norm.xyz = (mat*norm).xyz;
+	norm.xyz = normalize(norm.xyz-pos.xyz);
+
+	vary_normal = norm.xyz;
+			
+	gl_FrontColor = gl_Color;
+	
+	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+}
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
new file mode 100644
index 00000000000..4cde013eefc
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
@@ -0,0 +1,15 @@
+/** 
+ * @file lightFullbrightShinyWaterF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+
+uniform sampler2D diffuseMap;
+uniform samplerCube environmentMap;
+
+void fullbright_shiny_lighting_water() 
+{
+	gl_FragColor = texture2D(diffuseMap, gl_TexCoord[0].xy);
+}
diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl
new file mode 100644
index 00000000000..f0baeeeee58
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl
@@ -0,0 +1,39 @@
+/** 
+ * @file shinySimpleSkinnedV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#version 120
+
+void calcAtmospherics(vec3 inPositionEye);
+mat4 getObjectSkinnedTransform();
+
+attribute vec4 object_weight;
+
+void main()
+{
+	mat4 mat = getObjectSkinnedTransform();
+	
+	mat = gl_ModelViewMatrix * mat;
+	vec3 pos = (mat*gl_Vertex).xyz;
+	
+	vec4 norm = gl_Vertex;
+	norm.xyz += gl_Normal.xyz;
+	norm.xyz = (mat*norm).xyz;
+	norm.xyz = normalize(norm.xyz-pos.xyz);
+		
+	vec3 ref = reflect(pos.xyz, -norm.xyz);
+
+	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+	gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
+
+	calcAtmospherics(pos.xyz);
+
+	gl_FrontColor = gl_Color;
+	
+	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	
+	gl_FogFragCoord = pos.z;
+}
diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyWaterF.glsl
new file mode 100644
index 00000000000..5e6e4c16b76
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyWaterF.glsl
@@ -0,0 +1,13 @@
+/** 
+ * @file fullbrightShinyWaterF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+void fullbright_shiny_lighting_water();
+
+void main() 
+{
+	fullbright_shiny_lighting_water();
+}
diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl
new file mode 100644
index 00000000000..02ff3cc2a96
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl
@@ -0,0 +1,37 @@
+/** 
+ * @file fullbrightSkinnedV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#version 120
+
+void calcAtmospherics(vec3 inPositionEye);
+mat4 getObjectSkinnedTransform();
+
+attribute vec4 object_weight;
+
+void main()
+{
+	//transform vertex
+	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+	
+	mat4 mat = getObjectSkinnedTransform();
+	
+	mat = gl_ModelViewMatrix * mat;
+	vec3 pos = (mat*gl_Vertex).xyz;
+	
+	vec4 norm = gl_Vertex;
+	norm.xyz += gl_Normal.xyz;
+	norm.xyz = (mat*norm).xyz;
+	norm.xyz = normalize(norm.xyz-pos.xyz);
+		
+	calcAtmospherics(pos.xyz);
+
+	gl_FrontColor = gl_Color;
+	
+	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+		
+	gl_FogFragCoord = pos.z;
+}
diff --git a/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl
new file mode 100644
index 00000000000..4146646058d
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl
@@ -0,0 +1,39 @@
+/** 
+ * @file shinySimpleSkinnedV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#version 120
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+void calcAtmospherics(vec3 inPositionEye);
+mat4 getObjectSkinnedTransform();
+
+attribute vec4 object_weight;
+
+void main()
+{
+	mat4 mat = getObjectSkinnedTransform();
+	
+	mat = gl_ModelViewMatrix * mat;
+	vec3 pos = (mat*gl_Vertex).xyz;
+	
+	vec4 norm = gl_Vertex;
+	norm.xyz += gl_Normal.xyz;
+	norm.xyz = (mat*norm).xyz;
+	norm.xyz = normalize(norm.xyz-pos.xyz);
+		
+	vec3 ref = reflect(pos.xyz, -norm.xyz);
+
+	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+	gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
+
+	calcAtmospherics(pos.xyz);
+
+	vec4 color = calcLighting(pos.xyz, norm.xyz, gl_Color, vec4(0.));
+	gl_FrontColor = color;
+	
+	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+}
diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl
new file mode 100644
index 00000000000..59944b8861b
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl
@@ -0,0 +1,39 @@
+/** 
+ * @file simpleV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#version 120
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+void calcAtmospherics(vec3 inPositionEye);
+mat4 getObjectSkinnedTransform();
+
+attribute vec4 object_weight;
+
+void main()
+{
+	//transform vertex
+	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+	
+	mat4 mat = getObjectSkinnedTransform();
+	
+	mat = gl_ModelViewMatrix * mat;
+	vec3 pos = (mat*gl_Vertex).xyz;
+	
+	vec4 norm = gl_Vertex;
+	norm.xyz += gl_Normal.xyz;
+	norm.xyz = (mat*norm).xyz;
+	norm.xyz = normalize(norm.xyz-pos.xyz);
+		
+	calcAtmospherics(pos.xyz);
+
+	vec4 color = calcLighting(pos.xyz, norm.xyz, gl_Color, vec4(0.));
+	gl_FrontColor = color;
+	
+	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	
+	gl_FogFragCoord = pos.z;
+}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
new file mode 100644
index 00000000000..dc4663677b5
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
@@ -0,0 +1,84 @@
+/** 
+ * @file alphaSkinnedV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+void calcAtmospherics(vec3 inPositionEye);
+
+float calcDirectionalLight(vec3 n, vec3 l);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
+mat4 getObjectSkinnedTransform();
+vec3 atmosAmbient(vec3 light);
+vec3 atmosAffectDirectionalLight(float lightIntensity);
+vec3 scaleDownLight(vec3 light);
+vec3 scaleUpLight(vec3 light);
+
+varying vec3 vary_ambient;
+varying vec3 vary_directional;
+varying vec3 vary_fragcoord;
+varying vec3 vary_position;
+varying vec3 vary_light;
+
+uniform float near_clip;
+uniform float shadow_offset;
+uniform float shadow_bias;
+
+void main()
+{
+	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+	
+	mat4 mat = getObjectSkinnedTransform();
+	
+	mat = gl_ModelViewMatrix * mat;
+	
+	vec3 pos = (mat*gl_Vertex).xyz;
+	
+	gl_Position = gl_ProjectionMatrix * vec4(pos, 1.0);
+	
+	vec4 n = gl_Vertex;
+	n.xyz += gl_Normal.xyz;
+	n.xyz = (mat*n).xyz;
+	n.xyz = normalize(n.xyz-pos.xyz);
+	
+	vec3 norm = n.xyz;
+	
+	float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz));
+	vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset;
+			
+	calcAtmospherics(pos.xyz);
+
+	//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
+	vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
+
+	// Collect normal lights (need to be divided by two, as we later multiply by 2)
+	col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].specular.a);
+	col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].spotDirection.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].specular.a);
+	col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].spotDirection.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].specular.a);
+	col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].spotDirection.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].specular.a);
+	col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].specular.a);
+	col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].specular.a);
+	col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
+	col.rgb = scaleDownLight(col.rgb);
+	
+	// Add windlight lights
+	col.rgb += atmosAmbient(vec3(0.));
+	
+	vary_light = gl_LightSource[0].position.xyz;
+	
+	vary_ambient = col.rgb*gl_Color.rgb;
+	vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
+	
+	col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
+	
+	gl_FrontColor = col;
+
+	gl_FogFragCoord = pos.z;
+	
+	pos.xyz = (gl_ModelViewProjectionMatrix * gl_Vertex).xyz;
+	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
+	
+}
+
diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterF.glsl
new file mode 100644
index 00000000000..eca9a567f66
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyWaterF.glsl
@@ -0,0 +1,29 @@
+/** 
+ * @file lightFullbrightShinyWaterF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+uniform samplerCube environmentMap;
+
+vec3 fullbrightShinyAtmosTransport(vec3 light);
+vec3 fullbrightScaleSoftClip(vec3 light);
+vec4 applyWaterFog(vec4 color);
+
+void fullbright_shiny_lighting_water()
+{
+	vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy);
+	color.rgb *= gl_Color.rgb;
+	
+	vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb;	
+	color.rgb = mix(color.rgb, envColor.rgb, gl_Color.a);
+
+	color.rgb = fullbrightShinyAtmosTransport(color.rgb);
+	color.rgb = fullbrightScaleSoftClip(color.rgb);
+	color.a = max(color.a, gl_Color.a);
+
+	gl_FragColor = applyWaterFog(color);
+}
+
diff --git a/indra/newview/llfloaterimportcollada.cpp b/indra/newview/llfloaterimportcollada.cpp
new file mode 100644
index 00000000000..476c02cd465
--- /dev/null
+++ b/indra/newview/llfloaterimportcollada.cpp
@@ -0,0 +1,1116 @@
+/** 
+ * @file llfloaterimportcollada.cpp
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llfloaterimportcollada.h"
+
+#include "dae.h"
+//#include "dom.h"
+#include "dom/domAsset.h"
+#include "dom/domBind_material.h"
+#include "dom/domConstants.h"
+#include "dom/domEffect.h"
+#include "dom/domGeometry.h"
+#include "dom/domInstance_geometry.h"
+#include "dom/domInstance_material.h"
+#include "dom/domInstance_node.h"
+#include "dom/domInstance_effect.h"
+#include "dom/domMaterial.h"
+#include "dom/domMatrix.h"
+#include "dom/domNode.h"
+#include "dom/domProfile_COMMON.h"
+#include "dom/domRotate.h"
+#include "dom/domScale.h"
+#include "dom/domTranslate.h"
+#include "dom/domVisual_scene.h"
+
+#include "llagent.h"
+#include "llassetuploadresponders.h"
+#include "lleconomy.h"
+#include "llfloaterperms.h"
+#include "llfloaterreg.h"
+#include "llsdutil.h"
+#include "llsdutil_math.h"
+#include "llselectmgr.h"
+#include "llvfile.h"
+#include "llvfs.h"
+#include "llviewermenufile.h"
+#include "llviewerregion.h"
+#include "llvolumemessage.h"
+#include "llmodel.h"
+#include "llmeshreduction.h"
+#include "material_codes.h"
+
+//
+// floater
+//
+
+#if LL_MESH_ENABLED
+
+LLFloaterImportCollada::LLFloaterImportCollada(const LLSD& key)
+	: LLFloater(key)
+{
+}
+
+
+BOOL LLFloaterImportCollada::postBuild()
+{
+	if (!LLFloater::postBuild())
+	{
+		return FALSE;
+	}
+
+	childSetCommitCallback("ok", LLImportCollada::onCommitOK, this);
+	childSetCommitCallback("cancel", LLImportCollada::onCommitCancel, this);
+	
+	setStatusIdle();
+	setAssetCount(0,0);
+	enableOK(TRUE);
+
+	return TRUE;
+}
+
+
+void LLFloaterImportCollada::setAssetCount(S32 mesh_count, S32 texture_count)
+{
+	childSetTextArg("mesh count", "[COUNT]", llformat("%d", mesh_count));
+	childSetTextArg("texture count", "[COUNT]", llformat("%d", texture_count));
+}
+
+void LLFloaterImportCollada::setStatusAssetUploading(std::string asset_name)
+{
+	LLUIString uploading = getString("status_uploading");
+	uploading.setArg("[NAME]", asset_name);
+	childSetTextArg("status", "[STATUS]", uploading.getString());
+}
+
+void LLFloaterImportCollada::setStatusCreatingPrim(std::string prim_name)
+{
+	LLUIString creating = getString("status_creating");
+	creating.setArg("[NAME]", prim_name);
+	childSetTextArg("status", "[STATUS]", creating.getString());
+}
+
+void LLFloaterImportCollada::setStatusIdle()
+{
+	childSetTextArg("status", "[STATUS]", getString("status_idle"));
+}
+
+void LLFloaterImportCollada::enableOK(BOOL enable)
+{
+	childSetEnabled("ok", enable);
+}
+
+
+//
+// misc helpers
+//
+
+
+// why oh why do forbid matrix multiplication in our llmath library?
+LLMatrix4 matrix_multiply(LLMatrix4 a, LLMatrix4 b)
+{
+	a *= b;
+
+	return a;
+}
+
+// why oh why does colladadom not provide such things?
+daeElement* getFirstChild(daeElement* parent)
+{
+	daeTArray< daeSmartRef<daeElement> > children = parent->getChildren();
+
+	if (children.getCount() > 0)
+	{
+		return children[0];
+	}
+	else
+	{
+		return NULL;
+	}
+}
+
+// why oh why does colladadom not provide such things?
+daeElement* getNextSibling(daeElement* child)
+{
+	daeElement* parent = child->getParent();
+
+	if (parent == NULL)
+	{
+		// must be root, root has no siblings
+		return NULL;
+	}
+
+	daeElement* sibling = NULL;
+
+	daeTArray< daeSmartRef<daeElement> > children = parent->getChildren();
+	for (S32 i = 0; i < children.getCount(); i++)
+	{
+		if (child == children[i])
+		{
+			if ((i+1) < children.getCount())
+			{
+				sibling = children[i+1];
+			}
+		}
+	}
+
+	return sibling;
+}
+
+// try to get a decent label for this element
+std::string getElementLabel(daeElement *element)
+{
+	// if we have a name attribute, use it
+	std::string name = element->getAttribute("name");
+	if (name.length())
+	{
+		return name;
+	}
+
+	// if we have an ID attribute, use it
+	if (element->getID())
+	{
+		return std::string(element->getID());
+	}
+
+	// if we have a parent, use it
+	daeElement* parent = element->getParent();
+	if (parent)
+	{
+		// if parent has a name, use it
+		std::string name = parent->getAttribute("name");
+		if (name.length())
+		{
+			return name;
+		}
+
+		// if parent has an ID, use it
+		if (parent->getID())
+		{
+			return std::string(parent->getID());
+		}
+	}
+
+	// try to use our type
+	daeString element_name = element->getElementName();
+	if (element_name)
+	{
+		return std::string(element_name);
+	}
+
+	// if all else fails, use "object"
+	return std::string("object");
+}
+
+LLColor4 getDaeColor(daeElement* element)
+{
+	LLColor4 value;
+	domCommon_color_or_texture_type_complexType::domColor* color =
+		daeSafeCast<domCommon_color_or_texture_type_complexType::domColor>(element->getDescendant("color"));
+	if (color)
+	{
+		domFx_color_common domfx_color = color->getValue();
+		value = LLColor4(domfx_color[0], domfx_color[1], domfx_color[2], domfx_color[3]);
+	}
+
+	return value;
+}
+
+LLTextureEntry profileToTextureEntry(domProfile_COMMON* material)
+{
+	LLTextureEntry te;
+
+	te.setID(LLUUID("5748decc-f629-461c-9a36-a35a221fe21f")); // blank texture
+	daeElement* diffuse = material->getDescendant("diffuse");
+	if (diffuse)
+	{
+		te.setColor(LLColor3(0.1f, 0.9f, 1.0f));
+					
+		domCommon_color_or_texture_type_complexType::domTexture* texture =
+			daeSafeCast<domCommon_color_or_texture_type_complexType::domTexture>(diffuse->getDescendant("texture"));
+		if (texture)
+		{
+			domCommon_newparam_type_Array newparams = material->getNewparam_array();
+			for (S32 i = 0; i < newparams.getCount(); i++)
+			{
+				domFx_surface_common* surface = newparams[i]->getSurface();
+				if (surface)
+				{
+					domFx_surface_init_common* init = surface->getFx_surface_init_common();
+					if (init)
+					{
+						domFx_surface_init_from_common_Array init_from = init->getInit_from_array();
+
+						if (init_from.getCount() > 0)
+						{
+							daeElement* image = init_from[0]->getValue().getElement();
+							if (image)
+							{
+								LLUUID texture_asset = LLImportColladaAssetCache::getInstance()->getAssetForDaeElement(image);
+
+								if (texture_asset.notNull())
+								{
+									te.setID(texture_asset);
+									te.setColor(LLColor3(1,1,1));
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		
+		domCommon_color_or_texture_type_complexType::domColor* color =
+			daeSafeCast<domCommon_color_or_texture_type_complexType::domColor>(diffuse->getDescendant("color"));
+		if (color)
+		{
+			domFx_color_common domfx_color = color->getValue();
+			LLColor4 value = LLColor4(domfx_color[0], domfx_color[1], domfx_color[2], domfx_color[3]);
+			te.setColor(value);
+		}
+	}
+
+	daeElement* emission = material->getDescendant("emission");
+	if (emission)
+	{
+		LLColor4 emission_color = getDaeColor(emission);
+		if (((emission_color[0] + emission_color[1] + emission_color[2]) / 3.0) > 0.25)
+		{
+			te.setFullbright(TRUE);
+		}
+	}
+
+	return te;
+}
+
+std::vector<LLTextureEntry> getMaterials(LLModel* model, domInstance_geometry* instance_geo)
+{
+	std::vector<LLTextureEntry> texture_entries;
+	for (int i = 0; i < model->mMaterialList.size(); i++)
+	{
+		LLTextureEntry texture_entry;
+
+		domInstance_material* instance_mat = NULL;
+
+		domBind_material::domTechnique_common* technique =
+			daeSafeCast<domBind_material::domTechnique_common>(instance_geo->getDescendant(daeElement::matchType(domBind_material::domTechnique_common::ID())));
+
+		if (technique)
+		{
+			daeTArray< daeSmartRef<domInstance_material> > inst_materials = technique->getChildrenByType<domInstance_material>();
+			for (int j = 0; j < inst_materials.getCount(); j++)
+			{
+				std::string symbol(inst_materials[j]->getSymbol());
+
+				if (symbol == model->mMaterialList[i]) // found the binding
+				{
+					instance_mat = inst_materials[j];
+				}
+			}
+		}
+
+		if (instance_mat)
+		{
+			domMaterial* material = daeSafeCast<domMaterial>(instance_mat->getTarget().getElement());
+			if (material)
+			{
+				domInstance_effect* instance_effect =
+					daeSafeCast<domInstance_effect>(material->getDescendant(daeElement::matchType(domInstance_effect::ID())));
+				if (instance_effect)
+				{
+					domEffect* effect = daeSafeCast<domEffect>(instance_effect->getUrl().getElement());
+					if (effect)
+					{
+						domProfile_COMMON* profile =
+							daeSafeCast<domProfile_COMMON>(effect->getDescendant(daeElement::matchType(domProfile_COMMON::ID())));
+						if (profile)
+						{
+							texture_entry = profileToTextureEntry(profile);
+						}
+					}
+				}
+			}
+		}
+		
+		texture_entries.push_back(texture_entry);
+	}
+
+	return texture_entries;
+}
+
+LLTextureEntry instanceGeoToTextureEntry(domInstance_geometry* instance_geo)
+{
+	LLTextureEntry te;
+	domInstance_material* instance_mat = 
+		daeSafeCast<domInstance_material>(instance_geo->getDescendant(daeElement::matchType(domInstance_material::ID())));
+	if (instance_mat)
+	{
+	}
+
+	return te;
+}
+
+
+
+// responder for asset uploads
+// does all the normal stuff followed by a notification to continue importing
+// WARNING - currently unused - TODO
+class LLColladaNewAgentInventoryResponder : public LLNewAgentInventoryResponder
+{
+	LLColladaNewAgentInventoryResponder(const LLSD& post_data,
+										const LLUUID& vfile_id,
+										LLAssetType::EType asset_type)
+	    : LLNewAgentInventoryResponder(post_data, vfile_id, asset_type)
+	{
+	}
+	LLColladaNewAgentInventoryResponder(const LLSD& post_data,
+										const std::string& file_name,
+										LLAssetType::EType asset_type)
+	    : LLNewAgentInventoryResponder(post_data, file_name, asset_type)
+	{
+	}
+
+	virtual void uploadComplete(const LLSD& content)
+	{
+		LLNewAgentInventoryResponder::uploadComplete(content);
+	}
+	
+};
+
+BOOL LLImportColladaAssetCache::uploadImageAsset(domImage* image)
+{
+	// we only support init_from now - embedded data will come later
+	domImage::domInit_from* init = image->getInit_from();
+	if (!init)
+	{
+		return FALSE;
+	}
+
+	std::string filename = cdom::uriToNativePath(init->getValue().str());
+
+	std::string name = getElementLabel(image);
+	
+	LLUUID transaction_id = upload_new_resource(filename, name, std::string(),
+												0, LLFolderType::FT_TEXTURE, LLInventoryType::IT_TEXTURE,
+												LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(),
+												LLFloaterPerms::getEveryonePerms(),
+												name, NULL,
+												LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(), NULL);
+
+	if (transaction_id.isNull())
+	{
+		llwarns << "cannot upload " << filename << llendl;
+		
+		return FALSE;
+	}
+
+	mTransactionMap[transaction_id] = image;
+
+	LLFloaterReg::findTypedInstance<LLFloaterImportCollada>("import_collada")->setStatusAssetUploading(name);
+	
+	return TRUE;
+}
+
+
+
+//
+// asset cache -
+// uploads assets and provides a map from collada element to asset
+//
+
+
+
+BOOL LLImportColladaAssetCache::uploadMeshAsset(domMesh* mesh)
+{
+	LLPointer<LLModel> model = LLModel::loadModelFromDomMesh(mesh);
+
+	if (model->getNumVolumeFaces() == 0)
+	{
+		return FALSE;
+	}
+
+	// generate LODs
+	
+	
+	std::vector<LLPointer<LLModel> > lods;
+	lods.push_back(model);
+	S32 triangle_count = model->getNumTriangles();
+
+	for (S32 i = 0; i < 4; i++)
+	{
+		LLPointer<LLModel> last_model = lods.back();
+
+		S32 triangle_target = (S32)(triangle_count / pow(3.f, i + 1));
+		if (triangle_target > 16)
+		{
+			LLMeshReduction reduction;
+			LLPointer<LLModel> new_model = reduction.reduce(model, triangle_target, LLMeshReduction::TRIANGLE_BUDGET);
+			lods.push_back(new_model);
+		}
+		else
+		{
+			lods.push_back(last_model);
+		}
+	}
+	
+    // write model to temp file
+
+	std::string filename = gDirUtilp->getTempFilename();
+	LLModel::writeModel(filename,
+						lods[4],
+						lods[0],
+						lods[1],
+						lods[2],
+		                lods[3],
+						lods[4]->mPhysicsShape);
+
+
+	// copy file to VFS
+
+	LLTransactionID tid;
+	tid.generate();
+	LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID());  // create asset uuid
+
+	S32 file_size;
+	LLAPRFile infile ;
+	infile.open(filename, LL_APR_RB, NULL, &file_size);
+
+	if (infile.getFileHandle())
+	{
+		LLVFile file(gVFS, uuid, LLAssetType::AT_MESH, LLVFile::WRITE);
+
+		file.setMaxSize(file_size);
+
+		const S32 buf_size = 65536;
+		U8 copy_buf[buf_size];
+		while ((file_size = infile.read(copy_buf, buf_size)))
+		{
+			file.write(copy_buf, file_size);
+		}
+	}
+
+	
+	std::string name = getElementLabel(mesh);
+	
+	upload_new_resource(tid, LLAssetType::AT_MESH, name, std::string(), 0,LLFolderType::FT_MESH, LLInventoryType::IT_MESH,
+						LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
+						name, NULL,
+						LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(), NULL);
+
+	LLFile::remove(filename);
+
+	mTransactionMap[uuid] = mesh;
+
+	LLFloaterReg::findTypedInstance<LLFloaterImportCollada>("import_collada")->setStatusAssetUploading(name);
+
+	return TRUE;
+}
+
+
+// called by the mesh asset upload responder to indicate the mesh asset has been uploaded
+void LLImportColladaAssetCache::assetUploaded(LLUUID transaction_uuid, LLUUID asset_uuid, BOOL success)
+{
+	std::map<LLUUID, daeElement*>::iterator i = mTransactionMap.find(transaction_uuid);
+
+	if (i != mTransactionMap.end())
+	{
+		daeElement* element = i->second;
+			
+
+		if (success)
+		{
+			mAssetMap[element] = asset_uuid;
+		}
+		else // failure
+		{
+			// if failed, put back on end of queue
+			mUploadsPending.push_back(element);
+		}
+		
+		mUploads--;
+		uploadNextAsset();
+	}
+}
+
+const S32 MAX_CONCURRENT_UPLOADS = 5;
+
+void LLImportColladaAssetCache::uploadNextAsset()
+{
+	while ((mUploadsPending.size() > 0) && (mUploads < MAX_CONCURRENT_UPLOADS))
+	{
+		BOOL upload_started = FALSE;
+
+		daeElement* element = mUploadsPending.back();
+		mUploadsPending.pop_back();
+
+		domImage* image = daeSafeCast<domImage>(element);
+		if (image)
+		{
+			upload_started = uploadImageAsset(image);
+		}
+		
+		domMesh* mesh = daeSafeCast<domMesh>(element);
+		if (mesh)
+		{
+			upload_started = uploadMeshAsset(mesh);
+		}
+
+		if (upload_started)
+		{
+			mUploads++;
+		}
+
+	}
+
+	if ((mUploadsPending.size() == 0) && (mUploads == 0))
+	{
+		// we're done! notify the importer
+		LLImportCollada::getInstance()->assetsUploaded();
+	}
+
+	updateCount();
+}
+
+
+void LLImportColladaAssetCache::clear()
+{
+	mDAE = NULL;
+	mTransactionMap.clear();
+	mAssetMap.clear();
+	mUploadsPending.clear();
+	mUploads = 0;
+}
+
+void LLImportColladaAssetCache::endImport()
+{
+	clear();
+}
+
+void LLImportColladaAssetCache::updateCount()
+{
+	S32 mesh_count = 0;
+	S32 image_count = 0;
+
+	for (S32 i = 0; i < mUploadsPending.size(); i++)
+	{
+		daeElement* element = mUploadsPending[i];
+
+		if (daeSafeCast<domMesh>(element))
+		{
+			mesh_count++;
+		}
+
+		if (daeSafeCast<domImage>(element))
+		{
+			image_count++;
+		}
+	}
+	
+	LLFloaterReg::findTypedInstance<LLFloaterImportCollada>("import_collada")->setAssetCount(mesh_count, image_count);
+}
+
+void LLImportColladaAssetCache::prepareForUpload(DAE* dae)
+{
+	clear();
+	mDAE = dae;
+
+	daeDatabase* db = mDAE->getDatabase();
+
+	S32 mesh_count = db->getElementCount(NULL, COLLADA_TYPE_MESH);
+	for (S32 i = 0; i < mesh_count; i++)
+	{
+		domMesh* mesh = NULL;
+
+		db->getElement((daeElement**) &mesh, i, NULL, COLLADA_TYPE_MESH);
+
+		mUploadsPending.push_back(mesh);
+	}
+
+	
+	S32 image_count = db->getElementCount(NULL, COLLADA_TYPE_IMAGE);
+	for (S32 i = 0; i < image_count; i++)
+	{
+		domImage* image = NULL;
+		db->getElement((daeElement**) &image, i, NULL, COLLADA_TYPE_IMAGE);
+		
+		mUploadsPending.push_back(image);
+	}
+
+	updateCount();
+}
+
+
+void LLImportColladaAssetCache::uploadAssets()
+{
+	uploadNextAsset();
+}
+
+
+LLUUID LLImportColladaAssetCache::getAssetForDaeElement(daeElement* element)
+{
+	LLUUID id;
+	
+	std::map<daeElement*, LLUUID>::iterator i = mAssetMap.find(element);
+	if (i != mAssetMap.end())
+	{
+		id = i->second;
+	}
+
+	return id;
+}
+
+
+//
+// importer
+//
+
+
+
+LLImportCollada::LLImportCollada()
+{
+	mIsImporting = FALSE;
+}
+
+
+
+
+void LLImportCollada::appendObjectAsset(domInstance_geometry* instance_geo)
+{
+	domGeometry* geo = daeSafeCast<domGeometry>(instance_geo->getUrl().getElement());
+	if (!geo)
+	{
+		llwarns << "cannot find geometry" << llendl;
+		return;
+	}
+	
+	domMesh* mesh = daeSafeCast<domMesh>(geo->getDescendant(daeElement::matchType(domMesh::ID())));
+	if (!mesh)
+	{
+		llwarns << "could not find mesh" << llendl;
+		return;
+	}
+	
+	LLUUID mesh_asset = LLImportColladaAssetCache::getInstance()->getAssetForDaeElement(mesh);
+	if (mesh_asset.isNull())
+	{
+		llwarns << "no mesh asset, skipping" << llendl;
+		return;
+	}
+
+	// load the model
+	LLModel* model = LLModel::loadModelFromDomMesh(mesh);
+
+
+
+	
+	// get our local transformation
+	LLMatrix4 transformation = mStack.front().transformation;
+
+	// adjust the transformation to compensate for mesh normalization
+	LLVector3 mesh_scale_vector;
+	LLVector3 mesh_translation_vector;
+	model->getNormalizedScaleTranslation(mesh_scale_vector, mesh_translation_vector);
+	LLMatrix4 mesh_translation;
+	mesh_translation.setTranslation(mesh_translation_vector);
+	transformation = matrix_multiply(mesh_translation, transformation);
+	LLMatrix4 mesh_scale;
+	mesh_scale.initScale(mesh_scale_vector);
+	transformation = matrix_multiply(mesh_scale, transformation);
+
+	// check for reflection
+	BOOL reflected = (transformation.determinant() < 0);
+	
+	// compute position
+	LLVector3 position = LLVector3(0, 0, 0) * transformation;
+
+	// compute scale
+	LLVector3 x_transformed = LLVector3(1, 0, 0) * transformation - position;
+	LLVector3 y_transformed = LLVector3(0, 1, 0) * transformation - position;
+	LLVector3 z_transformed = LLVector3(0, 0, 1) * transformation - position;
+	F32 x_length = x_transformed.normalize();
+	F32 y_length = y_transformed.normalize();
+	F32 z_length = z_transformed.normalize();
+	LLVector3 scale = LLVector3(x_length, y_length, z_length);
+
+	// adjust for "reflected" geometry
+	LLVector3 x_transformed_reflected = x_transformed;
+	if (reflected)
+	{
+		x_transformed_reflected *= -1.0;
+	}
+	
+	// compute rotation
+	LLMatrix3 rotation_matrix;
+	rotation_matrix.setRows(x_transformed_reflected, y_transformed, z_transformed);
+	LLQuaternion quat_rotation = rotation_matrix.quaternion();
+	quat_rotation.normalize(); // the rotation_matrix might not have been orthoginal.  make it so here.
+	LLVector3 euler_rotation;
+	quat_rotation.getEulerAngles(&euler_rotation.mV[VX], &euler_rotation.mV[VY], &euler_rotation.mV[VZ]);
+
+	
+	//
+	// build parameter block to construct this prim
+	//
+	
+	LLSD object_params;
+
+    // create prim
+
+	// set volume params
+	LLVolumeParams  volume_params;
+	volume_params.setType( LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE );
+	volume_params.setBeginAndEndS( 0.f, 1.f );
+	volume_params.setBeginAndEndT( 0.f, 1.f );
+	volume_params.setRatio  ( 1, 1 );
+	volume_params.setShear  ( 0, 0 );
+	U8 sculpt_type = LL_SCULPT_TYPE_MESH;
+	if (reflected)
+	{
+		sculpt_type |= LL_SCULPT_FLAG_MIRROR;
+	}
+	volume_params.setSculptID(mesh_asset, sculpt_type);
+	object_params["shape"] = volume_params.asLLSD();
+
+	object_params["material"] = LL_MCODE_WOOD;
+
+	object_params["group-id"] = gAgent.getGroupID();
+	object_params["pos"] = ll_sd_from_vector3(position);
+	object_params["rotation"] = ll_sd_from_quaternion(quat_rotation);
+	object_params["scale"] = ll_sd_from_vector3(scale);
+	object_params["name"] = mStack.front().name;
+
+	// load material from dae file
+	std::vector<LLTextureEntry> texture_entries = getMaterials(model, instance_geo);
+	object_params["facelist"] = LLSD::emptyArray();
+	for (int i = 0; i < texture_entries.size(); i++)
+	{
+		object_params["facelist"][i] = texture_entries[i].asLLSD();
+	}
+
+	// set extra parameters
+	LLSculptParams sculpt_params;
+	sculpt_params.setSculptTexture(mesh_asset);
+	sculpt_params.setSculptType(sculpt_type);
+	U8 buffer[MAX_OBJECT_PARAMS_SIZE+1];
+	LLDataPackerBinaryBuffer dp(buffer, MAX_OBJECT_PARAMS_SIZE);
+	sculpt_params.pack(dp);
+	std::vector<U8> v(dp.getCurrentSize());
+	memcpy(&v[0], buffer, dp.getCurrentSize());
+	LLSD extra_parameter;
+	extra_parameter["extra_parameter"] = sculpt_params.mType;
+	extra_parameter["param_data"] = v;
+	object_params["extra_parameters"].append(extra_parameter);
+
+	mObjectList.append(object_params);
+	
+	delete model;
+
+	LLFloaterReg::findTypedInstance<LLFloaterImportCollada>("import_collada")->setStatusCreatingPrim(mStack.front().name);
+	
+	return;
+}
+
+void LLImportCollada::uploadObjectAsset()
+{
+	LLSD request;
+	request["objects"] = mObjectList;
+	
+	std::string url = gAgent.getRegion()->getCapability("UploadObjectAsset");
+	LLHTTPClient::post(url, request, new LLHTTPClient::Responder());
+}
+
+
+
+void LLImportCollada::importFile(std::string filename)
+{
+	if (mIsImporting)
+	{
+		llwarns << "Importer already running, import command for " << filename << " ignored" << llendl;
+		return;
+	}
+
+	LLFloaterReg::showInstance("import_collada");
+	LLFloaterReg::findTypedInstance<LLFloaterImportCollada>("import_collada")->enableOK(TRUE);
+
+	
+	mIsImporting = TRUE;
+	mDAE = new DAE;
+	mImportOrigin = gAgent.getPositionAgent() + LLVector3(0, 0, 2);
+	mSceneTransformation = LLMatrix4();  // identity
+	mFilename = filename;
+	mCreates = 0;
+	mObjectList = LLSD::emptyArray();
+	
+	if (mDAE->open(mFilename) == NULL)
+	{
+		llwarns << "cannot open file " << mFilename << llendl;
+		endImport();
+		return;
+	}
+
+	LLImportColladaAssetCache::getInstance()->prepareForUpload(mDAE);
+
+	return;
+}
+
+
+void LLImportCollada::assetsUploaded()
+{
+	if (!mIsImporting)
+	{
+		// weird, we got a callback while not importing.
+		return;
+	}
+	
+	daeDocument* doc = mDAE->getDoc(mFilename);
+	if (!doc)
+	{
+		llwarns << "can't find internal doc" << llendl;
+		endImport();
+	}
+	
+	daeElement* root = doc->getDomRoot();
+	if (!root)
+	{
+		llwarns << "document has no root" << llendl;
+		endImport();
+	}
+
+	domAsset::domUnit* unit = daeSafeCast<domAsset::domUnit>(root->getDescendant(daeElement::matchType(domAsset::domUnit::ID())));
+	if (unit)
+	{
+		mSceneTransformation *= unit->getMeter();
+	}
+
+	domUpAxisType up = UPAXISTYPE_Y_UP;  // default is Y_UP
+	domAsset::domUp_axis* up_axis =
+		daeSafeCast<domAsset::domUp_axis>(root->getDescendant(daeElement::matchType(domAsset::domUp_axis::ID())));
+	if (up_axis)
+	{
+		up = up_axis->getValue();
+	}
+	
+	if (up == UPAXISTYPE_X_UP)
+	{
+		LLMatrix4 rotation;
+		rotation.initRotation(0.0f, 90.0f * DEG_TO_RAD, 0.0f);
+
+		mSceneTransformation = matrix_multiply(rotation, mSceneTransformation);
+	}
+	else if (up == UPAXISTYPE_Y_UP)
+	{
+		LLMatrix4 rotation;
+		rotation.initRotation(90.0f * DEG_TO_RAD, 0.0f, 0.0f);
+
+		mSceneTransformation = matrix_multiply(rotation, mSceneTransformation);
+	}
+    // else Z_UP, which is our behavior
+
+	
+
+	daeElement* scene = root->getDescendant("visual_scene");
+	if (!scene)
+	{
+		llwarns << "document has no visual_scene" << llendl;
+		endImport();
+	}
+
+	processElement(scene);
+	processNextElement();
+}
+
+void LLImportCollada::pushStack(daeElement* next_element, std::string name, LLMatrix4 transformation)
+{
+	struct StackState new_state;
+
+	new_state.next_element = next_element;
+	new_state.name = name;
+	new_state.transformation = transformation;
+
+	mStack.push_front(new_state);
+}
+
+
+
+void LLImportCollada::popStack()
+{
+	mStack.pop_front();
+}
+
+
+
+BOOL LLImportCollada::processElement(daeElement* element)
+{
+	if (mStack.size() > 0)
+	{
+		mStack.front().next_element = getNextSibling(element);
+	}
+	
+	domTranslate* translate = daeSafeCast<domTranslate>(element);
+	if (translate)
+	{
+		domFloat3 dom_value = translate->getValue();
+
+		LLMatrix4 translation;
+		translation.setTranslation(LLVector3(dom_value[0], dom_value[1], dom_value[2]));
+
+		mStack.front().transformation = matrix_multiply(translation, mStack.front().transformation);
+	}
+
+	domRotate* rotate = daeSafeCast<domRotate>(element);
+	if (rotate)
+	{
+		domFloat4 dom_value = rotate->getValue();
+
+		LLMatrix4 rotation;
+		rotation.initRotTrans(dom_value[3] * DEG_TO_RAD, LLVector3(dom_value[0], dom_value[1], dom_value[2]), LLVector3(0, 0, 0));
+
+		mStack.front().transformation = matrix_multiply(rotation, mStack.front().transformation);
+	}
+
+	domScale* scale = daeSafeCast<domScale>(element);
+	if (scale)
+	{
+		domFloat3 dom_value = scale->getValue();
+
+		LLMatrix4 scaling;
+		scaling.initScale(LLVector3(dom_value[0], dom_value[1], dom_value[2]));
+
+		mStack.front().transformation = matrix_multiply(scaling, mStack.front().transformation);
+	}
+
+	domMatrix* matrix = daeSafeCast<domMatrix>(element);
+	if (matrix)
+	{
+		domFloat4x4 dom_value = matrix->getValue();
+
+		LLMatrix4 matrix_transform;
+
+		for (int i = 0; i < 4; i++)
+			for(int j = 0; j < 4; j++)
+			{
+				matrix_transform.mMatrix[i][j] = dom_value[i + j*4];
+			}
+		
+		mStack.front().transformation = matrix_multiply(matrix_transform, mStack.front().transformation);
+	}
+
+	domInstance_geometry* instance_geo = daeSafeCast<domInstance_geometry>(element);
+	if (instance_geo)
+	{
+		appendObjectAsset(instance_geo);
+	}
+
+	domNode* node = daeSafeCast<domNode>(element);
+	if (node)
+	{
+		pushStack(getFirstChild(element), getElementLabel(element), mStack.front().transformation);
+	}
+
+	domInstance_node* instance_node = daeSafeCast<domInstance_node>(element);
+	if (instance_node)
+	{
+		daeElement* instance = instance_node->getUrl().getElement();
+		if (instance)
+		{
+			pushStack(getFirstChild(instance), getElementLabel(instance), mStack.front().transformation);
+		}
+	}
+
+	domVisual_scene* scene = daeSafeCast<domVisual_scene>(element);
+	if (scene)
+	{
+		pushStack(getFirstChild(element), std::string("scene"), mSceneTransformation);
+	}
+
+	return FALSE;
+}
+
+
+void LLImportCollada::processNextElement()
+{
+	while(1)
+	{
+		if (mStack.size() == 0)
+		{
+			uploadObjectAsset();
+			endImport();
+			return;
+		}
+
+		daeElement *element = mStack.front().next_element;
+
+		if (element == NULL)
+		{
+			popStack();
+		}
+		else
+		{
+			processElement(element);
+		}
+	}
+}
+
+
+void LLImportCollada::endImport()
+{
+	LLFloaterReg::hideInstance("import_collada");
+
+	LLImportColladaAssetCache::getInstance()->endImport();
+	
+	if (mDAE)
+	{
+		delete mDAE;
+		mDAE = NULL;
+	}
+	
+	mIsImporting = FALSE;
+}
+
+
+/* static */
+void LLImportCollada::onCommitOK(LLUICtrl*, void*)
+{
+	LLFloaterReg::findTypedInstance<LLFloaterImportCollada>("import_collada")->enableOK(FALSE);
+
+	LLImportColladaAssetCache::getInstance()->uploadAssets();
+}
+
+
+/* static */
+void LLImportCollada::onCommitCancel(LLUICtrl*, void*)
+{
+	getInstance()->endImport();
+}
+
+#endif
diff --git a/indra/newview/llfloaterimportcollada.h b/indra/newview/llfloaterimportcollada.h
new file mode 100644
index 00000000000..818b19e403b
--- /dev/null
+++ b/indra/newview/llfloaterimportcollada.h
@@ -0,0 +1,143 @@
+/** 
+ * @file llfloaterimportcollada.h
+ * @brief The about box from Help -> About
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLFLOATERIMPORTCOLLADA_H
+#define LL_LLFLOATERIMPORTCOLLADA_H
+
+#include "llfloater.h"
+#include "llvolume.h" //for LL_MESH_ENABLED
+
+#if LL_MESH_ENABLED
+
+class LLFloaterImportCollada : public LLFloater
+{
+public:
+	LLFloaterImportCollada(const LLSD& key);
+	/* virtual */ BOOL postBuild();
+
+	void setAssetCount(S32 mesh_count, S32 texture_count);
+	void setStatusAssetUploading(std::string asset_name);
+	void setStatusCreatingPrim(std::string prim_name);
+	void setStatusIdle();
+	void enableOK(BOOL enable);
+};
+
+class LLViewerObject;
+class DAE;
+class daeElement;
+class domMesh;
+class domImage;
+class domInstance_geometry;
+class LLModel;
+class LLImportCollada;
+
+class LLImportColladaAssetCache : public LLSingleton<LLImportColladaAssetCache>
+{
+public:
+	// called first to initialize 
+	void prepareForUpload(DAE* dae);
+
+	// upload the assets in this collada file
+	void uploadAssets();
+
+	// get the uploaded assets which corresponds to this element
+	LLUUID getAssetForDaeElement(daeElement* element);
+
+	// stop the upload
+	void endImport();
+	
+	// reset
+	void clear();
+
+	// callback for notification when an asset has been uploaded
+	void assetUploaded(LLUUID transaction_uuid, LLUUID asset_uuid, BOOL success);
+
+private:
+	void uploadNextAsset();
+	BOOL uploadMeshAsset(domMesh* mesh);
+	BOOL uploadImageAsset(domImage* image);
+	void updateCount();
+	
+	std::vector<daeElement*> mUploadsPending;
+	std::map<LLUUID, daeElement*> mTransactionMap;
+	std::map<daeElement*, LLUUID> mAssetMap;
+	
+	DAE* mDAE;
+	S32 mUploads;
+};
+
+
+class LLImportCollada 
+: public LLSingleton<LLImportCollada>
+{
+public:
+	LLImportCollada();
+	void importFile(std::string filename);
+
+	// callback when all assets have been uploaded
+	void assetsUploaded();
+
+	// callback when buttons pressed
+	static void onCommitOK(LLUICtrl*, void*);
+	static void onCommitCancel(LLUICtrl*, void*);
+	
+	
+private:
+	void endImport();
+	void processNextElement();
+	BOOL processElement(daeElement* element);
+	void pushStack(daeElement* next_element, std::string name, LLMatrix4 transformation);
+	void popStack();
+	void appendObjectAsset(domInstance_geometry* instance_geo);
+	void uploadObjectAsset();
+	
+	struct StackState
+	{
+		daeElement* next_element;
+		std::string name;
+		LLMatrix4 transformation;
+	};
+
+	std::list<struct StackState> mStack;
+	S32 mCreates;
+	LLVector3 mImportOrigin;
+	std::string mFilename;
+	BOOL mIsImporting;
+	DAE  *mDAE;
+	LLSD mObjectList;
+	
+	LLMatrix4   mSceneTransformation;
+};
+
+#endif
+
+#endif // LL_LLFLOATERIMPORTCOLLADA_H
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
new file mode 100644
index 00000000000..5dd983d818c
--- /dev/null
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -0,0 +1,3382 @@
+/** 
+ * @file llfloatermodelpreview.cpp
+ * @brief LLFloaterModelPreview class implementation
+ *
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2007, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "dae.h"
+//#include "dom.h"
+#include "dom/domAsset.h"
+#include "dom/domBind_material.h"
+#include "dom/domCOLLADA.h"
+#include "dom/domConstants.h"
+#include "dom/domController.h"
+#include "dom/domEffect.h"
+#include "dom/domGeometry.h"
+#include "dom/domInstance_geometry.h"
+#include "dom/domInstance_material.h"
+#include "dom/domInstance_node.h"
+#include "dom/domInstance_effect.h"
+#include "dom/domMaterial.h"
+#include "dom/domMatrix.h"
+#include "dom/domNode.h"
+#include "dom/domProfile_COMMON.h"
+#include "dom/domRotate.h"
+#include "dom/domScale.h"
+#include "dom/domTranslate.h"
+#include "dom/domVisual_scene.h"
+
+#include "llfloatermodelpreview.h"
+
+#include "llfilepicker.h"
+#include "llimagebmp.h"
+#include "llimagetga.h"
+#include "llimagejpeg.h"
+#include "llimagepng.h"
+
+#include "llagent.h"
+#include "llbutton.h"
+#include "llcombobox.h"
+#include "lldatapacker.h"
+#include "lldrawable.h"
+#include "lldrawpoolavatar.h"
+#include "llrender.h"
+#include "llface.h"
+#include "lleconomy.h"
+#include "llfocusmgr.h"
+#include "llfloaterperms.h"
+#include "llmatrix4a.h"
+#include "llmeshrepository.h"
+#include "llsdutil_math.h"
+#include "lltextbox.h"
+#include "lltoolmgr.h"
+#include "llui.h"
+#include "llvector4a.h"
+#include "llviewercamera.h"
+#include "llviewerwindow.h"
+#include "llvoavatar.h"
+#include "llvoavatarself.h"
+#include "pipeline.h"
+#include "lluictrlfactory.h"
+#include "llviewermenufile.h"
+#include "llviewerregion.h"
+#include "llstring.h"
+#include "llbutton.h"
+#include "llcheckboxctrl.h"
+#include "llsliderctrl.h"
+#include "llspinctrl.h"
+#include "llvfile.h"
+#include "llvfs.h"
+
+
+#include "glod/glod.h"
+
+
+#if LL_MESH_ENABLED
+
+//static
+S32 LLFloaterModelPreview::sUploadAmount = 10;
+LLFloaterModelPreview* LLFloaterModelPreview::sInstance = NULL;
+
+const S32 PREVIEW_BORDER_WIDTH = 2;
+const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
+const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
+const S32 PREF_BUTTON_HEIGHT = 16 + 7 + 16;
+const S32 PREVIEW_TEXTURE_HEIGHT = 300;
+
+void drawBoxOutline(const LLVector3& pos, const LLVector3& size);
+
+std::string limit_name[] =
+{
+	"lowest limit",
+	"low limit",
+	"medium limit",
+	"high limit",
+	"physics limit",
+
+	"I went off the end of the limit_name array.  Me so smart."
+};
+
+std::string info_name[] =
+{
+	"lowest info",
+	"low info",
+	"medium info",
+	"high info",
+	"physics info",
+
+	"I went off the end of the info_name array.  Me so smart."
+};
+
+bool validate_face(const LLVolumeFace& face)
+{
+	for (U32 i = 0; i < face.mNumIndices; ++i)
+	{
+		if (face.mIndices[i] >= face.mNumVertices)
+		{
+			llwarns << "Face has invalid index." << llendl;
+			return false;
+		}
+	}
+
+	return true;
+}
+
+bool validate_model(const LLModel* mdl)
+{
+	if (mdl->getNumVolumeFaces() == 0)
+	{
+		llwarns << "Model has no faces!" << llendl;
+		return false;
+	}
+	
+	for (S32 i = 0; i < mdl->getNumVolumeFaces(); ++i)
+	{
+		if (mdl->getVolumeFace(i).mNumVertices == 0)
+		{
+			llwarns << "Face has no vertices." << llendl;
+			return false;
+		}
+
+		if (mdl->getVolumeFace(i).mNumIndices == 0)
+		{
+			llwarns << "Face has no indices." << llendl;
+			return false;
+		}
+
+		if (!validate_face(mdl->getVolumeFace(i)))
+		{
+			return false;
+		}
+	}
+
+	return true;
+}
+
+BOOL stop_gloderror()
+{
+	GLuint error = glodGetError();
+
+	if (error != GLOD_NO_ERROR)
+	{
+		llwarns << "GLOD error detected, cannot generate LOD: " << std::hex << error << llendl;
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+LLPhysicsDecompFloater::LLPhysicsDecompFloater(LLSD& key)
+: LLFloater(key)
+{
+
+}
+
+LLPhysicsDecompFloater::~LLPhysicsDecompFloater()
+{
+	if (LLFloaterModelPreview::sInstance && LLFloaterModelPreview::sInstance->mDecompFloater)
+	{
+		LLFloaterModelPreview::sInstance->mDecompFloater = NULL;
+	}
+}
+
+class LLMeshFilePicker : public LLFilePickerThread
+{
+public:
+	LLFloaterModelPreview* mFMP;
+	S32 mLOD;
+
+	LLMeshFilePicker(LLFloaterModelPreview* fmp, S32 lod)
+		: LLFilePickerThread(LLFilePicker::FFLOAD_COLLADA)
+	{
+		mFMP = fmp;
+		mLOD = lod;
+	}
+
+	virtual void notify(const std::string& filename)
+	{
+		mFMP->mModelPreview->loadModel(mFile, mLOD);
+	}
+};
+
+
+//-----------------------------------------------------------------------------
+// LLFloaterModelPreview()
+//-----------------------------------------------------------------------------
+LLFloaterModelPreview::LLFloaterModelPreview(const LLSD& key) : 
+	LLFloater(key)
+{
+	sInstance = this;
+	mLastMouseX = 0;
+	mLastMouseY = 0;
+	mGLName = 0;
+	mLoading = FALSE;
+	mDecompFloater = NULL;
+}
+
+//-----------------------------------------------------------------------------
+// postBuild()
+//-----------------------------------------------------------------------------
+BOOL LLFloaterModelPreview::postBuild()
+{
+	if (!LLFloater::postBuild())
+	{
+		return FALSE;
+	}
+
+	childSetCommitCallback("high detail combo", onHighLODCommit, this);
+	childSetCommitCallback("medium detail combo", onMediumLODCommit, this);
+	childSetCommitCallback("low detail combo", onLowLODCommit, this);
+	childSetCommitCallback("lowest detail combo", onLowestLODCommit, this);
+	childSetCommitCallback("physics detail combo", onPhysicsLODCommit, this);
+
+
+	childSetCommitCallback("high limit", onHighLimitCommit, this);
+	childSetCommitCallback("medium limit", onMediumLimitCommit, this);
+	childSetCommitCallback("low limit", onLowLimitCommit, this);
+	childSetCommitCallback("lowest limit", onLowestLimitCommit, this);
+	childSetCommitCallback("physics limit", onPhysicsLimitCommit, this);
+
+	childSetCommitCallback("smooth normals", onSmoothNormalsCommit, this);
+
+	childSetCommitCallback("show edges", onShowEdgesCommit, this);
+	childSetCommitCallback("auto fill", onAutoFillCommit, this);
+
+	childSetCommitCallback("explode", onExplodeCommit, this);
+
+	childSetTextArg("status", "[STATUS]", getString("status_idle"));
+
+	for (S32 lod = 0; lod < LLModel::NUM_LODS; ++lod)
+	{
+		if (lod == LLModel::LOD_PHYSICS)
+		{
+			childSetTextArg(info_name[lod], "[HULLS]", std::string("0"));
+			childSetTextArg(info_name[lod], "[POINTS]", std::string("0"));
+		}
+		else
+		{
+			childSetTextArg(info_name[lod], "[TRIANGLES]", std::string("0"));
+			childSetTextArg(info_name[lod], "[VERTICES]", std::string("0"));
+			childSetTextArg(info_name[lod], "[SUBMESHES]", std::string("0"));
+			std::string msg = getString("required");
+			childSetTextArg(info_name[lod], "[MESSAGE]", msg);
+		}
+
+		childSetVisible(limit_name[lod], FALSE);
+	}
+
+	//childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d",sUploadAmount));
+	childSetAction("ok_btn", onUpload, this);
+
+	childSetAction("consolidate", onConsolidate, this);
+	childSetAction("scrub materials", onScrubMaterials, this);
+
+	childSetAction("decompose_btn", onDecompose, this);
+
+	childSetCommitCallback("preview_lod_combo", onPreviewLODCommit, this);
+	
+	const U32 width = 512;
+	const U32 height = 512;
+
+	mPreviewRect.set(getRect().getWidth()-PREVIEW_HPAD-width,
+				PREVIEW_HPAD+height,
+				getRect().getWidth()-PREVIEW_HPAD,
+				PREVIEW_HPAD);
+
+	mModelPreview = new LLModelPreview(512, 512, this);
+	mModelPreview->setPreviewTarget(16.f);
+	
+	return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// LLFloaterModelPreview()
+//-----------------------------------------------------------------------------
+LLFloaterModelPreview::~LLFloaterModelPreview()
+{
+	sInstance = NULL;
+
+	delete mModelPreview;
+	
+	if (mGLName)
+	{
+		LLImageGL::deleteTextures(1, &mGLName );
+	}
+
+	if (mDecompFloater)
+	{
+		mDecompFloater->closeFloater();
+		mDecompFloater = NULL;
+	}	
+}
+
+void LLFloaterModelPreview::loadModel(S32 lod)
+{
+	mLoading = TRUE;
+
+	(new LLMeshFilePicker(this, lod))->getFile();
+}
+
+void LLFloaterModelPreview::setLODMode(S32 lod, S32 mode)
+{
+	if (mode == 0)
+	{
+		loadModel(lod);
+	}
+	else if (mode != mModelPreview->mLODMode[lod])
+	{
+		mModelPreview->mLODMode[lod] = mode;
+		mModelPreview->genLODs(lod);
+	}
+
+	mModelPreview->setPreviewLOD(lod);
+	
+	
+	LLSpinCtrl* lim = getChild<LLSpinCtrl>(limit_name[lod], TRUE);
+
+	if (mode == 1) //triangle count
+	{
+		U32 tri_count = 0;
+		for (LLModelLoader::model_list::iterator iter = mModelPreview->mBaseModel.begin();
+				iter != mModelPreview->mBaseModel.end(); ++iter)
+		{
+			tri_count += (*iter)->getNumTriangles();
+		}
+
+		lim->setMaxValue(tri_count);
+		lim->setVisible(TRUE);
+	}
+	else
+	{
+		lim->setVisible(FALSE);
+	}
+}
+
+void LLFloaterModelPreview::setLimit(S32 lod, S32 limit)
+{
+	if (limit != mModelPreview->mLimit[lod])
+	{
+		mModelPreview->mLimit[lod] = limit;
+		mModelPreview->genLODs(lod);
+		mModelPreview->setPreviewLOD(lod);
+	}
+}
+
+void LLFloaterModelPreview::onPreviewLODCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview *fp =(LLFloaterModelPreview *)userdata;
+	
+	if (!fp->mModelPreview)
+	{
+		return;
+	}
+
+	S32 which_mode = 0;
+
+	LLCtrlSelectionInterface* iface = fp->childGetSelectionInterface("preview_lod_combo");
+	if (iface)
+	{
+		which_mode = iface->getFirstSelectedIndex();
+	}
+	fp->mModelPreview->setPreviewLOD(which_mode);
+}
+
+//static 
+void LLFloaterModelPreview::setLODMode(S32 lod, void* userdata)
+{
+	LLFloaterModelPreview *fp =(LLFloaterModelPreview *)userdata;
+	
+	if (!fp->mModelPreview)
+	{
+		return;
+	}
+
+	S32 which_mode = 0;
+
+	std::string combo_name[] =
+	{
+		"lowest detail combo",
+		"low detail combo",
+		"medium detail combo",
+		"high detail combo",
+		"physics detail combo",
+
+		"I went off the end of the combo_name array.  Me so smart."
+	};
+
+	LLCtrlSelectionInterface* iface = fp->childGetSelectionInterface(combo_name[lod]);
+	if (iface)
+	{
+		which_mode = iface->getFirstSelectedIndex();
+	}
+
+	fp->setLODMode(lod, which_mode);
+}
+
+//static 
+void LLFloaterModelPreview::onHighLODCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLODMode(3, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::onMediumLODCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLODMode(2, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::onLowLODCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLODMode(1, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::onLowestLODCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLODMode(0, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::onPhysicsLODCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLODMode(4, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::setLimit(S32 lod, void* userdata)
+{
+	LLFloaterModelPreview *fp =(LLFloaterModelPreview *)userdata;
+	
+	if (!fp->mModelPreview)
+	{
+		return;
+	}
+
+	S32 limit = fp->childGetValue(limit_name[lod]).asInteger();
+
+	
+	fp->setLimit(lod, limit);
+}
+
+//static 
+void LLFloaterModelPreview::onHighLimitCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLimit(3, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::onMediumLimitCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLimit(2, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::onLowLimitCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLimit(1, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::onLowestLimitCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLimit(0, userdata);
+}
+
+//static 
+void LLFloaterModelPreview::onPhysicsLimitCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview::setLimit(4, userdata);
+}
+
+//static
+void LLFloaterModelPreview::onSmoothNormalsCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata;
+
+	fp->mModelPreview->smoothNormals();
+}
+
+//static
+void LLFloaterModelPreview::onShowEdgesCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata;
+
+	fp->mModelPreview->refresh();
+}
+
+//static
+void LLFloaterModelPreview::onExplodeCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata;
+
+	fp->mModelPreview->refresh();
+}
+
+//static 
+void LLFloaterModelPreview::onAutoFillCommit(LLUICtrl* ctrl, void* userdata)
+{
+	LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata;
+
+	fp->mModelPreview->genLODs();
+}
+
+
+//-----------------------------------------------------------------------------
+// draw()
+//-----------------------------------------------------------------------------
+void LLFloaterModelPreview::draw()
+{
+	LLFloater::draw();
+	LLRect r = getRect();
+
+	if (!mLoading)
+	{
+		childSetTextArg("status", "[STATUS]", getString("status_idle"));
+	}
+	
+	childSetTextArg("description_label", "[PRIM_COST]", llformat("%d", mModelPreview->mResourceCost));
+	childSetTextArg("description_label", "[TEXTURES]", llformat("%d", mModelPreview->mTextureSet.size()));
+
+	if (mDecompFloater)
+	{
+		mDecompFloater->childSetText("status", gMeshRepo.mDecompThread->mStatus);
+	}
+
+	U32 resource_cost = mModelPreview->mResourceCost*10;
+
+	if (childGetValue("upload_textures").asBoolean())
+	{
+		resource_cost += mModelPreview->mTextureSet.size()*10;
+	}
+	
+	childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d", resource_cost));
+	
+	if (mModelPreview)
+	{
+		gGL.color3f(1.f, 1.f, 1.f);
+
+		gGL.getTexUnit(0)->bind(mModelPreview);
+		
+		gGL.begin( LLRender::QUADS );
+		{
+			gGL.texCoord2f(0.f, 1.f);
+			gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mTop);
+			gGL.texCoord2f(0.f, 0.f);
+			gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mBottom);
+			gGL.texCoord2f(1.f, 0.f);
+			gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mBottom);
+			gGL.texCoord2f(1.f, 1.f);
+			gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mTop);
+		}
+		gGL.end();
+
+		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+	}
+}
+
+//-----------------------------------------------------------------------------
+// handleMouseDown()
+//-----------------------------------------------------------------------------
+BOOL LLFloaterModelPreview::handleMouseDown(S32 x, S32 y, MASK mask)
+{
+	if (mPreviewRect.pointInRect(x, y))
+	{
+		bringToFront( x, y );
+		gFocusMgr.setMouseCapture(this);
+		gViewerWindow->hideCursor();
+		mLastMouseX = x;
+		mLastMouseY = y;
+		return TRUE;
+	}
+
+	return LLFloater::handleMouseDown(x, y, mask);
+}
+
+//-----------------------------------------------------------------------------
+// handleMouseUp()
+//-----------------------------------------------------------------------------
+BOOL LLFloaterModelPreview::handleMouseUp(S32 x, S32 y, MASK mask)
+{
+	gFocusMgr.setMouseCapture(FALSE);
+	gViewerWindow->showCursor();
+	return LLFloater::handleMouseUp(x, y, mask);
+}
+
+//-----------------------------------------------------------------------------
+// handleHover()
+//-----------------------------------------------------------------------------
+BOOL LLFloaterModelPreview::handleHover	(S32 x, S32 y, MASK mask)
+{
+	MASK local_mask = mask & ~MASK_ALT;
+
+	if (mModelPreview && hasMouseCapture())
+	{
+		if (local_mask == MASK_PAN)
+		{
+			// pan here
+			mModelPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f);
+		}
+		else if (local_mask == MASK_ORBIT)
+		{
+			F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f;
+			F32 pitch_radians = (F32)(y - mLastMouseY) * 0.02f;
+			
+			mModelPreview->rotate(yaw_radians, pitch_radians);
+		}
+		else 
+		{
+		
+			F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f;
+			F32 zoom_amt = (F32)(y - mLastMouseY) * 0.02f;
+			
+			mModelPreview->rotate(yaw_radians, 0.f);
+			mModelPreview->zoom(zoom_amt);
+		}
+
+		
+		mModelPreview->refresh();
+		
+		LLUI::setMousePositionLocal(this, mLastMouseX, mLastMouseY);
+	}
+
+	if (!mPreviewRect.pointInRect(x, y) || !mModelPreview)
+	{
+		return LLFloater::handleHover(x, y, mask);
+	}
+	else if (local_mask == MASK_ORBIT)
+	{
+		gViewerWindow->setCursor(UI_CURSOR_TOOLCAMERA);
+	}
+	else if (local_mask == MASK_PAN)
+	{
+		gViewerWindow->setCursor(UI_CURSOR_TOOLPAN);
+	}
+	else
+	{
+		gViewerWindow->setCursor(UI_CURSOR_TOOLZOOMIN);
+	}
+
+	return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// handleScrollWheel()
+//-----------------------------------------------------------------------------
+BOOL LLFloaterModelPreview::handleScrollWheel(S32 x, S32 y, S32 clicks)
+{
+	if (mPreviewRect.pointInRect(x, y) && mModelPreview)
+	{
+		mModelPreview->zoom((F32)clicks * -0.2f);
+		mModelPreview->refresh();
+	}
+
+	return TRUE;
+}
+
+//static
+void LLFloaterModelPreview::onPhysicsParamCommit(LLUICtrl* ctrl, void* data)
+{
+	LLCDParam* param = (LLCDParam*) data;
+
+	LLCDResult ret = LLCD_OK;
+
+	if (LLConvexDecomposition::getInstance() == NULL)
+	{
+		llinfos << "convex decomposition tool is a stub on this platform. cannot get decomp." << llendl;
+		return;
+	}
+
+	if (param->mType == LLCDParam::LLCD_FLOAT)
+	{
+		ret = LLConvexDecomposition::getInstance()->setParam(param->mName, (F32) ctrl->getValue().asReal());
+	}
+	else if (param->mType == LLCDParam::LLCD_INTEGER ||
+		param->mType == LLCDParam::LLCD_ENUM)
+	{
+		ret = LLConvexDecomposition::getInstance()->setParam(param->mName, ctrl->getValue().asInteger());
+	}
+	else if (param->mType == LLCDParam::LLCD_BOOLEAN)
+	{
+		ret = LLConvexDecomposition::getInstance()->setParam(param->mName, ctrl->getValue().asBoolean());
+	}
+
+	if (ret)
+	{
+		llerrs << "WTF?" << llendl;
+	}
+}
+
+//static
+void LLFloaterModelPreview::onPhysicsStageExecute(LLUICtrl* ctrl, void* data)
+{
+	LLCDStageData* stage = (LLCDStageData*) data;
+	
+	LLModel* mdl = NULL;
+
+	if (sInstance)
+	{
+		if (sInstance->mModelPreview)
+		{
+			if (sInstance->mDecompFloater)
+			{
+				S32 idx = sInstance->mDecompFloater->childGetValue("model").asInteger();
+				if (idx >= 0 && idx < sInstance->mModelPreview->mModel[LLModel::LOD_PHYSICS].size())
+				{
+					mdl = sInstance->mModelPreview->mModel[LLModel::LOD_PHYSICS][idx];
+				}
+			}
+		}
+	}
+	
+	if (mdl)
+	{
+		gMeshRepo.mDecompThread->execute(stage->mName, mdl);
+	}
+}
+
+//static
+void LLFloaterModelPreview::onPhysicsStageCancel(LLUICtrl* ctrl, void*data)
+{
+	gMeshRepo.mDecompThread->cancel();
+}
+
+void LLFloaterModelPreview::showDecompFloater()
+{
+	if (!mDecompFloater)
+	{
+		LLSD key;
+		mDecompFloater = new LLPhysicsDecompFloater(key);
+	
+		S32 left = 20;
+		S32 right = 270;
+
+		S32 cur_y = 30;
+
+		{
+			//add status text
+			LLTextBox::Params p;
+			p.name("status");
+			p.rect(LLRect(left, cur_y, right-80, cur_y-20));
+			mDecompFloater->addChild(LLUICtrlFactory::create<LLTextBox>(p));
+		}
+
+
+		{ //add cancel button
+			LLButton::Params p;
+			p.name("Cancel");
+			p.label("Cancel");
+			p.rect(LLRect(right-80, cur_y, right, cur_y-20));		
+			LLButton* button = LLUICtrlFactory::create<LLButton>(p);
+			button->setCommitCallback(onPhysicsStageCancel, NULL);		
+			mDecompFloater->addChild(button);
+		}
+
+		cur_y += 30;
+
+
+		const LLCDStageData* stage;
+		S32 stage_count = 0;
+		if (LLConvexDecomposition::getInstance() != NULL)
+		{
+			stage_count = LLConvexDecomposition::getInstance()->getStages(&stage);
+		}
+
+		const LLCDParam* param;
+		S32 param_count = 0;
+		if (LLConvexDecomposition::getInstance() != NULL)
+		{
+			param_count = LLConvexDecomposition::getInstance()->getParameters(&param);
+		}
+
+		for (S32 j = stage_count-1; j >= 0; --j)
+		{
+			LLButton::Params p;
+			p.name(stage[j].mName);
+			p.label(stage[j].mName);
+			p.rect(LLRect(left, cur_y, right, cur_y-20));		
+			LLButton* button = LLUICtrlFactory::create<LLButton>(p);
+			button->setCommitCallback(onPhysicsStageExecute, (void*) &stage[j]);		
+			mDecompFloater->addChild(button);
+			gMeshRepo.mDecompThread->mStageID[stage[j].mName] = j;
+			cur_y += 30;
+			// protected against stub by stage_count being 0 for stub above
+			LLConvexDecomposition::getInstance()->registerCallback(j, LLPhysicsDecomp::llcdCallback);
+
+			for (S32 i = 0; i < param_count; ++i)
+			{
+				if (param[i].mStage != j)
+				{
+					continue;
+				}
+
+				if (param[i].mType == LLCDParam::LLCD_FLOAT)
+				{
+					LLSliderCtrl::Params p;
+					p.name(param[i].mName);
+					p.label(param[i].mName);
+					p.rect(LLRect(left, cur_y, right, cur_y-20));
+					p.min_value(param[i].mDetails.mRange.mLow.mFloat);
+					p.max_value(param[i].mDetails.mRange.mHigh.mFloat);
+					p.increment(param[i].mDetails.mRange.mDelta.mFloat);
+					p.decimal_digits(3);
+					p.initial_value(param[i].mDefault.mFloat);
+					LLSliderCtrl* slider = LLUICtrlFactory::create<LLSliderCtrl>(p);
+					slider->setCommitCallback(onPhysicsParamCommit, (void*) &param[i]);
+					mDecompFloater->addChild(slider);
+					cur_y += 30;
+				}
+				else if (param[i].mType == LLCDParam::LLCD_INTEGER)
+				{
+					LLSliderCtrl::Params p;
+					p.name(param[i].mName);
+					p.label(param[i].mName);
+					p.rect(LLRect(left, cur_y, right, cur_y-20));
+					p.min_value(param[i].mDetails.mRange.mLow.mIntOrEnumValue);
+					p.max_value(param[i].mDetails.mRange.mHigh.mIntOrEnumValue);
+					p.increment(param[i].mDetails.mRange.mDelta.mIntOrEnumValue);
+					p.initial_value(param[i].mDefault.mIntOrEnumValue);
+					LLSliderCtrl* slider = LLUICtrlFactory::create<LLSliderCtrl>(p);
+					slider->setCommitCallback(onPhysicsParamCommit, (void*) &param[i]);
+					mDecompFloater->addChild(slider);	
+					cur_y += 30;
+				}
+				else if (param[i].mType == LLCDParam::LLCD_BOOLEAN)
+				{
+					LLCheckBoxCtrl::Params p;
+					p.rect(LLRect(left, cur_y, right, cur_y-20));
+					p.name(param[i].mName);
+					p.label(param[i].mName);
+					p.initial_value(param[i].mDefault.mBool);
+					LLCheckBoxCtrl* check_box = LLUICtrlFactory::create<LLCheckBoxCtrl>(p);
+					check_box->setCommitCallback(onPhysicsParamCommit, (void*) &param[i]);
+					mDecompFloater->addChild(check_box);
+					cur_y += 30;
+				}
+				else if (param[i].mType == LLCDParam::LLCD_ENUM)
+				{
+					LLComboBox::Params p;
+					p.rect(LLRect(left, cur_y, right/3, cur_y-20));
+					p.name(param[i].mName);
+					p.label(param[i].mName);
+					LLComboBox* combo_box = LLUICtrlFactory::create<LLComboBox>(p);
+					for (S32 k = 0; k < param[i].mDetails.mEnumValues.mNumEnums; ++k)
+					{
+						combo_box->add(param[i].mDetails.mEnumValues.mEnumsArray[k].mName, 
+							LLSD::Integer(param[i].mDetails.mEnumValues.mEnumsArray[k].mValue));
+					}
+					combo_box->setValue(param[i].mDefault.mIntOrEnumValue);
+					combo_box->setCommitCallback(onPhysicsParamCommit, (void*) &param[i]);
+					mDecompFloater->addChild(combo_box);
+					cur_y += 30;
+				}
+			}
+		}
+
+		//mesh render checkbox
+		{
+			LLCheckBoxCtrl::Params p;
+			p.label("Mesh: ");
+			p.name("render_mesh");
+			p.rect(LLRect(left, cur_y, right/4, cur_y-20));
+			LLCheckBoxCtrl* check = LLUICtrlFactory::create<LLCheckBoxCtrl>(p);
+			check->setValue(true);
+			mDecompFloater->addChild(check);
+		}
+
+		//hull render checkbox
+		{
+			LLCheckBoxCtrl::Params p;
+			p.label("Hull: ");
+			p.name("render_hull");
+			p.rect(LLRect(right/4, cur_y, right/2, cur_y-20));
+			LLCheckBoxCtrl* check = LLUICtrlFactory::create<LLCheckBoxCtrl>(p);
+			check->setValue(true);
+			mDecompFloater->addChild(check);
+		}
+
+		{ //submesh combo box label
+			LLTextBox::Params p;
+			p.label("Model");
+			p.name("model label");
+			p.rect(LLRect(right/3, cur_y, right/2, cur_y-20));
+			LLTextBox* text_box = LLUICtrlFactory::create<LLTextBox>(p);
+			text_box->setValue("Model");
+			mDecompFloater->addChild(text_box);
+		}
+		{
+			//add submesh combo box
+			LLComboBox::Params p;
+			p.rect(LLRect(right/2, cur_y, right, cur_y-20));
+			p.name("model");
+			LLComboBox* combo_box = LLUICtrlFactory::create<LLComboBox>(p);
+			for (S32 i = 0; i < mModelPreview->mBaseModel.size(); ++i)
+			{
+				LLModel* mdl = mModelPreview->mBaseModel[i];
+				combo_box->add(mdl->mLabel, i);
+			}
+			combo_box->setValue(0);
+			mDecompFloater->addChild(combo_box);
+			cur_y += 30;
+		}
+
+		mDecompFloater->childSetCommitCallback("model", LLFloaterModelPreview::refresh, LLFloaterModelPreview::sInstance);
+		mDecompFloater->childSetCommitCallback("render_mesh", LLFloaterModelPreview::refresh, LLFloaterModelPreview::sInstance);
+		mDecompFloater->childSetCommitCallback("render_hull", LLFloaterModelPreview::refresh, LLFloaterModelPreview::sInstance);
+
+		mDecompFloater->setRect(LLRect(10, cur_y+20, right+20, 10)); 
+	}
+
+	mDecompFloater->openFloater();
+}
+
+//-----------------------------------------------------------------------------
+// onMouseCaptureLost()
+//-----------------------------------------------------------------------------
+// static
+void LLFloaterModelPreview::onMouseCaptureLostModelPreview(LLMouseHandler* handler)
+{
+	gViewerWindow->showCursor();
+}
+
+//-----------------------------------------------------------------------------
+// LLModelLoader
+//-----------------------------------------------------------------------------
+LLModelLoader::LLModelLoader(std::string filename, S32 lod, LLModelPreview* preview)
+: LLThread("Model Loader"), mFilename(filename), mLod(lod), mPreview(preview), mState(STARTING), mFirstTransform(TRUE)
+{
+	mJointMap["mPelvis"] = "mPelvis";
+	mJointMap["mTorso"] = "mTorso";
+	mJointMap["mChest"] = "mChest";
+	mJointMap["mNeck"] = "mNeck";
+	mJointMap["mHead"] = "mHead";
+	mJointMap["mSkull"] = "mSkull";
+	mJointMap["mEyeRight"] = "mEyeRight";
+	mJointMap["mEyeLeft"] = "mEyeLeft";
+	mJointMap["mCollarLeft"] = "mCollarLeft";
+	mJointMap["mShoulderLeft"] = "mShoulderLeft";
+	mJointMap["mElbowLeft"] = "mElbowLeft";
+	mJointMap["mWristLeft"] = "mWristLeft";
+	mJointMap["mCollarRight"] = "mCollarRight";
+	mJointMap["mShoulderRight"] = "mShoulderRight";
+	mJointMap["mElbowRight"] = "mElbowRight";
+	mJointMap["mWristRight"] = "mWristRight";
+	mJointMap["mHipRight"] = "mHipRight";
+	mJointMap["mKneeRight"] = "mKneeRight";
+	mJointMap["mAnkleRight"] = "mAnkleRight";
+	mJointMap["mFootRight"] = "mFootRight";
+	mJointMap["mToeRight"] = "mToeRight";
+	mJointMap["mHipLeft"] = "mHipLeft";
+	mJointMap["mKneeLeft"] = "mKneeLeft";
+	mJointMap["mAnkleLeft"] = "mAnkleLeft";
+	mJointMap["mFootLeft"] = "mFootLeft";
+	mJointMap["mToeLeft"] = "mToeLeft";
+
+	mJointMap["avatar_mPelvis"] = "mPelvis";
+	mJointMap["avatar_mTorso"] = "mTorso";
+	mJointMap["avatar_mChest"] = "mChest";
+	mJointMap["avatar_mNeck"] = "mNeck";
+	mJointMap["avatar_mHead"] = "mHead";
+	mJointMap["avatar_mSkull"] = "mSkull";
+	mJointMap["avatar_mEyeRight"] = "mEyeRight";
+	mJointMap["avatar_mEyeLeft"] = "mEyeLeft";
+	mJointMap["avatar_mCollarLeft"] = "mCollarLeft";
+	mJointMap["avatar_mShoulderLeft"] = "mShoulderLeft";
+	mJointMap["avatar_mElbowLeft"] = "mElbowLeft";
+	mJointMap["avatar_mWristLeft"] = "mWristLeft";
+	mJointMap["avatar_mCollarRight"] = "mCollarRight";
+	mJointMap["avatar_mShoulderRight"] = "mShoulderRight";
+	mJointMap["avatar_mElbowRight"] = "mElbowRight";
+	mJointMap["avatar_mWristRight"] = "mWristRight";
+	mJointMap["avatar_mHipRight"] = "mHipRight";
+	mJointMap["avatar_mKneeRight"] = "mKneeRight";
+	mJointMap["avatar_mAnkleRight"] = "mAnkleRight";
+	mJointMap["avatar_mFootRight"] = "mFootRight";
+	mJointMap["avatar_mToeRight"] = "mToeRight";
+	mJointMap["avatar_mHipLeft"] = "mHipLeft";
+	mJointMap["avatar_mKneeLeft"] = "mKneeLeft";
+	mJointMap["avatar_mAnkleLeft"] = "mAnkleLeft";
+	mJointMap["avatar_mFootLeft"] = "mFootLeft";
+	mJointMap["avatar_mToeLeft"] = "mToeLeft";
+
+
+	mJointMap["hip"] = "mPelvis";
+	mJointMap["abdomen"] = "mTorso";
+	mJointMap["chest"] = "mChest";
+	mJointMap["neck"] = "mNeck";
+	mJointMap["head"] = "mHead";
+	mJointMap["figureHair"] = "mSkull";
+	mJointMap["lCollar"] = "mCollarLeft";
+	mJointMap["lShldr"] = "mShoulderLeft";
+	mJointMap["lForeArm"] = "mElbowLeft";
+	mJointMap["lHand"] = "mWristLeft";
+	mJointMap["rCollar"] = "mCollarRight";
+	mJointMap["rShldr"] = "mShoulderRight";
+	mJointMap["rForeArm"] = "mElbowRight";
+	mJointMap["rHand"] = "mWristRight";
+	mJointMap["rThigh"] = "mHipRight";
+	mJointMap["rShin"] = "mKneeRight";
+	mJointMap["rFoot"] = "mFootRight";
+	mJointMap["lThigh"] = "mHipLeft";
+	mJointMap["lShin"] = "mKneeLeft";
+	mJointMap["lFoot"] = "mFootLeft";
+}
+
+void stretch_extents(LLModel* model, LLMatrix4a& mat, LLVector4a& min, LLVector4a& max, BOOL& first_transform)
+{
+	LLVector4a box[] = 
+	{
+		LLVector4a(-1, 1,-1),
+		LLVector4a(-1, 1, 1),
+		LLVector4a(-1,-1,-1),
+		LLVector4a(-1,-1, 1),
+		LLVector4a( 1, 1,-1),
+		LLVector4a( 1, 1, 1),
+		LLVector4a( 1,-1,-1),
+		LLVector4a( 1,-1, 1),
+	};
+
+	for (S32 j = 0; j < model->getNumVolumeFaces(); ++j)
+	{
+		const LLVolumeFace& face = model->getVolumeFace(j);
+		
+		LLVector4a center;
+		center.setAdd(face.mExtents[0], face.mExtents[1]);
+		center.mul(0.5f);
+		LLVector4a size;
+		size.setSub(face.mExtents[1],face.mExtents[0]);
+		size.mul(0.5f);
+
+		for (U32 i = 0; i < 8; i++)
+		{
+			LLVector4a t;
+			t.setMul(size, box[i]);
+			t.add(center);
+
+			LLVector4a v;
+
+			mat.affineTransform(t, v);								
+			
+			if (first_transform)
+			{
+				first_transform = FALSE;
+				min = max = v;
+			}
+			else
+			{
+				update_min_max(min, max, v);
+			}
+		}
+	}
+}
+
+void stretch_extents(LLModel* model, LLMatrix4& mat, LLVector3& min, LLVector3& max, BOOL& first_transform)
+{
+	LLVector4a mina, maxa;
+	LLMatrix4a mata;
+
+	mata.loadu(mat);
+	mina.load3(min.mV);
+	maxa.load3(max.mV);
+
+	stretch_extents(model, mata, mina, maxa, first_transform);
+	
+	min.set(mina.getF32ptr());
+	max.set(maxa.getF32ptr());
+}
+
+void LLModelLoader::run()
+{
+	DAE dae;
+	domCOLLADA* dom = dae.open(mFilename);
+
+	if (dom)
+	{
+		daeDatabase* db = dae.getDatabase();
+
+		daeInt count = db->getElementCount(NULL, COLLADA_TYPE_MESH);
+
+		daeDocument* doc = dae.getDoc(mFilename);
+		if (!doc)
+		{
+			llwarns << "can't find internal doc" << llendl;
+			return;
+		}
+
+		daeElement* root = doc->getDomRoot();
+		if (!root)
+		{
+			llwarns << "document has no root" << llendl;
+			return;
+		}
+
+		//get unit scale
+		mTransform.setIdentity();
+
+		domAsset::domUnit* unit = daeSafeCast<domAsset::domUnit>(root->getDescendant(daeElement::matchType(domAsset::domUnit::ID())));
+
+		if (unit)
+		{
+			F32 meter = unit->getMeter();
+			mTransform.mMatrix[0][0] = meter;
+			mTransform.mMatrix[1][1] = meter;
+			mTransform.mMatrix[2][2] = meter;
+		}
+
+		//get up axis rotation
+		LLMatrix4 rotation;
+
+		domUpAxisType up = UPAXISTYPE_Y_UP;  // default is Y_UP
+		domAsset::domUp_axis* up_axis =
+			daeSafeCast<domAsset::domUp_axis>(root->getDescendant(daeElement::matchType(domAsset::domUp_axis::ID())));
+
+		if (up_axis)
+		{
+			up = up_axis->getValue();
+		}
+		
+		if (up == UPAXISTYPE_X_UP)
+		{
+			rotation.initRotation(0.0f, 90.0f * DEG_TO_RAD, 0.0f);
+		}
+		else if (up == UPAXISTYPE_Y_UP)
+		{
+			rotation.initRotation(90.0f * DEG_TO_RAD, 0.0f, 0.0f);
+		}
+
+		rotation *= mTransform;
+		mTransform = rotation;
+
+
+		for (daeInt idx = 0; idx < count; ++idx)
+		{ //build map of domEntities to LLModel
+			domMesh* mesh = NULL;
+			db->getElement((daeElement**) &mesh, idx, NULL, COLLADA_TYPE_MESH);
+
+			if (mesh)
+			{
+				LLPointer<LLModel> model = LLModel::loadModelFromDomMesh(mesh);
+
+				if (model.notNull() && validate_model(model))
+				{
+					mModelList.push_back(model);
+					mModel[mesh] = model;
+				}
+			}
+		}
+
+		count = db->getElementCount(NULL, COLLADA_TYPE_SKIN);
+		for (daeInt idx = 0; idx < count; ++idx)
+		{ //add skinned meshes as instances
+			domSkin* skin = NULL;
+			db->getElement((daeElement**) &skin, idx, NULL, COLLADA_TYPE_SKIN);
+
+			if (skin)
+			{	
+				domGeometry* geom = daeSafeCast<domGeometry>(skin->getSource().getElement());
+				
+				if (geom)
+				{
+					domMesh* mesh = geom->getMesh();
+					if (mesh)
+					{
+						LLModel* model = mModel[mesh];
+						if (model)
+						{
+							LLVector3 mesh_scale_vector;
+							LLVector3 mesh_translation_vector;
+							model->getNormalizedScaleTranslation(mesh_scale_vector, mesh_translation_vector);
+
+							LLMatrix4 normalized_transformation;
+							normalized_transformation.setTranslation(mesh_translation_vector);
+							
+							LLMatrix4 mesh_scale;
+							mesh_scale.initScale(mesh_scale_vector);
+							mesh_scale *= normalized_transformation;
+							normalized_transformation = mesh_scale;
+
+							glh::matrix4f inv_mat((F32*) normalized_transformation.mMatrix);
+							inv_mat = inv_mat.inverse();
+							LLMatrix4 inverse_normalized_transformation(inv_mat.m);							
+
+							domSkin::domBind_shape_matrix* bind_mat = skin->getBind_shape_matrix();
+
+							if (bind_mat)
+							{ //get bind shape matrix
+								domFloat4x4& dom_value = bind_mat->getValue();
+								
+								for (int i = 0; i < 4; i++)
+								{
+									for(int j = 0; j < 4; j++)
+									{
+										model->mBindShapeMatrix.mMatrix[i][j] = dom_value[i + j*4];
+									}
+								}
+
+								LLMatrix4 trans = normalized_transformation;
+								trans *= model->mBindShapeMatrix;
+								model->mBindShapeMatrix = trans;
+
+							}
+
+							/*{
+								LLMatrix4 rotation;
+								if (up == UPAXISTYPE_X_UP)
+								{
+									rotation.initRotation(0.0f, 90.0f * DEG_TO_RAD, 0.0f);
+								}
+								else if (up == UPAXISTYPE_Z_UP)
+								{
+									rotation.initRotation(90.0f * DEG_TO_RAD, 90.0f * DEG_TO_RAD, 0.0f);
+								}
+
+								rotation *= model->mBindShapeMatrix;
+								model->mBindShapeMatrix = rotation;
+							}*/
+
+							
+							domSkin::domJoints* joints = skin->getJoints();
+
+							domInputLocal_Array& joint_input = joints->getInput_array();
+
+							for (size_t i = 0; i < joint_input.getCount(); ++i)
+							{
+								domInputLocal* input = joint_input.get(i);
+								xsNMTOKEN semantic = input->getSemantic();
+
+								if (strcmp(semantic, COMMON_PROFILE_INPUT_JOINT) == 0)
+								{ //found joint source, fill model->mJointMap and model->mJointList
+									daeElement* elem = input->getSource().getElement();
+									
+									domSource* source = daeSafeCast<domSource>(elem);
+									if (source)
+									{ 
+										
+
+										domName_array* names_source = source->getName_array();
+										
+										if (names_source)
+										{
+											domListOfNames &names = names_source->getValue();					
+
+											for (size_t j = 0; j < names.getCount(); ++j)
+											{
+												std::string name(names.get(j));
+												if (mJointMap.find(name) != mJointMap.end())
+												{
+													name = mJointMap[name];
+												}
+												model->mJointList.push_back(name);
+												model->mJointMap[name] = j;
+											}	
+										}
+										else
+										{
+											domIDREF_array* names_source = source->getIDREF_array();
+											if (names_source)
+											{
+												xsIDREFS& names = names_source->getValue();
+
+												for (size_t j = 0; j < names.getCount(); ++j)
+												{
+													std::string name(names.get(j).getID());
+													if (mJointMap.find(name) != mJointMap.end())
+													{
+														name = mJointMap[name];
+													}
+													model->mJointList.push_back(name);
+													model->mJointMap[name] = j;
+												}
+											}
+										}
+									}
+								}
+								else if (strcmp(semantic, COMMON_PROFILE_INPUT_INV_BIND_MATRIX) == 0)
+								{ //found inv_bind_matrix array, fill model->mInvBindMatrix
+									domSource* source = daeSafeCast<domSource>(input->getSource().getElement());
+									if (source)
+									{
+										domFloat_array* t = source->getFloat_array();
+										if (t)
+										{
+											domListOfFloats& transform = t->getValue();
+											S32 count = transform.getCount()/16;
+
+											for (S32 k = 0; k < count; ++k)
+											{
+												LLMatrix4 mat;
+
+												for (int i = 0; i < 4; i++)
+												{
+													for(int j = 0; j < 4; j++)
+													{
+														mat.mMatrix[i][j] = transform[k*16 + i + j*4];
+													}
+												}
+
+												model->mInvBindMatrix.push_back(mat);
+											}
+										}
+									}
+								}
+							}
+
+							
+							//grab raw position array
+							
+							domVertices* verts = mesh->getVertices();
+							if (verts)
+							{
+								domInputLocal_Array& inputs = verts->getInput_array();
+								for (size_t i = 0; i < inputs.getCount() && model->mPosition.empty(); ++i)
+								{
+									if (strcmp(inputs[i]->getSemantic(), COMMON_PROFILE_INPUT_POSITION) == 0)
+									{
+										domSource* pos_source = daeSafeCast<domSource>(inputs[i]->getSource().getElement());
+										if (pos_source)
+										{
+											domFloat_array* pos_array = pos_source->getFloat_array();
+											if (pos_array)
+											{
+												domListOfFloats& pos = pos_array->getValue();
+												
+												for (size_t j = 0; j < pos.getCount(); j += 3)
+												{
+													if (pos.getCount() <= j+2)
+													{
+														llerrs << "WTF?" << llendl;
+													}
+													
+													LLVector3 v(pos[j], pos[j+1], pos[j+2]);
+
+													//transform from COLLADA space to volume space
+													v = v * inverse_normalized_transformation;
+
+													model->mPosition.push_back(v);
+												}
+											}
+										}
+									}
+								}
+							}
+
+							//grab skin weights array
+							domSkin::domVertex_weights* weights = skin->getVertex_weights();
+							if (weights)
+							{
+								domInputLocalOffset_Array& inputs = weights->getInput_array();
+								domFloat_array* vertex_weights = NULL;
+								for (size_t i = 0; i < inputs.getCount(); ++i)
+								{
+									if (strcmp(inputs[i]->getSemantic(), COMMON_PROFILE_INPUT_WEIGHT) == 0)
+									{
+										domSource* weight_source = daeSafeCast<domSource>(inputs[i]->getSource().getElement());
+										if (weight_source)
+										{
+											vertex_weights = weight_source->getFloat_array();
+										}
+									}
+								}
+
+								if (vertex_weights)
+								{
+									domListOfFloats& w = vertex_weights->getValue();
+									domListOfUInts& vcount = weights->getVcount()->getValue();
+									domListOfInts& v = weights->getV()->getValue();
+
+									U32 c_idx = 0;
+									for (size_t vc_idx = 0; vc_idx < vcount.getCount(); ++vc_idx)
+									{ //for each vertex
+										daeUInt count = vcount[vc_idx];
+
+										//create list of weights that influence this vertex
+										LLModel::weight_list weight_list;
+
+										for (daeUInt i = 0; i < count; ++i)
+										{ //for each weight
+											daeInt joint_idx = v[c_idx++];
+											daeInt weight_idx = v[c_idx++];
+
+											if (joint_idx == -1)
+											{
+												//ignore bindings to bind_shape_matrix
+												continue;
+											}
+
+											F32 weight_value = w[weight_idx];
+
+											weight_list.push_back(LLModel::JointWeight(joint_idx, weight_value));	
+										}
+
+										//sort by joint weight
+										std::sort(weight_list.begin(), weight_list.end(), LLModel::CompareWeightGreater());
+
+										std::vector<LLModel::JointWeight> wght;
+										
+										F32 total = 0.f;
+
+										for (U32 i = 0; i < llmin((U32) 4, (U32) weight_list.size()); ++i)
+										{ //take up to 4 most significant weights
+											if (weight_list[i].mWeight > 0.f)
+											{
+												wght.push_back( weight_list[i] );
+												total += weight_list[i].mWeight;
+											}
+										}
+										
+										F32 scale = 1.f/total;
+										if (scale != 1.f)
+										{ //normalize weights
+											for (U32 i = 0; i < wght.size(); ++i)
+											{ 
+												wght[i].mWeight *= scale;
+											}
+										}
+
+										model->mSkinWeights[model->mPosition[vc_idx]] = wght;
+									}
+									
+									//add instance to scene for this model
+									
+									LLMatrix4 transform;
+									std::vector<LLImportMaterial> materials;
+									materials.resize(model->getNumVolumeFaces());
+									mScene[transform].push_back(LLModelInstance(model, transform, materials));
+									stretch_extents(model, transform, mExtents[0], mExtents[1], mFirstTransform);
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+
+		daeElement* scene = root->getDescendant("visual_scene");
+		if (!scene)
+		{
+			llwarns << "document has no visual_scene" << llendl;
+			return;
+		}
+
+		processElement(scene);
+
+		mPreview->loadModelCallback(mLod);
+	}
+}
+
+void LLModelLoader::processElement(daeElement* element)
+{
+	LLMatrix4 saved_transform = mTransform;
+
+	domTranslate* translate = daeSafeCast<domTranslate>(element);
+	if (translate)
+	{
+		domFloat3 dom_value = translate->getValue();
+
+		LLMatrix4 translation;
+		translation.setTranslation(LLVector3(dom_value[0], dom_value[1], dom_value[2]));
+		
+		translation *= mTransform;
+		mTransform = translation;
+	}
+
+	domRotate* rotate = daeSafeCast<domRotate>(element);
+	if (rotate)
+	{
+		domFloat4 dom_value = rotate->getValue();
+
+		LLMatrix4 rotation;
+		rotation.initRotTrans(dom_value[3] * DEG_TO_RAD, LLVector3(dom_value[0], dom_value[1], dom_value[2]), LLVector3(0, 0, 0));
+
+		rotation *= mTransform;
+		mTransform = rotation;
+	}
+
+	domScale* scale = daeSafeCast<domScale>(element);
+	if (scale)
+	{
+		domFloat3 dom_value = scale->getValue();
+
+		LLMatrix4 scaling;
+		scaling.initScale(LLVector3(dom_value[0], dom_value[1], dom_value[2]));
+
+		scaling *= mTransform;
+		mTransform = scaling;
+	}
+
+	domMatrix* matrix = daeSafeCast<domMatrix>(element);
+	if (matrix)
+	{
+		domFloat4x4 dom_value = matrix->getValue();
+
+		LLMatrix4 matrix_transform;
+
+		for (int i = 0; i < 4; i++)
+		{
+			for(int j = 0; j < 4; j++)
+			{
+				matrix_transform.mMatrix[i][j] = dom_value[i + j*4];
+			}
+		}
+		
+		matrix_transform *= mTransform;
+		mTransform = matrix_transform;
+	}
+
+	domInstance_geometry* instance_geo = daeSafeCast<domInstance_geometry>(element);
+	if (instance_geo)
+	{
+		domGeometry* geo = daeSafeCast<domGeometry>(instance_geo->getUrl().getElement());
+		if (geo)
+		{
+			domMesh* mesh = daeSafeCast<domMesh>(geo->getDescendant(daeElement::matchType(domMesh::ID())));
+			if (mesh)
+			{
+				LLModel* model = mModel[mesh];
+				if (model)
+				{
+					LLMatrix4 transformation = mTransform;
+
+					std::vector<LLImportMaterial> materials = getMaterials(model, instance_geo);
+
+					// adjust the transformation to compensate for mesh normalization
+					LLVector3 mesh_scale_vector;
+					LLVector3 mesh_translation_vector;
+					model->getNormalizedScaleTranslation(mesh_scale_vector, mesh_translation_vector);
+
+					LLMatrix4 mesh_translation;
+					mesh_translation.setTranslation(mesh_translation_vector);
+					mesh_translation *= transformation;
+					transformation = mesh_translation;
+					
+					LLMatrix4 mesh_scale;
+					mesh_scale.initScale(mesh_scale_vector);
+					mesh_scale *= transformation;
+					transformation = mesh_scale;
+					
+					mScene[transformation].push_back(LLModelInstance(model, transformation, materials));
+
+					stretch_extents(model, transformation, mExtents[0], mExtents[1], mFirstTransform);			
+				}
+			}
+		}
+	}
+
+	domInstance_node* instance_node = daeSafeCast<domInstance_node>(element);
+	if (instance_node)
+	{
+		daeElement* instance = instance_node->getUrl().getElement();
+		if (instance)
+		{
+			processElement(instance);
+		}
+	}
+
+	//process children
+	daeTArray< daeSmartRef<daeElement> > children = element->getChildren();
+	for (S32 i = 0; i < children.getCount(); i++)
+	{
+		processElement(children[i]);
+	}
+
+	domNode* node = daeSafeCast<domNode>(element);
+	if (node)
+	{ //this element was a node, restore transform before processiing siblings
+		mTransform = saved_transform;	
+	}
+}
+
+std::vector<LLImportMaterial> LLModelLoader::getMaterials(LLModel* model, domInstance_geometry* instance_geo)
+{
+	std::vector<LLImportMaterial> materials;
+	for (int i = 0; i < model->mMaterialList.size(); i++)
+	{
+		LLImportMaterial import_material;
+
+		domInstance_material* instance_mat = NULL;
+
+		domBind_material::domTechnique_common* technique =
+			daeSafeCast<domBind_material::domTechnique_common>(instance_geo->getDescendant(daeElement::matchType(domBind_material::domTechnique_common::ID())));
+
+		if (technique)
+		{
+			daeTArray< daeSmartRef<domInstance_material> > inst_materials = technique->getChildrenByType<domInstance_material>();
+			for (int j = 0; j < inst_materials.getCount(); j++)
+			{
+				std::string symbol(inst_materials[j]->getSymbol());
+
+				if (symbol == model->mMaterialList[i]) // found the binding
+				{
+					instance_mat = inst_materials[j];
+				}
+			}
+		}
+
+		if (instance_mat)
+		{
+			domMaterial* material = daeSafeCast<domMaterial>(instance_mat->getTarget().getElement());
+			if (material)
+			{
+				domInstance_effect* instance_effect =
+					daeSafeCast<domInstance_effect>(material->getDescendant(daeElement::matchType(domInstance_effect::ID())));
+				if (instance_effect)
+				{
+					domEffect* effect = daeSafeCast<domEffect>(instance_effect->getUrl().getElement());
+					if (effect)
+					{
+						domProfile_COMMON* profile =
+							daeSafeCast<domProfile_COMMON>(effect->getDescendant(daeElement::matchType(domProfile_COMMON::ID())));
+						if (profile)
+						{
+							import_material = profileToMaterial(profile);
+						}
+					}
+				}
+			}
+		}
+		
+		materials.push_back(import_material);
+	}
+
+	return materials;
+}
+
+LLImportMaterial LLModelLoader::profileToMaterial(domProfile_COMMON* material)
+{
+	LLImportMaterial mat;
+	mat.mFullbright = FALSE;
+
+	daeElement* diffuse = material->getDescendant("diffuse");
+	if (diffuse)
+	{
+		domCommon_color_or_texture_type_complexType::domTexture* texture =
+			daeSafeCast<domCommon_color_or_texture_type_complexType::domTexture>(diffuse->getDescendant("texture"));
+		if (texture)
+		{
+			domCommon_newparam_type_Array newparams = material->getNewparam_array();
+			for (S32 i = 0; i < newparams.getCount(); i++)
+			{
+				domFx_surface_common* surface = newparams[i]->getSurface();
+				if (surface)
+				{
+					domFx_surface_init_common* init = surface->getFx_surface_init_common();
+					if (init)
+					{
+						domFx_surface_init_from_common_Array init_from = init->getInit_from_array();
+						
+						if (init_from.getCount() > i)
+						{
+							domImage* image = daeSafeCast<domImage>(init_from[i]->getValue().getElement());
+							if (image)
+							{
+								// we only support init_from now - embedded data will come later
+								domImage::domInit_from* init = image->getInit_from();
+								if (init)
+								{
+									std::string filename = cdom::uriToNativePath(init->getValue().str());
+																					
+									mat.mDiffuseMap = LLViewerTextureManager::getFetchedTextureFromUrl("file://" + filename, TRUE, LLViewerTexture::BOOST_PREVIEW);
+									mat.mDiffuseMap->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, TRUE, FALSE, this->mPreview, NULL, NULL);
+
+									mat.mDiffuseMap->forceToSaveRawImage();
+									mat.mDiffuseMapFilename = filename;
+									mat.mDiffuseMapLabel = getElementLabel(material);
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		
+		domCommon_color_or_texture_type_complexType::domColor* color =
+			daeSafeCast<domCommon_color_or_texture_type_complexType::domColor>(diffuse->getDescendant("color"));
+		if (color)
+		{
+			domFx_color_common domfx_color = color->getValue();
+			LLColor4 value = LLColor4(domfx_color[0], domfx_color[1], domfx_color[2], domfx_color[3]);
+			mat.mDiffuseColor = value;
+		}
+	}
+
+	daeElement* emission = material->getDescendant("emission");
+	if (emission)
+	{
+		LLColor4 emission_color = getDaeColor(emission);
+		if (((emission_color[0] + emission_color[1] + emission_color[2]) / 3.0) > 0.25)
+		{
+			mat.mFullbright = TRUE;
+		}
+	}
+
+	return mat;
+}
+
+// try to get a decent label for this element
+std::string LLModelLoader::getElementLabel(daeElement *element)
+{
+	// if we have a name attribute, use it
+	std::string name = element->getAttribute("name");
+	if (name.length())
+	{
+		return name;
+	}
+
+	// if we have an ID attribute, use it
+	if (element->getID())
+	{
+		return std::string(element->getID());
+	}
+
+	// if we have a parent, use it
+	daeElement* parent = element->getParent();
+	if (parent)
+	{
+		// if parent has a name, use it
+		std::string name = parent->getAttribute("name");
+		if (name.length())
+		{
+			return name;
+		}
+
+		// if parent has an ID, use it
+		if (parent->getID())
+		{
+			return std::string(parent->getID());
+		}
+	}
+
+	// try to use our type
+	daeString element_name = element->getElementName();
+	if (element_name)
+	{
+		return std::string(element_name);
+	}
+
+	// if all else fails, use "object"
+	return std::string("object");
+}
+
+LLColor4 LLModelLoader::getDaeColor(daeElement* element)
+{
+	LLColor4 value;
+	domCommon_color_or_texture_type_complexType::domColor* color =
+		daeSafeCast<domCommon_color_or_texture_type_complexType::domColor>(element->getDescendant("color"));
+	if (color)
+	{
+		domFx_color_common domfx_color = color->getValue();
+		value = LLColor4(domfx_color[0], domfx_color[1], domfx_color[2], domfx_color[3]);
+	}
+
+	return value;
+}
+
+//-----------------------------------------------------------------------------
+// LLModelPreview
+//-----------------------------------------------------------------------------
+
+LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloaterModelPreview* fmp) 
+: LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE), LLMutex(NULL)
+{
+	mNeedsUpdate = TRUE;
+	mCameraDistance = 0.f;
+	mCameraYaw = 0.f;
+	mCameraPitch = 0.f;
+	mCameraZoom = 1.f;
+	mTextureName = 0;
+	mPreviewLOD = 3;
+	mModelLoader = NULL;
+
+	mLODMode[0] = 0;
+
+	for (U32 i = 1; i < LLModel::NUM_LODS; i++)
+	{
+		mLODMode[i] = 1;
+		mLimit[i] = 0;
+	}
+
+	mFMP = fmp;
+
+	glodInit();
+}
+
+LLModelPreview::~LLModelPreview()
+{
+	if (mModelLoader)
+	{
+		delete mModelLoader;
+		mModelLoader = NULL;
+	}
+
+	//*HACK : *TODO : turn this back on when we understand why this crashes
+	//glodShutdown();
+}
+
+U32 LLModelPreview::calcResourceCost()
+{
+	rebuildUploadData();
+
+	U32 cost = 0;
+	std::set<LLModel*> accounted;
+	U32 num_points = 0;
+	U32 num_hulls = 0;
+
+	for (U32 i = 0; i < mUploadData.size(); ++i)
+	{
+		LLModelInstance& instance = mUploadData[i];
+
+		if (accounted.find(instance.mModel) == accounted.end())
+		{
+			accounted.insert(instance.mModel);
+
+			LLModel::physics_shape& physics_shape = instance.mLOD[LLModel::LOD_PHYSICS] ? instance.mLOD[LLModel::LOD_PHYSICS]->mPhysicsShape : instance.mModel->mPhysicsShape;
+
+			LLSD ret = LLModel::writeModel("",  
+									instance.mLOD[4], 
+									instance.mLOD[3], 
+									instance.mLOD[2], 
+									instance.mLOD[1], 
+									instance.mLOD[0],
+									physics_shape,
+									TRUE);
+			cost += gMeshRepo.calcResourceCost(ret);
+
+			
+			num_hulls += physics_shape.size();
+			for (U32 i = 0; i < physics_shape.size(); ++i)
+			{
+				num_points += physics_shape[i].size();
+			}
+		}
+	}
+
+	mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[HULLS]", llformat("%d",num_hulls));
+	mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[POINTS]", llformat("%d",num_points));				
+
+	updateStatusMessages();
+
+	return cost;
+}
+
+void LLModelPreview::rebuildUploadData()
+{
+	mUploadData.clear();
+	mTextureSet.clear();
+
+	//fill uploaddata instance vectors from scene data
+
+	for (LLModelLoader::scene::iterator iter = mBaseScene.begin(); iter != mBaseScene.end(); ++iter)
+	{ //for each transform in scene
+		for (LLModelLoader::model_instance_list::iterator model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter)
+		{ //for each instance with said transform applied
+			LLModelInstance& instance = *model_iter;
+
+			LLModel* base_model = instance.mModel;
+
+			S32 idx = 0;
+			for (idx = 0; idx < mBaseModel.size(); ++idx)
+			{  //find reference instance for this model
+				if (mBaseModel[idx] == base_model)
+				{
+					break;
+				}
+			}
+
+			for (U32 i = 0; i < LLModel::NUM_LODS; i++)
+			{ //fill LOD slots based on reference model index
+				if (!mModel[i].empty())
+				{
+					instance.mLOD[i] = mModel[i][idx];
+				}
+				else
+				{
+					instance.mLOD[i] = NULL;
+				}
+			}
+
+			mUploadData.push_back(instance);
+		}
+	}
+}
+
+
+void LLModelPreview::loadModel(std::string filename, S32 lod)
+{
+	LLMutexLock lock(this);
+	
+	if (mModelLoader)
+	{
+		delete mModelLoader;
+		mModelLoader = NULL;
+	}
+
+	if (filename.empty() && mBaseModel.empty())
+	{
+		mFMP->closeFloater(false);
+		return;
+	}
+
+	if (lod == 3 && !mGroup.empty())
+	{
+		for (std::map<LLModel*, U32>::iterator iter = mGroup.begin(); iter != mGroup.end(); ++iter)
+		{
+			glodDeleteGroup(iter->second);
+			stop_gloderror();
+		}
+
+		for (std::map<LLModel*, U32>::iterator iter = mObject.begin(); iter != mObject.end(); ++iter)
+		{
+			glodDeleteObject(iter->second);
+			stop_gloderror();
+		}
+
+		mGroup.clear();
+		mObject.clear();
+	}
+
+	mModelLoader = new LLModelLoader(filename, lod, this);
+
+	mModelLoader->start();
+
+	mFMP->childSetTextArg("status", "[STATUS]", mFMP->getString("status_reading_file"));
+
+	if (mFMP->childGetValue("description_form").asString().empty())
+	{
+		std::string name = gDirUtilp->getBaseFileName(filename, true);
+		mFMP->childSetValue("description_form", name);
+	}
+
+	mFMP->openFloater();
+}
+
+void LLModelPreview::clearIncompatible(S32 lod)
+{
+	for (U32 i = 0; i <= LLModel::LOD_HIGH; i++)
+	{ //clear out any entries that aren't compatible with this model
+		if (i != lod)
+		{
+			if (mModel[i].size() != mModel[lod].size())
+			{
+				mModel[i].clear();
+				mScene[i].clear();
+				mVertexBuffer[i].clear();
+
+				if (i == LLModel::LOD_HIGH)
+				{
+					mBaseModel = mModel[lod];
+					mBaseScene = mScene[lod];
+					mVertexBuffer[5].clear();
+				}
+			}
+		}
+	}
+}
+
+void LLModelPreview::loadModelCallback(S32 lod)
+{ //NOT the main thread
+	LLMutexLock lock(this);
+	if (!mModelLoader)
+	{
+		return;
+	}
+
+	mModel[lod] = mModelLoader->mModelList;
+	mScene[lod] = mModelLoader->mScene;
+	mVertexBuffer[lod].clear();
+	
+	setPreviewLOD(lod);
+	
+	
+	if (lod == LLModel::LOD_HIGH)
+	{ //save a copy of the highest LOD for automatic LOD manipulation
+		mBaseModel = mModel[lod];
+		mBaseScene = mScene[lod];
+		mVertexBuffer[5].clear();
+		//mModel[lod] = NULL;
+	}
+
+	clearIncompatible(lod);
+
+	mResourceCost = calcResourceCost();
+
+	mPreviewTarget = (mModelLoader->mExtents[0] + mModelLoader->mExtents[1]) * 0.5f;
+	mPreviewScale = (mModelLoader->mExtents[1] - mModelLoader->mExtents[0]) * 0.5f;
+	setPreviewTarget(mPreviewScale.magVec()*2.f);
+
+	mFMP->mLoading = FALSE;
+	refresh();
+}
+
+void LLModelPreview::smoothNormals()
+{
+	S32 which_lod = mPreviewLOD;
+
+
+	if (which_lod > 4 || which_lod < 0 ||
+		mModel[which_lod].empty())
+	{
+		return;
+	}
+
+	F32 angle_cutoff = mFMP->childGetValue("edge threshold").asReal();
+
+	angle_cutoff *= DEG_TO_RAD;
+
+	if (which_lod == 3 && !mBaseModel.empty())
+	{
+		for (LLModelLoader::model_list::iterator iter = mBaseModel.begin(); iter != mBaseModel.end(); ++iter)
+		{
+			(*iter)->smoothNormals(angle_cutoff);
+		}
+
+		mVertexBuffer[5].clear();
+	}
+
+	for (LLModelLoader::model_list::iterator iter = mModel[which_lod].begin(); iter != mModel[which_lod].end(); ++iter)
+	{
+		(*iter)->smoothNormals(angle_cutoff);
+	}
+	
+	mVertexBuffer[which_lod].clear();
+	refresh();
+
+}
+
+void LLModelPreview::consolidate()
+{
+	std::map<LLImportMaterial, std::vector<LLModelInstance> > composite;
+
+	LLMatrix4 identity;
+
+	//bake out each node in current scene to composite
+	for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter)
+	{ //for each transform in current scene
+		LLMatrix4 mat = iter->first;
+		glh::matrix4f inv_trans = glh::matrix4f((F32*) mat.mMatrix).inverse().transpose();
+		LLMatrix4 norm_mat(inv_trans.m);
+
+		for (LLModelLoader::model_instance_list::iterator model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter)
+		{ //for each instance with that transform
+			LLModelInstance& source_instance = *model_iter;
+			LLModel* source = source_instance.mModel;
+			
+			if (!validate_model(source))
+			{
+				llerrs << "Invalid model found!" << llendl;
+			}
+
+			for (S32 i = 0; i < source->getNumVolumeFaces(); ++i)
+			{ //for each face in instance
+				const LLVolumeFace& src_face = source->getVolumeFace(i);
+				LLImportMaterial& source_material = source_instance.mMaterial[i];
+
+				//get model in composite that is composite for this material
+				LLModel* model = NULL;
+
+				if (composite.find(source_material) != composite.end())
+				{
+					model = composite[source_material].rbegin()->mModel;
+					if (model->getVolumeFace(0).mNumVertices + src_face.mNumVertices > 65535)
+					{
+						model = NULL;
+					}
+				}
+
+				if (model == NULL)
+				{  //no model found, make new model
+					std::vector<LLImportMaterial> materials;
+					materials.push_back(source_material);
+					LLVolumeParams volume_params;
+					volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+					model = new LLModel(volume_params, 0.f);
+					model->mLabel = source->mLabel;
+					model->setNumVolumeFaces(0);
+					composite[source_material].push_back(LLModelInstance(model, identity, materials));
+				}
+			
+				model->appendFace(src_face, source->mMaterialList[i], mat, norm_mat);
+			}
+		}
+	}
+
+
+	//condense composite into as few LLModel instances as possible
+	LLModelLoader::model_list new_model;
+	std::vector<LLModelInstance> instance_list;
+	
+	LLVolumeParams volume_params;
+	volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+
+	std::vector<LLImportMaterial> empty_material;
+	LLModelInstance cur_instance(new LLModel(volume_params, 0.f), identity, empty_material);
+	cur_instance.mModel->setNumVolumeFaces(0);
+
+	BOOL first_transform = TRUE;
+
+	LLModelLoader::scene new_scene;
+	LLVector3 min,max;
+
+	for (std::map<LLImportMaterial, std::vector<LLModelInstance> >::iterator iter = composite.begin();
+			iter != composite.end();
+			++iter)
+	{
+		std::map<LLImportMaterial, std::vector<LLModelInstance> >::iterator next_iter = iter; ++next_iter;
+		
+		for (std::vector<LLModelInstance>::iterator instance_iter = iter->second.begin(); 
+				instance_iter != iter->second.end();
+				++instance_iter)
+		{
+			LLModel* source = instance_iter->mModel;
+
+			if (instance_iter->mMaterial.size() != 1)
+			{
+				llerrs << "WTF?" << llendl;
+			}
+
+			if (source->getNumVolumeFaces() != 1)
+			{
+				llerrs << "WTF?" << llendl;
+			}
+
+			if (source->mMaterialList.size() != 1)
+			{
+				llerrs << "WTF?" << llendl;
+			}
+
+			cur_instance.mModel->addFace(source->getVolumeFace(0));
+			cur_instance.mMaterial.push_back(instance_iter->mMaterial[0]);
+			cur_instance.mModel->mMaterialList.push_back(source->mMaterialList[0]);
+
+			BOOL last_model = FALSE;
+		
+			std::vector<LLModelInstance>::iterator next_instance = instance_iter; ++next_instance;
+
+			if (next_iter == composite.end() &&
+				next_instance == iter->second.end())
+			{
+				last_model = TRUE;
+			}
+
+			if (last_model || cur_instance.mModel->getNumVolumeFaces() >= MAX_MODEL_FACES)
+			{
+				cur_instance.mModel->mLabel = source->mLabel;
+
+				cur_instance.mModel->optimizeVolumeFaces();
+				cur_instance.mModel->normalizeVolumeFaces();
+
+				if (!validate_model(cur_instance.mModel))
+				{
+					llerrs << "Invalid model detected." << llendl;
+				}
+
+				new_model.push_back(cur_instance.mModel);
+
+				LLMatrix4 transformation = LLMatrix4();
+
+				// adjust the transformation to compensate for mesh normalization
+				LLVector3 mesh_scale_vector;
+				LLVector3 mesh_translation_vector;
+				cur_instance.mModel->getNormalizedScaleTranslation(mesh_scale_vector, mesh_translation_vector);
+
+				LLMatrix4 mesh_translation;
+				mesh_translation.setTranslation(mesh_translation_vector);
+				mesh_translation *= transformation;
+				transformation = mesh_translation;
+				
+				LLMatrix4 mesh_scale;
+				mesh_scale.initScale(mesh_scale_vector);
+				mesh_scale *= transformation;
+				transformation = mesh_scale;
+							
+				cur_instance.mTransform = transformation;
+
+				new_scene[transformation].push_back(cur_instance);
+				stretch_extents(cur_instance.mModel, transformation, min, max, first_transform);
+
+				if (!last_model)
+				{
+					cur_instance = LLModelInstance(new LLModel(volume_params, 0.f), identity, empty_material);
+					cur_instance.mModel->setNumVolumeFaces(0);
+				}
+			}
+		}
+	}
+		
+	mScene[mPreviewLOD] = new_scene;
+	mModel[mPreviewLOD] = new_model;
+	mVertexBuffer[mPreviewLOD].clear();
+
+	if (mPreviewLOD == LLModel::LOD_HIGH)
+	{
+		mBaseScene = new_scene;
+		mBaseModel = new_model;
+		mVertexBuffer[5].clear();
+	}
+
+	mPreviewTarget = (min+max)*0.5f;
+	mPreviewScale = (max-min)*0.5f;
+	setPreviewTarget(mPreviewScale.magVec()*2.f);
+
+	clearIncompatible(mPreviewLOD);
+
+	mResourceCost = calcResourceCost();
+	refresh();
+}
+
+void LLModelPreview::scrubMaterials()
+{
+	for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter)
+	{ //for each transform in current scene
+		for (LLModelLoader::model_instance_list::iterator model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter)
+		{ //for each instance with that transform
+			LLModelInstance& source_instance = *model_iter;
+			LLModel* source = source_instance.mModel;
+			
+			for (S32 i = 0; i < source->getNumVolumeFaces(); ++i)
+			{ //for each face in instance
+				LLImportMaterial& source_material = source_instance.mMaterial[i];
+
+				//clear material info
+				source_material.mDiffuseColor = LLColor4(1,1,1,1);
+				source_material.mDiffuseMap = NULL;
+				source_material.mDiffuseMapFilename.clear();
+				source_material.mDiffuseMapLabel.clear();
+				source_material.mFullbright = false;
+			}
+		}
+	}
+
+
+	mVertexBuffer[mPreviewLOD].clear();
+
+	if (mPreviewLOD == LLModel::LOD_HIGH)
+	{
+		mBaseScene = mScene[mPreviewLOD];
+		mBaseModel = mModel[mPreviewLOD];
+		mVertexBuffer[5].clear();
+	}
+
+	mResourceCost = calcResourceCost();
+	refresh();
+}
+
+void LLModelPreview::genLODs(S32 which_lod)
+{
+	if (mBaseModel.empty())
+	{
+		return;
+	}
+
+	LLVertexBuffer::unbind();
+
+	stop_gloderror();
+	static U32 cur_name = 1;
+
+	S32 limit = -1;
+
+	if (which_lod != -1)
+	{
+		limit = mLimit[which_lod];
+	}
+
+	U32 triangle_count = 0;
+
+	for (LLModelLoader::model_list::iterator iter = mBaseModel.begin(); iter != mBaseModel.end(); ++iter)
+	{
+		LLModel* mdl = *iter;
+		for (S32 i = 0; i < mdl->getNumVolumeFaces(); ++i)
+		{
+			triangle_count += mdl->getVolumeFace(i).mNumIndices/3;
+		}
+	}
+
+	U32 base_triangle_count = triangle_count;
+
+	U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0;
+
+	for (LLModelLoader::model_list::iterator iter = mBaseModel.begin(); iter != mBaseModel.end(); ++iter)
+	{ //build GLOD objects for each model in base model list
+		LLModel* mdl = *iter;
+		if (mGroup[mdl] == 0)
+		{
+			mGroup[mdl] = cur_name++;
+			mObject[mdl] = cur_name++;
+
+			glodNewGroup(mGroup[mdl]);
+			stop_gloderror();
+
+			glodGroupParameteri(mGroup[mdl], GLOD_ADAPT_MODE, GLOD_TRIANGLE_BUDGET);
+			stop_gloderror();		
+
+			glodGroupParameteri(mGroup[mdl], GLOD_ERROR_MODE, GLOD_OBJECT_SPACE_ERROR);
+			stop_gloderror();
+
+			glodGroupParameterf(mGroup[mdl], GLOD_OBJECT_SPACE_ERROR_THRESHOLD, 0.025f);
+			stop_gloderror();
+
+			glodNewObject(mObject[mdl], mGroup[mdl], GLOD_DISCRETE);
+			stop_gloderror();
+
+			if (iter == mBaseModel.begin() && !mdl->mSkinWeights.empty())
+			{ //regenerate vertex buffer for skinned models to prevent animation feedback during LOD generation
+				mVertexBuffer[5].clear();
+			}
+
+			if (mVertexBuffer[5].empty())
+			{
+				genBuffers(5);
+			}
+
+			U32 tri_count = 0;
+			for (U32 i = 0; i < mVertexBuffer[5][mdl].size(); ++i)
+			{
+				mVertexBuffer[5][mdl][i]->setBuffer(type_mask);
+				U32 num_indices = mVertexBuffer[5][mdl][i]->getNumIndices();
+				if (num_indices > 2)
+				{
+					glodInsertElements(mObject[mdl], i, GL_TRIANGLES, num_indices, GL_UNSIGNED_SHORT, mVertexBuffer[5][mdl][i]->getIndicesPointer(), 0, 0.f);
+				}
+				tri_count += num_indices/3;
+				stop_gloderror();
+			}
+
+			//store what percentage of total model (in terms of triangle count) this model makes up
+			mPercentage[mdl] = (F32) tri_count / (F32) base_triangle_count;
+
+			//build glodobject
+			glodBuildObject(mObject[mdl]);
+			if (stop_gloderror())
+			{
+				glodDeleteGroup(mGroup[mdl]);
+				stop_gloderror();
+				glodDeleteObject(mObject[mdl]);
+				stop_gloderror();
+
+				mGroup[mdl] = 0;
+				mObject[mdl] = 0;
+
+				if (which_lod == -1)
+				{
+						mModel[LLModel::LOD_HIGH] = mBaseModel;
+				}
+
+				return;
+			}
+
+		}
+		
+		if (which_lod == -1 || mLODMode[which_lod] == 1)
+		{
+			//generating LODs for all entries, or this entry has a triangle budget
+			glodGroupParameteri(mGroup[mdl], GLOD_ADAPT_MODE, GLOD_TRIANGLE_BUDGET);
+			stop_gloderror();		
+		}
+		else
+		{ 
+			//this entry uses error mode
+			glodGroupParameteri(mGroup[mdl], GLOD_ADAPT_MODE, GLOD_OBJECT_SPACE_ERROR);
+			stop_gloderror();
+		}
+
+		if (which_lod != -1 && mLODMode[which_lod] == 2)
+		{
+			glodGroupParameterf(mGroup[mdl], GLOD_OBJECT_SPACE_ERROR_THRESHOLD, llmax(limit/100.f, 0.01f));
+			stop_gloderror();
+		}
+		else
+		{
+			glodGroupParameterf(mGroup[mdl], GLOD_OBJECT_SPACE_ERROR_THRESHOLD, 0.025f);
+			stop_gloderror();
+		}
+	}
+
+
+	S32 start = LLModel::LOD_HIGH;
+	S32 end = 0;
+
+	BOOL error_mode = FALSE;
+
+	if (which_lod != -1)
+	{
+		start = end = which_lod;
+
+		if (mLODMode[which_lod] == 2)
+		{
+			error_mode = TRUE;
+		}
+	}
+	
+	
+	for (S32 lod = start; lod >= end; --lod)
+	{
+		if (!error_mode)
+		{
+			if (which_lod == -1)
+			{
+				if (lod < start)
+				{
+					triangle_count /= 3;
+				}
+			}
+			else
+			{
+				triangle_count = limit;
+			}
+		}
+
+		mModel[lod].clear();
+		mModel[lod].resize(mBaseModel.size());
+		mVertexBuffer[lod].clear();
+
+		U32 actual_tris = 0;
+		U32 actual_verts = 0;
+		U32 submeshes = 0;
+
+		for (U32 mdl_idx = 0; mdl_idx < mBaseModel.size(); ++mdl_idx)
+		{ 
+			LLModel* base = mBaseModel[mdl_idx];
+
+			U32 target_count = U32(mPercentage[base]*triangle_count);
+
+			if (error_mode)
+			{
+				target_count = base->getNumTriangles();
+			}
+
+			if (target_count < 4)
+			{ 
+				target_count = 4;
+			}
+
+			if (which_lod == -1 || mLODMode[which_lod] == 1)
+			{
+				glodGroupParameteri(mGroup[base], GLOD_MAX_TRIANGLES, target_count);
+				stop_gloderror();
+			}
+			
+			glodAdaptGroup(mGroup[base]);
+			stop_gloderror();
+
+			GLint patch_count = 0;
+			glodGetObjectParameteriv(mObject[base], GLOD_NUM_PATCHES, &patch_count);
+			stop_gloderror();
+
+			LLVolumeParams volume_params;
+			volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+			mModel[lod][mdl_idx] = new LLModel(volume_params, 0.f);
+
+			GLint* sizes = new GLint[patch_count*2];
+			glodGetObjectParameteriv(mObject[base], GLOD_PATCH_SIZES, sizes);
+			stop_gloderror();
+
+			GLint* names = new GLint[patch_count];
+			glodGetObjectParameteriv(mObject[base], GLOD_PATCH_NAMES, names);
+			stop_gloderror();
+
+			mModel[lod][mdl_idx]->setNumVolumeFaces(patch_count);
+			
+			LLModel* target_model = mModel[lod][mdl_idx];
+
+			for (GLint i = 0; i < patch_count; ++i)
+			{
+				LLPointer<LLVertexBuffer> buff = new LLVertexBuffer(type_mask, 0);
+				
+				if (sizes[i*2+1] > 0 && sizes[i*2] > 0)
+				{
+					buff->allocateBuffer(sizes[i*2+1], sizes[i*2], true);
+					buff->setBuffer(type_mask);
+					glodFillElements(mObject[base], names[i], GL_UNSIGNED_SHORT, buff->getIndicesPointer());
+					stop_gloderror();
+				}
+				else
+				{ //this face was eliminated, create a dummy triangle (one vertex, 3 indices, all 0)
+					buff->allocateBuffer(1, 3, true);
+					memset(buff->getMappedData(), 0, buff->getSize());
+					memset(buff->getIndicesPointer(), 0, buff->getIndicesSize());
+				}
+				
+				buff->validateRange(0, buff->getNumVerts()-1, buff->getNumIndices(), 0);
+
+				LLStrider<LLVector3> pos;
+				LLStrider<LLVector3> norm;
+				LLStrider<LLVector2> tc;
+				LLStrider<U16> index;
+
+				buff->getVertexStrider(pos);
+				buff->getNormalStrider(norm);
+				buff->getTexCoord0Strider(tc);
+				buff->getIndexStrider(index);
+
+
+				target_model->setVolumeFaceData(names[i], pos, norm, tc, index, buff->getNumVerts(), buff->getNumIndices());
+				actual_tris += buff->getNumIndices()/3;
+				actual_verts += buff->getNumVerts();
+				++submeshes;
+
+				if (!validate_face(target_model->getVolumeFace(names[i])))
+				{
+					llerrs << "Invalid face generated during LOD generation." << llendl;
+				}
+			}
+
+			//blind copy skin weights and just take closest skin weight to point on
+			//decimated mesh for now (auto-generating LODs with skin weights is still a bit
+			//of an open problem).
+			target_model->mPosition = base->mPosition;
+			target_model->mSkinWeights = base->mSkinWeights;
+			target_model->mJointMap = base->mJointMap;
+			target_model->mJointList = base->mJointList;
+			target_model->mInvBindMatrix = base->mInvBindMatrix;
+			target_model->mBindShapeMatrix = base->mBindShapeMatrix;
+
+			if (!validate_model(target_model))
+			{
+				llerrs << "Invalid model generated when creating LODs" << llendl;
+			}
+
+			delete [] sizes;
+			delete [] names;
+		}
+
+		//rebuild scene based on mBaseScene
+		mScene[lod].clear();
+		mScene[lod] = mBaseScene;
+
+		for (U32 i = 0; i < mBaseModel.size(); ++i)
+		{
+			LLModel* mdl = mBaseModel[i];
+			LLModel* target = mModel[lod][i];
+			if (target)
+			{
+				for (LLModelLoader::scene::iterator iter = mScene[lod].begin(); iter != mScene[lod].end(); ++iter)
+				{
+					for (U32 j = 0; j < iter->second.size(); ++j)
+					{
+						if (iter->second[j].mModel == mdl)
+						{
+							iter->second[j].mModel = target;
+						}
+					}
+				}
+			}
+		}
+		
+		mResourceCost = calcResourceCost();
+	}
+}
+
+void LLModelPreview::updateStatusMessages()
+{
+	//triangle/vertex/submesh count for each mesh asset for each lod
+	std::vector<S32> tris[LLModel::NUM_LODS];
+	std::vector<S32> verts[LLModel::NUM_LODS];
+	std::vector<S32> submeshes[LLModel::NUM_LODS];
+	
+	//total triangle/vertex/submesh count for each lod
+	S32 total_tris[LLModel::NUM_LODS];
+	S32 total_verts[LLModel::NUM_LODS];
+	S32 total_submeshes[LLModel::NUM_LODS];
+
+	for (S32 lod = 0; lod <= LLModel::LOD_HIGH; ++lod)
+	{
+		//initialize total for this lod to 0
+		total_tris[lod] = total_verts[lod] = total_submeshes[lod] = 0;
+
+		for (U32 i = 0; i < mModel[lod].size(); ++i)
+		{ //for each model in the lod
+			S32 cur_tris = 0;
+			S32 cur_verts = 0;
+			S32 cur_submeshes = mModel[lod][i]->getNumVolumeFaces();
+
+			for (S32 j = 0; j < cur_submeshes; ++j)
+			{ //for each submesh (face), add triangles and vertices to current total
+				const LLVolumeFace& face = mModel[lod][i]->getVolumeFace(j);
+				cur_tris += face.mNumIndices/3;
+				cur_verts += face.mNumVertices;
+			}
+
+			//add this model to the lod total
+			total_tris[lod] += cur_tris;
+			total_verts[lod] += cur_verts;
+			total_submeshes[lod] += cur_submeshes;
+
+			//store this model's counts to asset data
+			tris[lod].push_back(cur_tris);
+			verts[lod].push_back(cur_verts);
+			submeshes[lod].push_back(cur_submeshes);
+		}
+	}
+	
+
+	std::string upload_message;
+
+	for (S32 lod = 0; lod <= LLModel::LOD_HIGH; ++lod)
+	{
+		mFMP->childSetTextArg(info_name[lod], "[TRIANGLES]", llformat("%d", total_tris[lod]));
+		mFMP->childSetTextArg(info_name[lod], "[VERTICES]", llformat("%d", total_verts[lod]));
+		mFMP->childSetTextArg(info_name[lod], "[SUBMESHES]", llformat("%d", total_submeshes[lod]));
+
+		std::string message = "good";
+		
+		const U32 lod_high = LLModel::LOD_HIGH;
+
+		if (lod != lod_high)
+		{
+			if (total_submeshes[lod] == 0)
+			{ //no model loaded for this lod, see if one is required
+				for (U32 i = 0; i < verts[lod_high].size(); ++i)
+				{
+					const F32 ratio = 0.5f;
+					const S32 required_verts = 128;
+
+					F32 scaler = powf(0.5f, lod_high-lod);
+					S32 max_verts = verts[lod_high][i]*scaler;
+
+					if (max_verts > required_verts)
+					{ //some model in this slot might have more than 128 vertices
+					  	
+						//if any model higher up the chain has more than 128 vertices, 
+						// lod is required here
+						for (S32 j = lod+1; j <= LLModel::LOD_HIGH; ++j)
+						{
+							if (verts[j].size() > i && verts[j][i] > 128)
+							{
+								message = "required";
+								upload_message = "missing_lod";
+							}
+						}
+					}
+				}
+			}
+			else if (total_submeshes[lod] != total_submeshes[lod_high])
+			{
+				message = "mesh_mismatch";
+				upload_message = "bad_lod";
+			}
+			else if (tris[lod].size() != tris[lod_high].size())
+			{
+				message = "model_mismatch";
+				upload_message = "bad_lod";
+			}
+			else
+			{
+				for (U32 i = 0; i < verts[lod].size(); ++i)
+				{
+					const F32 ratio = 0.5f;
+					
+					F32 scaler = powf(0.5f, lod_high-lod);
+					S32 max_verts = verts[lod_high][i]*scaler;
+
+					if (verts[lod][i] > max_verts)
+					{
+						message = "too_heavy";
+						upload_message = "bad_lod";
+					}
+				}
+			}
+		}
+
+		mFMP->childSetTextArg(info_name[lod], "[MESSAGE]", mFMP->getString(message));
+	}
+
+	if (upload_message.empty())
+	{
+		mFMP->childSetTextArg("upload_message", "[MESSAGE]", std::string(""));
+		mFMP->childEnable("ok_btn");
+	}
+	else
+	{
+		mFMP->childSetTextArg("upload_message", "[MESSAGE]", mFMP->getString(upload_message));
+		mFMP->childDisable("ok_btn");
+	}
+}
+
+void LLModelPreview::setPreviewTarget(F32 distance)
+{ 
+	mCameraDistance = distance;
+	mCameraZoom = 1.f;
+	mCameraPitch = 0.f;
+	mCameraYaw = 0.f;
+	mCameraOffset.clearVec();
+}
+
+void LLModelPreview::genBuffers(S32 lod)
+{
+	U32 tri_count = 0;
+	U32 vertex_count = 0;
+	U32 mesh_count = 0;
+
+	LLModelLoader::model_list* model = NULL;
+
+	if (lod < 0 || lod > 4)
+	{
+		model = &mBaseModel;
+		lod = 5;
+	}
+	else
+	{
+		model = &(mModel[lod]);
+	}
+
+	if (!mVertexBuffer[lod].empty())
+	{
+		mVertexBuffer[lod].clear();
+	}
+
+	mVertexBuffer[lod].clear();
+
+	LLModelLoader::model_list::iterator base_iter = mBaseModel.begin();
+
+	for (LLModelLoader::model_list::iterator iter = model->begin(); iter != model->end(); ++iter)
+	{
+		LLModel* mdl = *iter;
+		if (!mdl)
+		{
+			continue;
+		}
+
+		LLModel* base_mdl = *base_iter;
+		base_iter++;
+
+		for (S32 i = 0; i < mdl->getNumVolumeFaces(); ++i)
+		{
+			const LLVolumeFace &vf = mdl->getVolumeFace(i);
+			U32 num_vertices = vf.mNumVertices;
+			U32 num_indices = vf.mNumIndices;
+
+			if (!num_vertices || ! num_indices)
+			{
+				continue;
+			}
+
+			LLVertexBuffer* vb = NULL;
+			
+			bool skinned = !mdl->mSkinWeights.empty();
+
+			U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0;
+			
+			if (skinned)
+			{
+				mask |= LLVertexBuffer::MAP_WEIGHT4;
+			}
+
+			vb = new LLVertexBuffer(mask, 0);
+			
+			vb->allocateBuffer(num_vertices, num_indices, TRUE);
+
+			LLStrider<LLVector3> vertex_strider;
+			LLStrider<LLVector3> normal_strider;
+			LLStrider<LLVector2> tc_strider;
+			LLStrider<U16> index_strider;
+			LLStrider<LLVector4> weights_strider;
+
+			vb->getVertexStrider(vertex_strider);
+			vb->getNormalStrider(normal_strider);
+			vb->getTexCoord0Strider(tc_strider);
+			vb->getIndexStrider(index_strider);
+
+			if (skinned)
+			{
+				vb->getWeight4Strider(weights_strider);
+			}
+			
+			LLVector4a::memcpyNonAliased16((F32*) vertex_strider.get(), (F32*) vf.mPositions, num_vertices*4*sizeof(F32));
+			LLVector4a::memcpyNonAliased16((F32*) tc_strider.get(), (F32*) vf.mTexCoords, num_vertices*2*sizeof(F32));
+			LLVector4a::memcpyNonAliased16((F32*) normal_strider.get(), (F32*) vf.mNormals, num_vertices*4*sizeof(F32));
+
+			if (skinned)
+			{
+				// build vertices and normals
+				for (U32 i = 0; i < num_vertices; i++)
+				{
+					//find closest weight to vf.mVertices[i].mPosition
+					LLVector3 pos(vf.mPositions[i].getF32ptr());
+
+					LLModel::weight_list weight_list = base_mdl->getJointInfluences(pos);
+
+					LLVector4 w(0,0,0,0);
+					if (weight_list.size() > 4)
+					{
+						llerrs << "WTF?" << llendl;
+					}
+
+					for (U32 i = 0; i < weight_list.size(); ++i)
+					{
+						F32 wght = llmin(weight_list[i].mWeight, 0.999999f);
+						F32 joint = (F32) weight_list[i].mJointIdx;
+						w.mV[i] = joint + wght;
+					}
+					
+					*(weights_strider++) = w;
+				}
+			}
+
+			// build indices
+			for (U32 i = 0; i < num_indices; i++)
+			{
+				*(index_strider++) = vf.mIndices[i];
+			}
+
+			mVertexBuffer[lod][mdl].push_back(vb);
+
+			vertex_count += num_vertices;
+			tri_count += num_indices/3;
+			++mesh_count;
+
+		}
+	}
+
+	if (lod == 4)
+	{
+		for (U32 i = 0; i < 4; i++)
+		{
+			LLSpinCtrl* lim = mFMP->getChild<LLSpinCtrl>(limit_name[i], TRUE);
+
+			lim->setMaxValue(tri_count);
+		}
+	}
+}
+
+//-----------------------------------------------------------------------------
+// render()
+//-----------------------------------------------------------------------------
+BOOL LLModelPreview::render()
+{
+	LLMutexLock lock(this);
+	mNeedsUpdate = FALSE;
+
+	S32 width = getWidth();
+	S32 height = getHeight();
+
+	LLGLSUIDefault def;
+	LLGLDisable no_blend(GL_BLEND);
+	LLGLEnable cull(GL_CULL_FACE);
+	LLGLDepthTest depth(GL_TRUE);
+	LLGLDisable fog(GL_FOG);
+
+	glMatrixMode(GL_PROJECTION);
+	gGL.pushMatrix();
+	glLoadIdentity();
+	glOrtho(0.0f, width, 0.0f, height, -1.0f, 1.0f);
+
+	glMatrixMode(GL_MODELVIEW);
+	gGL.pushMatrix();
+	glLoadIdentity();
+		
+	gGL.color4f(0.15f, 0.2f, 0.3f, 1.f);
+
+	gl_rect_2d_simple( width, height );
+
+	bool avatar_preview = false;
+	for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter)
+	{
+		for (LLModelLoader::model_instance_list::iterator model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter)
+		{
+			LLModelInstance& instance = *model_iter;
+			LLModel* model = instance.mModel;
+			if (!model->mSkinWeights.empty())
+			{
+				avatar_preview = true;
+			}
+		}
+	}
+
+	mFMP->childSetEnabled("consolidate", !avatar_preview);
+	
+	F32 explode = mFMP->childGetValue("explode").asReal();
+
+	glMatrixMode(GL_PROJECTION);
+	gGL.popMatrix();
+
+	glMatrixMode(GL_MODELVIEW);
+	gGL.popMatrix();
+
+	glClear(GL_DEPTH_BUFFER_BIT);
+
+	LLViewerCamera::getInstance()->setAspect((F32) width / height );
+	LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom);
+
+	LLVector3 target_pos = mPreviewTarget;
+	LLVector3 offset = mCameraOffset;
+
+	F32 z_near = llmax(mCameraDistance-mPreviewScale.magVec(), 0.001f);
+	F32 z_far = mCameraDistance+mPreviewScale.magVec();
+
+	if (avatar_preview)
+	{
+		target_pos = gAgentAvatarp->getPositionAgent();
+		z_near = 0.01f;
+		z_far = 1024.f;
+		mCameraDistance = 16.f;
+
+		//render avatar previews every frame
+		refresh();
+	}
+
+	LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * 
+		LLQuaternion(mCameraYaw, LLVector3::z_axis);
+
+	LLQuaternion av_rot = camera_rot;
+	LLViewerCamera::getInstance()->setOriginAndLookAt(
+		target_pos + ((LLVector3(mCameraDistance, 0.f, 0.f) + offset) * av_rot),		// camera
+		LLVector3::z_axis,																	// up
+		target_pos);											// point of interest
+
+	
+	LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, width, height, FALSE, z_near, z_far);
+
+	stop_glerror();
+
+	gPipeline.enableLightsAvatar();
+
+	gGL.pushMatrix();
+	const F32 BRIGHTNESS = 0.9f;
+	gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS);
+	
+	LLGLEnable normalize(GL_NORMALIZE);
+
+	if (!mBaseModel.empty() && mVertexBuffer[5].empty())
+	{
+		genBuffers(-1);
+		genBuffers(3);
+		//genLODs();
+	}
+
+	bool physics = (mPreviewLOD == LLModel::LOD_PHYSICS);
+
+	S32 physics_idx = -1;
+
+	bool render_mesh = true;
+	bool render_hull = false;
+
+	if (physics && mFMP->mDecompFloater)
+	{
+		physics_idx = mFMP->mDecompFloater->childGetValue("model").asInteger();
+		render_mesh = mFMP->mDecompFloater->childGetValue("render_mesh").asBoolean();
+		render_hull = mFMP->mDecompFloater->childGetValue("render_hull").asBoolean();
+	}
+
+	if (!mModel[mPreviewLOD].empty())
+	{
+		if (mVertexBuffer[mPreviewLOD].empty())
+		{
+			genBuffers(mPreviewLOD);
+		}
+
+		if (!avatar_preview)
+		{
+			for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter)
+			{
+				gGL.pushMatrix();
+				LLMatrix4 mat = iter->first;
+
+				glMultMatrixf((GLfloat*) mat.mMatrix);				
+				
+				for (LLModelLoader::model_instance_list::iterator model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter)
+				{
+					LLModelInstance& instance = *model_iter;
+					LLModel* model = instance.mModel;
+
+					if (instance.mTransform != mat)
+					{
+						llerrs << "WTF?" << llendl;
+					}
+
+					if (render_mesh)
+					{
+						for (U32 i = 0; i < mVertexBuffer[mPreviewLOD][model].size(); ++i)
+						{
+							LLVertexBuffer* buffer = mVertexBuffer[mPreviewLOD][model][i];
+
+							buffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0);
+							if (physics)
+							{
+								if (physics_idx > -1 && model == mModel[mPreviewLOD][physics_idx])
+								{
+									glColor4f(1,0,0,1);
+								}
+								else
+								{
+									glColor4f(0.75f, 0.75f, 0.75f, 1.f);
+								}
+							}
+							else
+							{
+								glColor4fv(instance.mMaterial[i].mDiffuseColor.mV);
+								if (i < instance.mMaterial.size() && instance.mMaterial[i].mDiffuseMap.notNull())
+								{
+									gGL.getTexUnit(0)->bind(instance.mMaterial[i].mDiffuseMap, true);
+									if (instance.mMaterial[i].mDiffuseMap->getDiscardLevel() > -1)
+									{
+										mTextureSet.insert(instance.mMaterial[i].mDiffuseMap);
+									}
+								}
+							}
+
+							buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0);
+							gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+							glColor3f(0.4f, 0.4f, 0.4f);
+
+							if (mFMP->childGetValue("show edges").asBoolean())
+							{
+								glLineWidth(3.f);
+								glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+								buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0);
+								glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+								glLineWidth(1.f);
+							}
+						}
+					}
+
+					if (render_hull)
+					{
+						LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread;
+						if (decomp)
+						{
+							LLMutexLock(decomp->mMutex);
+												
+							std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > >::iterator iter = 
+								mPhysicsMesh.find(model);
+							if (iter != mPhysicsMesh.end())
+							{
+								for (U32 i = 0; i < iter->second.size(); ++i)
+								{
+									if (explode > 0.f)
+									{
+										gGL.pushMatrix();
+
+										LLVector3 offset = model->mHullCenter[i]-model->mPhysicsCenter;
+										offset *= explode;
+
+										gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]);
+									}
+
+									static std::vector<LLColor4U> hull_colors;
+
+									if (i+1 >= hull_colors.size())
+									{
+										hull_colors.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127, 255));
+									}
+
+									LLVertexBuffer* buff = iter->second[i];
+									if (buff)
+									{
+										buff->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL);			
+
+										glColor4ubv(hull_colors[i].mV);
+										buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
+									
+										if (mFMP->childGetValue("show edges").asBoolean())
+										{
+											glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+											glLineWidth(3.f);
+											glColor4ub(hull_colors[i].mV[0]/2, hull_colors[i].mV[1]/2, hull_colors[i].mV[2]/2, 255);
+											buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
+											glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+											glLineWidth(1.f);
+										}	
+									}
+
+									if (explode > 0.f)
+									{
+										gGL.popMatrix();
+									}
+								}
+							}
+						}	
+
+						//mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[HULLS]", llformat("%d",decomp->mHulls.size()));
+						//mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[POINTS]", llformat("%d",decomp->mTotalPoints));				
+					}
+				}
+
+				gGL.popMatrix();
+			}
+
+			if (physics)
+			{
+				mPreviewLOD = LLModel::LOD_PHYSICS;
+			}
+		}
+		else
+		{
+			LLVOAvatarSelf* avatar = gAgentAvatarp;
+			target_pos = avatar->getPositionAgent();
+
+			LLViewerCamera::getInstance()->setOriginAndLookAt(
+				target_pos + ((LLVector3(mCameraDistance, 0.f, 0.f) + offset) * av_rot),		// camera
+				LLVector3::z_axis,																	// up
+				target_pos);											// point of interest
+
+			avatar->renderCollisionVolumes();
+
+			for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter)
+			{
+				for (LLModelLoader::model_instance_list::iterator model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter)
+				{
+					LLModelInstance& instance = *model_iter;
+					LLModel* model = instance.mModel;
+
+					if (!model->mSkinWeights.empty())
+					{
+						for (U32 i = 0; i < mVertexBuffer[mPreviewLOD][model].size(); ++i)
+						{
+							LLVertexBuffer* buffer = mVertexBuffer[mPreviewLOD][model][i];
+
+							const LLVolumeFace& face = model->getVolumeFace(i);
+
+							LLStrider<LLVector3> position;
+							buffer->getVertexStrider(position);
+							
+							LLStrider<LLVector4> weight;
+							buffer->getWeight4Strider(weight);
+							
+							//quick 'n dirty software vertex skinning
+
+							//build matrix palette
+							LLMatrix4 mat[64];
+							for (U32 j = 0; j < model->mJointList.size(); ++j)
+							{
+								LLJoint* joint = avatar->getJoint(model->mJointList[j]);
+								if (joint)
+								{
+									mat[j] = model->mInvBindMatrix[j];
+									mat[j] *= joint->getWorldMatrix();
+								}
+							}
+
+							for (U32 j = 0; j < buffer->getRequestedVerts(); ++j)
+							{
+								LLMatrix4 final_mat;
+								final_mat.mMatrix[0][0] = final_mat.mMatrix[1][1] = final_mat.mMatrix[2][2] = final_mat.mMatrix[3][3] = 0.f;
+
+								LLVector4 wght;
+								S32 idx[4];
+
+								F32 scale = 0.f;
+								for (U32 k = 0; k < 4; k++)
+								{
+									F32 w = weight[j].mV[k];
+
+									idx[k] = (S32) floorf(w);
+									wght.mV[k] = w - floorf(w);
+									scale += wght.mV[k];
+								}
+
+								wght *= 1.f/scale;						
+
+								for (U32 k = 0; k < 4; k++)
+								{
+									F32* src = (F32*) mat[idx[k]].mMatrix;
+									F32* dst = (F32*) final_mat.mMatrix;
+
+									F32 w = wght.mV[k];
+
+									for (U32 l = 0; l < 16; l++)
+									{
+										dst[l] += src[l]*w;
+									}
+								}
+
+								//VECTORIZE THIS
+								LLVector3 v(face.mPositions[j].getF32ptr());
+								
+								v = v * model->mBindShapeMatrix;
+								v = v * final_mat;
+
+								position[j] = v;
+							}
+
+							buffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0);
+							glColor4fv(instance.mMaterial[i].mDiffuseColor.mV);
+							gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+							buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0);
+							glColor3f(0.4f, 0.4f, 0.4f);
+
+							if (mFMP->childGetValue("show edges").asBoolean())
+							{
+								glLineWidth(3.f);
+								glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+								buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0);
+								glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+								glLineWidth(1.f);
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+
+	gGL.popMatrix();
+		
+	return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// refresh()
+//-----------------------------------------------------------------------------
+void LLModelPreview::refresh()
+{ 
+	mNeedsUpdate = TRUE; 
+}
+
+//-----------------------------------------------------------------------------
+// rotate()
+//-----------------------------------------------------------------------------
+void LLModelPreview::rotate(F32 yaw_radians, F32 pitch_radians)
+{
+	mCameraYaw = mCameraYaw + yaw_radians;
+
+	mCameraPitch = llclamp(mCameraPitch + pitch_radians, F_PI_BY_TWO * -0.8f, F_PI_BY_TWO * 0.8f);
+}
+
+//-----------------------------------------------------------------------------
+// zoom()
+//-----------------------------------------------------------------------------
+void LLModelPreview::zoom(F32 zoom_amt)
+{
+	F32 new_zoom = mCameraZoom+zoom_amt;
+		
+	mCameraZoom	= llclamp(new_zoom, 1.f, 10.f);
+}
+
+void LLModelPreview::pan(F32 right, F32 up)
+{
+	mCameraOffset.mV[VY] = llclamp(mCameraOffset.mV[VY] + right * mCameraDistance / mCameraZoom, -1.f, 1.f);
+	mCameraOffset.mV[VZ] = llclamp(mCameraOffset.mV[VZ] + up * mCameraDistance / mCameraZoom, -1.f, 1.f);
+}
+
+void LLModelPreview::setPreviewLOD(S32 lod)
+{
+	mPreviewLOD = llclamp(lod, 0, 4);
+	refresh();
+}
+
+//static 
+void LLFloaterModelPreview::onBrowseHighLOD(void* data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) data;
+	mp->loadModel(3);
+}
+
+//static 
+void LLFloaterModelPreview::onBrowseMediumLOD(void* data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) data;
+	mp->loadModel(2);
+}
+
+//static 
+void LLFloaterModelPreview::onBrowseLowLOD(void* data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) data;
+	mp->loadModel(1);
+}
+
+//static 
+void LLFloaterModelPreview::onBrowseLowestLOD(void* data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) data;
+	mp->loadModel(0);
+}
+
+//static
+void LLFloaterModelPreview::onUpload(void* user_data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) user_data;
+
+	if (mp->mDecompFloater)
+	{
+		mp->mDecompFloater->closeFloater();
+	}
+
+	mp->mModelPreview->rebuildUploadData();
+		
+	gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, mp->mModelPreview->mPreviewScale, mp->childGetValue("upload_textures").asBoolean());
+
+	mp->closeFloater(false);
+}
+
+//static 
+void LLFloaterModelPreview::onConsolidate(void* user_data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) user_data;
+	mp->mModelPreview->consolidate();
+}
+
+//static 
+void LLFloaterModelPreview::onScrubMaterials(void* user_data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) user_data;
+	mp->mModelPreview->scrubMaterials();
+}
+
+//static 
+void LLFloaterModelPreview::onDecompose(void* user_data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) user_data;
+	mp->showDecompFloater();
+}
+
+//static
+void LLFloaterModelPreview::onModelDecompositionComplete(LLModel* model, std::vector<LLPointer<LLVertexBuffer> >& physics_mesh)
+{
+	if (sInstance && sInstance->mModelPreview)
+	{
+		sInstance->mModelPreview->mPhysicsMesh[model] = physics_mesh;
+
+		sInstance->mModelPreview->mResourceCost = sInstance->mModelPreview->calcResourceCost();
+	}
+}
+
+
+//static 
+void LLFloaterModelPreview::refresh(LLUICtrl* ctrl, void* user_data)
+{
+	LLFloaterModelPreview* mp = (LLFloaterModelPreview*) user_data;
+	mp->mModelPreview->refresh();
+}
+
+void LLFloaterModelPreview::updateResourceCost()
+{
+	U32 cost = mModelPreview->mResourceCost;
+	childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d",cost));
+}
+
+//static
+void LLModelPreview::textureLoadedCallback( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata )
+{
+	LLModelPreview* preview = (LLModelPreview*) userdata;
+	preview->refresh();
+}
+
+#endif
+
diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h
new file mode 100644
index 00000000000..1f9de2e2b9e
--- /dev/null
+++ b/indra/newview/llfloatermodelpreview.h
@@ -0,0 +1,275 @@
+/**
+ * @file llfloatermodelpreview.h
+ * @brief LLFloaterModelPreview class definition
+ *
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2007, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLFLOATERMODELPREVIEW_H
+#define LL_LLFLOATERMODELPREVIEW_H
+
+#include "llfloaternamedesc.h"
+
+#include "lldynamictexture.h"
+#include "llquaternion.h"
+#include "llmeshrepository.h"
+#include "llmodel.h"
+#include "llthread.h"
+
+#if LL_MESH_ENABLED
+class LLComboBox;
+class LLJoint;
+class LLViewerJointMesh;
+class LLVOAvatar;
+class LLTextBox;
+class LLVertexBuffer;
+class LLModelPreview;
+class LLFloaterModelPreview;
+class daeElement;
+class domProfile_COMMON;
+class domInstance_geometry;
+
+class LLPhysicsDecompFloater : public LLFloater
+{
+public:
+
+	LLPhysicsDecompFloater(LLSD& key);
+	~LLPhysicsDecompFloater();
+};
+
+class LLModelLoader : public LLThread
+{
+public:
+	typedef enum
+	{
+		STARTING = 0,
+		READING_FILE,
+		CREATING_FACES,
+		GENERATING_VERTEX_BUFFERS,
+		GENERATING_LOD,
+		DONE,
+	} eLoadState;
+
+	U32 mState;
+	std::string mFilename;
+	S32 mLod;
+	LLModelPreview* mPreview;
+	LLMatrix4 mTransform;
+	BOOL mFirstTransform;
+	LLVector3 mExtents[2];
+
+	std::map<daeElement*, LLPointer<LLModel> > mModel;
+	
+	typedef std::vector<LLPointer<LLModel> > model_list;
+	model_list mModelList;
+
+	typedef std::vector<LLModelInstance> model_instance_list;
+	
+	typedef std::map<LLMatrix4, model_instance_list > scene;
+
+	scene mScene;
+
+	LLModelLoader(std::string filename, S32 lod, LLModelPreview* preview);
+
+	virtual void run();
+	
+	void processElement(daeElement* element);
+	std::vector<LLImportMaterial> getMaterials(LLModel* model, domInstance_geometry* instance_geo);
+	LLImportMaterial profileToMaterial(domProfile_COMMON* material);
+	std::string getElementLabel(daeElement *element);
+	LLColor4 getDaeColor(daeElement* element);
+
+	//map of avatar joints as named in COLLADA assets to internal joint names
+	std::map<std::string, std::string> mJointMap;
+};
+
+class LLModelPreview : public LLViewerDynamicTexture, public LLMutex
+{
+ public:
+	
+	 LLModelPreview(S32 width, S32 height, LLFloaterModelPreview* fmp);
+	virtual ~LLModelPreview();
+
+	void setPreviewTarget(F32 distance);
+	void setTexture(U32 name) { mTextureName = name; }
+
+	BOOL render();
+	void genBuffers(S32 lod);
+	void refresh();
+	void rotate(F32 yaw_radians, F32 pitch_radians);
+	void zoom(F32 zoom_amt);
+	void pan(F32 right, F32 up);
+	virtual BOOL needsRender() { return mNeedsUpdate; }
+	void setPreviewLOD(S32 lod);
+	void loadModel(std::string filename, S32 lod);
+	void loadModelCallback(S32 lod);
+	void genLODs(S32 which_lod = -1);
+	void smoothNormals();
+	void consolidate();
+	void scrubMaterials();
+	U32 calcResourceCost();
+	void rebuildUploadData();
+	void clearIncompatible(S32 lod);
+	void updateStatusMessages();
+
+	static void	textureLoadedCallback( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata );
+
+ protected:
+	friend class LLFloaterModelPreview;
+	friend class LLPhysicsDecomp;
+
+	LLFloaterModelPreview* mFMP;
+
+	BOOL        mNeedsUpdate;
+	U32         mTextureName;
+	F32			mCameraDistance;
+	F32			mCameraYaw;
+	F32			mCameraPitch;
+	F32			mCameraZoom;
+	LLVector3	mCameraOffset;
+	LLVector3	mPreviewTarget;
+	LLVector3	mPreviewScale;
+	S32			mPreviewLOD;
+	U32			mResourceCost;
+	S32			mLODMode[LLModel::NUM_LODS];
+	S32			mLimit[LLModel::NUM_LODS];
+	
+	LLModelLoader* mModelLoader;
+
+
+	LLModelLoader::scene mScene[LLModel::NUM_LODS];
+	LLModelLoader::scene mBaseScene;
+
+	LLModelLoader::model_list mModel[LLModel::NUM_LODS];
+	LLModelLoader::model_list mBaseModel;
+
+	std::map<LLModel*, U32> mGroup;
+	std::map<LLModel*, U32> mObject;
+	std::map<LLModel*, std::vector<U32> > mPatch;
+
+	std::map<LLModel*, F32> mPercentage;
+	std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > > mPhysicsMesh;
+
+	LLMeshUploadThread::instance_list mUploadData;
+	std::set<LLPointer<LLViewerFetchedTexture> > mTextureSet;
+
+	//map of vertex buffers to models (one vertex buffer in vector per face in model
+	std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > > mVertexBuffer[6];
+};
+
+class LLFloaterModelPreview : public LLFloater
+{
+public:
+	static LLFloaterModelPreview* sInstance;
+
+	LLFloaterModelPreview(const LLSD& key);
+	virtual ~LLFloaterModelPreview();
+
+	virtual BOOL postBuild();
+	
+	BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+	BOOL handleMouseUp(S32 x, S32 y, MASK mask);
+	BOOL handleHover(S32 x, S32 y, MASK mask);
+	BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); 
+
+	static void onMouseCaptureLostModelPreview(LLMouseHandler*);
+	static void setUploadAmount(S32 amount) { sUploadAmount = amount; }
+
+	static void onBrowseHighLOD(void* data);
+	static void onBrowseMediumLOD(void* data); 
+	static void onBrowseLowLOD(void* data);
+	static void onBrowseLowestLOD(void* data);
+
+	static void onUpload(void* data);
+
+	static void onConsolidate(void* data);
+	static void onScrubMaterials(void* data);
+	static void onDecompose(void* data);
+	static void onModelDecompositionComplete(LLModel* model, std::vector<LLPointer<LLVertexBuffer> >& physics_mesh);
+
+	static void refresh(LLUICtrl* ctrl, void* data);
+
+	void updateResourceCost();
+
+	void			loadModel(S32 lod);
+
+protected:
+	friend class LLModelPreview;
+	friend class LLMeshFilePicker;
+	friend class LLPhysicsDecomp;
+	friend class LLPhysicsDecompFloater;
+	
+	static void		onPreviewLODCommit(LLUICtrl*,void*);
+	
+	static void		onHighLODCommit(LLUICtrl*,void*);
+	static void		onMediumLODCommit(LLUICtrl*,void*);
+	static void		onLowLODCommit(LLUICtrl*,void*);
+	static void		onLowestLODCommit(LLUICtrl*,void*);
+	static void		onPhysicsLODCommit(LLUICtrl*,void*);
+
+	static void		onHighLimitCommit(LLUICtrl*,void*);
+	static void		onMediumLimitCommit(LLUICtrl*,void*);
+	static void		onLowLimitCommit(LLUICtrl*,void*);
+	static void		onLowestLimitCommit(LLUICtrl*,void*);
+	static void		onPhysicsLimitCommit(LLUICtrl*,void*);
+	
+	static void		onSmoothNormalsCommit(LLUICtrl*,void*);
+
+	static void		onAutoFillCommit(LLUICtrl*,void*);
+	static void		onShowEdgesCommit(LLUICtrl*,void*);
+
+	static void		onExplodeCommit(LLUICtrl*, void*);
+
+	static void onPhysicsParamCommit(LLUICtrl* ctrl, void* userdata);
+	static void onPhysicsStageExecute(LLUICtrl* ctrl, void* userdata);
+	static void onPhysicsStageCancel(LLUICtrl* ctrl, void* userdata);
+	static void onClosePhysicsFloater(LLUICtrl* ctrl, void* userdata);
+
+	void			draw();
+	static void		setLODMode(S32 lod, void* userdata);
+	void			setLODMode(S32 lod, S32 which_mode);
+
+	static void		setLimit(S32 lod, void* userdata);
+	void			setLimit(S32 lod, S32 limit);
+
+	void showDecompFloater();
+	
+	LLModelPreview*	mModelPreview;
+
+	LLFloater* mDecompFloater;
+	
+	S32				mLastMouseX;
+	S32				mLastMouseY;
+	LLRect			mPreviewRect;
+	U32				mGLName;
+	BOOL			mLoading;
+	static S32		sUploadAmount;
+};
+
+#endif
+
+#endif  // LL_LLFLOATERMODELPREVIEW_H
diff --git a/indra/newview/llmeshreduction.cpp b/indra/newview/llmeshreduction.cpp
new file mode 100644
index 00000000000..e785784a324
--- /dev/null
+++ b/indra/newview/llmeshreduction.cpp
@@ -0,0 +1,291 @@
+/** 
+ * @file llmeshreduction.cpp
+ * @brief LLMeshReduction class implementation
+ *
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llmeshreduction.h"
+#include "llgl.h"
+#include "llvertexbuffer.h"
+
+#include "glod/glod.h"
+
+#if LL_MESH_ENABLED
+
+static BOOL stop_gloderror()
+{
+	GLuint error = glodGetError();
+
+	if (error != GLOD_NO_ERROR)
+	{
+		llwarns << "GLOD error detected: " << std::hex << error << llendl;
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+
+void create_vertex_buffers_from_model(LLModel* model, std::vector<LLPointer <LLVertexBuffer> >& vertex_buffers)
+{
+#if 0 //VECTORIZE THIS ?
+	vertex_buffers.clear();
+	
+	for (S32 i = 0; i < model->getNumVolumeFaces(); ++i)
+	{
+		const LLVolumeFace &vf = model->getVolumeFace(i);
+		U32 num_vertices = vf.mNumVertices;
+		U32 num_indices = vf.mNumIndices;
+
+		if (!num_vertices || ! num_indices)
+		{
+			continue;
+		}
+
+		LLVertexBuffer* vb =
+			new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0, 0);
+		
+		vb->allocateBuffer(num_vertices, num_indices, TRUE);
+
+		LLStrider<LLVector3> vertex_strider;
+		LLStrider<LLVector3> normal_strider;
+		LLStrider<LLVector2> tc_strider;
+		LLStrider<U16> index_strider;
+
+		vb->getVertexStrider(vertex_strider);
+		vb->getNormalStrider(normal_strider);
+		vb->getTexCoord0Strider(tc_strider);
+
+		vb->getIndexStrider(index_strider);
+
+		// build vertices and normals
+		for (U32 i = 0; (S32)i < num_vertices; i++)
+		{
+			*(vertex_strider++) = vf.mVertices[i].mPosition;
+			*(tc_strider++) = vf.mVertices[i].mTexCoord;
+			LLVector3 normal = vf.mVertices[i].mNormal;
+			normal.normalize();
+			*(normal_strider++) = normal;
+		}
+
+		// build indices
+		for (U32 i = 0; i < num_indices; i++)
+		{
+			*(index_strider++) = vf.mIndices[i];
+		}
+
+
+		vertex_buffers.push_back(vb);
+	}
+#endif
+}
+
+void create_glod_object_from_vertex_buffers(S32 object, S32 group, std::vector<LLPointer <LLVertexBuffer> >& vertex_buffers)
+{
+	glodNewGroup(group);
+	stop_gloderror();
+	glodNewObject(object, group, GLOD_DISCRETE);
+	stop_gloderror();
+
+	for (U32 i = 0; i < vertex_buffers.size(); ++i)
+	{
+		vertex_buffers[i]->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0);
+		
+		U32 num_indices = vertex_buffers[i]->getNumIndices();
+		
+		if (num_indices > 2)
+		{
+			glodInsertElements(object, i, GL_TRIANGLES, num_indices, GL_UNSIGNED_SHORT,
+							   vertex_buffers[i]->getIndicesPointer(), 0, 0.f);
+		}
+		stop_gloderror();
+	}
+	
+	glodBuildObject(object);
+	stop_gloderror();
+}
+
+// extract the GLOD data into vertex buffers
+void create_vertex_buffers_from_glod_object(S32 object, S32 group, std::vector<LLPointer <LLVertexBuffer> >& vertex_buffers)
+{
+	vertex_buffers.clear();
+	
+	GLint patch_count = 0;
+	glodGetObjectParameteriv(object, GLOD_NUM_PATCHES, &patch_count);
+	stop_gloderror();
+
+	GLint* sizes = new GLint[patch_count*2];
+	glodGetObjectParameteriv(object, GLOD_PATCH_SIZES, sizes);
+	stop_gloderror();
+
+	GLint* names = new GLint[patch_count];
+	glodGetObjectParameteriv(object, GLOD_PATCH_NAMES, names);
+	stop_gloderror();
+
+	for (S32 i = 0; i < patch_count; i++)
+	{
+		LLPointer<LLVertexBuffer> buff =
+			new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0, 0);
+			
+		if (sizes[i*2+1] > 0 && sizes[i*2] > 0)
+		{
+			buff->allocateBuffer(sizes[i*2+1], sizes[i*2], true);
+			buff->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0);
+			glodFillElements(object, names[i], GL_UNSIGNED_SHORT, buff->getIndicesPointer());
+			stop_gloderror();
+		}
+		else
+		{
+            // this face was eliminated, create a dummy triangle (one vertex, 3 indices, all 0)
+			buff->allocateBuffer(1, 3, true);
+		}
+
+		vertex_buffers.push_back(buff);
+	}
+	
+	glodDeleteObject(object);
+	stop_gloderror();
+	glodDeleteGroup(group);
+	stop_gloderror();
+	
+	delete [] sizes;
+	delete [] names;
+}
+
+
+LLPointer<LLModel> create_model_from_vertex_buffers(std::vector<LLPointer <LLVertexBuffer> >& vertex_buffers)
+{
+	// extract the newly reduced mesh
+
+	// create our output model
+	LLVolumeParams volume_params;
+	volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+	LLPointer<LLModel> out_model = new LLModel(volume_params, 0.f);
+
+	out_model->setNumVolumeFaces(vertex_buffers.size());
+
+	// build new faces from each vertex buffer
+	for (GLint i = 0; i < vertex_buffers.size(); ++i)
+	{
+		LLStrider<LLVector3> pos;
+		LLStrider<LLVector3> norm;
+		LLStrider<LLVector2> tc;
+		LLStrider<U16> index;
+
+		vertex_buffers[i]->getVertexStrider(pos);
+		vertex_buffers[i]->getNormalStrider(norm);
+		vertex_buffers[i]->getTexCoord0Strider(tc);
+		vertex_buffers[i]->getIndexStrider(index);
+
+		out_model->setVolumeFaceData(i, pos, norm, tc, index,
+									 vertex_buffers[i]->getNumVerts(), vertex_buffers[i]->getNumIndices());
+	}
+	
+	return out_model;
+}
+
+
+
+LLMeshReduction::LLMeshReduction()
+{
+	mCounter = 1;
+
+	glodInit();
+}
+
+LLMeshReduction::~LLMeshReduction()
+{
+	glodShutdown();
+}
+
+
+LLPointer<LLModel> LLMeshReduction::reduce(LLModel* in_model, F32 limit, S32 mode)
+{
+	LLVertexBuffer::unbind();
+
+	// create vertex buffers from model
+	std::vector<LLPointer<LLVertexBuffer> > in_vertex_buffers;
+	create_vertex_buffers_from_model(in_model, in_vertex_buffers);
+
+	// create glod object from vertex buffers
+	stop_gloderror();
+	S32 glod_group = mCounter++;
+	S32 glod_object = mCounter++;
+	create_glod_object_from_vertex_buffers(glod_object, glod_group, in_vertex_buffers);
+
+	
+	// set reduction parameters
+	stop_gloderror();
+
+	if (mode == TRIANGLE_BUDGET)
+	{
+		// triangle budget mode
+		glodGroupParameteri(glod_group, GLOD_ADAPT_MODE, GLOD_TRIANGLE_BUDGET);
+		stop_gloderror();		
+		glodGroupParameteri(glod_group, GLOD_ERROR_MODE, GLOD_OBJECT_SPACE_ERROR);
+		stop_gloderror();		
+		S32 triangle_count = (S32)limit;
+		glodGroupParameteri(glod_group, GLOD_MAX_TRIANGLES, triangle_count);
+		stop_gloderror();		
+	}
+	else if (mode == ERROR_THRESHOLD)
+	{ 
+		// error threshold mode
+		glodGroupParameteri(glod_group, GLOD_ADAPT_MODE, GLOD_ERROR_THRESHOLD);
+		glodGroupParameteri(glod_group, GLOD_ERROR_MODE, GLOD_OBJECT_SPACE_ERROR);
+		F32 error_threshold = limit;
+		glodGroupParameterf(glod_group, GLOD_OBJECT_SPACE_ERROR_THRESHOLD, error_threshold);
+		stop_gloderror();
+	}
+	
+	else
+	{
+		// not a legal mode
+		return NULL;
+	}
+
+
+	// do the reduction
+	glodAdaptGroup(glod_group);
+	stop_gloderror();
+
+	// convert glod object into vertex buffers
+	std::vector<LLPointer<LLVertexBuffer> > out_vertex_buffers;
+	create_vertex_buffers_from_glod_object(glod_object, glod_group, out_vertex_buffers);
+
+	// convert vertex buffers into a model
+	LLPointer<LLModel> out_model = create_model_from_vertex_buffers(out_vertex_buffers);
+
+	
+	return out_model;
+}
+
+#endif
+
diff --git a/indra/newview/llmeshreduction.h b/indra/newview/llmeshreduction.h
new file mode 100644
index 00000000000..d86696978d0
--- /dev/null
+++ b/indra/newview/llmeshreduction.h
@@ -0,0 +1,59 @@
+/** 
+ * @file llmeshreduction.h
+ * @brief LLMeshReduction class definition
+ *
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLMESHREDUCTION_H
+#define LL_LLMESHREDUCTION_H
+
+#include "llmodel.h"
+
+#if LL_MESH_ENABLED
+
+class LLMeshReduction
+{
+ public:
+	enum EReductionMode
+	{
+		TRIANGLE_BUDGET,
+		ERROR_THRESHOLD
+	};
+	
+	LLMeshReduction();
+	~LLMeshReduction();
+
+	LLPointer<LLModel> reduce(LLModel* in_model, F32 limit, S32 mode);
+	
+private:
+	U32 mCounter;
+};
+
+#endif
+
+#endif  // LL_LLMESHREDUCTION_H
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
new file mode 100644
index 00000000000..96a170ef079
--- /dev/null
+++ b/indra/newview/llmeshrepository.cpp
@@ -0,0 +1,2676 @@
+/** 
+ * @file llmeshrepository.cpp
+ * @brief Mesh repository implementation.
+ *
+ * $LicenseInfo:firstyear=2005&license=viewergpl$
+ * 
+ * Copyright (c) 2005-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "apr_pools.h"
+#include "apr_dso.h"
+
+#include "llmeshrepository.h"
+
+#include "llagent.h"
+#include "llappviewer.h"
+#include "llbufferstream.h"
+#include "llcurl.h"
+#include "llfasttimer.h"
+#include "llfloatermodelpreview.h"
+#include "llfloaterperms.h"
+#include "lleconomy.h"
+#include "llimagej2c.h"
+#include "llhost.h"
+#include "llnotificationsutil.h"
+#include "llsd.h"
+#include "llsdutil_math.h"
+#include "llsdserialize.h"
+#include "llthread.h"
+#include "llvfile.h"
+#include "llviewercontrol.h"
+#include "llviewermenufile.h"
+#include "llviewerobjectlist.h"
+#include "llviewerregion.h"
+#include "llviewertexturelist.h"
+#include "llvolume.h"
+#include "llvolumemgr.h"
+#include "llvovolume.h"
+#include "llworld.h"
+#include "material_codes.h"
+#include "pipeline.h"
+
+
+#include <queue>
+
+#if LL_MESH_ENABLED
+
+LLFastTimer::DeclareTimer FTM_MESH_UPDATE("Mesh Update");
+LLFastTimer::DeclareTimer FTM_LOAD_MESH("Load Mesh");
+
+LLMeshRepository gMeshRepo;
+
+const U32 MAX_MESH_REQUESTS_PER_SECOND = 100;
+
+U32 LLMeshRepository::sBytesReceived = 0;
+U32 LLMeshRepository::sHTTPRequestCount = 0;
+U32 LLMeshRepository::sHTTPRetryCount = 0;
+U32 LLMeshRepository::sCacheBytesRead = 0;
+U32 LLMeshRepository::sCacheBytesWritten = 0;
+U32 LLMeshRepository::sPeakKbps = 0;
+	
+
+std::string header_lod[] = 
+{
+	"lowest_lod",
+	"low_lod",
+	"medium_lod",
+	"high_lod"
+};
+
+
+//get the number of bytes resident in memory for given volume
+U32 get_volume_memory_size(const LLVolume* volume)
+{
+	U32 indices = 0;
+	U32 vertices = 0;
+
+	for (U32 i = 0; i < volume->getNumVolumeFaces(); ++i)
+	{
+		const LLVolumeFace& face = volume->getVolumeFace(i);
+		indices += face.mNumIndices;
+		vertices += face.mNumVertices;
+	}
+
+
+	return indices*2+vertices*11+sizeof(LLVolume)+sizeof(LLVolumeFace)*volume->getNumVolumeFaces();
+}
+
+std::string scrub_host_name(std::string http_url, const LLHost& host)
+{ //curl loves to abuse the DNS cache, so scrub host names out of urls where trivial to prevent DNS timeouts
+	std::string ip_string = host.getIPString();
+	std::string host_string = host.getHostName();
+
+	std::string::size_type idx = http_url.find(host_string);
+
+	if (!ip_string.empty() && !host_string.empty() && idx != std::string::npos)
+	{
+		http_url.replace(idx, host_string.length(), ip_string);
+	}
+
+	return http_url;
+}
+
+LLVertexBuffer* get_vertex_buffer_from_mesh(LLCDMeshData& mesh, F32 scale = 1.f)
+{
+	LLVertexBuffer* buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL, 0);
+	buff->allocateBuffer(mesh.mNumTriangles*3, 0, true);
+
+	LLStrider<LLVector3> pos;
+	LLStrider<LLVector3> norm;
+
+	buff->getVertexStrider(pos);
+	buff->getNormalStrider(norm);
+
+	const F32* v = mesh.mVertexBase;
+	
+	if (mesh.mIndexType == LLCDMeshData::INT_16)
+	{
+		U16* idx = (U16*) mesh.mIndexBase;
+		for (S32 j = 0; j < mesh.mNumTriangles; ++j)
+		{ 
+			F32* mp0 = (F32*) ((U8*)v+idx[0]*mesh.mVertexStrideBytes);
+			F32* mp1 = (F32*) ((U8*)v+idx[1]*mesh.mVertexStrideBytes);
+			F32* mp2 = (F32*) ((U8*)v+idx[2]*mesh.mVertexStrideBytes);
+
+			idx = (U16*) (((U8*)idx)+mesh.mIndexStrideBytes);
+			
+			LLVector3 v0(mp0);
+			LLVector3 v1(mp1);
+			LLVector3 v2(mp2);
+
+			LLVector3 n = (v1-v0)%(v2-v0);
+			n.normalize();
+
+			*pos++ = v0*scale;
+			*pos++ = v1*scale;
+			*pos++ = v2*scale;
+
+			*norm++ = n;
+			*norm++ = n;
+			*norm++ = n;			
+		}
+	}
+	else
+	{
+		U32* idx = (U32*) mesh.mIndexBase;
+		for (S32 j = 0; j < mesh.mNumTriangles; ++j)
+		{ 
+			F32* mp0 = (F32*) ((U8*)v+idx[0]*mesh.mVertexStrideBytes);
+			F32* mp1 = (F32*) ((U8*)v+idx[1]*mesh.mVertexStrideBytes);
+			F32* mp2 = (F32*) ((U8*)v+idx[2]*mesh.mVertexStrideBytes);
+
+			idx = (U32*) (((U8*)idx)+mesh.mIndexStrideBytes);
+			
+			LLVector3 v0(mp0);
+			LLVector3 v1(mp1);
+			LLVector3 v2(mp2);
+
+			LLVector3 n = (v1-v0)%(v2-v0);
+			n.normalize();
+
+			*(pos++) = v0*scale;
+			*(pos++) = v1*scale;
+			*(pos++) = v2*scale;
+
+			*(norm++) = n;
+			*(norm++) = n;
+			*(norm++) = n;			
+		}
+	}
+
+	return buff;
+}
+
+S32 LLMeshRepoThread::sActiveHeaderRequests = 0;
+S32 LLMeshRepoThread::sActiveLODRequests = 0;
+U32	LLMeshRepoThread::sMaxConcurrentRequests = 1;
+
+
+class LLTextureCostResponder : public LLCurl::Responder
+{
+public:
+	LLTextureUploadData mData;
+	LLMeshUploadThread* mThread;
+
+	LLTextureCostResponder(LLTextureUploadData data, LLMeshUploadThread* thread) 
+		: mData(data), mThread(thread)
+	{
+
+	}
+
+	virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+	{
+		mThread->mPendingConfirmations--;
+		if (isGoodStatus(status))
+		{
+			mThread->priceResult(mData, content);	
+		}
+		else
+		{
+			llwarns << status << ": " << reason << llendl;
+			llwarns << "Retrying. (" << ++mData.mRetries << ")" << llendl;
+			
+			if (status == 499)
+			{
+				mThread->uploadTexture(mData);
+			}
+			else
+			{
+				llerrs << "Unhandled status " << status << llendl;
+			}
+		}
+	}
+};
+
+class LLTextureUploadResponder : public LLCurl::Responder
+{
+public:
+	LLTextureUploadData mData;
+	LLMeshUploadThread* mThread;
+
+	LLTextureUploadResponder(LLTextureUploadData data, LLMeshUploadThread* thread)
+		: mData(data), mThread(thread)
+	{
+	}
+
+	virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+	{
+		mThread->mPendingUploads--;
+		if (isGoodStatus(status))
+		{
+			mData.mUUID = content["new_asset"].asUUID();
+			gMeshRepo.updateInventory(LLMeshRepository::inventory_data(mData.mPostData, content));
+			mThread->onTextureUploaded(mData);
+		}
+		else
+		{
+			llwarns << status << ": " << reason << llendl;
+			llwarns << "Retrying. (" << ++mData.mRetries << ")" << llendl;
+
+			if (status == 404)
+			{
+				mThread->uploadTexture(mData);
+			}
+			else if (status == 499)
+			{
+				mThread->mConfirmedTextureQ.push(mData);
+			}
+			else
+			{
+				llerrs << "Unhandled status " << status << llendl;
+			}
+		}
+	}
+};
+
+class LLMeshCostResponder : public LLCurl::Responder
+{
+public:
+	LLMeshUploadData mData;
+	LLMeshUploadThread* mThread;
+
+	LLMeshCostResponder(LLMeshUploadData data, LLMeshUploadThread* thread) 
+		: mData(data), mThread(thread)
+	{
+
+	}
+
+	virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+	{
+		mThread->mPendingConfirmations--;
+
+		if (isGoodStatus(status))
+		{
+			mThread->priceResult(mData, content);	
+		}
+		else
+		{
+			llwarns << status << ": " << reason << llendl;
+			llwarns << "Retrying. (" << ++mData.mRetries << ")" << llendl;
+			
+			if (status == 499)
+			{
+				mThread->uploadModel(mData);
+			}
+			else if (status == 400)
+			{
+				llwarns << "Status 400 received from server, giving up." << llendl;
+			}
+			else
+			{
+				llerrs << "Unhandled status " << status << llendl;
+			}
+		}
+	}
+};
+
+class LLMeshUploadResponder : public LLCurl::Responder
+{
+public:
+	LLMeshUploadData mData;
+	LLMeshUploadThread* mThread;
+
+	LLMeshUploadResponder(LLMeshUploadData data, LLMeshUploadThread* thread)
+		: mData(data), mThread(thread)
+	{
+	}
+
+	virtual void completed(U32 status, const std::string& reason, const LLSD& content)
+	{
+		mThread->mPendingUploads--;
+		if (isGoodStatus(status))
+		{
+			mData.mUUID = content["new_asset"].asUUID();
+			if (mData.mUUID.isNull())
+			{
+				LLSD args;
+				std::string message = content["error"]["message"];
+				std::string identifier = content["error"]["identifier"];
+				std::string invalidity_identifier = content["error"]["invalidity_identifier"];
+
+				args["MESSAGE"] = message;
+				args["IDENTIFIER"] = identifier;
+				args["INVALIDITY_IDENTIFIER"] = invalidity_identifier;
+				args["LABEL"] = mData.mBaseModel->mLabel;
+
+				gMeshRepo.uploadError(args);
+			}
+			else
+			{
+				gMeshRepo.updateInventory(LLMeshRepository::inventory_data(mData.mPostData, content));
+				mThread->onModelUploaded(mData);
+			}
+		}
+		else
+		{
+			llwarns << status << ": " << reason << llendl;
+			llwarns << "Retrying. (" << ++mData.mRetries << ")" << llendl;
+
+			if (status == 404)
+			{
+				mThread->uploadModel(mData);
+			}
+			else if (status == 499)
+			{
+				mThread->mConfirmedQ.push(mData);
+			}
+			else if (status != 500)
+			{ //drop internal server errors on the floor, otherwise grab
+				llerrs << "Unhandled status " << status << llendl;
+			}
+		}
+	}
+};
+
+
+class LLMeshHeaderResponder : public LLCurl::Responder
+{
+public:
+	LLVolumeParams mMeshParams;
+	
+	LLMeshHeaderResponder(const LLVolumeParams& mesh_params)
+		: mMeshParams(mesh_params)
+	{
+	}
+
+	virtual void completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer);
+
+};
+
+class LLMeshLODResponder : public LLCurl::Responder
+{
+public:
+	LLVolumeParams mMeshParams;
+	S32 mLOD;
+	U32 mRequestedBytes;
+	U32 mOffset;
+
+	LLMeshLODResponder(const LLVolumeParams& mesh_params, S32 lod, U32 offset, U32 requested_bytes)
+		: mMeshParams(mesh_params), mLOD(lod), mOffset(offset), mRequestedBytes(requested_bytes)
+	{
+	}
+
+	virtual void completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer);
+
+};
+
+class LLMeshSkinInfoResponder : public LLCurl::Responder
+{
+public:
+	LLUUID mMeshID;
+	U32 mRequestedBytes;
+	U32 mOffset;
+
+	LLMeshSkinInfoResponder(const LLUUID& id, U32 offset, U32 size)
+		: mMeshID(id), mRequestedBytes(size), mOffset(offset)
+	{
+	}
+
+	virtual void completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer);
+
+};
+
+class LLMeshDecompositionResponder : public LLCurl::Responder
+{
+public:
+	LLUUID mMeshID;
+	U32 mRequestedBytes;
+	U32 mOffset;
+
+	LLMeshDecompositionResponder(const LLUUID& id, U32 offset, U32 size)
+		: mMeshID(id), mRequestedBytes(size), mOffset(offset)
+	{
+	}
+
+	virtual void completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer);
+
+};
+
+
+LLMeshRepoThread::LLMeshRepoThread()
+: LLThread("mesh repo", NULL) 
+{ 
+	mWaiting = false;
+	mMutex = new LLMutex(NULL);
+	mHeaderMutex = new LLMutex(NULL);
+	mSignal = new LLCondition(NULL);
+}
+
+LLMeshRepoThread::~LLMeshRepoThread()
+{
+	
+}
+
+void LLMeshRepoThread::run()
+{
+	mCurlRequest = new LLCurlRequest();
+	LLCDResult res =	LLConvexDecomposition::initThread();
+	if (res != LLCD_OK)
+	{
+		llwarns << "convex decomposition unable to be loaded" << llendl;
+	}
+
+	while (!LLApp::isQuitting())
+	{
+		mWaiting = true;
+		mSignal->wait();
+		mWaiting = false;
+
+		if (!LLApp::isQuitting())
+		{
+			static U32 count = 0;
+
+			static F32 last_hundred = gFrameTimeSeconds;
+
+			if (gFrameTimeSeconds - last_hundred > 1.f)
+			{ //a second has gone by, clear count
+				last_hundred = gFrameTimeSeconds;
+				count = 0;	
+			}
+
+			// NOTE: throttling intentionally favors LOD requests over header requests
+			
+			while (!mLODReqQ.empty() && count < MAX_MESH_REQUESTS_PER_SECOND && sActiveLODRequests < sMaxConcurrentRequests)
+			{
+				{
+					LLMutexLock lock(mMutex);
+					LODRequest req = mLODReqQ.front();
+					mLODReqQ.pop();
+					if (fetchMeshLOD(req.mMeshParams, req.mLOD))
+					{
+						count++;
+					}
+				}
+			}
+
+			while (!mHeaderReqQ.empty() && count < MAX_MESH_REQUESTS_PER_SECOND && sActiveHeaderRequests < sMaxConcurrentRequests)
+			{
+				{
+					LLMutexLock lock(mMutex);
+					HeaderRequest req = mHeaderReqQ.front();
+					mHeaderReqQ.pop();
+					if (fetchMeshHeader(req.mMeshParams))
+					{
+						count++;
+					}
+				}
+			}
+
+			{
+				std::set<LLUUID> incomplete;
+				for (std::set<LLUUID>::iterator iter = mSkinRequests.begin(); iter != mSkinRequests.end(); ++iter)
+				{
+					LLUUID mesh_id = *iter;
+					if (!fetchMeshSkinInfo(mesh_id))
+					{
+						incomplete.insert(mesh_id);
+					}
+				}
+				mSkinRequests = incomplete;
+			}
+
+			{
+				std::set<LLUUID> incomplete;
+				for (std::set<LLUUID>::iterator iter = mDecompositionRequests.begin(); iter != mDecompositionRequests.end(); ++iter)
+				{
+					LLUUID mesh_id = *iter;
+					if (!fetchMeshDecomposition(mesh_id))
+					{
+						incomplete.insert(mesh_id);
+					}
+				}
+				mDecompositionRequests = incomplete;
+			}
+
+
+		}
+
+		mCurlRequest->process();
+	}
+	
+	res = LLConvexDecomposition::quitThread();
+	if (res != LLCD_OK)
+	{
+		llwarns << "convex decomposition unable to be quit" << llendl;
+	}
+
+	delete mCurlRequest;
+	delete mMutex;
+}
+
+void LLMeshRepoThread::loadMeshSkinInfo(const LLUUID& mesh_id)
+{ //protected by mSignal, no locking needed here
+	mSkinRequests.insert(mesh_id);
+}
+
+void LLMeshRepoThread::loadMeshDecomposition(const LLUUID& mesh_id)
+{ //protected by mSignal, no locking needed here
+	mDecompositionRequests.insert(mesh_id);
+}
+	
+void LLMeshRepoThread::loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
+{ //protected by mSignal, no locking needed here
+
+	mesh_header_map::iterator iter = mMeshHeader.find(mesh_params.getSculptID());
+	if (iter != mMeshHeader.end())
+	{ //if we have the header, request LOD byte range
+		LODRequest req(mesh_params, lod);
+		mLODReqQ.push(req);
+	}
+	else
+	{ 
+		HeaderRequest req(mesh_params);
+		
+		pending_lod_map::iterator pending = mPendingLOD.find(mesh_params);
+
+		if (pending != mPendingLOD.end())
+		{ //append this lod request to existing header request
+			pending->second.push_back(lod);
+			if (pending->second.size() > 4)
+			{
+				llerrs << "WTF?" << llendl;
+			} 
+		}
+		else
+		{ //if no header request is pending, fetch header
+			mHeaderReqQ.push(req);
+			mPendingLOD[mesh_params].push_back(lod);
+		}
+	}
+}
+
+//static 
+std::string LLMeshRepoThread::constructUrl(LLUUID mesh_id)
+{
+	std::string http_url;
+	
+	if (gAgent.getRegion())
+	{
+		http_url = gAgent.getRegion()->getCapability("GetMesh");
+		scrub_host_name(http_url, gAgent.getRegionHost());
+	}
+
+	if (!http_url.empty())
+	{
+		http_url += "/?mesh_id=";
+		http_url += mesh_id.asString().c_str();
+	}
+	else
+	{
+		llwarns << "Current region does not have GetMesh capability!  Cannot load " << mesh_id << ".mesh" << llendl;
+	}
+
+	return http_url;
+}
+
+bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
+{ //protected by mMutex
+	mHeaderMutex->lock();
+
+	if (mMeshHeader.find(mesh_id) == mMeshHeader.end())
+	{ //we have no header info for this mesh, do nothing
+		mHeaderMutex->unlock();
+		return false;
+	}
+
+	U32 header_size = mMeshHeaderSize[mesh_id];
+
+	if (header_size > 0)
+	{
+		S32 offset = header_size + mMeshHeader[mesh_id]["skin"]["offset"].asInteger();
+		S32 size = mMeshHeader[mesh_id]["skin"]["size"].asInteger();
+
+		mHeaderMutex->unlock();
+
+		if (offset >= 0 && size > 0)
+		{
+			//check VFS for mesh skin info
+			LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH);
+			if (file.getSize() >= offset+size)
+			{
+				LLMeshRepository::sCacheBytesRead += size;
+				file.seek(offset);
+				U8* buffer = new U8[size];
+				file.read(buffer, size);
+
+				//make sure buffer isn't all 0's (reserved block but not written)
+				bool zero = true;
+				for (S32 i = 0; i < llmin(size, 1024) && zero; ++i)
+				{
+					zero = buffer[i] > 0 ? false : true;
+				}
+
+				if (!zero)
+				{ //attempt to parse
+					if (skinInfoReceived(mesh_id, buffer, size))
+					{
+						delete[] buffer;
+						return true;
+					}
+				}
+
+				delete[] buffer;
+			}
+
+			//reading from VFS failed for whatever reason, fetch from sim
+			std::vector<std::string> headers;
+			headers.push_back("Accept: application/octet-stream");
+
+			std::string http_url = constructUrl(mesh_id);
+			if (!http_url.empty())
+			{
+				++sActiveLODRequests;
+				LLMeshRepository::sHTTPRequestCount++;
+				mCurlRequest->getByteRange(constructUrl(mesh_id), headers, offset, size,
+										   new LLMeshSkinInfoResponder(mesh_id, offset, size));
+			}
+		}
+	}
+	else
+	{	
+		mHeaderMutex->unlock();
+	}
+
+	//early out was not hit, effectively fetched
+	return true;
+}
+
+bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
+{ //protected by mMutex
+	mHeaderMutex->lock();
+
+	if (mMeshHeader.find(mesh_id) == mMeshHeader.end())
+	{ //we have no header info for this mesh, do nothing
+		mHeaderMutex->unlock();
+		return false;
+	}
+
+	U32 header_size = mMeshHeaderSize[mesh_id];
+
+	if (header_size > 0)
+	{
+		S32 offset = header_size + mMeshHeader[mesh_id]["decomposition"]["offset"].asInteger();
+		S32 size = mMeshHeader[mesh_id]["decomposition"]["size"].asInteger();
+
+		mHeaderMutex->unlock();
+
+		if (offset >= 0 && size > 0)
+		{
+			//check VFS for mesh skin info
+			LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH);
+			if (file.getSize() >= offset+size)
+			{
+				LLMeshRepository::sCacheBytesRead += size;
+				file.seek(offset);
+				U8* buffer = new U8[size];
+				file.read(buffer, size);
+
+				//make sure buffer isn't all 0's (reserved block but not written)
+				bool zero = true;
+				for (S32 i = 0; i < llmin(size, 1024) && zero; ++i)
+				{
+					zero = buffer[i] > 0 ? false : true;
+				}
+
+				if (!zero)
+				{ //attempt to parse
+					if (decompositionReceived(mesh_id, buffer, size))
+					{
+						delete[] buffer;
+						return true;
+					}
+				}
+
+				delete[] buffer;
+			}
+
+			//reading from VFS failed for whatever reason, fetch from sim
+			std::vector<std::string> headers;
+			headers.push_back("Accept: application/octet-stream");
+
+			std::string http_url = constructUrl(mesh_id);
+			if (!http_url.empty())
+			{
+				++sActiveLODRequests;
+				LLMeshRepository::sHTTPRequestCount++;
+				mCurlRequest->getByteRange(constructUrl(mesh_id), headers, offset, size,
+										   new LLMeshDecompositionResponder(mesh_id, offset, size));
+			}
+		}
+	}
+	else
+	{	
+		mHeaderMutex->unlock();
+	}
+
+	//early out was not hit, effectively fetched
+	return true;
+}
+
+bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params)
+{
+	bool retval = false;
+
+	{
+		//look for mesh in asset in vfs
+		LLVFile file(gVFS, mesh_params.getSculptID(), LLAssetType::AT_MESH);
+			
+		S32 size = file.getSize();
+
+		if (size > 0)
+		{
+			U8 buffer[1024];
+			S32 bytes = llmin(size, 1024);
+			LLMeshRepository::sCacheBytesRead += bytes;	
+			file.read(buffer, bytes);
+			if (headerReceived(mesh_params, buffer, bytes))
+			{ //did not do an HTTP request, return false
+				return false;
+			}
+		}
+	}
+
+	//either cache entry doesn't exist or is corrupt, request header from simulator
+
+	std::vector<std::string> headers;
+	headers.push_back("Accept: application/octet-stream");
+
+	std::string http_url = constructUrl(mesh_params.getSculptID());
+	if (!http_url.empty())
+	{
+		++sActiveHeaderRequests;
+		retval = true;
+		//grab first 4KB if we're going to bother with a fetch.  Cache will prevent future fetches if a full mesh fits
+		//within the first 4KB
+		LLMeshRepository::sHTTPRequestCount++;
+		mCurlRequest->getByteRange(http_url, headers, 0, 4096, new LLMeshHeaderResponder(mesh_params));
+	}
+
+	return retval;
+}
+
+bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
+{ //protected by mMutex
+	mHeaderMutex->lock();
+
+	bool retval = false;
+
+	LLUUID mesh_id = mesh_params.getSculptID();
+	
+	U32 header_size = mMeshHeaderSize[mesh_id];
+
+	if (header_size > 0)
+	{
+		S32 offset = header_size + mMeshHeader[mesh_id][header_lod[lod]]["offset"].asInteger();
+		S32 size = mMeshHeader[mesh_id][header_lod[lod]]["size"].asInteger();
+		mHeaderMutex->unlock();
+		if (offset >= 0 && size > 0)
+		{
+
+			//check VFS for mesh asset
+			LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH);
+			if (file.getSize() >= offset+size)
+			{
+				LLMeshRepository::sCacheBytesRead += size;
+				file.seek(offset);
+				U8* buffer = new U8[size];
+				file.read(buffer, size);
+
+				//make sure buffer isn't all 0's (reserved block but not written)
+				bool zero = true;
+				for (S32 i = 0; i < llmin(size, 1024) && zero; ++i)
+				{
+					zero = buffer[i] > 0 ? false : true;
+				}
+
+				if (!zero)
+				{ //attempt to parse
+					if (lodReceived(mesh_params, lod, buffer, size))
+					{
+						delete[] buffer;
+						return false;
+					}
+				}
+
+				delete[] buffer;
+			}
+
+			//reading from VFS failed for whatever reason, fetch from sim
+			std::vector<std::string> headers;
+			headers.push_back("Accept: application/octet-stream");
+
+			std::string http_url = constructUrl(mesh_id);
+			if (!http_url.empty())
+			{
+				++sActiveLODRequests;
+				retval = true;
+				LLMeshRepository::sHTTPRequestCount++;
+				mCurlRequest->getByteRange(constructUrl(mesh_id), headers, offset, size,
+										   new LLMeshLODResponder(mesh_params, lod, offset, size));
+			}
+			else
+			{
+				mUnavailableQ.push(LODRequest(mesh_params, lod));
+			}
+		}
+		else
+		{
+			mUnavailableQ.push(LODRequest(mesh_params, lod));
+		}
+	}
+	else
+	{
+		mHeaderMutex->unlock();
+	}
+
+	return retval;
+}
+
+bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* data, S32 data_size)
+{
+	LLSD header;
+	
+	U32 header_size = 0;
+	if (data_size > 0)
+	{
+		std::string res_str((char*) data, data_size);
+
+		std::istringstream stream(res_str);
+
+		if (!LLSDSerialize::deserialize(header, stream, data_size))
+		{
+			llwarns << "Mesh header parse error.  Not a valid mesh asset!" << llendl;
+			return false;
+		}
+
+		header_size = stream.tellg();
+	}
+	else
+	{
+		header["404"] = 1;
+	}
+
+	{
+		U32 cost = gMeshRepo.calcResourceCost(header);
+
+		LLUUID mesh_id = mesh_params.getSculptID();
+		
+		mHeaderMutex->lock();
+		mMeshHeaderSize[mesh_id] = header_size;
+		mMeshHeader[mesh_id] = header;
+		mMeshResourceCost[mesh_id] = cost;
+		mHeaderMutex->unlock();
+
+		//check for pending requests
+		pending_lod_map::iterator iter = mPendingLOD.find(mesh_params);
+		if (iter != mPendingLOD.end())
+		{
+			for (U32 i = 0; i < iter->second.size(); ++i)
+			{
+				LODRequest req(mesh_params, iter->second[i]);
+				mLODReqQ.push(req);
+			}
+		}
+		mPendingLOD.erase(iter);
+	}
+
+	return true;
+}
+
+bool LLMeshRepoThread::lodReceived(const LLVolumeParams& mesh_params, S32 lod, U8* data, S32 data_size)
+{
+	LLVolume* volume = new LLVolume(mesh_params, LLVolumeLODGroup::getVolumeScaleFromDetail(lod));
+	std::string mesh_string((char*) data, data_size);
+	std::istringstream stream(mesh_string);
+
+	if (volume->unpackVolumeFaces(stream, data_size))
+	{
+		LoadedMesh mesh(volume, mesh_params, lod);
+		if (volume->getNumFaces() > 0)
+		{
+			LLMutexLock lock(mMutex);
+			mLoadedQ.push(mesh);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+bool LLMeshRepoThread::skinInfoReceived(const LLUUID& mesh_id, U8* data, S32 data_size)
+{
+	LLSD skin;
+
+	if (data_size > 0)
+	{
+		std::string res_str((char*) data, data_size);
+
+		std::istringstream stream(res_str);
+
+		if (!unzip_llsd(skin, stream, data_size))
+		{
+			llwarns << "Mesh skin info parse error.  Not a valid mesh asset!" << llendl;
+			return false;
+		}
+	}
+	
+	{
+		LLMeshSkinInfo info;
+		info.mMeshID = mesh_id;
+
+		if (skin.has("joint_names"))
+		{
+			for (U32 i = 0; i < skin["joint_names"].size(); ++i)
+			{
+				info.mJointNames.push_back(skin["joint_names"][i]);
+			}
+		}
+
+		if (skin.has("inverse_bind_matrix"))
+		{
+			for (U32 i = 0; i < skin["inverse_bind_matrix"].size(); ++i)
+			{
+				LLMatrix4 mat;
+				for (U32 j = 0; j < 4; j++)
+				{
+					for (U32 k = 0; k < 4; k++)
+					{
+						mat.mMatrix[j][k] = skin["inverse_bind_matrix"][i][j*4+k].asReal();
+					}
+				}
+
+				info.mInvBindMatrix.push_back(mat);
+			}
+		}
+
+		if (skin.has("bind_shape_matrix"))
+		{
+			for (U32 j = 0; j < 4; j++)
+			{
+				for (U32 k = 0; k < 4; k++)
+				{
+					info.mBindShapeMatrix.mMatrix[j][k] = skin["bind_shape_matrix"][j*4+k].asReal();
+				}
+			}
+		}
+
+		mSkinInfoQ.push(info);
+	}
+
+	return true;
+}
+
+bool LLMeshRepoThread::decompositionReceived(const LLUUID& mesh_id, U8* data, S32 data_size)
+{
+	LLSD decomp;
+
+	if (data_size > 0)
+	{
+		std::string res_str((char*) data, data_size);
+
+		std::istringstream stream(res_str);
+
+		if (!unzip_llsd(decomp, stream, data_size))
+		{
+			llwarns << "Mesh decomposition parse error.  Not a valid mesh asset!" << llendl;
+			return false;
+		}
+	}
+	
+	{
+		LLMeshDecomposition* d = new LLMeshDecomposition();
+		d->mMeshID = mesh_id;
+
+		// updated for const-correctness. gcc is picky about this type of thing - Nyx
+		const LLSD::Binary& hulls = decomp["HullList"].asBinary();
+		const LLSD::Binary& position = decomp["Position"].asBinary();
+
+		U16* p = (U16*) &position[0];
+
+		d->mHull.resize(hulls.size());
+
+		LLVector3 min;
+		LLVector3 max;
+		LLVector3 range;
+
+		min.setValue(decomp["Min"]);
+		max.setValue(decomp["Max"]);
+		range = max-min;
+
+		for (U32 i = 0; i < hulls.size(); ++i)
+		{
+			U8 count = hulls[i];
+			
+			for (U32 j = 0; j < count; ++j)
+			{
+				d->mHull[i].push_back(LLVector3(
+					(F32) p[0]/65535.f*range.mV[0]+min.mV[0],
+					(F32) p[1]/65535.f*range.mV[1]+min.mV[1],
+					(F32) p[2]/65535.f*range.mV[2]+min.mV[2]));
+				p += 3;
+			}		 
+
+		}
+			
+		//get mesh for decomposition
+		for (U32 i = 0; i < d->mHull.size(); ++i)
+		{
+			LLCDHull hull;
+			hull.mNumVertices = d->mHull[i].size();
+			hull.mVertexBase = d->mHull[i][0].mV;
+			hull.mVertexStrideBytes = 12;
+
+			LLCDMeshData mesh;
+			LLCDResult res = LLCD_OK;
+			if (LLConvexDecomposition::getInstance() != NULL)
+			{
+				res = LLConvexDecomposition::getInstance()->getMeshFromHull(&hull, &mesh);
+			}
+			if (res != LLCD_OK)
+			{
+				llwarns << "could not get mesh from hull from convex decomposition lib." << llendl;
+				return false;
+			}
+
+
+			d->mMesh.push_back(get_vertex_buffer_from_mesh(mesh));
+		}	
+
+		mDecompositionQ.push(d);
+	}
+
+	return true;
+}
+
+LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, LLVector3& scale, bool upload_textures)
+: LLThread("mesh upload")
+{
+	mInstanceList = data;
+	mUploadTextures = upload_textures;
+	mMutex = new LLMutex(NULL);
+	mCurlRequest = NULL;
+	mPendingConfirmations = 0;
+	mPendingUploads = 0;
+	mPendingCost = 0;
+	mFinished = false;
+	mOrigin = gAgent.getPositionAgent();
+	mHost = gAgent.getRegionHost();
+	mUploadObjectAssetCapability = gAgent.getRegion()->getCapability("UploadObjectAsset");
+	mNewInventoryCapability = gAgent.getRegion()->getCapability("NewFileAgentInventoryVariablePrice");
+
+	mOrigin += gAgent.getAtAxis() * scale.magVec();
+	
+	scrub_host_name(mUploadObjectAssetCapability, mHost);
+	scrub_host_name(mNewInventoryCapability, mHost);
+}
+
+LLMeshUploadThread::~LLMeshUploadThread()
+{
+
+}
+
+void LLMeshUploadThread::run()
+{
+	mCurlRequest = new LLCurlRequest();
+
+	//build map of LLModel refs to instances for callbacks
+	for (instance_list::iterator iter = mInstanceList.begin(); iter != mInstanceList.end(); ++iter)
+	{
+		mInstance[iter->mModel].push_back(*iter);
+	}
+
+	std::set<LLPointer<LLViewerTexture> > textures;
+
+	//populate upload queue with relevant models
+	for (instance_map::iterator iter = mInstance.begin(); iter != mInstance.end(); ++iter)
+	{
+		LLMeshUploadData data;
+		data.mBaseModel = iter->first;
+
+		LLModelInstance& instance = *(iter->second.begin());
+
+		for (S32 i = 0; i < 5; i++)
+		{
+			data.mModel[i] = instance.mLOD[i];
+		}
+
+		uploadModel(data);
+
+		if (mUploadTextures)
+		{
+			for (std::vector<LLImportMaterial>::iterator material_iter = instance.mMaterial.begin();
+				material_iter != instance.mMaterial.end(); ++material_iter)
+			{
+
+				if (textures.find(material_iter->mDiffuseMap) == textures.end())
+				{
+					textures.insert(material_iter->mDiffuseMap);
+					
+					LLTextureUploadData data(material_iter->mDiffuseMap, material_iter->mDiffuseMapLabel);
+					uploadTexture(data);
+				}
+			}
+		}
+	}
+
+
+	//upload textures
+	bool done = false;
+	do
+	{
+		if (!mTextureQ.empty())
+		{
+			sendCostRequest(mTextureQ.front());
+			mTextureQ.pop();
+		}
+
+		if (!mConfirmedTextureQ.empty())
+		{
+			doUploadTexture(mConfirmedTextureQ.front());
+			mConfirmedTextureQ.pop();
+		}
+
+		mCurlRequest->process();
+
+		done = mTextureQ.empty() && mConfirmedTextureQ.empty();
+	}
+	while (!done || mCurlRequest->getQueued() > 0);
+
+	LLSD object_asset;
+	object_asset["objects"] = LLSD::emptyArray();
+
+	done = false;
+	do 
+	{
+		static S32 count = 0;
+		static F32 last_hundred = gFrameTimeSeconds;
+		if (gFrameTimeSeconds - last_hundred > 1.f)
+		{
+			last_hundred = gFrameTimeSeconds;
+			count = 0;
+		}
+
+		//how many requests to push before calling process
+		const S32 PUSH_PER_PROCESS = 32;
+
+		S32 tcount = llmin(count+PUSH_PER_PROCESS, 100);
+
+		while (!mUploadQ.empty() && count < tcount)
+		{ //send any pending upload requests
+			mMutex->lock();
+			LLMeshUploadData data = mUploadQ.front();
+			mUploadQ.pop();
+			mMutex->unlock();
+			sendCostRequest(data);
+			count++;
+		}
+
+		tcount = llmin(count+PUSH_PER_PROCESS, 100);
+		
+		while (!mConfirmedQ.empty() && count < tcount)
+		{ //process any meshes that have been confirmed for upload
+			LLMeshUploadData& data = mConfirmedQ.front();
+			doUploadModel(data);
+			mConfirmedQ.pop();
+			count++;
+		}
+	
+		tcount = llmin(count+PUSH_PER_PROCESS, 100);
+
+		while (!mInstanceQ.empty() && count < tcount)
+		{ //create any objects waiting for upload
+			count++;
+			object_asset["objects"].append(createObject(mInstanceQ.front()));
+			mInstanceQ.pop();
+		}
+			
+		mCurlRequest->process();
+			
+		done = mInstanceQ.empty() && mConfirmedQ.empty() && mUploadQ.empty();
+	}
+	while (!done || mCurlRequest->getQueued() > 0);
+
+	delete mCurlRequest;
+	mCurlRequest = NULL;
+
+	// now upload the object asset
+	std::string url = mUploadObjectAssetCapability;
+	LLHTTPClient::post(url, object_asset, new LLHTTPClient::Responder());
+
+	mFinished = true;
+}
+
+void LLMeshUploadThread::uploadModel(LLMeshUploadData& data)
+{ //called from arbitrary thread
+	{
+		LLMutexLock lock(mMutex);
+		mUploadQ.push(data);
+	}
+}
+
+void LLMeshUploadThread::uploadTexture(LLTextureUploadData& data)
+{ //called from mesh upload thread
+	mTextureQ.push(data);	
+}
+
+
+static LLFastTimer::DeclareTimer FTM_NOTIFY_MESH_LOADED("Notify Loaded");
+static LLFastTimer::DeclareTimer FTM_NOTIFY_MESH_UNAVAILABLE("Notify Unavailable");
+
+void LLMeshRepoThread::notifyLoadedMeshes()
+{
+	while (!mLoadedQ.empty())
+	{
+		mMutex->lock();
+		LoadedMesh mesh = mLoadedQ.front();
+		mLoadedQ.pop();
+		mMutex->unlock();
+		
+		if (mesh.mVolume && mesh.mVolume->getNumVolumeFaces() > 0)
+		{
+			gMeshRepo.notifyMeshLoaded(mesh.mMeshParams, mesh.mVolume);
+		}
+		else
+		{
+			gMeshRepo.notifyMeshUnavailable(mesh.mMeshParams, 
+				LLVolumeLODGroup::getVolumeDetailFromScale(mesh.mVolume->getDetail()));
+		}
+	}
+
+	while (!mUnavailableQ.empty())
+	{
+		mMutex->lock();
+		LODRequest req = mUnavailableQ.front();
+		mUnavailableQ.pop();
+		mMutex->unlock();
+		
+		gMeshRepo.notifyMeshUnavailable(req.mMeshParams, req.mLOD);
+	}
+
+	while (!mSkinInfoQ.empty())
+	{
+		gMeshRepo.notifySkinInfoReceived(mSkinInfoQ.front());
+		mSkinInfoQ.pop();
+	}
+
+	while (!mDecompositionQ.empty())
+	{
+		gMeshRepo.notifyDecompositionReceived(mDecompositionQ.front());
+		mDecompositionQ.pop();
+	}
+}
+
+S32 LLMeshRepoThread::getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod) 
+{ //only ever called from main thread
+	lod = llclamp(lod, 0, 3);
+
+	LLMutexLock lock(mHeaderMutex);
+	mesh_header_map::iterator iter = mMeshHeader.find(mesh_params.getSculptID());
+
+	if (iter != mMeshHeader.end())
+	{
+		LLSD& header = iter->second;
+
+		if (header.has("404"))
+		{
+			return -1;
+		}
+
+		if (header[header_lod[lod]]["size"].asInteger() > 0)
+		{
+			return lod;
+		}
+
+		//search down to find the next available lower lod
+		for (S32 i = lod-1; i >= 0; --i)
+		{
+			if (header[header_lod[i]]["size"].asInteger() > 0)
+			{
+				return i;
+			}
+		}
+
+		//search up to find then ext available higher lod
+		for (S32 i = lod+1; i < 4; ++i)
+		{
+			if (header[header_lod[i]]["size"].asInteger() > 0)
+			{
+				return i;
+			}
+		}
+
+		//header exists and no good lod found, treat as 404
+		header["404"] = 1;
+		return -1;
+	}
+
+	return lod;
+}
+
+U32 LLMeshRepoThread::getResourceCost(const LLUUID& mesh_id)
+{
+	LLMutexLock lock(mHeaderMutex);
+	
+	std::map<LLUUID, U32>::iterator iter = mMeshResourceCost.find(mesh_id);
+	if (iter != mMeshResourceCost.end())
+	{
+		return iter->second;
+	}
+
+	return 0;
+}
+
+void LLMeshRepository::cacheOutgoingMesh(LLMeshUploadData& data, LLSD& header)
+{
+	mThread->mMeshHeader[data.mUUID] = header;
+
+	// we cache the mesh for default parameters
+	LLVolumeParams volume_params;
+	volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+	volume_params.setSculptID(data.mUUID, LL_SCULPT_TYPE_MESH);
+
+	for (U32 i = 0; i < 4; i++)
+	{
+		if (data.mModel[i].notNull())
+		{
+			LLPointer<LLVolume> volume = new LLVolume(volume_params, LLVolumeLODGroup::getVolumeScaleFromDetail(i));
+			volume->copyVolumeFaces(data.mModel[i]);
+		}
+	}
+
+}
+
+void LLMeshLODResponder::completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer)
+{
+
+	LLMeshRepoThread::sActiveLODRequests--;
+	S32 data_size = buffer->countAfter(channels.in(), NULL);
+
+	if (status < 200 || status > 400)
+	{
+		llwarns << status << ": " << reason << llendl;
+	}
+
+	if (data_size < mRequestedBytes)
+	{
+		if (status == 499 || status == 503)
+		{ //timeout or service unavailable, try again
+			LLMeshRepository::sHTTPRetryCount++;
+			gMeshRepo.mThread->loadMeshLOD(mMeshParams, mLOD);
+		}
+		else
+		{
+			llwarns << "Unhandled status " << status << llendl;
+		}
+		return;
+	}
+
+	LLMeshRepository::sBytesReceived += mRequestedBytes;
+
+	U8* data = NULL;
+
+	if (data_size > 0)
+	{
+		data = new U8[data_size];
+		buffer->readAfter(channels.in(), NULL, data, data_size);
+	}
+
+	if (gMeshRepo.mThread->lodReceived(mMeshParams, mLOD, data, data_size))
+	{
+		//good fetch from sim, write to VFS for caching
+		LLVFile file(gVFS, mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLVFile::WRITE);
+
+		S32 offset = mOffset;
+		S32 size = mRequestedBytes;
+
+		if (file.getSize() >= offset+size)
+		{
+			file.seek(offset);
+			file.write(data, size);
+			LLMeshRepository::sCacheBytesWritten += size;
+		}
+	}
+
+	delete [] data;
+}
+
+void LLMeshSkinInfoResponder::completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer)
+{
+	S32 data_size = buffer->countAfter(channels.in(), NULL);
+
+	if (status < 200 || status > 400)
+	{
+		llwarns << status << ": " << reason << llendl;
+	}
+
+	if (data_size < mRequestedBytes)
+	{
+		if (status == 499 || status == 503)
+		{ //timeout or service unavailable, try again
+			LLMeshRepository::sHTTPRetryCount++;
+			gMeshRepo.mThread->loadMeshSkinInfo(mMeshID);
+		}
+		else
+		{
+			llwarns << "Unhandled status " << status << llendl;
+		}
+		return;
+	}
+
+	LLMeshRepository::sBytesReceived += mRequestedBytes;
+
+	U8* data = NULL;
+
+	if (data_size > 0)
+	{
+		data = new U8[data_size];
+		buffer->readAfter(channels.in(), NULL, data, data_size);
+	}
+
+	if (gMeshRepo.mThread->skinInfoReceived(mMeshID, data, data_size))
+	{
+		//good fetch from sim, write to VFS for caching
+		LLVFile file(gVFS, mMeshID, LLAssetType::AT_MESH, LLVFile::WRITE);
+
+		S32 offset = mOffset;
+		S32 size = mRequestedBytes;
+
+		if (file.getSize() >= offset+size)
+		{
+			LLMeshRepository::sCacheBytesWritten += size;
+			file.seek(offset);
+			file.write(data, size);
+		}
+	}
+
+	delete [] data;
+}
+
+void LLMeshDecompositionResponder::completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer)
+{
+	S32 data_size = buffer->countAfter(channels.in(), NULL);
+
+	if (status < 200 || status > 400)
+	{
+		llwarns << status << ": " << reason << llendl;
+	}
+
+	if (data_size < mRequestedBytes)
+	{
+		if (status == 499 || status == 503)
+		{ //timeout or service unavailable, try again
+			LLMeshRepository::sHTTPRetryCount++;
+			gMeshRepo.mThread->loadMeshDecomposition(mMeshID);
+		}
+		else
+		{
+			llwarns << "Unhandled status " << status << llendl;
+		}
+		return;
+	}
+
+	LLMeshRepository::sBytesReceived += mRequestedBytes;
+
+	U8* data = NULL;
+
+	if (data_size > 0)
+	{
+		data = new U8[data_size];
+		buffer->readAfter(channels.in(), NULL, data, data_size);
+	}
+
+	if (gMeshRepo.mThread->decompositionReceived(mMeshID, data, data_size))
+	{
+		//good fetch from sim, write to VFS for caching
+		LLVFile file(gVFS, mMeshID, LLAssetType::AT_MESH, LLVFile::WRITE);
+
+		S32 offset = mOffset;
+		S32 size = mRequestedBytes;
+
+		if (file.getSize() >= offset+size)
+		{
+			LLMeshRepository::sCacheBytesWritten += size;
+			file.seek(offset);
+			file.write(data, size);
+		}
+	}
+
+	delete [] data;
+}
+
+void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer)
+{
+	LLMeshRepoThread::sActiveHeaderRequests--;
+	if (status < 200 || status > 400)
+	{
+		llwarns << status << ": " << reason << llendl;
+	}
+
+	S32 data_size = buffer->countAfter(channels.in(), NULL);
+
+	U8* data = NULL;
+
+	if (data_size > 0)
+	{
+		data = new U8[data_size];
+		buffer->readAfter(channels.in(), NULL, data, data_size);
+	}
+
+	LLMeshRepository::sBytesReceived += llmin(data_size, 4096);
+
+	if (!gMeshRepo.mThread->headerReceived(mMeshParams, data, data_size))
+	{
+		llwarns << "Header responder failed with status: " << status << ": " << reason << llendl;
+		if (status == 503 || status == 499)
+		{ //retry
+			LLMeshRepository::sHTTPRetryCount++;
+			LLMeshRepoThread::HeaderRequest req(mMeshParams);
+			gMeshRepo.mThread->mHeaderReqQ.push(req);
+		}
+	}
+	else if (data && data_size > 0)
+	{
+		//header was successfully retrieved from sim, cache in vfs
+		LLUUID mesh_id = mMeshParams.getSculptID();
+		LLSD header = gMeshRepo.mThread->mMeshHeader[mesh_id];
+
+		std::stringstream str;
+
+		S32 lod_bytes = 0;
+
+		for (U32 i = 0; i < LLModel::LOD_PHYSICS; ++i)
+		{ //figure out how many bytes we'll need to reserve in the file
+			std::string lod_name = header_lod[i];
+			lod_bytes = llmax(lod_bytes, header[lod_name]["offset"].asInteger()+header[lod_name]["size"].asInteger());
+		}
+		
+		//just in case skin info or decomposition is at the end of the file (which it shouldn't be)
+		lod_bytes = llmax(lod_bytes, header["skin"]["offset"].asInteger() + header["skin"]["size"].asInteger());
+		lod_bytes = llmax(lod_bytes, header["decomposition"]["offset"].asInteger() + header["decomposition"]["size"].asInteger());
+
+		S32 header_bytes = (S32) gMeshRepo.mThread->mMeshHeaderSize[mesh_id];
+		S32 bytes = lod_bytes + header_bytes; 
+
+		
+		//it's possible for the remote asset to have more data than is needed for the local cache
+		//only allocate as much space in the VFS as is needed for the local cache
+		data_size = llmin(data_size, bytes);
+
+		LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH, LLVFile::WRITE);
+		if (file.getMaxSize() >= bytes || file.setMaxSize(bytes))
+		{
+			LLMeshRepository::sCacheBytesWritten += data_size;
+
+			file.write((const U8*) data, data_size);
+			
+			//zero out the rest of the file 
+			U8 block[4096];
+			memset(block, 0, 4096);
+
+			while (bytes-file.tell() > 4096)
+			{
+				file.write(block, 4096);
+			}
+
+			S32 remaining = bytes-file.tell();
+
+			if (remaining < 0 || remaining > 4096)
+			{
+				llerrs << "Bad padding of mesh asset cache entry." << llendl;
+			}
+
+			if (remaining > 0)
+			{
+				file.write(block, remaining);
+			}
+		}
+	}
+
+	delete [] data;
+}
+
+
+LLMeshRepository::LLMeshRepository()
+: mMeshMutex(NULL),
+  mMeshThreadCount(0),
+  mThread(NULL)
+{
+
+}
+
+void LLMeshRepository::init()
+{
+	mMeshMutex = new LLMutex(NULL);
+	
+	mDecompThread = new LLPhysicsDecomp();
+	mDecompThread->start();
+
+	while (!mDecompThread->mInited)
+	{ //wait for physics decomp thread to init
+		apr_sleep(100);
+	}
+
+	mThread = new LLMeshRepoThread();
+	mThread->start();
+}
+
+void LLMeshRepository::shutdown()
+{
+	mThread->mSignal->signal();
+
+	delete mThread;
+	mThread = NULL;
+
+	for (U32 i = 0; i < mUploads.size(); ++i)
+	{
+		delete mUploads[i];
+	}
+
+	mUploads.clear();
+
+	delete mMeshMutex;
+	mMeshMutex = NULL;
+
+	if (mDecompThread)
+	{
+		mDecompThread->shutdown();
+		delete mDecompThread;
+		mDecompThread = NULL;
+	}
+}
+
+
+S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_params, S32 detail)
+{
+	if (detail < 0 || detail > 4)
+	{
+		return detail;
+	}
+
+	LLFastTimer t(FTM_LOAD_MESH); 
+
+	{
+		LLMutexLock lock(mMeshMutex);
+		//add volume to list of loading meshes
+		mesh_load_map::iterator iter = mLoadingMeshes[detail].find(mesh_params);
+		if (iter != mLoadingMeshes[detail].end())
+		{ //request pending for this mesh, append volume id to list
+			iter->second.insert(vobj->getID());
+		}
+		else
+		{
+			//first request for this mesh
+			mLoadingMeshes[detail][mesh_params].insert(vobj->getID());
+			mPendingRequests.push_back(LLMeshRepoThread::LODRequest(mesh_params, detail));
+		}
+	}
+
+	//do a quick search to see if we can't display something while we wait for this mesh to load
+	LLVolume* volume = vobj->getVolume();
+
+	if (volume)
+	{
+		if (volume->getNumVolumeFaces() == 0 && !volume->isTetrahedron())
+		{
+			volume->makeTetrahedron();
+		}
+
+		LLVolumeParams params = volume->getParams();
+
+		LLVolumeLODGroup* group = LLPrimitive::getVolumeManager()->getGroup(params);
+
+		if (group)
+		{
+			//first see what the next lowest LOD available might be
+			for (S32 i = detail-1; i >= 0; --i)
+			{
+				LLVolume* lod = group->refLOD(i);
+				if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0)
+				{
+					group->derefLOD(lod);
+					return i;
+				}
+
+				group->derefLOD(lod);
+			}
+
+			//no lower LOD is a available, is a higher lod available?
+			for (S32 i = detail+1; i < 4; ++i)
+			{
+				LLVolume* lod = group->refLOD(i);
+				if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0)
+				{
+					group->derefLOD(lod);
+					return i;
+				}
+
+				group->derefLOD(lod);
+			}
+		}
+		else
+		{
+			llerrs << "WTF?" << llendl;
+		}
+	}
+
+	return detail;
+}
+
+static LLFastTimer::DeclareTimer FTM_START_MESH_THREAD("Start Thread");
+static LLFastTimer::DeclareTimer FTM_LOAD_MESH_LOD("Load LOD");
+static LLFastTimer::DeclareTimer FTM_MESH_LOCK1("Lock 1");
+static LLFastTimer::DeclareTimer FTM_MESH_LOCK2("Lock 2");
+
+void LLMeshRepository::notifyLoadedMeshes()
+{ //called from main thread
+
+	LLMeshRepoThread::sMaxConcurrentRequests = gSavedSettings.getU32("MeshMaxConcurrentRequests");
+
+	//clean up completed upload threads
+	for (std::vector<LLMeshUploadThread*>::iterator iter = mUploads.begin(); iter != mUploads.end(); )
+	{
+		LLMeshUploadThread* thread = *iter;
+
+		if (thread->isStopped() && thread->finished())
+		{
+			iter = mUploads.erase(iter);
+			delete thread;
+		}
+		else
+		{
+			++iter;
+		}
+	}
+
+	//update inventory
+	if (!mInventoryQ.empty())
+	{
+		LLMutexLock lock(mMeshMutex);
+		while (!mInventoryQ.empty())
+		{
+			inventory_data& data = mInventoryQ.front();
+
+			LLAssetType::EType asset_type = LLAssetType::lookup(data.mPostData["asset_type"].asString());
+			LLInventoryType::EType inventory_type = LLInventoryType::lookup(data.mPostData["inventory_type"].asString());
+
+			on_new_single_inventory_upload_complete(
+				asset_type,
+				inventory_type,
+				data.mPostData["asset_type"].asString(),
+				data.mPostData["folder_id"].asUUID(),
+				data.mPostData["name"],
+				data.mPostData["description"],
+				data.mResponse,
+				0);
+			
+			mInventoryQ.pop();
+		}
+	}
+	
+	if (!mThread->mWaiting)
+	{ //curl thread is churning, wait for it to go idle
+		return;
+	}
+
+	LLFastTimer t(FTM_MESH_UPDATE);
+
+	{
+		LLFastTimer t(FTM_MESH_LOCK1);
+		mMeshMutex->lock();	
+	}
+
+	{
+		LLFastTimer t(FTM_MESH_LOCK2);
+		mThread->mMutex->lock();
+	}
+	
+	//popup queued error messages from background threads
+	while (!mUploadErrorQ.empty())
+	{
+		LLNotificationsUtil::add("MeshUploadError", mUploadErrorQ.front());
+		mUploadErrorQ.pop();
+	}
+
+	S32 push_count = LLMeshRepoThread::sMaxConcurrentRequests-(LLMeshRepoThread::sActiveHeaderRequests+LLMeshRepoThread::sActiveLODRequests);
+
+	if (push_count > 0)
+	{
+		//calculate "score" for pending requests
+
+		//create score map
+		std::map<LLUUID, F32> score_map;
+
+		for (U32 i = 0; i < 4; ++i)
+		{
+			for (mesh_load_map::iterator iter = mLoadingMeshes[i].begin();  iter != mLoadingMeshes[i].end(); ++iter)
+			{
+				F32 max_score = 0.f;
+				for (std::set<LLUUID>::iterator obj_iter = iter->second.begin(); obj_iter != iter->second.end(); ++obj_iter)
+				{
+					LLViewerObject* object = gObjectList.findObject(*obj_iter);
+
+					if (object)
+					{
+						LLDrawable* drawable = object->mDrawable;
+						if (drawable)
+						{
+							F32 cur_score = drawable->getRadius()/llmax(drawable->mDistanceWRTCamera, 1.f);
+							max_score = llmax(max_score, cur_score);
+						}
+					}
+				}
+				
+				score_map[iter->first.getSculptID()] = max_score;
+			}
+		}
+
+		//set "score" for pending requests
+		for (std::vector<LLMeshRepoThread::LODRequest>::iterator iter = mPendingRequests.begin(); iter != mPendingRequests.end(); ++iter)
+		{
+			iter->mScore = score_map[iter->mMeshParams.getSculptID()];
+		}
+
+		//sort by "score"
+		std::sort(mPendingRequests.begin(), mPendingRequests.end(), LLMeshRepoThread::CompareScoreGreater());
+
+		while (!mPendingRequests.empty() && push_count > 0)
+		{
+			LLFastTimer t(FTM_LOAD_MESH_LOD);
+			LLMeshRepoThread::LODRequest& request = mPendingRequests.front();
+			mThread->loadMeshLOD(request.mMeshParams, request.mLOD);
+			mPendingRequests.erase(mPendingRequests.begin());
+			push_count--;
+		}
+	}
+
+	//send skin info requests
+	while (!mPendingSkinRequests.empty())
+	{
+		mThread->loadMeshSkinInfo(mPendingSkinRequests.front());
+		mPendingSkinRequests.pop();
+	}
+	
+	//send decomposition requests
+	while (!mPendingDecompositionRequests.empty())
+	{
+		mThread->loadMeshDecomposition(mPendingDecompositionRequests.front());
+		mPendingDecompositionRequests.pop();
+	}
+	
+	mThread->notifyLoadedMeshes();
+
+	mThread->mMutex->unlock();
+	mMeshMutex->unlock();
+
+	mThread->mSignal->signal();
+}
+
+void LLMeshRepository::notifySkinInfoReceived(LLMeshSkinInfo& info)
+{
+	mSkinMap[info.mMeshID] = info;
+	mLoadingSkins.erase(info.mMeshID);
+}
+
+void LLMeshRepository::notifyDecompositionReceived(LLMeshDecomposition* decomp)
+{
+	mDecompositionMap[decomp->mMeshID] = decomp;
+	mLoadingDecompositions.erase(decomp->mMeshID);
+}
+
+void LLMeshRepository::notifyMeshLoaded(const LLVolumeParams& mesh_params, LLVolume* volume)
+{
+	S32 detail = LLVolumeLODGroup::getVolumeDetailFromScale(volume->getDetail());
+
+	//get list of objects waiting to be notified this mesh is loaded
+	mesh_load_map::iterator obj_iter = mLoadingMeshes[detail].find(mesh_params);
+
+	if (volume && obj_iter != mLoadingMeshes[detail].end())
+	{
+		//make sure target volume is still valid
+		if (volume->getNumVolumeFaces() <= 0)
+		{
+			llwarns << "Mesh loading returned empty volume." << llendl;
+			volume->makeTetrahedron();
+		}
+		
+		{ //update system volume
+			LLVolume* sys_volume = LLPrimitive::getVolumeManager()->refVolume(mesh_params, detail);
+			if (sys_volume)
+			{
+				sys_volume->copyVolumeFaces(volume);
+				LLPrimitive::getVolumeManager()->unrefVolume(sys_volume);
+			}
+			else
+			{
+				llwarns << "Couldn't find system volume for given mesh." << llendl;
+			}
+		}
+
+		//notify waiting LLVOVolume instances that their requested mesh is available
+		for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
+		{
+			LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
+			if (vobj)
+			{
+				vobj->notifyMeshLoaded();
+			}
+		}
+		
+		mLoadingMeshes[detail].erase(mesh_params);
+	}
+}
+
+void LLMeshRepository::notifyMeshUnavailable(const LLVolumeParams& mesh_params, S32 lod)
+{
+	//get list of objects waiting to be notified this mesh is loaded
+	mesh_load_map::iterator obj_iter = mLoadingMeshes[lod].find(mesh_params);
+
+	F32 detail = LLVolumeLODGroup::getVolumeScaleFromDetail(lod);
+
+	if (obj_iter != mLoadingMeshes[lod].end())
+	{
+		for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
+		{
+			LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
+			if (vobj)
+			{
+				LLVolume* obj_volume = vobj->getVolume();
+
+				if (obj_volume && 
+					obj_volume->getDetail() == detail &&
+					obj_volume->getParams() == mesh_params)
+				{ //should force volume to find most appropriate LOD
+					vobj->setVolume(obj_volume->getParams(), lod);
+				}
+			}
+		}
+		
+		mLoadingMeshes[lod].erase(mesh_params);
+	}
+}
+
+S32 LLMeshRepository::getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
+{ 
+	return mThread->getActualMeshLOD(mesh_params, lod);
+}
+
+U32 LLMeshRepository::calcResourceCost(LLSD& header)
+{
+	U32 bytes = 0;
+
+	for (U32 i = 0; i < 4; i++)
+	{
+		bytes += header[header_lod[i]]["size"].asInteger();
+	}
+
+	bytes += header["skin"]["size"].asInteger();
+
+	return bytes/4096 + 1;
+}
+
+U32 LLMeshRepository::getResourceCost(const LLUUID& mesh_id)
+{
+	return mThread->getResourceCost(mesh_id);
+}
+
+const LLMeshSkinInfo* LLMeshRepository::getSkinInfo(const LLUUID& mesh_id)
+{
+	if (mesh_id.notNull())
+	{
+		skin_map::iterator iter = mSkinMap.find(mesh_id);
+		if (iter != mSkinMap.end())
+		{
+			return &(iter->second);
+		}
+		
+		//no skin info known about given mesh, try to fetch it
+		{
+			LLMutexLock lock(mMeshMutex);
+			//add volume to list of loading meshes
+			std::set<LLUUID>::iterator iter = mLoadingSkins.find(mesh_id);
+			if (iter == mLoadingSkins.end())
+			{ //no request pending for this skin info
+				mLoadingSkins.insert(mesh_id);
+				mPendingSkinRequests.push(mesh_id);
+			}
+		}
+	}
+
+	return NULL;
+}
+
+const LLMeshDecomposition* LLMeshRepository::getDecomposition(const LLUUID& mesh_id)
+{
+	if (mesh_id.notNull())
+	{
+		decomposition_map::iterator iter = mDecompositionMap.find(mesh_id);
+		if (iter != mDecompositionMap.end())
+		{
+			return iter->second;
+		}
+		
+		//no skin info known about given mesh, try to fetch it
+		{
+			LLMutexLock lock(mMeshMutex);
+			//add volume to list of loading meshes
+			std::set<LLUUID>::iterator iter = mLoadingDecompositions.find(mesh_id);
+			if (iter == mLoadingDecompositions.end())
+			{ //no request pending for this skin info
+				mLoadingDecompositions.insert(mesh_id);
+				mPendingDecompositionRequests.push(mesh_id);
+			}
+		}
+	}
+
+	return NULL;
+}
+
+void LLMeshRepository::uploadModel(std::vector<LLModelInstance>& data, LLVector3& scale, bool upload_textures)
+{
+	LLMeshUploadThread* thread = new LLMeshUploadThread(data, scale, upload_textures);
+	mUploads.push_back(thread);
+	thread->start();
+}
+
+void LLMeshUploadThread::sendCostRequest(LLMeshUploadData& data)
+{
+	//write model file to memory buffer
+	std::stringstream ostr;
+	
+	LLModel::physics_shape& phys_shape = data.mModel[LLModel::LOD_PHYSICS].notNull() ? 
+		data.mModel[LLModel::LOD_PHYSICS]->mPhysicsShape : 
+		data.mBaseModel->mPhysicsShape;
+
+	LLSD header = LLModel::writeModel(ostr,  
+		data.mModel[LLModel::LOD_PHYSICS],
+		data.mModel[LLModel::LOD_HIGH],
+		data.mModel[LLModel::LOD_MEDIUM],
+		data.mModel[LLModel::LOD_LOW],
+		data.mModel[LLModel::LOD_IMPOSTOR], 
+		phys_shape,
+		true);
+
+	std::string desc = data.mBaseModel->mLabel;
+	
+	// Grab the total vertex count of the model
+	// along with other information for the "asset_resources" map
+	// to send to the server.
+	LLSD asset_resources = LLSD::emptyMap();
+
+
+	std::string url = mNewInventoryCapability; 
+
+	if (!url.empty())
+	{
+		LLSD body = generate_new_resource_upload_capability_body(
+			LLAssetType::AT_MESH,
+			desc,
+			desc,
+			LLFolderType::FT_MESH,
+			LLInventoryType::IT_MESH,
+			LLFloaterPerms::getNextOwnerPerms(),
+			LLFloaterPerms::getGroupPerms(),
+			LLFloaterPerms::getEveryonePerms());
+
+		body["asset_resources"] = asset_resources;
+
+		mPendingConfirmations++;
+		LLCurlRequest::headers_t headers;
+
+		data.mPostData = body;
+
+		mCurlRequest->post(url, headers, body, new LLMeshCostResponder(data, this));
+	}	
+}
+
+void LLMeshUploadThread::sendCostRequest(LLTextureUploadData& data)
+{
+	if (data.mTexture.notNull() && data.mTexture->getDiscardLevel() >= 0)
+	{
+		LLSD asset_resources = LLSD::emptyMap();
+
+		std::string url = mNewInventoryCapability; 
+
+		if (!url.empty())
+		{
+			LLSD body = generate_new_resource_upload_capability_body(
+				LLAssetType::AT_TEXTURE,
+				data.mLabel,
+				data.mLabel,
+				LLFolderType::FT_TEXTURE,
+				LLInventoryType::IT_TEXTURE,
+				LLFloaterPerms::getNextOwnerPerms(),
+				LLFloaterPerms::getGroupPerms(),
+				LLFloaterPerms::getEveryonePerms());
+
+			body["asset_resources"] = asset_resources;
+
+			mPendingConfirmations++;
+			LLCurlRequest::headers_t headers;
+			
+			data.mPostData = body;
+			mCurlRequest->post(url, headers, body, new LLTextureCostResponder(data, this));
+		}	
+	}
+}
+
+
+void LLMeshUploadThread::doUploadModel(LLMeshUploadData& data)
+{
+	if (!data.mRSVP.empty())
+	{
+		std::stringstream ostr;
+
+		LLModel::physics_shape& phys_shape = data.mModel[LLModel::LOD_PHYSICS].notNull() ? 
+		data.mModel[LLModel::LOD_PHYSICS]->mPhysicsShape : 
+		data.mBaseModel->mPhysicsShape;
+
+		LLModel::writeModel(ostr,  
+			data.mModel[LLModel::LOD_PHYSICS],
+			data.mModel[LLModel::LOD_HIGH],
+			data.mModel[LLModel::LOD_MEDIUM],
+			data.mModel[LLModel::LOD_LOW],
+			data.mModel[LLModel::LOD_IMPOSTOR], 
+			phys_shape);
+
+		data.mAssetData = ostr.str();
+
+		LLCurlRequest::headers_t headers;
+		mPendingUploads++;
+
+		mCurlRequest->post(data.mRSVP, headers, data.mAssetData, new LLMeshUploadResponder(data, this));
+	}
+}
+
+void LLMeshUploadThread::doUploadTexture(LLTextureUploadData& data)
+{
+	if (!data.mRSVP.empty())
+	{
+		std::stringstream ostr;
+		
+		if (!data.mTexture->isRawImageValid())
+		{
+			data.mTexture->reloadRawImage(data.mTexture->getDiscardLevel());
+		}
+
+		LLPointer<LLImageJ2C> upload_file = LLViewerTextureList::convertToUploadFile(data.mTexture->getRawImage());
+		
+		ostr.write((const char*) upload_file->getData(), upload_file->getDataSize());
+
+		data.mAssetData = ostr.str();
+
+		LLCurlRequest::headers_t headers;
+		mPendingUploads++;
+
+		mCurlRequest->post(data.mRSVP, headers, data.mAssetData, new LLTextureUploadResponder(data, this));
+	}
+}
+
+
+void LLMeshUploadThread::onModelUploaded(LLMeshUploadData& data)
+{
+	createObjects(data);
+}
+
+void LLMeshUploadThread::onTextureUploaded(LLTextureUploadData& data)
+{
+	mTextureMap[data.mTexture] = data;
+}
+
+
+void LLMeshUploadThread::createObjects(LLMeshUploadData& data)
+{
+	instance_list& instances = mInstance[data.mBaseModel];
+
+	for (instance_list::iterator iter = instances.begin(); iter != instances.end(); ++iter)
+	{ //create prims that reference given mesh
+		LLModelInstance& instance = *iter;
+		instance.mMeshID = data.mUUID;
+		mInstanceQ.push(instance);
+	}
+}
+
+LLSD LLMeshUploadThread::createObject(LLModelInstance& instance)
+{
+	LLMatrix4 transformation = instance.mTransform;
+
+	if (instance.mMeshID.isNull())
+	{
+		llerrs << "WTF?" << llendl;
+	}
+
+	// check for reflection
+	BOOL reflected = (transformation.determinant() < 0);
+
+	// compute position
+	LLVector3 position = LLVector3(0, 0, 0) * transformation;
+
+	// compute scale
+	LLVector3 x_transformed = LLVector3(1, 0, 0) * transformation - position;
+	LLVector3 y_transformed = LLVector3(0, 1, 0) * transformation - position;
+	LLVector3 z_transformed = LLVector3(0, 0, 1) * transformation - position;
+	F32 x_length = x_transformed.normalize();
+	F32 y_length = y_transformed.normalize();
+	F32 z_length = z_transformed.normalize();
+	LLVector3 scale = LLVector3(x_length, y_length, z_length);
+
+    // adjust for "reflected" geometry
+	LLVector3 x_transformed_reflected = x_transformed;
+	if (reflected)
+	{
+		x_transformed_reflected *= -1.0;
+	}
+	
+	// compute rotation
+	LLMatrix3 rotation_matrix;
+	rotation_matrix.setRows(x_transformed_reflected, y_transformed, z_transformed);
+	LLQuaternion quat_rotation = rotation_matrix.quaternion();
+	quat_rotation.normalize(); // the rotation_matrix might not have been orthoginal.  make it so here.
+	LLVector3 euler_rotation;
+	quat_rotation.getEulerAngles(&euler_rotation.mV[VX], &euler_rotation.mV[VY], &euler_rotation.mV[VZ]);
+
+	//
+	// build parameter block to construct this prim
+	//
+	
+	LLSD object_params;
+
+	// create prim
+
+	// set volume params
+	U8 sculpt_type = LL_SCULPT_TYPE_MESH;
+	if (reflected)
+	{
+		sculpt_type |= LL_SCULPT_FLAG_MIRROR;
+	}
+	LLVolumeParams  volume_params;
+	volume_params.setType( LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE );
+	volume_params.setBeginAndEndS( 0.f, 1.f );
+	volume_params.setBeginAndEndT( 0.f, 1.f );
+	volume_params.setRatio  ( 1, 1 );
+	volume_params.setShear  ( 0, 0 );
+	volume_params.setSculptID(instance.mMeshID, sculpt_type);
+	object_params["shape"] = volume_params.asLLSD();
+
+	object_params["material"] = LL_MCODE_WOOD;
+
+	object_params["group-id"] = gAgent.getGroupID();
+	object_params["pos"] = ll_sd_from_vector3(position + mOrigin);
+	object_params["rotation"] = ll_sd_from_quaternion(quat_rotation);
+	object_params["scale"] = ll_sd_from_vector3(scale);
+	object_params["name"] = instance.mModel->mLabel;
+
+	// load material from dae file
+	object_params["facelist"] = LLSD::emptyArray();
+	for (S32 i = 0; i < instance.mMaterial.size(); i++)
+	{
+		LLTextureEntry te;
+		LLImportMaterial& mat = instance.mMaterial[i];
+
+		te.setColor(mat.mDiffuseColor);
+
+		LLUUID diffuse_id = mTextureMap[mat.mDiffuseMap].mUUID;
+
+		if (diffuse_id.notNull())
+		{
+			te.setID(diffuse_id);
+		}
+		else
+		{
+			te.setID(LLUUID("5748decc-f629-461c-9a36-a35a221fe21f")); // blank texture
+		}
+
+		te.setFullbright(mat.mFullbright);
+
+		object_params["facelist"][i] = te.asLLSD();
+	}
+
+	// set extra parameters
+	LLSculptParams sculpt_params;
+	sculpt_params.setSculptTexture(instance.mMeshID);
+	sculpt_params.setSculptType(sculpt_type);
+	U8 buffer[MAX_OBJECT_PARAMS_SIZE+1];
+	LLDataPackerBinaryBuffer dp(buffer, MAX_OBJECT_PARAMS_SIZE);
+	sculpt_params.pack(dp);
+	std::vector<U8> v(dp.getCurrentSize());
+	memcpy(&v[0], buffer, dp.getCurrentSize());
+	LLSD extra_parameter;
+	extra_parameter["extra_parameter"] = sculpt_params.mType;
+	extra_parameter["param_data"] = v;
+	object_params["extra_parameters"].append(extra_parameter);
+
+	return object_params;
+}
+
+void LLMeshUploadThread::priceResult(LLMeshUploadData& data, const LLSD& content)
+{
+	mPendingCost += content["upload_price"].asInteger();
+	data.mRSVP = content["rsvp"].asString();
+	data.mRSVP = scrub_host_name(data.mRSVP, mHost);
+
+	mConfirmedQ.push(data);
+}
+
+void LLMeshUploadThread::priceResult(LLTextureUploadData& data, const LLSD& content)
+{
+	mPendingCost += content["upload_price"].asInteger();
+	data.mRSVP = content["rsvp"].asString();
+	data.mRSVP = scrub_host_name(data.mRSVP, mHost);
+
+	mConfirmedTextureQ.push(data);
+}
+
+
+bool LLImportMaterial::operator<(const LLImportMaterial &rhs) const
+{
+	if (mDiffuseMap != rhs.mDiffuseMap)
+	{
+		return mDiffuseMap < rhs.mDiffuseMap;
+	}
+
+	if (mDiffuseMapFilename != rhs.mDiffuseMapFilename)
+	{
+		return mDiffuseMapFilename < rhs.mDiffuseMapFilename;
+	}
+
+	if (mDiffuseMapLabel != rhs.mDiffuseMapLabel)
+	{
+		return mDiffuseMapLabel < rhs.mDiffuseMapLabel;
+	}
+
+	if (mDiffuseColor != rhs.mDiffuseColor)
+	{
+		return mDiffuseColor < rhs.mDiffuseColor;
+	}
+
+	return mFullbright < rhs.mFullbright;
+}
+
+
+void LLMeshRepository::updateInventory(inventory_data data)
+{
+	LLMutexLock lock(mMeshMutex);
+	mInventoryQ.push(data);
+}
+
+void LLMeshRepository::uploadError(LLSD& args)
+{
+	LLMutexLock lock(mMeshMutex);
+	mUploadErrorQ.push(args);
+}
+
+
+LLPhysicsDecomp::LLPhysicsDecomp()
+: LLThread("Physics Decomp")
+{
+	mInited = false;
+	mQuitting = false;
+	mDone = false;
+	mStage = -1;
+	mContinue = 1;
+
+	mSignal = new LLCondition(NULL);
+	mMutex = new LLMutex(NULL);
+
+	setStatusMessage("Idle");
+}
+
+LLPhysicsDecomp::~LLPhysicsDecomp()
+{
+	shutdown();
+}
+
+void LLPhysicsDecomp::shutdown()
+{
+	if (mSignal)
+	{
+		mQuitting = true;
+		mContinue = 0;
+		mSignal->signal();
+
+		while (!mDone)
+		{
+			apr_sleep(100);
+		}
+	}
+}
+
+void LLPhysicsDecomp::setStatusMessage(std::string msg)
+{
+	LLMutexLock lock(mMutex);
+	mStatus = msg;
+}
+
+void LLPhysicsDecomp::execute(const char* stage, LLModel* mdl)
+{
+	LLMutexLock lock(mMutex);
+
+	if (mModel.notNull())
+	{
+		llwarns << "Not done processing previous model." << llendl;
+		return;
+	}
+
+	mModel = mdl;
+	//load model into LLCD
+	if (mdl)
+	{
+		mStage = mStageID[stage];
+				
+		U16 index_offset = 0;
+
+		if (mStage == 0)
+		{
+			mPositions.clear();
+			mIndices.clear();
+			
+			//queue up vertex positions and indices
+			for (S32 i = 0; i < mdl->getNumVolumeFaces(); ++i)
+			{
+				const LLVolumeFace& face = mdl->getVolumeFace(i);
+				if (mPositions.size() + face.mNumVertices > 65535)
+				{
+					continue;
+				}
+
+				for (U32 j = 0; j < face.mNumVertices; ++j)
+				{
+					mPositions.push_back(LLVector3(face.mPositions[j].getF32ptr()));
+				}
+
+				for (U32 j = 0; j < face.mNumIndices; ++j)
+				{
+					mIndices.push_back(face.mIndices[j]+index_offset);
+				}
+
+				index_offset += face.mNumVertices;
+			}
+		}
+
+		//signal decomposition thread
+		mSignal->signal();
+	}
+}
+
+//static
+S32 LLPhysicsDecomp::llcdCallback(const char* status, S32 p1, S32 p2)
+{	
+	LLPhysicsDecomp* comp = gMeshRepo.mDecompThread;
+	comp->setStatusMessage(llformat("%s: %d/%d", status, p1, p2));
+	return comp->mContinue;
+}
+
+void LLPhysicsDecomp::cancel()
+{
+	mContinue = 0;
+}
+
+void LLPhysicsDecomp::run()
+{
+	LLConvexDecomposition::initSystem();
+	mInited = true;
+
+	while (!mQuitting)
+	{
+		mSignal->wait();
+		if (!mQuitting)
+		{
+			//load data intoLLCD
+			if (mStage == 0)
+			{
+				mMesh.mVertexBase = mPositions[0].mV;
+				mMesh.mVertexStrideBytes = 12;
+				mMesh.mNumVertices = mPositions.size();
+
+				mMesh.mIndexType = LLCDMeshData::INT_16;
+				mMesh.mIndexBase = &(mIndices[0]);
+				mMesh.mIndexStrideBytes = 6;
+				
+				mMesh.mNumTriangles = mIndices.size()/3;
+
+				LLCDResult ret = LLCD_OK;
+				if (LLConvexDecomposition::getInstance() != NULL)
+				{
+					ret  = LLConvexDecomposition::getInstance()->setMeshData(&mMesh);
+				}
+
+				if (ret)
+				{
+					llerrs << "Convex Decomposition thread valid but could not set mesh data" << llendl;
+				}
+			}
+
+			setStatusMessage("Executing.");
+
+			mContinue = 1;
+			LLCDResult ret = LLCD_OK;
+			if (LLConvexDecomposition::getInstance() != NULL)
+			{
+				ret = LLConvexDecomposition::getInstance()->executeStage(mStage);
+			}
+
+			mContinue = 0;
+			if (ret)
+			{
+				llerrs << "Convex Decomposition thread valid but could not execute stage " << mStage << llendl;
+			}
+
+
+			setStatusMessage("Reading results");
+
+			S32 num_hulls =0;
+			if (LLConvexDecomposition::getInstance() != NULL)
+			{
+				num_hulls = LLConvexDecomposition::getInstance()->getNumHullsFromStage(mStage);
+			}
+			
+			if (mModel.isNull())
+			{
+				llerrs << "mModel should never be null here!" << llendl;
+			}
+
+			mMutex->lock();
+			mModel->mPhysicsShape.clear();
+			mModel->mPhysicsShape.resize(num_hulls);
+			mModel->mHullCenter.clear();
+			mModel->mHullCenter.resize(num_hulls);
+			std::vector<LLPointer<LLVertexBuffer> > mesh_buffer;
+			mesh_buffer.resize(num_hulls);
+			mModel->mPhysicsCenter.clearVec();
+			mModel->mPhysicsPoints = 0;
+			mMutex->unlock();
+
+			for (S32 i = 0; i < num_hulls; ++i)
+			{
+				std::vector<LLVector3> p;
+				LLCDHull hull;
+				// if LLConvexDecomposition is a stub, num_hulls should have been set to 0 above, and we should not reach this code
+				LLConvexDecomposition::getInstance()->getHullFromStage(mStage, i, &hull);
+
+				const F32* v = hull.mVertexBase;
+
+				LLVector3 hull_center;
+
+				for (S32 j = 0; j < hull.mNumVertices; ++j)
+				{
+					LLVector3 vert(v[0], v[1], v[2]); 
+					p.push_back(vert);
+					hull_center += vert;
+					v = (F32*) (((U8*) v) + hull.mVertexStrideBytes);
+				}
+
+				
+				hull_center *= 1.f/hull.mNumVertices;
+
+				LLCDMeshData mesh;
+				// if LLConvexDecomposition is a stub, num_hulls should have been set to 0 above, and we should not reach this code
+				LLConvexDecomposition::getInstance()->getMeshFromStage(mStage, i, &mesh);
+
+				mesh_buffer[i] = get_vertex_buffer_from_mesh(mesh);
+
+				mMutex->lock();
+				mModel->mPhysicsShape[i] = p;
+				mModel->mHullCenter[i] = hull_center;
+				mModel->mPhysicsPoints += hull.mNumVertices;
+				mModel->mPhysicsCenter += hull_center;
+
+				mMutex->unlock();
+			}
+
+			{
+				LLMutexLock lock(mMutex);
+				mModel->mPhysicsCenter *= 1.f/mModel->mPhysicsPoints;
+			
+				LLFloaterModelPreview::onModelDecompositionComplete(mModel, mesh_buffer);
+				//done updating model
+				mModel = NULL;
+			}
+
+			setStatusMessage("Done.");
+			LLFloaterModelPreview::sInstance->mModelPreview->refresh();
+		}
+	}
+
+	LLConvexDecomposition::quitSystem();
+
+	//delete mSignal;
+	delete mMutex;
+	mSignal = NULL;
+	mMutex = NULL;
+	mDone = true;
+}
+
+#endif
+
diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h
new file mode 100644
index 00000000000..d5e21c35cc5
--- /dev/null
+++ b/indra/newview/llmeshrepository.h
@@ -0,0 +1,471 @@
+/** 
+ * @file llmeshrepository.h
+ * @brief Client-side repository of mesh assets.
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_MESH_REPOSITORY_H
+#define LL_MESH_REPOSITORY_H
+
+#include "llassettype.h"
+#include "llmodel.h"
+#include "lluuid.h"
+#include "llviewertexture.h"
+#include "llvolume.h"
+
+#if LL_MESH_ENABLED
+
+#define LLCONVEXDECOMPINTER_STATIC 1
+
+#include "llconvexdecomposition.h"
+
+class LLVOVolume;
+class LLMeshResponder;
+class LLCurlRequest;
+class LLMutex;
+class LLCondition;
+class LLVFS;
+class LLMeshRepository;
+
+class LLMeshUploadData
+{
+public:
+	LLPointer<LLModel> mBaseModel;
+	LLPointer<LLModel> mModel[5];
+	LLUUID mUUID;
+	U32 mRetries;
+	std::string mRSVP;
+	std::string mAssetData;
+	LLSD mPostData;
+
+	LLMeshUploadData()
+	{
+		mRetries = 0;
+	}
+};
+
+class LLTextureUploadData
+{
+public:
+	LLPointer<LLViewerFetchedTexture> mTexture;
+	LLUUID mUUID;
+	std::string mRSVP;
+	std::string mLabel;
+	U32 mRetries;
+	std::string mAssetData;
+	LLSD mPostData;
+
+	LLTextureUploadData()
+	{
+		mRetries = 0;
+	}
+
+	LLTextureUploadData(LLViewerFetchedTexture* texture, std::string& label)
+		: mTexture(texture), mLabel(label)
+	{
+		mRetries = 0;
+	}
+};
+
+class LLImportMaterial
+{
+public:
+	LLPointer<LLViewerFetchedTexture> mDiffuseMap;
+	std::string mDiffuseMapFilename;
+	std::string mDiffuseMapLabel;
+	LLColor4 mDiffuseColor;
+	bool mFullbright;
+
+	bool operator<(const LLImportMaterial &params) const;
+
+	LLImportMaterial() 
+		: mFullbright(false) 
+	{ 
+		mDiffuseColor.set(1,1,1,1);
+	}
+};
+
+class LLModelInstance 
+{
+public:
+	LLPointer<LLModel> mModel;
+	LLPointer<LLModel> mLOD[5];
+	 
+	LLUUID mMeshID;
+
+	LLMatrix4 mTransform;
+	std::vector<LLImportMaterial> mMaterial;
+
+	LLModelInstance(LLModel* model, LLMatrix4& transform, std::vector<LLImportMaterial>& materials)
+		: mModel(model), mTransform(transform), mMaterial(materials)
+	{
+	}
+};
+
+class LLMeshSkinInfo 
+{
+public:
+	LLUUID mMeshID;
+	std::vector<std::string> mJointNames;
+	std::vector<LLMatrix4> mInvBindMatrix;
+	LLMatrix4 mBindShapeMatrix;
+};
+
+class LLMeshDecomposition
+{
+public:
+	LLMeshDecomposition() { }
+
+	LLUUID mMeshID;
+	LLModel::physics_shape mHull;
+
+	std::vector<LLPointer<LLVertexBuffer> > mMesh;
+};
+
+class LLPhysicsDecomp : public LLThread
+{
+public:
+	LLCondition* mSignal;
+	LLMutex* mMutex;
+	
+	LLCDMeshData mMesh;
+	
+	bool mInited;
+	bool mQuitting;
+	bool mDone;
+
+	S32 mContinue;
+	std::string mStatus;
+
+	std::vector<LLVector3> mPositions;
+	std::vector<U16> mIndices;
+
+	S32 mStage;
+
+	LLPhysicsDecomp();
+	~LLPhysicsDecomp();
+
+	void shutdown();
+	void setStatusMessage(std::string msg);
+	
+	void execute(const char* stage, LLModel* mdl);
+	static S32 llcdCallback(const char*, S32, S32);
+	void cancel();
+
+	virtual void run();
+
+	std::map<std::string, S32> mStageID;
+	LLPointer<LLModel> mModel;
+};
+
+class LLMeshRepoThread : public LLThread
+{
+public:
+
+	static S32 sActiveHeaderRequests;
+	static S32 sActiveLODRequests;
+	static U32 sMaxConcurrentRequests;
+
+	LLCurlRequest* mCurlRequest;
+	LLMutex*	mMutex;
+	LLMutex*	mHeaderMutex;
+	LLCondition* mSignal;
+
+	bool mWaiting;
+
+	//map of known mesh headers
+	typedef std::map<LLUUID, LLSD> mesh_header_map;
+	mesh_header_map mMeshHeader;
+	
+	std::map<LLUUID, U32> mMeshHeaderSize;
+	std::map<LLUUID, U32> mMeshResourceCost;
+
+	class HeaderRequest
+	{ 
+	public:
+		const LLVolumeParams mMeshParams;
+
+		HeaderRequest(const LLVolumeParams&  mesh_params)
+			: mMeshParams(mesh_params)
+		{
+		}
+
+		bool operator<(const HeaderRequest& rhs) const
+		{
+			return mMeshParams < rhs.mMeshParams;
+		}
+	};
+
+	class LODRequest
+	{
+	public:
+		LLVolumeParams  mMeshParams;
+		S32 mLOD;
+		F32 mScore;
+
+		LODRequest(const LLVolumeParams&  mesh_params, S32 lod)
+			: mMeshParams(mesh_params), mLOD(lod), mScore(0.f)
+		{
+		}
+	};
+
+	struct CompareScoreGreater
+	{
+		bool operator()(const LODRequest& lhs, const LODRequest& rhs)
+		{
+			return lhs.mScore > rhs.mScore; // greatest = first
+		}
+	};
+	
+
+	class LoadedMesh
+	{
+	public:
+		LLPointer<LLVolume> mVolume;
+		LLVolumeParams mMeshParams;
+		S32 mLOD;
+
+		LoadedMesh(LLVolume* volume, const LLVolumeParams&  mesh_params, S32 lod)
+			: mVolume(volume), mMeshParams(mesh_params), mLOD(lod)
+		{
+		}
+
+	};
+
+	//set of requested skin info
+	std::set<LLUUID> mSkinRequests;
+	
+	//queue of completed skin info requests
+	std::queue<LLMeshSkinInfo> mSkinInfoQ;
+
+	//set of requested decompositions
+	std::set<LLUUID> mDecompositionRequests;
+	
+	//queue of completed Decomposition info requests
+	std::queue<LLMeshDecomposition*> mDecompositionQ;
+
+	//queue of requested headers
+	std::queue<HeaderRequest> mHeaderReqQ;
+
+	//queue of requested LODs
+	std::queue<LODRequest> mLODReqQ;
+
+	//queue of unavailable LODs (either asset doesn't exist or asset doesn't have desired LOD)
+	std::queue<LODRequest> mUnavailableQ;
+
+	//queue of successfully loaded meshes
+	std::queue<LoadedMesh> mLoadedQ;
+
+	//map of pending header requests and currently desired LODs
+	typedef std::map<LLVolumeParams, std::vector<S32> > pending_lod_map;
+	pending_lod_map mPendingLOD;
+
+	static std::string constructUrl(LLUUID mesh_id);
+
+	LLMeshRepoThread();
+	~LLMeshRepoThread();
+
+	virtual void run();
+
+	void loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
+	bool fetchMeshHeader(const LLVolumeParams& mesh_params);
+	bool fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
+	bool headerReceived(const LLVolumeParams& mesh_params, U8* data, S32 data_size);
+	bool lodReceived(const LLVolumeParams& mesh_params, S32 lod, U8* data, S32 data_size);
+	bool skinInfoReceived(const LLUUID& mesh_id, U8* data, S32 data_size);
+	bool decompositionReceived(const LLUUID& mesh_id, U8* data, S32 data_size);
+
+	void notifyLoadedMeshes();
+	S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
+	U32 getResourceCost(const LLUUID& mesh_params);
+
+	void loadMeshSkinInfo(const LLUUID& mesh_id);
+	void loadMeshDecomposition(const LLUUID& mesh_id);
+
+	//send request for skin info, returns true if header info exists 
+	//  (should hold onto mesh_id and try again later if header info does not exist)
+	bool fetchMeshSkinInfo(const LLUUID& mesh_id);
+
+	//send request for decomposition, returns true if header info exists 
+	//  (should hold onto mesh_id and try again later if header info does not exist)
+	bool fetchMeshDecomposition(const LLUUID& mesh_id);
+};
+
+class LLMeshUploadThread : public LLThread 
+{
+public:
+	typedef std::vector<LLModelInstance> instance_list;
+	instance_list mInstanceList;
+
+	typedef std::map<LLPointer<LLModel>, instance_list> instance_map;
+	instance_map mInstance;
+
+	LLMutex*					mMutex;
+	LLCurlRequest* mCurlRequest;
+	S32				mPendingConfirmations;
+	S32				mPendingUploads;
+	S32				mPendingCost;
+	bool			mFinished;
+	LLVector3		mOrigin;
+	bool			mUploadTextures;
+
+	LLHost			mHost;
+	std::string		mUploadObjectAssetCapability;
+	std::string		mNewInventoryCapability;
+
+	std::queue<LLMeshUploadData> mUploadQ;
+	std::queue<LLMeshUploadData> mConfirmedQ;
+	std::queue<LLModelInstance> mInstanceQ;
+
+	std::queue<LLTextureUploadData> mTextureQ;
+	std::queue<LLTextureUploadData> mConfirmedTextureQ;
+
+	std::map<LLPointer<LLViewerFetchedTexture>, LLTextureUploadData> mTextureMap;
+
+	LLMeshUploadThread(instance_list& data, LLVector3& scale, bool upload_textures);
+	~LLMeshUploadThread();
+
+	void uploadTexture(LLTextureUploadData& data);
+	void doUploadTexture(LLTextureUploadData& data);
+	void sendCostRequest(LLTextureUploadData& data);
+	void priceResult(LLTextureUploadData& data, const LLSD& content);
+	void onTextureUploaded(LLTextureUploadData& data);
+
+	void uploadModel(LLMeshUploadData& data);
+	void sendCostRequest(LLMeshUploadData& data);
+	void doUploadModel(LLMeshUploadData& data);
+	void onModelUploaded(LLMeshUploadData& data);
+	void createObjects(LLMeshUploadData& data);
+	LLSD createObject(LLModelInstance& instance);
+	void priceResult(LLMeshUploadData& data, const LLSD& content);
+
+	bool finished() { return mFinished; }
+	virtual void run();
+	
+};
+
+class LLMeshRepository
+{
+public:
+
+	//metrics
+	static U32 sBytesReceived;
+	static U32 sHTTPRequestCount;
+	static U32 sHTTPRetryCount;
+	static U32 sCacheBytesRead;
+	static U32 sCacheBytesWritten;
+	static U32 sPeakKbps;
+	
+
+	LLMeshRepository();
+
+	void init();
+	void shutdown();
+
+	//mesh management functions
+	S32 loadMesh(LLVOVolume* volume, const LLVolumeParams& mesh_params, S32 detail = 0);
+	
+	void notifyLoadedMeshes();
+	void notifyMeshLoaded(const LLVolumeParams& mesh_params, LLVolume* volume);
+	void notifyMeshUnavailable(const LLVolumeParams& mesh_params, S32 lod);
+	void notifySkinInfoReceived(LLMeshSkinInfo& info);
+	void notifyDecompositionReceived(LLMeshDecomposition* info);
+
+	S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
+	U32 calcResourceCost(LLSD& header);
+	U32 getResourceCost(const LLUUID& mesh_params);
+	const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id);
+	const LLMeshDecomposition* getDecomposition(const LLUUID& mesh_id);
+
+	void uploadModel(std::vector<LLModelInstance>& data, LLVector3& scale, bool upload_textures);
+
+	
+
+
+	typedef std::map<LLVolumeParams, std::set<LLUUID> > mesh_load_map;
+	mesh_load_map mLoadingMeshes[4];
+	
+	typedef std::map<LLUUID, LLMeshSkinInfo> skin_map;
+	skin_map mSkinMap;
+
+	typedef std::map<LLUUID, LLMeshDecomposition*> decomposition_map;
+	decomposition_map mDecompositionMap;
+
+	LLMutex*					mMeshMutex;
+	
+	std::vector<LLMeshRepoThread::LODRequest> mPendingRequests;
+	
+	//list of mesh ids awaiting skin info
+	std::set<LLUUID> mLoadingSkins;
+
+	//list of mesh ids that need to send skin info fetch requests
+	std::queue<LLUUID> mPendingSkinRequests;
+
+	//list of mesh ids awaiting decompositions
+	std::set<LLUUID> mLoadingDecompositions;
+
+	//list of mesh ids that need to send decomposition fetch requests
+	std::queue<LLUUID> mPendingDecompositionRequests;
+	
+	U32 mMeshThreadCount;
+
+	void cacheOutgoingMesh(LLMeshUploadData& data, LLSD& header);
+	
+	LLMeshRepoThread* mThread;
+	std::vector<LLMeshUploadThread*> mUploads;
+
+	LLPhysicsDecomp* mDecompThread;
+	
+	class inventory_data
+	{
+	public:
+		LLSD mPostData;
+		LLSD mResponse;
+
+		inventory_data(const LLSD& data, const LLSD& content)
+			: mPostData(data), mResponse(content)
+		{
+		}
+	};
+
+	std::queue<inventory_data> mInventoryQ;
+
+	std::queue<LLSD> mUploadErrorQ;
+
+	void uploadError(LLSD& args);
+	void updateInventory(inventory_data data);
+
+};
+
+extern LLMeshRepository gMeshRepo;
+
+#endif
+
+#endif
+
-- 
GitLab


From e41525cac444ecacb96f18178de21b844c4fbe45 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 26 Aug 2010 17:06:34 -0500
Subject: [PATCH 679/683] Fix for crash when rendering translation handles.

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

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 64238b2008d..40ab3a3476c 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -901,7 +901,7 @@ LLVector3 LLRender::getUITranslation()
 {
 	if (mUIOffset.empty())
 	{
-		llerrs << "UI offset stack empty." << llendl;
+		return LLVector3(0,0,0);
 	}
 	return mUIOffset.back();
 }
@@ -910,7 +910,7 @@ LLVector3 LLRender::getUIScale()
 {
 	if (mUIScale.empty())
 	{
-		llerrs << "UI scale stack empty." << llendl;
+		return LLVector3(1,1,1);
 	}
 	return mUIScale.back();
 }
-- 
GitLab


From 8a67b31d6a775ef87d29e2c3e22e30368adf59b0 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 26 Aug 2010 17:06:59 -0500
Subject: [PATCH 680/683] Fix for various physics shape rendering glitches.

---
 indra/newview/llspatialpartition.cpp | 148 ++++++++++++++++-----------
 indra/newview/llviewerobject.h       |   7 ++
 2 files changed, 94 insertions(+), 61 deletions(-)

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index e55ec033563..291cc76c295 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2766,78 +2766,101 @@ void renderNormals(LLDrawable* drawablep)
 	}
 }
 
-void renderPhysicsShape(LLDrawable* drawable)
+void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
 {
-	LLVOVolume* volume = drawable->getVOVolume();
-	if (volume)
-	{
-		F32 threshold = gSavedSettings.getF32("ObjectCostHighThreshold");
-		F32 cost = volume->getObjectCost();
+	F32 threshold = gSavedSettings.getF32("ObjectCostHighThreshold");
+	F32 cost = volume->getObjectCost();
 
-		LLColor4 low = gSavedSettings.getColor4("ObjectCostLowColor");
-		LLColor4 mid = gSavedSettings.getColor4("ObjectCostMidColor");
-		LLColor4 high = gSavedSettings.getColor4("ObjectCostHighColor");
+	LLColor4 low = gSavedSettings.getColor4("ObjectCostLowColor");
+	LLColor4 mid = gSavedSettings.getColor4("ObjectCostMidColor");
+	LLColor4 high = gSavedSettings.getColor4("ObjectCostHighColor");
 
-		F32 normalizedCost = 1.f - exp( -(cost / threshold) );
+	F32 normalizedCost = 1.f - exp( -(cost / threshold) );
 
-		LLColor4 color;
-		if ( normalizedCost <= 0.5f )
-		{
-			color = lerp( low, mid, 2.f * normalizedCost );
-		}
-		else
-		{
-			color = lerp( mid, high, 2.f * ( normalizedCost - 0.5f ) );
-		}
+	LLColor4 color;
+	if ( normalizedCost <= 0.5f )
+	{
+		color = lerp( low, mid, 2.f * normalizedCost );
+	}
+	else
+	{
+		color = lerp( mid, high, 2.f * ( normalizedCost - 0.5f ) );
+	}
 
-		U32 data_mask = LLVertexBuffer::MAP_VERTEX;
+	U32 data_mask = LLVertexBuffer::MAP_VERTEX;
 
 #if LL_MESH_ENABLED
-		if (volume->isMesh())
-		{			
-			LLUUID mesh_id = volume->getVolume()->getParams().getSculptID();
-			const LLMeshDecomposition* decomp = gMeshRepo.getDecomposition(mesh_id);
-			if (decomp)
-			{
-				gGL.pushMatrix();
-				glMultMatrixf((F32*) volume->getRelativeXform().mMatrix);
-				
-				gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+	if (volume->isMesh())
+	{			
+		LLUUID mesh_id = volume->getVolume()->getParams().getSculptID();
+		const LLMeshDecomposition* decomp = gMeshRepo.getDecomposition(mesh_id);
+		if (decomp)
+		{
+			gGL.pushMatrix();
+			glMultMatrixf((F32*) volume->getRelativeXform().mMatrix);
+			
+			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 
-				for (U32 i = 0; i < decomp->mHull.size(); ++i)
-				{		
-					LLVertexBuffer* buff = decomp->mMesh[i];
+			for (U32 i = 0; i < decomp->mHull.size(); ++i)
+			{		
+				LLVertexBuffer* buff = decomp->mMesh[i];
 
-					buff->setBuffer(data_mask);
+				buff->setBuffer(data_mask);
 
-					glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-					glColor3fv(color.mV);
-					buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
-					glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+				glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+				glColor3fv(color.mV);
+				buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
+				glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 
-					{
-						LLGLEnable blend(GL_BLEND);
-						gGL.setSceneBlendType(LLRender::BT_ALPHA);
-						LLGLDepthTest depth(GL_TRUE, GL_FALSE);
-						glColor4fv(color.mV);
-						buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
-					}
+				{
+					LLGLEnable blend(GL_BLEND);
+					gGL.setSceneBlendType(LLRender::BT_ALPHA);
+					LLGLDepthTest depth(GL_TRUE, GL_FALSE);
+					glColor4fv(color.mV);
+					buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts());
 				}
+			}
 
-				gGL.popMatrix();
+			gGL.popMatrix();
 
-				return;
-			}
+			return;
 		}
+	}
 #endif //LL_MESH_ENABLED
-		
-		//push faces
-		glColor3fv(color.mV);
-		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-		pushVerts(drawable, data_mask);
-		glColor4fv(color.mV);
-		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-		pushVerts(drawable, data_mask);
+	
+	//push faces
+	glColor3fv(color.mV);
+	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+	pushVerts(drawable, data_mask);
+	glColor4fv(color.mV);
+	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+	pushVerts(drawable, data_mask);
+}
+
+void renderPhysicsShapes(LLSpatialGroup* group)
+{
+	LLGLEnable blend(GL_BLEND);
+	LLGLDepthTest test(GL_TRUE, GL_FALSE);
+
+	for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
+	{
+		LLDrawable* drawable = *i;
+		LLVOVolume* volume = drawable->getVOVolume();
+		if (volume && !volume->isAttachment() && volume->getPhysicsShapeType() != LLViewerObject::PHYSICS_SHAPE_NONE )
+		{
+			if (!group->mSpatialPartition->isBridge())
+			{
+				gGL.pushMatrix();
+				LLVector3 trans = drawable->getRegion()->getOriginAgent();
+				glTranslatef(trans.mV[0], trans.mV[1], trans.mV[2]);
+				renderPhysicsShape(drawable, volume);
+				gGL.popMatrix();
+			}
+			else
+			{
+				renderPhysicsShape(drawable, volume);
+			}
+		}
 	}
 }
 
@@ -3163,6 +3186,14 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 				stop_glerror();
 			}
 
+			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES))
+			{
+				group->rebuildGeom();
+				group->rebuildMesh();
+
+				renderPhysicsShapes(group);
+			}
+
 			//render visibility wireframe
 			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION))
 			{
@@ -3221,11 +3252,6 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 				renderNormals(drawable);
 			}
 			
-			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES))
-			{
-				renderPhysicsShape(drawable);
-			}
-
 			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BUILD_QUEUE))
 			{
 				if (drawable->isState(LLDrawable::IN_REBUILD_Q2))
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 649b8496440..aec920b6319 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -554,6 +554,13 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 		LL_VO_HUD_PART_GROUP =		LL_PCODE_APP | 0xc0,
 	} EVOType;
 
+	typedef enum e_physics_shape_types
+	{
+		PHYSICS_SHAPE_PRIM = 0,
+		PHYSICS_SHAPE_NONE,
+		PHYSICS_SHAPE_CONVEX_HULL,
+	} EPhysicsShapeType;
+
 	LLUUID			mID;
 
 	// unique within region, not unique across regions
-- 
GitLab


From 481367b34a90915c6f1d3d7a1f28b22547ef44b2 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 26 Aug 2010 17:18:05 -0500
Subject: [PATCH 681/683] Add missing xml files from viewer-experimental

---
 .../default/xui/en/floater_import_collada.xml |  42 +++++
 .../default/xui/en/floater_model_preview.xml  | 156 ++++++++++++++++++
 .../xui/en/floater_price_for_listing.xml      |  81 +++++++++
 3 files changed, 279 insertions(+)
 create mode 100644 indra/newview/skins/default/xui/en/floater_import_collada.xml
 create mode 100644 indra/newview/skins/default/xui/en/floater_model_preview.xml
 create mode 100644 indra/newview/skins/default/xui/en/floater_price_for_listing.xml

diff --git a/indra/newview/skins/default/xui/en/floater_import_collada.xml b/indra/newview/skins/default/xui/en/floater_import_collada.xml
new file mode 100644
index 00000000000..441ab6a2dee
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_import_collada.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater can_close="false" can_drag_on_left="false" can_minimize="false"
+     can_resize="false" height="160" min_height="160" width="300" min_width="300"
+     name="Import Collada" title="Import Scene">
+
+  <text bottom_delta="40" left="20" name="mesh count" height="15" follows="top|left">
+	Meshes: [COUNT]
+  </text>
+
+  <text bottom_delta="20" left="20" name="texture count" height="15" follows="top|left">
+	Textures: [COUNT]
+  </text>
+
+  <text bottom_delta="40" left="10" name="status" height="15" follows="top|left">
+    Status: [STATUS]
+  </text>
+
+   <button
+	  bottom_delta="40"
+      name="cancel"
+      label="Cancel"
+      enabled="true"
+      height="20"
+      layout="topleft"
+      left="125"
+      width="75" />
+
+   <button
+	  bottom_delta="0"
+      name="ok"
+      label="OK"
+      enabled="true"
+      height="20"
+      layout="topleft"
+      left="210"
+      width="75" />
+
+  <string name="status_idle">Idle</string>
+  <string name="status_uploading">Uploading [NAME]</string>
+  <string name="status_creating">Creating object [NAME]</string>
+  
+ </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml
new file mode 100644
index 00000000000..6508d2d68bf
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater can_close="true" can_drag_on_left="false" can_minimize="false"
+     can_resize="false" height="656" min_height="656" min_width="856"
+     name="Model Preview" title="Import Model" width="856">
+
+  <text bottom_delta="20" left="10" name="status" height="15" follows="top|left">
+    Status: [STATUS]
+  </text>
+
+  <string name="status_idle">Idle</string>
+  <string name="status_reading_file">Loading...</string>
+  <string name="status_generating_meshes">Generating Meshes...</string>
+  <string name="missing_lod">Cannot upload, missing required level of detail.</string>
+  <string name="bad_lod">Cannot upload, supplied levels of detail invalid.</string>"
+  <string name="too_heavy">Too many vertices.</string>
+  <string name="required">Required</string>
+  <string name="good">Good</string>
+  <string name="mesh_mismatch">Submesh count mismatch.</string>
+  <string name="model_mismatch">Model count mismatch.</string>
+  
+  <combo_box bottom_delta="20" follows="right|top" height="18" label="Preview"
+	     left="450" name="preview_lod_combo" width="120" tool_tip="LOD to view in preview render">
+    <combo_item name="preview_lowest">
+      Lowest
+    </combo_item>
+    <combo_item name="preview_low">
+      Low
+    </combo_item>
+    <combo_item name="preview_medium">
+      Medium
+    </combo_item>
+    <combo_item name="preview_high">
+      High
+    </combo_item>
+    <combo_item name="preview_high">
+      Physics
+    </combo_item>
+  </combo_box>
+ 
+  <button bottom_delta="0" left="10" width="120" name="auto fill" label="Generate LOD" tool_tip="Automatically generate levels of detail"/>
+  <button bottom_delta="0" left="140" width="120" name="smooth normals" label="Generate Normals" tool_tip="Regenerate normals based on mesh shape"/>
+  <button bottom_delta="0" left="260" width="120" name="consolidate" label="Consolidate" tool_tip="Combine similar submeshes (reduces number of submeshes)"/>
+  <button bottom_delta="30" left="260" width="120" name="scrub materials" label="Scrub Materials" tool_tip="Remove all material information (clear textures, set all colors to white)."/>
+  
+  <spinner bottom_delta="0" left="140" width="120" height="16" initial_value="75" label_width="60" name="edge threshold" decimal_digits="0" min_val="0" max_val="180" increment="5" label="Hard Angle" tool_tip="Maximum angle that will be smoothed between triangles when using Generate Normals"/>
+  <check_box bottom_delta="0" left="450" label="Show Edges" name="show edges" width="120" height="16" tool_tip="Render wireframe in preview window"/>
+  <slider bottom_delta="30" left="340" width="240" label="Explode" name="explode" height="16" initial_value="0" min_val="0" max_val="1" decimal_digits="2" increment="0.05"/>
+  <text bottom_delta="0" follows="top|left" height="15" left="10" name="high_lod_label">
+    High LOD:
+  </text>
+  <combo_box bottom_delta="0" left="97" follows="left|top" height="18" 
+             name="high detail combo" width="100" tool_tip="Specify mesh for this level of detail">
+    <combo_item name="high choose file">
+      Choose File...
+    </combo_item>
+    <combo_item name="high triangle limit">
+      Triangle Limit
+    </combo_item>
+  </combo_box>
+  <spinner bottom_delta="-5" left="200" width="120"  name="high limit" decimal_digits="0" increment="1" min_val="0" max_val="100" tool_tip="Triangle budget for this LOD"/>
+  <text bottom_delta="25" follows="top|left" height="15" left="10" name="high info" width="300">
+    [TRIANGLES] Triangles, [VERTICES] Vertices, [SUBMESHES] Submeshes.  
+    [MESSAGE]
+  </text>
+
+  <text bottom_delta="35" follows="top|left" height="15" left="10" name="medium_lod_label">
+    Medium LOD:
+  </text>
+  <combo_box bottom_delta="0" left="97" follows="left|top" height="18"
+             name="medium detail combo" width="100" tool_tip="Specify mesh for this level of detail">
+    <combo_item name="medium choose file">
+      Choose File...
+    </combo_item>
+    <combo_item name="medium triangle limit">
+      Triangle Limit
+    </combo_item>
+  </combo_box>
+  <spinner bottom_delta="-5" left="200" width="120"  name="medium limit" decimal_digits="0" increment="1" min_val="0" max_val="100" tool_tip="Triangle budget for this LOD"/>
+  <text bottom_delta="25" follows="top|left" height="15" left="10" name="medium info" width="300">
+    [TRIANGLES] Triangles, [VERTICES] Vertices, [SUBMESHES] Submeshes.  
+    [MESSAGE]
+  </text>
+
+  <text bottom_delta="35" follows="top|left" height="15" left="10" name="low_lod_label">
+    Low LOD:
+  </text>
+  <combo_box bottom_delta="0" left="97" follows="left|top" height="18" 
+             name="low detail combo" width="100" tool_tip="Specify mesh for this level of detail">
+    <combo_item name="low choose file">
+      Choose File...
+    </combo_item>
+    <combo_item name="low triangle limit">
+      Triangle Limit
+    </combo_item>
+  </combo_box>
+  <spinner bottom_delta="-5" left="200" width="120"  name="low limit" decimal_digits="0" increment="1" min_val="0" max_val="100" tool_tip="Triangle budget for this LOD"/>
+  <text bottom_delta="25" follows="top|left" height="15" left="10" name="low info" width="300">
+    [TRIANGLES] Triangles, [VERTICES] Vertices, [SUBMESHES] Submeshes
+    [MESSAGE]
+  </text>
+
+  <text bottom_delta="35" follows="top|left" height="15" left="10" name="lowest_lod_label">
+    Lowest LOD:
+  </text>
+  <combo_box bottom_delta="0" left="97" folimpostors="left|top" height="18" 
+             name="lowest detail combo" width="100" tool_tip="Specify mesh for this level of detail">
+    <combo_item name="lowest choose file">
+      Choose File...
+    </combo_item>
+    <combo_item name="lowest triangle limit">
+      Triangle Limit
+    </combo_item>
+  </combo_box>
+  <spinner bottom_delta="-5" left="200" width="120"  name="lowest limit" decimal_digits="0" increment="1" min_val="0" max_val="100" tool_tip="Triangle budget for this LOD"/>
+  <text bottom_delta="25" follows="top|left" height="15" left="10" name="lowest info" width="300">
+    [TRIANGLES] Triangles, [VERTICES] Vertices, [SUBMESHES] Submeshes
+    [MESSAGE]
+  </text>
+
+  <text bottom_delta="35" follows="top|left" height="15" left="10" name="physics_lod_label">
+    Physical Shape:
+  </text>
+  <combo_box bottom_delta="0" left="97" follows="left|top" height="18"
+             name="physics detail combo" width="100">
+    <combo_item name="physics choose file">
+      Choose File...
+    </combo_item>
+    <combo_item name="physics triangle limit">
+      Triangle Limit...
+    </combo_item>
+  </combo_box>
+  <spinner bottom_delta="-5" left="200" width="90"  name="physics limit" decimal_digits="0" increment="1" min_val="0" max_val="100" tool_tip="Triangle budget for this LOD"/>
+  <button bottom_delta="0" left="290" width="30" follows="left|top" height="20" label=">>" 
+          name="decompose_btn" tool_tip="Create convex decomposition."/>
+  <text bottom_delta="25" follows="top|left" height="15" left="10" name="physics info" width="300">
+    [TRIANGLES] Triangles, [HULLS] Hulls, [POINTS] Points
+  </text>
+  
+  <text bottom_delta="20" follows="top|left" height="15" name="description_label">
+	  Description:
+	  <!-- Info: [PRIM_COST] prim equivalents, [TEXTURES] textures. -->
+	</text>
+	<line_editor bottom_delta="24" follows="top|left|right" height="19" max_length="254"
+	     name="description_form" width="280" />
+	<button bottom_delta="25" follows="bottom|left" height="20" label="Upload"
+	     left="15" name="ok_btn" width="125" tool_tip="Upload to simulator"/>
+
+  <check_box bottom_delta="0" follow="bottom|left" height="20" label="Upload Textures"
+             left="160" width="125" name="upload_textures" tool_tip="Upload associated textures "/>
+  <text bottom_delta="20" left="15" follows="top|left" height="15" name="description_label" text_color="1 0.82 0.46 1">
+	  (No charge for upload during First Look)
+	</text>
+  <text bottom_delta="20" left="15" follows="top|left" height="15" name="upload_message">
+    [MESSAGE]
+  </text>
+ </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_price_for_listing.xml b/indra/newview/skins/default/xui/en/floater_price_for_listing.xml
new file mode 100644
index 00000000000..6312366b866
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_price_for_listing.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater
+ legacy_header_height="18"
+ can_minimize="false"
+ height="240"
+ layout="topleft"
+ name="price_for_listing"
+ help_topic="price_for_listing"
+ title="PUBLISH CLASSIFIED AD"
+ width="320">
+    <text
+     type="string"
+     length="1"
+     bottom="200"
+     follows="top|left"
+     font="SansSerif"
+     height="165"
+     layout="topleft"
+     left="15"
+     word_wrap="true"
+     name="explanation_text">
+        Your classified ad will run for one week from the day it is published.
+
+Your ad&apos;s position in the classified listings is determined by how much you choose to pay.
+
+The highest paid ads go to the top of the list, and appear higher in searches.
+    </text>
+    <text
+     type="string"
+     length="1"
+     follows="top|right"
+     font="SansSerif"
+     height="20"
+     layout="topleft"
+     left="140"
+     name="price_text"
+     top_delta="135"
+     width="85">
+        Price for Ad:
+    </text>
+    <text
+     type="string"
+     length="1"
+     follows="top|right"
+     font="SansSerif"
+     height="20"
+     layout="topleft"
+     left_pad="4"
+     name="price_symbol"
+     top_delta="0"
+     width="20">
+        L$
+    </text>
+    <line_editor
+     follows="top|left"
+     height="20"
+     layout="topleft"
+     left_pad="0"
+     max_length="6"
+     top_delta="-4"
+     name="price_edit"
+     width="60" />
+    <button
+     follows="top|left"
+     height="22"
+     label="OK"
+     layout="topleft"
+     left="105"
+     name="set_price_btn"
+     top_pad="22"
+     width="100" />
+    <button
+     follows="top|left"
+     height="22"
+     label="Cancel"
+     layout="topleft"
+     left_pad="5"
+     name="cancel_btn"
+     width="100" />
+
+</floater>
-- 
GitLab


From e763cb13b7e901eba0d5a8d6671222c31f6fd632 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 26 Aug 2010 18:35:42 -0500
Subject: [PATCH 682/683] Disable edit-and-continue (makes breakpoints not work
 on occasion).

---
 indra/cmake/00-Common.cmake | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 8262462ced4..d13fbb14d9b 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -35,10 +35,10 @@ if (WINDOWS)
   # Don't build DLLs.
   set(BUILD_SHARED_LIBS OFF)
 
-  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /ZI /MDd /MP"
+  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /MDd /MP"
       CACHE STRING "C++ compiler debug options" FORCE)
   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO 
-      "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /ZI /MD /MP"
+      "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Zi /MD /MP"
       CACHE STRING "C++ compiler release-with-debug options" FORCE)
   set(CMAKE_CXX_FLAGS_RELEASE
       "${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /MD /MP"
-- 
GitLab


From 771195865c4fb336f573025e9a7a22313bfb6cb8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 26 Aug 2010 18:36:25 -0500
Subject: [PATCH 683/683] CTS-219 Fix for broken geometry when importing from
 polygons.

---
 indra/llprimitive/llmodel.cpp | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 82765c740fc..e4b7cd80ce5 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -662,12 +662,18 @@ void load_face_from_dom_polygons(std::vector<LLVolumeFace>& face_list, std::vect
 		}
 	}
 
+	if (cur_idx != vert_idx.size())
+	{
+		llerrs << "WTF?" << llendl;
+	}
+
 	//build vertex array from map
-	verts.resize(vert_idx.size());
+	std::vector<LLVolumeFace::VertexData> new_verts;
+	new_verts.resize(vert_idx.size());
 
 	for (std::map<LLVolumeFace::VertexData, U32>::iterator iter = vert_idx.begin(); iter != vert_idx.end(); ++iter)
 	{
-		verts[iter->second] = iter->first;
+		new_verts[iter->second] = iter->first;
 		update_min_max(face.mExtents[0], face.mExtents[1], iter->first.getPosition());
 	}
 
@@ -679,8 +685,14 @@ void load_face_from_dom_polygons(std::vector<LLVolumeFace>& face_list, std::vect
 		indices[i] = vert_idx[verts[i]];
 	}
 
+	// DEBUG just build an expanded triangle list
+	/*for (U32 i = 0; i < verts.size(); ++i)
+	{
+		indices.push_back((U16) i);
+		update_min_max(face.mExtents[0], face.mExtents[1], verts[i].getPosition());
+	}*/
 
-    if (!verts.empty())
+    if (!new_verts.empty())
 	{
 		std::string material;
 
@@ -691,7 +703,7 @@ void load_face_from_dom_polygons(std::vector<LLVolumeFace>& face_list, std::vect
 
 		materials.push_back(material);
 		face_list.push_back(face);
-		face_list.rbegin()->fillFromLegacyData(verts, indices);
+		face_list.rbegin()->fillFromLegacyData(new_verts, indices);
 	}
 }
 
-- 
GitLab