TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
dtQueryFilter Class Reference

#include <DetourNavMeshQuery.h>

Public Member Functions

 dtQueryFilter ()
 
bool passFilter (const dtPolyRef ref, const dtMeshTile *tile, const dtPoly *poly) const
 
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
 
Getters and setters for the default implementation data.
float getAreaCost (const int i) const
 
void setAreaCost (const int i, const float cost)
 
unsigned short getIncludeFlags () const
 
void setIncludeFlags (const unsigned short flags)
 
unsigned short getExcludeFlags () const
 
void setExcludeFlags (const unsigned short flags)
 

Private Attributes

float m_areaCost [DT_MAX_AREAS]
 Cost per area type. (Used by default implementation.) More...
 
unsigned short m_includeFlags
 Flags for polygons that can be visited. (Used by default implementation.) More...
 
unsigned short m_excludeFlags
 Flags for polygons that should not be visted. (Used by default implementation.) More...
 

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

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 ( )
63  :
64  m_includeFlags(0xffff),
66 {
67  for (int i = 0; i < DT_MAX_AREAS; ++i)
68  m_areaCost[i] = 1.0f;
69 }
float m_areaCost[DT_MAX_AREAS]
Cost per area type. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:37
static const int DT_MAX_AREAS
Definition: DetourNavMesh.h:91
unsigned short m_includeFlags
Flags for polygons that can be visited. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:38
unsigned short m_excludeFlags
Flags for polygons that should not be visted. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:39

Member Function Documentation

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.
93 { return m_areaCost[i]; }
float m_areaCost[DT_MAX_AREAS]
Cost per area type. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:37
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]
98 {
99  return dtVdist(pa, pb) * m_areaCost[curPoly->getArea()];
100 }
float dtVdist(const float *v1, const float *v2)
Definition: DetourCommon.h:217
float m_areaCost[DT_MAX_AREAS]
Cost per area type. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:37
unsigned char getArea() const
Gets the user defined area id.
Definition: DetourNavMesh.h:182
Definition: BnetFileGenerator.h:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

112 { return m_excludeFlags; }
unsigned short m_excludeFlags
Flags for polygons that should not be visted. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:39
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.

103 { return m_includeFlags; }
unsigned short m_includeFlags
Flags for polygons that can be visited. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:38

+ Here is the caller graph for this function:

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.
90 {
91  return (poly->flags & m_includeFlags) != 0 && (poly->flags & m_excludeFlags) == 0;
92 }
unsigned short flags
The user defined polygon flags.
Definition: DetourNavMesh.h:166
unsigned short m_includeFlags
Flags for polygons that can be visited. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:38
unsigned short m_excludeFlags
Flags for polygons that should not be visted. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:39

+ Here is the caller graph for this function:

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.
98 { m_areaCost[i] = cost; }
float m_areaCost[DT_MAX_AREAS]
Cost per area type. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:37
void dtQueryFilter::setExcludeFlags ( const unsigned short  flags)
inline

Sets the exclude flags for the filter.

Parameters
[in]flagsThe new flags.
116 { m_excludeFlags = flags; }
unsigned short m_excludeFlags
Flags for polygons that should not be visted. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:39
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the caller graph for this function:

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

Sets the include flags for the filter.

Parameters
[in]flagsThe new flags.
107 { m_includeFlags = flags; }
unsigned short m_includeFlags
Flags for polygons that can be visited. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:38
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the caller graph for this function:

Member Data Documentation

float dtQueryFilter::m_areaCost[DT_MAX_AREAS]
private

Cost per area type. (Used by default implementation.)

unsigned short dtQueryFilter::m_excludeFlags
private

Flags for polygons that should not be visted. (Used by default implementation.)

unsigned short dtQueryFilter::m_includeFlags
private

Flags for polygons that can be visited. (Used by default implementation.)


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