summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturectrl.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-03-26 16:55:32 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-03-26 16:55:32 -0400
commitc810a409e22b90ebacb9946f8a4084ef0ad78d64 (patch)
tree9fc508213bd00db70fc7aba7f3d4995541266f11 /indra/newview/lltexturectrl.cpp
parent656d1826e665b477e85ec3cf6db07677a3b88852 (diff)
parentdd74c2cbd542daa8d6cedba7ba7a68268f7b73d3 (diff)
Merge GLTF PBR Maint 2 to main.
Diffstat (limited to 'indra/newview/lltexturectrl.cpp')
-rw-r--r--indra/newview/lltexturectrl.cpp134
1 files changed, 78 insertions, 56 deletions
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 28e01c6c21..62d3fa28bf 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -82,9 +82,11 @@
//static
bool get_is_predefined_texture(LLUUID asset_id)
{
- if (asset_id == LLUUID(gSavedSettings.getString("DefaultObjectTexture"))
- || asset_id == LLUUID(gSavedSettings.getString("UIImgWhiteUUID"))
- || asset_id == LLUUID(gSavedSettings.getString("UIImgInvisibleUUID"))
+ if (asset_id == DEFAULT_OBJECT_TEXTURE
+ || asset_id == DEFAULT_OBJECT_SPECULAR
+ || asset_id == DEFAULT_OBJECT_NORMAL
+ || asset_id == BLANK_OBJECT_NORMAL
+ || asset_id == IMG_WHITE
|| asset_id == LLUUID(SCULPT_DEFAULT_TEXTURE))
{
return true;
@@ -151,7 +153,8 @@ LLFloaterTexturePicker::LLFloaterTexturePicker(
PermissionMask immediate_filter_perm_mask,
PermissionMask dnd_filter_perm_mask,
BOOL can_apply_immediately,
- LLUIImagePtr fallback_image)
+ LLUIImagePtr fallback_image,
+ EPickInventoryType pick_type)
: LLFloater(LLSD()),
mOwner( owner ),
mImageAssetID( image_asset_id ),
@@ -181,7 +184,7 @@ LLFloaterTexturePicker::LLFloaterTexturePicker(
mSetImageAssetIDCallback(NULL),
mOnUpdateImageStatsCallback(NULL),
mBakeTextureEnabled(FALSE),
- mInventoryPickType(LLTextureCtrl::PICK_TEXTURE)
+ mInventoryPickType(pick_type)
{
mCanApplyImmediately = can_apply_immediately;
buildFromFile("floater_texture_ctrl.xml");
@@ -225,7 +228,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selecti
LLInventoryItem* itemp = gInventory.getItem(inv_view->getUUID());
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL
+ if (mInventoryPickType == PICK_MATERIAL
&& mImageAssetID == LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID
&& itemp && itemp->getAssetUUID().isNull())
{
@@ -266,7 +269,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selecti
void LLFloaterTexturePicker::setImageIDFromItem(const LLInventoryItem* itemp, bool set_selection)
{
LLUUID asset_id = itemp->getAssetUUID();
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL && asset_id.isNull())
+ if (mInventoryPickType == PICK_MATERIAL && asset_id.isNull())
{
// If an inventory item has a null asset, consider it a valid blank material(gltf)
asset_id = LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID;
@@ -425,11 +428,11 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop(
bool is_material = cargo_type == DAD_MATERIAL;
bool allow_dnd = false;
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ if (mInventoryPickType == PICK_MATERIAL)
{
allow_dnd = is_material;
}
- else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE)
+ else if (mInventoryPickType == PICK_TEXTURE)
{
allow_dnd = is_texture || is_mesh;
}
@@ -602,9 +605,7 @@ BOOL LLFloaterTexturePicker::postBuild()
// don't put keyboard focus on selected item, because the selection callback
// will assume that this was user input
-
-
- if(!mImageAssetID.isNull())
+ if(!mImageAssetID.isNull() || mInventoryPickType == PICK_MATERIAL)
{
mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO);
}
@@ -661,7 +662,7 @@ void LLFloaterTexturePicker::draw()
mGLTFMaterial = NULL;
if (mImageAssetID.notNull())
{
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ if (mInventoryPickType == PICK_MATERIAL)
{
mGLTFMaterial = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mImageAssetID);
llassert(mGLTFMaterial == nullptr || dynamic_cast<LLFetchedGLTFMaterial*>(gGLTFMaterialList.getMaterial(mImageAssetID)) != nullptr);
@@ -786,27 +787,43 @@ void LLFloaterTexturePicker::draw()
const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, BOOL copyable_only, BOOL ignore_library)
{
- LLUUID loockup_id = asset_id;
- if (loockup_id.isNull())
+ if (asset_id.isNull())
{
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
- {
- loockup_id = LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID;
- }
- else
- {
- return LLUUID::null;
- }
+ // null asset id means, no material or texture assigned
+ return LLUUID::null;
}
+ LLUUID loockup_id = asset_id;
+ if (mInventoryPickType == PICK_MATERIAL && loockup_id == LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID)
+ {
+ // default asset id means we are looking for an inventory item with a default asset UUID (null)
+ loockup_id = LLUUID::null;
+ }
+
LLViewerInventoryCategory::cat_array_t cats;
LLViewerInventoryItem::item_array_t items;
- LLAssetIDMatches asset_id_matches(loockup_id);
- gInventory.collectDescendentsIf(LLUUID::null,
- cats,
- items,
- LLInventoryModel::INCLUDE_TRASH,
- asset_id_matches);
+
+ if (loockup_id.isNull())
+ {
+ // looking for a material with a null id, null id is shared by a lot
+ // of objects as a default value, so have to filter by type as well
+ LLAssetIDAndTypeMatches matches(loockup_id, LLAssetType::AT_MATERIAL);
+ gInventory.collectDescendentsIf(LLUUID::null,
+ cats,
+ items,
+ LLInventoryModel::INCLUDE_TRASH,
+ matches);
+ }
+ else
+ {
+ LLAssetIDMatches asset_id_matches(loockup_id);
+ gInventory.collectDescendentsIf(LLUUID::null,
+ cats,
+ items,
+ LLInventoryModel::INCLUDE_TRASH,
+ asset_id_matches);
+ }
+
if (items.size())
{
@@ -871,7 +888,7 @@ void LLFloaterTexturePicker::commitCallback(LLTextureCtrl::ETexturePickOp op)
LLInventoryItem* itemp = gInventory.getItem(inv_view->getUUID());
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL
+ if (mInventoryPickType == PICK_MATERIAL
&& mImageAssetID == LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID
&& itemp && itemp->getAssetUUID().isNull())
{
@@ -1064,15 +1081,15 @@ void LLFloaterTexturePicker::onBtnAdd(void* userdata)
{
LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)userdata;
- if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL)
+ if (self->mInventoryPickType == PICK_TEXTURE_MATERIAL)
{
LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL_TEXTURE, true);
}
- else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE)
+ else if (self->mInventoryPickType == PICK_TEXTURE)
{
LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_IMAGE, true);
}
- else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ else if (self->mInventoryPickType == PICK_MATERIAL)
{
LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL, true);
}
@@ -1351,7 +1368,7 @@ void LLFloaterTexturePicker::changeMode()
getChild<LLCheckBoxCtrl>("hide_base_mesh_region")->setVisible(FALSE);// index == 2 ? TRUE : FALSE);
bool pipette_visible = (index == PICKER_INVENTORY)
- && (mInventoryPickType != LLTextureCtrl::PICK_MATERIAL);
+ && (mInventoryPickType != PICK_MATERIAL);
mPipetteBtn->setVisible(pipette_visible);
if (index == PICKER_BAKE)
@@ -1414,16 +1431,16 @@ void LLFloaterTexturePicker::refreshLocalList()
{
mLocalScrollCtrl->clearRows();
- if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL)
+ if (mInventoryPickType == PICK_TEXTURE_MATERIAL)
{
LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl);
LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl);
}
- else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE)
+ else if (mInventoryPickType == PICK_TEXTURE)
{
LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl);
}
- else if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ else if (mInventoryPickType == PICK_MATERIAL)
{
LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl);
}
@@ -1433,18 +1450,18 @@ void LLFloaterTexturePicker::refreshInventoryFilter()
{
U32 filter_types = 0x0;
- if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL)
+ if (mInventoryPickType == PICK_TEXTURE_MATERIAL)
{
filter_types |= 0x1 << LLInventoryType::IT_TEXTURE;
filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT;
filter_types |= 0x1 << LLInventoryType::IT_MATERIAL;
}
- else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE)
+ else if (mInventoryPickType == PICK_TEXTURE)
{
filter_types |= 0x1 << LLInventoryType::IT_TEXTURE;
filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT;
}
- else if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ else if (mInventoryPickType == PICK_MATERIAL)
{
filter_types |= 0x1 << LLInventoryType::IT_MATERIAL;
}
@@ -1479,13 +1496,13 @@ void LLFloaterTexturePicker::setBakeTextureEnabled(BOOL enabled)
onModeSelect(0, this);
}
-void LLFloaterTexturePicker::setInventoryPickType(LLTextureCtrl::EPickInventoryType type)
+void LLFloaterTexturePicker::setInventoryPickType(EPickInventoryType type)
{
mInventoryPickType = type;
refreshLocalList();
refreshInventoryFilter();
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ if (mInventoryPickType == PICK_MATERIAL)
{
getChild<LLButton>("Pipette")->setVisible(false);
}
@@ -1501,7 +1518,7 @@ void LLFloaterTexturePicker::setInventoryPickType(LLTextureCtrl::EPickInventoryT
setTitle(pick + mLabel);
}
- else if(mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ else if(mInventoryPickType == PICK_MATERIAL)
{
setTitle(getString("pick_material"));
}
@@ -1509,6 +1526,12 @@ void LLFloaterTexturePicker::setInventoryPickType(LLTextureCtrl::EPickInventoryT
{
setTitle(getString("pick_texture"));
}
+
+ // refresh selection
+ if (!mImageAssetID.isNull() || mInventoryPickType == PICK_MATERIAL)
+ {
+ mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO);
+ }
}
void LLFloaterTexturePicker::setImmediateFilterPermMask(PermissionMask mask)
@@ -1543,16 +1566,16 @@ void LLFloaterTexturePicker::onPickerCallback(const std::vector<std::string>& fi
LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)handle.get();
self->mLocalScrollCtrl->clearRows();
- if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL)
+ if (self->mInventoryPickType == PICK_TEXTURE_MATERIAL)
{
LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl);
LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl);
}
- else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE)
+ else if (self->mInventoryPickType == PICK_TEXTURE)
{
LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl);
}
- else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ else if (self->mInventoryPickType == PICK_MATERIAL)
{
LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl);
}
@@ -1565,7 +1588,7 @@ void LLFloaterTexturePicker::onTextureSelect( const LLTextureEntry& te )
if (inventory_item_id.notNull())
{
LLToolPipette::getInstance()->setResult(TRUE, "");
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ if (mInventoryPickType == PICK_MATERIAL)
{
// tes have no data about material ids
// Plus gltf materials are layered with overrides,
@@ -1625,8 +1648,7 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p)
// Default of defaults is white image for diff tex
//
- LLUUID whiteImage( gSavedSettings.getString( "UIImgWhiteUUID" ) );
- setBlankImageAssetID( whiteImage );
+ setBlankImageAssetID(IMG_WHITE);
setAllowNoTexture(p.allow_no_texture);
setCanApplyImmediately(p.can_apply_immediately);
@@ -1807,7 +1829,8 @@ void LLTextureCtrl::showPicker(BOOL take_focus)
mImmediateFilterPermMask,
mDnDFilterPermMask,
mCanApplyImmediately,
- mFallbackImage);
+ mFallbackImage,
+ mInventoryPickType);
mFloaterHandle = floaterp->getHandle();
LLFloaterTexturePicker* texture_floaterp = dynamic_cast<LLFloaterTexturePicker*>(floaterp);
@@ -1828,7 +1851,6 @@ void LLTextureCtrl::showPicker(BOOL take_focus)
texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1));
texture_floaterp->setBakeTextureEnabled(mBakeTextureEnabled);
- texture_floaterp->setInventoryPickType(mInventoryPickType);
}
LLFloater* root_floater = gFloaterView->getParentFloater(this);
@@ -1891,7 +1913,7 @@ BOOL LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask)
if (!mOpenTexPreview)
{
showPicker(FALSE);
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ if (mInventoryPickType == PICK_MATERIAL)
{
//grab materials first...
LLInventoryModelBackgroundFetch::instance().start(gInventory.findCategoryUUIDForType(LLFolderType::FT_MATERIAL));
@@ -2089,11 +2111,11 @@ BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
bool is_material = cargo_type == DAD_MATERIAL;
bool allow_dnd = false;
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ if (mInventoryPickType == PICK_MATERIAL)
{
allow_dnd = is_material;
}
- else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE)
+ else if (mInventoryPickType == PICK_TEXTURE)
{
allow_dnd = is_texture || is_mesh;
}
@@ -2156,7 +2178,7 @@ void LLTextureCtrl::draw()
if (texture.isNull())
{
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL)
+ if (mInventoryPickType == PICK_MATERIAL)
{
LLPointer<LLFetchedGLTFMaterial> material = gGLTFMaterialList.getMaterial(mImageAssetID);
if (material)
@@ -2313,7 +2335,7 @@ BOOL LLTextureCtrl::doDrop(LLInventoryItem* item)
// no callback installed, so just set the image ids and carry on.
LLUUID asset_id = item->getAssetUUID();
- if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL && asset_id.isNull())
+ if (mInventoryPickType == PICK_MATERIAL && asset_id.isNull())
{
// If an inventory material has a null asset, consider it a valid blank material(gltf)
asset_id = LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID;