summaryrefslogtreecommitdiff
path: root/indra/newview/llgltfmateriallist.cpp
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2024-01-24 14:37:33 -0800
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2024-01-24 14:37:33 -0800
commit373b06398c274eee476e4aa9c35b9c6327f9d45f (patch)
tree4a324b36ab896d9507374e71e15f9ec064b41add /indra/newview/llgltfmateriallist.cpp
parentbd9c0a2e658e183bb8a321cdce546f10b6d76afe (diff)
parentc22aefafb3d05be37965361913c02568fa10adf6 (diff)
Merge remote-tracking branch 'origin/release/materials_featurette' into DRTVWR-583
Diffstat (limited to 'indra/newview/llgltfmateriallist.cpp')
-rw-r--r--indra/newview/llgltfmateriallist.cpp175
1 files changed, 4 insertions, 171 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 8919229c78..a9216ae656 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;
@@ -628,7 +471,7 @@ void LLGLTFMaterialList::onAssetLoadComplete(const LLUUID& id, LLAssetType::ETyp
if (status != LL_ERR_NOERR)
{
LL_WARNS("GLTF") << "Error getting material asset data: " << LLAssetStorage::getErrorString(status) << " (" << status << ")" << LL_ENDL;
- asset_data->mMaterial->materialComplete();
+ asset_data->mMaterial->materialComplete(false);
delete asset_data;
}
else
@@ -713,7 +556,7 @@ void LLGLTFMaterialList::onAssetLoadComplete(const LLUUID& id, LLAssetType::ETyp
LL_DEBUGS("GLTF") << "Failed to get material " << id << LL_ENDL;
}
- asset_data->mMaterial->materialComplete();
+ asset_data->mMaterial->materialComplete(true);
delete asset_data;
});
@@ -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);
-}