From c285f59ce2a05703e3a1232fcaf3ee3aea714b3f Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sun, 18 Feb 2024 12:52:19 +0100 Subject: Replace BOOL with bool in llwindow and dependent classes --- indra/newview/llpathfindingpathtool.cpp | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 3187325101..26880365f2 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -63,9 +63,9 @@ LLPathfindingPathTool::~LLPathfindingPathTool() { } -BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) +bool LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) { - BOOL returnVal = FALSE; + bool returnVal = false; if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) { @@ -77,14 +77,14 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) computeFinalPoints(pX, pY, pMask); mIsLeftMouseButtonHeld = true; setMouseCapture(TRUE); - returnVal = TRUE; + returnVal = true; } else if (!isCameraModKeys(pMask)) { gViewerWindow->setCursor(UI_CURSOR_TOOLNO); mIsLeftMouseButtonHeld = true; setMouseCapture(TRUE); - returnVal = TRUE; + returnVal = true; } } mIsLeftMouseButtonHeld = true; @@ -92,31 +92,31 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) return returnVal; } -BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) +bool LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) { - BOOL returnVal = FALSE; + bool returnVal = false; if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) { computeFinalPoints(pX, pY, pMask); setMouseCapture(FALSE); - returnVal = TRUE; + returnVal = true; } mIsLeftMouseButtonHeld = false; return returnVal; } -BOOL LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) +bool LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) { setMouseCapture(TRUE); mIsMiddleMouseButtonHeld = true; gViewerWindow->setCursor(UI_CURSOR_TOOLNO); - return TRUE; + return true; } -BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) +bool LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) { if (!mIsLeftMouseButtonHeld && mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) { @@ -124,19 +124,19 @@ BOOL LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) } mIsMiddleMouseButtonHeld = false; - return TRUE; + return true; } -BOOL LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) +bool LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) { setMouseCapture(TRUE); mIsRightMouseButtonHeld = true; gViewerWindow->setCursor(UI_CURSOR_TOOLNO); - return TRUE; + return true; } -BOOL LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) +bool LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) { if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && mIsRightMouseButtonHeld) { @@ -144,17 +144,17 @@ BOOL LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) } mIsRightMouseButtonHeld = false; - return TRUE; + return true; } -BOOL LLPathfindingPathTool::handleDoubleClick(S32 pX, S32 pY, MASK pMask) +bool LLPathfindingPathTool::handleDoubleClick(S32 pX, S32 pY, MASK pMask) { - return TRUE; + return true; } -BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) +bool LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) { - BOOL returnVal = FALSE; + bool returnVal = false; if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && !isAnyPathToolModKeys(pMask)) { @@ -167,7 +167,7 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK 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; + returnVal = true; } else { -- cgit v1.2.3 From 60d3dd98a44230c21803c1606552ee098ed9fa7c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Feb 2024 21:05:14 +0100 Subject: Convert remaining BOOL to bool --- indra/newview/llpathfindingpathtool.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 26880365f2..fd5a56b70d 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -76,14 +76,14 @@ bool LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) : UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD); computeFinalPoints(pX, pY, pMask); mIsLeftMouseButtonHeld = true; - setMouseCapture(TRUE); + setMouseCapture(true); returnVal = true; } else if (!isCameraModKeys(pMask)) { gViewerWindow->setCursor(UI_CURSOR_TOOLNO); mIsLeftMouseButtonHeld = true; - setMouseCapture(TRUE); + setMouseCapture(true); returnVal = true; } } @@ -99,7 +99,7 @@ bool LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) { computeFinalPoints(pX, pY, pMask); - setMouseCapture(FALSE); + setMouseCapture(false); returnVal = true; } mIsLeftMouseButtonHeld = false; @@ -109,7 +109,7 @@ bool LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) bool LLPathfindingPathTool::handleMiddleMouseDown(S32 pX, S32 pY, MASK pMask) { - setMouseCapture(TRUE); + setMouseCapture(true); mIsMiddleMouseButtonHeld = true; gViewerWindow->setCursor(UI_CURSOR_TOOLNO); @@ -120,7 +120,7 @@ bool LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) { if (!mIsLeftMouseButtonHeld && mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) { - setMouseCapture(FALSE); + setMouseCapture(false); } mIsMiddleMouseButtonHeld = false; @@ -129,7 +129,7 @@ bool LLPathfindingPathTool::handleMiddleMouseUp(S32 pX, S32 pY, MASK pMask) bool LLPathfindingPathTool::handleRightMouseDown(S32 pX, S32 pY, MASK pMask) { - setMouseCapture(TRUE); + setMouseCapture(true); mIsRightMouseButtonHeld = true; gViewerWindow->setCursor(UI_CURSOR_TOOLNO); @@ -140,7 +140,7 @@ bool LLPathfindingPathTool::handleRightMouseUp(S32 pX, S32 pY, MASK pMask) { if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && mIsRightMouseButtonHeld) { - setMouseCapture(FALSE); + setMouseCapture(false); } mIsRightMouseButtonHeld = false; @@ -178,7 +178,7 @@ bool LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) return returnVal; } -BOOL LLPathfindingPathTool::handleKey(KEY pKey, MASK pMask) +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 -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/newview/llpathfindingpathtool.cpp | 932 ++++++++++++++++---------------- 1 file changed, 466 insertions(+), 466 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index 9d771beceb..a92a8fe138 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -1,466 +1,466 @@ -/** -* @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 -#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" - -#define PATH_TOOL_NAME "PathfindingPathTool" - -LLPathfindingPathTool::LLPathfindingPathTool() - : LLTool(PATH_TOOL_NAME), - mFinalPathData(), - mTempPathData(), - mPathResult(LLPathingLib::LLPL_NO_PATH), - mCharacterType(kCharacterTypeNone), - mPathEventSignal(), - mIsLeftMouseButtonHeld(false), - mIsMiddleMouseButtonHeld(false), - mIsRightMouseButtonHeld(false) -{ - setCharacterWidth(1.0f); - setCharacterType(mCharacterType); -} - -LLPathfindingPathTool::~LLPathfindingPathTool() -{ -} - -bool LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) -{ - bool returnVal = false; - - if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) - { - if (isAnyPathToolModKeys(pMask)) - { - gViewerWindow->setCursor(isPointAModKeys(pMask) - ? UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD - : UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD); - 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; - - return returnVal; -} - -bool LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) -{ - bool returnVal = false; - - if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) - { - 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 (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && !isAnyPathToolModKeys(pMask)) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); - } - - if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) - { - 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; - } - else - { - clearTemp(); - computeFinalPath(); - } - - 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; - - if (LLPathingLib::getInstance() == NULL) - { - status = kPathStatusNotImplemented; - } - else if ((gAgent.getRegion() != NULL) && !gAgent.getRegion()->capabilitiesReceived()) - { - status = kPathStatusUnknown; - } - 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); -} - -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); - 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 +* @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 +#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" + +#define PATH_TOOL_NAME "PathfindingPathTool" + +LLPathfindingPathTool::LLPathfindingPathTool() + : LLTool(PATH_TOOL_NAME), + mFinalPathData(), + mTempPathData(), + mPathResult(LLPathingLib::LLPL_NO_PATH), + mCharacterType(kCharacterTypeNone), + mPathEventSignal(), + mIsLeftMouseButtonHeld(false), + mIsMiddleMouseButtonHeld(false), + mIsRightMouseButtonHeld(false) +{ + setCharacterWidth(1.0f); + setCharacterType(mCharacterType); +} + +LLPathfindingPathTool::~LLPathfindingPathTool() +{ +} + +bool LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) +{ + bool returnVal = false; + + if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) + { + if (isAnyPathToolModKeys(pMask)) + { + gViewerWindow->setCursor(isPointAModKeys(pMask) + ? UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD + : UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD); + 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; + + return returnVal; +} + +bool LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask) +{ + bool returnVal = false; + + if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld) + { + 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 (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && !isAnyPathToolModKeys(pMask)) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); + } + + if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask)) + { + 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; + } + else + { + clearTemp(); + computeFinalPath(); + } + + 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; + + if (LLPathingLib::getInstance() == NULL) + { + status = kPathStatusNotImplemented; + } + else if ((gAgent.getRegion() != NULL) && !gAgent.getRegion()->capabilitiesReceived()) + { + status = kPathStatusUnknown; + } + 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); +} + +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); + 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 c082f6f67a6dcd3437d1f2413932fef8cdf7de07 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 30 May 2024 13:11:50 +0200 Subject: Re-enable compiler warning C4800 (performance warning) --- indra/newview/llpathfindingpathtool.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/llpathfindingpathtool.cpp') diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index a92a8fe138..61791492e7 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -35,9 +35,6 @@ #include "llagent.h" #include "llpathfindingmanager.h" -#include "llpathinglib.h" -#include "llsingleton.h" -#include "lltool.h" #include "llviewercamera.h" #include "llviewerregion.h" #include "llviewerwindow.h" -- cgit v1.2.3