uncacheClip method

void uncacheClip(
  1. AnimationClip clip
)

Deallocates all memory resources for a clip. Before using this method make sure to call AnimationAction.stop for all related actions.

Implementation

/// sure to call [AnimationAction.stop]() for all related actions.
void uncacheClip(AnimationClip clip) {
  final actions = _actions,
      clipUuid = clip.uuid,
      actionsByClip = this.actionsByClip,
      actionsForClip = actionsByClip[clipUuid];

  if (actionsForClip != null) {
    // note: just calling _removeInactiveAction would mess up the
    // iteration state and also require updating the state we can
    // just throw away

    final actionsToRemove = actionsForClip['knownActions'];

    for (int i = 0, n = actionsToRemove.length; i != n; ++i) {
      final AnimationAction action = actionsToRemove[i];

      deactivateAction(action);

      final cacheIndex = action.cacheIndex!, lastInactiveAction = actions[actions.length - 1];

      action.cacheIndex = null;
      action.byClipCacheIndex = null;

      lastInactiveAction.cacheIndex = cacheIndex;
      actions[cacheIndex] = lastInactiveAction;
      actions.removeLast();

      _removeInactiveBindingsForAction(action);
    }

    actionsByClip.remove(clipUuid);
  }
}