diff options
Diffstat (limited to 'indra/newview/llviewerobject.cpp')
-rw-r--r-- | indra/newview/llviewerobject.cpp | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index a256b770b1..ccc1259c25 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -414,11 +414,6 @@ void LLViewerObject::deleteTEImages() delete[] mTESpecularMaps; mTESpecularMaps = NULL; } - - mGLTFBaseColorMaps.clear(); - mGLTFNormalMaps.clear(); - mGLTFMetallicRoughnessMaps.clear(); - mGLTFEmissiveMaps.clear(); } void LLViewerObject::markDead() @@ -4766,11 +4761,6 @@ void LLViewerObject::setNumTEs(const U8 num_tes) mTEImages = new_images; mTENormalMaps = new_normmaps; mTESpecularMaps = new_specmaps; - - mGLTFBaseColorMaps.resize(num_tes); - mGLTFNormalMaps.resize(num_tes); - mGLTFMetallicRoughnessMaps.resize(num_tes); - mGLTFEmissiveMaps.resize(num_tes); } else { @@ -4930,14 +4920,28 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); } - auto fetch_texture = [](const LLUUID& id, LLViewerObject *obj) + LLFetchedGLTFMaterial* mat = (LLFetchedGLTFMaterial*) getTE(te)->getGLTFMaterial(); + LLUUID mat_id = getRenderMaterialID(te); + if (mat == nullptr && mat_id.notNull()) + { + mat = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mat_id); + getTE(te)->setGLTFMaterial(mat); + } + else if (mat_id.isNull() && mat != nullptr) + { + mat = nullptr; + getTE(te)->setGLTFMaterial(nullptr); + } + + auto fetch_texture = [this](const LLUUID& id) { LLViewerFetchedTexture* img = nullptr; if (id.notNull()) { if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(id)) { - LLViewerTexture* viewerTexture = obj->getBakedTextureForMagicId(id); + // TODO -- fall back to LLTextureEntry::mGLTFRenderMaterial when overriding with baked texture + LLViewerTexture* viewerTexture = getBakedTextureForMagicId(id); img = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : nullptr; } else @@ -4950,34 +4954,13 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) return img; }; - LLGLTFMaterial* mat = getTE(te)->getGLTFMaterial(); - LLUUID mat_id = getRenderMaterialID(te); - if (mat == nullptr && mat_id.notNull()) - { - mat = gGLTFMaterialList.getMaterial(mat_id); - getTE(te)->setGLTFMaterial(mat); - } - else if (mat_id.isNull() && mat != nullptr) - { - mat = nullptr; - getTE(te)->setGLTFMaterial(nullptr); - } - if (mat != nullptr) { - mGLTFBaseColorMaps[te] = fetch_texture(mat->mBaseColorId, this); - mGLTFNormalMaps[te] = fetch_texture(mat->mNormalId, this); - mGLTFMetallicRoughnessMaps[te] = fetch_texture(mat->mMetallicRoughnessId, this); - mGLTFEmissiveMaps[te] = fetch_texture(mat->mEmissiveId, this); + mat->mBaseColorTexture = fetch_texture(mat->mBaseColorId); + mat->mNormalTexture = fetch_texture(mat->mNormalId); + mat->mMetallicRoughnessTexture = fetch_texture(mat->mMetallicRoughnessId); + mat->mEmissiveTexture= fetch_texture(mat->mEmissiveId); } - else - { - mGLTFBaseColorMaps[te] = nullptr; - mGLTFNormalMaps[te] = nullptr; - mGLTFMetallicRoughnessMaps[te] = nullptr; - mGLTFEmissiveMaps[te] = nullptr; - } - } void LLViewerObject::refreshBakeTexture() |