Fix for SL-18458 overrides not applying when cache load happened before LLViewerObject::updateTEMaterialTextures call

master
Brad Linden 2023-03-23 16:51:30 -07:00
parent b72c66ae68
commit cf3a0c77f1
5 changed files with 42 additions and 17 deletions

View File

@ -366,6 +366,8 @@ void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFM
void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
{
LL_PROFILE_ZONE_SCOPED;
llassert(obj);
const LLUUID& id = obj->getID();
auto iter = mQueuedOverrides.find(id);

View File

@ -4963,12 +4963,16 @@ void LLViewerObject::updateTEMaterialTextures(U8 te)
mat = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mat_id);
if (mat->isFetching())
{ // material is not loaded yet, rebuild draw info when the object finishes loading
LLUUID id = getID();
mat->onMaterialComplete([=]
mat->onMaterialComplete([id=getID()]
{
LLViewerObject* obj = gObjectList.findObject(id);
if (obj)
{
LLViewerRegion* region = obj->getRegion();
if(region)
{
region->loadCacheMiscExtras(obj->getLocalID());
}
obj->markForUpdate(FALSE);
}
});
@ -5698,6 +5702,23 @@ void LLViewerObject::setDebugText(const std::string &utf8text)
updateText();
}
void LLViewerObject::appendDebugText(const std::string &utf8text)
{
if (utf8text.empty() && !mText)
{
return;
}
if (!mText)
{
initHudText();
}
mText->addLine(utf8text, LLColor4::white);
mText->setZCompare(FALSE);
mText->setDoFade(FALSE);
updateText();
}
void LLViewerObject::initHudText()
{
mText = (LLHUDText *)LLHUDObject::addHUDObject(LLHUDObject::LL_HUD_TEXT);
@ -7260,12 +7281,14 @@ void LLViewerObject::setRenderMaterialID(S32 te_in, const LLUUID& id, bool updat
}
else
{
LLPointer<LLViewerObject> this_ptr = this;
new_material->onMaterialComplete([this_ptr]() mutable {
if (this_ptr->isDead()) { return; }
this_ptr->rebuildMaterial();
});
new_material->onMaterialComplete([obj_id = getID()]()
{
LLViewerObject* obj = gObjectList.findObject(obj_id);
if (obj)
{
obj->rebuildMaterial();
}
});
}
// predictively update LLRenderMaterialParams (don't wait for server)

View File

@ -442,6 +442,7 @@ public:
void sendMaterialUpdate() const;
void setDebugText(const std::string &utf8text);
void appendDebugText(const std::string &utf8text);
void initHudText();
void restoreHudText();
void setIcon(LLViewerTexture* icon_image);

View File

@ -823,7 +823,7 @@ void LLViewerRegion::saveObjectCache()
// Map of LLVOCacheEntry takes time to release, store map for cleanup on idle
sRegionCacheCleanup.insert(mImpl->mCacheMap.begin(), mImpl->mCacheMap.end());
mImpl->mCacheMap.clear();
// TODO - probably need to do the same for overrides cache
// TODO - probably need to do the same for overrides cache
}
void LLViewerRegion::sendMessage()
@ -1151,6 +1151,8 @@ void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry, bool for_rendering)
entry->setState(LLVOCacheEntry::INACTIVE);
entry->removeOctreeEntry();
entry->setValid(FALSE);
// TODO kill extras/material overrides cache too
}
//physically delete the cache entry
@ -1863,7 +1865,7 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry)
addActiveCacheEntry(entry);
}
loadCacheMiscExtras(entry->getLocalID(), entry, entry->getCRC());
loadCacheMiscExtras(entry->getLocalID());
return obj;
}
@ -2879,6 +2881,7 @@ void LLViewerRegion::dumpCache()
{
LL_INFOS() << "Changes " << i << " " << change_bin[i] << LL_ENDL;
}
// TODO - add overrides cache too
}
void LLViewerRegion::unpackRegionHandshake()
@ -3547,15 +3550,11 @@ std::string LLViewerRegion::getSimHostName()
return std::string("...");
}
void LLViewerRegion::loadCacheMiscExtras(U32 local_id, LLVOCacheEntry * entry, U32 crc)
void LLViewerRegion::loadCacheMiscExtras(U32 local_id)
{
auto iter = mImpl->mGLTFOverridesJson.find(local_id);
if (iter != mImpl->mGLTFOverridesJson.end())
{
LLGLTFMaterialList::loadCacheOverrides(iter->second);
}
else
{
LL_DEBUGS("GLTF") << "cache miss for handle: " << mHandle << " local_id:" << local_id << LL_ENDL;
}
}

View File

@ -423,9 +423,9 @@ private:
void decodeBoundingInfo(LLVOCacheEntry* entry);
bool isNonCacheableObjectCreated(U32 local_id);
void loadCacheMiscExtras(U32 local_id, LLVOCacheEntry * entry, U32 crc);
public:
void loadCacheMiscExtras(U32 local_id);
struct CompareDistance
{
bool operator()(const LLViewerRegion* const& lhs, const LLViewerRegion* const& rhs)