Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ten3roberts/bsp-pathfinding
Path finding using Binary Spatial Partitioning
https://github.com/ten3roberts/bsp-pathfinding
Last synced: about 2 months ago
JSON representation
Path finding using Binary Spatial Partitioning
- Host: GitHub
- URL: https://github.com/ten3roberts/bsp-pathfinding
- Owner: ten3roberts
- License: bsd-3-clause
- Created: 2021-12-29T21:37:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-22T07:50:38.000Z (over 2 years ago)
- Last Synced: 2024-11-15T22:11:54.258Z (about 2 months ago)
- Language: Rust
- Size: 188 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bsp-pathfinding
Provides a path finding search space generation and A* search algorithm
using Binary Spatial Partitioning.The navigable space is defined by polygons delimiting the space. A graph of
navigable nodes and edges will be generated.The algorithm does not impose any constraints on size or angle of the scene
as is the case for grid or quadtree based approaches.## Usage
```rust
use bsp_pathfinding::*;
use glam::*;
// Define a simple scene
let square = Shape::rect(Vec2::new(50.0, 50.0), Vec2::new(0.0, 0.0));
let left = Shape::rect(Vec2::new(10.0, 200.0), Vec2::new(-200.0, 10.0));
let right = Shape::rect(Vec2::new(10.0, 200.0), Vec2::new(200.0, 10.0));
let bottom = Shape::rect(Vec2::new(200.0, 10.0), Vec2::new(10.0, -200.0));
let top = Shape::rect(Vec2::new(200.0, 10.0), Vec2::new(10.0, 200.0));// Create navigational context from the scene
let nav = NavigationContext::new([square, left, right, top, bottom].iter().flatten());// Find a path
let start = Vec2::new(-100.0, 0.0);
let end = Vec2::new(100.0, 30.0);let path = nav
.find_path(start, end, heuristics::euclidiean, SearchInfo::default())
.expect("Failed to find a path");
```