Polyart 2D Physics Engine

Section 4: Collision Response


Collision Response

Types of collision prevention fallbacks (Response types)- When one type fails to prevent interpenetration, the next is used
  1. Impulse - An impulse will be applied to prevent the segments from interpenetrating. Friction is only applied at this step.
  2. Relative Freeze A - The velocities at the points of collision in the direction of the normal will be set to the average.
  3. Relative Freeze B - The velocities at the points of collision will be set to the average.
  4. Movement Fudge - The velocity will be changed JUST for the current frame making the objects move apart. This is useful if the necessary velocity will launch the object unrealisticly fast. Since it modifies a velocity invisible to the other response types and might cause them to malfunction, only a total freeze should be attempted after this.
  5. Total Freeze - No movement will take place. Since the objects on this frame are not colliding, preventing movement will ensure this on the next frame.

Alternative fallback - Soft/Solid collision structure


Possible collision scenario
  1. Force is applied and does not prevent interpenetration
  2. Movement fudge is applied and also fails
  3. The object is permitted to penetrate the soft structure and use the solid. Movement fudge is applied again.
  4. At this last attempt the objects linear velocities are set to be the same and the rotational is set to 0.
Objects already penetrating
CGeometry2D


Resistance at a point is defined as 
F/V = Mass for the linear component +  1 / (1/m + R/I)  (for the angular component


Suedocode for proper collision routine
  1. Create octree sets A + B
  2. Set collision response to time of collision
  3. A.CollideWith(B) - response function has two bounding boxes one from A and one from B
  4. Handle first Collision time
  5. A.CollideWith(BoxFromB);
  6. B.CollideWith(BoxFromA);
  7. Update A and B's position in the octrees
  8. loop to step 4 if more collisions exist
Temporary Collision response
  1. Create octree sets A + B
  2. Set collision response to apply collision impulse
  3. A.CollideWith(B) - response function has two bounding boxes one from A and one from B
  4. loop to step 3 if a collision happened
Body Set Detection
  1. Loop through each body set: CurSet
  2. Loop through each body on the queue for the current set: CurBody
  3. Loop though each body set that collides with the current set: CurSet2 Collide CurBody with CurSet2
Pose response In debug mode after body A collides with body B a collision check is applied again and an error message box popped up on the screen stating the response failed to prevent interpenetration.
Copyright 2004 © Polyart. All rights reserved.
Designed by Kenneth Manta