From 11e6428586ef7c6bc3fa28312086bb4f2275940c Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 11 Jan 2024 17:13:17 +0100 Subject: [PATCH] [libgdx] Fixed PhysicsConstraint ignoring load scale. See commit c7a8123. --- .../esotericsoftware/spine/SkeletonBinary.java | 8 ++++---- .../com/esotericsoftware/spine/SkeletonJson.java | 15 +++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java index 3e369c75e..ed16c99e9 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java @@ -325,8 +325,8 @@ public class SkeletonBinary extends SkeletonLoader { data.strength = input.readFloat(); data.damping = input.readFloat(); data.massInverse = input.readFloat(); - data.wind = input.readFloat(); - data.gravity = input.readFloat(); + data.wind = input.readFloat() * scale; + data.gravity = input.readFloat() * scale; data.mix = input.readFloat(); flags = input.read(); if ((flags & 1) != 0) data.inertiaGlobal = true; @@ -992,10 +992,10 @@ public class SkeletonBinary extends SkeletonLoader { readTimeline(input, timelines, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1); break; case PHYSICS_WIND: - readTimeline(input, timelines, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), 1); + readTimeline(input, timelines, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), scale); break; case PHYSICS_GRAVITY: - readTimeline(input, timelines, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), 1); + readTimeline(input, timelines, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), scale); break; case PHYSICS_MIX: readTimeline(input, timelines, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1); diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java index 8c2c1f7ab..df02b05f1 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java @@ -310,8 +310,8 @@ public class SkeletonJson extends SkeletonLoader { data.strength = constraintMap.getFloat("strength", 100); data.damping = constraintMap.getFloat("damping", 1); data.massInverse = 1f / constraintMap.getFloat("mass", 1); - data.wind = constraintMap.getFloat("wind", 0); - data.gravity = constraintMap.getFloat("gravity", 0); + data.wind = constraintMap.getFloat("wind", 0) * scale; + data.gravity = constraintMap.getFloat("gravity", 0) * scale; data.mix = constraintMap.getFloat("mix", 1); data.inertiaGlobal = constraintMap.getBoolean("inertiaGlobal", false); data.strengthGlobal = constraintMap.getBoolean("strengthGlobal", false); @@ -957,6 +957,7 @@ public class SkeletonJson extends SkeletonLoader { } CurveTimeline1 timeline; + float timelineScale = 1.0f; if (timelineName.equals("inertia")) timeline = new PhysicsConstraintInertiaTimeline(frames, frames, index); else if (timelineName.equals("strength")) @@ -965,15 +966,17 @@ public class SkeletonJson extends SkeletonLoader { timeline = new PhysicsConstraintDampingTimeline(frames, frames, index); else if (timelineName.equals("mass")) timeline = new PhysicsConstraintMassTimeline(frames, frames, index); - else if (timelineName.equals("wind")) + else if (timelineName.equals("wind")) { timeline = new PhysicsConstraintWindTimeline(frames, frames, index); - else if (timelineName.equals("gravity")) + timelineScale = scale; + } else if (timelineName.equals("gravity")) { timeline = new PhysicsConstraintGravityTimeline(frames, frames, index); - else if (timelineName.equals("mix")) // + timelineScale = scale; + } else if (timelineName.equals("mix")) // timeline = new PhysicsConstraintMixTimeline(frames, frames, index); else continue; - timelines.add(readTimeline(keyMap, timeline, 0, 1)); + timelines.add(readTimeline(keyMap, timeline, 0, timelineScale)); } }