Sculpt: Avoid calculating brush normal for view automasking

View automasking does not use the brush plane normal, so it does not
need to calculate this as part of the main brush loop.

Pull Request: https://projects.blender.org/blender/blender/pulls/137642
This commit is contained in:
Sean Kim
2025-04-17 22:12:54 +02:00
committed by Sean Kim
parent b6342a7e94
commit 68bb7d674b
3 changed files with 4 additions and 6 deletions

View File

@@ -818,7 +818,7 @@ static int sculpt_brush_needs_normal(const SculptSession &ss, const Sculpt &sd,
using namespace blender::ed::sculpt_paint;
const MTex *mask_tex = BKE_brush_mask_texture_get(&brush, OB_MODE_SCULPT);
return ((bke::brush::supports_normal_weight(brush) && (ss.cache->normal_weight > 0.0f)) ||
auto_mask::needs_normal(ss, sd, &brush) ||
auto_mask::needs_normal(sd, &brush) ||
ELEM(brush.sculpt_brush_type,
SCULPT_BRUSH_TYPE_BLOB,
SCULPT_BRUSH_TYPE_CREASE,

View File

@@ -112,7 +112,7 @@ std::unique_ptr<Cache> cache_init(const Depsgraph &depsgraph,
bool mode_enabled(const Sculpt &sd, const Brush *br, eAutomasking_flag mode);
bool is_enabled(const Sculpt &sd, const Object &object, const Brush *br);
bool needs_normal(const SculptSession &ss, const Sculpt &sd, const Brush *brush);
bool needs_normal(const Sculpt &sd, const Brush *brush);
/**
* Calculate all auto-masking influence on each vertex.

View File

@@ -115,11 +115,9 @@ static int calc_effective_bits(const Sculpt &sd, const Brush *brush)
return sd.automasking_flags;
}
bool needs_normal(const SculptSession & /*ss*/, const Sculpt &sd, const Brush *brush)
bool needs_normal(const Sculpt &sd, const Brush *brush)
{
int flags = calc_effective_bits(sd, brush);
return flags & (BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL);
return calc_effective_bits(sd, brush) & BRUSH_AUTOMASKING_BRUSH_NORMAL;
}
static float normal_calc(const float3 &compare_normal,