Skip to content

Commit

Permalink
Renamed all instances of 'extents' to 'halfExtents' (recastnavigation…
Browse files Browse the repository at this point in the history
  • Loading branch information
aymarfisherman authored and jakobbotsch committed Aug 20, 2017
1 parent 840c100 commit 7cca61d
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Detour/Include/DetourNavMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ class dtNavMesh
dtPolyRef* polys, const int maxPolys) const;
/// Find nearest polygon within a tile.
dtPolyRef findNearestPolyInTile(const dtMeshTile* tile, const float* center,
const float* extents, float* nearestPt) const;
const float* halfExtents, float* nearestPt) const;
/// Returns closest point on polygon.
void closestPointOnPoly(dtPolyRef ref, const float* pos, float* closest, bool* posOverPoly) const;

Expand Down
12 changes: 6 additions & 6 deletions Detour/Include/DetourNavMeshQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,33 +316,33 @@ class dtNavMeshQuery

/// Finds the polygon nearest to the specified center point.
/// @param[in] center The center of the search box. [(x, y, z)]
/// @param[in] extents The search distance along each axis. [(x, y, z)]
/// @param[in] halfExtents The search distance along each axis. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query.
/// @param[out] nearestRef The reference id of the nearest polygon.
/// @param[out] nearestPt The nearest point on the polygon. [opt] [(x, y, z)]
/// @returns The status flags for the query.
dtStatus findNearestPoly(const float* center, const float* extents,
dtStatus findNearestPoly(const float* center, const float* halfExtents,
const dtQueryFilter* filter,
dtPolyRef* nearestRef, float* nearestPt) const;

/// Finds polygons that overlap the search box.
/// @param[in] center The center of the search box. [(x, y, z)]
/// @param[in] extents The search distance along each axis. [(x, y, z)]
/// @param[in] halfExtents The search distance along each axis. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query.
/// @param[out] polys The reference ids of the polygons that overlap the query box.
/// @param[out] polyCount The number of polygons in the search result.
/// @param[in] maxPolys The maximum number of polygons the search result can hold.
/// @returns The status flags for the query.
dtStatus queryPolygons(const float* center, const float* extents,
dtStatus queryPolygons(const float* center, const float* halfExtents,
const dtQueryFilter* filter,
dtPolyRef* polys, int* polyCount, const int maxPolys) const;

/// Finds polygons that overlap the search box.
/// @param[in] center The center of the search box. [(x, y, z)]
/// @param[in] extents The search distance along each axis. [(x, y, z)]
/// @param[in] halfExtents The search distance along each axis. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query.
/// @param[in] query The query. Polygons found will be batched together and passed to this query.
dtStatus queryPolygons(const float* center, const float* extents,
dtStatus queryPolygons(const float* center, const float* halfExtents,
const dtQueryFilter* filter, dtPolyQuery* query) const;

/// Finds the non-overlapping navigation polygons in the local neighbourhood around the center position.
Expand Down
14 changes: 7 additions & 7 deletions Detour/Source/DetourNavMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,12 @@ void dtNavMesh::connectExtOffMeshLinks(dtMeshTile* tile, dtMeshTile* target, int
if (targetPoly->firstLink == DT_NULL_LINK)
continue;

const float ext[3] = { targetCon->rad, target->header->walkableClimb, targetCon->rad };
const float halfExtents[3] = { targetCon->rad, target->header->walkableClimb, targetCon->rad };

// Find polygon to connect to.
const float* p = &targetCon->pos[3];
float nearestPt[3];
dtPolyRef ref = findNearestPolyInTile(tile, p, ext, nearestPt);
dtPolyRef ref = findNearestPolyInTile(tile, p, halfExtents, nearestPt);
if (!ref)
continue;
// findNearestPoly may return too optimistic results, further check to make sure.
Expand Down Expand Up @@ -570,12 +570,12 @@ void dtNavMesh::baseOffMeshLinks(dtMeshTile* tile)
dtOffMeshConnection* con = &tile->offMeshCons[i];
dtPoly* poly = &tile->polys[con->poly];

const float ext[3] = { con->rad, tile->header->walkableClimb, con->rad };
const float halfExtents[3] = { con->rad, tile->header->walkableClimb, con->rad };

// Find polygon to connect to.
const float* p = &con->pos[0]; // First vertex
float nearestPt[3];
dtPolyRef ref = findNearestPolyInTile(tile, p, ext, nearestPt);
dtPolyRef ref = findNearestPolyInTile(tile, p, halfExtents, nearestPt);
if (!ref) continue;
// findNearestPoly may return too optimistic results, further check to make sure.
if (dtSqr(nearestPt[0]-p[0])+dtSqr(nearestPt[2]-p[2]) > dtSqr(con->rad))
Expand Down Expand Up @@ -696,12 +696,12 @@ void dtNavMesh::closestPointOnPoly(dtPolyRef ref, const float* pos, float* close
}

dtPolyRef dtNavMesh::findNearestPolyInTile(const dtMeshTile* tile,
const float* center, const float* extents,
const float* center, const float* halfExtents,
float* nearestPt) const
{
float bmin[3], bmax[3];
dtVsub(bmin, center, extents);
dtVadd(bmax, center, extents);
dtVsub(bmin, center, halfExtents);
dtVadd(bmax, center, halfExtents);

// Get nearby polygons from proximity grid.
dtPolyRef polys[128];
Expand Down
18 changes: 9 additions & 9 deletions Detour/Source/DetourNavMeshQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ class dtFindNearestPolyQuery : public dtPolyQuery
/// return #DT_SUCCESS, but @p nearestRef will be zero. So if in doubt, check
/// @p nearestRef before using @p nearestPt.
///
dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* extents,
dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* halfExtents,
const dtQueryFilter* filter,
dtPolyRef* nearestRef, float* nearestPt) const
{
Expand All @@ -770,7 +770,7 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* exten

dtFindNearestPolyQuery query(this, center);

dtStatus status = queryPolygons(center, extents, filter, &query);
dtStatus status = queryPolygons(center, halfExtents, filter, &query);
if (dtStatusFailed(status))
return status;

Expand Down Expand Up @@ -943,7 +943,7 @@ class dtCollectPolysQuery : public dtPolyQuery
/// be filled to capacity. The method of choosing which polygons from the
/// full set are included in the partial result set is undefined.
///
dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents,
dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* halfExtents,
const dtQueryFilter* filter,
dtPolyRef* polys, int* polyCount, const int maxPolys) const
{
Expand All @@ -952,7 +952,7 @@ dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents

dtCollectPolysQuery collector(polys, maxPolys);

dtStatus status = queryPolygons(center, extents, filter, &collector);
dtStatus status = queryPolygons(center, halfExtents, filter, &collector);
if (dtStatusFailed(status))
return status;

Expand All @@ -963,21 +963,21 @@ dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents
/// @par
///
/// The query will be invoked with batches of polygons. Polygons passed
/// to the query have bounding boxes that overlap with the center and extents
/// to the query have bounding boxes that overlap with the center and halfExtents
/// passed to this function. The dtPolyQuery::process function is invoked multiple
/// times until all overlapping polygons have been processed.
///
dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents,
dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* halfExtents,
const dtQueryFilter* filter, dtPolyQuery* query) const
{
dtAssert(m_nav);

if (!center || !extents || !filter || !query)
if (!center || !halfExtents || !filter || !query)
return DT_FAILURE | DT_INVALID_PARAM;

float bmin[3], bmax[3];
dtVsub(bmin, center, extents);
dtVadd(bmax, center, extents);
dtVsub(bmin, center, halfExtents);
dtVadd(bmax, center, halfExtents);

// Find tiles the query touches.
int minx, miny, maxx, maxy;
Expand Down
12 changes: 8 additions & 4 deletions DetourCrowd/Include/DetourCrowd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -325,9 +325,13 @@ class dtCrowd
/// @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.
Expand Down
9 changes: 5 additions & 4 deletions DetourCrowd/Source/DetourCrowd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions DetourCrowd/Source/DetourPathCorridor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ bool dtPathCorridor::moveOverOffmeshConnection(dtPolyRef offMeshConRef, dtPolyRe
- 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.
Expand Down Expand Up @@ -470,7 +470,7 @@ bool dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, c
- 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.
*/
Expand Down
4 changes: 2 additions & 2 deletions DetourTileCache/Include/DetourTileCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct dtObstacleBox
struct dtObstacleOrientedBox
{
float center[ 3 ];
float extents[ 3 ];
float halfExtents[ 3 ];
float rotAux[ 2 ]; //{ cos(0.5f*angle)*sin(-0.5f*angle); cos(0.5f*angle)*cos(0.5f*angle) - 0.5 }
};

Expand Down Expand Up @@ -146,7 +146,7 @@ class dtTileCache
dtStatus addBoxObstacle(const float* bmin, const float* bmax, dtObstacleRef* result);

// Box obstacle: can be rotated in Y.
dtStatus addBoxObstacle(const float* center, const float* extents, const float yRadians, dtObstacleRef* result);
dtStatus addBoxObstacle(const float* center, const float* halfExtents, const float yRadians, dtObstacleRef* result);

dtStatus removeObstacle(const dtObstacleRef ref);

Expand Down
2 changes: 1 addition & 1 deletion DetourTileCache/Include/DetourTileCacheBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ dtStatus dtMarkBoxArea(dtTileCacheLayer& layer, const float* orig, const float c
const float* bmin, const float* bmax, const unsigned char areaId);

dtStatus dtMarkBoxArea(dtTileCacheLayer& layer, const float* orig, const float cs, const float ch,
const float* center, const float* extents, const float* rotAux, const unsigned char areaId);
const float* center, const float* halfExtents, const float* rotAux, const unsigned char areaId);

dtStatus dtBuildTileCacheRegions(dtTileCacheAlloc* alloc,
dtTileCacheLayer& layer,
Expand Down
12 changes: 6 additions & 6 deletions DetourTileCache/Source/DetourTileCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ dtStatus dtTileCache::addBoxObstacle(const float* bmin, const float* bmax, dtObs
return DT_SUCCESS;
}

dtStatus dtTileCache::addBoxObstacle(const float* center, const float* extents, const float yRadians, dtObstacleRef* result)
dtStatus dtTileCache::addBoxObstacle(const float* center, const float* halfExtents, const float yRadians, dtObstacleRef* result)
{
if (m_nreqs >= MAX_REQUESTS)
return DT_FAILURE | DT_BUFFER_TOO_SMALL;
Expand All @@ -441,7 +441,7 @@ dtStatus dtTileCache::addBoxObstacle(const float* center, const float* extents,
ob->state = DT_OBSTACLE_PROCESSING;
ob->type = DT_OBSTACLE_ORIENTED_BOX;
dtVcopy(ob->orientedBox.center, center);
dtVcopy(ob->orientedBox.extents, extents);
dtVcopy(ob->orientedBox.halfExtents, halfExtents);

float coshalf= cosf(0.5f*yRadians);
float sinhalf = sinf(-0.5f*yRadians);
Expand Down Expand Up @@ -694,7 +694,7 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh*
else if (ob->type == DT_OBSTACLE_ORIENTED_BOX)
{
dtMarkBoxArea(*bc.layer, tile->header->bmin, m_params.cs, m_params.ch,
ob->orientedBox.center, ob->orientedBox.extents, ob->orientedBox.rotAux, 0);
ob->orientedBox.center, ob->orientedBox.halfExtents, ob->orientedBox.rotAux, 0);
}
}
}
Expand Down Expand Up @@ -809,11 +809,11 @@ void dtTileCache::getObstacleBounds(const struct dtTileCacheObstacle* ob, float*
{
const dtObstacleOrientedBox &orientedBox = ob->orientedBox;

float maxr = 1.41f*dtMax(orientedBox.extents[0], orientedBox.extents[2]);
float maxr = 1.41f*dtMax(orientedBox.halfExtents[0], orientedBox.halfExtents[2]);
bmin[0] = orientedBox.center[0] - maxr;
bmax[0] = orientedBox.center[0] + maxr;
bmin[1] = orientedBox.center[1] - orientedBox.extents[1];
bmax[1] = orientedBox.center[1] + orientedBox.extents[1];
bmin[1] = orientedBox.center[1] - orientedBox.halfExtents[1];
bmax[1] = orientedBox.center[1] + orientedBox.halfExtents[1];
bmin[2] = orientedBox.center[2] - maxr;
bmax[2] = orientedBox.center[2] + maxr;
}
Expand Down
12 changes: 6 additions & 6 deletions DetourTileCache/Source/DetourTileCacheBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ dtStatus dtMarkBoxArea(dtTileCacheLayer& layer, const float* orig, const float c
}

dtStatus dtMarkBoxArea(dtTileCacheLayer& layer, const float* orig, const float cs, const float ch,
const float* center, const float* extents, const float* rotAux, const unsigned char areaId)
const float* center, const float* halfExtents, const float* rotAux, const unsigned char areaId)
{
const int w = (int)layer.header->width;
const int h = (int)layer.header->height;
Expand All @@ -2052,13 +2052,13 @@ dtStatus dtMarkBoxArea(dtTileCacheLayer& layer, const float* orig, const float c
float cx = (center[0] - orig[0])*ics;
float cz = (center[2] - orig[2])*ics;

float maxr = 1.41f*dtMax(extents[0], extents[2]);
float maxr = 1.41f*dtMax(halfExtents[0], halfExtents[2]);
int minx = (int)floorf(cx - maxr*ics);
int maxx = (int)floorf(cx + maxr*ics);
int minz = (int)floorf(cz - maxr*ics);
int maxz = (int)floorf(cz + maxr*ics);
int miny = (int)floorf((center[1]-extents[1]-orig[1])*ich);
int maxy = (int)floorf((center[1]+extents[1]-orig[1])*ich);
int miny = (int)floorf((center[1]-halfExtents[1]-orig[1])*ich);
int maxy = (int)floorf((center[1]+halfExtents[1]-orig[1])*ich);

if (maxx < 0) return DT_SUCCESS;
if (minx >= w) return DT_SUCCESS;
Expand All @@ -2070,8 +2070,8 @@ dtStatus dtMarkBoxArea(dtTileCacheLayer& layer, const float* orig, const float c
if (minz < 0) minz = 0;
if (maxz >= h) maxz = h-1;

float xhalf = extents[0]*ics + 0.5f;
float zhalf = extents[2]*ics + 0.5f;
float xhalf = halfExtents[0]*ics + 0.5f;
float zhalf = halfExtents[2]*ics + 0.5f;

for (int z = minz; z <= maxz; ++z)
{
Expand Down
2 changes: 1 addition & 1 deletion RecastDemo/Include/Sample_Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Sample_Debug : public Sample
rcContourSet* m_cset;
rcPolyMesh* m_pmesh;

float m_ext[3];
float m_halfExtents[3];
float m_center[3];
float m_bmin[3], m_bmax[3];
dtPolyRef m_ref;
Expand Down
2 changes: 1 addition & 1 deletion RecastDemo/Source/ConvexVolumeTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void ConvexVolumeTool::handleRender()
{
duDebugDraw& dd = m_sample->getDebugDraw();

// Find height extents of the shape.
// Find height extent of the shape.
float minh = FLT_MAX, maxh = 0;
for (int i = 0; i < m_npts; ++i)
minh = rcMin(minh, m_pts[i*3+1]);
Expand Down
8 changes: 4 additions & 4 deletions RecastDemo/Source/CrowdTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ void CrowdToolState::setMoveTarget(const float* p, bool adjust)
dtNavMeshQuery* navquery = m_sample->getNavMeshQuery();
dtCrowd* crowd = m_sample->getCrowd();
const dtQueryFilter* filter = crowd->getFilter(0);
const float* ext = crowd->getQueryExtents();
const float* halfExtents = crowd->getQueryExtents();

if (adjust)
{
Expand Down Expand Up @@ -740,7 +740,7 @@ void CrowdToolState::setMoveTarget(const float* p, bool adjust)
}
else
{
navquery->findNearestPoly(p, ext, filter, &m_targetRef, m_targetPos);
navquery->findNearestPoly(p, halfExtents, filter, &m_targetRef, m_targetPos);

if (m_agentDebug.idx != -1)
{
Expand Down Expand Up @@ -1032,10 +1032,10 @@ void CrowdTool::handleClick(const float* s, const float* p, bool shift)
if (nav && navquery)
{
dtQueryFilter filter;
const float* ext = crowd->getQueryExtents();
const float* halfExtents = crowd->getQueryExtents();
float tgt[3];
dtPolyRef ref;
navquery->findNearestPoly(p, ext, &filter, &ref, tgt);
navquery->findNearestPoly(p, halfExtents, &filter, &ref, tgt);
if (ref)
{
unsigned short flags = 0;
Expand Down
Loading

0 comments on commit 7cca61d

Please sign in to comment.