Skip to content

Commit 5a50be4

Browse files
committed
#4294 Make upload order more deterministic #2
1 parent d033bba commit 5a50be4

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

indra/newview/llmeshrepository.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,18 +2699,11 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
26992699

27002700
S32 instance_num = 0;
27012701

2702-
// Upload should happen in deterministic order, so sort instances by model name.
2703-
// Note: probably can sort by mBaseModel->mSubmodelID here as well to avoid
2704-
// running over the list twice.
2705-
std::vector<std::pair<LLModel*, instance_list>> sorted_instances(mInstance.begin(), mInstance.end());
2706-
std::sort(sorted_instances.begin(), sorted_instances.end(),
2707-
[](const std::pair<LLModel*, instance_list>& a, const std::pair<LLModel*, instance_list>& b)
2708-
{
2709-
return a.first->mLabel < b.first->mLabel;
2710-
});
2711-
2712-
// Handle models, ignore submodels for now
2713-
for (auto& iter : sorted_instances)
2702+
// Handle models, ignore submodels for now.
2703+
// Probably should pre-sort by mSubmodelID instead of running twice.
2704+
// Note: mInstance should be sorted by model name for the sake of
2705+
// deterministic order.
2706+
for (auto& iter : mInstance)
27142707
{
27152708
LLMeshUploadData data;
27162709
data.mBaseModel = iter.first;
@@ -2869,7 +2862,7 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
28692862
}
28702863

28712864
// Now handle the submodels.
2872-
for (auto& iter : sorted_instances)
2865+
for (auto& iter : mInstance)
28732866
{
28742867
LLMeshUploadData data;
28752868
data.mBaseModel = iter.first;

indra/newview/llmeshrepository.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,22 @@ class LLMeshUploadThread : public LLThread, public LLCore::HttpHandler
674674
typedef std::vector<LLModelInstance> instance_list;
675675
instance_list mInstanceList;
676676

677-
typedef std::map<LLPointer<LLModel>, instance_list> instance_map;
677+
// Upload should happen in deterministic order, so sort instances by model name.
678+
struct LLUploadModelInstanceLess
679+
{
680+
inline bool operator()(const LLPointer<LLModel>& a, const LLPointer<LLModel>& b) const
681+
{
682+
if (a.isNull() || b.isNull())
683+
{
684+
llassert(false); // We are uploading these models, they shouldn't be null.
685+
return true;
686+
}
687+
// Note: probably can sort by mBaseModel->mSubmodelID here as well to avoid
688+
// running over the list twice in wholeModelToLLSD.
689+
return a->mLabel < b->mLabel;
690+
}
691+
};
692+
typedef std::map<LLPointer<LLModel>, instance_list, LLUploadModelInstanceLess> instance_map;
678693
instance_map mInstance;
679694

680695
LLMutex* mMutex;

0 commit comments

Comments
 (0)