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.2.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/llpathfindinglinkset.cpp | 158 ++++++++++++++++++--------------- 1 file changed, 85 insertions(+), 73 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') 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; -- cgit v1.2.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/llpathfindinglinkset.cpp | 165 +++++++++++++++++++-------------- 1 file changed, 97 insertions(+), 68 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') 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; } -- cgit v1.2.3 From ad08e72cfa85960e2db9e1d5bed413c8612e7afa Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 16 Feb 2012 15:04:33 -0800 Subject: Removing some old code checking for both the float and integer versions of the walkability coefficients. All server-side code has these values as integers now. --- indra/newview/llpathfindinglinkset.cpp | 101 ++------------------------------- 1 file changed, 4 insertions(+), 97 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 48f8ceaa8a..641f1de16b 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -57,9 +57,6 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mLandImpact(0U), mLocation(), mLinksetUse(kUnknown), -#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), @@ -93,52 +90,6 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); -#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE - mIsWalkabilityCoefficientsF32 = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isReal(); - if (mIsWalkabilityCoefficientsF32) - { - // Old server-side storage was real - mWalkabilityCoefficientA = llround(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).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(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(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(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(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(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(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(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); mWalkabilityCoefficientA = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asInteger(); llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE); @@ -161,7 +112,6 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& 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(pLinksetItem.has(LINKSET_POSITION_FIELD)); llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); @@ -175,9 +125,6 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) mLandImpact(pOther.mLandImpact), mLocation(pOther.mLocation), mLinksetUse(pOther.mLinksetUse), -#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), @@ -197,9 +144,6 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse mLandImpact = pOther.mLandImpact; mLocation = pOther.mLocation; mLinksetUse = pOther.mLinksetUse; -#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; @@ -239,63 +183,26 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, 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) - { - if (mWalkabilityCoefficientA != pA) - { - itemData[LINKSET_WALKABILITY_A_FIELD] = llclamp(static_cast(pA) / 100.0f, 0.0f, 1.0f); - } - if (mWalkabilityCoefficientB != pB) - { - itemData[LINKSET_WALKABILITY_B_FIELD] = llclamp(static_cast(pB) / 100.0f, 0.0f, 1.0f); - } - if (mWalkabilityCoefficientC != pC) - { - itemData[LINKSET_WALKABILITY_C_FIELD] = llclamp(static_cast(pC) / 100.0f, 0.0f, 1.0f); - } - if (mWalkabilityCoefficientD != pD) - { - itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(static_cast(pD) / 100.0f, 0.0f, 1.0f); - } - } - else - { - if (mWalkabilityCoefficientA != pA) - { - itemData[LINKSET_WALKABILITY_A_FIELD] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); - } - if (mWalkabilityCoefficientB != pB) - { - itemData[LINKSET_WALKABILITY_B_FIELD] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); - } - if (mWalkabilityCoefficientC != pC) - { - itemData[LINKSET_WALKABILITY_C_FIELD] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); - } - if (mWalkabilityCoefficientD != pD) - { - itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); - } - } -#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE + if (mWalkabilityCoefficientA != pA) { itemData[LINKSET_WALKABILITY_A_FIELD] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } + if (mWalkabilityCoefficientB != pB) { itemData[LINKSET_WALKABILITY_B_FIELD] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } + if (mWalkabilityCoefficientC != pC) { itemData[LINKSET_WALKABILITY_C_FIELD] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } + if (mWalkabilityCoefficientD != pD) { itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); } -#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE return itemData; } -- cgit v1.2.3 From 3960e8f49d19bc929f6986504856c06df78160dd Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 16 Feb 2012 17:23:57 -0800 Subject: PATH-292: Clearing up an assert case that could happen in practice. --- indra/newview/llpathfindinglinkset.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 641f1de16b..de17edbf61 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -176,9 +176,8 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, { LLSD itemData; - if (mLinksetUse != pLinksetUse) + if ((pLinksetUse != kUnknown) && (mLinksetUse != pLinksetUse)) { - 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)); -- cgit v1.2.3 From 73aa47f391341e6d6ef5136ef73302be689d3e9d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 23 Feb 2012 16:51:06 -0800 Subject: PATH-292: Reworking how and where linksets are requested and managed. --- indra/newview/llpathfindinglinkset.cpp | 37 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index de17edbf61..d775ec2fef 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -34,6 +34,7 @@ #define LINKSET_NAME_FIELD "name" #define LINKSET_DESCRIPTION_FIELD "description" #define LINKSET_LAND_IMPACT_FIELD "landimpact" +#define LINKSET_MODIFIABLE_FIELD "modifiable" #define LINKSET_PERMANENT_FIELD "permanent" #define LINKSET_WALKABLE_FIELD "walkable" #define LINKSET_PHANTOM_FIELD "phantom" @@ -55,7 +56,8 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mName(), mDescription(), mLandImpact(0U), - mLocation(), + mLocation(LLVector3::zero), + mIsLocked(FALSE), mLinksetUse(kUnknown), mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), @@ -75,6 +77,12 @@ 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(); + if (pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)) + { + llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsLocked = !pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + } + llassert(pLinksetItem.has(LINKSET_PHANTOM_FIELD)); llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); bool isPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean(); @@ -124,6 +132,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) mDescription(pOther.mDescription), mLandImpact(pOther.mLandImpact), mLocation(pOther.mLocation), + mIsLocked(pOther.mIsLocked), mLinksetUse(pOther.mLinksetUse), mWalkabilityCoefficientA(pOther.mWalkabilityCoefficientA), mWalkabilityCoefficientB(pOther.mWalkabilityCoefficientB), @@ -143,6 +152,7 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse mDescription = pOther.mDescription; mLandImpact = pOther.mLandImpact; mLocation = pOther.mLocation; + // mIsLocked = pOther.mIsLocked; XXX stinson 02/23/2012 : disabling temporarily until all sim-service responses include the modifiable state mLinksetUse = pOther.mLinksetUse; mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; mWalkabilityCoefficientB = pOther.mWalkabilityCoefficientB; @@ -152,33 +162,16 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse return *this; } -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::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const { LLSD itemData; if ((pLinksetUse != kUnknown) && (mLinksetUse != pLinksetUse)) { - itemData[LINKSET_PHANTOM_FIELD] = static_cast(LLPathfindingLinkset::isPhantom(pLinksetUse)); + if (!mIsLocked) + { + 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)); } -- cgit v1.2.3 From 9b06300e2c94eae83a29637073f65d4ffc73bf6d Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Sat, 25 Feb 2012 22:27:06 -0800 Subject: PATH-292: Adding the ability to view and edit pathfinding attributes of the terrain. --- indra/newview/llpathfindinglinkset.cpp | 152 ++++++++++++++++++++------------- 1 file changed, 91 insertions(+), 61 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index d775ec2fef..9df9968332 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -51,8 +51,26 @@ const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0); const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100); +LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) + : mUUID(), + mIsTerrain(true), + mName(), + mDescription(), + mLandImpact(0U), + mLocation(LLVector3::zero), + mIsLocked(TRUE), + mLinksetUse(kUnknown), + mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) +{ + parsePathfindingData(pTerrainLinksetItem); +} + LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetItem) : mUUID(pUUID), + mIsTerrain(false), mName(), mDescription(), mLandImpact(0U), @@ -64,66 +82,8 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) { - llassert(pLinksetItem.has(LINKSET_NAME_FIELD)); - llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString()); - mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString(); - - llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD)); - llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString()); - mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString(); - - 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(); - - if (pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)) - { - llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsLocked = !pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); - } - - 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(); - - llassert(pLinksetItem.has(LINKSET_WALKABLE_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABLE_FIELD).isBoolean()); - bool isWalkable = pLinksetItem.get(LINKSET_WALKABLE_FIELD).asBoolean(); - - mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); - - llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); - 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(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(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(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); - - llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); - llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); - mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD)); + parseObjectData(pLinksetItem); + parsePathfindingData(pLinksetItem); } LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) @@ -166,7 +126,7 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, { LLSD itemData; - if ((pLinksetUse != kUnknown) && (mLinksetUse != pLinksetUse)) + if (!isTerrain() && (pLinksetUse != kUnknown) && (mLinksetUse != pLinksetUse)) { if (!mIsLocked) { @@ -199,6 +159,76 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, return itemData; } +void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) +{ + llassert(pLinksetItem.has(LINKSET_NAME_FIELD)); + llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString()); + mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString(); + + llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD)); + llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString()); + mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString(); + + 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(); + + if (pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)) + { + llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsLocked = !pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + } + + llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); + llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); + mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD)); +} + +void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem) +{ + bool isPhantom = false; + if (pLinksetItem.has(LINKSET_PHANTOM_FIELD)) + { + llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); + 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(); + + llassert(pLinksetItem.has(LINKSET_WALKABLE_FIELD)); + llassert(pLinksetItem.get(LINKSET_WALKABLE_FIELD).isBoolean()); + bool isWalkable = pLinksetItem.get(LINKSET_WALKABLE_FIELD).asBoolean(); + + mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); + + llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); + 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(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(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(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); +} + LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable) { return (pIsPhantom ? (pIsPermanent ? (pIsWalkable ? kMaterialVolume : kExclusionVolume) : kDynamicPhantom) : -- cgit v1.2.3 From 974510262081b20dd1256b8e538cebb07b38ae38 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Sat, 25 Feb 2012 22:42:27 -0800 Subject: Replacing the asserts that the modifiable bit is sent across now with the latest server deploys. --- indra/newview/llpathfindinglinkset.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 9df9968332..5f4389ffe1 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -112,7 +112,7 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse mDescription = pOther.mDescription; mLandImpact = pOther.mLandImpact; mLocation = pOther.mLocation; - // mIsLocked = pOther.mIsLocked; XXX stinson 02/23/2012 : disabling temporarily until all sim-service responses include the modifiable state + mIsLocked = pOther.mIsLocked; mLinksetUse = pOther.mLinksetUse; mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; mWalkabilityCoefficientB = pOther.mWalkabilityCoefficientB; @@ -174,11 +174,9 @@ void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); mLandImpact = pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger(); - if (pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)) - { - llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsLocked = !pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); - } + llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)); + llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsLocked = !pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); -- cgit v1.2.3 From 518bc51e668570beeec5f13fd2f3cc4d28f66551 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 27 Feb 2012 15:43:58 -0800 Subject: PATH-292: Adding better usability and warning notifications for the handling of locked linksets. --- indra/newview/llpathfindinglinkset.cpp | 66 ++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 26 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 5f4389ffe1..33c66ff764 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -122,6 +122,46 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse return *this; } +BOOL LLPathfindingLinkset::isPhantom() const +{ + return isPhantom(getLinksetUse()); +} + +BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) +{ + BOOL retVal; + + switch (pLinksetUse) + { + 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 retVal; +} + +LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse) +{ + BOOL isPhantom = LLPathfindingLinkset::isPhantom(pLinksetUse); + BOOL isPermanent = LLPathfindingLinkset::isPermanent(pLinksetUse); + BOOL isWalkable = LLPathfindingLinkset::isWalkable(pLinksetUse); + + return getLinksetUse(!isPhantom, isPermanent, isWalkable); +} + LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const { LLSD itemData; @@ -233,32 +273,6 @@ LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPh (pIsPermanent ? (pIsWalkable ? kWalkable : kStaticObstacle) : kDynamicObstacle)); } -BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) -{ - BOOL retVal; - - switch (pLinksetUse) - { - 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 retVal; -} - BOOL LLPathfindingLinkset::isPermanent(ELinksetUse pLinksetUse) { BOOL retVal; -- cgit v1.2.3 From 10ab7acd3a9f62c0dfd2c91990f528ae3598010a Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 27 Feb 2012 17:43:16 -0800 Subject: PATH-292: Ensuring that the terrain linkset use is clearly called out as unmodifiable. --- indra/newview/llpathfindinglinkset.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 33c66ff764..1578494241 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -58,7 +58,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) mDescription(), mLandImpact(0U), mLocation(LLVector3::zero), - mIsLocked(TRUE), + mIsModifiable(TRUE), mLinksetUse(kUnknown), mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), @@ -75,7 +75,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mDescription(), mLandImpact(0U), mLocation(LLVector3::zero), - mIsLocked(FALSE), + mIsModifiable(TRUE), mLinksetUse(kUnknown), mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), @@ -92,7 +92,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) mDescription(pOther.mDescription), mLandImpact(pOther.mLandImpact), mLocation(pOther.mLocation), - mIsLocked(pOther.mIsLocked), + mIsModifiable(pOther.mIsModifiable), mLinksetUse(pOther.mLinksetUse), mWalkabilityCoefficientA(pOther.mWalkabilityCoefficientA), mWalkabilityCoefficientB(pOther.mWalkabilityCoefficientB), @@ -112,7 +112,7 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse mDescription = pOther.mDescription; mLandImpact = pOther.mLandImpact; mLocation = pOther.mLocation; - mIsLocked = pOther.mIsLocked; + mIsModifiable = pOther.mIsModifiable; mLinksetUse = pOther.mLinksetUse; mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; mWalkabilityCoefficientB = pOther.mWalkabilityCoefficientB; @@ -168,7 +168,7 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, if (!isTerrain() && (pLinksetUse != kUnknown) && (mLinksetUse != pLinksetUse)) { - if (!mIsLocked) + if (mIsModifiable) { itemData[LINKSET_PHANTOM_FIELD] = static_cast(LLPathfindingLinkset::isPhantom(pLinksetUse)); } @@ -216,7 +216,7 @@ void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)); llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsLocked = !pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); -- cgit v1.2.3 From 36d7de33b2cf0fe749e95044dbc8be89c1673555 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 6 Mar 2012 12:12:35 -0800 Subject: Updating the pathfinding linksets service to reference the new navmesh category field. Also, still supporting the old permanent/walkable field names until fully deprecated from all server builds. --- indra/newview/llpathfindinglinkset.cpp | 197 ++++++++++++++++++++++++++++----- 1 file changed, 171 insertions(+), 26 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 1578494241..8144c7e4c6 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -31,18 +31,25 @@ #include "v3math.h" #include "lluuid.h" -#define LINKSET_NAME_FIELD "name" -#define LINKSET_DESCRIPTION_FIELD "description" -#define LINKSET_LAND_IMPACT_FIELD "landimpact" -#define LINKSET_MODIFIABLE_FIELD "modifiable" -#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" +#define LINKSET_NAME_FIELD "name" +#define LINKSET_DESCRIPTION_FIELD "description" +#define LINKSET_LAND_IMPACT_FIELD "landimpact" +#define LINKSET_MODIFIABLE_FIELD "modifiable" +#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS +#define DEPRECATED_LINKSET_PERMANENT_FIELD "permanent" +#define DEPRECATED_LINKSET_WALKABLE_FIELD "walkable" +#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS +#define LINKSET_CATEGORY_FIELD "navmesh_category" +#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" + +#define LINKSET_CATEGORY_VALUE_INCLUDE 0 +#define LINKSET_CATEGORY_VALUE_EXCLUDE 1 +#define LINKSET_CATEGORY_VALUE_IGNORE 2 //--------------------------------------------------------------------------- // LLPathfindingLinkset @@ -156,10 +163,9 @@ BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse) { BOOL isPhantom = LLPathfindingLinkset::isPhantom(pLinksetUse); - BOOL isPermanent = LLPathfindingLinkset::isPermanent(pLinksetUse); - BOOL isWalkable = LLPathfindingLinkset::isWalkable(pLinksetUse); + ENavMeshGenerationCategory navMeshGenerationCategory = getNavMeshGenerationCategory(pLinksetUse); - return getLinksetUse(!isPhantom, isPermanent, isWalkable); + return getLinksetUse(!isPhantom, navMeshGenerationCategory); } LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const @@ -172,8 +178,11 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, { 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 DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + itemData[DEPRECATED_LINKSET_PERMANENT_FIELD] = static_cast(LLPathfindingLinkset::isPermanent(pLinksetUse)); + itemData[DEPRECATED_LINKSET_WALKABLE_FIELD] = static_cast(LLPathfindingLinkset::isWalkable(pLinksetUse)); +#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + itemData[LINKSET_CATEGORY_FIELD] = convertCategoryToLLSD(getNavMeshGenerationCategory(pLinksetUse)); } if (mWalkabilityCoefficientA != pA) @@ -232,15 +241,27 @@ void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem) 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(); - - llassert(pLinksetItem.has(LINKSET_WALKABLE_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABLE_FIELD).isBoolean()); - bool isWalkable = pLinksetItem.get(LINKSET_WALKABLE_FIELD).asBoolean(); - - mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); +#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + if (pLinksetItem.has(LINKSET_CATEGORY_FIELD)) + { + mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); + } + else + { + llassert(pLinksetItem.has(DEPRECATED_LINKSET_PERMANENT_FIELD)); + llassert(pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean()); + bool isPermanent = pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean(); + + llassert(pLinksetItem.has(DEPRECATED_LINKSET_WALKABLE_FIELD)); + llassert(pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean()); + bool isWalkable = pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean(); + + mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); + } +#else // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + llassert(pLinksetItem.has(LINKSET_CATEGORY_FIELD)); + mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); +#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); llassert(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); @@ -267,6 +288,7 @@ void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem) llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE); } +#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable) { return (pIsPhantom ? (pIsPermanent ? (pIsWalkable ? kMaterialVolume : kExclusionVolume) : kDynamicPhantom) : @@ -324,3 +346,126 @@ BOOL LLPathfindingLinkset::isWalkable(ELinksetUse pLinksetUse) return retVal; } +#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + +LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, ENavMeshGenerationCategory pNavMeshGenerationCategory) +{ + ELinksetUse linksetUse = kUnknown; + + if (pIsPhantom) + { + switch (pNavMeshGenerationCategory) + { + case kNavMeshGenerationIgnore : + linksetUse = kDynamicPhantom; + break; + case kNavMeshGenerationInclude : + linksetUse = kMaterialVolume; + break; + case kNavMeshGenerationExclude : + linksetUse = kExclusionVolume; + break; + default : + linksetUse = kUnknown; + llassert(0); + break; + } + } + else + { + switch (pNavMeshGenerationCategory) + { + case kNavMeshGenerationIgnore : + linksetUse = kDynamicObstacle; + break; + case kNavMeshGenerationInclude : + linksetUse = kWalkable; + break; + case kNavMeshGenerationExclude : + linksetUse = kStaticObstacle; + break; + default : + linksetUse = kUnknown; + llassert(0); + break; + } + } + + return linksetUse; +} + +LLPathfindingLinkset::ENavMeshGenerationCategory LLPathfindingLinkset::getNavMeshGenerationCategory(ELinksetUse pLinksetUse) +{ + ENavMeshGenerationCategory navMeshGenerationCategory; + switch (pLinksetUse) + { + case kWalkable : + case kMaterialVolume : + navMeshGenerationCategory = kNavMeshGenerationInclude; + break; + case kStaticObstacle : + case kExclusionVolume : + navMeshGenerationCategory = kNavMeshGenerationExclude; + break; + case kDynamicObstacle : + case kDynamicPhantom : + navMeshGenerationCategory = kNavMeshGenerationIgnore; + break; + case kUnknown : + default : + navMeshGenerationCategory = kNavMeshGenerationIgnore; + llassert(0); + break; + } + + return navMeshGenerationCategory; +} + +LLSD LLPathfindingLinkset::convertCategoryToLLSD(ENavMeshGenerationCategory pNavMeshGenerationCategory) +{ + LLSD llsd; + + switch (pNavMeshGenerationCategory) + { + case kNavMeshGenerationIgnore : + llsd = static_cast(LINKSET_CATEGORY_VALUE_IGNORE); + break; + case kNavMeshGenerationInclude : + llsd = static_cast(LINKSET_CATEGORY_VALUE_INCLUDE); + break; + case kNavMeshGenerationExclude : + llsd = static_cast(LINKSET_CATEGORY_VALUE_EXCLUDE); + break; + default : + llsd = static_cast(LINKSET_CATEGORY_VALUE_IGNORE); + llassert(0); + break; + } + + return llsd; +} + +LLPathfindingLinkset::ENavMeshGenerationCategory LLPathfindingLinkset::convertCategoryFromLLSD(const LLSD &llsd) +{ + ENavMeshGenerationCategory navMeshGenerationCategory; + + llassert(llsd.isInteger()); + switch (llsd.asInteger()) + { + case LINKSET_CATEGORY_VALUE_IGNORE : + navMeshGenerationCategory = kNavMeshGenerationIgnore; + break; + case LINKSET_CATEGORY_VALUE_INCLUDE : + navMeshGenerationCategory = kNavMeshGenerationInclude; + break; + case LINKSET_CATEGORY_VALUE_EXCLUDE : + navMeshGenerationCategory = kNavMeshGenerationExclude; + break; + default : + navMeshGenerationCategory = kNavMeshGenerationIgnore; + llassert(0); + break; + } + + return navMeshGenerationCategory; +} -- cgit v1.2.3 From e4537a06857589ee7dbae1199c7bbf2f639457ab Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 6 Mar 2012 12:26:49 -0800 Subject: Putting into place a work-around for missing "modifiable" field datum in the linksets service. --- indra/newview/llpathfindinglinkset.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 8144c7e4c6..1300022e8b 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -65,6 +65,9 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) mDescription(), mLandImpact(0U), mLocation(LLVector3::zero), +#ifdef MISSING_MODIFIABLE_FIELD_WAR + mHasModifiable(true), +#endif // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable(TRUE), mLinksetUse(kUnknown), mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), @@ -82,6 +85,9 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mDescription(), mLandImpact(0U), mLocation(LLVector3::zero), +#ifdef MISSING_MODIFIABLE_FIELD_WAR + mHasModifiable(false), +#endif // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable(TRUE), mLinksetUse(kUnknown), mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), @@ -99,7 +105,12 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) mDescription(pOther.mDescription), mLandImpact(pOther.mLandImpact), mLocation(pOther.mLocation), +#ifdef MISSING_MODIFIABLE_FIELD_WAR + mHasModifiable(pOther.mHasModifiable), + mIsModifiable(pOther.mHasModifiable ? pOther.mIsModifiable : TRUE), +#else // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable(pOther.mIsModifiable), +#endif // MISSING_MODIFIABLE_FIELD_WAR mLinksetUse(pOther.mLinksetUse), mWalkabilityCoefficientA(pOther.mWalkabilityCoefficientA), mWalkabilityCoefficientB(pOther.mWalkabilityCoefficientB), @@ -119,7 +130,15 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse mDescription = pOther.mDescription; mLandImpact = pOther.mLandImpact; mLocation = pOther.mLocation; +#ifdef MISSING_MODIFIABLE_FIELD_WAR + if (pOther.mHasModifiable) + { + mHasModifiable = pOther.mHasModifiable; + mIsModifiable = pOther.mIsModifiable; + } +#else // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable = pOther.mIsModifiable; +#endif // MISSING_MODIFIABLE_FIELD_WAR mLinksetUse = pOther.mLinksetUse; mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; mWalkabilityCoefficientB = pOther.mWalkabilityCoefficientB; @@ -223,9 +242,18 @@ void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); mLandImpact = pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger(); +#ifdef MISSING_MODIFIABLE_FIELD_WAR + mHasModifiable = pLinksetItem.has(LINKSET_MODIFIABLE_FIELD); + if (mHasModifiable) + { + llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + } +#else // MISSING_MODIFIABLE_FIELD_WAR llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)); llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); +#endif // MISSING_MODIFIABLE_FIELD_WAR llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); -- cgit v1.2.3 From d3550dfcd64cfc182fd120338d3e7eb25ac339af Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 19 Mar 2012 16:24:51 -0700 Subject: Adding non-volume status to the pathfinding linkset to restrict non-convex linksets from being set to be a material or exclusion volume. --- indra/newview/llpathfindinglinkset.cpp | 99 +++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 38 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 1300022e8b..f2d95d9221 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -31,15 +31,16 @@ #include "v3math.h" #include "lluuid.h" -#define LINKSET_NAME_FIELD "name" -#define LINKSET_DESCRIPTION_FIELD "description" -#define LINKSET_LAND_IMPACT_FIELD "landimpact" -#define LINKSET_MODIFIABLE_FIELD "modifiable" +#define LINKSET_NAME_FIELD "name" +#define LINKSET_DESCRIPTION_FIELD "description" +#define LINKSET_LAND_IMPACT_FIELD "landimpact" +#define LINKSET_MODIFIABLE_FIELD "modifiable" #ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS -#define DEPRECATED_LINKSET_PERMANENT_FIELD "permanent" +#define DEPRECATED_LINKSET_PERMANENT_FIELD "permanent" #define DEPRECATED_LINKSET_WALKABLE_FIELD "walkable" #endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS #define LINKSET_CATEGORY_FIELD "navmesh_category" +#define LINKSET_CAN_BE_VOLUME "can_be_volume" #define LINKSET_PHANTOM_FIELD "phantom" #define LINKSET_WALKABILITY_A_FIELD "A" #define LINKSET_WALKABILITY_B_FIELD "B" @@ -68,7 +69,8 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) #ifdef MISSING_MODIFIABLE_FIELD_WAR mHasModifiable(true), #endif // MISSING_MODIFIABLE_FIELD_WAR - mIsModifiable(TRUE), + mIsModifiable(FALSE), + mCanBeVolume(FALSE), mLinksetUse(kUnknown), mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), @@ -89,6 +91,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mHasModifiable(false), #endif // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable(TRUE), + mCanBeVolume(TRUE), mLinksetUse(kUnknown), mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), @@ -111,6 +114,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) #else // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable(pOther.mIsModifiable), #endif // MISSING_MODIFIABLE_FIELD_WAR + mCanBeVolume(pOther.mCanBeVolume), mLinksetUse(pOther.mLinksetUse), mWalkabilityCoefficientA(pOther.mWalkabilityCoefficientA), mWalkabilityCoefficientB(pOther.mWalkabilityCoefficientB), @@ -139,6 +143,7 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse #else // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable = pOther.mIsModifiable; #endif // MISSING_MODIFIABLE_FIELD_WAR + mCanBeVolume = pOther.mCanBeVolume; mLinksetUse = pOther.mLinksetUse; mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; mWalkabilityCoefficientB = pOther.mWalkabilityCoefficientB; @@ -153,32 +158,6 @@ BOOL LLPathfindingLinkset::isPhantom() const return isPhantom(getLinksetUse()); } -BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) -{ - BOOL retVal; - - switch (pLinksetUse) - { - 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 retVal; -} - LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse) { BOOL isPhantom = LLPathfindingLinkset::isPhantom(pLinksetUse); @@ -187,19 +166,31 @@ LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUseWithToggled return getLinksetUse(!isPhantom, navMeshGenerationCategory); } +bool LLPathfindingLinkset::isShowUnmodifiablePhantomWarning(ELinksetUse pLinksetUse) const +{ + return (!isModifiable() && (isPhantom() != isPhantom(pLinksetUse))); +} + +bool LLPathfindingLinkset::isShowCannotBeVolumeWarning(ELinksetUse pLinksetUse) const +{ + return (!canBeVolume() && ((pLinksetUse == kMaterialVolume) || (pLinksetUse == kExclusionVolume))); +} + LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const { LLSD itemData; - if (!isTerrain() && (pLinksetUse != kUnknown) && (mLinksetUse != pLinksetUse)) + if (!isTerrain() && (pLinksetUse != kUnknown) && (getLinksetUse() != pLinksetUse) && + (canBeVolume() || ((pLinksetUse != kMaterialVolume) && (pLinksetUse != kExclusionVolume)))) { - if (mIsModifiable) + if (isModifiable()) { - itemData[LINKSET_PHANTOM_FIELD] = static_cast(LLPathfindingLinkset::isPhantom(pLinksetUse)); + itemData[LINKSET_PHANTOM_FIELD] = static_cast(isPhantom(pLinksetUse)); } + #ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - itemData[DEPRECATED_LINKSET_PERMANENT_FIELD] = static_cast(LLPathfindingLinkset::isPermanent(pLinksetUse)); - itemData[DEPRECATED_LINKSET_WALKABLE_FIELD] = static_cast(LLPathfindingLinkset::isWalkable(pLinksetUse)); + itemData[DEPRECATED_LINKSET_PERMANENT_FIELD] = static_cast(isPermanent(pLinksetUse)); + itemData[DEPRECATED_LINKSET_WALKABLE_FIELD] = static_cast(isWalkable(pLinksetUse)); #endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS itemData[LINKSET_CATEGORY_FIELD] = convertCategoryToLLSD(getNavMeshGenerationCategory(pLinksetUse)); } @@ -290,7 +281,13 @@ void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem) llassert(pLinksetItem.has(LINKSET_CATEGORY_FIELD)); mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); #endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - + + if (pLinksetItem.has(LINKSET_CAN_BE_VOLUME)) + { + llassert(pLinksetItem.get(LINKSET_CAN_BE_VOLUME).isBoolean()); + mCanBeVolume = pLinksetItem.get(LINKSET_CAN_BE_VOLUME).asBoolean(); + } + llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); llassert(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); mWalkabilityCoefficientA = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asInteger(); @@ -376,6 +373,32 @@ BOOL LLPathfindingLinkset::isWalkable(ELinksetUse pLinksetUse) } #endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS +BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) +{ + BOOL retVal; + + switch (pLinksetUse) + { + 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 retVal; +} + LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, ENavMeshGenerationCategory pNavMeshGenerationCategory) { ELinksetUse linksetUse = kUnknown; -- cgit v1.2.3 From cbebd682f7b9b0cff120bc36d9db9bb170dc1b2a Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 25 Apr 2012 13:04:13 -0700 Subject: Removing windows line endings from .h and .cpp files. --- indra/newview/llpathfindinglinkset.cpp | 1044 ++++++++++++++++---------------- 1 file changed, 522 insertions(+), 522 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index f2d95d9221..e7478870ca 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -1,522 +1,522 @@ -/** - * @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" - -#define LINKSET_NAME_FIELD "name" -#define LINKSET_DESCRIPTION_FIELD "description" -#define LINKSET_LAND_IMPACT_FIELD "landimpact" -#define LINKSET_MODIFIABLE_FIELD "modifiable" -#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS -#define DEPRECATED_LINKSET_PERMANENT_FIELD "permanent" -#define DEPRECATED_LINKSET_WALKABLE_FIELD "walkable" -#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS -#define LINKSET_CATEGORY_FIELD "navmesh_category" -#define LINKSET_CAN_BE_VOLUME "can_be_volume" -#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" - -#define LINKSET_CATEGORY_VALUE_INCLUDE 0 -#define LINKSET_CATEGORY_VALUE_EXCLUDE 1 -#define LINKSET_CATEGORY_VALUE_IGNORE 2 - -//--------------------------------------------------------------------------- -// LLPathfindingLinkset -//--------------------------------------------------------------------------- - -const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0); -const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100); - -LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) - : mUUID(), - mIsTerrain(true), - mName(), - mDescription(), - mLandImpact(0U), - mLocation(LLVector3::zero), -#ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable(true), -#endif // MISSING_MODIFIABLE_FIELD_WAR - mIsModifiable(FALSE), - mCanBeVolume(FALSE), - mLinksetUse(kUnknown), - mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), - mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), - mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), - mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) -{ - parsePathfindingData(pTerrainLinksetItem); -} - -LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetItem) - : mUUID(pUUID), - mIsTerrain(false), - mName(), - mDescription(), - mLandImpact(0U), - mLocation(LLVector3::zero), -#ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable(false), -#endif // MISSING_MODIFIABLE_FIELD_WAR - mIsModifiable(TRUE), - mCanBeVolume(TRUE), - mLinksetUse(kUnknown), - mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), - mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), - mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), - mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) -{ - parseObjectData(pLinksetItem); - parsePathfindingData(pLinksetItem); -} - -LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) - : mUUID(pOther.mUUID), - mName(pOther.mName), - mDescription(pOther.mDescription), - mLandImpact(pOther.mLandImpact), - mLocation(pOther.mLocation), -#ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable(pOther.mHasModifiable), - mIsModifiable(pOther.mHasModifiable ? pOther.mIsModifiable : TRUE), -#else // MISSING_MODIFIABLE_FIELD_WAR - mIsModifiable(pOther.mIsModifiable), -#endif // MISSING_MODIFIABLE_FIELD_WAR - mCanBeVolume(pOther.mCanBeVolume), - mLinksetUse(pOther.mLinksetUse), - 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; -#ifdef MISSING_MODIFIABLE_FIELD_WAR - if (pOther.mHasModifiable) - { - mHasModifiable = pOther.mHasModifiable; - mIsModifiable = pOther.mIsModifiable; - } -#else // MISSING_MODIFIABLE_FIELD_WAR - mIsModifiable = pOther.mIsModifiable; -#endif // MISSING_MODIFIABLE_FIELD_WAR - mCanBeVolume = pOther.mCanBeVolume; - mLinksetUse = pOther.mLinksetUse; - mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; - mWalkabilityCoefficientB = pOther.mWalkabilityCoefficientB; - mWalkabilityCoefficientC = pOther.mWalkabilityCoefficientC; - mWalkabilityCoefficientD = pOther.mWalkabilityCoefficientD; - - return *this; -} - -BOOL LLPathfindingLinkset::isPhantom() const -{ - return isPhantom(getLinksetUse()); -} - -LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse) -{ - BOOL isPhantom = LLPathfindingLinkset::isPhantom(pLinksetUse); - ENavMeshGenerationCategory navMeshGenerationCategory = getNavMeshGenerationCategory(pLinksetUse); - - return getLinksetUse(!isPhantom, navMeshGenerationCategory); -} - -bool LLPathfindingLinkset::isShowUnmodifiablePhantomWarning(ELinksetUse pLinksetUse) const -{ - return (!isModifiable() && (isPhantom() != isPhantom(pLinksetUse))); -} - -bool LLPathfindingLinkset::isShowCannotBeVolumeWarning(ELinksetUse pLinksetUse) const -{ - return (!canBeVolume() && ((pLinksetUse == kMaterialVolume) || (pLinksetUse == kExclusionVolume))); -} - -LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const -{ - LLSD itemData; - - if (!isTerrain() && (pLinksetUse != kUnknown) && (getLinksetUse() != pLinksetUse) && - (canBeVolume() || ((pLinksetUse != kMaterialVolume) && (pLinksetUse != kExclusionVolume)))) - { - if (isModifiable()) - { - itemData[LINKSET_PHANTOM_FIELD] = static_cast(isPhantom(pLinksetUse)); - } - -#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - itemData[DEPRECATED_LINKSET_PERMANENT_FIELD] = static_cast(isPermanent(pLinksetUse)); - itemData[DEPRECATED_LINKSET_WALKABLE_FIELD] = static_cast(isWalkable(pLinksetUse)); -#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - itemData[LINKSET_CATEGORY_FIELD] = convertCategoryToLLSD(getNavMeshGenerationCategory(pLinksetUse)); - } - - if (mWalkabilityCoefficientA != pA) - { - itemData[LINKSET_WALKABILITY_A_FIELD] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); - } - - if (mWalkabilityCoefficientB != pB) - { - itemData[LINKSET_WALKABILITY_B_FIELD] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); - } - - if (mWalkabilityCoefficientC != pC) - { - itemData[LINKSET_WALKABILITY_C_FIELD] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); - } - - if (mWalkabilityCoefficientD != pD) - { - itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); - } - - return itemData; -} - -void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) -{ - llassert(pLinksetItem.has(LINKSET_NAME_FIELD)); - llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString()); - mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString(); - - llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD)); - llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString()); - mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString(); - - 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(); - -#ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable = pLinksetItem.has(LINKSET_MODIFIABLE_FIELD); - if (mHasModifiable) - { - llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); - } -#else // MISSING_MODIFIABLE_FIELD_WAR - llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)); - llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); -#endif // MISSING_MODIFIABLE_FIELD_WAR - - llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); - llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); - mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD)); -} - -void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem) -{ - bool isPhantom = false; - if (pLinksetItem.has(LINKSET_PHANTOM_FIELD)) - { - llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); - isPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean(); - } - -#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - if (pLinksetItem.has(LINKSET_CATEGORY_FIELD)) - { - mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); - } - else - { - llassert(pLinksetItem.has(DEPRECATED_LINKSET_PERMANENT_FIELD)); - llassert(pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean()); - bool isPermanent = pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean(); - - llassert(pLinksetItem.has(DEPRECATED_LINKSET_WALKABLE_FIELD)); - llassert(pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean()); - bool isWalkable = pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean(); - - mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); - } -#else // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - llassert(pLinksetItem.has(LINKSET_CATEGORY_FIELD)); - mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); -#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - - if (pLinksetItem.has(LINKSET_CAN_BE_VOLUME)) - { - llassert(pLinksetItem.get(LINKSET_CAN_BE_VOLUME).isBoolean()); - mCanBeVolume = pLinksetItem.get(LINKSET_CAN_BE_VOLUME).asBoolean(); - } - - llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); - 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(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(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(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); -} - -#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS -LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable) -{ - return (pIsPhantom ? (pIsPermanent ? (pIsWalkable ? kMaterialVolume : kExclusionVolume) : kDynamicPhantom) : - (pIsPermanent ? (pIsWalkable ? kWalkable : kStaticObstacle) : kDynamicObstacle)); -} - -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; -} -#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - -BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) -{ - BOOL retVal; - - switch (pLinksetUse) - { - 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 retVal; -} - -LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, ENavMeshGenerationCategory pNavMeshGenerationCategory) -{ - ELinksetUse linksetUse = kUnknown; - - if (pIsPhantom) - { - switch (pNavMeshGenerationCategory) - { - case kNavMeshGenerationIgnore : - linksetUse = kDynamicPhantom; - break; - case kNavMeshGenerationInclude : - linksetUse = kMaterialVolume; - break; - case kNavMeshGenerationExclude : - linksetUse = kExclusionVolume; - break; - default : - linksetUse = kUnknown; - llassert(0); - break; - } - } - else - { - switch (pNavMeshGenerationCategory) - { - case kNavMeshGenerationIgnore : - linksetUse = kDynamicObstacle; - break; - case kNavMeshGenerationInclude : - linksetUse = kWalkable; - break; - case kNavMeshGenerationExclude : - linksetUse = kStaticObstacle; - break; - default : - linksetUse = kUnknown; - llassert(0); - break; - } - } - - return linksetUse; -} - -LLPathfindingLinkset::ENavMeshGenerationCategory LLPathfindingLinkset::getNavMeshGenerationCategory(ELinksetUse pLinksetUse) -{ - ENavMeshGenerationCategory navMeshGenerationCategory; - switch (pLinksetUse) - { - case kWalkable : - case kMaterialVolume : - navMeshGenerationCategory = kNavMeshGenerationInclude; - break; - case kStaticObstacle : - case kExclusionVolume : - navMeshGenerationCategory = kNavMeshGenerationExclude; - break; - case kDynamicObstacle : - case kDynamicPhantom : - navMeshGenerationCategory = kNavMeshGenerationIgnore; - break; - case kUnknown : - default : - navMeshGenerationCategory = kNavMeshGenerationIgnore; - llassert(0); - break; - } - - return navMeshGenerationCategory; -} - -LLSD LLPathfindingLinkset::convertCategoryToLLSD(ENavMeshGenerationCategory pNavMeshGenerationCategory) -{ - LLSD llsd; - - switch (pNavMeshGenerationCategory) - { - case kNavMeshGenerationIgnore : - llsd = static_cast(LINKSET_CATEGORY_VALUE_IGNORE); - break; - case kNavMeshGenerationInclude : - llsd = static_cast(LINKSET_CATEGORY_VALUE_INCLUDE); - break; - case kNavMeshGenerationExclude : - llsd = static_cast(LINKSET_CATEGORY_VALUE_EXCLUDE); - break; - default : - llsd = static_cast(LINKSET_CATEGORY_VALUE_IGNORE); - llassert(0); - break; - } - - return llsd; -} - -LLPathfindingLinkset::ENavMeshGenerationCategory LLPathfindingLinkset::convertCategoryFromLLSD(const LLSD &llsd) -{ - ENavMeshGenerationCategory navMeshGenerationCategory; - - llassert(llsd.isInteger()); - switch (llsd.asInteger()) - { - case LINKSET_CATEGORY_VALUE_IGNORE : - navMeshGenerationCategory = kNavMeshGenerationIgnore; - break; - case LINKSET_CATEGORY_VALUE_INCLUDE : - navMeshGenerationCategory = kNavMeshGenerationInclude; - break; - case LINKSET_CATEGORY_VALUE_EXCLUDE : - navMeshGenerationCategory = kNavMeshGenerationExclude; - break; - default : - navMeshGenerationCategory = kNavMeshGenerationIgnore; - llassert(0); - break; - } - - return navMeshGenerationCategory; -} +/** + * @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" + +#define LINKSET_NAME_FIELD "name" +#define LINKSET_DESCRIPTION_FIELD "description" +#define LINKSET_LAND_IMPACT_FIELD "landimpact" +#define LINKSET_MODIFIABLE_FIELD "modifiable" +#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS +#define DEPRECATED_LINKSET_PERMANENT_FIELD "permanent" +#define DEPRECATED_LINKSET_WALKABLE_FIELD "walkable" +#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS +#define LINKSET_CATEGORY_FIELD "navmesh_category" +#define LINKSET_CAN_BE_VOLUME "can_be_volume" +#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" + +#define LINKSET_CATEGORY_VALUE_INCLUDE 0 +#define LINKSET_CATEGORY_VALUE_EXCLUDE 1 +#define LINKSET_CATEGORY_VALUE_IGNORE 2 + +//--------------------------------------------------------------------------- +// LLPathfindingLinkset +//--------------------------------------------------------------------------- + +const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0); +const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100); + +LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) + : mUUID(), + mIsTerrain(true), + mName(), + mDescription(), + mLandImpact(0U), + mLocation(LLVector3::zero), +#ifdef MISSING_MODIFIABLE_FIELD_WAR + mHasModifiable(true), +#endif // MISSING_MODIFIABLE_FIELD_WAR + mIsModifiable(FALSE), + mCanBeVolume(FALSE), + mLinksetUse(kUnknown), + mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) +{ + parsePathfindingData(pTerrainLinksetItem); +} + +LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetItem) + : mUUID(pUUID), + mIsTerrain(false), + mName(), + mDescription(), + mLandImpact(0U), + mLocation(LLVector3::zero), +#ifdef MISSING_MODIFIABLE_FIELD_WAR + mHasModifiable(false), +#endif // MISSING_MODIFIABLE_FIELD_WAR + mIsModifiable(TRUE), + mCanBeVolume(TRUE), + mLinksetUse(kUnknown), + mWalkabilityCoefficientA(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientB(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), + mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) +{ + parseObjectData(pLinksetItem); + parsePathfindingData(pLinksetItem); +} + +LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) + : mUUID(pOther.mUUID), + mName(pOther.mName), + mDescription(pOther.mDescription), + mLandImpact(pOther.mLandImpact), + mLocation(pOther.mLocation), +#ifdef MISSING_MODIFIABLE_FIELD_WAR + mHasModifiable(pOther.mHasModifiable), + mIsModifiable(pOther.mHasModifiable ? pOther.mIsModifiable : TRUE), +#else // MISSING_MODIFIABLE_FIELD_WAR + mIsModifiable(pOther.mIsModifiable), +#endif // MISSING_MODIFIABLE_FIELD_WAR + mCanBeVolume(pOther.mCanBeVolume), + mLinksetUse(pOther.mLinksetUse), + 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; +#ifdef MISSING_MODIFIABLE_FIELD_WAR + if (pOther.mHasModifiable) + { + mHasModifiable = pOther.mHasModifiable; + mIsModifiable = pOther.mIsModifiable; + } +#else // MISSING_MODIFIABLE_FIELD_WAR + mIsModifiable = pOther.mIsModifiable; +#endif // MISSING_MODIFIABLE_FIELD_WAR + mCanBeVolume = pOther.mCanBeVolume; + mLinksetUse = pOther.mLinksetUse; + mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; + mWalkabilityCoefficientB = pOther.mWalkabilityCoefficientB; + mWalkabilityCoefficientC = pOther.mWalkabilityCoefficientC; + mWalkabilityCoefficientD = pOther.mWalkabilityCoefficientD; + + return *this; +} + +BOOL LLPathfindingLinkset::isPhantom() const +{ + return isPhantom(getLinksetUse()); +} + +LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse) +{ + BOOL isPhantom = LLPathfindingLinkset::isPhantom(pLinksetUse); + ENavMeshGenerationCategory navMeshGenerationCategory = getNavMeshGenerationCategory(pLinksetUse); + + return getLinksetUse(!isPhantom, navMeshGenerationCategory); +} + +bool LLPathfindingLinkset::isShowUnmodifiablePhantomWarning(ELinksetUse pLinksetUse) const +{ + return (!isModifiable() && (isPhantom() != isPhantom(pLinksetUse))); +} + +bool LLPathfindingLinkset::isShowCannotBeVolumeWarning(ELinksetUse pLinksetUse) const +{ + return (!canBeVolume() && ((pLinksetUse == kMaterialVolume) || (pLinksetUse == kExclusionVolume))); +} + +LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const +{ + LLSD itemData; + + if (!isTerrain() && (pLinksetUse != kUnknown) && (getLinksetUse() != pLinksetUse) && + (canBeVolume() || ((pLinksetUse != kMaterialVolume) && (pLinksetUse != kExclusionVolume)))) + { + if (isModifiable()) + { + itemData[LINKSET_PHANTOM_FIELD] = static_cast(isPhantom(pLinksetUse)); + } + +#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + itemData[DEPRECATED_LINKSET_PERMANENT_FIELD] = static_cast(isPermanent(pLinksetUse)); + itemData[DEPRECATED_LINKSET_WALKABLE_FIELD] = static_cast(isWalkable(pLinksetUse)); +#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + itemData[LINKSET_CATEGORY_FIELD] = convertCategoryToLLSD(getNavMeshGenerationCategory(pLinksetUse)); + } + + if (mWalkabilityCoefficientA != pA) + { + itemData[LINKSET_WALKABILITY_A_FIELD] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + + if (mWalkabilityCoefficientB != pB) + { + itemData[LINKSET_WALKABILITY_B_FIELD] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + + if (mWalkabilityCoefficientC != pC) + { + itemData[LINKSET_WALKABILITY_C_FIELD] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + + if (mWalkabilityCoefficientD != pD) + { + itemData[LINKSET_WALKABILITY_D_FIELD] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE); + } + + return itemData; +} + +void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) +{ + llassert(pLinksetItem.has(LINKSET_NAME_FIELD)); + llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString()); + mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString(); + + llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD)); + llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString()); + mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString(); + + 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(); + +#ifdef MISSING_MODIFIABLE_FIELD_WAR + mHasModifiable = pLinksetItem.has(LINKSET_MODIFIABLE_FIELD); + if (mHasModifiable) + { + llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + } +#else // MISSING_MODIFIABLE_FIELD_WAR + llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)); + llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); +#endif // MISSING_MODIFIABLE_FIELD_WAR + + llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); + llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); + mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD)); +} + +void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem) +{ + bool isPhantom = false; + if (pLinksetItem.has(LINKSET_PHANTOM_FIELD)) + { + llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); + isPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean(); + } + +#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + if (pLinksetItem.has(LINKSET_CATEGORY_FIELD)) + { + mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); + } + else + { + llassert(pLinksetItem.has(DEPRECATED_LINKSET_PERMANENT_FIELD)); + llassert(pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean()); + bool isPermanent = pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean(); + + llassert(pLinksetItem.has(DEPRECATED_LINKSET_WALKABLE_FIELD)); + llassert(pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean()); + bool isWalkable = pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean(); + + mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); + } +#else // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + llassert(pLinksetItem.has(LINKSET_CATEGORY_FIELD)); + mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); +#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + + if (pLinksetItem.has(LINKSET_CAN_BE_VOLUME)) + { + llassert(pLinksetItem.get(LINKSET_CAN_BE_VOLUME).isBoolean()); + mCanBeVolume = pLinksetItem.get(LINKSET_CAN_BE_VOLUME).asBoolean(); + } + + llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); + 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(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(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(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); +} + +#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS +LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable) +{ + return (pIsPhantom ? (pIsPermanent ? (pIsWalkable ? kMaterialVolume : kExclusionVolume) : kDynamicPhantom) : + (pIsPermanent ? (pIsWalkable ? kWalkable : kStaticObstacle) : kDynamicObstacle)); +} + +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; +} +#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS + +BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) +{ + BOOL retVal; + + switch (pLinksetUse) + { + 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 retVal; +} + +LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, ENavMeshGenerationCategory pNavMeshGenerationCategory) +{ + ELinksetUse linksetUse = kUnknown; + + if (pIsPhantom) + { + switch (pNavMeshGenerationCategory) + { + case kNavMeshGenerationIgnore : + linksetUse = kDynamicPhantom; + break; + case kNavMeshGenerationInclude : + linksetUse = kMaterialVolume; + break; + case kNavMeshGenerationExclude : + linksetUse = kExclusionVolume; + break; + default : + linksetUse = kUnknown; + llassert(0); + break; + } + } + else + { + switch (pNavMeshGenerationCategory) + { + case kNavMeshGenerationIgnore : + linksetUse = kDynamicObstacle; + break; + case kNavMeshGenerationInclude : + linksetUse = kWalkable; + break; + case kNavMeshGenerationExclude : + linksetUse = kStaticObstacle; + break; + default : + linksetUse = kUnknown; + llassert(0); + break; + } + } + + return linksetUse; +} + +LLPathfindingLinkset::ENavMeshGenerationCategory LLPathfindingLinkset::getNavMeshGenerationCategory(ELinksetUse pLinksetUse) +{ + ENavMeshGenerationCategory navMeshGenerationCategory; + switch (pLinksetUse) + { + case kWalkable : + case kMaterialVolume : + navMeshGenerationCategory = kNavMeshGenerationInclude; + break; + case kStaticObstacle : + case kExclusionVolume : + navMeshGenerationCategory = kNavMeshGenerationExclude; + break; + case kDynamicObstacle : + case kDynamicPhantom : + navMeshGenerationCategory = kNavMeshGenerationIgnore; + break; + case kUnknown : + default : + navMeshGenerationCategory = kNavMeshGenerationIgnore; + llassert(0); + break; + } + + return navMeshGenerationCategory; +} + +LLSD LLPathfindingLinkset::convertCategoryToLLSD(ENavMeshGenerationCategory pNavMeshGenerationCategory) +{ + LLSD llsd; + + switch (pNavMeshGenerationCategory) + { + case kNavMeshGenerationIgnore : + llsd = static_cast(LINKSET_CATEGORY_VALUE_IGNORE); + break; + case kNavMeshGenerationInclude : + llsd = static_cast(LINKSET_CATEGORY_VALUE_INCLUDE); + break; + case kNavMeshGenerationExclude : + llsd = static_cast(LINKSET_CATEGORY_VALUE_EXCLUDE); + break; + default : + llsd = static_cast(LINKSET_CATEGORY_VALUE_IGNORE); + llassert(0); + break; + } + + return llsd; +} + +LLPathfindingLinkset::ENavMeshGenerationCategory LLPathfindingLinkset::convertCategoryFromLLSD(const LLSD &llsd) +{ + ENavMeshGenerationCategory navMeshGenerationCategory; + + llassert(llsd.isInteger()); + switch (llsd.asInteger()) + { + case LINKSET_CATEGORY_VALUE_IGNORE : + navMeshGenerationCategory = kNavMeshGenerationIgnore; + break; + case LINKSET_CATEGORY_VALUE_INCLUDE : + navMeshGenerationCategory = kNavMeshGenerationInclude; + break; + case LINKSET_CATEGORY_VALUE_EXCLUDE : + navMeshGenerationCategory = kNavMeshGenerationExclude; + break; + default : + navMeshGenerationCategory = kNavMeshGenerationIgnore; + llassert(0); + break; + } + + return navMeshGenerationCategory; +} -- cgit v1.2.3 From d4e5e180f82a8d959b88cc3eb1f69a3fff238d6a Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 9 May 2012 18:04:45 -0700 Subject: Adding an owner field to the pathfinding linksets console. Making the scroll list just wide enough for the additional field, but not cleaning up the rest of the floater until Leo has a chance to review. --- indra/newview/llpathfindinglinkset.cpp | 43 ++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index e7478870ca..e2ece8794f 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -26,13 +26,18 @@ */ #include "llviewerprecompiledheaders.h" + #include "llpathfindinglinkset.h" -#include "llsd.h" + #include "v3math.h" +#include "llavatarname.h" +#include "llavatarnamecache.h" +#include "llsd.h" #include "lluuid.h" #define LINKSET_NAME_FIELD "name" #define LINKSET_DESCRIPTION_FIELD "description" +#define LINKSET_OWNER_FIELD "owner" #define LINKSET_LAND_IMPACT_FIELD "landimpact" #define LINKSET_MODIFIABLE_FIELD "modifiable" #ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS @@ -64,6 +69,8 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) mIsTerrain(true), mName(), mDescription(), + mOwnerUUID(), + mOwnerName(), mLandImpact(0U), mLocation(LLVector3::zero), #ifdef MISSING_MODIFIABLE_FIELD_WAR @@ -85,6 +92,8 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mIsTerrain(false), mName(), mDescription(), + mOwnerUUID(), + mOwnerName(), mLandImpact(0U), mLocation(LLVector3::zero), #ifdef MISSING_MODIFIABLE_FIELD_WAR @@ -106,6 +115,8 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) : mUUID(pOther.mUUID), mName(pOther.mName), mDescription(pOther.mDescription), + mOwnerUUID(pOther.mOwnerUUID), + mOwnerName(pOther.mOwnerName), mLandImpact(pOther.mLandImpact), mLocation(pOther.mLocation), #ifdef MISSING_MODIFIABLE_FIELD_WAR @@ -132,6 +143,8 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse mUUID = pOther.mUUID; mName = pOther.mName; mDescription = pOther.mDescription; + mOwnerUUID = pOther.mOwnerUUID; + mOwnerName = pOther.mOwnerName; mLandImpact = pOther.mLandImpact; mLocation = pOther.mLocation; #ifdef MISSING_MODIFIABLE_FIELD_WAR @@ -153,6 +166,18 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse return *this; } +std::string LLPathfindingLinkset::getOwnerName() const +{ + std::string ownerName; + + if (hasOwnerName()) + { + ownerName = mOwnerName.getCompleteName(); + } + + return ownerName; +} + BOOL LLPathfindingLinkset::isPhantom() const { return isPhantom(getLinksetUse()); @@ -227,7 +252,21 @@ void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD)); llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString()); mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString(); - + +#ifdef SERVER_SIDE_OWNER_ROLLOUT_COMPLETE + llassert(pLinksetItem.has(LINKSET_OWNER_FIELD)); + llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID()); + mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID(); + LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); +#else // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE + if (pLinksetItem.has(LINKSET_OWNER_FIELD)) + { + llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID()); + mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID(); + LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); + } +#endif // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE + llassert(pLinksetItem.has(LINKSET_LAND_IMPACT_FIELD)); llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).isInteger()); llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); -- cgit v1.2.3 From 3c2be426e5e905076d00b9492c0e66c8b31caf19 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 30 May 2012 18:47:12 -0700 Subject: First pass at refactoring the pathfinding linksets and pathfinding characters classes to reduce code duplication, as both functionalities were heavily duplicated. --- indra/newview/llpathfindinglinkset.cpp | 168 +++++++++++---------------------- 1 file changed, 53 insertions(+), 115 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index e2ece8794f..dca5b6c93d 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -29,15 +29,9 @@ #include "llpathfindinglinkset.h" -#include "v3math.h" -#include "llavatarname.h" -#include "llavatarnamecache.h" +#include "llpathfindingobject.h" #include "llsd.h" -#include "lluuid.h" -#define LINKSET_NAME_FIELD "name" -#define LINKSET_DESCRIPTION_FIELD "description" -#define LINKSET_OWNER_FIELD "owner" #define LINKSET_LAND_IMPACT_FIELD "landimpact" #define LINKSET_MODIFIABLE_FIELD "modifiable" #ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS @@ -51,7 +45,6 @@ #define LINKSET_WALKABILITY_B_FIELD "B" #define LINKSET_WALKABILITY_C_FIELD "C" #define LINKSET_WALKABILITY_D_FIELD "D" -#define LINKSET_POSITION_FIELD "position" #define LINKSET_CATEGORY_VALUE_INCLUDE 0 #define LINKSET_CATEGORY_VALUE_EXCLUDE 1 @@ -64,15 +57,10 @@ const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0); const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100); -LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) - : mUUID(), +LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainData) + : LLPathfindingObject(), mIsTerrain(true), - mName(), - mDescription(), - mOwnerUUID(), - mOwnerName(), mLandImpact(0U), - mLocation(LLVector3::zero), #ifdef MISSING_MODIFIABLE_FIELD_WAR mHasModifiable(true), #endif // MISSING_MODIFIABLE_FIELD_WAR @@ -84,18 +72,13 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) { - parsePathfindingData(pTerrainLinksetItem); + parsePathfindingData(pTerrainData); } -LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetItem) - : mUUID(pUUID), +LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetData) + : LLPathfindingObject(pUUID, pLinksetData), mIsTerrain(false), - mName(), - mDescription(), - mOwnerUUID(), - mOwnerName(), mLandImpact(0U), - mLocation(LLVector3::zero), #ifdef MISSING_MODIFIABLE_FIELD_WAR mHasModifiable(false), #endif // MISSING_MODIFIABLE_FIELD_WAR @@ -107,18 +90,14 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) { - parseObjectData(pLinksetItem); - parsePathfindingData(pLinksetItem); + parseLinksetData(pLinksetData); + parsePathfindingData(pLinksetData); } LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) - : mUUID(pOther.mUUID), - mName(pOther.mName), - mDescription(pOther.mDescription), - mOwnerUUID(pOther.mOwnerUUID), - mOwnerName(pOther.mOwnerName), + : LLPathfindingObject(pOther), + mIsTerrain(pOther.mIsTerrain), mLandImpact(pOther.mLandImpact), - mLocation(pOther.mLocation), #ifdef MISSING_MODIFIABLE_FIELD_WAR mHasModifiable(pOther.mHasModifiable), mIsModifiable(pOther.mHasModifiable ? pOther.mIsModifiable : TRUE), @@ -140,13 +119,10 @@ LLPathfindingLinkset::~LLPathfindingLinkset() LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkset& pOther) { - mUUID = pOther.mUUID; - mName = pOther.mName; - mDescription = pOther.mDescription; - mOwnerUUID = pOther.mOwnerUUID; - mOwnerName = pOther.mOwnerName; + dynamic_cast(*this) = pOther; + + mIsTerrain = pOther.mIsTerrain; mLandImpact = pOther.mLandImpact; - mLocation = pOther.mLocation; #ifdef MISSING_MODIFIABLE_FIELD_WAR if (pOther.mHasModifiable) { @@ -166,18 +142,6 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse return *this; } -std::string LLPathfindingLinkset::getOwnerName() const -{ - std::string ownerName; - - if (hasOwnerName()) - { - ownerName = mOwnerName.getCompleteName(); - } - - return ownerName; -} - BOOL LLPathfindingLinkset::isPhantom() const { return isPhantom(getLinksetUse()); @@ -243,111 +207,85 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, return itemData; } -void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) +void LLPathfindingLinkset::parseLinksetData(const LLSD &pLinksetData) { - llassert(pLinksetItem.has(LINKSET_NAME_FIELD)); - llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString()); - mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString(); - - llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD)); - llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString()); - mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString(); - -#ifdef SERVER_SIDE_OWNER_ROLLOUT_COMPLETE - llassert(pLinksetItem.has(LINKSET_OWNER_FIELD)); - llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID()); - mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID(); - LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); -#else // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE - if (pLinksetItem.has(LINKSET_OWNER_FIELD)) - { - llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID()); - mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID(); - LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); - } -#endif // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE - - 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(pLinksetData.has(LINKSET_LAND_IMPACT_FIELD)); + llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).isInteger()); + llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); + mLandImpact = pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger(); #ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable = pLinksetItem.has(LINKSET_MODIFIABLE_FIELD); + mHasModifiable = pLinksetData.has(LINKSET_MODIFIABLE_FIELD); if (mHasModifiable) { - llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); } #else // MISSING_MODIFIABLE_FIELD_WAR - llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)); - llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + llassert(pLinksetData.has(LINKSET_MODIFIABLE_FIELD)); + llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); #endif // MISSING_MODIFIABLE_FIELD_WAR - - llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); - llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); - mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD)); } -void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem) +void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetData) { bool isPhantom = false; - if (pLinksetItem.has(LINKSET_PHANTOM_FIELD)) + if (pLinksetData.has(LINKSET_PHANTOM_FIELD)) { - llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); - isPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean(); + llassert(pLinksetData.get(LINKSET_PHANTOM_FIELD).isBoolean()); + isPhantom = pLinksetData.get(LINKSET_PHANTOM_FIELD).asBoolean(); } #ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - if (pLinksetItem.has(LINKSET_CATEGORY_FIELD)) + if (pLinksetData.has(LINKSET_CATEGORY_FIELD)) { - mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); + mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD))); } else { - llassert(pLinksetItem.has(DEPRECATED_LINKSET_PERMANENT_FIELD)); - llassert(pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean()); - bool isPermanent = pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean(); + llassert(pLinksetData.has(DEPRECATED_LINKSET_PERMANENT_FIELD)); + llassert(pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean()); + bool isPermanent = pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean(); - llassert(pLinksetItem.has(DEPRECATED_LINKSET_WALKABLE_FIELD)); - llassert(pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean()); - bool isWalkable = pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean(); + llassert(pLinksetData.has(DEPRECATED_LINKSET_WALKABLE_FIELD)); + llassert(pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean()); + bool isWalkable = pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean(); mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); } #else // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - llassert(pLinksetItem.has(LINKSET_CATEGORY_FIELD)); - mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); + llassert(pLinksetData.has(LINKSET_CATEGORY_FIELD)); + mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD))); #endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - if (pLinksetItem.has(LINKSET_CAN_BE_VOLUME)) + if (pLinksetData.has(LINKSET_CAN_BE_VOLUME)) { - llassert(pLinksetItem.get(LINKSET_CAN_BE_VOLUME).isBoolean()); - mCanBeVolume = pLinksetItem.get(LINKSET_CAN_BE_VOLUME).asBoolean(); + llassert(pLinksetData.get(LINKSET_CAN_BE_VOLUME).isBoolean()); + mCanBeVolume = pLinksetData.get(LINKSET_CAN_BE_VOLUME).asBoolean(); } - llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); - mWalkabilityCoefficientA = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_WALKABILITY_A_FIELD)); + llassert(pLinksetData.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); + mWalkabilityCoefficientA = pLinksetData.get(LINKSET_WALKABILITY_A_FIELD).asInteger(); llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientA <= MAX_WALKABILITY_VALUE); - llassert(pLinksetItem.has(LINKSET_WALKABILITY_B_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).isInteger()); - mWalkabilityCoefficientB = pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_WALKABILITY_B_FIELD)); + llassert(pLinksetData.get(LINKSET_WALKABILITY_B_FIELD).isInteger()); + mWalkabilityCoefficientB = pLinksetData.get(LINKSET_WALKABILITY_B_FIELD).asInteger(); llassert(mWalkabilityCoefficientB >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientB <= MAX_WALKABILITY_VALUE); - llassert(pLinksetItem.has(LINKSET_WALKABILITY_C_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).isInteger()); - mWalkabilityCoefficientC = pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_WALKABILITY_C_FIELD)); + llassert(pLinksetData.get(LINKSET_WALKABILITY_C_FIELD).isInteger()); + mWalkabilityCoefficientC = pLinksetData.get(LINKSET_WALKABILITY_C_FIELD).asInteger(); llassert(mWalkabilityCoefficientC >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientC <= MAX_WALKABILITY_VALUE); - llassert(pLinksetItem.has(LINKSET_WALKABILITY_D_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).isInteger()); - mWalkabilityCoefficientD = pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_WALKABILITY_D_FIELD)); + llassert(pLinksetData.get(LINKSET_WALKABILITY_D_FIELD).isInteger()); + mWalkabilityCoefficientD = pLinksetData.get(LINKSET_WALKABILITY_D_FIELD).asInteger(); llassert(mWalkabilityCoefficientD >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE); } -- cgit v1.2.3 From 3352a1eac15f752535b636866eeb966ec3900c62 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 30 May 2012 19:39:08 -0700 Subject: Cleaning up some unreferenced headers and classes definitions from previous refactoring. --- indra/newview/llpathfindinglinkset.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index dca5b6c93d..5b321b4408 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -29,6 +29,8 @@ #include "llpathfindinglinkset.h" +#include + #include "llpathfindingobject.h" #include "llsd.h" -- cgit v1.2.3 From 20759f491f71dadcc75aaa1ce9475b13cc6d10ac Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 17:11:54 -0700 Subject: PATH-719: Removing the DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS as the viewer no longer has to support the Premium Wilderness regions on the old server code. --- indra/newview/llpathfindinglinkset.cpp | 105 +++------------------------------ 1 file changed, 9 insertions(+), 96 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 5b321b4408..e153c50935 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -34,19 +34,15 @@ #include "llpathfindingobject.h" #include "llsd.h" -#define LINKSET_LAND_IMPACT_FIELD "landimpact" -#define LINKSET_MODIFIABLE_FIELD "modifiable" -#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS -#define DEPRECATED_LINKSET_PERMANENT_FIELD "permanent" -#define DEPRECATED_LINKSET_WALKABLE_FIELD "walkable" -#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS -#define LINKSET_CATEGORY_FIELD "navmesh_category" -#define LINKSET_CAN_BE_VOLUME "can_be_volume" -#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_LAND_IMPACT_FIELD "landimpact" +#define LINKSET_MODIFIABLE_FIELD "modifiable" +#define LINKSET_CATEGORY_FIELD "navmesh_category" +#define LINKSET_CAN_BE_VOLUME "can_be_volume" +#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_CATEGORY_VALUE_INCLUDE 0 #define LINKSET_CATEGORY_VALUE_EXCLUDE 1 @@ -179,10 +175,6 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, itemData[LINKSET_PHANTOM_FIELD] = static_cast(isPhantom(pLinksetUse)); } -#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - itemData[DEPRECATED_LINKSET_PERMANENT_FIELD] = static_cast(isPermanent(pLinksetUse)); - itemData[DEPRECATED_LINKSET_WALKABLE_FIELD] = static_cast(isWalkable(pLinksetUse)); -#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS itemData[LINKSET_CATEGORY_FIELD] = convertCategoryToLLSD(getNavMeshGenerationCategory(pLinksetUse)); } @@ -239,27 +231,8 @@ void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetData) isPhantom = pLinksetData.get(LINKSET_PHANTOM_FIELD).asBoolean(); } -#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - if (pLinksetData.has(LINKSET_CATEGORY_FIELD)) - { - mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD))); - } - else - { - llassert(pLinksetData.has(DEPRECATED_LINKSET_PERMANENT_FIELD)); - llassert(pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean()); - bool isPermanent = pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean(); - - llassert(pLinksetData.has(DEPRECATED_LINKSET_WALKABLE_FIELD)); - llassert(pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean()); - bool isWalkable = pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean(); - - mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); - } -#else // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS llassert(pLinksetData.has(LINKSET_CATEGORY_FIELD)); mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD))); -#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS if (pLinksetData.has(LINKSET_CAN_BE_VOLUME)) { @@ -292,66 +265,6 @@ void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetData) llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE); } -#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS -LLPathfindingLinkset::ELinksetUse LLPathfindingLinkset::getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable) -{ - return (pIsPhantom ? (pIsPermanent ? (pIsWalkable ? kMaterialVolume : kExclusionVolume) : kDynamicPhantom) : - (pIsPermanent ? (pIsWalkable ? kWalkable : kStaticObstacle) : kDynamicObstacle)); -} - -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; -} -#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - BOOL LLPathfindingLinkset::isPhantom(ELinksetUse pLinksetUse) { BOOL retVal; -- cgit v1.2.3 From b5694ee3aab311423186a1e4eb7288b14ee57d61 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 17:21:12 -0700 Subject: PATH-720: Removing the MISSING_MODIFIABLE_FIELD_WAR as the viewer no longer has to support the Premium Wilderness regions on the old server code. --- indra/newview/llpathfindinglinkset.cpp | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index e153c50935..4cb749b3ca 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -59,9 +59,6 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainData) : LLPathfindingObject(), mIsTerrain(true), mLandImpact(0U), -#ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable(true), -#endif // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable(FALSE), mCanBeVolume(FALSE), mLinksetUse(kUnknown), @@ -77,9 +74,6 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& : LLPathfindingObject(pUUID, pLinksetData), mIsTerrain(false), mLandImpact(0U), -#ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable(false), -#endif // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable(TRUE), mCanBeVolume(TRUE), mLinksetUse(kUnknown), @@ -96,12 +90,7 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) : LLPathfindingObject(pOther), mIsTerrain(pOther.mIsTerrain), mLandImpact(pOther.mLandImpact), -#ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable(pOther.mHasModifiable), - mIsModifiable(pOther.mHasModifiable ? pOther.mIsModifiable : TRUE), -#else // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable(pOther.mIsModifiable), -#endif // MISSING_MODIFIABLE_FIELD_WAR mCanBeVolume(pOther.mCanBeVolume), mLinksetUse(pOther.mLinksetUse), mWalkabilityCoefficientA(pOther.mWalkabilityCoefficientA), @@ -121,15 +110,7 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse mIsTerrain = pOther.mIsTerrain; mLandImpact = pOther.mLandImpact; -#ifdef MISSING_MODIFIABLE_FIELD_WAR - if (pOther.mHasModifiable) - { - mHasModifiable = pOther.mHasModifiable; - mIsModifiable = pOther.mIsModifiable; - } -#else // MISSING_MODIFIABLE_FIELD_WAR mIsModifiable = pOther.mIsModifiable; -#endif // MISSING_MODIFIABLE_FIELD_WAR mCanBeVolume = pOther.mCanBeVolume; mLinksetUse = pOther.mLinksetUse; mWalkabilityCoefficientA = pOther.mWalkabilityCoefficientA; @@ -208,18 +189,9 @@ void LLPathfindingLinkset::parseLinksetData(const LLSD &pLinksetData) llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); mLandImpact = pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger(); -#ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable = pLinksetData.has(LINKSET_MODIFIABLE_FIELD); - if (mHasModifiable) - { - llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); - } -#else // MISSING_MODIFIABLE_FIELD_WAR llassert(pLinksetData.has(LINKSET_MODIFIABLE_FIELD)); llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); -#endif // MISSING_MODIFIABLE_FIELD_WAR } void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetData) -- cgit v1.2.3 From 78910cf3016fc55eaf8214640b348df0f8bcdeda Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 26 Jun 2012 18:04:19 -0700 Subject: Updating the header licensing comments. --- indra/newview/llpathfindinglinkset.cpp | 51 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'indra/newview/llpathfindinglinkset.cpp') diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index 4cb749b3ca..fe4daabd89 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -1,29 +1,30 @@ /** - * @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$ - */ +* @file llpathfindinglinkset.cpp +* @brief Definition of a pathfinding linkset that contains various properties required for havok pathfinding. +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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" -- cgit v1.2.3