Page MenuHome
Paste P1067

D5385 alternative (View3D: 2D viewport navigation mode)
ActivePublic

Authored by Campbell Barton (campbellbarton) on Aug 7 2019, 10:40 AM.
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 48aaf55bdfa..ee58036e06f 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1466,6 +1466,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_paint_depth_navigate")
if sys.platform == "darwin":
flow.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index e987a623d0b..9bee0ee4047 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -523,7 +523,8 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->flag &= ~(USER_FLAG_UNUSED_4);
- userdef->uiflag &= ~(USER_HEADER_FROM_PREF | USER_UIFLAG_UNUSED_12 | USER_UIFLAG_UNUSED_22);
+ userdef->uiflag &= ~(USER_HEADER_FROM_PREF | USER_DEPTH_NAVIGATE_PAINT |
+ USER_UIFLAG_UNUSED_22);
}
if (!USER_VERSION_ATLEAST(280, 41)) {
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 6144f5751f2..34a087ab76e 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -842,6 +842,21 @@ static void stroke_done(struct bContext *C, struct wmOperator *op)
BLI_freelistN(&stroke->line);
paint_stroke_data_free(op);
+
+ if (U.uiflag & USER_DEPTH_NAVIGATE_PAINT) {
+ if (ups->last_stroke_valid && ups->average_stroke_counter > 0) {
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ if (v3d && rv3d) {
+ if (!(rv3d->persp != RV3D_PERSP || v3d->ob_centre_cursor || v3d->ob_centre)) {
+ float dist_co[3];
+ float fac = 1.0f / ups->average_stroke_counter;
+ mul_v3_v3fl(dist_co, ups->average_stroke_accum, fac);
+ ED_view3d_distance_set_from_location(rv3d, dist_co, v3d->clip_start);
+ }
+ }
+ }
+ }
}
/* Returns zero if the stroke dots should not be spaced, non-zero otherwise */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index b8914c7a74f..f9f56df66a2 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -928,7 +928,7 @@ typedef enum eUserpref_UI_Flag {
USER_MENUOPENAUTO = (1 << 9),
USER_DEPTH_CURSOR = (1 << 10),
USER_AUTOPERSP = (1 << 11),
- USER_UIFLAG_UNUSED_12 = (1 << 12), /* cleared */
+ USER_DEPTH_NAVIGATE_PAINT = (1 << 12),
USER_GLOBALUNDO = (1 << 13),
USER_ORBIT_SELECTION = (1 << 14),
USER_DEPTH_NAVIGATE = (1 << 15),
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 38cb3e1d222..170b624682b 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -5162,6 +5162,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
"Auto Depth",
"Use the depth under the mouse to improve view pan/rotate/zoom functionality");
+ prop = RNA_def_property(srna, "use_paint_depth_navigate", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DEPTH_NAVIGATE_PAINT);
+ RNA_def_property_ui_text(
+ prop, "Auto Depth Paint", "Use the depth of paint brush strokes when painting");
+
prop = RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "uiflag", USER_CAM_LOCK_NO_PARENT);
RNA_def_property_ui_text(prop,