Collision detection - getting stuck on corners

Hi there,
I am currently implementing collision detection on walls by doing a moving sphere(camera) polygon test. The camera stops and slides as it should except when it hits the outside corners of walls(say the outside of a building). My camera then gets stuck.

Now, after some debugging, I know it’s getting stuck because both walls share an edge. My collision detector then is unable to reliably tell me which wall I’m in contact with and therefore my collision response functions also break.

I have managed to get a work around by enclosing each wall in a slightly larger bounding plane. But this doesn’t feel like a very satisfactory solution - when I’m at the level of the wall it seems as though I might as well test directly against the on screen geometry. Anyone dealt with this before? Am I on the wrong path?

Thanks, Ben

Moving to the math section.

One solution is to bevel your geometry, both axially and at the edges. You can then expand all the planes–both original and bevels–together. This is a common approach taken by many BSP based colliders, but will work for stand-alone geometry as well.

How about just checking if the movement is into or out of the wall?

E.g.:

     handle  ignore
          \  /
       O-->\/
            
  

That shouldn’t take more than a dot product with the wall’s surface normal.

(I guess the story becomes more complex when you have an inside corner though. That might work better if you just have the wall exert an influence in its own normal vector’s direction.)

   \
\   \
 \   \
  \   \
   \ R \
    \   \    
   A \   \
------o  oo
   B  |  |  
      |  |  ^
      | R|  |
      |  |  o camera

This is the kind of trouble the OP is referring to, I think. If the camera slides along B toward A, it will end up behind the expanded plane. Many other nasty cases can crop up, but this one is typical.

The unpleasantness stems from expanding the object planes by an amount equal to the sphere’s radius in the normal direction (any distance method would do). The more accute the angle A is w.r.t. B, the more severe the problem, not to mention the extreme protrusion caused by such accute angles (think pointy cone here).

With axial beveling, the problem is solved, since each geometry is expanded against the same axial planes. This has the effect of “chopping off” the offending protrusions. Edge bevels help with other situations such as cone-like formations, where axial bevels alone will not handle the all base edges.

Note that it is much easier to bevel simple, convex polytopes. There are ways of beveling a BSP directly, but it is non-trivial. With convex geometry, one can simply add the bevel planes to the object definition–that’s it. Testing collisions with simple geometry is fast, easy, and fun too!

why don´t you try using the normal vector of the plane, that way you can diferentiate both surfaces, and yor algorithm wont get stuck. by the way, how does your colission detection algorithm work? may be theres a conceptual problem there