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] 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 44ff173502..844918432d 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 a4142b41b0..4f17775dfd 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 f66f0c2d72..ea0aa54751 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