No, you don't need to remove them. That's how you get the scale values.Finished porting. I may release soon.
Do I have to delete these lines?
Code:state._scale._x = (float)Math.Round(Math.Sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]), 4); state._scale._y = (float)Math.Round(Math.Sqrt(p[4] * p[4] + p[5] * p[5] + p[6] * p[6]), 4); state._scale._z = (float)Math.Round(Math.Sqrt(p[8] * p[8] + p[9] * p[9] + p[10] * p[10]), 4);
I didn't clarify what I meant about the problem with scaling. The problem with distortion is unavoidable, simply because that's how scaling works. It distorts the matrix. Open any modeling program and apply scale + rotate and you'll see the same thing.
It appears that rotating a bone that is affected by scaling causes the rotation to be irregular at certain points. This is most likely due to the use of the frame matrices, which have scaling applied. What you will probably need to do is replace the use of frame matrices and construct new ones by stripping out the scale values.
Get the effective scale from the frame matrix like so:
ScaleX = sqrt(00² + 01² + 02²)
ScaleY = sqrt(04² + 05² + 06²)
ScaleZ = sqrt(08² + 09² + 10²)
Multiply the inverse (1 / scale) by each value in the column. Leave the 4th column alone because this holds a valid world location for the bone. You can then use this matrix to convert to/from local-space. I may be easier just to show you...