alteous / euler

Mathematics library for 3D computer graphics.
Apache License 2.0
24 stars 2 forks source link

Idea: include collision-rs #1

Open bwasty opened 7 years ago

bwasty commented 7 years ago

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.

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

alteous commented 7 years ago
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.