Recast Navigation
Navigation-mesh Toolset for Games
dtQueryFilter Class Reference

Defines polygon filtering and traversal costs for navigation mesh query operations. More...

#include <DetourNavMeshQuery.h>

Public Member Functions

 dtQueryFilter ()
 
bool passFilter (const dtPolyRef ref, const dtMeshTile *tile, const dtPoly *poly) const
 Returns true if the polygon can be visited. More...
 
float getCost (const float *pa, const float *pb, const dtPolyRef prevRef, const dtMeshTile *prevTile, const dtPoly *prevPoly, const dtPolyRef curRef, const dtMeshTile *curTile, const dtPoly *curPoly, const dtPolyRef nextRef, const dtMeshTile *nextTile, const dtPoly *nextPoly) const
 Returns cost to move from the beginning to the end of a line segment that is fully contained within a polygon. More...
 
Getters and setters for the default implementation data.
float getAreaCost (const int i) const
 Returns the traversal cost of the area. More...
 
void setAreaCost (const int i, const float cost)
 Sets the traversal cost of the area. More...
 
unsigned short getIncludeFlags () const
 Returns the include flags for the filter. More...
 
void setIncludeFlags (const unsigned short flags)
 Sets the include flags for the filter. More...
 
unsigned short getExcludeFlags () const
 Returns the exclude flags for the filter. More...
 
void setExcludeFlags (const unsigned short flags)
 Sets the exclude flags for the filter. More...
 

Description

Defines polygon filtering and traversal costs for navigation mesh query operations.

The Default Implementation

At construction: All area costs default to 1.0. All flags are included and none are excluded.

If a polygon has both an include and an exclude flag, it will be excluded.

The way filtering works, a navigation mesh polygon must have at least one flag set to ever be considered by a query. So a polygon with no flags will never be considered.

Setting the include flags to 0 will result in all polygons being excluded.

Custom Implementations

DT_VIRTUAL_QUERYFILTER must be defined in order to extend this class.

Implement a custom query filter by overriding the virtual passFilter() and getCost() functions. If this is done, both functions should be as fast as possible. Use cached local copies of data rather than accessing your own objects where possible.

Custom implementations do not need to adhere to the flags or cost logic used by the default implementation.

In order for A* searches to work properly, the cost should be proportional to the travel distance. Implementing a cost modifier less than 1.0 is likely to lead to problems during pathfinding.

See also
dtNavMeshQuery

Constructor & Destructor Documentation

◆ dtQueryFilter()

dtQueryFilter::dtQueryFilter ( )

Member Function Documentation

◆ getAreaCost()

float dtQueryFilter::getAreaCost ( const int  i) const
inline

Returns the traversal cost of the area.

Parameters
[in]iThe id of the area.
Returns
The traversal cost of the area.

◆ getCost()

float dtQueryFilter::getCost ( const float *  pa,
const float *  pb,
const dtPolyRef  prevRef,
const dtMeshTile prevTile,
const dtPoly prevPoly,
const dtPolyRef  curRef,
const dtMeshTile curTile,
const dtPoly curPoly,
const dtPolyRef  nextRef,
const dtMeshTile nextTile,
const dtPoly nextPoly 
) const
inline

Returns cost to move from the beginning to the end of a line segment that is fully contained within a polygon.

Parameters
[in]paThe start position on the edge of the previous and current polygon. [(x, y, z)]
[in]pbThe end position on the edge of the current and next polygon. [(x, y, z)]
[in]prevRefThe reference id of the previous polygon. [opt]
[in]prevTileThe tile containing the previous polygon. [opt]
[in]prevPolyThe previous polygon. [opt]
[in]curRefThe reference id of the current polygon.
[in]curTileThe tile containing the current polygon.
[in]curPolyThe current polygon.
[in]nextRefThe refernece id of the next polygon. [opt]
[in]nextTileThe tile containing the next polygon. [opt]
[in]nextPolyThe next polygon. [opt]

◆ getExcludeFlags()

unsigned short dtQueryFilter::getExcludeFlags ( ) const
inline

Returns the exclude flags for the filter.

Any polygons that include one ore more of these flags will be excluded from the operation.

◆ getIncludeFlags()

unsigned short dtQueryFilter::getIncludeFlags ( ) const
inline

Returns the include flags for the filter.

Any polygons that include one or more of these flags will be included in the operation.

◆ passFilter()

bool dtQueryFilter::passFilter ( const dtPolyRef  ref,
const dtMeshTile tile,
const dtPoly poly 
) const
inline

Returns true if the polygon can be visited.

(I.e. Is traversable.)

Parameters
[in]refThe reference id of the polygon test.
[in]tileThe tile containing the polygon.
[in]polyThe polygon to test.

◆ setAreaCost()

void dtQueryFilter::setAreaCost ( const int  i,
const float  cost 
)
inline

Sets the traversal cost of the area.

Parameters
[in]iThe id of the area.
[in]costThe new cost of traversing the area.

◆ setExcludeFlags()

void dtQueryFilter::setExcludeFlags ( const unsigned short  flags)
inline

Sets the exclude flags for the filter.

Parameters
[in]flagsThe new flags.

◆ setIncludeFlags()

void dtQueryFilter::setIncludeFlags ( const unsigned short  flags)
inline

Sets the include flags for the filter.

Parameters
[in]flagsThe new flags.

The documentation for this class was generated from the following files: