/// @brief Returns the biggest frame range this event can have public FrameRange GetMaxFrameRange() { FrameRange range = new FrameRange(0, 0); if (id == 0) { range.Start = 0; } else { range.Start = root.GetEvents()[id - 1].End; } if (id == root.GetEvents().Count - 1) // last one? { range.End = root.Length; } else { range.End = root.GetEvents()[id + 1].Start; } return(range); }
/// @brief Returns what kind of overlap it has with \e range. /// @note Assumes They are both valid public FrameRangeOverlap GetOverlap(FrameRange range) { if (range.Start >= Start) { // contains, left or none if (range.End <= End) { return(FrameRangeOverlap.ContainsFull); } else { if (range.Start > End) { return(FrameRangeOverlap.MissOnRight); } return(FrameRangeOverlap.ContainsStart); } } else { // contained, right or none if (range.End < Start) { return(FrameRangeOverlap.MissOnLeft); } else { if (range.End > End) { return(FrameRangeOverlap.IsContained); } return(FrameRangeOverlap.ContainsEnd); } } }
/// @brief Returns if the ranges intersect, i.e. touching returns false /// @note Assumes They are both valid public bool Collides(FrameRange range) { return(Start < range.End && End > range.Start); // return (range.start > start && range.start < end) || (range.end > start && range.end < end ); }
/// @brief Returns if the ranges overlap, i.e. touching return true /// @note Assumes They are both valid public bool Overlaps(FrameRange range) { return(range.End >= Start && range.Start <= End); }
public static FrameRange Resize(FrameRange cur, FrameRange clampV) { cur.Start = Mathf.Clamp(cur.Start, clampV.Start, clampV.End); cur.End = Mathf.Clamp(cur.End, cur.Start, clampV.End); return cur; }