UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
dtQueryFilter Class Reference

#include <DetourNavMeshQuery.h>

Public Member Functions

 dtQueryFilter (bool inIsVirtual=true)
 
virtual ~dtQueryFilter ()
 
bool getIsVirtual () const
 Returns true if it's a virtual filter.
 
bool passFilter (const dtPolyRef ref, const dtMeshTile *tile, const dtPoly *poly) const
 
dtReal getCost (const dtReal *pa, const dtReal *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
 
bool equals (const dtQueryFilter *other) const
 Check if two filters have the same data values.
 
bool equals (const dtQueryFilter &other) const
 
void copyFrom (const dtQueryFilter *other)
 Copy data values from source filter.
 
void copyFrom (const dtQueryFilter &other)
 
Getters and setters for the default implementation data.
dtReal getAreaCost (const int i) const
 
void setAreaCost (const int i, const dtReal cost)
 
const dtRealgetAllAreaCosts () const
 
dtReal getAreaFixedCost (const int i) const
 
void setAreaFixedCost (const int i, const dtReal cost)
 
const dtRealgetAllFixedAreaCosts () const
 
dtReal getModifiedHeuristicScale () const
 
dtReal getHeuristicScale () const
 
void setHeuristicScale (const dtReal newScale)
 Set euclidean distance heuristic scale.
 
bool isValidLinkSide (const unsigned char side) const
 
void setIsBacktracking (const bool isBacktracking)
 Sets up filter for backtracking.
 
bool getIsBacktracking () const
 
void setShouldIgnoreClosedNodes (const bool shouldIgnore)
 Instruct filter whether it can reopen nodes already on closed list.
 
bool getShouldIgnoreClosedNodes () const
 
unsigned short getIncludeFlags () const
 
void setIncludeFlags (const unsigned short flags)
 
unsigned short getExcludeFlags () const
 
void setExcludeFlags (const unsigned short flags)
 

Protected Member Functions

bool passInlineFilter (const dtPolyRef ref, const dtMeshTile *tile, const dtPoly *poly) const
 inlined filter implementation.
 
virtual bool passVirtualFilter (const dtPolyRef ref, const dtMeshTile *tile, const dtPoly *poly) const
 virtual filter implementation (defaults to passInlineFilter).
 
dtReal getInlineCost (const dtReal *pa, const dtReal *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
 inlined scoring function.
 
virtual dtReal getVirtualCost (const dtReal *pa, const dtReal *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
 virtual scoring function implementation (defaults to getInlineCost).
 
virtual float getVirtualCost (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 final
 

Protected Attributes

dtQueryFilterData data
 
bool isVirtual
 

Detailed 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

dtQueryFilter.isVIrtual must be true 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 ( bool  inIsVirtual = true)
inline

◆ ~dtQueryFilter()

virtual dtQueryFilter::~dtQueryFilter ( )
inlinevirtual

Member Function Documentation

◆ copyFrom() [1/2]

void dtQueryFilter::copyFrom ( const dtQueryFilter other)
inline

◆ copyFrom() [2/2]

void dtQueryFilter::copyFrom ( const dtQueryFilter other)
inline

Copy data values from source filter.

◆ equals() [1/2]

bool dtQueryFilter::equals ( const dtQueryFilter other) const
inline

◆ equals() [2/2]

bool dtQueryFilter::equals ( const dtQueryFilter other) const
inline

Check if two filters have the same data values.

◆ getAllAreaCosts()

const dtReal * dtQueryFilter::getAllAreaCosts ( ) const
inline

◆ getAllFixedAreaCosts()

const dtReal * dtQueryFilter::getAllFixedAreaCosts ( ) const
inline

◆ getAreaCost()

dtReal 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.

◆ getAreaFixedCost()

dtReal dtQueryFilter::getAreaFixedCost ( const int  i) const
inline

Returns the fixed cost for entering an area.

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

◆ getCost()

dtReal dtQueryFilter::getCost ( const dtReal pa,
const dtReal 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 reference 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.

◆ getHeuristicScale()

dtReal dtQueryFilter::getHeuristicScale ( ) const
inline

Retrieves euclidean distance heuristic scale

Returns
heuristic scale

◆ 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.

◆ getInlineCost()

dtReal dtQueryFilter::getInlineCost ( const dtReal pa,
const dtReal 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
inlineprotected

inlined scoring function.

See also
getCost for parameter description

◆ getIsBacktracking()

bool dtQueryFilter::getIsBacktracking ( ) const
inline

Retrieves information whether this filter is set up for backtracking

Returns
is backtracking

◆ getIsVirtual()

bool dtQueryFilter::getIsVirtual ( ) const
inline

Returns true if it's a virtual filter.

◆ getModifiedHeuristicScale()

dtReal dtQueryFilter::getModifiedHeuristicScale ( ) const
inline

◆ getShouldIgnoreClosedNodes()

bool dtQueryFilter::getShouldIgnoreClosedNodes ( ) const
inline

Retrieves information whether this filter allows reopening closed nodes

Returns
should consider reopening nodes already on closed list

◆ getVirtualCost() [1/2]

virtual dtReal dtQueryFilter::getVirtualCost ( const dtReal pa,
const dtReal 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
inlineprotectedvirtual

virtual scoring function implementation (defaults to getInlineCost).

See also
getCost for parameter description

◆ getVirtualCost() [2/2]

virtual float dtQueryFilter::getVirtualCost ( 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
inlinefinalprotectedvirtual

◆ isValidLinkSide()

bool dtQueryFilter::isValidLinkSide ( const unsigned char  side) const
inline

Filters link in regards to its side. Used for backtracking.

Returns
should link with this side be accepted

◆ 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.

◆ passInlineFilter()

bool dtQueryFilter::passInlineFilter ( const dtPolyRef  ref,
const dtMeshTile tile,
const dtPoly poly 
) const
inlineprotected

inlined filter implementation.

See also
passFilter for parameter description

◆ passVirtualFilter()

virtual bool dtQueryFilter::passVirtualFilter ( const dtPolyRef  ref,
const dtMeshTile tile,
const dtPoly poly 
) const
inlineprotectedvirtual

virtual filter implementation (defaults to passInlineFilter).

See also
passFilter for parameter description

◆ setAreaCost()

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

Sets the traversal cost of the area.

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

◆ setAreaFixedCost()

void dtQueryFilter::setAreaFixedCost ( const int  i,
const dtReal  cost 
)
inline

Sets the fixed cost for entering an area.

Parameters
[in]iThe id of the area.
[in]costThe new fixed cost of entering the area polygon.

◆ setExcludeFlags()

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

Sets the exclude flags for the filter.

Parameters
[in]flagsThe new flags.

◆ setHeuristicScale()

void dtQueryFilter::setHeuristicScale ( const dtReal  newScale)
inline

Set euclidean distance heuristic scale.

◆ setIncludeFlags()

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

Sets the include flags for the filter.

Parameters
[in]flagsThe new flags.

◆ setIsBacktracking()

void dtQueryFilter::setIsBacktracking ( const bool  isBacktracking)
inline

Sets up filter for backtracking.

◆ setShouldIgnoreClosedNodes()

void dtQueryFilter::setShouldIgnoreClosedNodes ( const bool  shouldIgnore)
inline

Instruct filter whether it can reopen nodes already on closed list.

Member Data Documentation

◆ data

dtQueryFilterData dtQueryFilter::data
protected

◆ isVirtual

bool dtQueryFilter::isVirtual
protected

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