From e87610277a86a99b1be2d25483ffecb48117bf18 Mon Sep 17 00:00:00 2001 From: badlogic Date: Wed, 15 May 2019 15:08:49 +0200 Subject: [PATCH] [lua] Renamed attachmentVertices to deform, see #1303. --- spine-lua/Animation.lua | 52 +++++++++++----------- spine-lua/AnimationState.lua | 6 +-- spine-lua/MeshAttachment.lua | 2 +- spine-lua/Slot.lua | 4 +- spine-lua/attachments/VertexAttachment.lua | 2 +- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/spine-lua/Animation.lua b/spine-lua/Animation.lua index 17efcf48c..1eff5a117 100644 --- a/spine-lua/Animation.lua +++ b/spine-lua/Animation.lua @@ -826,8 +826,8 @@ function Animation.DeformTimeline.new (frameCount) if not slotAttachment:applyDeform(self.attachment) then return end local frames = self.frames - local verticesArray = slot.attachmentVertices - if #(verticesArray) == 0 then blend = MixBlend.setup end + local deformArray = slot.deform + if #(deformArray) == 0 then blend = MixBlend.setup end local frameVertices = self.frameVertices local vertexCount = #(frameVertices[0]) @@ -835,27 +835,27 @@ function Animation.DeformTimeline.new (frameCount) if time < frames[0] then local vertexAttachment = slotAttachment; if blend == MixBlend.setup then - slot.attachmentVertices = {} + slot.deform = {} return; elseif blend == MixBlend.first then if (alpha == 1) then - slot.attachmentVertices = {} + slot.deform = {} return; end - local vertices = utils.setArraySize(verticesArray, vertexCount) + local deform = utils.setArraySize(deformArray, vertexCount) if (vertexAttachment.bones == nil) then local setupVertices = vertexAttachment.vertices local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] + (setupVertices[i] - vertices[i]) * alpha + deform[i] = deform[i] + (setupVertices[i] - deform[i]) * alpha i = i + 1 end else alpha = 1 - alpha local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] * alpha + deform[i] = deform[i] * alpha i = i + 1 end end @@ -863,7 +863,7 @@ function Animation.DeformTimeline.new (frameCount) return end - local vertices = utils.setArraySize(verticesArray, vertexCount) + local deform = utils.setArraySize(deformArray, vertexCount) if time >= frames[zlen(frames) - 1] then -- Time is after last frame. local lastVertices = frameVertices[zlen(frames) - 1] if alpha == 1 then @@ -874,21 +874,21 @@ function Animation.DeformTimeline.new (frameCount) local setupVertices = vertexAttachment.vertices local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] + lastVertices[i] - setupVertices[i] + deform[i] = deform[i] + lastVertices[i] - setupVertices[i] i = i + 1 end else -- Weighted deform offsets, with alpha. local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] + lastVertices[i] + deform[i] = deform[i] + lastVertices[i] i = i + 1 end end else local i = 1 while i <= vertexCount do - vertices[i] = lastVertices[i] + deform[i] = lastVertices[i] i = i + 1 end end @@ -901,21 +901,21 @@ function Animation.DeformTimeline.new (frameCount) local i = 1 while i <= vertexCount do local setup = setupVertices[i] - vertices[i] = setup + (lastVertices[i] - setup) * alpha + deform[i] = setup + (lastVertices[i] - setup) * alpha i = i + 1 end else -- Weighted deform offsets, with alpha. local i = 1 while i <= vertexCount do - vertices[i] = lastVertices[i] * alpha + deform[i] = lastVertices[i] * alpha i = i + 1 end end elseif blend == MixBlend.first or blend == MixBlend.replace then local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] + (lastVertices[i] - vertices[i]) * alpha + deform[i] = deform[i] + (lastVertices[i] - deform[i]) * alpha i = i + 1 end local vertexAttachment = slotAttachment @@ -923,14 +923,14 @@ function Animation.DeformTimeline.new (frameCount) local setupVertices = vertexAttachment.vertices local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] + (lastVertices[i] - setupVertices[i]) * alpha + deform[i] = deform[i] + (lastVertices[i] - setupVertices[i]) * alpha i = i + 1 end else -- Weighted deform offsets, with alpha. local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] + lastVertices[i] * alpha + deform[i] = deform[i] + lastVertices[i] * alpha i = i + 1 end end @@ -940,14 +940,14 @@ function Animation.DeformTimeline.new (frameCount) local setupVertices = vertexAttachment.vertices local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] + (lastVertices[i] - setupVertices[i]) * alpha + deform[i] = deform[i] + (lastVertices[i] - setupVertices[i]) * alpha i = i + 1 end else -- Weighted deform offsets, with alpha. local i = 1 while i <= vertexCount do - vertices[i] = vertices[i] + lastVertices[i] * alpha + deform[i] = deform[i] + lastVertices[i] * alpha i = i + 1 end end @@ -972,7 +972,7 @@ function Animation.DeformTimeline.new (frameCount) local i = 1 while i <= vertexCount do local prev = prevVertices[i] - vertices[i] = vertices[i] + prev + (nextVertices[i] - prev) * precent - setupVertices[i] + deform[i] = deform[i] + prev + (nextVertices[i] - prev) * precent - setupVertices[i] i = i + 1 end else @@ -980,7 +980,7 @@ function Animation.DeformTimeline.new (frameCount) local i = 1 while i <= vertexCount do local prev = prevVertices[i] - vertices[i] = vertices[i] + prev + (nextVertices[i] - prev) * percent + deform[i] = deform[i] + prev + (nextVertices[i] - prev) * percent i = i + 1 end end @@ -988,7 +988,7 @@ function Animation.DeformTimeline.new (frameCount) local i = 1 while i <= vertexCount do local prev = prevVertices[i] - vertices[i] = prev + (nextVertices[i] - prev) * percent + deform[i] = prev + (nextVertices[i] - prev) * percent i = i + 1 end end @@ -1002,7 +1002,7 @@ function Animation.DeformTimeline.new (frameCount) while i <= vertexCount do local prev = prevVertices[i] local setup = setupVertices[i] - vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha + deform[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha i = i + 1 end else @@ -1010,7 +1010,7 @@ function Animation.DeformTimeline.new (frameCount) local i = 1 while i <= vertexCount do local prev = prevVertices[i] - vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha + deform[i] = (prev + (nextVertices[i] - prev) * percent) * alpha i = i + 1 end end @@ -1018,7 +1018,7 @@ function Animation.DeformTimeline.new (frameCount) local i = 1 while i <= vertexCount do local prev = prevVertices[i] - vertices[i] = vertices[i] + (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha + deform[i] = deform[i] + (prev + (nextVertices[i] - prev) * percent - deform[i]) * alpha i = i + 1 end elseif blend == MixBlend.add then @@ -1028,7 +1028,7 @@ function Animation.DeformTimeline.new (frameCount) local i = 1 while i <= vertexCount do local prev = prevVertices[i] - vertices[i] = vertices[i] + (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha + deform[i] = deform[i] + (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha i = i + 1 end else @@ -1036,7 +1036,7 @@ function Animation.DeformTimeline.new (frameCount) local i = 1 while i <= vertexCount do local prev = prevVertices[i] - vertices[i] = vertices[i] + (prev + (nextVertices[i] - prev) * percent) * alpha + deform[i] = deform[i] + (prev + (nextVertices[i] - prev) * percent) * alpha i = i + 1 end end diff --git a/spine-lua/AnimationState.lua b/spine-lua/AnimationState.lua index 59120f77d..c62d0f5b4 100644 --- a/spine-lua/AnimationState.lua +++ b/spine-lua/AnimationState.lua @@ -816,7 +816,7 @@ function AnimationState:_animationsChanged () local highestIndex = -1 for i, entry in pairs(self.tracks) do if i > highestIndex then highestIndex = i end - + if entry then while entry.mixingFrom do entry = entry.mixingFrom @@ -830,7 +830,7 @@ function AnimationState:_animationsChanged () until (entry == nil) end end - + self.propertyIDs = {} for i = highestIndex, 0, -1 do entry = self.tracks[i] @@ -846,7 +846,7 @@ function AnimationState:computeNotLast(entry) local timelinesCount = #entry.animation.timelines local timelineMode = entry.timelineMode local propertyIDs = self.propertyIDs - + local i = 1 while i <= timelinesCount do local timeline = timelines[i] diff --git a/spine-lua/MeshAttachment.lua b/spine-lua/MeshAttachment.lua index f9781dc29..a5b06eb44 100644 --- a/spine-lua/MeshAttachment.lua +++ b/spine-lua/MeshAttachment.lua @@ -79,7 +79,7 @@ x,y=slot.bone.skeleton.x,slot.bone.skeleton.y local m00, m01, m10, m11 = bone.m00, bone.m01, bone.m10, bone.m11 local vertices = self.vertices local verticesCount = #vertices - if slot.attachmentVertices and #slot.attachmentVertices == verticesCount then vertices = slot.attachmentVertices end + if slot.deform and #slot.deform == verticesCount then vertices = slot.deform end for i = 1, verticesCount, 2 do local vx = vertices[i] local vy = vertices[i + 1] diff --git a/spine-lua/Slot.lua b/spine-lua/Slot.lua index 38a0a1ce0..a78cd6e21 100644 --- a/spine-lua/Slot.lua +++ b/spine-lua/Slot.lua @@ -45,7 +45,7 @@ function Slot.new (data, bone) darkColor = nil, attachment = nil, attachmentTime = 0, - attachmentVertices = {} + deform = {} } setmetatable(self, Slot) @@ -61,7 +61,7 @@ function Slot:setAttachment (attachment) if self.attachment == attachment then return end self.attachment = attachment self.attachmentTime = self.bone.skeleton.time - self.attachmentVertices = {} + self.deform = {} end function Slot:setAttachmentTime (time) diff --git a/spine-lua/attachments/VertexAttachment.lua b/spine-lua/attachments/VertexAttachment.lua index 945d2c54f..e79a1031f 100644 --- a/spine-lua/attachments/VertexAttachment.lua +++ b/spine-lua/attachments/VertexAttachment.lua @@ -60,7 +60,7 @@ end function VertexAttachment:computeWorldVertices (slot, start, count, worldVertices, offset, stride) count = offset + (count / 2) * stride local skeleton = slot.bone.skeleton - local deformArray = slot.attachmentVertices + local deformArray = slot.deform local vertices = self.vertices local bones = self.bones if not bones then