From e477a74feb21c4ddcb077c7256457b44e69fba24 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Mon, 9 Nov 2009 12:14:29 -0800
Subject: [PATCH] Better fix for DEV-42153.

---
 indra/newview/llvovolume.cpp | 39 +++++++++---------------------------
 1 file changed, 10 insertions(+), 29 deletions(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 021fc746488..09769d5e80a 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1640,38 +1640,19 @@ bool LLVOVolume::hasMedia() const
 
 LLVector3 LLVOVolume::getApproximateFaceNormal(U8 face_id)
 {
-	LLVector3 result = LLVector3::zero;
-	
-	LLFace* facep = mDrawable->getFace(face_id);
-	if(facep)
-	{
-		LLStrider<LLVector3> verticesp;
-		LLStrider<LLVector3> normalsp;
-		LLStrider<LLVector2> texCoordsp;
-		LLStrider<U16> indicesp;
-		S32 index_offset;
-		index_offset = facep->getGeometry(verticesp,normalsp,texCoordsp, indicesp);
-		
-		if(index_offset != -1 && (normalsp.get() != NULL))
+	LLVolume* volume = getVolume();
+	LLVector3 result;
+
+	if (volume && face_id < volume->getNumVolumeFaces())
+	{
+		const LLVolumeFace& face = volume->getVolumeFace(face_id);
+		for (S32 i = 0; i < face.mVertices.size(); ++i)
 		{
-			U16 count = facep->getGeomCount();
-			U16 i;
-			
-			for(i=0; i < count; i++)
-			{
-				LLVector3 normal = *normalsp++;
-//				llinfos << "adding " << normal << llendl;
-				result += normal;
-			}
+			result += face.mVertices[i].mNormal;
 		}
-	}
-	
-	if(!result.isNull())
-	{
-//		llinfos << "before conversion: " << result << llendl;
+
 		result = volumeDirectionToAgent(result);
-		result.normalize();
-//		llinfos << "after conversion: " << result << llendl;
+		result.normVec();
 	}
 	
 	return result;
-- 
GitLab