mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 17:56:04 +08:00
[cpp] Fixed AnimationState not respecting MixBlend.first for rotate timelines. See #1274.
This commit is contained in:
parent
2843950e18
commit
c0277ff12b
@ -642,14 +642,19 @@ void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleto
|
|||||||
|
|
||||||
Bone *bone = skeleton._bones[rotateTimeline->_boneIndex];
|
Bone *bone = skeleton._bones[rotateTimeline->_boneIndex];
|
||||||
Vector<float>& frames = rotateTimeline->_frames;
|
Vector<float>& frames = rotateTimeline->_frames;
|
||||||
|
float r1, r2;
|
||||||
if (time < frames[0]) {
|
if (time < frames[0]) {
|
||||||
if (blend == MixBlend_Setup) {
|
switch (blend) {
|
||||||
|
case MixBlend_Setup:
|
||||||
bone->_rotation = bone->_data._rotation;
|
bone->_rotation = bone->_data._rotation;
|
||||||
}
|
default:
|
||||||
return;
|
return;
|
||||||
|
case MixBlend_First:
|
||||||
|
r1 = bone->_rotation;
|
||||||
|
r2 = bone->_data._rotation;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
float r2;
|
r1 = blend == MixBlend_Setup ? bone->_data._rotation : bone->_rotation;
|
||||||
if (time >= frames[frames.size() - RotateTimeline::ENTRIES]) {
|
if (time >= frames[frames.size() - RotateTimeline::ENTRIES]) {
|
||||||
// Time is after last frame.
|
// Time is after last frame.
|
||||||
r2 = bone->_data._rotation + frames[frames.size() + RotateTimeline::PREV_ROTATION];
|
r2 = bone->_data._rotation + frames[frames.size() + RotateTimeline::PREV_ROTATION];
|
||||||
@ -667,9 +672,9 @@ void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleto
|
|||||||
r2 = prevRotation + r2 * percent + bone->_data._rotation;
|
r2 = prevRotation + r2 * percent + bone->_data._rotation;
|
||||||
r2 -= (16384 - (int) (16384.499999999996 - r2 / 360)) * 360;
|
r2 -= (16384 - (int) (16384.499999999996 - r2 / 360)) * 360;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
|
// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
|
||||||
float r1 = blend == MixBlend_Setup ? bone->_data._rotation : bone->_rotation;
|
|
||||||
float total, diff = r2 - r1;
|
float total, diff = r2 - r1;
|
||||||
diff -= (16384 - (int) (16384.499999999996 - diff / 360)) * 360;
|
diff -= (16384 - (int) (16384.499999999996 - diff / 360)) * 360;
|
||||||
if (diff == 0) {
|
if (diff == 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user