[Bf-blender-cvs] [4e8c430c6e1] sculpt-dev: Sculpt IPMask: Free ghash when finishing

Pablo Dobarro noreply at git.blender.org
Fri Feb 26 14:59:01 CET 2021


Commit: 4e8c430c6e1d0f297a83fba1c7a49c272d277eab
Author: Pablo Dobarro
Date:   Fri Feb 26 01:31:49 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB4e8c430c6e1d0f297a83fba1c7a49c272d277eab

Sculpt IPMask: Free ghash when finishing

===================================================================

M	source/blender/editors/sculpt_paint/sculpt_filter_mask.c
M	source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

===================================================================

diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
index 1f8d5b607be..3277913199b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
@@ -345,11 +345,6 @@ typedef enum MaskFilterStepDirectionType {
     MASK_FILTER_STEP_DIRECTION_BACKWARD,
 } MaskFilterStepDirectionType;
 
-typedef struct MaskFilterDeltaStep {
-    int totelem;
-    int *index;
-    float *delta;
-} MaskFilterDeltaStep;
 
 /* Grown/Shrink vertex callbacks. */
 static float sculpt_ipmask_vertex_grow_cb(SculptSession *ss, const int vertex,  float *current_mask) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index ba0d1f86489..843fab58f1c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -174,6 +174,12 @@ void SCULPT_filter_cache_init(bContext *C, Object *ob, Sculpt *sd, const int und
   copy_m4_m4(ss->filter_cache->viewmat_inv, vc.rv3d->viewinv);
 }
 
+static void mask_filter_delta_step_free(void *delta_step_free) {
+    MaskFilterDeltaStep *delta_step = (MaskFilterDeltaStep *)delta_step_free;
+    MEM_SAFE_FREE(delta_step->delta);
+    MEM_SAFE_FREE(delta_step->index);
+    MEM_SAFE_FREE(delta_step);
+}
 void SCULPT_filter_cache_free(SculptSession *ss)
 {
   if (ss->filter_cache->cloth_sim) {
@@ -182,6 +188,9 @@ void SCULPT_filter_cache_free(SculptSession *ss)
   if (ss->filter_cache->automasking) {
     SCULPT_automasking_cache_free(ss->filter_cache->automasking);
   }
+  if (ss->filter_cache->mask_delta_step) {
+      BLI_ghash_free(ss->filter_cache->mask_delta_step, NULL, mask_filter_delta_step_free);
+  }
   MEM_SAFE_FREE(ss->filter_cache->nodes);
   MEM_SAFE_FREE(ss->filter_cache->mask_update_it);
   MEM_SAFE_FREE(ss->filter_cache->prev_mask);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 1a8df17e35a..173bf69620f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1299,6 +1299,12 @@ typedef struct ExpandCache {
 /* IPMask filter vertex callback function. */
 typedef float(SculptIPMaskFilterStepVertexCB)(struct SculptSession *, int, float *);
 
+typedef struct MaskFilterDeltaStep {
+    int totelem;
+    int *index;
+    float *delta;
+} MaskFilterDeltaStep;
+
 typedef struct FilterCache {
   bool enabled_axis[3];
   bool enabled_force_axis[3];



More information about the Bf-blender-cvs mailing list