[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21394] branches/soc-2009-aligorith/source /blender: NLA SoC: Start of integration of Meta-strips in Transform

Joshua Leung aligorith at gmail.com
Tue Jul 7 04:12:56 CEST 2009


Revision: 21394
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21394
Author:   aligorith
Date:     2009-07-07 04:12:50 +0200 (Tue, 07 Jul 2009)

Log Message:
-----------
NLA SoC: Start of integration of Meta-strips in Transform 

* Chains of selected strips are now converted to meta-strips before transforms begin, and converted back afterwards. This simplifies the transform code needed in later stages...

* Transform-flushing code for Meta-Strips should now work. There seems to be a little bit of numeric inaccuracy problems somewhere, as two strips which met at the same frame can get separated when scaling.

* Meta-strips now draw with proper text identification

* Snapping strips now properly clears meta-strips if a moved strip needs to be moved into a new track to be accomodated.

* Fixed a filter used by a selection-operator.

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c
    branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
    branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c	2009-07-07 01:21:02 UTC (rev 21393)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c	2009-07-07 02:12:50 UTC (rev 21394)
@@ -781,6 +781,8 @@
 {
 	NlaStrip *strip;
 	float oStart, oEnd, offset;
+	float oLen, nLen;
+	short scaleChanged= 0;
 	
 	/* sanity checks 
 	 *	- strip must exist
@@ -806,17 +808,44 @@
 	if (IS_EQ(oStart, mstrip->start) && IS_EQ(oEnd, mstrip->end))
 		return;
 	
+	/* check if scale changed */
+	oLen = oEnd - oStart;
+	nLen = mstrip->end - mstrip->start;
+	if (IS_EQ(nLen, oLen) == 0)
+		scaleChanged= 1;
+	
 	/* for each child-strip, calculate new start/end points based on this new info */
 	for (strip= mstrip->strips.first; strip; strip= strip->next) {
-		//PointerRNA strip_ptr;
+		if (scaleChanged) {
+			PointerRNA ptr;
+			float p1, p2, nStart, nEnd;
+			
+			/* compute positions of endpoints relative to old extents of strip */
+			p1= (strip->start - oStart) / oLen;
+			p2= (strip->end - oStart) / oLen;
+			
+			/* compute the new strip endpoints using the proportions */
+			nStart= (p1 * nLen) + mstrip->start;
+			nEnd= (p2 * nLen) + mstrip->start;
+			
+			/* firstly, apply the new positions manually, then apply using RNA 
+			 *	- first time is to make sure no truncation errors from one endpoint not being 
+			 *	  set yet occur
+			 *	- second time is to make sure scale is computed properly...
+			 */
+			strip->start= nStart;
+			strip->end= nEnd;
+			
+			RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &ptr);
+			RNA_float_set(&ptr, "start_frame", nStart);
+			RNA_float_set(&ptr, "end_frame", nEnd);
+		}
+		else {
+			/* just apply the changes in offset to both ends of the strip */
+			strip->start += offset;
+			strip->end += offset;
+		}
 		
-		/* firstly, just apply the changes in offset to both ends of the strip */
-		strip->start += offset;
-		strip->end += offset;
-		
-		/* now, we need to fix the endpoint to take into account scaling */
-		// TODO..
-		
 		/* finally, make sure the strip's children (if it is a meta-itself), get updated */
 		BKE_nlameta_flush_transforms(strip);
 	}

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c	2009-07-07 01:21:02 UTC (rev 21393)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c	2009-07-07 02:12:50 UTC (rev 21394)
@@ -366,13 +366,21 @@
 	/* for now, just init the string with fixed-formats */
 	switch (strip->type) {
 		case NLASTRIP_TYPE_TRANSITION: /* Transition */
-			sprintf(str, "%d | Transition | %.2f %s %.2f", index, strip->start, dir, strip->end);
+			sprintf(str, "%d | Transition | %.2f %s %.2f", 
+				index, strip->start, dir, strip->end);
 			break;
+			
+		case NLASTRIP_TYPE_META: /* Meta */
+			sprintf(str, "%d | %sMeta | %.2f %s %.2f", 
+				index, ((strip->flag & NLASTRIP_FLAG_TEMP_META)?"Temp-":""), 
+				strip->start, dir, strip->end);
+			break;
 		
 		case NLASTRIP_TYPE_CLIP:	/* Action-Clip (default) */
 		default:
 			if (strip->act)
-				sprintf(str, "%d | Act: %s | %.2f %s %.2f", index, strip->act->id.name+2, strip->start, dir, strip->end);
+				sprintf(str, "%d | Act: %s | %.2f %s %.2f", 
+					index, strip->act->id.name+2, strip->start, dir, strip->end);
 			else
 				sprintf(str, "%d | Act: <NONE>", index); // xxx... need a better format?
 			break;

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-07 01:21:02 UTC (rev 21393)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c	2009-07-07 02:12:50 UTC (rev 21394)
@@ -1264,6 +1264,9 @@
 				/* need to add a new track above the current one */
 				track= add_nlatrack(adt, nlt);
 				BKE_nlatrack_add_strip(track, strip);
+				
+				/* clear temp meta-strips on this new track, as we may not be able to get back to it */
+				BKE_nlastrips_clear_metas(&track->strips, 0, 1);
 			}
 		}
 		

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c	2009-07-07 01:21:02 UTC (rev 21393)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c	2009-07-07 02:12:50 UTC (rev 21394)
@@ -513,7 +513,7 @@
 	
 	
 	/* filter data */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	
 	/* select strips on the side where most data occurs */

