       # TODO add forces here from whatever external forces are present (force
       # generators + force generator registry?)
 
+      # save the acceleration for contact resolution for resting contacts.
+      @lastAcceleration = Vec.scale @acceleration, dt
+
       @velocity = Vec.scale @velocity, Math.pow(@damping, dt)
-      @velocity = Vec.add @velocity, Vec.scale @acceleration, dt
+      @velocity = Vec.add @velocity, @lastAcceleration
 
     if @inverseMoment > 0
       @orientation = Rotation.addAngle @orientation, @angularVelocity * dt

  damping: 0.9999 # minimal
  angularDamping: 0.9999

  vertices: -> []

  color: "#CCC"


    # TODO save acceleration per frame and compensate here

    # debug "sepV", sepV

    # calculate distribution of desired deltaV between linear and angular
    # components on both bodies:
    deltaV = @from.inverseMass
    deltaV += @from.angularInertiaAt(@position, @normal)

    # ignore velocity accumulated in the last frame for reducing vibration
    # during resting contacts.
    velocityFromAcceleration = Vec.dotProduct @from.lastAcceleration, @normal

    if @to
      deltaV += @to.inverseMass
      deltaV += @to.angularInertiaAt(@position, @normal)
      velocityFromAcceleration -= Vec.dotProduct @to.lastAcceleration, @normal

    desiredDeltaV = -sepV - @restitution * (sepV - velocityFromAcceleration)
    impulse = Vec.scale @normal, desiredDeltaV / deltaV

    @from.applyImpulse impulse, @position
