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

View File

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