condor-for-games 0.4.0

Rust pathfinding library for grids, polygonal scenes, navmeshes, and replanning.
Documentation
//! Small caller-owned exact polygonal query.

use condor::{
    Point2, Polygon, PolygonPathfinder, PolygonScene, PolygonSearchRequest, VisibilityGraph,
    polygonal::WorldBounds,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let scene = scene();
    let request = PolygonSearchRequest::new(Point2::new(0.5, 0.5), Point2::new(4.5, 4.5));
    scene.validate(request)?;
    let result = VisibilityGraph.search(&scene, request)?;
    println!("found={} cost={:?}", result.is_found(), result.cost());
    Ok(())
}

fn scene() -> PolygonScene {
    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),
        ])],
    }
}