diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_fcurve.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_fcurve.c | 61 |
1 files changed, 48 insertions, 13 deletions
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 9dbc9a62aa4..efd571d2b18 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -127,9 +127,18 @@ static StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr) /* ****************************** */ #include "BKE_fcurve.h" -#include "BKE_depsgraph.h" #include "BKE_animsys.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +static bool rna_ChannelDriver_is_simple_expression_get(PointerRNA *ptr) +{ + ChannelDriver *driver = ptr->data; + + return BKE_driver_has_simple_expression(driver); +} + static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) { ID *id = ptr->id.data; @@ -138,8 +147,8 @@ static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA driver->flag &= ~DRIVER_FLAG_INVALID; /* TODO: this really needs an update guard... */ - DAG_relations_tag_update(bmain); - DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_relations_tag_update(bmain); + DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); WM_main_add_notifier(NC_SCENE | ND_FRAME, scene); } @@ -149,7 +158,7 @@ static void rna_ChannelDriver_update_expr(Main *bmain, Scene *scene, PointerRNA ChannelDriver *driver = ptr->data; /* tag driver as needing to be recompiled */ - driver->flag |= DRIVER_FLAG_RECOMPILE; + BKE_driver_invalidate_expression(driver, true, false); /* update_data() clears invalid flag and schedules for updates */ rna_ChannelDriver_update_data(bmain, scene, ptr); @@ -182,8 +191,7 @@ static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA * ChannelDriver *driver = ptr->data; rna_DriverTarget_update_data(bmain, scene, ptr); - driver->flag |= DRIVER_FLAG_RENAMEVAR; - + BKE_driver_invalidate_expression(driver, false, true); } /* ----------- */ @@ -479,6 +487,18 @@ static void rna_FCurve_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), Po rna_FCurve_update_data_ex((FCurve *)ptr->data); } +/* RNA update callback for F-Curves to indicate that there are copy-on-write tagging/flushing needed + * (e.g. for properties that affect how animation gets evaluated) + */ +static void rna_FCurve_update_eval(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + IdAdtTemplate *iat = (IdAdtTemplate *)ptr->id.data; + if (iat && iat->adt && iat->adt->action) { + /* action is separate datablock, needs separate tag */ + DEG_id_tag_update(&iat->adt->action->id, DEG_TAG_COPY_ON_WRITE); + } +} + static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr) { @@ -588,10 +608,22 @@ static void rna_FModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin ID *id = ptr->id.data; FModifier *fcm = (FModifier *)ptr->data; AnimData *adt = BKE_animdata_from_id(id); - DAG_id_tag_update(id, (GS(id->name) == ID_OB) ? OB_RECALC_OB : OB_RECALC_DATA); + + DEG_id_tag_update(id, (GS(id->name) == ID_OB) ? OB_RECALC_OB : OB_RECALC_DATA); + + /* tag datablock for time update so that animation is recalculated, + * as FModifiers affect how animation plays... + */ + DEG_id_tag_update(id, DEG_TAG_TIME); if (adt != NULL) { adt->recalc |= ADT_RECALC_ANIM; + + if (adt->action != NULL) { + /* action is separate datablock, needs separate tag */ + DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE); + } } + if (fcm->curve && fcm->type == FMODIFIER_TYPE_CYCLES) { calchandles_fcurve(fcm->curve); } @@ -1471,6 +1503,7 @@ static void rna_def_drivertarget(BlenderRNA *brna) prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable"); /* note: custom set function is ONLY to avoid rna setting a user for this. */ RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", NULL); @@ -1555,6 +1588,7 @@ static void rna_def_drivervar(BlenderRNA *brna) prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets"); RNA_def_property_struct_type(prop, "DriverTarget"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable"); /* Name Validity Flags */ @@ -1631,15 +1665,11 @@ static void rna_def_channeldriver(BlenderRNA *brna) prop = RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "variables", NULL); RNA_def_property_struct_type(prop, "DriverVariable"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver"); rna_def_channeldriver_variables(brna, prop); /* Settings */ - prop = RNA_def_property(srna, "show_debug_info", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_SHOWDEBUG); - RNA_def_property_ui_text(prop, "Show Debug Info", - "Show intermediate values for the driver calculations to allow debugging of drivers"); - prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_USE_SELF); RNA_def_property_ui_text(prop, "Use Self", @@ -1651,6 +1681,10 @@ static void rna_def_channeldriver(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DRIVER_FLAG_INVALID); RNA_def_property_ui_text(prop, "Invalid", "Driver could not be evaluated in past, so should be skipped"); + prop = RNA_def_property(srna, "is_simple_expression", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_ChannelDriver_is_simple_expression_get", NULL); + RNA_def_property_ui_text(prop, "Simple Expression", "The scripted expression can be evaluated without using the full python interpreter"); /* Functions */ RNA_api_drivers(srna); @@ -1915,6 +1949,7 @@ static void rna_def_fcurve(BlenderRNA *brna) /* Pointers */ prop = RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)"); @@ -1966,7 +2001,7 @@ static void rna_def_fcurve(BlenderRNA *brna) prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED); RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated"); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, "rna_FCurve_update_eval"); prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE); |