Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: include collision-rs #1

Open
bwasty opened this issue Sep 24, 2017 · 2 comments
Open

Idea: include collision-rs #1

bwasty opened this issue Sep 24, 2017 · 2 comments

Comments

@bwasty
Copy link

bwasty commented Sep 24, 2017

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
Copy link
Owner

alteous commented Sep 24, 2017

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
Copy link
Owner

alteous commented Sep 24, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants