From c80df5ac39e31fb17fa8a1158cbea2de8faf0319 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 23 Sep 2011 18:00:35 +0300 Subject: STORM-1612 FIXED Implemented click-to-walk in Advanced mode. Changes: * Click and double click in-world can now trigger click-to-walk or click-to-teleport actions, depending on preferences. * Grouped keyboard- and mouse-related settings in Preferences -> Move. --- indra/newview/lltoolpie.cpp | 157 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 122 insertions(+), 35 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index c38c8bad80..e614fe23d0 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -35,7 +35,7 @@ #include "llagent.h" #include "llagentcamera.h" #include "llavatarnamecache.h" -#include "llviewercontrol.h" +#include "lleventtimer.h" #include "llfocusmgr.h" #include "llfirstuse.h" #include "llfloaterland.h" @@ -57,6 +57,7 @@ #include "lltrans.h" #include "llviewercamera.h" #include "llviewerparcelmedia.h" +#include "llviewercontrol.h" #include "llviewermenu.h" #include "llviewerobjectlist.h" #include "llviewerobject.h" @@ -76,6 +77,41 @@ static void handle_click_action_play(); static void handle_click_action_open_media(LLPointer objectp); static ECursorType cursor_from_parcel_media(U8 click_action); +/** + * Schedule teleport to the specified location when user clicks in world. + * + * Deferring teleport is needed for double-click-to-walk to work. + * If double click in the world view occurs, teleport gets canceled. + */ +class LLClickToTeleportTimer : public LLEventTimer +{ + LOG_CLASS(LLClickToTeleportTimer); +public: + LLClickToTeleportTimer(const LLVector3d& pos); + ~LLClickToTeleportTimer(); + /*virtual*/ BOOL tick(); + +private: + LLVector3d mTeleportPos; +}; + +LLClickToTeleportTimer::LLClickToTeleportTimer(const LLVector3d& pos) +: LLEventTimer(0.33) // should be greater than double click interval +, mTeleportPos(pos) +{ +}; + +LLClickToTeleportTimer::~LLClickToTeleportTimer() +{ + LLToolPie::instance().mClickToTeleportTimer = NULL; +} + +BOOL LLClickToTeleportTimer::tick() +{ + lldebugs << "Teleporting to " << mTeleportPos << llendl; + gAgent.teleportViaLocationLookAt(mTeleportPos); + return TRUE; // destroy the timer +} LLToolPie::LLToolPie() : LLTool(std::string("Pie")), @@ -84,6 +120,8 @@ LLToolPie::LLToolPie() mMouseSteerX(-1), mMouseSteerY(-1), mBlockClickToWalk(false), + mBlockClickToTeleport(false), + mClickToTeleportTimer(NULL), mClickAction(0), mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ), mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") ) @@ -479,6 +517,18 @@ void LLToolPie::resetSelection() mClickAction = 0; } +void LLToolPie::walkToClickedLocation() +{ + if(mAutoPilotDestination) { mAutoPilotDestination->markDead(); } + mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); + mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); + mAutoPilotDestination->setPixelSize(5); + mAutoPilotDestination->setColor(LLColor4U(170, 210, 190)); + mAutoPilotDestination->setDuration(3.f); + + handle_go_to(); +} + // When we get object properties after left-clicking on an object // with left-click = buy, if it's the same object, do the buy. @@ -637,44 +687,64 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) mMouseButtonDown = false; if (click_action == CLICK_ACTION_NONE // not doing 1-click action - && gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled && !gAgent.getFlying() // don't auto-navigate while flying until that works && gAgentAvatarp && !gAgentAvatarp->isSitting() - && !mBlockClickToWalk // another behavior hasn't cancelled click to walk && !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land || mPick.mObjectID.notNull())) // or on an object { - // handle special cases of steering picks - LLViewerObject* avatar_object = mPick.getObject(); - - // get pointer to avatar - while (avatar_object && !avatar_object->isAvatar()) + if (gSavedSettings.getBOOL("ClickToWalk") + && !mBlockClickToWalk) // another behavior hasn't cancelled click to walk { - avatar_object = (LLViewerObject*)avatar_object->getParent(); - } + // handle special cases of steering picks + LLViewerObject* avatar_object = mPick.getObject(); - if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) - { - const F64 SELF_CLICK_WALK_DISTANCE = 3.0; - // pretend we picked some point a bit in front of avatar - mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE; + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) + { + avatar_object = (LLViewerObject*)avatar_object->getParent(); + } + + if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) + { + const F64 SELF_CLICK_WALK_DISTANCE = 3.0; + // pretend we picked some point a bit in front of avatar + mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE; + } + gAgentCamera.setFocusOnAvatar(TRUE, TRUE); + walkToClickedLocation(); + LLFirstUse::notMoving(false); + + return TRUE; } - gAgentCamera.setFocusOnAvatar(TRUE, TRUE); - if(mAutoPilotDestination) { mAutoPilotDestination->markDead(); } - mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); - mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); - mAutoPilotDestination->setPixelSize(5); - mAutoPilotDestination->setColor(LLColor4U(170, 210, 190)); - mAutoPilotDestination->setDuration(3.f); + else if (gSavedSettings.getBOOL("ClickToTeleport") && !mBlockClickToTeleport) + { + LLViewerObject* objp = mPick.getObject(); + LLViewerObject* parentp = objp ? objp->getRootEdit() : NULL; - handle_go_to(); - LLFirstUse::notMoving(false); + bool is_in_world = mPick.mObjectID.notNull() && objp && !objp->isHUDAttachment(); + bool is_land = mPick.mPickType == LLPickInfo::PICK_LAND; + bool has_touch_handler = (objp && objp->flagHandleTouch()) || (parentp && parentp->flagHandleTouch()); + bool has_click_action = final_click_action(objp); - mBlockClickToWalk = false; + if (is_land || (is_in_world && !has_touch_handler && !has_click_action)) + { + LLVector3d pos = mPick.mPosGlobal; + pos.mdV[VZ] += gAgentAvatarp->getPelvisToFoot(); - return TRUE; + if (gSavedSettings.getBOOL("DoubleClickAutoPilot")) + { + // defer for more than the double click interval. + scheduleTeleport(pos); + } + else + { + gAgent.teleportViaLocationLookAt(pos); + } + return TRUE; + } + } } gViewerWindow->setCursor(UI_CURSOR_ARROW); if (hasMouseCapture()) @@ -686,6 +756,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on mBlockClickToWalk = false; + mBlockClickToTeleport = false; return LLTool::handleMouseUp(x, y, mask); } @@ -706,18 +777,17 @@ BOOL LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask) llinfos << "LLToolPie handleDoubleClick (becoming mouseDown)" << llendl; } + cancelScheduledTeleport(); + if (gSavedSettings.getBOOL("DoubleClickAutoPilot")) { - if (mPick.mPickType == LLPickInfo::PICK_LAND - && !mPick.mPosGlobal.isExactlyZero()) - { - handle_go_to(); - return TRUE; - } - else if (mPick.mObjectID.notNull() - && !mPick.mPosGlobal.isExactlyZero()) + // Avoid teleporting for the second time when user releases mouse button after double click. + mBlockClickToTeleport = true; + + if ((mPick.mPickType == LLPickInfo::PICK_LAND && !mPick.mPosGlobal.isExactlyZero()) || + (mPick.mObjectID.notNull() && !mPick.mPosGlobal.isExactlyZero())) { - handle_go_to(); + walkToClickedLocation(); return TRUE; } } @@ -1373,6 +1443,23 @@ bool LLToolPie::inCameraSteerMode() return mMouseButtonDown && mMouseOutsideSlop && gSavedSettings.getBOOL("ClickToWalk"); } +void LLToolPie::scheduleTeleport(const LLVector3d& pos) +{ + // cancel previously scheduled teleport (if any) + cancelScheduledTeleport(); + + // and schedule new one + mClickToTeleportTimer = new LLClickToTeleportTimer(pos); +} + +void LLToolPie::cancelScheduledTeleport() +{ + if (mClickToTeleportTimer) + { + delete mClickToTeleportTimer; + } +} + // true if x,y outside small box around start_x,start_y BOOL LLToolPie::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y) { -- cgit v1.2.3 From bcdd0b52dd3f0b2e0f5d7310526dca79aea7b146 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 23 Sep 2011 21:46:55 +0300 Subject: STORM-1612 FOLLOWUP Trivial Windows compilation fix. --- indra/newview/lltoolpie.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index e614fe23d0..a05fc9536e 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -96,7 +96,7 @@ private: }; LLClickToTeleportTimer::LLClickToTeleportTimer(const LLVector3d& pos) -: LLEventTimer(0.33) // should be greater than double click interval +: LLEventTimer(0.33f) // should be greater than double click interval , mTeleportPos(pos) { }; -- cgit v1.2.3 From f6a8a2c5460c8f61b37154de01cd2f9575ef87de Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 29 Sep 2011 15:35:02 +0300 Subject: STORM-1612 WIP Implemented new click-to-walk/teleport preferences design. --- indra/newview/lltoolpie.cpp | 127 +++++++------------------------------------- 1 file changed, 18 insertions(+), 109 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index a05fc9536e..b0d9bd5d70 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -35,7 +35,6 @@ #include "llagent.h" #include "llagentcamera.h" #include "llavatarnamecache.h" -#include "lleventtimer.h" #include "llfocusmgr.h" #include "llfirstuse.h" #include "llfloaterland.h" @@ -77,42 +76,6 @@ static void handle_click_action_play(); static void handle_click_action_open_media(LLPointer objectp); static ECursorType cursor_from_parcel_media(U8 click_action); -/** - * Schedule teleport to the specified location when user clicks in world. - * - * Deferring teleport is needed for double-click-to-walk to work. - * If double click in the world view occurs, teleport gets canceled. - */ -class LLClickToTeleportTimer : public LLEventTimer -{ - LOG_CLASS(LLClickToTeleportTimer); -public: - LLClickToTeleportTimer(const LLVector3d& pos); - ~LLClickToTeleportTimer(); - /*virtual*/ BOOL tick(); - -private: - LLVector3d mTeleportPos; -}; - -LLClickToTeleportTimer::LLClickToTeleportTimer(const LLVector3d& pos) -: LLEventTimer(0.33f) // should be greater than double click interval -, mTeleportPos(pos) -{ -}; - -LLClickToTeleportTimer::~LLClickToTeleportTimer() -{ - LLToolPie::instance().mClickToTeleportTimer = NULL; -} - -BOOL LLClickToTeleportTimer::tick() -{ - lldebugs << "Teleporting to " << mTeleportPos << llendl; - gAgent.teleportViaLocationLookAt(mTeleportPos); - return TRUE; // destroy the timer -} - LLToolPie::LLToolPie() : LLTool(std::string("Pie")), mMouseButtonDown( false ), @@ -120,8 +83,6 @@ LLToolPie::LLToolPie() mMouseSteerX(-1), mMouseSteerY(-1), mBlockClickToWalk(false), - mBlockClickToTeleport(false), - mClickToTeleportTimer(NULL), mClickAction(0), mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ), mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") ) @@ -687,64 +648,35 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) mMouseButtonDown = false; if (click_action == CLICK_ACTION_NONE // not doing 1-click action + && gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled && !gAgent.getFlying() // don't auto-navigate while flying until that works && gAgentAvatarp && !gAgentAvatarp->isSitting() + && !mBlockClickToWalk // another behavior hasn't cancelled click to walk && !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land || mPick.mObjectID.notNull())) // or on an object { - if (gSavedSettings.getBOOL("ClickToWalk") - && !mBlockClickToWalk) // another behavior hasn't cancelled click to walk - { - // handle special cases of steering picks - LLViewerObject* avatar_object = mPick.getObject(); - - // get pointer to avatar - while (avatar_object && !avatar_object->isAvatar()) - { - avatar_object = (LLViewerObject*)avatar_object->getParent(); - } - - if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) - { - const F64 SELF_CLICK_WALK_DISTANCE = 3.0; - // pretend we picked some point a bit in front of avatar - mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE; - } - gAgentCamera.setFocusOnAvatar(TRUE, TRUE); - walkToClickedLocation(); - LLFirstUse::notMoving(false); + // handle special cases of steering picks + LLViewerObject* avatar_object = mPick.getObject(); - return TRUE; - } - else if (gSavedSettings.getBOOL("ClickToTeleport") && !mBlockClickToTeleport) + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) { - LLViewerObject* objp = mPick.getObject(); - LLViewerObject* parentp = objp ? objp->getRootEdit() : NULL; - - bool is_in_world = mPick.mObjectID.notNull() && objp && !objp->isHUDAttachment(); - bool is_land = mPick.mPickType == LLPickInfo::PICK_LAND; - bool has_touch_handler = (objp && objp->flagHandleTouch()) || (parentp && parentp->flagHandleTouch()); - bool has_click_action = final_click_action(objp); - - if (is_land || (is_in_world && !has_touch_handler && !has_click_action)) - { - LLVector3d pos = mPick.mPosGlobal; - pos.mdV[VZ] += gAgentAvatarp->getPelvisToFoot(); + avatar_object = (LLViewerObject*)avatar_object->getParent(); + } - if (gSavedSettings.getBOOL("DoubleClickAutoPilot")) - { - // defer for more than the double click interval. - scheduleTeleport(pos); - } - else - { - gAgent.teleportViaLocationLookAt(pos); - } - return TRUE; - } + if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) + { + const F64 SELF_CLICK_WALK_DISTANCE = 3.0; + // pretend we picked some point a bit in front of avatar + mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE; } + gAgentCamera.setFocusOnAvatar(TRUE, TRUE); + walkToClickedLocation(); + LLFirstUse::notMoving(false); + + return TRUE; } gViewerWindow->setCursor(UI_CURSOR_ARROW); if (hasMouseCapture()) @@ -756,7 +688,6 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on mBlockClickToWalk = false; - mBlockClickToTeleport = false; return LLTool::handleMouseUp(x, y, mask); } @@ -777,13 +708,8 @@ BOOL LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask) llinfos << "LLToolPie handleDoubleClick (becoming mouseDown)" << llendl; } - cancelScheduledTeleport(); - if (gSavedSettings.getBOOL("DoubleClickAutoPilot")) { - // Avoid teleporting for the second time when user releases mouse button after double click. - mBlockClickToTeleport = true; - if ((mPick.mPickType == LLPickInfo::PICK_LAND && !mPick.mPosGlobal.isExactlyZero()) || (mPick.mObjectID.notNull() && !mPick.mPosGlobal.isExactlyZero())) { @@ -1443,23 +1369,6 @@ bool LLToolPie::inCameraSteerMode() return mMouseButtonDown && mMouseOutsideSlop && gSavedSettings.getBOOL("ClickToWalk"); } -void LLToolPie::scheduleTeleport(const LLVector3d& pos) -{ - // cancel previously scheduled teleport (if any) - cancelScheduledTeleport(); - - // and schedule new one - mClickToTeleportTimer = new LLClickToTeleportTimer(pos); -} - -void LLToolPie::cancelScheduledTeleport() -{ - if (mClickToTeleportTimer) - { - delete mClickToTeleportTimer; - } -} - // true if x,y outside small box around start_x,start_y BOOL LLToolPie::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y) { -- cgit v1.2.3