[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39138] branches/soc-2011-pepper: Sound clip NLA Strips for Nexyon

Joshua Leung aligorith at gmail.com
Sun Aug 7 14:27:20 CEST 2011


Revision: 39138
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39138
Author:   aligorith
Date:     2011-08-07 12:27:20 +0000 (Sun, 07 Aug 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_nla.py
    branches/soc-2011-pepper/source/blender/blenkernel/BKE_nla.h
    branches/soc-2011-pepper/source/blender/blenkernel/intern/anim_sys.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/nla.c
    branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c
    branches/soc-2011-pepper/source/blender/editors/space_nla/nla_buttons.c
    branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c
    branches/soc-2011-pepper/source/blender/editors/space_nla/nla_edit.c
    branches/soc-2011-pepper/source/blender/editors/space_nla/nla_intern.h
    branches/soc-2011-pepper/source/blender/editors/space_nla/nla_ops.c
    branches/soc-2011-pepper/source/blender/makesdna/DNA_anim_types.h
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_nla.c

Modified: branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_nla.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_nla.py	2011-08-07 12:19:07 UTC (rev 39137)
+++ branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_nla.py	2011-08-07 12:27:20 UTC (rev 39138)
@@ -173,6 +173,7 @@
         layout.column()
         layout.operator("nla.actionclip_add")
         layout.operator("nla.transition_add")
+        layout.operator("nla.soundclip_add")
 
         layout.separator()
         layout.operator("nla.meta_add")

Modified: branches/soc-2011-pepper/source/blender/blenkernel/BKE_nla.h
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/BKE_nla.h	2011-08-07 12:19:07 UTC (rev 39137)
+++ branches/soc-2011-pepper/source/blender/blenkernel/BKE_nla.h	2011-08-07 12:27:20 UTC (rev 39138)
@@ -39,6 +39,8 @@
 struct NlaStrip;
 struct NlaTrack;
 struct bAction;
+struct Scene;
+struct Speaker;
 
 /* ----------------------------- */
 /* Data Management */
@@ -54,6 +56,7 @@
 struct NlaTrack *add_nlatrack(struct AnimData *adt, struct NlaTrack *prev);
 struct NlaStrip *add_nlastrip(struct bAction *act);
 struct NlaStrip *add_nlastrip_to_stack(struct AnimData *adt, struct bAction *act);
+struct NlaStrip *add_nla_soundstrip(struct Scene *scene, struct Speaker *spk);
 
 /* ----------------------------- */
 /* API */

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/anim_sys.c	2011-08-07 12:19:07 UTC (rev 39137)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/anim_sys.c	2011-08-07 12:27:20 UTC (rev 39138)
@@ -1921,6 +1921,9 @@
 		case NLASTRIP_TYPE_META: /* meta */
 			nlastrip_evaluate_meta(ptr, channels, modifiers, nes);
 			break;
+			
+		default: /* do nothing */
+			break;
 	}
 	
 	/* clear temp recursion safe-check */

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/nla.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/nla.c	2011-08-07 12:19:07 UTC (rev 39137)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/nla.c	2011-08-07 12:27:20 UTC (rev 39138)
@@ -46,6 +46,8 @@
 
 #include "DNA_anim_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_sound_types.h"
+#include "DNA_speaker_types.h"
 
 #include "BKE_action.h"
 #include "BKE_fcurve.h"
@@ -53,6 +55,9 @@
 #include "BKE_global.h"
 #include "BKE_library.h"
 
+#ifdef WITH_AUDASPACE
+#  include "AUD_C-API.h"
+#endif
 
 #include "RNA_access.h"
 #include "nla_private.h"
@@ -337,6 +342,41 @@
 	return strip;
 }
 
+/* Add a NLA Strip referencing the given speaker's sound */
+NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
+{
+	NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip");
+	
+	/* if speaker has a sound, set the strip length to the length of the sound,
+	 * otherwise default to length of 10 frames
+	 */
+#ifdef WITH_AUDASPACE
+	if (speaker->sound) 
+	{
+		AUD_SoundInfo info = AUD_getInfo(speaker->sound->playback_handle);
+		
+		strip->end = ceil(info.length * FPS);
+	}
+	else 
+#endif
+	{
+		strip->end = 10.0f;
+	}
+	
+	/* general settings */
+	strip->type = NLASTRIP_TYPE_SOUND;
+	
+	strip->flag = NLASTRIP_FLAG_SELECT;
+	strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */
+	
+	/* strip should be referenced as-is */
+	strip->scale= 1.0f;
+	strip->repeat = 1.0f;
+	
+	/* return this strip */
+	return strip;
+}
+
 /* *************************************************** */
 /* NLA Evaluation <-> Editing Stuff */
 

Modified: branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c	2011-08-07 12:19:07 UTC (rev 39137)
+++ branches/soc-2011-pepper/source/blender/editors/animation/anim_filter.c	2011-08-07 12:27:20 UTC (rev 39138)
@@ -397,6 +397,7 @@
  *	2A) nla tracks: include animdata block's data as there are NLA tracks+strips there
  *	2B) actions to convert to nla: include animdata block's data as there is an action that can be 
  *		converted to a new NLA strip, and the filtering options allow this
+ *	2C) allow non-animated datablocks to be included so that datablocks can be added
  *	3) drivers: include drivers from animdata block (for Drivers mode in Graph Editor)
  *	4) normal keyframes: only when there is an active action
  */
