diff options
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterpathfindinglinksets.cpp | 431 | ||||
-rw-r--r-- | indra/newview/llfloaterpathfindinglinksets.h | 80 | ||||
-rw-r--r-- | indra/newview/llpathfindinglinksets.cpp | 408 | ||||
-rw-r--r-- | indra/newview/llpathfindinglinksets.h | 106 |
5 files changed, 549 insertions, 478 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9a15b65f83..194c7d35bb 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -415,6 +415,7 @@ set(viewer_SOURCE_FILES llparcelselection.cpp llparticipantlist.cpp llpatchvertexarray.cpp + llpathfindinglinksets.cpp llphysicsmotion.cpp llphysicsshapebuilderutil.cpp llplacesinventorybridge.cpp @@ -963,6 +964,7 @@ set(viewer_HEADER_FILES llparcelselection.h llparticipantlist.h llpatchvertexarray.h + llpathfindinglinksets.h llphysicsmotion.h llphysicsshapebuilderutil.h llplacesinventorybridge.h diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index e8f1401095..6c4d958f14 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -45,6 +45,7 @@ #include "llviewerregion.h"
#include "llhttpclient.h"
#include "lluuid.h"
+#include "llpathfindinglinksets.h"
#define XUI_PATH_STATE_WALKABLE 1
#define XUI_PATH_STATE_OBSTACLE 2
@@ -91,382 +92,6 @@ private: };
//---------------------------------------------------------------------------
-// PathfindingLinkset
-//---------------------------------------------------------------------------
-
-const S32 PathfindingLinkset::MIN_WALKABILITY_VALUE(0);
-const S32 PathfindingLinkset::MAX_WALKABILITY_VALUE(100);
-
-PathfindingLinkset::PathfindingLinkset(const std::string &pUUID, const LLSD& pNavMeshItem)
- : mUUID(pUUID),
- mName(),
- mDescription(),
- mLandImpact(0U),
- mLocation(),
- mPathState(kIgnored),
- mIsPhantom(false),
-#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- mIsWalkabilityCoefficientsF32(false),
-#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- mA(MIN_WALKABILITY_VALUE),
- mB(MIN_WALKABILITY_VALUE),
- mC(MIN_WALKABILITY_VALUE),
- mD(MIN_WALKABILITY_VALUE)
-{
- llassert(pNavMeshItem.has("name"));
- llassert(pNavMeshItem.get("name").isString());
- mName = pNavMeshItem.get("name").asString();
-
- llassert(pNavMeshItem.has("description"));
- llassert(pNavMeshItem.get("description").isString());
- mDescription = pNavMeshItem.get("description").asString();
-
- llassert(pNavMeshItem.has("landimpact"));
- llassert(pNavMeshItem.get("landimpact").isInteger());
- llassert(pNavMeshItem.get("landimpact").asInteger() >= 0);
- mLandImpact = pNavMeshItem.get("landimpact").asInteger();
-
- llassert(pNavMeshItem.has("permanent"));
- llassert(pNavMeshItem.get("permanent").isBoolean());
- bool isPermanent = pNavMeshItem.get("permanent").asBoolean();
-
- llassert(pNavMeshItem.has("walkable"));
- llassert(pNavMeshItem.get("walkable").isBoolean());
- bool isWalkable = pNavMeshItem.get("walkable").asBoolean();
-
- mPathState = getPathState(isPermanent, isWalkable);
-
- llassert(pNavMeshItem.has("phantom"));
- llassert(pNavMeshItem.get("phantom").isBoolean());
- mIsPhantom = pNavMeshItem.get("phantom").asBoolean();
-
- llassert(pNavMeshItem.has("A"));
-#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- mIsWalkabilityCoefficientsF32 = pNavMeshItem.get("A").isReal();
- if (mIsWalkabilityCoefficientsF32)
- {
- // Old server-side storage was real
- mA = llround(pNavMeshItem.get("A").asReal() * 100.0f);
-
- llassert(pNavMeshItem.has("B"));
- llassert(pNavMeshItem.get("B").isReal());
- mB = llround(pNavMeshItem.get("B").asReal() * 100.0f);
-
- llassert(pNavMeshItem.has("C"));
- llassert(pNavMeshItem.get("C").isReal());
- mC = llround(pNavMeshItem.get("C").asReal() * 100.0f);
-
- llassert(pNavMeshItem.has("D"));
- llassert(pNavMeshItem.get("D").isReal());
- mD = llround(pNavMeshItem.get("D").asReal() * 100.0f);
- }
- else
- {
- // New server-side storage will be integer
- llassert(pNavMeshItem.get("A").isInteger());
- mA = pNavMeshItem.get("A").asInteger();
- llassert(mA >= MIN_WALKABILITY_VALUE);
- llassert(mA <= MAX_WALKABILITY_VALUE);
-
- llassert(pNavMeshItem.has("B"));
- llassert(pNavMeshItem.get("B").isInteger());
- mB = pNavMeshItem.get("B").asInteger();
- llassert(mB >= MIN_WALKABILITY_VALUE);
- llassert(mB <= MAX_WALKABILITY_VALUE);
-
- llassert(pNavMeshItem.has("C"));
- llassert(pNavMeshItem.get("C").isInteger());
- mC = pNavMeshItem.get("C").asInteger();
- llassert(mC >= MIN_WALKABILITY_VALUE);
- llassert(mC <= MAX_WALKABILITY_VALUE);
-
- llassert(pNavMeshItem.has("D"));
- llassert(pNavMeshItem.get("D").isInteger());
- mD = pNavMeshItem.get("D").asInteger();
- llassert(mD >= MIN_WALKABILITY_VALUE);
- llassert(mD <= MAX_WALKABILITY_VALUE);
- }
-#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- llassert(pNavMeshItem.get("A").isInteger());
- mA = pNavMeshItem.get("A").asInteger();
- llassert(mA >= MIN_WALKABILITY_VALUE);
- llassert(mA <= MAX_WALKABILITY_VALUE);
-
- llassert(pNavMeshItem.has("B"));
- llassert(pNavMeshItem.get("B").isInteger());
- mB = pNavMeshItem.get("B").asInteger();
- llassert(mB >= MIN_WALKABILITY_VALUE);
- llassert(mB <= MAX_WALKABILITY_VALUE);
-
- llassert(pNavMeshItem.has("C"));
- llassert(pNavMeshItem.get("C").isInteger());
- mC = pNavMeshItem.get("C").asInteger();
- llassert(mC >= MIN_WALKABILITY_VALUE);
- llassert(mC <= MAX_WALKABILITY_VALUE);
-
- llassert(pNavMeshItem.has("D"));
- llassert(pNavMeshItem.get("D").isInteger());
- mD = pNavMeshItem.get("D").asInteger();
- llassert(mD >= MIN_WALKABILITY_VALUE);
- llassert(mD <= MAX_WALKABILITY_VALUE);
-#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
-
- llassert(pNavMeshItem.has("position"));
- llassert(pNavMeshItem.get("position").isArray());
- mLocation.setValue(pNavMeshItem.get("position"));
-}
-
-PathfindingLinkset::PathfindingLinkset(const PathfindingLinkset& pOther)
- : mUUID(pOther.mUUID),
- mName(pOther.mName),
- mDescription(pOther.mDescription),
- mLandImpact(pOther.mLandImpact),
- mLocation(pOther.mLocation),
- mPathState(pOther.mPathState),
- mIsPhantom(pOther.mIsPhantom),
-#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- mIsWalkabilityCoefficientsF32(pOther.mIsWalkabilityCoefficientsF32),
-#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- mA(pOther.mA),
- mB(pOther.mB),
- mC(pOther.mC),
- mD(pOther.mD)
-{
-}
-
-PathfindingLinkset::~PathfindingLinkset()
-{
-}
-
-PathfindingLinkset& PathfindingLinkset::operator =(const PathfindingLinkset& pOther)
-{
- mUUID = pOther.mUUID;
- mName = pOther.mName;
- mDescription = pOther.mDescription;
- mLandImpact = pOther.mLandImpact;
- mLocation = pOther.mLocation;
- mPathState = pOther.mPathState;
- mIsPhantom = pOther.mIsPhantom;
-#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- mIsWalkabilityCoefficientsF32 = pOther.mIsWalkabilityCoefficientsF32;
-#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- mA = pOther.mA;
- mB = pOther.mB;
- mC = pOther.mC;
- mD = pOther.mD;
-
- return *this;
-}
-
-const LLUUID& PathfindingLinkset::getUUID() const
-{
- return mUUID;
-}
-
-const std::string& PathfindingLinkset::getName() const
-{
- return mName;
-}
-
-const std::string& PathfindingLinkset::getDescription() const
-{
- return mDescription;
-}
-
-U32 PathfindingLinkset::getLandImpact() const
-{
- return mLandImpact;
-}
-
-const LLVector3& PathfindingLinkset::getPositionAgent() const
-{
- return mLocation;
-}
-
-PathfindingLinkset::EPathState PathfindingLinkset::getPathState() const
-{
- return mPathState;
-}
-
-void PathfindingLinkset::setPathState(EPathState pPathState)
-{
- mPathState = pPathState;
-}
-
-PathfindingLinkset::EPathState PathfindingLinkset::getPathState(bool pIsPermanent, bool pIsWalkable)
-{
- return (pIsPermanent ? (pIsWalkable ? kWalkable : kObstacle) : kIgnored);
-}
-
-BOOL PathfindingLinkset::isPermanent(EPathState pPathState)
-{
- BOOL retVal;
-
- switch (pPathState)
- {
- case kWalkable :
- case kObstacle :
- retVal = true;
- break;
- case kIgnored :
- retVal = false;
- break;
- default :
- retVal = false;
- llassert(0);
- break;
- }
-
- return retVal;
-}
-
-BOOL PathfindingLinkset::isWalkable(EPathState pPathState)
-{
- BOOL retVal;
-
- switch (pPathState)
- {
- case kWalkable :
- retVal = true;
- break;
- case kObstacle :
- case kIgnored :
- retVal = false;
- break;
- default :
- retVal = false;
- llassert(0);
- break;
- }
-
- return retVal;
-}
-
-BOOL PathfindingLinkset::isPhantom() const
-{
- return mIsPhantom;
-}
-
-void PathfindingLinkset::setPhantom(BOOL pIsPhantom)
-{
- mIsPhantom = pIsPhantom;
-}
-
-S32 PathfindingLinkset::getA() const
-{
- return mA;
-}
-
-void PathfindingLinkset::setA(S32 pA)
-{
- mA = pA;
-}
-
-S32 PathfindingLinkset::getB() const
-{
- return mB;
-}
-
-void PathfindingLinkset::setB(S32 pB)
-{
- mB = pB;
-}
-
-S32 PathfindingLinkset::getC() const
-{
- return mC;
-}
-
-void PathfindingLinkset::setC(S32 pC)
-{
- mC = pC;
-}
-
-S32 PathfindingLinkset::getD() const
-{
- return mD;
-}
-
-void PathfindingLinkset::setD(S32 pD)
-{
- mD = pD;
-}
-
-LLSD PathfindingLinkset::getAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const
-{
- LLSD itemData;
-
- if (mPathState != pPathState)
- {
- itemData["permanent"] = static_cast<bool>(PathfindingLinkset::isPermanent(pPathState));
- itemData["walkable"] = static_cast<bool>(PathfindingLinkset::isWalkable(pPathState));
- }
-#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- if (mIsWalkabilityCoefficientsF32)
- {
- if (mA != pA)
- {
- itemData["A"] = llclamp(static_cast<F32>(pA) / 100.0f, 0.0f, 1.0f);
- }
- if (mB != pB)
- {
- itemData["B"] = llclamp(static_cast<F32>(pB) / 100.0f, 0.0f, 1.0f);
- }
- if (mC != pC)
- {
- itemData["C"] = llclamp(static_cast<F32>(pC) / 100.0f, 0.0f, 1.0f);
- }
- if (mD != pD)
- {
- itemData["D"] = llclamp(static_cast<F32>(pD) / 100.0f, 0.0f, 1.0f);
- }
- }
- else
- {
- if (mA != pA)
- {
- itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
- }
- if (mB != pB)
- {
- itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
- }
- if (mC != pC)
- {
- itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
- }
- if (mD != pD)
- {
- itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
- }
- }
-#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- if (mA != pA)
- {
- itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
- }
- if (mB != pB)
- {
- itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
- }
- if (mC != pC)
- {
- itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
- }
- if (mD != pD)
- {
- itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
- }
-#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- if (mIsPhantom != pIsPhantom)
- {
- itemData["phantom"] = static_cast<bool>(pIsPhantom);
- }
-
- return itemData;
-}
-
-//---------------------------------------------------------------------------
// FilterString
//---------------------------------------------------------------------------
@@ -598,9 +223,9 @@ void PathfindingLinksets::setNavMeshData(const LLSD& pNavMeshData) {
const std::string& uuid(navMeshDataIter->first);
const LLSD& linksetData = navMeshDataIter->second;
- PathfindingLinkset linkset(uuid, linksetData);
+ LLPathfindingLinkset linkset(uuid, linksetData);
- mAllLinksets.insert(std::pair<std::string, PathfindingLinkset>(uuid, linkset));
+ mAllLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
}
mIsFiltersDirty = true;
@@ -613,12 +238,12 @@ void PathfindingLinksets::updateNavMeshData(const LLSD& pNavMeshData) {
const std::string& uuid(navMeshDataIter->first);
const LLSD& linksetData = navMeshDataIter->second;
- PathfindingLinkset linkset(uuid, linksetData);
+ LLPathfindingLinkset linkset(uuid, linksetData);
PathfindingLinksetMap::iterator linksetIter = mAllLinksets.find(uuid);
if (linksetIter == mAllLinksets.end())
{
- mAllLinksets.insert(std::pair<std::string, PathfindingLinkset>(uuid, linkset));
+ mAllLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
}
else
{
@@ -730,21 +355,21 @@ void PathfindingLinksets::applyFilters() linksetIter != mAllLinksets.end(); ++linksetIter)
{
const std::string& uuid(linksetIter->first);
- const PathfindingLinkset& linkset(linksetIter->second);
+ const LLPathfindingLinkset& linkset(linksetIter->second);
if (doesMatchFilters(linkset))
{
- mFilteredLinksets.insert(std::pair<std::string, PathfindingLinkset>(uuid, linkset));
+ mFilteredLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
}
}
mIsFiltersDirty = false;
}
-BOOL PathfindingLinksets::doesMatchFilters(const PathfindingLinkset& pLinkset) const
+BOOL PathfindingLinksets::doesMatchFilters(const LLPathfindingLinkset& pLinkset) const
{
- return (((mIsWalkableFilter && (pLinkset.getPathState() == PathfindingLinkset::kWalkable)) ||
- (mIsObstacleFilter && (pLinkset.getPathState() == PathfindingLinkset::kObstacle)) ||
- (mIsIgnoredFilter && (pLinkset.getPathState() == PathfindingLinkset::kIgnored))) &&
+ return (((mIsWalkableFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kWalkable)) ||
+ (mIsObstacleFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kObstacle)) ||
+ (mIsIgnoredFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kIgnored))) &&
(!mNameFilter.isActive() || mNameFilter.doesMatch(pLinkset.getName())) &&
(!mDescriptionFilter.isActive() || mDescriptionFilter.doesMatch(pLinkset.getDescription())));
}
@@ -1109,7 +734,7 @@ void LLFloaterPathfindingLinksets::updateLinksetsList() for (PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetMap.begin();
linksetIter != linksetMap.end(); ++linksetIter)
{
- const PathfindingLinkset& linkset(linksetIter->second);
+ const LLPathfindingLinkset& linkset(linksetIter->second);
LLSD columns;
@@ -1132,13 +757,13 @@ void LLFloaterPathfindingLinksets::updateLinksetsList() columns[4]["column"] = "path_state";
switch (linkset.getPathState())
{
- case PathfindingLinkset::kWalkable :
+ case LLPathfindingLinkset::kWalkable :
columns[4]["value"] = getString("linkset_path_state_walkable");
break;
- case PathfindingLinkset::kObstacle :
+ case LLPathfindingLinkset::kObstacle :
columns[4]["value"] = getString("linkset_path_state_obstacle");
break;
- case PathfindingLinkset::kIgnored :
+ case LLPathfindingLinkset::kIgnored :
columns[4]["value"] = getString("linkset_path_state_ignored");
break;
default :
@@ -1282,7 +907,7 @@ void LLFloaterPathfindingLinksets::updateEditFields() const PathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(firstItem->getUUID().asString());
- const PathfindingLinkset &linkset(linksetIter->second);
+ const LLPathfindingLinkset &linkset(linksetIter->second);
setPathState(linkset.getPathState());
mEditA->setValue(LLSD(linkset.getA()));
@@ -1300,7 +925,7 @@ void LLFloaterPathfindingLinksets::applyEditFields() std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected();
if (!selectedItems.empty())
{
- PathfindingLinkset::EPathState pathState = getPathState();
+ LLPathfindingLinkset::EPathState pathState = getPathState();
const std::string &aString = mEditA->getText();
const std::string &bString = mEditB->getText();
const std::string &cString = mEditC->getText();
@@ -1321,7 +946,7 @@ void LLFloaterPathfindingLinksets::applyEditFields() LLUUID uuid = listItem->getUUID();
const PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString());
- const PathfindingLinkset &linkset = linksetIter->second;
+ const LLPathfindingLinkset &linkset = linksetIter->second;
LLSD itemData = linkset.getAlteredFields(pathState, aValue, bValue, cValue, dValue, isPhantom);
@@ -1361,23 +986,23 @@ void LLFloaterPathfindingLinksets::setEnableEditFields(BOOL pEnabled) mApplyEdits->setEnabled(pEnabled);
}
-PathfindingLinkset::EPathState LLFloaterPathfindingLinksets::getPathState() const
+LLPathfindingLinkset::EPathState LLFloaterPathfindingLinksets::getPathState() const
{
- PathfindingLinkset::EPathState pathState;
+ LLPathfindingLinkset::EPathState pathState;
switch (mEditPathState->getValue().asInteger())
{
case XUI_PATH_STATE_WALKABLE :
- pathState = PathfindingLinkset::kWalkable;
+ pathState = LLPathfindingLinkset::kWalkable;
break;
case XUI_PATH_STATE_OBSTACLE :
- pathState = PathfindingLinkset::kObstacle;
+ pathState = LLPathfindingLinkset::kObstacle;
break;
case XUI_PATH_STATE_IGNORED :
- pathState = PathfindingLinkset::kIgnored;
+ pathState = LLPathfindingLinkset::kIgnored;
break;
default :
- pathState = PathfindingLinkset::kIgnored;
+ pathState = LLPathfindingLinkset::kIgnored;
llassert(0);
break;
}
@@ -1385,19 +1010,19 @@ PathfindingLinkset::EPathState LLFloaterPathfindingLinksets::getPathState() cons return pathState;
}
-void LLFloaterPathfindingLinksets::setPathState(PathfindingLinkset::EPathState pPathState)
+void LLFloaterPathfindingLinksets::setPathState(LLPathfindingLinkset::EPathState pPathState)
{
LLSD radioGroupValue;
switch (pPathState)
{
- case PathfindingLinkset::kWalkable :
+ case LLPathfindingLinkset::kWalkable :
radioGroupValue = XUI_PATH_STATE_WALKABLE;
break;
- case PathfindingLinkset::kObstacle :
+ case LLPathfindingLinkset::kObstacle :
radioGroupValue = XUI_PATH_STATE_OBSTACLE;
break;
- case PathfindingLinkset::kIgnored :
+ case LLPathfindingLinkset::kIgnored :
radioGroupValue = XUI_PATH_STATE_IGNORED;
break;
default :
diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h index 976eaa355f..739e52ccef 100644 --- a/indra/newview/llfloaterpathfindinglinksets.h +++ b/indra/newview/llfloaterpathfindinglinksets.h @@ -32,10 +32,7 @@ #include "v3math.h"
#include "llfloater.h"
#include "lluuid.h"
-
-// This is a reminder to remove the code regarding the changing of the data type for the
-// walkability coefficients from F32 to S32 representing the percentage from 0-100.
-#define XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+#include "llpathfindinglinksets.h"
class LLTextBase;
class LLScrollListCtrl;
@@ -44,73 +41,6 @@ class LLCheckBoxCtrl; class LLRadioGroup;
class LLButton;
-class PathfindingLinkset
-{
-public:
- typedef enum
- {
- kWalkable,
- kObstacle,
- kIgnored
- } EPathState;
-
- PathfindingLinkset(const std::string &pUUID, const LLSD &pNavMeshItem);
- PathfindingLinkset(const PathfindingLinkset& pOther);
- virtual ~PathfindingLinkset();
-
- PathfindingLinkset& operator = (const PathfindingLinkset& pOther);
-
- const LLUUID& getUUID() const;
- const std::string& getName() const;
- const std::string& getDescription() const;
- U32 getLandImpact() const;
- const LLVector3& getPositionAgent() const;
-
- EPathState getPathState() const;
- void setPathState(EPathState pPathState);
- static EPathState getPathState(bool pIsPermanent, bool pIsWalkable);
- static BOOL isPermanent(EPathState pPathState);
- static BOOL isWalkable(EPathState pPathState);
-
- BOOL isPhantom() const;
- void setPhantom(BOOL pIsPhantom);
-
- S32 getA() const;
- void setA(S32 pA);
-
- S32 getB() const;
- void setB(S32 pB);
-
- S32 getC() const;
- void setC(S32 pC);
-
- S32 getD() const;
- void setD(S32 pD);
-
- LLSD getAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const;
-
-protected:
-
-private:
- static const S32 MIN_WALKABILITY_VALUE;
- static const S32 MAX_WALKABILITY_VALUE;
-
- LLUUID mUUID;
- std::string mName;
- std::string mDescription;
- U32 mLandImpact;
- LLVector3 mLocation;
- EPathState mPathState;
- BOOL mIsPhantom;
-#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- BOOL mIsWalkabilityCoefficientsF32;
-#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
- S32 mA;
- S32 mB;
- S32 mC;
- S32 mD;
-};
-
class FilterString
{
public:
@@ -136,7 +66,7 @@ private: class PathfindingLinksets
{
public:
- typedef std::map<std::string, PathfindingLinkset> PathfindingLinksetMap;
+ typedef std::map<std::string, LLPathfindingLinkset> PathfindingLinksetMap;
PathfindingLinksets();
PathfindingLinksets(const LLSD& pNavMeshData);
@@ -177,7 +107,7 @@ private: BOOL mIsIgnoredFilter;
void applyFilters();
- BOOL doesMatchFilters(const PathfindingLinkset& pLinkset) const;
+ BOOL doesMatchFilters(const LLPathfindingLinkset& pLinkset) const;
};
class LLFloaterPathfindingLinksets
@@ -277,8 +207,8 @@ private: void applyEditFields();
void setEnableEditFields(BOOL pEnabled);
- PathfindingLinkset::EPathState getPathState() const;
- void setPathState(PathfindingLinkset::EPathState pPathState);
+ LLPathfindingLinkset::EPathState getPathState() const;
+ void setPathState(LLPathfindingLinkset::EPathState pPathState);
};
#endif // LL_LLFLOATERPATHFINDINGLINKSETS_H
diff --git a/indra/newview/llpathfindinglinksets.cpp b/indra/newview/llpathfindinglinksets.cpp new file mode 100644 index 0000000000..bc898e8eb7 --- /dev/null +++ b/indra/newview/llpathfindinglinksets.cpp @@ -0,0 +1,408 @@ +/**
+ * @file llpathfindinglinksets.cpp
+ * @author William Todd Stinson
+ * @brief Definition of a pathfinding linkset that contains various properties required for havok pathfinding.
+ *
+ * $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 "llpathfindinglinksets.h"
+#include "llsd.h"
+#include "v3math.h"
+#include "lluuid.h"
+
+//---------------------------------------------------------------------------
+// LLPathfindingLinkset
+//---------------------------------------------------------------------------
+
+const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0);
+const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100);
+
+LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pNavMeshItem)
+ : mUUID(pUUID),
+ mName(),
+ mDescription(),
+ mLandImpact(0U),
+ mLocation(),
+ mPathState(kIgnored),
+ mIsPhantom(false),
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mIsWalkabilityCoefficientsF32(false),
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mA(MIN_WALKABILITY_VALUE),
+ mB(MIN_WALKABILITY_VALUE),
+ mC(MIN_WALKABILITY_VALUE),
+ mD(MIN_WALKABILITY_VALUE)
+{
+ llassert(pNavMeshItem.has("name"));
+ llassert(pNavMeshItem.get("name").isString());
+ mName = pNavMeshItem.get("name").asString();
+
+ llassert(pNavMeshItem.has("description"));
+ llassert(pNavMeshItem.get("description").isString());
+ mDescription = pNavMeshItem.get("description").asString();
+
+ llassert(pNavMeshItem.has("landimpact"));
+ llassert(pNavMeshItem.get("landimpact").isInteger());
+ llassert(pNavMeshItem.get("landimpact").asInteger() >= 0);
+ mLandImpact = pNavMeshItem.get("landimpact").asInteger();
+
+ llassert(pNavMeshItem.has("permanent"));
+ llassert(pNavMeshItem.get("permanent").isBoolean());
+ bool isPermanent = pNavMeshItem.get("permanent").asBoolean();
+
+ llassert(pNavMeshItem.has("walkable"));
+ llassert(pNavMeshItem.get("walkable").isBoolean());
+ bool isWalkable = pNavMeshItem.get("walkable").asBoolean();
+
+ mPathState = getPathState(isPermanent, isWalkable);
+
+ llassert(pNavMeshItem.has("phantom"));
+ llassert(pNavMeshItem.get("phantom").isBoolean());
+ mIsPhantom = pNavMeshItem.get("phantom").asBoolean();
+
+ llassert(pNavMeshItem.has("A"));
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mIsWalkabilityCoefficientsF32 = pNavMeshItem.get("A").isReal();
+ if (mIsWalkabilityCoefficientsF32)
+ {
+ // Old server-side storage was real
+ mA = llround(pNavMeshItem.get("A").asReal() * 100.0f);
+
+ llassert(pNavMeshItem.has("B"));
+ llassert(pNavMeshItem.get("B").isReal());
+ mB = llround(pNavMeshItem.get("B").asReal() * 100.0f);
+
+ llassert(pNavMeshItem.has("C"));
+ llassert(pNavMeshItem.get("C").isReal());
+ mC = llround(pNavMeshItem.get("C").asReal() * 100.0f);
+
+ llassert(pNavMeshItem.has("D"));
+ llassert(pNavMeshItem.get("D").isReal());
+ mD = llround(pNavMeshItem.get("D").asReal() * 100.0f);
+ }
+ else
+ {
+ // New server-side storage will be integer
+ llassert(pNavMeshItem.get("A").isInteger());
+ mA = pNavMeshItem.get("A").asInteger();
+ llassert(mA >= MIN_WALKABILITY_VALUE);
+ llassert(mA <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("B"));
+ llassert(pNavMeshItem.get("B").isInteger());
+ mB = pNavMeshItem.get("B").asInteger();
+ llassert(mB >= MIN_WALKABILITY_VALUE);
+ llassert(mB <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("C"));
+ llassert(pNavMeshItem.get("C").isInteger());
+ mC = pNavMeshItem.get("C").asInteger();
+ llassert(mC >= MIN_WALKABILITY_VALUE);
+ llassert(mC <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("D"));
+ llassert(pNavMeshItem.get("D").isInteger());
+ mD = pNavMeshItem.get("D").asInteger();
+ llassert(mD >= MIN_WALKABILITY_VALUE);
+ llassert(mD <= MAX_WALKABILITY_VALUE);
+ }
+#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ llassert(pNavMeshItem.get("A").isInteger());
+ mA = pNavMeshItem.get("A").asInteger();
+ llassert(mA >= MIN_WALKABILITY_VALUE);
+ llassert(mA <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("B"));
+ llassert(pNavMeshItem.get("B").isInteger());
+ mB = pNavMeshItem.get("B").asInteger();
+ llassert(mB >= MIN_WALKABILITY_VALUE);
+ llassert(mB <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("C"));
+ llassert(pNavMeshItem.get("C").isInteger());
+ mC = pNavMeshItem.get("C").asInteger();
+ llassert(mC >= MIN_WALKABILITY_VALUE);
+ llassert(mC <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("D"));
+ llassert(pNavMeshItem.get("D").isInteger());
+ mD = pNavMeshItem.get("D").asInteger();
+ llassert(mD >= MIN_WALKABILITY_VALUE);
+ llassert(mD <= MAX_WALKABILITY_VALUE);
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+
+ llassert(pNavMeshItem.has("position"));
+ llassert(pNavMeshItem.get("position").isArray());
+ mLocation.setValue(pNavMeshItem.get("position"));
+}
+
+LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther)
+ : mUUID(pOther.mUUID),
+ mName(pOther.mName),
+ mDescription(pOther.mDescription),
+ mLandImpact(pOther.mLandImpact),
+ mLocation(pOther.mLocation),
+ mPathState(pOther.mPathState),
+ mIsPhantom(pOther.mIsPhantom),
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mIsWalkabilityCoefficientsF32(pOther.mIsWalkabilityCoefficientsF32),
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mA(pOther.mA),
+ mB(pOther.mB),
+ mC(pOther.mC),
+ mD(pOther.mD)
+{
+}
+
+LLPathfindingLinkset::~LLPathfindingLinkset()
+{
+}
+
+LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkset& pOther)
+{
+ mUUID = pOther.mUUID;
+ mName = pOther.mName;
+ mDescription = pOther.mDescription;
+ mLandImpact = pOther.mLandImpact;
+ mLocation = pOther.mLocation;
+ mPathState = pOther.mPathState;
+ mIsPhantom = pOther.mIsPhantom;
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mIsWalkabilityCoefficientsF32 = pOther.mIsWalkabilityCoefficientsF32;
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mA = pOther.mA;
+ mB = pOther.mB;
+ mC = pOther.mC;
+ mD = pOther.mD;
+
+ return *this;
+}
+
+const LLUUID& LLPathfindingLinkset::getUUID() const
+{
+ return mUUID;
+}
+
+const std::string& LLPathfindingLinkset::getName() const
+{
+ return mName;
+}
+
+const std::string& LLPathfindingLinkset::getDescription() const
+{
+ return mDescription;
+}
+
+U32 LLPathfindingLinkset::getLandImpact() const
+{
+ return mLandImpact;
+}
+
+const LLVector3& LLPathfindingLinkset::getPositionAgent() const
+{
+ return mLocation;
+}
+
+LLPathfindingLinkset::EPathState LLPathfindingLinkset::getPathState() const
+{
+ return mPathState;
+}
+
+void LLPathfindingLinkset::setPathState(EPathState pPathState)
+{
+ mPathState = pPathState;
+}
+
+LLPathfindingLinkset::EPathState LLPathfindingLinkset::getPathState(bool pIsPermanent, bool pIsWalkable)
+{
+ return (pIsPermanent ? (pIsWalkable ? kWalkable : kObstacle) : kIgnored);
+}
+
+BOOL LLPathfindingLinkset::isPermanent(EPathState pPathState)
+{
+ BOOL retVal;
+
+ switch (pPathState)
+ {
+ case kWalkable :
+ case kObstacle :
+ retVal = true;
+ break;
+ case kIgnored :
+ retVal = false;
+ break;
+ default :
+ retVal = false;
+ llassert(0);
+ break;
+ }
+
+ return retVal;
+}
+
+BOOL LLPathfindingLinkset::isWalkable(EPathState pPathState)
+{
+ BOOL retVal;
+
+ switch (pPathState)
+ {
+ case kWalkable :
+ retVal = true;
+ break;
+ case kObstacle :
+ case kIgnored :
+ retVal = false;
+ break;
+ default :
+ retVal = false;
+ llassert(0);
+ break;
+ }
+
+ return retVal;
+}
+
+BOOL LLPathfindingLinkset::isPhantom() const
+{
+ return mIsPhantom;
+}
+
+void LLPathfindingLinkset::setPhantom(BOOL pIsPhantom)
+{
+ mIsPhantom = pIsPhantom;
+}
+
+S32 LLPathfindingLinkset::getA() const
+{
+ return mA;
+}
+
+void LLPathfindingLinkset::setA(S32 pA)
+{
+ mA = pA;
+}
+
+S32 LLPathfindingLinkset::getB() const
+{
+ return mB;
+}
+
+void LLPathfindingLinkset::setB(S32 pB)
+{
+ mB = pB;
+}
+
+S32 LLPathfindingLinkset::getC() const
+{
+ return mC;
+}
+
+void LLPathfindingLinkset::setC(S32 pC)
+{
+ mC = pC;
+}
+
+S32 LLPathfindingLinkset::getD() const
+{
+ return mD;
+}
+
+void LLPathfindingLinkset::setD(S32 pD)
+{
+ mD = pD;
+}
+
+LLSD LLPathfindingLinkset::getAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const
+{
+ LLSD itemData;
+
+ if (mPathState != pPathState)
+ {
+ itemData["permanent"] = static_cast<bool>(LLPathfindingLinkset::isPermanent(pPathState));
+ itemData["walkable"] = static_cast<bool>(LLPathfindingLinkset::isWalkable(pPathState));
+ }
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ if (mIsWalkabilityCoefficientsF32)
+ {
+ if (mA != pA)
+ {
+ itemData["A"] = llclamp(static_cast<F32>(pA) / 100.0f, 0.0f, 1.0f);
+ }
+ if (mB != pB)
+ {
+ itemData["B"] = llclamp(static_cast<F32>(pB) / 100.0f, 0.0f, 1.0f);
+ }
+ if (mC != pC)
+ {
+ itemData["C"] = llclamp(static_cast<F32>(pC) / 100.0f, 0.0f, 1.0f);
+ }
+ if (mD != pD)
+ {
+ itemData["D"] = llclamp(static_cast<F32>(pD) / 100.0f, 0.0f, 1.0f);
+ }
+ }
+ else
+ {
+ if (mA != pA)
+ {
+ itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mB != pB)
+ {
+ itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mC != pC)
+ {
+ itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mD != pD)
+ {
+ itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ }
+#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ if (mA != pA)
+ {
+ itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mB != pB)
+ {
+ itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mC != pC)
+ {
+ itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mD != pD)
+ {
+ itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ if (mIsPhantom != pIsPhantom)
+ {
+ itemData["phantom"] = static_cast<bool>(pIsPhantom);
+ }
+
+ return itemData;
+}
diff --git a/indra/newview/llpathfindinglinksets.h b/indra/newview/llpathfindinglinksets.h new file mode 100644 index 0000000000..be909677b6 --- /dev/null +++ b/indra/newview/llpathfindinglinksets.h @@ -0,0 +1,106 @@ +/**
+ * @file llpathfindinglinksets.h
+ * @author William Todd Stinson
+ * @brief Definition of a pathfinding linkset that contains various properties required for havok pathfinding.
+ *
+ * $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$
+ */
+
+#ifndef LL_LLPATHFINDINGLINKSETS_H
+#define LL_LLPATHFINDINGLINKSETS_H
+
+#include "llsd.h"
+#include "v3math.h"
+#include "lluuid.h"
+
+// This is a reminder to remove the code regarding the changing of the data type for the
+// walkability coefficients from F32 to S32 representing the percentage from 0-100.
+#define XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+
+class LLPathfindingLinkset
+{
+public:
+ typedef enum
+ {
+ kWalkable,
+ kObstacle,
+ kIgnored
+ } EPathState;
+
+ LLPathfindingLinkset(const std::string &pUUID, const LLSD &pNavMeshItem);
+ LLPathfindingLinkset(const LLPathfindingLinkset& pOther);
+ virtual ~LLPathfindingLinkset();
+
+ LLPathfindingLinkset& operator = (const LLPathfindingLinkset& pOther);
+
+ const LLUUID& getUUID() const;
+ const std::string& getName() const;
+ const std::string& getDescription() const;
+ U32 getLandImpact() const;
+ const LLVector3& getPositionAgent() const;
+
+ EPathState getPathState() const;
+ void setPathState(EPathState pPathState);
+ static EPathState getPathState(bool pIsPermanent, bool pIsWalkable);
+ static BOOL isPermanent(EPathState pPathState);
+ static BOOL isWalkable(EPathState pPathState);
+
+ BOOL isPhantom() const;
+ void setPhantom(BOOL pIsPhantom);
+
+ S32 getA() const;
+ void setA(S32 pA);
+
+ S32 getB() const;
+ void setB(S32 pB);
+
+ S32 getC() const;
+ void setC(S32 pC);
+
+ S32 getD() const;
+ void setD(S32 pD);
+
+ LLSD getAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const;
+
+protected:
+
+private:
+ static const S32 MIN_WALKABILITY_VALUE;
+ static const S32 MAX_WALKABILITY_VALUE;
+
+ LLUUID mUUID;
+ std::string mName;
+ std::string mDescription;
+ U32 mLandImpact;
+ LLVector3 mLocation;
+ EPathState mPathState;
+ BOOL mIsPhantom;
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ BOOL mIsWalkabilityCoefficientsF32;
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ S32 mA;
+ S32 mB;
+ S32 mC;
+ S32 mD;
+};
+
+#endif // LL_LLFLOATERPATHFINDINGLINKSETS_H
|