Added variable fartouch distance (@fartouch:<dist>=n|y)

--HG--
branch : RLVa
master
Kitty Barnett 2016-06-04 17:36:59 +02:00
parent 0e605d4400
commit 3318ce60c1
10 changed files with 52 additions and 24 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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]

View File

@ -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();

View File

@ -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
{

View File

@ -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)

View File

@ -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);

View File

@ -198,6 +198,7 @@ enum ERlvBehaviour {
enum ERlvBehaviourModifier
{
RLV_MODIFIER_FARTOUCHDIST,
RLV_MODIFIER_SITTPDIST,
RLV_MODIFIER_TPLOCALDIST,

View File

@ -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())
{

View File

@ -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));