summaryrefslogtreecommitdiff
path: root/indra/newview/llgltfmateriallist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llgltfmateriallist.cpp')
-rw-r--r--indra/newview/llgltfmateriallist.cpp171
1 files changed, 2 insertions, 169 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 8919229c78..92c58a2dbc 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -139,69 +139,18 @@ static bool is_valid_update(const LLSD& data)
}
#endif
-class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler
+class LLGLTFMaterialOverrideDispatchHandler
{
LOG_CLASS(LLGLTFMaterialOverrideDispatchHandler);
public:
LLGLTFMaterialOverrideDispatchHandler() = default;
- ~LLGLTFMaterialOverrideDispatchHandler() override = default;
+ ~LLGLTFMaterialOverrideDispatchHandler() = default;
void addCallback(void(*callback)(const LLUUID& object_id, S32 side))
{
mSelectionCallbacks.push_back(callback);
}
- bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override
- {
- LL_PROFILE_ZONE_SCOPED;
- // receive override data from simulator via LargeGenericMessage
- // message should have:
- // object_id - UUID of LLViewerObject
- // sides - array of S32 indices of texture entries
- // gltf_json - array of corresponding Strings of GLTF json for override data
-
- LLSD message;
- bool success = true;
-#if 0 //deprecated
- for(const std::string& llsdRaw : strings)
- {
- std::istringstream llsdData(llsdRaw);
- if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length()))
- {
- LL_WARNS() << "LLGLTFMaterialOverrideDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL;
- success = false;
- continue;
- }
-
- LLGLTFOverrideCacheEntry object_override;
- if (!object_override.fromLLSD(message))
- {
- // malformed message, nothing we can do to handle it
- LL_DEBUGS("GLTF") << "Message without id:" << message << LL_ENDL;
- success = false;
- continue;
- }
-
- // Cache the data
- {
- LLViewerRegion * region = LLWorld::instance().getRegionFromHandle(object_override.mRegionHandle);
-
- if (region)
- {
- region->cacheFullUpdateGLTFOverride(object_override);
- }
- else
- {
- LL_WARNS("GLTF") << "could not access region for material overrides message cache, region_handle: " << LL_ENDL;
- }
- }
- applyData(object_override);
- }
-
-#endif
- return success;
- }
-
void doSelectionCallbacks(const LLUUID& object_id, S32 side)
{
for (auto& callback : mSelectionCallbacks)
@@ -210,112 +159,6 @@ public:
}
}
- void applyData(const LLGLTFOverrideCacheEntry &object_override)
- {
- // Parse the data
-
-#if 0 // DEPRECATED
- LL::WorkQueue::ptr_t main_queue = LL::WorkQueue::getInstance("mainloop");
- LL::WorkQueue::ptr_t general_queue = LL::WorkQueue::getInstance("General");
-
- struct ReturnData
- {
- public:
- LLGLTFMaterial mMaterial;
- S32 mSide;
- bool mSuccess;
- };
-
- if (!object_override.mSides.empty())
- {
- // fromJson() is performance heavy offload to a thread.
- main_queue->postTo(
- general_queue,
- [sides=object_override.mSides]() // Work done on general queue
- {
- std::vector<ReturnData> results;
-
- results.reserve(sides.size());
- // parse json
- std::unordered_map<S32, LLSD>::const_iterator iter = sides.begin();
- std::unordered_map<S32, LLSD>::const_iterator end = sides.end();
- while (iter != end)
- {
- ReturnData result;
-
- result.mMaterial.applyOverrideLLSD(iter->second);
-
- result.mSuccess = true;
- result.mSide = iter->first;
-
- results.push_back(result);
- iter++;
- }
- return results;
- },
- [object_id=object_override.mObjectId, this](std::vector<ReturnData> results) // Callback to main thread
- {
- LLViewerObject * obj = gObjectList.findObject(object_id);
-
- if (results.size() > 0 )
- {
- std::unordered_set<S32> side_set;
-
- for (auto const & result : results)
- {
- S32 side = result.mSide;
- if (result.mSuccess)
- {
- // copy to heap here because LLTextureEntry is going to take ownership with an LLPointer
- LLGLTFMaterial * material = new LLGLTFMaterial(result.mMaterial);
-
- // flag this side to not be nulled out later
- side_set.insert(side);
-
- if (obj)
- {
- obj->setTEGLTFMaterialOverride(side, material);
- }
- }
-
- // unblock material editor
- if (obj && obj->getTE(side) && obj->getTE(side)->isSelected())
- {
- doSelectionCallbacks(object_id, side);
- }
- }
-
- if (obj && side_set.size() != obj->getNumTEs())
- { // object exists and at least one texture entry needs to have its override data nulled out
- for (int i = 0; i < obj->getNumTEs(); ++i)
- {
- if (side_set.find(i) == side_set.end())
- {
- obj->setTEGLTFMaterialOverride(i, nullptr);
- if (obj->getTE(i) && obj->getTE(i)->isSelected())
- {
- doSelectionCallbacks(object_id, i);
- }
- }
- }
- }
- }
- else if (obj)
- { // override list was empty or an error occurred, null out all overrides for this object
- for (int i = 0; i < obj->getNumTEs(); ++i)
- {
- obj->setTEGLTFMaterialOverride(i, nullptr);
- if (obj->getTE(i) && obj->getTE(i)->isSelected())
- {
- doSelectionCallbacks(obj->getID(), i);
- }
- }
- }
- });
- }
-#endif
- }
-
private:
std::vector<void(*)(const LLUUID& object_id, S32 side)> mSelectionCallbacks;
@@ -822,12 +665,6 @@ void LLGLTFMaterialList::flushMaterials()
}
// static
-void LLGLTFMaterialList::registerCallbacks()
-{
- gGenericDispatcher.addHandler("GLTFMaterialOverride", &handle_gltf_override_message);
-}
-
-// static
void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool) )
{
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
@@ -864,7 +701,3 @@ void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides,
}
}
-void LLGLTFMaterialList::loadCacheOverrides(const LLGLTFOverrideCacheEntry& override)
-{
- handle_gltf_override_message.applyData(override);
-}