Fix: New sculpt brush factors broken with mask attribute

Caused by 6a5c14e58f90552b4c01 which still inverted the mask even though
it was being subtracted from the factor, effectively inverting it anyway.
Instead restore the previous logic which gathered the mask before
dealing with visibility. That's preferred because it can be replaced with
a `gather` when mask storage is inverted to be like selection, and
because the logic is a bit simpler. Also remove the clamping of the mask
since it generally shouldn't break sculpt code and because mask values
are clamped by editing tools already.
This commit is contained in:
Hans Goudey 2024-06-18 21:06:32 -04:00
parent ea90d3f409
commit b0d68627a3

@ -6539,14 +6539,24 @@ void fill_factor_from_hide_and_mask(const Mesh &mesh,
{
BLI_assert(verts.size() == r_factors.size());
fill_factor_from_hide(mesh, verts, r_factors);
/* TODO: Avoid overhead of accessing attributes for every PBVH node. */
const bke::AttributeAccessor attributes = mesh.attributes();
if (const VArray mask = *attributes.lookup<float>(".sculpt_mask", bke::AttrDomain::Point)) {
const VArraySpan span(mask);
for (const int i : verts.index_range()) {
r_factors[i] -= std::max(1.0f - span[verts[i]], 0.0f);
r_factors[i] = 1.0f - span[verts[i]];
}
}
else {
r_factors.fill(1.0f);
}
if (const VArray hide_vert = *attributes.lookup<bool>(".hide_vert", bke::AttrDomain::Point)) {
const VArraySpan span(hide_vert);
for (const int i : verts.index_range()) {
if (span[verts[i]]) {
r_factors[i] = 0.0f;
}
}
}
}