[Bf-blender-cvs] [8ae0573c0f6] sculpt-dev: Sculpt IPMask: Unify function to apply delta steps

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


Commit: 8ae0573c0f621f5ef7693be7704542a9eb951e7d
Author: Pablo Dobarro
Date:   Fri Feb 26 00:50:25 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB8ae0573c0f621f5ef7693be7704542a9eb951e7d

Sculpt IPMask: Unify function to apply delta steps

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

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 a10493d7397..9f80ef6079b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
@@ -514,23 +514,19 @@ static void sculpt_ipmask_apply_mask_data(SculptSession *ss, const float *mask)
     }
 }
 
-static float *sculpt_ipmask_apply_delta_step_forward(MaskFilterDeltaStep *delta_step, const float *current_mask) {
+static float *sculpt_ipmask_apply_delta_step(MaskFilterDeltaStep *delta_step, const float *current_mask, const MaskFilterStepDirectionType direction) {
     float *next_mask = MEM_dupallocN(current_mask);
     for (int i = 0; i < delta_step->totelem; i++) {
-        next_mask[delta_step->index[i]] = current_mask[delta_step->index[i]] + delta_step->delta[i];
-    }
-    return next_mask;
-}
-
-static float *sculpt_ipmask_apply_delta_step_backward(MaskFilterDeltaStep *delta_step, const float *current_mask) {
-    float *next_mask = MEM_dupallocN(current_mask);
-    for (int i = 0; i < delta_step->totelem; i++) {
-        next_mask[delta_step->index[i]] = current_mask[delta_step->index[i]] - delta_step->delta[i];
+        if (direction == MASK_FILTER_STEP_DIRECTION_FORWARD) {
+            next_mask[delta_step->index[i]] = current_mask[delta_step->index[i]] + delta_step->delta[i];
+        }
+        else {
+            next_mask[delta_step->index[i]] = current_mask[delta_step->index[i]] - delta_step->delta[i];
+        }
     }
     return next_mask;
 }
 
-
 #define IPMASK_FILTER_STEP_SENSITIVITY 0.05f
 static int sculpt_ipmask_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
@@ -582,7 +578,7 @@ static int sculpt_ipmask_filter_modal(bContext *C, wmOperator *op, const wmEvent
       if (direction == MASK_FILTER_STEP_DIRECTION_FORWARD) {
       if (BLI_ghash_haskey(filter_cache->mask_delta_step, POINTER_FROM_INT(delta_index))) {
           MaskFilterDeltaStep *delta_step = BLI_ghash_lookup(filter_cache->mask_delta_step, POINTER_FROM_INT(delta_index));
-          next_mask = sculpt_ipmask_apply_delta_step_forward(delta_step, current_mask);
+          next_mask = sculpt_ipmask_apply_delta_step_forward(delta_step, current_mask, direction);
       }
       else {
           next_mask = sculpt_ipmask_step_compute(ss, current_mask, direction);
@@ -594,7 +590,7 @@ static int sculpt_ipmask_filter_modal(bContext *C, wmOperator *op, const wmEvent
       else {
       if (BLI_ghash_haskey(filter_cache->mask_delta_step, POINTER_FROM_INT(delta_index))) {
           MaskFilterDeltaStep *delta_step = BLI_ghash_lookup(filter_cache->mask_delta_step, POINTER_FROM_INT(delta_index));
-          next_mask = sculpt_ipmask_apply_delta_step_backward(delta_step, current_mask);
+          next_mask = sculpt_ipmask_apply_delta_step_backward(delta_step, current_mask, direction);
       }
       else {
           next_mask = sculpt_ipmask_step_compute(ss, current_mask, direction);
@@ -696,8 +692,8 @@ void SCULPT_OT_ipmask_filter(struct wmOperatorType *ot)
               1,
               1,
               100,
-              "Iterations",
-              "Number of times that the filter is going to be applied",
+              "Iterations per Step",
+              "Number of times that the filter is going to be applied per step",
               1,
               100);
 }



More information about the Bf-blender-cvs mailing list