mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 10:16:01 +08:00
[lua] Store timeline ids inside set in Animation for O(1) lookup. See #1462.
This commit is contained in:
parent
06089630fb
commit
2c0881da61
@ -50,8 +50,17 @@ function Animation.new (name, timelines, duration)
|
|||||||
local self = {
|
local self = {
|
||||||
name = name,
|
name = name,
|
||||||
timelines = timelines,
|
timelines = timelines,
|
||||||
|
timelineIds = {},
|
||||||
duration = duration
|
duration = duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i,timeline in ipairs(self.timelines) do
|
||||||
|
self.timelineIds[timeline:getPropertyId()] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function self:hasTimeline(id)
|
||||||
|
return self.timelineIds[id] == true
|
||||||
|
end
|
||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, loop, events, alpha, blend, direction)
|
function self:apply (skeleton, lastTime, time, loop, events, alpha, blend, direction)
|
||||||
if not skeleton then error("skeleton cannot be nil.", 2) end
|
if not skeleton then error("skeleton cannot be nil.", 2) end
|
||||||
|
|||||||
@ -894,13 +894,13 @@ function AnimationState:computeHold(entry)
|
|||||||
if to == nil or timeline.type == Animation.TimelineType.attachment
|
if to == nil or timeline.type == Animation.TimelineType.attachment
|
||||||
or timeline.type == Animation.TimelineType.drawOrder
|
or timeline.type == Animation.TimelineType.drawOrder
|
||||||
or timeline.type == Animation.TimelineType.event
|
or timeline.type == Animation.TimelineType.event
|
||||||
or not self:hasTimeline(to, id) then
|
or not to.animation:hasTimeline(id) then
|
||||||
timelineMode[i] = FIRST
|
timelineMode[i] = FIRST
|
||||||
else
|
else
|
||||||
local next = to.mixingTo
|
local next = to.mixingTo
|
||||||
skip = false
|
skip = false
|
||||||
while next do
|
while next do
|
||||||
if not self:hasTimeline(id) then
|
if not next.animation:hasTimeline(id) then
|
||||||
if entry.mixDuration > 0 then
|
if entry.mixDuration > 0 then
|
||||||
timelineMode[i] = HOLD_MIX
|
timelineMode[i] = HOLD_MIX
|
||||||
timelineHoldMix[i] = next
|
timelineHoldMix[i] = next
|
||||||
@ -917,14 +917,6 @@ function AnimationState:computeHold(entry)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function AnimationState:hasTimeline(entry, id)
|
|
||||||
local timelines = entry.animation.timelines
|
|
||||||
for i,timeline in ipairs(timelines) do
|
|
||||||
if timeline:getPropertyId() == id then return true end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function AnimationState:getCurrent (trackIndex)
|
function AnimationState:getCurrent (trackIndex)
|
||||||
return self.tracks[trackIndex]
|
return self.tracks[trackIndex]
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user