diff options
| author | RunitaiLinden <davep@lindenlab.com> | 2023-08-29 16:42:55 -0500 | 
|---|---|---|
| committer | RunitaiLinden <davep@lindenlab.com> | 2023-08-29 16:42:55 -0500 | 
| commit | 455bbcf742691b709353aa3c3e35a76d0ff38ee4 (patch) | |
| tree | fa806a884bde35d117c40a3d1348b52833dcd020 /indra/newview | |
| parent | a3a811606088f1b40d9e098ddff8b38a2420b8e9 (diff) | |
SL-20229 Add GenericStreamingMessage and use it to receive GLTF material overrides
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llappviewer.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llgltfmateriallist.cpp | 75 | ||||
| -rw-r--r-- | indra/newview/llgltfmateriallist.h | 3 | ||||
| -rw-r--r-- | indra/newview/llstartup.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/llviewergenericmessage.cpp | 18 | ||||
| -rw-r--r-- | indra/newview/llviewergenericmessage.h | 1 | ||||
| -rwxr-xr-x | indra/newview/llviewerregion.cpp | 16 | ||||
| -rw-r--r-- | indra/newview/llvocache.cpp | 34 | ||||
| -rw-r--r-- | indra/newview/llvocache.h | 2 | 
9 files changed, 103 insertions, 49 deletions
| diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 343778fe03..a6e938e54c 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4138,7 +4138,7 @@ U32 LLAppViewer::getObjectCacheVersion()  {  	// Viewer object cache version, change if object update  	// format changes. JC -	const U32 INDRA_OBJECT_CACHE_VERSION = 16; +	const U32 INDRA_OBJECT_CACHE_VERSION = 17;  	return INDRA_OBJECT_CACHE_VERSION;  } 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 diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h index ce8781baba..7317214019 100644 --- a/indra/newview/llgltfmateriallist.h +++ b/indra/newview/llgltfmateriallist.h @@ -101,6 +101,9 @@ public:      static void loadCacheOverrides(const LLGLTFOverrideCacheEntry& override); +    // Apply an override update with the given data +    void applyOverrideMessage(LLMessageSystem* msg, const std::string& data); +  private:      friend class LLGLTFMaterialOverrideDispatchHandler;      // save an override update that we got from the simulator for later (for example, if an override arrived for an unknown object) diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 8ffab761f4..eccfd40fe6 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2709,6 +2709,7 @@ void register_viewer_callbacks(LLMessageSystem* msg)  	msg->setHandlerFunc("InitiateDownload", process_initiate_download);  	msg->setHandlerFunc("LandStatReply", LLFloaterTopObjects::handle_land_reply);      msg->setHandlerFunc("GenericMessage", process_generic_message); +    msg->setHandlerFunc("GenericStreamingMessage", process_generic_streaming_message);      msg->setHandlerFunc("LargeGenericMessage", process_large_generic_message);  	msg->setHandlerFuncFast(_PREHASH_FeatureDisabled, process_feature_disabled_message); diff --git a/indra/newview/llviewergenericmessage.cpp b/indra/newview/llviewergenericmessage.cpp index d3de9d72bf..7ea792c404 100644 --- a/indra/newview/llviewergenericmessage.cpp +++ b/indra/newview/llviewergenericmessage.cpp @@ -32,9 +32,10 @@  #include "lldispatcher.h"  #include "lluuid.h"  #include "message.h" +#include "llgenericstreamingmessage.h"  #include "llagent.h" - +#include "llgltfmateriallist.h"  LLDispatcher gGenericDispatcher; @@ -92,6 +93,21 @@ void process_generic_message(LLMessageSystem* msg, void**)  	}  } +void process_generic_streaming_message(LLMessageSystem* msg, void**) +{ +    LLGenericStreamingMessage data; +    data.unpack(msg); +    switch (data.mMethod) +    { +    case LLGenericStreamingMessage::METHOD_GLTF_MATERIAL_OVERRIDE: +        gGLTFMaterialList.applyOverrideMessage(msg, data.mData); +        break; +    default: +        LL_WARNS() << "GenericStreamingMessage received unknown method: " << data.mMethod << LL_ENDL; +        break; +    } +} +  void process_large_generic_message(LLMessageSystem* msg, void**)  {      LLUUID agent_id; diff --git a/indra/newview/llviewergenericmessage.h b/indra/newview/llviewergenericmessage.h index 170f38a485..96a73a3d5f 100644 --- a/indra/newview/llviewergenericmessage.h +++ b/indra/newview/llviewergenericmessage.h @@ -38,6 +38,7 @@ void send_generic_message(const std::string& method,  						  const LLUUID& invoice = LLUUID::null);  void process_generic_message(LLMessageSystem* msg, void**); +void process_generic_streaming_message(LLMessageSystem* msg, void**);  void process_large_generic_message(LLMessageSystem* msg, void**); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 6b92b16ef4..ead1e8c073 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -215,7 +215,7 @@ public:  	LLVOCacheEntry::vocache_entry_set_t   mVisibleEntries; //must-be-created visible entries wait for objects creation.	  	LLVOCacheEntry::vocache_entry_priority_list_t mWaitingList; //transient list storing sorted visible entries waiting for object creation.  	std::set<U32>                          mNonCacheableCreatedList; //list of local ids of all non-cacheable objects -    LLVOCacheEntry::vocache_gltf_overrides_map_t mGLTFOverridesJson; // for materials +    LLVOCacheEntry::vocache_gltf_overrides_map_t mGLTFOverridesLLSD; // for materials  	// time?  	// LRU info? @@ -787,7 +787,7 @@ void LLViewerRegion::loadObjectCache()  	{          LLVOCache & vocache = LLVOCache::instance();  		vocache.readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap); -        vocache.readGenericExtrasFromCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesJson); +        vocache.readGenericExtrasFromCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesLLSD);  		if (mImpl->mCacheMap.empty())  		{ @@ -817,7 +817,7 @@ void LLViewerRegion::saveObjectCache()          LLVOCache & instance = LLVOCache::instance();          instance.writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, removal_enabled); -        instance.writeGenericExtrasToCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesJson, mCacheDirty, removal_enabled); +        instance.writeGenericExtrasToCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesLLSD, mCacheDirty, removal_enabled);  		mCacheDirty = FALSE;  	} @@ -2656,7 +2656,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec  void LLViewerRegion::cacheFullUpdateGLTFOverride(const LLGLTFOverrideCacheEntry &override_data)  {      U32 local_id = override_data.mLocalId; -    mImpl->mGLTFOverridesJson[local_id] = override_data; +    mImpl->mGLTFOverridesLLSD[local_id] = override_data;  }  LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id) @@ -3546,8 +3546,8 @@ std::string LLViewerRegion::getSimHostName()  void LLViewerRegion::loadCacheMiscExtras(U32 local_id)  { -    auto iter = mImpl->mGLTFOverridesJson.find(local_id); -    if (iter != mImpl->mGLTFOverridesJson.end()) +    auto iter = mImpl->mGLTFOverridesLLSD.find(local_id); +    if (iter != mImpl->mGLTFOverridesLLSD.end())      {          LLGLTFMaterialList::loadCacheOverrides(iter->second);      } @@ -3559,8 +3559,8 @@ void LLViewerRegion::applyCacheMiscExtras(LLViewerObject* obj)      llassert(obj);      U32 local_id = obj->getLocalID(); -    auto iter = mImpl->mGLTFOverridesJson.find(local_id); -    if (iter != mImpl->mGLTFOverridesJson.end()) +    auto iter = mImpl->mGLTFOverridesLLSD.find(local_id); +    if (iter != mImpl->mGLTFOverridesLLSD.end())      {          llassert(iter->second.mGLTFMaterial.size() == iter->second.mSides.size()); diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index a92057d010..dd5b9f9fd5 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -85,40 +85,24 @@ bool LLGLTFOverrideCacheEntry::fromLLSD(const LLSD& data)      // message should be interpreted thusly:      ///  sides is a list of face indices -    //   gltf_json is a list of corresponding json +    //   gltf_llsd is a list of corresponding GLTF override LLSD      //   any side not represented in "sides" has no override -    if (data.has("sides") && data.has("gltf_json")) +    if (data.has("sides") && data.has("gltf_llsd"))      {          LLSD const& sides = data.get("sides"); -        LLSD const& gltf_json = data.get("gltf_json"); +        LLSD const& gltf_llsd = data.get("gltf_llsd"); -        if (sides.isArray() && gltf_json.isArray() && +        if (sides.isArray() && gltf_llsd.isArray() &&              sides.size() != 0 && -            sides.size() == gltf_json.size()) +            sides.size() == gltf_llsd.size())          {              for (int i = 0; i < sides.size(); ++i)              {                  S32 side_idx = sides[i].asInteger(); -                std::string gltf_json_str = gltf_json[i].asString(); -                mSides[side_idx] = gltf_json_str; +                mSides[side_idx] = gltf_llsd[i];                  LLGLTFMaterial* override_mat = new LLGLTFMaterial(); -                std::string error, warn; -                if (override_mat->fromJSON(gltf_json_str, warn, error)) -                { -                    mGLTFMaterial[side_idx] = override_mat; -                } -                else -                { -                    LL_WARNS() << "Invalid GLTF string: \n" << gltf_json_str << LL_ENDL; -                    if (!error.empty()) -                    { -                        LL_WARNS() << "Error: " << error << LL_ENDL; -                    } -                    if (!warn.empty()) -                    { -                        LL_WARNS() << "Warning: " << warn << LL_ENDL; -                    } -                } +                override_mat->applyOverrideLLSD(gltf_llsd[i]); +                mGLTFMaterial[side_idx] = override_mat;              }          }          else @@ -157,7 +141,7 @@ LLSD LLGLTFOverrideCacheEntry::toLLSD() const          // check that mSides and mGLTFMaterial have exactly the same keys present          llassert(mGLTFMaterial.count(side.first) == 1);          data["sides"].append(LLSD::Integer(side.first)); -        data["gltf_json"].append(side.second); +        data["gltf_llsd"].append(side.second);      }      return data; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index ec0df31828..8525edd121 100644 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -48,7 +48,7 @@ public:      LLUUID mObjectId;      U32    mLocalId = 0; -    std::unordered_map<S32, std::string> mSides; //json per side +    std::unordered_map<S32, LLSD> mSides; //override LLSD per side      std::unordered_map<S32, LLPointer<LLGLTFMaterial> > mGLTFMaterial; //GLTF material per side      U64 mRegionHandle = 0;  }; | 
