Updated recast to 1.5.1

This commit is contained in:
Johxz 2016-12-11 13:17:15 -06:00
parent 630949514a
commit c7e5b35744
55 changed files with 3277 additions and 1460 deletions

View file

@ -45,6 +45,12 @@ static const int DT_CROWDAGENT_MAX_CORNERS = 4;
/// dtCrowdAgentParams::obstacleAvoidanceType
static const int DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS = 8;
/// The maximum number of query filter types supported by the crowd manager.
/// @ingroup crowd
/// @see dtQueryFilter, dtCrowd::getFilter() dtCrowd::getEditableFilter(),
/// dtCrowdAgentParams::queryFilterType
static const int DT_CROWD_MAX_QUERY_FILTER_TYPE = 16;
/// Provides neighbor data for agents managed by the crowd.
/// @ingroup crowd
/// @see dtCrowdAgent::neis, dtCrowd
@ -87,6 +93,9 @@ struct dtCrowdAgentParams
/// [Limits: 0 <= value <= #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
unsigned char obstacleAvoidanceType;
/// The index of the query filter used by this agent.
unsigned char queryFilterType;
/// User defined data attached to the agent.
void* userData;
};
@ -106,12 +115,15 @@ enum MoveRequestState
/// @ingroup crowd
struct dtCrowdAgent
{
/// 1 if the agent is active, or 0 if the agent is in an unused slot in the agent pool.
unsigned char active;
/// True if the agent is active, false if the agent is in an unused slot in the agent pool.
bool active;
/// The type of mesh polygon the agent is traversing. (See: #CrowdAgentState)
unsigned char state;
/// True if the agent has valid path (targetState == DT_CROWDAGENT_TARGET_VALID) and the path does not lead to the requested position, else false.
bool partial;
/// The path corridor the agent is using.
dtPathCorridor corridor;
@ -131,10 +143,10 @@ struct dtCrowdAgent
float desiredSpeed;
float npos[3]; ///< The current agent position. [(x, y, z)]
float disp[3];
float dvel[3]; ///< The desired velocity of the agent. [(x, y, z)]
float nvel[3];
float vel[3]; ///< The actual velocity of the agent. [(x, y, z)]
float disp[3]; ///< A temporary value used to accumulate agent displacement during iterative collision resolution. [(x, y, z)]
float dvel[3]; ///< The desired velocity of the agent. Based on the current path, calculated from scratch each frame. [(x, y, z)]
float nvel[3]; ///< The desired velocity adjusted by obstacle avoidance, calculated from scratch each frame. [(x, y, z)]
float vel[3]; ///< The actual velocity of the agent. The change from nvel -> vel is constrained by max acceleration. [(x, y, z)]
/// The agent's configuration parameters.
dtCrowdAgentParams params;
@ -161,7 +173,7 @@ struct dtCrowdAgent
struct dtCrowdAgentAnimation
{
unsigned char active;
bool active;
float initPos[3], startPos[3], endPos[3];
dtPolyRef polyRef;
float t, tmax;
@ -206,8 +218,9 @@ class dtCrowd
int m_maxPathResult;
float m_ext[3];
dtQueryFilter m_filter;
dtQueryFilter m_filters[DT_CROWD_MAX_QUERY_FILTER_TYPE];
float m_maxAgentRadius;
int m_velocitySampleCount;
@ -218,7 +231,7 @@ class dtCrowd
void updateMoveRequest(const float dt);
void checkPathValidity(dtCrowdAgent** agents, const int nagents, const float dt);
inline int getAgentIndex(const dtCrowdAgent* agent) const { return agent - m_agents; }
inline int getAgentIndex(const dtCrowdAgent* agent) const { return (int)(agent - m_agents); }
bool requestMoveTargetReplan(const int idx, dtPolyRef ref, const float* pos);
@ -251,9 +264,14 @@ public:
/// @return The requested agent.
const dtCrowdAgent* getAgent(const int idx);
/// Gets the specified agent from the pool.
/// @param[in] idx The agent index. [Limits: 0 <= value < #getAgentCount()]
/// @return The requested agent.
dtCrowdAgent* getEditableAgent(const int idx);
/// The maximum number of agents that can be managed by the object.
/// @return The maximum number of agents.
const int getAgentCount() const;
int getAgentCount() const;
/// Adds a new agent to the crowd.
/// @param[in] pos The requested position of the agent. [(x, y, z)]
@ -301,11 +319,11 @@ public:
/// Gets the filter used by the crowd.
/// @return The filter used by the crowd.
const dtQueryFilter* getFilter() const { return &m_filter; }
inline const dtQueryFilter* getFilter(const int i) const { return (i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE) ? &m_filters[i] : 0; }
/// Gets the filter used by the crowd.
/// @return The filter used by the crowd.
dtQueryFilter* getEditableFilter() { return &m_filter; }
inline dtQueryFilter* getEditableFilter(const int i) { return (i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE) ? &m_filters[i] : 0; }
/// Gets the search extents [(x, y, z)] used by the crowd for query operations.
/// @return The search extents used by the crowd. [(x, y, z)]
@ -325,6 +343,11 @@ public:
/// Gets the query object used by the crowd.
const dtNavMeshQuery* getNavMeshQuery() const { return m_navquery; }
private:
// Explicitly disabled copy constructor and copy assignment operator.
dtCrowd(const dtCrowd&);
dtCrowd& operator=(const dtCrowd&);
};
/// Allocates a crowd object using the Detour allocator.
@ -429,4 +452,4 @@ This value is often based on the agent radius. E.g. radius * 30
A higher value will result in agents trying to stay farther away from each other at
the cost of more difficult steering in tight spaces.
*/
*/

View file

@ -40,7 +40,7 @@ class dtLocalBoundary
dtPolyRef m_polys[MAX_LOCAL_POLYS];
int m_npolys;
void addSegment(const float dist, const float* seg);
void addSegment(const float dist, const float* s);
public:
dtLocalBoundary();
@ -56,6 +56,11 @@ public:
inline const float* getCenter() const { return m_center; }
inline int getSegmentCount() const { return m_nsegs; }
inline const float* getSegment(int i) const { return m_segs[i].s; }
private:
// Explicitly disabled copy constructor and copy assignment operator.
dtLocalBoundary(const dtLocalBoundary&);
dtLocalBoundary& operator=(const dtLocalBoundary&);
};
#endif // DETOURLOCALBOUNDARY_H

