Vertex Paint: move normal falloff into the brush
authorCampbell Barton <ideasman42@gmail.com>
Fri, 6 Oct 2017 09:11:17 +0000 (20:11 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 6 Oct 2017 09:15:28 +0000 (20:15 +1100)
All related settings are already in the brush,
so it's inconvenient to switch panels to change this one option.

release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenloader/intern/versioning_270.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/makesdna/DNA_brush_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_brush.c
source/blender/makesrna/intern/rna_sculpt_paint.c

index 62e88e47e2052ae45d25d49ad1c72a099bed42ab..dedad63833af7579bc4dd0907c512384381cce08 100644 (file)
@@ -1139,6 +1139,12 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
                 col.separator()
 
             col.prop(brush, "use_frontface", text="Front Faces Only")
+            row = col.row()
+            row.prop(brush, "use_frontface_falloff", text="Falloff Angle")
+            sub = row.row()
+            sub.active = brush.use_frontface_falloff
+            sub.prop(brush, "falloff_angle", text="")
+
             col.prop(brush, "use_projected")
 
             col = layout.column()
@@ -1175,6 +1181,12 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
                 col.separator()
 
             col.prop(brush, "use_frontface", text="Front Faces Only")
+            row = col.row()
+            row.prop(brush, "use_frontface_falloff", text="Falloff Angle")
+            sub = row.row()
+            sub.active = brush.use_frontface_falloff
+            sub.prop(brush, "falloff_angle", text="")
+
             col.prop(brush, "use_projected")
 
             col.separator()
@@ -1767,16 +1779,7 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
         wpaint = tool_settings.weight_paint
 
         col = layout.column()
-        col.label("Falloff:")
-
-        row = col.row()
-        row.prop(wpaint, "use_normal_falloff")
-        sub = row.row()
-        sub.active = (wpaint.use_normal_falloff)
-        sub.prop(wpaint, "normal_angle", text="")
-        col = layout.column()
-        row = col.row()
-        row.prop(wpaint, "use_group_restrict")
+        col.prop(wpaint, "use_group_restrict")
 
         obj = context.weight_paint_object
         if obj.type == 'MESH':
index 6c863eacfbe8a24735c787d944a52ebd3bb77428..095f21a5b06746f14967e1324147003aee856d5a 100644 (file)
@@ -1683,7 +1683,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                        }
                }
 
-               if (!DNA_struct_elem_find(fd->filesdna, "VPaint", "char", "normal_angle")) {
+               if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "falloff_angle")) {
+                       for (Brush *br = main->brush.first; br; br = br->id.next) {
+                               br->falloff_angle = DEG2RADF(80);
+                               br->flag &= ~(
+                                       BRUSH_FLAG_DEPRECATED_1 | BRUSH_FLAG_DEPRECATED_2 |
+                                       BRUSH_FLAG_DEPRECATED_3 | BRUSH_FLAG_DEPRECATED_4 |
+                                       BRUSH_FRONTFACE_FALLOFF);
+                       }
+
                        for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
                                ToolSettings *ts = scene->toolsettings;
                                for (int i = 0; i < 2; i++) {
@@ -1691,7 +1699,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                                        if (vp != NULL) {
                                                /* remove all other flags */
                                                vp->flag &= (VP_FLAG_VGROUP_RESTRICT);
-                                               vp->normal_angle = 80;
                                        }
                                }
                        }
