diff options
author | Ptolemy <ptolemy@lindenlab.com> | 2022-06-30 12:50:49 -0700 |
---|---|---|
committer | Ptolemy <ptolemy@lindenlab.com> | 2022-06-30 12:50:49 -0700 |
commit | 82232de0d2aecfddca2988249e79a73b4d972aa5 (patch) | |
tree | f6dfb8a8c2d0ca9ee3a3e3dca37386130ffe1653 /indra/newview/llviewerobject.cpp | |
parent | 38b6f10717918643c1169a4007dc92cfe36fc4d5 (diff) | |
parent | 68dfa1f5501f58d1ca158aeabcc3fd07e8a2e70f (diff) |
Merge branch 'DRTVWR-559' of bitbucket.org:lindenlab/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview/llviewerobject.cpp')
-rw-r--r-- | indra/newview/llviewerobject.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 16479e02a2..753fb014c9 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -107,6 +107,7 @@ #include "llcleanup.h" #include "llcallstack.h" #include "llmeshrepository.h" +#include "llgltfmateriallist.h" #include "llgl.h" //#define DEBUG_UPDATE_TYPE @@ -4906,6 +4907,18 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) }; 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) { mGLTFAlbedoMaps[te] = fetch_texture(mat->mAlbedoId); @@ -4913,6 +4926,14 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) mGLTFMetallicRoughnessMaps[te] = fetch_texture(mat->mMetallicRoughnessId); mGLTFEmissiveMaps[te] = fetch_texture(mat->mEmissiveId); } + else + { + mGLTFAlbedoMaps[te] = nullptr; + mGLTFNormalMaps[te] = nullptr; + mGLTFMetallicRoughnessMaps[te] = nullptr; + mGLTFEmissiveMaps[te] = nullptr; + } + } void LLViewerObject::refreshBakeTexture() @@ -6991,6 +7012,69 @@ LLVOAvatar* LLViewerObject::getAvatar() const return NULL; } +bool LLViewerObject::hasRenderMaterialParams() const +{ + return getParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL); +} + +void LLViewerObject::setHasRenderMaterialParams(bool has_materials) +{ + bool had_materials = hasRenderMaterialParams(); + + if (had_materials != has_materials) + { + if (has_materials) + { + setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, true); + } + else + { + setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, FALSE, true); + } + } +} + +const LLUUID& LLViewerObject::getRenderMaterialID(U8 te) const +{ + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + return param_block->getMaterial(te); + } + + return LLUUID::null; +} + +void LLViewerObject::setRenderMaterialID(U8 te, const LLUUID& id) +{ + if (id.notNull()) + { + getTE(te)->setGLTFMaterial(gGLTFMaterialList.getMaterial(id)); + setHasRenderMaterialParams(true); + } + else + { + getTE(te)->setGLTFMaterial(nullptr); + } + + faceMappingChanged(); + gPipeline.markTextured(mDrawable); + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + param_block->setMaterial(te, id); + + if (param_block->isEmpty()) + { // might be empty if id is null + setHasRenderMaterialParams(false); + } + else + { + parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true); + } + } +} class ObjectPhysicsProperties : public LLHTTPNode { |