summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerobject.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-06-23 16:21:53 -0500
committerDave Parks <davep@lindenlab.com>2022-06-23 16:21:53 -0500
commit394479d7cc48a0170854e07f14267e28ba247990 (patch)
tree4e68623cf90138e851e082619d52b04c26949ea0 /indra/newview/llviewerobject.cpp
parent54edd8ba8b824241f3d6df9e3ffff7a7c926665d (diff)
SL-17653 WIP - Apply GLTF material in Material Editor to selected object when you click "Save"
Diffstat (limited to 'indra/newview/llviewerobject.cpp')
-rw-r--r--indra/newview/llviewerobject.cpp56
1 files changed, 42 insertions, 14 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 857a94d7be..16479e02a2 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -406,6 +406,11 @@ void LLViewerObject::deleteTEImages()
delete[] mTESpecularMaps;
mTESpecularMaps = NULL;
}
+
+ mGLTFAlbedoMaps.clear();
+ mGLTFNormalMaps.clear();
+ mGLTFMetallicRoughnessMaps.clear();
+ mGLTFEmissiveMaps.clear();
}
void LLViewerObject::markDead()
@@ -4731,6 +4736,11 @@ void LLViewerObject::setNumTEs(const U8 num_tes)
mTEImages = new_images;
mTENormalMaps = new_normmaps;
mTESpecularMaps = new_specmaps;
+
+ mGLTFAlbedoMaps.resize(num_tes);
+ mGLTFNormalMaps.resize(num_tes);
+ mGLTFMetallicRoughnessMaps.resize(num_tes);
+ mGLTFEmissiveMaps.resize(num_tes);
}
else
{
@@ -4859,23 +4869,28 @@ void LLViewerObject::updateAvatarMeshVisibility(const LLUUID& id, const LLUUID&
}
}
-void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry)
+
+void LLViewerObject::setTE(const U8 te, const LLTextureEntry& texture_entry)
{
- LLUUID old_image_id;
- if (getTE(te))
- {
- old_image_id = getTE(te)->getID();
- }
-
- LLPrimitive::setTE(te, texture_entry);
+ LLUUID old_image_id;
+ if (getTE(te))
+ {
+ old_image_id = getTE(te)->getID();
+ }
- const LLUUID& image_id = getTE(te)->getID();
- LLViewerTexture* bakedTexture = getBakedTextureForMagicId(image_id);
- mTEImages[te] = bakedTexture ? bakedTexture : LLViewerTextureManager::getFetchedTexture(image_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
+ LLPrimitive::setTE(te, texture_entry);
-
- updateAvatarMeshVisibility(image_id,old_image_id);
+ const LLUUID& image_id = getTE(te)->getID();
+ LLViewerTexture* bakedTexture = getBakedTextureForMagicId(image_id);
+ mTEImages[te] = bakedTexture ? bakedTexture : LLViewerTextureManager::getFetchedTexture(image_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
+
+ updateAvatarMeshVisibility(image_id, old_image_id);
+ updateTEMaterialTextures(te);
+}
+
+void LLViewerObject::updateTEMaterialTextures(U8 te)
+{
if (getTE(te)->getMaterialParams().notNull())
{
const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID();
@@ -4884,6 +4899,20 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry)
const LLUUID& spec_id = getTE(te)->getMaterialParams()->getSpecularID();
mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE);
}
+
+ auto fetch_texture = [](const LLUUID& id)
+ {
+ return LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE);
+ };
+
+ LLGLTFMaterial* mat = getTE(te)->getGLTFMaterial();
+ if (mat != nullptr)
+ {
+ mGLTFAlbedoMaps[te] = fetch_texture(mat->mAlbedoId);
+ mGLTFNormalMaps[te] = fetch_texture(mat->mNormalId);
+ mGLTFMetallicRoughnessMaps[te] = fetch_texture(mat->mMetallicRoughnessId);
+ mGLTFEmissiveMaps[te] = fetch_texture(mat->mEmissiveId);
+ }
}
void LLViewerObject::refreshBakeTexture()
@@ -5424,7 +5453,6 @@ void LLViewerObject::fitFaceTexture(const U8 face)
LL_INFOS() << "fitFaceTexture not implemented" << LL_ENDL;
}
-
LLBBox LLViewerObject::getBoundingBoxAgent() const
{
LLVector3 position_agent;