mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-23 18:21:23 +08:00
[ts] Scale gravity/wind when loading skeleton, see #2446
This commit is contained in:
parent
be25484ac2
commit
bd1acdc1d6
@ -239,8 +239,8 @@ export class SkeletonBinary {
|
|||||||
data.strength = input.readFloat();
|
data.strength = input.readFloat();
|
||||||
data.damping = input.readFloat();
|
data.damping = input.readFloat();
|
||||||
data.massInverse = input.readFloat();
|
data.massInverse = input.readFloat();
|
||||||
data.wind = input.readFloat();
|
data.wind = input.readFloat() * scale;
|
||||||
data.gravity = input.readFloat();
|
data.gravity = input.readFloat() * scale;
|
||||||
data.mix = input.readFloat();
|
data.mix = input.readFloat();
|
||||||
flags = input.readByte();
|
flags = input.readByte();
|
||||||
if ((flags & 1) != 0) data.inertiaGlobal = true;
|
if ((flags & 1) != 0) data.inertiaGlobal = true;
|
||||||
@ -953,10 +953,10 @@ export class SkeletonBinary {
|
|||||||
timelines.push(readTimeline1(input, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1));
|
timelines.push(readTimeline1(input, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1));
|
||||||
break;
|
break;
|
||||||
case PHYSICS_WIND:
|
case PHYSICS_WIND:
|
||||||
timelines.push(readTimeline1(input, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), 1));
|
timelines.push(readTimeline1(input, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), scale));
|
||||||
break;
|
break;
|
||||||
case PHYSICS_GRAVITY:
|
case PHYSICS_GRAVITY:
|
||||||
timelines.push(readTimeline1(input, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), 1));
|
timelines.push(readTimeline1(input, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), scale));
|
||||||
break;
|
break;
|
||||||
case PHYSICS_MIX:
|
case PHYSICS_MIX:
|
||||||
timelines.push(readTimeline1(input, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1));
|
timelines.push(readTimeline1(input, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1));
|
||||||
|
|||||||
@ -258,8 +258,8 @@ export class SkeletonJson {
|
|||||||
data.strength = getValue(constraintMap, "strength", 100);
|
data.strength = getValue(constraintMap, "strength", 100);
|
||||||
data.damping = getValue(constraintMap, "damping", 1);
|
data.damping = getValue(constraintMap, "damping", 1);
|
||||||
data.massInverse = 1 / getValue(constraintMap, "mass", 1);
|
data.massInverse = 1 / getValue(constraintMap, "mass", 1);
|
||||||
data.wind = getValue(constraintMap, "wind", 0);
|
data.wind = getValue(constraintMap, "wind", 0) * scale;
|
||||||
data.gravity = getValue(constraintMap, "gravity", 0);
|
data.gravity = getValue(constraintMap, "gravity", 0) * scale;
|
||||||
data.mix = getValue(constraintMap, "mix", 1);
|
data.mix = getValue(constraintMap, "mix", 1);
|
||||||
data.inertiaGlobal = getValue(constraintMap, "inertiaGlobal", false);
|
data.inertiaGlobal = getValue(constraintMap, "inertiaGlobal", false);
|
||||||
data.strengthGlobal = getValue(constraintMap, "strengthGlobal", false);
|
data.strengthGlobal = getValue(constraintMap, "strengthGlobal", false);
|
||||||
@ -911,6 +911,7 @@ export class SkeletonJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let timeline;
|
let timeline;
|
||||||
|
let timelineScale = 1;
|
||||||
if (timelineName == "inertia")
|
if (timelineName == "inertia")
|
||||||
timeline = new PhysicsConstraintInertiaTimeline(frames, frames, constraintIndex);
|
timeline = new PhysicsConstraintInertiaTimeline(frames, frames, constraintIndex);
|
||||||
else if (timelineName == "strength")
|
else if (timelineName == "strength")
|
||||||
@ -919,15 +920,19 @@ export class SkeletonJson {
|
|||||||
timeline = new PhysicsConstraintDampingTimeline(frames, frames, constraintIndex);
|
timeline = new PhysicsConstraintDampingTimeline(frames, frames, constraintIndex);
|
||||||
else if (timelineName == "mass")
|
else if (timelineName == "mass")
|
||||||
timeline = new PhysicsConstraintMassTimeline(frames, frames, constraintIndex);
|
timeline = new PhysicsConstraintMassTimeline(frames, frames, constraintIndex);
|
||||||
else if (timelineName == "wind")
|
else if (timelineName == "wind") {
|
||||||
timeline = new PhysicsConstraintWindTimeline(frames, frames, constraintIndex);
|
timeline = new PhysicsConstraintWindTimeline(frames, frames, constraintIndex);
|
||||||
else if (timelineName == "gravity")
|
timelineScale = scale;
|
||||||
|
}
|
||||||
|
else if (timelineName == "gravity") {
|
||||||
timeline = new PhysicsConstraintGravityTimeline(frames, frames, constraintIndex);
|
timeline = new PhysicsConstraintGravityTimeline(frames, frames, constraintIndex);
|
||||||
|
timelineScale = scale;
|
||||||
|
}
|
||||||
else if (timelineName == "mix") //
|
else if (timelineName == "mix") //
|
||||||
timeline = new PhysicsConstraintMixTimeline(frames, frames, constraintIndex);
|
timeline = new PhysicsConstraintMixTimeline(frames, frames, constraintIndex);
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
timelines.push(readTimeline1(timelineMap, timeline, 0, 1));
|
timelines.push(readTimeline1(timelineMap, timeline, 0, timelineScale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user