From a02f6217008dc9a82995fba705d129796fe3014c Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 18 Aug 2022 16:29:52 -0700 Subject: SL-17005: Clean up debug code --- indra/llwindow/llwindowwin32.cpp | 16 ++-------------- indra/newview/app_settings/settings.xml | 23 ----------------------- indra/newview/pipeline.cpp | 4 ---- 3 files changed, 2 insertions(+), 41 deletions(-) (limited to 'indra') diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 9e2e07102e..201330137f 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -48,8 +48,6 @@ #include "llthreadsafequeue.h" #include "stringize.h" #include "llframetimer.h" -#include "commoncontrol.h" // TODO: Remove after testing -#include "llsd.h" // TODO: Remove after testing // System includes #include @@ -418,9 +416,7 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool std::atomic mAvailableVRAM; - bool mTryUseDXGIAdapter; // TODO: Remove after testing IDXGIAdapter3* mDXGIAdapter = nullptr; - bool mTryUseD3DDevice; // TODO: Remove after testing LPDIRECT3D9 mD3D = nullptr; LPDIRECT3DDEVICE9 mD3DDevice = nullptr; }; @@ -4553,14 +4549,6 @@ U32 LLWindowWin32::getAvailableVRAMMegabytes() inline LLWindowWin32::LLWindowWin32Thread::LLWindowWin32Thread() : ThreadPool("Window Thread", 1, MAX_QUEUE_SIZE) { - const LLSD skipDXGI{ LL::CommonControl::get("Global", "DisablePrimaryGraphicsMemoryAccounting") }; // TODO: Remove after testing - LL_WARNS() << "DisablePrimaryGraphicsMemoryAccounting: " << skipDXGI << ", as boolean: " << skipDXGI.asBoolean() << LL_ENDL; - mTryUseDXGIAdapter = !skipDXGI.asBoolean(); - LL_WARNS() << "mTryUseDXGIAdapter: " << mTryUseDXGIAdapter << LL_ENDL; - const LLSD skipD3D{ LL::CommonControl::get("Global", "DisableSecondaryGraphicsMemoryAccounting") }; // TODO: Remove after testing - LL_WARNS() << "DisableSecondaryGraphicsMemoryAccounting: " << skipD3D << ", as boolean: " << skipD3D.asBoolean() << LL_ENDL; - mTryUseD3DDevice = !skipD3D.asBoolean(); - LL_WARNS() << "mTryUseD3DDevice: " << mTryUseD3DDevice << LL_ENDL; ThreadPool::start(); } @@ -4677,7 +4665,7 @@ void debugEnumerateGraphicsAdapters() void LLWindowWin32::LLWindowWin32Thread::initDX() { - if (mDXGIAdapter == NULL && mTryUseDXGIAdapter) + if (mDXGIAdapter == NULL) { debugEnumerateGraphicsAdapters(); @@ -4711,7 +4699,7 @@ void LLWindowWin32::LLWindowWin32Thread::initDX() void LLWindowWin32::LLWindowWin32Thread::initD3D() { - if (mDXGIAdapter == NULL && mD3DDevice == NULL && mTryUseD3DDevice && mWindowHandle != 0) + if (mDXGIAdapter == NULL && mD3DDevice == NULL && mWindowHandle != 0) { mD3D = Direct3DCreate9(D3D_SDK_VERSION); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index afa8217af2..bc4945eca5 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -3387,29 +3387,6 @@ Value 0 - - DisablePrimaryGraphicsMemoryAccounting - - Comment - Disable the first method used to detect GPU memory use - Persist - 1 - Type - Boolean - Value - 0 - - DisableSecondaryGraphicsMemoryAccounting - - Comment - Disable the second method used to detect GPU memory use, used as a fallback when the first method fails - Persist - 1 - Type - Boolean - Value - 0 - DisableTextHyperlinkActions Comment diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d4e667bcc6..9ec3418132 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -434,7 +434,6 @@ void LLPipeline::connectRefreshCachedSettingsSafe(const std::string name) void LLPipeline::init() { - LL_WARNS() << "Begin pipeline initialization" << LL_ENDL; // TODO: Remove after testing refreshCachedSettings(); gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); @@ -451,7 +450,6 @@ void LLPipeline::init() mInitialized = true; stop_glerror(); - LL_WARNS() << "No GL errors yet. Pipeline initialization will continue." << LL_ENDL; // TODO: Remove after testing //create render pass pools getPool(LLDrawPool::POOL_ALPHA); @@ -512,9 +510,7 @@ void LLPipeline::init() // Enable features - LL_WARNS() << "Shader initialization start" << LL_ENDL; // TODO: Remove after testing LLViewerShaderMgr::instance()->setShaders(); - LL_WARNS() << "Shader initialization end" << LL_ENDL; // TODO: Remove after testing stop_glerror(); -- cgit v1.2.3 From 439aa79414edfe48f3bfa5d154987d741308bdbb Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Mon, 24 Oct 2022 22:14:20 +0300 Subject: SL-18432 Fix for alpha sorting --- indra/newview/llspatialpartition.h | 2 +- indra/newview/llvovolume.cpp | 51 ++++++-------------------------------- 2 files changed, 8 insertions(+), 45 deletions(-) (limited to 'indra') diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index f7bc9fb644..6d3ef33801 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -264,7 +264,7 @@ public: return lhs->mAvatarp < rhs->mAvatarp; } - return lhs->mRenderOrder < rhs->mRenderOrder; + return lhs->mRenderOrder > rhs->mRenderOrder; } }; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index e923115c43..a4e0d367c8 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5515,7 +5515,7 @@ static inline void add_face(T*** list, U32* count, T* face) { if (count[1] < MAX_FACE_COUNT) { - //face->setDrawOrderIndex(count[1]); + face->setDrawOrderIndex(count[1]); list[1][count[1]++] = face; } } @@ -5523,36 +5523,12 @@ static inline void add_face(T*** list, U32* count, T* face) { if (count[0] < MAX_FACE_COUNT) { - //face->setDrawOrderIndex(count[0]); + face->setDrawOrderIndex(count[0]); list[0][count[0]++] = face; } } } -// return index into linkset for given object (0 for root prim) -U32 get_linkset_index(LLVOVolume* vobj) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; - if (vobj->isRootEdit()) - { - return 0; - } - - LLViewerObject* root = vobj->getRootEdit(); - U32 idx = 1; - for (const auto& child : root->getChildren()) - { - if (child == vobj) - { - return idx; - } - ++idx; - } - - llassert(false); - return idx; //should never get here -} - void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; @@ -5714,8 +5690,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { avatar->addAttachmentOverridesForObject(vobj, NULL, false); } - - U32 linkset_index = get_linkset_index(vobj); // Standard rigged mesh attachments: bool rigged = !vobj->isAnimatedObject() && skinInfo && vobj->isAttachment(); @@ -5736,9 +5710,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } - // order by linkset index first and face index second - facep->setDrawOrderIndex(linkset_index * 100 + i); - //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group facep->setVertexBuffer(NULL); @@ -5763,6 +5734,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (facep->isState(LLFace::RIGGED)) { //face is not rigged but used to be, remove from rigged face pool + LLDrawPoolAvatar* pool = (LLDrawPoolAvatar*)facep->getPool(); + if (pool) + { + pool->removeFace(facep); + } facep->clearState(LLFace::RIGGED); facep->mAvatar = NULL; facep->mSkinInfo = NULL; @@ -6216,14 +6192,6 @@ struct CompareBatchBreakerRigged } }; -struct CompareDrawOrder -{ - bool operator()(const LLFace* const& lhs, const LLFace* const& rhs) - { - return lhs->getDrawOrderIndex() < rhs->getDrawOrderIndex(); - } -}; - U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace** faces, U32 face_count, BOOL distance_sort, BOOL batch_textures, BOOL rigged) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; @@ -6267,11 +6235,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace //sort faces by things that break batches, including avatar and mesh id std::sort(faces, faces + face_count, CompareBatchBreakerRigged()); } - else - { - // preserve legacy draw order for rigged faces - std::sort(faces, faces + face_count, CompareDrawOrder()); - } } else if (!distance_sort) { -- cgit v1.2.3 From 687a012a695bb7da55fc2b9b220f48de658cb8b6 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Oct 2022 19:55:59 +0300 Subject: SL-18008 Add "Save/Edit Materials" buttons to attachment's right click menu --- .../skins/default/xui/en/menu_attachment_self.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indra') diff --git a/indra/newview/skins/default/xui/en/menu_attachment_self.xml b/indra/newview/skins/default/xui/en/menu_attachment_self.xml index 3b91b9df7a..630a1981df 100644 --- a/indra/newview/skins/default/xui/en/menu_attachment_self.xml +++ b/indra/newview/skins/default/xui/en/menu_attachment_self.xml @@ -12,6 +12,22 @@ + + + + + + + + Date: Tue, 25 Oct 2022 10:11:21 -0700 Subject: Xcode build fixes for DRTVWR-559 --- indra/newview/llgltfmateriallist.cpp | 2 +- indra/newview/llviewerobject.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index cd60d34d2f..05ed7a2019 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -119,7 +119,7 @@ void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFM void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) { const LLUUID& id = obj->getID(); - auto& iter = mQueuedOverrides.find(id); + auto iter = mQueuedOverrides.find(id); if (iter != mQueuedOverrides.end()) { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index ac519970b7..ac76ad7272 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5335,7 +5335,7 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma tep->setGLTFMaterialOverride(override_mat); // if override mat exists, we must also have a source mat - llassert(override_mat ? src_mat : true); + llassert(override_mat ? bool(src_mat) : true); if (override_mat && src_mat) { -- cgit v1.2.3 From ca53f265b45b01378748039d2345005688545114 Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Tue, 25 Oct 2022 14:28:35 -0700 Subject: Bump Teamcity for new Project Viewer build of DRTVWR-559 --- indra/cmake/00-Common.cmake | 1 + 1 file changed, 1 insertion(+) (limited to 'indra') diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 572422d080..d81d3ac1f0 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -232,3 +232,4 @@ else (USESYSTEMLIBS) endif (USESYSTEMLIBS) endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED) + -- cgit v1.2.3 From 89625f92473bd2894acd287caeeb1d20673f8ddb Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 26 Oct 2022 00:41:35 +0300 Subject: SL-18444 Live Material Editor updating with selection --- indra/newview/llinspectobject.cpp | 15 ++++-- indra/newview/llmaterialeditor.cpp | 93 ++++++++++++++++++++++++----------- indra/newview/llmaterialeditor.h | 4 ++ indra/newview/llsidepaneltaskinfo.cpp | 7 ++- indra/newview/llsidepaneltaskinfo.h | 2 + 5 files changed, 87 insertions(+), 34 deletions(-) (limited to 'indra') diff --git a/indra/newview/llinspectobject.cpp b/indra/newview/llinspectobject.cpp index 5329f10612..42bf416efb 100644 --- a/indra/newview/llinspectobject.cpp +++ b/indra/newview/llinspectobject.cpp @@ -116,6 +116,7 @@ private: viewer_media_t mMediaImpl; LLMediaEntry* mMediaEntry; LLSafeHandle mObjectSelection; + boost::signals2::connection mSelectionUpdateSlot; }; LLInspectObject::LLInspectObject(const LLSD& sd) @@ -175,9 +176,12 @@ BOOL LLInspectObject::postBuild(void) getChild("more_info_btn")->setCommitCallback( boost::bind(&LLInspectObject::onClickMoreInfo, this)); - // Watch for updates to selection properties off the network - LLSelectMgr::getInstance()->mUpdateSignal.connect( - boost::bind(&LLInspectObject::update, this) ); + if (!mSelectionUpdateSlot.connected()) + { + // Watch for updates to selection properties off the network + mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect( + boost::bind(&LLInspectObject::update, this)); + } return TRUE; } @@ -243,6 +247,11 @@ void LLInspectObject::onClose(bool app_quitting) mObjectSelection = NULL; mPreviousObjectID = mObjectID; + if (mSelectionUpdateSlot.connected()) + { + mSelectionUpdateSlot.disconnect(); + } + getChild("gear_btn")->hideMenu(); } diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 06705a277b..1e75216079 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -302,6 +302,11 @@ void LLMaterialEditor::onClickCloseBtn(bool app_quitting) void LLMaterialEditor::onClose(bool app_quitting) { + if (mSelectionUpdateSlot.connected()) + { + mSelectionUpdateSlot.disconnect(); + } + LLPreview::onClose(app_quitting); } @@ -1463,42 +1468,61 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind ); } } +void LLMaterialEditor::onSelectionChanged() +{ + mHasUnsavedChanges = false; + clearTextures(); + setFromSelection(); + saveLiveValues(); +} + +void LLMaterialEditor::saveLiveValues() +{ + // Collect ids to be able to revert overrides. + // TODO: monitor selection changes and resave on selection changes + mObjectOverridesSavedValues.clear(); + struct g : public LLSelectedObjectFunctor + { + g(LLMaterialEditor* me) : mEditor(me) {} + virtual bool apply(LLViewerObject* objectp) + { + if (!objectp) + { + return false; + } + + U32 local_id = objectp->getLocalID(); + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + for (U8 te = 0; te < num_tes; te++) + { + LLUUID mat_id = objectp->getRenderMaterialID(te); + mEditor->mObjectOverridesSavedValues[local_id].push_back(mat_id); + } + return true; + } + LLMaterialEditor* mEditor; + } savefunc(this); + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&savefunc); +} void LLMaterialEditor::loadLive() { LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD(LIVE_MATERIAL_EDITOR_KEY)); - if (me->setFromSelection()) + if (me) { + me->setFromSelection(); me->mIsOverride = true; me->setTitle(me->getString("material_override_title")); me->childSetVisible("save", false); me->childSetVisible("save_as", false); - me->mObjectOverridesSavedValues.clear(); - // Collect ids to be able to revert overrides. - // TODO: monitor selection changes and resave on selection changes - struct g : public LLSelectedObjectFunctor + // Set up for selection changes updates + if (!me->mSelectionUpdateSlot.connected()) { - g(LLMaterialEditor* me) : mEditor(me) {} - virtual bool apply(LLViewerObject* objectp) - { - if (!objectp) - { - return false; - } - - U32 local_id = objectp->getLocalID(); - S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); - for (U8 te = 0; te < num_tes; te++) - { - LLUUID mat_id = objectp->getRenderMaterialID(te); - mEditor->mObjectOverridesSavedValues[local_id].push_back(mat_id); - } - return true; - } - LLMaterialEditor* mEditor; - } savefunc(me); - LLSelectMgr::getInstance()->getSelection()->applyToObjects(&savefunc); + me->mSelectionUpdateSlot = LLSelectMgr::instance().mUpdateSignal.connect(boost::bind(&LLMaterialEditor::onSelectionChanged, me)); + } + // Collect ids to be able to revert overrides on cancel. + me->saveLiveValues(); me->openFloater(); me->setFocus(TRUE); @@ -2095,6 +2119,10 @@ bool LLMaterialEditor::setFromSelection() return true; } + // pick defaults from a blank material; + LLGLTFMaterial blank_mat; + setFromGLTFMaterial(&blank_mat); + return false; } @@ -2424,6 +2452,16 @@ S32 LLMaterialEditor::saveTextures() } // discard upload buffers once textures have been saved + clearTextures(); + + // asset storage can callback immediately, causing a decrease + // of mUploadingTexturesCount, report amount of work scheduled + // not amount of work remaining + return work_count; +} + +void LLMaterialEditor::clearTextures() +{ mBaseColorJ2C = nullptr; mNormalJ2C = nullptr; mEmissiveJ2C = nullptr; @@ -2438,11 +2476,6 @@ S32 LLMaterialEditor::saveTextures() mNormalTextureUploadId.setNull(); mMetallicTextureUploadId.setNull(); mEmissiveTextureUploadId.setNull(); - - // asset storage can callback immediately, causing a decrease - // of mUploadingTexturesCount, report amount of work scheduled - // not amount of work remaining - return work_count; } void LLMaterialEditor::loadDefaults() diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 60907b18ba..438acb532b 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -103,6 +103,8 @@ public: // will promt to select specific one static void loadMaterialFromFile(const std::string& filename, S32 index = -1); + void onSelectionChanged(); // // live overrides selection changes + void saveLiveValues(); // for restoration on cancel static void loadLive(); static void loadObjectSave(); @@ -118,6 +120,7 @@ public: // save textures to inventory if needed // returns amount of scheduled uploads S32 saveTextures(); + void clearTextures(); void onClickSave(); @@ -279,5 +282,6 @@ private: // local id, texture ids per face for object overrides // for "cancel" support std::map mObjectOverridesSavedValues; + boost::signals2::connection mSelectionUpdateSlot; }; diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp index 7fa06f51e3..6216057c17 100644 --- a/indra/newview/llsidepaneltaskinfo.cpp +++ b/indra/newview/llsidepaneltaskinfo.cpp @@ -77,7 +77,7 @@ static LLPanelInjector t_task_info("sidepanel_task_info"); LLSidepanelTaskInfo::LLSidepanelTaskInfo() { setMouseOpaque(FALSE); - LLSelectMgr::instance().mUpdateSignal.connect(boost::bind(&LLSidepanelTaskInfo::refreshAll, this)); + mSelectionUpdateSlot = LLSelectMgr::instance().mUpdateSignal.connect(boost::bind(&LLSidepanelTaskInfo::refreshAll, this)); } @@ -85,6 +85,11 @@ LLSidepanelTaskInfo::~LLSidepanelTaskInfo() { if (sActivePanel == this) sActivePanel = NULL; + + if (mSelectionUpdateSlot.connected()) + { + mSelectionUpdateSlot.disconnect(); + } } // virtual diff --git a/indra/newview/llsidepaneltaskinfo.h b/indra/newview/llsidepaneltaskinfo.h index dc259cb22d..ac9c57f2e2 100644 --- a/indra/newview/llsidepaneltaskinfo.h +++ b/indra/newview/llsidepaneltaskinfo.h @@ -154,6 +154,8 @@ private: LLView* mDAE; LLView* mDAN; LLView* mDAF; + + boost::signals2::connection mSelectionUpdateSlot; }; -- cgit v1.2.3 From 631b7de4b2262855984ed1d35ae7859507b12e9e Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 26 Oct 2022 15:03:55 +0300 Subject: SL-18444 Either connection should be create in onOpen or disconnect happen in destructor --- indra/newview/llinspectobject.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/llinspectobject.cpp b/indra/newview/llinspectobject.cpp index 42bf416efb..3d13985f08 100644 --- a/indra/newview/llinspectobject.cpp +++ b/indra/newview/llinspectobject.cpp @@ -142,6 +142,10 @@ LLInspectObject::LLInspectObject(const LLSD& sd) LLInspectObject::~LLInspectObject() { + if (mSelectionUpdateSlot.connected()) + { + mSelectionUpdateSlot.disconnect(); + } } /*virtual*/ @@ -247,11 +251,6 @@ void LLInspectObject::onClose(bool app_quitting) mObjectSelection = NULL; mPreviousObjectID = mObjectID; - if (mSelectionUpdateSlot.connected()) - { - mSelectionUpdateSlot.disconnect(); - } - getChild("gear_btn")->hideMenu(); } -- cgit v1.2.3 From d69c814db94c907a1a772e4e63a8b82a293985d2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 26 Oct 2022 20:18:33 +0300 Subject: SL-18446 Terse-update selection set from live material editor #1 --- indra/newview/llmaterialeditor.cpp | 169 +++++++++++++++++++++++++++---------- indra/newview/llmaterialeditor.h | 8 +- indra/newview/llviewermenu.cpp | 24 ++---- 3 files changed, 139 insertions(+), 62 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 1e75216079..58804a901f 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -67,6 +67,24 @@ const std::string MATERIAL_EMISSIVE_DEFAULT_NAME = "Emissive"; const LLUUID LIVE_MATERIAL_EDITOR_KEY("6cf97162-8b68-49eb-b627-79886c9fd17d"); +// Dirty flags +static const U32 MATERIAL_BASE_COLOR_DIRTY = 0x1 << 0; +static const U32 MATERIAL_BASE_TRANSPARENCY_DIRTY = 0x1 << 1; +static const U32 MATERIAL_BASE_COLOR_TEX_DIRTY = 0x1 << 2; + +static const U32 MATERIAL_NORMAL_TEX_DIRTY = 0x1 << 3; + +static const U32 MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY = 0x1 << 4; +static const U32 MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY = 0x1 << 5; +static const U32 MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY = 0x1 << 6; + +static const U32 MATERIAL_EMISIVE_COLOR_DIRTY = 0x1 << 7; +static const U32 MATERIAL_EMISIVE_TEX_DIRTY = 0x1 << 8; + +static const U32 MATERIAL_DOUBLE_SIDED_DIRTY = 0x1 << 9; +static const U32 MATERIAL_ALPHA_MODE_DIRTY = 0x1 << 10; +static const U32 MATERIAL_ALPHA_CUTOFF_DIRTY = 0x1 << 11; + LLFloaterComboOptions::LLFloaterComboOptions() : LLFloater(LLSD()) { @@ -199,7 +217,7 @@ private: // Default constructor LLMaterialEditor::LLMaterialEditor(const LLSD& key) : LLPreview(key) - , mHasUnsavedChanges(false) + , mUnsavedChanges(0) , mExpectedUploadCost(0) , mUploadingTexturesCount(0) { @@ -251,33 +269,30 @@ BOOL LLMaterialEditor::postBuild() getChild("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); getChild("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); - boost::function changes_callback = [this](LLUICtrl * ctrl, void*) + boost::function changes_callback = [this](LLUICtrl * ctrl, void* userData) { - setHasUnsavedChanges(true); + const U32 *flag = (const U32*)userData; + markChangesUnsaved(*flag); // Apply changes to object live applyToSelection(); }; - childSetCommitCallback("double sided", changes_callback, NULL); + childSetCommitCallback("double sided", changes_callback, (void*)&MATERIAL_DOUBLE_SIDED_DIRTY); // BaseColor - childSetCommitCallback("base color", changes_callback, NULL); - childSetCommitCallback("transparency", changes_callback, NULL); - childSetCommitCallback("alpha mode", changes_callback, NULL); - childSetCommitCallback("alpha cutoff", changes_callback, NULL); + childSetCommitCallback("base color", changes_callback, (void*)&MATERIAL_BASE_COLOR_DIRTY); + childSetCommitCallback("transparency", changes_callback, (void*)&MATERIAL_BASE_TRANSPARENCY_DIRTY); + childSetCommitCallback("alpha mode", changes_callback, (void*)&MATERIAL_ALPHA_MODE_DIRTY); + childSetCommitCallback("alpha cutoff", changes_callback, (void*)&MATERIAL_ALPHA_CUTOFF_DIRTY); // Metallic-Roughness - childSetCommitCallback("metalness factor", changes_callback, NULL); - childSetCommitCallback("roughness factor", changes_callback, NULL); - - // Metallic-Roughness - childSetCommitCallback("metalness factor", changes_callback, NULL); - childSetCommitCallback("roughness factor", changes_callback, NULL); + childSetCommitCallback("metalness factor", changes_callback, (void*)&MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY); + childSetCommitCallback("roughness factor", changes_callback, (void*)&MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY); // Emissive - childSetCommitCallback("emissive color", changes_callback, NULL); + childSetCommitCallback("emissive color", changes_callback, (void*)&MATERIAL_EMISIVE_COLOR_DIRTY); - childSetVisible("unsaved_changes", mHasUnsavedChanges); + childSetVisible("unsaved_changes", mUnsavedChanges); getChild("total_upload_fee")->setTextArg("[FEE]", llformat("%d", 0)); @@ -333,7 +348,7 @@ void LLMaterialEditor::setBaseColorUploadId(const LLUUID& id) // Only set if we will need to upload this texture mBaseColorTextureUploadId = id; } - setHasUnsavedChanges(true); + markChangesUnsaved(MATERIAL_BASE_COLOR_TEX_DIRTY); } LLColor4 LLMaterialEditor::getBaseColor() @@ -405,7 +420,7 @@ void LLMaterialEditor::setMetallicRoughnessUploadId(const LLUUID& id) childSetValue("metallic_upload_fee", getString("upload_fee_string")); mMetallicTextureUploadId = id; } - setHasUnsavedChanges(true); + markChangesUnsaved(MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY); } F32 LLMaterialEditor::getMetalnessFactor() @@ -448,7 +463,7 @@ void LLMaterialEditor::setEmissiveUploadId(const LLUUID& id) childSetValue("emissive_upload_fee", getString("upload_fee_string")); mEmissiveTextureUploadId = id; } - setHasUnsavedChanges(true); + markChangesUnsaved(MATERIAL_EMISIVE_TEX_DIRTY); } LLColor4 LLMaterialEditor::getEmissiveColor() @@ -481,7 +496,7 @@ void LLMaterialEditor::setNormalUploadId(const LLUUID& id) childSetValue("normal_upload_fee", getString("upload_fee_string")); mNormalTextureUploadId = id; } - setHasUnsavedChanges(true); + markChangesUnsaved(MATERIAL_NORMAL_TEX_DIRTY); } bool LLMaterialEditor::getDoubleSided() @@ -494,12 +509,22 @@ void LLMaterialEditor::setDoubleSided(bool double_sided) childSetValue("double sided", double_sided); } -void LLMaterialEditor::setHasUnsavedChanges(bool value) +void LLMaterialEditor::resetUnsavedChanges() +{ + mUnsavedChanges = 0; + childSetVisible("unsaved_changes", false); + setCanSave(false); + + mExpectedUploadCost = 0; + getChild("total_upload_fee")->setTextArg("[FEE]", llformat("%d", mExpectedUploadCost)); +} + +void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) { - mHasUnsavedChanges = value; - childSetVisible("unsaved_changes", value); + mUnsavedChanges |= dirty_flag; + childSetVisible("unsaved_changes", mUnsavedChanges); - if (mHasUnsavedChanges) + if (mUnsavedChanges) { const LLInventoryItem* item = getItem(); if (item) @@ -594,7 +619,7 @@ void LLMaterialEditor::onCommitBaseColorTexture(LLUICtrl * ctrl, const LLSD & da // the texture that is not in use childSetValue("base_color_upload_fee", getString("no_upload_fee_string")); } - setHasUnsavedChanges(true); + markChangesUnsaved(MATERIAL_BASE_COLOR_TEX_DIRTY); applyToSelection(); } @@ -609,7 +634,7 @@ void LLMaterialEditor::onCommitMetallicTexture(LLUICtrl * ctrl, const LLSD & dat { childSetValue("metallic_upload_fee", getString("no_upload_fee_string")); } - setHasUnsavedChanges(true); + markChangesUnsaved(MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY); applyToSelection(); } @@ -624,7 +649,7 @@ void LLMaterialEditor::onCommitEmissiveTexture(LLUICtrl * ctrl, const LLSD & dat { childSetValue("emissive_upload_fee", getString("no_upload_fee_string")); } - setHasUnsavedChanges(true); + markChangesUnsaved(MATERIAL_EMISIVE_TEX_DIRTY); applyToSelection(); } @@ -639,7 +664,7 @@ void LLMaterialEditor::onCommitNormalTexture(LLUICtrl * ctrl, const LLSD & data) { childSetValue("normal_upload_fee", getString("no_upload_fee_string")); } - setHasUnsavedChanges(true); + markChangesUnsaved(MATERIAL_NORMAL_TEX_DIRTY); applyToSelection(); } @@ -1223,7 +1248,7 @@ void LLMaterialEditor::onSaveAsMsgCallback(const LLSD& notification, const LLSD& else { std::string buffer = getEncodedAsset(); - LLPointer cb = new LLMaterialEditorCopiedCallback(buffer, getKey(), mHasUnsavedChanges); + LLPointer cb = new LLMaterialEditorCopiedCallback(buffer, getKey(), mUnsavedChanges); copy_inventory_item( gAgent.getID(), item->getPermissions().getOwner(), @@ -1251,7 +1276,7 @@ void LLMaterialEditor::onSaveAsMsgCallback(const LLSD& notification, const LLSD& void LLMaterialEditor::onClickCancel() { - if (mHasUnsavedChanges) + if (mUnsavedChanges) { LLNotificationsUtil::add("UsavedMaterialChanges", LLSD(), LLSD(), boost::bind(&LLMaterialEditor::onCancelMsgCallback, this, _1, _2)); } @@ -1470,7 +1495,7 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind } void LLMaterialEditor::onSelectionChanged() { - mHasUnsavedChanges = false; + mUnsavedChanges = 0; clearTextures(); setFromSelection(); saveLiveValues(); @@ -1551,7 +1576,6 @@ void LLMaterialEditor::loadFromGLTFMaterial(LLUUID &asset_id) LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor"); me->mMaterialName = LLTrans::getString("New Material"); me->setTitle(me->mMaterialName); - me->setHasUnsavedChanges(true); me->setFromGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id)); me->openFloater(); me->setFocus(TRUE); @@ -1653,7 +1677,7 @@ void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std:: setFromGltfMetaData(filename_lc, model_in, index); - setHasUnsavedChanges(true); + markChangesUnsaved(U32_MAX); openFloater(); setFocus(TRUE); @@ -1991,8 +2015,8 @@ private: class LLRenderMaterialOverrideFunctor : public LLSelectedTEFunctor { public: - LLRenderMaterialOverrideFunctor(LLMaterialEditor * me, std::string const & url, LLUUID const & asset_id) - : mEditor(me), mCapUrl(url), mAssetID(asset_id) + LLRenderMaterialOverrideFunctor(LLMaterialEditor * me, std::string const & url) + : mEditor(me), mCapUrl(url) { } @@ -2007,9 +2031,69 @@ public: if (objectp && objectp->permModify() && objectp->getVolume()) { - LLPointer material = new LLGLTFMaterial(); - - mEditor->getGLTFMaterial(material); + // Get material from object + // Selection can cover multiple objects, and live editor is + // supposed to overwrite changed values only + LLTextureEntry* tep = objectp->getTE(te); + LLPointer material = tep->getGLTFMaterial(); + if (material.isNull()) + { + material = new LLGLTFMaterial(); + } + + // Override object's values with values from editor where appropriate + if (mEditor->getUnsavedChangesFlags() & MATERIAL_BASE_COLOR_DIRTY) + { + material->mBaseColor = mEditor->getBaseColor(); + } + if (mEditor->getUnsavedChangesFlags() & MATERIAL_BASE_TRANSPARENCY_DIRTY) + { + material->mBaseColor.mV[3] = mEditor->getTransparency(); + } + if (mEditor->getUnsavedChangesFlags() & MATERIAL_BASE_COLOR_TEX_DIRTY) + { + material->mBaseColorId = mEditor->getBaseColorId(); + } + + if (mEditor->getUnsavedChangesFlags() & MATERIAL_NORMAL_TEX_DIRTY) + { + material->mNormalId = mEditor->getNormalId(); + } + + if (mEditor->getUnsavedChangesFlags() & MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY) + { + material->mMetallicRoughnessId = mEditor->getMetallicRoughnessId(); + } + if (mEditor->getUnsavedChangesFlags() & MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY) + { + material->mMetallicFactor = mEditor->getMetalnessFactor(); + } + if (mEditor->getUnsavedChangesFlags() & MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY) + { + material->mRoughnessFactor = mEditor->getRoughnessFactor(); + } + + if (mEditor->getUnsavedChangesFlags() & MATERIAL_EMISIVE_COLOR_DIRTY) + { + material->mEmissiveColor = mEditor->getEmissiveColor(); + } + if (mEditor->getUnsavedChangesFlags() & MATERIAL_EMISIVE_TEX_DIRTY) + { + material->mEmissiveId = mEditor->getEmissiveId(); + } + + if (mEditor->getUnsavedChangesFlags() & MATERIAL_DOUBLE_SIDED_DIRTY) + { + material->mDoubleSided = mEditor->getDoubleSided(); + } + if (mEditor->getUnsavedChangesFlags() & MATERIAL_ALPHA_MODE_DIRTY) + { + material->setAlphaMode(mEditor->getAlphaMode()); + } + if (mEditor->getUnsavedChangesFlags() & MATERIAL_ALPHA_CUTOFF_DIRTY) + { + material->mAlphaCutoff = mEditor->getAlphaCutoff(); + } std::string overrides_json = material->asJSON(); @@ -2026,7 +2110,6 @@ public: private: LLMaterialEditor * mEditor; std::string mCapUrl; - LLUUID mAssetID; }; void LLMaterialEditor::applyToSelection() @@ -2045,7 +2128,7 @@ void LLMaterialEditor::applyToSelection() { LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); // TODO figure out how to get the right asset id in cases where we don't have a good one - LLRenderMaterialOverrideFunctor override_func(this, url, mAssetID); + LLRenderMaterialOverrideFunctor override_func(this, url); selected_objects->applyToTEs(&override_func); } else @@ -2162,7 +2245,7 @@ void LLMaterialEditor::loadAsset() { mAssetStatus = PREVIEW_ASSET_LOADED; loadDefaults(); - setHasUnsavedChanges(false); + resetUnsavedChanges(); setEnableEditing(allow_modify && !source_library); } else @@ -2187,7 +2270,7 @@ void LLMaterialEditor::loadAsset() LL_WARNS() << "Can't find object " << mObjectUUID << " associated with notecard." << LL_ENDL; mAssetID.setNull(); mAssetStatus = PREVIEW_ASSET_LOADED; - setHasUnsavedChanges(false); + resetUnsavedChanges(); setEnableEditing(allow_modify && !source_library); return; } @@ -2274,7 +2357,7 @@ void LLMaterialEditor::onLoadComplete(const LLUUID& asset_uuid, BOOL allow_modify = editor->canModify(editor->mObjectUUID, editor->getItem()); BOOL source_library = editor->mObjectUUID.isNull() && gInventory.isObjectDescendentOf(editor->mItemUUID, gInventory.getLibraryRootFolderID()); editor->setEnableEditing(allow_modify && !source_library); - editor->setHasUnsavedChanges(false); + editor->resetUnsavedChanges(); editor->mAssetStatus = PREVIEW_ASSET_LOADED; editor->setEnabled(true); // ready for use } diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 438acb532b..040dbe99da 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -209,7 +209,6 @@ public: bool getDoubleSided(); void setDoubleSided(bool double_sided); - void setHasUnsavedChanges(bool value); void setCanSaveAs(bool value); void setCanSave(bool value); void setEnableEditing(bool can_modify); @@ -224,6 +223,8 @@ public: void modifyMaterialCoro(std::string cap_url, LLSD overrides); + U32 getUnsavedChangesFlags() { return mUnsavedChanges; } + private: void setFromGLTFMaterial(LLGLTFMaterial* mat); bool setFromSelection(); @@ -271,7 +272,10 @@ private: // based on what we know about it. const std::string buildMaterialDescription(); - bool mHasUnsavedChanges; + void resetUnsavedChanges(); + void markChangesUnsaved(U32 dirty_flag); + + U32 mUnsavedChanges; // flags to indicate individual changed parameters S32 mUploadingTexturesCount; S32 mExpectedUploadCost; std::string mMaterialNameShort; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 18d215f9f4..e1b92e5f2e 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2956,30 +2956,20 @@ void handle_object_edit() return; } -void load_life_gltf_material(bool copy) +void handle_object_edit_gltf_material() { - update_camera(); - - LLSelectedTEGetmatIdAndPermissions func; - LLUUID mat_id; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); - - if (copy) + if (!LLFloaterReg::instanceVisible("build")) { - LLMaterialEditor::loadFromGLTFMaterial(mat_id); + handle_object_edit(); // does update_camera(); } else { - LLMaterialEditor::loadLive(); - } + update_camera(); - LLViewerJoystick::getInstance()->moveObjects(true); - LLViewerJoystick::getInstance()->setNeedsReset(true); -} + LLViewerJoystick::getInstance()->moveObjects(true); + LLViewerJoystick::getInstance()->setNeedsReset(true); + } -void handle_object_edit_gltf_material() -{ - handle_object_edit(); LLMaterialEditor::loadLive(); } -- cgit v1.2.3 From a022452ff56c31cb028d5a17d827c82f1a74e624 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 26 Oct 2022 14:35:44 -0400 Subject: Increment viewer version to 6.6.7 following promotion of DRTVWR-574 --- indra/newview/VIEWER_VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt index 10abd6ae5b..5db1411e12 100644 --- a/indra/newview/VIEWER_VERSION.txt +++ b/indra/newview/VIEWER_VERSION.txt @@ -1 +1 @@ -6.6.6 +6.6.7 -- cgit v1.2.3 From 5ee774f4ecda6ab312239b0d2ab1d7849ff535b0 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 26 Oct 2022 22:40:16 +0300 Subject: SL-18446 Support "multiple textures" in Live material overrides --- indra/newview/llmaterialeditor.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 58804a901f..a6d2729dfa 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -334,6 +334,7 @@ void LLMaterialEditor::setBaseColorId(const LLUUID& id) { mBaseColorTextureCtrl->setValue(id); mBaseColorTextureCtrl->setDefaultImageAssetID(id); + mBaseColorTextureCtrl->setTentative(FALSE); } void LLMaterialEditor::setBaseColorUploadId(const LLUUID& id) @@ -409,6 +410,7 @@ void LLMaterialEditor::setMetallicRoughnessId(const LLUUID& id) { mMetallicTextureCtrl->setValue(id); mMetallicTextureCtrl->setDefaultImageAssetID(id); + mMetallicTextureCtrl->setTentative(FALSE); } void LLMaterialEditor::setMetallicRoughnessUploadId(const LLUUID& id) @@ -452,6 +454,7 @@ void LLMaterialEditor::setEmissiveId(const LLUUID& id) { mEmissiveTextureCtrl->setValue(id); mEmissiveTextureCtrl->setDefaultImageAssetID(id); + mEmissiveTextureCtrl->setTentative(FALSE); } void LLMaterialEditor::setEmissiveUploadId(const LLUUID& id) @@ -485,6 +488,7 @@ void LLMaterialEditor::setNormalId(const LLUUID& id) { mNormalTextureCtrl->setValue(id); mNormalTextureCtrl->setDefaultImageAssetID(id); + mNormalTextureCtrl->setTentative(FALSE); } void LLMaterialEditor::setNormalUploadId(const LLUUID& id) @@ -2188,25 +2192,40 @@ bool LLMaterialEditor::setFromSelection() { struct LLSelectedTEGetGLTFRenderMaterial : public LLSelectedTEGetFunctor > { - LLPointer get(LLViewerObject* object, S32 te_index) + LLPointer get(LLViewerObject* objectp, S32 te_index) { - return object->getTE(te_index)->getGLTFRenderMaterial(); // present user with combined override + asset + if (!objectp) + { + return nullptr; + } + LLTextureEntry *tep = objectp->getTE(te_index); + if (!tep) + { + return nullptr; + } + return tep->getGLTFRenderMaterial(); // present user with combined override + asset } } func; LLPointer mat; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat); + bool identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat); if (mat.notNull()) { setFromGLTFMaterial(mat); - return true; + } + else + { + // pick defaults from a blank material; + LLGLTFMaterial blank_mat; + setFromGLTFMaterial(&blank_mat); } - // pick defaults from a blank material; - LLGLTFMaterial blank_mat; - setFromGLTFMaterial(&blank_mat); + mBaseColorTextureCtrl->setTentative(!identical); + mMetallicTextureCtrl->setTentative(!identical); + mEmissiveTextureCtrl->setTentative(!identical); + mNormalTextureCtrl->setTentative(!identical); - return false; + return mat.notNull(); } -- cgit v1.2.3