[Bf-blender-cvs] [830df9b33d3] blender2.8: Updates to manipulator API

Campbell Barton noreply at git.blender.org
Thu Jun 15 12:56:39 CEST 2017


Commit: 830df9b33d3e2afdf3bb23b469378899c34fda78
Author: Campbell Barton
Date:   Thu Jun 15 20:48:24 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB830df9b33d3e2afdf3bb23b469378899c34fda78

Updates to manipulator API

While this is work-in-progress from custom-manipulators branch
its stable so adding into 2.8 so we don't get too much out of sync.

- ManipulatorGroupType's are moved out of the manipulator-map and are now
  global (like operators, panels etc) and added into spaces as needed.
  Without this all operators that might ever use a manipulator in the 3D
  view would be polling the viewport.
- Add optional get/set callbacks for non-RNA properties
  Needed so re-usable manipulators can control values that
  don't correspond to a single properly or need conversion.
- Fix divide by zero bug in arrow manipulator (when moving zero pixels).

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

M	source/blender/CMakeLists.txt
M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/manipulator_library/CMakeLists.txt
M	source/blender/editors/manipulator_library/arrow2d_manipulator.c
M	source/blender/editors/manipulator_library/arrow3d_manipulator.c
M	source/blender/editors/manipulator_library/cage2d_manipulator.c
M	source/blender/editors/manipulator_library/dial3d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_draw_utils.c
M	source/blender/editors/manipulator_library/manipulator_library_intern.h
M	source/blender/editors/manipulator_library/manipulator_library_presets.c
M	source/blender/editors/manipulator_library/manipulator_library_utils.c
M	source/blender/editors/manipulator_library/primitive3d_manipulator.c
M	source/blender/editors/space_node/node_manipulators.c
M	source/blender/editors/space_node/space_node.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_manipulators.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/util/ed_util.c
D	source/blender/makesdna/DNA_manipulator_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/windowmanager/CMakeLists.txt
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_init_exit.c
M	source/blender/windowmanager/manipulators/WM_manipulator_api.h
M	source/blender/windowmanager/manipulators/WM_manipulator_types.h
M	source/blender/windowmanager/manipulators/intern/wm_manipulator.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
A	source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
A	source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
A	source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup_type.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
M	source/blender/windowmanager/manipulators/wm_manipulator_fn.h
M	source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index b46d3a3e64c..564ca473903 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -58,7 +58,6 @@ set(SRC_DNA_INC
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lightprobe_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_listBase.h
-	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_manipulator_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meshdata_types.h
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index a20d2925564..da5a0cdcf2b 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -161,10 +161,10 @@ void TRANSFORM_WGT_manipulator(struct wmManipulatorGroupType *wgt);
 
 void TRANSFORM_WGT_object(struct wmManipulatorGroupType *wgt);
 
-bool WIDGETGROUP_manipulator2d_poll(const struct bContext *C, struct wmManipulatorGroupType *wgrouptype);
-void WIDGETGROUP_manipulator2d_init(const struct bContext *C, struct wmManipulatorGroup *wgroup);
-void WIDGETGROUP_manipulator2d_refresh(const struct bContext *C, struct wmManipulatorGroup *wgroup);
-void WIDGETGROUP_manipulator2d_draw_prepare(const struct bContext *C, struct wmManipulatorGroup *wgroup);
+bool ED_widgetgroup_manipulator2d_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt);
+void ED_widgetgroup_manipulator2d_setup(const struct bContext *C, struct wmManipulatorGroup *mgroup);
+void ED_widgetgroup_manipulator2d_refresh(const struct bContext *C, struct wmManipulatorGroup *mgroup);
+void ED_widgetgroup_manipulator2d_draw_prepare(const struct bContext *C, struct wmManipulatorGroup *mgroup);
 
 
 /* Snapping */
