[Bf-blender-cvs] [91d16ceb56a] sculpt-mode-features: View Navigation: 2D viewport panning

Pablo Dobarro noreply at git.blender.org
Wed Mar 13 17:36:34 CET 2019


Commit: 91d16ceb56aa6a1d04111424bc18c902b23d5a44
Author: Pablo Dobarro
Date:   Wed Mar 13 17:26:54 2019 +0100
Branches: sculpt-mode-features
https://developer.blender.org/rB91d16ceb56aa6a1d04111424bc18c902b23d5a44

View Navigation: 2D viewport panning

This option helps to keep the working area under control when working
with brushes, especially if this feature is used with rotate around
selection enabled. Now, panning speed does not depend on zoom level and
it behaves more similarly to a 2D environment.

The option certainly needs a better name and description, and it could
be a good idea to hide and disable it if rotate around selection is
disabled.

Mode info: D3931

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

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index c11a802c90f..812b1590400 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1405,6 +1405,7 @@ class USERPREF_PT_navigation_orbit(PreferencePanel, Panel):
         flow.prop(inputs, "use_rotate_around_active")
         flow.prop(inputs, "use_auto_perspective")
         flow.prop(inputs, "use_mouse_depth_navigate")
+        flow.prop(inputs, "use_2d_viewport_panning")
         if sys.platform == "darwin":
             flow.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
 
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 005e78fbc1a..b9a2be2d6ef 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -125,6 +125,7 @@ static void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3
 typedef struct ViewOpsData {
 	/** Context pointers (assigned by #viewops_data_alloc). */
 	Main *bmain;
+	bContext *C;
 	Scene *scene;
 	ScrArea *sa;
 	ARegion *ar;
@@ -499,7 +500,7 @@ static void viewops_data_create(
 		negate_v3_v3(tvec, rv3d->ofs);
 		vod->init.zfac = ED_view3d_calc_zfac(rv3d, tvec, NULL);
 	}
-
+	vod->C = C;
 	vod->reverse = 1.0f;
 	if (rv3d->persmat[2][1] < 0.0f)
 		vod->reverse = -1.0f;
@@ -1615,11 +1616,26 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y)
 	}
 	else {
 		float dvec[3];
-		float mval_f[2];
 
-		mval_f[0] = x - vod->prev.event_xy[0];
-		mval_f[1] = y - vod->prev.event_xy[1];
-		ED_view3d_win_to_delta(vod->ar, mval_f, dvec, vod->init.zfac);
+		if (U.uiflag2 & USER_2D_VIEWPORT_PANNING) {
+			float nvec[3];
+			float center[3];
+			float ssdp[3];
+
+			view3d_orbit_calc_center(vod->C,center);
+			ED_view3d_project(vod->ar, center, ssdp);
+			ssdp[0] = ssdp[0] + x - vod->prev.event_xy[0];
+			ssdp[1] = ssdp[1] + y - vod->prev.event_xy[1];
+			ED_view3d_win_to_3d(vod->v3d, vod->ar, center, ssdp, nvec);
+			sub_v3_v3v3(dvec,  nvec, center);
+		}
+		else {
+			float mval_f[2];
+
+			mval_f[0] = x - vod->prev.event_xy[0];
+			mval_f[1] = y - vod->prev.event_xy[1];
+			ED_view3d_win_to_delta(vod->ar, mval_f, dvec, vod->init.zfac);
+		}
 
 		add_v3_v3(vod->rv3d->ofs, dvec);
 
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 048b7e60d57..5950ceac41b 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -900,6 +900,7 @@ typedef enum eUserpref_UI_Flag2 {
 	USER_REGION_OVERLAP			= (1 << 1),
 	USER_TRACKPAD_NATURAL		= (1 << 2),
 	USER_EDIT_MODE_SMOOTH_WIRE	= (1 << 3),
+	USER_2D_VIEWPORT_PANNING	= (1 << 4),
 } eUserpref_UI_Flag2;
 
 /** #UserDef.tablet_api */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index dda36d89eb1..3d57837babe 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -4679,6 +4679,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
 	        "When entering numbers while transforming, "
 	        "default to advanced mode for full math expression evaluation");
 
+	/* View Panning */
+	prop = RNA_def_property(srna, "use_2d_viewport_panning", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_2D_VIEWPORT_PANNING);
+	RNA_def_property_ui_text(prop, "2D viewport panning", "Keeps the rotation center under the cursor when panning");
+
 	/* View Navigation */
 	prop = RNA_def_property(srna, "navigation_mode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "navigation_mode");



More information about the Bf-blender-cvs mailing list