diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llgltfmateriallist.cpp | 46 | ||||
-rw-r--r-- | indra/newview/llgltfmateriallist.h | 25 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 22 |
3 files changed, 84 insertions, 9 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index dabacccf66..8e184c719d 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -38,6 +38,8 @@ #include "llviewergenericmessage.h" #include "llviewerobjectlist.h" #include "llcorehttputil.h" +#include "llagent.h" + #include "tinygltf/tiny_gltf.h" #include <strstream> @@ -48,6 +50,8 @@ LLGLTFMaterialList gGLTFMaterialList; +LLGLTFMaterialList::modify_queue_t LLGLTFMaterialList::sModifyQueue; + const LLUUID LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID("968cbad0-4dad-d64e-71b5-72bf13ad051a"); namespace @@ -225,6 +229,48 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) } } +void LLGLTFMaterialList::queueModifyMaterial(const LLUUID& id, S32 side, const LLGLTFMaterial& mat) +{ + sModifyQueue.push_back({ id, side, mat, LLUUID::null, true, false }); +} + +void LLGLTFMaterialList::flushModifyMaterialQueue(void(*done_callback)(bool)) +{ + LLSD data = LLSD::emptyArray(); + + S32 i = 0; + for (auto& e : sModifyQueue) + { + data[i]["object_id"] = e.object_id; + data[i]["side"] = e.side; + + if (e.has_asset_id) + { + data[i]["asset_id"] = e.asset_id; + } + + if (e.has_override) + { + data[i]["gltf_json"] = e.override_data.asJSON(); + } + + ++i; + } + + std::stringstream str; + + LLSDSerialize::serialize(data, str, LLSDSerialize::LLSD_NOTATION, LLSDFormatter::OPTIONS_PRETTY); + LL_INFOS() << "\n" << str.str() << LL_ENDL; + + LLCoros::instance().launch("modifyMaterialCoro", + std::bind(&LLGLTFMaterialList::modifyMaterialCoro, + gAgent.getRegionCapability("ModifyMaterialParams"), + data, + done_callback)); + + sModifyQueue.clear(); +} + LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id) { LL_PROFILE_ZONE_SCOPED; diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h index bfdd9e5e32..e035d2108d 100644 --- a/indra/newview/llgltfmateriallist.h +++ b/indra/newview/llgltfmateriallist.h @@ -51,6 +51,12 @@ public: static void registerCallbacks(); + // save an override update that we want to send to the simulator for later + static void queueModifyMaterial(const LLUUID& id, S32 side, const LLGLTFMaterial& mat); + + // flush pending material updates to the simulator + static void flushModifyMaterialQueue(void(*done_callback)(bool)); + // apply given override data via given cap url // cap_url -- should be gAgent.getRegionCapability("ModifyMaterialParams") // overrides -- LLSD map in the format @@ -58,11 +64,11 @@ public: // "side": integer - index of face to be modified // "gltf_json" : string - GLTF compliant json of override data (optional, if omitted any existing override data will be cleared) static void modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool)); - // save an override update for later (for example, if an override arrived for an unknown object) + + // save an override update that we got from the simulator for later (for example, if an override arrived for an unknown object) void queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data); void applyQueuedOverrides(LLViewerObject* obj); - private: typedef std::unordered_map<LLUUID, LLPointer<LLFetchedGLTFMaterial > > uuid_mat_map_t; uuid_mat_map_t mList; @@ -72,6 +78,21 @@ private: queued_override_map_t mQueuedOverrides; LLUUID mLastUpdateKey; + + struct ModifyMaterialData + { + LLUUID object_id; + S32 side = -1; + LLGLTFMaterial override_data; + LLUUID asset_id; + + bool has_override = false; + bool has_asset_id = false; + }; + + typedef std::list<ModifyMaterialData> modify_queue_t; + static modify_queue_t sModifyQueue; + }; extern LLGLTFMaterialList gGLTFMaterialList; diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 397a302069..749b5a4c1b 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -2275,14 +2275,16 @@ public: material->setAlphaCutoff(mEditor->getAlphaCutoff(), true); } - std::string overrides_json = material->asJSON(); - #if 1 - // debug - std::string err, warn; - LLGLTFMaterial debug; - debug.fromJSON(overrides_json, warn, err); -#endif + if (mObjectTE == te + && mObjectId == objectp->getID()) + { + mSuccess = true; + } + LLGLTFMaterialList::queueModifyMaterial(objectp->getID(), te, *material); +#else + + std::string overrides_json = material->asJSON(); LLSD overrides = llsd::map( "object_id", objectp->getID(), @@ -2300,6 +2302,7 @@ public: done_callback = modifyCallback; } LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLGLTFMaterialList::modifyMaterialCoro, mCapUrl, overrides, done_callback)); +#endif } return true; } @@ -2347,6 +2350,11 @@ void LLMaterialEditor::applyToSelection() LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); LLRenderMaterialOverrideFunctor override_func(this, url, mOverrideObjectId, mOverrideObjectTE); selected_objects->applyToTEs(&override_func); + + void(*done_callback)(bool) = LLRenderMaterialOverrideFunctor::modifyCallback; + + LLGLTFMaterialList::flushModifyMaterialQueue(done_callback); + if (!override_func.getResult()) { // OverrideFunctor didn't find expected object or face |