[lua] Fixed DeformTimeline, see #1016.

This commit is contained in:
badlogic 2017-10-11 11:20:40 +02:00
parent bd3b5cd1fe
commit bb97951cf9

View File

@ -797,50 +797,43 @@ function Animation.DeformTimeline.new (frameCount)
local frames = self.frames local frames = self.frames
local verticesArray = slot.attachmentVertices local verticesArray = slot.attachmentVertices
if #(verticesArray) == 0 then alpha = 1 end
local frameVertices = self.frameVertices local frameVertices = self.frameVertices
local vertexCount = #(frameVertices[0]) local vertexCount = #(frameVertices[0])
local vertices = utils.setArraySize(verticesArray, vertexCount)
if time < frames[0] then if time < frames[0] then
local vertexAttachment = slotAttachment; local vertexAttachment = slotAttachment;
if pose == MixPose.setup then if pose == MixPose.setup then
if (vertexAttachment.bones == nil) then slot.attachmentVertices = {}
local i = 1 return;
local setupVertices = vertexAttachment.vertices
while i <= vertexCount do
vertices[i] = setupVertices[i]
i = i + 1
end
else
local i = 1
while i <= vertexCount do
vertices[i] = 0
i = i + 1
end
end
elseif pose == MixPose.current then elseif pose == MixPose.current then
if (alpha ~= 1) then if (alpha == 1) then
if (vertexAttachment.bones == nil) then slot.attachmentVertices = {}
local setupVertices = vertexAttachment.vertices return;
local i = 1 end
while i <= vertexCount do
vertices[i] = vertices[i] + (setupVertices[i] - vertices[i]) * alpha local vertices = utils.setArraySize(verticesArray, vertexCount)
i = i + 1 if (vertexAttachment.bones == nil) then
end local setupVertices = vertexAttachment.vertices
else local i = 1
alpha = 1 - alpha while i <= vertexCount do
local i = 1 vertices[i] = vertices[i] + (setupVertices[i] - vertices[i]) * alpha
while i <= vertexCount do i = i + 1
vertices[i] = vertices[i] * alpha end
i = i + 1 else
end alpha = 1 - alpha
end local i = 1
end while i <= vertexCount do
vertices[i] = vertices[i] * alpha
i = i + 1
end
end
end end
return return
end end
local vertices = utils.setArraySize(verticesArray, vertexCount)
if time >= frames[zlen(frames) - 1] then -- Time is after last frame. if time >= frames[zlen(frames) - 1] then -- Time is after last frame.
local lastVertices = frameVertices[zlen(frames) - 1] local lastVertices = frameVertices[zlen(frames) - 1]
if alpha == 1 then if alpha == 1 then