Skip to content

Commit

Permalink
[unity] Fixed Mecanim state not updated when referenced clip's `Loop …
Browse files Browse the repository at this point in the history
…Time` changes. Also fixes Override controllers which never used the override clips' loop parameter but the original one. Closes EsotericSoftware#1649.
  • Loading branch information
HaraldCsaszar committed May 29, 2020
1 parent bc55962 commit 05d8b24
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ public void Apply (Skeleton skeleton) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, info.clip.isLooping, stateInfo.speed < 0), info.clip.isLooping, null, weight, layerBlendMode, MixDirection.In);
}
if (hasNext) {
for (int c = 0; c < nextClipInfoCount; c++) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), info.clip.isLooping, null, weight, layerBlendMode, MixDirection.In);
}
}
if (isInterruptionActive) {
Expand All @@ -288,7 +288,7 @@ public void Apply (Skeleton skeleton) {
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0),
interruptingStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
info.clip.isLooping, null, weight, layerBlendMode, MixDirection.In);
}
}
} else { // case MixNext || Hard
Expand All @@ -298,15 +298,15 @@ public void Apply (Skeleton skeleton) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, info.clip.isLooping, stateInfo.speed < 0), info.clip.isLooping, null, 1f, layerBlendMode, MixDirection.In);
++c; break;
}
// Mix the rest
for (; c < clipInfoCount; c++) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, info.clip.isLooping, stateInfo.speed < 0), info.clip.isLooping, null, weight, layerBlendMode, MixDirection.In);
}

c = 0;
Expand All @@ -317,7 +317,7 @@ public void Apply (Skeleton skeleton) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), info.clip.isLooping, null, 1f, layerBlendMode, MixDirection.In);
++c; break;
}
}
Expand All @@ -326,7 +326,7 @@ public void Apply (Skeleton skeleton) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), info.clip.isLooping, null, weight, layerBlendMode, MixDirection.In);
}
}

Expand All @@ -340,7 +340,7 @@ public void Apply (Skeleton skeleton) {
float weight = clipWeight * layerWeight; if (weight == 0) continue;
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), interruptingStateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
clip.Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), info.clip.isLooping, null, 1f, layerBlendMode, MixDirection.In);
++c; break;
}
}
Expand All @@ -351,7 +351,7 @@ public void Apply (Skeleton skeleton) {
float weight = clipWeight * layerWeight; if (weight == 0) continue;
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), interruptingStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
clip.Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), info.clip.isLooping, null, weight, layerBlendMode, MixDirection.In);
}
}
}
Expand Down

0 comments on commit 05d8b24

Please sign in to comment.