Shape Expansion and other tweaks

While working on a path-planning system, I had to add a few things to Box2D that I thought others might find useful:

  • changed the assert in b2BroadPhase::ComputeBounds to accept bounding boxes with zero width or height
  • fixed spurious intersections for segments perfectly aligned with a polygon edge
  • added an optional expansion radius parameter to b2Shape::TestPoint() and b2Shape::TestSegment()

I made the ComputeBounds change because axis-aligned segments generate zero-width or zero-height bounding boxes.

The expansion in b2PolygonShape is fairly naive, and would be better served by a polygon-capsule intersection test. It worked for what I needed it to do, though. 🙂

Original thread: https://box2d.org/forum/viewtopic.php?t=1254