diff --git a/spine-lua/AttachmentLoader.lua b/spine-lua/AttachmentLoader.lua index 3c93e5210..bb8f6ac9e 100644 --- a/spine-lua/AttachmentLoader.lua +++ b/spine-lua/AttachmentLoader.lua @@ -32,6 +32,8 @@ local AttachmentType = require "spine-lua.AttachmentType" local RegionAttachment = require "spine-lua.RegionAttachment" local BoundingBoxAttachment = require "spine-lua.BoundingBoxAttachment" +local MeshAttachment = require "spine-lua.MeshAttachment" +local SkinningMeshAttachment = require "spine-lua.SkinnedMeshAttachment" local AttachmentLoader = {} function AttachmentLoader.new () diff --git a/spine-lua/SkeletonJson.lua b/spine-lua/SkeletonJson.lua index f747197c4..7c8a315df 100755 --- a/spine-lua/SkeletonJson.lua +++ b/spine-lua/SkeletonJson.lua @@ -266,19 +266,21 @@ function SkeletonJson.new (attachmentLoader) return mesh elseif type == AttachmentType.skinnedmesh then - local mesh = self.attachmentLoader.newSkinnedMeshAttachment(skin, name, path) + local mesh = self.attachmentLoader.newSkinningMeshAttachment(skin, name, path) if not mesh then return null end mesh.path = path local uvs = getArray(map, "uvs", 1) - vertices = getArray(map, "vertices", 1) + local vertices = getArray(map, "vertices", 1) local weights = {} local bones = {} - for i = 1, vertices do + local i, n = 1, #vertices + while i < n do local boneCount = vertices[i] i = i + 1 table.insert(bones, boneCount) - for ii = 1, i + boneCount * 4 do + local nn = i + boneCount * 4 + while i < nn do table.insert(bones, vertices[i]) table.insert(weights, vertices[i + 1] * scale) table.insert(weights, vertices[i + 2] * scale) diff --git a/spine-lua/SkinnedMeshAttachment.lua b/spine-lua/SkinnedMeshAttachment.lua index 607a913e6..2281ce673 100644 --- a/spine-lua/SkinnedMeshAttachment.lua +++ b/spine-lua/SkinnedMeshAttachment.lua @@ -37,7 +37,7 @@ function SkinnedMeshAttachment.new (name) local self = { name = name, - type = AttachmentType.mesh, + type = AttachmentType.skinnedmesh, bones = nil, weights = nil, uvs = nil, @@ -75,15 +75,15 @@ function SkinnedMeshAttachment.new (name) end function self:computeWorldVertices (x, y, slot, worldVertices) - local skeletonBones = slot.skeleton.bones + local skeletonBones = slot.bone.skeleton.bones local weights = self.weights local bones = self.bones - local w, v, b, f = 0, 0, 0, 0 - local n = bones.length + local w, v, b, f = 1, 1, 1, 1 + local n = #bones local wx, wy, bone, vx, vy, weight - if #slot.attachmentVertices == 0 then - while v < n do + if slot.attachmentVerticesCount == 0 then + while v <= n do wx = 0 wy = 0 local nn = bones[v] + v