/**
   * Increments each track entry {@link TrackEntry#getTrackTime()}, setting queued animations as
   * current if needed.
   */
  public void update(float delta) {
    delta *= timeScale;
    for (int i = 0, n = tracks.size; i < n; i++) {
      TrackEntry current = tracks.get(i);
      if (current == null) continue;

      current.animationLast = current.nextAnimationLast;
      current.trackLast = current.nextTrackLast;

      float currentDelta = delta * current.timeScale;

      if (current.delay > 0) {
        current.delay -= currentDelta;
        if (current.delay > 0) continue;
        currentDelta = -current.delay;
        current.delay = 0;
      }

      TrackEntry next = current.next;
      if (next != null) {
        // When the next entry's delay is passed, change to the next entry, preserving leftover
        // time.
        float nextTime = current.trackLast - next.delay;
        if (nextTime >= 0) {
          next.delay = 0;
          next.trackTime = nextTime + delta * next.timeScale;
          current.trackTime += currentDelta;
          setCurrent(i, next, true);
          while (next.mixingFrom != null) {
            next.mixTime += currentDelta;
            next = next.mixingFrom;
          }
          continue;
        }
      } else {
        // Clear the track when there is no next entry, the track end time is reached, and there is
        // no mixingFrom.
        if (current.trackLast >= current.trackEnd && current.mixingFrom == null) {
          tracks.set(i, null);
          queue.end(current);
          disposeNext(current);
          continue;
        }
      }
      updateMixingFrom(current, delta);

      current.trackTime += currentDelta;
    }

    queue.drain();
  }
  private void updateMixingFrom(TrackEntry entry, float delta) {
    TrackEntry from = entry.mixingFrom;
    if (from == null) return;

    updateMixingFrom(from, delta);

    if (entry.mixTime >= entry.mixDuration && from.mixingFrom == null && entry.mixTime > 0) {
      entry.mixingFrom = null;
      queue.end(from);
      return;
    }

    from.animationLast = from.nextAnimationLast;
    from.trackLast = from.nextTrackLast;
    from.trackTime += delta * from.timeScale;
    entry.mixTime += delta * entry.timeScale;
  }