summaryrefslogtreecommitdiff
path: root/indra/newview/llgltfmateriallist.cpp
diff options
context:
space:
mode:
authorBrad Kittenbrink <brad@lindenlab.com>2022-10-19 09:18:24 -0700
committerBrad Kittenbrink <brad@lindenlab.com>2022-10-19 09:18:24 -0700
commitd0c2c862efe2ce684b48092465cc753b3ab64da9 (patch)
treefada5a3d37dc69eaa07630cbe395375835114ec6 /indra/newview/llgltfmateriallist.cpp
parentf575c139300a6c53fa13dd0d7cbfbaa739e2b4b0 (diff)
SL-18105 viewer side for handling Material Override LargeGenericMessage
LLGLTFMaterialList now decodes gltf json overrides from the server and stores them in LLTextureEntry::mGLTFMaterialOverrides
Diffstat (limited to 'indra/newview/llgltfmateriallist.cpp')
-rw-r--r--indra/newview/llgltfmateriallist.cpp55
1 files changed, 42 insertions, 13 deletions
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 0fd5f37b51..9c04ef4c38 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -35,36 +35,65 @@
#include "lltinygltfhelper.h"
#include "llviewercontrol.h"
#include "llviewergenericmessage.h"
+#include "llviewerobjectlist.h"
#include "tinygltf/tiny_gltf.h"
#include <strstream>
+#include "json/reader.h"
+#include "json/value.h"
+
namespace
{
class LLGLTFOverrideDispatchHandler : public LLDispatchHandler
{
+ LOG_CLASS(LLGLTFOverrideDispatchHandler);
public:
LLGLTFOverrideDispatchHandler() = default;
~LLGLTFOverrideDispatchHandler() override = default;
bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override
{
- for (std::string const & s : strings) {
- LL_DEBUGS() << "received override: " << s << LL_ENDL;
-
-#if 0
- // for now messages are coming in llsd
- LLSD override_data;
- std::istringstream input(s);
- LLSDSerialize::deserialize(override_data, input, s.length());
- LL_DEBUGS() << "deserialized override: " << override_data << LL_ENDL;
-#else
+ // iterate over pairs of parameters
+ int i;
+ for (i = 0; i+1 < strings.size(); i += 2)
+ {
+ std::string params_json = strings[i];
+ std::string override_json = strings[i+1];
+
+ LL_DEBUGS() << "received override: " << params_json << " | " << override_json << LL_ENDL;
+
+ Json::Value params;
+ Json::Reader reader;
+ bool success = reader.parse(params_json, params);
+ if (!success)
+ {
+ LL_WARNS() << "failed to parse override parameters. errors: " << reader.getFormatedErrorMessages() << LL_ENDL;
+ break;
+ }
+
+ LLViewerObject * obj = gObjectList.findObject(LLUUID(params["object_id"].asString()));
+ S32 side = params["side"].asInt();
+
std::string warn_msg, error_msg;
- LLGLTFMaterial override_data;
- override_data.fromJSON(s, warn_msg, error_msg);
-#endif
+ LLPointer<LLGLTFMaterial> override_data = new LLGLTFMaterial();
+ success = override_data->fromJSON(override_json, warn_msg, error_msg);
+// if (!success)
+// {
+// LL_WARNS() << "failed to parse GLTF override data. errors: " << error_msg << " | warnings: " << warn_msg << LL_ENDL;
+// break;
+// }
+
+ if(obj)
+ {
+ obj->getTE(side)->setGLTFMaterialOverride(override_data);
+ }
+
+ LL_DEBUGS() << "successfully parsed override: " << override_data->asJSON() << LL_ENDL;
}
+ LL_WARNS_IF(i != strings.size()) << "parse error or unhandled mismatched odd number of parameters for material override" << LL_ENDL;
+
return true;
}
};