[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21384] branches/soc-2009-aligorith/source /blender: NLA SoC: Fixes for Meta-Strips and Editing

Joshua Leung aligorith at gmail.com
Mon Jul 6 14:24:09 CEST 2009


Revision: 21384
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21384
Author:   aligorith
Date:     2009-07-06 14:24:09 +0200 (Mon, 06 Jul 2009)

Log Message:
-----------
NLA SoC: Fixes for Meta-Strips and Editing

* Split strip (YKEY) now plays nicely with Transitions and Metas. Meta strips get split up into their child strips, while transitions are ignored.

* Wrapped Meta_Strip->strips in RNA

* Bugfixes in Meta-strip API functions to silence some runtime-errors...

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/blenkernel/BKE_nla.h
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
    branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/BKE_nla.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/BKE_nla.h	2009-07-06 12:19:06 UTC (rev 21383)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/BKE_nla.h	2009-07-06 12:24:09 UTC (rev 21384)
@@ -61,6 +61,7 @@
 
 void BKE_nlastrips_make_metas(ListBase *strips, short temp);
 void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp);
+void BKE_nlastrips_clear_metastrip(ListBase *strips, struct NlaStrip *strip);
 short BKE_nlameta_add_strip(struct NlaStrip *mstrip, struct NlaStrip *strip);
 void BKE_nlameta_flush_transforms(struct NlaStrip *mstrip);
 

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c	2009-07-06 12:19:06 UTC (rev 21383)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c	2009-07-06 12:24:09 UTC (rev 21384)
@@ -650,6 +650,9 @@
 				/* set temp flag if appropriate (i.e. for transform-type editing) */
 				if (temp)
 					mstrip->flag |= NLASTRIP_FLAG_TEMP_META;
+					
+				/* set default repeat/scale values to prevent warnings */
+				mstrip->repeat= mstrip->scale= 1.0f;
 				
 				/* make its start frame be set to the start frame of the current strip */
 				mstrip->start= strip->start;
@@ -671,6 +674,28 @@
 	}
 }
 
+/* Split a meta-strip into a set of normal strips */
+void BKE_nlastrips_clear_metastrip (ListBase *strips, NlaStrip *strip)
+{
+	NlaStrip *cs, *csn;
+	
+	/* sanity check */
+	if ELEM(NULL, strips, strip)
+		return;
+	
+	/* move each one of the meta-strip's children before the meta-strip
+	 * in the list of strips after unlinking them from the meta-strip
+	 */
+	for (cs= strip->strips.first; cs; cs= csn) {
+		csn= cs->next;
+		BLI_remlink(&strip->strips, cs);
+		BLI_insertlinkbefore(strips, strip, cs);
+	}
+	
+	/* free the meta-strip now */
+	BLI_freelinkN(strips, strip);
+}
+
 /* Remove meta-strips (i.e. flatten the list of strips) from the top-level of the list of strips
  *	sel: only consider selected meta-strips, otherwise all meta-strips are removed
  *	onlyTemp: only remove the 'temporary' meta-strips used for transforms
@@ -692,19 +717,7 @@
 			/* if check if selection and 'temporary-only' considerations are met */
 			if ((onlySel==0) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
 				if ((!onlyTemp) || (strip->flag & NLASTRIP_FLAG_TEMP_META)) {
-					NlaStrip *cs, *csn;
-					
-					/* move each one of the meta-strip's children before the meta-strip
-					 * in the list of strips after unlinking them from the meta-strip
-					 */
-					for (cs= strip->strips.first; cs; cs= csn) {
-						csn= cs->next;
-						BLI_remlink(&strip->strips, cs);
-						BLI_insertlinkbefore(strips, strip, cs);
-					}
-					
-					/* free the meta-strip now */
-					BLI_freelinkN(strips, strip);
+					BKE_nlastrips_clear_metastrip(strips, strip);
 				}
 			}
 		}

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c	2009-07-06 12:19:06 UTC (rev 21383)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c	2009-07-06 12:24:09 UTC (rev 21384)
@@ -736,6 +736,55 @@
 // 	- multiple splits
 //	- variable-length splits?
 
