mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[haxe] 4.3 porting WIP - latest updates.
This commit is contained in:
parent
8d046cbbf4
commit
f4a6677097
@ -135,8 +135,8 @@ class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsConstraintD
|
||||
ux = bx;
|
||||
uy = by;
|
||||
} else {
|
||||
var a = remaining, i = p.inertia, f = skeleton.data.referenceScale, d = -1., m = 0., e = 0., qx = data.limit * delta,
|
||||
qy = qx * Math.abs(skeleton.scaleY);
|
||||
var a = remaining, i = p.inertia, f = skeleton.data.referenceScale, d = -1., m = 0., e = 0., ax = 0., ay = 0.,
|
||||
qx = data.limit * delta, qy = qx * Math.abs(skeleton.scaleY);
|
||||
qx *= Math.abs(skeleton.scaleX);
|
||||
if (x || y) {
|
||||
if (x) {
|
||||
@ -154,8 +154,9 @@ class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsConstraintD
|
||||
d = Math.pow(p.damping, 60 * t);
|
||||
m = t * p.massInverse;
|
||||
e = p.strength;
|
||||
var w = f * p.wind * skeleton.scaleX, g = f * p.gravity * skeleton.scaleY,
|
||||
ax = w * skeleton.windX + g * skeleton.gravityX, ay = w * skeleton.windY + g * skeleton.gravityY;
|
||||
var w = f * p.wind, g = f * p.gravity;
|
||||
ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX;
|
||||
ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY;
|
||||
do {
|
||||
if (x) {
|
||||
xVelocity += (ax - xOffset * e) * m;
|
||||
@ -210,11 +211,11 @@ class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsConstraintD
|
||||
d = Math.pow(p.damping, 60 * t);
|
||||
m = t * p.massInverse;
|
||||
e = p.strength;
|
||||
var w = f * p.wind, g = f * (Bone.yDown ? -p.gravity : p.gravity);
|
||||
ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX;
|
||||
ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY;
|
||||
}
|
||||
var g = Bone.yDown ? -p.gravity : p.gravity;
|
||||
var rs = rotateOffset, ss = scaleOffset, h = l / f,
|
||||
ax = p.wind * skeleton.windX + g * skeleton.gravityX,
|
||||
ay = p.wind * skeleton.windY + g * skeleton.gravityY;
|
||||
var rs = rotateOffset, ss = scaleOffset, h = l / f;
|
||||
while (true) {
|
||||
a -= t;
|
||||
if (scaleX) {
|
||||
|
||||
@ -36,23 +36,47 @@ abstract class Posed< //
|
||||
|
||||
/** The constraint's setup pose data. */
|
||||
public final data:D;
|
||||
|
||||
public final pose:P;
|
||||
public final pose:A;
|
||||
public final constrained:A;
|
||||
public var applied:A;
|
||||
|
||||
public function new (data:D, pose:P, constrained:A) {
|
||||
public function new (data:D, pose:A, constrained:A) {
|
||||
if (data == null) throw new SpineException("data cannot be null.");
|
||||
this.data = data;
|
||||
this.pose = pose;
|
||||
this.constrained = constrained;
|
||||
applied = cast pose;
|
||||
applied = pose;
|
||||
}
|
||||
|
||||
/** The constraint's setup pose data. */
|
||||
public function getData ():D {
|
||||
return data;
|
||||
}
|
||||
|
||||
public function getPose ():P {
|
||||
return pose;
|
||||
}
|
||||
|
||||
public function getAppliedPose ():A {
|
||||
return applied;
|
||||
}
|
||||
|
||||
public function setupPose ():Void {
|
||||
pose.set(data.setup);
|
||||
}
|
||||
|
||||
public function usePose ():Void { // Port: usePose - reference runtime: pose()
|
||||
applied = pose;
|
||||
}
|
||||
|
||||
public function useConstrained ():Void { // Port: useConstrained - reference runtime: constrained()
|
||||
applied = constrained;
|
||||
}
|
||||
|
||||
public function resetConstrained ():Void { // Port: resetConstrained - reference runtime: reset()
|
||||
constrained.set(pose);
|
||||
}
|
||||
|
||||
public function toString ():String {
|
||||
return data.name;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ abstract class PosedActive< //
|
||||
|
||||
public var active:Bool;
|
||||
|
||||
public function new (data:D, pose:P, constrained:A) {
|
||||
public function new (data:D, pose:A, constrained:A) {
|
||||
super(data, pose, constrained);
|
||||
setupPose();
|
||||
}
|
||||
|
||||
@ -154,12 +154,12 @@ class Skeleton {
|
||||
resetCache.resize(0);
|
||||
|
||||
for (slot in slots)
|
||||
slot.applied = slot.pose;
|
||||
slot.usePose();
|
||||
|
||||
for (bone in bones) {
|
||||
bone.sorted = bone.data.skinRequired;
|
||||
bone.active = !bone.sorted;
|
||||
bone.applied = cast(bone.pose, BonePose);
|
||||
bone.usePose();
|
||||
}
|
||||
|
||||
if (skin != null) {
|
||||
@ -175,7 +175,7 @@ class Skeleton {
|
||||
}
|
||||
|
||||
for (constraint in constraints)
|
||||
constraint.applied = constraint.pose;
|
||||
constraint.usePose();
|
||||
for (c in constraints) {
|
||||
var constraint:Constraint<Dynamic, Dynamic, Dynamic> = c;
|
||||
constraint.active = constraint.isSourceActive()
|
||||
@ -203,7 +203,7 @@ class Skeleton {
|
||||
|
||||
public function constrained (object:Posed<Dynamic, Dynamic, Dynamic>) {
|
||||
if (object.pose == object.applied) {
|
||||
object.applied = object.constrained;
|
||||
object.useConstrained();
|
||||
resetCache.push(object);
|
||||
}
|
||||
}
|
||||
@ -232,8 +232,8 @@ class Skeleton {
|
||||
public function updateWorldTransform(physics:Physics):Void {
|
||||
_update++;
|
||||
|
||||
for (object in resetCache)
|
||||
object.applied.set(object.pose);
|
||||
for (resetable in resetCache)
|
||||
resetable.resetConstrained();
|
||||
|
||||
for (updatable in _updateCache)
|
||||
updatable.update(this, physics);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user