[Bf-blender-cvs] [2b8d599b3a9] blender2.8: Manipulator: add array get/set functions

Campbell Barton noreply at git.blender.org
Fri Jun 16 18:36:37 CEST 2017


Commit: 2b8d599b3a93c78661ff9a2c460b7144278409be
Author: Campbell Barton
Date:   Sat Jun 17 02:31:21 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB2b8d599b3a93c78661ff9a2c460b7144278409be

Manipulator: add array get/set functions

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

M	source/blender/windowmanager/manipulators/WM_manipulator_api.h
M	source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c

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

diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index 6a7585740cb..13c5e024b9d 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -121,10 +121,19 @@ void WM_manipulator_property_def_func(
 
 bool WM_manipulator_property_is_valid(
         const struct wmManipulatorProperty *mpr_prop);
-void  WM_manipulator_property_value_set(
-        struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, const float value);
 float WM_manipulator_property_value_get(
         const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop);
+void  WM_manipulator_property_value_set(
+        struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
+        const float value);
+
+void WM_manipulator_property_value_get_array(
+        const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
+        float *value, const int value_len);
+void WM_manipulator_property_value_set_array(
+        struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
+        const float *value, const int value_len);
+
 void WM_manipulator_property_range_get(
         const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
         float range[2]);
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
index 5a8eb1d68dc..e280fc6db79 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
@@ -123,6 +123,23 @@ bool WM_manipulator_property_is_valid(const wmManipulatorProperty *mpr_prop)
 	         (mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn));
 }
 
+float WM_manipulator_property_value_get(
+        const wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
+{
+	if (mpr_prop->custom_func.value_get_fn) {
+		float value = 0.0f;
+		mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, &value, 1);
+		return value;
+	}
+
+	if (mpr_prop->index == -1) {
+		return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
+	}
+	else {
+		return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index);
+	}
+}
+
 void WM_manipulator_property_value_set(
         bContext *C, const wmManipulator *mpr,
         wmManipulatorProperty *mpr_prop, const float value)
@@ -142,21 +159,32 @@ void WM_manipulator_property_value_set(
 	RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
 }
 
-float WM_manipulator_property_value_get(
-        const wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
+void WM_manipulator_property_value_get_array(
+        const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+        float *value, const int value_len)
 {
 	if (mpr_prop->custom_func.value_get_fn) {
-		float value = 0.0f;
-		mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, &value, 1);
-		return value;
+		mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, value, value_len);
+		return;
 	}
 
-	if (mpr_prop->index == -1) {
-		return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
-	}
-	else {
-		return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index);
+	BLI_assert(RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) == value_len);
+	return RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
+}
+
+void WM_manipulator_property_value_set_array(
+        bContext *C, const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+        const float *value, const int value_len)
+{
+	if (mpr_prop->custom_func.value_set_fn) {
+		mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, value, value_len);
+		return;
 	}
+
+	BLI_assert(RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) == value_len);
+	RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, value);
+
+	RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
 }
 
 void WM_manipulator_property_range_get(




More information about the Bf-blender-cvs mailing list