euler icon indicating copy to clipboard operation
euler copied to clipboard

Idea: include collision-rs

Open bwasty opened this issue 8 years ago • 2 comments

Background: I wrote my own Bounds struct, because I overlooked that collision-rs already has an Aabb3 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.

bwasty avatar Sep 24 '17 10:09 bwasty

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>.

alteous avatar Sep 24 '17 13:09 alteous

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.

alteous avatar Sep 24 '17 13:09 alteous