activateAction method

dynamic activateAction(
  1. dynamic action
)

Implementation

activateAction(action) {
  if (!isActiveAction(action)) {
    if (action.cacheIndex == null) {
      // this action has been forgotten by the cache, but the user
      // appears to be still using it -> rebind

      var rootUuid = (action.localRoot ?? root).uuid,
          clipUuid = action.clip.uuid,
          actionsForClip = _actionsByClip[clipUuid];

      _bindAction(action, actionsForClip && actionsForClip.knownActions[0]);

      _addInactiveAction(action, clipUuid, rootUuid);
    }

    var bindings = action.propertyBindings;

    // increment reference counts / sort out state
    for (var i = 0, n = bindings.length; i != n; ++i) {
      var binding = bindings[i];

      if (binding.useCount++ == 0) {
        _lendBinding(binding);
        binding.saveOriginalState();
      }
    }

    _lendAction(action);
  }
}