diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_animation.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_animation.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index c9c8a791545..3d11e7bb723 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -73,10 +73,11 @@ const EnumPropertyItem rna_enum_keying_flag_items[] = { #include "BLI_math_base.h" #include "BKE_animsys.h" -#include "BKE_depsgraph.h" #include "BKE_fcurve.h" #include "BKE_nla.h" +#include "DEG_depsgraph.h" + #include "DNA_object_types.h" #include "WM_api.h" @@ -88,7 +89,7 @@ static void rna_AnimData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point /* tag for refresh so that scheduled updates (e.g. action changed) will * get computed and reflected in the scene [#34869] */ - DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); } static int rna_AnimData_action_editable(PointerRNA *ptr, const char **UNUSED(r_info)) @@ -114,7 +115,7 @@ static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value) adt = BKE_animdata_from_id(ownerId); if (adt) { adt->recalc |= ADT_RECALC_ANIM; - DAG_id_tag_update(ownerId, OB_RECALC_TIME); + DEG_id_tag_update(ownerId, OB_RECALC_TIME); } } @@ -584,6 +585,34 @@ static FCurve *rna_Driver_find(AnimData *adt, ReportList *reports, const char *d return list_find_fcurve(&adt->drivers, data_path, index); } +bool rna_AnimaData_override_apply( + PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, + PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *UNUSED(prop_storage), + const int len_dst, const int len_src, const int len_storage, + IDOverrideStaticPropertyOperation *opop) +{ + BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0); + BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_REPLACE && "Unsupported RNA override operation on animdata pointer"); + UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop); + + /* AnimData is a special case, since you cannot edit/replace it, it's either existent or not. */ + AnimData *adt_dst = RNA_property_pointer_get(ptr_dst, prop_dst).data; + AnimData *adt_src = RNA_property_pointer_get(ptr_src, prop_src).data; + + if (adt_dst == NULL && adt_src != NULL) { + /* Copy anim data from reference into final local ID. */ + BKE_animdata_copy_id(NULL, ptr_dst->id.data, ptr_src->id.data, false); + return true; + } + else if (adt_dst != NULL && adt_src == NULL) { + /* Override has cleared/removed anim data from its reference. */ + BKE_animdata_free(ptr_dst->id.data, true); + return true; + } + + return false; +} + #else /* helper function for Keying Set -> keying settings */ @@ -998,6 +1027,8 @@ void rna_def_animdata_common(StructRNA *srna) prop = RNA_def_property(srna, "animation_data", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "adt"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC); + RNA_def_property_override_funcs(prop, NULL, NULL, "rna_AnimaData_override_apply"); RNA_def_property_ui_text(prop, "Animation Data", "Animation data for this data-block"); } @@ -1021,7 +1052,7 @@ static void rna_def_animdata(BlenderRNA *brna) /* Active Action */ prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); /* this flag as well as the dynamic test must be defined for this to be editable... */ - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT | PROP_OVERRIDABLE_STATIC); RNA_def_property_pointer_funcs(prop, NULL, "rna_AnimData_action_set", NULL, "rna_Action_id_poll"); RNA_def_property_editable_func(prop, "rna_AnimData_action_editable"); RNA_def_property_ui_text(prop, "Action", "Active Action for this data-block"); |