[Bf-blender-cvs] [03145616843] master: Sculpt: Add color alpha controls to the brush cursor

Pablo Dobarro noreply at git.blender.org
Mon Dec 30 16:39:51 CET 2019


Commit: 03145616843e06ee215d9a06973a2655eb0d486a
Author: Pablo Dobarro
Date:   Mon Dec 30 16:41:20 2019 +0100
Branches: master
https://developer.blender.org/rB03145616843e06ee215d9a06973a2655eb0d486a

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

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

M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/makesdna/DNA_brush_defaults.h
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index b5f2ca0f117..e9760f76cfc 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -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:
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 03582990703..bf53d6f216b 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -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;
+    }
   }
 }
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 856072ec47a..9021666c001 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -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) &&
diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h
index 9d3689ce4ee..f7998fab8db 100644
--- a/source/blender/makesdna/DNA_brush_defaults.h
+++ b/source/blender/makesdna/DNA_brush_defaults.h
@@ -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}, \
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 3860ea6b312..8cd0b5d55cd 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -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];
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 5b683ffd80e..29c792a3bfb 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -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");
 
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 61f51de41a5..9df27ca71f0 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -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;
   }



More information about the Bf-blender-cvs mailing list