[csharp] Fixed PhysicsConstraint ignoring load scale.

This commit is contained in:
Harald Csaszar 2024-01-11 16:50:12 +01:00
parent 92986788c1
commit c7a81230ff
3 changed files with 15 additions and 10 deletions

View File

@ -312,8 +312,8 @@ namespace Spine {
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;
@ -997,10 +997,10 @@ namespace Spine {
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);

View File

@ -299,8 +299,8 @@ namespace Spine {
data.strength = GetFloat(constraintMap, "strength", 100);
data.damping = GetFloat(constraintMap, "damping", 1);
data.massInverse = 1f / GetFloat(constraintMap, "mass", 1);
data.wind = GetFloat(constraintMap, "wind", 0);
data.gravity = GetFloat(constraintMap, "gravity", 0);
data.wind = GetFloat(constraintMap, "wind", 0) * scale;
data.gravity = GetFloat(constraintMap, "gravity", 0) * scale;
data.mix = GetFloat(constraintMap, "mix", 1);
data.inertiaGlobal = GetBoolean(constraintMap, "inertiaGlobal", false);
data.strengthGlobal = GetBoolean(constraintMap, "strengthGlobal", false);
@ -1036,6 +1036,7 @@ namespace Spine {
}
CurveTimeline1 timeline;
float timelineScale = 1.0f;
if (timelineName == "inertia")
timeline = new PhysicsConstraintInertiaTimeline(frames, frames, index);
else if (timelineName == "strength")
@ -1044,15 +1045,19 @@ namespace Spine {
timeline = new PhysicsConstraintDampingTimeline(frames, frames, index);
else if (timelineName == "mass")
timeline = new PhysicsConstraintMassTimeline(frames, frames, index);
else if (timelineName == "wind")
else if (timelineName == "wind") {
timeline = new PhysicsConstraintWindTimeline(frames, frames, index);
else if (timelineName == "gravity")
timelineScale = scale;
}
else if (timelineName == "gravity") {
timeline = new PhysicsConstraintGravityTimeline(frames, frames, index);
timelineScale = scale;
}
else if (timelineName == "mix") //
timeline = new PhysicsConstraintMixTimeline(frames, frames, index);
else
continue;
timelines.Add(ReadTimeline(ref keyMapEnumerator, timeline, 0, 1));
timelines.Add(ReadTimeline(ref keyMapEnumerator, timeline, 0, timelineScale));
}
}
}

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-csharp",
"displayName": "spine-csharp Runtime",
"description": "This plugin provides the spine-csharp core runtime.",
"version": "4.2.6",
"version": "4.2.7",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",