[Bf-blender-cvs] [b21ab6c1b17] greasepencil-object: GPencil: Speedup Eraser evaluation using collision check

Antonio Vazquez noreply at git.blender.org
Thu Feb 13 19:56:38 CET 2020


Commit: b21ab6c1b176d9eb0ce0d08226db838c33023cd8
Author: Antonio Vazquez
Date:   Thu Feb 13 19:56:30 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rBb21ab6c1b176d9eb0ce0d08226db838c33023cd8

GPencil: Speedup Eraser evaluation using collision check

Now the eraser use the collision boundbox detection with the stroke before analyze stroke points.

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

M	source/blender/editors/gpencil/gpencil_paint.c

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

diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 6e675994879..bcda4ab4972 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1347,7 +1347,6 @@ static void gp_stroke_soft_refine(bGPDstroke *gps)
 }
 
 /* eraser tool - evaluation per stroke */
-/* TODO: this could really do with some optimization (KD-Tree/BVH?) */
 static void gp_stroke_eraser_dostroke(tGPsdata *p,
                                       bGPDlayer *gpl,
                                       bGPDframe *gpf,
@@ -1617,6 +1616,9 @@ static void gp_stroke_doeraser(tGPsdata *p)
     else if (gpf == NULL) {
       continue;
     }
+    float diff_mat[4][4];
+    /* calculate difference matrix */
+    BKE_gpencil_parent_matrix_get(p->depsgraph, p->ob, gpl, diff_mat);
 
     /* loop over strokes, checking segments for intersections */
     for (gps = gpf->strokes.first; gps; gps = gpn) {
@@ -1625,6 +1627,12 @@ static void gp_stroke_doeraser(tGPsdata *p)
       if (ED_gpencil_stroke_color_use(p->ob, gpl, gps) == false) {
         continue;
       }
+
+      /* Check if the stroke collide with mouse. */
+      if (!ED_gpencil_stroke_check_collision(&p->gsc, gps, p->mval, calc_radius, diff_mat)) {
+        continue;
+      }
+
       /* Not all strokes in the datablock may be valid in the current editor/context
        * (e.g. 2D space strokes in the 3D view, if the same datablock is shared)
        */



More information about the Bf-blender-cvs mailing list