mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[cpp] Port of commit 3ea4f66. AnimationState, fixed rotation mix when direction changes. See #2158.
This commit is contained in:
parent
ddc190527f
commit
6d4f2c2c1b
@ -742,19 +742,21 @@ void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleto
|
|||||||
lastTotal = 0;
|
lastTotal = 0;
|
||||||
lastDiff = diff;
|
lastDiff = diff;
|
||||||
} else {
|
} else {
|
||||||
lastTotal = timelinesRotation[i]; // Angle and direction of mix, including loops.
|
lastTotal = timelinesRotation[i];
|
||||||
lastDiff = timelinesRotation[i + 1];// Difference between bones.
|
lastDiff = timelinesRotation[i + 1];
|
||||||
}
|
}
|
||||||
|
float loops = lastTotal - MathUtil::fmod(lastTotal, 360.f);
|
||||||
bool current = diff > 0, dir = lastTotal >= 0;
|
total = diff + loops;
|
||||||
// Detect cross at 0 (not 180).
|
bool current = diff >= 0, dir = lastTotal >= 0;
|
||||||
if (MathUtil::sign(lastDiff) != MathUtil::sign(diff) && MathUtil::abs(lastDiff) <= 90) {
|
if (MathUtil::abs(lastDiff) <= 90 && MathUtil::sign(lastDiff) != MathUtil::sign(diff)) {
|
||||||
// A cross after a 360 rotation is a loop.
|
if (MathUtil::abs(lastTotal - loops) > 180) {
|
||||||
if (MathUtil::abs(lastTotal) > 180) lastTotal += 360 * MathUtil::sign(lastTotal);
|
total += 360.f * MathUtil::sign(lastTotal);
|
||||||
dir = current;
|
dir = current;
|
||||||
}
|
} else if (loops != 0)
|
||||||
|
total -= 360.f * MathUtil::sign(lastTotal);
|
||||||
total = diff + lastTotal - MathUtil::fmod(lastTotal, 360);// Store loops as part of lastTotal.
|
else
|
||||||
|
dir = current;
|
||||||
|
}
|
||||||
if (dir != current) {
|
if (dir != current) {
|
||||||
total += 360 * MathUtil::sign(lastTotal);
|
total += 360 * MathUtil::sign(lastTotal);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user