[Bf-blender-cvs] [812b30daf58] blender-v2.81-release: GPencil: Fix unreported performance issue with relative onion mode

Antonio Vazquez noreply at git.blender.org
Wed Oct 16 21:58:44 CEST 2019


Commit: 812b30daf582c03ff6ed89b85e783f3fcb7bb723
Author: Antonio Vazquez
Date:   Wed Oct 16 21:55:47 2019 +0200
Branches: blender-v2.81-release
https://developer.blender.org/rB812b30daf582c03ff6ed89b85e783f3fcb7bb723

GPencil: Fix unreported performance issue with relative onion mode

When the relative mode was used, the calculation of the total number of vertices was not done and it was using the total number of vertices in the datablock. This worked for small files, but with complex files the time to allocate all the data was too long and the performance was very bad.

Now, for relative mode the real number of vertex is calculated.

Also fixed the same problem when onion and multiedit is enabled.

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

M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index a13896a2b08..f178cd08e31 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -169,6 +169,34 @@ static void gpencil_calc_vertex(GPENCIL_StorageList *stl,
       continue;
     }
 
+    /* Relative onion mode needs to find the frame range before. */
+    int frame_from = -9999;
+    int frame_to = 9999;
+    if ((is_onion) && (mode == GP_ONION_MODE_RELATIVE)) {
+      /* 1) Found first Frame. */
+      int step = gpd->gstep;
+      int idx = 0;
+      if (gpl->actframe) {
+        for (bGPDframe *gf = gpl->actframe->prev; gf; gf = gf->prev) {
+          idx++;
+          frame_from = gf->framenum;
+          if (idx >= step) {
+            break;
+          }
+        }
+        /* 2) Found last Frame. */
+        step = gpd->gstep_next;
+        idx = 0;
+        for (bGPDframe *gf = gpl->actframe->next; gf; gf = gf->next) {
+          idx++;
+          frame_to = gf->framenum;
+          if (idx >= step) {
+            break;
+          }
+        }
+      }
+    }
+
     /* If multiedit or onion skin need to count all frames of the layer. */
     if ((is_multiedit) || (is_onion)) {
       init_gpf = gpl->frames.first;
@@ -191,21 +219,32 @@ static void gpencil_calc_vertex(GPENCIL_StorageList *stl,
           }
         }
         else {
-          /* Only selected frames. */
-          if ((mode == GP_ONION_MODE_SELECTED) && ((gpf->flag & GP_FRAME_SELECT) == 0)) {
-            continue;
-          }
-          /* Verify keyframe type. */
-          if ((onion_keytype > -1) && (gpf->key_type != onion_keytype)) {
-            continue;
-          }
-          /* Absolute range. */
-          if (mode == GP_ONION_MODE_ABSOLUTE) {
-            if ((gpl->actframe) && (abs(gpl->actframe->framenum - gpf->framenum) > step)) {
+          bool select = ((is_multiedit) &&
+                         ((gpf == gpl->actframe) || (gpf->flag & GP_FRAME_SELECT)));
+
+          if (!select) {
+            /* Only selected frames. */
+            if ((mode == GP_ONION_MODE_SELECTED) && ((gpf->flag & GP_FRAME_SELECT) == 0)) {
+              continue;
+            }
+            /* Verify keyframe type. */
+            if ((onion_keytype > -1) && (gpf->key_type != onion_keytype)) {
               continue;
             }
+            /* Absolute range. */
+            if (mode == GP_ONION_MODE_ABSOLUTE) {
+              if ((gpl->actframe) && (abs(gpl->actframe->framenum - gpf->framenum) > step)) {
+                continue;
+              }
+            }
+            /* Relative range. */
+            if (mode == GP_ONION_MODE_RELATIVE) {
+              if ((gpf->framenum < frame_from) || (gpf->framenum > frame_to)) {
+                continue;
+              }
+            }
           }
-          /* For relative range it takes too much time compute, so use all frames. */
+
           cache_ob->tot_vertex += gps->totpoints + 3;
           cache_ob->tot_triangles += gps->totpoints - 1;
         }



More information about the Bf-blender-cvs mailing list