diff --git a/source/blender/editors/manipulator_library/CMakeLists.txt b/source/blender/editors/manipulator_library/CMakeLists.txt
index 1d1dcf8b725..cb31627e09a 100644
--- a/source/blender/editors/manipulator_library/CMakeLists.txt
+++ b/source/blender/editors/manipulator_library/CMakeLists.txt
@@ -43,6 +43,7 @@ set(SRC
 	dial3d_manipulator.c
 	geom_arrow_manipulator.c
 	geom_cube_manipulator.c
+	geom_dial_manipulator.c
 	manipulator_draw_utils.c
 	manipulator_library_presets.c
 	manipulator_library_utils.c
diff --git a/source/blender/editors/manipulator_library/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/arrow2d_manipulator.c
index 1273710ff69..1798a3dbd6d 100644
--- a/source/blender/editors/manipulator_library/arrow2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/arrow2d_manipulator.c
@@ -39,7 +39,6 @@
 #include "BLI_math.h"
 #include "BLI_rect.h"
 
-#include "DNA_manipulator_types.h"
 #include "DNA_windowmanager_types.h"
 
 #include "ED_screen.h"
diff --git a/source/blender/editors/manipulator_library/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/arrow3d_manipulator.c
index a2a2feb811c..c856374661f 100644
--- a/source/blender/editors/manipulator_library/arrow3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/arrow3d_manipulator.c
@@ -40,7 +40,6 @@
 
 #include "BLI_math.h"
 
-#include "DNA_manipulator_types.h"
 #include "DNA_view3d_types.h"
 
 #include "ED_view3d.h"
@@ -90,7 +89,7 @@ typedef struct ArrowManipulator3D {
 
 /* -------------------------------------------------------------------- */
 
-static void manipulator_arrow_get_final_pos(wmManipulator *mpr, float r_pos[3])
+static void manipulator_arrow_position_get(wmManipulator *mpr, float r_pos[3])
 {
 	ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
 
@@ -194,7 +193,7 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
 	float final_pos[3];
 
 	manipulator_color_get(&arrow->manipulator, highlight, col);
-	manipulator_arrow_get_final_pos(&arrow->manipulator, final_pos);
+	manipulator_arrow_position_get(&arrow->manipulator, final_pos);
 
 	if (arrow->flag & ARROW_UP_VECTOR_SET) {
 		copy_v3_v3(rot[2], arrow->direction);
@@ -238,7 +237,7 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
 	}
 }
 
-static void manipulator_arrow_render_3d_intersect(
+static void manipulator_arrow_draw_select(
         const bContext *UNUSED(C), wmManipulator *mpr,
         int selectionbase)
 {
@@ -327,14 +326,17 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
 
 	normalize_v3(viewvec);
 	if (!use_vertical) {
-		float fac;
 		/* now find a plane parallel to the view vector so we can intersect with the arrow direction */
 		cross_v3_v3v3(tangent, viewvec, offset);
 		cross_v3_v3v3(plane, tangent, viewvec);
-		fac = dot_v3v3(plane, offset) / dot_v3v3(arrow->direction, plane);
 
+		const float plane_offset = dot_v3v3(plane, offset);
+		const float plane_dir = dot_v3v3(plane, arrow->direction);
+		const float fac = (plane_dir != 0.0f) ? (plane_offset / plane_dir) : 0.0f;
 		facdir = (fac < 0.0) ? -1.0 : 1.0;
-		mul_v3_v3fl(offset, arrow->direction, fac);
+		if (isfinite(fac)) {
+			mul_v3_v3fl(offset, arrow->direction, fac);
+		}
 	}
 	else {
 		facdir = (m_diff[1] < 0.0) ? -1.0 : 1.0;
@@ -344,18 +346,18 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
 	ManipulatorCommonData *data = &arrow->data;
 	const float ofs_new = facdir * len_v3(offset);
 
-	wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset");
+	wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset");
 
 	/* set the property for the operator and call its modal function */
-	if (mpr_prop->prop != NULL) {
+	if (WM_manipulator_property_is_valid(mpr_prop)) {
 		const bool constrained = arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED;
 		const bool inverted = arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED;
 		const bool use_precision = flag & WM_MANIPULATOR_TWEAK_PRECISE;
 		float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision);
 
-		manipulator_property_value_set(C, mpr, mpr_prop, value);
+		WM_manipulator_property_value_set(C, mpr, mpr_prop, value);
 		/* get clamped value */
-		value = manipulator_property_value_get(mpr, mpr_prop);
+		value = WM_manipulator_property_value_get(mpr, mpr_prop);
 
 		data->offset = manipulator_offset_from_value(data, value, constrained, inverted);
 	}
@@ -374,11 +376,11 @@ static void manipulator_arrow_invoke(
 {
 	ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
 	ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
-	wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset");
+	wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset");
 
 	/* Some manipulators don't use properties. */
-	if (mpr_prop && mpr_prop->prop) {
-		inter->init_value = RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
+	if (mpr_prop && WM_manipulator_property_is_valid(mpr_prop)) {
+		inter->init_value = WM_manipulator_property_value_get(mpr, mpr_prop);
 	}
 
 	inter->init_offset = arrow->data.offset;
@@ -388,16 +390,16 @@ static void manipulator_arrow_invoke(
 
 	inter->init_scale = mpr->scale;
 
-	manipulator_arrow_get_final_pos(mpr, inter->init_origin);
+	manipulator_arrow_position_get(mpr, inter->init_origin);
 
 	mpr->interaction_data = inter;
 }
 
-static void manipulator_arrow_property_update(wmManipulator *mnp, wmManipulatorProperty *mpr_prop)
+static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
 {
-	ArrowManipulator3D *arrow = (ArrowManipulator3D *)mnp;
+	ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
 	manipulator_property_data_update(
-	        mnp, &arrow->data, mpr_prop,
+	        mpr, &arrow->data, mpr_prop,
 	        (arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED) != 0,
 	        (arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED) != 0);
 }
@@ -411,7 +413,7 @@ static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool c
 	ManipulatorCommonData *data = &arrow->data;
 	ManipulatorInteraction *inter = mpr->interaction_data;
 
-	wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset");
+	wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset");
 	manipulator_property_value_reset(C, mpr, inter, mpr_prop);
 	data->offset = inter->init_offset;
 }
@@ -486,15 +488,15 @@ void ED_manipulator_arrow3d_set_line_len(wmManipulator *mpr, const float len)
 /**
  * Define a custom property UI range
  *
- * \note Needs to be called before WM_manipulator_def_property!
+ * \note Needs to be called before WM_manipulator_property_def_rna!
  */
 void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, const float max)
 {
 	ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
 
 	BLI_assert(min < max);
-	BLI_assert(!(WM_manipulator_get_property(mpr, "offset") && "Make sure this function "
-	           "is called before WM_manipulator_def_property"));
+	BLI_assert(!(WM_manipulator_property_find(mpr, "offset") && "Make sure this function "
+	           "is called before WM_manipulator_property_def_rna"));
 
 	arrow->data.range = max - min;
 	arrow->data.min = min;
@@ -504,13 +506,13 @@ void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, co
 /**
  * Define a custom factor for arrow min/max distance
  *
- * \note Needs to be called before WM_manipulator_def_property!
+ * \note Needs to be called before WM_manipulator_property_def_rna!
  */
 void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac)
 {
 	ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
-	BLI_assert(!(WM_manipulator_get_property(mpr, "offset") && "Make sure this function "
-	           "is called before WM_manipulator_def_property"));
+	BLI_assert(!(WM_manipulator_property_find(mpr, "offset") && "Make sure this function "
+	           "is called before WM_manipulator_property_def_rna"));
 
 	arrow->data.range_fac = range_fac;
 }
@@ -532,8 +534,8 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt)
 
 	/* api callbacks */
 	wt

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list