[Bf-blender-cvs] [e603f05b695] greasepencil-object: GPencil: Add curve falloff for Vertex Paint brushes

Antonio Vazquez noreply at git.blender.org
Sat Nov 9 16:15:17 CET 2019


Commit: e603f05b6959fd69f99642851ebbf7d44cf264e9
Author: Antonio Vazquez
Date:   Sat Nov 9 16:15:06 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rBe603f05b6959fd69f99642851ebbf7d44cf264e9

GPencil: Add curve falloff for Vertex Paint brushes

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/gpencil/gpencil_vertex_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 fc49be8a82d..262649e695f 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2318,6 +2318,41 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex(View3DPanel, Panel):
         sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="")
 
 
+class VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff(Panel, View3DPaintPanel):
+    bl_context = ".greasepencil_vertex"
+    bl_label = "Falloff"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ts = context.tool_settings
+        settings = ts.gpencil_vertex_paint
+        brush = settings.brush
+        return (settings and settings.brush and settings.brush.curve)
+
+    def draw(self, context):
+        layout = self.layout
+        ts = context.tool_settings
+        settings = ts.gpencil_vertex_paint
+        brush = settings.brush
+
+        col = layout.column(align=True)
+        row = col.row(align=True)
+        row.prop(brush, "curve_preset", text="")
+
+        if brush.curve_preset == 'CUSTOM':
+            layout.template_curve_mapping(brush, "curve", brush=True)
+
+            col = layout.column(align=True)
+            row = col.row(align=True)
+            row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
+            row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
+            row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
+            row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
+            row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
+            row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
+
+
 class VIEW3D_PT_tools_grease_pencil_brush_vertex_palette(View3DPanel, Panel):
     bl_context = ".greasepencil_vertex"
     bl_label = "Color Palette"
@@ -2554,6 +2589,7 @@ classes = (
     VIEW3D_PT_tools_grease_pencil_vertex_brush,
     VIEW3D_PT_tools_grease_pencil_brush_vertex,
     VIEW3D_PT_tools_grease_pencil_brush_vertex_palette,
+    VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff,
 )
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c
index 12bce027587..d0b57cbced9 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -208,6 +208,11 @@ static float brush_influence_calc(tGP_BrushVertexpaintData *gso, const int radiu
 
   influence *= fac;
 
+  /* Apply Brush curve. */
+  if (brush->curve) {
+    float brush_fallof = BKE_curvemapping_evaluateF(brush->curve, 0, fac);
+    influence *= brush_fallof;
+  }
   /* apply multiframe falloff */
   influence *= gso->mf_falloff;
 
@@ -391,6 +396,7 @@ static bool gp_vertexpaint_brush_init(bContext *C, wmOperator *op)
   op->customdata = gso;
 
   gso->brush = paint->brush;
+  BKE_curvemapping_initialize(gso->brush->curve);
 
   gso->is_painting = false;
   gso->first = true;



More information about the Bf-blender-cvs mailing list