Explorar el Código

[lua] Renamed attachmentVertices to deform, see #1303.

badlogic hace 6 años
padre
commit
e87610277a

+ 26 - 26
spine-lua/Animation.lua

@@ -826,8 +826,8 @@ function Animation.DeformTimeline.new (frameCount)
 		if not slotAttachment:applyDeform(self.attachment) then return end
 		if not slotAttachment:applyDeform(self.attachment) then return end
 
 
 		local frames = self.frames
 		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 frameVertices = self.frameVertices
 		local vertexCount = #(frameVertices[0])		
 		local vertexCount = #(frameVertices[0])		
@@ -835,27 +835,27 @@ function Animation.DeformTimeline.new (frameCount)
 		if time < frames[0] then
 		if time < frames[0] then
 			local vertexAttachment = slotAttachment;
 			local vertexAttachment = slotAttachment;
 			if blend == MixBlend.setup then
 			if blend == MixBlend.setup then
-        slot.attachmentVertices = {}
+        slot.deform = {}
         return;
         return;
 			elseif blend == MixBlend.first then
 			elseif blend == MixBlend.first then
         if (alpha == 1) then
         if (alpha == 1) then
-          slot.attachmentVertices = {}
+          slot.deform = {}
           return;
           return;
         end
         end
 
 
-        local vertices = utils.setArraySize(verticesArray, vertexCount)
+        local deform = utils.setArraySize(deformArray, vertexCount)
         if (vertexAttachment.bones == nil) then
         if (vertexAttachment.bones == nil) then
           local setupVertices = vertexAttachment.vertices
           local setupVertices = vertexAttachment.vertices
           local i = 1
           local i = 1
           while i <= vertexCount do
           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
             i = i + 1
           end
           end
         else
         else
           alpha = 1 - alpha
           alpha = 1 - alpha
           local i = 1
           local i = 1
           while i <= vertexCount do
           while i <= vertexCount do
-            vertices[i] = vertices[i] * alpha
+            deform[i] = deform[i] * alpha
             i = i + 1
             i = i + 1
           end
           end
         end
         end
@@ -863,7 +863,7 @@ function Animation.DeformTimeline.new (frameCount)
 			return
 			return
 		end
 		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.
 		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
@@ -874,21 +874,21 @@ function Animation.DeformTimeline.new (frameCount)
 						local setupVertices = vertexAttachment.vertices
 						local setupVertices = vertexAttachment.vertices
 						local i = 1
 						local i = 1
 						while i <= vertexCount do
 						while i <= vertexCount do
-							vertices[i] = vertices[i] + lastVertices[i] - setupVertices[i]
+							deform[i] = deform[i] + lastVertices[i] - setupVertices[i]
 							i = i + 1
 							i = i + 1
 						end
 						end
 					else
 					else
 						-- Weighted deform offsets, with alpha.
 						-- Weighted deform offsets, with alpha.
 						local i = 1
 						local i = 1
 						while i <= vertexCount do
 						while i <= vertexCount do
-							vertices[i] = vertices[i] + lastVertices[i]
+							deform[i] = deform[i] + lastVertices[i]
 							i = i + 1
 							i = i + 1
 						end
 						end
 					end
 					end
 				else
 				else
 					local i = 1
 					local i = 1
 					while i <= vertexCount do
 					while i <= vertexCount do
-						vertices[i] = lastVertices[i]
+						deform[i] = lastVertices[i]
 						i = i + 1
 						i = i + 1
 					end
 					end
 				end
 				end
@@ -901,21 +901,21 @@ function Animation.DeformTimeline.new (frameCount)
 						local i = 1
 						local i = 1
 						while i <= vertexCount do
 						while i <= vertexCount do
 							local setup = setupVertices[i]
 							local setup = setupVertices[i]
-							vertices[i] = setup + (lastVertices[i] - setup) * alpha
+							deform[i] = setup + (lastVertices[i] - setup) * alpha
 							i = i + 1
 							i = i + 1
 						end
 						end
 					else
 					else
 						-- Weighted deform offsets, with alpha.
 						-- Weighted deform offsets, with alpha.
 						local i = 1
 						local i = 1
 						while i <= vertexCount do
 						while i <= vertexCount do
