mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[lua] Many fixes, a few things still broken.
This commit is contained in:
parent
6428b82e1e
commit
0b26b5e74a
@ -155,7 +155,7 @@ function Animation.Timeline.new (timelineType, frameEntries, frameCount, propert
|
|||||||
local self = {
|
local self = {
|
||||||
timelineType = timelineType,
|
timelineType = timelineType,
|
||||||
propertyIds = propertyIds,
|
propertyIds = propertyIds,
|
||||||
frames = utils.newNumberArrayZero((frameCount - 1) * frameEntries)
|
frames = utils.newNumberArrayZero(frameCount * frameEntries)
|
||||||
}
|
}
|
||||||
|
|
||||||
function self:getFrameEntries ()
|
function self:getFrameEntries ()
|
||||||
@ -201,19 +201,10 @@ local BEZIER_SIZE = 18
|
|||||||
|
|
||||||
Animation.CurveTimeline = {}
|
Animation.CurveTimeline = {}
|
||||||
function Animation.CurveTimeline.new (timelineType, frameEntries, frameCount, bezierCount, propertyIds)
|
function Animation.CurveTimeline.new (timelineType, frameEntries, frameCount, bezierCount, propertyIds)
|
||||||
local LINEAR = 0
|
|
||||||
local STEPPED = 1
|
|
||||||
local BEZIER = 2
|
|
||||||
local BEZIER_SIZE = 10 * 2 - 1
|
|
||||||
|
|
||||||
local self = Animation.Timeline.new(timelineType, frameEntries, frameCount, propertyIds)
|
local self = Animation.Timeline.new(timelineType, frameEntries, frameCount, propertyIds)
|
||||||
self.curves = utils.newNumberArrayZero(frameCount + bezierCount * BEZIER_SIZE)
|
self.curves = utils.newNumberArrayZero(frameCount + bezierCount * BEZIER_SIZE)
|
||||||
self.curves[frameCount - 1] = STEPPED
|
self.curves[frameCount - 1] = STEPPED
|
||||||
|
|
||||||
function self:getFrameCount ()
|
|
||||||
return math_floor(zlen(self.curves) / BEZIER_SIZE) + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function self:setStepped (frame)
|
function self:setStepped (frame)
|
||||||
self.curves[frame] = STEPPED
|
self.curves[frame] = STEPPED
|
||||||
end
|
end
|
||||||
@ -1459,8 +1450,8 @@ function Animation.DeformTimeline.new (frameCount, bezierCount, slotIndex, attac
|
|||||||
end
|
end
|
||||||
|
|
||||||
utils.setArraySize(deform, vertexCount)
|
utils.setArraySize(deform, vertexCount)
|
||||||
if time >= frames[zlen(frames) - 1] then -- Time is after last frame.
|
if time >= frames[#frames] then -- Time is after last frame.
|
||||||
local lastVertices = vertices[zlen(frames) - 1]
|
local lastVertices = vertices[#frames]
|
||||||
if alpha == 1 then
|
if alpha == 1 then
|
||||||
if blend == MixBlend.add then
|
if blend == MixBlend.add then
|
||||||
if vertexAttachment.bones == nil then
|
if vertexAttachment.bones == nil then
|
||||||
|
|||||||
@ -551,7 +551,7 @@ end
|
|||||||
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
|
||||||
timelinesRotation[i] = 0
|
timelinesRotation[i] = 0
|
||||||
timelinesRotation[i+1] = 0
|
timelinesRotation[i + 1] = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if alpha == 1 then
|
if alpha == 1 then
|
||||||
@ -722,9 +722,9 @@ function AnimationState:setCurrent (index, current, interrupt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function AnimationState:setAnimationByName (trackIndex, animationName, loop)
|
function AnimationState:setAnimationByName (trackIndex, animationName, loop)
|
||||||
local animation = self.data.skeletonData:findAnimation(animationName)
|
local animation = self.data.skeletonData:findAnimation(animationName)
|
||||||
if not animation then error("Animation not found: " .. animationName, 2) end
|
if not animation then error("Animation not found: " .. animationName, 2) end
|
||||||
return self:setAnimation(trackIndex, animation, loop)
|
return self:setAnimation(trackIndex, animation, loop)
|
||||||
end
|
end
|
||||||
|
|
||||||
function AnimationState:setAnimation (trackIndex, animation, loop)
|
function AnimationState:setAnimation (trackIndex, animation, loop)
|
||||||
|
|||||||
@ -859,7 +859,7 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
for i,keyMap in ipairs(timelineMap) do
|
for i,keyMap in ipairs(timelineMap) do
|
||||||
local frame = i - 1
|
local frame = i - 1
|
||||||
timeline:setFrame(frame, time, mixRotate, mixX, mixY, mixScaleX, mixScaleY, mixShearY)
|
timeline:setFrame(frame, time, mixRotate, mixX, mixY, mixScaleX, mixScaleY, mixShearY)
|
||||||
local nextMap = timelineMap[frame + 1]
|
local nextMap = timelineMap[i + 1]
|
||||||
if not nextMap then
|
if not nextMap then
|
||||||
timeline:shrink(bezier)
|
timeline:shrink(bezier)
|
||||||
break
|
break
|
||||||
@ -927,7 +927,7 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
for i,keyMap in ipairs(timelineMap) do
|
for i,keyMap in ipairs(timelineMap) do
|
||||||
local frame = i - 1
|
local frame = i - 1
|
||||||
timeline:setFrame(frame, time, mixRotate, mixX, mixY)
|
timeline:setFrame(frame, time, mixRotate, mixX, mixY)
|
||||||
local nextMap = timelineMap[frame + 1]
|
local nextMap = timelineMap[i + 1]
|
||||||
if not nextMap then
|
if not nextMap then
|
||||||
timeline:shrink(bezier)
|
timeline:shrink(bezier)
|
||||||
break
|
break
|
||||||
@ -981,8 +981,11 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
local deform = nil
|
local deform = nil
|
||||||
local verticesValue = getValue(keyMap, "vertices", nil)
|
local verticesValue = getValue(keyMap, "vertices", nil)
|
||||||
if verticesValue == nil then
|
if verticesValue == nil then
|
||||||
deform = vertices
|
if weighted then
|
||||||
if weighted then deform = utils.newNumberArray(deformLength) end
|
deform = utils.newNumberArray(deformLength)
|
||||||
|
else
|
||||||
|
deform = vertices
|
||||||
|
end
|
||||||
else
|
else
|
||||||
deform = utils.newNumberArray(deformLength)
|
deform = utils.newNumberArray(deformLength)
|
||||||
local start = getValue(keyMap, "offset", 0) + 1
|
local start = getValue(keyMap, "offset", 0) + 1
|
||||||
@ -1005,7 +1008,7 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
timeline:setFrame(frame, time, deform)
|
timeline:setFrame(frame, time, deform)
|
||||||
local nextMap = timelineMap[frame + 1]
|
local nextMap = timelineMap[i + 1]
|
||||||
if not nextMap then
|
if not nextMap then
|
||||||
timeline:shrink(bezier)
|
timeline:shrink(bezier)
|
||||||
break
|
break
|
||||||
@ -1109,16 +1112,6 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
table_insert(skeletonData.animations, Animation.new(name, timelines, duration))
|
table_insert(skeletonData.animations, Animation.new(name, timelines, duration))
|
||||||
end
|
end
|
||||||
|
|
||||||
readCurve = function (map, timeline, frame)
|
|
||||||
local curve = map["curve"]
|
|
||||||
if not curve then return end
|
|
||||||
if curve == "stepped" then
|
|
||||||
timeline:setStepped(frame)
|
|
||||||
else
|
|
||||||
timeline:setCurve(frame, getValue(map, "curve", 0), getValue(map, "c2", 0), getValue(map, "c3", 1), getValue(map, "c4", 1))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
readTimeline1 = function (keys, timeline, defaultValue, scale)
|
readTimeline1 = function (keys, timeline, defaultValue, scale)
|
||||||
local keyMap = keys[1]
|
local keyMap = keys[1]
|
||||||
local time = getValue(keyMap, "time", 0)
|
local time = getValue(keyMap, "time", 0)
|
||||||
@ -1127,17 +1120,17 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
for i,keyMap in ipairs(keys) do
|
for i,keyMap in ipairs(keys) do
|
||||||
local frame = i - 1
|
local frame = i - 1
|
||||||
timeline:setFrame(frame, time, value)
|
timeline:setFrame(frame, time, value)
|
||||||
local nextMap = keys[frame + 1]
|
local nextMap = keys[i + 1]
|
||||||
if not nextMap then break end
|
if not nextMap then
|
||||||
|
timeline:shrink(bezier)
|
||||||
|
return timeline
|
||||||
|
end
|
||||||
local time2 = getValue(nextMap, "time", 0)
|
local time2 = getValue(nextMap, "time", 0)
|
||||||
local value2 = getValue(nextMap, "value", defaultValue) * scale
|
local value2 = getValue(nextMap, "value", defaultValue) * scale
|
||||||
local curve = keyMap.curve
|
if keyMap.curve then bezier = readCurve(keyMap.curve, timeline, bezier, frame, 0, time, time2, value, value2, scale) end
|
||||||
if curve then bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value, value2, scale) end
|
|
||||||
time = time2
|
time = time2
|
||||||
value = value2
|
value = value2
|
||||||
end
|
end
|
||||||
timeline:shrink(bezier)
|
|
||||||
return timeline
|
|
||||||
end
|
end
|
||||||
|
|
||||||
readTimeline2 = function (keys, timeline, name1, name2, defaultValue, scale)
|
readTimeline2 = function (keys, timeline, name1, name2, defaultValue, scale)
|
||||||
@ -1149,8 +1142,11 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
for i,keyMap in ipairs(keys) do
|
for i,keyMap in ipairs(keys) do
|
||||||
local frame = i - 1
|
local frame = i - 1
|
||||||
timeline:setFrame(frame, time, value1, value2)
|
timeline:setFrame(frame, time, value1, value2)
|
||||||
local nextMap = keys[frame + 1]
|
local nextMap = keys[i + 1]
|
||||||
if not nextMap then break end
|
if not nextMap then
|
||||||
|
timeline:shrink(bezier)
|
||||||
|
return timeline
|
||||||
|
end
|
||||||
local time2 = getValue(nextMap, "time", 0)
|
local time2 = getValue(nextMap, "time", 0)
|
||||||
local nvalue1 = getValue(nextMap, name1, defaultValue) * scale
|
local nvalue1 = getValue(nextMap, name1, defaultValue) * scale
|
||||||
local nvalue2 = getValue(nextMap, name2, defaultValue) * scale
|
local nvalue2 = getValue(nextMap, name2, defaultValue) * scale
|
||||||
@ -1163,8 +1159,6 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
value1 = nvalue1
|
value1 = nvalue1
|
||||||
value2 = nvalue2
|
value2 = nvalue2
|
||||||
end
|
end
|
||||||
timeline:shrink(bezier)
|
|
||||||
return timeline
|
|
||||||
end
|
end
|
||||||
|
|
||||||
readCurve = function (curve, timeline, bezier, frame, value, time1, time2, value1, value2, scale)
|
readCurve = function (curve, timeline, bezier, frame, value, time1, time2, value1, value2, scale)
|
||||||
|
|||||||
@ -61,11 +61,11 @@ end
|
|||||||
function VertexAttachment:computeWorldVertices (slot, start, count, worldVertices, offset, stride)
|
function VertexAttachment:computeWorldVertices (slot, start, count, worldVertices, offset, stride)
|
||||||
count = offset + (count / 2) * stride
|
count = offset + (count / 2) * stride
|
||||||
local skeleton = slot.bone.skeleton
|
local skeleton = slot.bone.skeleton
|
||||||
local deformArray = slot.deform
|
local deform = slot.deform
|
||||||
local vertices = self.vertices
|
local vertices = self.vertices
|
||||||
local bones = self.bones
|
local bones = self.bones
|
||||||
if not bones then
|
if not bones then
|
||||||
if #deformArray > 0 then vertices = deformArray end
|
if #deform > 0 then vertices = deform end
|
||||||
local bone = slot.bone
|
local bone = slot.bone
|
||||||
x = bone.worldX
|
x = bone.worldX
|
||||||
y = bone.worldY
|
y = bone.worldY
|
||||||
@ -95,7 +95,7 @@ function VertexAttachment:computeWorldVertices (slot, start, count, worldVertice
|
|||||||
i = i + 2
|
i = i + 2
|
||||||
end
|
end
|
||||||
local skeletonBones = skeleton.bones
|
local skeletonBones = skeleton.bones
|
||||||
if #deformArray == 0 then
|
if #deform == 0 then
|
||||||
local w = offset
|
local w = offset
|
||||||
local b = skip * 3
|
local b = skip * 3
|
||||||
while w < count do
|
while w < count do
|
||||||
@ -119,7 +119,6 @@ function VertexAttachment:computeWorldVertices (slot, start, count, worldVertice
|
|||||||
w = w + stride
|
w = w + stride
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local deform = deformArray
|
|
||||||
local w = offset
|
local w = offset
|
||||||
local b = skip * 3
|
local b = skip * 3
|
||||||
local f = skip * 2
|
local f = skip * 2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user