From 6135fa868497ea86f81ea1ceeb12384a8c6aac81 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Mon, 31 Jan 2022 11:21:07 -0400 Subject: [PATCH 1/3] [libgdx] Made fixes from 4.1-beta-physics in 4.1-beta. --- .../spine/attachments/BoundingBoxAttachment.java | 2 +- .../esotericsoftware/spine/attachments/ClippingAttachment.java | 2 +- .../com/esotericsoftware/spine/attachments/MeshAttachment.java | 2 +- .../esotericsoftware/spine/attachments/RegionAttachment.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/BoundingBoxAttachment.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/BoundingBoxAttachment.java index 99346857b..10d85c99f 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/BoundingBoxAttachment.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/BoundingBoxAttachment.java @@ -59,6 +59,6 @@ public class BoundingBoxAttachment extends VertexAttachment { } public BoundingBoxAttachment copy () { - return new BoundingBoxAttachment(name); + return new BoundingBoxAttachment(this); } } diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/ClippingAttachment.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/ClippingAttachment.java index 3b2825a80..a3d9a62d4 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/ClippingAttachment.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/ClippingAttachment.java @@ -69,6 +69,6 @@ public class ClippingAttachment extends VertexAttachment { } public ClippingAttachment copy () { - return new ClippingAttachment(name); + return new ClippingAttachment(this); } } diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java index 8aa35026b..6efc7e482 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java @@ -80,7 +80,7 @@ public class MeshAttachment extends VertexAttachment implements HasTextureRegion arraycopy(other.triangles, 0, triangles, 0, triangles.length); hullLength = other.hullLength; - sequence = sequence != null ? new Sequence(sequence) : null; + sequence = other.sequence != null ? new Sequence(other.sequence) : null; // Nonessential. if (other.edges != null) { diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java index d7f9c76ff..8bfa883d1 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/RegionAttachment.java @@ -75,7 +75,7 @@ public class RegionAttachment extends Attachment implements HasTextureRegion { arraycopy(other.uvs, 0, uvs, 0, 8); arraycopy(other.offset, 0, offset, 0, 8); color.set(other.color); - sequence = sequence != null ? new Sequence(sequence) : null; + sequence = other.sequence != null ? new Sequence(other.sequence) : null; } /** Calculates the {@link #offset} and {@link #uvs} using the region and the attachment's transform. Must be called if the From 60ee4bce073b0029fb8952150e39fc9e2d95d1a5 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Mon, 31 Jan 2022 11:36:49 -0400 Subject: [PATCH 2/3] [libgdx] Skeleton Viewer, changes from 4.1-beta-physics. --- spine-libgdx/spine-skeletonviewer/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 36 ++++++++++++++----- .../spine/SkeletonViewer.java | 27 +++++++++----- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/spine-libgdx/spine-skeletonviewer/.classpath b/spine-libgdx/spine-skeletonviewer/.classpath index 120f0223f..e8bc7f783 100644 --- a/spine-libgdx/spine-skeletonviewer/.classpath +++ b/spine-libgdx/spine-skeletonviewer/.classpath @@ -2,7 +2,7 @@ - + diff --git a/spine-libgdx/spine-skeletonviewer/.settings/org.eclipse.jdt.core.prefs b/spine-libgdx/spine-skeletonviewer/.settings/org.eclipse.jdt.core.prefs index 4e563d526..8525f818d 100644 --- a/spine-libgdx/spine-skeletonviewer/.settings/org.eclipse.jdt.core.prefs +++ b/spine-libgdx/spine-skeletonviewer/.settings/org.eclipse.jdt.core.prefs @@ -10,9 +10,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary=com.esotericsoftware org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -125,9 +125,10 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -135,17 +136,20 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -231,11 +235,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -266,6 +271,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -290,13 +297,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -344,6 +355,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -380,9 +393,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -408,6 +424,10 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=3 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java index ee984259b..fd0c13f5e 100644 --- a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java +++ b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java @@ -102,8 +102,9 @@ public class SkeletonViewer extends ApplicationAdapter { ui.loadPrefs(); if (args.length == 0) { - loadSkeleton( - Gdx.files.internal(Gdx.app.getPreferences("spine-skeletonviewer").getString("lastFile", "spineboy/spineboy.json"))); + FileHandle file = Gdx.files + .internal(Gdx.app.getPreferences("spine-skeletonviewer").getString("lastFile", "spineboy/spineboy.json")); + if (file.exists()) loadSkeleton(file); } else loadSkeleton(Gdx.files.internal(args[0])); @@ -118,8 +119,15 @@ public class SkeletonViewer extends ApplicationAdapter { } } - boolean loadSkeleton (final @Null FileHandle skeletonFile) { + boolean loadSkeleton (@Null FileHandle skeletonFile) { if (skeletonFile == null) return false; + + try { + skeletonFile = new FileHandle(skeletonFile.file().getCanonicalFile()); + } catch (Throwable ex) { + skeletonFile = new FileHandle(skeletonFile.file().getAbsoluteFile()); + } + FileHandle oldSkeletonFile = this.skeletonFile; this.skeletonFile = skeletonFile; reloadTimer = 0; @@ -138,7 +146,7 @@ public class SkeletonViewer extends ApplicationAdapter { skeletonData = loader.readSkeletonData(skeletonFile); if (skeletonData.getBones().size == 0) throw new Exception("No bones in skeleton data."); } catch (Throwable ex) { - System.out.println("Error loading skeleton: " + skeletonFile.file().getAbsolutePath()); + System.out.println("Error loading skeleton: " + skeletonFile.path()); ex.printStackTrace(); ui.toast("Error loading skeleton: " + skeletonFile.name()); this.skeletonFile = oldSkeletonFile; @@ -369,19 +377,20 @@ public class SkeletonViewer extends ApplicationAdapter { } if (dpiScale >= 2.0f) uiScale = 2; - SkeletonViewer skeletonViewer = new SkeletonViewer(); + final SkeletonViewer skeletonViewer = new SkeletonViewer(); Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); config.disableAudio(true); config.setWindowedMode((int)(800 * uiScale), (int)(600 * uiScale)); - config.setTitle("Skeleton Viewer"); + config.setTitle("Skeleton Viewer " + version); config.setBackBufferConfig(8, 8, 8, 8, 24, 0, 2); config.setWindowListener(new Lwjgl3WindowAdapter() { @Override public void filesDropped (String[] files) { for (String file : files) { - if (file.endsWith(".json") || file.endsWith(".skel")) { - skeletonViewer.loadSkeleton(Gdx.files.absolute(file)); - return; + for (String endSuffix : endSuffixes) { + for (String dataSuffix : dataSuffixes) { + if (file.endsWith(dataSuffix + endSuffix) && skeletonViewer.loadSkeleton(Gdx.files.absolute(file))) return; + } } } } From 9271eb239a9b2747082ea67158961e85a6a9403f Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Mon, 31 Jan 2022 11:42:35 -0400 Subject: [PATCH 3/3] Removed spring constraints. The physics features have been moved to 4.2. --- .../com/esotericsoftware/spine/Skeleton.java | 71 +------- .../esotericsoftware/spine/SkeletonData.java | 20 --- .../spine/SpringConstraint.java | 169 ------------------ .../spine/SpringConstraintData.java | 115 ------------ 4 files changed, 3 insertions(+), 372 deletions(-) delete mode 100644 spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SpringConstraint.java delete mode 100644 spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SpringConstraintData.java diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java index 8d2154229..a246752dc 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java @@ -55,7 +55,6 @@ public class Skeleton { final Array ikConstraints; final Array transformConstraints; final Array pathConstraints; - final Array springConstraints; final Array updateCache = new Array(); @Null Skin skin; final Color color; @@ -101,10 +100,6 @@ public class Skeleton { for (PathConstraintData pathConstraintData : data.pathConstraints) pathConstraints.add(new PathConstraint(pathConstraintData, this)); - springConstraints = new Array(data.springConstraints.size); - for (SpringConstraintData springConstraintData : data.springConstraints) - springConstraints.add(new SpringConstraint(springConstraintData, this)); - color = new Color(1, 1, 1, 1); updateCache(); @@ -150,10 +145,6 @@ public class Skeleton { for (PathConstraint pathConstraint : skeleton.pathConstraints) pathConstraints.add(new PathConstraint(pathConstraint, this)); - springConstraints = new Array(skeleton.springConstraints.size); - for (SpringConstraint springConstraint : skeleton.springConstraints) - springConstraints.add(new SpringConstraint(springConstraint, this)); - skin = skeleton.skin; color = new Color(skeleton.color); scaleX = skeleton.scaleX; @@ -187,11 +178,10 @@ public class Skeleton { } } - int ikCount = ikConstraints.size, transformCount = transformConstraints.size, pathCount = pathConstraints.size, - springCount = springConstraints.size; + int ikCount = ikConstraints.size, transformCount = transformConstraints.size, pathCount = pathConstraints.size; Object[] ikConstraints = this.ikConstraints.items, transformConstraints = this.transformConstraints.items, - pathConstraints = this.pathConstraints.items, springConstraints = this.springConstraints.items; - int constraintCount = ikCount + transformCount + pathCount + springCount; + pathConstraints = this.pathConstraints.items; + int constraintCount = ikCount + transformCount + pathCount; outer: for (int i = 0; i < constraintCount; i++) { for (int ii = 0; ii < ikCount; ii++) { @@ -215,13 +205,6 @@ public class Skeleton { continue outer; } } - for (int ii = 0; ii < springCount; ii++) { - SpringConstraint constraint = (SpringConstraint)springConstraints[ii]; - if (constraint.data.order == i) { - sortSpringConstraint(constraint); - continue outer; - } - } } for (int i = 0; i < boneCount; i++) @@ -333,23 +316,6 @@ public class Skeleton { } } - private void sortSpringConstraint (SpringConstraint constraint) { - constraint.active = !constraint.data.skinRequired || (skin != null && skin.constraints.contains(constraint.data, true)); - if (!constraint.active) return; - - Object[] constrained = constraint.bones.items; - int boneCount = constraint.bones.size; - for (int i = 0; i < boneCount; i++) - sortBone((Bone)constrained[i]); - - updateCache.add(constraint); - - for (int i = 0; i < boneCount; i++) - sortReset(((Bone)constrained[i]).children); - for (int i = 0; i < boneCount; i++) - ((Bone)constrained[i]).sorted = true; - } - private void sortBone (Bone bone) { if (bone.sorted) return; Bone parent = bone.parent; @@ -466,20 +432,6 @@ public class Skeleton { constraint.mixX = data.mixX; constraint.mixY = data.mixY; } - - Object[] springConstraints = this.springConstraints.items; - for (int i = 0, n = this.springConstraints.size; i < n; i++) { - SpringConstraint constraint = (SpringConstraint)springConstraints[i]; - SpringConstraintData data = constraint.data; - constraint.mix = data.mix; - constraint.friction = data.friction; - constraint.gravity = data.gravity; - constraint.wind = data.wind; - constraint.stiffness = data.stiffness; - constraint.damping = data.damping; - constraint.rope = data.rope; - constraint.stretch = data.stretch; - } } /** Sets the slots and draw order to their setup pose values. */ @@ -686,23 +638,6 @@ public class Skeleton { return null; } - /** The skeleton's spring constraints. */ - public Array getSpringConstraints () { - return springConstraints; - } - - /** Finds a spring constraint by comparing each spring constraint's name. It is more efficient to cache the results of this - * method than to call it repeatedly. */ - public @Null SpringConstraint findSpringConstraint (String constraintName) { - if (constraintName == null) throw new IllegalArgumentException("constraintName cannot be null."); - Object[] springConstraints = this.springConstraints.items; - for (int i = 0, n = this.springConstraints.size; i < n; i++) { - SpringConstraint constraint = (SpringConstraint)springConstraints[i]; - if (constraint.data.name.equals(constraintName)) return constraint; - } - return null; - } - /** Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose. * @param offset An output value, the distance from the skeleton origin to the bottom left corner of the AABB. * @param size An output value, the width and height of the AABB. diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java index 0aefa6670..24427e3ca 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java @@ -47,7 +47,6 @@ public class SkeletonData { final Array ikConstraints = new Array(); final Array transformConstraints = new Array(); final Array pathConstraints = new Array(); - final Array springConstraints = new Array(); float x, y, width, height; @Null String version, hash; @@ -216,25 +215,6 @@ public class SkeletonData { return null; } - // --- Spring constraints - - /** The skeleton's spring constraints. */ - public Array getSpringConstraints () { - return springConstraints; - } - - /** Finds a spring constraint by comparing each spring constraint's name. It is more efficient to cache the results of this - * method than to call it multiple times. */ - public @Null SpringConstraintData findSpringConstraint (String constraintName) { - if (constraintName == null) throw new IllegalArgumentException("constraintName cannot be null."); - Object[] springConstraints = this.springConstraints.items; - for (int i = 0, n = this.springConstraints.size; i < n; i++) { - SpringConstraintData constraint = (SpringConstraintData)springConstraints[i]; - if (constraint.name.equals(constraintName)) return constraint; - } - return null; - } - // --- /** The skeleton's name, which by default is the name of the skeleton data file when possible, or null when a name hasn't been diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SpringConstraint.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SpringConstraint.java deleted file mode 100644 index 1f9418402..000000000 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SpringConstraint.java +++ /dev/null @@ -1,169 +0,0 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -package com.esotericsoftware.spine; - -import com.badlogic.gdx.utils.Array; - -/** Stores the current pose for a spring constraint. A spring constraint applies physics to bones. - *

