[Bf-blender-cvs] [f1b10fa29d8] temp-dynamic-overrides: Initial step to support dynoverride eval in RNA code.

Bastien Montagne noreply at git.blender.org
Thu May 17 16:45:25 CEST 2018


Commit: f1b10fa29d814505a6d391b7936c1e8891f8ee52
Author: Bastien Montagne
Date:   Thu May 17 16:43:26 2018 +0200
Branches: temp-dynamic-overrides
https://developer.blender.org/rBf1b10fa29d814505a6d391b7936c1e8891f8ee52

Initial step to support dynoverride eval in RNA code.

Using as much as possible static override code. Againm ideally we'll
merge back both into a fully single system after everything is working.

Also found a way to reduce a bit verbosity of code here...

===================================================================

M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_animation.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_internal_types.h
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_pose.c
M	source/blender/makesrna/intern/rna_rna.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 03ab08620f3..a7716d0ed45 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -7509,7 +7509,7 @@ static bool rna_property_override_operation_apply(
 	            ptr_local, ptr_override, ptr_storage,
 	            prop_local, prop_override, prop_storage,
 	            len_local, len_reference, len_storage,
-	            opop);
+	            opop, NULL);
 }
 
 /**
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 6eed4153e0d..e7402983230 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -78,6 +78,8 @@ const EnumPropertyItem rna_enum_keying_flag_items[] = {
 
 #include "DEG_depsgraph.h"
 
+#include "DNA_ID.h"
+#include "DNA_layer_types.h"
 #include "DNA_object_types.h"
 
 #include "WM_api.h"
@@ -589,8 +591,13 @@ 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)
+        IDOverrideStaticPropertyOperation *opop, DynamicOverrideProperty *dyn_prop)
 {
+	if (dyn_prop != NULL) {
+		printf("%s: unsupported dynamic override...", __func__);
+		return false;
+	}
+
 	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);
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 121d45f791d..8f4b673e577 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -36,6 +36,7 @@
 #define RNA_MAGIC ((int)~0)
 
 struct Depsgraph;
+struct DynamicOverrideProperty;
 struct FreestyleSettings;
 struct ID;
 struct IDOverrideStatic;
@@ -209,7 +210,7 @@ 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 IDOverrideStaticPropertyOperation *opop);
+        struct IDOverrideStaticPropertyOperation *opop, struct DynamicOverrideProperty *dyn_prop);
 
 void rna_def_animviz_common(struct StructRNA *srna);
 void rna_def_motionpath_common(struct StructRNA *srna);
@@ -426,7 +427,7 @@ bool rna_property_override_apply_default(
         struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage,
         struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage,
         const int len_dst, const int len_src, const int len_storage,
-        struct IDOverrideStaticPropertyOperation *opop);
+        struct IDOverrideStaticPropertyOperation *opop, struct DynamicOverrideProperty *dyn_prop);
 
 
 /* Builtin Property Callbacks */
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 88efff30481..65f3bca0750 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -40,6 +40,7 @@ struct PointerRNA;
 struct FunctionRNA;
 struct CollectionPropertyIterator;
 struct bContext;
+struct DynamicOverrideProperty;
 struct IDOverrideStatic;
 struct IDOverrideStaticProperty;
 struct IDOverrideStaticPropertyOperation;
@@ -166,7 +167,7 @@ typedef bool (*RNAPropOverrideApply)(
         struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage,
         struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage,
         const int len_dst, const int len_src, const int len_storage,
-        struct IDOverrideStaticPropertyOperation *opop);
+        struct IDOverrideStaticPropertyOperation *opop, struct DynamicOverrideProperty *dyn_prop);
 
 /* Container - generic abstracted container of RNA properties */
 typedef struct ContainerRNA {
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index f57489f1b89..eeeaa72020e 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -176,6 +176,7 @@ const EnumPropertyItem rna_enum_object_axis_items[] = {
 #include "DNA_constraint_types.h"
 #include "DNA_ID.h"
 #include "DNA_lattice_types.h"
+#include "DNA_layer_types.h"
 #include "DNA_node_types.h"
 
 #include "BKE_armature.h"
@@ -1135,8 +1136,13 @@ bool rna_Object_constraints_override_apply(
         PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage),
         PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage),
         const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage),
