Sign in to follow this  

Reducing Collision Tests 2D

This topic is 3854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm using parametric ray-based detection and it works perfectly for edges and corners, I'm doing everything in 2D. The main problem is reducing the number of tests. In my sprite-based game I was using a grid so all I had to to was make a bounding box out of my moving object and then find out which grid cells it overlapped, then I would do the collision detection on only those cells. This new game I'm making using vertices and line segments, so the grid technique will work only if a vertex is inside the bounding box, but if a line segment goes through the box (with the vertices on the outside) I can't detect it. I know I can do quick eliminations by checking the distance to the line segment, normal facing, etc. but I'd still have to check every line segment (thousands of them) for every moving object (lots of those). What should I do ? Thanks.

Share this post


Link to post
Share on other sites
You _can_ use a grid -- I highly recommend "Real-Time Collision Detection", it has a great section on grids.

It sounds like you don't know of a way to insert linesegs into the grid -- one simple (but not optimal) way is to just calculate the bounding box of the lineseg, then insert the seg into all cells touched by the bounding box.

Share this post


Link to post
Share on other sites

This topic is 3854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this