The UI portion of Bakes on Mesh... and the entire thing, sure, why not?

Also let's now select the proper tab when we input an ID or select a face
with an asset ID that we can find in a tab, but that never works for BOM
when applied.
This commit is contained in:
Liru Færs
2019-10-10 21:19:50 -04:00
parent 1cb9ea16da
commit 7c24e67c50
18 changed files with 722 additions and 42 deletions

View File

@@ -4765,12 +4765,75 @@ void LLViewerObject::sendTEUpdate() const
msg->sendReliable( regionp->getHost() );
}
LLViewerTexture* LLViewerObject::getBakedTextureForMagicId(const LLUUID& id)
{
if (!LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(id))
{
return NULL;
}
LLViewerObject *root = getRootEdit();
if (root && root->isAnimatedObject())
{
return LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
}
LLVOAvatar* avatar = getAvatar();
if (avatar)
{
LLAvatarAppearanceDefines::EBakedTextureIndex texIndex = LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::assetIdToBakedTextureIndex(id);
LLViewerTexture* bakedTexture = avatar->getBakedTexture(texIndex);
if (bakedTexture == NULL || bakedTexture->isMissingAsset())
{
return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
}
else
{
return bakedTexture;
}
}
else
{
return LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
}
}
void LLViewerObject::updateAvatarMeshVisibility(const LLUUID& id, const LLUUID& old_id)
{
if (id == old_id)
{
return;
}
if (!LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(old_id) && !LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(id))
{
return;
}
LLVOAvatar* avatar = getAvatar();
if (avatar)
{
avatar->updateMeshVisibility();
}
}
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);
const LLUUID& image_id = getTE(te)->getID();
mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
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);
if (getTE(te)->getMaterialParams().notNull())
{
@@ -4782,12 +4845,31 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry)
}
}
void LLViewerObject::refreshBakeTexture()
{
for (int face_index = 0; face_index < getNumTEs(); face_index++)
{
LLTextureEntry* tex_entry = getTE(face_index);
if (tex_entry && LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(tex_entry->getID()))
{
const LLUUID& image_id = tex_entry->getID();
LLViewerTexture* bakedTexture = getBakedTextureForMagicId(image_id);
changeTEImage(face_index, bakedTexture);
}
}
}
void LLViewerObject::setTEImage(const U8 te, LLViewerTexture *imagep)
{
if (mTEImages[te] != imagep)
{
mTEImages[te] = imagep;
LLUUID old_image_id = getTE(te) ? getTE(te)->getID() : LLUUID::null;
LLPrimitive::setTETexture(te, imagep->getID());
LLViewerTexture* baked_texture = getBakedTextureForMagicId(imagep->getID());
mTEImages[te] = baked_texture ? baked_texture : imagep;
updateAvatarMeshVisibility(imagep->getID(), old_image_id);
setChanged(TEXTURE);
if (mDrawable.notNull())
{
@@ -4798,13 +4880,18 @@ void LLViewerObject::setTEImage(const U8 te, LLViewerTexture *imagep)
S32 LLViewerObject::setTETextureCore(const U8 te, LLViewerTexture *image)
{
if (!image)
return 0;
LLUUID old_image_id = getTE(te)->getID();
const LLUUID& uuid = image->getID();
S32 retval = 0;
if (uuid != getTE(te)->getID() ||
uuid == LLUUID::null)
{
retval = LLPrimitive::setTETexture(te, uuid);
mTEImages[te] = image;
LLViewerTexture* baked_texture = getBakedTextureForMagicId(uuid);
mTEImages[te] = baked_texture ? baked_texture : image;
updateAvatarMeshVisibility(uuid,old_image_id);
setChanged(TEXTURE);
if (mDrawable.notNull())
{