GP: New option to paint a predefined weight
authorAntonioya <blendergit@gmail.com>
Tue, 20 Nov 2018 17:11:42 +0000 (18:11 +0100)
committerAntonioya <blendergit@gmail.com>
Tue, 20 Nov 2018 17:12:04 +0000 (18:12 +0100)
Enabling this option, the weight is set to the predefined value and not the result of the sum of the paint actions.

release/scripts/startup/bl_ui/space_topbar.py
source/blender/editors/gpencil/gpencil_brush.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_sculpt_paint.c

index 6fffba1fe395330a821200804cc3375576eaa16a..a145ec5114e084bcdee9ef1524162245f68ae4c5 100644 (file)
@@ -405,8 +405,15 @@ class _draw_left_context_mode:
             layout.prop(brush, "size", slider=True)
 
             row = layout.row(align=True)
-            row.prop(brush, "strength", slider=True)
-            row.prop(brush, "use_pressure_strength", text="")
+            row.prop(settings, "use_fix_weight", text="", icon='WPAINT_HLT')
+            if settings.use_fix_weight is False:
+                row.prop(brush, "strength", slider=True)
+            else:
+                row.prop(brush, "strength", text="Weight", slider=True)
+
+            sub = row.row(align=True)
+            sub.enabled = not settings.use_fix_weight
+            sub.prop(brush, "use_pressure_strength", text="")
 
         @staticmethod
         def PARTICLE(context, layout, tool):
index 75b632238af3b8058cf6c6d45321269be8236eb1..1710bd6be88df8d20a30d7f1361df5a5721b26b7 100644 (file)
@@ -903,11 +903,21 @@ static bool gp_brush_weight_apply(
 
        if (gp_brush_invert_check(gso)) {
                /* reduce weight */
-               curweight -= inf;
+               if (gso->settings->flag & GP_SCULPT_SETT_FLAG_PAINT_WEIGHT) {
+                       curweight = 0.0f;
+               }
+               else {
+                       curweight -= inf;
+               }
        }
        else {
                /* increase weight */
-               curweight += inf;
+               if (gso->settings->flag & GP_SCULPT_SETT_FLAG_PAINT_WEIGHT) {
+                       curweight = gso->gp_brush->strength;
+               }
+               else {
+                       curweight += inf;
+               }
        }
 
        CLAMP(curweight, 0.0f, 1.0f);
index c1ced30169b56b49629323df6e5a61e473788281..640fe5269716cf3cd36f4683c71d50359ae499a8 100644 (file)
@@ -1051,6 +1051,8 @@ typedef enum eGP_Sculpt_SettingsFlag {
        GP_SCULPT_SETT_FLAG_FRAME_FALLOFF = (1 << 5),
        /* apply brush to uv data */
        GP_SCULPT_SETT_FLAG_APPLY_UV = (1 << 6),
+       /* paint weight, not add/substract */
+       GP_SCULPT_SETT_FLAG_PAINT_WEIGHT = (1 << 7),
 } eGP_Sculpt_SettingsFlag;
 
 /* Settings for GP Interpolation Operators */
index b067bec4b43989d447274691a8b585f21b161b77..7aa3847294462d101fa3d69f7a7708af9111310b 100644 (file)
@@ -1244,6 +1244,13 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
        RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 
+       prop = RNA_def_property(srna, "use_fix_weight", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_PAINT_WEIGHT);
+       RNA_def_property_ui_text(prop, "Fix Weight",
+               "Set the predefined weight to any point affected by the brush");
+       RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+       RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
        prop = RNA_def_property(srna, "use_multiframe_falloff", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_FRAME_FALLOFF);
        RNA_def_property_ui_text(prop, "Use Falloff", "Use falloff effect when edit in multiframe mode to compute brush effect by frame");