Sculpt/Paint: Ignore INBETWEEN_MOUSEMOVE events on certain brush tools
authorPablo Dobarro <pablodp606@gmail.com>
Tue, 6 Aug 2019 23:36:17 +0000 (01:36 +0200)
committerPablo Dobarro <pablodp606@gmail.com>
Mon, 12 Aug 2019 10:58:08 +0000 (12:58 +0200)
Some brush tools were being executed too often when using devices with high polling rates, causing performance issues. This should improve the performance of brushes that don't need those updates.

Reviewed By: brecht

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

source/blender/editors/sculpt_paint/paint_stroke.c

index 6144f5751f266f4f762f831315eaf2886ce8f0e9..694dae49d304f1622b4eb14114dfbfb200cb7236 100644 (file)
@@ -233,6 +233,23 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
   return true;
 }
 
+static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode mode)
+{
+  switch (mode) {
+    case PAINT_MODE_SCULPT:
+      if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB)) {
+        return false;
+      }
+      else {
+        return true;
+      }
+    default:
+      break;
+  }
+
+  return true;
+}
+
 /* Initialize the stroke cache variants from operator properties */
 static bool paint_brush_update(bContext *C,
                                Brush *brush,
@@ -1188,6 +1205,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
   bool redraw = false;
   float pressure;
 
+  if (event->type == INBETWEEN_MOUSEMOVE && !paint_tool_require_inbetween_mouse_events(br, mode)) {
+    return OPERATOR_RUNNING_MODAL;
+  }
+
   /* see if tablet affects event. Line, anchored and drag dot strokes do not support pressure */
   pressure = ((br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ?
                   1.0f :