From 14b317008b8a5157eca5010ab3f5a08ee2f78fe7 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Thu, 27 May 2021 18:37:46 -0400 Subject: [PATCH] [libgdx] Keep slot deform when changing the attachment if the new attachment is compatible with the deform. Forum discussion: http://esotericsoftware.com/forum/Swapping-a-linked-mesh-attachment-causes-a-flicker-15869?p=69490#p69490 --- .../src/com/esotericsoftware/spine/Slot.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Slot.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Slot.java index 14e72e832..124ca7eaf 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Slot.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Slot.java @@ -105,12 +105,17 @@ public class Slot { return attachment; } - /** Sets the slot's attachment and, if the attachment changed, resets {@link #attachmentTime} and clears {@link #deform}. */ + /** Sets the slot's attachment and, if the attachment changed, resets {@link #attachmentTime} and clears the {@link #deform}. + * The deform is not cleared if the old attachment has the same {@link VertexAttachment#getDeformAttachment()} as the specified + * attachment. */ public void setAttachment (@Null Attachment attachment) { if (this.attachment == attachment) return; + if (!(attachment instanceof VertexAttachment) || !(this.attachment instanceof VertexAttachment) + || ((VertexAttachment)attachment).getDeformAttachment() != ((VertexAttachment)this.attachment).getDeformAttachment()) { + deform.clear(); + } this.attachment = attachment; attachmentTime = bone.skeleton.time; - deform.clear(); } /** The time that has elapsed since the last time the attachment was set or cleared. Relies on Skeleton