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-08-24 00:10:41 +0300
committerAntonio Vazquez <blendergit@gmail.com>2019-08-24 00:10:48 +0300
commitee4ec69b28047629a1c153af356757a8fac5cee9 (patch)
treebe1023060e66794968e8e6f7a64b8dea268872ad /source/blender/draw/engines/gpencil/gpencil_cache_utils.c
parentd795dd1fa78036e7faa92891ee985c61508612c6 (diff)
Fix T66924 : Move GPencil Modifiers evaluation to Depsgraph
Before, the evaluation of modifers were done in draw manager. The reason of the old design was grease pencil was designed before depsgraph was in place. This commit moves this logic to depsgraph to follow general design and reduce Draw Manager complexity. Also, this is required in order to use modifiers in Edit modes. Really, there is nothing really new in the creation of derived data, only the logic has been moved to depsgraph, but the main logic is the same. In order to get a reference to the original stroke and points, a pointer is added to Runtime data as part of the evaluated data. These pointers allow to know and use the original data. As the modifiers now are evaluated in Depsgraph, the evaluated stroke is usable in Edit modes, so now it's possible to work with the evaluated version instead to use a "ghost" of the final image over the original geometry as work today. Reviewed By: brecht Differential Revision: https://developer.blender.org/D5470
Diffstat (limited to 'source/blender/draw/engines/gpencil/gpencil_cache_utils.c')
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_cache_utils.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 67ffe62f3c6..ea806c3da90 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -274,11 +274,6 @@ static GpencilBatchCache *gpencil_batch_cache_init(Object *ob, int cfra)
cache->cache_frame = cfra;
- /* create array of derived frames equal to number of layers */
- cache->tot_layers = BLI_listbase_count(&gpd->layers);
- CLAMP_MIN(cache->tot_layers, 1);
- cache->derived_array = MEM_callocN(sizeof(struct bGPDframe) * cache->tot_layers, "Derived GPF");
-
return cache;
}
@@ -301,18 +296,16 @@ static void gpencil_batch_cache_clear(GpencilBatchCache *cache)
MEM_SAFE_FREE(cache->b_edit.batch);
MEM_SAFE_FREE(cache->b_edlin.batch);
+ /* internal format data */
+ MEM_SAFE_FREE(cache->b_stroke.format);
+ MEM_SAFE_FREE(cache->b_point.format);
+ MEM_SAFE_FREE(cache->b_fill.format);
+ MEM_SAFE_FREE(cache->b_edit.format);
+ MEM_SAFE_FREE(cache->b_edlin.format);
+
MEM_SAFE_FREE(cache->grp_cache);
cache->grp_size = 0;
cache->grp_used = 0;
-
- /* clear all frames derived data */
- for (int i = 0; i < cache->tot_layers; i++) {
- bGPDframe *derived_gpf = &cache->derived_array[i];
- BKE_gpencil_free_frame_runtime_data(derived_gpf);
- derived_gpf = NULL;
- }
- cache->tot_layers = 0;
- MEM_SAFE_FREE(cache->derived_array);
}
/* get cache */
@@ -355,4 +348,14 @@ void DRW_gpencil_freecache(struct Object *ob)
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
}
}
+
+ /* clear all frames evaluated data */
+ for (int i = 0; i < ob->runtime.gpencil_tot_layers; i++) {
+ bGPDframe *eval_gpf = &ob->runtime.gpencil_evaluated_frames[i];
+ BKE_gpencil_free_frame_runtime_data(eval_gpf);
+ eval_gpf = NULL;
+ }
+
+ ob->runtime.gpencil_tot_layers = 0;
+ MEM_SAFE_FREE(ob->runtime.gpencil_evaluated_frames);
}