diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-09-14 00:28:28 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-09-14 01:37:46 +0300 |
commit | 5034c565bf627b4ecaac44376566212f432d97ff (patch) | |
tree | eba38e271b1b68d9477421926fe6e4cf0a31794d /indra/newview/llselectmgr.cpp | |
parent | 5a10b11b0d306334cd80f52f267ca8c525672062 (diff) |
SL-18044 (PBR) No-copy textures not applying to objects
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r-- | indra/newview/llselectmgr.cpp | 138 |
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); } |