mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26: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 = {
|
||||
name = name,
|
||||
timelines = timelines,
|
||||
timelineIds = {},
|
||||
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)
|
||||
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
|
||||
or timeline.type == Animation.TimelineType.drawOrder
|
||||
or timeline.type == Animation.TimelineType.event
|
||||
or not self:hasTimeline(to, id) then
|
||||
or not to.animation:hasTimeline(id) then
|
||||
timelineMode[i] = FIRST
|
||||
else
|
||||
local next = to.mixingTo
|
||||
skip = false
|
||||
while next do
|
||||
if not self:hasTimeline(id) then
|
||||
if not next.animation:hasTimeline(id) then
|
||||
if entry.mixDuration > 0 then
|
||||
timelineMode[i] = HOLD_MIX
|
||||
timelineHoldMix[i] = next
|
||||
@ -917,14 +917,6 @@ function AnimationState:computeHold(entry)
|
||||
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)
|
||||
return self.tracks[trackIndex]
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user