private List <ClipEventBar> ComputeBarClipEvent(IEnumerable <VisualEffectPlayableSerializedEvent> clipEvents, out uint rowCount) { m_ClipEventBars.Clear(); rowCount = 1; using (var iterator = clipEvents.GetEnumerator()) { while (iterator.MoveNext()) { var enter = iterator.Current; iterator.MoveNext(); var exit = iterator.Current; var candidate = new ClipEventBar() { start = (float)enter.time, end = (float)exit.time, rowIndex = 0u, color = new Color(enter.editorColor.r, enter.editorColor.g, enter.editorColor.b) }; while (!AvailableEmplacement(candidate, m_ClipEventBars)) { candidate.rowIndex++; } if (candidate.rowIndex >= rowCount) { rowCount = candidate.rowIndex + 1; } m_ClipEventBars.Add(candidate); } } return(m_ClipEventBars); }
static bool AvailableEmplacement(ClipEventBar current, IEnumerable <ClipEventBar> currentBars) { return(!currentBars.Any(o => { if (o.rowIndex == current.rowIndex) { if (!(current.end < o.start || current.start > o.end)) { return true; } } return false; })); }