Modified: branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c	2009-07-07 01:21:02 UTC (rev 21393)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c	2009-07-07 02:12:50 UTC (rev 21394)
@@ -2617,6 +2617,9 @@
 		NlaTrack *nlt= (NlaTrack *)ale->data;
 		NlaStrip *strip;
 		
+		/* make some meta-strips for chains of selected strips */
+		BKE_nlastrips_make_metas(&nlt->strips, 1);
+		
 		/* only consider selected strips */
 		for (strip= nlt->strips.first; strip; strip= strip->next) {
 			// TODO: we can make strips have handles later on...
@@ -4754,6 +4757,26 @@
 		if (ANIM_animdata_context_getdata(&ac) == 0)
 			return;
 		
+		if (ac.datatype) 
+		{
+			ListBase anim_data = {NULL, NULL};
+			bAnimListElem *ale;
+			short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NLATRACKS);
+			
+			/* get channels to work on */
+			ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+			
+			for (ale= anim_data.first; ale; ale= ale->next) {
+				NlaTrack *nlt= (NlaTrack *)ale->data;
+				
+				/* remove the temp metas */
+				BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);
+			}
+			
+			/* free temp memory */
+			BLI_freelistN(&anim_data);
+		}
+		
 		// XXX check on the calls below... we need some of these sanity checks
 		//synchronize_action_strips();
 		//ANIM_editkeyframes_refresh(&ac);

Modified: branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c	2009-07-07 01:21:02 UTC (rev 21393)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c	2009-07-07 02:12:50 UTC (rev 21394)
@@ -82,6 +82,7 @@
 #include "BKE_key.h"
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
+#include "BKE_nla.h"
 #include "BKE_object.h"
 #include "BKE_utildefines.h"
 #include "BKE_context.h"
@@ -388,6 +389,20 @@
 				}
 			}
 		}
+		
+		/* loop over the TransDataNla again, flushing the transforms (since we use Metas to make transforms easier) */
+		td= t->data;
+		for (i = 0; i < t->total; i++, td++)
+		{
+			if (td->extra)
+			{
+				TransDataNla *tdn= td->extra;
+				NlaStrip *strip= tdn->strip;
+				
+				// TODO: this may flush some things twice, but that's fine as there's no impact from that
+				BKE_nlameta_flush_transforms(strip);
+			}
+		}
 	}
 	else if (t->obedit) {
 		if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {





More information about the Bf-blender-cvs mailing list