- * See Spring constraints in the Spine User Guide. */ -public class SpringConstraint implements Updatable { - final SpringConstraintData data; - final Array bones; - // BOZO! - stiffness -> strength. stiffness, damping, rope, stretch -> move to spring. - float mix, friction, gravity, wind, stiffness, damping; - boolean rope, stretch; - - boolean active; - - public SpringConstraint (SpringConstraintData data, Skeleton skeleton) { - if (data == null) throw new IllegalArgumentException("data cannot be null."); - if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); - this.data = data; - mix = data.mix; - friction = data.friction; - gravity = data.gravity; - wind = data.wind; - stiffness = data.stiffness; - damping = data.damping; - rope = data.rope; - stretch = data.stretch; - - bones = new Array(data.bones.size); - for (BoneData boneData : data.bones) - bones.add(skeleton.bones.get(boneData.index)); - } - - /** Copy constructor. */ - public SpringConstraint (SpringConstraint constraint, Skeleton skeleton) { - if (constraint == null) throw new IllegalArgumentException("constraint cannot be null."); - if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); - data = constraint.data; - bones = new Array(constraint.bones.size); - for (Bone bone : constraint.bones) - bones.add(skeleton.bones.get(bone.data.index)); - mix = constraint.mix; - friction = constraint.friction; - gravity = constraint.gravity; - wind = constraint.wind; - stiffness = constraint.stiffness; - damping = constraint.damping; - rope = constraint.rope; - stretch = constraint.stretch; - } - - /** Applies the constraint to the constrained bones. */ - public void update () { - - } - - /** The bones that will be modified by this spring constraint. */ - public Array getBones () { - return bones; - } - - /** A percentage (0-1) that controls the mix between the constrained and unconstrained poses. */ - public float getMix () { - return mix; - } - - public void setMix (float mix) { - this.mix = mix; - } - - public float getFriction () { - return friction; - } - - public void setFriction (float friction) { - this.friction = friction; - } - - public float getGravity () { - return gravity; - } - - public void setGravity (float gravity) { - this.gravity = gravity; - } - - public float getWind () { - return wind; - } - - public void setWind (float wind) { - this.wind = wind; - } - - public float getStiffness () { - return stiffness; - } - - public void setStiffness (float stiffness) { - this.stiffness = stiffness; - } - - public float getDamping () { - return damping; - } - - public void setDamping (float damping) { - this.damping = damping; - } - - public boolean getRope () { - return rope; - } - - public void setRope (boolean rope) { - this.rope = rope; - } - - public boolean getStretch () { - return stretch; - } - - public void setStretch (boolean stretch) { - this.stretch = stretch; - } - - public boolean isActive () { - return active; - } - - /** The spring constraint's setup pose data. */ - public SpringConstraintData getData () { - return data; - } - - public String toString () { - return data.name; - } -} diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SpringConstraintData.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SpringConstraintData.java deleted file mode 100644 index af6f5a910..000000000 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SpringConstraintData.java +++ /dev/null @@ -1,115 +0,0 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -package com.esotericsoftware.spine; - -import com.badlogic.gdx.utils.Array; - -/** Stores the setup pose for a {@link SpringConstraint}. - *

- * See Spring constraints in the Spine User Guide. */ -public class SpringConstraintData extends ConstraintData { - final Array bones = new Array(); - float mix, friction, gravity, wind, stiffness, damping; - boolean rope, stretch; - - public SpringConstraintData (String name) { - super(name); - } - - /** The bones that are constrained by this spring constraint. */ - public Array getBones () { - return bones; - } - - /** A percentage (0-1) that controls the mix between the constrained and unconstrained poses. */ - public float getMix () { - return mix; - } - - public void setMix (float mix) { - this.mix = mix; - } - - public float getFriction () { - return friction; - } - - public void setFriction (float friction) { - this.friction = friction; - } - - public float getGravity () { - return gravity; - } - - public void setGravity (float gravity) { - this.gravity = gravity; - } - - public float getWind () { - return wind; - } - - public void setWind (float wind) { - this.wind = wind; - } - - public float getStiffness () { - return stiffness; - } - - public void setStiffness (float stiffness) { - this.stiffness = stiffness; - } - - public float getDamping () { - return damping; - } - - public void setDamping (float damping) { - this.damping = damping; - } - - public boolean getRope () { - return rope; - } - - public void setRope (boolean rope) { - this.rope = rope; - } - - public boolean getStretch () { - return stretch; - } - - public void setStretch (boolean stretch) { - this.stretch = stretch; - } -}