[Bf-blender-cvs] [817ccc3a995] sculpt-dev: Sculpt IPMask: Implement smooth and sharpen callbacks
Pablo Dobarro
noreply at git.blender.org
Fri Feb 26 14:59:00 CET 2021
Commit: 817ccc3a9958be148f108c237df5d7feae024eb6
Author: Pablo Dobarro
Date: Fri Feb 26 00:03:44 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB817ccc3a9958be148f108c237df5d7feae024eb6
Sculpt IPMask: Implement smooth and sharpen callbacks
===================================================================
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 5c8bdad4694..b555cee1ade 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
@@ -396,12 +396,50 @@ static float sculpt_ipmask_vertex_shrink_cb(SculptSession *ss, const int vertex,
return min;
}
+/* Smooth/Sharpen vertex callbacks. */
+static float sculpt_ipmask_vertex_smooth_cb(SculptSession *ss, const int vertex, const float *current_mask) {
+ float accum = 0.0f;
+ int total = 0;
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
+ accum += current_mask[ni.index];
+ total++;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ return total > 0? accum/total : current_mask[vertex];
+}
+
+static float sculpt_ipmask_vertex_sharpen_cb(SculptSession *ss, const int vertex, const float *current_mask) {
+ float accum = 0.0f;
+ int total = 0;
+ float vmask = current_mask[vertex];
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
+ accum += current_mask[ni.index];
+ total++;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ const float avg = total > 0? accum/total : current_mask[vertex];
+ const float val = avg - vmask;
+
+ float new_mask;
+ if (vmask > 0.5f) {
+ new_mask = vmask + 0.01f;
+ }
+ else {
+ new_mask = vmask - 0.01f;
+ }
+ 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_grow_cb(ss, i, current_mask);
+ next_mask[i] = sculpt_ipmask_vertex_smooth_cb(ss, i, current_mask);
}
return next_mask;
}
@@ -410,7 +448,8 @@ static float *sculpt_ipmask_step_compute_backward(SculptSession *ss, const float
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_shrink_cb(ss, i, current_mask);
+ next_mask[i] = sculpt_ipmask_vertex_sharpen_cb(ss, i, current_mask);
}
return next_mask;
}
More information about the Bf-blender-cvs
mailing list