[Bf-blender-cvs] [dbe33031801] experimental-build: LibOverride: Add initial support for adding new NLA tracks.

Bastien Montagne noreply at git.blender.org
Fri Nov 20 14:24:19 CET 2020


Commit: dbe330318011c137fc09d6a238f9282c983dadbf
Author: Bastien Montagne
Date:   Fri Nov 20 14:23:37 2020 +0100
Branches: experimental-build
https://developer.blender.org/rBdbe330318011c137fc09d6a238f9282c983dadbf

LibOverride: Add initial support for adding new NLA tracks.

Also makes NLA tracks and strips overridable.

Most of the work was as usual checking operators and adding protections
against illegal operations in override context.

Differential Revision: https://developer.blender.org/D9611

===================================================================

M	source/blender/blenkernel/intern/nla.c
M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/space_nla/nla_channels.c
M	source/blender/editors/space_nla/nla_edit.c
M	source/blender/editors/transform/transform_convert_nla.c
M	source/blender/makesdna/DNA_anim_types.h
M	source/blender/makesrna/intern/rna_access_compare_override.c
M	source/blender/makesrna/intern/rna_animation.c
M	source/blender/makesrna/intern/rna_nla.c

===================================================================

diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 56bd83140bf..60da0768aeb 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -293,7 +293,7 @@ NlaTrack *BKE_nlatrack_add(AnimData *adt, NlaTrack *prev)
   nlt = MEM_callocN(sizeof(NlaTrack), "NlaTrack");
 
   /* set settings requiring the track to not be part of the stack yet */
-  nlt->flag = NLATRACK_SELECTED;
+  nlt->flag = NLATRACK_SELECTED | NLATRACK_OVERRIDELIBRARY_LOCAL;
   nlt->index = BLI_listbase_count(&adt->nla_tracks);
 
   /* add track to stack, and make it the active one */
@@ -2273,6 +2273,11 @@ void BKE_nla_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *tracks)
 {
   /* we only care about the NLA strips inside the tracks */
   LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
+    /* If linking from a library, clear 'local' library override flag. */
+    if (id->lib != NULL) {
+      nlt->flag &= ~NLATRACK_OVERRIDELIBRARY_LOCAL;
+    }
+
     blend_lib_read_nla_strips(reader, id, &nlt->strips);
   }
 }
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 360335a54d7..cee4ac3d595 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1063,18 +1063,27 @@ static void rearrange_animchannels_filter_visible(ListBase *anim_data_visible,
                                                   eAnim_ChannelType type)
 {
   ListBase anim_data = {NULL, NULL};
-  bAnimListElem *ale, *ale_next;
-  int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
+  eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
+                              ANIMFILTER_LIST_CHANNELS);
 
   /* get all visible channels */
   ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 
   /* now, only keep the ones that are of the types we are interested in */
-  for (ale = anim_data.first; ale; ale = ale_next) {
-    ale_next = ale->next;
-
+  LISTBASE_FOREACH_MUTABLE (bAnimListElem *, ale, &anim_data) {
     if (ale->type != type) {
       BLI_freelinkN(&anim_data, ale);
+      continue;
+    }
+
+    if (type == ANIMTYPE_NLATRACK) {
+      NlaTrack *nlt = (NlaTrack *)ale->data;
+
+      if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+        /* No re-arrangement of non-local tracks of override data. */
+        BLI_freelinkN(&anim_data, ale);
+        continue;
+      }
     }
   }
 
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 561de5e82a6..2c2ee7b7388 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -796,6 +796,11 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
       NlaTrack *nlt = (NlaTrack *)ale->data;
       AnimData *adt = ale->adt;
 
+      if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+        /* No deletion of non-local tracks of override data. */
+        continue;
+      }
+
       /* if track is currently 'solo', then AnimData should have its
        * 'has solo' flag disabled
        */
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index ed8e5ad76e9..640f751d04e 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -966,6 +966,11 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
     AnimData *adt = ale->adt;
     NlaStrip *strip;
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+      /* No making metastrips in non-local tracks of override data. */
+      continue;
+    }
+
     /* create meta-strips from the continuous chains of selected strips */
     BKE_nlastrips_make_metas(&nlt->strips, 0);
 
@@ -1030,6 +1035,11 @@ static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op))
   for (ale = anim_data.first; ale; ale = ale->next) {
     NlaTrack *nlt = (NlaTrack *)ale->data;
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+      /* No removing metastrips from non-local tracks of override data. */
+      continue;
+    }
+
     /* clear all selected meta-strips, regardless of whether they are temporary or not */
     BKE_nlastrips_clear_metas(&nlt->strips, 1, 0);
 
