From 68bb7d674becf33f5364ea2579b65e0f2ef27e47 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Thu, 17 Apr 2025 22:12:54 +0200 Subject: [PATCH] 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 --- source/blender/editors/sculpt_paint/sculpt.cc | 2 +- source/blender/editors/sculpt_paint/sculpt_automask.hh | 2 +- source/blender/editors/sculpt_paint/sculpt_automasking.cc | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 9c3f44f6a71..28586620d59 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -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, diff --git a/source/blender/editors/sculpt_paint/sculpt_automask.hh b/source/blender/editors/sculpt_paint/sculpt_automask.hh index 90f1311b270..e5eea0c4d96 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automask.hh +++ b/source/blender/editors/sculpt_paint/sculpt_automask.hh @@ -112,7 +112,7 @@ std::unique_ptr 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. diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc index cd8bef722e4..608ac284697 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc @@ -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,