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.

master
Todd Stinson 2012-03-06 12:12:35 -08:00
parent 49477cec95
commit 36d7de33b2
2 changed files with 208 additions and 47 deletions

View File

@ -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<bool>(LLPathfindingLinkset::isPhantom(pLinksetUse));
}
itemData[LINKSET_PERMANENT_FIELD] = static_cast<bool>(LLPathfindingLinkset::isPermanent(pLinksetUse));
itemData[LINKSET_WALKABLE_FIELD] = static_cast<bool>(LLPathfindingLinkset::isWalkable(pLinksetUse));
#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
itemData[DEPRECATED_LINKSET_PERMANENT_FIELD] = static_cast<bool>(LLPathfindingLinkset::isPermanent(pLinksetUse));
itemData[DEPRECATED_LINKSET_WALKABLE_FIELD] = static_cast<bool>(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<S32>(LINKSET_CATEGORY_VALUE_IGNORE);
break;
case kNavMeshGenerationInclude :
llsd = static_cast<S32>(LINKSET_CATEGORY_VALUE_INCLUDE);
break;
case kNavMeshGenerationExclude :
llsd = static_cast<S32>(LINKSET_CATEGORY_VALUE_EXCLUDE);
break;
default :
llsd = static_cast<S32>(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;
}

View File

@ -38,9 +38,18 @@ class LLPathfindingLinkset;
typedef boost::shared_ptr<LLPathfindingLinkset> LLPathfindingLinksetPtr;
#define DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
class LLPathfindingLinkset
{
public:
typedef enum
{
kNavMeshGenerationIgnore,
kNavMeshGenerationInclude,
kNavMeshGenerationExclude
} ENavMeshGenerationCategory;
typedef enum
{
kUnknown,
@ -59,25 +68,25 @@ public:
LLPathfindingLinkset& operator = (const LLPathfindingLinkset& pOther);
inline bool isTerrain() const {return mIsTerrain;};
inline const LLUUID& getUUID() const {return mUUID;};
inline const std::string& getName() const {return mName;};
inline const std::string& getDescription() const {return mDescription;};
inline U32 getLandImpact() const {return mLandImpact;};
inline const LLVector3& getLocation() const {return mLocation;};
BOOL isModifiable() const {return mIsModifiable;};
BOOL isPhantom() const;
static BOOL isPhantom(ELinksetUse pLinksetUse);
static ELinksetUse getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse);
inline bool isTerrain() const {return mIsTerrain;};
inline const LLUUID& getUUID() const {return mUUID;};
inline const std::string& getName() const {return mName;};
inline const std::string& getDescription() const {return mDescription;};
inline U32 getLandImpact() const {return mLandImpact;};
inline const LLVector3& getLocation() const {return mLocation;};
BOOL isModifiable() const {return mIsModifiable;};
BOOL isPhantom() const;
static BOOL isPhantom(ELinksetUse pLinksetUse);
static ELinksetUse getLinksetUseWithToggledPhantom(ELinksetUse pLinksetUse);
inline ELinksetUse getLinksetUse() const {return mLinksetUse;};
inline ELinksetUse getLinksetUse() const {return mLinksetUse;};
inline S32 getWalkabilityCoefficientA() const {return mWalkabilityCoefficientA;};
inline S32 getWalkabilityCoefficientB() const {return mWalkabilityCoefficientB;};
inline S32 getWalkabilityCoefficientC() const {return mWalkabilityCoefficientC;};
inline S32 getWalkabilityCoefficientD() const {return mWalkabilityCoefficientD;};
inline S32 getWalkabilityCoefficientA() const {return mWalkabilityCoefficientA;};
inline S32 getWalkabilityCoefficientB() const {return mWalkabilityCoefficientB;};
inline S32 getWalkabilityCoefficientC() const {return mWalkabilityCoefficientC;};
inline S32 getWalkabilityCoefficientD() const {return mWalkabilityCoefficientD;};
LLSD encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const;
LLSD encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const;
static const S32 MIN_WALKABILITY_VALUE;
static const S32 MAX_WALKABILITY_VALUE;
@ -85,11 +94,18 @@ public:
protected:
private:
void parseObjectData(const LLSD &pLinksetItem);
void parsePathfindingData(const LLSD &pLinksetItem);
static ELinksetUse getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable);
static BOOL isPermanent(ELinksetUse pLinksetUse);
static BOOL isWalkable(ELinksetUse pLinksetUse);
void parseObjectData(const LLSD &pLinksetItem);
void parsePathfindingData(const LLSD &pLinksetItem);
#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
static ELinksetUse getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable);
static BOOL isPermanent(ELinksetUse pLinksetUse);
static BOOL isWalkable(ELinksetUse pLinksetUse);
#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
static ELinksetUse getLinksetUse(bool pIsPhantom, ENavMeshGenerationCategory pNavMeshGenerationCategory);
static ENavMeshGenerationCategory getNavMeshGenerationCategory(ELinksetUse pLinksetUse);
static LLSD convertCategoryToLLSD(ENavMeshGenerationCategory pNavMeshGenerationCategory);
static ENavMeshGenerationCategory convertCategoryFromLLSD(const LLSD &llsd);
LLUUID mUUID;
bool mIsTerrain;