5 releases
0.1.7 | Sep 11, 2023 |
---|---|
0.1.6 | Sep 2, 2023 |
0.1.5 | Aug 25, 2023 |
0.1.1 | Aug 23, 2023 |
0.1.0 | Aug 22, 2023 |
#420 in Graphics APIs
29 downloads per month
6KB
66 lines
raylite
Lightweight, 0-dependency raycasting in Rust
ð§WIP: Very early in development, feel free to post issues/contribute!
ð Installation
Install using cargo: cargo add raylite
ðŠķ Example
main.rs:
use raylite::{cast, Barrier, Ray};
fn main() {
// Positions are differentiated here because emission direction matters
let ray = Ray {
position: (0., 0.), // Emission origin position
end_position: (2., 0.), // Emission end position
};
let mut bar = Barrier {
positions: ((1., -1.), (1., 1.)), // Direction does not matter for Barriers
};
let result = cast(&ray, &bar); // Returns a Result<RayHit, RayFail>
assert!(result.is_ok()); // Result is an Ok<RayHit> containing hit info
bar = Barrier {
positions: ((-1., -1.), (-1., 1.)), // Place barrier behind the Ray
};
let result = cast(&ray, &bar);
assert!(result.is_err()); // Result is an Err<RayFail::NoHit>
}
cast_wide()
provides the same functionality as cast()
, but requires you to provide a &Vec<Barrier>
for batching purposes.