2D Collision detection with BSPs

Started by
12 comments, last by Promit 19 years, 8 months ago
*sigh* No. I don't understand how to traverse the BSP tree. Mainly, I don't understand what to do if a segment is across a partition line.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Advertisement
If it were me I might go about managing your collisions in a slightly different fashion. As mentioned, one problem with bsp design is that if the data is large enough you may still be searching for eons trying to find a collision. The bigger the level, the larger the search. Even if the geometry was first divided into a quad tree the issue is still present, given a game world that is large enough.
At this point I shall point out that my experience with bsp concepts does not span much further than reading a few paragraphs… I do apologize if the prior paragraph is a load of nonsense or the next is similarly bad.
If I were in your situation I would take a different approach:
A dynamically allocated 2d array exists to grant fast access to the immediate geometry surrounding a given position. The array elements represent ‘sectors’ of the map. The sectors are arranged like a grid, each one not large in size. An element contains a list of pointers, of which point to line segments that lie within the corresponding sector. The array must operate so as that point p is in sector p.x / sector_width, p.y / sector_height.
To perform collision checks for circle c, one must only test against the segments found in the circle’s current sector and the eight sectors surrounding it.

Hope this helps… and sorry it’s so rushed…

Jackson Allan
Okay Promit, I see what you mean now. If your swept sphere crosses the boundary, have you tried something like this?

if( Side == Classify.Front ){  CheckNode( Node.Front, s, tr, r );}else if( Side == Classify.Back ){  CheckNode( Node.Back, s, tr, r );}else if( Side == Classify.Across ){  CheckNode( Node.Front, s, tr, r );  CheckNode( Node.Back, s, tr, r );}
do unto others... and then run like hell.
You're a couple days late, but that's what I ended up doing. Except I'm also aplitting the ray on the boundary, since it makes swept circles much easier to deal with.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement