[Bf-blender-cvs] [87f8bb8d1d] master: Fix another part of T50565: Planar constraints were always initialized to accurate transform

Sergey Sharybin noreply at git.blender.org
Thu Mar 2 12:18:53 CET 2017


Commit: 87f8bb8d1d3692845b92545a4cbe5c1b5c03ec36
Author: Sergey Sharybin
Date:   Thu Mar 2 12:18:07 2017 +0100
Branches: master
https://developer.blender.org/rB87f8bb8d1d3692845b92545a4cbe5c1b5c03ec36

Fix another part of T50565: Planar constraints were always initialized to accurate transform

Now it is defined by keymap.

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

M	source/blender/editors/physics/physics_ops.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_ops.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/transform/transform_ops.c

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

diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 0c907f1975..b1d708ebc0 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -138,13 +138,21 @@ static void keymap_particle(wmKeyConfig *keyconf)
 	RNA_boolean_set(kmi->ptr, "unselected", true);
 
 	/* Shift+LMB behavior first, so it has priority over KM_ANY item below. */
-	kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+	kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
 	RNA_boolean_set(kmi->ptr, "release_confirm", true);
 	RNA_boolean_set(kmi->ptr, "use_planar_constraint", true);
+	RNA_boolean_set(kmi->ptr, "use_accurate", false);
+
+	kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+	RNA_boolean_set(kmi->ptr, "release_confirm", true);
+	RNA_boolean_set(kmi->ptr, "use_planar_constraint", false);
+	RNA_boolean_set(kmi->ptr, "use_accurate", true);
+
 	/* Using KM_ANY here to allow holding modifiers before starting to transform. */
 	kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
 	RNA_boolean_set(kmi->ptr, "release_confirm", true);
 	RNA_boolean_set(kmi->ptr, "use_planar_constraint", false);
+	RNA_boolean_set(kmi->ptr, "use_accurate", false);
 
 	WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index df649a59f0..04670f5a84 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4798,7 +4798,10 @@ void VIEW3D_OT_manipulator(wmOperatorType *ot)
 
 	prop = RNA_def_boolean(ot->srna, "use_planar_constraint", false, "Planar Constraint", "Limit the transformation to the "
 	                       "two axes that have not been clicked (translate/scale only)");
-	RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+	RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
+
+	prop = RNA_def_boolean(ot->srna, "use_accurate", false, "Accurate", "Use accurate transformation");
+	RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
 }
 
 static int enable_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 0fa6841fe2..d71639c35d 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -241,13 +241,21 @@ void view3d_keymap(wmKeyConfig *keyconf)
 	keymap = WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
 
 	/* Shift+LMB behavior first, so it has priority over KM_ANY item below. */
-	kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+	kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
 	RNA_boolean_set(kmi->ptr, "release_confirm", true);
 	RNA_boolean_set(kmi->ptr, "use_planar_constraint", true);
+	RNA_boolean_set(kmi->ptr, "use_accurate", false);
+
+	kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+	RNA_boolean_set(kmi->ptr, "release_confirm", true);
+	RNA_boolean_set(kmi->ptr, "use_planar_constraint", false);
+	RNA_boolean_set(kmi->ptr, "use_accurate", true);
+
 	/* Using KM_ANY here to allow holding modifiers before starting to transform. */
 	kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
 	RNA_boolean_set(kmi->ptr, "release_confirm", true);
 	RNA_boolean_set(kmi->ptr, "use_planar_constraint", false);
+	RNA_boolean_set(kmi->ptr, "use_accurate", false);
 
 	WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
 	
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 1916f9b4da..7d9063c328 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2176,7 +2176,14 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 	calculateCenter(t);
 
 	if (event) {
-		initMouseInput(t, &t->mouse, t->center2d, event->mval, event->shift);
+		/* Initialize accurate transform to settings requested by keymap. */
+		bool use_accurate = false;
+		if ((prop = RNA_struct_find_property(op->ptr, "use_accurate")) && RNA_property_is_set(op->ptr, prop)) {
+			if (RNA_property_boolean_get(op->ptr, prop)) {
+				use_accurate = true;
+			}
+		}
+		initMouseInput(t, &t->mouse, t->center2d, event->mval, use_accurate);
 	}
 
 	switch (mode) {
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index e141724f2d..c906c467f8 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1836,6 +1836,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 	int constraint_axis[3] = {0, 0, 0};
 	int val;
 	const bool use_planar = RNA_boolean_get(op->ptr, "use_planar_constraint");
+	const bool use_accurate = RNA_boolean_get(op->ptr, "use_accurate");
 
 	if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return 0;
 	if (!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return 0;
@@ -1851,6 +1852,13 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 		drawflags = manipulator_selectbuf(sa, ar, event->mval, 0.2f * (float)U.tw_hotspot);
 		if (drawflags == 0) drawflags = val;
 
+		/* We are not doing translation but were requested to do planar constraints.
+		 * This wouldn't work, so we give other keymaps a chance.
+		 */
+		if ((drawflags & MAN_TRANS_C) == 0 && use_planar) {
+			return 0;
+		}
+
 		if (drawflags & MAN_TRANS_C) {
 			switch (drawflags) {
 				case MAN_TRANS_C:
@@ -1881,6 +1889,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 					break;
 			}
 			RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
+			RNA_boolean_set(op->ptr, "use_accurate", use_accurate);
 			WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, op->ptr);
 		}
 		else if (drawflags & MAN_SCALE_C) {
@@ -1911,6 +1920,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 					break;
 			}
 			RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
+			RNA_boolean_set(op->ptr, "use_accurate", use_accurate);
 			WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, op->ptr);
 		}
 		else if (drawflags == MAN_ROT_T) { /* trackball need special case, init is different */
@@ -1924,6 +1934,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 			if ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) && RNA_property_is_set(op->ptr, prop)) {
 				RNA_property_boolean_set(&props_ptr, prop, RNA_property_boolean_get(op->ptr, prop));
 			}
+			RNA_boolean_set(op->ptr, "use_accurate", use_accurate);
 			WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
 			WM_operator_properties_free(&props_ptr);
 		}
@@ -1940,6 +1951,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 					break;
 			}
 			RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
+			RNA_boolean_set(op->ptr, "use_accurate", use_accurate);
 			WM_operator_name_call(C, "TRANSFORM_OT_rotate", WM_OP_INVOKE_DEFAULT, op->ptr);
 		}
 	}
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index cbe58ddf58..2a97384cf7 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -569,6 +569,9 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
 		// Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit
 		/*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
 		//RNA_def_property_flag(prop, PROP_HIDDEN);
+
+		prop = RNA_def_boolean(ot->srna, "use_accurate", 0, "Accurate", "Use accurate transformation");
+		RNA_def_property_flag(prop, PROP_HIDDEN);
 	}
 }




More information about the Bf-blender-cvs mailing list