Skip to content

Commit

Permalink
fix(geckolibcore): transitions affecting bones that have zero animations
Browse files Browse the repository at this point in the history
  • Loading branch information
bernie-g committed Feb 25, 2024
1 parent 5586afa commit cf26116
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Publishing
version=1.0.11
version=1.0.12
group=software.bernie.geckolib3
archivesBaseName=core
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public interface ICustomInstructionListener<A extends IAnimatable> {
public double tickOffset;
protected Queue<Animation> animationQueue = new LinkedList<>();
protected Animation currentAnimation;
protected Animation previousAnimation;
protected AnimationBuilder currentAnimationBuilder = new AnimationBuilder();
protected boolean shouldResetTick = false;
private final HashMap<String, BoneSnapshot> boneSnapshots = new HashMap<>();
Expand Down Expand Up @@ -370,6 +371,7 @@ public void process(double tick, AnimationEvent<T> event, List<IBone> modelRende
Animation animation = model.getAnimation(currentAnimation.animationName, this.animatable);
if (animation != null) {
boolean loop = currentAnimation.loop;
previousAnimation = currentAnimation;
currentAnimation = animation;
currentAnimation.loop = loop;
} else {
Expand Down Expand Up @@ -439,6 +441,7 @@ public void process(double tick, AnimationEvent<T> event, List<IBone> modelRende

//can be null
BoneAnimation boneAnimation = currentAnimation.boneAnimations.get(bone.getName());
BoneAnimation previousAnimation = this.previousAnimation == null ? null : this.previousAnimation.boneAnimations.get(bone.getName());

// Adding the initial positions of the upcoming animation, so the model
// transitions to the initial state of the new animation
Expand All @@ -458,15 +461,15 @@ public void process(double tick, AnimationEvent<T> event, List<IBone> modelRende
boneAnimationQueue.rotationZQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
boneSnapshot.rotationValueZ - initialSnapshot.rotationValueZ,
zPoint.animationStartValue));
} else {
} else if (previousAnimation != null && !previousAnimation.rotationKeyFrames.xKeyFrames.isEmpty()) {
boneAnimationQueue.rotationXQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
boneSnapshot.rotationValueX - initialSnapshot.rotationValueX,
boneSnapshot.rotationValueX,
initialSnapshot.rotationValueX));
boneAnimationQueue.rotationYQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
boneSnapshot.rotationValueY - initialSnapshot.rotationValueY,
boneSnapshot.rotationValueY,
initialSnapshot.rotationValueY));
boneAnimationQueue.rotationZQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
boneSnapshot.rotationValueZ - initialSnapshot.rotationValueZ,
boneSnapshot.rotationValueZ,
initialSnapshot.rotationValueZ));
}

Expand All @@ -483,7 +486,7 @@ public void process(double tick, AnimationEvent<T> event, List<IBone> modelRende
boneSnapshot.positionOffsetY, yPoint.animationStartValue));
boneAnimationQueue.positionZQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
boneSnapshot.positionOffsetZ, zPoint.animationStartValue));
} else {
} else if (previousAnimation != null && !previousAnimation.positionKeyFrames.xKeyFrames.isEmpty()) {
boneAnimationQueue.positionXQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
boneSnapshot.positionOffsetX, initialSnapshot.positionOffsetX));
boneAnimationQueue.positionYQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
Expand All @@ -505,7 +508,7 @@ public void process(double tick, AnimationEvent<T> event, List<IBone> modelRende
boneSnapshot.scaleValueY, yPoint.animationStartValue));
boneAnimationQueue.scaleZQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
boneSnapshot.scaleValueZ, zPoint.animationStartValue));
} else {
} else if (previousAnimation != null && !previousAnimation.scaleKeyFrames.xKeyFrames.isEmpty()) {
boneAnimationQueue.scaleXQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
boneSnapshot.scaleValueX, initialSnapshot.scaleValueX));
boneAnimationQueue.scaleYQueue.add(new AnimationPoint(null, tick, transitionLengthTicks,
Expand Down Expand Up @@ -573,6 +576,7 @@ private void processCurrentAnimation(double tick, double actualTick, Evaluator e
// animation next frame
this.animationState = AnimationState.Transitioning;
shouldResetTick = true;
previousAnimation = currentAnimation;
currentAnimation = this.animationQueue.peek();
}
} else {
Expand Down Expand Up @@ -665,6 +669,7 @@ private void processCurrentAnimation(double tick, double actualTick, Evaluator e
}

if (this.transitionLengthTicks == 0 && shouldResetTick && this.animationState == AnimationState.Transitioning) {
previousAnimation = currentAnimation;
this.currentAnimation = animationQueue.poll();
}
}
Expand Down

0 comments on commit cf26116

Please sign in to comment.