Sculpt: Add color alpha controls to the brush cursor

Previously the alpha was hardcoded to 0.7. Now it is possible to control
the cursor alpha by changing the alpha color of the cursor color
property. New alpha default is 0.9. This, with the new saturated colors,
should make the cursor more visible on highdpi screens.

I also removed the cache location preview as it is too visible right now
with the new alpha and color values.

Reviewed By: billreynish

Differential Revision: https://developer.blender.org/D6433
This commit is contained in:
Pablo Dobarro 2019-12-30 16:41:20 +01:00
parent 394b48029c
commit 0314561684
7 changed files with 22 additions and 18 deletions

View File

@ -893,9 +893,11 @@ void BKE_brush_debug_print_state(Brush *br)
BR_TEST(add_col[0], f);
BR_TEST(add_col[1], f);
BR_TEST(add_col[2], f);
BR_TEST(add_col[3], f);
BR_TEST(sub_col[0], f);
BR_TEST(sub_col[1], f);
BR_TEST(sub_col[2], f);
BR_TEST(sub_col[3], f);
printf("\n");
@ -1006,6 +1008,11 @@ void BKE_brush_sculpt_reset(Brush *br)
}
/* Cursor colors */
/* Default Alpha */
br->add_col[3] = 0.90f;
br->sub_col[3] = 0.90f;
switch (br->sculpt_tool) {
case SCULPT_TOOL_DRAW:
case SCULPT_TOOL_DRAW_SHARP:

View File

@ -4317,5 +4317,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
/* Brush cursor alpha */
for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
br->add_col[3] = 0.9f;
br->sub_col[3] = 0.9f;
}
}
}

View File

@ -1329,7 +1329,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* set various defaults */
const float *outline_col = brush->add_col;
const float outline_alpha = 0.7f;
const float outline_alpha = brush->add_col[3];
float translation[2] = {x, y};
float final_radius = (BKE_brush_size_get(scene, brush) * zoomx);
@ -1547,16 +1547,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
}
else {
if (vc.obact->sculpt->cache && !vc.obact->sculpt->cache->first_time) {
/* Draw cursor location preview when the stroke is active using the data from StrokeCache
*/
float cursor_location[3];
wmViewport(&ar->winrct);
copy_v3_v3(cursor_location, ss->cache->true_location);
if (ss->cache->brush->sculpt_tool == SCULPT_TOOL_GRAB) {
add_v3_v3(cursor_location, ss->cache->grab_delta);
}
cursor_draw_point_with_symmetry(
pos, ar, cursor_location, sd, vc.obact, ss->cache->radius);
/* Draw cached dynamic mesh preview lines */
if (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) &&

View File

@ -85,10 +85,10 @@
/* brush appearance */ \
\
/* add mode color is light red */ \
.add_col = {1.0, 0.39, 0.39}, \
.add_col = {1.0, 0.39, 0.39, 0.9}, \
\
/* subtract mode color is light blue */ \
.sub_col = {0.39, 0.39, 1.0}, \
.sub_col = {0.39, 0.39, 1.0, 0.9}, \
\
.stencil_pos = {256, 256}, \
.stencil_dimension = {256, 256}, \

View File

@ -357,8 +357,8 @@ typedef struct Brush {
/* fill tool */
float fill_threshold;
float add_col[3];
float sub_col[3];
float add_col[4];
float sub_col[4];
float stencil_pos[2];
float stencil_dimension[2];

View File

@ -2374,13 +2374,13 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "cursor_color_add", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "add_col");
RNA_def_property_array(prop, 3);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Add Color", "Color of cursor when adding");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "cursor_color_subtract", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "sub_col");
RNA_def_property_array(prop, 3);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Subtract Color", "Color of cursor when subtracting");
RNA_def_property_update(prop, 0, "rna_Brush_update");

View File

@ -2209,7 +2209,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
short strdrawlen = 0;
float strwidth, strheight;
float r1 = 0.0f, r2 = 0.0f, rmin = 0.0, tex_radius, alpha;
float zoom[2], col[3] = {1, 1, 1};
float zoom[2], col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
switch (rc->subtype) {
case PROP_NONE:
@ -2477,7 +2477,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
}
if (!radial_control_get_path(
&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 3, RC_PROP_REQUIRE_FLOAT)) {
&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 4, RC_PROP_REQUIRE_FLOAT)) {
return 0;
}