[Bf-blender-cvs] [8bc2b9468a2] temp-D10103-nla_support_strip_overlap_during_transform: NLA: Strip Post-transform Vertical Shuffle and Auto-Grow Track List

Wayde Moss noreply at git.blender.org
Wed Jan 13 07:05:19 CET 2021


Commit: 8bc2b9468a224410ca2dfc4d2eaffffd517df8e5
Author: Wayde Moss
Date:   Wed Jan 13 00:51:47 2021 -0500
Branches: temp-D10103-nla_support_strip_overlap_during_transform
https://developer.blender.org/rB8bc2b9468a224410ca2dfc4d2eaffffd517df8e5

NLA: Strip Post-transform Vertical Shuffle and Auto-Grow Track List

**Not ready for review**

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

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

M	source/blender/blenkernel/BKE_nla.h
M	source/blender/blenkernel/intern/ipo.c
M	source/blender/blenkernel/intern/nla.c
M	source/blender/editors/object/object_add.c
M	source/blender/editors/space_action/action_data.c
M	source/blender/editors/space_nla/nla_channels.c
M	source/blender/editors/space_nla/nla_draw.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_animation.c
M	source/blender/makesrna/intern/rna_nla.c

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

diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index 16d48024d07..f3b6d584e31 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -46,8 +46,8 @@ struct PropertyRNA;
 /* ----------------------------- */
 /* Data Management */
 
-void BKE_nlastrip_free(ListBase *strips, struct NlaStrip *strip, bool do_id_user);
-void BKE_nlatrack_free(ListBase *tracks, struct NlaTrack *nlt, bool do_id_user);
+void BKE_nlastrip_free(struct NlaStrip *strip, bool do_id_user);
+void BKE_nlatrack_free(struct NlaTrack *nlt, bool do_id_user);
 void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user);
 
 struct NlaStrip *BKE_nlastrip_copy(struct Main *bmain,
@@ -60,10 +60,39 @@ struct NlaTrack *BKE_nlatrack_copy(struct Main *bmain,
                                    const int flag);
 void BKE_nla_tracks_copy(struct Main *bmain, ListBase *dst, ListBase *src, const int flag);
 
-struct NlaTrack *BKE_nlatrack_add(struct AnimData *adt,
-                                  struct NlaTrack *prev,
-                                  bool is_liboverride);
+struct NlaTrack *BKE_nlatrack_new();
+void BKE_nlatrack_remove(ListBase *tracks, struct NlaTrack *nlt);
+void BKE_nlatrack_remove_and_free(ListBase *tracks, struct NlaTrack *nlt, const bool do_id_user);
+
+void BKE_nlatrack_insert_after(ListBase *nla_tracks,
+                               struct NlaTrack *prev,
+                               struct NlaTrack *new_track,
+                               const bool is_liboverride);
+
+void BKE_nlatrack_insert_before(ListBase *nla_tracks,
+                                struct NlaTrack *next,
+                                struct NlaTrack *new_track,
+                                const bool is_liboverride);
+
+struct NlaTrack *BKE_nlatrack_new_after_and_set_active(ListBase *nla_tracks,
+                                                       struct NlaTrack *prev,
+                                                       const bool is_liboverride);
+
+struct NlaTrack *BKE_nlatrack_new_before_and_set_active(ListBase *nla_tracks,
+                                                        struct NlaTrack *next,
+                                                        const bool is_liboverride);
+
+struct NlaTrack *BKE_nlatrack_new_tail_and_set_active(ListBase *nla_tracks,
+                                                      const bool is_liboverride);
+struct NlaTrack *BKE_nlatrack_new_head_and_set_active(ListBase *nla_tracks,
+                                                      const bool is_liboverride);
+
 struct NlaStrip *BKE_nlastrip_new(struct bAction *act);
+
+void BKE_nlatrack_remove_strip(struct NlaTrack *track, struct NlaStrip *strip);
+void BKE_nlastrip_remove(ListBase *strips, struct NlaStrip *strip);
+void BKE_nlastrip_remove_and_free(ListBase *strips, struct NlaStrip *strip, const bool do_id_user);
+
 struct NlaStrip *BKE_nlastack_add_strip(struct AnimData *adt,
                                         struct bAction *act,
                                         const bool is_liboverride);
@@ -79,12 +108,13 @@ void BKE_nla_strip_foreach_id(struct NlaStrip *strip, struct LibraryForeachIDDat
 bool BKE_nlastrips_has_space(ListBase *strips, float start, float end);
 void BKE_nlastrips_sort_strips(ListBase *strips);
 
-bool BKE_nlastrips_add_strip(ListBase *strips, struct NlaStrip *strip);
+void BKE_nlastrips_add_strip(ListBase *strips, struct NlaStrip *strip);
+bool BKE_nlastrips_try_add_strip(ListBase *strips, struct NlaStrip *strip);
 
 void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp);
 void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp);
 void BKE_nlastrips_clear_metastrip(ListBase *strips, struct NlaStrip *strip);