@@ -1096,6 +1106,10 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
     NlaStrip *strip, *nstrip, *next;
     NlaTrack *track;
 
+    /* Note: In this case we allow it in override context because this operator is almost always
+     * paired with the transform one, which will ensure that the new strip ends up in a valid
+     * (local) track. */
+
     for (strip = nlt->strips.first; strip; strip = next) {
       next = strip->next;
 
@@ -1209,6 +1223,11 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
     NlaTrack *nlt = (NlaTrack *)ale->data;
     NlaStrip *strip, *nstrip;
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+      /* No deletion of strips in non-local tracks of override data. */
+      continue;
+    }
+
     for (strip = nlt->strips.first; strip; strip = nstrip) {
       nstrip = strip->next;
 
@@ -1359,6 +1378,11 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
     AnimData *adt = ale->adt;
     NlaStrip *strip, *next;
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+      /* No splitting of strips in non-local tracks of override data. */
+      continue;
+    }
+
     for (strip = nlt->strips.first; strip; strip = next) {
       next = strip->next;
 
@@ -1503,6 +1527,11 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
     NlaStrip *strip, *stripN = NULL;
     NlaStrip *area = NULL, *sb = NULL;
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+      /* No re-ordering of strips whithin non-local tracks of override data. */
+      continue;
+    }
+
     /* make temporary metastrips so that entire islands of selections can be moved around */
     BKE_nlastrips_make_metas(&nlt->strips, 1);
 
@@ -1679,6 +1708,12 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
       continue;
     }
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && ((nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0 ||
+                                            (nltn->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0)) {
+      /* No moving of strips in non-local tracks of override data. */
+      continue;
+    }
+
     /* for every selected strip, try to move */
     for (strip = nlt->strips.first; strip; strip = stripn) {
       stripn = strip->next;
@@ -1756,6 +1791,12 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
       continue;
     }
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && ((nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0 ||
+                                            (nltp->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0)) {
+      /* No moving of strips in non-local tracks of override data. */
+      continue;
+    }
+
     /* for every selected strip, try to move */
     for (strip = nlt->strips.first; strip; strip = stripn) {
       stripn = strip->next;
@@ -2023,11 +2064,11 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
       /* strip must be selected, and must be action-clip only
        * (transitions don't have scale) */
       if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
-        /* if the referenced action is used by other strips,
-         * make this strip use its own copy */
-        if (strip->act == NULL) {
+        if (strip->act == NULL || ID_IS_OVERRIDE_LIBRARY(strip->act) || ID_IS_LINKED(strip->act)) {
           continue;
         }
+        /* if the referenced action is used by other strips,
+         * make this strip use its own copy */
         if (strip->act->id.us > 1) {
           /* make a copy of the Action to work on */
           bAction *act = (bAction *)BKE_id_copy(bmain, &strip->act->id);
@@ -2375,6 +2416,11 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
     NlaTrack *nlt = (NlaTrack *)ale->data;
     NlaStrip *strip;
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+      /* No adding f-modifiers to strips in non-local tracks of override data. */
+      continue;
+    }
+
     for (strip = nlt->strips.first; strip; strip = strip->next) {
       /* can F-Modifier be added to the current strip? */
       if (active_only) {
@@ -2552,6 +2598,11 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
     NlaTrack *nlt = (NlaTrack *)ale->data;
     NlaStrip *strip;
 
+    if (ID_IS_OVERRIDE_LIBRARY(ale->id) && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+      /* No pasting in non-local tracks of override data. */
+      continue;
+    }
+
     for (strip = nlt->strips.first; strip; strip = strip->next) {
       /* can F-Modifier be added to the current strip? */
       if (active_only) {
diff --git a/source/blender/editors/transform/transform_convert_nla.c b/source/blender/editors/transform/transform_convert_nla.c
index 8f18f6a8c96..cb91f88c253 100644
--- a/source/blender/editors/transform/transform_convert_nla.c
+++ b/source/blender/editors/transform/transform_convert_nla.c
@@ -462,6 +462,12 @@ void recalcData_nla(TransInfo *t)
      * - we need to calculate both,
      *   as only one may have been altered by transform if only 1 handle moved.
      */
+    /* In LibOverride case, we cannot move trips across tracks that come from the linked data. */
+    const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(tdn->id);
+    if (is_liboverride && (tdn->nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
+      continue;
+    }
+
     delta_y1 = ((int)tdn->h1[1] / NLACHANNEL_STE

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list