mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 16:26:40 +08:00
Added requires in attachment loader
Minor fixes for off-by-one indexing and loop counts for skinned meshes Some fixes for names or counts, again for skinned meshes
This commit is contained in:
parent
f018d2451a
commit
aaa0c1f25d
@ -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 ()
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user