diff options
author | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2024-01-24 14:37:33 -0800 |
---|---|---|
committer | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2024-01-24 14:37:33 -0800 |
commit | 373b06398c274eee476e4aa9c35b9c6327f9d45f (patch) | |
tree | 4a324b36ab896d9507374e71e15f9ec064b41add /indra/newview/llfetchedgltfmaterial.cpp | |
parent | bd9c0a2e658e183bb8a321cdce546f10b6d76afe (diff) | |
parent | c22aefafb3d05be37965361913c02568fa10adf6 (diff) |
Merge remote-tracking branch 'origin/release/materials_featurette' into DRTVWR-583
Diffstat (limited to 'indra/newview/llfetchedgltfmaterial.cpp')
-rw-r--r-- | indra/newview/llfetchedgltfmaterial.cpp | 88 |
1 files changed, 83 insertions, 5 deletions
diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 9590066b55..6bd613622e 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -29,14 +29,14 @@ #include "llviewertexturelist.h" #include "llavatarappearancedefines.h" +#include "llviewerobject.h" +#include "llselectmgr.h" #include "llshadermgr.h" #include "pipeline.h" LLFetchedGLTFMaterial::LLFetchedGLTFMaterial() : LLGLTFMaterial() , mExpectedFlusTime(0.f) - , mActive(true) - , mFetching(false) { } @@ -83,11 +83,11 @@ void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) if (baseColorTex != nullptr) { - gGL.getTexUnit(0)->bindFast(baseColorTex); + shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, baseColorTex); } else { - gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep); + shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, LLViewerFetchedTexture::sWhiteImagep); } F32 base_color_packed[8]; @@ -145,6 +145,83 @@ void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) } +LLViewerFetchedTexture* fetch_texture(const LLUUID& id) +{ + LLViewerFetchedTexture* img = nullptr; + if (id.notNull()) + { + img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + img->addTextureStats(64.f * 64.f, TRUE); + } + return img; +}; + +bool LLFetchedGLTFMaterial::replaceLocalTexture(const LLUUID& tracking_id, const LLUUID& old_id, const LLUUID& new_id) +{ + bool res = false; + if (mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR] == old_id) + { + mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR] = new_id; + mBaseColorTexture = fetch_texture(new_id); + res = true; + } + if (mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL] == old_id) + { + mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL] = new_id; + mNormalTexture = fetch_texture(new_id); + res = true; + } + if (mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS] == old_id) + { + mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS] = new_id; + mMetallicRoughnessTexture = fetch_texture(new_id); + res = true; + } + if (mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE] == old_id) + { + mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE] = new_id; + mEmissiveTexture = fetch_texture(new_id); + res = true; + } + + for (int i = 0; i < GLTF_TEXTURE_INFO_COUNT; ++i) + { + if (mTextureId[i] == new_id) + { + res = true; + } + } + + if (res) + { + mTrackingIdToLocalTexture[tracking_id] = new_id; + } + else + { + mTrackingIdToLocalTexture.erase(tracking_id); + } + + return res; +} + +void LLFetchedGLTFMaterial::addTextureEntry(LLTextureEntry* te) +{ + mTextureEntires.insert(te); +} + +void LLFetchedGLTFMaterial::removeTextureEntry(LLTextureEntry* te) +{ + mTextureEntires.erase(te); +} + +void LLFetchedGLTFMaterial::updateTextureTracking() +{ + for (local_tex_map_t::value_type &val : mTrackingIdToLocalTexture) + { + LLLocalBitmapMgr::getInstance()->associateGLTFMaterial(val.first, this); + } +} + void LLFetchedGLTFMaterial::materialBegin() { llassert(!mFetching); @@ -164,10 +241,11 @@ void LLFetchedGLTFMaterial::onMaterialComplete(std::function<void()> material_co materialCompleteCallbacks.push_back(material_complete); } -void LLFetchedGLTFMaterial::materialComplete() +void LLFetchedGLTFMaterial::materialComplete(bool success) { llassert(mFetching); mFetching = false; + mFetchSuccess = success; for (std::function<void()> material_complete : materialCompleteCallbacks) { |