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.cpp105
1 files changed, 92 insertions, 13 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 99a052f719..8919229c78 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,89 @@ 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);
+ llassert(region);
+
+ 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);
+
+ // NOTE: obj may be null if the viewer hasn't heard about the object yet, cache update in any case
+
+ if (obj && gShowObjectUpdates)
+ { // display a cyan blip for override updates when "Show Updates to Objects" enabled
+ LLColor4 color(0.f, 1.f, 1.f, 1.f);
+ gPipeline.addDebugBlip(obj->getPositionAgent(), color);
+ }
+
+ const LLSD& tes = data["te"];
+ const LLSD& od = data["od"];
+
+ constexpr U32 MAX_TES = 45;
+ bool has_te[MAX_TES] = { false };
+
+ if (tes.isArray()) // NOTE: if no "te" array exists, this is a malformed message (null out all overrides will come in as an empty te array)
+ {
+ LLGLTFOverrideCacheEntry cache;
+ cache.mLocalId = local_id;
+ cache.mObjectId = id;
+ cache.mRegionHandle = region->getHandle();
+
+ U32 count = llmin(tes.size(), MAX_TES);
+ for (U32 i = 0; i < count; ++i)
+ {
+ LLGLTFMaterial* mat = new LLGLTFMaterial(); // setTEGLTFMaterialOverride and cache will take ownership
+ mat->applyOverrideLLSD(od[i]);
+
+ S32 te = tes[i].asInteger();
+
+ has_te[te] = true;
+ cache.mSides[te] = od[i];
+ cache.mGLTFMaterial[te] = mat;
+
+ if (obj)
+ {
+ obj->setTEGLTFMaterialOverride(te, mat);
+ if (obj->getTE(te) && obj->getTE(te)->isSelected())
+ {
+ handle_gltf_override_message.doSelectionCallbacks(id, te);
+ }
+ }
+ }
+
+ if (obj)
+ { // null out overrides on TEs that shouldn't have them
+ U32 count = llmin(obj->getNumTEs(), MAX_TES);
+ for (U32 i = 0; i < count; ++i)
+ {
+ LLTextureEntry* te = obj->getTE(i);
+ if (!has_te[i] && te && te->getGLTFMaterialOverride())
+ {
+ obj->setTEGLTFMaterialOverride(i, nullptr);
+ handle_gltf_override_message.doSelectionCallbacks(id, i);
+ }
+ }
+ }
+
+ region->cacheFullUpdateGLTFOverride(cache);
+ }
+
+ }
+}
+
void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data)
{
#if 0