#1325 Fix for GLTF overrides sometimes not showing up. (#1340)

meow-7.2.2
RunitaiLinden 2024-04-26 13:38:30 -05:00 committed by GitHub
parent 6f51d909a2
commit 8465a8acb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 46 additions and 15 deletions

View File

@ -244,12 +244,8 @@ void LLGLTFMaterialList::applyOverrideMessage(LLMessageSystem* msg, const std::s
}
}
// Workaround for server sending empty overrides.
if(cache.mSides.size() > 0)
{
region->cacheFullUpdateGLTFOverride(cache);
LL_DEBUGS("GLTF") << "GLTF Material Override: " << cache.mObjectId << " " << cache.mLocalId << " " << cache.mRegionHandle << " (sides:" << (cache.mSides.size()) << ")" << LL_ENDL;
}
region->cacheFullUpdateGLTFOverride(cache);
LL_DEBUGS("GLTF") << "GLTF Material Override: " << cache.mObjectId << " " << cache.mLocalId << " " << cache.mRegionHandle << " (sides:" << (cache.mSides.size()) << ")" << LL_ENDL;
}
}

View File

@ -2744,7 +2744,14 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
void LLViewerRegion::cacheFullUpdateGLTFOverride(const LLGLTFOverrideCacheEntry &override_data)
{
U32 local_id = override_data.mLocalId;
mImpl->mGLTFOverridesLLSD[local_id] = override_data;
if (override_data.mSides.size() > 0)
{ // empty override means overrides were removed from this object
mImpl->mGLTFOverridesLLSD[local_id] = override_data;
}
else
{
mImpl->mGLTFOverridesLLSD.erase(local_id);
}
}
LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id)
@ -2961,6 +2968,11 @@ void LLViewerRegion::dumpCache()
// TODO - add overrides cache too
}
void LLViewerRegion::clearVOCacheFromMemory()
{
mImpl->mCacheMap.clear();
}
void LLViewerRegion::unpackRegionHandshake()
{
LLMessageSystem *msg = gMessageSystem;

View File

@ -378,7 +378,8 @@ public:
LLViewerObject* updateCacheEntry(U32 local_id, LLViewerObject* objectp);
void findOrphans(U32 parent_id);
void clearCachedVisibleObjects();
void dumpCache();
void dumpCache ();
void clearVOCacheFromMemory();
void unpackRegionHandshake();

View File

@ -1272,6 +1272,13 @@ void LLVOCache::removeEntry(HeaderEntryInfo* entry)
getObjectCacheFilename(entry->mHandle, filename);
LL_INFOS() << "Removing entry for region with filename" << filename << LL_ENDL;
// make sure corresponding LLViewerRegion also clears its in-memory cache
LLViewerRegion* regionp = LLWorld::instance().getRegionFromHandle(entry->mHandle);
if (regionp)
{
regionp->clearVOCacheFromMemory();
}
header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry);
if(iter != mHeaderEntryQueue.end())
{
@ -1340,10 +1347,14 @@ void LLVOCache::removeFromCache(HeaderEntryInfo* entry)
std::string filename;
getObjectCacheFilename(entry->mHandle, filename);
LL_WARNS("GLTF", "VOCache") << "Removing object cache for handle " << entry->mHandle << "Filename: " << filename << LL_ENDL;
LLAPRFile::remove(filename, mLocalAPRFilePoolp);
// Note: `removeFromCache` should take responsibility for cleaning up all cache artefacts specfic to the handle/entry.
// Note: `removeFromCache` should take responsibility for cleaning up all cache artefacts specfic to the handle/entry.
// as such this now includes the generic extras
removeGenericExtrasForHandle(entry->mHandle);
filename = getObjectCacheExtrasFilename(entry->mHandle);
LL_WARNS("GLTF", "VOCache") << "Removing generic extras for handle " << entry->mHandle << "Filename: " << filename << LL_ENDL;
LLFile::remove(filename);
entry->mTime = INVALID_TIME ;
updateEntry(entry) ; //update the head file.
@ -1358,7 +1369,7 @@ void LLVOCache::readCacheHeader()
}
//clear stale info.
clearCacheInMemory();
clearCacheInMemory();
bool success = true ;
if (LLAPRFile::isExist(mHeaderFileName, mLocalAPRFilePoolp))
@ -1605,7 +1616,7 @@ void LLVOCache::readGenericExtrasFromCache(U64 handle, const LLUUID& id, LLVOCac
}
// For future versions we may call a legacy handler here, but realistically we'll just consider this cache out of date.
// The important thing is to make sure it gets removed.
if(versionNumber != LLGLTFOverrideCacheEntry::VERSION && versionNumber != 0)
if(versionNumber != LLGLTFOverrideCacheEntry::VERSION)
{
LL_WARNS() << "Unexpected version number " << versionNumber << " for extras cache for handle " << handle << LL_ENDL;
in.close();
@ -1614,7 +1625,7 @@ void LLVOCache::readGenericExtrasFromCache(U64 handle, const LLUUID& id, LLVOCac
}
LL_DEBUGS("VOCache") << "Reading extras cache for handle " << handle << ", version " << versionNumber << LL_ENDL;
std::getline(in, line);
if(!LLUUID::validate(line))
{
LL_WARNS() << "Failed reading extras cache for handle" << handle << ". invalid uuid line: '" << line << "'" << LL_ENDL;
@ -1847,8 +1858,19 @@ void LLVOCache::removeGenericExtrasForHandle(U64 handle)
LL_WARNS() << "Not removing cache for handle " << handle << ": Cache is currently in read-only mode." << LL_ENDL;
return ;
}
LL_WARNS("GLTF", "VOCache") << "Removing generic extras for handle " << handle << "Filename: " << getObjectCacheExtrasFilename(handle) << LL_ENDL;
LLFile::remove(getObjectCacheExtrasFilename(handle));
// NOTE: when removing the extras, we must also remove the objects so the simulator will send us a full upddate with the valid overrides
auto* entry = mHandleEntryMap[handle];
if (entry)
{
removeEntry(entry);
}
else
{
//shouldn't happen, but if it does, we should remove the extras file since it's orphaned
LL_WARNS("GLTF", "VOCache") << "Removing generic extras for handle " << entry->mHandle << "Filename: " << getObjectCacheExtrasFilename(handle) << LL_ENDL;
LLFile::remove(getObjectCacheExtrasFilename(entry->mHandle));
}
}
void LLVOCache::writeGenericExtrasToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_gltf_overrides_map_t& cache_extras_entry_map, BOOL dirty_cache, bool removal_enabled)