condor-for-games 0.4.0

Rust pathfinding library for grids, polygonal scenes, navmeshes, and replanning.
Documentation
//! Reuse a caller-owned polygonal map from one fixed source.

use condor::{
    ContinuousShortestPathMap, Point2, Polygon, PolygonScene, PolygonShortestPathMap,
    PolygonShortestPathMapBuilder, polygonal::WorldBounds,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let scene = PolygonScene {
        world_bounds: WorldBounds::new(Point2::new(0.0, 0.0), Point2::new(6.0, 6.0)),
        obstacles: vec![Polygon::new(vec![
            Point2::new(2.0, 1.0),
            Point2::new(3.0, 1.0),
            Point2::new(3.0, 3.0),
            Point2::new(2.0, 3.0),
        ])],
    };
    let map = ContinuousShortestPathMap.preprocess(&scene, Point2::new(0.5, 0.5))?;
    let result = map.query(Point2::new(4.5, 2.5))?;
    println!("cost={:?}", result.cost());
    Ok(())
}