From c609a45c26dae083cedc8d06566564cb55d2e72e Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Wed, 17 Apr 2024 16:58:48 +0200 Subject: secondlife/viewer#912 BugSplat Crash 1412267 (missed refactoring for FindModel) # Conflicts: # indra/newview/llmodelpreview.cpp --- indra/newview/llmodelpreview.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'indra/newview/llmodelpreview.cpp') diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 29ab4e38c0..4ac3abd747 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -132,7 +132,7 @@ std::string getLodSuffix(S32 lod) return suffix; } -void FindModel(LLModelLoader::scene& scene, const std::string& name_to_match, LLModel*& baseModelOut, LLMatrix4& matOut) +static bool FindModel(LLModelLoader::scene& scene, const std::string& name_to_match, LLModel*& baseModelOut, LLMatrix4& matOut) { for (auto scene_iter = scene.begin(); scene_iter != scene.end(); scene_iter++) { @@ -142,10 +142,11 @@ void FindModel(LLModelLoader::scene& scene, const std::string& name_to_match, LL { baseModelOut = model_iter->mModel; matOut = scene_iter->first; - return; + return true; } } } + return false; } //----------------------------------------------------------------------------- @@ -319,10 +320,8 @@ void LLModelPreview::rebuildUploadData() mat *= scale_mat; - for (auto model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter) - { // for each instance with said transform applied - LLModelInstance instance = *model_iter; - + for (LLModelInstance& instance : iter->second) + { //for each instance with said transform applied LLModel* base_model = instance.mModel; if (base_model && !requested_name.empty()) @@ -354,7 +353,7 @@ void LLModelPreview::rebuildUploadData() } else { - //Physics can be inherited from other LODs or loaded, so we need to adjust what extension we are searching for + // Physics can be inherited from other LODs or loaded, so we need to adjust what extension we are searching for extensionLOD = mPhysicsSearchLOD; } @@ -365,9 +364,9 @@ void LLModelPreview::rebuildUploadData() name_to_match += toAdd; } - FindModel(mScene[i], name_to_match, lod_model, transform); + bool found = FindModel(mScene[i], name_to_match, lod_model, transform); - if (!lod_model && i != LLModel::LOD_PHYSICS) + if (!found && i != LLModel::LOD_PHYSICS) { if (mImporterDebug) { @@ -380,7 +379,7 @@ void LLModelPreview::rebuildUploadData() } int searchLOD = (i > LLModel::LOD_HIGH) ? LLModel::LOD_HIGH : i; - while ((searchLOD <= LLModel::LOD_HIGH) && !lod_model) + for (; searchLOD <= LLModel::LOD_HIGH; ++searchLOD) { std::string name_to_match = instance.mLabel; llassert(!name_to_match.empty()); @@ -394,8 +393,8 @@ void LLModelPreview::rebuildUploadData() // See if we can find an appropriately named model in LOD 'searchLOD' // - FindModel(mScene[searchLOD], name_to_match, lod_model, transform); - searchLOD++; + if (FindModel(mScene[searchLOD], name_to_match, lod_model, transform)) + break; } } } @@ -1174,8 +1173,7 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod) LLModel* found_model = NULL; LLMatrix4 transform; - FindModel(mBaseScene, loaded_name, found_model, transform); - if (found_model) + if (FindModel(mBaseScene, loaded_name, found_model, transform)) { // don't rename correctly named models (even if they are placed in a wrong order) name_based = true; } -- cgit v1.2.3 From 497c309a5b148fd86a0e1429343092f0a6ca2e0d Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Tue, 1 Apr 2025 15:02:24 +0300 Subject: #912 Refactor FindModel() --- indra/newview/llmodelpreview.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llmodelpreview.cpp') diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 4ac3abd747..5a8fd299bf 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -132,16 +132,16 @@ std::string getLodSuffix(S32 lod) return suffix; } -static bool FindModel(LLModelLoader::scene& scene, const std::string& name_to_match, LLModel*& baseModelOut, LLMatrix4& matOut) +static bool FindModel(const LLModelLoader::scene& scene, const std::string& name_to_match, LLModel*& baseModelOut, LLMatrix4& matOut) { - for (auto scene_iter = scene.begin(); scene_iter != scene.end(); scene_iter++) + for (const auto& scene_pair : scene) { - for (auto model_iter = scene_iter->second.begin(); model_iter != scene_iter->second.end(); model_iter++) + for (const auto& model_iter : scene_pair.second) { - if (model_iter->mModel && (model_iter->mModel->mLabel == name_to_match)) + if (model_iter.mModel && (model_iter.mModel->mLabel == name_to_match)) { - baseModelOut = model_iter->mModel; - matOut = scene_iter->first; + baseModelOut = model_iter.mModel; + matOut = scene_pair.first; return true; } } -- cgit v1.2.3 From 872fd15cafc4f35214b44fbc187e413872bd4595 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 10 May 2025 10:10:42 +0300 Subject: #4056 Crash at childGetSelectionInterface in model importer --- indra/newview/llmodelpreview.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/newview/llmodelpreview.cpp') diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 5a8fd299bf..0dbfa50769 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -2498,6 +2498,8 @@ void LLModelPreview::updateStatusMessages() S32 phys_tris = 0; S32 phys_hulls = 0; S32 phys_points = 0; + S32 which_mode = 0; + S32 file_mode = 1; //get the triangle count for the whole scene for (LLModelLoader::scene::iterator iter = mScene[LLModel::LOD_PHYSICS].begin(), endIter = mScene[LLModel::LOD_PHYSICS].end(); iter != endIter; ++iter) @@ -2619,18 +2621,16 @@ void LLModelPreview::updateStatusMessages() fmp->childEnable("simplify_cancel"); fmp->childEnable("decompose_cancel"); } - } - - LLCtrlSelectionInterface* iface = fmp->childGetSelectionInterface("physics_lod_combo"); - S32 which_mode = 0; - S32 file_mode = 1; - if (iface) - { - which_mode = iface->getFirstSelectedIndex(); - file_mode = iface->getItemCount() - 1; + LLCtrlSelectionInterface* iface = fmp->childGetSelectionInterface("physics_lod_combo"); + if (iface) + { + which_mode = iface->getFirstSelectedIndex(); + file_mode = iface->getItemCount() - 1; + } } + if (which_mode == file_mode) { mFMP->childEnable("physics_file"); -- cgit v1.2.3