+/* split a given Action-Clip strip */
+static void nlaedit_split_strip_actclip (NlaTrack *nlt, NlaStrip *strip)
+{
+	NlaStrip *nstrip;
+	float midframe, midaframe, len;
+	
+	/* calculate the frames to do the splitting at */
+		/* strip extents */
+	len= strip->end - strip->start;
+	if (IS_EQ(len, 0.0f)) 
+		return;
+	else
+		midframe= strip->start + (len / 2.0f);
+		
+		/* action range */
+	len= strip->actend - strip->actstart;
+	if (IS_EQ(len, 0.0f))
+		midaframe= strip->actend;
+	else
+		midaframe= strip->actstart + (len / 2.0f);
+	
+	/* make a copy (assume that this is possible) and append
+	 * it immediately after the current strip
+	 */
+	nstrip= copy_nlastrip(strip);
+	BLI_insertlinkafter(&nlt->strips, strip, nstrip);
+	
+	/* set the endpoint of the first strip and the start of the new strip 
+	 * to the midframe values calculated above
+	 */
+	strip->end= midframe;
+	nstrip->start= midframe;
+	
+	strip->actend= midaframe;
+	nstrip->actstart= midaframe;
+	
+	/* clear the active flag from the copy */
+	nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE;
+}
+
+/* split a given Meta strip */
+static void nlaedit_split_strip_meta (NlaTrack *nlt, NlaStrip *strip)
+{
+	/* simply ungroup it for now...  */
+	BKE_nlastrips_clear_metastrip(&nlt->strips, strip);
+}
+
+/* ----- */
+
 static int nlaedit_split_exec (bContext *C, wmOperator *op)
 {
 	bAnimContext ac;
@@ -755,47 +804,26 @@
 	/* for each NLA-Track, split all selected strips into two strips */
 	for (ale= anim_data.first; ale; ale= ale->next) {
 		NlaTrack *nlt= (NlaTrack *)ale->data;
-		NlaStrip *strip, *nstrip, *next;
+		NlaStrip *strip, *next;
 		
 		for (strip= nlt->strips.first; strip; strip= next) {
 			next= strip->next;
 			
 			/* if selected, split the strip at its midpoint */
 			if (strip->flag & NLASTRIP_FLAG_SELECT) {
-				float midframe, midaframe, len;
-				
-				/* calculate the frames to do the splitting at */
-					/* strip extents */
-				len= strip->end - strip->start;
-				if (IS_EQ(len, 0.0f)) 
-					continue;
-				else
-					midframe= strip->start + (len / 2.0f);
+				/* splitting method depends on the type of strip */
+				switch (strip->type) {
+					case NLASTRIP_TYPE_CLIP: /* action-clip */
+						nlaedit_split_strip_actclip(nlt, strip);
+						break;
+						
+					case NLASTRIP_TYPE_META: /* meta-strips need special handling */
+						nlaedit_split_strip_meta(nlt, strip);
+						break;
 					
-					/* action range */
-				len= strip->actend - strip->actstart;
-				if (IS_EQ(len, 0.0f))
-					midaframe= strip->actend;
-				else
-					midaframe= strip->actstart + (len / 2.0f);
-				
-				/* make a copy (assume that this is possible) and append
-				 * it immediately after the current strip
-				 */
-				nstrip= copy_nlastrip(strip);
-				BLI_insertlinkafter(&nlt->strips, strip, nstrip);
-				
-				/* set the endpoint of the first strip and the start of the new strip 
-				 * to the midframe values calculated above
-				 */
-				strip->end= midframe;
-				nstrip->start= midframe;
-				
-				strip->actend= midaframe;
-				nstrip->actstart= midaframe;
-				
-				/* clear the active flag from the copy */
-				nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE;
+					default: /* for things like Transitions, do not split! */
+						break;
+				}
 			}
 		}
 	}

Modified: branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c	2009-07-06 12:19:06 UTC (rev 21383)
+++ branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c	2009-07-06 12:24:09 UTC (rev 21384)
@@ -207,7 +207,7 @@
 	static EnumPropertyItem prop_type_items[] = {
 		{NLASTRIP_TYPE_CLIP, "CLIP", 0, "Action Clip", "NLA Strip references some Action."},
 		{NLASTRIP_TYPE_TRANSITION, "TRANSITION", 0, "Transition", "NLA Strip 'transitions' between adjacent strips."},
-		{NLASTRIP_TYPE_META, "META", 0, "Strip Container", "NLA Strip acts as a container for adjacent strips."},
+		{NLASTRIP_TYPE_META, "META", 0, "Meta", "NLA Strip acts as a container for adjacent strips."},
 		{0, NULL, 0, NULL, NULL}};
 	static EnumPropertyItem prop_mode_blend_items[] = {
 		{NLASTRIP_MODE_BLEND, "BLEND", 0, "Blend", "Results of strip and accumulated results are combined in ratio governed by influence."},
@@ -308,6 +308,11 @@
 	RNA_def_property_struct_type(prop, "FModifier");
 	RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting all the F-Curves in the referenced Action.");
 	
+	/* Strip's Sub-Strips (for Meta-Strips) */
+	prop= RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE);
+	RNA_def_property_struct_type(prop, "NlaStrip");
+	RNA_def_property_ui_text(prop, "NLA Strips", "NLA Strips that this strip acts as a container for (if it is of type Meta).");
+	
 	/* Settings - Values necessary for evaluation */
 	prop= RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0.0f, 1.0f);





More information about the Bf-blender-cvs mailing list