=====================================================================
Jiggle Copyright 2003 Danny Chapman: danny@rowlhouse.freeserve.co.uk
Jiggle comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions; see the GNU General Public License

Note - I need to clear things with my employer before releasing the source code.
When this is sorted (Christmas 2003?) I hope to be able to release the source 
code - hence the license....

=====================================================================

======== Usage ==============
Run jiggle.exe on its own, or
jiggle.exe my_config.cfg
or run one of the batch files.

Tweak stuff in jiggle.cfg - depending on what kind of demo you want to see/how fast your machine is. All the demos run at 90 FPS or more on my 2GHz Athlon. 

Not much interaction at the moment:

arrow keys move the camera

the keys wasd lift and move the first object that was created. space just lifts it.

if there's a car, the keys 'tfgh' control it, and '1' and '2' change views.

'c' creates a car.

'b' creates a box.

'y' creates a cylinder.

'p' toggles the autopilot on the first car (if one exists)

'F' toggles object freezing

========= Background =========

Implementation follows (sort of) the algorithm described in "Nonconvex rigid bodies with stacking" by Guendelman et al.

In particular, this means:

1. Collisions are done with impulses.

2. Constraints are done with impulses. Resting contact is treated as a constraint, 
   implemented by doing an inelastic collision. Joints are also done using constraints/impulses.

3. The timestepping is cunningly organised so as to do away with the need for artificial
   distinctions between collisions/resting contact etc

4. Collisions/constraints are applied in an iterative manner.

5. The algorithm does not back up to avoid penetration (it "predicts" penetration, then applies
   impulses to try to avoid it). This is good and bad - good because you don't have to stop/restart
   the solver, and bad because it can't guarantee no penetration.

However, it only uses one collision detection per time-step.

========= Todo (9 Dec) =======

1. general speed-ups. Done most of the obvious ones... 

2. better collision detection, including spatial partitioning. Support basic primitives (esp box
   and sphere) and allow combining them.

3. more/better joint types - universal joint currently done with two hinges (inefficient)

4. better friction on the joints.

5. integrate "moving" surfaces into the contact step - this is for wheels, so that 
   friction etc can be applied using impulses, in order to get no skidding when 
   stationary.

6. quaternions alongside the rotation

7. add cleanup code... and separate the files out into modules.

8. Detect near-collisions - then update the collision structures during the impulse iterations. This
   would approximate the multiple-collision detections per timestep in the original paper.

========= History ============
23 Feb 2004:
Implement the max-distance constraint properly, and use it more in the hinge joint.
Simplify and improve the ragdoll using the above change.

30 Dec:
Speed up for the mesh creation for box/ellipsoid/cylinder, and allow cloning (e.g. with the car).
Screensaver.
Fix the mesh lookup.
Allow a bit of (configurable) slop in the joints - improves the ragdoll look.

21 Dec:
Cylinder. 
Fix friction so it uses the velocity after the collision impulse
Impose constraints during the collision phase.
Various deactivation improvements.

18 Dec:
Object deactivation. Reverted to using the non-interpolated collision mesh (still bad in places).

8/9 Dec:
General speed ups. Set up the batch files - I'll try to keep the associated configs the same so I can keep track of speedup work.

7 Dec:
Joint friction. Improvements to collision detection. ragdoll loop demo.

4 Dec:
Joint limits
non-collidable body pairs
ellipsoid

3 Dec:
constraints (world and body-body)
first rag doll

2 Dec
penetration resolution done using impulses
first run through profiler

1 Dec
implemented body-body collisions

28 Nov
Got the basic framework running, with objects interacting with the ground, but not each other

20 Nov (approx)
Started.
