Collision Engines
- Step based overlap detection.
- (+)Simple
- (+++)Sort and Sweep is a very powerful optimization
- Compute a step forward
- (-)Things that move too fast can jump over things
- Full Prediction
- (++)Not step based
- Moderate complexity
- (++)Not possible to jump past other things
- (+)Very fast with just a few objects
- (--)Very slow with lots of objects.
- (---)Only motion that can be "solved" are allowed. (linear)
- Hybrid Engine
- (-)Step based
- The swept volume of the object's motion that step is used for overlap sort and sweep.
- Objects with overlapping swept volumes are collected and given to a predictive engine for that step.
- (++)Things don't get jumped over.
- (+)Multiple collision within a step (rattle)
- What do overlapping regions look like in a dense gas simulation?
- (-)Motion within a step is limited to "solvable" motions (linear)
The Basics
Body
The top level objects that participate in the collision engine are called "Bodies". A Body is is made up of one or more "Fixtures" and is either Static, Dynamic, or Kinematic.
- Body Types:
- Static: The body is immovable.
- Dynamic: The body moves, bounces, and falls in gravity.
- Kinematic: The body moves but does not bounce or fall in gravity.
- Dynamic Body limitations:
- Because the simulation doesn't handle rotations, dynamic bodies can only be made of either a single circular fixture or multiple circular fixtures with the same center point.
- Static Body limitations:
- Static bodies can be made up of any number of any kind of fixture.
- Kinematic Body limitations:
- A kinematic Body can be made of any number of any kind of fixture. But it cannot rotate. (kinematic bodies are currently not implemented)
- AABB: the Axis Aligned Bounding Box of the Body is computed by union of the Fixture AABBs.
Fixture
A Fixture has a Geometry (circle, point, line, etc..), and a "Fixture Definition" that contains: Density, Collision Restitution, and Physical vs. Sensor status.- Fixture Type:
- Physical Fixtures physically impact with other physical Fixtures.
- Sensor Fixtures is sent a notification when a physical fixtures overlaps it. The physical fixture is not notified. Nothing happens when two sensor fixtures overlap.
Sensor Fixtures can be used for "traps", "Sight regions", and cross region doorways. - AABB: Axis Aligned Bounding Box.
Geometry
The geometries current available are: Point, Circle, Line Segment, and Poly Line.
- Point is just a position.
- Circle is a position and a radius.
- Line Segment: Only the line segment itself is collided against the end points are not included as "corners" (see Poly Line below). The Line Segment is represented as both
- Two endpoints
- A unit normal and the distance from the origin to the line in the normal direction.
- Poly Line is a collection of lines connected by points (corners). Both the line segments are the corners (and end points) are included in the collision detection.
Colliders
To work out collision we need to take geometries and motions and predict forward when, or if, they will intersect. This is necessary even for a simple step-wise overlap detect engine. You notice that next step (frame) two object that were not overlapping will be overlapping. So you then need to work out exactly where and when they first touch so the collision and "bounce" can be computed.