diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-11-20 12:22:32 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-11-20 12:29:35 +0300 |
commit | 698f1e3d942adf4a28c89b7d4a4a7be6ad53624f (patch) | |
tree | a6e3ec298abf24c8498bb7861a1d25f9a98a64cd /source/blender/blenkernel/intern | |
parent | 640eb0067017dfbfd7db8c0584251352c17534aa (diff) |
Fix T57938: Dynamic paint baking issues
Quite usual fix for the caching systems.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/dynamicpaint.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 7e692330b79..5453982b070 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -915,10 +915,13 @@ void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface) surface->data = NULL; } -void dynamicPaint_freeSurface(DynamicPaintSurface *surface) +void dynamicPaint_freeSurface(const DynamicPaintModifierData *pmd, + DynamicPaintSurface *surface) { /* point cache */ - BKE_ptcache_free_list(&(surface->ptcaches)); + if ((pmd->modifier.flag & eModifierFlag_SharedCaches) == 0) { + BKE_ptcache_free_list(&(surface->ptcaches)); + } surface->pointcache = NULL; if (surface->effector_weights) @@ -940,7 +943,7 @@ void dynamicPaint_freeCanvas(DynamicPaintModifierData *pmd) while (surface) { next_surface = surface->next; - dynamicPaint_freeSurface(surface); + dynamicPaint_freeSurface(pmd, surface); surface = next_surface; } @@ -1139,7 +1142,9 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str return true; } -void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tpmd) +void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd, + struct DynamicPaintModifierData *tpmd, + int flag) { /* Init modifier */ tpmd->type = pmd->type; @@ -1154,11 +1159,19 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd, stru tpmd->canvas->pmd = tpmd; /* free default surface */ if (tpmd->canvas->surfaces.first) - dynamicPaint_freeSurface(tpmd->canvas->surfaces.first); + dynamicPaint_freeSurface(tpmd, tpmd->canvas->surfaces.first); /* copy existing surfaces */ for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) { DynamicPaintSurface *t_surface = dynamicPaint_createNewSurface(tpmd->canvas, NULL); + if (flag & LIB_ID_CREATE_NO_MAIN) { + /* TODO(sergey): Consider passing some tips to the surface + * creation to avoid this allocate-and-free cache behavior. */ + BKE_ptcache_free_list(&t_surface->ptcaches); + tpmd->modifier.flag |= eModifierFlag_SharedCaches; + t_surface->ptcaches = surface->ptcaches; + t_surface->pointcache = surface->pointcache; + } /* surface settings */ t_surface->brush_group = surface->brush_group; |