From 58f299fb8ab409545b5ea386eb60965486e3d380 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 27 Jan 2012 18:03:04 -0800 Subject: PATH-187: Moving the filtered pathfinding linksets class into its own file. --- indra/newview/llpathfindinglinkset.cpp | 344 +++++++++++++++++++++++++++++++++ 1 file changed, 344 insertions(+) create mode 100644 indra/newview/llpathfindinglinkset.cpp (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp new file mode 100644 index 0000000000..bfe851d8ee --- /dev/null +++ b/indra/newview/llpathfindinglinkset.cpp @@ -0,0 +1,344 @@ +/** + * @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 "llpathfindinglinkset.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 + mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientD(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 + mWalkabilityCoefficientA = llround(pNavMeshItem.get("A").asReal() * 100.0f); + + llassert(pNavMeshItem.has("B")); + llassert(pNavMeshItem.get("B").isReal()); + mWalkabilityCoefficientB = llround(pNavMeshItem.get("B").asReal() * 100.0f); + + llassert(pNavMeshItem.has("C")); + llassert(pNavMeshItem.get("C").isReal()); + mWalkabilityCoefficientC = llround(pNavMeshItem.get("C").asReal() * 100.0f); + + llassert(pNavMeshItem.has("D")); + llassert(pNavMeshItem.get("D").isReal()); + mWalkabilityCoefficientD = llround(pNavMeshItem.get("D").asReal() * 100.0f); + } + else + { + // New server-side storage will be integer + llassert(pNavMeshItem.get("A").isInteger()); + mWalkabilityCoefficientA = pNavMeshItem.get("A").asInteger(); + llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE); + llassert(mWalkabilityCoefficientA <= MAX_WALKABILITY_VALUE); + + llassert(pNavMeshItem.has("B")); + llassert(pNavMeshItem.get("B").isInteger()); + mWalkabilityCoefficientB = pNavMeshItem.get("B").asInteger(); + llassert(mWalkabilityCoefficientB >= MIN_WALKABILITY_VALUE); + llassert(mWalkabilityCoefficientB <= MAX_WALKABILITY_VALUE); + + llassert(pNavMeshItem.has("C")); + llassert(pNavMeshItem.get("C").isInteger()); + mWalkabilityCoefficientC = pNavMeshItem.get("C").asInteger(); + llassert(mWalkabilityCoefficientC >= MIN_WALKABILITY_VALUE); + llassert(mWalkabilityCoefficientC <= MAX_WALKABILITY_VALUE); + + llassert(pNavMeshItem.has("D")); + llassert(pNavMeshItem.get("D").isInteger()); + mWalkabilityCoefficientD = pNavMeshItem.get("D").asInteger(); + llassert(mWalkabilityCoefficientD >= MIN_WALKABILITY_VALUE); + llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE); + } +#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE + llassert(pNavMeshItem.get("A").isInteger()); + mWalkabilityCoefficientA = pNavMeshItem.get("A").asInteger(); + llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE); + llassert(mWalkabilityCoefficientA <= MAX_WALKABILITY_VALUE); + + llassert(pNavMeshItem.has("B")); + llassert(pNavMeshItem.get("B").isInteger()); + mWalkabilityCoefficientB = pNavMeshItem.get("B").asInteger(); + llassert(mWalkabilityCoefficientB >= MIN_WALKABILITY_VALUE); + llassert(mWalkabilityCoefficientB <= MAX_WALKABILITY_VALUE); + + llassert(pNavMeshItem.has("C")); + llassert(pNavMeshItem.get("C").isInteger()); + mWalkabilityCoefficientC = pNavMeshItem.get("C").asInteger(); + llassert(mWalkabilityCoefficientC >= MIN_WALKABILITY_VALUE); + llassert(mWalkabilityCoefficientC <= MAX_WALKABILITY_VALUE); + + llassert(pNavMeshItem.has("D")); + llassert(pNavMeshItem.get("D").isInteger()); + mWalkabilityCoefficientD = pNavMeshItem.get("D").asInteger(); + llassert(mWalkabilityCoefficientD >= MIN_WALKABILITY_VALUE); + llassert(mWalkabilityCoefficientD <= 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 + mWalkabilityCoefficientA(pOther.mWalkabilityCoefficientA), + mWalkabilityCoefficientB(pOther.mWalkabilityCoefficientB), + mWalkabilityCoefficientC(pOther.mWalkabilityCoefficientC), + mWalkabilityCoefficientD(pOther.mWalkabilityCoefficientD) +{ +} + +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 + mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; + mWalkabilityCoefficientB = pOther.mWalkabilityCoefficientB; + mWalkabilityCoefficientC = pOther.mWalkabilityCoefficientC; + mWalkabilityCoefficientD = pOther.mWalkabilityCoefficientD; + + return *this; +} + + +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; +} + +void LLPathfindingLinkset::setWalkabilityCoefficientA(S32 pA) +{ + mWalkabilityCoefficientA = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); +} + +void LLPathfindingLinkset::setWalkabilityCoefficientB(S32 pB) +{ + mWalkabilityCoefficientB = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); +} + +void LLPathfindingLinkset::setWalkabilityCoefficientC(S32 pC) +{ + mWalkabilityCoefficientC = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); +} + +void LLPathfindingLinkset::setWalkabilityCoefficientD(S32 pD) +{ + mWalkabilityCoefficientD = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); +} + +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(LLPathfindingLinkset::isPermanent(pPathState)); + itemData["walkable"] = static_cast(LLPathfindingLinkset::isWalkable(pPathState)); + } +#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE + if (mIsWalkabilityCoefficientsF32) + { + if (mWalkabilityCoefficientA != pA) + { + itemData["A"] = llclamp(static_cast(pA) / 100.0f, 0.0f, 1.0f); + } + if (mWalkabilityCoefficientB != pB) + { + itemData["B"] = llclamp(static_cast(pB) / 100.0f, 0.0f, 1.0f); + } + if (mWalkabilityCoefficientC != pC) + { + itemData["C"] = llclamp(static_cast(pC) / 100.0f, 0.0f, 1.0f); + } + if (mWalkabilityCoefficientD != pD) + { + itemData["D"] = llclamp(static_cast(pD) / 100.0f, 0.0f, 1.0f); + } + } + else + { + if (mWalkabilityCoefficientA != pA) + { + itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + if (mWalkabilityCoefficientB != pB) + { + itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + if (mWalkabilityCoefficientC != pC) + { + itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + if (mWalkabilityCoefficientD != pD) + { + itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + } +#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE + if (mWalkabilityCoefficientA != pA) + { + itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + if (mWalkabilityCoefficientB != pB) + { + itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + if (mWalkabilityCoefficientC != pC) + { + itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + if (mWalkabilityCoefficientD != 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(pIsPhantom); + } + + return itemData; +} -- cgit v1.3 From de6ae690b5315307b59b1a2ac722700c3839e4ba Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 30 Jan 2012 16:33:41 -0800 Subject: PATH-187: Consolidating field names for the cap service into local defines. --- indra/newview/llfilteredpathfindinglinksets.cpp | 24 ++-- indra/newview/llfilteredpathfindinglinksets.h | 6 +- indra/newview/llfloaterpathfindinglinksets.cpp | 2 +- indra/newview/llpathfindinglinkset.cpp | 158 +++++++++++++----------- indra/newview/llpathfindinglinkset.h | 4 +- 5 files changed, 103 insertions(+), 91 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llfilteredpathfindinglinksets.cpp b/indra/newview/llfilteredpathfindinglinksets.cpp index c956a5752b..aaff2bcc68 100644 --- a/indra/newview/llfilteredpathfindinglinksets.cpp +++ b/indra/newview/llfilteredpathfindinglinksets.cpp @@ -122,7 +122,7 @@ LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets() { } -LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets(const LLSD& pNavMeshData) +LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets(const LLSD& pLinksetItems) : mAllLinksets(), mFilteredLinksets(), mIsFiltersDirty(false), @@ -132,7 +132,7 @@ LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets(const LLSD& pNavMes mIsObstacleFilter(true), mIsIgnoredFilter(true) { - setPathfindingLinksets(pNavMeshData); + setPathfindingLinksets(pLinksetItems); } LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets(const LLFilteredPathfindingLinksets& pOther) @@ -152,15 +152,15 @@ LLFilteredPathfindingLinksets::~LLFilteredPathfindingLinksets() clearPathfindingLinksets(); } -void LLFilteredPathfindingLinksets::setPathfindingLinksets(const LLSD& pNavMeshData) +void LLFilteredPathfindingLinksets::setPathfindingLinksets(const LLSD& pLinksetItems) { clearPathfindingLinksets(); - for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap(); - navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter) + for (LLSD::map_const_iterator linksetItemIter = pLinksetItems.beginMap(); + linksetItemIter != pLinksetItems.endMap(); ++linksetItemIter) { - const std::string& uuid(navMeshDataIter->first); - const LLSD& linksetData = navMeshDataIter->second; + const std::string& uuid(linksetItemIter->first); + const LLSD& linksetData = linksetItemIter->second; LLPathfindingLinkset linkset(uuid, linksetData); mAllLinksets.insert(std::pair(uuid, linkset)); @@ -169,13 +169,13 @@ void LLFilteredPathfindingLinksets::setPathfindingLinksets(const LLSD& pNavMeshD mIsFiltersDirty = true; } -void LLFilteredPathfindingLinksets::updatePathfindingLinksets(const LLSD& pNavMeshData) +void LLFilteredPathfindingLinksets::updatePathfindingLinksets(const LLSD& pLinksetItems) { - for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap(); - navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter) + for (LLSD::map_const_iterator linksetItemIter = pLinksetItems.beginMap(); + linksetItemIter != pLinksetItems.endMap(); ++linksetItemIter) { - const std::string& uuid(navMeshDataIter->first); - const LLSD& linksetData = navMeshDataIter->second; + const std::string& uuid(linksetItemIter->first); + const LLSD& linksetData = linksetItemIter->second; LLPathfindingLinkset linkset(uuid, linksetData); PathfindingLinksetMap::iterator linksetIter = mAllLinksets.find(uuid); diff --git a/indra/newview/llfilteredpathfindinglinksets.h b/indra/newview/llfilteredpathfindinglinksets.h index afd2b2b01d..de9b3a5e15 100644 --- a/indra/newview/llfilteredpathfindinglinksets.h +++ b/indra/newview/llfilteredpathfindinglinksets.h @@ -61,12 +61,12 @@ public: typedef std::map PathfindingLinksetMap; LLFilteredPathfindingLinksets(); - LLFilteredPathfindingLinksets(const LLSD& pNavMeshData); + LLFilteredPathfindingLinksets(const LLSD& pLinksetItems); LLFilteredPathfindingLinksets(const LLFilteredPathfindingLinksets& pOther); virtual ~LLFilteredPathfindingLinksets(); - void setPathfindingLinksets(const LLSD& pNavMeshData); - void updatePathfindingLinksets(const LLSD& pNavMeshData); + void setPathfindingLinksets(const LLSD& pLinksetItems); + void updatePathfindingLinksets(const LLSD& pLinksetItems); void clearPathfindingLinksets(); const PathfindingLinksetMap& getAllLinksets() const; diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index 3edb4e5c73..4d3581fc60 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -672,7 +672,7 @@ void LLFloaterPathfindingLinksets::applyEditFields() 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()) { diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index bfe851d8ee..daa308f862 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -31,6 +31,18 @@ #include "v3math.h" #include "lluuid.h" +#define LINKSET_NAME_FIELD "name" +#define LINKSET_DESCRIPTION_FIELD "description" +#define LINKSET_LAND_IMPACT_FIELD "landimpact" +#define LINKSET_PERMANENT_FIELD "permanent" +#define LINKSET_WALKABLE_FIELD "walkable" +#define LINKSET_PHANTOM_FIELD "phantom" +#define LINKSET_WALKABILITY_A_FIELD "A" +#define LINKSET_WALKABILITY_B_FIELD "B" +#define LINKSET_WALKABILITY_C_FIELD "C" +#define LINKSET_WALKABILITY_D_FIELD "D" +#define LINKSET_POSITION_FIELD "position" + //--------------------------------------------------------------------------- // LLPathfindingLinkset //--------------------------------------------------------------------------- @@ -38,7 +50,7 @@ const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0); const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100); -LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pNavMeshItem) +LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetItem) : mUUID(pUUID), mName(), mDescription(), @@ -54,107 +66,107 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) { - llassert(pNavMeshItem.has("name")); - llassert(pNavMeshItem.get("name").isString()); - mName = pNavMeshItem.get("name").asString(); + llassert(pLinksetItem.has(LINKSET_NAME_FIELD)); + llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString()); + mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString(); - llassert(pNavMeshItem.has("description")); - llassert(pNavMeshItem.get("description").isString()); - mDescription = pNavMeshItem.get("description").asString(); + llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD)); + llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString()); + mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString(); - llassert(pNavMeshItem.has("landimpact")); - llassert(pNavMeshItem.get("landimpact").isInteger()); - llassert(pNavMeshItem.get("landimpact").asInteger() >= 0); - mLandImpact = pNavMeshItem.get("landimpact").asInteger(); + llassert(pLinksetItem.has(LINKSET_LAND_IMPACT_FIELD)); + llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).isInteger()); + llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); + mLandImpact = pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger(); - llassert(pNavMeshItem.has("permanent")); - llassert(pNavMeshItem.get("permanent").isBoolean()); - bool isPermanent = pNavMeshItem.get("permanent").asBoolean(); + llassert(pLinksetItem.has(LINKSET_PERMANENT_FIELD)); + llassert(pLinksetItem.get(LINKSET_PERMANENT_FIELD).isBoolean()); + bool isPermanent = pLinksetItem.get(LINKSET_PERMANENT_FIELD).asBoolean(); - llassert(pNavMeshItem.has("walkable")); - llassert(pNavMeshItem.get("walkable").isBoolean()); - bool isWalkable = pNavMeshItem.get("walkable").asBoolean(); + llassert(pLinksetItem.has(LINKSET_WALKABLE_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABLE_FIELD).isBoolean()); + bool isWalkable = pLinksetItem.get(LINKSET_WALKABLE_FIELD).asBoolean(); mPathState = getPathState(isPermanent, isWalkable); - llassert(pNavMeshItem.has("phantom")); - llassert(pNavMeshItem.get("phantom").isBoolean()); - mIsPhantom = pNavMeshItem.get("phantom").asBoolean(); + llassert(pLinksetItem.has(LINKSET_PHANTOM_FIELD)); + llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); + mIsPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean(); - llassert(pNavMeshItem.has("A")); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); #ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE - mIsWalkabilityCoefficientsF32 = pNavMeshItem.get("A").isReal(); + mIsWalkabilityCoefficientsF32 = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isReal(); if (mIsWalkabilityCoefficientsF32) { // Old server-side storage was real - mWalkabilityCoefficientA = llround(pNavMeshItem.get("A").asReal() * 100.0f); + mWalkabilityCoefficientA = llround(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asReal() * 100.0f); - llassert(pNavMeshItem.has("B")); - llassert(pNavMeshItem.get("B").isReal()); - mWalkabilityCoefficientB = llround(pNavMeshItem.get("B").asReal() * 100.0f); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_B_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).isReal()); + mWalkabilityCoefficientB = llround(pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).asReal() * 100.0f); - llassert(pNavMeshItem.has("C")); - llassert(pNavMeshItem.get("C").isReal()); - mWalkabilityCoefficientC = llround(pNavMeshItem.get("C").asReal() * 100.0f); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_C_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).isReal()); + mWalkabilityCoefficientC = llround(pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).asReal() * 100.0f); - llassert(pNavMeshItem.has("D")); - llassert(pNavMeshItem.get("D").isReal()); - mWalkabilityCoefficientD = llround(pNavMeshItem.get("D").asReal() * 100.0f); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_D_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).isReal()); + mWalkabilityCoefficientD = llround(pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).asReal() * 100.0f); } else { // New server-side storage will be integer - llassert(pNavMeshItem.get("A").isInteger()); - mWalkabilityCoefficientA = pNavMeshItem.get("A").asInteger(); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); + mWalkabilityCoefficientA = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asInteger(); llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientA <= MAX_WALKABILITY_VALUE); - llassert(pNavMeshItem.has("B")); - llassert(pNavMeshItem.get("B").isInteger()); - mWalkabilityCoefficientB = pNavMeshItem.get("B").asInteger(); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_B_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).isInteger()); + mWalkabilityCoefficientB = pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).asInteger(); llassert(mWalkabilityCoefficientB >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientB <= MAX_WALKABILITY_VALUE); - llassert(pNavMeshItem.has("C")); - llassert(pNavMeshItem.get("C").isInteger()); - mWalkabilityCoefficientC = pNavMeshItem.get("C").asInteger(); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_C_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).isInteger()); + mWalkabilityCoefficientC = pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).asInteger(); llassert(mWalkabilityCoefficientC >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientC <= MAX_WALKABILITY_VALUE); - llassert(pNavMeshItem.has("D")); - llassert(pNavMeshItem.get("D").isInteger()); - mWalkabilityCoefficientD = pNavMeshItem.get("D").asInteger(); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_D_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).isInteger()); + mWalkabilityCoefficientD = pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).asInteger(); llassert(mWalkabilityCoefficientD >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE); } #else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE - llassert(pNavMeshItem.get("A").isInteger()); - mWalkabilityCoefficientA = pNavMeshItem.get("A").asInteger(); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); + mWalkabilityCoefficientA = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asInteger(); llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientA <= MAX_WALKABILITY_VALUE); - llassert(pNavMeshItem.has("B")); - llassert(pNavMeshItem.get("B").isInteger()); - mWalkabilityCoefficientB = pNavMeshItem.get("B").asInteger(); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_B_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).isInteger()); + mWalkabilityCoefficientB = pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).asInteger(); llassert(mWalkabilityCoefficientB >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientB <= MAX_WALKABILITY_VALUE); - llassert(pNavMeshItem.has("C")); - llassert(pNavMeshItem.get("C").isInteger()); - mWalkabilityCoefficientC = pNavMeshItem.get("C").asInteger(); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_C_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).isInteger()); + mWalkabilityCoefficientC = pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).asInteger(); llassert(mWalkabilityCoefficientC >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientC <= MAX_WALKABILITY_VALUE); - llassert(pNavMeshItem.has("D")); - llassert(pNavMeshItem.get("D").isInteger()); - mWalkabilityCoefficientD = pNavMeshItem.get("D").asInteger(); + llassert(pLinksetItem.has(LINKSET_WALKABILITY_D_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).isInteger()); + mWalkabilityCoefficientD = pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).asInteger(); llassert(mWalkabilityCoefficientD >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE); #endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE - llassert(pNavMeshItem.has("position")); - llassert(pNavMeshItem.get("position").isArray()); - mLocation.setValue(pNavMeshItem.get("position")); + llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); + llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); + mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD)); } LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) @@ -269,75 +281,75 @@ void LLPathfindingLinkset::setWalkabilityCoefficientD(S32 pD) mWalkabilityCoefficientD = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } -LLSD LLPathfindingLinkset::getAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const +LLSD LLPathfindingLinkset::encodeAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const { LLSD itemData; if (mPathState != pPathState) { - itemData["permanent"] = static_cast(LLPathfindingLinkset::isPermanent(pPathState)); - itemData["walkable"] = static_cast(LLPathfindingLinkset::isWalkable(pPathState)); + itemData[LINKSET_PERMANENT_FIELD] = static_cast(LLPathfindingLinkset::isPermanent(pPathState)); + itemData[LINKSET_WALKABLE_FIELD] = static_cast(LLPathfindingLinkset::isWalkable(pPathState)); } #ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE if (mIsWalkabilityCoefficientsF32) { if (mWalkabilityCoefficientA != pA) { - itemData["A"] = llclamp(static_cast(pA) / 100.0f, 0.0f, 1.0f); + itemData[LINKSET_WALKABILITY_A_FIELD] = llclamp(static_cast(pA) / 100.0f, 0.0f, 1.0f); } if (mWalkabilityCoefficientB != pB) { - itemData["B"] = llclamp(static_cast(pB) / 100.0f, 0.0f, 1.0f); + itemData[LINKSET_WALKABILITY_B_FIELD] = llclamp(static_cast(pB) / 100.0f, 0.0f, 1.0f); } if (mWalkabilityCoefficientC != pC) { - itemData["C"] = llclamp(static_cast(pC) / 100.0f, 0.0f, 1.0f); + itemData[LINKSET_WALKABILITY_C_FIELD] = llclamp(static_cast(pC) / 100.0f, 0.0f, 1.0f); } if (mWalkabilityCoefficientD != pD) { - itemData["D"] = llclamp(static_cast(pD) / 100.0f, 0.0f, 1.0f); + itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(static_cast(pD) / 100.0f, 0.0f, 1.0f); } } else { if (mWalkabilityCoefficientA != pA) { - itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + itemData[LINKSET_WALKABILITY_A_FIELD] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } if (mWalkabilityCoefficientB != pB) { - itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + itemData[LINKSET_WALKABILITY_B_FIELD] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } if (mWalkabilityCoefficientC != pC) { - itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + itemData[LINKSET_WALKABILITY_C_FIELD] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } if (mWalkabilityCoefficientD != pD) { - itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } } #else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE if (mWalkabilityCoefficientA != pA) { - itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + itemData[LINKSET_WALKABILITY_A_FIELD] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } if (mWalkabilityCoefficientB != pB) { - itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + itemData[LINKSET_WALKABILITY_B_FIELD] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } if (mWalkabilityCoefficientC != pC) { - itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + itemData[LINKSET_WALKABILITY_C_FIELD] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } if (mWalkabilityCoefficientD != pD) { - itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } #endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE if (mIsPhantom != pIsPhantom) { - itemData["phantom"] = static_cast(pIsPhantom); + itemData[LINKSET_PHANTOM_FIELD] = static_cast(pIsPhantom); } return itemData; diff --git a/indra/newview/llpathfindinglinkset.h b/indra/newview/llpathfindinglinkset.h index c6165907d0..d4e58874eb 100644 --- a/indra/newview/llpathfindinglinkset.h +++ b/indra/newview/llpathfindinglinkset.h @@ -47,7 +47,7 @@ public: kIgnored } EPathState; - LLPathfindingLinkset(const std::string &pUUID, const LLSD &pNavMeshItem); + LLPathfindingLinkset(const std::string &pUUID, const LLSD &pLinksetItem); LLPathfindingLinkset(const LLPathfindingLinkset& pOther); virtual ~LLPathfindingLinkset(); @@ -81,7 +81,7 @@ public: inline S32 getWalkabilityCoefficientD() const {return mWalkabilityCoefficientD;}; void setWalkabilityCoefficientD(S32 pD); - LLSD getAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const; + LLSD encodeAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const; protected: -- cgit v1.3 From e156e9ed03fd16af36e2b28823f07658f4d9b0c8 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 16 Feb 2012 14:55:21 -0800 Subject: PATH-292: First pass at implementing the new design of the linksets floater. --- indra/newview/llfilteredpathfindinglinksets.cpp | 59 +- indra/newview/llfilteredpathfindinglinksets.h | 22 +- indra/newview/llfloaterpathfindinglinksets.cpp | 337 ++++---- indra/newview/llfloaterpathfindinglinksets.h | 54 +- indra/newview/llpathfindinglinkset.cpp | 165 ++-- indra/newview/llpathfindinglinkset.h | 61 +- .../xui/en/floater_pathfinding_linksets.xml | 864 ++++++++++++--------- 7 files changed, 872 insertions(+), 690 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llfilteredpathfindinglinksets.cpp b/indra/newview/llfilteredpathfindinglinksets.cpp index aaff2bcc68..b76d95737c 100644 --- a/indra/newview/llfilteredpathfindinglinksets.cpp +++ b/indra/newview/llfilteredpathfindinglinksets.cpp @@ -116,9 +116,7 @@ LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets() mIsFiltersDirty(false), mNameFilter(), mDescriptionFilter(), - mIsWalkableFilter(true), - mIsObstacleFilter(true), - mIsIgnoredFilter(true) + mLinksetUseFilter(LLPathfindingLinkset::kUnknown) { } @@ -128,9 +126,7 @@ LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets(const LLSD& pLinkse mIsFiltersDirty(false), mNameFilter(), mDescriptionFilter(), - mIsWalkableFilter(true), - mIsObstacleFilter(true), - mIsIgnoredFilter(true) + mLinksetUseFilter(LLPathfindingLinkset::kUnknown) { setPathfindingLinksets(pLinksetItems); } @@ -141,9 +137,7 @@ LLFilteredPathfindingLinksets::LLFilteredPathfindingLinksets(const LLFilteredPat mIsFiltersDirty(pOther.mIsFiltersDirty), mNameFilter(pOther.mNameFilter), mDescriptionFilter(pOther.mDescriptionFilter), - mIsWalkableFilter(pOther.mIsWalkableFilter), - mIsObstacleFilter(pOther.mIsObstacleFilter), - mIsIgnoredFilter(pOther.mIsIgnoredFilter) + mLinksetUseFilter(pOther.mLinksetUseFilter) { } @@ -219,7 +213,8 @@ const LLFilteredPathfindingLinksets::PathfindingLinksetMap& LLFilteredPathfindin BOOL LLFilteredPathfindingLinksets::isFiltersActive() const { - return (mNameFilter.isActive() || mDescriptionFilter.isActive() || !mIsWalkableFilter || !mIsObstacleFilter || !mIsIgnoredFilter); + return (mNameFilter.isActive() || mDescriptionFilter.isActive() || + (mLinksetUseFilter != LLPathfindingLinkset::kUnknown)); } void LLFilteredPathfindingLinksets::setNameFilter(const std::string& pNameFilter) @@ -242,46 +237,22 @@ const std::string& LLFilteredPathfindingLinksets::getDescriptionFilter() const return mDescriptionFilter.get(); } -void LLFilteredPathfindingLinksets::setWalkableFilter(BOOL pWalkableFilter) +void LLFilteredPathfindingLinksets::setLinksetUseFilter(LLPathfindingLinkset::ELinksetUse pLinksetUse) { - mIsFiltersDirty = (mIsFiltersDirty || (mIsWalkableFilter == pWalkableFilter)); - mIsWalkableFilter = pWalkableFilter; + mIsFiltersDirty = (mIsFiltersDirty || (mLinksetUseFilter == pLinksetUse)); + mLinksetUseFilter = pLinksetUse; } -BOOL LLFilteredPathfindingLinksets::isWalkableFilter() const +LLPathfindingLinkset::ELinksetUse LLFilteredPathfindingLinksets::getLinksetUseFilter() const { - return mIsWalkableFilter; -} - -void LLFilteredPathfindingLinksets::setObstacleFilter(BOOL pObstacleFilter) -{ - mIsFiltersDirty = (mIsFiltersDirty || (mIsObstacleFilter == pObstacleFilter)); - mIsObstacleFilter = pObstacleFilter; -} - -BOOL LLFilteredPathfindingLinksets::isObstacleFilter() const -{ - return mIsObstacleFilter; -} - -void LLFilteredPathfindingLinksets::setIgnoredFilter(BOOL pIgnoredFilter) -{ - mIsFiltersDirty = (mIsFiltersDirty || (mIsIgnoredFilter == pIgnoredFilter)); - mIsIgnoredFilter = pIgnoredFilter; -} - -BOOL LLFilteredPathfindingLinksets::isIgnoredFilter() const -{ - return mIsIgnoredFilter; + return mLinksetUseFilter; } void LLFilteredPathfindingLinksets::clearFilters() { mNameFilter.clear(); mDescriptionFilter.clear(); - mIsWalkableFilter = true; - mIsObstacleFilter = true; - mIsIgnoredFilter = true; + mLinksetUseFilter = LLPathfindingLinkset::kUnknown; mIsFiltersDirty = false; } @@ -305,9 +276,7 @@ void LLFilteredPathfindingLinksets::applyFilters() BOOL LLFilteredPathfindingLinksets::doesMatchFilters(const LLPathfindingLinkset& pLinkset) const { - 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()))); + return (((mLinksetUseFilter == LLPathfindingLinkset::kUnknown) || (mLinksetUseFilter == pLinkset.getLinksetUse())) && + (!mNameFilter.isActive() || mNameFilter.doesMatch(pLinkset.getName())) && + (!mDescriptionFilter.isActive() || mDescriptionFilter.doesMatch(pLinkset.getDescription()))); } diff --git a/indra/newview/llfilteredpathfindinglinksets.h b/indra/newview/llfilteredpathfindinglinksets.h index de9b3a5e15..388818c32b 100644 --- a/indra/newview/llfilteredpathfindinglinksets.h +++ b/indra/newview/llfilteredpathfindinglinksets.h @@ -30,9 +30,9 @@ #include #include +#include "llpathfindinglinkset.h" class LLSD; -class LLPathfindingLinkset; class FilterString { @@ -80,14 +80,8 @@ public: void setDescriptionFilter(const std::string& pDescriptionFilter); const std::string& getDescriptionFilter() const; - void setWalkableFilter(BOOL pWalkableFilter); - BOOL isWalkableFilter() const; - - void setObstacleFilter(BOOL pObstacleFilter); - BOOL isObstacleFilter() const; - - void setIgnoredFilter(BOOL pIgnoredFilter); - BOOL isIgnoredFilter() const; + void setLinksetUseFilter(LLPathfindingLinkset::ELinksetUse pLinksetUse); + LLPathfindingLinkset::ELinksetUse getLinksetUseFilter() const; void clearFilters(); @@ -97,12 +91,10 @@ private: PathfindingLinksetMap mAllLinksets; PathfindingLinksetMap mFilteredLinksets; - bool mIsFiltersDirty; - FilterString mNameFilter; - FilterString mDescriptionFilter; - BOOL mIsWalkableFilter; - BOOL mIsObstacleFilter; - BOOL mIsIgnoredFilter; + bool mIsFiltersDirty; + FilterString mNameFilter; + FilterString mDescriptionFilter; + LLPathfindingLinkset::ELinksetUse mLinksetUseFilter; void applyFilters(); BOOL doesMatchFilters(const LLPathfindingLinkset& pLinkset) const; diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index 5c7f288226..ac95483a66 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -27,30 +27,33 @@ #include "llviewerprecompiledheaders.h" #include "llfloater.h" +#include "llfloaterreg.h" #include "llfloaterpathfindinglinksets.h" #include "llsd.h" +#include "lluuid.h" #include "v3math.h" #include "lltextvalidate.h" #include "llagent.h" #include "llhandle.h" -#include "llfloaterreg.h" #include "lltextbase.h" #include "lllineeditor.h" #include "llscrolllistitem.h" #include "llscrolllistctrl.h" -#include "llcheckboxctrl.h" -#include "llradiogroup.h" +#include "llcombobox.h" #include "llbutton.h" #include "llresmgr.h" #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 -#define XUI_PATH_STATE_IGNORED 3 +#define XUI_LINKSET_USE_NONE 0 +#define XUI_LINKSET_USE_WALKABLE 1 +#define XUI_LINKSET_USE_STATIC_OBSTACLE 2 +#define XUI_LINKSET_USE_DYNAMIC_OBSTACLE 3 +#define XUI_LINKSET_USE_MATERIAL_VOLUME 4 +#define XUI_LINKSET_USE_EXCLUSION_VOLUME 5 +#define XUI_LINKSET_USE_DYNAMIC_PHANTOM 6 //--------------------------------------------------------------------------- // NavMeshDataGetResponder @@ -100,11 +103,24 @@ private: BOOL LLFloaterPathfindingLinksets::postBuild() { - childSetAction("apply_filters", boost::bind(&LLFloaterPathfindingLinksets::onApplyFiltersClicked, this)); + childSetAction("apply_filters", boost::bind(&LLFloaterPathfindingLinksets::onApplyAllFilters, this)); childSetAction("clear_filters", boost::bind(&LLFloaterPathfindingLinksets::onClearFiltersClicked, this)); - childSetAction("refresh_linksets_list", boost::bind(&LLFloaterPathfindingLinksets::onRefreshLinksetsClicked, this)); - childSetAction("select_all_linksets", boost::bind(&LLFloaterPathfindingLinksets::onSelectAllLinksetsClicked, this)); - childSetAction("select_none_linksets", boost::bind(&LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked, this)); + + mFilterByName = findChild("filter_by_name"); + llassert(mFilterByName != NULL); + mFilterByName->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyAllFilters, this)); + mFilterByName->setSelectAllonFocusReceived(true); + mFilterByName->setCommitOnFocusLost(true); + + mFilterByDescription = findChild("filter_by_description"); + llassert(mFilterByDescription != NULL); + mFilterByDescription->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyAllFilters, this)); + mFilterByDescription->setSelectAllonFocusReceived(true); + mFilterByDescription->setCommitOnFocusLost(true); + + mFilterByLinksetUse = findChild("filter_by_linkset_use"); + llassert(mFilterByLinksetUse != NULL); + mFilterByLinksetUse->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyAllFilters, this)); mLinksetsScrollList = findChild("pathfinding_linksets"); llassert(mLinksetsScrollList != NULL); @@ -115,41 +131,40 @@ BOOL LLFloaterPathfindingLinksets::postBuild() mLinksetsStatus = findChild("linksets_status"); llassert(mLinksetsStatus != NULL); - mFilterByName = findChild("filter_by_name"); - llassert(mFilterByName != NULL); - mFilterByName->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyFiltersClicked, this)); - mFilterByName->setSelectAllonFocusReceived(true); - mFilterByName->setCommitOnFocusLost(true); + mRefreshListButton = findChild("refresh_linksets_list"); + llassert(mRefreshListButton != NULL); + mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onRefreshLinksetsClicked, this)); - mFilterByDescription = findChild("filter_by_description"); - llassert(mFilterByDescription != NULL); - mFilterByDescription->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyFiltersClicked, this)); - mFilterByDescription->setSelectAllonFocusReceived(true); - mFilterByDescription->setCommitOnFocusLost(true); + mSelectAllButton = findChild("select_all_linksets"); + llassert(mSelectAllButton != NULL); + mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onSelectAllLinksetsClicked, this)); - mFilterByWalkable = findChild("filter_by_walkable"); - llassert(mFilterByWalkable != NULL); - mFilterByWalkable->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyFiltersClicked, this)); + mSelectNoneButton = findChild("select_none_linksets"); + llassert(mSelectNoneButton != NULL); + mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked, this)); - mFilterByObstacle = findChild("filter_by_obstacle"); - llassert(mFilterByObstacle != NULL); - mFilterByObstacle->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyFiltersClicked, this)); + mTakeButton = findChild("take_linksets"); + llassert(mTakeButton != NULL); + mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onTakeClicked, this)); - mFilterByIgnored = findChild("filter_by_ignored"); - llassert(mFilterByIgnored != NULL); - mFilterByIgnored->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyFiltersClicked, this)); + mTakeCopyButton = findChild("take_copy_linksets"); + llassert(mTakeCopyButton != NULL); + mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onTakeCopyClicked, this)); - mEditPathState = findChild("edit_path_state"); - llassert(mEditPathState != NULL); + mReturnButton = findChild("return_linksets"); + llassert(mReturnButton != NULL); + mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onReturnClicked, this)); - mEditPathStateWalkable = findChild("edit_pathing_state_walkable"); - llassert(mEditPathStateWalkable != NULL); + mDeleteButton = findChild("delete_linksets"); + llassert(mDeleteButton != NULL); + mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onDeleteClicked, this)); - mEditPathStateObstacle = findChild("edit_pathing_state_obstacle"); - llassert(mEditPathStateObstacle != NULL); + mTeleportButton = findChild("teleport_me_to_linkset"); + llassert(mTeleportButton != NULL); + mTeleportButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onTeleportClicked, this)); - mEditPathStateIgnored = findChild("edit_pathing_state_ignored"); - llassert(mEditPathStateIgnored != NULL); + mEditLinksetUse = findChild("edit_linkset_use"); + llassert(mEditLinksetUse != NULL); mLabelWalkabilityCoefficients = findChild("walkability_coefficients_label"); llassert(mLabelWalkabilityCoefficients != NULL); @@ -157,37 +172,34 @@ BOOL LLFloaterPathfindingLinksets::postBuild() mLabelEditA = findChild("edit_a_label"); llassert(mLabelEditA != NULL); - mLabelEditB = findChild("edit_b_label"); - llassert(mLabelEditB != NULL); - - mLabelEditC = findChild("edit_c_label"); - llassert(mLabelEditC != NULL); - - mLabelEditD = findChild("edit_d_label"); - llassert(mLabelEditD != NULL); - mEditA = findChild("edit_a_value"); llassert(mEditA != NULL); mEditA->setPrevalidate(LLTextValidate::validatePositiveS32); + mLabelEditB = findChild("edit_b_label"); + llassert(mLabelEditB != NULL); + mEditB = findChild("edit_b_value"); llassert(mEditB != NULL); mEditB->setPrevalidate(LLTextValidate::validatePositiveS32); + mLabelEditC = findChild("edit_c_label"); + llassert(mLabelEditC != NULL); + mEditC = findChild("edit_c_value"); llassert(mEditC != NULL); mEditC->setPrevalidate(LLTextValidate::validatePositiveS32); + mLabelEditD = findChild("edit_d_label"); + llassert(mLabelEditD != NULL); + mEditD = findChild("edit_d_value"); llassert(mEditD != NULL); mEditD->setPrevalidate(LLTextValidate::validatePositiveS32); - mEditPhantom = findChild("edit_phantom_value"); - llassert(mEditPhantom != NULL); - - mApplyEdits = findChild("apply_edit_values"); - llassert(mApplyEdits != NULL); - mApplyEdits->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyChangesClicked, this)); + mApplyEditsButton = findChild("apply_edit_values"); + llassert(mApplyEditsButton != NULL); + mApplyEditsButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyChangesClicked, this)); setEnableEditFields(false); setMessagingState(kMessagingInitial); @@ -235,30 +247,31 @@ BOOL LLFloaterPathfindingLinksets::isMessagingInProgress() const LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed) : LLFloater(pSeed), mSelfHandle(), - mPathfindingLinksets(), - mMessagingState(kMessagingInitial), - mLinksetsScrollList(NULL), - mLinksetsStatus(NULL), mFilterByName(NULL), mFilterByDescription(NULL), - mFilterByWalkable(NULL), - mFilterByObstacle(NULL), - mFilterByIgnored(NULL), - mEditPathState(NULL), - mEditPathStateWalkable(NULL), - mEditPathStateObstacle(NULL), - mEditPathStateIgnored(NULL), + mFilterByLinksetUse(NULL), + mLinksetsScrollList(NULL), + mLinksetsStatus(NULL), + mRefreshListButton(NULL), + mSelectAllButton(NULL), + mTakeButton(NULL), + mTakeCopyButton(NULL), + mReturnButton(NULL), + mDeleteButton(NULL), + mTeleportButton(NULL), + mEditLinksetUse(NULL), mLabelWalkabilityCoefficients(NULL), mLabelEditA(NULL), - mLabelEditB(NULL), - mLabelEditC(NULL), - mLabelEditD(NULL), mEditA(NULL), + mLabelEditB(NULL), mEditB(NULL), + mLabelEditC(NULL), mEditC(NULL), + mLabelEditD(NULL), mEditD(NULL), - mEditPhantom(NULL), - mApplyEdits(NULL) + mApplyEditsButton(NULL), + mPathfindingLinksets(), + mMessagingState(kMessagingInitial) { mSelfHandle.bind(this); } @@ -378,7 +391,7 @@ void LLFloaterPathfindingLinksets::setMessagingState(EMessagingState pMessagingS updateEditFields(); } -void LLFloaterPathfindingLinksets::onApplyFiltersClicked() +void LLFloaterPathfindingLinksets::onApplyAllFilters() { applyFilters(); } @@ -409,6 +422,31 @@ void LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked() selectNoneLinksets(); } +void LLFloaterPathfindingLinksets::onTakeClicked() +{ + llwarns << "functionality not yet implemented for " << mTakeButton->getName() << llendl; +} + +void LLFloaterPathfindingLinksets::onTakeCopyClicked() +{ + llwarns << "functionality not yet implemented for " << mTakeCopyButton->getName() << llendl; +} + +void LLFloaterPathfindingLinksets::onReturnClicked() +{ + llwarns << "functionality not yet implemented for " << mReturnButton->getName() << llendl; +} + +void LLFloaterPathfindingLinksets::onDeleteClicked() +{ + llwarns << "functionality not yet implemented for " << mDeleteButton->getName() << llendl; +} + +void LLFloaterPathfindingLinksets::onTeleportClicked() +{ + llwarns << "functionality not yet implemented for " << mTeleportButton->getName() << llendl; +} + void LLFloaterPathfindingLinksets::onApplyChangesClicked() { applyEditFields(); @@ -418,9 +456,7 @@ void LLFloaterPathfindingLinksets::applyFilters() { mPathfindingLinksets.setNameFilter(mFilterByName->getText()); mPathfindingLinksets.setDescriptionFilter(mFilterByDescription->getText()); - mPathfindingLinksets.setWalkableFilter(mFilterByWalkable->get()); - mPathfindingLinksets.setObstacleFilter(mFilterByObstacle->get()); - mPathfindingLinksets.setIgnoredFilter(mFilterByIgnored->get()); + mPathfindingLinksets.setLinksetUseFilter(getFilterLinksetUse()); updateLinksetsList(); } @@ -429,9 +465,7 @@ void LLFloaterPathfindingLinksets::clearFilters() mPathfindingLinksets.clearFilters(); mFilterByName->setText(LLStringExplicit(mPathfindingLinksets.getNameFilter())); mFilterByDescription->setText(LLStringExplicit(mPathfindingLinksets.getDescriptionFilter())); - mFilterByWalkable->set(mPathfindingLinksets.isWalkableFilter()); - mFilterByObstacle->set(mPathfindingLinksets.isObstacleFilter()); - mFilterByIgnored->set(mPathfindingLinksets.isIgnoredFilter()); + setFilterLinksetUse(mPathfindingLinksets.getLinksetUseFilter()); updateLinksetsList(); } @@ -480,45 +514,51 @@ void LLFloaterPathfindingLinksets::updateLinksetsList() columns[3]["value"] = llformat("%1.0f m", dist_vec(avatarPosition, linkset.getLocation())); columns[3]["font"] = "SANSSERIF"; - columns[4]["column"] = "path_state"; - switch (linkset.getPathState()) + columns[4]["column"] = "linkset_use"; + switch (linkset.getLinksetUse()) { case LLPathfindingLinkset::kWalkable : - columns[4]["value"] = getString("linkset_path_state_walkable"); + columns[4]["value"] = getString("linkset_use_walkable"); + break; + case LLPathfindingLinkset::kStaticObstacle : + columns[4]["value"] = getString("linkset_use_static_obstacle"); break; - case LLPathfindingLinkset::kObstacle : - columns[4]["value"] = getString("linkset_path_state_obstacle"); + case LLPathfindingLinkset::kDynamicObstacle : + columns[4]["value"] = getString("linkset_use_dynamic_obstacle"); break; - case LLPathfindingLinkset::kIgnored : - columns[4]["value"] = getString("linkset_path_state_ignored"); + case LLPathfindingLinkset::kMaterialVolume : + columns[4]["value"] = getString("linkset_use_material_volume"); break; + case LLPathfindingLinkset::kExclusionVolume : + columns[4]["value"] = getString("linkset_use_exclusion_volume"); + break; + case LLPathfindingLinkset::kDynamicPhantom : + columns[4]["value"] = getString("linkset_use_dynamic_phantom"); + break; + case LLPathfindingLinkset::kUnknown : default : - columns[4]["value"] = getString("linkset_path_state_ignored"); + columns[4]["value"] = getString("linkset_use_dynamic_obstacle"); llassert(0); break; } columns[4]["font"] = "SANSSERIF"; - columns[5]["column"] = "is_phantom"; - columns[5]["value"] = getString(linkset.isPhantom() ? "linkset_is_phantom" : "linkset_is_not_phantom"); + columns[5]["column"] = "a_percent"; + columns[5]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientA()); columns[5]["font"] = "SANSSERIF"; - columns[6]["column"] = "a_percent"; - columns[6]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientA()); + columns[6]["column"] = "b_percent"; + columns[6]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientB()); columns[6]["font"] = "SANSSERIF"; - columns[7]["column"] = "b_percent"; - columns[7]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientB()); + columns[7]["column"] = "c_percent"; + columns[7]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientC()); columns[7]["font"] = "SANSSERIF"; - columns[8]["column"] = "c_percent"; - columns[8]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientC()); + columns[8]["column"] = "d_percent"; + columns[8]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientD()); columns[8]["font"] = "SANSSERIF"; - columns[9]["column"] = "d_percent"; - columns[9]["value"] = llformat("%3d", linkset.getWalkabilityCoefficientD()); - columns[9]["font"] = "SANSSERIF"; - LLSD element; element["id"] = linkset.getUUID().asString(); element["column"] = columns; @@ -623,12 +663,11 @@ void LLFloaterPathfindingLinksets::updateEditFields() std::vector selectedItems = mLinksetsScrollList->getAllSelected(); if (selectedItems.empty()) { - mEditPathState->clear(); + mEditLinksetUse->clear(); mEditA->clear(); mEditB->clear(); mEditC->clear(); mEditD->clear(); - mEditPhantom->clear(); setEnableEditFields(false); } @@ -640,12 +679,11 @@ void LLFloaterPathfindingLinksets::updateEditFields() LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(firstItem->getUUID().asString()); const LLPathfindingLinkset &linkset(linksetIter->second); - setPathState(linkset.getPathState()); + setEditLinksetUse(linkset.getLinksetUse()); 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); } @@ -656,7 +694,7 @@ void LLFloaterPathfindingLinksets::applyEditFields() std::vector selectedItems = mLinksetsScrollList->getAllSelected(); if (!selectedItems.empty()) { - LLPathfindingLinkset::EPathState pathState = getPathState(); + LLPathfindingLinkset::ELinksetUse pathState = getEditLinksetUse(); const std::string &aString = mEditA->getText(); const std::string &bString = mEditB->getText(); const std::string &cString = mEditC->getText(); @@ -665,7 +703,6 @@ void LLFloaterPathfindingLinksets::applyEditFields() S32 bValue = static_cast(atoi(bString.c_str())); S32 cValue = static_cast(atoi(cString.c_str())); S32 dValue = static_cast(atoi(dString.c_str())); - BOOL isPhantom = mEditPhantom->getValue(); const LLFilteredPathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets(); @@ -679,7 +716,7 @@ void LLFloaterPathfindingLinksets::applyEditFields() const LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString()); const LLPathfindingLinkset &linkset = linksetIter->second; - LLSD itemData = linkset.encodeAlteredFields(pathState, aValue, bValue, cValue, dValue, isPhantom); + LLSD itemData = linkset.encodeAlteredFields(pathState, aValue, bValue, cValue, dValue); if (!itemData.isUndefined()) { @@ -700,10 +737,7 @@ void LLFloaterPathfindingLinksets::applyEditFields() void LLFloaterPathfindingLinksets::setEnableEditFields(BOOL pEnabled) { - mEditPathState->setEnabled(pEnabled); - mEditPathStateWalkable->setEnabled(pEnabled); - mEditPathStateObstacle->setEnabled(pEnabled); - mEditPathStateIgnored->setEnabled(pEnabled); + mEditLinksetUse->setEnabled(pEnabled); mLabelWalkabilityCoefficients->setEnabled(pEnabled); mLabelEditA->setEnabled(pEnabled); mLabelEditB->setEnabled(pEnabled); @@ -713,56 +747,99 @@ void LLFloaterPathfindingLinksets::setEnableEditFields(BOOL pEnabled) mEditB->setEnabled(pEnabled); mEditC->setEnabled(pEnabled); mEditD->setEnabled(pEnabled); - mEditPhantom->setEnabled(pEnabled); - mApplyEdits->setEnabled(pEnabled); + mApplyEditsButton->setEnabled(pEnabled); +} + +LLPathfindingLinkset::ELinksetUse LLFloaterPathfindingLinksets::getFilterLinksetUse() const +{ + return convertToLinksetUse(mFilterByLinksetUse->getValue()); +} + +void LLFloaterPathfindingLinksets::setFilterLinksetUse(LLPathfindingLinkset::ELinksetUse pLinksetUse) +{ + mFilterByLinksetUse->setValue(convertToXuiValue(pLinksetUse)); +} + +LLPathfindingLinkset::ELinksetUse LLFloaterPathfindingLinksets::getEditLinksetUse() const +{ + return convertToLinksetUse(mEditLinksetUse->getValue()); } -LLPathfindingLinkset::EPathState LLFloaterPathfindingLinksets::getPathState() const +void LLFloaterPathfindingLinksets::setEditLinksetUse(LLPathfindingLinkset::ELinksetUse pLinksetUse) { - LLPathfindingLinkset::EPathState pathState; + mEditLinksetUse->setValue(convertToXuiValue(pLinksetUse)); +} + +LLPathfindingLinkset::ELinksetUse LLFloaterPathfindingLinksets::convertToLinksetUse(LLSD pXuiValue) const +{ + LLPathfindingLinkset::ELinksetUse linkUse; - switch (mEditPathState->getValue().asInteger()) + switch (pXuiValue.asInteger()) { - case XUI_PATH_STATE_WALKABLE : - pathState = LLPathfindingLinkset::kWalkable; + case XUI_LINKSET_USE_NONE : + linkUse = LLPathfindingLinkset::kUnknown; + break; + case XUI_LINKSET_USE_WALKABLE : + linkUse = LLPathfindingLinkset::kWalkable; + break; + case XUI_LINKSET_USE_STATIC_OBSTACLE : + linkUse = LLPathfindingLinkset::kStaticObstacle; + break; + case XUI_LINKSET_USE_DYNAMIC_OBSTACLE : + linkUse = LLPathfindingLinkset::kDynamicObstacle; break; - case XUI_PATH_STATE_OBSTACLE : - pathState = LLPathfindingLinkset::kObstacle; + case XUI_LINKSET_USE_MATERIAL_VOLUME : + linkUse = LLPathfindingLinkset::kMaterialVolume; break; - case XUI_PATH_STATE_IGNORED : - pathState = LLPathfindingLinkset::kIgnored; + case XUI_LINKSET_USE_EXCLUSION_VOLUME : + linkUse = LLPathfindingLinkset::kExclusionVolume; + break; + case XUI_LINKSET_USE_DYNAMIC_PHANTOM : + linkUse = LLPathfindingLinkset::kDynamicPhantom; break; default : - pathState = LLPathfindingLinkset::kIgnored; + linkUse = LLPathfindingLinkset::kUnknown; llassert(0); break; } - return pathState; + return linkUse; } -void LLFloaterPathfindingLinksets::setPathState(LLPathfindingLinkset::EPathState pPathState) +LLSD LLFloaterPathfindingLinksets::convertToXuiValue(LLPathfindingLinkset::ELinksetUse pLinksetUse) const { - LLSD radioGroupValue; + LLSD xuiValue; - switch (pPathState) + switch (pLinksetUse) { + case LLPathfindingLinkset::kUnknown : + xuiValue = XUI_LINKSET_USE_NONE; + break; case LLPathfindingLinkset::kWalkable : - radioGroupValue = XUI_PATH_STATE_WALKABLE; + xuiValue = XUI_LINKSET_USE_WALKABLE; + break; + case LLPathfindingLinkset::kStaticObstacle : + xuiValue = XUI_LINKSET_USE_STATIC_OBSTACLE; + break; + case LLPathfindingLinkset::kDynamicObstacle : + xuiValue = XUI_LINKSET_USE_DYNAMIC_OBSTACLE; + break; + case LLPathfindingLinkset::kMaterialVolume : + xuiValue = XUI_LINKSET_USE_MATERIAL_VOLUME; break; - case LLPathfindingLinkset::kObstacle : - radioGroupValue = XUI_PATH_STATE_OBSTACLE; + case LLPathfindingLinkset::kExclusionVolume : + xuiValue = XUI_LINKSET_USE_EXCLUSION_VOLUME; break; - case LLPathfindingLinkset::kIgnored : - radioGroupValue = XUI_PATH_STATE_IGNORED; + case LLPathfindingLinkset::kDynamicPhantom : + xuiValue = XUI_LINKSET_USE_DYNAMIC_PHANTOM; break; default : - radioGroupValue = XUI_PATH_STATE_IGNORED; + xuiValue = XUI_LINKSET_USE_NONE; llassert(0); break; } - mEditPathState->setValue(radioGroupValue); + return xuiValue; } //--------------------------------------------------------------------------- diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h index ce266b1706..229b5daa77 100644 --- a/indra/newview/llfloaterpathfindinglinksets.h +++ b/indra/newview/llfloaterpathfindinglinksets.h @@ -38,8 +38,7 @@ class LLSD; class LLTextBase; class LLScrollListCtrl; class LLLineEditor; -class LLCheckBoxCtrl; -class LLRadioGroup; +class LLComboBox; class LLButton; class LLFloaterPathfindingLinksets @@ -78,30 +77,32 @@ protected: private: LLRootHandle mSelfHandle; - LLFilteredPathfindingLinksets mPathfindingLinksets; - EMessagingState mMessagingState; - LLScrollListCtrl *mLinksetsScrollList; - LLTextBase *mLinksetsStatus; LLLineEditor *mFilterByName; LLLineEditor *mFilterByDescription; - LLCheckBoxCtrl *mFilterByWalkable; - LLCheckBoxCtrl *mFilterByObstacle; - LLCheckBoxCtrl *mFilterByIgnored; - LLRadioGroup *mEditPathState; - LLUICtrl *mEditPathStateWalkable; - LLUICtrl *mEditPathStateObstacle; - LLUICtrl *mEditPathStateIgnored; + LLComboBox *mFilterByLinksetUse; + LLScrollListCtrl *mLinksetsScrollList; + LLTextBase *mLinksetsStatus; + LLButton *mRefreshListButton; + LLButton *mSelectAllButton; + LLButton *mSelectNoneButton; + LLButton *mTakeButton; + LLButton *mTakeCopyButton; + LLButton *mReturnButton; + LLButton *mDeleteButton; + LLButton *mTeleportButton; + LLComboBox *mEditLinksetUse; LLTextBase *mLabelWalkabilityCoefficients; LLTextBase *mLabelEditA; - LLTextBase *mLabelEditB; - LLTextBase *mLabelEditC; - LLTextBase *mLabelEditD; LLLineEditor *mEditA; + LLTextBase *mLabelEditB; LLLineEditor *mEditB; + LLTextBase *mLabelEditC; LLLineEditor *mEditC; + LLTextBase *mLabelEditD; LLLineEditor *mEditD; - LLCheckBoxCtrl *mEditPhantom; - LLButton *mApplyEdits; + LLButton *mApplyEditsButton; + LLFilteredPathfindingLinksets mPathfindingLinksets; + EMessagingState mMessagingState; // Does its own instance management, so clients not allowed // to allocate or destroy. @@ -120,12 +121,17 @@ private: void setMessagingState(EMessagingState pMessagingState); - void onApplyFiltersClicked(); + void onApplyAllFilters(); void onClearFiltersClicked(); void onLinksetsSelectionChange(); void onRefreshLinksetsClicked(); void onSelectAllLinksetsClicked(); void onSelectNoneLinksetsClicked(); + void onTakeClicked(); + void onTakeCopyClicked(); + void onReturnClicked(); + void onDeleteClicked(); + void onTeleportClicked(); void onApplyChangesClicked(); void applyFilters(); @@ -141,8 +147,14 @@ private: void applyEditFields(); void setEnableEditFields(BOOL pEnabled); - LLPathfindingLinkset::EPathState getPathState() const; - void setPathState(LLPathfindingLinkset::EPathState pPathState); + LLPathfindingLinkset::ELinksetUse getFilterLinksetUse() const; + void setFilterLinksetUse(LLPathfindingLinkset::ELinksetUse pLinksetUse); + + LLPathfindingLinkset::ELinksetUse getEditLinksetUse() const; + void setEditLinksetUse(LLPathfindingLinkset::ELinksetUse pLinksetUse); + + LLPathfindingLinkset::ELinksetUse convertToLinksetUse(LLSD pXuiValue) const; + LLSD convertToXuiValue(LLPathfindingLinkset::ELinksetUse pLinksetUse) const; }; #endif // LL_LLFLOATERPATHFINDINGLINKSETS_H diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index daa308f862..48f8ceaa8a 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -56,8 +56,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mDescription(), mLandImpact(0U), mLocation(), - mPathState(kIgnored), - mIsPhantom(false), + mLinksetUse(kUnknown), #ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE mIsWalkabilityCoefficientsF32(false), #endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE @@ -79,6 +78,10 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); mLandImpact = pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger(); + llassert(pLinksetItem.has(LINKSET_PHANTOM_FIELD)); + llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); + bool isPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean(); + llassert(pLinksetItem.has(LINKSET_PERMANENT_FIELD)); llassert(pLinksetItem.get(LINKSET_PERMANENT_FIELD).isBoolean()); bool isPermanent = pLinksetItem.get(LINKSET_PERMANENT_FIELD).asBoolean(); @@ -87,11 +90,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& llassert(pLinksetItem.get(LINKSET_WALKABLE_FIELD).isBoolean()); bool isWalkable = pLinksetItem.get(LINKSET_WALKABLE_FIELD).asBoolean(); - mPathState = getPathState(isPermanent, isWalkable); - - llassert(pLinksetItem.has(LINKSET_PHANTOM_FIELD)); - llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); - mIsPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean(); + mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); #ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE @@ -175,8 +174,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) mDescription(pOther.mDescription), mLandImpact(pOther.mLandImpact), mLocation(pOther.mLocation), - mPathState(pOther.mPathState), - mIsPhantom(pOther.mIsPhantom), + mLinksetUse(pOther.mLinksetUse), #ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE mIsWalkabilityCoefficientsF32(pOther.mIsWalkabilityCoefficientsF32), #endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE @@ -198,8 +196,7 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse mDescription = pOther.mDescription; mLandImpact = pOther.mLandImpact; mLocation = pOther.mLocation; - mPathState = pOther.mPathState; - mIsPhantom = pOther.mIsPhantom; + mLinksetUse = pOther.mLinksetUse; #ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE mIsWalkabilityCoefficientsF32 = pOther.mIsWalkabilityCoefficientsF32; #endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE @@ -211,56 +208,6 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse return *this; } - -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; -} - void LLPathfindingLinkset::setWalkabilityCoefficientA(S32 pA) { mWalkabilityCoefficientA = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); @@ -281,14 +228,16 @@ void LLPathfindingLinkset::setWalkabilityCoefficientD(S32 pD) mWalkabilityCoefficientD = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } -LLSD LLPathfindingLinkset::encodeAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const +LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const { LLSD itemData; - if (mPathState != pPathState) + if (mLinksetUse != pLinksetUse) { - itemData[LINKSET_PERMANENT_FIELD] = static_cast(LLPathfindingLinkset::isPermanent(pPathState)); - itemData[LINKSET_WALKABLE_FIELD] = static_cast(LLPathfindingLinkset::isWalkable(pPathState)); + llassert(pLinksetUse != kUnknown); + itemData[LINKSET_PHANTOM_FIELD] = static_cast(LLPathfindingLinkset::isPhantom(pLinksetUse)); + itemData[LINKSET_PERMANENT_FIELD] = static_cast(LLPathfindingLinkset::isPermanent(pLinksetUse)); + itemData[LINKSET_WALKABLE_FIELD] = static_cast(LLPathfindingLinkset::isWalkable(pLinksetUse)); } #ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE if (mIsWalkabilityCoefficientsF32) @@ -347,10 +296,90 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(EPathState pPathState, S32 pA, S3 itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } #endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE - if (mIsPhantom != pIsPhantom) + + return itemData; +} + +LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable) +{ + return (pIsPhantom ? (pIsPermanent ? (pIsWalkable ? kMaterialVolume : kExclusionVolume) : kDynamicPhantom) : + (pIsPermanent ? (pIsWalkable ? kWalkable : kStaticObstacle) : kDynamicObstacle)); +} + +BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) +{ + BOOL retVal; + + switch (pLinksetUse) { - itemData[LINKSET_PHANTOM_FIELD] = static_cast(pIsPhantom); + case kWalkable : + case kStaticObstacle : + case kDynamicObstacle : + retVal = false; + break; + case kMaterialVolume : + case kExclusionVolume : + case kDynamicPhantom : + retVal = true; + break; + case kUnknown : + default : + retVal = false; + llassert(0); + break; } - return itemData; + return retVal; +} + +BOOL LLPathfindingLinkset::isPermanent(ELinksetUse pLinksetUse) +{ + BOOL retVal; + + switch (pLinksetUse) + { + case kWalkable : + case kStaticObstacle : + case kMaterialVolume : + case kExclusionVolume : + retVal = true; + break; + case kDynamicObstacle : + case kDynamicPhantom : + retVal = false; + break; + case kUnknown : + default : + retVal = false; + llassert(0); + break; + } + + return retVal; +} + +BOOL LLPathfindingLinkset::isWalkable(ELinksetUse pLinksetUse) +{ + BOOL retVal; + + switch (pLinksetUse) + { + case kWalkable : + case kMaterialVolume : + retVal = true; + break; + case kStaticObstacle : + case kDynamicObstacle : + case kExclusionVolume : + case kDynamicPhantom : + retVal = false; + break; + case kUnknown : + default : + retVal = false; + llassert(0); + break; + } + + return retVal; } diff --git a/indra/newview/llpathfindinglinkset.h b/indra/newview/llpathfindinglinkset.h index d4e58874eb..58d72b1430 100644 --- a/indra/newview/llpathfindinglinkset.h +++ b/indra/newview/llpathfindinglinkset.h @@ -42,10 +42,14 @@ class LLPathfindingLinkset public: typedef enum { + kUnknown, kWalkable, - kObstacle, - kIgnored - } EPathState; + kStaticObstacle, + kDynamicObstacle, + kMaterialVolume, + kExclusionVolume, + kDynamicPhantom + } ELinksetUse; LLPathfindingLinkset(const std::string &pUUID, const LLSD &pLinksetItem); LLPathfindingLinkset(const LLPathfindingLinkset& pOther); @@ -53,21 +57,14 @@ public: LLPathfindingLinkset& operator = (const LLPathfindingLinkset& pOther); - inline const LLUUID& getUUID() const {return mUUID;}; - inline const std::string& getName() const {return mName;}; - inline const std::string& getDescription() const {return mDescription;}; - inline U32 getLandImpact() const {return mLandImpact;}; - inline const LLVector3& getLocation() const {return mLocation;}; + inline const LLUUID& getUUID() const {return mUUID;}; + inline const std::string& getName() const {return mName;}; + inline const std::string& getDescription() const {return mDescription;}; + inline U32 getLandImpact() const {return mLandImpact;}; + inline const LLVector3& getLocation() const {return mLocation;}; - inline EPathState getPathState() const {return mPathState;}; - inline void setPathState(EPathState pPathState) {mPathState = pPathState;}; - - static EPathState getPathState(bool pIsPermanent, bool pIsWalkable); - static BOOL isPermanent(EPathState pPathState); - static BOOL isWalkable(EPathState pPathState); - - inline BOOL isPhantom() const {return mIsPhantom;}; - inline void setPhantom(BOOL pIsPhantom) {mIsPhantom = pIsPhantom;}; + inline ELinksetUse getLinksetUse() const {return mLinksetUse;}; + inline void setLinksetUse(ELinksetUse pLinksetUse) {mLinksetUse = pLinksetUse;}; inline S32 getWalkabilityCoefficientA() const {return mWalkabilityCoefficientA;}; void setWalkabilityCoefficientA(S32 pA); @@ -81,28 +78,32 @@ public: inline S32 getWalkabilityCoefficientD() const {return mWalkabilityCoefficientD;}; void setWalkabilityCoefficientD(S32 pD); - LLSD encodeAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const; + LLSD encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const; protected: private: + static ELinksetUse getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable); + static BOOL isPhantom(ELinksetUse pLinksetUse); + static BOOL isPermanent(ELinksetUse pLinksetUse); + static BOOL isWalkable(ELinksetUse pLinksetUse); + 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; + LLUUID mUUID; + std::string mName; + std::string mDescription; + U32 mLandImpact; + LLVector3 mLocation; + ELinksetUse mLinksetUse; #ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE - BOOL mIsWalkabilityCoefficientsF32; + BOOL mIsWalkabilityCoefficientsF32; #endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE - S32 mWalkabilityCoefficientA; - S32 mWalkabilityCoefficientB; - S32 mWalkabilityCoefficientC; - S32 mWalkabilityCoefficientD; + S32 mWalkabilityCoefficientA; + S32 mWalkabilityCoefficientB; + S32 mWalkabilityCoefficientC; + S32 mWalkabilityCoefficientD; }; #endif // LL_LLPATHFINDINGLINKSET_H diff --git a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml index ec720b55ca..badade9661 100644 --- a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml +++ b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml @@ -3,9 +3,9 @@ open_positioning="cascading" can_resize="true" can_tear_off="false" - height="330" + height="382" width="950" - min_height="330" + min_height="382" min_width="950" layout="topleft" name="floater_pathfinding_linksets" @@ -27,401 +27,503 @@ No pathfinding linksets [NUM_SELECTED] linksets selected out of [NUM_TOTAL] Required capability is not available in current region - Walkable - Obstacle - Ignored - Phantom - -- - - Filter by: - - - Name - - - - Description - - - - - -