ezEngine Release 26.9
Loading...
Searching...
No Matches
ezAiNavmeshQuery Class Reference

Allows to do queries on a navmesh. More...

#include <NavMeshQuery.h>

Public Member Functions

ezAiNavMeshGetNavmesh () const
 
void SetNavmesh (ezAiNavMesh *pNavmesh)
 Sets on which navmesh to do the queries.
 
void SetQueryFilter (const dtQueryFilter &filter)
 Sets the filter to use on the navmesh to ignore certain areas.
 
void SetSearchExtents (float fExtentsXY, float fExtentsZ)
 Sets the half-extents of the search box used to snap an arbitrary position onto the nearest navmesh polygon (findNearestPoly). fExtentsXY is also used as the search radius for FindClosestPointOnNavmesh's wall query. Separate from the vertical (Z) extent, since navmeshes are usually thin (often a flat plane), so a horizontal search distance that's appropriate for e.g. how far inertia can carry something off the mesh would vastly over-match vertically if the same value were used for both.
 
float GetSearchExtentsXY () const
 
float GetSearchExtentsZ () const
 
bool PrepareQueryArea (const ezVec3 &vCenter, float fRadius)
 Checks that the given area of the navmesh is loaded, such that query results are useful.
 
bool Raycast (const ezVec3 &vStart, const ezVec3 &vDir, float fDistance, ezAiNavmeshRaycastHit &out_raycastHit)
 Does a raycast along the navmesh from the start position into a given direction.
 
bool FindRandomPointAroundCircle (const ezVec3 &vStart, float fRadius, ezRandom &ref_rng, ezVec3 &out_vPoint)
 Attempts to find a random point on the navmesh. The circle limits which navmesh polygons are visited.
 
bool FindClosestPointOnNavmesh (const ezVec3 &vPos, ezVec3 &out_vPoint, ezVec3 *out_pNormal=nullptr)
 Finds the closest point on the navmesh to vPos, e.g. to clamp a position back onto walkable ground.
 

Detailed Description

Allows to do queries on a navmesh.

Member Function Documentation

◆ FindClosestPointOnNavmesh()

bool ezAiNavmeshQuery::FindClosestPointOnNavmesh ( const ezVec3 vPos,
ezVec3 out_vPoint,
ezVec3 out_pNormal = nullptr 
)

Finds the closest point on the navmesh to vPos, e.g. to clamp a position back onto walkable ground.

out_pNormal, if provided, is filled with the direction from the navmesh border back towards the mesh interior (i.e. "inwards"), so that the caller can nudge the clamped point away from the border to counteract floating point imprecision. It is only set if a border could be determined; check the return value regardless.

Returns false, if no navmesh polygon could be found near vPos at all.

◆ FindRandomPointAroundCircle()

bool ezAiNavmeshQuery::FindRandomPointAroundCircle ( const ezVec3 vStart,
float  fRadius,
ezRandom ref_rng,
ezVec3 out_vPoint 
)

Attempts to find a random point on the navmesh. The circle limits which navmesh polygons are visited.

The result may be outside the circle, if the circle overlaps with a large navmesh polygon.

◆ PrepareQueryArea()

bool ezAiNavmeshQuery::PrepareQueryArea ( const ezVec3 vCenter,
float  fRadius 
)

Checks that the given area of the navmesh is loaded, such that query results are useful.

Returns false, if some navmesh sector is not yet available. It will be put into a queue and generated over the next frames.

◆ Raycast()

bool ezAiNavmeshQuery::Raycast ( const ezVec3 vStart,
const ezVec3 vDir,
float  fDistance,
ezAiNavmeshRaycastHit out_raycastHit 
)

Does a raycast along the navmesh from the start position into a given direction.

Returns true, if a navmesh edge has been hit and the result struct was filled with details.

◆ SetNavmesh()

void ezAiNavmeshQuery::SetNavmesh ( ezAiNavMesh pNavmesh)

Sets on which navmesh to do the queries.

See also
ezAiNavMeshWorldModule::GetNavMesh()

◆ SetQueryFilter()

void ezAiNavmeshQuery::SetQueryFilter ( const dtQueryFilter &  filter)

Sets the filter to use on the navmesh to ignore certain areas.

See also
ezAiNavMeshWorldModule::GetPathSearchFilter()

◆ SetSearchExtents()

void ezAiNavmeshQuery::SetSearchExtents ( float  fExtentsXY,
float  fExtentsZ 
)
inline

Sets the half-extents of the search box used to snap an arbitrary position onto the nearest navmesh polygon (findNearestPoly). fExtentsXY is also used as the search radius for FindClosestPointOnNavmesh's wall query. Separate from the vertical (Z) extent, since navmeshes are usually thin (often a flat plane), so a horizontal search distance that's appropriate for e.g. how far inertia can carry something off the mesh would vastly over-match vertically if the same value were used for both.

Applies to all queries made through this instance from now on. Pick this based on how far a queried position may realistically be off the navmesh, not per-call.


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