summaryrefslogtreecommitdiff
path: root/indra/newview/llgltfmateriallist.cpp
diff options
context:
space:
mode:
authorRunitaiLinden <davep@lindenlab.com>2023-08-29 16:42:55 -0500
committerRunitaiLinden <davep@lindenlab.com>2023-08-29 16:42:55 -0500
commit455bbcf742691b709353aa3c3e35a76d0ff38ee4 (patch)
treefa806a884bde35d117c40a3d1348b52833dcd020 /indra/newview/llgltfmateriallist.cpp
parenta3a811606088f1b40d9e098ddff8b38a2420b8e9 (diff)
SL-20229 Add GenericStreamingMessage and use it to receive GLTF material overrides
Diffstat (limited to 'indra/newview/llgltfmateriallist.cpp')
-rw-r--r--indra/newview/llgltfmateriallist.cpp75
1 files changed, 62 insertions, 13 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 99a052f719..a204315a2a 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -160,9 +160,9 @@ public:
// 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);
@@ -198,6 +198,7 @@ public:
applyData(object_override);
}
+#endif
return success;
}
@@ -213,6 +214,7 @@ public:
{
// 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");
@@ -235,24 +237,17 @@ public:
results.reserve(sides.size());
// parse json
- std::unordered_map<S32, std::string>::const_iterator iter = sides.begin();
- std::unordered_map<S32, std::string>::const_iterator end = sides.end();
+ std::unordered_map<S32, LLSD>::const_iterator iter = sides.begin();
+ std::unordered_map<S32, LLSD>::const_iterator end = sides.end();
while (iter != end)
{
- std::string warn_msg, error_msg;
-
ReturnData result;
- bool success = result.mMaterial.fromJSON(iter->second, warn_msg, error_msg);
-
- result.mSuccess = success;
+ result.mMaterial.applyOverrideLLSD(iter->second);
+
+ result.mSuccess = true;
result.mSide = iter->first;
- if (!success)
- {
- LL_WARNS("GLTF") << "failed to parse GLTF override data. errors: " << error_msg << " | warnings: " << warn_msg << LL_ENDL;
- }
-
results.push_back(result);
iter++;
}
@@ -318,6 +313,7 @@ public:
}
});
}
+#endif
}
private:
@@ -330,6 +326,59 @@ namespace
LLGLTFMaterialOverrideDispatchHandler handle_gltf_override_message;
}
+void LLGLTFMaterialList::applyOverrideMessage(LLMessageSystem* msg, const std::string& data_in)
+{
+ std::istringstream str(data_in);
+
+ LLSD data;
+
+ LLSDSerialize::fromNotation(data, str, data_in.length());
+
+ const LLHost& host = msg->getSender();
+
+ LLViewerRegion* region = LLWorld::instance().getRegion(host);
+
+ if (region)
+ {
+ U32 local_id = data.get("id").asInteger();
+ LLUUID id;
+ gObjectList.getUUIDFromLocal(id, local_id, host.getAddress(), host.getPort());
+ LLViewerObject* obj = gObjectList.findObject(id);
+
+ if (obj)
+ {
+ const LLSD& tes = data["te"];
+ const LLSD& od = data["od"];
+
+ if (tes.isArray())
+ {
+ LLGLTFOverrideCacheEntry cache;
+ cache.mLocalId = local_id;
+ cache.mObjectId = id;
+ cache.mRegionHandle = region->getHandle();
+
+ for (int i = 0; i < tes.size(); ++i)
+ {
+ S32 te = tes[i].asInteger();
+ LLGLTFMaterial* mat = new LLGLTFMaterial(); // setTEGLTFMaterialOverride will take ownership
+ mat->applyOverrideLLSD(od[i]);
+ obj->setTEGLTFMaterialOverride(te, mat);
+
+ cache.mSides[te] = od[i];
+ cache.mGLTFMaterial[te] = mat;
+
+ if (obj->getTE(te) && obj->getTE(te)->isSelected())
+ {
+ handle_gltf_override_message.doSelectionCallbacks(id, te);
+ }
+ }
+
+ region->cacheFullUpdateGLTFOverride(cache);
+ }
+ }
+ }
+}
+
void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data)
{
#if 0