summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterpathfindinglinksets.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterpathfindinglinksets.cpp')
-rw-r--r--indra/newview/llfloaterpathfindinglinksets.cpp795
1 files changed, 80 insertions, 715 deletions
diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp
index e8f1401095..4d3581fc60 100644
--- a/indra/newview/llfloaterpathfindinglinksets.cpp
+++ b/indra/newview/llfloaterpathfindinglinksets.cpp
@@ -32,7 +32,7 @@
#include "v3math.h"
#include "lltextvalidate.h"
#include "llagent.h"
-#include "llfloater.h"
+#include "llhandle.h"
#include "llfloaterreg.h"
#include "lltextbase.h"
#include "lllineeditor.h"
@@ -45,6 +45,8 @@
#include "llviewerregion.h"
#include "llhttpclient.h"
#include "lluuid.h"
+#include "llpathfindinglinkset.h"
+#include "llfilteredpathfindinglinksets.h"
#define XUI_PATH_STATE_WALKABLE 1
#define XUI_PATH_STATE_OBSTACLE 2
@@ -57,7 +59,8 @@
class NavMeshDataGetResponder : public LLHTTPClient::Responder
{
public:
- NavMeshDataGetResponder(const std::string& pNavMeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater);
+ NavMeshDataGetResponder(const std::string& pNavMeshDataGetURL,
+ const LLHandle<LLFloaterPathfindingLinksets> &pLinksetsHandle);
virtual ~NavMeshDataGetResponder();
virtual void result(const LLSD& pContent);
@@ -66,8 +69,8 @@ public:
private:
NavMeshDataGetResponder(const NavMeshDataGetResponder& pOther);
- std::string mNavMeshDataGetURL;
- LLFloaterPathfindingLinksets *mLinksetsFloater;
+ std::string mNavMeshDataGetURL;
+ LLHandle<LLFloaterPathfindingLinksets> mLinksetsFloaterHandle;
};
//---------------------------------------------------------------------------
@@ -77,7 +80,8 @@ private:
class NavMeshDataPutResponder : public LLHTTPClient::Responder
{
public:
- NavMeshDataPutResponder(const std::string& pNavMeshDataPutURL, LLFloaterPathfindingLinksets *pLinksetsFloater);
+ NavMeshDataPutResponder(const std::string& pNavMeshDataPutURL,
+ const LLHandle<LLFloaterPathfindingLinksets> &pLinksetsHandle);
virtual ~NavMeshDataPutResponder();
virtual void result(const LLSD& pContent);
@@ -86,670 +90,11 @@ public:
private:
NavMeshDataPutResponder(const NavMeshDataPutResponder& pOther);
- std::string mNavMeshDataPutURL;
- LLFloaterPathfindingLinksets *mLinksetsFloater;
+ std::string mNavMeshDataPutURL;
+ LLHandle<LLFloaterPathfindingLinksets> mLinksetsFloaterHandle;
};
//---------------------------------------------------------------------------
-// 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
-//---------------------------------------------------------------------------
-
-FilterString::FilterString()
- : mFilter(),
- mUpperFilter()
-{
-}
-
-FilterString::FilterString(const std::string& pFilter)
- : mFilter(pFilter),
- mUpperFilter()
-{
- LLStringUtil::trim(mFilter);
- mUpperFilter = mFilter;
- if (!mUpperFilter.empty())
- {
- LLStringUtil::toUpper(mUpperFilter);
- }
-}
-
-FilterString::FilterString(const FilterString& pOther)
- : mFilter(pOther.mFilter),
- mUpperFilter(pOther.mUpperFilter)
-{
-}
-
-FilterString::~FilterString()
-{
-}
-
-const std::string& FilterString::get() const
-{
- return mFilter;
-}
-
-bool FilterString::set(const std::string& pFilter)
-{
- std::string newFilter(pFilter);
- LLStringUtil::trim(newFilter);
- bool didFilterChange = (mFilter.compare(newFilter) != 0);
- if (didFilterChange)
- {
- mFilter = newFilter;
- mUpperFilter = newFilter;
- LLStringUtil::toUpper(mUpperFilter);
- }
-
- return didFilterChange;
-}
-
-void FilterString::clear()
-{
- mFilter.clear();
- mUpperFilter.clear();
-}
-
-bool FilterString::isActive() const
-{
- return !mFilter.empty();
-}
-
-bool FilterString::doesMatch(const std::string& pTestString) const
-{
- bool doesMatch = true;
-
- if (isActive())
- {
- std::string upperTestString(pTestString);
- LLStringUtil::toUpper(upperTestString);
- doesMatch = (upperTestString.find(mUpperFilter) != std::string::npos);
- }
-
- return doesMatch;
-}
-
-//---------------------------------------------------------------------------
-// PathfindingLinksets
-//---------------------------------------------------------------------------
-
-PathfindingLinksets::PathfindingLinksets()
- : mAllLinksets(),
- mFilteredLinksets(),
- mIsFiltersDirty(false),
- mNameFilter(),
- mDescriptionFilter(),
- mIsWalkableFilter(true),
- mIsObstacleFilter(true),
- mIsIgnoredFilter(true)
-{
-}
-
-PathfindingLinksets::PathfindingLinksets(const LLSD& pNavMeshData)
- : mAllLinksets(),
- mFilteredLinksets(),
- mIsFiltersDirty(false),
- mNameFilter(),
- mDescriptionFilter(),
- mIsWalkableFilter(true),
- mIsObstacleFilter(true),
- mIsIgnoredFilter(true)
-{
- setNavMeshData(pNavMeshData);
-}
-
-PathfindingLinksets::PathfindingLinksets(const PathfindingLinksets& pOther)
- : mAllLinksets(pOther.mAllLinksets),
- mFilteredLinksets(pOther.mFilteredLinksets),
- mIsFiltersDirty(pOther.mIsFiltersDirty),
- mNameFilter(pOther.mNameFilter),
- mDescriptionFilter(pOther.mDescriptionFilter),
- mIsWalkableFilter(pOther.mIsWalkableFilter),
- mIsObstacleFilter(pOther.mIsObstacleFilter),
- mIsIgnoredFilter(pOther.mIsIgnoredFilter)
-{
-}
-
-PathfindingLinksets::~PathfindingLinksets()
-{
- clearLinksets();
-}
-
-void PathfindingLinksets::setNavMeshData(const LLSD& pNavMeshData)
-{
- clearLinksets();
-
- for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap();
- navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter)
- {
- const std::string& uuid(navMeshDataIter->first);
- const LLSD& linksetData = navMeshDataIter->second;
- PathfindingLinkset linkset(uuid, linksetData);
-
- mAllLinksets.insert(std::pair<std::string, PathfindingLinkset>(uuid, linkset));
- }
-
- mIsFiltersDirty = true;
-}
-
-void PathfindingLinksets::updateNavMeshData(const LLSD& pNavMeshData)
-{
- for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap();
- navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter)
- {
- const std::string& uuid(navMeshDataIter->first);
- const LLSD& linksetData = navMeshDataIter->second;
- PathfindingLinkset linkset(uuid, linksetData);
-
- PathfindingLinksetMap::iterator linksetIter = mAllLinksets.find(uuid);
- if (linksetIter == mAllLinksets.end())
- {
- mAllLinksets.insert(std::pair<std::string, PathfindingLinkset>(uuid, linkset));
- }
- else
- {
- linksetIter->second = linkset;
- }
- }
-
- mIsFiltersDirty = true;
-}
-
-void PathfindingLinksets::clearLinksets()
-{
- mAllLinksets.clear();
- mFilteredLinksets.clear();
- mIsFiltersDirty = false;
-}
-
-const PathfindingLinksets::PathfindingLinksetMap& PathfindingLinksets::getAllLinksets() const
-{
- return mAllLinksets;
-}
-
-const PathfindingLinksets::PathfindingLinksetMap& PathfindingLinksets::getFilteredLinksets()
-{
- if (!isFiltersActive())
- {
- return mAllLinksets;
- }
- else
- {
- applyFilters();
- return mFilteredLinksets;
- }
-}
-
-BOOL PathfindingLinksets::isFiltersActive() const
-{
- return (mNameFilter.isActive() || mDescriptionFilter.isActive() || !mIsWalkableFilter || !mIsObstacleFilter || !mIsIgnoredFilter);
-}
-
-void PathfindingLinksets::setNameFilter(const std::string& pNameFilter)
-{
- mIsFiltersDirty = (mNameFilter.set(pNameFilter) || mIsFiltersDirty);
-}
-
-const std::string& PathfindingLinksets::getNameFilter() const
-{
- return mNameFilter.get();
-}
-
-void PathfindingLinksets::setDescriptionFilter(const std::string& pDescriptionFilter)
-{
- mIsFiltersDirty = (mDescriptionFilter.set(pDescriptionFilter) || mIsFiltersDirty);
-}
-
-const std::string& PathfindingLinksets::getDescriptionFilter() const
-{
- return mDescriptionFilter.get();
-}
-
-void PathfindingLinksets::setWalkableFilter(BOOL pWalkableFilter)
-{
- mIsFiltersDirty = (mIsFiltersDirty || (mIsWalkableFilter == pWalkableFilter));
- mIsWalkableFilter = pWalkableFilter;
-}
-
-BOOL PathfindingLinksets::isWalkableFilter() const
-{
- return mIsWalkableFilter;
-}
-
-void PathfindingLinksets::setObstacleFilter(BOOL pObstacleFilter)
-{
- mIsFiltersDirty = (mIsFiltersDirty || (mIsObstacleFilter == pObstacleFilter));
- mIsObstacleFilter = pObstacleFilter;
-}
-
-BOOL PathfindingLinksets::isObstacleFilter() const
-{
- return mIsObstacleFilter;
-}
-
-void PathfindingLinksets::setIgnoredFilter(BOOL pIgnoredFilter)
-{
- mIsFiltersDirty = (mIsFiltersDirty || (mIsIgnoredFilter == pIgnoredFilter));
- mIsIgnoredFilter = pIgnoredFilter;
-}
-
-BOOL PathfindingLinksets::isIgnoredFilter() const
-{
- return mIsIgnoredFilter;
-}
-
-void PathfindingLinksets::clearFilters()
-{
- mNameFilter.clear();
- mDescriptionFilter.clear();
- mIsWalkableFilter = true;
- mIsObstacleFilter = true;
- mIsIgnoredFilter = true;
- mIsFiltersDirty = false;
-}
-
-void PathfindingLinksets::applyFilters()
-{
- mFilteredLinksets.clear();
-
- for (PathfindingLinksetMap::const_iterator linksetIter = mAllLinksets.begin();
- linksetIter != mAllLinksets.end(); ++linksetIter)
- {
- const std::string& uuid(linksetIter->first);
- const PathfindingLinkset& linkset(linksetIter->second);
- if (doesMatchFilters(linkset))
- {
- mFilteredLinksets.insert(std::pair<std::string, PathfindingLinkset>(uuid, linkset));
- }
- }
-
- mIsFiltersDirty = false;
-}
-
-BOOL PathfindingLinksets::doesMatchFilters(const PathfindingLinkset& pLinkset) const
-{
- return (((mIsWalkableFilter && (pLinkset.getPathState() == PathfindingLinkset::kWalkable)) ||
- (mIsObstacleFilter && (pLinkset.getPathState() == PathfindingLinkset::kObstacle)) ||
- (mIsIgnoredFilter && (pLinkset.getPathState() == PathfindingLinkset::kIgnored))) &&
- (!mNameFilter.isActive() || mNameFilter.doesMatch(pLinkset.getName())) &&
- (!mDescriptionFilter.isActive() || mDescriptionFilter.doesMatch(pLinkset.getDescription())));
-}
-
-//---------------------------------------------------------------------------
// LLFloaterPathfindingLinksets
//---------------------------------------------------------------------------
@@ -889,6 +234,7 @@ BOOL LLFloaterPathfindingLinksets::isMessagingInProgress() const
LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed)
: LLFloater(pSeed),
+ mSelfHandle(),
mPathfindingLinksets(),
mMessagingState(kMessagingInitial),
mLinksetsScrollList(NULL),
@@ -914,6 +260,7 @@ LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed)
mEditPhantom(NULL),
mApplyEdits(NULL)
{
+ mSelfHandle.bind(this);
}
LLFloaterPathfindingLinksets::~LLFloaterPathfindingLinksets()
@@ -932,7 +279,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataGetRequest()
else
{
setMessagingState(kMessagingFetchStarting);
- mPathfindingLinksets.clearLinksets();
+ mPathfindingLinksets.clearPathfindingLinksets();
updateLinksetsList();
std::string navMeshDataURL = getCapabilityURL();
@@ -944,7 +291,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataGetRequest()
else
{
setMessagingState(kMessagingFetchRequestSent);
- LLHTTPClient::get(navMeshDataURL, new NavMeshDataGetResponder(navMeshDataURL, this));
+ LLHTTPClient::get(navMeshDataURL, new NavMeshDataGetResponder(navMeshDataURL, mSelfHandle));
}
}
}
@@ -960,7 +307,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataPutRequest(const LLSD& pPostDa
}
else
{
- LLHTTPClient::put(navMeshDataURL, pPostData, new NavMeshDataPutResponder(navMeshDataURL, this));
+ LLHTTPClient::put(navMeshDataURL, pPostData, new NavMeshDataPutResponder(navMeshDataURL, mSelfHandle));
}
}
}
@@ -968,7 +315,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataPutRequest(const LLSD& pPostDa
void LLFloaterPathfindingLinksets::handleNavMeshDataGetReply(const LLSD& pNavMeshData)
{
setMessagingState(kMessagingFetchReceived);
- mPathfindingLinksets.setNavMeshData(pNavMeshData);
+ mPathfindingLinksets.setPathfindingLinksets(pNavMeshData);
updateLinksetsList();
setMessagingState(kMessagingComplete);
}
@@ -976,7 +323,7 @@ void LLFloaterPathfindingLinksets::handleNavMeshDataGetReply(const LLSD& pNavMes
void LLFloaterPathfindingLinksets::handleNavMeshDataGetError(const std::string& pURL, const std::string& pErrorReason)
{
setMessagingState(kMessagingFetchError);
- mPathfindingLinksets.clearLinksets();
+ mPathfindingLinksets.clearPathfindingLinksets();
updateLinksetsList();
llwarns << "Error fetching object navmesh properties from URL '" << pURL << "' because " << pErrorReason << llendl;
}
@@ -984,7 +331,7 @@ void LLFloaterPathfindingLinksets::handleNavMeshDataGetError(const std::string&
void LLFloaterPathfindingLinksets::handleNavMeshDataPutReply(const LLSD& pModifiedData)
{
setMessagingState(kMessagingModifyReceived);
- mPathfindingLinksets.updateNavMeshData(pModifiedData);
+ mPathfindingLinksets.updatePathfindingLinksets(pModifiedData);
updateLinksetsList();
setMessagingState(kMessagingComplete);
}
@@ -1025,6 +372,7 @@ void LLFloaterPathfindingLinksets::setMessagingState(EMessagingState pMessagingS
{
mMessagingState = pMessagingState;
updateLinksetsStatusMessage();
+ updateEditFields();
}
void LLFloaterPathfindingLinksets::onApplyFiltersClicked()
@@ -1104,12 +452,12 @@ void LLFloaterPathfindingLinksets::updateLinksetsList()
updateLinksetsStatusMessage();
const LLVector3& avatarPosition = gAgent.getPositionAgent();
- const PathfindingLinksets::PathfindingLinksetMap& linksetMap = mPathfindingLinksets.getFilteredLinksets();
+ const LLFilteredPathfindingLinksets::PathfindingLinksetMap& linksetMap = mPathfindingLinksets.getFilteredLinksets();
- for (PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetMap.begin();
+ for (LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetMap.begin();
linksetIter != linksetMap.end(); ++linksetIter)
{
- const PathfindingLinkset& linkset(linksetIter->second);
+ const LLPathfindingLinkset& linkset(linksetIter->second);
LLSD columns;
@@ -1126,19 +474,19 @@ void LLFloaterPathfindingLinksets::updateLinksetsList()
columns[2]["font"] = "SANSSERIF";
columns[3]["column"] = "dist_from_you";
- columns[3]["value"] = llformat("%1.0f m", dist_vec(avatarPosition, linkset.getPositionAgent()));
+ columns[3]["value"] = llformat("%1.0f m", dist_vec(avatarPosition, linkset.getLocation()));
columns[3]["font"] = "SANSSERIF";
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 :
@@ -1153,19 +501,19 @@ void LLFloaterPathfindingLinksets::updateLinksetsList()
columns[5]["font"] = "SANSSERIF";
columns[6]["column"] = "a_percent";
- columns[6]["value"] = llformat("%3d", linkset.getA());
+ columns[6]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientA());
columns[6]["font"] = "SANSSERIF";
columns[7]["column"] = "b_percent";
- columns[7]["value"] = llformat("%3d", linkset.getB());
+ columns[7]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientB());
columns[7]["font"] = "SANSSERIF";
columns[8]["column"] = "c_percent";
- columns[8]["value"] = llformat("%3d", linkset.getC());
+ columns[8]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientC());
columns[8]["font"] = "SANSSERIF";
columns[9]["column"] = "d_percent";
- columns[9]["value"] = llformat("%3d", linkset.getD());
+ columns[9]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientD());
columns[9]["font"] = "SANSSERIF";
LLSD element;
@@ -1177,6 +525,7 @@ void LLFloaterPathfindingLinksets::updateLinksetsList()
mLinksetsScrollList->selectMultiple(selectedUUIDs);
updateLinksetsStatusMessage();
+ updateEditFields();
}
void LLFloaterPathfindingLinksets::selectAllLinksets()
@@ -1280,15 +629,15 @@ void LLFloaterPathfindingLinksets::updateEditFields()
{
LLScrollListItem *firstItem = selectedItems.front();
- const PathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
- PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(firstItem->getUUID().asString());
- const PathfindingLinkset &linkset(linksetIter->second);
+ const LLFilteredPathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
+ LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(firstItem->getUUID().asString());
+ const LLPathfindingLinkset &linkset(linksetIter->second);
setPathState(linkset.getPathState());
- mEditA->setValue(LLSD(linkset.getA()));
- mEditB->setValue(LLSD(linkset.getB()));
- mEditC->setValue(LLSD(linkset.getC()));
- mEditD->setValue(LLSD(linkset.getD()));
+ mEditA->setValue(LLSD(linkset.getWalkabilityCoefficientA()));
+ mEditB->setValue(LLSD(linkset.getWalkabilityCoefficientB()));
+ mEditC->setValue(LLSD(linkset.getWalkabilityCoefficientC()));
+ mEditD->setValue(LLSD(linkset.getWalkabilityCoefficientD()));
mEditPhantom->set(linkset.isPhantom());
setEnableEditFields(true);
@@ -1300,7 +649,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();
@@ -1311,7 +660,7 @@ void LLFloaterPathfindingLinksets::applyEditFields()
S32 dValue = static_cast<S32>(atoi(dString.c_str()));
BOOL isPhantom = mEditPhantom->getValue();
- const PathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
+ const LLFilteredPathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
LLSD editData;
for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin();
@@ -1320,10 +669,10 @@ void LLFloaterPathfindingLinksets::applyEditFields()
const LLScrollListItem *listItem = *itemIter;
LLUUID uuid = listItem->getUUID();
- const PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString());
- const PathfindingLinkset &linkset = linksetIter->second;
+ const LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString());
+ const LLPathfindingLinkset &linkset = linksetIter->second;
- LLSD itemData = linkset.getAlteredFields(pathState, aValue, bValue, cValue, dValue, isPhantom);
+ LLSD itemData = linkset.encodeAlteredFields(pathState, aValue, bValue, cValue, dValue, isPhantom);
if (!itemData.isUndefined())
{
@@ -1361,23 +710,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 +734,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 :
@@ -1413,48 +762,64 @@ void LLFloaterPathfindingLinksets::setPathState(PathfindingLinkset::EPathState p
// NavMeshDataGetResponder
//---------------------------------------------------------------------------
-NavMeshDataGetResponder::NavMeshDataGetResponder(const std::string& pNavMeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater)
+NavMeshDataGetResponder::NavMeshDataGetResponder(const std::string& pNavMeshDataGetURL,
+ const LLHandle<LLFloaterPathfindingLinksets> &pLinksetsHandle)
: mNavMeshDataGetURL(pNavMeshDataGetURL),
- mLinksetsFloater(pLinksetsFloater)
+ mLinksetsFloaterHandle(pLinksetsHandle)
{
}
NavMeshDataGetResponder::~NavMeshDataGetResponder()
{
- mLinksetsFloater = NULL;
}
void NavMeshDataGetResponder::result(const LLSD& pContent)
{
- mLinksetsFloater->handleNavMeshDataGetReply(pContent);
+ LLFloaterPathfindingLinksets *linksetsFloater = mLinksetsFloaterHandle.get();
+ if (linksetsFloater != NULL)
+ {
+ linksetsFloater->handleNavMeshDataGetReply(pContent);
+ }
}
void NavMeshDataGetResponder::error(U32 status, const std::string& reason)
{
- mLinksetsFloater->handleNavMeshDataGetError(mNavMeshDataGetURL, reason);
+ LLFloaterPathfindingLinksets *linksetsFloater = mLinksetsFloaterHandle.get();
+ if (linksetsFloater != NULL)
+ {
+ linksetsFloater->handleNavMeshDataGetError(mNavMeshDataGetURL, reason);
+ }
}
//---------------------------------------------------------------------------
// NavMeshDataPutResponder
//---------------------------------------------------------------------------
-NavMeshDataPutResponder::NavMeshDataPutResponder(const std::string& pNavMeshDataPutURL, LLFloaterPathfindingLinksets *pLinksetsFloater)
+NavMeshDataPutResponder::NavMeshDataPutResponder(const std::string& pNavMeshDataPutURL,
+ const LLHandle<LLFloaterPathfindingLinksets> &pLinksetsHandle)
: mNavMeshDataPutURL(pNavMeshDataPutURL),
- mLinksetsFloater(pLinksetsFloater)
+ mLinksetsFloaterHandle(pLinksetsHandle)
{
}
NavMeshDataPutResponder::~NavMeshDataPutResponder()
{
- mLinksetsFloater = NULL;
}
void NavMeshDataPutResponder::result(const LLSD& pContent)
{
- mLinksetsFloater->handleNavMeshDataPutReply(pContent);
+ LLFloaterPathfindingLinksets *linksetsFloater = mLinksetsFloaterHandle.get();
+ if (linksetsFloater != NULL)
+ {
+ linksetsFloater->handleNavMeshDataPutReply(pContent);
+ }
}
void NavMeshDataPutResponder::error(U32 status, const std::string& reason)
{
- mLinksetsFloater->handleNavMeshDataPutError(mNavMeshDataPutURL, reason);
+ LLFloaterPathfindingLinksets *linksetsFloater = mLinksetsFloaterHandle.get();
+ if (linksetsFloater != NULL)
+ {
+ linksetsFloater->handleNavMeshDataPutError(mNavMeshDataPutURL, reason);
+ }
}