[Bf-blender-cvs] [f305aba8688] blender2.8: Make sure 'use_property_button_exec' can deal with arrays as well

Dalai Felinto noreply at git.blender.org
Wed May 10 20:36:55 CEST 2017


Commit: f305aba8688a2b88b6495985435cc79213a22a3f
Author: Dalai Felinto
Date:   Wed May 10 20:36:11 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBf305aba8688a2b88b6495985435cc79213a22a3f

Make sure 'use_property_button_exec' can deal with arrays as well

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

M	source/blender/editors/interface/interface_ops.c
M	source/blender/makesrna/RNA_define.h
M	source/blender/makesrna/intern/rna_internal_types.h

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

diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index c130064ca12..09388ff1a18 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -353,11 +353,21 @@ static int use_property_button_exec(bContext *C, wmOperator *UNUSED(op))
 		return OPERATOR_CANCELLED;
 	}
 
+	int array_len = RNA_property_array_length(&scene_props_ptr, prop);
+	bool is_array = array_len != 0;
+
 	switch (RNA_property_type(prop)) {
 		case PROP_FLOAT:
 		{
-			float value = RNA_property_float_get(&scene_props_ptr, prop);
-			BKE_collection_engine_property_add_float(props, identifier, value);
+			if (is_array) {
+				float values[RNA_MAX_ARRAY_LENGTH];
+				RNA_property_float_get_array(&scene_props_ptr, prop, values);
+				BKE_collection_engine_property_add_float_array(props, identifier, values, array_len);
+			}
+			else {
+				float value = RNA_property_float_get(&scene_props_ptr, prop);
+				BKE_collection_engine_property_add_float(props, identifier, value);
+			}
 			break;
 		}
 		case PROP_ENUM:
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 6e62313b00a..54938b236d5 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -37,6 +37,14 @@
 extern "C" {
 #endif
 
+#ifdef UNIT_TEST
+#define RNA_MAX_ARRAY_LENGTH 64
+#else
+#define RNA_MAX_ARRAY_LENGTH 32
+#endif
+
+#define RNA_MAX_ARRAY_DIMENSION 3
+
 /* Blender RNA */
 
 BlenderRNA *RNA_create(void);
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index df591659fdb..c412d110e5e 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -45,15 +45,6 @@ struct GHash;
 struct Main;
 struct Scene;
 
-#ifdef UNIT_TEST
-#define RNA_MAX_ARRAY_LENGTH 64
-#else
-#define RNA_MAX_ARRAY_LENGTH 32
-#endif
-
-#define RNA_MAX_ARRAY_DIMENSION 3
-
-
 /* store local properties here */
 #define RNA_IDP_UI "_RNA_UI"




More information about the Bf-blender-cvs mailing list