I have two slightly different rigs (two armatures from different sources) and trying to transfer rotations between corresponding bones, from one armature to another (retarget current pose at some degree). Everything is fine except one thing - some bones has different rolls in edit mode, and simple cloning of rotation_quaternion shifts final positions.
The quiestion is: How i can account for roll difference, when applying rotation_quaternion from donor bone to target one? I don`t wish to reset roll on target bones, instead i with to recalculate quaternion for different roll, so target roll will stay the same, but quaternion will account for the difference instead. Imho this is possible, since rotation_quaternion is able to completely define bone rotation, but... how? How i can translate quaternion from one bone-local coordinate system to another?
I already tryed to calculate something like this: "donor rotation_quaternion" - "donor roll" + "target roll" to get "target rotation_quaternion". For example i tryed to create "donor roll" - "target roll" rotation matrix and apply it to rotate quaternion around target bone Z axis (to undo roll difference), but no luck.
So... How roll is applyed to final bone orientation? Is there the way to remove/undo it from rotation_quaternion?
Any help really appreciated