I am implementing a skeleton system for my latest game. I am using my own linear algebra classes which already have some optimisations, such as separate transformPoint and transformVector functions which avoid some multiplications by 0 or 1. It is working well so my question is not HOW to implement skeletal animation.
My question is how to optimise the matrix multiplications. At the moment there are several full 4x4 multiplications and 1 inverse per bone. I need the inverse because this is not just for skinning but also physics and stuff. But there are many 0s and 1s in the homogeneous matrices which can be optimised out. Also, I want to be able to specify the degrees of freedom for each joint, and in which order they are calculated, so for example, a shoulder joint could rotate yaw then pitch, or pitch then yaw. The result would be different. Should I have a separate matrix constructor for each permutation, which I believe is 15?
I assume this is a common issue with skeletal systems, so is there a standard method for this? How do engines normally optimise forward kinematic calculations?
I calculate all the matrices for the bones, starting at the root and working outwards. Note: my bones are in an array that is sorted by heirarchy depth so a bone's parent's matrices will already have been computed.
Please note: this is not a questions about skinning, I have no problem with that.