waymark
Pathfinding and spatial queries on navigation meshes.
Overview
waymark provides pathfinding on navigation meshes generated by landmark or
other tools. It implements A* pathfinding, spatial queries, and supports
multi-tile navigation meshes.
Rust port of the Detour component from RecastNavigation.
Features
- A Pathfinding*: Find paths between points on the navmesh
- Path Straightening: Funnel algorithm for optimal paths
- Raycasting: Line-of-sight queries against the navmesh
- Spatial Queries: Find nearest points, random points, polygon heights
- Off-mesh Connections: Support for jumps, ladders, and teleports
- Multi-tile Support: Large world navigation with tiled meshes
- Query Filters: Customizable traversal costs and area filtering
Optional Features
serialization- Save/load navigation meshes via Serde
WASM Support
This crate is fully compatible with WebAssembly. Build for WASM with:
The serialization feature works on WASM with in-memory buffers. File-based
save/load is not available on WASM.
Example
use ;
use Vec3;
// Build a NavMesh from landmark output
let params = default;
let nav_mesh = build_from_recast?;
// Create a query object
let mut query = new;
let filter = default;
let extents = new;
// Find the start and end polygons
let = query.find_nearest_poly?;
let = query.find_nearest_poly?;
// Find a path (A* polygon corridor)
let path = query.find_path?;
// Straighten the path using the funnel algorithm
let straight_path = query.find_straight_path?;
Query Types
| Query | Description |
|---|---|
find_path |
A* path between two polygons |
find_straight_path |
Straightened path with corners |
raycast |
Line-of-sight test |
find_nearest_poly |
Closest polygon to a point |
find_random_point |
Random navigable location |
get_poly_height |
Height at a point on a polygon |
License
Dual-licensed under either:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)