|
@@ -310,96 +310,107 @@ local tmpColor = spine.Color.newWith(0, 0, 0, 0)
|
|
local tmpColor2 = spine.Color.newWith(0, 0, 0, 0)
|
|
local tmpColor2 = spine.Color.newWith(0, 0, 0, 0)
|
|
|
|
|
|
function SkeletonRenderer:draw (skeleton)
|
|
function SkeletonRenderer:draw (skeleton)
|
|
|
|
+ local vertexEffect = self.vertexEffect
|
|
|
|
+ if (vertexEffect) then vertexEffect:beginEffect(skeleton) end
|
|
|
|
+
|
|
local batcher = self.batcher
|
|
local batcher = self.batcher
|
|
local premultipliedAlpha = self.premultipliedAlpha
|
|
local premultipliedAlpha = self.premultipliedAlpha
|
|
-
|
|
|
|
- if (self.vertexEffect) then self.vertexEffect:beginEffect(skeleton) end
|
|
|
|
|
|
+ local skeletonColor = skeleton.color
|
|
|
|
+ local color = tmpColor
|
|
|
|
+ local dark = tmpColor2
|
|
|
|
|
|
local lastLoveBlendMode = love.graphics.getBlendMode()
|
|
local lastLoveBlendMode = love.graphics.getBlendMode()
|
|
love.graphics.setBlendMode("alpha")
|
|
love.graphics.setBlendMode("alpha")
|
|
local lastBlendMode = spine.BlendMode.normal
|
|
local lastBlendMode = spine.BlendMode.normal
|
|
batcher:begin()
|
|
batcher:begin()
|
|
|
|
|
|
- local drawOrder = skeleton.drawOrder
|
|
|
|
- for i, slot in ipairs(drawOrder) do
|
|
|
|
- if slot.bone.active then
|
|
|
|
- local attachment = slot.attachment
|
|
|
|
|
|
+ for i, slot in ipairs(skeleton.drawOrder) do repeat
|
|
|
|
+ if not slot.bone.active then
|
|
|
|
+ self.clipper:clipEnd(slot)
|
|
|
|
+ break -- continues for loop
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ local attachment = slot.attachment
|
|
|
|
+ if attachment then
|
|
local vertices = worldVertices
|
|
local vertices = worldVertices
|
|
- local uvs = nil
|
|
|
|
- local indices = nil
|
|
|
|
- local texture = nil
|
|
|
|
- local color = tmpColor
|
|
|
|
- if attachment then
|
|
|
|
- if attachment.type == spine.AttachmentType.region then
|
|
|
|
- numVertices = 4
|
|
|
|
- attachment:computeWorldVertices(slot.bone, vertices, 0, 2)
|
|
|
|
- uvs = attachment.uvs
|
|
|
|
- indices = SkeletonRenderer.QUAD_TRIANGLES
|
|
|
|
- texture = attachment.region.renderObject.texture
|
|
|
|
- elseif attachment.type == spine.AttachmentType.mesh then
|
|
|
|
- numVertices = attachment.worldVerticesLength / 2
|
|
|
|
- attachment:computeWorldVertices(slot, 0, attachment.worldVerticesLength, vertices, 0, 2)
|
|
|
|
- uvs = attachment.uvs
|
|
|
|
- indices = attachment.triangles
|
|
|
|
- texture = attachment.region.renderObject.texture
|
|
|
|
- elseif attachment.type == spine.AttachmentType.clipping then
|
|
|
|
- self.clipper:clipStart(slot, attachment)
|
|
|
|
- end
|
|
|
|
|
|
+ local vertexCount
|
|
|
|
+ local uvs
|
|
|
|
+ local indices
|
|
|
|
+ local texture
|
|
|
|
+ if attachment.type == spine.AttachmentType.region then
|
|
|
|
+ vertexCount = 4
|
|
|
|
+ attachment:computeWorldVertices(slot.bone, vertices, 0, 2)
|
|
|
|
+ uvs = attachment.uvs
|
|
|
|
+ indices = SkeletonRenderer.QUAD_TRIANGLES
|
|
|
|
+ texture = attachment.region.renderObject.texture
|
|
|
|
+ elseif attachment.type == spine.AttachmentType.mesh then
|
|
|
|
+ vertexCount = attachment.worldVerticesLength / 2
|
|
|
|
+ attachment:computeWorldVertices(slot, 0, attachment.worldVerticesLength, vertices, 0, 2)
|
|
|
|
+ uvs = attachment.uvs
|
|
|
|
+ indices = attachment.triangles
|
|
|
|
+ texture = attachment.region.renderObject.texture
|
|
|
|
+ elseif attachment.type == spine.AttachmentType.clipping then
|
|
|
|
+ self.clipper:clipStart(slot, attachment)
|
|
|
|
+ break -- continues for loop
|
|
|
|
+ end
|
|
|
|
|
|
- if texture then
|
|
|
|
- local slotBlendMode = slot.data.blendMode
|
|
|
|
- if lastBlendMode ~= slotBlendMode then
|
|
|
|
- batcher:stop()
|
|
|
|
- batcher:begin()
|
|
|
|
-
|
|
|
|
- if slotBlendMode == spine.BlendMode.normal then
|
|
|
|
- love.graphics.setBlendMode("alpha")
|
|
|
|
- elseif slotBlendMode == spine.BlendMode.additive then
|
|
|
|
- love.graphics.setBlendMode("add")
|
|
|
|
- elseif slotBlendMode == spine.BlendMode.multiply then
|
|
|
|
- love.graphics.setBlendMode("multiply", "premultiplied")
|
|
|
|
- elseif slotBlendMode == spine.BlendMode.screen then
|
|
|
|
- love.graphics.setBlendMode("screen")
|
|
|
|
- end
|
|
|
|
- lastBlendMode = slotBlendMode
|
|
|
|
|
|
+ if texture then
|
|
|
|
+ local slotBlendMode = slot.data.blendMode
|
|
|
|
+ if lastBlendMode ~= slotBlendMode then
|
|
|
|
+ batcher:stop()
|
|
|
|
+ batcher:begin()
|
|
|
|
+
|
|
|
|
+ if slotBlendMode == spine.BlendMode.normal then
|
|
|
|
+ love.graphics.setBlendMode("alpha")
|
|
|
|
+ elseif slotBlendMode == spine.BlendMode.additive then
|
|
|
|
+ love.graphics.setBlendMode("add")
|
|
|
|
+ elseif slotBlendMode == spine.BlendMode.multiply then
|
|
|
|
+ love.graphics.setBlendMode("multiply", "premultiplied")
|
|
|
|
+ elseif slotBlendMode == spine.BlendMode.screen then
|
|
|
|
+ love.graphics.setBlendMode("screen")
|
|
end
|
|
end
|
|
|
|
+ lastBlendMode = slotBlendMode
|
|
|
|
+ end
|
|
|
|
|
|
- local skeleton = slot.bone.skeleton
|
|
|
|
- local skeletonColor = skeleton.color
|
|
|
|
- local slotColor = slot.color
|
|
|
|
- local attachmentColor = attachment.color
|
|
|
|
- local alpha = skeletonColor.a * slotColor.a * attachmentColor.a
|
|
|
|
- local multiplier = alpha
|
|
|
|
- if premultipliedAlpha then multiplier = 1 end
|
|
|
|
- color:set(skeletonColor.r * slotColor.r * attachmentColor.r * multiplier,
|
|
|
|
- skeletonColor.g * slotColor.g * attachmentColor.g * multiplier,
|
|
|
|
- skeletonColor.b * slotColor.b * attachmentColor.b * multiplier,
|
|
|
|
- alpha)
|
|
|
|
-
|
|
|
|
- local dark = tmpColor2
|
|
|
|
- if slot.darkColor then dark = slot.darkColor
|
|
|
|
- else dark:set(0, 0, 0, 0) end
|
|
|
|
-
|
|
|
|
- if self.clipper:isClipping() then
|
|
|
|
- self.clipper:clipTriangles(vertices, attachment.uvs, indices, #indices)
|
|
|
|
- vertices = self.clipper.clippedVertices
|
|
|
|
- numVertices = #vertices / 2
|
|
|
|
- uvs = self.clipper.clippedUVs
|
|
|
|
- indices = self.clipper.clippedTriangles
|
|
|
|
- end
|
|
|
|
|
|
+ local slotColor = slot.color
|
|
|
|
+ local attachmentColor = attachment.color
|
|
|
|
+ local alpha = skeletonColor.a * slotColor.a * attachmentColor.a
|
|
|
|
+ local multiplier
|
|
|
|
+ if premultipliedAlpha then
|
|
|
|
+ multiplier = 1
|
|
|
|
+ else
|
|
|
|
+ multiplier = alpha
|
|
|
|
+ end
|
|
|
|
+ color:set(skeletonColor.r * slotColor.r * attachmentColor.r * multiplier,
|
|
|
|
+ skeletonColor.g * slotColor.g * attachmentColor.g * multiplier,
|
|
|
|
+ skeletonColor.b * slotColor.b * attachmentColor.b * multiplier,
|
|
|
|
+ alpha)
|
|
|
|
+
|
|
|
|
+ if slot.darkColor then
|
|
|
|
+ dark = slot.darkColor
|
|
|
|
+ else
|
|
|
|
+ dark:set(0, 0, 0, 0)
|
|
|
|
+ end
|
|
|
|
|
|
- batcher:draw(texture, vertices, uvs, numVertices, indices, color, dark, self.vertexEffect)
|
|
|
|
|
|
+ if self.clipper:isClipping() then
|
|
|
|
+ self.clipper:clipTriangles(vertices, attachment.uvs, indices, #indices)
|
|
|
|
+ vertices = self.clipper.clippedVertices
|
|
|
|
+ vertexCount = #vertices / 2
|
|
|
|
+ uvs = self.clipper.clippedUVs
|
|
|
|
+ indices = self.clipper.clippedTriangles
|
|
end
|
|
end
|
|
|
|
|
|
- self.clipper:clipEnd(slot)
|
|
|
|
|
|
+ batcher:draw(texture, vertices, uvs, vertexCount, indices, color, dark, vertexEffect)
|
|
end
|
|
end
|
|
|
|
+
|
|
|
|
+ self.clipper:clipEnd(slot)
|
|
end
|
|
end
|
|
- end
|
|
|
|
|
|
+ until true end
|
|
|
|
|
|
batcher:stop()
|
|
batcher:stop()
|
|
love.graphics.setBlendMode(lastLoveBlendMode)
|
|
love.graphics.setBlendMode(lastLoveBlendMode)
|
|
self.clipper:clipEnd2()
|
|
self.clipper:clipEnd2()
|
|
- if (self.vertexEffect) then self.vertexEffect:endEffect(skeleton) end
|
|
|
|
|
|
+ if (vertexEffect) then vertexEffect:endEffect(skeleton) end
|
|
end
|
|
end
|
|
|
|
|
|
spine.PolygonBatcher = PolygonBatcher
|
|
spine.PolygonBatcher = PolygonBatcher
|