Merge branch '3.7-beta' into 3.7-beta-cpp

This commit is contained in:
badlogic 2018-07-24 15:01:36 +02:00
commit 54653d3a9e
11 changed files with 49 additions and 125 deletions

View File

@ -92,31 +92,19 @@ package spine {
var rotationY : Number = 0, la : Number = 0, lb : Number = 0, lc : Number = 0, ld : Number = 0; var rotationY : Number = 0, la : Number = 0, lb : Number = 0, lc : Number = 0, ld : Number = 0;
var sin : Number = 0, cos : Number = 0; var sin : Number = 0, cos : Number = 0;
var s : Number = 0; var s : Number = 0;
var sx : Number = _skeleton.scaleX;
var sy : Number = _skeleton.scaleY * (yDown ? -1 : 1);
var parent : Bone = _parent; var parent : Bone = _parent;
if (!parent) { // Root bone. if (!parent) { // Root bone.
rotationY = rotation + 90 + shearY; 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; var skeleton : Skeleton = _skeleton;
if (skeleton.flipX) { this.a = MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
x = -x; this.b = MathUtils.cosDeg(rotationY) * scaleY * sy;
la = -la; this.c = MathUtils.sinDeg(rotation + shearX) * scaleX * sx;
lb = -lb; this.d = MathUtils.sinDeg(rotationY) * scaleY * sy;
} worldX = x * sx + skeleton.x;
if (skeleton.flipY != yDown) { worldY = y * sy + skeleton.y;
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;
return; return;
} }
@ -174,8 +162,8 @@ package spine {
case TransformMode.noScaleOrReflection: { case TransformMode.noScaleOrReflection: {
cos = MathUtils.cosDeg(rotation); cos = MathUtils.cosDeg(rotation);
sin = MathUtils.sinDeg(rotation); sin = MathUtils.sinDeg(rotation);
var za : Number = pa * cos + pb * sin; var za : Number = (pa * cos + pb * sin) / sx;
var zc : Number = pc * cos + pd * sin; var zc : Number = (pc * cos + pd * sin) / sy;
s = Math.sqrt(za * za + zc * zc); s = Math.sqrt(za * za + zc * zc);
if (s > 0.00001) s = 1 / s; if (s > 0.00001) s = 1 / s;
za *= s; za *= s;
@ -188,25 +176,17 @@ package spine {
lb = MathUtils.cosDeg(90 + shearY) * scaleY; lb = MathUtils.cosDeg(90 + shearY) * scaleY;
lc = MathUtils.sinDeg(shearX) * scaleX; lc = MathUtils.sinDeg(shearX) * scaleX;
ld = MathUtils.sinDeg(90 + shearY) * scaleY; 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;
}
this.a = za * la + zb * lc; this.a = za * la + zb * lc;
this.b = za * lb + zb * ld; this.b = za * lb + zb * ld;
this.c = zc * la + zd * lc; this.c = zc * la + zd * lc;
this.d = zc * lb + zd * ld; this.d = zc * lb + zd * ld;
return; break;
} }
} }
if (_skeleton.flipX) { this.a *= sx;
this.a = -this.a; this.b *= sx;
this.b = -this.b; this.c *= sy;
} this.d *= sy;
if (_skeleton.flipY != yDown) {
this.c = -this.c;
this.d = -this.d;
}
} }
public function setToSetupPose() : void { public function setToSetupPose() : void {

View File

@ -50,7 +50,7 @@ package spine {
private var _skin : Skin; private var _skin : Skin;
public var color : Color = new Color(1, 1, 1, 1); public var color : Color = new Color(1, 1, 1, 1);
public var time : Number = 0; 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 var x : Number = 0, y : Number = 0;
public function Skeleton(data : SkeletonData) { public function Skeleton(data : SkeletonData) {

View File

@ -146,14 +146,14 @@ package spine.flash {
wrapper.transform.colorTransform = colorTransform; wrapper.transform.colorTransform = colorTransform;
var bone : Bone = slot.bone; var bone : Bone = slot.bone;
var flipX : int = skeleton.flipX ? -1 : 1; var scaleX : Number = skeleton.scaleX;
var flipY : int = skeleton.flipY ? -1 : 1; var scaleY : Number = skeleton.scaleY;
wrapper.x = bone.worldX; wrapper.x = bone.worldX;
wrapper.y = bone.worldY; wrapper.y = bone.worldY;
wrapper.rotation = bone.worldRotationX * flipX * flipY; wrapper.rotation = bone.worldRotationX * scaleX * scaleX;
wrapper.scaleX = bone.worldScaleX * flipX; wrapper.scaleX = bone.worldScaleX * scaleX;
wrapper.scaleY = bone.worldScaleY * flipY; wrapper.scaleY = bone.worldScaleY * scaleY;
addChild(wrapper); addChild(wrapper);
} }
} }

View File

@ -25,7 +25,7 @@ function loadSkeleton(atlasFile, jsonFile, x, y, scale, animation, skin)
json.scale = scale json.scale = scale
local skeletonData = json:readSkeletonDataFile("data/" .. jsonFile) local skeletonData = json:readSkeletonDataFile("data/" .. jsonFile)
local skeleton = spine.Skeleton.new(skeletonData) 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.x = x
skeleton.group.y = y skeleton.group.y = y

View File

@ -45,8 +45,7 @@ function loadSkeleton (jsonFile, atlasFile, animation, skin, scale, x, y)
local skeleton = spine.Skeleton.new(skeletonData) local skeleton = spine.Skeleton.new(skeletonData)
skeleton.x = x skeleton.x = x
skeleton.y = y skeleton.y = y
skeleton.flipX = false skeleton.scaleY = -1
skeleton.flipY = true
if skin then if skin then
skeleton:setSkin(skin) skeleton:setSkin(skin)
end end
@ -97,13 +96,13 @@ end
function love.load(arg) function love.load(arg)
if arg[#arg] == "-debug" then require("mobdebug").start() end if arg[#arg] == "-debug" then require("mobdebug").start() end
skeletonRenderer = spine.SkeletonRenderer.new(true) 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("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("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("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("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("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("vine-pro", "vine", "grow", nil, 0.3, 400, 500))
table.insert(skeletons, loadSkeleton("stretchyman-pro", "stretchyman", "sneak", nil, 0.3, 200, 500))
end end
function love.update (delta) function love.update (delta)

View File

@ -377,7 +377,7 @@ function AnimationState:apply (skeleton)
for i,current in pairs(tracks) do for i,current in pairs(tracks) do
if not (current == nil or current.delay > 0) then if not (current == nil or current.delay > 0) then
applied = true applied = true
<<<<<<< HEAD
local blend = current.mixBlend local blend = current.mixBlend
if i == 0 then blend = MixBlend.first end if i == 0 then blend = MixBlend.first end
@ -385,15 +385,6 @@ function AnimationState:apply (skeleton)
local mix = current.alpha local mix = current.alpha
if current.mixingFrom then if current.mixingFrom then
mix = mix * self:applyMixingFrom(current, skeleton, blend) 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 elseif current.trackTime >= current.trackEnd and current.next == nil then
mix = 0 mix = 0
end end
@ -411,19 +402,13 @@ function AnimationState:apply (skeleton)
local firstFrame = #current.timelinesRotation == 0 local firstFrame = #current.timelinesRotation == 0
local timelinesRotation = current.timelinesRotation local timelinesRotation = current.timelinesRotation
for i,timeline in ipairs(timelines) do for ii,timeline in ipairs(timelines) do
<<<<<<< HEAD
local timelineBlend = MixBlend.setup 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 if timeline.type == Animation.TimelineType.rotate then
self:applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, i * 2, self:applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii * 2,
firstFrame) -- FIXME passing ii * 2, indexing correct? firstFrame)
else else
timeline:apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, MixDirection._in) timeline:apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, MixDirection._in)
end end
@ -468,7 +453,6 @@ function AnimationState:applyMixingFrom (to, skeleton, blend)
for i,timeline in ipairs(timelines) do for i,timeline in ipairs(timelines) do
timeline:apply(skeleton, animationLast, animationTime, events, alphaMix, blend, MixDirection.out) timeline:apply(skeleton, animationLast, animationTime, events, alphaMix, blend, MixDirection.out)
end end
<<<<<<< HEAD
else else
local timelineData = from.timelineData local timelineData = from.timelineData
local timelineDipMix = from.timelineDipMix local timelineDipMix = from.timelineDipMix
@ -493,13 +477,6 @@ function AnimationState:applyMixingFrom (to, skeleton, blend)
elseif timelineData[i] == DIP then elseif timelineData[i] == DIP then
timelineBlend = MixBlend.setup timelineBlend = MixBlend.setup
alpha = alphaDip 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 else
timelineBlend = MixBlend.setup timelineBlend = MixBlend.setup
local dipMix = timelineDipMix[i] local dipMix = timelineDipMix[i]
@ -525,13 +502,8 @@ function AnimationState:applyMixingFrom (to, skeleton, blend)
return mix return mix
end end
<<<<<<< HEAD
function AnimationState:applyRotateTimeline (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) function AnimationState:applyRotateTimeline (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame)
if firstFrame then if firstFrame then
=======
function AnimationState:applyRotateTimeline (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame)
if firstFrame then
>>>>>>> 3.6
timelinesRotation[i] = 0 timelinesRotation[i] = 0
timelinesRotation[i+1] = 0 timelinesRotation[i+1] = 0
end end
@ -858,13 +830,8 @@ function AnimationState:_animationsChanged ()
local mixingTo = self.mixingTo local mixingTo = self.mixingTo
for i, entry in pairs(self.tracks) do for i, entry in pairs(self.tracks) do
<<<<<<< HEAD
if entry and (i == 0 or entry.mixBlend ~= MixBlend.add) then if entry and (i == 0 or entry.mixBlend ~= MixBlend.add) then
entry:setTimelineData(nil, mixingTo, propertyIDs) entry:setTimelineData(nil, mixingTo, propertyIDs)
=======
if entry then
entry:setTimelineData(nil, mixingTo, propertyIDs)
>>>>>>> 3.6
end end
end end
end end

View File

@ -96,32 +96,21 @@ function Bone:updateWorldTransformWith (x, y, rotation, scaleX, scaleY, shearX,
self.ashearY = shearY self.ashearY = shearY
self.appliedValid = true self.appliedValid = true
local sx = self.skeleton.scaleX;
local sy = self.skeleton.scaleY;
local parent = self.parent local parent = self.parent
if parent == nil then if parent == nil then
local rotationY = rotation + 90 + shearY local rotationY = rotation + 90 + shearY
local rotationRad = math_rad(rotation + shearX) local rotationRad = math_rad(rotation + shearX)
local rotationYRad = math_rad(rotationY) 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 skeleton = self.skeleton local skeleton = self.skeleton
if skeleton.flipX then self.a = math_cos(rotationRad) * scaleX * sx
x = -x self.b = math_cos(rotationYRad) * scaleY * sy
la = -la self.c = math_sin(rotationRad) * scaleX * sx
lb = -lb self.d = math_sin(rotationYRad) * scaleY * sy
end self.worldX = x * sx + skeleton.x
if skeleton.flipY then self.worldY = y * sy + skeleton.y
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
return return
end end
@ -176,8 +165,8 @@ function Bone:updateWorldTransformWith (x, y, rotation, scaleX, scaleY, shearX,
elseif transformMode == TransformMode.noScale or transformMode == TransformMode.noScaleOrReflection then elseif transformMode == TransformMode.noScale or transformMode == TransformMode.noScaleOrReflection then
local cos = math_cos(math_rad(rotation)) local cos = math_cos(math_rad(rotation))
local sin = math_sin(math_rad(rotation)) local sin = math_sin(math_rad(rotation))
local za = pa * cos + pb * sin local za = (pa * cos + pb * sin) / sx
local zc = pc * cos + pd * sin local zc = (pc * cos + pd * sin) / sy
local s = math_sqrt(za * za + zc * zc) local s = math_sqrt(za * za + zc * zc)
if s > 0.00001 then s = 1 / s end if s > 0.00001 then s = 1 / s end
za = za * s 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 lb = math_cos(math_rad(90 + shearY)) * scaleY;
local lc = math_sin(math_rad(shearX)) * scaleX; local lc = math_sin(math_rad(shearX)) * scaleX;
local ld = math_sin(math_rad(90 + shearY)) * scaleY; 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.a = za * la + zb * lc
self.b = za * lb + zb * ld self.b = za * lb + zb * ld
self.c = zc * la + zd * lc self.c = zc * la + zd * lc
self.d = zc * lb + zd * ld self.d = zc * lb + zd * ld
return
end end
if self.skeleton.flipX then self.a = self.a * sx
self.a = -self.a self.b = self.b * sx
self.b = -self.b self.c = self.c * sy
end self.d = self.d * sy
if self.skeleton.flipY then
self.c = -self.c
self.d = -self.d
end
end end
function Bone:setToSetupPose () function Bone:setToSetupPose ()

View File

@ -63,7 +63,7 @@ function Skeleton.new (data)
skin = nil, skin = nil,
color = Color.newWith(1, 1, 1, 1), color = Color.newWith(1, 1, 1, 1),
time = 0, time = 0,
flipX = false, flipY = false, scaleX = 1, scaleY = 1,
x = 0, y = 0 x = 0, y = 0
} }
setmetatable(self, Skeleton) setmetatable(self, Skeleton)