diff options
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r-- | indra/newview/llselectmgr.cpp | 290 |
1 files changed, 280 insertions, 10 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 86f7d2bf25..2475900d0e 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" @@ -1168,8 +1169,8 @@ void LLSelectMgr::highlightObjectOnly(LLViewerObject* objectp) return; } - if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) - || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced()))) + if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) + || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced()))) { // only select my own objects return; @@ -1746,6 +1747,7 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item) S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); bool texture_copied = false; + bool updated = false; for (S32 te = 0; te < num_tes; ++te) { if (node->isTESelected(te)) @@ -1754,22 +1756,68 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item) // without making any copies if (!texture_copied) { - LLToolDragAndDrop::handleDropTextureProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); texture_copied = true; } // apply texture for the selected faces add(LLStatViewer::EDIT_TEXTURE, 1); object->setTEImage(te, image); - dialog_refresh_all(); - - // send the update to the simulator - object->sendTEUpdate(); + updated = true; } } + + if (updated) // not nessesary? sendTEUpdate update supposed to be done by sendfunc + { + dialog_refresh_all(); + + // send the update to the simulator + object->sendTEUpdate(); + } } } +void LLObjectSelection::applyNoCopyPbrMaterialToTEs(LLViewerInventoryItem* item) +{ + if (!item) + { + return; + } + + LLUUID asset_id = item->getAssetUUID(); + + for (iterator iter = begin(); iter != end(); ++iter) + { + LLSelectNode* node = *iter; + LLViewerObject* object = (*iter)->getObject(); + if (!object) + { + continue; + } + + S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); + bool material_copied = false; + for (S32 te = 0; te < num_tes; ++te) + { + if (node->isTESelected(te)) + { + //(no-copy) materials must be moved to the object's inventory only once + // without making any copies + if (!material_copied && asset_id.notNull()) + { + LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + material_copied = true; + } + + // apply texture for the selected faces + //add(LLStatViewer::EDIT_TEXTURE, 1); + object->setRenderMaterialID(te, asset_id, false /*will be sent later*/); + } + } + } +} + + //----------------------------------------------------------------------------- // selectionSetImage() //----------------------------------------------------------------------------- @@ -1862,6 +1910,148 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid) } //----------------------------------------------------------------------------- +// selectionSetGLTFMaterial() +//----------------------------------------------------------------------------- +void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) +{ + // First for (no copy) textures and multiple object selection + LLViewerInventoryItem* item = gInventory.getItem(mat_id); + if (item + && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()) + && (mSelectedObjects->getNumNodes() > 1)) + { + LL_WARNS() << "Attempted to apply no-copy material to multiple objects" + << LL_ENDL; + return; + } + + struct f : public LLSelectedTEFunctor + { + LLViewerInventoryItem* mItem; + LLUUID mMatId; + f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mMatId(id) {} + bool apply(LLViewerObject* objectp, S32 te) + { + if (objectp && !objectp->permModify()) + { + return false; + } + LLUUID asset_id = mMatId; + if (mItem) + { + 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) + { + 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 // Shouldn't happen? + { + S32 num_faces = objectp->getNumTEs(); + for (S32 face = 0; face < num_faces; face++) + { + 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); + } + } + } + + return true; + } + }; + + if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) + { + getSelection()->applyNoCopyPbrMaterialToTEs(item); + } + 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) + { + // 1 particle effect per object + LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE); + effectp->setSourceObject(gAgentAvatarp); + effectp->setTargetObject(object); + effectp->setDuration(LL_HUD_DUR_SHORT); + effectp->setColor(LLColor4U(gAgent.getEffectColor())); + } + + dialog_refresh_all(); + object->sendTEUpdate(); + return true; + } + } sendfunc(item); + getSelection()->applyToObjects(&sendfunc); +} + +//----------------------------------------------------------------------------- // selectionSetColor() //----------------------------------------------------------------------------- void LLSelectMgr::selectionSetColor(const LLColor4 &color) @@ -2038,6 +2228,59 @@ BOOL LLSelectMgr::selectionRevertTextures() return revert_successful; } +void LLSelectMgr::selectionRevertGLTFMaterials() +{ + struct f : public LLSelectedTEFunctor + { + LLObjectSelectionHandle mSelectedObjects; + f(LLObjectSelectionHandle sel) : mSelectedObjects(sel) {} + bool apply(LLViewerObject* objectp, S32 te) + { + if (objectp && !objectp->permModify()) + { + return false; + } + + LLSelectNode* nodep = mSelectedObjects->findNode(objectp); + if (nodep && te < (S32)nodep->mSavedGLTFMaterials.size()) + { + LLUUID asset_id = nodep->mSavedGLTFMaterials[te]; + objectp->setRenderMaterialID(te, asset_id, false /*wait for bulk update*/); + } + return true; + } + } setfunc(mSelectedObjects); + getSelection()->applyToTEs(&setfunc); + + 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); +} + void LLSelectMgr::selectionSetBumpmap(U8 bumpmap, const LLUUID &image_id) { struct f : public LLSelectedTEFunctor @@ -2067,7 +2310,7 @@ void LLSelectMgr::selectionSetBumpmap(U8 bumpmap, const LLUUID &image_id) { LLViewerObject *object = mSelectedObjects->getFirstRootObject(); if (!object) return; - LLToolDragAndDrop::handleDropTextureProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } getSelection()->applyToTEs(&setfunc); @@ -2127,7 +2370,7 @@ void LLSelectMgr::selectionSetShiny(U8 shiny, const LLUUID &image_id) { LLViewerObject *object = mSelectedObjects->getFirstRootObject(); if (!object) return; - LLToolDragAndDrop::handleDropTextureProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } getSelection()->applyToTEs(&setfunc); @@ -5628,6 +5871,17 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data // this should be the only place that saved textures is called node->saveTextures(texture_ids); } + + if (can_copy && can_transfer && node->getObject()->getVolume()) + { + uuid_vec_t material_ids; + LLVOVolume* vobjp = (LLVOVolume*)node->getObject(); + for (int i = 0; i < vobjp->getNumTEs(); ++i) + { + material_ids.push_back(vobjp->getRenderMaterialID(i)); + } + node->savedGLTFMaterials(material_ids); + } } node->mValid = TRUE; @@ -6094,7 +6348,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) auto renderMeshSelection_f = [fogCfx, wireframe_selection](LLSelectNode* node, LLViewerObject* objectp, LLColor4 hlColor) { //Need to because crash on ATI 3800 (and similar cards) MAINT-5018 - LLGLDisable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLDisable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0); LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; @@ -6379,6 +6633,7 @@ LLSelectNode::LLSelectNode(const LLSelectNode& nodep) } saveTextures(nodep.mSavedTextures); + savedGLTFMaterials(nodep.mSavedGLTFMaterials); } LLSelectNode::~LLSelectNode() @@ -6512,6 +6767,20 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures) } } +void LLSelectNode::savedGLTFMaterials(const uuid_vec_t& materials) +{ + if (mObject.notNull()) + { + mSavedGLTFMaterials.clear(); + + for (uuid_vec_t::const_iterator materials_it = materials.begin(); + materials_it != materials.end(); ++materials_it) + { + mSavedGLTFMaterials.push_back(*materials_it); + } + } +} + void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { mTextureScaleRatios.clear(); @@ -8307,6 +8576,7 @@ DEF_DUMMY_CHECK_FUNCTOR(int) DEF_DUMMY_CHECK_FUNCTOR(LLColor4) DEF_DUMMY_CHECK_FUNCTOR(LLMediaEntry) DEF_DUMMY_CHECK_FUNCTOR(LLPointer<LLMaterial>) +DEF_DUMMY_CHECK_FUNCTOR(LLPointer<LLGLTFMaterial>) DEF_DUMMY_CHECK_FUNCTOR(std::string) DEF_DUMMY_CHECK_FUNCTOR(std::vector<std::string>) |