diff options
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r-- | indra/newview/llselectmgr.cpp | 310 |
1 files changed, 263 insertions, 47 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 195b172102..5c1a339570 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" @@ -1038,10 +1039,6 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab // check to see if object is already in list LLSelectNode *nodep = mSelectedObjects->findNode(objectp); - // Reset (in anticipation of being set to an appropriate value by panel refresh, if they're up) - // - setTextureChannel(LLRender::DIFFUSE_MAP); - // if not in list, add it if (!nodep) { @@ -1168,8 +1165,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 +1743,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,27 +1752,76 @@ 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 + // blank out most override data on the server + //add(LLStatViewer::EDIT_TEXTURE, 1); + object->setRenderMaterialID(te, asset_id); + } + } + } + + LLGLTFMaterialList::flushUpdates(); +} + + //----------------------------------------------------------------------------- // selectionSetImage() //----------------------------------------------------------------------------- // *TODO: re-arch texture applying out of lltooldraganddrop -void LLSelectMgr::selectionSetImage(const LLUUID& imageid) +bool LLSelectMgr::selectionSetImage(const LLUUID& imageid) { // First for (no copy) textures and multiple object selection LLViewerInventoryItem* item = gInventory.getItem(imageid); @@ -1782,9 +1829,11 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid) && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()) && (mSelectedObjects->getNumNodes() > 1) ) { - LL_WARNS() << "Attempted to apply no-copy texture to multiple objects" - << LL_ENDL; - return; + LL_DEBUGS() << "Attempted to apply no-copy texture " << imageid + << " to multiple objects" << LL_ENDL; + + LLNotificationsUtil::add("FailedToApplyTextureNoCopyToMultiple"); + return false; } struct f : public LLSelectedTEFunctor @@ -1800,21 +1849,11 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid) } if (mItem) { - if (te == -1) // all faces - { - LLToolDragAndDrop::dropTextureAllFaces(objectp, - mItem, - LLToolDragAndDrop::SOURCE_AGENT, - LLUUID::null); - } - else // one face - { - LLToolDragAndDrop::dropTextureOneFace(objectp, - te, - mItem, - LLToolDragAndDrop::SOURCE_AGENT, - LLUUID::null); - } + LLToolDragAndDrop::dropTextureOneFace(objectp, + te, + mItem, + LLToolDragAndDrop::SOURCE_AGENT, + LLUUID::null); } else // not an inventory item { @@ -1859,6 +1898,99 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid) } } sendfunc(item); getSelection()->applyToObjects(&sendfunc); + + return true; +} + +//----------------------------------------------------------------------------- +// selectionSetGLTFMaterial() +//----------------------------------------------------------------------------- +bool 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_DEBUGS() << "Attempted to apply no-copy material " << mat_id + << "to multiple objects" << LL_ENDL; + + LLNotificationsUtil::add("FailedToApplyGLTFNoCopyToMultiple"); + return false; + } + + 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) + { + // If success, the material may be copied into the object's inventory + BOOL success = LLToolDragAndDrop::handleDropMaterialProtections(objectp, mItem, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + if (!success) + { + return false; + } + asset_id = mItem->getAssetUUID(); + } + + // Blank out most override data on the object and send to server + objectp->setRenderMaterialID(te, 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; + } + + 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); + + LLGLTFMaterialList::flushUpdates(); + + return true; } //----------------------------------------------------------------------------- @@ -2038,6 +2170,48 @@ 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->mSavedGLTFMaterialIds.size()) + { + // Restore base material + LLUUID asset_id = nodep->mSavedGLTFMaterialIds[te]; + + // Update material locally + objectp->setRenderMaterialID(te, asset_id, false /*wait for LLGLTFMaterialList update*/); + objectp->setTEGLTFMaterialOverride(te, nodep->mSavedGLTFOverrideMaterials[te]); + + // Enqueue update to server + if (asset_id.notNull()) + { + // Restore overrides and base material + LLGLTFMaterialList::queueApply(objectp, te, asset_id, nodep->mSavedGLTFOverrideMaterials[te]); + } + else + { + //blank override out + LLGLTFMaterialList::queueApply(objectp, te, asset_id); + } + + } + return true; + } + } setfunc(mSelectedObjects); + getSelection()->applyToTEs(&setfunc); +} + void LLSelectMgr::selectionSetBumpmap(U8 bumpmap, const LLUUID &image_id) { struct f : public LLSelectedTEFunctor @@ -2067,7 +2241,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 +2301,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); @@ -5625,9 +5799,38 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data if (can_copy && can_transfer) { - // 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; + gltf_materials_vec_t override_materials; + LLVOVolume* vobjp = (LLVOVolume*)node->getObject(); + for (int i = 0; i < vobjp->getNumTEs(); ++i) + { + material_ids.push_back(vobjp->getRenderMaterialID(i)); + + // Make a copy to ensure we won't affect live material + // with any potential changes nor live changes will be + // reflected in a saved copy. + // Like changes from local material (reuses pointer) or + // from live editor (revert mechanics might modify this) + LLGLTFMaterial* old_override = node->getObject()->getTE(i)->getGLTFMaterialOverride(); + if (old_override) + { + LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(*old_override); + override_materials.push_back(mat); + } + else + { + override_materials.push_back(nullptr); + } + } + // processObjectProperties does not include overrides so this + // might need to be moved to LLGLTFMaterialOverrideDispatchHandler + node->saveGLTFMaterials(material_ids, override_materials); + } } node->mValid = TRUE; @@ -6093,9 +6296,6 @@ 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); - LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; if (shader) @@ -6379,6 +6579,7 @@ LLSelectNode::LLSelectNode(const LLSelectNode& nodep) } saveTextures(nodep.mSavedTextures); + saveGLTFMaterials(nodep.mSavedGLTFMaterialIds, nodep.mSavedGLTFOverrideMaterials); } LLSelectNode::~LLSelectNode() @@ -6512,6 +6713,27 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures) } } +void LLSelectNode::saveGLTFMaterials(const uuid_vec_t& materials, const gltf_materials_vec_t& override_materials) +{ + if (mObject.notNull()) + { + mSavedGLTFMaterialIds.clear(); + mSavedGLTFOverrideMaterials.clear(); + + for (uuid_vec_t::const_iterator materials_it = materials.begin(); + materials_it != materials.end(); ++materials_it) + { + mSavedGLTFMaterialIds.push_back(*materials_it); + } + + for (gltf_materials_vec_t::const_iterator mat_it = override_materials.begin(); + mat_it != override_materials.end(); ++mat_it) + { + mSavedGLTFOverrideMaterials.push_back(*mat_it); + } + } +} + void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { mTextureScaleRatios.clear(); @@ -6731,15 +6953,8 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) { gGL.flush(); gGL.blendFunc(LLRender::BF_SOURCE_COLOR, LLRender::BF_ONE); - LLGLEnable fog(GL_FOG); - glFogi(GL_FOG_MODE, GL_LINEAR); - float d = (LLViewerCamera::getInstance()->getPointOfInterest()-LLViewerCamera::getInstance()->getOrigin()).magVec(); - LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgentCamera.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0); - glFogf(GL_FOG_START, d); - glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV()))); - glFogfv(GL_FOG_COLOR, fogCol.mV); - - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL); + + LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL); gGL.flush(); gGL.begin(LLRender::LINES); { @@ -7613,7 +7828,7 @@ S32 LLObjectSelection::getSelectedObjectRenderCost() for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) { // add the cost of each individual texture in the linkset - cost += iter->second; + cost += LLVOVolume::getTextureCost(*iter); } textures.clear(); @@ -7635,7 +7850,7 @@ S32 LLObjectSelection::getSelectedObjectRenderCost() for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) { // add the cost of each individual texture in the linkset - cost += iter->second; + cost += LLVOVolume::getTextureCost(*iter); } textures.clear(); @@ -8307,6 +8522,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>) |