mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-05 10:16:54 +08:00
[lua] IkConstraintTimeline.STRETCH was incorrect, resulting in ik timeline mixes not being properly set. Closes #1353.
This commit is contained in:
parent
e8eb894304
commit
4d2e813967
@ -278,7 +278,7 @@ function Animation.RotateTimeline.new (frameCount)
|
|||||||
r = r - (16384 - math_floor(16384.499999999996 - r / 360)) * 360 -- Wrap within -180 and 180.
|
r = r - (16384 - math_floor(16384.499999999996 - r / 360)) * 360 -- Wrap within -180 and 180.
|
||||||
bone.rotation = bone.rotation + r * alpha;
|
bone.rotation = bone.rotation + r * alpha;
|
||||||
elseif blend == MixBlend.add then
|
elseif blend == MixBlend.add then
|
||||||
bone.rotation = bone.rotation + r * alpha;
|
bone.rotation = bone.rotation + r * alpha;
|
||||||
end
|
end
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
@ -318,7 +318,7 @@ function Animation.TranslateTimeline.new (frameCount)
|
|||||||
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
||||||
self.boneIndex = -1
|
self.boneIndex = -1
|
||||||
self.type = TimelineType.translate
|
self.type = TimelineType.translate
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.translate * SHL_24 + self.boneIndex
|
return TimelineType.translate * SHL_24 + self.boneIndex
|
||||||
end
|
end
|
||||||
@ -334,7 +334,7 @@ function Animation.TranslateTimeline.new (frameCount)
|
|||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
|
|
||||||
local bone = skeleton.bones[self.boneIndex]
|
local bone = skeleton.bones[self.boneIndex]
|
||||||
if time < frames[0] then
|
if time < frames[0] then
|
||||||
if blend == MixBlend.setup then
|
if blend == MixBlend.setup then
|
||||||
bone.x = bone.data.x
|
bone.x = bone.data.x
|
||||||
bone.y = bone.data.y
|
bone.y = bone.data.y
|
||||||
@ -389,7 +389,7 @@ function Animation.ScaleTimeline.new (frameCount)
|
|||||||
|
|
||||||
local self = Animation.TranslateTimeline.new(frameCount)
|
local self = Animation.TranslateTimeline.new(frameCount)
|
||||||
self.type = TimelineType.scale
|
self.type = TimelineType.scale
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.scale * SHL_24 + self.boneIndex
|
return TimelineType.scale * SHL_24 + self.boneIndex
|
||||||
end
|
end
|
||||||
@ -437,7 +437,7 @@ function Animation.ScaleTimeline.new (frameCount)
|
|||||||
else
|
else
|
||||||
local bx = 0
|
local bx = 0
|
||||||
local by = 0
|
local by = 0
|
||||||
if direction == MixDirection.out then
|
if direction == MixDirection.out then
|
||||||
if blend == MixBlend.setup then
|
if blend == MixBlend.setup then
|
||||||
bx = bone.data.scaleX
|
bx = bone.data.scaleX
|
||||||
by = bone.data.scaleY
|
by = bone.data.scaleY
|
||||||
@ -490,7 +490,7 @@ function Animation.ShearTimeline.new (frameCount)
|
|||||||
|
|
||||||
local self = Animation.TranslateTimeline.new(frameCount)
|
local self = Animation.TranslateTimeline.new(frameCount)
|
||||||
self.type = TimelineType.shear
|
self.type = TimelineType.shear
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.shear * SHL_24 + self.boneIndex
|
return TimelineType.shear * SHL_24 + self.boneIndex
|
||||||
end
|
end
|
||||||
@ -560,7 +560,7 @@ function Animation.ColorTimeline.new (frameCount)
|
|||||||
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
||||||
self.slotIndex = -1
|
self.slotIndex = -1
|
||||||
self.type = TimelineType.color
|
self.type = TimelineType.color
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.color * SHL_24 + self.slotIndex
|
return TimelineType.color * SHL_24 + self.slotIndex
|
||||||
end
|
end
|
||||||
@ -577,7 +577,7 @@ function Animation.ColorTimeline.new (frameCount)
|
|||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, blend, direction)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, blend, direction)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
local slot = skeleton.slots[self.slotIndex]
|
local slot = skeleton.slots[self.slotIndex]
|
||||||
if time < frames[0] then
|
if time < frames[0] then
|
||||||
if blend == MixBlend.setup then
|
if blend == MixBlend.setup then
|
||||||
slot.color:setFrom(slot.data.color)
|
slot.color:setFrom(slot.data.color)
|
||||||
elseif blend == MixBlend.first then
|
elseif blend == MixBlend.first then
|
||||||
@ -648,7 +648,7 @@ function Animation.TwoColorTimeline.new (frameCount)
|
|||||||
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
||||||
self.slotIndex = -1
|
self.slotIndex = -1
|
||||||
self.type = TimelineType.twoColor
|
self.type = TimelineType.twoColor
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.twoColor * SHL_24 + self.slotIndex
|
return TimelineType.twoColor * SHL_24 + self.slotIndex
|
||||||
end
|
end
|
||||||
@ -668,7 +668,7 @@ function Animation.TwoColorTimeline.new (frameCount)
|
|||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, blend, direction)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, blend, direction)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
local slot = skeleton.slots[self.slotIndex]
|
local slot = skeleton.slots[self.slotIndex]
|
||||||
if time < frames[0] then
|
if time < frames[0] then
|
||||||
if blend == MixBlend.setup then
|
if blend == MixBlend.setup then
|
||||||
slot.color:setFrom(slot.data.color)
|
slot.color:setFrom(slot.data.color)
|
||||||
slot.darkColor:setFrom(slot.data.darkColor)
|
slot.darkColor:setFrom(slot.data.darkColor)
|
||||||
@ -722,7 +722,7 @@ function Animation.TwoColorTimeline.new (frameCount)
|
|||||||
else
|
else
|
||||||
local light = slot.color
|
local light = slot.color
|
||||||
local dark = slot.darkColor
|
local dark = slot.darkColor
|
||||||
if blend == MixBlend.setup then
|
if blend == MixBlend.setup then
|
||||||
light:setFrom(slot.data.color)
|
light:setFrom(slot.data.color)
|
||||||
dark:setFrom(slot.data.darkColor)
|
dark:setFrom(slot.data.darkColor)
|
||||||
end
|
end
|
||||||
@ -751,7 +751,7 @@ function Animation.AttachmentTimeline.new (frameCount)
|
|||||||
self.frames[frameIndex] = time
|
self.frames[frameIndex] = time
|
||||||
self.attachmentNames[frameIndex] = attachmentName
|
self.attachmentNames[frameIndex] = attachmentName
|
||||||
end
|
end
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.attachment * SHL_24 + self.slotIndex
|
return TimelineType.attachment * SHL_24 + self.slotIndex
|
||||||
end
|
end
|
||||||
@ -768,9 +768,9 @@ function Animation.AttachmentTimeline.new (frameCount)
|
|||||||
end
|
end
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then
|
if time < frames[0] then
|
||||||
if blend == MixBlend.setup or blend == MixBlend.first then
|
if blend == MixBlend.setup or blend == MixBlend.first then
|
||||||
attachmentName = slot.data.attachmentName
|
attachmentName = slot.data.attachmentName
|
||||||
if not attachmentName then
|
if not attachmentName then
|
||||||
@ -830,8 +830,8 @@ function Animation.DeformTimeline.new (frameCount)
|
|||||||
if #(verticesArray) == 0 then blend = MixBlend.setup end
|
if #(verticesArray) == 0 then blend = MixBlend.setup end
|
||||||
|
|
||||||
local frameVertices = self.frameVertices
|
local frameVertices = self.frameVertices
|
||||||
local vertexCount = #(frameVertices[0])
|
local vertexCount = #(frameVertices[0])
|
||||||
|
|
||||||
if time < frames[0] then
|
if time < frames[0] then
|
||||||
local vertexAttachment = slotAttachment;
|
local vertexAttachment = slotAttachment;
|
||||||
if blend == MixBlend.setup then
|
if blend == MixBlend.setup then
|
||||||
@ -1054,7 +1054,7 @@ function Animation.EventTimeline.new (frameCount)
|
|||||||
events = {},
|
events = {},
|
||||||
type = TimelineType.event
|
type = TimelineType.event
|
||||||
}
|
}
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.event * SHL_24
|
return TimelineType.event * SHL_24
|
||||||
end
|
end
|
||||||
@ -1111,7 +1111,7 @@ function Animation.DrawOrderTimeline.new (frameCount)
|
|||||||
drawOrders = {},
|
drawOrders = {},
|
||||||
type = TimelineType.drawOrder
|
type = TimelineType.drawOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.drawOrder * SHL_24
|
return TimelineType.drawOrder * SHL_24
|
||||||
end
|
end
|
||||||
@ -1134,9 +1134,9 @@ function Animation.DrawOrderTimeline.new (frameCount)
|
|||||||
end
|
end
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then
|
if time < frames[0] then
|
||||||
if blend == MixBlend.setup or blend == MixBlend.first then
|
if blend == MixBlend.setup or blend == MixBlend.first then
|
||||||
for i,slot in ipairs(slots) do
|
for i,slot in ipairs(slots) do
|
||||||
drawOrder[i] = slots[i]
|
drawOrder[i] = slots[i]
|
||||||
@ -1179,13 +1179,13 @@ function Animation.IkConstraintTimeline.new (frameCount)
|
|||||||
local MIX = 1
|
local MIX = 1
|
||||||
local BEND_DIRECTION = 2
|
local BEND_DIRECTION = 2
|
||||||
local COMPRESS = 3
|
local COMPRESS = 3
|
||||||
local STRETCH = 1
|
local STRETCH = 4
|
||||||
|
|
||||||
local self = Animation.CurveTimeline.new(frameCount)
|
local self = Animation.CurveTimeline.new(frameCount)
|
||||||
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES) -- time, mix, bendDirection, compress, stretch, ...
|
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES) -- time, mix, bendDirection, compress, stretch, ...
|
||||||
self.ikConstraintIndex = -1
|
self.ikConstraintIndex = -1
|
||||||
self.type = TimelineType.ikConstraint
|
self.type = TimelineType.ikConstraint
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.ikConstraint * SHL_24 + self.ikConstraintIndex
|
return TimelineType.ikConstraint * SHL_24 + self.ikConstraintIndex
|
||||||
end
|
end
|
||||||
@ -1229,7 +1229,7 @@ function Animation.IkConstraintTimeline.new (frameCount)
|
|||||||
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
||||||
if blend == MixBlend.setup then
|
if blend == MixBlend.setup then
|
||||||
constraint.mix = constraint.data.mix + (frames[zlen(frames) + PREV_MIX] - constraint.data.mix) * alpha
|
constraint.mix = constraint.data.mix + (frames[zlen(frames) + PREV_MIX] - constraint.data.mix) * alpha
|
||||||
if direction == MixDirection.out then
|
if direction == MixDirection.out then
|
||||||
constraint.bendDirection = constraint.data.bendDirection
|
constraint.bendDirection = constraint.data.bendDirection
|
||||||
constraint.compress = constraint.data.compress
|
constraint.compress = constraint.data.compress
|
||||||
constraint.stretch = constraint.data.stretch
|
constraint.stretch = constraint.data.stretch
|
||||||
@ -1240,7 +1240,7 @@ function Animation.IkConstraintTimeline.new (frameCount)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
constraint.mix = constraint.mix + (frames[zlen(frames) + PREV_MIX] - constraint.mix) * alpha;
|
constraint.mix = constraint.mix + (frames[zlen(frames) + PREV_MIX] - constraint.mix) * alpha;
|
||||||
if direction == MixDirection._in then
|
if direction == MixDirection._in then
|
||||||
constraint.bendDirection = math_floor(frames[zlen(frames) + PREV_BEND_DIRECTION])
|
constraint.bendDirection = math_floor(frames[zlen(frames) + PREV_BEND_DIRECTION])
|
||||||
if (math_floor(frames[zlen(frames) + PREV_COMPRESS]) == 1) then constraint.compress = true else constraint.compress = false end
|
if (math_floor(frames[zlen(frames) + PREV_COMPRESS]) == 1) then constraint.compress = true else constraint.compress = false end
|
||||||
if (math_floor(frames[zlen(frames) + PREV_STRETCH]) == 1) then constraint.stretch = true else constraint.stretch = false end
|
if (math_floor(frames[zlen(frames) + PREV_STRETCH]) == 1) then constraint.stretch = true else constraint.stretch = false end
|
||||||
@ -1269,7 +1269,7 @@ function Animation.IkConstraintTimeline.new (frameCount)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
constraint.mix = constraint.mix + (mix + (frames[frame + MIX] - mix) * percent - constraint.mix) * alpha;
|
constraint.mix = constraint.mix + (mix + (frames[frame + MIX] - mix) * percent - constraint.mix) * alpha;
|
||||||
if direction == MixDirection._in then
|
if direction == MixDirection._in then
|
||||||
constraint.bendDirection = math_floor(frames[frame + PREV_BEND_DIRECTION])
|
constraint.bendDirection = math_floor(frames[frame + PREV_BEND_DIRECTION])
|
||||||
if (math_floor(frames[frame + PREV_COMPRESS]) == 1) then constraint.compress = true else constraint.compress = false end
|
if (math_floor(frames[frame + PREV_COMPRESS]) == 1) then constraint.compress = true else constraint.compress = false end
|
||||||
if (math_floor(frames[frame + PREV_STRETCH]) == 1) then constraint.stretch = true else constraint.stretch = false end
|
if (math_floor(frames[frame + PREV_STRETCH]) == 1) then constraint.stretch = true else constraint.stretch = false end
|
||||||
@ -1298,7 +1298,7 @@ function Animation.TransformConstraintTimeline.new (frameCount)
|
|||||||
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
||||||
self.transformConstraintIndex = -1
|
self.transformConstraintIndex = -1
|
||||||
self.type = TimelineType.transformConstraint
|
self.type = TimelineType.transformConstraint
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.transformConstraint * SHL_24 + self.transformConstraintIndex
|
return TimelineType.transformConstraint * SHL_24 + self.transformConstraintIndex
|
||||||
end
|
end
|
||||||
@ -1404,7 +1404,7 @@ function Animation.PathConstraintPositionTimeline.new (frameCount)
|
|||||||
local constraint = skeleton.pathConstraints[self.pathConstraintIndex]
|
local constraint = skeleton.pathConstraints[self.pathConstraintIndex]
|
||||||
if (time < frames[0]) then
|
if (time < frames[0]) then
|
||||||
if blend == MixBlend.setup then
|
if blend == MixBlend.setup then
|
||||||
constraint.position = constraint.data.position
|
constraint.position = constraint.data.position
|
||||||
elseif blend == MixBlend.first then
|
elseif blend == MixBlend.first then
|
||||||
constraint.position = constraint.position + (constraint.data.position - constraint.position) * alpha
|
constraint.position = constraint.position + (constraint.data.position - constraint.position) * alpha
|
||||||
end
|
end
|
||||||
@ -1508,7 +1508,7 @@ function Animation.PathConstraintMixTimeline.new (frameCount)
|
|||||||
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
self.frames = utils.newNumberArrayZero(frameCount * ENTRIES)
|
||||||
self.pathConstraintIndex = -1
|
self.pathConstraintIndex = -1
|
||||||
self.type = TimelineType.pathConstraintMix
|
self.type = TimelineType.pathConstraintMix
|
||||||
|
|
||||||
function self:getPropertyId ()
|
function self:getPropertyId ()
|
||||||
return TimelineType.pathConstraintMix * SHL_24 + self.pathConstraintIndex
|
return TimelineType.pathConstraintMix * SHL_24 + self.pathConstraintIndex
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user