Fix T64164: Resetting a curvemap could result in a mirrored curve
authorPhilipp Oeser <info@graphics-engineer.com>
Mon, 6 May 2019 11:03:23 +0000 (13:03 +0200)
committerPhilipp Oeser <info@graphics-engineer.com>
Mon, 6 May 2019 11:44:22 +0000 (13:44 +0200)
A template_curve_mapping with brush=True was always resetting the curve
to a positive slope (descending from left to right).
Behaviour is now changed so that specifying "use_negative_slope" is
taken into account as well.

Also use this for:
- paint "cavity_curve"
- gpencil "curve_sensitivity" / "curve_strength" / "curve_jitter" /
"interpolation_curve"

Reviewers: brecht

Maniphest Tasks: T64164

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

release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/editors/interface/interface_templates.c

index d672984..9610c16 100644 (file)
@@ -1490,7 +1490,8 @@ class VIEW3D_PT_tools_imagepaint_options_cavity(View3DPaintPanel, Panel):
 
         layout.active = ipaint.use_cavity
 
-        layout.template_curve_mapping(ipaint, "cavity_curve", brush=True)
+        layout.template_curve_mapping(ipaint, "cavity_curve", brush=True,
+                                      use_negative_slope=True)
 
 
 # TODO, move to space_view3d.py
@@ -1870,7 +1871,8 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_sensitivity(View3DPanel, Panel):
         brush = context.tool_settings.gpencil_paint.brush
         gp_settings = brush.gpencil_settings
 
-        layout.template_curve_mapping(gp_settings, "curve_sensitivity", brush=True)
+        layout.template_curve_mapping(gp_settings, "curve_sensitivity", brush=True,
+                                      use_negative_slope=True)
 
 
 class VIEW3D_PT_tools_grease_pencil_brushcurves_strength(View3DPanel, Panel):
@@ -1885,7 +1887,8 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_strength(View3DPanel, Panel):
         brush = context.tool_settings.gpencil_paint.brush
         gp_settings = brush.gpencil_settings
 
-        layout.template_curve_mapping(gp_settings, "curve_strength", brush=True)
+        layout.template_curve_mapping(gp_settings, "curve_strength", brush=True,
+                                      use_negative_slope=True)
 
 
 class VIEW3D_PT_tools_grease_pencil_brushcurves_jitter(View3DPanel, Panel):
@@ -1900,7 +1903,8 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_jitter(View3DPanel, Panel):
         brush = context.tool_settings.gpencil_paint.brush
         gp_settings = brush.gpencil_settings
 
-        layout.template_curve_mapping(gp_settings, "curve_jitter", brush=True)
+        layout.template_curve_mapping(gp_settings, "curve_jitter", brush=True,
+                                      use_negative_slope=True)
 
 
 # Grease Pencil stroke editing tools
@@ -1942,7 +1946,8 @@ class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
         col.prop(settings, "type")
         if settings.type == 'CUSTOM':
             # TODO: Options for loading/saving curve presets?
-            col.template_curve_mapping(settings, "interpolation_curve", brush=True)
+            col.template_curve_mapping(settings, "interpolation_curve", brush=True,
+                                       use_negative_slope=True)
         elif settings.type != 'LINEAR':
             col.prop(settings, "easing")
 
index e96141e..40c8521 100644 (file)
@@ -4042,6 +4042,11 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_
   return curvemap_tools_func(C, ar, cumap_v, false, UICURVE_FUNC_RESET_NEG);
 }
 
+static uiBlock *curvemap_brush_tools_negslope_func(bContext *C, ARegion *ar, void *cumap_v)
+{
+  return curvemap_tools_func(C, ar, cumap_v, false, UICURVE_FUNC_RESET_POS);
+}
+
 static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
 {
   ED_region_tag_redraw(CTX_wm_region(C));
@@ -4217,7 +4222,19 @@ static void curvemap_buttons_layout(uiLayout *layout,
                     TIP_("Zoom out"));
   UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL);
 
-  if (brush) {
+  if (brush && neg_slope) {
+    bt = uiDefIconBlockBut(block,
+                           curvemap_brush_tools_negslope_func,
+                           cumap,
+                           0,
+                           ICON_DOWNARROW_HLT,
+                           0,
+                           0,
+                           dx,
+                           dx,
+                           TIP_("Tools"));
+  }
+  else if (brush) {
     bt = uiDefIconBlockBut(block,
                            curvemap_brush_tools_func,
                            cumap,