private void Evaluate(Playable playable, FrameData frameData) { if (m_IntervalTree == null) { return; } double localTime = playable.GetTime(); m_ActiveBit = m_ActiveBit == 0 ? 1 : 0; m_CurrentListOfActiveClips.Clear(); m_IntervalTree.IntersectsWith(DiscreteTime.GetNearestTick(localTime), m_CurrentListOfActiveClips); foreach (var c in m_CurrentListOfActiveClips) { c.intervalBit = m_ActiveBit; if (frameData.timeLooped) { c.Reset(); } } // all previously active clips having a different intervalBit flag are not // in the current intersection, therefore are considered becoming disabled at this frame var timelineEnd = playable.GetDuration(); foreach (var c in m_ActiveClips) { if (c.intervalBit != m_ActiveBit) { var clipEnd = (double)DiscreteTime.FromTicks(c.intervalEnd); var time = frameData.timeLooped ? Math.Min(clipEnd, timelineEnd) : Math.Min(localTime, clipEnd); c.EvaluateAt(time, frameData); c.enable = false; } } m_ActiveClips.Clear(); // case 998642 - don't use m_ActiveClips.AddRange, as in 4.6 .Net scripting it causes GC allocs for (var a = 0; a < m_CurrentListOfActiveClips.Count; a++) { m_CurrentListOfActiveClips[a].EvaluateAt(localTime, frameData); m_ActiveClips.Add(m_CurrentListOfActiveClips[a]); } int count = m_EvaluateCallbacks.Count; for (int i = 0; i < count; i++) { m_EvaluateCallbacks[i].Evaluate(); } }
public override void DisableAt(double localTime, double rootDuration, FrameData frameData) { var time = Math.Min(localTime, (double)DiscreteTime.FromTicks(intervalEnd)); if (frameData.timeLooped) { time = Math.Min(time, rootDuration); } var clipTime = clip.ToLocalTime(time); if (clipTime > -DiscreteTime.tickValue / 2) { SetTime(clipTime); } enable = false; }