#4294 Make upload order more deterministic

to make root prim more deterministic instead of being random each try
master
Andrey Kleshchev 2025-07-11 22:40:43 +03:00 committed by Andrey Kleshchev
parent 3da493295e
commit 07d0fbe94e
1 changed files with 22 additions and 10 deletions

View File

@ -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)
{