mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 10:16:01 +08:00
[as3] Fix compilation errors, port IK constraint changes
This commit is contained in:
parent
6ae45f1a5a
commit
9cd552dba0
@ -66,7 +66,7 @@ package spine {
|
|||||||
apply1(bones[0], target.worldX, target.worldY, compress, stretch, _data.uniform, mix);
|
apply1(bones[0], target.worldX, target.worldY, compress, stretch, _data.uniform, mix);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
apply2(bones[0], bones[1], target.worldX, target.worldY, bendDirection, stretch, softness, mix);
|
apply2(bones[0], bones[1], target.worldX, target.worldY, bendDirection, stretch, _data.uniform, softness, mix);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,8 +132,8 @@ package spine {
|
|||||||
/** Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The
|
/** Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The
|
||||||
* target is specified in the world coordinate system.
|
* target is specified in the world coordinate system.
|
||||||
* @param child Any descendant bone of the parent. */
|
* @param child Any descendant bone of the parent. */
|
||||||
static public function apply2(parent : Bone, child : Bone, targetX : Number, targetY : Number, bendDir : int, stretch : Boolean, softness: Number, alpha : Number) : void {
|
static public function apply2(parent : Bone, child : Bone, targetX : Number, targetY : Number, bendDir : int, stretch : Boolean, uniform : Boolean, softness: Number, alpha : Number) : void {
|
||||||
var px : Number = parent.ax, py : Number = parent.ay, psx : Number = parent.ascaleX, sx : Number = psx, psy : Number = parent.ascaleY, csx : Number = child.ascaleX;
|
var px : Number = parent.ax, py : Number = parent.ay, psx : Number = parent.ascaleX, psy : Number = parent.ascaleY, sx : Number = psx, sy : Number = psy, csx : Number = child.ascaleX;
|
||||||
var os1 : int, os2 : int, s2 : int;
|
var os1 : int, os2 : int, s2 : int;
|
||||||
if (psx < 0) {
|
if (psx < 0) {
|
||||||
psx = -psx;
|
psx = -psx;
|
||||||
@ -154,7 +154,7 @@ package spine {
|
|||||||
os2 = 0;
|
os2 = 0;
|
||||||
var cx : Number = child.ax, cy : Number, cwx : Number, cwy : Number, a : Number = parent.a, b : Number = parent.b, c : Number = parent.c, d : Number = parent.d;
|
var cx : Number = child.ax, cy : Number, cwx : Number, cwy : Number, a : Number = parent.a, b : Number = parent.b, c : Number = parent.c, d : Number = parent.d;
|
||||||
var u : Boolean = Math.abs(psx - psy) <= 0.0001;
|
var u : Boolean = Math.abs(psx - psy) <= 0.0001;
|
||||||
if (!u) {
|
if (!u || stretch) {
|
||||||
cy = 0;
|
cy = 0;
|
||||||
cwx = a * cx + parent.worldX;
|
cwx = a * cx + parent.worldX;
|
||||||
cwy = c * cx + parent.worldY;
|
cwy = c * cx + parent.worldY;
|
||||||
@ -181,7 +181,7 @@ package spine {
|
|||||||
var tx : Number = (x * d - y * b) * id - px, ty : Number = (y * a - x * c) * id - py;
|
var tx : Number = (x * d - y * b) * id - px, ty : Number = (y * a - x * c) * id - py;
|
||||||
var dd : Number = tx * tx + ty * ty;
|
var dd : Number = tx * tx + ty * ty;
|
||||||
if (softness != 0) {
|
if (softness != 0) {
|
||||||
softness *= psx * (csx + 1) / 2;
|
softness *= psx * (csx + 1) * 0.5;
|
||||||
var td : Number = Math.sqrt(dd), sd : Number = td - l1 - l2 * psx + softness;
|
var td : Number = Math.sqrt(dd), sd : Number = td - l1 - l2 * psx + softness;
|
||||||
if (sd > 0) {
|
if (sd > 0) {
|
||||||
var p : Number = Math.min(1, sd / (softness * 2)) - 1;
|
var p : Number = Math.min(1, sd / (softness * 2)) - 1;
|
||||||
@ -195,13 +195,19 @@ package spine {
|
|||||||
if (u) {
|
if (u) {
|
||||||
l2 *= psx;
|
l2 *= psx;
|
||||||
var cos : Number = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2);
|
var cos : Number = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2);
|
||||||
if (cos < -1)
|
if (cos < -1) {
|
||||||
cos = -1;
|
cos = -1;
|
||||||
else if (cos > 1) {
|
a2 = Math.PI * bendDir;
|
||||||
|
} else if (cos > 1) {
|
||||||
cos = 1;
|
cos = 1;
|
||||||
if (stretch) sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1;
|
a2 = 0;
|
||||||
}
|
if (stretch) {
|
||||||
a2 = Math.acos(cos) * bendDir;
|
a = (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1;
|
||||||
|
sx *= a;
|
||||||
|
if (uniform) sy *= a;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
a2 = Math.acos(cos) * bendDir;
|
||||||
a = l1 + l2 * cos;
|
a = l1 + l2 * cos;
|
||||||
b = l2 * Math.sin(a2);
|
b = l2 * Math.sin(a2);
|
||||||
a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b);
|
a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b);
|
||||||
@ -215,7 +221,7 @@ package spine {
|
|||||||
if (d >= 0) {
|
if (d >= 0) {
|
||||||
var q : Number = Math.sqrt(d);
|
var q : Number = Math.sqrt(d);
|
||||||
if (c1 < 0) q = -q;
|
if (c1 < 0) q = -q;
|
||||||
q = -(c1 + q) / 2;
|
q = -(c1 + q) * 0.5;
|
||||||
var r0 : Number = q / c2, r1 : Number = c / q;
|
var r0 : Number = q / c2, r1 : Number = c / q;
|
||||||
var r : Number = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
|
var r : Number = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
|
||||||
if (r * r <= dd) {
|
if (r * r <= dd) {
|
||||||
@ -246,7 +252,7 @@ package spine {
|
|||||||
maxY = y;
|
maxY = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dd <= (minDist + maxDist) / 2) {
|
if (dd <= (minDist + maxDist) * 0.5) {
|
||||||
a1 = ta - Math.atan2(minY * bendDir, minX);
|
a1 = ta - Math.atan2(minY * bendDir, minX);
|
||||||
a2 = minAngle * bendDir;
|
a2 = minAngle * bendDir;
|
||||||
} else {
|
} else {
|
||||||
@ -260,7 +266,7 @@ package spine {
|
|||||||
if (a1 > 180)
|
if (a1 > 180)
|
||||||
a1 -= 360;
|
a1 -= 360;
|
||||||
else if (a1 < -180) a1 += 360;
|
else if (a1 < -180) a1 += 360;
|
||||||
parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0);
|
parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, sy, 0, 0);
|
||||||
rotation = child.arotation;
|
rotation = child.arotation;
|
||||||
a2 = ((a2 + os) * MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation;
|
a2 = ((a2 + os) * MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation;
|
||||||
if (a2 > 180)
|
if (a2 > 180)
|
||||||
|
|||||||
@ -466,7 +466,7 @@ package spine {
|
|||||||
rgbaTimeline.setFrame(frame, time, rgba.r, rgba.g, rgba.b, rgba.a);
|
rgbaTimeline.setFrame(frame, time, rgba.r, rgba.g, rgba.b, rgba.a);
|
||||||
nextMap = timelineMap[frame + 1];
|
nextMap = timelineMap[frame + 1];
|
||||||
if (!nextMap) {
|
if (!nextMap) {
|
||||||
timeline.shrink(bezier);
|
rgbaTimeline.shrink(bezier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
time2 = getNumber(nextMap, "time", 0);
|
time2 = getNumber(nextMap, "time", 0);
|
||||||
@ -494,7 +494,7 @@ package spine {
|
|||||||
rgbTimeline.setFrame(frame, time, rgb.r, rgb.g, rgb.b);
|
rgbTimeline.setFrame(frame, time, rgb.r, rgb.g, rgb.b);
|
||||||
nextMap = timelineMap[frame + 1];
|
nextMap = timelineMap[frame + 1];
|
||||||
if (!nextMap) {
|
if (!nextMap) {
|
||||||
timeline.shrink(bezier);
|
rgbTimeline.shrink(bezier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
time2 = getNumber(nextMap, "time", 0);
|
time2 = getNumber(nextMap, "time", 0);
|
||||||
@ -525,7 +525,7 @@ package spine {
|
|||||||
rgba2Timeline.setFrame(frame, time, lighta.r, lighta.g, lighta.b, lighta.a, darka.r, darka.g, darka.b);
|
rgba2Timeline.setFrame(frame, time, lighta.r, lighta.g, lighta.b, lighta.a, darka.r, darka.g, darka.b);
|
||||||
nextMap = timelineMap[frame + 1];
|
nextMap = timelineMap[frame + 1];
|
||||||
if (!nextMap) {
|
if (!nextMap) {
|
||||||
timeline.shrink(bezier);
|
rgba2Timeline.shrink(bezier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
time2 = getNumber(nextMap, "time", 0);
|
time2 = getNumber(nextMap, "time", 0);
|
||||||
@ -560,7 +560,7 @@ package spine {
|
|||||||
rgb2Timeline.setFrame(frame, time, light.r, light.g, light.b, dark.r, dark.g, dark.b);
|
rgb2Timeline.setFrame(frame, time, light.r, light.g, light.b, dark.r, dark.g, dark.b);
|
||||||
nextMap = timelineMap[frame + 1];
|
nextMap = timelineMap[frame + 1];
|
||||||
if (!nextMap) {
|
if (!nextMap) {
|
||||||
timeline.shrink(bezier);
|
rgb2Timeline.shrink(bezier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
time2 = getNumber(nextMap, "time", 0);
|
time2 = getNumber(nextMap, "time", 0);
|
||||||
@ -650,7 +650,7 @@ package spine {
|
|||||||
ikTimeline.setFrame(frame, time, mix, softness, getValue(keyMap, "bendPositive", true) ? 1 : -1, getValue(keyMap, "compress", false), getValue(keyMap, "stretch", false));
|
ikTimeline.setFrame(frame, time, mix, softness, getValue(keyMap, "bendPositive", true) ? 1 : -1, getValue(keyMap, "compress", false), getValue(keyMap, "stretch", false));
|
||||||
nextMap = timelineMap[frame + 1];
|
nextMap = timelineMap[frame + 1];
|
||||||
if (!nextMap) {
|
if (!nextMap) {
|
||||||
timeline.shrink(bezier);
|
ikTimeline.shrink(bezier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,7 +696,7 @@ package spine {
|
|||||||
transformTimeline.setFrame(frame, time, mixRotate, mixX, mixY, mixScaleX, mixScaleY, mixShearY);
|
transformTimeline.setFrame(frame, time, mixRotate, mixX, mixY, mixScaleX, mixScaleY, mixShearY);
|
||||||
nextMap = timelineMap[frame + 1];
|
nextMap = timelineMap[frame + 1];
|
||||||
if (!nextMap) {
|
if (!nextMap) {
|
||||||
timeline.shrink(bezier);
|
transformTimeline.shrink(bezier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,7 +758,7 @@ package spine {
|
|||||||
mixTimeline.setFrame(frame, time, mixRotate, mixX, mixY);
|
mixTimeline.setFrame(frame, time, mixRotate, mixX, mixY);
|
||||||
nextMap = timelineMap[frame + 1];
|
nextMap = timelineMap[frame + 1];
|
||||||
if (!nextMap) {
|
if (!nextMap) {
|
||||||
timeline.shrink(bezier);
|
mixTimeline.shrink(bezier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
time2 = getNumber(nextMap, "time", 0);
|
time2 = getNumber(nextMap, "time", 0);
|
||||||
@ -829,7 +829,7 @@ package spine {
|
|||||||
deformTimeline.setFrame(frame, time, deform);
|
deformTimeline.setFrame(frame, time, deform);
|
||||||
nextMap = timelineMap[frame + 1];
|
nextMap = timelineMap[frame + 1];
|
||||||
if (!nextMap) {
|
if (!nextMap) {
|
||||||
timeline.shrink(bezier);
|
deformTimeline.shrink(bezier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
time2 = getNumber(nextMap, "time", 0);
|
time2 = getNumber(nextMap, "time", 0);
|
||||||
@ -844,7 +844,7 @@ package spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw order timelines.
|
// Draw order timelines.
|
||||||
var drawOrdersp : Array = map["drawOrder"];
|
var drawOrders : Array = map["drawOrder"];
|
||||||
if (drawOrders) {
|
if (drawOrders) {
|
||||||
var drawOrderTimeline : DrawOrderTimeline = new DrawOrderTimeline(drawOrders.length);
|
var drawOrderTimeline : DrawOrderTimeline = new DrawOrderTimeline(drawOrders.length);
|
||||||
var slotCount : int = skeletonData.slots.length;
|
var slotCount : int = skeletonData.slots.length;
|
||||||
|
|||||||
@ -302,7 +302,7 @@ package spine.animation {
|
|||||||
}
|
}
|
||||||
from.totalAlpha += alpha;
|
from.totalAlpha += alpha;
|
||||||
if (timeline is RotateTimeline)
|
if (timeline is RotateTimeline)
|
||||||
applyRotateTimeline(timeline, skeleton, applyTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
|
applyRotateTimeline(RotateTimeline(timeline), skeleton, applyTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
|
||||||
else if (timeline is AttachmentTimeline) {
|
else if (timeline is AttachmentTimeline) {
|
||||||
applyAttachmentTimeline(AttachmentTimeline(timeline), skeleton, applyTime, timelineBlend, attachments);
|
applyAttachmentTimeline(AttachmentTimeline(timeline), skeleton, applyTime, timelineBlend, attachments);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ package spine.animation {
|
|||||||
|
|
||||||
/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}.
|
/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}.
|
||||||
* @param propertyIds Unique identifiers for the properties the timeline modifies. */
|
* @param propertyIds Unique identifiers for the properties the timeline modifies. */
|
||||||
public function CurveTimeline1 (frameCount : int, bezierCount : int, propertyId : string) {
|
public function CurveTimeline1 (frameCount : int, bezierCount : int, propertyId : String) {
|
||||||
super(frameCount, bezierCount, [ propertyId ]);
|
super(frameCount, bezierCount, [ propertyId ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user