diff options
author | Todd Stinson <stinson@lindenlab.com> | 2012-04-10 18:20:21 -0700 |
---|---|---|
committer | Todd Stinson <stinson@lindenlab.com> | 2012-04-10 18:20:21 -0700 |
commit | ba0e3c3c6485fefbe273b6fa8f9121850166b2cc (patch) | |
tree | 0de97b2d7895f0d2a6309ec5f3f20ce55e7cc086 /indra | |
parent | 76b280a2ad2549a795589fe75328cda71115da97 (diff) |
Adding the display of the temporary start/end path character on hover state.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llpathfindingpathtool.cpp | 160 | ||||
-rw-r--r-- | indra/newview/llpathfindingpathtool.h | 28 |
2 files changed, 134 insertions, 54 deletions
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<LLPathfindingPathTool>(),
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);
}
diff --git a/indra/newview/llpathfindingpathtool.h b/indra/newview/llpathfindingpathtool.h index 2b9b363fec..0ec22d959c 100644 --- a/indra/newview/llpathfindingpathtool.h +++ b/indra/newview/llpathfindingpathtool.h @@ -87,8 +87,27 @@ protected: private:
bool isAnyPathToolModKeys(MASK pMask) const;
- bool isStartPathToolModKeys(MASK pMask) const;
- bool isEndPathToolModKeys(MASK pMask) const;
+ bool isPointAModKeys(MASK pMask) const;
+ bool isPointBModKeys(MASK pMask) const;
+
+ void setFinalA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint);
+ bool hasFinalA() const;
+ const LLVector3 &getFinalAStart() const;
+ const LLVector3 &getFinalAEnd() const;
+
+ void setTempA(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint);
+ bool hasTempA() const;
+
+ void setFinalB(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint);
+ bool hasFinalB() const;
+ const LLVector3 &getFinalBStart() const;
+ const LLVector3 &getFinalBEnd() const;
+
+ void setTempB(const LLVector3 &pStartPoint, const LLVector3 &pEndPoint);
+ bool hasTempB() const;
+
+ void clearFinal();
+ void clearTemp();
void computeFinalPath();
void computeTempPath();
@@ -96,11 +115,6 @@ private: LLPathingLib::PathingPacket mFinalPathData;
LLPathingLib::PathingPacket mTempPathData;
LLPathingLib::LLPLResult mPathResult;
- bool mHasFinalStartPoint;
- bool mHasFinalEndPoint;
- bool mHasTempStartPoint;
- bool mHasTempEndPoint;
- F32 mCharacterWidth;
ECharacterType mCharacterType;
path_event_signal_t mPathEventSignal;
};
|