[Bf-blender-cvs] [77ce16299d4] sculpt-mode-features: Sculpt vertex colors: Support for Unified paint settings and secondary color

Pablo Dobarro noreply at git.blender.org
Mon Jul 15 19:11:26 CEST 2019


Commit: 77ce16299d42ff0d8b939d32b23232cc75de125c
Author: Pablo Dobarro
Date:   Mon Jul 15 19:11:53 2019 +0200
Branches: sculpt-mode-features
https://developer.blender.org/rB77ce16299d42ff0d8b939d32b23232cc75de125c

Sculpt vertex colors: Support for Unified paint settings and secondary
color

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index f557802e1c8..bef6b8723d9 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -368,7 +368,12 @@ def brush_basic_sculpt_settings(layout, context, brush, *, compact=False):
     if not capabilities.has_direction:
         layout.row().prop(brush, "direction", expand=True, **({"text": ""} if compact else {}))
 
-    UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="Color")
+    row = layout.row(align=True)
+    UnifiedPaintPanel.prop_unified_color(row, context, brush, "color", text="")
+    UnifiedPaintPanel.prop_unified_color(row, context, brush, "secondary_color", text="")
+    row.separator()
+    row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="", emboss=False)
+
 
 
 def brush_basic_gpencil_paint_settings(layout, _context, brush, *, compact=True):
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 41dfd6f68c3..1aded3fb0fb 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1272,7 +1272,7 @@ static bool brush_colors_flip_poll(bContext *C)
   else {
     Object *ob = CTX_data_active_object(C);
     if (ob != NULL) {
-      if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT)) {
+      if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT | OB_MODE_SCULPT)) {
         return true;
       }
     }
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 1c34c137430..4c60a2df1aa 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2685,9 +2685,16 @@ static void apply_color(SculptSession *ss, PBVHVertexIter *vd, const Brush *brus
 {
   float factor = ss->cache ? fade * fabs(ss->cache->bstrength) : fade;
   CLAMP(factor, 0.0f, 1.0f);
-  unsigned char r = brush->rgb[0] * 255;
-  unsigned char g = brush->rgb[1] * 255;
-  unsigned char b = brush->rgb[2] * 255;
+  float b_rgb[3];
+  if (ss->cache) {
+    copy_v3_v3(b_rgb, ss->cache->paint_color);
+  }
+  else {
+    copy_v3_v3(b_rgb, brush->rgb);
+  }
+  unsigned char r = b_rgb[0] * 255;
+  unsigned char g = b_rgb[1] * 255;
+  unsigned char b = b_rgb[2] * 255;
   unsigned char a = factor * 255;
   unsigned char brushColor[4] = {r, g, b, a};
   unsigned char *col = (unsigned char *)vd->col;
@@ -5704,6 +5711,16 @@ static void sculpt_update_cache_invariants(
     cache->active_vertex_mesh_index = ss->active_vertex_mesh_index;
   }
 
+  /* SCULPT VERTEX COLORS */
+  if (ups->flag & UNIFIED_PAINT_COLOR) {
+    copy_v3_v3(cache->paint_color, ups->rgb);
+    copy_v3_v3(cache->paint_color_secondary, ups->secondary_rgb);
+  }
+  else {
+    copy_v3_v3(cache->paint_color, brush->rgb);
+    copy_v3_v3(cache->paint_color_secondary, brush->secondary_rgb);
+  }
+
   cache->first_time = 1;
 
 #define PIXEL_INPUT_THRESHHOLD 5
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 2137f7b3478..13f92a42048 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -408,6 +408,9 @@ typedef struct StrokeCache {
   rcti previous_r; /* previous redraw rectangle */
   rcti current_r;  /* current redraw rectangle */
 
+  float paint_color[3];
+  float paint_color_secondary[3];
+
 } StrokeCache;
 
 void sculpt_cache_calc_brushdata_symm(StrokeCache *cache,



More information about the Bf-blender-cvs mailing list