[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14833] trunk/blender/source/blender: NLA and IPO now have the "AfterTrans Keyframe" option that prevents the creation of duplicate keyframes after transform.

Joshua Leung aligorith at gmail.com
Wed May 14 11:00:43 CEST 2008


Revision: 14833
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14833
Author:   aligorith
Date:     2008-05-14 11:00:22 +0200 (Wed, 14 May 2008)

Log Message:
-----------
NLA and IPO now have the "AfterTrans Keyframe" option that prevents the creation of duplicate keyframes after transform.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/src/header_ipo.c
    trunk/blender/source/blender/src/header_nla.c
    trunk/blender/source/blender/src/transform_conversions.c

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h	2008-05-13 23:57:35 UTC (rev 14832)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h	2008-05-14 09:00:22 UTC (rev 14833)
@@ -524,7 +524,8 @@
 #define SI_DRAW_STRETCH	1<<21
 
 /* SpaceIpo->flag */
-#define SIPO_LOCK_VIEW	1<<0
+#define SIPO_LOCK_VIEW			1<<0
+#define SIPO_NOTRANSKEYCULL		1<<1
 
 /* SpaceText flags (moved from DNA_text_types.h) */
 
@@ -616,6 +617,7 @@
 #define SNLA_ALLKEYED		1
 #define SNLA_ACTIVELAYERS	2
 #define SNLA_DRAWTIME		4
+#define SNLA_NOTRANSKEYCULL	8
 
 /* time->flag */
 	/* show timing in frames instead of in seconds */

Modified: trunk/blender/source/blender/src/header_ipo.c
===================================================================
--- trunk/blender/source/blender/src/header_ipo.c	2008-05-13 23:57:35 UTC (rev 14832)
+++ trunk/blender/source/blender/src/header_ipo.c	2008-05-14 09:00:22 UTC (rev 14833)
@@ -751,6 +751,9 @@
 	case 14: /* Clear Preview Range */
 		anim_previewrange_clear();
 		break;
+	case 15: /* AutoMerge Keyframes */
+		G.sipo->flag ^= SIPO_NOTRANSKEYCULL;
+		break;
 	}
 }
 
@@ -772,6 +775,9 @@
 	else
 		uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Keys|K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
 	
+	uiDefIconTextBut(block, BUTM, 1, (G.sipo->flag & SIPO_NOTRANSKEYCULL)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT, 
+					 "AutoMerge Keyframes|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
+	
 	uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Out|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");

Modified: trunk/blender/source/blender/src/header_nla.c
===================================================================
--- trunk/blender/source/blender/src/header_nla.c	2008-05-13 23:57:35 UTC (rev 14832)
+++ trunk/blender/source/blender/src/header_nla.c	2008-05-14 09:00:22 UTC (rev 14833)
@@ -128,6 +128,9 @@
 	case 9: /* Clear Preview Range */
 		anim_previewrange_clear();
 		break;
+	case 10: /* AutoMerge Keyframes */
+		G.snla->flag ^= SNLA_NOTRANSKEYCULL;
+		break;
 	}
 }
 
@@ -148,6 +151,9 @@
 	} else {
 		uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Seconds|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
 	}
