Open bwasty opened 7 years ago
Including collision types is a good idea.
In my project the most useful collision test is (Ray, Aabb)
. I don't like the way collision-rs
handles this case though, returning Option<Point3<f32>>
instead of just Option<f32>
.
match aabb.collide(ray) {
ray::Collision::Hit(t) if t > 0.0 => {
println!("Hit at distance {} from ray origin", t);
let _pt = ray.pos + t * ray.dir;
},
ray::Collision::Hit(_) => {
println!("It's behind you!");
},
ray::Collision::Miss => {},
}
I like to write code like this.
Background: I wrote my own
Bounds
struct, because I overlooked thatcollision-rs
already has anAabb3
that is just what I need (didn't associate bounding boxes with collision detection, so I ignored the lib...).For a 'go-to' CG math wrapper I'd expect bounding boxes and perhaps also some other features of
collision-rs
.