Преглед на файлове

[ts] Scale gravity/wind when loading skeleton, see #2446

Mario Zechner преди 1 година
родител
ревизия
bd1acdc1d6
променени са 2 файла, в които са добавени 14 реда и са изтрити 9 реда
  1. 4 4
      spine-ts/spine-core/src/SkeletonBinary.ts
  2. 10 5
      spine-ts/spine-core/src/SkeletonJson.ts

+ 4 - 4
spine-ts/spine-core/src/SkeletonBinary.ts

@@ -239,8 +239,8 @@ export class SkeletonBinary {
 			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.readByte();
 			if ((flags & 1) != 0) data.inertiaGlobal = true;
@@ -953,10 +953,10 @@ export class SkeletonBinary {
 						timelines.push(readTimeline1(input, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1));
 						break;
 					case PHYSICS_WIND:
-						timelines.push(readTimeline1(input, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), 1));
+						timelines.push(readTimeline1(input, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), scale));
 						break;
 					case PHYSICS_GRAVITY:
-						timelines.push(readTimeline1(input, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), 1));
+						timelines.push(readTimeline1(input, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), scale));
 						break;
 					case PHYSICS_MIX:
 						timelines.push(readTimeline1(input, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1));

+ 10 - 5
spine-ts/spine-core/src/SkeletonJson.ts

@@ -258,8 +258,8 @@ export class SkeletonJson {
 				data.strength = getValue(constraintMap, "strength", 100);
 				data.damping = getValue(constraintMap, "damping", 1);
 				data.massInverse = 1 / getValue(constraintMap, "mass", 1);
-				data.wind = getValue(constraintMap, "wind", 0);
-				data.gravity = getValue(constraintMap, "gravity", 0);
+				data.wind = getValue(constraintMap, "wind", 0) * scale;
+				data.gravity = getValue(constraintMap, "gravity", 0) * scale;
 				data.mix = getValue(constraintMap, "mix", 1);
 				data.inertiaGlobal = getValue(constraintMap, "inertiaGlobal", false);
 				data.strengthGlobal = getValue(constraintMap, "strengthGlobal", false);
@@ -911,6 +911,7 @@ export class SkeletonJson {
 					}
 
 					let timeline;
+					let timelineScale = 1;
 					if (timelineName == "inertia")
 						timeline = new PhysicsConstraintInertiaTimeline(frames, frames, constraintIndex);
 					else if (timelineName == "strength")
@@ -919,15 +920,19 @@ export class SkeletonJson {
 						timeline = new PhysicsConstraintDampingTimeline(frames, frames, constraintIndex);
 					else if (timelineName == "mass")
 						timeline = new PhysicsConstraintMassTimeline(frames, frames, constraintIndex);
-					else if (timelineName == "wind")
+					else if (timelineName == "wind") {
 						timeline = new PhysicsConstraintWindTimeline(frames, frames, constraintIndex);
-					else if (timelineName == "gravity")
+						timelineScale = scale;
+					}
+					else if (timelineName == "gravity") {
 						timeline = new PhysicsConstraintGravityTimeline(frames, frames, constraintIndex);
+						timelineScale = scale;
+					}
 					else if (timelineName == "mix") //
 						timeline = new PhysicsConstraintMixTimeline(frames, frames, constraintIndex);
 					else
 						continue;
-					timelines.push(readTimeline1(timelineMap, timeline, 0, 1));
+					timelines.push(readTimeline1(timelineMap, timeline, 0, timelineScale));
 				}
 			}
 		}