Skip to main content

find_nearest_poly

Function find_nearest_poly 

Source
pub fn find_nearest_poly(
    mesh: &NavMesh,
    center: [f32; 3],
    half_extents: [f32; 3],
    include: u16,
    exclude: u16,
) -> Option<(u64, [f32; 3])>
Expand description

dtNavMeshQuery::findNearestPoly: the polygon of the mesh nearest to center within the box center plus or minus half_extents, and the nearest point on it.

A polygon is a candidate when its flags have a bit of include and none of exclude (the stock dtQueryFilter). Off-mesh connections are never candidates. The candidates come from the BV trees of the tiles the box touches (calcTileLoc of its corners, rows first), and the nearest is chosen as in Detour: a position directly over a polygon counts by its vertical distance beyond the tile’s walkableClimb only. The point uses the DayZ closestPointOnPoly (spec 10.2).

Returns None when no candidate exists.