Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2019-10-16 22:55:47 +0300
committerAntonio Vazquez <blendergit@gmail.com>2019-10-16 22:56:25 +0300
commit812b30daf582c03ff6ed89b85e783f3fcb7bb723 (patch)
treeb6c1c0c884768e9616ca1ac3cb4913bda9d31edf /source/blender/draw/engines
parent7e78fbf2dedfd70f8c9971ee1412183abc5a9ca7 (diff)
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.
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c63
1 files changed, 51 insertions, 12 deletions
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;
}