[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20028] branches/blender2.5/blender/source /blender: F-Curve Modifiers - Per-Modifier Muting:

Joshua Leung aligorith at gmail.com
Sat May 2 06:51:16 CEST 2009


Revision: 20028
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20028
Author:   aligorith
Date:     2009-05-02 06:51:14 +0200 (Sat, 02 May 2009)

Log Message:
-----------
F-Curve Modifiers - Per-Modifier Muting:

It is now possible to mute individual modifiers so that they will not contribute to the final result. 

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_fcurve.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c	2009-05-02 04:20:36 UTC (rev 20027)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c	2009-05-02 04:51:14 UTC (rev 20028)
@@ -2239,7 +2239,7 @@
 		/* only evaluate if there's a callback for this */
 		// TODO: implement the 'influence' control feature...
 		if (fmi && fmi->evaluate_modifier) {
-			if ((fcm->flag & FMODIFIER_FLAG_DISABLED) == 0)
+			if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0)
 				fmi->evaluate_modifier(fcu, fcm, &cvalue, evaltime);
 		}
 	}

Modified: branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c	2009-05-02 04:20:36 UTC (rev 20027)
+++ branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c	2009-05-02 04:51:14 UTC (rev 20028)
@@ -871,18 +871,21 @@
 		but= uiDefBut(block, ROUNDBOX, B_REDR, "", 0, *yco-2, width, 24, NULL, 5.0, 0.0, 15.0, (float)(rb_col-20), ""); 
 		
 		/* expand */
-		uiDefIconButBitS(block, ICONTOG, FMODIFIER_FLAG_EXPANDED, B_REDR, ICON_TRIA_RIGHT,	5, *yco-1, 20, 20, &fcm->flag, 0.0, 0.0, 0, 0, "Modifier is expanded");
+		uiDefIconButBitS(block, ICONTOG, FMODIFIER_FLAG_EXPANDED, B_REDR, ICON_TRIA_RIGHT,	5, *yco-1, 20, 20, &fcm->flag, 0.0, 0.0, 0, 0, "Modifier is expanded.");
 		
 		/* checkbox for 'active' status (for now) */
-		but= uiDefIconButBitS(block, ICONTOG, FMODIFIER_FLAG_ACTIVE, B_REDR, ICON_RADIOBUT_OFF,	25, *yco-1, 20, 20, &fcm->flag, 0.0, 0.0, 0, 0, "Modifier is active one");
+		but= uiDefIconButBitS(block, ICONTOG, FMODIFIER_FLAG_ACTIVE, B_REDR, ICON_RADIOBUT_OFF,	25, *yco-1, 20, 20, &fcm->flag, 0.0, 0.0, 0, 0, "Modifier is active one.");
 		uiButSetFunc(but, activate_fmodifier_cb, fcu, fcm);
 		
 		/* name */
 		if (fmi)
-			but= uiDefBut(block, LABEL, 1, fmi->name,	10+40, *yco, 240, 20, NULL, 0.0, 0.0, 0, 0, "F-Curve Modifier Type. Click to make modifier active one.");
+			uiDefBut(block, LABEL, 1, fmi->name,	10+40, *yco, 150, 20, NULL, 0.0, 0.0, 0, 0, "F-Curve Modifier Type. Click to make modifier active one.");
 		else
-			but= uiDefBut(block, LABEL, 1, "<Unknown Modifier>",	10+40, *yco, 240, 20, NULL, 0.0, 0.0, 0, 0, "F-Curve Modifier Type. Click to make modifier active one.");
+			uiDefBut(block, LABEL, 1, "<Unknown Modifier>",	10+40, *yco, 150, 20, NULL, 0.0, 0.0, 0, 0, "F-Curve Modifier Type. Click to make modifier active one.");
 		
+		/* 'mute' button */
+		uiDefIconButBitS(block, ICONTOG, FMODIFIER_FLAG_MUTED, B_REDR, ICON_MUTE_IPO_OFF,	10+(width-60), *yco-1, 20, 20, &fcm->flag, 0.0, 0.0, 0, 0, "Modifier is temporarily muted (not evaluated).");
+		
 		/* delete button */
 		but= uiDefIconBut(block, BUT, B_REDR, ICON_X, 10+(width-30), *yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Delete F-Curve Modifier.");
 		uiButSetFunc(but, delete_fmodifier_cb, fcu, fcm);

Modified: branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c	2009-05-02 04:20:36 UTC (rev 20027)
+++ branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c	2009-05-02 04:51:14 UTC (rev 20028)
@@ -775,6 +775,37 @@
 	glDisable(GL_BLEND);
 }
 
+/* check if any FModifiers to draw controls for  - fcm is 'active' modifier */
+static short fcurve_needs_draw_fmodifier_controls (FCurve *fcu, FModifier *fcm)
+{
+	/* don't draw if there aren't any modifiers at all */
+	if (fcu->modifiers.first == NULL) 
+		return 0;
+	
+	/* if there's an active modifier - don't draw if it is cycles modifier, since
+	 * that basically still shows the original points
+	 */
+	if ((fcm) && (fcm->type == FMODIFIER_TYPE_CYCLES))
+		return 0;
+	
+	/* if only one modifier - don't draw if it is muted or disabled */
+	if (fcu->modifiers.first == fcu->modifiers.last) {
+		fcm= fcu->modifiers.first;
+		if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) 
+			return 0;
+	}
+	
+	/* if only active modifier - don't draw if it is muted or disabled */
+	if (fcm) {
+		if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) 
+			return 0;
+	}
+	
+	/* if we're still here, this means that there are modifiers with controls to be drawn */
+	// FIXME: what happens if all the modifiers were muted/disabled
+	return 1;
+}
+
 /* This is called twice from space_graph.c -> graph_main_area_draw()
  * Unselected then selected F-Curves are drawn so that they do not occlude each other.
  */
@@ -853,14 +884,8 @@
 		}
 		
 		/* 2) draw handles and vertices as appropriate based on active */
-		if ( ((fcm) && (fcm->type != FMODIFIER_TYPE_CYCLES)) || (fcu->modifiers.first && !fcm) ) {
-			/* draw controls for the 'active' modifier
-			 *	- there may not be an 'active' modifier on this curve to draw
-			 *	- this curve may not be active, so modifier controls shouldn't get drawn either
-			 *
-			 * NOTE: cycles modifier is currently an exception where the original points can still be edited, so
-			 *  	 	this branch is skipped... (TODO: set up the generic system for this so that we don't need special hacks like this)
-			 */
+		if (fcurve_needs_draw_fmodifier_controls(fcu, fcm)) {
+			/* only draw controls if this is the active modifier */
 			if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) {
 				switch (fcm->type) {
 					case FMODIFIER_TYPE_ENVELOPE: /* envelope */

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h	2009-05-02 04:20:36 UTC (rev 20027)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h	2009-05-02 04:51:14 UTC (rev 20028)
@@ -61,6 +61,8 @@
 	FMODIFIER_FLAG_EXPANDED		= (1<<1),
 		/* modifier is active one (in UI) for editing purposes */
 	FMODIFIER_FLAG_ACTIVE		= (1<<2),
+		/* user wants modifier to be skipped */
+	FMODIFIER_FLAG_MUTED		= (1<<3),
 } eFModifier_Flags; 
 
 /* --- */

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_fcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_fcurve.c	2009-05-02 04:20:36 UTC (rev 20027)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_fcurve.c	2009-05-02 04:51:14 UTC (rev 20028)
@@ -491,10 +491,15 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_EXPANDED);
 	RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI.");
 	
+	prop= RNA_def_property(srna, "muted", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_MUTED);
+	RNA_def_property_ui_text(prop, "Muted", "F-Curve Modifier will not be evaluated.");
+	
 		// XXX this is really an internal flag, but it may be useful for some tools to be able to access this...
 	prop= RNA_def_property(srna, "disabled", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-	RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_DISABLED	);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_DISABLED);
 	RNA_def_property_ui_text(prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated.");
 	
 		// TODO: setting this to true must ensure that all others in stack are turned off too...





More information about the Bf-blender-cvs mailing list