summaryrefslogtreecommitdiff
path: root/indra/newview
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
parent2a5219b23f5f91a2415a51324bb5c160a0139663 (diff)
parent2e268392a387d58ced0dc4bf7dfe5ff2ce25da1e (diff)
Merge branch 'DRTVWR-559' of ssh://bitbucket.org/lindenlab/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl2
-rw-r--r--indra/newview/llreflectionmap.cpp5
-rw-r--r--indra/newview/llselectmgr.cpp138
-rw-r--r--indra/newview/lltexturectrl.cpp51
-rw-r--r--indra/newview/lltooldraganddrop.cpp5
-rw-r--r--indra/newview/llviewerobject.cpp7
6 files changed, 142 insertions, 66 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 78f6a5b130..652e609718 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -539,4 +539,4 @@ void pbrDirectionalLight(inout vec3 colorDiffuse,
colorDiffuse += sunDiffuse;
colorSpec += sunSpec;
-} \ No newline at end of file
+}
diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp
index 2a7ab84501..d9dd1e9381 100644
--- a/indra/newview/llreflectionmap.cpp
+++ b/indra/newview/llreflectionmap.cpp
@@ -82,6 +82,11 @@ void LLReflectionMap::autoAdjustOrigin()
// cast a ray towards 8 corners of bounding box
// nudge origin towards center of empty space
+ if (!node)
+ {
+ return;
+ }
+
if (node->isLeaf() || node->getChildCount() > 1 || node->getData().size() > 0)
{ // use center of object bounding box for leaf nodes or nodes with multiple child nodes
mOrigin = bounds[0];
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);
}
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index b887b079ce..c167fcc717 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -1665,56 +1665,7 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLUUID id)
if (op == TEXTURE_SELECT && mOnSelectCallback)
{
- // determine if the selected item in inventory is a material
- // by finding the item in inventory and inspecting its (IT_) type
- LLUUID item_id = floaterp->findItemID(floaterp->getAssetID(), FALSE);
- LLInventoryItem* item = gInventory.getItem(item_id);
- if (item)
- {
- if (item->getInventoryType() == LLInventoryType::IT_MATERIAL)
- {
- // ask the selection manager for the list of selected objects
- // to which the material will be applied.
- LLObjectSelectionHandle selectedObjectsHandle = LLSelectMgr::getInstance()->getSelection();
- if (selectedObjectsHandle.notNull())
- {
- LLObjectSelection* selectedObjects = selectedObjectsHandle.get();
- if (!selectedObjects->isEmpty())
- {
- // we have a selection - iterate over it
- for (LLObjectSelection::valid_iterator obj_iter = selectedObjects->valid_begin();
- obj_iter != selectedObjects->valid_end();
- ++obj_iter)
- {
- LLSelectNode* object = *obj_iter;
- LLViewerObject* viewer_object = object->getObject();
- if (viewer_object)
- {
- // the asset ID of the material we want to apply
- // the the selected objects
- LLUUID asset_id = item->getAssetUUID();
-
- // iterate over the faces in the object
- // TODO: consider the case where user has
- // selected only certain faces
- S32 num_faces = viewer_object->getNumTEs();
- for (S32 face = 0; face < num_faces; face++)
- {
- viewer_object->setRenderMaterialID(face, asset_id);
- dialog_refresh_all();
- }
- viewer_object->sendTEUpdate();
- }
- }
- }
- }
- }
- }
- else
- // original behavior for textures, not materials
- {
- mOnSelectCallback(this, LLSD());
- }
+ mOnSelectCallback(this, LLSD());
}
else if (op == TEXTURE_CANCEL && mOnCancelCallback)
{
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index ab54e2afc6..282c84d7fc 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1114,6 +1114,11 @@ void LLToolDragAndDrop::dropMaterialAllFaces(LLViewerObject* hit_obj,
for (S32 face = 0; face < num_faces; face++)
{
// update viewer side material in anticipation of update from simulator
+
+ // TODO: fix this!
+ // Calling setRenderMaterialID multiple times sends material param
+ // updates multiple times and can create race condition.
+ // Send update only once!
hit_obj->setRenderMaterialID(face, asset_id);
dialog_refresh_all();
}
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bdc47e0c50..d0bd0f45a2 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -7057,7 +7057,12 @@ void LLViewerObject::setRenderMaterialID(U8 te, const LLUUID& id)
if (id.notNull())
{
getTE(te)->setGLTFMaterial(gGLTFMaterialList.getMaterial(id));
- setHasRenderMaterialParams(true);
+
+ if (!hasRenderMaterialParams())
+ {
+ // make sure param section exists
+ setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, false /*prevent an immediate update*/);
+ }
}
else
{