-        IDOverrideStaticPropertyOperation *opop)
+        IDOverrideStaticPropertyOperation *opop, DynamicOverrideProperty *dyn_prop)
 {
+	if (dyn_prop != NULL) {
+		printf("%s: unsupported dynamic override...", __func__);
+		return false;
+	}
+
 	BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER &&
 	           "Unsupported RNA override operation on constraints collection");
 
@@ -1209,8 +1215,13 @@ bool rna_Object_modifiers_override_apply(
         PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage),
         PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage),
         const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage),
-        IDOverrideStaticPropertyOperation *opop)
+        IDOverrideStaticPropertyOperation *opop, DynamicOverrideProperty *dyn_prop)
 {
+	if (dyn_prop != NULL) {
+		printf("%s: unsupported dynamic override...", __func__);
+		return false;
+	}
+
 	BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER &&
 	           "Unsupported RNA override operation on modifiers collection");
 
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 014ac426b54..8aed36dea9d 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -99,6 +99,7 @@ const EnumPropertyItem rna_enum_color_sets_items[] = {
 #include "BKE_armature.h"
 
 #include "DNA_userdef_types.h"
+#include "DNA_layer_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -569,8 +570,13 @@ bool rna_PoseChannel_constraints_override_apply(
         PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage),
         PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage),
         const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage),
-        IDOverrideStaticPropertyOperation *opop)
+        IDOverrideStaticPropertyOperation *opop, DynamicOverrideProperty *dyn_prop)
 {
+	if (dyn_prop != NULL) {
+		printf("%s: unsupported dynamic override...", __func__);
+		return false;
+	}
+
 	BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER &&
 	           "Unsupported RNA override operation on constraints collection");
 
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 8cd0f94f546..02a2465ff34 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -26,6 +26,7 @@
 
 #include <stdlib.h>
 
+#include "DNA_layer_types.h"
 #include "DNA_ID.h"
 
 #include "BLI_utildefines.h"
@@ -2038,55 +2039,59 @@ bool rna_property_override_apply_default(
         PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage,
         PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *prop_storage,
         const int len_dst, const int len_src, const int len_storage,
-        IDOverrideStaticPropertyOperation *opop)
+        IDOverrideStaticPropertyOperation *opop, DynamicOverrideProperty *dyn_prop)
 {
+#define RNA_PROPERTY_GET_SINGLE(_typename, _ptr, _prop, _index) \
+	(is_array ? RNA_property_##_typename##_get_index((_ptr), (_prop), (_index)) : \
+	            RNA_property_##_typename##_get((_ptr), (_prop)))
+#define RNA_PROPERTY_SET_SINGLE(_typename, _ptr, _prop, _index, _value) \
+	(is_array ? RNA_property_##_typename##_set_index((_ptr), (_prop), (_index), (_value)) : \
+	            RNA_property_##_typename##_set((_ptr), (_prop), (_value)))
+
+
+	BLI_assert(opop != NULL || dyn_prop != NULL);
 	BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage));
 	UNUSED_VARS_NDEBUG(len_src, len_storage);
 
-	const int index = opop->subitem_reference_index;
-	const short override_op = opop->operation;
+	/* Dynamic override does not support sub-item array currently... */
+	const bool is_array = len_dst > 0;
+	const int index = is_array ? (opop != NULL ? opop->subitem_reference_index : -1) : 0;
+	const short override_op = opop != NULL ? opop->operation : dyn_prop->operation;
 
+	const bool do_free_array = (opop != NULL) && (len_dst > RNA_STACK_ARRAY);
 	switch (RNA_property_type(prop_dst)) {
 		case PROP_BOOLEAN:
-			if (len_dst) {
-				if (index == -1) {
-					int array_stack_a[RNA_STACK_ARRAY];
-					int *array_a;
-
-					array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) : array_stack_a;
+			if (is_array && index == -1) {
+				int array_stack_a[RNA_STACK_ARRAY];
+				int *array_a;
 
+				if (opop != NULL) {
+					array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) :
+					                                        array_stack_a;
 					RNA_property_boolean_get_array(ptr_src, prop_src, array_a);
-
-					switch (override_op) {
-						case IDOVERRIDESTATIC_OP_REPLACE:
-							RNA_proper

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list