Changes to support applying textures to BlinnPhong when PBR exists
We need to inject a flag from the tools floater that reaches the dragdrop tooling overriding the behaviour that by-default applies the texture to the color channel on the PBR mat. This is minimal code but rather horrible for maintenance, suggestions of better options are welcome.master
parent
e1665ddb4b
commit
a0271ef772
|
|
@ -1919,8 +1919,52 @@ bool LLObjectSelection::applyRestrictedPbrMaterialToTEs(LLViewerInventoryItem* i
|
|||
//-----------------------------------------------------------------------------
|
||||
// selectionSetImage()
|
||||
//-----------------------------------------------------------------------------
|
||||
// <FS:Beq> Allow editing of non-PBR materials in-situ
|
||||
template<bool IsPBR>
|
||||
struct TextureApplyFunctor : public LLSelectedTEFunctor
|
||||
{
|
||||
LLViewerInventoryItem* mItem;
|
||||
LLUUID mImageID;
|
||||
TextureApplyFunctor(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mImageID(id) {}
|
||||
bool apply(LLViewerObject* objectp, S32 te) override
|
||||
{
|
||||
if(!objectp || !objectp->permModify())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mItem && objectp->isAttachment())
|
||||
{
|
||||
const LLPermissions& perm = mItem->getPermissions();
|
||||
BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE;
|
||||
if (!unrestricted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mItem)
|
||||
{
|
||||
if constexpr (IsPBR)
|
||||
{
|
||||
LLToolDragAndDrop::dropTextureOneFace(objectp, te, mItem, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LLToolDragAndDrop::dropTextureOneFace(objectp, te, mItem, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null, false, -2); // -2 means no PBR
|
||||
}
|
||||
}
|
||||
else // not an inventory item
|
||||
{
|
||||
objectp->setTEImage(te, LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// </FS:Beq>
|
||||
// *TODO: re-arch texture applying out of lltooldraganddrop
|
||||
bool LLSelectMgr::selectionSetImage(const LLUUID& imageid)
|
||||
bool LLSelectMgr::selectionSetImage(const LLUUID& imageid, bool isPBR)
|
||||
{
|
||||
// First for (no copy) textures and multiple object selection
|
||||
LLViewerInventoryItem* item = gInventory.getItem(imageid);
|
||||
|
|
@ -1935,60 +1979,73 @@ bool LLSelectMgr::selectionSetImage(const LLUUID& imageid)
|
|||
return false;
|
||||
}
|
||||
|
||||
struct f : public LLSelectedTEFunctor
|
||||
{
|
||||
LLViewerInventoryItem* mItem;
|
||||
LLUUID mImageID;
|
||||
f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mImageID(id) {}
|
||||
bool apply(LLViewerObject* objectp, S32 te)
|
||||
{
|
||||
if(!objectp || !objectp->permModify())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// <FS:Beq> Allow editing of non-PBR materials in-situ
|
||||
// struct f : public LLSelectedTEFunctor
|
||||
// {
|
||||
// LLViewerInventoryItem* mItem;
|
||||
// LLUUID mImageID;
|
||||
// f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mImageID(id) {}
|
||||
// bool apply(LLViewerObject* objectp, S32 te)
|
||||
// {
|
||||
// if(!objectp || !objectp->permModify())
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// Might be better to run willObjectAcceptInventory
|
||||
if (mItem && objectp->isAttachment())
|
||||
{
|
||||
const LLPermissions& perm = mItem->getPermissions();
|
||||
BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE;
|
||||
if (!unrestricted)
|
||||
{
|
||||
// Attachments are in world and in inventory simultaneously,
|
||||
// at the moment server doesn't support such a situation.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// // Might be better to run willObjectAcceptInventory
|
||||
// if (mItem && objectp->isAttachment())
|
||||
// {
|
||||
// const LLPermissions& perm = mItem->getPermissions();
|
||||
// BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE;
|
||||
// if (!unrestricted)
|
||||
// {
|
||||
// // Attachments are in world and in inventory simultaneously,
|
||||
// // at the moment server doesn't support such a situation.
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (mItem)
|
||||
{
|
||||
LLToolDragAndDrop::dropTextureOneFace(objectp,
|
||||
te,
|
||||
mItem,
|
||||
LLToolDragAndDrop::SOURCE_AGENT,
|
||||
LLUUID::null,
|
||||
false);
|
||||
}
|
||||
else // not an inventory item
|
||||
{
|
||||
// Texture picker defaults aren't inventory items
|
||||
// * Don't need to worry about permissions for them
|
||||
// * Can just apply the texture and be done with it.
|
||||
objectp->setTEImage(te, LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// if (mItem)
|
||||
// {
|
||||
// LLToolDragAndDrop::dropTextureOneFace(objectp,
|
||||
// te,
|
||||
// mItem,
|
||||
// LLToolDragAndDrop::SOURCE_AGENT,
|
||||
// LLUUID::null,
|
||||
// false);
|
||||
// }
|
||||
// else // not an inventory item
|
||||
// {
|
||||
// // Texture picker defaults aren't inventory items
|
||||
// // * Don't need to worry about permissions for them
|
||||
// // * Can just apply the texture and be done with it.
|
||||
// objectp->setTEImage(te, LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE));
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// }
|
||||
// };
|
||||
// </FS:Beq>
|
||||
if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()))
|
||||
{
|
||||
getSelection()->applyNoCopyTextureToTEs(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
f setfunc(item, imageid);
|
||||
getSelection()->applyToTEs(&setfunc);
|
||||
// <FS:Beq> Allow editing of non-PBR materials in-situ
|
||||
// f setfunc(item, imageid);
|
||||
// getSelection()->applyToTEs(&setfunc);
|
||||
TextureApplyFunctor<true> setfuncPBR(item, imageid); // For PBR textures
|
||||
TextureApplyFunctor<false> setfuncBP(item, imageid); // For non-PBR textures
|
||||
if(isPBR)
|
||||
{
|
||||
getSelection()->applyToTEs(&setfuncPBR);
|
||||
}
|
||||
else
|
||||
{
|
||||
getSelection()->applyToTEs(&setfuncBP);
|
||||
}
|
||||
// </FS:Beq>
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -717,7 +717,7 @@ public:
|
|||
void selectionSetDensity(F32 density);
|
||||
void selectionSetRestitution(F32 restitution);
|
||||
void selectionSetMaterial(U8 material);
|
||||
bool selectionSetImage(const LLUUID& imageid); // could be item or asset id
|
||||
bool selectionSetImage(const LLUUID& imageid, bool isPBR=true); // <FS:Beq/> inject PBR awareness.
|
||||
bool selectionSetGLTFMaterial(const LLUUID& mat_id); // material id only
|
||||
void selectionSetColor(const LLColor4 &color);
|
||||
void selectionSetColorOnly(const LLColor4 &color); // Set only the RGB channels
|
||||
|
|
|
|||
|
|
@ -1467,7 +1467,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
|
|||
|
||||
LLUUID asset_id = item->getAssetUUID();
|
||||
|
||||
if (hit_obj->getRenderMaterialID(hit_face).notNull() && !remove_pbr)
|
||||
if (hit_obj->getRenderMaterialID(hit_face).notNull() && !remove_pbr && tex_channel >= -1) // <FS:Beq/> tex_channel -2 means ignorePBR then treat as -1, don't judge me.
|
||||
{
|
||||
// Overrides require textures to be copy and transfer free
|
||||
LLPermissions item_permissions = item->getPermissions();
|
||||
|
|
@ -1493,6 +1493,12 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
|
|||
}
|
||||
return;
|
||||
}
|
||||
// <FS:Beq> tex_channel -2 means ignorePBR then treat as -1
|
||||
if(tex_channel < -1)
|
||||
{
|
||||
tex_channel = -1;
|
||||
}
|
||||
// </FS:Beq>
|
||||
BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id);
|
||||
if (!success)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue