Merge branch '3.7-beta' into 3.7-beta-ue4-cpp

This commit is contained in:
badlogic 2018-06-07 17:32:01 +02:00
commit ff3cc660ca
37 changed files with 137 additions and 139 deletions

View File

@ -130,6 +130,9 @@ package spine.animation {
var finished : Boolean = updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
@ -141,8 +144,6 @@ package spine.animation {
return finished;
}
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale;
return false;

View File

@ -325,6 +325,9 @@ int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTr
finished = _spAnimationState_updateMixingFrom(self, from, delta);
from->animationLast = from->nextAnimationLast;
from->trackLast = from->nextTrackLast;
/* Require mixTime > 0 to ensure the mixing from entry was applied at least once. */
if (to->mixTime > 0 && (to->mixTime >= to->mixDuration || to->timeScale == 0)) {
/* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */
@ -336,8 +339,6 @@ int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTr
return finished;
}
from->animationLast = from->nextAnimationLast;
from->trackLast = from->nextTrackLast;
from->trackTime += delta * from->timeScale;
to->mixTime += delta * to->timeScale;
return 0;

View File

@ -34,7 +34,7 @@ function loadSkeleton(atlasFile, jsonFile, x, y, scale, animation, skin)
-- create an animation state object to apply animations to the skeleton
local animationStateData = spine.AnimationStateData.new(skeletonData)
animationStateData.defaultMix = 0.2
animationStateData.defaultMix = 0.5
local animationState = spine.AnimationState.new(animationStateData)
-- set the skeleton invisible

View File

@ -28,7 +28,7 @@
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
spine = {}
local spine = {}
spine.utils = require "spine-lua.utils"
spine.SkeletonJson = require "spine-lua.SkeletonJson"
@ -88,7 +88,7 @@ local QUAD_TRIANGLES = { 1, 2, 3, 3, 4, 1 }
spine.Skeleton.new_super = spine.Skeleton.new
spine.Skeleton.updateWorldTransform_super = spine.Skeleton.updateWorldTransform
spine.Skeleton.new = function(skeletonData, group)
self = spine.Skeleton.new_super(skeletonData)
local self = spine.Skeleton.new_super(skeletonData)
self.group = group or display.newGroup()
self.drawingGroup = nil
self.premultipliedAlpha = false
@ -156,7 +156,7 @@ function spine.Skeleton:updateWorldTransform()
uvs = nil
}
for i,slot in ipairs(drawOrder) do
for _,slot in ipairs(drawOrder) do
local attachment = slot.attachment
local vertices = nil
local uvs = nil

View File

@ -758,6 +758,9 @@ bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) {
bool finished = updateMixingFrom(from, delta);
from->_animationLast = from->_nextAnimationLast;
from->_trackLast = from->_nextTrackLast;
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to->_mixTime > 0 && (to->_mixTime >= to->_mixDuration || to->_timeScale == 0)) {
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
@ -769,8 +772,6 @@ bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) {
return finished;
}
from->_animationLast = from->_nextAnimationLast;
from->_trackLast = from->_nextTrackLast;
from->_trackTime += delta * from->_timeScale;
to->_mixTime += delta * to->_timeScale;

View File

@ -198,6 +198,7 @@ function TrackEntry:setTimelineData(to, mixingToArray, propertyIDs)
local timelineDipMix = self.timelineDipMix
local i = 1
local skip
while i <= timelinesCount do
local id = "" .. timelines[i]:getPropertyId()
if not (propertyIDs[id] == nil) then
@ -208,7 +209,7 @@ function TrackEntry:setTimelineData(to, mixingToArray, propertyIDs)
local ii = mixingToLast
while ii > 0 do
local entry = mixingTo[ii]
local skip = false
skip = false
if not entry:hasTimeline(id) then
if entry.mixDuration > 0 then
timelineData[i] = DIP_MIX

View File

@ -33,13 +33,13 @@ local Atlas = {}
function Atlas.parse(atlasPath, atlasBase)
local function parseIntTuple4( l )
local a,b,c,d = string.match( l , " ? ?%a+: ([+-]?%d+), ?([+-]?%d+), ?([+-]?%d+), ?([+-]?%d+)" )
local a,b,c,d = tonumber( a ), tonumber( b ), tonumber( c ), tonumber( d )
a,b,c,d = tonumber( a ), tonumber( b ), tonumber( c ), tonumber( d )
return a and b and c and d and {a, b, c ,d}
end
local function parseIntTuple2( l )
local a,b = string.match( l , " ? ?%a+: ([+-]?%d+), ?([+-]?%d+)" )
local a,b = tonumber( a ), tonumber( b )
a,b = tonumber( a ), tonumber( b )
return a and b and {a, b}
end

View File

@ -69,10 +69,6 @@ function AtlasAttachmentLoader:newMeshAttachment (skin, name, path)
return attachment
end
function AtlasAttachmentLoader:newSkinningMeshAttachment (skin, name, path)
return SkinningMeshAttachment.new(name)
end
function AtlasAttachmentLoader:newBoundingBoxAttachment (skin, name)
return BoundingBoxAttachment.new(name)
end

View File

@ -48,10 +48,6 @@ function AttachmentLoader.new ()
return MeshAttachment.new(name)
end
function self:newSkinningMeshAttachment (skin, name, path)
return SkinningMeshAttachment.new(name)
end
function self:newBoundingBoxAttachment (skin, name)
return BoundingBoxAttachment.new(name)
end

View File

@ -240,7 +240,7 @@ function Bone:getWorldScaleY ()
return math_sqrt(self.b * self.b + self.d * self.d)
end
function updateAppliedTransform ()
function Bone:updateAppliedTransform ()
local parent = self.parent
if parent == nil then
self.ax = self.worldX

View File

@ -57,7 +57,7 @@ function IkConstraint.new (data, skeleton)
setmetatable(self, IkConstraint)
local self_bones = self.bones
for i,boneData in ipairs(data.bones) do
for _,boneData in ipairs(data.bones) do
table_insert(self_bones, skeleton:findBone(boneData.name))
end
self.target = skeleton:findBone(data.target.name)

View File

