summaryrefslogtreecommitdiff
path: root/indra/newview/llselectmgr.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-09-13 18:41:43 -0500
committerDave Parks <davep@lindenlab.com>2022-09-13 18:41:43 -0500
commit93389059d5490f4ed9550bc2b38d7973a4c73a18 (patch)
tree112af7702ca68f805e11d0e7be6a61f7d83ff238 /indra/newview/llselectmgr.cpp
parent2a5219b23f5f91a2415a51324bb5c160a0139663 (diff)
parent2e268392a387d58ced0dc4bf7dfe5ff2ce25da1e (diff)
Merge branch 'DRTVWR-559' of ssh://bitbucket.org/lindenlab/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r--indra/newview/llselectmgr.cpp138
1 files changed, 124 insertions, 14 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 12ba29466d..7d994f1d05 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -63,6 +63,7 @@
#include "llfloatertools.h"
#include "llframetimer.h"
#include "llfocusmgr.h"
+#include "llgltfmateriallist.h"
#include "llhudeffecttrail.h"
#include "llhudmanager.h"
#include "llinventorymodel.h"
@@ -1792,16 +1793,56 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id)
asset_id = mItem->getAssetUUID();
}
+ if (asset_id.notNull() && !objectp->hasRenderMaterialParams())
+ {
+ // make sure param section exists
+ objectp->setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, false /*prevent an update*/);
+ }
+
if (te != -1)
{
- objectp->setRenderMaterialID(te, asset_id);
+ LLTextureEntry* tep = objectp->getTE(te);
+ if (asset_id.notNull())
+ {
+ tep->setGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id));
+ }
+ else
+ {
+ tep->setGLTFMaterial(nullptr);
+ }
+
+ objectp->faceMappingChanged();
+ gPipeline.markTextured(objectp->mDrawable);
+
+ LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)objectp->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL);
+ if (param_block)
+ {
+ param_block->setMaterial(te, asset_id);
+ }
}
- else
+ else // Shouldn't happen?
{
S32 num_faces = objectp->getNumTEs();
for (S32 face = 0; face < num_faces; face++)
{
- objectp->setRenderMaterialID(face, asset_id);
+ LLTextureEntry* tep = objectp->getTE(face);
+ if (asset_id.notNull())
+ {
+ tep->setGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id));
+ }
+ else
+ {
+ tep->setGLTFMaterial(nullptr);
+ }
+
+ objectp->faceMappingChanged();
+ gPipeline.markTextured(objectp->mDrawable);
+
+ LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)objectp->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL);
+ if (param_block)
+ {
+ param_block->setMaterial(face, asset_id);
+ }
}
}
@@ -1809,26 +1850,43 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id)
}
};
- if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()))
+ // TODO: once PBR starts supporting permissions, implement/figure this out
+ /*if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()))
{
getSelection()->applyNoCopyTextureToTEs(item);
}
- else
+ else*/
{
f setfunc(item, mat_id);
getSelection()->applyToTEs(&setfunc);
}
-
struct g : public LLSelectedObjectFunctor
{
LLViewerInventoryItem* mItem;
g(LLViewerInventoryItem* item) : mItem(item) {}
virtual bool apply(LLViewerObject* object)
{
+ if (object && !object->permModify())
+ {
+ return false;
+ }
+
+ LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)object->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL);
+ if (param_block)
+ {
+ if (param_block->isEmpty())
+ {
+ object->setHasRenderMaterialParams(false);
+ }
+ else
+ {
+ object->parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true);
+ }
+ }
+
if (!mItem)
{
- object->sendTEUpdate();
// 1 particle effect per object
LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
effectp->setSourceObject(gAgentAvatarp);
@@ -1836,6 +1894,8 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id)
effectp->setDuration(LL_HUD_DUR_SHORT);
effectp->setColor(LLColor4U(gAgent.getEffectColor()));
}
+
+ object->sendTEUpdate();
return true;
}
} sendfunc(item);
@@ -2025,15 +2085,40 @@ void LLSelectMgr::selectionRevertGLTFMaterials()
{
LLObjectSelectionHandle mSelectedObjects;
f(LLObjectSelectionHandle sel) : mSelectedObjects(sel) {}
- bool apply(LLViewerObject* object, S32 te)
+ bool apply(LLViewerObject* objectp, S32 te)
{
- if (object->permModify())
+ if (objectp && !objectp->permModify())
{
- LLSelectNode* nodep = mSelectedObjects->findNode(object);
- if (nodep && te < (S32)nodep->mSavedGLTFMaterials.size())
+ return false;
+ }
+
+ LLSelectNode* nodep = mSelectedObjects->findNode(objectp);
+ if (nodep && te < (S32)nodep->mSavedGLTFMaterials.size())
+ {
+ LLUUID asset_id = nodep->mSavedGLTFMaterials[te];
+ LLTextureEntry* tep = objectp->getTE(te);
+ if (asset_id.notNull())
+ {
+ tep->setGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id));
+
+ if (!objectp->hasRenderMaterialParams())
+ {
+ // make sure param section exists
+ objectp->setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, false /*prevent an immediate update*/);
+ }
+ }
+ else
+ {
+ tep->setGLTFMaterial(nullptr);
+ }
+
+ objectp->faceMappingChanged();
+ gPipeline.markTextured(objectp->mDrawable);
+
+ LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)objectp->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL);
+ if (param_block)
{
- LLUUID id = nodep->mSavedGLTFMaterials[te];
- object->setRenderMaterialID(te, id);
+ param_block->setMaterial(te, asset_id);
}
}
return true;
@@ -2041,7 +2126,32 @@ void LLSelectMgr::selectionRevertGLTFMaterials()
} setfunc(mSelectedObjects);
getSelection()->applyToTEs(&setfunc);
- LLSelectMgrSendFunctor sendfunc;
+ struct g : public LLSelectedObjectFunctor
+ {
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object && !object->permModify())
+ {
+ return false;
+ }
+
+ LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)object->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL);
+ if (param_block)
+ {
+ if (param_block->isEmpty())
+ {
+ object->setHasRenderMaterialParams(false);
+ }
+ else
+ {
+ object->parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true);
+ }
+ }
+
+ object->sendTEUpdate();
+ return true;
+ }
+ } sendfunc;
getSelection()->applyToObjects(&sendfunc);
}