View file

@ -58,6 +58,10 @@ public:
inline float getSampleCollisionTimePenalty(const int i) const { return m_tpen[i]; }
private:
// Explicitly disabled copy constructor and copy assignment operator.
dtObstacleAvoidanceDebugData(const dtObstacleAvoidanceDebugData&);
dtObstacleAvoidanceDebugData& operator=(const dtObstacleAvoidanceDebugData&);
int m_nsamples;
int m_maxSamples;
float* m_vel;
@ -122,17 +126,18 @@ public:
const dtObstacleSegment* getObstacleSegment(const int i) { return &m_segments[i]; }
private:
// Explicitly disabled copy constructor and copy assignment operator.
dtObstacleAvoidanceQuery(const dtObstacleAvoidanceQuery&);
dtObstacleAvoidanceQuery& operator=(const dtObstacleAvoidanceQuery&);
void prepare(const float* pos, const float* dvel);
float processSample(const float* vcand, const float cs,
const float* pos, const float rad,
const float* vel, const float* dvel,
const float minPenalty,
dtObstacleAvoidanceDebugData* debug);
dtObstacleCircle* insertCircle(const float dist);
dtObstacleSegment* insertSegment(const float dist);
dtObstacleAvoidanceParams m_params;
float m_invHorizTime;
float m_vmax;

View file

@ -92,14 +92,16 @@ public:
/// @param[in] npos The desired new position. [(x, y, z)]
/// @param[in] navquery The query object used to build the corridor.
/// @param[in] filter The filter to apply to the operation.
void movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
/// @return Returns true if move succeeded.
bool movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
/// Moves the target from the curent location to the desired location, adjusting the corridor
/// as needed to reflect the change.
/// @param[in] npos The desired new target position. [(x, y, z)]
/// @param[in] navquery The query object used to build the corridor.
/// @param[in] filter The filter to apply to the operation.
void moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
/// @return Returns true if move succeeded.
bool moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
/// Loads a new path and target into the corridor.
/// @param[in] target The target location within the last polygon of the path. [(x, y, z)]
@ -129,7 +131,12 @@ public:
/// The number of polygons in the current corridor path.
/// @return The number of polygons in the current corridor path.
inline int getPathCount() const { return m_npath; }
inline int getPathCount() const { return m_npath; }
private:
// Explicitly disabled copy constructor and copy assignment operator.
dtPathCorridor(const dtPathCorridor&);
dtPathCorridor& operator=(const dtPathCorridor&);
};
int dtMergeCorridorStartMoved(dtPolyRef* path, const int npath, const int maxPath,

View file

@ -70,6 +70,10 @@ public:
inline const dtNavMeshQuery* getNavQuery() const { return m_navquery; }
private:
// Explicitly disabled copy constructor and copy assignment operator.
dtPathQueue(const dtPathQueue&);
dtPathQueue& operator=(const dtPathQueue&);
};
#endif // DETOURPATHQUEUE_H

View file

@ -21,7 +21,6 @@
class dtProximityGrid
{
int m_maxItems;
float m_cellSize;
float m_invCellSize;
@ -44,7 +43,7 @@ public:
dtProximityGrid();
~dtProximityGrid();
bool init(const int maxItems, const float cellSize);
bool init(const int poolSize, const float cellSize);
void clear();
@ -59,7 +58,12 @@ public:
int getItemCountAt(const int x, const int y) const;
inline const int* getBounds() const { return m_bounds; }
inline const float getCellSize() const { return m_cellSize; }
inline float getCellSize() const { return m_cellSize; }
private:
// Explicitly disabled copy constructor and copy assignment operator.
dtProximityGrid(const dtProximityGrid&);
dtProximityGrid& operator=(const dtProximityGrid&);
};
dtProximityGrid* dtAllocProximityGrid();