@ -78,7 +78,7 @@ function PathConstraint.new (data, skeleton)
}
setmetatable(self, PathConstraint)
for i,boneData in ipairs(data.bones) do
for _,boneData in ipairs(data.bones) do
table_insert(self.bones, skeleton:findBone(boneData.name))
end
@ -244,6 +244,7 @@ function PathConstraint:computeWorldPositions (path, spacesCount, tangents, perc
local verticesLength = path.worldVerticesLength
local curveCount = verticesLength / 6
local prevCurve = PathConstraint.NONE
local i = 0
if not path.constantSpeed then
local lengths = path.lengths
@ -251,14 +252,14 @@ function PathConstraint:computeWorldPositions (path, spacesCount, tangents, perc
local pathLength = lengths[curveCount + 1];
if percentPosition then position = position * pathLength end
if percentSpacing then
local i = 0
i = 0
while i < spacesCount do
spaces[i + 1] = spaces[i + 1] * pathLength
i = i + 1
end
end
world = utils.setArraySize(self.world, 8);
local i = 0
i = 0
local o = 0
local curve = 0
while i < spacesCount do
@ -354,7 +355,6 @@ function PathConstraint:computeWorldPositions (path, spacesCount, tangents, perc
local ddfy = 0
local dfx = 0
local dfy = 0
i = 0
local w = 2
while i < curveCount do
cx1 = world[w + 1]
@ -395,7 +395,7 @@ function PathConstraint:computeWorldPositions (path, spacesCount, tangents, perc
position = position * pathLength / path.lengths[curveCount];
end
if percentSpacing then
local i = 0
i = 0
while i < spacesCount do
spaces[i + 1] = spaces[i + 1] * pathLength
i = i + 1
@ -404,7 +404,7 @@ function PathConstraint:computeWorldPositions (path, spacesCount, tangents, perc
local segments = self.segments
local curveLength = 0
local i = 0
i = 0
local o = 0
local curve = 0
local segment = 0

View File

@ -85,6 +85,7 @@ function RegionAttachment.new (name)
y = y + bone.worldY
local m00, m01, m10, m11 = bone.m00, bone.m01, bone.m10, bone.m11
local offset = self.offset
local vertices = self.vertices;
vertices[0] = offset[0] * m00 + offset[1] * m01 + x
vertices[1] = offset[0] * m10 + offset[1] * m11 + y
vertices[2] = offset[2] * m00 + offset[3] * m01 + x

View File

@ -68,7 +68,7 @@ function Skeleton.new (data)
}
setmetatable(self, Skeleton)
for i,boneData in ipairs(data.bones) do
for _,boneData in ipairs(data.bones) do
local bone = nil
if boneData.parent == nil then
bone = Bone.new(boneData, self, nil)
@ -80,7 +80,7 @@ function Skeleton.new (data)
table_insert(self.bones, bone)
end
for i,slotData in ipairs(data.slots) do
for _,slotData in ipairs(data.slots) do
local bone = self.bones[slotData.boneData.index]
local slot = Slot.new(slotData, bone)
table_insert(self.slots, slot)
@ -88,15 +88,15 @@ function Skeleton.new (data)
table_insert(self.drawOrder, slot)
end
for i,ikConstraintData in ipairs(data.ikConstraints) do
for _, ikConstraintData in ipairs(data.ikConstraints) do
table_insert(self.ikConstraints, IkConstraint.new(ikConstraintData, self))
end
for i, transformConstraintData in ipairs(data.transformConstraints) do
for _, transformConstraintData in ipairs(data.transformConstraints) do
table_insert(self.transformConstraints, TransformConstraint.new(transformConstraintData, self))
end
for i, pathConstraintData in ipairs(data.pathConstraints) do
for _, pathConstraintData in ipairs(data.pathConstraints) do
table_insert(self.pathConstraints, PathConstraint.new(pathConstraintData, self))
end
@ -113,7 +113,7 @@ function Skeleton:updateCache ()
self.updateCacheReset = {}
local bones = self.bones
for i, bone in ipairs(bones) do
for _, bone in ipairs(bones) do
bone.sorted = false
end
@ -167,7 +167,7 @@ function Skeleton:updateCache ()
i = i + 1
end
for i, bone in ipairs(self.bones) do
for _, bone in ipairs(self.bones) do
self:sortBone(bone)
end
end
@ -183,7 +183,7 @@ function Skeleton:sortIkConstraint (constraint)
if #constrained > 1 then
local child = constrained[#constrained]
local contains = false
for i,updatable in ipairs(self._updateCache) do
for _, updatable in ipairs(self._updateCache) do
if updatable == child then
contains = true
break
@ -202,11 +202,11 @@ function Skeleton:sortPathConstraint(constraint)
local slot = constraint.target
local slotIndex = slot.data.index
local slotBone = slot.bone
if self.skin then self:sortPathConstraintAttachment(skin, slotIndex, slotBone) end
if self.data.defaultSkin and not (self.data.defaultSkin == skin) then
if self.skin then self:sortPathConstraintAttachment(self.skin, slotIndex, slotBone) end
if self.data.defaultSkin and not (self.data.defaultSkin == self.skin) then
self:sortPathConstraintAttachment(self.data.defaultSkin, slotIndex, slotBone)
end
for i,skin in ipairs(self.data.skins) do
for _,skin in ipairs(self.data.skins) do
self:sortPathConstraintAttachment(skin, slotIndex, slotBone)
end
@ -214,17 +214,17 @@ function Skeleton:sortPathConstraint(constraint)
if attachment and attachment.type == AttachmentType.path then self:sortPathConstraintAttachmentWith(attachment, slotBone) end
local constrained = constraint.bones
for i,bone in ipairs(constrained) do
for _,bone in ipairs(constrained) do
self:sortBone(bone)
end
table_insert(self._updateCache, constraint)
for i,bone in ipairs(constrained) do
for _,bone in ipairs(constrained) do
self:sortReset(bone.children)
end
for i,bone in ipairs(constrained) do
for _,bone in ipairs(constrained) do
bone.sorted = true
end
end
@ -234,11 +234,11 @@ function Skeleton:sortTransformConstraint(constraint)
local constrained = constraint.bones
if constraint.data.local_ then
for i,bone in ipairs(constrained) do
for _,bone in ipairs(constrained) do
local child = constrained[#constrained]
local contains = false
sortBone(child.parent)
for i,updatable in ipairs(self._updateCache) do
self:sortBone(child.parent)
for _,updatable in ipairs(self._updateCache) do
if updatable == child then
contains = true
break
@ -247,18 +247,18 @@ function Skeleton:sortTransformConstraint(constraint)
if not contains then table_insert(self.updateCacheReset, child) end
end
else
for i,bone in ipairs(constrained) do
for _,bone in ipairs(constrained) do
self:sortBone(bone)
end
end
table_insert(self._updateCache, constraint)
for i,bone in ipairs(constrained) do
for _,bone in ipairs(constrained) do
self:sortReset(bone.children)
end
for i,bone in ipairs(constrained) do
for _,bone in ipairs(constrained) do
bone.sorted = true
end
end
@ -266,7 +266,7 @@ end
function Skeleton:sortPathConstraintAttachment(skin, slotIndex, slotBone)
local attachments = skin.attachments[slotIndex]
if not attachments then return end
for key,attachment in pairs(attachments) do
for _,attachment in pairs(attachments) do
self:sortPathConstraintAttachmentWith(attachment, slotBone)
end
end
@ -301,7 +301,7 @@ function Skeleton:sortBone(bone)
end
function Skeleton:sortReset(bones)
for i, bone in ipairs(bones) do
for _, bone in ipairs(bones) do
if bone.sorted then self:sortReset(bone.children) end
bone.sorted = false
end
@ -310,7 +310,7 @@ end
-- Updates the world transform for each bone and applies IK constraints.
function Skeleton:updateWorldTransform ()
local updateCacheReset = self.updateCacheReset
for i,bone in ipairs(updateCacheReset) do
for _,bone in ipairs(updateCacheReset) do
bone.ax = bone.x
bone.ay = bone.y
bone.arotation = bone.rotation
@ -322,7 +322,7 @@ function Skeleton:updateWorldTransform ()
end
local updateCache = self._updateCache
for i, updatable in ipairs(updateCache) do
for _, updatable in ipairs(updateCache) do
updatable:update()
end
end
@ -333,17 +333,17 @@ function Skeleton:setToSetupPose ()
end
function Skeleton:setBonesToSetupPose ()
for i,bone in ipairs(self.bones) do
for _,bone in ipairs(self.bones) do
bone:setToSetupPose()
end
for i,ikConstraint in ipairs(self.ikConstraints) do
for _,ikConstraint in ipairs(self.ikConstraints) do
ikConstraint.bendDirection = ikConstraint.data.bendDirection
ikConstraint.mix = ikConstraint.data.mix
end
local transformConstraints = self.transformConstraints
for i, constraint in ipairs(transformConstraints) do
for _, constraint in ipairs(transformConstraints) do
local data = constraint.data
constraint.rotateMix = data.rotateMix
constraint.translateMix = data.translateMix
@ -352,7 +352,7 @@ function Skeleton:setBonesToSetupPose ()
end
local pathConstraints = self.pathConstraints
for i, constraint in ipairs(pathConstraints) do
for _, constraint in ipairs(pathConstraints) do
local data = constraint.data
constraint.position = data.position
constraint.spacing = data.spacing
@ -374,7 +374,7 @@ end
function Skeleton:findBone (boneName)
if not boneName then error("boneName cannot be nil.", 2) end
for i,bone in ipairs(self.bones) do
for _,bone in ipairs(self.bones) do
if bone.data.name == boneName then return bone end
end
return nil
@ -463,8 +463,8 @@ end
function Skeleton:findIkConstraint(constraintName)
if not constraintName then error("constraintName cannot be null.", 2) end
local ikConstaints = self.ikConstraints
for i, ikConstraint in ipairs(ikConstraints) do
local ikConstraints = self.ikConstraints
for _, ikConstraint in ipairs(ikConstraints) do
if ikConstraint.data.name == constraintName then return ikConstraint end
end
return nil
@ -473,7 +473,7 @@ end
function Skeleton:findTransformConstraint(constraintName)
if not constraintName then error("constraintName cannot be null.", 2) end
local transformConstraints = self.transformConstraints
for i, transformConstraint in ipairs(transformConstraints) do
for _, transformConstraint in ipairs(transformConstraints) do
if transformConstraint.data.name == constraintName then return transformConstraint end
end
return nil
@ -482,7 +482,7 @@ end
function Skeleton:findPathConstraint(constraintName)
if not constraintName then error("constraintName cannot be null.", 2) end
local pathConstraints = self.pathConstraints
for i, pathConstraint in ipairs(pathConstraints) do
for _, pathConstraint in ipairs(pathConstraints) do
if pathConstraint.data.name == constraintName then return pathConstraint end
end
return nil
@ -496,7 +496,7 @@ function Skeleton:getBounds(offset, size)
local minY = 99999999
local maxX = -99999999
local maxY = -99999999
for i, slot in ipairs(drawOrder) do
for _, slot in ipairs(drawOrder) do
local vertices = {}
local attachment = slot.attachment
if attachment then

View File

@ -59,7 +59,7 @@ function SkeletonBounds:update (skeleton, updateAabb)
self.polygons = polygons
local slots = skeleton.slots
for i,slot in ipairs(skeleton.slots) do
for _,slot in ipairs(skeleton.slots) do
local attachment = slot.attachment
if attachment and attachment.type == AttachmentType.boundingbox then
local boundingBox = attachment
@ -85,7 +85,7 @@ end
function SkeletonBounds:aabbCompute ()
local minX, minY, maxX, maxY = 9999999, 9999999, -9999999, -9999999
local polygons = self.polygons
for i,vertices in ipairs(polygons) do
for _,vertices in ipairs(polygons) do
local count = #vertices
for ii = 1, count, 2 do
local x = vertices[ii]
@ -179,7 +179,7 @@ function SkeletonBounds:polygonIntersectsSegment (polygon, x1, y1, x2, y2)
end
function SkeletonBounds:getPolygon (attachment)
local index = spine.utils.indexOf(self.boundingBoxes, attachment)
local index = utils.indexOf(self.boundingBoxes, attachment)
if index == -1 then
return nil
else

View File

@ -66,7 +66,7 @@ function SkeletonClipping:clipStart(slot, clip)
clip:computeWorldVertices(slot, 0, n, vertices, 0, 2)
self:makeClockwise(self.clippingPolygon)
self.clippingPolygons = self.triangulator:decompose(self.clippingPolygon, self.triangulator:triangulate(self.clippingPolygon))
for i,polygon in ipairs(self.clippingPolygons) do
for _,polygon in ipairs(self.clippingPolygons) do
self:makeClockwise(polygon)
table_insert(polygon, polygon[1])
table_insert(polygon, polygon[2])
@ -274,7 +274,7 @@ function SkeletonClipping:clip(x1, y1, x2, y2, x3, y3, clippingArea, output)
end
if outputStart == #output then -- All edges outside.
for i, v in ipairs(originalOutput) do
for i, _ in ipairs(originalOutput) do
originalOutput[i] = nil
end
return true
@ -286,7 +286,7 @@ function SkeletonClipping:clip(x1, y1, x2, y2, x3, y3, clippingArea, output)
if (i == clippingVerticesLast) then break end
local temp = output
output = input
for i, v in ipairs(output) do
for i, _ in ipairs(output) do
output[i] = nil
end
input = temp
@ -294,7 +294,7 @@ function SkeletonClipping:clip(x1, y1, x2, y2, x3, y3, clippingArea, output)
end
if originalOutput ~= output then
for i, v in ipairs(originalOutput) do
for i, _ in ipairs(originalOutput) do
originalOutput[i] = nil
end
i = 1

View File

@ -56,7 +56,7 @@ end
function SkeletonData:findBone (boneName)
if not boneName then error("boneName cannot be nil.", 2) end
for i,bone in ipairs(self.bones) do
for _,bone in ipairs(self.bones) do
if bone.name == boneName then return bone end
end
return nil
@ -85,7 +85,7 @@ end
function SkeletonData:findSkin (skinName)
if not skinName then error("skinName cannot be nil.", 2) end
for i,skin in ipairs(self.skins) do
for _,skin in ipairs(self.skins) do
if skin.name == skinName then return skin end
end
return nil
@ -93,7 +93,7 @@ end
function SkeletonData:findEvent (eventName)
if not eventName then error("eventName cannot be nil.", 2) end
for i,event in ipairs(self.events) do
for _,event in ipairs(self.events) do
if event.name == eventName then return event end
end
return nil
@ -101,7 +101,7 @@ end
function SkeletonData:findAnimation (animationName)
if not animationName then error("animationName cannot be nil.", 2) end
for i,animation in ipairs(self.animations) do
for _,animation in ipairs(self.animations) do
if animation.name == animationName then return animation end
end
return nil
@ -109,7 +109,7 @@ end
function SkeletonData:findIkConstraint (constraintName)
if not constraintName then error("constraintName cannot be nil.", 2) end
for i,constraint in ipairs(self.ikConstraints) do
for _,constraint in ipairs(self.ikConstraints) do
if constraint.name == constraintName then return constraint end
end
return nil
@ -117,7 +117,7 @@ end
function SkeletonData:findTransformConstraint (constraintName)
if not constraintName then error("constraintName cannot be nil.", 2) end
for i,constraint in ipairs(self.transformConstraints) do
for _,constraint in ipairs(self.transformConstraints) do
if constraint.name == constraintName then return constraint end
end
return nil
@ -125,7 +125,7 @@ end
function SkeletonData:findPathConstraint (constraintName)
if not constraintName then error("constraintName cannot be nil.", 2) end
for i,constraint in ipairs(self.pathConstraints) do
for _,constraint in ipairs(self.pathConstraints) do
if constraint.name == constraintName then return constraint end
end
return nil

View File

@ -60,7 +60,7 @@ function SkeletonJson.new (attachmentLoader)
}
function self:readSkeletonDataFile (fileName, base)
return self:readSkeletonData(spine.utils.readFile(fileName, base))
return self:readSkeletonData(utils.readFile(fileName, base))
end
local readAttachment
@ -76,7 +76,7 @@ function SkeletonJson.new (attachmentLoader)
function self:readSkeletonData (jsonText)
local scale = self.scale
local skeletonData = SkeletonData.new(self.attachmentLoader)
local root = spine.utils.readJSON(jsonText)
local root = utils.readJSON(jsonText)
if not root then error("Invalid JSON: " .. jsonText, 2) end
-- Skeleton.
@ -117,7 +117,6 @@ function SkeletonJson.new (attachmentLoader)
-- Slots.
if root["slots"] then
for i,slotMap in ipairs(root["slots"]) do
local index = i
local slotName = slotMap["name"]
local boneName = slotMap["bone"]
local boneData = skeletonData:findBone(boneName)
@ -151,11 +150,11 @@ function SkeletonJson.new (attachmentLoader)
-- IK constraints.
if root["ik"] then
for i,constraintMap in ipairs(root["ik"]) do
for _,constraintMap in ipairs(root["ik"]) do
local data = IkConstraintData.new(constraintMap["name"])
data.order = getValue(constraintMap, "order", 0)
for i,boneName in ipairs(constraintMap["bones"]) do
for _,boneName in ipairs(constraintMap["bones"]) do
local bone = skeletonData:findBone(boneName)
if not bone then error("IK bone not found: " .. boneName) end
table_insert(data.bones, bone)
@ -174,11 +173,11 @@ function SkeletonJson.new (attachmentLoader)
-- Transform constraints
if root["transform"] then
for i,constraintMap in ipairs(root["transform"]) do
data = TransformConstraintData.new(constraintMap.name)
for _,constraintMap in ipairs(root["transform"]) do
local data = TransformConstraintData.new(constraintMap.name)
data.order = getValue(constraintMap, "order", 0)
for i,boneName in ipairs(constraintMap.bones) do
for _,boneName in ipairs(constraintMap.bones) do
local bone = skeletonData:findBone(boneName)
if not bone then error("Transform constraint bone not found: " .. boneName, 2) end
table_insert(data.bones, bone)
@ -186,7 +185,7 @@ function SkeletonJson.new (attachmentLoader)
local targetName = constraintMap.target
data.target = skeletonData:findBone(targetName)
if not data.target then error("Transform constraint target bone not found: " .. boneName, 2) end
if not data.target then error("Transform constraint target bone not found: " .. (targetName or "none"), 2) end
data.offsetRotation = getValue(constraintMap, "rotation", 0);
data.offsetX = getValue(constraintMap, "x", 0) * scale;
@ -206,11 +205,11 @@ function SkeletonJson.new (attachmentLoader)
-- Path constraints
if root["path"] then
for i,constraintMap in ipairs(root.path) do
for _,constraintMap in ipairs(root.path) do
local data = PathConstraintData.new(constraintMap.name);
data.order = getValue(constraintMap, "order", 0)
for i,boneName in ipairs(constraintMap.bones) do
for _,boneName in ipairs(constraintMap.bones) do
local bone = skeletonData:findBone(boneName)
if not bone then error("Path constraint bone not found: " .. boneName, 2) end
table_insert(data.bones, bone)
@ -254,7 +253,7 @@ function SkeletonJson.new (attachmentLoader)
end
-- Linked meshes
for i, linkedMesh in ipairs(self.linkedMeshes) do
for _, linkedMesh in ipairs(self.linkedMeshes) do
local skin = skeletonData.defaultSkin
if linkedMesh.skin then skin = skeletonData:findSkin(linkedMesh.skin) end
if not skin then error("Skin not found: " .. linkedMesh.skin) end
@ -331,7 +330,7 @@ function SkeletonJson.new (attachmentLoader)
elseif type == AttachmentType.mesh or type == AttachmentType.linkedmesh then
local mesh = attachmentLoader:newMeshAttachment(skin, name, path)
if not mesh then return null end
if not mesh then return nil end
mesh.path = path
local color = map.color
@ -487,7 +486,7 @@ function SkeletonJson.new (attachmentLoader)
timeline.slotIndex = slotIndex
local frameIndex = 0
for i,valueMap in ipairs(values) do
for _,valueMap in ipairs(values) do
local color = valueMap["color"]
timeline:setFrame(
frameIndex, valueMap["time"],
@ -506,7 +505,7 @@ function SkeletonJson.new (attachmentLoader)
timeline.slotIndex = slotIndex
local frameIndex = 0
for i,valueMap in ipairs(values) do
for _,valueMap in ipairs(values) do
local light = valueMap["light"]
local dark = valueMap["dark"]
timeline:setFrame(
@ -529,7 +528,7 @@ function SkeletonJson.new (attachmentLoader)
timeline.slotIndex = slotIndex
local frameIndex = 0
for i,valueMap in ipairs(values) do
for _,valueMap in ipairs(values) do
local attachmentName = valueMap["name"]
timeline:setFrame(frameIndex, valueMap["time"], attachmentName)
frameIndex = frameIndex + 1
@ -557,7 +556,7 @@ function SkeletonJson.new (attachmentLoader)
timeline.boneIndex = boneIndex
local frameIndex = 0
for i,valueMap in ipairs(values) do
for _,valueMap in ipairs(values) do
timeline:setFrame(frameIndex, valueMap["time"], valueMap["angle"])
readCurve(valueMap, timeline, frameIndex)
frameIndex = frameIndex + 1
@ -579,7 +578,7 @@ function SkeletonJson.new (attachmentLoader)
timeline.boneIndex = boneIndex
local frameIndex = 0
for i,valueMap in ipairs(values) do
for _,valueMap in ipairs(values) do
local x = (valueMap["x"] or 0) * timelineScale
local y = (valueMap["y"] or 0) * timelineScale
timeline:setFrame(frameIndex, valueMap["time"], x, y)
@ -608,7 +607,7 @@ function SkeletonJson.new (attachmentLoader)
end
end
local frameIndex = 0
for i,valueMap in ipairs(values) do
for _,valueMap in ipairs(values) do
local mix = 1
if valueMap["mix"] ~= nil then mix = valueMap["mix"] end
local bendPositive = 1
@ -635,7 +634,7 @@ function SkeletonJson.new (attachmentLoader)
end
end
local frameIndex = 0
for i,valueMap in ipairs(values) do
for _,valueMap in ipairs(values) do
timeline:setFrame(frameIndex, valueMap.time, getValue(valueMap, "rotateMix", 1), getValue(valueMap, "translateMix", 1), getValue(valueMap, "scaleMix", 1), getValue(valueMap, "shearMix", 1))
readCurve(valueMap, timeline, frameIndex)
frameIndex = frameIndex + 1
@ -664,7 +663,7 @@ function SkeletonJson.new (attachmentLoader)
end
timeline.pathConstraintIndex = index
local frameIndex = 0
for i,valueMap in ipairs(timelineMap) do
for _,valueMap in ipairs(timelineMap) do
timeline:setFrame(frameIndex, valueMap.time, getValue(valueMap, timelineName, 0) * timelineScale)
readCurve(valueMap, timeline, frameIndex)
frameIndex = frameIndex + 1
@ -675,7 +674,7 @@ function SkeletonJson.new (attachmentLoader)
local timeline = Animation.PathConstraintMixTimeline.new(#timelineMap)
timeline.pathConstraintIndex = index
local frameIndex = 0
for i,valueMap in ipairs(timelineMap) do
for _,valueMap in ipairs(timelineMap) do
timeline:setFrame(frameIndex, valueMap.time, getValue(valueMap, "rotateMix", 1), getValue(valueMap, "translateMix", 1))
readCurve(valueMap, timeline, frameIndex)
frameIndex = frameIndex + 1
@ -708,7 +707,7 @@ function SkeletonJson.new (attachmentLoader)
timeline.attachment = attachment
local frameIndex = 0
for i,valueMap in ipairs(timelineMap) do
for _,valueMap in ipairs(timelineMap) do
local deform = nil
local verticesValue = getValue(valueMap, "vertices", nil)
if verticesValue == nil then
@ -754,7 +753,7 @@ function SkeletonJson.new (attachmentLoader)
local timeline = Animation.DrawOrderTimeline.new(#drawOrderValues)
local slotCount = #skeletonData.slots
local frameIndex = 0
for i,drawOrderMap in ipairs(drawOrderValues) do
for _,drawOrderMap in ipairs(drawOrderValues) do
local drawOrder = nil
local offsets = drawOrderMap["offsets"]
if offsets then
@ -762,7 +761,7 @@ function SkeletonJson.new (attachmentLoader)
local unchanged = {}
local originalIndex = 1
local unchangedIndex = 1
for ii,offsetMap in ipairs(offsets) do
for _,offsetMap in ipairs(offsets) do
local slotIndex = skeletonData:findSlotIndex(offsetMap["slot"])
if slotIndex == -1 then error("Slot not found: " .. offsetMap["slot"]) end
-- Collect unchanged items.
@ -801,7 +800,7 @@ function SkeletonJson.new (attachmentLoader)
if events then
local timeline = Animation.EventTimeline.new(#events)
local frameIndex = 0
for i,eventMap in ipairs(events) do
for _,eventMap in ipairs(events) do
local eventData = skeletonData:findEvent(eventMap["name"])
if not eventData then error("Event not found: " .. eventMap["name"]) end
local event = Event.new(eventMap["time"], eventData)

View File

@ -86,14 +86,14 @@ end
function Skin:findNamesForSlot (slotIndex)
local names = {}
for k,v in self.attachments do
for _,v in self.attachments do
if v[1] == slotIndex then table_insert(names, v[2]) end
end
end
function Skin:findAttachmentsForSlot (slotIndex)
local attachments = {}
for k,v in self.attachments do
for _,v in self.attachments do
if v[1] == slotIndex then table_insert(attachments, v[3]) end
end
end

View File

@ -235,14 +235,14 @@ function TextureAtlas:parse (atlasContent, imageLoader)
end
function TextureAtlas:findRegion(name)
for i, region in ipairs(self.regions) do
for _, region in ipairs(self.regions) do
if region.name == name then return region end
end
return nil
end
function TextureAtlas:dispose()
for i, page in ipairs(self.pairs) do
for _, page in ipairs(self.pairs) do
-- FIXME implement disposing of pages
-- love2d doesn't support manual disposing
end

View File

@ -41,6 +41,7 @@ local table_insert = table.insert
local math_deg = math.deg
local math_rad = math.rad
local math_abs = math.abs
local math_floor = math.floor
local TransformConstraint = {}
TransformConstraint.__index = TransformConstraint
@ -58,7 +59,7 @@ function TransformConstraint.new (data, skeleton)
}
setmetatable(self, TransformConstraint)
for i,bone in ipairs(data.bones) do
for _,bone in ipairs(data.bones) do
table_insert(self.bones, skeleton:findBone(bone.name))
end
self.target = skeleton:findBone(data.target.name)
@ -101,7 +102,7 @@ function TransformConstraint:applyAbsoluteWorld ()
local offsetRotation = self.data.offsetRotation * degRadReflect
local offsetShearY = self.data.offsetShearY * degRadReflect
local bones = self.bones
for i, bone in ipairs(bones) do
for _, bone in ipairs(bones) do
local modified = false
if rotateMix ~= 0 then
local a = bone.a
@ -188,7 +189,7 @@ function TransformConstraint:applyRelativeWorld ()
local offsetRotation = self.data.offsetRotation * degRadReflect
local offsetShearY = self.data.offsetShearY * degRadReflect
local bones = self.bones
for i, bone in ipairs(bones) do
for _, bone in ipairs(bones) do
local modified = false
if rotateMix ~= 0 then
@ -226,7 +227,7 @@ function TransformConstraint:applyRelativeWorld ()
local s = (math_sqrt(ta * ta + tc * tc) - 1 + self.data.offsetScaleX) * scaleMix + 1
bone.a = bone.a * s
bone.c = bone.c * s
local s = (math_sqrt(tb * tb + td * td) - 1 + self.data.offsetScaleY) * scaleMix + 1
s = (math_sqrt(tb * tb + td * td) - 1 + self.data.offsetScaleY) * scaleMix + 1
bone.b = bone.b * s
bone.d = bone.d * s
modified = true
@ -260,7 +261,7 @@ function TransformConstraint:applyAbsoluteLocal ()
local target = self.target
if not target.appliedValid then target:updatedAppliedTransform() end
local bones = self.bones
for i, bone in ipairs(bones) do
for _, bone in ipairs(bones) do
local modified = false
if not bone.appliedValid then bone:updateAppliedTransform() end
@ -308,7 +309,7 @@ function TransformConstraint:applyRelativeLocal ()
local target = self.target
if not target.appliedValid then target:updateAppliedTransform() end
local bones = self.bones
for i, bone in ipairs(bones) do
for _, bone in ipairs(bones) do
if not bone.appliedValid then bone:updateAppliedTransform() end
local rotation = bone.arotation
@ -328,7 +329,7 @@ function TransformConstraint:applyRelativeLocal ()
scaleX = scaleX * (((target.ascaleX - 1 + self.data.offsetScaleX) * scaleMix) + 1)
end
if scaleY > 0.00001 then
scaleY = scaleY * (((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1)
scaleY = scaleY * (((target.ascaleY - 1 + self.data.offsetScaleY) * scaleMix) + 1)
end
end

View File

@ -1331,6 +1331,8 @@ var spine;
if (from == null)
return true;
var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom;
@ -1339,8 +1341,6 @@ var spine;
}
return finished;
}
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale;
return false;
@ -10047,7 +10047,7 @@ var spine;
else {
for (var i = 0; i < config.atlasPages.length; i++) {
if (config.atlasPagesContent && config.atlasPagesContent[i]) {
assets.loadTextureData(config.atlasPages[i], config.atlasPagesContent[0]);
assets.loadTextureData(config.atlasPages[i], config.atlasPagesContent[i]);
}
else {
assets.loadTexture(config.atlasPages[i]);

File diff suppressed because one or more lines are too long

View File

@ -1331,6 +1331,8 @@ var spine;
if (from == null)
return true;
var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom;
@ -1339,8 +1341,6 @@ var spine;
}
return finished;
}
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale;
return false;

File diff suppressed because one or more lines are too long

View File

@ -1331,6 +1331,8 @@ var spine;
if (from == null)
return true;
var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom;
@ -1339,8 +1341,6 @@ var spine;
}
return finished;
}
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale;
return false;

File diff suppressed because one or more lines are too long

View File

@ -1331,6 +1331,8 @@ var spine;
if (from == null)
return true;
var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom;
@ -1339,8 +1341,6 @@ var spine;
}
return finished;
}
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale;
return false;

File diff suppressed because one or more lines are too long

View File

@ -1331,6 +1331,8 @@ var spine;
if (from == null)
return true;
var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom;
@ -1339,8 +1341,6 @@ var spine;
}
return finished;
}
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale;
return false;

File diff suppressed because one or more lines are too long

View File

@ -1331,6 +1331,8 @@ var spine;
if (from == null)
return true;
var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom;
@ -1339,8 +1341,6 @@ var spine;
}
return finished;
}
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale;
return false;
@ -9384,7 +9384,7 @@ var spine;
else {
for (var i = 0; i < config.atlasPages.length; i++) {
if (config.atlasPagesContent && config.atlasPagesContent[i]) {
assets.loadTextureData(config.atlasPages[i], config.atlasPagesContent[0]);
assets.loadTextureData(config.atlasPages[i], config.atlasPagesContent[i]);
}
else {
assets.loadTexture(config.atlasPages[i]);

File diff suppressed because one or more lines are too long

View File

@ -114,6 +114,9 @@ module spine {
let finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
@ -125,8 +128,6 @@ module spine {
return finished;
}
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale;
return false;