Parcourir la source

[corona] Fixed clipping, closes #1522.

badlogic il y a 6 ans
Parent
commit
691c795fa0
1 fichiers modifiés avec 7 ajouts et 6 suppressions
  1. 7 6
      spine-corona/spine-corona/spine.lua

+ 7 - 6
spine-corona/spine-corona/spine.lua

@@ -163,7 +163,7 @@ function spine.Skeleton:updateWorldTransform()
 		local indices = nil
 		local indices = nil
 
 
 		if slot.bone.active then
 		if slot.bone.active then
-
+			local isClippingAttachment = false
 			if attachment then
 			if attachment then
 				if attachment.type == spine.AttachmentType.region then
 				if attachment.type == spine.AttachmentType.region then
 					numVertices = 4
 					numVertices = 4
@@ -183,6 +183,7 @@ function spine.Skeleton:updateWorldTransform()
 					blendMode = toCoronaBlendMode(slot.data.blendMode)
 					blendMode = toCoronaBlendMode(slot.data.blendMode)
 				elseif attachment.type == spine.AttachmentType.clipping then
 				elseif attachment.type == spine.AttachmentType.clipping then
 					self.clipper:clipStart(slot, attachment)
 					self.clipper:clipStart(slot, attachment)
+					isClippingAttachment = true
 				end
 				end
 
 
 				if texture and vertices and indices then
 				if texture and vertices and indices then
@@ -195,9 +196,9 @@ function spine.Skeleton:updateWorldTransform()
 					if premultipliedAlpha then multiplier = alpha end
 					if premultipliedAlpha then multiplier = alpha end
 
 
 					color:set(skeletonColor.r * slotColor.r * attachmentColor.r * multiplier,
 					color:set(skeletonColor.r * slotColor.r * attachmentColor.r * multiplier,
-						skeletonColor.g * slotColor.g * attachmentColor.g * multiplier,
-						skeletonColor.b * slotColor.b * attachmentColor.b * multiplier,
-						alpha)
+							skeletonColor.g * slotColor.g * attachmentColor.g * multiplier,
+							skeletonColor.b * slotColor.b * attachmentColor.b * multiplier,
+							alpha)
 
 
 					if not lastTexture then lastTexture = texture end
 					if not lastTexture then lastTexture = texture end
 					if lastColor.r == -1 then lastColor:setFrom(color) end
 					if lastColor.r == -1 then lastColor:setFrom(color) end
@@ -222,9 +223,9 @@ function spine.Skeleton:updateWorldTransform()
 					end
 					end
 
 
 					self:batch(vertices, uvs, numVertices, indices, groupVertices, groupUvs, groupIndices)
 					self:batch(vertices, uvs, numVertices, indices, groupVertices, groupUvs, groupIndices)
-				end
 
 
-				self.clipper:clipEnd(slot)
+				end
+				if not isClippingAttachment then self.clipper:clipEnd(slot) end
 			end
 			end
 		end
 		end
 	end
 	end