diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-09-29 22:38:40 +0300 |
|---|---|---|
| committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-09-29 22:39:32 +0300 |
| commit | 9346b45188462056698083f4f83fe8fecbe19bdf (patch) | |
| tree | 9d0ac5c1633c27d85ffb9e44d62c6d4f6c1a2a27 /indra/newview/llmaterialeditor.cpp | |
| parent | 02df55b9b366f3df98fc4b861dffa779c9d0a536 (diff) | |
SL-17653 Multi-material file support for local materials
Diffstat (limited to 'indra/newview/llmaterialeditor.cpp')
| -rw-r--r-- | indra/newview/llmaterialeditor.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 27694e9ce4..7270317b8c 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1176,6 +1176,8 @@ void LLMaterialFilePicker::notify(const std::vector<std::string>& filenames) if (filenames.size() > 0) { + // Todo: there is no point creating LLMaterialEditor before + // loading material, just creates unnessesary work if decode fails LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor"); if (me) { @@ -1235,7 +1237,7 @@ void LLMaterialFilePicker::textureLoadedCallback(BOOL success, LLViewerFetchedTe { } -void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) +void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 index) { tinygltf::TinyGLTF loader; std::string error_msg; @@ -1264,19 +1266,26 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) return; } - if (model_in.materials.empty()) + if (model_in.materials.empty() || (index >= model_in.materials.size())) { // materials are missing LLNotificationsUtil::add("CannotUploadMaterial"); return; } - if (model_in.materials.size() == 1) + if (index >= 0) { + // Prespecified material + loadMaterial(model_in, filename_lc, index); + } + else if (model_in.materials.size() == 1) + { + // Only one, just load it loadMaterial(model_in, filename_lc, 0); } else { + // Promt user to select material std::list<std::string> material_list; std::vector<tinygltf::Material>::const_iterator mat_iter = model_in.materials.begin(); std::vector<tinygltf::Material>::const_iterator mat_end = model_in.materials.end(); |
