diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llgltfmateriallist.cpp | 56 | ||||
-rw-r--r-- | indra/newview/llgltfmateriallist.h | 2 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llpanelface.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llpanelface.h | 2 |
5 files changed, 30 insertions, 38 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 048085fb71..d04a674e91 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -148,7 +148,7 @@ public: void addCallback(void(*callback)(const LLUUID& object_id, S32 side)) { - mCallbacks.push_back(callback); + mSelectionCallbacks.push_back(callback); } bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override @@ -214,6 +214,14 @@ public: return true; } + void doSelectionCallbacks(const LLUUID& object_id, S32 side) + { + for (auto& callback : mSelectionCallbacks) + { + callback(object_id, side); + } + } + void applyData(const LLGLTFOverrideCacheEntry &object_override) { // Parse the data @@ -289,41 +297,31 @@ public: // object not ready to receive override data, queue for later gGLTFMaterialList.queueOverrideUpdate(object_override.mObjectId, results[i].mSide, results[i].mMaterial); } - else if (obj && obj->isAnySelected()) + else if (obj && obj->getTE(i) && obj->getTE(i)->isSelected()) { - for (auto& override_update_callback : mCallbacks) - { - override_update_callback(object_override.mObjectId, results[i].mSide); - } + doSelectionCallbacks(object_override.mObjectId, results[i].mSide); } } else { // unblock material editor - if (obj && obj->isAnySelected()) + if (obj && obj->getTE(i) && obj->getTE(i)->isSelected()) { - for (auto& override_update_callback : mCallbacks) - { - override_update_callback(object_override.mObjectId, results[i].mSide); - } + doSelectionCallbacks(object_override.mObjectId, results[i].mSide); } } } if (obj && side_set.size() != obj->getNumTEs()) { // object exists and at least one texture entry needs to have its override data nulled out - bool object_has_selection = obj->isAnySelected(); for (int i = 0; i < obj->getNumTEs(); ++i) { if (side_set.find(i) == side_set.end()) { obj->setTEGLTFMaterialOverride(i, nullptr); - if (object_has_selection) + if (obj->getTE(i) && obj->getTE(i)->isSelected()) { - for (auto& override_update_callback : mCallbacks) - { - override_update_callback(object_override.mObjectId, i); - } + doSelectionCallbacks(object_override.mObjectId, i); } } } @@ -331,23 +329,21 @@ public: } else if (obj) { // override list was empty or an error occurred, null out all overrides for this object - bool object_has_selection = obj->isAnySelected(); for (int i = 0; i < obj->getNumTEs(); ++i) { obj->setTEGLTFMaterialOverride(i, nullptr); - if (object_has_selection) + if (obj->getTE(i) && obj->getTE(i)->isSelected()) { - for (auto& override_update_callback : mCallbacks) - { - override_update_callback(obj->getID(), i); - } + doSelectionCallbacks(obj->getID(), i); } } } }); } - std::vector<void(*)(const LLUUID& object_id, S32 side)> mCallbacks; +private: + + std::vector<void(*)(const LLUUID& object_id, S32 side)> mSelectionCallbacks; }; namespace @@ -375,23 +371,19 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) if (iter != mQueuedOverrides.end()) { - bool object_has_selection = obj->isAnySelected(); override_list_t& overrides = iter->second; for (int i = 0; i < overrides.size(); ++i) { if (overrides[i].notNull()) { - if (!obj->getTE(i)->getGLTFMaterial()) + if (!obj->getTE(i) || !obj->getTE(i)->getGLTFMaterial()) { // object doesn't have its base GLTF material yet, don't apply override (yet) return; } obj->setTEGLTFMaterialOverride(i, overrides[i]); - if (object_has_selection) + if (obj->getTE(i)->isSelected()) { - for (auto& override_update_callback : handle_gltf_override_message.mCallbacks) - { - override_update_callback(id, i); - } + handle_gltf_override_message.doSelectionCallbacks(id, i); } } } @@ -480,7 +472,7 @@ void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool)) } } -void LLGLTFMaterialList::addUpdateCallback(void(*update_callback)(const LLUUID& object_id, S32 side)) +void LLGLTFMaterialList::addSelectionUpdateCallback(void(*update_callback)(const LLUUID& object_id, S32 side)) { handle_gltf_override_message.addCallback(update_callback); } diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h index 5a184f5e94..abbb755599 100644 --- a/indra/newview/llgltfmateriallist.h +++ b/indra/newview/llgltfmateriallist.h @@ -75,7 +75,7 @@ public: // for cases that care about the done_callback forwarded to LLCoros::instance().launch static void flushUpdates(void(*done_callback)(bool) = nullptr); - static void addUpdateCallback(void(*update_callback)(const LLUUID& object_id, S32 side)); + static void addSelectionUpdateCallback(void(*update_callback)(const LLUUID& object_id, S32 side)); // Queue an explicit LLSD ModifyMaterialParams update apply given override data // overrides -- LLSD map (or array of maps) in the format: diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index f1fd276402..8c8a07bc21 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -400,7 +400,7 @@ BOOL LLMaterialEditor::postBuild() if (mIsOverride) { // Material override change success callback - LLGLTFMaterialList::addUpdateCallback(&LLMaterialEditor::updateLive); + LLGLTFMaterialList::addSelectionUpdateCallback(&LLMaterialEditor::updateLive); // Live editing needs a recovery mechanism on cancel mBaseColorTextureCtrl->setOnCancelCallback(boost::bind(&LLMaterialEditor::onCancelCtrl, this, _1, _2, MATERIAL_BASE_COLOR_TEX_DIRTY)); diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 21c824ff5c..3d72865f69 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -276,7 +276,7 @@ BOOL LLPanelFace::postBuild() getChild<LLUICtrl>("gltfTextureOffsetU")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetU, this, _1), nullptr); getChild<LLUICtrl>("gltfTextureOffsetV")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetV, this, _1), nullptr); - LLGLTFMaterialList::addUpdateCallback(&LLPanelFace::onMaterialOverrideReceived); + LLGLTFMaterialList::addSelectionUpdateCallback(&LLPanelFace::onMaterialOverrideReceived); sMaterialOverrideSelection.connect(); childSetAction("button align",&LLPanelFace::onClickAutoFix,this); @@ -2056,7 +2056,7 @@ void LLPanelFace::unloadMedia() // static void LLPanelFace::onMaterialOverrideReceived(const LLUUID& object_id, S32 side) { - sMaterialOverrideSelection.onObjectUpdated(object_id, side); + sMaterialOverrideSelection.onSelectedObjectUpdated(object_id, side); } ////////////////////////////////////////////////////////////////////////////// @@ -4771,7 +4771,7 @@ void LLPanelFace::Selection::setObjectUpdatePending(const LLUUID &object_id, S32 mPendingSide = side; } -void LLPanelFace::Selection::onObjectUpdated(const LLUUID& object_id, S32 side) +void LLPanelFace::Selection::onSelectedObjectUpdated(const LLUUID& object_id, S32 side) { if (object_id == mSelectedObjectID && side == mSelectedSide) { diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 520b399d42..24bc973bde 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -487,7 +487,7 @@ private: // Callbacks void onSelectionChanged() { mNeedsSelectionCheck = true; } - void onObjectUpdated(const LLUUID &object_id, S32 side); + void onSelectedObjectUpdated(const LLUUID &object_id, S32 side); protected: void clearObjectUpdatePending(); |