Making the armature constraint play nice with scaling

Armature constraints play an important part in character rigging, allowing you to constrain an object to multiple bones with weighted influences. This is very useful for layering face rig mechanisms for instance.

Currently it works in two ways that both fall short for me:

  1. Linear. Your object is influenced by the linearly blended matrices of the targets. This results in volume loss and shear deformation when rotating the targets, just like with linear skinning.
  2. Dual Quaternion. Your object is controlled with averaged quaternions of the targets. The volume and shape are preserved, until you attempt to scale the targets along one or two axes. The object will then scale and shear in some unpredictable direction.

I tried a different system that linearly blends the matrices for the position, averages the quaternions for the orientation and linearly blends the target scaling on top of all of that. The result is linear armature constraint behavior except without volume loss.

I worked out the math in a Python script that is evaluated every frame for a few specific objects in a Blender scene, but I’m a little lost as to where to even begin implementing it in Blender, or if it’s even a good idea. Would anyone want to take a look at my Python implementation and possibly help me to enhance the Amature Constraint feature?

Targets rotating and then non-uniformly scaling and shearing, the effects linearly blending onto the object.