highfidelity/hifi — pull request #3307 by AndrewMeadows (2014-08-21 00:26:57+00:00)
Title: JS scripts can set spine rotation

The "lean avatar torso when getting head position data from gadgets" code was preventing JS scripts from modifying the base spine joint. This PR makes that code play a little better with the "animation priority" system that can be used to prevent systems from fighting over joint animation states.

ATM all scripts cannot set their animation priority so all scripts have equal access and may fight over joint animations (last script to set joint rotation wins) but the priority for scripts is higher than the hard-coded paths currently implemented for motion tracker devices.

While working on this project I encountered a few known problems with the animation priority system (which needs more work, yes, but will have to be fixed later):

(1) A script cannot release the animation of a joint that it has set. So once a script has set the animation of any particular joint then anything with lower priority (e.g. any trackers and the system that relaxes the avatar to the "default pose") will stop working...

(2) ... until any script is stopped (whether it has updated any animation states or not), at which point the animation priorities will be reset and the normal animation controls will be able to work.

This means that if you were to use ScriptA to put the avatar into a static pose once... it would stay that way until you removed ScriptB and the static pose will be lost.