diff options
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d96942e47e7..5eb935f4651 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1761,9 +1761,9 @@ void BKE_object_free_derived_caches(Object *ob) BKE_geometry_set_free(ob->runtime.geometry_set_eval); ob->runtime.geometry_set_eval = NULL; } - if (ob->runtime.geometry_set_preview != NULL) { - BKE_geometry_set_free(ob->runtime.geometry_set_preview); - ob->runtime.geometry_set_preview = NULL; + if (ob->runtime.geometry_set_previews != NULL) { + BLI_ghash_free(ob->runtime.geometry_set_previews, NULL, (GHashValFreeFP)BKE_geometry_set_free); + ob->runtime.geometry_set_previews = NULL; } } @@ -1816,14 +1816,20 @@ void BKE_object_free_caches(Object *object) } /* Can be called from multiple threads. */ -void BKE_object_set_preview_geometry_set(Object *ob, struct GeometrySet *geometry_set) +void BKE_object_preview_geometry_set_add(Object *ob, + const uint64_t key, + struct GeometrySet *geometry_set) { static ThreadMutex mutex = BLI_MUTEX_INITIALIZER; BLI_mutex_lock(&mutex); - if (ob->runtime.geometry_set_preview != NULL) { - BKE_geometry_set_free(ob->runtime.geometry_set_preview); - } - ob->runtime.geometry_set_preview = geometry_set; + if (ob->runtime.geometry_set_previews == NULL) { + ob->runtime.geometry_set_previews = BLI_ghash_int_new(__func__); + } + BLI_ghash_reinsert(ob->runtime.geometry_set_previews, + POINTER_FROM_UINT(key), + geometry_set, + NULL, + (GHashValFreeFP)BKE_geometry_set_free); BLI_mutex_unlock(&mutex); } |