Merge branch 'release/gltf-maint2' of https://github.com/secondlife/viewer

# Conflicts:
#	README.md
master
Ansariel 2024-02-11 19:46:50 +01:00
commit 86230977c4
9 changed files with 201 additions and 68 deletions

View File

@ -4,8 +4,8 @@ on:
workflow_dispatch:
pull_request:
push:
branches: ["*"]
tags: ["*"]
branches: ["main", "release/*", "project/*"]
tags: ["Second_Life_*"]
jobs:
build:

View File

@ -50,7 +50,7 @@ const LLUUID IMG_FIRE ("aca40aa8-44cf-44ca-a0fa-93e1a2986f82"); // dataserver
const LLUUID IMG_FACE_SELECT ("a85ac674-cb75-4af6-9499-df7c5aaf7a28"); // face selector
const LLUUID IMG_DEFAULT_AVATAR ("c228d1cf-4b5d-4ba8-84f4-899a0796aa97"); // dataserver
const LLUUID IMG_INVISIBLE ("3a367d1c-bef1-6d43-7595-e88c1e3aadb3"); // dataserver
const LLUUID IMG_WHITE ("3a367d1c-bef1-6d43-7595-e88c1e3aadb3"); // dataserver
const LLUUID IMG_WHITE ("5748decc-f629-461c-9a36-a35a221fe21f"); // dataserver
const LLUUID IMG_EXPLOSION ("68edcf47-ccd7-45b8-9f90-1649d7f12806"); // On dataserver
const LLUUID IMG_EXPLOSION_2 ("21ce046c-83fe-430a-b629-c7660ac78d7c"); // On dataserver

View File

@ -229,6 +229,17 @@ LLRender::eTexIndex LLPanelFace::getTextureDropChannel()
return LLRender::eTexIndex(MATTYPE_DIFFUSE);
}
LLGLTFMaterial::TextureInfo LLPanelFace::getPBRDropChannel()
{
if (mComboMatMedia && mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR)
{
LLRadioGroup* radio_pbr_type = getChild<LLRadioGroup>("radio_pbr_type");
return texture_info_from_pbrtype(radio_pbr_type->getSelectedIndex());
}
return texture_info_from_pbrtype(PBRTYPE_BASE_COLOR);
}
// Things the UI provides...
//
LLUUID LLPanelFace::getCurrentNormalMap() { return mBumpyTextureCtrl->getImageAssetID(); }
@ -4837,7 +4848,8 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te)
LLToolDragAndDrop::dropTextureAllFaces(objectp,
itemp_res,
from_library ? LLToolDragAndDrop::SOURCE_LIBRARY : LLToolDragAndDrop::SOURCE_AGENT,
LLUUID::null);
LLUUID::null,
false);
}
else // one face
{
@ -4846,6 +4858,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te)
itemp_res,
from_library ? LLToolDragAndDrop::SOURCE_LIBRARY : LLToolDragAndDrop::SOURCE_AGENT,
LLUUID::null,
false,
0);
}
}

View File

@ -128,6 +128,7 @@ public:
LLRender::eTexIndex getTextureChannelToEdit();
LLRender::eTexIndex getTextureDropChannel();
LLGLTFMaterial::TextureInfo getPBRDropChannel();
protected:
void navigateToTitleMedia(const std::string url);

View File

