diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index e55ec03356367547690b5ce8f6d4185017df5fbe..291cc76c295e114ba40e3e9517965c4c15d80793 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 649b84964406ef4bc9273fffb6f51c3dfba0f92d..aec920b6319383f5d4d2b7afd4072b3cdd73b72f 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