Hi Latch! I was running several tests yesterday, and a few more today based on what you'd said.
I don't think that DBC 1.20 is saving animation data incorrectly - I've been running Lightning Limbs in 1.20, and the animations I've been saving out with it run fine in 1.13 and GDK but don't work in 1.20 itself. But adding the - signs as you suggested makes the animation work in 1.13, 1.20 and GDK. So I think the error merely lies in DBC's playing of the object, rather than anything else - though why the change in signs doesn't affect the animation in other programs is a mystery to me.
120 does seem to be the golden number - I've found that if I set these keyframes:
Rotate Limb 1, T, 0, 0, 0
Set Object Keyframe 1, 0
Rotate Limb 1, T, 0, 90, 0
Set Object Keyframe 1, 90
Rotate Limb 1, T, 0, 119, 0
Set Object Keyframe 1, 119
Rotate Limb 1, T, 0, 180, 0
Set Object Keyframe 1, 180
Rotate Limb 1, T, 0, 270, 0
Set Object Keyframe 1, 270
Rotate Limb 1, T, 0, 360, 0
Set Object Keyframe 1, 360
the limb will spin to 119 before flipping back round through 0 to reach 180. But change the 119 to 120, and the limb will only spin round to 90 before flipping back through 0, through 180 and then to 120. I can't quite explain why 120 should be such an important number, but I was thinking the reverse of direction as the limb hits 90 might be explained in terms of the sin curve.
It was your two equations that set me onto it, as I realised that Cos(90-x) = Sin(x). Also, when I looked at the animation data I saw the line "90 ; 4; 0.707107, 0.000000, -0.707107, 0.000000;;," and 0.707107 is a special number, Sin(45). But Sin(45) = Sin(135), so when I'm faced with 0.707107 I have no way of knowing which angle it should actually be. For any given value, ArcSin will only return a number between 0 and 90, and so DB will never produce an angle that rotates the limb between 90 and 180. Instead, it will spin the limb in the other direction and move 3 times faster to arrive at the correct location in time for the next keyframe.
It wouldn't surprise me if I was totally wrong on all this, but I'm afraid it's the best guess I've got. The limit of 120 might be due, as you suggested, to the way the interpolation is calculated. Certainly the presence of a keyframe between 90 and 120 can force the limb to keep rotating in the right direction before flipping back - maybe the typo in the c++ code was that 120 should read 180, as (I'm guessing) the limb rotation would then be subject to the maths that controls the rotation through 180..360 and that clearly works.
Quote: "In DBC 1.13, there was probably an algorithm that looked at the interpolation between keys and if it was less than a certain amount, the angle was calculated to be in the + direction, and if the interpolation was greater than a certain amount, the angle was calculated to be in - direction."
I don't think it would have been in DB 1.13 itself, rather the d3d dll. According to one of the files I got about the .x file format ages ago, the animation templates are used by the Direct3d Retained Mode, but support for that was removed from DB 1.20 because the dll wasn't always present on the newer operating systems. Perhaps the error crept in when DBC 1.20 was being programmed to take over the dll's commands?
[Edit]
Just been doing another test, Latch, and I've got some bad news - your fix works fine but only if there is rotation about just 1 axis. Add in a second axis, with 360 rotation, and your fix gets the animation working fine, but "flipped", so to speak. I've attached a Knight with animation I set up in DB 1.20 (pulled out the low-res one by mistake, so the Chest is Limb 2). 5 keyframes were set:
Rotate Limb 1, T, 0, 0, 0
Set Object Keyframe 1, 0
Rotate Limb 1, T, 0, 90, 90
Set Object Keyframe 1, 90
Rotate Limb 1, T, 0, 180, 180
Set Object Keyframe 1, 180
Rotate Limb 1, T, 0, 270, 270
Set Object Keyframe 1, 270
Rotate Limb 1, T, 0, 360, 360
Set Object Keyframe 1, 360
But if you invert the signs as you suggested, the animation becomes quite different, I think like a mirror image of the original.
It is said there are 10 types of people in this world - those who understand binary, and those who have friends!