F-Curve Modifiers - Per-Modifier Muting:

It is now possible to mute individual modifiers so that they will not contribute to the final result.
This commit is contained in:
Joshua Leung
2009-05-02 04:51:14 +00:00
parent 4b025d6865
commit 4cf8900c70
5 changed files with 49 additions and 14 deletions

View File

@@ -2239,7 +2239,7 @@ float evaluate_fcurve (FCurve *fcu, float evaltime)
/* 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);
}
}

View File

@@ -871,17 +871,20 @@ static void graph_panel_modifier_draw(uiBlock *block, FCurve *fcu, FModifier *fc
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.");

View File

@@ -775,6 +775,37 @@ void graph_draw_ghost_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, Vie
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 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
}
/* 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 */

View File

@@ -61,6 +61,8 @@ enum {
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;
/* --- */

View File

@@ -491,10 +491,15 @@ void rna_def_fmodifier(BlenderRNA *brna)
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...