update recast

This commit is contained in:
Johxz 2018-02-28 22:15:31 -06:00
parent 78caec2718
commit 594866f24c
34 changed files with 1138 additions and 407 deletions

View file

@ -217,7 +217,7 @@ class dtCrowd
dtPolyRef* m_pathResult;
int m_maxPathResult;
float m_ext[3];
float m_agentPlacementHalfExtents[3];
dtQueryFilter m_filters[DT_CROWD_MAX_QUERY_FILTER_TYPE];
@ -325,9 +325,13 @@ public:
/// @return The filter used by the crowd.
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)]
const float* getQueryExtents() const { return m_ext; }
/// Gets the search halfExtents [(x, y, z)] used by the crowd for query operations.
/// @return The search halfExtents used by the crowd. [(x, y, z)]
const float* getQueryHalfExtents() const { return m_agentPlacementHalfExtents; }
/// Same as getQueryHalfExtents. Left to maintain backwards compatibility.
/// @return The search halfExtents used by the crowd. [(x, y, z)]
const float* getQueryExtents() const { return m_agentPlacementHalfExtents; }
/// Gets the velocity sample count.
/// @return The velocity sample count.
@ -453,3 +457,4 @@ A higher value will result in agents trying to stay farther away from each other
the cost of more difficult steering in tight spaces.
*/

View file

@ -386,7 +386,8 @@ bool dtCrowd::init(const int maxAgents, const float maxAgentRadius, dtNavMesh* n
m_maxAgents = maxAgents;
m_maxAgentRadius = maxAgentRadius;
dtVset(m_ext, m_maxAgentRadius*2.0f,m_maxAgentRadius*1.5f,m_maxAgentRadius*2.0f);
// Larger than agent radius because it is also used for agent recovery.
dtVset(m_agentPlacementHalfExtents, m_maxAgentRadius*2.0f, m_maxAgentRadius*1.5f, m_maxAgentRadius*2.0f);
m_grid = dtAllocProximityGrid();
if (!m_grid)
@ -531,7 +532,7 @@ int dtCrowd::addAgent(const float* pos, const dtCrowdAgentParams* params)
float nearest[3];
dtPolyRef ref = 0;
dtVcopy(nearest, pos);
dtStatus status = m_navquery->findNearestPoly(pos, m_ext, &m_filters[ag->params.queryFilterType], &ref, nearest);
dtStatus status = m_navquery->findNearestPoly(pos, m_agentPlacementHalfExtents, &m_filters[ag->params.queryFilterType], &ref, nearest);
if (dtStatusFailed(status))
{
dtVcopy(nearest, pos);
@ -965,7 +966,7 @@ void dtCrowd::checkPathValidity(dtCrowdAgent** agents, const int nagents, const
float nearest[3];
dtVcopy(nearest, agentPos);
agentRef = 0;
m_navquery->findNearestPoly(ag->npos, m_ext, &m_filters[ag->params.queryFilterType], &agentRef, nearest);
m_navquery->findNearestPoly(ag->npos, m_agentPlacementHalfExtents, &m_filters[ag->params.queryFilterType], &agentRef, nearest);
dtVcopy(agentPos, nearest);
if (!agentRef)
@ -1001,7 +1002,7 @@ void dtCrowd::checkPathValidity(dtCrowdAgent** agents, const int nagents, const
float nearest[3];
dtVcopy(nearest, ag->targetPos);
ag->targetRef = 0;
m_navquery->findNearestPoly(ag->targetPos, m_ext, &m_filters[ag->params.queryFilterType], &ag->targetRef, nearest);
m_navquery->findNearestPoly(ag->targetPos, m_agentPlacementHalfExtents, &m_filters[ag->params.queryFilterType], &ag->targetRef, nearest);
dtVcopy(ag->targetPos, nearest);
replan = true;
}

View file

@ -207,6 +207,9 @@ void dtFreeObstacleAvoidanceQuery(dtObstacleAvoidanceQuery* ptr)
dtObstacleAvoidanceQuery::dtObstacleAvoidanceQuery() :
m_invHorizTime(0),
m_vmax(0),
m_invVmax(0),
m_maxCircles(0),
m_circles(0),
m_ncircles(0),

View file

@ -431,7 +431,7 @@ Behavior:
- The new position will be located in the adjusted corridor's first polygon.
The expected use case is that the desired position will be 'near' the current corridor. What is considered 'near'
depends on local polygon density, query search extents, etc.
depends on local polygon density, query search half extents, etc.
The resulting position will differ from the desired position if the desired position is not on the navigation mesh,
or it can't be reached using a local search.
@ -470,7 +470,7 @@ Behavior:
- The corridor is automatically adjusted (shorted or lengthened) in order to remain valid.
- The new target will be located in the adjusted corridor's last polygon.
The expected use case is that the desired target will be 'near' the current corridor. What is considered 'near' depends on local polygon density, query search extents, etc.
The expected use case is that the desired target will be 'near' the current corridor. What is considered 'near' depends on local polygon density, query search half extents, etc.
The resulting target will differ from the desired target if the desired target is not on the navigation mesh, or it can't be reached using a local search.
*/

View file

@ -48,6 +48,7 @@ inline int hashPos2(int x, int y, int n)
dtProximityGrid::dtProximityGrid() :
m_cellSize(0),
m_invCellSize(0),
m_pool(0),
m_poolHead(0),
m_poolSize(0),