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>2011-08-07 16:27:20 +0400
committerJoshua Leung <aligorith@gmail.com>2011-08-07 16:27:20 +0400
commit022e815fbd6d81f9b1baa177cce1abf2f42bcb21 (patch)
tree5c8b9b947ef50d4b0f398cf6a53b81a04e4f83c9 /source/blender/editors/space_nla/nla_edit.c
parent2d884fc035d403d43c7a18e3e61cd56ccdfbec2b (diff)
Sound clip NLA Strips for Nexyon
These are basically just for specifying when a speaker should fire off it's soundclip, and as such, many NLA operations are irrelevant for it. They can only be specified on object-level for speaker objects. I've still got some UI tweaks I'll need to work on in order for these to be able to be added even when the speaker doesn't have any NLA tracks yet. (EDIT: while typing this, I had an idea for how to do this, but that'll be for next commit). In the mean time, you'll need to add a single keyframe for the object, snowflake that action and delete the NLA strip before you can start editing.
Diffstat (limited to 'source/blender/editors/space_nla/nla_edit.c')
-rw-r--r--source/blender/editors/space_nla/nla_edit.c95
1 files changed, 94 insertions, 1 deletions
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index eb22495c977..fa24bd2f895 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -36,6 +36,7 @@
#include <math.h>
#include "DNA_anim_types.h"
+#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
@@ -536,12 +537,15 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op)
/* check if there's space between the two */
if (IS_EQ(s1->end, s2->start))
continue;
- /* make neither one is a transition
+ /* make sure neither one is a transition
* - although this is impossible to create with the standard tools,
* the user may have altered the settings
*/
if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type))
continue;
+ /* also make sure neither one is a soundclip */
+ if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type))
+ continue;
/* allocate new strip */
strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip");
@@ -608,6 +612,91 @@ void NLA_OT_transition_add (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+/* ******************** Add Sound Clip Operator ***************************** */
+/* Add a new sound clip */
+
+static int nlaedit_add_sound_exec (bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ Scene *scene;
+ int cfra;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ scene = ac.scene;
+ cfra = CFRA;
+
+ /* get a list of the editable tracks being shown in the NLA */
+ filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* for each track, add sound clips if it belongs to a speaker */
+ // TODO: what happens if there aren't any tracks... well that's a more general problem for later
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ Object *ob = (Object *)ale->id; /* may not be object until we actually check! */
+
+ AnimData *adt = ale->adt;
+ NlaTrack *nlt= (NlaTrack *)ale->data;
+ NlaStrip *strip;
+
+ /* does this belong to speaker - assumed to live on Object level only */
+ if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER))
+ continue;
+
+ /* create a new strip, and offset it to start on the current frame */
+ strip= add_nla_soundstrip(ac.scene, ob->data);
+
+ strip->start += cfra;
+ strip->end += cfra;
+
+ /* firstly try adding strip to our current track, but if that fails, add to a new track */
+ if (BKE_nlatrack_add_strip(nlt, strip) == 0) {
+ /* trying to add to the current failed (no space),
+ * so add a new track to the stack, and add to that...
+ */
+ nlt= add_nlatrack(adt, NULL);
+ BKE_nlatrack_add_strip(nlt, strip);
+ }
+
+ /* auto-name it */
+ BKE_nlastrip_validate_name(adt, strip);
+ }
+
+ /* free temp data */
+ BLI_freelistN(&anim_data);
+
+ /* refresh auto strip properties */
+ ED_nla_postop_refresh(&ac);
+
+ /* set notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL);
+
+ /* done */
+ return OPERATOR_FINISHED;
+}
+
+void NLA_OT_soundclip_add (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Add Sound Clip";
+ ot->idname= "NLA_OT_soundclip_add";
+ ot->description= "Add a strip for controlling when speaker plays its sound clip";
+
+ /* api callbacks */
+ ot->exec= nlaedit_add_sound_exec;
+ ot->poll= nlaop_poll_tweakmode_off;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ******************** Add Meta-Strip Operator ***************************** */
/* Add new meta-strips incorporating the selected strips */
@@ -1923,6 +2012,10 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
continue;
}
+ /* sound clips are not affected by FModifiers */
+ if (strip->type == NLASTRIP_TYPE_SOUND)
+ continue;
+
/* add F-Modifier of specified type to selected, and make it the active one */
fcm= add_fmodifier(&strip->modifiers, type);