summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2025-07-11 22:40:43 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2025-07-12 02:22:02 +0300
commit07d0fbe94e89d0509b64232858e384a439810bb8 (patch)
tree2752641beb44b33dfd488815baa6d27d54f31b6a
parent3da493295e68481c2437465c1e0846541e9e43d8 (diff)
#4294 Make upload order more deterministic
to make root prim more deterministic instead of being random each try
-rw-r--r--indra/newview/llmeshrepository.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index b5a1bbd534..6236df1a13 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -2699,10 +2699,21 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
S32 instance_num = 0;
- for (instance_map::iterator iter = mInstance.begin(); iter != mInstance.end(); ++iter)
+ // Upload should happen in deterministic order, so sort instances by model name.
+ // Note: probably can sort by mBaseModel->mSubmodelID here as well to avoid
+ // running over the list twice.
+ std::vector<std::pair<LLModel*, instance_list>> sorted_instances(mInstance.begin(), mInstance.end());
+ std::sort(sorted_instances.begin(), sorted_instances.end(),
+ [](const std::pair<LLModel*, instance_list>& a, const std::pair<LLModel*, instance_list>& b)
+ {
+ return a.first->mLabel < b.first->mLabel;
+ });
+
+ // Handle models, ignore submodels for now
+ for (auto& iter : sorted_instances)
{
LLMeshUploadData data;
- data.mBaseModel = iter->first;
+ data.mBaseModel = iter.first;
if (data.mBaseModel->mSubmodelID)
{
@@ -2711,7 +2722,7 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
continue;
}
- LLModelInstance& first_instance = *(iter->second.begin());
+ LLModelInstance& first_instance = *(iter.second.begin());
for (S32 i = 0; i < 5; i++)
{
data.mModel[i] = first_instance.mLOD[i];
@@ -2758,8 +2769,8 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
}
// For all instances that use this model
- for (instance_list::iterator instance_iter = iter->second.begin();
- instance_iter != iter->second.end();
+ for (instance_list::iterator instance_iter = iter.second.begin();
+ instance_iter != iter.second.end();
++instance_iter)
{
@@ -2857,10 +2868,11 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
}
}
- for (instance_map::iterator iter = mInstance.begin(); iter != mInstance.end(); ++iter)
+ // Now handle the submodels.
+ for (auto& iter : sorted_instances)
{
LLMeshUploadData data;
- data.mBaseModel = iter->first;
+ data.mBaseModel = iter.first;
if (!data.mBaseModel->mSubmodelID)
{
@@ -2869,7 +2881,7 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
continue;
}
- LLModelInstance& first_instance = *(iter->second.begin());
+ LLModelInstance& first_instance = *(iter.second.begin());
for (S32 i = 0; i < 5; i++)
{
data.mModel[i] = first_instance.mLOD[i];
@@ -2916,8 +2928,8 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
}
// For all instances that use this model
- for (instance_list::iterator instance_iter = iter->second.begin();
- instance_iter != iter->second.end();
+ for (instance_list::iterator instance_iter = iter.second.begin();
+ instance_iter != iter.second.end();
++instance_iter)
{