@@ -1625,7 +1626,7 @@
 		case OB_SPEAKER: /* ---------- Speaker ----------- */
 		{
 			Speaker *spk= (Speaker *)ob->data;
-
+			
 			type= ANIMTYPE_DSSPK;
 			expanded= FILTER_SPK_OBJD(spk);
 		}

Modified: branches/soc-2011-pepper/source/blender/editors/space_nla/nla_buttons.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/space_nla/nla_buttons.c	2011-08-07 12:19:07 UTC (rev 39137)
+++ branches/soc-2011-pepper/source/blender/editors/space_nla/nla_buttons.c	2011-08-07 12:27:20 UTC (rev 39138)
@@ -213,6 +213,24 @@
 	return (strip->type == NLASTRIP_TYPE_CLIP);
 }
 
+static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt))
+{
+	PointerRNA ptr;
+	NlaStrip *strip;
+	
+	if (!nla_panel_context(C, NULL, NULL, &ptr))
+		return 0;
+	if (ptr.data == NULL)
+		return 0;
+	
+	strip= ptr.data;
+	
+	if (strip->type == NLASTRIP_TYPE_SOUND)
+		return 0;
+		
+	return 1;
+}
+
 /* -------------- */
 
 /* active AnimData */
@@ -278,6 +296,7 @@
 	uiLayout *layout= pa->layout;
 	uiLayout *column, *row, *subcol;
 	uiBlock *block;
+	short showEvalProps = 1;
 	
 	if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
 		return;
@@ -297,32 +316,41 @@
 		uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE);
 		uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE);
 	
-	/* extrapolation */
-	row= uiLayoutRow(layout, 1);
-		uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE);
+	/* Evaluation-Related Strip Properties ------------------ */
 	
-	/* blending */
-	row= uiLayoutRow(layout, 1);
-		uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE);
+	/* sound properties strips don't have these settings */
+	if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND)
+		showEvalProps = 0;
+	
+	/* only show if allowed to... */
+	if (showEvalProps) {
+		/* extrapolation */
+		row= uiLayoutRow(layout, 1);
+			uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE);
 		
-	/* blend in/out + autoblending
-	 *	- blend in/out can only be set when autoblending is off
-	 */
-	column= uiLayoutColumn(layout, 1);
-		uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); 
-		uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle?
-		
-		subcol= uiLayoutColumn(column, 1);
-			uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); 
-			uiItemR(subcol, &strip_ptr, "blend_in", 0, NULL, ICON_NONE);
-			uiItemR(subcol, &strip_ptr, "blend_out", 0, NULL, ICON_NONE);
-		
-	/* settings */
-	column= uiLayoutColumn(layout, 1);
-		uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); 
-		uiItemL(column, "Playback Settings:", ICON_NONE);
-		uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE);
-		uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE);
+		/* blending */
+		row= uiLayoutRow(layout, 1);
+			uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE);
+			
+		/* blend in/out + autoblending
+		 *	- blend in/out can only be set when autoblending is off
+		 */
+		column= uiLayoutColumn(layout, 1);
+			uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); 
+			uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle?
+			
+			subcol= uiLayoutColumn(column, 1);
+				uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); 
+				uiItemR(subcol, &strip_ptr, "blend_in", 0, NULL, ICON_NONE);
+				uiItemR(subcol, &strip_ptr, "blend_out", 0, NULL, ICON_NONE);
+			
+		/* settings */
+		column= uiLayoutColumn(layout, 1);
+			uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); 
+			uiItemL(column, "Playback Settings:", ICON_NONE);
+			uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE);
+			uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE);
+	}
 }
 
 
@@ -476,14 +504,14 @@
 	strcpy(pt->idname, "NLA_PT_evaluation");
 	strcpy(pt->label, "Evaluation");
 	pt->draw= nla_panel_evaluation;
-	pt->poll= nla_strip_panel_poll;
+	pt->poll= nla_strip_eval_panel_poll;
 	BLI_addtail(&art->paneltypes, pt);
 	
 	pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers");
 	strcpy(pt->idname, "NLA_PT_modifiers");
 	strcpy(pt->label, "Modifiers");
 	pt->draw= nla_panel_modifiers;
-	pt->poll= nla_strip_panel_poll;
+	pt->poll= nla_strip_eval_panel_poll;
 	BLI_addtail(&art->paneltypes, pt);
 }
 

Modified: branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c	2011-08-07 12:19:07 UTC (rev 39137)
+++ branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c	2011-08-07 12:27:20 UTC (rev 39138)
@@ -198,7 +198,24 @@
 			color[1]= 0.15f;
 			color[2]= 0.26f;
 		}
-	}	
+	}
+	else if (strip->type == NLASTRIP_TYPE_SOUND) {
+		/* Sound Clip */
+		if (strip->flag & NLASTRIP_FLAG_SELECT) {
+			/* selected - use a bright teal color */
+			// FIXME: hardcoded temp-hack colors
+			color[0]= 0.12f;
+			color[1]= 0.48f;
+			color[2]= 0.48f;
+		}
+		else {
+			/* normal, unselected strip - use (hardly noticable) teal tinge */
+			// FIXME: hardcoded temp-hack colors
+			color[0]= 0.17f;
+			color[1]= 0.24f;
+			color[2]= 0.24f;
+		}
+	}
 	else {
 		/* Action Clip (default/normal type of strip) */
 		if ((strip->flag & NLASTRIP_FLAG_ACTIVE) && (adt && (adt->flag & ADT_NLA_EDIT_ON))) {

Modified: branches/soc-2011-pepper/source/blender/editors/space_nla/nla_edit.c
===================================================================

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list