|
@@ -34,8 +34,8 @@ package spine.animation {
|
|
|
|
|
|
public class IkConstraintTimeline extends CurveTimeline {
|
|
public class IkConstraintTimeline extends CurveTimeline {
|
|
static public const ENTRIES : int = 5;
|
|
static public const ENTRIES : int = 5;
|
|
- static internal const PREV_TIME : int = -5, PREV_MIX : int = -4, PREV_BEND_DIRECTION : int = -3, PREV_COMPRESS : int = -2, PREV_STRETCH : int = -1;
|
|
|
|
- static internal const MIX : int = 1, BEND_DIRECTION : int = 2, COMPRESS : int = 3, STRETCH : int = 4;
|
|
|
|
|
|
+ static internal const PREV_TIME : int = -6, PREV_MIX : int = -5, PREV_SOFTNESS : int = -4, PREV_BEND_DIRECTION : int = -3, PREV_COMPRESS : int = -2, PREV_STRETCH : int = -1;
|
|
|
|
+ static internal const MIX : int = 1, SOFTNESS : int = 2, BEND_DIRECTION : int = 3, COMPRESS : int = 4, STRETCH : int = 5;
|
|
public var ikConstraintIndex : int;
|
|
public var ikConstraintIndex : int;
|
|
public var frames : Vector.<Number>; // time, mix, bendDirection, compress, stretch, ...
|
|
public var frames : Vector.<Number>; // time, mix, bendDirection, compress, stretch, ...
|
|
|
|
|
|
@@ -49,10 +49,11 @@ package spine.animation {
|
|
}
|
|
}
|
|
|
|
|
|
/** Sets the time, mix and bend direction of the specified keyframe. */
|
|
/** Sets the time, mix and bend direction of the specified keyframe. */
|
|
- public function setFrame(frameIndex : int, time : Number, mix : Number, bendDirection : int, compress: Boolean, stretch: Boolean) : void {
|
|
|
|
|
|
+ public function setFrame(frameIndex : int, time : Number, mix : Number, softness: Number, bendDirection : int, compress: Boolean, stretch: Boolean) : void {
|
|
frameIndex *= ENTRIES;
|
|
frameIndex *= ENTRIES;
|
|
frames[frameIndex] = time;
|
|
frames[frameIndex] = time;
|
|
frames[int(frameIndex + MIX)] = mix;
|
|
frames[int(frameIndex + MIX)] = mix;
|
|
|
|
+ frames[int(frameIndex + SOFTNESS)] = softness;
|
|
frames[int(frameIndex + BEND_DIRECTION)] = bendDirection;
|
|
frames[int(frameIndex + BEND_DIRECTION)] = bendDirection;
|
|
frames[int(frameIndex + COMPRESS)] = compress ? 1 : 0;
|
|
frames[int(frameIndex + COMPRESS)] = compress ? 1 : 0;
|
|
frames[int(frameIndex + STRETCH)] = stretch ? 1 : 0;
|
|
frames[int(frameIndex + STRETCH)] = stretch ? 1 : 0;
|
|
@@ -65,12 +66,14 @@ package spine.animation {
|
|
switch (blend) {
|
|
switch (blend) {
|
|
case MixBlend.setup:
|
|
case MixBlend.setup:
|
|
constraint.mix = constraint.data.mix;
|
|
constraint.mix = constraint.data.mix;
|
|
|
|
+ constraint.softness = constraint.data.softness;
|
|
constraint.bendDirection = constraint.data.bendDirection;
|
|
constraint.bendDirection = constraint.data.bendDirection;
|
|
constraint.compress = constraint.data.compress;
|
|
constraint.compress = constraint.data.compress;
|
|
constraint.stretch = constraint.data.stretch;
|
|
constraint.stretch = constraint.data.stretch;
|
|
return;
|
|
return;
|
|
case MixBlend.first:
|
|
case MixBlend.first:
|
|
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
|
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
|
|
|
+ constraint.softness += (constraint.data.softness - constraint.softness) * alpha;
|
|
constraint.bendDirection = constraint.data.bendDirection;
|
|
constraint.bendDirection = constraint.data.bendDirection;
|
|
constraint.compress = constraint.data.compress;
|
|
constraint.compress = constraint.data.compress;
|
|
constraint.stretch = constraint.data.stretch;
|
|
constraint.stretch = constraint.data.stretch;
|
|
@@ -81,7 +84,8 @@ package spine.animation {
|
|
if (time >= frames[int(frames.length - ENTRIES)]) { // Time is after last frame.
|
|
if (time >= frames[int(frames.length - ENTRIES)]) { // Time is after last frame.
|
|
if (blend == MixBlend.setup) {
|
|
if (blend == MixBlend.setup) {
|
|
constraint.mix = constraint.data.mix + (frames[frames.length + PREV_MIX] - constraint.data.mix) * alpha;
|
|
constraint.mix = constraint.data.mix + (frames[frames.length + PREV_MIX] - constraint.data.mix) * alpha;
|
|
-
|
|
|
|
|
|
+ constraint.softness = constraint.data.softness
|
|
|
|
+ + (frames[frames.length + PREV_SOFTNESS] - constraint.data.softness) * alpha;
|
|
if (direction == MixDirection.Out) {
|
|
if (direction == MixDirection.Out) {
|
|
constraint.bendDirection = constraint.data.bendDirection;
|
|
constraint.bendDirection = constraint.data.bendDirection;
|
|
constraint.compress = constraint.data.compress;
|
|
constraint.compress = constraint.data.compress;
|
|
@@ -93,6 +97,7 @@ package spine.animation {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
constraint.mix += (frames[frames.length + PREV_MIX] - constraint.mix) * alpha;
|
|
constraint.mix += (frames[frames.length + PREV_MIX] - constraint.mix) * alpha;
|
|
|
|
+ constraint.softness += (frames[frames.length + PREV_SOFTNESS] - constraint.softness) * alpha;
|
|
if (direction == MixDirection.In) {
|
|
if (direction == MixDirection.In) {
|
|
constraint.bendDirection = int(frames[frames.length + PREV_BEND_DIRECTION]);
|
|
constraint.bendDirection = int(frames[frames.length + PREV_BEND_DIRECTION]);
|
|
constraint.compress = int(frames[frames.length + PREV_COMPRESS]) != 0;
|
|
constraint.compress = int(frames[frames.length + PREV_COMPRESS]) != 0;
|
|
@@ -105,11 +110,14 @@ package spine.animation {
|
|
// Interpolate between the previous frame and the current frame.
|
|
// Interpolate between the previous frame and the current frame.
|
|
var frame : int = Animation.binarySearch(frames, time, ENTRIES);
|
|
var frame : int = Animation.binarySearch(frames, time, ENTRIES);
|
|
var mix : Number = frames[int(frame + PREV_MIX)];
|
|
var mix : Number = frames[int(frame + PREV_MIX)];
|
|
|
|
+ var softness : Number = frames[frame + PREV_SOFTNESS];
|
|
var frameTime : Number = frames[frame];
|
|
var frameTime : Number = frames[frame];
|
|
var percent : Number = getCurvePercent(frame / ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PREV_TIME] - frameTime));
|
|
var percent : Number = getCurvePercent(frame / ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PREV_TIME] - frameTime));
|
|
|
|
|
|
if (blend == MixBlend.setup) {
|
|
if (blend == MixBlend.setup) {
|
|
constraint.mix = constraint.data.mix + (mix + (frames[frame + MIX] - mix) * percent - constraint.data.mix) * alpha;
|
|
constraint.mix = constraint.data.mix + (mix + (frames[frame + MIX] - mix) * percent - constraint.data.mix) * alpha;
|
|
|
|
+ constraint.softness = constraint.data.softness
|
|
|
|
+ + (softness + (frames[frame + SOFTNESS] - softness) * percent - constraint.data.softness) * alpha;
|
|
if (direction == MixDirection.Out) {
|
|
if (direction == MixDirection.Out) {
|
|
constraint.bendDirection = constraint.data.bendDirection;
|
|
constraint.bendDirection = constraint.data.bendDirection;
|
|
constraint.compress = constraint.data.compress;
|
|
constraint.compress = constraint.data.compress;
|
|
@@ -121,6 +129,7 @@ package spine.animation {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
constraint.mix += (mix + (frames[frame + MIX] - mix) * percent - constraint.mix) * alpha;
|
|
constraint.mix += (mix + (frames[frame + MIX] - mix) * percent - constraint.mix) * alpha;
|
|
|
|
+ constraint.softness += (softness + (frames[frame + SOFTNESS] - softness) * percent - constraint.softness) * alpha;
|
|
if (direction == MixDirection.In) {
|
|
if (direction == MixDirection.In) {
|
|
constraint.bendDirection = int(frames[frame + PREV_BEND_DIRECTION]);
|
|
constraint.bendDirection = int(frames[frame + PREV_BEND_DIRECTION]);
|
|
constraint.compress = int(frames[frame + PREV_COMPRESS]) != 0;
|
|
constraint.compress = int(frames[frame + PREV_COMPRESS]) != 0;
|