-							vertices[i] = lastVertices[i] * alpha
+							deform[i] = lastVertices[i] * alpha
 							i = i + 1
 							i = i + 1
 						end
 						end
 					end
 					end
 				elseif blend == MixBlend.first or blend == MixBlend.replace then
 				elseif blend == MixBlend.first or blend == MixBlend.replace then
 					local i = 1
 					local i = 1
 					while i <= vertexCount do
 					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
 						i = i + 1
 					end
 					end
 					local vertexAttachment = slotAttachment
 					local vertexAttachment = slotAttachment
@@ -923,14 +923,14 @@ function Animation.DeformTimeline.new (frameCount)
 						local setupVertices = vertexAttachment.vertices
 						local setupVertices = vertexAttachment.vertices
 						local i = 1
 						local i = 1
 						while i <= vertexCount do
 						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
 							i = i + 1
 						end
 						end
 					else
 					else
 						-- Weighted deform offsets, with alpha.
 						-- Weighted deform offsets, with alpha.
 						local i = 1
 						local i = 1
 						while i <= vertexCount do
 						while i <= vertexCount do
-							vertices[i] = vertices[i] + lastVertices[i] * alpha
+							deform[i] = deform[i] + lastVertices[i] * alpha
 							i = i + 1
 							i = i + 1
 						end
 						end
 					end
 					end
@@ -940,14 +940,14 @@ function Animation.DeformTimeline.new (frameCount)
 						local setupVertices = vertexAttachment.vertices
 						local setupVertices = vertexAttachment.vertices
 						local i = 1
 						local i = 1
 						while i <= vertexCount do
 						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
 							i = i + 1
 						end
 						end
 					else
 					else
 						-- Weighted deform offsets, with alpha.
 						-- Weighted deform offsets, with alpha.
 						local i = 1
 						local i = 1
 						while i <= vertexCount do
 						while i <= vertexCount do
-							vertices[i] = vertices[i] + lastVertices[i] * alpha
+							deform[i] = deform[i] + lastVertices[i] * alpha
 							i = i + 1
 							i = i + 1
 						end
 						end
 					end
 					end
@@ -972,7 +972,7 @@ function Animation.DeformTimeline.new (frameCount)
 					local i = 1
 					local i = 1
 					while i <= vertexCount do
 					while i <= vertexCount do
 						local prev = prevVertices[i]
 						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
 						i = i + 1
 					end
 					end
 				else
 				else
@@ -980,7 +980,7 @@ function Animation.DeformTimeline.new (frameCount)
 					local i = 1
 					local i = 1
 					while i <= vertexCount do
 					while i <= vertexCount do
 						local prev = prevVertices[i]
 						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
 						i = i + 1
 					end
 					end
 				end
 				end
@@ -988,7 +988,7 @@ function Animation.DeformTimeline.new (frameCount)
 				local i = 1
 				local i = 1
 				while i <= vertexCount do
 				while i <= vertexCount do
 					local prev = prevVertices[i]
 					local prev = prevVertices[i]
-					vertices[i] = prev + (nextVertices[i] - prev) * percent
+					deform[i] = prev + (nextVertices[i] - prev) * percent
 					i = i + 1
 					i = i + 1
 				end
 				end
 			end
 			end
