|
@@ -125,11 +125,13 @@ class BlendSpace2D extends AnimNode {
|
|
|
override function tick(dt:Float) {
|
|
|
super.tick(dt);
|
|
|
|
|
|
- for (animInfo in animInfos) {
|
|
|
- // keep all the animations in sync
|
|
|
- var scale = (animInfo.anim.getDuration()) / currentAnimLenght;
|
|
|
- animInfo.anim.update(dt * scale);
|
|
|
- @:privateAccess animInfo.anim.isSync = false;
|
|
|
+ if (currentAnimLenght > 0) {
|
|
|
+ for (animInfo in animInfos) {
|
|
|
+ // keep all the animations in sync
|
|
|
+ var scale = (animInfo.anim.getDuration()) / currentAnimLenght;
|
|
|
+ animInfo.anim.update(dt * scale);
|
|
|
+ @:privateAccess animInfo.anim.isSync = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -194,8 +196,25 @@ class BlendSpace2D extends AnimNode {
|
|
|
throw "assert";
|
|
|
|
|
|
currentAnimLenght = 0.0;
|
|
|
+
|
|
|
+ // Compensate for null animations that don't have lenght
|
|
|
+ var nulls = 0;
|
|
|
+ var nullWeights: Float = 0;
|
|
|
for (i => pt in triangles[currentTriangle]) {
|
|
|
- currentAnimLenght += pt.animInfo.anim.getDuration()/pt.speed * weights[i];
|
|
|
+ if (pt.animInfo == null) {
|
|
|
+ nulls ++;
|
|
|
+ nullWeights += weights[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nulls < 3) {
|
|
|
+ nullWeights /= (3 - nulls);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (i => pt in triangles[currentTriangle]) {
|
|
|
+ if(pt.animInfo != null) {
|
|
|
+ currentAnimLenght += pt.animInfo.anim.getDuration()/pt.speed * weights[i] + nullWeights;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|