highfidelity/hifi — pull request #3057 by AndrewMeadows (2014-06-23 20:32:22+00:00)
Title: Ragdoll Part3: avatar shapes self collide (but don't yet affect the joint positions of MyAvatar)

The verlet simulation is functional: we can collide shapes, back them out, and enforce constraints.

What is new:

We have a PhysicsSimulation class that computes and resolves collisions and then enforces constraints. It repeats this cycle several times a frame to move toward a solution that is correct for all parts. The Model class now derives from PhysicsEntity, and PhysicsEntity instances can be added/removed from the simulation between steps. All per-joint shape stuff has been moved from the Model class to SkeltonModel. VerletCapsuleShape and VerletSphereShape derive from their base shapes and make it possible to use a collection of verlet points in the simulation.

Some things that are NOT done:

(a) feedback into SkeletonModel joint positions
(b) angular constraints
(c) friction
(d) broadphase collision culling
(e) adding multiple entities (works in theory, but would introduce poor performance until (d) is done)

To watch the collisions:

(1) Enable ragdoll physics via the menu: Developer --> Avatar Options --> Collide As Ragdoll
(2) Make the skeleton collision shapes visible: Developer --> Avatar Options --> Skeleton Collision Shapes
(3) Use the hydra or something to move the avatar hands around. Note that the skeleton shapes will collide against each other and deflect such that they do not overlap much.

Some things to note (besides the fact that the Avatar skeleton is not yet affected by the collisions):

(i) Only MyAvatar currently has verlet physics, and it only collides with itself (not with other avatars, voxels, or particles).
(ii) It is possible to tunnel limb through torso or other limbs. We don't yet have collision or angular constraints constraints, or angular constraints and we slave the shapes to the current avatar positions pretty hard (for low lag). This means that the "solution" to a collision can pop to a new solution on the other side.
(iii) The shapes may feel like they are sliding against each other like greasy blobs. There is no friction yet!
(iv) Glitchy behavior might be less noticeable on Release builds. The simulation is time-limited to about 2msec and Release simulations will get two or three times more iterations than Debug. More iterations mean more stable per-frame solutions.