summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorTodd Stinson <stinson@lindenlab.com>2012-04-10 19:02:47 -0700
committerTodd Stinson <stinson@lindenlab.com>2012-04-10 19:02:47 -0700
commitc7df83c77dce0d59a4ac8e3ff65f104431eed117 (patch)
tree7fe13aa893488e2ada9d31fbe3594c85626ea281 /indra/newview
parent1f09812ad23208016f0046ef2d1187f15958a822 (diff)
Refactoring to remove duplicate code.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llpathfindingpathtool.cpp111
-rw-r--r--indra/newview/llpathfindingpathtool.h4
2 files changed, 58 insertions, 57 deletions
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;
diff --git a/indra/newview/llpathfindingpathtool.h b/indra/newview/llpathfindingpathtool.h
index be2b90ee1a..ab1408826e 100644
--- a/indra/newview/llpathfindingpathtool.h
+++ b/indra/newview/llpathfindingpathtool.h
@@ -97,6 +97,10 @@ private:
bool isPointAModKeys(MASK pMask) const;
bool isPointBModKeys(MASK pMask) const;
+ void getRayPoints(S32 pX, S32 pY, LLVector3 &pRayStart, LLVector3 &pRayEnd) const;
+ void computeFinalPoints(S32 pX, S32 pY, MASK pMask);
+ void computeTempPoints(S32 pX, S32 pY, MASK pMask);
+
void setFinalA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint);
bool hasFinalA() const;
const LLVector3 &getFinalAStart() const;