Reducing Collision Tests 2D

Started by
0 comments, last by raigan 16 years, 11 months ago
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.
Advertisement
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.

This topic is closed to new replies.

Advertisement