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] 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 33a8d33ce1..c8ef911cc1 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 340f60ed1a..4c6d244f3c 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 3554ceb7f0..f13bb73acf 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