[Bf-blender-cvs] [61ca31f28b8] id_override_static: Add custom override_apply func for animdata.
Bastien Montagne
noreply at git.blender.org
Thu Nov 16 10:26:17 CET 2017
Commit: 61ca31f28b80696402cd1a9c78e36ddfb155649e
Author: Bastien Montagne
Date: Thu Nov 16 10:10:33 2017 +0100
Branches: id_override_static
https://developer.blender.org/rB61ca31f28b80696402cd1a9c78e36ddfb155649e
Add custom override_apply func for animdata.
This makes creating animation in overridden ID working, at least in the
most basic case...
===================================================================
M source/blender/makesrna/intern/rna_animation.c
M source/blender/makesrna/intern/rna_internal.h
===================================================================
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 47f2a3a582f..06527817ffe 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -585,6 +585,33 @@ 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_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage,
+ PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *UNUSED(prop_storage),
+ const int len_local, const int len_reference, const int len_storage,
+ IDOverridePropertyOperation *opop)
+{
+ BLI_assert(len_local == len_reference && (!ptr_storage || len_local == len_storage));
+ BLI_assert(opop->operation == IDOVERRIDE_OP_REPLACE && "Unsupported RNA override operation on animdata pointer");
+
+ /* AnimData is a special case, since you cannot edit/replace it, it's either existent or not. */
+ AnimData *adt_local = RNA_property_pointer_get(ptr_local, prop_local).data;
+ AnimData *adt_reference = RNA_property_pointer_get(ptr_reference, prop_reference).data;
+
+ if (adt_local == NULL && adt_reference != NULL) {
+ /* Copy anim data from reference into final local ID. */
+ BKE_animdata_copy_id(NULL, ptr_local->id.data, ptr_reference->id.data, false);
+ return true;
+ }
+ else if (adt_local != NULL && adt_reference == NULL) {
+ /* Override has cleared/removed anim data from its reference. */
+ BKE_animdata_free(ptr_local->id.data, true);
+ return true;
+ }
+
+ return false;
+}
+
#else
/* helper function for Keying Set -> keying settings */
@@ -1000,6 +1027,7 @@ void rna_def_animdata_common(StructRNA *srna)
RNA_def_property_pointer_sdna(prop, NULL, "adt");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_OVERRIDABLE);
+ 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");
}
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index cf81217b72b..a39610e7315 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -203,6 +203,12 @@ void RNA_def_mask(struct BlenderRNA *brna);
void rna_def_animdata_common(struct StructRNA *srna);
+bool rna_AnimaData_override_apply(
+ struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage,
+ struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage,
+ const int len_local, const int len_reference, const int len_storage,
+ struct IDOverridePropertyOperation *opop);
+
void rna_def_animviz_common(struct StructRNA *srna);
void rna_def_motionpath_common(struct StructRNA *srna);
More information about the Bf-blender-cvs
mailing list