-bool BKE_nlameta_add_strip(struct NlaStrip *mstrip, struct NlaStrip *strip);
+bool BKE_nlameta_try_add_strip(struct NlaStrip *mstrip, struct NlaStrip *strip);
 void BKE_nlameta_flush_transforms(struct NlaStrip *mstrip);
 
 /* ............ */
@@ -99,9 +129,10 @@ void BKE_nlatrack_solo_toggle(struct AnimData *adt, struct NlaTrack *nlt);
 bool BKE_nlatrack_has_space(struct NlaTrack *nlt, float start, float end);
 void BKE_nlatrack_sort_strips(struct NlaTrack *nlt);
 
-bool BKE_nlatrack_add_strip(struct NlaTrack *nlt,
-                            struct NlaStrip *strip,
-                            const bool is_liboverride);
+void BKE_nlatrack_add_strip(struct NlaTrack *nlt, struct NlaStrip *strip);
+bool BKE_nlatrack_try_add_strip(struct NlaTrack *nlt,
+                                struct NlaStrip *strip,
+                                const bool is_liboverride);
 
 bool BKE_nlatrack_get_bounds(struct NlaTrack *nlt, float bounds[2]);
 
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 1ab6e61e20e..a2979c86b8a 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -2012,12 +2012,12 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
       }
 
       /* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */
