diff options
author | Yann Lanthony <yann-lty> | 2022-03-07 13:37:50 +0300 |
---|---|---|
committer | Falk David <falkdavid@gmx.de> | 2022-03-07 13:38:56 +0300 |
commit | 7ca13eef7c3349b346b178b8f4ca64838d2f4ccf (patch) | |
tree | 1f2bd382ae4622e7fd5cba2a75bd535dbc7e7447 /source/blender/blenkernel/intern/gpencil.c | |
parent | 57c5f2a50329d6591eea41ac65ec94890c3c33df (diff) |
Improve multi-user gpencil data performance with modifiers
When a grease pencil data-block has multiple users and is subject
to modifiers, layer transforms or parenting, performance
(especially playback) is greatly affected.
This was caused by the grease pencil eval process which does per
instance full-copies of the original datablock in case those
kinds of transformations need to be applied.
This commit changes the behavior of the eval process to do shallow
copies (layers with empty frames) of the datablock instead
and duplicates only the visible strokes.
When we need to have a unique eval data
per instance, only copy the strokes of visible
frames to this copy.
Performance:
On a test file with 1350 frames 33k strokes and 480k points
in a single grease pencil object that was instanced 13 times:
- master: 2.8 - 3.3 fps
- patch: 42 - 52 fps
Co-authored by: @filedescriptor
This patch was contributed by The SPA Studios.
Reviewed By: #grease_pencil, pepeland
Differential Revision: https://developer.blender.org/D14238
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 16d43d40c50..92ed273cac8 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -2568,11 +2568,13 @@ void BKE_gpencil_visible_stroke_advanced_iter(ViewLayer *view_layer, layer_cb(gpl, gpf, NULL, thunk); } - LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { - if (gps->totpoints == 0) { - continue; + if (stroke_cb) { + LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { + if (gps->totpoints == 0) { + continue; + } + stroke_cb(gpl, gpf, gps, thunk); } - stroke_cb(gpl, gpf, gps, thunk); } } /* Draw Active frame on top. */ @@ -2590,12 +2592,13 @@ void BKE_gpencil_visible_stroke_advanced_iter(ViewLayer *view_layer, gpl->opacity = prev_opacity; continue; } - - LISTBASE_FOREACH (bGPDstroke *, gps, &act_gpf->strokes) { - if (gps->totpoints == 0) { - continue; + if (stroke_cb) { + LISTBASE_FOREACH (bGPDstroke *, gps, &act_gpf->strokes) { + if (gps->totpoints == 0) { + continue; + } + stroke_cb(gpl, act_gpf, gps, thunk); } - stroke_cb(gpl, act_gpf, gps, thunk); } } |