|
|
@ -68,31 +68,53 @@ public final class AnimChannel { |
|
|
|
private float blendRate = 0; |
|
|
|
private float blendRate = 0; |
|
|
|
|
|
|
|
|
|
|
|
private static float clampWrapTime(float t, float max, LoopMode loopMode){ |
|
|
|
private static float clampWrapTime(float t, float max, LoopMode loopMode){ |
|
|
|
if (max == Float.POSITIVE_INFINITY) |
|
|
|
if (t == 0) { |
|
|
|
return t; |
|
|
|
return 0; // prevent division by 0 errors
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (t < 0f){ |
|
|
|
switch (loopMode) { |
|
|
|
//float tMod = -(-t % max);
|
|
|
|
case Cycle: |
|
|
|
switch (loopMode){ |
|
|
|
boolean sign = ((int) (t / max) % 2) != 0; |
|
|
|
case DontLoop: |
|
|
|
float result; |
|
|
|
return 0; |
|
|
|
if (t < 0){ |
|
|
|
case Cycle: |
|
|
|
result = sign ? t % max : -(max + (t % max)); |
|
|
|
return t; |
|
|
|
} else { |
|
|
|
case Loop: |
|
|
|
result = sign ? -(max - (t % max)) : t % max; |
|
|
|
return max - t; |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
}else if (t > max){ |
|
|
|
case DontLoop: |
|
|
|
switch (loopMode){ |
|
|
|
return t > max ? max : (t < 0 ? 0 : t); |
|
|
|
case DontLoop: |
|
|
|
case Loop: |
|
|
|
return max; |
|
|
|
return t % max; |
|
|
|
case Cycle: |
|
|
|
|
|
|
|
return /*-max;*/-(2f * max - t); |
|
|
|
|
|
|
|
case Loop: |
|
|
|
|
|
|
|
return t - max; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return t; |
|
|
|
return t; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (max == Float.POSITIVE_INFINITY)
|
|
|
|
|
|
|
|
// return t;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (t < 0f){
|
|
|
|
|
|
|
|
// //float tMod = -(-t % max);
|
|
|
|
|
|
|
|
// switch (loopMode){
|
|
|
|
|
|
|
|
// case DontLoop:
|
|
|
|
|
|
|
|
// return 0;
|
|
|
|
|
|
|
|
// case Cycle:
|
|
|
|
|
|
|
|
// return t;
|
|
|
|
|
|
|
|
// case Loop:
|
|
|
|
|
|
|
|
// return max - t;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }else if (t > max){
|
|
|
|
|
|
|
|
// switch (loopMode){
|
|
|
|
|
|
|
|
// case DontLoop:
|
|
|
|
|
|
|
|
// return max;
|
|
|
|
|
|
|
|
// case Cycle:
|
|
|
|
|
|
|
|
// return -(2f * max - t) % max;
|
|
|
|
|
|
|
|
// case Loop:
|
|
|
|
|
|
|
|
// return t % max;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return t;
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AnimChannel(AnimControl control){ |
|
|
|
AnimChannel(AnimControl control){ |
|
|
@ -225,6 +247,8 @@ public final class AnimChannel { |
|
|
|
loopModeBlendFrom = loopMode; |
|
|
|
loopModeBlendFrom = loopMode; |
|
|
|
blendAmount = 0f; |
|
|
|
blendAmount = 0f; |
|
|
|
blendRate = 1f / blendTime; |
|
|
|
blendRate = 1f / blendTime; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
blendFrom = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
animation = anim; |
|
|
|
animation = anim; |
|
|
@ -335,9 +359,12 @@ public final class AnimChannel { |
|
|
|
if (animation == null) |
|
|
|
if (animation == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (blendFrom != null){ |
|
|
|
if (blendFrom != null && blendAmount != 1.0f){ |
|
|
|
blendFrom.setTime(timeBlendFrom, 1f - blendAmount, control, this, vars); |
|
|
|
// The blendFrom anim is set, the actual animation
|
|
|
|
//blendFrom.setTime(timeBlendFrom, control.skeleton, 1f - blendAmount, affectedBones);
|
|
|
|
// playing will be set
|
|
|
|
|
|
|
|
blendFrom.setTime(timeBlendFrom, 1f, control, this, vars); |
|
|
|
|
|
|
|
// blendFrom.setTime(timeBlendFrom, 1f - blendAmount, control, this, vars);
|
|
|
|
|
|
|
|
|
|
|
|
timeBlendFrom += tpf * speedBlendFrom; |
|
|
|
timeBlendFrom += tpf * speedBlendFrom; |
|
|
|
timeBlendFrom = clampWrapTime(timeBlendFrom, |
|
|
|
timeBlendFrom = clampWrapTime(timeBlendFrom, |
|
|
|
blendFrom.getLength(), |
|
|
|
blendFrom.getLength(), |
|
|
@ -353,9 +380,8 @@ public final class AnimChannel { |
|
|
|
blendFrom = null; |
|
|
|
blendFrom = null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
animation.setTime(time, blendAmount, control, this, vars); |
|
|
|
animation.setTime(time, blendAmount, control, this, vars); |
|
|
|
//animation.setTime(time, control.skeleton, blendAmount, affectedBones);
|
|
|
|
|
|
|
|
time += tpf * speed; |
|
|
|
time += tpf * speed; |
|
|
|
|
|
|
|
|
|
|
|
if (animation.getLength() > 0){ |
|
|
|
if (animation.getLength() > 0){ |
|
|
@ -368,10 +394,10 @@ public final class AnimChannel { |
|
|
|
|
|
|
|
|
|
|
|
time = clampWrapTime(time, animation.getLength(), loopMode); |
|
|
|
time = clampWrapTime(time, animation.getLength(), loopMode); |
|
|
|
if (time < 0){ |
|
|
|
if (time < 0){ |
|
|
|
|
|
|
|
// Negative time indicates that speed should be inverted
|
|
|
|
|
|
|
|
// (for cycle loop mode only)
|
|
|
|
time = -time; |
|
|
|
time = -time; |
|
|
|
speed = -speed; |
|
|
|
speed = -speed; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|