From 2115211328261d875dc0ccacdc2021f1c501a36d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 9 Apr 2012 18:53:52 -0700 Subject: Re-implementing the path testing functionality as a proper LLTool. --- indra/newview/llpathfindingpathtool.cpp | 206 ++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 indra/newview/llpathfindingpathtool.cpp (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp new file mode 100644 index 0000000000..f27c722264 --- /dev/null +++ b/indra/newview/llpathfindingpathtool.cpp @@ -0,0 +1,206 @@ +/** + * @file llpathfindingpathtool.cpp + * @author William Todd Stinson + * @brief XXX + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llpathfindingpathtool.h" +#include "llsingleton.h" +#include "lltool.h" +#include "llviewerwindow.h" +#include "llviewercamera.h" +#include "llpathfindingmanager.h" +#include "llpathinglib.h" + +#include +#include + +#define PATH_TOOL_NAME "PathfindingPathTool" + +LLPathfindingPathTool::LLPathfindingPathTool() + : LLTool(PATH_TOOL_NAME), + LLSingleton(), + mPathData(), + mPathResult(LLPathingLib::LLPL_PATH_NOT_GENERATED), + mHasStartPoint(false), + mHasEndPoint(false), + mCharacterWidth(1.0f), + mCharacterType(kCharacterTypeNone), + mPathEventSignal() +{ + if (!LLPathingLib::getInstance()) + { + LLPathingLib::initSystem(); + } +} + +LLPathfindingPathTool::~LLPathfindingPathTool() +{ +} + +BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) +{ + if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) + { + LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); + LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); + LLVector3 rayStart = mousePos; + LLVector3 rayEnd = mousePos + dv * 150; + + if (pMask & MASK_CONTROL) + { + mPathData.mStartPointA = rayStart; + mPathData.mEndPointA = rayEnd; + mHasStartPoint = true; + } + else if (pMask & MASK_SHIFT) + { + mPathData.mStartPointB = rayStart; + mPathData.mEndPointB = rayEnd; + mHasEndPoint = true; + } + computePath(); + } + + return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); +} + +BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) +{ + if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); + } + + return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); +} + +LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const +{ + EPathStatus status = kPathStatusUnknown; + + if (LLPathingLib::getInstance() == NULL) + { + status = kPathStatusNotImplemented; + } + else if (!LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion()) + { + status = kPathStatusNotEnabled; + } + else if (!mHasStartPoint && !mHasEndPoint) + { + status = kPathStatusChooseStartAndEndPoints; + } + else if (!mHasStartPoint) + { + status = kPathStatusChooseStartPoint; + } + else if (!mHasEndPoint) + { + status = kPathStatusChooseEndPoint; + } + else if (mPathResult == LLPathingLib::LLPL_PATH_GENERATED_OK) + { + status = kPathStatusHasValidPath; + } + else if (mPathResult == LLPathingLib::LLPL_NO_PATH) + { + status = kPathStatusHasInvalidPath; + } + else + { + status = kPathStatusError; + } + + return status; +} + +F32 LLPathfindingPathTool::getCharacterWidth() const +{ + return mCharacterWidth; +} + +void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) +{ + mCharacterWidth = pCharacterWidth; + mPathData.mCharacterWidth = pCharacterWidth; + computePath(); +} + +LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const +{ + return mCharacterType; +} + +void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) +{ + mCharacterType = pCharacterType; + switch (pCharacterType) + { + case kCharacterTypeNone : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; + break; + case kCharacterTypeA : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_A; + break; + case kCharacterTypeB : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_B; + break; + case kCharacterTypeC : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_C; + break; + case kCharacterTypeD : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_D; + break; + default : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; + llassert(0); + break; + } + computePath(); +} + +bool LLPathfindingPathTool::isRenderPath() const +{ + return (mHasStartPoint && mHasEndPoint); +} + +void LLPathfindingPathTool::clearPath() +{ + mHasStartPoint = false; + mHasEndPoint = false; + computePath(); +} + +LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEventListener(path_event_callback_t pPathEventCallback) +{ + return mPathEventSignal.connect(pPathEventCallback); +} + +void LLPathfindingPathTool::computePath() +{ + mPathResult = LLPathingLib::getInstance()->generatePath(mPathData); + mPathEventSignal(); +} -- cgit v1.2.3 From 7f49803dd284417674988a4de5262ad63f66d092 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 10 Apr 2012 11:13:12 -0700 Subject: BUILDFIX: Correcting one more build issue on linux and mac platforms. --- indra/newview/llpathfindingpathtool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index f27c722264..9acb04a486 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -32,7 +32,7 @@ #include "llviewerwindow.h" #include "llviewercamera.h" #include "llpathfindingmanager.h" -#include "llpathinglib.h" +#include "LLPathingLib.h" #include #include -- cgit v1.2.3 From 31543e637bcb0e6ddc83d21a3efdbe242fcf9f71 Mon Sep 17 00:00:00 2001 From: prep Date: Tue, 10 Apr 2012 14:34:28 -0400 Subject: Fixed default character width bug. Updated rendertri api for new path rendering bookends. --- indra/newview/llpathfindingpathtool.cpp | 414 ++++++++++++++++---------------- 1 file changed, 208 insertions(+), 206 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index f27c722264..6200586cf1 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -1,206 +1,208 @@ -/** - * @file llpathfindingpathtool.cpp - * @author William Todd Stinson - * @brief XXX - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" -#include "llpathfindingpathtool.h" -#include "llsingleton.h" -#include "lltool.h" -#include "llviewerwindow.h" -#include "llviewercamera.h" -#include "llpathfindingmanager.h" -#include "llpathinglib.h" - -#include -#include - -#define PATH_TOOL_NAME "PathfindingPathTool" - -LLPathfindingPathTool::LLPathfindingPathTool() - : LLTool(PATH_TOOL_NAME), - LLSingleton(), - mPathData(), - mPathResult(LLPathingLib::LLPL_PATH_NOT_GENERATED), - mHasStartPoint(false), - mHasEndPoint(false), - mCharacterWidth(1.0f), - mCharacterType(kCharacterTypeNone), - mPathEventSignal() -{ - if (!LLPathingLib::getInstance()) - { - LLPathingLib::initSystem(); - } -} - -LLPathfindingPathTool::~LLPathfindingPathTool() -{ -} - -BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) -{ - if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) - { - LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); - LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); - LLVector3 rayStart = mousePos; - LLVector3 rayEnd = mousePos + dv * 150; - - if (pMask & MASK_CONTROL) - { - mPathData.mStartPointA = rayStart; - mPathData.mEndPointA = rayEnd; - mHasStartPoint = true; - } - else if (pMask & MASK_SHIFT) - { - mPathData.mStartPointB = rayStart; - mPathData.mEndPointB = rayEnd; - mHasEndPoint = true; - } - computePath(); - } - - return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); -} - -BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) -{ - if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); - } - - return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); -} - -LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const -{ - EPathStatus status = kPathStatusUnknown; - - if (LLPathingLib::getInstance() == NULL) - { - status = kPathStatusNotImplemented; - } - else if (!LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion()) - { - status = kPathStatusNotEnabled; - } - else if (!mHasStartPoint && !mHasEndPoint) - { - status = kPathStatusChooseStartAndEndPoints; - } - else if (!mHasStartPoint) - { - status = kPathStatusChooseStartPoint; - } - else if (!mHasEndPoint) - { - status = kPathStatusChooseEndPoint; - } - else if (mPathResult == LLPathingLib::LLPL_PATH_GENERATED_OK) - { - status = kPathStatusHasValidPath; - } - else if (mPathResult == LLPathingLib::LLPL_NO_PATH) - { - status = kPathStatusHasInvalidPath; - } - else - { - status = kPathStatusError; - } - - return status; -} - -F32 LLPathfindingPathTool::getCharacterWidth() const -{ - return mCharacterWidth; -} - -void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) -{ - mCharacterWidth = pCharacterWidth; - mPathData.mCharacterWidth = pCharacterWidth; - computePath(); -} - -LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const -{ - return mCharacterType; -} - -void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) -{ - mCharacterType = pCharacterType; - switch (pCharacterType) - { - case kCharacterTypeNone : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; - break; - case kCharacterTypeA : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_A; - break; - case kCharacterTypeB : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_B; - break; - case kCharacterTypeC : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_C; - break; - case kCharacterTypeD : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_D; - break; - default : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; - llassert(0); - break; - } - computePath(); -} - -bool LLPathfindingPathTool::isRenderPath() const -{ - return (mHasStartPoint && mHasEndPoint); -} - -void LLPathfindingPathTool::clearPath() -{ - mHasStartPoint = false; - mHasEndPoint = false; - computePath(); -} - -LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEventListener(path_event_callback_t pPathEventCallback) -{ - return mPathEventSignal.connect(pPathEventCallback); -} - -void LLPathfindingPathTool::computePath() -{ - mPathResult = LLPathingLib::getInstance()->generatePath(mPathData); - mPathEventSignal(); -} +/** + * @file llpathfindingpathtool.cpp + * @author William Todd Stinson + * @brief XXX + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llpathfindingpathtool.h" +#include "llsingleton.h" +#include "lltool.h" +#include "llviewerwindow.h" +#include "llviewercamera.h" +#include "llpathfindingmanager.h" +#include "llpathinglib.h" + +#include +#include + +#define PATH_TOOL_NAME "PathfindingPathTool" + +LLPathfindingPathTool::LLPathfindingPathTool() + : LLTool(PATH_TOOL_NAME), + LLSingleton(), + mPathData(), + mPathResult(LLPathingLib::LLPL_PATH_NOT_GENERATED), + mHasStartPoint(false), + mHasEndPoint(false), + mCharacterWidth(1.0f), + mCharacterType(kCharacterTypeNone), + mPathEventSignal() +{ + if (!LLPathingLib::getInstance()) + { + LLPathingLib::initSystem(); + } + + mPathData.mCharacterWidth = mCharacterWidth; +} + +LLPathfindingPathTool::~LLPathfindingPathTool() +{ +} + +BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) +{ + if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) + { + LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); + LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); + LLVector3 rayStart = mousePos; + LLVector3 rayEnd = mousePos + dv * 150; + + if (pMask & MASK_CONTROL) + { + mPathData.mStartPointA = rayStart; + mPathData.mEndPointA = rayEnd; + mHasStartPoint = true; + } + else if (pMask & MASK_SHIFT) + { + mPathData.mStartPointB = rayStart; + mPathData.mEndPointB = rayEnd; + mHasEndPoint = true; + } + computePath(); + } + + return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); +} + +BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) +{ + if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); + } + + return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); +} + +LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const +{ + EPathStatus status = kPathStatusUnknown; + + if (LLPathingLib::getInstance() == NULL) + { + status = kPathStatusNotImplemented; + } + else if (!LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion()) + { + status = kPathStatusNotEnabled; + } + else if (!mHasStartPoint && !mHasEndPoint) + { + status = kPathStatusChooseStartAndEndPoints; + } + else if (!mHasStartPoint) + { + status = kPathStatusChooseStartPoint; + } + else if (!mHasEndPoint) + { + status = kPathStatusChooseEndPoint; + } + else if (mPathResult == LLPathingLib::LLPL_PATH_GENERATED_OK) + { + status = kPathStatusHasValidPath; + } + else if (mPathResult == LLPathingLib::LLPL_NO_PATH) + { + status = kPathStatusHasInvalidPath; + } + else + { + status = kPathStatusError; + } + + return status; +} + +F32 LLPathfindingPathTool::getCharacterWidth() const +{ + return mCharacterWidth; +} + +void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) +{ + mCharacterWidth = pCharacterWidth; + mPathData.mCharacterWidth = pCharacterWidth; + computePath(); +} + +LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const +{ + return mCharacterType; +} + +void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) +{ + mCharacterType = pCharacterType; + switch (pCharacterType) + { + case kCharacterTypeNone : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; + break; + case kCharacterTypeA : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_A; + break; + case kCharacterTypeB : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_B; + break; + case kCharacterTypeC : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_C; + break; + case kCharacterTypeD : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_D; + break; + default : + mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; + llassert(0); + break; + } + computePath(); +} + +bool LLPathfindingPathTool::isRenderPath() const +{ + return (mHasStartPoint && mHasEndPoint); +} + +void LLPathfindingPathTool::clearPath() +{ + mHasStartPoint = false; + mHasEndPoint = false; + computePath(); +} + +LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEventListener(path_event_callback_t pPathEventCallback) +{ + return mPathEventSignal.connect(pPathEventCallback); +} + +void LLPathfindingPathTool::computePath() +{ + mPathResult = LLPathingLib::getInstance()->generatePath(mPathData); + mPathEventSignal(); +} -- cgit v1.2.3 From 7a60a12531769629ba20914128581498256f3e2f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 10 Apr 2012 12:05:12 -0700 Subject: Implementing a temporary path functionality based on a suggestion to improve usability. --- indra/newview/llpathfindingpathtool.cpp | 146 ++++++++++++++++++++++++-------- 1 file changed, 112 insertions(+), 34 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 9acb04a486..5825f3d392 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -42,10 +42,13 @@ LLPathfindingPathTool::LLPathfindingPathTool() : LLTool(PATH_TOOL_NAME), LLSingleton(), - mPathData(), + mFinalPathData(), + mTempPathData(), mPathResult(LLPathingLib::LLPL_PATH_NOT_GENERATED), - mHasStartPoint(false), - mHasEndPoint(false), + mHasFinalStartPoint(false), + mHasFinalEndPoint(false), + mHasTempStartPoint(false), + mHasTempEndPoint(false), mCharacterWidth(1.0f), mCharacterType(kCharacterTypeNone), mPathEventSignal() @@ -62,39 +65,78 @@ LLPathfindingPathTool::~LLPathfindingPathTool() BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) { - if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) + BOOL returnVal = FALSE; + + if (isAnyPathToolModKeys(pMask)) { LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); LLVector3 rayStart = mousePos; LLVector3 rayEnd = mousePos + dv * 150; - if (pMask & MASK_CONTROL) + if (isStartPathToolModKeys(pMask)) { - mPathData.mStartPointA = rayStart; - mPathData.mEndPointA = rayEnd; - mHasStartPoint = true; + mFinalPathData.mStartPointA = rayStart; + mFinalPathData.mEndPointA = rayEnd; + mHasFinalStartPoint = true; } - else if (pMask & MASK_SHIFT) + else if (isEndPathToolModKeys(pMask)) { - mPathData.mStartPointB = rayStart; - mPathData.mEndPointB = rayEnd; - mHasEndPoint = true; + mFinalPathData.mStartPointB = rayStart; + mFinalPathData.mEndPointB = rayEnd; + mHasFinalEndPoint = true; } - computePath(); + computeFinalPath(); + + returnVal = TRUE; } - return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); + return returnVal; } BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) { - if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) + BOOL returnVal = FALSE; + + if (isAnyPathToolModKeys(pMask)) { gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); + + LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); + LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); + LLVector3 rayStart = mousePos; + LLVector3 rayEnd = mousePos + dv * 150; + + if (isStartPathToolModKeys(pMask)) + { + mTempPathData.mStartPointA = rayStart; + mTempPathData.mEndPointA = rayEnd; + mHasTempStartPoint = true; + mTempPathData.mStartPointB = mFinalPathData.mStartPointB; + mTempPathData.mEndPointB = mFinalPathData.mEndPointB; + mHasTempEndPoint = mHasFinalEndPoint; + } + else if (isEndPathToolModKeys(pMask)) + { + mTempPathData.mStartPointB = rayStart; + mTempPathData.mEndPointB = rayEnd; + mHasTempEndPoint = true; + mTempPathData.mStartPointA = mFinalPathData.mStartPointA; + mTempPathData.mEndPointA = mFinalPathData.mEndPointA; + mHasTempStartPoint = mHasFinalStartPoint; + } + computeTempPath(); + + returnVal = TRUE; + } + else + { + mHasTempStartPoint = false; + mHasTempEndPoint = false; + computeFinalPath(); } - return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); + return returnVal; } LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const @@ -109,15 +151,15 @@ LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const { status = kPathStatusNotEnabled; } - else if (!mHasStartPoint && !mHasEndPoint) + else if (!mHasFinalStartPoint && !mHasFinalEndPoint) { status = kPathStatusChooseStartAndEndPoints; } - else if (!mHasStartPoint) + else if (!mHasFinalStartPoint) { status = kPathStatusChooseStartPoint; } - else if (!mHasEndPoint) + else if (!mHasFinalEndPoint) { status = kPathStatusChooseEndPoint; } @@ -145,8 +187,10 @@ F32 LLPathfindingPathTool::getCharacterWidth() const void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) { mCharacterWidth = pCharacterWidth; - mPathData.mCharacterWidth = pCharacterWidth; - computePath(); + mFinalPathData.mCharacterWidth = pCharacterWidth; + mTempPathData.mCharacterWidth = pCharacterWidth; + computeFinalPath(); + computeTempPath(); } LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const @@ -157,41 +201,48 @@ LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) { mCharacterType = pCharacterType; + + LLPathingLib::LLPLCharacterType characterType; switch (pCharacterType) { case kCharacterTypeNone : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; break; case kCharacterTypeA : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_A; + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_A; break; case kCharacterTypeB : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_B; + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_B; break; case kCharacterTypeC : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_C; + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_C; break; case kCharacterTypeD : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_D; + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_D; break; default : - mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; llassert(0); break; } - computePath(); + mFinalPathData.mCharacterType = characterType; + mTempPathData.mCharacterType = characterType; + computeFinalPath(); + computeTempPath(); } bool LLPathfindingPathTool::isRenderPath() const { - return (mHasStartPoint && mHasEndPoint); + return (mHasFinalStartPoint && mHasFinalEndPoint) || (mHasTempStartPoint && mHasTempEndPoint); } void LLPathfindingPathTool::clearPath() { - mHasStartPoint = false; - mHasEndPoint = false; - computePath(); + mHasFinalStartPoint = false; + mHasFinalEndPoint = false; + mHasTempStartPoint = false; + mHasTempEndPoint = false; + computeFinalPath(); } LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEventListener(path_event_callback_t pPathEventCallback) @@ -199,8 +250,35 @@ LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEven return mPathEventSignal.connect(pPathEventCallback); } -void LLPathfindingPathTool::computePath() +bool LLPathfindingPathTool::isAnyPathToolModKeys(MASK pMask) const +{ + return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); +} + +bool LLPathfindingPathTool::isStartPathToolModKeys(MASK pMask) const +{ + return ((pMask & MASK_CONTROL) != 0); +} + +bool LLPathfindingPathTool::isEndPathToolModKeys(MASK pMask) const +{ + return ((pMask & MASK_SHIFT) != 0); +} + +void LLPathfindingPathTool::computeFinalPath() { - mPathResult = LLPathingLib::getInstance()->generatePath(mPathData); + mPathResult = LLPathingLib::LLPL_PATH_NOT_GENERATED; + if (mHasFinalStartPoint && mHasFinalEndPoint && (LLPathingLib::getInstance() != NULL)) + { + mPathResult = LLPathingLib::getInstance()->generatePath(mFinalPathData); + } mPathEventSignal(); } + +void LLPathfindingPathTool::computeTempPath() +{ + if (mHasTempStartPoint && mHasTempEndPoint && (LLPathingLib::getInstance() != NULL)) + { + LLPathingLib::getInstance()->generatePath(mTempPathData); + } +} -- cgit v1.2.3 From ba2a9aa8ca4c690a051269b973a20bbba0c0b572 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 10 Apr 2012 12:34:03 -0700 Subject: Ensuring that the defaults are synced after building the pathfinding console and pathfinding path tool. --- indra/newview/llpathfindingpathtool.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 11759f5523..3952b70da7 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -58,7 +58,8 @@ LLPathfindingPathTool::LLPathfindingPathTool() LLPathingLib::initSystem(); } - mFinalPathData.mCharacterWidth = mCharacterWidth; + setCharacterWidth(mCharacterWidth); + setCharacterType(mCharacterType); } LLPathfindingPathTool::~LLPathfindingPathTool() -- cgit v1.2.3 From 76b280a2ad2549a795589fe75328cda71115da97 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 10 Apr 2012 16:26:49 -0700 Subject: Updating the pathfinding console with the results from the temporary path. --- indra/newview/llpathfindingpathtool.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 3952b70da7..3301fe7721 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -282,6 +282,7 @@ void LLPathfindingPathTool::computeTempPath() { if (mHasTempStartPoint && mHasTempEndPoint && (LLPathingLib::getInstance() != NULL)) { - LLPathingLib::getInstance()->generatePath(mTempPathData); + mPathResult = LLPathingLib::getInstance()->generatePath(mTempPathData); } + mPathEventSignal(); } -- cgit v1.2.3 From ba0e3c3c6485fefbe273b6fa8f9121850166b2cc Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 10 Apr 2012 18:20:21 -0700 Subject: Adding the display of the temporary start/end path character on hover state. --- indra/newview/llpathfindingpathtool.cpp | 160 ++++++++++++++++++++++---------- 1 file changed, 113 insertions(+), 47 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 3301fe7721..594682c530 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -44,12 +44,7 @@ LLPathfindingPathTool::LLPathfindingPathTool() LLSingleton(), mFinalPathData(), mTempPathData(), - mPathResult(LLPathingLib::LLPL_PATH_NOT_GENERATED), - mHasFinalStartPoint(false), - mHasFinalEndPoint(false), - mHasTempStartPoint(false), - mHasTempEndPoint(false), - mCharacterWidth(1.0f), + mPathResult(LLPathingLib::LLPL_NO_PATH), mCharacterType(kCharacterTypeNone), mPathEventSignal() { @@ -58,7 +53,7 @@ LLPathfindingPathTool::LLPathfindingPathTool() LLPathingLib::initSystem(); } - setCharacterWidth(mCharacterWidth); + setCharacterWidth(1.0f); setCharacterType(mCharacterType); } @@ -77,17 +72,13 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) LLVector3 rayStart = mousePos; LLVector3 rayEnd = mousePos + dv * 150; - if (isStartPathToolModKeys(pMask)) + if (isPointAModKeys(pMask)) { - mFinalPathData.mStartPointA = rayStart; - mFinalPathData.mEndPointA = rayEnd; - mHasFinalStartPoint = true; + setFinalA(rayStart, rayEnd); } - else if (isEndPathToolModKeys(pMask)) + else if (isPointBModKeys(pMask)) { - mFinalPathData.mStartPointB = rayStart; - mFinalPathData.mEndPointB = rayEnd; - mHasFinalEndPoint = true; + setFinalB(rayStart, rayEnd); } computeFinalPath(); @@ -110,23 +101,21 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) LLVector3 rayStart = mousePos; LLVector3 rayEnd = mousePos + dv * 150; - if (isStartPathToolModKeys(pMask)) + if (isPointAModKeys(pMask)) { - mTempPathData.mStartPointA = rayStart; - mTempPathData.mEndPointA = rayEnd; - mHasTempStartPoint = true; - mTempPathData.mStartPointB = mFinalPathData.mStartPointB; - mTempPathData.mEndPointB = mFinalPathData.mEndPointB; - mHasTempEndPoint = mHasFinalEndPoint; - } - else if (isEndPathToolModKeys(pMask)) + setTempA(rayStart, rayEnd); + if (hasFinalB()) + { + setTempB(getFinalBStart(), getFinalBEnd()); + } + } + else if (isPointBModKeys(pMask)) { - mTempPathData.mStartPointB = rayStart; - mTempPathData.mEndPointB = rayEnd; - mHasTempEndPoint = true; - mTempPathData.mStartPointA = mFinalPathData.mStartPointA; - mTempPathData.mEndPointA = mFinalPathData.mEndPointA; - mHasTempStartPoint = mHasFinalStartPoint; + if (hasFinalA()) + { + setTempA(getFinalAStart(), getFinalAEnd()); + } + setTempB(rayStart, rayEnd); } computeTempPath(); @@ -134,8 +123,7 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) } else { - mHasTempStartPoint = false; - mHasTempEndPoint = false; + clearTemp(); computeFinalPath(); } @@ -154,15 +142,15 @@ LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const { status = kPathStatusNotEnabled; } - else if (!mHasFinalStartPoint && !mHasFinalEndPoint) + else if (!hasFinalA() && !hasFinalB()) { status = kPathStatusChooseStartAndEndPoints; } - else if (!mHasFinalStartPoint) + else if (!hasFinalA()) { status = kPathStatusChooseStartPoint; } - else if (!mHasFinalEndPoint) + else if (!hasFinalB()) { status = kPathStatusChooseEndPoint; } @@ -184,12 +172,11 @@ LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const F32 LLPathfindingPathTool::getCharacterWidth() const { - return mCharacterWidth; + return mFinalPathData.mCharacterWidth; } void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) { - mCharacterWidth = pCharacterWidth; mFinalPathData.mCharacterWidth = pCharacterWidth; mTempPathData.mCharacterWidth = pCharacterWidth; computeFinalPath(); @@ -236,15 +223,13 @@ void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) bool LLPathfindingPathTool::isRenderPath() const { - return (mHasFinalStartPoint && mHasFinalEndPoint) || (mHasTempStartPoint && mHasTempEndPoint); + return (hasFinalA() || hasFinalB() || hasTempA() || hasTempB()); } void LLPathfindingPathTool::clearPath() { - mHasFinalStartPoint = false; - mHasFinalEndPoint = false; - mHasTempStartPoint = false; - mHasTempEndPoint = false; + clearFinal(); + clearTemp(); computeFinalPath(); } @@ -258,20 +243,100 @@ bool LLPathfindingPathTool::isAnyPathToolModKeys(MASK pMask) const return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); } -bool LLPathfindingPathTool::isStartPathToolModKeys(MASK pMask) const +bool LLPathfindingPathTool::isPointAModKeys(MASK pMask) const { return ((pMask & MASK_CONTROL) != 0); } -bool LLPathfindingPathTool::isEndPathToolModKeys(MASK pMask) const +bool LLPathfindingPathTool::isPointBModKeys(MASK pMask) const { return ((pMask & MASK_SHIFT) != 0); } +void LLPathfindingPathTool::setFinalA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) +{ + mFinalPathData.mStartPointA = pStartPoint; + mFinalPathData.mEndPointA = pEndPoint; + mFinalPathData.mHasPointA = true; +} + +bool LLPathfindingPathTool::hasFinalA() const +{ + return mFinalPathData.mHasPointA; +} + +const LLVector3 &LLPathfindingPathTool::getFinalAStart() const +{ + return mFinalPathData.mStartPointA; +} + +const LLVector3 &LLPathfindingPathTool::getFinalAEnd() const +{ + return mFinalPathData.mEndPointA; +} + +void LLPathfindingPathTool::setTempA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) +{ + mTempPathData.mStartPointA = pStartPoint; + mTempPathData.mEndPointA = pEndPoint; + mTempPathData.mHasPointA = true; +} + +bool LLPathfindingPathTool::hasTempA() const +{ + return mTempPathData.mHasPointA; +} + +void LLPathfindingPathTool::setFinalB(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) +{ + mFinalPathData.mStartPointB = pStartPoint; + mFinalPathData.mEndPointB = pEndPoint; + mFinalPathData.mHasPointB = true; +} + +bool LLPathfindingPathTool::hasFinalB() const +{ + return mFinalPathData.mHasPointB; +} + +const LLVector3 &LLPathfindingPathTool::getFinalBStart() const +{ + return mFinalPathData.mStartPointB; +} + +const LLVector3 &LLPathfindingPathTool::getFinalBEnd() const +{ + return mFinalPathData.mEndPointB; +} + +void LLPathfindingPathTool::setTempB(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) +{ + mTempPathData.mStartPointB = pStartPoint; + mTempPathData.mEndPointB = pEndPoint; + mTempPathData.mHasPointB = true; +} + +bool LLPathfindingPathTool::hasTempB() const +{ + return mTempPathData.mHasPointB; +} + +void LLPathfindingPathTool::clearFinal() +{ + mFinalPathData.mHasPointA = false; + mFinalPathData.mHasPointB = false; +} + +void LLPathfindingPathTool::clearTemp() +{ + mTempPathData.mHasPointA = false; + mTempPathData.mHasPointB = false; +} + void LLPathfindingPathTool::computeFinalPath() { - mPathResult = LLPathingLib::LLPL_PATH_NOT_GENERATED; - if (mHasFinalStartPoint && mHasFinalEndPoint && (LLPathingLib::getInstance() != NULL)) + mPathResult = LLPathingLib::LLPL_NO_PATH; + if (LLPathingLib::getInstance() != NULL) { mPathResult = LLPathingLib::getInstance()->generatePath(mFinalPathData); } @@ -280,7 +345,8 @@ void LLPathfindingPathTool::computeFinalPath() void LLPathfindingPathTool::computeTempPath() { - if (mHasTempStartPoint && mHasTempEndPoint && (LLPathingLib::getInstance() != NULL)) + mPathResult = LLPathingLib::LLPL_NO_PATH; + if (LLPathingLib::getInstance() != NULL) { mPathResult = LLPathingLib::getInstance()->generatePath(mTempPathData); } -- cgit v1.2.3 From 1f09812ad23208016f0046ef2d1187f15958a822 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 10 Apr 2012 18:42:36 -0700 Subject: Modifying the behavior so that the user is able to drag the start/end points, but holding ctrl/shift while hovering will still not be destructive to the old values. --- indra/newview/llpathfindingpathtool.cpp | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 594682c530..4eb6068e42 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -83,11 +83,73 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) computeFinalPath(); returnVal = TRUE; + setMouseCapture(TRUE); } return returnVal; } +BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) +{ + BOOL returnVal = FALSE; + + if (isAnyPathToolModKeys(pMask)) + { + LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); + LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); + LLVector3 rayStart = mousePos; + LLVector3 rayEnd = mousePos + dv * 150; + + if (isPointAModKeys(pMask)) + { + setFinalA(rayStart, rayEnd); + } + else if (isPointBModKeys(pMask)) + { + setFinalB(rayStart, rayEnd); + } + computeFinalPath(); + + setMouseCapture(FALSE); + returnVal = TRUE; + } + + return returnVal; +} + +BOOL LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) +{ + setMouseCapture(TRUE); + + return TRUE; +} + +BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) +{ + setMouseCapture(FALSE); + + return TRUE; +} + +BOOL LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) +{ + setMouseCapture(TRUE); + + return TRUE; +} + +BOOL LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) +{ + setMouseCapture(FALSE); + + return TRUE; +} + +BOOL LLPathfindingPathTool::handleDoubleClick(S32 pX, S32 pY, MASK pMask) +{ + return TRUE; +} + BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; -- cgit v1.2.3 From c7df83c77dce0d59a4ac8e3ff65f104431eed117 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 10 Apr 2012 19:02:47 -0700 Subject: Refactoring to remove duplicate code. --- indra/newview/llpathfindingpathtool.cpp | 111 ++++++++++++++++---------------- 1 file changed, 54 insertions(+), 57 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 4eb6068e42..d838441dfb 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -67,23 +67,9 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) if (isAnyPathToolModKeys(pMask)) { - LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); - LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); - LLVector3 rayStart = mousePos; - LLVector3 rayEnd = mousePos + dv * 150; - - if (isPointAModKeys(pMask)) - { - setFinalA(rayStart, rayEnd); - } - else if (isPointBModKeys(pMask)) - { - setFinalB(rayStart, rayEnd); - } - computeFinalPath(); - - returnVal = TRUE; + computeFinalPoints(pX, pY, pMask); setMouseCapture(TRUE); + returnVal = TRUE; } return returnVal; @@ -95,21 +81,7 @@ BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) if (isAnyPathToolModKeys(pMask)) { - LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); - LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); - LLVector3 rayStart = mousePos; - LLVector3 rayEnd = mousePos + dv * 150; - - if (isPointAModKeys(pMask)) - { - setFinalA(rayStart, rayEnd); - } - else if (isPointBModKeys(pMask)) - { - setFinalB(rayStart, rayEnd); - } - computeFinalPath(); - + computeFinalPoints(pX, pY, pMask); setMouseCapture(FALSE); returnVal = TRUE; } @@ -119,7 +91,7 @@ BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) BOOL LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) { - setMouseCapture(TRUE); + setMouseCapture(FALSE); return TRUE; } @@ -133,7 +105,7 @@ BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) BOOL LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) { - setMouseCapture(TRUE); + setMouseCapture(FALSE); return TRUE; } @@ -157,30 +129,7 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) if (isAnyPathToolModKeys(pMask)) { gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); - - LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); - LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); - LLVector3 rayStart = mousePos; - LLVector3 rayEnd = mousePos + dv * 150; - - if (isPointAModKeys(pMask)) - { - setTempA(rayStart, rayEnd); - if (hasFinalB()) - { - setTempB(getFinalBStart(), getFinalBEnd()); - } - } - else if (isPointBModKeys(pMask)) - { - if (hasFinalA()) - { - setTempA(getFinalAStart(), getFinalAEnd()); - } - setTempB(rayStart, rayEnd); - } - computeTempPath(); - + computeTempPoints(pX, pY, pMask); returnVal = TRUE; } else @@ -315,6 +264,54 @@ bool LLPathfindingPathTool::isPointBModKeys(MASK pMask) const return ((pMask & MASK_SHIFT) != 0); } +void LLPathfindingPathTool::getRayPoints(S32 pX, S32 pY, LLVector3 &pRayStart, LLVector3 &pRayEnd) const +{ + LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); + LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); + pRayStart = mousePos; + pRayEnd = mousePos + dv * 150; +} + +void LLPathfindingPathTool::computeFinalPoints(S32 pX, S32 pY, MASK pMask) +{ + LLVector3 rayStart, rayEnd; + getRayPoints(pX, pY, rayStart, rayEnd); + + if (isPointAModKeys(pMask)) + { + setFinalA(rayStart, rayEnd); + } + else if (isPointBModKeys(pMask)) + { + setFinalB(rayStart, rayEnd); + } + computeFinalPath(); +} + +void LLPathfindingPathTool::computeTempPoints(S32 pX, S32 pY, MASK pMask) +{ + LLVector3 rayStart, rayEnd; + getRayPoints(pX, pY, rayStart, rayEnd); + + if (isPointAModKeys(pMask)) + { + setTempA(rayStart, rayEnd); + if (hasFinalB()) + { + setTempB(getFinalBStart(), getFinalBEnd()); + } + } + else if (isPointBModKeys(pMask)) + { + if (hasFinalA()) + { + setTempA(getFinalAStart(), getFinalAEnd()); + } + setTempB(rayStart, rayEnd); + } + computeTempPath(); +} + void LLPathfindingPathTool::setFinalA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) { mFinalPathData.mStartPointA = pStartPoint; -- cgit v1.2.3 From 6aeb2c68b9294e77ef9e16a8ad2fcd38d40ecfaf Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 11 Apr 2012 13:20:54 -0700 Subject: Refining the behavior of the pathing test tool behavior with regards to mouse clicks. --- indra/newview/llpathfindingpathtool.cpp | 54 ++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index d838441dfb..03e441a7f2 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -46,7 +46,10 @@ LLPathfindingPathTool::LLPathfindingPathTool() mTempPathData(), mPathResult(LLPathingLib::LLPL_NO_PATH), mCharacterType(kCharacterTypeNone), - mPathEventSignal() + mPathEventSignal(), + mIsLeftMouseButtonHeld(false), + mIsMiddleMouseButtonHeld(false), + mIsRightMouseButtonHeld(false) { if (!LLPathingLib::getInstance()) { @@ -65,12 +68,16 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; - if (isAnyPathToolModKeys(pMask)) + llinfos << "STINSON DEBUG: got here" << llendl; + + if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) { computeFinalPoints(pX, pY, pMask); + mIsLeftMouseButtonHeld = true; setMouseCapture(TRUE); returnVal = TRUE; } + mIsLeftMouseButtonHeld = true; return returnVal; } @@ -79,54 +86,85 @@ BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; - if (isAnyPathToolModKeys(pMask)) + llinfos << "STINSON DEBUG: got here" << llendl; + + if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) { computeFinalPoints(pX, pY, pMask); setMouseCapture(FALSE); returnVal = TRUE; } + mIsLeftMouseButtonHeld = false; return returnVal; } BOOL LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) { - setMouseCapture(FALSE); + llinfos << "STINSON DEBUG: got here" << llendl; + + setMouseCapture(TRUE); + mIsMiddleMouseButtonHeld = true; + gViewerWindow->setCursor(UI_CURSOR_TOOLNO); return TRUE; } BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) { - setMouseCapture(FALSE); + llinfos << "STINSON DEBUG: got here" << llendl; + + if (!mIsLeftMouseButtonHeld && mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) + { + setMouseCapture(FALSE); + } + mIsMiddleMouseButtonHeld = false; return TRUE; } BOOL LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) { - setMouseCapture(FALSE); + llinfos << "STINSON DEBUG: got here" << llendl; + + setMouseCapture(TRUE); + mIsRightMouseButtonHeld = true; + gViewerWindow->setCursor(UI_CURSOR_TOOLNO); return TRUE; } BOOL LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) { - setMouseCapture(FALSE); + llinfos << "STINSON DEBUG: got here" << llendl; + + if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && mIsRightMouseButtonHeld) + { + setMouseCapture(FALSE); + } + mIsRightMouseButtonHeld = false; return TRUE; } BOOL LLPathfindingPathTool::handleDoubleClick(S32 pX, S32 pY, MASK pMask) { + llinfos << "STINSON DEBUG: got here" << llendl; + return TRUE; } +void LLPathfindingPathTool::onMouseCaptureLost() +{ + llinfos << "STINSON DEBUG: got here" << llendl; +} + BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; + llinfos << "STINSON DEBUG: got here" << llendl; - if (isAnyPathToolModKeys(pMask)) + if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) { gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); computeTempPoints(pX, pY, pMask); -- cgit v1.2.3 From dfdbfdbed603d762ad01dcaa84f8a8d06dac0169 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 11 Apr 2012 13:39:25 -0700 Subject: Should not be recomputing the temporary path when settin gthe width and type. --- indra/newview/llpathfindingpathtool.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 03e441a7f2..0497a8972f 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -229,7 +229,6 @@ void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) mFinalPathData.mCharacterWidth = pCharacterWidth; mTempPathData.mCharacterWidth = pCharacterWidth; computeFinalPath(); - computeTempPath(); } LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const @@ -267,7 +266,6 @@ void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) mFinalPathData.mCharacterType = characterType; mTempPathData.mCharacterType = characterType; computeFinalPath(); - computeTempPath(); } bool LLPathfindingPathTool::isRenderPath() const -- cgit v1.2.3 From f1df928b4bc1df7bc8ab6871c5273b04d0b77dea Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 11 Apr 2012 13:58:26 -0700 Subject: Removing debug messaging that was accidentally committed. --- indra/newview/llpathfindingpathtool.cpp | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 0497a8972f..23fdd43b0b 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -68,8 +68,6 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; - llinfos << "STINSON DEBUG: got here" << llendl; - if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) { computeFinalPoints(pX, pY, pMask); @@ -86,8 +84,6 @@ BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; - llinfos << "STINSON DEBUG: got here" << llendl; - if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) { computeFinalPoints(pX, pY, pMask); @@ -101,8 +97,6 @@ BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) BOOL LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) { - llinfos << "STINSON DEBUG: got here" << llendl; - setMouseCapture(TRUE); mIsMiddleMouseButtonHeld = true; gViewerWindow->setCursor(UI_CURSOR_TOOLNO); @@ -112,8 +106,6 @@ BOOL LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) { - llinfos << "STINSON DEBUG: got here" << llendl; - if (!mIsLeftMouseButtonHeld && mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) { setMouseCapture(FALSE); @@ -125,8 +117,6 @@ BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) BOOL LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) { - llinfos << "STINSON DEBUG: got here" << llendl; - setMouseCapture(TRUE); mIsRightMouseButtonHeld = true; gViewerWindow->setCursor(UI_CURSOR_TOOLNO); @@ -136,8 +126,6 @@ BOOL LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) BOOL LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) { - llinfos << "STINSON DEBUG: got here" << llendl; - if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && mIsRightMouseButtonHeld) { setMouseCapture(FALSE); @@ -149,20 +137,12 @@ BOOL LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) BOOL LLPathfindingPathTool::handleDoubleClick(S32 pX, S32 pY, MASK pMask) { - llinfos << "STINSON DEBUG: got here" << llendl; - return TRUE; } -void LLPathfindingPathTool::onMouseCaptureLost() -{ - llinfos << "STINSON DEBUG: got here" << llendl; -} - BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; - llinfos << "STINSON DEBUG: got here" << llendl; if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) { -- cgit v1.2.3 From 1cdef4903daea1622923550b1328b659a594b029 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 18 Apr 2012 16:03:33 -0700 Subject: Updating to the latest llphysicextensions pre-built package with the now lowercased version of the header file names. --- indra/newview/llpathfindingpathtool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 23fdd43b0b..04ea400090 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -32,7 +32,7 @@ #include "llviewerwindow.h" #include "llviewercamera.h" #include "llpathfindingmanager.h" -#include "LLPathingLib.h" +#include "llpathinglib.h" #include #include -- cgit v1.2.3 From cbebd682f7b9b0cff120bc36d9db9bb170dc1b2a Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 25 Apr 2012 13:04:13 -0700 Subject: Removing windows line endings from .h and .cpp files. --- indra/newview/llpathfindingpathtool.cpp | 858 ++++++++++++++++---------------- 1 file changed, 429 insertions(+), 429 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 04ea400090..8825f82f29 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -1,429 +1,429 @@ -/** - * @file llpathfindingpathtool.cpp - * @author William Todd Stinson - * @brief XXX - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" -#include "llpathfindingpathtool.h" -#include "llsingleton.h" -#include "lltool.h" -#include "llviewerwindow.h" -#include "llviewercamera.h" -#include "llpathfindingmanager.h" -#include "llpathinglib.h" - -#include -#include - -#define PATH_TOOL_NAME "PathfindingPathTool" - -LLPathfindingPathTool::LLPathfindingPathTool() - : LLTool(PATH_TOOL_NAME), - LLSingleton(), - mFinalPathData(), - mTempPathData(), - mPathResult(LLPathingLib::LLPL_NO_PATH), - mCharacterType(kCharacterTypeNone), - mPathEventSignal(), - mIsLeftMouseButtonHeld(false), - mIsMiddleMouseButtonHeld(false), - mIsRightMouseButtonHeld(false) -{ - if (!LLPathingLib::getInstance()) - { - LLPathingLib::initSystem(); - } - - setCharacterWidth(1.0f); - setCharacterType(mCharacterType); -} - -LLPathfindingPathTool::~LLPathfindingPathTool() -{ -} - -BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) -{ - BOOL returnVal = FALSE; - - if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) - { - computeFinalPoints(pX, pY, pMask); - mIsLeftMouseButtonHeld = true; - setMouseCapture(TRUE); - returnVal = TRUE; - } - mIsLeftMouseButtonHeld = true; - - return returnVal; -} - -BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) -{ - BOOL returnVal = FALSE; - - if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) - { - computeFinalPoints(pX, pY, pMask); - setMouseCapture(FALSE); - returnVal = TRUE; - } - mIsLeftMouseButtonHeld = false; - - return returnVal; -} - -BOOL LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) -{ - setMouseCapture(TRUE); - mIsMiddleMouseButtonHeld = true; - gViewerWindow->setCursor(UI_CURSOR_TOOLNO); - - return TRUE; -} - -BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) -{ - if (!mIsLeftMouseButtonHeld && mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) - { - setMouseCapture(FALSE); - } - mIsMiddleMouseButtonHeld = false; - - return TRUE; -} - -BOOL LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) -{ - setMouseCapture(TRUE); - mIsRightMouseButtonHeld = true; - gViewerWindow->setCursor(UI_CURSOR_TOOLNO); - - return TRUE; -} - -BOOL LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) -{ - if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && mIsRightMouseButtonHeld) - { - setMouseCapture(FALSE); - } - mIsRightMouseButtonHeld = false; - - return TRUE; -} - -BOOL LLPathfindingPathTool::handleDoubleClick(S32 pX, S32 pY, MASK pMask) -{ - return TRUE; -} - -BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) -{ - BOOL returnVal = FALSE; - - if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); - computeTempPoints(pX, pY, pMask); - returnVal = TRUE; - } - else - { - clearTemp(); - computeFinalPath(); - } - - return returnVal; -} - -LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const -{ - EPathStatus status = kPathStatusUnknown; - - if (LLPathingLib::getInstance() == NULL) - { - status = kPathStatusNotImplemented; - } - else if (!LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion()) - { - status = kPathStatusNotEnabled; - } - else if (!hasFinalA() && !hasFinalB()) - { - status = kPathStatusChooseStartAndEndPoints; - } - else if (!hasFinalA()) - { - status = kPathStatusChooseStartPoint; - } - else if (!hasFinalB()) - { - status = kPathStatusChooseEndPoint; - } - else if (mPathResult == LLPathingLib::LLPL_PATH_GENERATED_OK) - { - status = kPathStatusHasValidPath; - } - else if (mPathResult == LLPathingLib::LLPL_NO_PATH) - { - status = kPathStatusHasInvalidPath; - } - else - { - status = kPathStatusError; - } - - return status; -} - -F32 LLPathfindingPathTool::getCharacterWidth() const -{ - return mFinalPathData.mCharacterWidth; -} - -void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) -{ - mFinalPathData.mCharacterWidth = pCharacterWidth; - mTempPathData.mCharacterWidth = pCharacterWidth; - computeFinalPath(); -} - -LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const -{ - return mCharacterType; -} - -void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) -{ - mCharacterType = pCharacterType; - - LLPathingLib::LLPLCharacterType characterType; - switch (pCharacterType) - { - case kCharacterTypeNone : - characterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; - break; - case kCharacterTypeA : - characterType = LLPathingLib::LLPL_CHARACTER_TYPE_A; - break; - case kCharacterTypeB : - characterType = LLPathingLib::LLPL_CHARACTER_TYPE_B; - break; - case kCharacterTypeC : - characterType = LLPathingLib::LLPL_CHARACTER_TYPE_C; - break; - case kCharacterTypeD : - characterType = LLPathingLib::LLPL_CHARACTER_TYPE_D; - break; - default : - characterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; - llassert(0); - break; - } - mFinalPathData.mCharacterType = characterType; - mTempPathData.mCharacterType = characterType; - computeFinalPath(); -} - -bool LLPathfindingPathTool::isRenderPath() const -{ - return (hasFinalA() || hasFinalB() || hasTempA() || hasTempB()); -} - -void LLPathfindingPathTool::clearPath() -{ - clearFinal(); - clearTemp(); - computeFinalPath(); -} - -LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEventListener(path_event_callback_t pPathEventCallback) -{ - return mPathEventSignal.connect(pPathEventCallback); -} - -bool LLPathfindingPathTool::isAnyPathToolModKeys(MASK pMask) const -{ - return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); -} - -bool LLPathfindingPathTool::isPointAModKeys(MASK pMask) const -{ - return ((pMask & MASK_CONTROL) != 0); -} - -bool LLPathfindingPathTool::isPointBModKeys(MASK pMask) const -{ - return ((pMask & MASK_SHIFT) != 0); -} - -void LLPathfindingPathTool::getRayPoints(S32 pX, S32 pY, LLVector3 &pRayStart, LLVector3 &pRayEnd) const -{ - LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); - LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); - pRayStart = mousePos; - pRayEnd = mousePos + dv * 150; -} - -void LLPathfindingPathTool::computeFinalPoints(S32 pX, S32 pY, MASK pMask) -{ - LLVector3 rayStart, rayEnd; - getRayPoints(pX, pY, rayStart, rayEnd); - - if (isPointAModKeys(pMask)) - { - setFinalA(rayStart, rayEnd); - } - else if (isPointBModKeys(pMask)) - { - setFinalB(rayStart, rayEnd); - } - computeFinalPath(); -} - -void LLPathfindingPathTool::computeTempPoints(S32 pX, S32 pY, MASK pMask) -{ - LLVector3 rayStart, rayEnd; - getRayPoints(pX, pY, rayStart, rayEnd); - - if (isPointAModKeys(pMask)) - { - setTempA(rayStart, rayEnd); - if (hasFinalB()) - { - setTempB(getFinalBStart(), getFinalBEnd()); - } - } - else if (isPointBModKeys(pMask)) - { - if (hasFinalA()) - { - setTempA(getFinalAStart(), getFinalAEnd()); - } - setTempB(rayStart, rayEnd); - } - computeTempPath(); -} - -void LLPathfindingPathTool::setFinalA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) -{ - mFinalPathData.mStartPointA = pStartPoint; - mFinalPathData.mEndPointA = pEndPoint; - mFinalPathData.mHasPointA = true; -} - -bool LLPathfindingPathTool::hasFinalA() const -{ - return mFinalPathData.mHasPointA; -} - -const LLVector3 &LLPathfindingPathTool::getFinalAStart() const -{ - return mFinalPathData.mStartPointA; -} - -const LLVector3 &LLPathfindingPathTool::getFinalAEnd() const -{ - return mFinalPathData.mEndPointA; -} - -void LLPathfindingPathTool::setTempA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) -{ - mTempPathData.mStartPointA = pStartPoint; - mTempPathData.mEndPointA = pEndPoint; - mTempPathData.mHasPointA = true; -} - -bool LLPathfindingPathTool::hasTempA() const -{ - return mTempPathData.mHasPointA; -} - -void LLPathfindingPathTool::setFinalB(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) -{ - mFinalPathData.mStartPointB = pStartPoint; - mFinalPathData.mEndPointB = pEndPoint; - mFinalPathData.mHasPointB = true; -} - -bool LLPathfindingPathTool::hasFinalB() const -{ - return mFinalPathData.mHasPointB; -} - -const LLVector3 &LLPathfindingPathTool::getFinalBStart() const -{ - return mFinalPathData.mStartPointB; -} - -const LLVector3 &LLPathfindingPathTool::getFinalBEnd() const -{ - return mFinalPathData.mEndPointB; -} - -void LLPathfindingPathTool::setTempB(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) -{ - mTempPathData.mStartPointB = pStartPoint; - mTempPathData.mEndPointB = pEndPoint; - mTempPathData.mHasPointB = true; -} - -bool LLPathfindingPathTool::hasTempB() const -{ - return mTempPathData.mHasPointB; -} - -void LLPathfindingPathTool::clearFinal() -{ - mFinalPathData.mHasPointA = false; - mFinalPathData.mHasPointB = false; -} - -void LLPathfindingPathTool::clearTemp() -{ - mTempPathData.mHasPointA = false; - mTempPathData.mHasPointB = false; -} - -void LLPathfindingPathTool::computeFinalPath() -{ - mPathResult = LLPathingLib::LLPL_NO_PATH; - if (LLPathingLib::getInstance() != NULL) - { - mPathResult = LLPathingLib::getInstance()->generatePath(mFinalPathData); - } - mPathEventSignal(); -} - -void LLPathfindingPathTool::computeTempPath() -{ - mPathResult = LLPathingLib::LLPL_NO_PATH; - if (LLPathingLib::getInstance() != NULL) - { - mPathResult = LLPathingLib::getInstance()->generatePath(mTempPathData); - } - mPathEventSignal(); -} +/** + * @file llpathfindingpathtool.cpp + * @author William Todd Stinson + * @brief XXX + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llpathfindingpathtool.h" +#include "llsingleton.h" +#include "lltool.h" +#include "llviewerwindow.h" +#include "llviewercamera.h" +#include "llpathfindingmanager.h" +#include "llpathinglib.h" + +#include +#include + +#define PATH_TOOL_NAME "PathfindingPathTool" + +LLPathfindingPathTool::LLPathfindingPathTool() + : LLTool(PATH_TOOL_NAME), + LLSingleton(), + mFinalPathData(), + mTempPathData(), + mPathResult(LLPathingLib::LLPL_NO_PATH), + mCharacterType(kCharacterTypeNone), + mPathEventSignal(), + mIsLeftMouseButtonHeld(false), + mIsMiddleMouseButtonHeld(false), + mIsRightMouseButtonHeld(false) +{ + if (!LLPathingLib::getInstance()) + { + LLPathingLib::initSystem(); + } + + setCharacterWidth(1.0f); + setCharacterType(mCharacterType); +} + +LLPathfindingPathTool::~LLPathfindingPathTool() +{ +} + +BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) +{ + BOOL returnVal = FALSE; + + if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) + { + computeFinalPoints(pX, pY, pMask); + mIsLeftMouseButtonHeld = true; + setMouseCapture(TRUE); + returnVal = TRUE; + } + mIsLeftMouseButtonHeld = true; + + return returnVal; +} + +BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) +{ + BOOL returnVal = FALSE; + + if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) + { + computeFinalPoints(pX, pY, pMask); + setMouseCapture(FALSE); + returnVal = TRUE; + } + mIsLeftMouseButtonHeld = false; + + return returnVal; +} + +BOOL LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) +{ + setMouseCapture(TRUE); + mIsMiddleMouseButtonHeld = true; + gViewerWindow->setCursor(UI_CURSOR_TOOLNO); + + return TRUE; +} + +BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) +{ + if (!mIsLeftMouseButtonHeld && mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) + { + setMouseCapture(FALSE); + } + mIsMiddleMouseButtonHeld = false; + + return TRUE; +} + +BOOL LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) +{ + setMouseCapture(TRUE); + mIsRightMouseButtonHeld = true; + gViewerWindow->setCursor(UI_CURSOR_TOOLNO); + + return TRUE; +} + +BOOL LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) +{ + if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && mIsRightMouseButtonHeld) + { + setMouseCapture(FALSE); + } + mIsRightMouseButtonHeld = false; + + return TRUE; +} + +BOOL LLPathfindingPathTool::handleDoubleClick(S32 pX, S32 pY, MASK pMask) +{ + return TRUE; +} + +BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) +{ + BOOL returnVal = FALSE; + + if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); + computeTempPoints(pX, pY, pMask); + returnVal = TRUE; + } + else + { + clearTemp(); + computeFinalPath(); + } + + return returnVal; +} + +LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const +{ + EPathStatus status = kPathStatusUnknown; + + if (LLPathingLib::getInstance() == NULL) + { + status = kPathStatusNotImplemented; + } + else if (!LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion()) + { + status = kPathStatusNotEnabled; + } + else if (!hasFinalA() && !hasFinalB()) + { + status = kPathStatusChooseStartAndEndPoints; + } + else if (!hasFinalA()) + { + status = kPathStatusChooseStartPoint; + } + else if (!hasFinalB()) + { + status = kPathStatusChooseEndPoint; + } + else if (mPathResult == LLPathingLib::LLPL_PATH_GENERATED_OK) + { + status = kPathStatusHasValidPath; + } + else if (mPathResult == LLPathingLib::LLPL_NO_PATH) + { + status = kPathStatusHasInvalidPath; + } + else + { + status = kPathStatusError; + } + + return status; +} + +F32 LLPathfindingPathTool::getCharacterWidth() const +{ + return mFinalPathData.mCharacterWidth; +} + +void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) +{ + mFinalPathData.mCharacterWidth = pCharacterWidth; + mTempPathData.mCharacterWidth = pCharacterWidth; + computeFinalPath(); +} + +LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const +{ + return mCharacterType; +} + +void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) +{ + mCharacterType = pCharacterType; + + LLPathingLib::LLPLCharacterType characterType; + switch (pCharacterType) + { + case kCharacterTypeNone : + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; + break; + case kCharacterTypeA : + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_A; + break; + case kCharacterTypeB : + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_B; + break; + case kCharacterTypeC : + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_C; + break; + case kCharacterTypeD : + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_D; + break; + default : + characterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; + llassert(0); + break; + } + mFinalPathData.mCharacterType = characterType; + mTempPathData.mCharacterType = characterType; + computeFinalPath(); +} + +bool LLPathfindingPathTool::isRenderPath() const +{ + return (hasFinalA() || hasFinalB() || hasTempA() || hasTempB()); +} + +void LLPathfindingPathTool::clearPath() +{ + clearFinal(); + clearTemp(); + computeFinalPath(); +} + +LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEventListener(path_event_callback_t pPathEventCallback) +{ + return mPathEventSignal.connect(pPathEventCallback); +} + +bool LLPathfindingPathTool::isAnyPathToolModKeys(MASK pMask) const +{ + return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); +} + +bool LLPathfindingPathTool::isPointAModKeys(MASK pMask) const +{ + return ((pMask & MASK_CONTROL) != 0); +} + +bool LLPathfindingPathTool::isPointBModKeys(MASK pMask) const +{ + return ((pMask & MASK_SHIFT) != 0); +} + +void LLPathfindingPathTool::getRayPoints(S32 pX, S32 pY, LLVector3 &pRayStart, LLVector3 &pRayEnd) const +{ + LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); + LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); + pRayStart = mousePos; + pRayEnd = mousePos + dv * 150; +} + +void LLPathfindingPathTool::computeFinalPoints(S32 pX, S32 pY, MASK pMask) +{ + LLVector3 rayStart, rayEnd; + getRayPoints(pX, pY, rayStart, rayEnd); + + if (isPointAModKeys(pMask)) + { + setFinalA(rayStart, rayEnd); + } + else if (isPointBModKeys(pMask)) + { + setFinalB(rayStart, rayEnd); + } + computeFinalPath(); +} + +void LLPathfindingPathTool::computeTempPoints(S32 pX, S32 pY, MASK pMask) +{ + LLVector3 rayStart, rayEnd; + getRayPoints(pX, pY, rayStart, rayEnd); + + if (isPointAModKeys(pMask)) + { + setTempA(rayStart, rayEnd); + if (hasFinalB()) + { + setTempB(getFinalBStart(), getFinalBEnd()); + } + } + else if (isPointBModKeys(pMask)) + { + if (hasFinalA()) + { + setTempA(getFinalAStart(), getFinalAEnd()); + } + setTempB(rayStart, rayEnd); + } + computeTempPath(); +} + +void LLPathfindingPathTool::setFinalA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) +{ + mFinalPathData.mStartPointA = pStartPoint; + mFinalPathData.mEndPointA = pEndPoint; + mFinalPathData.mHasPointA = true; +} + +bool LLPathfindingPathTool::hasFinalA() const +{ + return mFinalPathData.mHasPointA; +} + +const LLVector3 &LLPathfindingPathTool::getFinalAStart() const +{ + return mFinalPathData.mStartPointA; +} + +const LLVector3 &LLPathfindingPathTool::getFinalAEnd() const +{ + return mFinalPathData.mEndPointA; +} + +void LLPathfindingPathTool::setTempA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) +{ + mTempPathData.mStartPointA = pStartPoint; + mTempPathData.mEndPointA = pEndPoint; + mTempPathData.mHasPointA = true; +} + +bool LLPathfindingPathTool::hasTempA() const +{ + return mTempPathData.mHasPointA; +} + +void LLPathfindingPathTool::setFinalB(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) +{ + mFinalPathData.mStartPointB = pStartPoint; + mFinalPathData.mEndPointB = pEndPoint; + mFinalPathData.mHasPointB = true; +} + +bool LLPathfindingPathTool::hasFinalB() const +{ + return mFinalPathData.mHasPointB; +} + +const LLVector3 &LLPathfindingPathTool::getFinalBStart() const +{ + return mFinalPathData.mStartPointB; +} + +const LLVector3 &LLPathfindingPathTool::getFinalBEnd() const +{ + return mFinalPathData.mEndPointB; +} + +void LLPathfindingPathTool::setTempB(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint) +{ + mTempPathData.mStartPointB = pStartPoint; + mTempPathData.mEndPointB = pEndPoint; + mTempPathData.mHasPointB = true; +} + +bool LLPathfindingPathTool::hasTempB() const +{ + return mTempPathData.mHasPointB; +} + +void LLPathfindingPathTool::clearFinal() +{ + mFinalPathData.mHasPointA = false; + mFinalPathData.mHasPointB = false; +} + +void LLPathfindingPathTool::clearTemp() +{ + mTempPathData.mHasPointA = false; + mTempPathData.mHasPointB = false; +} + +void LLPathfindingPathTool::computeFinalPath() +{ + mPathResult = LLPathingLib::LLPL_NO_PATH; + if (LLPathingLib::getInstance() != NULL) + { + mPathResult = LLPathingLib::getInstance()->generatePath(mFinalPathData); + } + mPathEventSignal(); +} + +void LLPathfindingPathTool::computeTempPath() +{ + mPathResult = LLPathingLib::LLPL_NO_PATH; + if (LLPathingLib::getInstance() != NULL) + { + mPathResult = LLPathingLib::getInstance()->generatePath(mTempPathData); + } + mPathEventSignal(); +} -- cgit v1.2.3 From 9eec646601d6ce903d41dc305364373dc0a18b74 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 1 May 2012 15:19:39 -0700 Subject: Removing another capability check that was occurring prior to the receipt of the listed capabilities. --- indra/newview/llpathfindingpathtool.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 8825f82f29..1e327a3ba7 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -27,10 +27,13 @@ #include "llviewerprecompiledheaders.h" #include "llpathfindingpathtool.h" + +#include "llagent.h" #include "llsingleton.h" #include "lltool.h" -#include "llviewerwindow.h" #include "llviewercamera.h" +#include "llviewerregion.h" +#include "llviewerwindow.h" #include "llpathfindingmanager.h" #include "llpathinglib.h" @@ -167,6 +170,10 @@ LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const { status = kPathStatusNotImplemented; } + else if ((gAgent.getRegion() != NULL) && !gAgent.getRegion()->capabilitiesReceived()) + { + status = kPathStatusUnknown; + } else if (!LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion()) { status = kPathStatusNotEnabled; -- cgit v1.2.3 From fb7c7043a467d0d6c2b741ca603b6b1c57a52ae9 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 1 Jun 2012 16:50:28 -0700 Subject: PATH-668: Eating the escape key in the pathfinding path tool to avoid certain bad behaviors. --- indra/newview/llpathfindingpathtool.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 1e327a3ba7..bc5a265111 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -162,6 +162,15 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) return returnVal; } +BOOL LLPathfindingPathTool::handleKey(KEY pKey, MASK pMask) +{ + // Eat the escape key or else the camera tool will pick up and reset to default view. This, + // in turn, will cause some other methods to get called. And one of those methods will reset + // the current toolset back to the basic toolset. This means that the pathfinding path toolset + // will no longer be active, but typically with pathfinding path elements on screen. + return (pKey == KEY_ESCAPE); +} + LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const { EPathStatus status = kPathStatusUnknown; -- cgit v1.2.3 From b912c27bf44a45e607adc3b5c94d3fd8a9bbf53e Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 16:40:53 -0700 Subject: PATH-711: Implementing Leo's changes for the pathfinding console. --- indra/newview/llpathfindingpathtool.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index bc5a265111..5567869a1c 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -54,11 +54,6 @@ LLPathfindingPathTool::LLPathfindingPathTool() mIsMiddleMouseButtonHeld(false), mIsRightMouseButtonHeld(false) { - if (!LLPathingLib::getInstance()) - { - LLPathingLib::initSystem(); - } - setCharacterWidth(1.0f); setCharacterType(mCharacterType); } -- cgit v1.2.3 From 11b6e272abf05c5429865aaa1366bd450b8bc218 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 21 Jun 2012 16:39:35 -0700 Subject: PATH-743: Altering the mouse cursor to give more feed back when in path testing mode. --- indra/newview/llpathfindingpathtool.cpp | 49 ++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 5567869a1c..82426920d8 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -66,12 +66,30 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; - if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) + if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) { - computeFinalPoints(pX, pY, pMask); - mIsLeftMouseButtonHeld = true; - setMouseCapture(TRUE); - returnVal = TRUE; + if (isAnyPathToolModKeys(pMask)) + { + if (isPointAModKeys(pMask)) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START); + } + else if (isPointBModKeys(pMask)) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END); + } + computeFinalPoints(pX, pY, pMask); + mIsLeftMouseButtonHeld = true; + setMouseCapture(TRUE); + returnVal = TRUE; + } + else if (!isCameraModKeys(pMask)) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLNO); + mIsLeftMouseButtonHeld = true; + setMouseCapture(TRUE); + returnVal = TRUE; + } } mIsLeftMouseButtonHeld = true; @@ -82,7 +100,7 @@ BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; - if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) + if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) { computeFinalPoints(pX, pY, pMask); setMouseCapture(FALSE); @@ -142,9 +160,21 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) { BOOL returnVal = FALSE; - if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) + if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && !isAnyPathToolModKeys(pMask)) { gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); + } + + if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) + { + if (isPointAModKeys(pMask)) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START); + } + else if (isPointBModKeys(pMask)) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END); + } computeTempPoints(pX, pY, pMask); returnVal = TRUE; } @@ -291,6 +321,11 @@ bool LLPathfindingPathTool::isPointBModKeys(MASK pMask) const return ((pMask & MASK_SHIFT) != 0); } +bool LLPathfindingPathTool::isCameraModKeys(MASK pMask) const +{ + return ((pMask & MASK_ALT) != 0); +} + void LLPathfindingPathTool::getRayPoints(S32 pX, S32 pY, LLVector3 &pRayStart, LLVector3 &pRayEnd) const { LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); -- cgit v1.2.3 From bf1c1947d752e1f4d18d77b3190691d8244bc91f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 25 Jun 2012 14:28:21 -0700 Subject: PATH-743: Updating the cursors for path testing mode to final designs. --- indra/newview/llpathfindingpathtool.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 82426920d8..fde2257777 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -72,11 +72,11 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) { if (isPointAModKeys(pMask)) { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START); + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD); } else if (isPointBModKeys(pMask)) { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END); + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD); } computeFinalPoints(pX, pY, pMask); mIsLeftMouseButtonHeld = true; @@ -169,11 +169,25 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) { if (isPointAModKeys(pMask)) { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START); + if (mIsLeftMouseButtonHeld) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD); + } + else + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START); + } } else if (isPointBModKeys(pMask)) { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END); + if (mIsLeftMouseButtonHeld) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD); + } + else + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END); + } } computeTempPoints(pX, pY, pMask); returnVal = TRUE; -- cgit v1.2.3 From 9b46e116a92ee4d005ae3e1d66a4fbaa270770ec Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 25 Jun 2012 14:44:09 -0700 Subject: PATH-743: Small code refactoring for clean-up. --- indra/newview/llpathfindingpathtool.cpp | 36 ++++++--------------------------- 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index fde2257777..6cf90addab 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -70,14 +70,9 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) { if (isAnyPathToolModKeys(pMask)) { - if (isPointAModKeys(pMask)) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD); - } - else if (isPointBModKeys(pMask)) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD); - } + gViewerWindow->setCursor(isPointAModKeys(pMask) + ? UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD + : UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD); computeFinalPoints(pX, pY, pMask); mIsLeftMouseButtonHeld = true; setMouseCapture(TRUE); @@ -167,28 +162,9 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) { - if (isPointAModKeys(pMask)) - { - if (mIsLeftMouseButtonHeld) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD); - } - else - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_START); - } - } - else if (isPointBModKeys(pMask)) - { - if (mIsLeftMouseButtonHeld) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD); - } - else - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING_PATH_END); - } - } + gViewerWindow->setCursor(isPointAModKeys(pMask) + ? (mIsLeftMouseButtonHeld ? UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD : UI_CURSOR_TOOLPATHFINDING_PATH_START) + : (mIsLeftMouseButtonHeld ? UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD : UI_CURSOR_TOOLPATHFINDING_PATH_END)); computeTempPoints(pX, pY, pMask); returnVal = TRUE; } -- cgit v1.2.3 From 78910cf3016fc55eaf8214640b348df0f8bcdeda Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 26 Jun 2012 18:04:19 -0700 Subject: Updating the header licensing comments. --- indra/newview/llpathfindingpathtool.cpp | 52 +++++++++++++++++---------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 6cf90addab..ac4a2fffb9 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -1,31 +1,33 @@ /** - * @file llpathfindingpathtool.cpp - * @author William Todd Stinson - * @brief XXX - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ +* @file llpathfindingpathtool.cpp +* @brief Implementation of llpathfindingpathtool +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + #include "llviewerprecompiledheaders.h" + #include "llpathfindingpathtool.h" #include "llagent.h" -- cgit v1.2.3 From 685a672b74550ca0dbf8a816257c84c9c44fd34d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 28 Jun 2012 15:37:55 -0700 Subject: Cleaning up new files in preparation for merge into viewer-release. --- indra/newview/llpathfindingpathtool.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index ac4a2fffb9..006755e20b 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -30,17 +30,17 @@ #include "llpathfindingpathtool.h" +#include +#include + #include "llagent.h" +#include "llpathfindingmanager.h" +#include "llpathinglib.h" #include "llsingleton.h" #include "lltool.h" #include "llviewercamera.h" #include "llviewerregion.h" #include "llviewerwindow.h" -#include "llpathfindingmanager.h" -#include "llpathinglib.h" - -#include -#include #define PATH_TOOL_NAME "PathfindingPathTool" -- cgit v1.2.3