Hide 3D Cursor in Paint Modes (with exceptions)

= Hide 3D Cursor in Paint Modes (with exceptions)

In paint modes, the 3D Cursor mostly is rather useless so it's more annoying than useful. This patch aims to hide the cursor in cases it's not used.

Included exceptions (cases where cursor is drawn in paint modes):
* Active object is in weight paint mode and a selected bone in pose mode can be found
* Clone brush (only if //Clone from paint slot// is disabled)

There might be more exceptions where the cursor should be shown in paint modes, but those are all I could find for now. Feel free to hint me for more.

Note: After D1110 was rejected, Campbell and me discussed this a bit more on IRC and agreed that this behaviour might be a good solution.

Reviewers: psy-fi, campbellbarton

Reviewed By: psy-fi, campbellbarton

Projects: #user_interface

Differential Revision: https://developer.blender.org/D1113
This commit is contained in:
Julian Eisel 2015-02-17 03:26:03 +01:00
parent 4bb331dfd5
commit 0294327615
Notes: blender-bot 2023-02-14 09:28:29 +01:00
Referenced by issue #43716, Regression: Mask Modifier Creates "Web" of Phantom Lines
3 changed files with 46 additions and 5 deletions

View File

@ -904,8 +904,15 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN
ED_region_tag_redraw(ar);
break;
case NC_BRUSH:
if (wmn->action == NA_EDITED)
ED_region_tag_redraw_overlay(ar);
switch (wmn->action) {
case NA_EDITED:
ED_region_tag_redraw_overlay(ar);
/* used on brush changes - needed because 3d cursor
* has to be drawn if clone brush is selected */
case NA_SELECTED:
ED_region_tag_redraw(ar);
break;
}
break;
case NC_MATERIAL:
switch (wmn->data) {

View File

@ -42,6 +42,7 @@
#include "DNA_lamp_types.h"
#include "DNA_scene_types.h"
#include "DNA_world_types.h"
#include "DNA_brush_types.h"
#include "MEM_guardedalloc.h"
@ -3576,6 +3577,36 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3
}
static bool is_cursor_visible(Scene *scene)
{
Object *ob = OBACT;
/* don't draw cursor in paint modes, but with a few exceptions */
if (ob && ob->mode & OB_MODE_ALL_PAINT) {
/* exception: object is in weight paint and has deforming armature in pose mode */
if (ob->mode & OB_MODE_WEIGHT_PAINT) {
if (BKE_object_pose_armature_get(ob) != NULL) {
return true;
}
}
/* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
const Paint *p = BKE_paint_get_active(scene);
if (p && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) {
return true;
}
}
}
/* no exception met? then don't draw cursor! */
return false;
}
return true;
}
static void view3d_main_area_draw_info(const bContext *C, Scene *scene,
ARegion *ar, View3D *v3d,
const char *grid_unit, bool render_border)
@ -3609,7 +3640,10 @@ static void view3d_main_area_draw_info(const bContext *C, Scene *scene,
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
Object *ob;
drawcursor(scene, ar, v3d);
/* 3d cursor */
if (is_cursor_visible(scene)) {
drawcursor(scene, ar, v3d);
}
if (U.uiflag & USER_SHOW_ROTVIEWICON)
draw_view_axis(rv3d, &rect);

View File

@ -292,7 +292,7 @@ static void rna_Paint_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
Paint *paint = ptr->data;
Brush *br = paint->brush;
BKE_paint_invalidate_overlay_all();
WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
WM_main_add_notifier(NC_BRUSH | NA_SELECTED, br);
}
static void rna_ImaPaint_viewport_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
@ -730,7 +730,7 @@ static void rna_def_image_paint(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE);
RNA_def_property_ui_text(prop, "Clone Map",
"Use another UV map as clone source, otherwise use the 3D cursor as the source");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_viewport_update");
/* integers */