mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Merge branch '3.7-beta' into 3.7-beta-cpp
This commit is contained in:
commit
54653d3a9e
Binary file not shown.
@ -92,31 +92,19 @@ package spine {
|
||||
var rotationY : Number = 0, la : Number = 0, lb : Number = 0, lc : Number = 0, ld : Number = 0;
|
||||
var sin : Number = 0, cos : Number = 0;
|
||||
var s : Number = 0;
|
||||
var sx : Number = _skeleton.scaleX;
|
||||
var sy : Number = _skeleton.scaleY * (yDown ? -1 : 1);
|
||||
|
||||
var parent : Bone = _parent;
|
||||
if (!parent) { // Root bone.
|
||||
rotationY = rotation + 90 + shearY;
|
||||
la = MathUtils.cosDeg(rotation + shearX) * scaleX;
|
||||
lb = MathUtils.cosDeg(rotationY) * scaleY;
|
||||
lc = MathUtils.sinDeg(rotation + shearX) * scaleX;
|
||||
ld = MathUtils.sinDeg(rotationY) * scaleY;
|
||||
var skeleton : Skeleton = _skeleton;
|
||||
if (skeleton.flipX) {
|
||||
x = -x;
|
||||
la = -la;
|
||||
lb = -lb;
|
||||
}
|
||||
if (skeleton.flipY != yDown) {
|
||||
y = -y;
|
||||
lc = -lc;
|
||||
ld = -ld;
|
||||
}
|
||||
this.a = la;
|
||||
this.b = lb;
|
||||
this.c = lc;
|
||||
this.d = ld;
|
||||
worldX = x + skeleton.x;
|
||||
worldY = y + skeleton.y;
|
||||
rotationY = rotation + 90 + shearY;
|
||||
var skeleton : Skeleton = _skeleton;
|
||||
this.a = MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
|
||||
this.b = MathUtils.cosDeg(rotationY) * scaleY * sy;
|
||||
this.c = MathUtils.sinDeg(rotation + shearX) * scaleX * sx;
|
||||
this.d = MathUtils.sinDeg(rotationY) * scaleY * sy;
|
||||
worldX = x * sx + skeleton.x;
|
||||
worldY = y * sy + skeleton.y;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -174,8 +162,8 @@ package spine {
|
||||
case TransformMode.noScaleOrReflection: {
|
||||
cos = MathUtils.cosDeg(rotation);
|
||||
sin = MathUtils.sinDeg(rotation);
|
||||
var za : Number = pa * cos + pb * sin;
|
||||
var zc : Number = pc * cos + pd * sin;
|
||||
var za : Number = (pa * cos + pb * sin) / sx;
|
||||
var zc : Number = (pc * cos + pd * sin) / sy;
|
||||
s = Math.sqrt(za * za + zc * zc);
|
||||
if (s > 0.00001) s = 1 / s;
|
||||
za *= s;
|
||||
@ -187,26 +175,18 @@ package spine {
|
||||
la = MathUtils.cosDeg(shearX) * scaleX;
|
||||
lb = MathUtils.cosDeg(90 + shearY) * scaleY;
|
||||
lc = MathUtils.sinDeg(shearX) * scaleX;
|
||||
ld = MathUtils.sinDeg(90 + shearY) * scaleY;
|
||||
if (this.data.transformMode != TransformMode.noScaleOrReflection ? pa * pd - pb * pc < 0 : this.skeleton.flipX != this.skeleton.flipY) {
|
||||
zb = -zb;
|
||||
zd = -zd;
|
||||
}
|
||||
ld = MathUtils.sinDeg(90 + shearY) * scaleY;
|
||||
this.a = za * la + zb * lc;
|
||||
this.b = za * lb + zb * ld;
|
||||
this.c = zc * la + zd * lc;
|
||||
this.d = zc * lb + zd * ld;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_skeleton.flipX) {
|
||||
this.a = -this.a;
|
||||
this.b = -this.b;
|
||||
}
|
||||
if (_skeleton.flipY != yDown) {
|
||||
this.c = -this.c;
|
||||
this.d = -this.d;
|
||||
}
|
||||
this.a *= sx;
|
||||
this.b *= sx;
|
||||
this.c *= sy;
|
||||
this.d *= sy;
|
||||
}
|
||||
|
||||
public function setToSetupPose() : void {
|
||||
|
||||
@ -50,7 +50,7 @@ package spine {
|
||||
private var _skin : Skin;
|
||||
public var color : Color = new Color(1, 1, 1, 1);
|
||||
public var time : Number = 0;
|
||||
public var flipX : Boolean, flipY : Boolean;
|
||||
public var scaleX : Number = 1, scaleY : Number = 1;
|
||||
public var x : Number = 0, y : Number = 0;
|
||||
|
||||
public function Skeleton(data : SkeletonData) {
|
||||
|
||||
@ -146,14 +146,14 @@ package spine.flash {
|
||||
wrapper.transform.colorTransform = colorTransform;
|
||||
|
||||
var bone : Bone = slot.bone;
|
||||
var flipX : int = skeleton.flipX ? -1 : 1;
|
||||
var flipY : int = skeleton.flipY ? -1 : 1;
|
||||
var scaleX : Number = skeleton.scaleX;
|
||||
var scaleY : Number = skeleton.scaleY;
|
||||
|
||||
wrapper.x = bone.worldX;
|
||||
wrapper.y = bone.worldY;
|
||||
wrapper.rotation = bone.worldRotationX * flipX * flipY;
|
||||
wrapper.scaleX = bone.worldScaleX * flipX;
|
||||
wrapper.scaleY = bone.worldScaleY * flipY;
|
||||
wrapper.rotation = bone.worldRotationX * scaleX * scaleX;
|
||||
wrapper.scaleX = bone.worldScaleX * scaleX;
|
||||
wrapper.scaleY = bone.worldScaleY * scaleY;
|
||||
addChild(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ function loadSkeleton(atlasFile, jsonFile, x, y, scale, animation, skin)
|
||||
json.scale = scale
|
||||
local skeletonData = json:readSkeletonDataFile("data/" .. jsonFile)
|
||||
local skeleton = spine.Skeleton.new(skeletonData)
|
||||
skeleton.flipY = true -- Corona's coordinate system has its y-axis point downwards
|
||||
skeleton.scaleY = -1 -- Corona's coordinate system has its y-axis point downwards
|
||||
skeleton.group.x = x
|
||||
skeleton.group.y = y
|
||||
|
||||
|
||||
@ -45,8 +45,7 @@ function loadSkeleton (jsonFile, atlasFile, animation, skin, scale, x, y)
|
||||
local skeleton = spine.Skeleton.new(skeletonData)
|
||||
skeleton.x = x
|
||||
skeleton.y = y
|
||||
skeleton.flipX = false
|
||||
skeleton.flipY = true
|
||||
skeleton.scaleY = -1
|
||||
if skin then
|
||||
skeleton:setSkin(skin)
|
||||
end
|
||||
@ -97,13 +96,13 @@ end
|
||||
function love.load(arg)
|
||||
if arg[#arg] == "-debug" then require("mobdebug").start() end
|
||||
skeletonRenderer = spine.SkeletonRenderer.new(true)
|
||||
table.insert(skeletons, loadSkeleton("stretchyman-pro", "stretchyman", "sneak", nil, 0.3, 200, 500))
|
||||
table.insert(skeletons, loadSkeleton("coin-pro", "coin", "rotate", nil, 0.5, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("spineboy-ess", "spineboy", "walk", nil, 0.5, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("raptor-pro", "raptor", "walk", nil, 0.3, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("goblins-pro", "goblins", "walk", "goblin", 1, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("tank-pro", "tank", "drive", nil, 0.2, 600, 500))
|
||||
table.insert(skeletons, loadSkeleton("vine-pro", "vine", "grow", nil, 0.3, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("stretchyman-pro", "stretchyman", "sneak", nil, 0.3, 200, 500))
|
||||
end
|
||||
|
||||
function love.update (delta)
|
||||
|
||||
@ -377,7 +377,7 @@ function AnimationState:apply (skeleton)
|
||||
for i,current in pairs(tracks) do
|
||||
if not (current == nil or current.delay > 0) then
|
||||
applied = true
|
||||
<<<<<<< HEAD
|
||||
|
||||
local blend = current.mixBlend
|
||||
if i == 0 then blend = MixBlend.first end
|
||||
|
||||
@ -385,15 +385,6 @@ function AnimationState:apply (skeleton)
|
||||
local mix = current.alpha
|
||||
if current.mixingFrom then
|
||||
mix = mix * self:applyMixingFrom(current, skeleton, blend)
|
||||
=======
|
||||
local currrentPose = MixPose.currentLayered
|
||||
if i == 0 then currentPose = MixPose.current end
|
||||
|
||||
-- Apply mixing from entries first.
|
||||
local mix = current.alpha
|
||||
if current.mixingFrom then
|
||||
mix = mix * self:applyMixingFrom(current, skeleton, currentPose)
|
||||
>>>>>>> 3.6
|
||||
elseif current.trackTime >= current.trackEnd and current.next == nil then
|
||||
mix = 0
|
||||
end
|
||||
@ -411,19 +402,13 @@ function AnimationState:apply (skeleton)
|
||||
local firstFrame = #current.timelinesRotation == 0
|
||||
local timelinesRotation = current.timelinesRotation
|
||||
|
||||
for i,timeline in ipairs(timelines) do
|
||||
<<<<<<< HEAD
|
||||
for ii,timeline in ipairs(timelines) do
|
||||
local timelineBlend = MixBlend.setup
|
||||
if timelineData[i] == SUBSEQUENT then timelineBlend = blend end
|
||||
if timelineData[ii] == SUBSEQUENT then timelineBlend = blend end
|
||||
|
||||
=======
|
||||
local pose = MixPose.currentPose
|
||||
if timelineData[i] >= FIRST then pose = MixPose.setup end
|
||||
|
||||
>>>>>>> 3.6
|
||||
if timeline.type == Animation.TimelineType.rotate then
|
||||
self:applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, i * 2,
|
||||
firstFrame) -- FIXME passing ii * 2, indexing correct?
|
||||
self:applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii * 2,
|
||||
firstFrame)
|
||||
else
|
||||
timeline:apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, MixDirection._in)
|
||||
end
|
||||
@ -468,7 +453,6 @@ function AnimationState:applyMixingFrom (to, skeleton, blend)
|
||||
for i,timeline in ipairs(timelines) do
|
||||
timeline:apply(skeleton, animationLast, animationTime, events, alphaMix, blend, MixDirection.out)
|
||||
end
|
||||
<<<<<<< HEAD
|
||||
else
|
||||
local timelineData = from.timelineData
|
||||
local timelineDipMix = from.timelineDipMix
|
||||
@ -493,13 +477,6 @@ function AnimationState:applyMixingFrom (to, skeleton, blend)
|
||||
elseif timelineData[i] == DIP then
|
||||
timelineBlend = MixBlend.setup
|
||||
alpha = alphaDip
|
||||
=======
|
||||
|
||||
if not skipSubsequent then
|
||||
from.totalAlpha = from.totalAlpha + alpha
|
||||
if timeline.type == Animation.TimelineType.rotate then
|
||||
self:applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i * 2, firstFrame)
|
||||
>>>>>>> 3.6
|
||||
else
|
||||
timelineBlend = MixBlend.setup
|
||||
local dipMix = timelineDipMix[i]
|
||||
@ -525,13 +502,8 @@ function AnimationState:applyMixingFrom (to, skeleton, blend)
|
||||
return mix
|
||||
end
|
||||
|
||||
<<<<<<< HEAD
|
||||
function AnimationState:applyRotateTimeline (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame)
|
||||
if firstFrame then
|
||||
=======
|
||||
function AnimationState:applyRotateTimeline (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame)
|
||||
if firstFrame then
|
||||
>>>>>>> 3.6
|
||||
timelinesRotation[i] = 0
|
||||
timelinesRotation[i+1] = 0
|
||||
end
|
||||
@ -858,13 +830,8 @@ function AnimationState:_animationsChanged ()
|
||||
local mixingTo = self.mixingTo
|
||||
|
||||
for i, entry in pairs(self.tracks) do
|
||||
<<<<<<< HEAD
|
||||
if entry and (i == 0 or entry.mixBlend ~= MixBlend.add) then
|
||||
entry:setTimelineData(nil, mixingTo, propertyIDs)
|
||||
=======
|
||||
if entry then
|
||||
entry:setTimelineData(nil, mixingTo, propertyIDs)
|
||||
>>>>>>> 3.6
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -95,33 +95,22 @@ function Bone:updateWorldTransformWith (x, y, rotation, scaleX, scaleY, shearX,
|
||||
self.ashearX = shearX
|
||||
self.ashearY = shearY
|
||||
self.appliedValid = true
|
||||
|
||||
local sx = self.skeleton.scaleX;
|
||||
local sy = self.skeleton.scaleY;
|
||||
|
||||
local parent = self.parent
|
||||
if parent == nil then
|
||||
local rotationY = rotation + 90 + shearY
|
||||
local rotationRad = math_rad(rotation + shearX)
|
||||
local rotationYRad = math_rad(rotationY)
|
||||
local la = math_cos(rotationRad) * scaleX
|
||||
local lb = math_cos(rotationYRad) * scaleY
|
||||
local lc = math_sin(rotationRad) * scaleX
|
||||
local ld = math_sin(rotationYRad) * scaleY
|
||||
local rotationYRad = math_rad(rotationY)
|
||||
local skeleton = self.skeleton
|
||||
if skeleton.flipX then
|
||||
x = -x
|
||||
la = -la
|
||||
lb = -lb
|
||||
end
|
||||
if skeleton.flipY then
|
||||
y = -y
|
||||
lc = -lc
|
||||
ld = -ld
|
||||
end
|
||||
self.a = la
|
||||
self.b = lb
|
||||
self.c = lc
|
||||
self.d = ld
|
||||
self.worldX = x + skeleton.x
|
||||
self.worldY = y + skeleton.y
|
||||
self.a = math_cos(rotationRad) * scaleX * sx
|
||||
self.b = math_cos(rotationYRad) * scaleY * sy
|
||||
self.c = math_sin(rotationRad) * scaleX * sx
|
||||
self.d = math_sin(rotationYRad) * scaleY * sy
|
||||
self.worldX = x * sx + skeleton.x
|
||||
self.worldY = y * sy + skeleton.y
|
||||
return
|
||||
end
|
||||
|
||||
@ -176,8 +165,8 @@ function Bone:updateWorldTransformWith (x, y, rotation, scaleX, scaleY, shearX,
|
||||
elseif transformMode == TransformMode.noScale or transformMode == TransformMode.noScaleOrReflection then
|
||||
local cos = math_cos(math_rad(rotation))
|
||||
local sin = math_sin(math_rad(rotation))
|
||||
local za = pa * cos + pb * sin
|
||||
local zc = pc * cos + pd * sin
|
||||
local za = (pa * cos + pb * sin) / sx
|
||||
local zc = (pc * cos + pd * sin) / sy
|
||||
local s = math_sqrt(za * za + zc * zc)
|
||||
if s > 0.00001 then s = 1 / s end
|
||||
za = za * s
|
||||
@ -190,27 +179,16 @@ function Bone:updateWorldTransformWith (x, y, rotation, scaleX, scaleY, shearX,
|
||||
local lb = math_cos(math_rad(90 + shearY)) * scaleY;
|
||||
local lc = math_sin(math_rad(shearX)) * scaleX;
|
||||
local ld = math_sin(math_rad(90 + shearY)) * scaleY;
|
||||
local flip = self.skeleton.flipX ~= self.skeleton.flipY
|
||||
if transformMode ~= TransformMode.noScaleOrReflection then flip = pa * pd - pb * pc < 0 end
|
||||
if flip then
|
||||
zb = -zb
|
||||
zd = -zd
|
||||
end
|
||||
self.a = za * la + zb * lc
|
||||
self.b = za * lb + zb * ld
|
||||
self.c = zc * la + zd * lc
|
||||
self.d = zc * lb + zd * ld
|
||||
return
|
||||
end
|
||||
|
||||
if self.skeleton.flipX then
|
||||
self.a = -self.a
|
||||
self.b = -self.b
|
||||
end
|
||||
if self.skeleton.flipY then
|
||||
self.c = -self.c
|
||||
self.d = -self.d
|
||||
end
|
||||
self.a = self.a * sx
|
||||
self.b = self.b * sx
|
||||
self.c = self.c * sy
|
||||
self.d = self.d * sy
|
||||
end
|
||||
|
||||
function Bone:setToSetupPose ()
|
||||
|
||||
@ -63,7 +63,7 @@ function Skeleton.new (data)
|
||||
skin = nil,
|
||||
color = Color.newWith(1, 1, 1, 1),
|
||||
time = 0,
|
||||
flipX = false, flipY = false,
|
||||
scaleX = 1, scaleY = 1,
|
||||
x = 0, y = 0
|
||||
}
|
||||
setmetatable(self, Skeleton)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user