[Bf-blender-cvs] [2e99348da74] sculpt-dev: Sculpt IPMask: Generalize compute function

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


Commit: 2e99348da74c134146607e75a673a026ed5b607d
Author: Pablo Dobarro
Date:   Fri Feb 26 00:08:25 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB2e99348da74c134146607e75a673a026ed5b607d

Sculpt IPMask: Generalize compute function

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

M	source/blender/editors/sculpt_paint/sculpt_filter_mask.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
index b555cee1ade..358f7129849 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
@@ -424,32 +424,28 @@ static float sculpt_ipmask_vertex_sharpen_cb(SculptSession *ss, const int vertex
 
   float new_mask;
           if (vmask > 0.5f) {
-            new_mask = vmask +  0.01f;
+            new_mask = vmask +  0.03f;
           }
           else {
-            new_mask = vmask - 0.01f;
+            new_mask = vmask - 0.03f;
           }
           new_mask += val / 2.0f;
     return clamp_f(new_mask, 0.0f, 1.0f);
 
 }
 
-static float *sculpt_ipmask_step_compute(SculptSession *ss, const float *current_mask) {
-    const int totvert = SCULPT_vertex_count_get(ss);
-    float *next_mask = MEM_malloc_arrayN(sizeof (float), totvert, "delta values");
-    for (int i = 0; i < totvert; i++) {
-        //next_mask[i] = sculpt_ipmask_vertex_grow_cb(ss, i, current_mask);
-        next_mask[i] = sculpt_ipmask_vertex_smooth_cb(ss, i, current_mask);
-    }
-    return next_mask;
-}
 
-static float *sculpt_ipmask_step_compute_backward(SculptSession *ss, const float *current_mask) {
+static float *sculpt_ipmask_step_compute(SculptSession *ss, const float *current_mask, MaskFilterStepDirectionType direction) {
     const int totvert = SCULPT_vertex_count_get(ss);
     float *next_mask = MEM_malloc_arrayN(sizeof (float), totvert, "delta values");
     for (int i = 0; i < totvert; i++) {
         //next_mask[i] = sculpt_ipmask_vertex_shrink_cb(ss, i, current_mask);
-        next_mask[i] = sculpt_ipmask_vertex_sharpen_cb(ss, i, current_mask);
+        if (direction == MASK_FILTER_STEP_DIRECTION_FORWARD) {
+            next_mask[i] = sculpt_ipmask_vertex_smooth_cb(ss, i, current_mask);
+        }
+        else {
+            next_mask[i] = sculpt_ipmask_vertex_sharpen_cb(ss, i, current_mask);
+        }
     }
     return next_mask;
 }
@@ -559,7 +555,7 @@ static int sculpt_ipmask_filter_modal(bContext *C, wmOperator *op, const wmEvent
       }
       else {
           printf("FORWARD, COMPUTING\n");
-          next_mask = sculpt_ipmask_step_compute(ss, current_mask);
+          next_mask = sculpt_ipmask_step_compute(ss, current_mask, direction);
           MaskFilterDeltaStep *delta_step = sculpt_ipmask_filter_delta_create(current_mask, next_mask, totvert);
           BLI_ghash_insert(filter_cache->mask_delta_step, POINTER_FROM_INT(delta_index), delta_step);
       }
@@ -573,7 +569,7 @@ static int sculpt_ipmask_filter_modal(bContext *C, wmOperator *op, const wmEvent
       }
       else {
           printf("BACKWARD, COMPUTING\n");
-          next_mask = sculpt_ipmask_step_compute_backward(ss, current_mask);
+          next_mask = sculpt_ipmask_step_compute(ss, current_mask, direction);
           MaskFilterDeltaStep *delta_step = sculpt_ipmask_filter_delta_create(next_mask, current_mask, totvert);
           BLI_ghash_insert(filter_cache->mask_delta_step, POINTER_FROM_INT(delta_index), delta_step);
       }



More information about the Bf-blender-cvs mailing list