index d10f483c52e2ed46d2ec8fb43d9e56f2d77efe37..6a1dbfc6b469b268e875c37b47b04b83e6b2008b 100644 (file)
@@ -104,6 +104,7 @@ struct NormalAnglePrecalc {
 static void view_angle_limits_init(
         struct NormalAnglePrecalc *a, float angle, bool do_mask_normal)
 {
+       angle = RAD2DEGF(angle);
        a->do_mask_normal = do_mask_normal;
        if (do_mask_normal) {
                a->angle_inner = angle;
@@ -144,7 +145,7 @@ static float view_angle_limits_apply_falloff(
 static bool vwpaint_use_normal(const VPaint *vp)
 {
        return ((vp->paint.brush->flag & BRUSH_FRONTFACE) != 0) ||
-              ((vp->flag & VP_FLAG_PROJECT_FLAT) == 0);
+              ((vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
 }
 
 
@@ -356,7 +357,7 @@ static float calc_vp_alpha_col_dl(
        if (strength > 0.0f) {
                float alpha = brush_alpha_pressure * strength;
 
-               if ((vp->flag & VP_FLAG_PROJECT_FLAT) == 0) {
+               if ((vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0) {
                        float dvec[3];
 
                        /* transpose ! */
@@ -1380,7 +1381,8 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
        wpd = MEM_callocN(sizeof(struct WPaintData), "WPaintData");
        paint_stroke_set_mode_data(stroke, wpd);
        view3d_set_viewcontext(C, &wpd->vc);
-       view_angle_limits_init(&wpd->normal_angle_precalc, vp->normal_angle, (vp->flag & VP_FLAG_PROJECT_FLAT) == 0);
+       view_angle_limits_init(&wpd->normal_angle_precalc, vp->paint.brush->falloff_angle,
+                              (vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
 
        wpd->active.index = vgroup_index.active;
        wpd->mirror.index = vgroup_index.mirror;
@@ -1560,7 +1562,7 @@ static void do_wpaint_brush_blur_task_cb_ex(
                                                dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
                                        if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
                                             (angle_cos > 0.0f)) &&
-                                           ((data->vp->flag & VP_FLAG_PROJECT_FLAT) ||
+                                           ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
                                             view_angle_limits_apply_falloff(&data->wpd->normal_angle_precalc, angle_cos, &brush_strength)))
                                        {
                                                const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
@@ -1638,7 +1640,7 @@ static void do_wpaint_brush_smear_task_cb_ex(
                                                dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
                                        if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
                                             (angle_cos > 0.0f)) &&
-                                           ((data->vp->flag & VP_FLAG_PROJECT_FLAT) ||
+                                           ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
                                             view_angle_limits_apply_falloff(&data->wpd->normal_angle_precalc, angle_cos, &brush_strength)))
                                        {
                                                bool do_color = false;
@@ -1741,7 +1743,7 @@ static void do_wpaint_brush_draw_task_cb_ex(
                                        dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
                                if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
                                     (angle_cos > 0.0f)) &&
-                                   ((data->vp->flag & VP_FLAG_PROJECT_FLAT) ||
+                                   ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
                                     view_angle_limits_apply_falloff(&data->wpd->normal_angle_precalc, angle_cos, &brush_strength)))
                                {
                                        const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
@@ -2375,7 +2377,8 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
        vpd = MEM_callocN(sizeof(*vpd), "VPaintData");
        paint_stroke_set_mode_data(stroke, vpd);
        view3d_set_viewcontext(C, &vpd->vc);
-       view_angle_limits_init(&vpd->normal_angle_precalc, vp->normal_angle, (vp->flag & VP_FLAG_PROJECT_FLAT) == 0);
+       view_angle_limits_init(&vpd->normal_angle_precalc, vp->paint.brush->falloff_angle,
+                              (vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
 
        vpd->paintcol = vpaint_get_current_col(scene, vp);
 
@@ -2542,7 +2545,7 @@ static void do_vpaint_brush_draw_task_cb_ex(
                                        dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
                                if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
                                     (angle_cos > 0.0f)) &&
-                                   ((data->vp->flag & VP_FLAG_PROJECT_FLAT) ||
+                                   ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
                                     view_angle_limits_apply_falloff(&data->vpd->normal_angle_precalc, angle_cos, &brush_strength)))
                                {
                                        const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
@@ -2630,7 +2633,7 @@ static void do_vpaint_brush_blur_task_cb_ex(
                                        dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
                                if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
                                     (angle_cos > 0.0f)) &&
-                                   ((data->vp->flag & VP_FLAG_PROJECT_FLAT) ||
+                                   ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
                                     view_angle_limits_apply_falloff(&data->vpd->normal_angle_precalc, angle_cos, &brush_strength)))
                                {
                                        const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
@@ -2747,7 +2750,7 @@ static void do_vpaint_brush_smear_task_cb_ex(
                                                dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
                                        if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
                                             (angle_cos > 0.0f)) &&
-                                           ((data->vp->flag & VP_FLAG_PROJECT_FLAT) ||
+                                           ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
                                             view_angle_limits_apply_falloff(&data->vpd->normal_angle_precalc, angle_cos, &brush_strength)))
                                        {
                                                const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
index 6f239ec558b95f84edfd9605c01dea92be139713..c285b44c9396be324ed2e3774ba5b4fb7068203c 100644 (file)
@@ -98,8 +98,9 @@ typedef struct Brush {
        char gradient_stroke_mode; /* source for stroke color gradient application */
        char gradient_fill_mode;   /* source for fill tool color gradient application */
 
+       char pad;
        char falloff_shape;     /* Projection shape (sphere, circle) */
-       char pad[5];
+       float falloff_angle;
 
        char sculpt_tool;       /* active sculpt tool */
        char vertexpaint_tool;  /* active vertex/weight paint blend mode (poorly named) */
@@ -184,13 +185,13 @@ typedef enum BrushGradientSourceFill {
 /* Brush.flag */
 typedef enum BrushFlags {
        BRUSH_AIRBRUSH = (1 << 0),
-//     BRUSH_TORUS = (1 << 1), deprecated, use paint->symmetry_flags & PAINT_TILE_*
+       BRUSH_FLAG_DEPRECATED_1 = (1 << 1),
        BRUSH_ALPHA_PRESSURE = (1 << 2),
        BRUSH_SIZE_PRESSURE = (1 << 3),
        BRUSH_JITTER_PRESSURE = (1 << 4),
        BRUSH_SPACING_PRESSURE = (1 << 5),
-       BRUSH_UNUSED = (1 << 6),
-//     BRUSH_RAKE = (1 << 7), deprecated, use brush_angle_mode
+       BRUSH_FLAG_DEPRECATED_2 = (1 << 6),
+       BRUSH_FLAG_DEPRECATED_3 = (1 << 7),
        BRUSH_ANCHORED = (1 << 8),
        BRUSH_DIR_IN = (1 << 9),
        BRUSH_SPACE = (1 << 10),
@@ -200,6 +201,7 @@ typedef enum BrushFlags {
        BRUSH_LOCK_ALPHA = (1 << 14),
        BRUSH_ORIGINAL_NORMAL = (1 << 15),
        BRUSH_OFFSET_PRESSURE = (1 << 16),
+       BRUSH_FLAG_DEPRECATED_4 = (1 << 17),
        BRUSH_SPACE_ATTEN = (1 << 18),
        BRUSH_ADAPTIVE_SPACE = (1 << 19),
        BRUSH_LOCK_SIZE = (1 << 20),
@@ -207,7 +209,7 @@ typedef enum BrushFlags {
        BRUSH_EDGE_TO_EDGE = (1 << 22),
        BRUSH_DRAG_DOT = (1 << 23),
        BRUSH_INVERSE_SMOOTH_PRESSURE = (1 << 24),
-//     BRUSH_RANDOM_ROTATION = (1 << 25), deprecated, use brush_angle_mode
+       BRUSH_FRONTFACE_FALLOFF = (1 << 25),
        BRUSH_PLANE_TRIM = (1 << 26),
        BRUSH_FRONTFACE = (1 << 27),
        BRUSH_CUSTOM_ICON = (1 << 28),
index acd712843deb4a011a036d026c1bf312d58890fd..3ad75142c46edd6741a7a84e0f6f292f3949b941 100644 (file)
@@ -1117,17 +1117,13 @@ typedef struct UvSculpt {
 /* Vertex Paint */
 typedef struct VPaint {
        Paint paint;
-       short flag;
-       char normal_angle;
-       char pad;
+       char flag;
+       char pad[3];
        int radial_symm[3]; /* For mirrored painting */
 } VPaint;
 
 /* VPaint.flag */
 enum {
-       /* TODO */
-       // VP_FLAG_PROJECT_XRAY        = (1 << 1),
-       VP_FLAG_PROJECT_FLAT        = (1 << 3),
        /* weight paint only */
        VP_FLAG_VGROUP_RESTRICT     = (1 << 7)
 };
index e6e8f6f5f95b36e9037419e96712d66499a0cedc..e73c1bf57ebd0b9cb58194d7abd771e91d6557ee 100644 (file)
@@ -1116,6 +1116,13 @@ static void rna_def_brush(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Blur Mode", "");
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+       prop = RNA_def_property(srna, "falloff_angle", PROP_FLOAT, PROP_ANGLE);
+       RNA_def_property_float_sdna(prop, NULL, "falloff_angle");
+       RNA_def_property_range(prop, 0, M_PI * 2);
+       RNA_def_property_ui_text(prop, "Falloff Angle",
+                                "Paint most on faces pointing towards the view according to this angle");
+       RNA_def_property_update(prop, 0, "rna_Brush_update");
+
        /* flag */
        /* This is an enum but its unlikely we add other shapes, so expose as a boolean. */
        prop = RNA_def_property(srna, "use_projected", PROP_BOOLEAN, PROP_NONE);
@@ -1199,6 +1206,11 @@ static void rna_def_brush(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Use Front-Face", "Brush only affects vertexes that face the viewer");
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+       prop = RNA_def_property(srna, "use_frontface_falloff", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FRONTFACE_FALLOFF);
+       RNA_def_property_ui_text(prop, "Use Front-Face Falloff", "Blend brush influence by how much they face the front");
+       RNA_def_property_update(prop, 0, "rna_Brush_update");
+
        prop = RNA_def_property(srna, "use_anchor", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ANCHORED);
        RNA_def_property_ui_text(prop, "Anchored", "Keep the brush anchored to the initial location");
index b12fece82d1384450396c1871aedfcba0b3f7203..422be83a7f66b2dae5e83bcf39701e798405784d 100644 (file)
@@ -671,21 +671,12 @@ static void rna_def_vertex_paint(BlenderRNA *brna)
        RNA_def_struct_path_func(srna, "rna_VertexPaint_path");
        RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of vertex and weight paint mode");
 
-       prop = RNA_def_property(srna, "use_normal_falloff", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", VP_FLAG_PROJECT_FLAT);
-       RNA_def_property_ui_text(prop, "Normals", "Paint most on faces pointing towards the view");
-       RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
        /* weight paint only */
        prop = RNA_def_property(srna, "use_group_restrict", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_FLAG_VGROUP_RESTRICT);
        RNA_def_property_ui_text(prop, "Restrict", "Restrict painting to vertices in the group");
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 
-       prop = RNA_def_property(srna, "normal_angle", PROP_INT, PROP_UNSIGNED);
-       RNA_def_property_range(prop, 0, 90);
-       RNA_def_property_ui_text(prop, "Angle", "Paint most on faces pointing towards the view according to this angle");
-
        /* Mirroring */
        prop = RNA_def_property(srna, "radial_symmetry", PROP_INT, PROP_XYZ);
        RNA_def_property_int_sdna(prop, NULL, "radial_symm");