[Bf-blender-cvs] [56d33186a48] sculpt-dev: Sculpt IPMask: Move main data update to its own function
Pablo Dobarro
noreply at git.blender.org
Fri Feb 26 14:59:02 CET 2021
Commit: 56d33186a48e3bed9e3fe6b10a869eb081c71916
Author: Pablo Dobarro
Date: Fri Feb 26 01:41:23 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB56d33186a48e3bed9e3fe6b10a869eb081c71916
Sculpt IPMask: Move main data update to its own 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 3714d036579..cb0fcf40e99 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
@@ -614,6 +614,43 @@ static void sculpt_ipmask_compute_and_store_step(SculptSession *ss,
MEM_freeN(next_mask);
}
+
+static void sculpt_ipmask_filter_update_to_target_step(SculptSession *ss, const int target_step, const int iteration_count) {
+ FilterCache *filter_cache = ss->filter_cache;
+ while (filter_cache->mask_filter_current_step != target_step) {
+ int next_step = filter_cache->mask_filter_current_step;
+ int delta_index = next_step;
+ MaskFilterStepDirectionType direction;
+
+ /* Get the next step and the delta step index associated with it. */
+ if (target_step > filter_cache->mask_filter_current_step) {
+ next_step = filter_cache->mask_filter_current_step + 1;
+ delta_index = filter_cache->mask_filter_current_step;
+ direction = MASK_FILTER_STEP_DIRECTION_FORWARD;
+ }
+ else {
+ next_step = filter_cache->mask_filter_current_step - 1;
+ delta_index = filter_cache->mask_filter_current_step - 1;
+ direction = MASK_FILTER_STEP_DIRECTION_BACKWARD;
+ }
+
+ /* Update the data one step forward/backward. */
+ if (BLI_ghash_haskey(filter_cache->mask_delta_step, POINTER_FROM_INT(delta_index))) {
+ /* This step was already computed, restore it from the current step and a delta. */
+ MaskFilterDeltaStep *delta_step = BLI_ghash_lookup(filter_cache->mask_delta_step,
+ POINTER_FROM_INT(delta_index));
+ sculpt_ipmask_restore_state_from_delta(ss, delta_step, direction);
+ }
+ else {
+ /* New step that was not yet computed. Compute and store the delta. */
+ sculpt_ipmask_compute_and_store_step(ss, iteration_count, delta_index, direction);
+ }
+
+ /* Update the current step. */
+ filter_cache->mask_filter_current_step = next_step;
+ }
+}
+
#define IPMASK_FILTER_STEP_SENSITIVITY 0.05f
static int sculpt_ipmask_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
@@ -621,7 +658,7 @@ static int sculpt_ipmask_filter_modal(bContext *C, wmOperator *op, const wmEvent
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
SculptSession *ss = ob->sculpt;
FilterCache *filter_cache = ss->filter_cache;
- const int iterations = RNA_int_get(op->ptr, "iterations");
+ const int iteration_count = RNA_int_get(op->ptr, "iterations");
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -646,32 +683,7 @@ static int sculpt_ipmask_filter_modal(bContext *C, wmOperator *op, const wmEvent
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
- while (filter_cache->mask_filter_current_step != target_step) {
- int next_step = filter_cache->mask_filter_current_step;
- int delta_index = next_step;
- MaskFilterStepDirectionType direction;
-
- if (target_step > filter_cache->mask_filter_current_step) {
- next_step = filter_cache->mask_filter_current_step + 1;
- delta_index = filter_cache->mask_filter_current_step;
- direction = MASK_FILTER_STEP_DIRECTION_FORWARD;
- }
- else {
- next_step = filter_cache->mask_filter_current_step - 1;
- delta_index = filter_cache->mask_filter_current_step - 1;
- direction = MASK_FILTER_STEP_DIRECTION_BACKWARD;
- }
-
- 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));
- sculpt_ipmask_restore_state_from_delta(ss, delta_step, direction);
- }
- else {
- sculpt_ipmask_compute_and_store_step(ss, iterations, delta_index, direction);
- }
- filter_cache->mask_filter_current_step = next_step;
- }
+ sculpt_ipmask_filter_update_to_target_step(ss, target_step, iteration_count);
SCULPT_tag_update_overlays(C);
More information about the Bf-blender-cvs
mailing list