mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-01 05:09:07 +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 AttachmentType = require "spine-lua.AttachmentType"
|
||||||
local RegionAttachment = require "spine-lua.RegionAttachment"
|
local RegionAttachment = require "spine-lua.RegionAttachment"
|
||||||
local BoundingBoxAttachment = require "spine-lua.BoundingBoxAttachment"
|
local BoundingBoxAttachment = require "spine-lua.BoundingBoxAttachment"
|
||||||
|
local MeshAttachment = require "spine-lua.MeshAttachment"
|
||||||
|
local SkinningMeshAttachment = require "spine-lua.SkinnedMeshAttachment"
|
||||||
|
|
||||||
local AttachmentLoader = {}
|
local AttachmentLoader = {}
|
||||||
function AttachmentLoader.new ()
|
function AttachmentLoader.new ()
|
||||||
|
|||||||
@ -266,19 +266,21 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
return mesh
|
return mesh
|
||||||
|
|
||||||
elseif type == AttachmentType.skinnedmesh then
|
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
|
if not mesh then return null end
|
||||||
mesh.path = path
|
mesh.path = path
|
||||||
|
|
||||||
local uvs = getArray(map, "uvs", 1)
|
local uvs = getArray(map, "uvs", 1)
|
||||||
vertices = getArray(map, "vertices", 1)
|
local vertices = getArray(map, "vertices", 1)
|
||||||
local weights = {}
|
local weights = {}
|
||||||
local bones = {}
|
local bones = {}
|
||||||
for i = 1, vertices do
|
local i, n = 1, #vertices
|
||||||
|
while i < n do
|
||||||
local boneCount = vertices[i]
|
local boneCount = vertices[i]
|
||||||
i = i + 1
|
i = i + 1
|
||||||
table.insert(bones, boneCount)
|
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(bones, vertices[i])
|
||||||
table.insert(weights, vertices[i + 1] * scale)
|
table.insert(weights, vertices[i + 1] * scale)
|
||||||
table.insert(weights, vertices[i + 2] * scale)
|
table.insert(weights, vertices[i + 2] * scale)
|
||||||
|
|||||||
@ -37,7 +37,7 @@ function SkinnedMeshAttachment.new (name)
|
|||||||
|
|
||||||
local self = {
|
local self = {
|
||||||
name = name,
|
name = name,
|
||||||
type = AttachmentType.mesh,
|
type = AttachmentType.skinnedmesh,
|
||||||
bones = nil,
|
bones = nil,
|
||||||
weights = nil,
|
weights = nil,
|
||||||
uvs = nil,
|
uvs = nil,
|
||||||
@ -75,15 +75,15 @@ function SkinnedMeshAttachment.new (name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self:computeWorldVertices (x, y, slot, worldVertices)
|
function self:computeWorldVertices (x, y, slot, worldVertices)
|
||||||
local skeletonBones = slot.skeleton.bones
|
local skeletonBones = slot.bone.skeleton.bones
|
||||||
local weights = self.weights
|
local weights = self.weights
|
||||||
local bones = self.bones
|
local bones = self.bones
|
||||||
|
|
||||||
local w, v, b, f = 0, 0, 0, 0
|
local w, v, b, f = 1, 1, 1, 1
|
||||||
local n = bones.length
|
local n = #bones
|
||||||
local wx, wy, bone, vx, vy, weight
|
local wx, wy, bone, vx, vy, weight
|
||||||
if #slot.attachmentVertices == 0 then
|
if slot.attachmentVerticesCount == 0 then
|
||||||
while v < n do
|
while v <= n do
|
||||||
wx = 0
|
wx = 0
|
||||||
wy = 0
|
wy = 0
|
||||||
local nn = bones[v] + v
|
local nn = bones[v] + v
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user