Refactor: Sculpt: Simplify relax face set strength logic
Pull Request: https://projects.blender.org/blender/blender/pulls/124010
This commit is contained in:
parent
f205079f1e
commit
6dd9c3254b
@ -429,11 +429,10 @@ static void do_draw_face_sets_brush_bmesh(Object &ob,
|
||||
|
||||
static void do_relax_face_sets_brush_task(Object &ob,
|
||||
const Brush &brush,
|
||||
const int iteration,
|
||||
const float strength,
|
||||
PBVHNode *node)
|
||||
{
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
float bstrength = ss.cache->bstrength;
|
||||
|
||||
PBVHVertexIter vd;
|
||||
|
||||
@ -442,10 +441,6 @@ static void do_relax_face_sets_brush_task(Object &ob,
|
||||
ss, test, brush.falloff_shape);
|
||||
|
||||
const bool relax_face_sets = !(ss.cache->iteration_count % 3 == 0);
|
||||
/* This operations needs a strength tweak as the relax deformation is too weak by default. */
|
||||
if (relax_face_sets && iteration < 2) {
|
||||
bstrength *= 1.5f;
|
||||
}
|
||||
|
||||
const int thread_id = BLI_task_parallel_thread_id(nullptr);
|
||||
auto_mask::NodeData automask_data = auto_mask::node_begin(
|
||||
@ -461,22 +456,33 @@ static void do_relax_face_sets_brush_task(Object &ob,
|
||||
continue;
|
||||
}
|
||||
|
||||
const float fade = bstrength * SCULPT_brush_strength_factor(ss,
|
||||
brush,
|
||||
vd.co,
|
||||
sqrtf(test.dist),
|
||||
vd.no,
|
||||
vd.fno,
|
||||
vd.mask,
|
||||
vd.vertex,
|
||||
thread_id,
|
||||
&automask_data);
|
||||
const float fade = SCULPT_brush_strength_factor(ss,
|
||||
brush,
|
||||
vd.co,
|
||||
sqrtf(test.dist),
|
||||
vd.no,
|
||||
vd.fno,
|
||||
vd.mask,
|
||||
vd.vertex,
|
||||
thread_id,
|
||||
&automask_data);
|
||||
|
||||
smooth::relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co);
|
||||
smooth::relax_vertex(ss, &vd, fade * strength * strength, relax_face_sets, vd.co);
|
||||
}
|
||||
BKE_pbvh_vertex_iter_end;
|
||||
}
|
||||
|
||||
static std::array<float, 4> iteration_strengths(const float strength, const int stroke_iteration)
|
||||
{
|
||||
if (stroke_iteration % 3 == 0) {
|
||||
return {strength, strength, strength, strength};
|
||||
}
|
||||
|
||||
/* This operations needs a strength tweak as the relax deformation is too weak by default. */
|
||||
const float modified_strength = strength * 1.5f;
|
||||
return {modified_strength, modified_strength, strength, strength};
|
||||
}
|
||||
|
||||
void do_draw_face_sets_brush(const Sculpt &sd, Object &ob, Span<PBVHNode *> nodes)
|
||||
{
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
@ -486,10 +492,13 @@ void do_draw_face_sets_brush(const Sculpt &sd, Object &ob, Span<PBVHNode *> node
|
||||
|
||||
if (ss.cache->alt_smooth) {
|
||||
SCULPT_boundary_info_ensure(ob);
|
||||
for (int iteration = 0; iteration < 4; iteration++) {
|
||||
const SculptSession &ss = *ob.sculpt;
|
||||
const std::array<float, 4> strengths = iteration_strengths(ss.cache->bstrength,
|
||||
ss.cache->iteration_count);
|
||||
for (const float strength : strengths) {
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (const int i : range) {
|
||||
do_relax_face_sets_brush_task(ob, brush, iteration, nodes[i]);
|
||||
do_relax_face_sets_brush_task(ob, brush, strength, nodes[i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user