Skip to content

Commit

Permalink
Core/MMAPs: Update recast
Browse files Browse the repository at this point in the history
Update recast to recastnavigation/recastnavigation@42b96b7
Previous MMAPs might still work but it's recommended to re-extract them.
  • Loading branch information
jackpoz committed Jun 25, 2014
1 parent ff25736 commit ed5e3fc
Show file tree
Hide file tree
Showing 13 changed files with 1,511 additions and 3,983 deletions.
2 changes: 1 addition & 1 deletion dep/PackageList.txt
Expand Up @@ -42,4 +42,4 @@ gSOAP (a portable development toolkit for C and C++ XML Web services and XML dat

recastnavigation (Recast is state of the art navigation mesh construction toolset for games)
https://github.com/memononen/recastnavigation
Version: 740a7ba51600a3c87ce5667ae276a38284a1ce75
Version: 42b96b7306d39bb7680ddb0f89d480a8296c83ff
19 changes: 19 additions & 0 deletions dep/recastnavigation/Detour/Include/DetourNavMesh.h
Expand Up @@ -119,6 +119,25 @@ enum dtStraightPathOptions
DT_STRAIGHTPATH_ALL_CROSSINGS = 0x02, ///< Add a vertex at every polygon edge crossing.
};


/// Options for dtNavMeshQuery::findPath
enum dtFindPathOptions
{
DT_FINDPATH_LOW_QUALITY_FAR = 0x01, ///< [provisional] trade quality for performance far from the origin. The idea is that by then a new query will be issued
DT_FINDPATH_ANY_ANGLE = 0x02, ///< use raycasts during pathfind to "shortcut" (raycast still consider costs)
};

/// Options for dtNavMeshQuery::raycast
enum dtRaycastOptions
{
DT_RAYCAST_USE_COSTS = 0x01, ///< Raycast should calculate movement cost along the ray and fill RaycastHit::cost
};


/// Limit raycasting during any angle pahfinding
/// The limit is given as a multiple of the character radius
static const float DT_RAY_CAST_LIMIT_PROPORTIONS = 50.0f;

/// Flags representing the type of a navigation mesh polygon.
enum dtPolyTypes
{
Expand Down
54 changes: 53 additions & 1 deletion dep/recastnavigation/Detour/Include/DetourNavMeshQuery.h
Expand Up @@ -41,6 +41,10 @@ class dtQueryFilter
public:
dtQueryFilter();

#ifdef DT_VIRTUAL_QUERYFILTER
virtual ~dtQueryFilter() { }
#endif

/// Returns true if the polygon can be visited. (I.e. Is traversable.)
/// @param[in] ref The reference id of the polygon test.
/// @param[in] tile The tile containing the polygon.
Expand Down Expand Up @@ -115,6 +119,34 @@ class dtQueryFilter

};



/// Provides information about raycast hit
/// filled by dtNavMeshQuery::raycast
/// @ingroup detour
struct dtRaycastHit
{
/// The hit parameter. (FLT_MAX if no wall hit.)
float t;

/// hitNormal The normal of the nearest wall hit. [(x, y, z)]
float hitNormal[3];

/// Pointer to an array of reference ids of the visited polygons. [opt]
dtPolyRef* path;

/// The number of visited polygons. [opt]
int pathCount;

/// The maximum number of polygons the @p path array can hold.
int maxPath;

/// The cost of the path until hit.
float pathCost;
};



/// Provides the ability to perform pathfinding related queries against
/// a navigation mesh.
/// @ingroup detour
Expand Down Expand Up @@ -179,10 +211,11 @@ class dtNavMeshQuery
/// @param[in] startPos A position within the start polygon. [(x, y, z)]
/// @param[in] endPos A position within the end polygon. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query.
/// @param[in] options query options (see: #dtFindPathOptions)
/// @returns The status flags for the query.
dtStatus initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef,
const float* startPos, const float* endPos,
const dtQueryFilter* filter);
const dtQueryFilter* filter, const unsigned int options = 0);

/// Updates an in-progress sliced path query.
/// @param[in] maxIter The maximum number of iterations to perform.
Expand Down Expand Up @@ -308,6 +341,7 @@ class dtNavMeshQuery

/// Casts a 'walkability' ray along the surface of the navigation mesh from
/// the start position toward the end position.
/// @note A wrapper around raycast(..., RaycastHit*). Retained for backward compatibility.
/// @param[in] startRef The reference id of the start polygon.
/// @param[in] startPos A position within the start polygon representing
/// the start of the ray. [(x, y, z)]
Expand All @@ -323,6 +357,22 @@ class dtNavMeshQuery
const dtQueryFilter* filter,
float* t, float* hitNormal, dtPolyRef* path, int* pathCount, const int maxPath) const;

