highfidelity/hifi — pull request #3253 by AndrewMeadows (2014-08-05 01:06:27+00:00)
Title: Ragdoll Part 8: improved contact points

Contact points now are much better at preventing tunneling of limbs through limbs. The ContactPoint class keeps track of a pair of shape-relative points where two shapes were touching at the end of the previous frame. After the integration step, but before the verlet loop, the ContactPoints are checked for violations where two shapes have moved past each other. On violation the ContactPoint moves the shapes (in a somewhat naive fashion -- more about this later) such that their two points coincide again (with some give for friction), and it then builds some internal constraints that try (during the verlet loop) to maintain distances between this virtual contact point and the verlet points of the shapes.

As mentioned above there is some treatment for friction and this is noticeable when the avatar self-collides.

Some known issues:

(1) The head model doesn't follow the body. This is probably because the head is following the "true target position" of the body's neck rather than the "visible position" after all collisions -- should be easy to fix.

(2) Sometimes there is an oscillation/vibration when one limb is pressing hard against another part of the body. There are two improvements that may help reduce this:

(2.a) The "naive fashion" by which the ContactPoint pulls the pair of shapes back into contact is to translate all VerletPoints for a particular shape the same amount, but a more correct way would be to move points different amounts depending on leverage arms and relative masses (i.e. more correct Lagrangian weights similar to how verlet dynamics are handled).

(2.b) During the verlet loop the ContactPoint's internal state is updated after each collision, and these changes modify (and therefore slightly invalidate) the ContactPoint-internal constraints that were computed before the verlet loop. These updates should be decoupled from the internal constraints.