[lua] Fixed Skin:attachAll, wrong indexing. Fixed MeshAttachment:setParentMesh, didn't set worldVerticesLength

This commit is contained in:
badlogic 2017-07-11 15:55:49 +02:00
parent f3e544319d
commit 5c71fcaaf8
2 changed files with 14 additions and 10 deletions

View File

@ -63,21 +63,24 @@ function Skin:getAttachment (slotIndex, name)
end end
function Skin:attachAll(skeleton, oldSkin) function Skin:attachAll(skeleton, oldSkin)
local slotIndex = 0
for i, slot in ipairs(skeleton.slots) do for i, slot in ipairs(skeleton.slots) do
local slotAttachment = slot.attachment local slotAttachment = slot.attachment
if slotAttachment and slotIndex <= #oldSkin.attachments then if slotAttachment then
local dictionary = oldSkin.attachments[slotIndex] local dictionary = oldSkin.attachments[i]
for key, value in dictionary do if (dictionary) then
local skinAttachment = value for key, value in pairs(dictionary) do
if slotAttachment == skinAttachment then local skinAttachment = value
local attachment = getAttachment(slotIndex, key) if slotAttachment == skinAttachment then
if attachment then slot.attachment = attachment end local attachment = self:getAttachment(i, key)
break if attachment then
print("Set attachment " .. attachment.name .. " on slot " .. slot.data.name)
slot:setAttachment(attachment)
end
break
end
end end
end end
end end
slotIndex = slotIndex + 1
end end
end end

View File

@ -103,6 +103,7 @@ function MeshAttachment:setParentMesh (parentMesh)
if parentMesh then if parentMesh then
self.bones = parentMesh.bones self.bones = parentMesh.bones
self.vertices = parentMesh.vertices self.vertices = parentMesh.vertices
self.worldVerticesLength = parentMesh.worldVerticesLength
self.regionUVs = parentMesh.regionUVs self.regionUVs = parentMesh.regionUVs
self.triangles = parentMesh.triangles self.triangles = parentMesh.triangles
self.hullLength = parentMesh.hullLength self.hullLength = parentMesh.hullLength