Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2014-04-28 16:07:15 +0400
committerJoshua Leung <aligorith@gmail.com>2014-04-28 17:59:41 +0400
commit68c3b6350ad702195a86adfcde65687269820afd (patch)
tree468a0b3537cde7a18f7526b0ceed7ff0ae99d36e /source/blender/blenkernel
parent27db75363e67f1da272fc9e4ca340e4eb8bf77d1 (diff)
NLA Editor: Duplicate/Duplicate Linked
This commit changes the default strip duplication behaviour (Shift-D) so that it will create a copy of whatever action it uses. Previously, it was very hard, if not impossible in some cases to create a new copy of an action to start working on in the NLA. If you want the old behaviour, you'll need to use ALt-D (Linked Duplicates). (Note: Although the new Shift-D may not be so optimal in all cases, I've decided to go with this version since it aligns better with the way this works for objects. Doing the opposite for NLA would just have added to the confusion)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_nla.h4
-rw-r--r--source/blender/blenkernel/intern/nla.c29
2 files changed, 22 insertions, 11 deletions
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index 7823efc3bae..0c29179aa1c 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -47,8 +47,8 @@ void free_nlastrip(ListBase *strips, struct NlaStrip *strip);
void free_nlatrack(ListBase *tracks, struct NlaTrack *nlt);
void free_nladata(ListBase *tracks);
-struct NlaStrip *copy_nlastrip(struct NlaStrip *strip);
-struct NlaTrack *copy_nlatrack(struct NlaTrack *nlt);
+struct NlaStrip *copy_nlastrip(struct NlaStrip *strip, const bool use_same_action);
+struct NlaTrack *copy_nlatrack(struct NlaTrack *nlt, const bool use_same_actions);
void copy_nladata(ListBase *dst, ListBase *src);
struct NlaTrack *add_nlatrack(struct AnimData *adt, struct NlaTrack *prev);
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index d251a8599b1..0c244e8a40b 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -157,8 +157,10 @@ void free_nladata(ListBase *tracks)
/* Copying ------------------------------------------- */
-/* Copy NLA strip */
-NlaStrip *copy_nlastrip(NlaStrip *strip)
+/* Copy NLA strip
+ * < use_same_action: if true, the existing action is used (instead of being duplicated)
+ */
+NlaStrip *copy_nlastrip(NlaStrip *strip, const bool use_same_action)
{
NlaStrip *strip_d;
NlaStrip *cs, *cs_d;
@@ -171,9 +173,17 @@ NlaStrip *copy_nlastrip(NlaStrip *strip)
strip_d = MEM_dupallocN(strip);
strip_d->next = strip_d->prev = NULL;
- /* increase user-count of action */
- if (strip_d->act)
- id_us_plus(&strip_d->act->id);
+ /* handle action */
+ if (strip_d->act) {
+ if (use_same_action) {
+ /* increase user-count of action */
+ id_us_plus(&strip_d->act->id);
+ }
+ else {
+ /* use a copy of the action instead (user count shouldn't have changed yet) */
+ strip_d->act = BKE_action_copy(strip_d->act);
+ }
+ }
/* copy F-Curves and modifiers */
copy_fcurves(&strip_d->fcurves, &strip->fcurves);
@@ -183,7 +193,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip)
BLI_listbase_clear(&strip_d->strips);
for (cs = strip->strips.first; cs; cs = cs->next) {
- cs_d = copy_nlastrip(cs);
+ cs_d = copy_nlastrip(cs, use_same_action);
BLI_addtail(&strip_d->strips, cs_d);
}
@@ -192,7 +202,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip)
}
/* Copy NLA Track */
-NlaTrack *copy_nlatrack(NlaTrack *nlt)
+NlaTrack *copy_nlatrack(NlaTrack *nlt, const bool use_same_actions)
{
NlaStrip *strip, *strip_d;
NlaTrack *nlt_d;
@@ -209,7 +219,7 @@ NlaTrack *copy_nlatrack(NlaTrack *nlt)
BLI_listbase_clear(&nlt_d->strips);
for (strip = nlt->strips.first; strip; strip = strip->next) {
- strip_d = copy_nlastrip(strip);
+ strip_d = copy_nlastrip(strip, use_same_actions);
BLI_addtail(&nlt_d->strips, strip_d);
}
@@ -232,7 +242,8 @@ void copy_nladata(ListBase *dst, ListBase *src)
/* copy each NLA-track, one at a time */
for (nlt = src->first; nlt; nlt = nlt->next) {
/* make a copy, and add the copy to the destination list */
- nlt_d = copy_nlatrack(nlt);
+ // XXX: we need to fix this sometime
+ nlt_d = copy_nlatrack(nlt, true);
BLI_addtail(dst, nlt_d);
}
}