SL-18458 Fix for overrides not applying if material is not loaded on rebuild.

master
Dave Parks 2023-03-23 13:33:21 -05:00
parent af57bbf0ca
commit 81bccc05e2
2 changed files with 22 additions and 2 deletions

View File

@ -376,8 +376,14 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
{
if (overrides[i].notNull())
{
if (!obj->getTE(i) || !obj->getTE(i)->getGLTFMaterial())
{ // object doesn't have its base GLTF material yet, don't apply override (yet)
if (!obj->getTE(i))
{ // object is incomplete
return;
}
if (!obj->getTE(i)->getGLTFMaterial())
{
// doesn't have its base GLTF material yet, don't apply override(yet)
return;
}
@ -387,6 +393,7 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
// can't apply this yet, since failure to change the material override
// probably means the base material is still being fetched. leave in
// the queue for later
//obj->setDebugText("early out 3");
return;
}

View File

@ -4961,6 +4961,18 @@ void LLViewerObject::updateTEMaterialTextures(U8 te)
if (mat == nullptr && mat_id.notNull())
{
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([=]
{
LLViewerObject* obj = gObjectList.findObject(id);
if (obj)
{
obj->markForUpdate(FALSE);
}
});
}
getTE(te)->setGLTFMaterial(mat);
}
else if (mat_id.isNull() && mat != nullptr)
@ -5391,6 +5403,7 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma
render_mat->applyOverride(*override_mat);
tep->setGLTFRenderMaterial(render_mat);
retval = TEM_CHANGE_TEXTURE;
}
else if (tep->setGLTFRenderMaterial(nullptr))
{