+	
+	uiDefIconTextBut(block, BUTM, 1, (G.snla->flag & SNLA_NOTRANSKEYCULL)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT, 
+					 "AutoMerge Keyframes|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
 		
 	uiDefBut(block, SEPR, 0, "",					0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 		

Modified: trunk/blender/source/blender/src/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/src/transform_conversions.c	2008-05-13 23:57:35 UTC (rev 14832)
+++ trunk/blender/source/blender/src/transform_conversions.c	2008-05-14 09:00:22 UTC (rev 14833)
@@ -144,6 +144,8 @@
 
 /* local function prototype - for Object/Bone Constraints */
 static short constraints_list_needinv(TransInfo *t, ListBase *list);
+/* local function prototype - for finding number of keyframes that are selected for editing */
+static int count_ipo_keys(Ipo *ipo, char side, float cfra);
 
 /* ************************** Functions *************************** */
 
@@ -2490,6 +2492,93 @@
 	BLI_freelistN(&act_data);
 }
 
+/* Called by special_aftertrans_update to make sure selected keyframes replace
+ * any other keyframes which may reside on that frame (that is not selected).
+ * remake_all_ipos should have already been called 
+ */
+static void posttrans_nla_clean (TransInfo *t)
+{
+	Base *base;
+	Object *ob;
+	bActionStrip *strip;
+	bActionChannel *achan;
+	bConstraintChannel *conchan;
+	float cfra;
+	char side;
+	int i;
+	
+	/* which side of the current frame should be allowed */
+	if (t->mode == TFM_TIME_EXTEND) {
+		/* only side on which mouse is gets transformed */
+		float xmouse, ymouse;
+		
+		areamouseco_to_ipoco(G.v2d, t->imval, &xmouse, &ymouse);
+		side = (xmouse > CFRA) ? 'R' : 'L';
+	}
+	else {
+		/* normal transform - both sides of current frame are considered */
+		side = 'B';
+	}
+	
+	/* only affect keyframes */
+	for (base=G.scene->base.first; base; base=base->next) {
+		ob= base->object;
+		
+		/* Check object ipos */
+		i= count_ipo_keys(ob->ipo, side, CFRA);
+		if (i) posttrans_ipo_clean(ob->ipo);
+		
+		/* Check object constraint ipos */
+		for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next) {
+			i= count_ipo_keys(conchan->ipo, side, CFRA);	
+			if (i) posttrans_ipo_clean(ob->ipo);
+		}
+		
+		/* skip actions and nlastrips if object is collapsed */
+		if (ob->nlaflag & OB_NLA_COLLAPSED)
+			continue;
+		
+		/* Check action ipos */
+		if (ob->action) {
+			/* exclude if strip is selected too */
+			for (strip=ob->nlastrips.first; strip; strip=strip->next) {
+				if (strip->flag & ACTSTRIP_SELECT) {
+					if (strip->act == ob->action)
+						break;
+				}
+			}
+			if (strip==NULL) {
+				cfra = get_action_frame(ob, CFRA);
+				
+				for (achan=ob->action->chanbase.first; achan; achan=achan->next) {
+					if (EDITABLE_ACHAN(achan)) {
+						i= count_ipo_keys(achan->ipo, side, cfra);
+						if (i) {
+							actstrip_map_ipo_keys(ob, achan->ipo, 0, 1); 
+							posttrans_ipo_clean(achan->ipo);
+							actstrip_map_ipo_keys(ob, achan->ipo, 1, 1);
+						}
+						
+						/* Check action constraint ipos */
+						if (EXPANDED_ACHAN(achan) && FILTER_CON_ACHAN(achan)) {
+							for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next) {
+								if (EDITABLE_CONCHAN(conchan)) {
+									i = count_ipo_keys(conchan->ipo, side, cfra);
+									if (i) {
+										actstrip_map_ipo_keys(ob, conchan->ipo, 0, 1); 
+										posttrans_ipo_clean(conchan->ipo);
+										actstrip_map_ipo_keys(ob, conchan->ipo, 1, 1);
+									}
+								}
+							}
+						}
+					}
+				}
+			}		
+		}
+	}
+}
+
 /* ----------------------------- */
 
 /* This function tests if a point is on the "mouse" side of the cursor/frame-marking */
@@ -3487,8 +3576,6 @@
 			if (key->ipo) {
 				IpoCurve *icu;
 				
-				
-				
 				if ( (G.saction->flag & SACTION_NOTRANSKEYCULL)==0 && 
 				     (cancelled == 0) )
 				{
@@ -3507,17 +3594,39 @@
 		G.saction->flag &= ~SACTION_MOVING;
 	}
 	else if (t->spacetype == SPACE_NLA) {
+		recalc_all_ipos();	// bad
 		synchronize_action_strips();
 		
 		/* cleanup */
 		for (base=G.scene->base.first; base; base=base->next)
 			base->flag &= ~(BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA);
 		
-		recalc_all_ipos();	// bad
+		/* after transform, remove duplicate keyframes on a frame that resulted from transform */
+		if ( (G.snla->flag & SNLA_NOTRANSKEYCULL)==0 && 
+			 (cancelled == 0) )
+		{
+			posttrans_nla_clean(t);
+		}
 	}
 	else if (t->spacetype == SPACE_IPO) {
 		// FIXME! is there any code from the old transform_ipo that needs to be added back? 
 		
+		/* after transform, remove duplicate keyframes on a frame that resulted from transform */
+		if (G.sipo->ipo) 
+		{
+			if ( (G.sipo->flag & SIPO_NOTRANSKEYCULL)==0 && 
+				 (cancelled == 0) )
+			{
+				if (NLA_IPO_SCALED) {
+					actstrip_map_ipo_keys(OBACT, G.sipo->ipo, 0, 1); 
+					posttrans_ipo_clean(G.sipo->ipo);
+					actstrip_map_ipo_keys(OBACT, G.sipo->ipo, 1, 1);
+				}
+				else 
+					posttrans_ipo_clean(G.sipo->ipo);
+			}
+		}
+		
 		/* resetting slow-parents isn't really necessary when editing sequence ipo's */
 		if (G.sipo->blocktype==ID_SEQ)
 			resetslowpar= 0;





More information about the Bf-blender-cvs mailing list