From 72d6aff610c99a6125e633d067dc71ef37d56f46 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Thu, 7 Jan 2021 20:55:37 +0100 Subject: [PATCH] Add @viewtransparent and @viewwireframe --- indra/newview/llviewermenu.cpp | 12 ++++++------ indra/newview/rlvactions.cpp | 22 ++++++++++++++++++++++ indra/newview/rlvactions.h | 14 ++++++++++++++ indra/newview/rlvdefines.h | 2 ++ indra/newview/rlvhandler.cpp | 20 ++++++++++++++++++++ indra/newview/rlvhelper.cpp | 2 ++ 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index f7b789c5d6..556a13c361 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1214,11 +1214,11 @@ class LLAdvancedToggleWireframe : public view_listener_t { bool handleEvent(const LLSD& userdata) { -// [RLVa:KB] - Checked: RLVa-2.0.0 - bool fRlvBlockWireframe = gRlvAttachmentLocks.hasLockedHUD(); - if ( (!gUseWireframe) && (fRlvBlockWireframe) ) +// [RLVa:KB] - @detach and @viewwireframe + const bool fRlvCanViewWireframe = RlvActions::canViewWireframe(); + if ( (!gUseWireframe) && (!fRlvCanViewWireframe) ) RlvUtil::notifyBlocked(RlvStringKeys::Blocked::Wireframe); - set_use_wireframe( (!gUseWireframe) && (!fRlvBlockWireframe) ); + set_use_wireframe( (!gUseWireframe) && (fRlvCanViewWireframe) ); return true; } }; @@ -8672,8 +8672,8 @@ class LLViewHighlightTransparent : public view_listener_t bool handleEvent(const LLSD& userdata) { // LLDrawPoolAlpha::sShowDebugAlpha = !LLDrawPoolAlpha::sShowDebugAlpha; -// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c - LLDrawPoolAlpha::sShowDebugAlpha = (!LLDrawPoolAlpha::sShowDebugAlpha) && (!gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)); +// [RLVa:KB] - @edit and @viewtransparent + LLDrawPoolAlpha::sShowDebugAlpha = (!LLDrawPoolAlpha::sShowDebugAlpha) && (RlvActions::canHighlightTransparent()); // [/RLVa:KB] return true; } diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index b5126ee47b..44def7256c 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -584,6 +584,28 @@ bool RlvActions::canShowLocation() return !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); } +// ============================================================================ +// World (General) +// + +bool RlvActions::canHighlightTransparent() +{ + // User cannot highlight transparent faces if: + // - prevented from editing (exceptions are not taken into account) + // - specifically prevented from highlight transparent faces + return !gRlvHandler.hasBehaviour(RLV_BHVR_EDIT) && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); +} + +bool RlvActions::canViewWireframe() +{ + // User can use wireframe rendering if: + // - no HUD attachment is (remove) locked + // - not specifically prevented from using wireframe mode + return + !gRlvAttachmentLocks.hasLockedHUD() && // Trivial function so no overhead when RLV is not enabled + !gRlvHandler.hasBehaviour(RLV_BHVR_VIEWWIREFRAME); +} + // ============================================================================ // Helper functions // diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index 7022e33eeb..6571023ca7 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -300,6 +300,20 @@ public: */ static bool canTouch(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero); + // =============== + // World (General) + // =============== +public: + /* + * Returns true if the user can highlight transparent faces + */ + static bool canHighlightTransparent(); + + /* + * Returns true if the user can switch to wireframe rendering + */ + static bool canViewWireframe(); + // ================ // Helper functions // ================ diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index ca3180d5c1..777f88d15e 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -157,6 +157,8 @@ enum ERlvBehaviour { RLV_BHVR_BUY, // "buy" RLV_BHVR_EDIT, // "edit" RLV_BHVR_EDITOBJ, // "editobj" + RLV_BHVR_VIEWTRANSPARENT, + RLV_BHVR_VIEWWIREFRAME, RLV_BHVR_PAY, // "pay" RLV_BHVR_REZ, // "rez" RLV_BHVR_FARTOUCH, // "fartouch" diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 369eb3334c..f916ca819e 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -2612,6 +2612,26 @@ void RlvBehaviourShowSelfToggleHandler::onCommandToggle(ERlvBehaviour eBvhr, boo gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); } +// Handles: @viewtransparent toggles +template<> template<> +void RlvBehaviourToggleHandler::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr) +{ + if (fHasBhvr) + { + LLDrawPoolAlpha::sShowDebugAlpha = false; + } +} + +// Handles: @viewwireframe toggles +template<> template<> +void RlvBehaviourToggleHandler::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr) +{ + if (fHasBhvr) + { + set_use_wireframe(false); + } +} + // ============================================================================ // Command handlers (RLV_TYPE_FORCE) // diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index e28f13661b..2f29ef1c74 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -100,6 +100,8 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourInfo("detachallthis_except", RLV_BHVR_DETACHTHISEXCEPT, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_SUBTREE)); addEntry(new RlvBehaviourGenericToggleProcessor("edit")); addEntry(new RlvBehaviourGenericProcessor("editobj", RLV_BHVR_EDITOBJ)); + addEntry(new RlvBehaviourGenericToggleProcessor("viewtransparent", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); + addEntry(new RlvBehaviourGenericToggleProcessor("viewwireframe", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); addEntry(new RlvBehaviourGenericProcessor("emote", RLV_BHVR_EMOTE)); addEntry(new RlvBehaviourGenericProcessor("fartouch", RLV_BHVR_FARTOUCH)); addModifier(RLV_BHVR_FARTOUCH, RLV_MODIFIER_FARTOUCHDIST, new RlvBehaviourModifier("Fartouch Distance", RLV_MODIFIER_FARTOUCH_DEFAULT, true, new RlvBehaviourModifierCompMin));