@ -1966,7 +1966,8 @@ bool LLSelectMgr::selectionSetImage(const LLUUID& imageid)
te,
mItem,
LLToolDragAndDrop::SOURCE_AGENT,
LLUUID::null);
LLUUID::null,
false);
}
else // not an inventory item
{

View File

@ -1080,10 +1080,64 @@ BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj,
return TRUE;
}
void set_texture_to_material(LLViewerObject* hit_obj,
S32 hit_face,
const LLUUID& asset_id,
LLGLTFMaterial::TextureInfo drop_channel)
{
LLTextureEntry* te = hit_obj->getTE(hit_face);
if (te)
{
LLPointer<LLGLTFMaterial> material = te->getGLTFMaterialOverride();
// make a copy to not invalidate existing
// material for multiple objects
if (material.isNull())
{
// Start with a material override which does not make any changes
material = new LLGLTFMaterial();
}
else
{
material = new LLGLTFMaterial(*material);
}
switch (drop_channel)
{
case LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR:
default:
{
material->setBaseColorId(asset_id);
}
break;
case LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS:
{
material->setOcclusionRoughnessMetallicId(asset_id);
}
break;
case LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE:
{
material->setEmissiveId(asset_id);
}
break;
case LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL:
{
material->setNormalId(asset_id);
}
break;
}
LLGLTFMaterialList::queueModify(hit_obj, hit_face, material);
}
}
void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
LLInventoryItem* item,
LLToolDragAndDrop::ESource source,
const LLUUID& src_id)
const LLUUID& src_id,
bool remove_pbr)
{
if (!item)
{
@ -1100,28 +1154,46 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
break;
}
}
if (!has_non_pbr_faces)
if (has_non_pbr_faces || remove_pbr)
{
return;
BOOL res = handleDropMaterialProtections(hit_obj, item, source, src_id);
if (!res)
{
return;
}
}
LLUUID asset_id = item->getAssetUUID();
BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id);
if (!success)
{
return;
}
// Overrides require textures to be copy and transfer free
LLPermissions item_permissions = item->getPermissions();
bool allow_adding_to_override = item_permissions.allowOperationBy(PERM_COPY, gAgent.getID());
allow_adding_to_override &= item_permissions.allowOperationBy(PERM_TRANSFER, gAgent.getID());
LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
add(LLStatViewer::EDIT_TEXTURE, 1);
for( S32 face = 0; face < num_faces; face++ )
{
if (hit_obj->getRenderMaterialID(face).isNull())
if (remove_pbr)
{
// update viewer side image in anticipation of update from simulator
hit_obj->setRenderMaterialID(face, LLUUID::null);
hit_obj->setTEImage(face, image);
dialog_refresh_all();
}
else if (hit_obj->getRenderMaterialID(face).isNull())
{
// update viewer side
hit_obj->setTEImage(face, image);
dialog_refresh_all();
}
else if (allow_adding_to_override)
{
set_texture_to_material(hit_obj, face, asset_id, LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR);
}
}
// send the update to the simulator
LLGLTFMaterialList::flushUpdates(nullptr);
hit_obj->sendTEUpdate();
}
@ -1269,21 +1341,13 @@ void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj,
dialog_refresh_all();
}
/*
void LLToolDragAndDrop::dropTextureOneFaceAvatar(LLVOAvatar* avatar, S32 hit_face, LLInventoryItem* item)
{
if (hit_face == -1) return;
LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(item->getAssetUUID());
avatar->userSetOptionalTE( hit_face, image);
}
*/
void LLToolDragAndDrop::dropTexture(LLViewerObject* hit_obj,
S32 hit_face,
LLInventoryItem* item,
ESource source,
const LLUUID& src_id,
bool all_faces,
bool remove_pbr,
S32 tex_channel)
{
LLSelectNode* nodep = nullptr;
@ -1295,13 +1359,15 @@ void LLToolDragAndDrop::dropTexture(LLViewerObject* hit_obj,
if (all_faces)
{
dropTextureAllFaces(hit_obj, item, source, src_id);
dropTextureAllFaces(hit_obj, item, source, src_id, remove_pbr);
// If user dropped a texture onto face it implies
// applying texture now without cancel, save to selection
if (nodep)
{
uuid_vec_t texture_ids;
uuid_vec_t material_ids;
gltf_materials_vec_t override_materials;
S32 num_faces = hit_obj->getNumTEs();
for (S32 face = 0; face < num_faces; face++)
{
@ -1314,13 +1380,35 @@ void LLToolDragAndDrop::dropTexture(LLViewerObject* hit_obj,
{
texture_ids.push_back(LLUUID::null);
}
// either removed or modified materials
if (remove_pbr)
{
material_ids.push_back(LLUUID::null);
}
else
{
material_ids.push_back(hit_obj->getRenderMaterialID(face));
}
LLTextureEntry* te = hit_obj->getTE(hit_face);
if (te && !remove_pbr)
{
override_materials.push_back(te->getGLTFMaterialOverride());
}
else
{
override_materials.push_back(nullptr);
}
}
nodep->saveTextures(texture_ids);
nodep->saveGLTFMaterials(material_ids, override_materials);
}
}
else
{
dropTextureOneFace(hit_obj, hit_face, item, source, src_id);
dropTextureOneFace(hit_obj, hit_face, item, source, src_id, remove_pbr, tex_channel);
// If user dropped a texture onto face it implies
// applying texture now without cancel, save to selection
@ -1340,6 +1428,16 @@ void LLToolDragAndDrop::dropTexture(LLViewerObject* hit_obj,
{
nodep->mSavedTextures[hit_face] = LLUUID::null;
}
LLTextureEntry* te = hit_obj->getTE(hit_face);
if (te && !remove_pbr)
{
nodep->mSavedGLTFOverrideMaterials[hit_face] = te->getGLTFMaterialOverride();
}
else
{
nodep->mSavedGLTFOverrideMaterials[hit_face] = nullptr;
}
}
}
}
@ -1349,6 +1447,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
LLInventoryItem* item,
LLToolDragAndDrop::ESource source,
const LLUUID& src_id,
bool remove_pbr,
S32 tex_channel)
{
if (hit_face == -1) return;
@ -1357,21 +1456,44 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
LL_WARNS() << "LLToolDragAndDrop::dropTextureOneFace no texture item." << LL_ENDL;
return;
}
if (hit_obj->getRenderMaterialID(hit_face).notNull())
LLUUID asset_id = item->getAssetUUID();
if (hit_obj->getRenderMaterialID(hit_face).notNull() && !remove_pbr)
{
// Overrides require textures to be copy and transfer free
LLPermissions item_permissions = item->getPermissions();
bool allow_adding_to_override = item_permissions.allowOperationBy(PERM_COPY, gAgent.getID());
allow_adding_to_override &= item_permissions.allowOperationBy(PERM_TRANSFER, gAgent.getID());
if (allow_adding_to_override)
{
LLGLTFMaterial::TextureInfo drop_channel = LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR;
LLPanelFace* panel_face = gFloaterTools->getPanelFace();
if (gFloaterTools->getVisible() && panel_face)
{
drop_channel = panel_face->getPBRDropChannel();
}
set_texture_to_material(hit_obj, hit_face, asset_id, drop_channel);
LLGLTFMaterialList::flushUpdates(nullptr);
}
return;
}
LLUUID asset_id = item->getAssetUUID();
BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id);
if (!success)
{
return;
}
if (remove_pbr)
{
hit_obj->setRenderMaterialID(hit_face, LLUUID::null);
}
// update viewer side image in anticipation of update from simulator
LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
add(LLStatViewer::EDIT_TEXTURE, 1);
LLTextureEntry* tep = hit_obj ? (hit_obj->getTE(hit_face)) : NULL;
LLTextureEntry* tep = hit_obj->getTE(hit_face);
LLPanelFace* panel_face = gFloaterTools->getPanelFace();
@ -1389,6 +1511,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
break;
case 1:
if (tep)
{
LLMaterialPtr old_mat = tep->getMaterialParams();
LLMaterialPtr new_mat = panel_face->createDefaultMaterial(old_mat);
@ -1400,6 +1523,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
break;
case 2:
if (tep)
{
LLMaterialPtr old_mat = tep->getMaterialParams();
LLMaterialPtr new_mat = panel_face->createDefaultMaterial(old_mat);
@ -2284,6 +2408,7 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
LLViewerInventoryCategory* cat;
locateInventory(item, cat);
if (!item || !item->isFinished()) return ACCEPT_NO;
LLPermissions item_permissions = item->getPermissions();
EAcceptance rv = willObjectAcceptInventory(obj, item);
if((mask & MASK_CONTROL))
{
@ -2298,12 +2423,12 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
return ACCEPT_NO_LOCKED;
}
if (cargo_type == DAD_TEXTURE)
if (cargo_type == DAD_TEXTURE && (mask & MASK_ALT) == 0)
{
bool has_non_pbr_faces = false;
if ((mask & MASK_SHIFT))
{
S32 num_faces = obj->getNumTEs();
bool has_non_pbr_faces = false;
for (S32 face = 0; face < num_faces; face++)
{
if (obj->getRenderMaterialID(face).isNull())
@ -2312,14 +2437,19 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
break;
}
}
if (!has_non_pbr_faces)
{
return ACCEPT_NO;
}
}
else if (obj->getRenderMaterialID(face).notNull())
else
{
return ACCEPT_NO;
has_non_pbr_faces = obj->getRenderMaterialID(face).isNull();
}
if (!has_non_pbr_faces)
{
// Only pbr faces selected, texture will be added to an override
// Overrides require textures to be copy and transfer free
bool allow_adding_to_override = item_permissions.allowOperationBy(PERM_COPY, gAgent.getID());
allow_adding_to_override &= item_permissions.allowOperationBy(PERM_TRANSFER, gAgent.getID());
if (!allow_adding_to_override) return ACCEPT_NO;
}
}
@ -2328,15 +2458,16 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
if (cargo_type == DAD_TEXTURE)
{
bool all_faces = mask & MASK_SHIFT;
if (item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()))
bool remove_pbr = mask & MASK_ALT;
if (item_permissions.allowOperationBy(PERM_COPY, gAgent.getID()))
{
dropTexture(obj, face, item, mSource, mSourceID, all_faces);
dropTexture(obj, face, item, mSource, mSourceID, all_faces, remove_pbr);
}
else
{
ESource source = mSource;
LLUUID source_id = mSourceID;
LLNotificationsUtil::add("ApplyInventoryToObject", LLSD(), LLSD(), [obj, face, item, source, source_id, all_faces](const LLSD& notification, const LLSD& response)
LLNotificationsUtil::add("ApplyInventoryToObject", LLSD(), LLSD(), [obj, face, item, source, source_id, all_faces, remove_pbr](const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
// if Cancel pressed
@ -2344,7 +2475,7 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
{
return;
}
dropTexture(obj, face, item, source, source_id, all_faces);
dropTexture(obj, face, item, source, source_id, all_faces, remove_pbr);
});
}
}
@ -2411,23 +2542,6 @@ EAcceptance LLToolDragAndDrop::dad3dMeshObject(
return dad3dApplyToObject(obj, face, mask, drop, DAD_MESH);
}
/*
EAcceptance LLToolDragAndDrop::dad3dTextureSelf(
LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
{
LL_DEBUGS() << "LLToolDragAndDrop::dad3dTextureAvatar()" << LL_ENDL;
if(drop)
{
if( !(mask & MASK_SHIFT) )
{
dropTextureOneFaceAvatar( (LLVOAvatar*)obj, face, (LLInventoryItem*)mCargoData);
}
}
return (mask & MASK_SHIFT) ? ACCEPT_NO : ACCEPT_YES_SINGLE;
}
*/
EAcceptance LLToolDragAndDrop::dad3dWearItem(
LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
{

View File

@ -249,17 +249,20 @@ public:
ESource source,
const LLUUID& src_id,
bool all_faces,
bool replace_pbr,
S32 tex_channel = -1);
static void dropTextureOneFace(LLViewerObject* hit_obj,
S32 hit_face,
LLInventoryItem* item,
ESource source,
const LLUUID& src_id,
bool remove_pbr,
S32 tex_channel = -1);
static void dropTextureAllFaces(LLViewerObject* hit_obj,
LLInventoryItem* item,
ESource source,
const LLUUID& src_id);
const LLUUID& src_id,
bool remove_pbr);
static void dropMaterial(LLViewerObject* hit_obj,
S32 hit_face,
LLInventoryItem* item,

View File

@ -846,8 +846,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("display - 2")
if (gResizeScreenTexture)
{
gResizeScreenTexture = FALSE;
gPipeline.resizeScreenTexture();
gResizeScreenTexture = FALSE;
}
gGL.setColorMask(true, true);

View File

@ -5537,8 +5537,9 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
//drawable->getVObj()->setDebugText(llformat("%d", drawable->isState(LLDrawable::ANIMATED_CHILD)));
U8 bump = (type == LLRenderPass::PASS_BUMP || type == LLRenderPass::PASS_POST_BUMP) ? facep->getTextureEntry()->getBumpmap() : 0;
U8 shiny = facep->getTextureEntry()->getShiny();
const LLTextureEntry* te = facep->getTextureEntry();
U8 bump = (type == LLRenderPass::PASS_BUMP || type == LLRenderPass::PASS_POST_BUMP) ? te->getBumpmap() : 0;
U8 shiny = te->getShiny();
LLViewerTexture* tex = facep->getTexture();
@ -5548,22 +5549,22 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
LLUUID mat_id;
auto* gltf_mat = (LLFetchedGLTFMaterial*) facep->getTextureEntry()->getGLTFRenderMaterial();
llassert(gltf_mat == nullptr || dynamic_cast<LLFetchedGLTFMaterial*>(facep->getTextureEntry()->getGLTFRenderMaterial()) != nullptr);
auto* gltf_mat = (LLFetchedGLTFMaterial*)te->getGLTFRenderMaterial();
llassert(gltf_mat == nullptr || dynamic_cast<LLFetchedGLTFMaterial*>(te->getGLTFRenderMaterial()) != nullptr);
if (gltf_mat != nullptr)
{
mat_id = gltf_mat->getHash(); // TODO: cache this hash
if (!facep->hasMedia())
if (!facep->hasMedia() || (tex && tex->getType() != LLViewerTexture::MEDIA_TEXTURE))
{ // no media texture, face texture will be unused
tex = nullptr;
}
}
else
{
mat = facep->getTextureEntry()->getMaterialParams().get();
mat = te->getMaterialParams().get();
if (mat)
{
mat_id = facep->getTextureEntry()->getMaterialParams()->getHash();
mat_id = te->getMaterialParams()->getHash();
}
}
@ -5578,7 +5579,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
if (mat)
{
BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) || (facep->getTextureEntry()->getColor().mV[3] < 0.999f) ? TRUE : FALSE;
BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) || (te->getColor().mV[3] < 0.999f) ? TRUE : FALSE;
if (type == LLRenderPass::PASS_ALPHA)
{
shader_mask = mat->getShaderMask(LLMaterial::DIFFUSE_ALPHA_MODE_BLEND, is_alpha);