/// Casts a 'walkability' ray along the surface of the navigation mesh from
/// the start position toward the end position.
/// @param[in] startRef The reference id of the start polygon.
/// @param[in] startPos A position within the start polygon representing
/// the start of the ray. [(x, y, z)]
/// @param[in] endPos The position to cast the ray toward. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query.
/// @param[in] flags govern how the raycast behaves. See dtRaycastOptions
/// @param[out] hit Pointer to a raycast hit structure which will be filled by the results.
/// @param[in] prevRef parent of start ref. Used during for cost calculation [opt]
/// @returns The status flags for the query.
dtStatus raycast(dtPolyRef startRef, const float* startPos, const float* endPos,
const dtQueryFilter* filter, const unsigned int options,
dtRaycastHit* hit, dtPolyRef prevRef = 0) const;


/// Finds the distance from the specified position to the nearest polygon wall.
/// @param[in] startRef The reference id of the polygon containing @p centerPos.
/// @param[in] centerPos The center of the search circle. [(x, y, z)]
Expand Down Expand Up @@ -463,6 +513,8 @@ class dtNavMeshQuery
dtPolyRef startRef, endRef;
float startPos[3], endPos[3];
const dtQueryFilter* filter;
unsigned int options;
float raycastLimitSqr;
};
dtQueryData m_query; ///< Sliced query state.

Expand Down
19 changes: 15 additions & 4 deletions dep/recastnavigation/Detour/Include/DetourNode.h
Expand Up @@ -25,6 +25,7 @@ enum dtNodeFlags
{
DT_NODE_OPEN = 0x01,
DT_NODE_CLOSED = 0x02,
DT_NODE_PARENT_DETACHED = 0x04, // parent of the node is not adjacent. Found using raycast.
};

typedef unsigned short dtNodeIndex;
Expand All @@ -35,21 +36,30 @@ struct dtNode
float pos[3]; ///< Position of the node.
float cost; ///< Cost from previous node to current node.
float total; ///< Cost up to the node.
unsigned int pidx : 30; ///< Index to parent node.
unsigned int flags : 2; ///< Node flags 0/open/closed.
unsigned int pidx : 24; ///< Index to parent node.
unsigned int state : 2; ///< extra state information. A polyRef can have multiple nodes with different extra info. see DT_MAX_STATES_PER_NODE
unsigned int flags : 3; ///< Node flags. A combination of dtNodeFlags.
dtPolyRef id; ///< Polygon ref the node corresponds to.
};


static const int DT_MAX_STATES_PER_NODE = 4; // number of extra states per node. See dtNode::state



class dtNodePool
{
public:
dtNodePool(int maxNodes, int hashSize);
~dtNodePool();
inline void operator=(const dtNodePool&) {}
void clear();
dtNode* getNode(dtPolyRef id);
dtNode* findNode(dtPolyRef id);

// Get a dtNode by ref and extra state information. If there is none then - allocate
// There can be more than one node for the same polyRef but with different extra state information
dtNode* getNode(dtPolyRef id, unsigned char state=0);
dtNode* findNode(dtPolyRef id, unsigned char state);
unsigned int findNodes(dtPolyRef id, dtNode** nodes, const int maxNodes);

inline unsigned int getNodeIdx(const dtNode* node) const
{
Expand Down Expand Up @@ -82,6 +92,7 @@ class dtNodePool
inline int getHashSize() const { return m_hashSize; }
inline dtNodeIndex getFirst(int bucket) const { return m_first[bucket]; }
inline dtNodeIndex getNext(int i) const { return m_next[i]; }
inline int getNodeCount() const { return m_nodeCount; }

private:

Expand Down

5 comments on commit ed5e3fc

@Gooyeth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"authored 5 days ago" lol

Thanks @jackpoz :)

@jackpoz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that means I committed it first 5 days ago, kept testing and editing it in the last days (including working on recastnavigation/recastnavigation#38 ) and then finally merged into master

@Niknox
Copy link

@Niknox Niknox commented on ed5e3fc Jun 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Respectable how much effort you put into that commit for us! Thanks!

@DoodleZero
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this will fix warrior charge or something like that... what's fixed there ?

@sucofog
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need a re-extraction or it will be fine?
EDIT: Just didn't see the commit text, sorry and thanks for your work VERY apreciated.

Please sign in to comment.