Commit: 471be7e7f58a4776857666df13e473c8ea0f4fd5
Author: Campbell Barton
Date:   Fri Oct 6 20:11:17 2017 +1100
Branches: master
https://developer.blender.org/rB471be7e7f58a4776857666df13e473c8ea0f4fd5

Vertex Paint: move normal falloff into the brush

All related settings are already in the brush,
so it's inconvenient to switch panels to change this one option.

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

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

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 62e88e47e20..dedad63833a 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -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':
diff --git a/source/blender/blenloader/intern/versioning_270.c 
b/source/blender/blenloader/intern/versioning_270.c
index 6c863eacfbe..095f21a5b06 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -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;
                                        }
                                }
                        }
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index d10f483c52e..6a1dbfc6b46 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -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);
diff --git a/source/blender/makesdna/DNA_brush_types.h 
b/source/blender/makesdna/DNA_brush_types.h
index 6f239ec558b..c285b44c939 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -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_SP

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to