Merge branch 'EsotericSoftware/3.6' into 3.6

This commit is contained in:
Stephen Gowen 2017-10-23 12:55:34 -04:00
commit 10c2ae1514
2 changed files with 41 additions and 9 deletions

View File

@ -258,13 +258,17 @@ namespace Spine {
break;
case Dip:
pose = MixPose.Setup;
alpha = alphaDip;
alpha = mix == 1 ? 0 : alphaDip;
break;
default:
pose = MixPose.Setup;
alpha = alphaDip;
var dipMix = timelineDipMix[i];
alpha *= Math.Max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
if (mix == 1) {
alpha = 0;
} else {
alpha = alphaDip;
var dipMix = timelineDipMix[i];
alpha *= Math.Max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
}
break;
}
from.totalAlpha += alpha;

View File

@ -51,7 +51,31 @@ import com.esotericsoftware.spine.Animation.Timeline;
* See <a href='http://esotericsoftware.com/spine-applying-animations/'>Applying Animations</a> in the Spine Runtimes Guide. */
public class AnimationState {
static private final Animation emptyAnimation = new Animation("<empty>", new Array(0), 0);
static private final int SUBSEQUENT = 0, FIRST = 1, DIP = 2, DIP_MIX = 3;
/** 1) A previously applied timeline has set this property.<br>
* Result: Mix from the current pose to the timeline pose. */
static private final int SUBSEQUENT = 0;
/** 1) This is the first timeline to set this property.<br>
* 2) The next track entry applied after this one does not have a timeline to set this property.<br>
* Result: Mix from the setup pose to the timeline pose. */
static private final int FIRST = 1;
/** 1) This is the first timeline to set this property.<br>
* 2) The next track entry to be applied does have a timeline to set this property.<br>
* 3) The next track entry after that one does not have a timeline to set this property.<br>
* Result: Mix from the setup pose to the timeline pose, but avoid the "dipping" problem by not using the mix percentage. This
* means the timeline pose won't mix out toward the setup pose. A subsequent timeline will set this property using a mix. */
static private final int DIP = 2;
/** 1) This is the first timeline to set this property.<br>
* 2) The next track entry to be applied does have a timeline to set this property.<br>
* 3) The next track entry after that one does have a timeline to set this property.<br>
* 4) timelineDipMix stores the first subsequent track entry that does not have a timeline to set this property.<br>
* Result: This is the same as DIP except the mix percentage from the timelineDipMix track entry is used. This handles when
* more than 2 track entries in a row have a timeline which sets the same property.<br>
* Eg, A -> B -> C -> D where A, B, and C have a timeline to set the same property, but D does not. When A is applied, A's mix
* percentage is not used to avoid dipping, however a later track entry (D, the first entry without a timeline which sets the
* property) is actually mixing out A (which affects B and C). Without using D's mix percentage, A would be applied fully until
* mixed out, causing snapping. */
static private final int DIP_MIX = 3;
private AnimationStateData data;
final Array<TrackEntry> tracks = new Array();
@ -257,13 +281,17 @@ public class AnimationState {
break;
case DIP:
pose = MixPose.setup;
alpha = alphaDip;
alpha = mix == 1 ? 0 : alphaDip;
break;
default:
pose = MixPose.setup;
alpha = alphaDip;
TrackEntry dipMix = (TrackEntry)timelineDipMix[i];
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
if (mix == 1)
alpha = 0;
else {
alpha = alphaDip;
TrackEntry dipMix = (TrackEntry)timelineDipMix[i];
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
}
break;
}
from.totalAlpha += alpha;