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>2015-02-28 02:57:17 +0300
committerJoshua Leung <aligorith@gmail.com>2015-02-28 16:34:50 +0300
commit13a0dce51c949e09842876da1c4dc68c047d6ed0 (patch)
tree6457defc461d73311615b3d98965721dcc4dbe01 /source/blender/blenkernel/intern/nla.c
parentb16fbabd616944007e4730640dd55db5fa021afa (diff)
Action Stashing: Don't allow an action to get stashed more than once
Diffstat (limited to 'source/blender/blenkernel/intern/nla.c')
-rw-r--r--source/blender/blenkernel/intern/nla.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 9be413ddcde..4af1f4ca411 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -1525,17 +1525,45 @@ void BKE_nla_validate_state(AnimData *adt)
/* Action Stashing -------------------------------------- */
+/* name of stashed tracks - the translation stuff is included here to save extra work */
+#define STASH_TRACK_NAME DATA_("[Action Stash]")
+
+/* Check if an action is "stashed" in the NLA already
+ *
+ * The criteria for this are:
+ * 1) The action in question lives in a "stash" track
+ * 2) We only check first-level strips. That is, we will not check inside meta strips.
+ */
+bool BKE_nla_action_is_stashed(AnimData *adt, bAction *act)
+{
+ NlaTrack *nlt;
+ NlaStrip *strip;
+
+ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
+ if (strstr(nlt->name, STASH_TRACK_NAME)) {
+ for (strip = nlt->strips.first; strip; strip = strip->next) {
+ if (strip->act == act)
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
/* "Stash" an action (i.e. store it as a track/layer in the NLA, but non-contributing)
* to retain it in the file for future uses
*/
bool BKE_nla_action_stash(AnimData *adt)
{
- const char *STASH_TRACK_NAME = DATA_("[Action Stash]");
-
NlaTrack *prev_track = NULL;
NlaTrack *nlt;
NlaStrip *strip;
+ /* do not add if it is already stashed */
+ if (BKE_nla_action_is_stashed(adt, adt->action))
+ return false;
+
/* create a new track, and add this immediately above the previous stashing track */
for (prev_track = adt->nla_tracks.last; prev_track; prev_track = prev_track->prev) {
if (strstr(prev_track->name, STASH_TRACK_NAME)) {