From 3318ce60c1935ff1c16b4fd34092ebb7ebc610d4 Mon Sep 17 00:00:00 2001 From: Kitty Barnett <develop@catznip.com> Date: Sat, 4 Jun 2016 17:36:59 +0200 Subject: [PATCH] Added variable fartouch distance (@fartouch:<dist>=n|y) --HG-- branch : RLVa --- indra/newview/llglsandbox.cpp | 9 ++++++--- indra/newview/llselectmgr.cpp | 5 ++++- indra/newview/lltoolplacer.cpp | 7 +++++-- indra/newview/lltoolselect.cpp | 13 +++++++------ indra/newview/llviewercamera.cpp | 13 ++++++++----- indra/newview/rlvactions.cpp | 11 +++++++++-- indra/newview/rlvactions.h | 7 ++++++- indra/newview/rlvdefines.h | 1 + indra/newview/rlvhandler.cpp | 7 ++++--- indra/newview/rlvhelper.cpp | 3 ++- 10 files changed, 52 insertions(+), 24 deletions(-) diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 3dd57d11db..841edc9448 100755 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -66,6 +66,7 @@ // [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) #include "rlvactions.h" #include "rlvhandler.h" +#include "rlvhelper.h" // [/RLVa:KB] // Height of the yellow selection highlight posts for land @@ -153,13 +154,15 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) // [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-1.0.0g if (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) { + static RlvCachedBehaviourModifier<float> s_nFartouchDist(RLV_MODIFIER_FARTOUCHDIST); + // We'll allow drag selection under fartouch, but only within the fartouch range // (just copy/paste the code above us to make that work, thank you Lindens!) LLVector3 relative_av_pos = av_pos; relative_av_pos -= LLViewerCamera::getInstance()->getOrigin(); - F32 new_far = relative_av_pos * LLViewerCamera::getInstance()->getAtAxis() + 1.5f; - F32 new_near = relative_av_pos * LLViewerCamera::getInstance()->getAtAxis() - 1.5f; + F32 new_far = relative_av_pos * LLViewerCamera::getInstance()->getAtAxis() + s_nFartouchDist; + F32 new_near = relative_av_pos * LLViewerCamera::getInstance()->getAtAxis() - s_nFartouchDist; new_near = llmax(new_near, 0.1f); @@ -168,7 +171,7 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) // Usurp these two limit_select_distance = TRUE; - select_dist_squared = 1.5f * 1.5f; + select_dist_squared = s_nFartouchDist * s_nFartouchDist; } // [/RLVa:KB] LLViewerCamera::getInstance()->setPerspective(FOR_SELECTION, diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index d4efc48c3c..00ddbc9c43 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -96,6 +96,7 @@ // [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) #include "rlvactions.h" #include "rlvhandler.h" +#include "rlvhelper.h" // [/RLVa:KB] #include "llglheaders.h" @@ -4345,6 +4346,8 @@ void LLSelectMgr::deselectAllIfTooFar() LLVector3d selectionCenter = getSelectionCenterGlobal(); // if (gSavedSettings.getBOOL("LimitSelectDistance") // [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-0.2.0f + static RlvCachedBehaviourModifier<float> s_nFartouchDist(RLV_MODIFIER_FARTOUCHDIST); + BOOL fRlvFartouch = gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH) && gFloaterTools->getVisible(); if ( (gSavedSettings.getBOOL("LimitSelectDistance") || (fRlvFartouch) ) // [/RLVa:KB] @@ -4355,7 +4358,7 @@ void LLSelectMgr::deselectAllIfTooFar() { // F32 deselect_dist = gSavedSettings.getF32("MaxSelectDistance"); // [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-0.2.0f - F32 deselect_dist = (!fRlvFartouch) ? gSavedSettings.getF32("MaxSelectDistance") : 1.5f; + F32 deselect_dist = (!fRlvFartouch) ? gSavedSettings.getF32("MaxSelectDistance") : s_nFartouchDist; // [/RLVa:KB] F32 deselect_dist_sq = deselect_dist * deselect_dist; diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp index 9bc4b2e944..ea819811ef 100755 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -45,6 +45,7 @@ #include "llui.h" // [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0a) #include "rlvhandler.h" +#include "rlvhelper.h" // [/RLVa:KB] //Headers added for functions moved from viewer.cpp @@ -128,9 +129,11 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj, // [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-0.2.0f // NOTE: don't use surface_pos_global since for prims it will be the center of the prim while we need center + offset - if ( (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && (dist_vec_squared(gAgent.getPositionGlobal(), pick.mPosGlobal) > 1.5f * 1.5f) ) + if (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) { - return FALSE; + static RlvCachedBehaviourModifier<float> s_nFartouchDist(RLV_MODIFIER_FARTOUCHDIST); + if (dist_vec_squared(gAgent.getPositionGlobal(), pick.mPosGlobal) > s_nFartouchDist * s_nFartouchDist) + return FALSE; } // [/RLVa:KB] diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 5cdb5388c4..2cd221c351 100755 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -96,13 +96,14 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi else if (LLToolMgr::instance().inBuildMode()) LLToolMgr::instance().toggleBuildMode(); } - - if ( (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && ((!object->isAttachment()) || (!object->permYouOwner())) && - (dist_vec_squared(gAgent.getPositionAgent(), object->getPositionRegion()) > 1.5f * 1.5f) ) + + if ( (RlvActions::hasBehaviour(RLV_BHVR_FARTOUCH)) && ((!object->isAttachment()) || (!object->permYouOwner())) ) { - // NOTE: see behaviour notes for a rather lengthy explanation of why we're doing things this way - //if (dist_vec_squared(gAgent.getPositionAgent(), object->getPositionRegion() + pick.mObjectOffset) > 1.5f * 1.5f) - if (dist_vec_squared(gAgent.getPositionAgent(), pick.mIntersection) > 1.5f * 1.5f) + static RlvCachedBehaviourModifier<float> s_nFartouchDist(RLV_MODIFIER_FARTOUCHDIST); + float nFartouchDistSq = s_nFartouchDist * s_nFartouchDist; + // NOTE: recheck why we did it this way, might be able to simplify + if ( (dist_vec_squared(gAgent.getPositionAgent(), object->getPositionRegion()) > nFartouchDistSq) && + (dist_vec_squared(gAgent.getPositionAgent(), pick.mIntersection) > nFartouchDistSq) ) { if ( (LLFloaterReg::instanceVisible("build")) && (pick.mKeyMask != MASK_SHIFT) && (pick.mKeyMask != MASK_CONTROL) ) LLSelectMgr::getInstance()->deselectAll(); diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index ac09961402..0507ffbe98 100755 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -41,7 +41,8 @@ #include "llworld.h" #include "lltoolmgr.h" #include "llviewerjoystick.h" -// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) +// [RLVa:KB] - RLVa-2.0.0 +#include "rlvactions.h" #include "rlvhandler.h" // [/RLVa:KB] @@ -356,15 +357,17 @@ void LLViewerCamera::setPerspective(BOOL for_selection, if (limit_select_distance) { // ...select distance from control -// z_far = gSavedSettings.getF32("MaxSelectDistance"); -// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Added: RLVa-1.2.0e - z_far = (!gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) ? gSavedSettings.getF32("MaxSelectDistance") : 1.5; -// [/RLVa:KB] + z_far = gSavedSettings.getF32("MaxSelectDistance"); } else { z_far = gAgentCamera.mDrawDistance; } + +// [RLVa:KB] - Checked: RLVa-2.0.0 + if (RlvActions::hasBehaviour(RLV_BHVR_FARTOUCH)) + z_far = RlvActions::getModifierValue<float>(RLV_MODIFIER_FARTOUCHDIST); +// [/RLVa:KB] } else { diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index cec3d79462..0e17bd2edc 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -163,6 +163,7 @@ bool RlvActions::canSit(const LLViewerObject* pObj, const LLVector3& posOffset / // - not standtp restricted or not currently sitting (if the user is sitting and tried to sit elsewhere the tp would just kick in) // - not a regular sit (i.e. due to @sit:<uuid>=force) // - not @sittp=n or @fartouch=n restricted or if they clicked on a point within the allowed radius + static RlvCachedBehaviourModifier<float> s_nFarTouchDist(RLV_MODIFIER_FARTOUCHDIST); static RlvCachedBehaviourModifier<float> s_nSitTpDist(RLV_MODIFIER_SITTPDIST); return ( (pObj) && (LL_PCODE_VOLUME == pObj->getPCode()) ) && @@ -171,7 +172,7 @@ bool RlvActions::canSit(const LLViewerObject* pObj, const LLVector3& posOffset / ((isAgentAvatarValid()) && (!gAgentAvatarp->isSitting())) ) && ( ( (NULL != gRlvHandler.getCurrentCommand()) && (RLV_BHVR_SIT == gRlvHandler.getCurrentCommand()->getBehaviourType()) ) || ( ((!hasBehaviour(RLV_BHVR_SITTP)) || (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) < s_nSitTpDist * s_nSitTpDist)) && - ((!hasBehaviour(RLV_BHVR_FARTOUCH)) || (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) < RLV_MODIFIER_FARTOUCH_DEFAULT * RLV_MODIFIER_FARTOUCH_DEFAULT)) ) ); + ((!hasBehaviour(RLV_BHVR_FARTOUCH)) || (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) < s_nFarTouchDist * s_nFarTouchDist)) ) ); } bool RlvActions::canStand() @@ -194,7 +195,13 @@ bool RlvActions::canShowLocation() // ============================================================================ // Helper functions -// +// + +template<> +const float& RlvActions::getModifierValue<float>(ERlvBehaviourModifier eBhvrMod) +{ + return RlvBehaviourDictionary::instance().getModifier(eBhvrMod)->getValue<float>(); +} // Checked: 2013-05-10 (RLVa-1.4.9) bool RlvActions::hasBehaviour(ERlvBehaviour eBhvr) diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index 11cadff5c3..2ad58254f9 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -142,7 +142,12 @@ public: // ================ public: /* - * Convenience function to check for a behaviour without having to include rlvhandler.h. + * Convenience function to get the current/active value of a behaviour modifier + */ + template<typename T> static const T& getModifierValue(ERlvBehaviourModifier eBhvrMod); + + /* + * Convenience function to check for a behaviour without having to include rlvhandler.h. * Do NOT call this function if speed is important (i.e. per-frame) */ static bool hasBehaviour(ERlvBehaviour eBhvr); diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index d62f389e00..e86733a7e4 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -198,6 +198,7 @@ enum ERlvBehaviour { enum ERlvBehaviourModifier { + RLV_MODIFIER_FARTOUCHDIST, RLV_MODIFIER_SITTPDIST, RLV_MODIFIER_TPLOCALDIST, diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index cbd54958e5..b713afd942 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -691,16 +691,17 @@ bool RlvHandler::canTouch(const LLViewerObject* pObj, const LLVector3& posOffset bool fCanTouch = (idRoot.notNull()) && ((pObj->isHUDAttachment()) || (!hasBehaviour(RLV_BHVR_TOUCHALL))) && ((!hasBehaviour(RLV_BHVR_TOUCHTHIS)) || (!isException(RLV_BHVR_TOUCHTHIS, idRoot, RLV_CHECK_PERMISSIVE))); + static RlvCachedBehaviourModifier<float> s_nFartouchDist(RLV_MODIFIER_FARTOUCHDIST); if (fCanTouch) { if ( (!pObj->isAttachment()) || (!pObj->permYouOwner()) ) { // Rezzed prim or attachment worn by another avie - fCanTouch = + fCanTouch = ( (!hasBehaviour(RLV_BHVR_TOUCHWORLD)) || (isException(RLV_BHVR_TOUCHWORLD, idRoot, RLV_CHECK_PERMISSIVE)) ) && ( (!pObj->isAttachment()) || (!hasBehaviour(RLV_BHVR_TOUCHATTACHOTHER)) ) && - ( (!hasBehaviour(RLV_BHVR_FARTOUCH)) || - (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) <= 1.5f * 1.5f) ); + ( (!hasBehaviour(RLV_BHVR_FARTOUCH)) || + (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) <= s_nFartouchDist * s_nFartouchDist) ); } else if (!pObj->isHUDAttachment()) { diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index d8baee2adf..95da01e8a1 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -102,7 +102,8 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourToggleProcessor<RLV_BHVR_EDIT, RLV_OPTION_NONE_OR_EXCEPTION>("edit")); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_EXCEPTION>("editobj", RLV_BHVR_EDITOBJ)); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("emote", RLV_BHVR_EMOTE)); - addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("fartouch", RLV_BHVR_FARTOUCH)); + addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE_OR_MODIFIER>("fartouch", RLV_BHVR_FARTOUCH)); + addModifier(RLV_BHVR_FARTOUCH, RLV_MODIFIER_FARTOUCHDIST, new RlvBehaviourModifier(RLV_MODIFIER_FARTOUCH_DEFAULT, true, &s_RlvBehaviourModifier_CompMin)); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("fly", RLV_BHVR_FLY)); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("interact", RLV_BHVR_INTERACT, RlvBehaviourInfo::BHVR_EXTENDED)); addEntry(new RlvBehaviourInfo("notify", RLV_BHVR_NOTIFY, RLV_TYPE_ADDREM)); -- GitLab