Fix: Clay strips brush does nothing with 'Original Plane' set

Introduced in de1c911d49

As noted in the comments of this commit, early returning in the
calculation of the Clay Strips brush prior to the plane being calculated
causes the initial value to be unset, which causes the brush to have no
effect even in the initial radius.

Pull Request: https://projects.blender.org/blender/blender/pulls/136962
This commit is contained in:
Sean Kim
2025-04-04 07:11:48 +02:00
committed by Sean Kim
parent 07e6f78ac1
commit 3d08408e73
2 changed files with 12 additions and 4 deletions

View File

@@ -256,10 +256,6 @@ void do_clay_strips_brush(const Depsgraph &depsgraph,
{
SculptSession &ss = *object.sculpt;
bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
if (math::is_zero(ss.cache->grab_delta_symm)) {
return;
}
const Brush &brush = *BKE_paint_brush_for_read(&sd.paint);
const bool flip = (ss.cache->bstrength < 0.0f);
const float radius = flip ? -ss.cache->radius : ss.cache->radius;
@@ -280,6 +276,12 @@ void do_clay_strips_brush(const Depsgraph &depsgraph,
area_normal = plane_normal;
}
/* Note: This return has to happen *after* the call to calc_brush_plane for now, as
* the method is not idempotent and sets variables inside the stroke cache. */
if (math::is_zero(ss.cache->grab_delta_symm)) {
return;
}
float4x4 mat = float4x4::identity();
mat.x_axis() = math::cross(area_normal, ss.cache->grab_delta_symm);
mat.y_axis() = math::cross(area_normal, float3(mat[0]));

View File

@@ -587,6 +587,12 @@ bool SCULPT_brush_type_needs_all_pbvh_nodes(const Brush &brush);
namespace blender::ed::sculpt_paint {
/**
* \warning This call is *not* idempotent and changes values inside the StrokeCache.
*
* Brushes may behave incorrectly if preserving original plane / normal when this
* method is not called.
*/
void calc_brush_plane(const Depsgraph &depsgraph,
const Brush &brush,
Object &ob,