[Bf-blender-cvs] [9251b077203] master: Sculpt/Paint: Remove Unified SIZE_PRESSURE and ALPHA_PRESSURE

Pablo Dobarro noreply at git.blender.org
Wed Nov 27 17:15:28 CET 2019


Commit: 9251b077203c763f1be83505ed0a4d1e19dab947
Author: Pablo Dobarro
Date:   Wed Nov 27 02:02:18 2019 +0100
Branches: master
https://developer.blender.org/rB9251b077203c763f1be83505ed0a4d1e19dab947

Sculpt/Paint: Remove Unified SIZE_PRESSURE and ALPHA_PRESSURE

The relation between the pressure/size and the pressure/alpha is a
fundamental property that defines the behavior of a brush, so it does
not make sense to have it unified across all brushes. This applies both
for sculpting and painting.

Some of the new 2.82 brushes need pressure/size or pressure/alpha to be
enabled to work propely, while others don't. Users should not be
switching on and off this property manually when changing brushes if they
want to use unified size. This is also causing that some users are using
the brushes with an incorrect configuration.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6291

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/BKE_brush.h
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/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 98e812cf02d..7c28095259e 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -296,11 +296,11 @@ def brush_basic_wpaint_settings(layout, context, brush, *, compact=False):
 
     row = layout.row(align=True)
     UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True)
-    UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="")
+    row.prop(brush, "use_pressure_size", text="")
 
     row = layout.row(align=True)
     UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength")
-    UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="")
+    row.prop(brush, "use_pressure_strength", text="")
 
     layout.prop(brush, "blend", text="" if compact else "Blend")
 
@@ -310,11 +310,11 @@ def brush_basic_vpaint_settings(layout, context, brush, *, compact=False):
 
     row = layout.row(align=True)
     UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True)
-    UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="")
+    row.prop(brush, "use_pressure_size", text="")
 
     row = layout.row(align=True)
     UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength")
-    UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="")
+    row.prop(brush, "use_pressure_strength", text="")
 
     if capabilities.has_color:
         layout.prop(brush, "blend", text="" if compact else "Blend")
@@ -326,12 +326,12 @@ def brush_basic_texpaint_settings(layout, context, brush, *, compact=False):
     if capabilities.has_radius:
         row = layout.row(align=True)
         UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True)
-        UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="")
+        row.prop(brush, "use_pressure_size", text="")
 
     row = layout.row(align=True)
 
     UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength")
-    UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="")
+    row.prop(brush, "use_pressure_strength", text="")
 
     if capabilities.has_color:
         layout.prop(brush, "blend", text="" if compact else "Blend")
@@ -352,7 +352,7 @@ def brush_basic_sculpt_settings(layout, context, brush, *, compact=False):
     else:
         UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True)
 
-    UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="")
+    row.prop(brush, "use_pressure_size", text="")
 
     # strength, use_strength_pressure, and use_strength_attenuation
     row = layout.row(align=True)
@@ -360,7 +360,7 @@ def brush_basic_sculpt_settings(layout, context, brush, *, compact=False):
     UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength")
 
     if capabilities.has_strength_pressure:
-        UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="")
+        row.prop(brush, "use_pressure_strength", text="")
 
     # direction
     if not capabilities.has_direction:
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 70741831727..c7f6c09b886 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -111,8 +111,8 @@ float BKE_brush_weight_get(const struct Scene *scene, const struct Brush *brush)
 void BKE_brush_weight_set(const struct Scene *scene, struct Brush *brush, float value);
 
 bool BKE_brush_use_locked_size(const struct Scene *scene, const struct Brush *brush);
-bool BKE_brush_use_alpha_pressure(const struct Scene *scene, const struct Brush *brush);
-bool BKE_brush_use_size_pressure(const struct Scene *scene, const struct Brush *brush);
+bool BKE_brush_use_alpha_pressure(const struct Brush *brush);
+bool BKE_brush_use_size_pressure(const struct Brush *brush);
 
 bool BKE_brush_sculpt_has_secondary_color(const struct Brush *brush);
 
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 27c3df5ce6e..a64da8f6606 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1399,20 +1399,14 @@ bool BKE_brush_use_locked_size(const Scene *scene, const Brush *brush)
                                           (brush->flag & BRUSH_LOCK_SIZE);
 }
 
-bool BKE_brush_use_size_pressure(const Scene *scene, const Brush *brush)
+bool BKE_brush_use_size_pressure(const Brush *brush)
 {
-  const short us_flag = scene->toolsettings->unified_paint_settings.flag;
-
-  return (us_flag & UNIFIED_PAINT_SIZE) ? (us_flag & UNIFIED_PAINT_BRUSH_SIZE_PRESSURE) :
-                                          (brush->flag & BRUSH_SIZE_PRESSURE);
+  return brush->flag & BRUSH_SIZE_PRESSURE;
 }
 
-bool BKE_brush_use_alpha_pressure(const Scene *scene, const Brush *brush)
+bool BKE_brush_use_alpha_pressure(const Brush *brush)
 {
-  const short us_flag = scene->toolsettings->unified_paint_settings.flag;
-
-  return (us_flag & UNIFIED_PAINT_ALPHA) ? (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) :
-                                           (brush->flag & BRUSH_ALPHA_PRESSURE);
+  return brush->flag & BRUSH_ALPHA_PRESSURE;
 }
 
 bool BKE_brush_sculpt_has_secondary_color(const Brush *brush)
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 4af589bb29f..7c33e853ed1 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4209,6 +4209,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
         br->pose_smooth_iterations = 4;
       }
     }
+
     /* Cloth pressure */
     for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
       for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
@@ -4223,5 +4224,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 
   {
     /* Versioning code until next subversion bump goes here. */
+
+    /* Remove Unified pressure/size and pressure/alpha */
+    for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+      ToolSettings *ts = scene->toolsettings;
+      UnifiedPaintSettings *ups = &ts->unified_paint_settings;
+      ups->flag &= ~(UNIFIED_PAINT_FLAG_UNUSED_0 | UNIFIED_PAINT_FLAG_UNUSED_1);
+    }
   }
 }
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 78c9980134f..856072ec47a 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -648,7 +648,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
       GPU_matrix_translate_2f(-x, -y);
 
       /* scale based on tablet pressure */
-      if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
+      if (primary && ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
         const float scale = ups->size_pressure_value;
         GPU_matrix_translate_2f(x, y);
         GPU_matrix_scale_2f(scale, scale);
@@ -778,7 +778,7 @@ static bool paint_draw_cursor_overlay(
     }
 
     /* scale based on tablet pressure */
-    if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
+    if (ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
       do_pop = true;
       GPU_matrix_push();
       GPU_matrix_translate_2fv(center);
@@ -1075,7 +1075,7 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups,
     unprojected_radius = paint_calc_object_space_radius(vc, location, projected_radius);
 
     /* scale 3D brush radius by pressure */
-    if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
+    if (ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
       unprojected_radius *= ups->size_pressure_value;
     }
 
@@ -1362,7 +1362,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
     immUniformColor3fvAlpha(outline_col, outline_alpha);
 
     /* draw brush outline */
-    if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush)) {
+    if (ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
       imm_draw_circle_wire_2d(
           pos, translation[0], translation[1], final_radius * ups->size_pressure_value, 40);
       /* outer at half alpha */
@@ -1407,8 +1407,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
 
     immUniformColor3fvAlpha(outline_col, outline_alpha);
 
-    if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush) &&
-        mode != PAINT_MODE_SCULPT) {
+    if (ups->stroke_active && BKE_brush_use_size_pressure(brush) && mode != PAINT_MODE_SCULPT) {
       imm_draw_circle_wire_3d(
           pos, translation[0], translation[1], final_radius * ups->size_pressure_value, 40);
       /* outer at half alpha */
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 9acc189ae95..0b770f17314 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -548,7 +548,7 @@ static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, Po
     return;
   }
 
-  if (BKE_brush_use_alpha_pressure(scene, brush)) {
+  if (BKE_brush_use_alpha_pressure(brush)) {
     BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * pressure * alphafac));
   }
   else {
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index ee359def68c..fc0c6d748cb 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -336,7 +336,7 @@ static bool paint_brush_update(bContext *C,
 
   ups->pixel_radius = BKE_brush_size_get(scene, brush)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list