-      if (BKE_nlatrack_add_strip(nlt, strip, false) == 0) {
+      if (!BKE_nlatrack_try_add_strip(nlt, strip, false)) {
         /* trying to add to the current failed (no space),
          * so add a new track to the stack, and add to that...
          */
-        nlt = BKE_nlatrack_add(adt, NULL, false);
-        BKE_nlatrack_add_strip(nlt, strip, false);
+        nlt = BKE_nlatrack_new_tail_and_set_active(&adt->nla_tracks, false);
+        BKE_nlatrack_add_strip(nlt, strip);
       }
 
       /* ensure that strip has a name */
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index ecafc76c84d..a77e7a2d800 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -66,10 +66,9 @@ static CLG_LogRef LOG = {"bke.nla"};
 
 /* Freeing ------------------------------------------- */
 
-/* Remove the given NLA strip from the NLA track it occupies, free the strip's data,
- * and the strip itself.
+/* Free the strip's data and the strip itself.
  */
-void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
+void BKE_nlastrip_free(NlaStrip *strip, bool do_id_user)
 {
   NlaStrip *cs, *csn;
 
@@ -81,7 +80,7 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
   /* free child-strips */
   for (cs = strip->strips.first; cs; cs = csn) {
     csn = cs->next;
-    BKE_nlastrip_free(&strip->strips, cs, do_id_user);
+    BKE_nlastrip_remove_and_free(&strip->strips, cs, do_id_user);
   }
 
   /* remove reference to action */
@@ -98,20 +97,17 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
 
   /* free own F-Modifiers */
   free_fmodifiers(&strip->modifiers);
+}
 
-  /* free the strip itself */
-  if (strips) {
-    BLI_freelinkN(strips, strip);
-  }
-  else {
-    MEM_freeN(strip);
-  }
+void BKE_nlatrack_remove_strip(NlaTrack *track, NlaStrip *strip)
+{
+  BLI_assert(track);
+  BKE_nlastrip_remove(&track->strips, strip);
 }
 
-/* Remove the given NLA track from the set of NLA tracks, free the track's data,
- * and the track itself.
+/* Free the track's data and the track itself.
  */
-void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
+void BKE_nlatrack_free(NlaTrack *nlt, const bool do_id_user)
 {
   NlaStrip *strip, *stripn;
 
@@ -123,16 +119,38 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
   /* free strips */
   for (strip = nlt->strips.first; strip; strip = stripn) {
     stripn = strip->next;
-    BKE_nlastrip_free(&nlt->strips, strip, do_id_user);
+    BKE_nlastrip_free(strip, do_id_user);
   }
 
   /* free NLA track itself now */
-  if (tracks) {
-    BLI_freelinkN(tracks, nlt);
-  }
-  else {
-    MEM_freeN(nlt);
-  }
+  MEM_freeN(nlt);
+}
+
+void BKE_nlastrip_remove(ListBase *strips, NlaStrip *strip)
+{
+  BLI_assert(strips);
+  BLI_remlink(strips, strip);
+}
+
+void BKE_nlastrip_remove_and_free(ListBase *strips, NlaStrip *strip, const bool do_id_user)
+{
+  BKE_nlastrip_remove(strips, strip);
+  BKE_nlastrip_free(strip, do_id_user);
+}
+
+void BKE_nlatrack_remove(ListBase *tracks, NlaTrack *nlt)
+{
+  BLI_assert(tracks);
+  BLI_remlink(tracks, nlt);
+}
+
+/* Remove the given NLA track from the set of NLA tracks, free the track's data,
+ * and the track itself.
+ */
+void BKE_nlatrack_remove_and_free(ListBase *tracks, NlaTrack *nlt, const bool do_id_user)
+{
+  BKE_nlatrack_remove(tracks, nlt);
+  BKE_nlatrack_free(nlt, do_id_user);
 }
 
 /* Free the elements of type NLA Tracks provided in the given list, but do not free
@@ -150,7 +168,7 @@ void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
   /* free tracks one by one */
   for (nlt = tracks->first; nlt; nlt = nltn) {
     nltn = nlt->next;
-    BKE_nlatrack_free(tracks, nlt, do_id_user);
+    BKE_nlatrack_remove_and_free(tracks, nlt, do_id_user);
   }
 
   /* clear the list's pointers to be safe */
@@ -277,27 +295,35 @@ void BKE_nla_tracks_copy(Main *bmain, ListBase *dst, ListBase *src, const int fl
 
 /* Adding ------------------------------------------- */
 
-/* Add a NLA Track to the given AnimData
- * - prev: NLA-Track to add the new one after
- */
-NlaTrack *BKE_nlatrack_add(AnimData *adt, NlaTrack *prev, const bool is_liboverride)
+NlaTrack *BKE_nlatrack_new()
 {
-  NlaTrack *nlt;
-
-  /* sanity checks */
-  if (adt == NULL) {
-    return NULL;
-  }
-
   /* allocate new track */
-  nlt = MEM_callocN(sizeof(NlaTrack), "NlaTrack");
+  NlaTrack *nlt = MEM_callocN(sizeof(NlaTrack), "NlaTrack");
 
   /* set settings requiring the track to not be part of the stack yet */
   nlt->flag = NLATRACK_SELECTED | NLATRACK_OVERRIDELIBRARY_LOCAL;
-  nlt->index = BLI_listbase_count(&adt->nla_tracks);
 
-  /* In liboverride case, we only add local tracks after all those comming from the linked data, so
-   * we need to find the first local track. */
+  return nlt;
+}
+
+void BKE_nlatrack_insert_after(ListBase *nla_tracks,
+                               NlaTrack *prev,
+                               NlaTrack *new_track,
+                

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list