[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35313] trunk/blender/source/blender/ editors: Bugfix [#26269] Initiating a duplication with shift D and cancelling

Joshua Leung aligorith at gmail.com
Thu Mar 3 00:39:09 CET 2011


Revision: 35313
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35313
Author:   aligorith
Date:     2011-03-02 23:39:08 +0000 (Wed, 02 Mar 2011)
Log Message:
-----------
Bugfix [#26269] Initiating a duplication with shift D and cancelling
in dope sheet/ graph editor leads to duplicated keys

The old hack using the transform "undostring" didn't work anymore, as
this wasn't set. Instead, I've added a special mode transform mode for
this that the duplicate operators can set to get this functionality.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_transform.h
    trunk/blender/source/blender/editors/space_action/action_edit.c
    trunk/blender/source/blender/editors/space_graph/graph_edit.c
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c

Modified: trunk/blender/source/blender/editors/include/ED_transform.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_transform.h	2011-03-02 22:32:13 UTC (rev 35312)
+++ trunk/blender/source/blender/editors/include/ED_transform.h	2011-03-02 23:39:08 UTC (rev 35313)
@@ -77,6 +77,7 @@
 	TFM_TIME_SLIDE,
 	TFM_TIME_SCALE,
 	TFM_TIME_EXTEND,
+	TFM_TIME_DUPLICATE,
 	TFM_BAKE_TIME,
 	TFM_BEVEL,
 	TFM_BWEIGHT,

Modified: trunk/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_edit.c	2011-03-02 22:32:13 UTC (rev 35312)
+++ trunk/blender/source/blender/editors/space_action/action_edit.c	2011-03-02 23:39:08 UTC (rev 35313)
@@ -663,7 +663,7 @@
 {
 	actkeys_duplicate_exec(C, op);
 	
-	RNA_int_set(op->ptr, "mode", TFM_TIME_TRANSLATE);
+	RNA_int_set(op->ptr, "mode", TFM_TIME_DUPLICATE);
 	WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
 
 	return OPERATOR_FINISHED;

Modified: trunk/blender/source/blender/editors/space_graph/graph_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_edit.c	2011-03-02 22:32:13 UTC (rev 35312)
+++ trunk/blender/source/blender/editors/space_graph/graph_edit.c	2011-03-02 23:39:08 UTC (rev 35313)
@@ -782,7 +782,7 @@
 {
 	graphkeys_duplicate_exec(C, op);
 	
-	RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
+	RNA_int_set(op->ptr, "mode", TFM_TIME_DUPLICATE);
 	WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
 
 	return OPERATOR_FINISHED;

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2011-03-02 22:32:13 UTC (rev 35312)
+++ trunk/blender/source/blender/editors/transform/transform.c	2011-03-02 23:39:08 UTC (rev 35313)
@@ -1677,6 +1677,16 @@
 	case TFM_TIME_SCALE:
 		initTimeScale(t);
 		break;
+	case TFM_TIME_DUPLICATE:
+		/* same as TFM_TIME_EXTEND, but we need the mode info for later 
+		 * so that duplicate-culling will work properly
+		 */
+		if ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)
+			initTranslation(t);
+		else
+			initTimeTranslate(t);
+		t->mode = mode;
+		break;
 	case TFM_TIME_EXTEND:
 		/* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
 		 * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2011-03-02 22:32:13 UTC (rev 35312)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2011-03-02 23:39:08 UTC (rev 35313)
@@ -4681,7 +4681,7 @@
 	Object *ob;
 //	short redrawipo=0, resetslowpar=1;
 	int cancelled= (t->state == TRANS_CANCEL);
-	short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0; /* see bugreport #21229 for reasons for this data */
+	short duplicate= (t->mode == TFM_TIME_DUPLICATE);
 	
 	/* early out when nothing happened */
 	if (t->total == 0 || t->mode == TFM_DUMMY)
@@ -4743,6 +4743,11 @@
 				AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
 				FCurve *fcu= (FCurve *)ale->key_data;
 				
+				/* 3 cases here for curve cleanups:
+				 * 1) NOTRANSKEYCULL on     -> cleanup of duplicates shouldn't be done
+				 * 2) cancelled == 0        -> user confirmed the transform, so duplicates should be removed
+				 * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these
+				 */
 				if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
 					 ((cancelled == 0) || (duplicate)) )
 				{
@@ -4769,7 +4774,11 @@
 					DAG_id_tag_update(&ob->id, OB_RECALC_OB);
 			}
 			
-			/* Do curve cleanups? */
+			/* 3 cases here for curve cleanups:
+			 * 1) NOTRANSKEYCULL on     -> cleanup of duplicates shouldn't be done
+			 * 2) cancelled == 0        -> user confirmed the transform, so duplicates should be removed
+			 * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these
+			 */
 			if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
 				 ((cancelled == 0) || (duplicate)) )
 			{
@@ -4796,7 +4805,13 @@
 		
 		else if (ac.datatype == ANIMCONT_GPENCIL) {
 			/* remove duplicate frames and also make sure points are in order! */
-			if ((cancelled == 0) || (duplicate))
+				/* 3 cases here for curve cleanups:
+				 * 1) NOTRANSKEYCULL on     -> cleanup of duplicates shouldn't be done
+				 * 2) cancelled == 0        -> user confirmed the transform, so duplicates should be removed
+				 * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these
+				 */
+			if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+				 ((cancelled == 0) || (duplicate)) )
 			{
 				bGPdata *gpd;
 				
@@ -4836,6 +4851,11 @@
 				AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
 				FCurve *fcu= (FCurve *)ale->key_data;
 				
+				/* 3 cases here for curve cleanups:
+				 * 1) NOTRANSKEYCULL on     -> cleanup of duplicates shouldn't be done
+				 * 2) cancelled == 0        -> user confirmed the transform, so duplicates should be removed
+				 * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these
+				 */
 				if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 &&
 					 ((cancelled == 0) || (duplicate)) )
 				{




More information about the Bf-blender-cvs mailing list