@@ -1002,7 +1002,7 @@ function Animation.DeformTimeline.new (frameCount)
 					while i <= vertexCount do
 					while i <= vertexCount do
 						local prev = prevVertices[i]
 						local prev = prevVertices[i]
 						local setup = setupVertices[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
 						i = i + 1
 					end
 					end
 				else
 				else
@@ -1010,7 +1010,7 @@ function Animation.DeformTimeline.new (frameCount)
 					local i = 1
 					local i = 1
 					while i <= vertexCount do
 					while i <= vertexCount do
 						local prev = prevVertices[i]
 						local prev = prevVertices[i]
-						vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha
+						deform[i] = (prev + (nextVertices[i] - prev) * percent) * alpha
 						i = i + 1
 						i = i + 1
 					end
 					end
 				end
 				end
@@ -1018,7 +1018,7 @@ function Animation.DeformTimeline.new (frameCount)
 				local i = 1
 				local i = 1
 				while i <= vertexCount do
 				while i <= vertexCount do
 					local prev = prevVertices[i]
 					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
 					i = i + 1
 				end
 				end
 			elseif blend == MixBlend.add then
 			elseif blend == MixBlend.add then
@@ -1028,7 +1028,7 @@ function Animation.DeformTimeline.new (frameCount)
 					local i = 1
 					local i = 1
 					while i <= vertexCount do
 					while i <= vertexCount do
 						local prev = prevVertices[i]
 						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
 						i = i + 1
 					end
 					end
 				else
 				else
@@ -1036,7 +1036,7 @@ function Animation.DeformTimeline.new (frameCount)
 					local i = 1
 					local i = 1
 					while i <= vertexCount do
 					while i <= vertexCount do
 						local prev = prevVertices[i]
 						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
 						i = i + 1
 					end
 					end
 				end
 				end

+ 3 - 3
spine-lua/AnimationState.lua

@@ -816,7 +816,7 @@ function AnimationState:_animationsChanged ()
 	local highestIndex = -1
 	local highestIndex = -1
 	for i, entry in pairs(self.tracks) do
 	for i, entry in pairs(self.tracks) do
 		if i > highestIndex then highestIndex = i end
 		if i > highestIndex then highestIndex = i end
-		
+
 		if entry then
 		if entry then
 			while entry.mixingFrom do
 			while entry.mixingFrom do
 				entry = entry.mixingFrom
 				entry = entry.mixingFrom
@@ -830,7 +830,7 @@ function AnimationState:_animationsChanged ()
 			until (entry == nil)
 			until (entry == nil)
 		end
 		end
 	end
 	end
-	
+
 	self.propertyIDs = {}
 	self.propertyIDs = {}
 	for i = highestIndex, 0, -1 do
 	for i = highestIndex, 0, -1 do
 		entry = self.tracks[i]
 		entry = self.tracks[i]
@@ -846,7 +846,7 @@ function AnimationState:computeNotLast(entry)
 	local timelinesCount = #entry.animation.timelines
 	local timelinesCount = #entry.animation.timelines
 	local timelineMode = entry.timelineMode
 	local timelineMode = entry.timelineMode
 	local propertyIDs = self.propertyIDs
 	local propertyIDs = self.propertyIDs
-	
+ 
 	local i = 1
 	local i = 1
 	while i <= timelinesCount do
 	while i <= timelinesCount do
 		local timeline = timelines[i]
 		local timeline = timelines[i]

+ 1 - 1
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 m00, m01, m10, m11 = bone.m00, bone.m01, bone.m10, bone.m11
 		local vertices = self.vertices
 		local vertices = self.vertices
 		local verticesCount = #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
 		for i = 1, verticesCount, 2 do
 			local vx = vertices[i]
 			local vx = vertices[i]
 			local vy = vertices[i + 1]
 			local vy = vertices[i + 1]

+ 2 - 2
spine-lua/Slot.lua

@@ -45,7 +45,7 @@ function Slot.new (data, bone)
 		darkColor = nil,
 		darkColor = nil,
 		attachment = nil,
 		attachment = nil,
 		attachmentTime = 0,
 		attachmentTime = 0,
-		attachmentVertices = {}
+		deform = {}
 	}	
 	}	
 
 
 	setmetatable(self, Slot)
 	setmetatable(self, Slot)
@@ -61,7 +61,7 @@ function Slot:setAttachment (attachment)
 	if self.attachment == attachment then return end
 	if self.attachment == attachment then return end
 	self.attachment = attachment
 	self.attachment = attachment
 	self.attachmentTime = self.bone.skeleton.time
 	self.attachmentTime = self.bone.skeleton.time
-	self.attachmentVertices = {}
+	self.deform = {}
 end
 end
 
 
 function Slot:setAttachmentTime (time)
 function Slot:setAttachmentTime (time)

+ 1 - 1
spine-lua/attachments/VertexAttachment.lua

@@ -60,7 +60,7 @@ 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.attachmentVertices
+	local deformArray = 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