diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 9399342a619b9d6f99566d1288538ef921fc4929..4cf15620425d5388e6299df814ae5ddb5b93b912 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -392,15 +392,18 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) } } -void LLGLTFMaterialList::queueModify(const LLUUID& id, S32 side, const LLGLTFMaterial* mat) +void LLGLTFMaterialList::queueModify(const LLViewerObject* obj, S32 side, const LLGLTFMaterial* mat) { - if (mat == nullptr) + if (obj && obj->getRenderMaterialID(side).notNull()) { - sModifyQueue.push_back({ id, side, LLGLTFMaterial(), false }); - } - else - { - sModifyQueue.push_back({ id, side, *mat, true}); + if (mat == nullptr) + { + sModifyQueue.push_back({ obj->getID(), side, LLGLTFMaterial(), false }); + } + else + { + sModifyQueue.push_back({ obj->getID(), side, *mat, true }); + } } } @@ -437,8 +440,14 @@ void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool)) S32 i = data.size(); - for (auto& e : sModifyQueue) + for (ModifyMaterialData& e : sModifyQueue) { +#ifdef SHOW_ASSERT + // validate object has a material id + LLViewerObject* obj = gObjectList.findObject(e.object_id); + llassert(obj && obj->getRenderMaterialID(e.side).notNull()); +#endif + data[i]["object_id"] = e.object_id; data[i]["side"] = e.side; diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h index 70540e5e011c24441d1ad9fd873d706b4a9acb16..5ce0e324f5fb39023f774cb9ea476b06b604af42 100644 --- a/indra/newview/llgltfmateriallist.h +++ b/indra/newview/llgltfmateriallist.h @@ -60,7 +60,7 @@ class LLGLTFMaterialList // mat - material to apply as override, or nullptr to remove existing overrides and revert to asset // // NOTE: do not use to revert to asset when applying a new asset id, use queueApply below - static void queueModify(const LLUUID& id, S32 side, const LLGLTFMaterial* mat); + static void queueModify(const LLViewerObject* obj, S32 side, const LLGLTFMaterial* mat); // Queue an application of a material asset we want to send to the simulator. Call "flushUpdates" to flush pending updates. // object_id - ID of object to apply material asset to diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index dabc7d16eaaf72f5370e641159f2002764fe04ee..a36ddeb532e5e136f95616caafeae43c25e0fb29 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -2674,7 +2674,7 @@ class LLRenderMaterialOverrideFunctor : public LLSelectedNodeFunctor { mSuccess = true; } - LLGLTFMaterialList::queueModify(objectp->getID(), te, material); + LLGLTFMaterialList::queueModify(objectp, te, material); } return true; } diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index cf02f3c4e42b1f2ebb0ab5b39df470af498538e8..cb09ec9fbfa731644b05709c108ce7ef6fb2312f 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -152,7 +152,7 @@ void LLPanelFace::updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial* new_override = *tep->getGLTFMaterialOverride(); } mFunc(&new_override); - LLGLTFMaterialList::queueModify(object->getID(), face, &new_override); + LLGLTFMaterialList::queueModify(object, face, &new_override); return true; } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 2b6578c272b64b097377c1165ce4c397cd9316d9..1f604f3cba7880e77d5e394a0a0fd3539bfacaa1 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2219,7 +2219,7 @@ void LLSelectMgr::selectionRevertGLTFMaterials() && asset_id.notNull()) { // Restore overrides - LLGLTFMaterialList::queueModify(objectp->getID(), te, nodep->mSavedGLTFOverrideMaterials[te]); + LLGLTFMaterialList::queueModify(objectp, te, nodep->mSavedGLTFOverrideMaterials[te]); } else {