From 042775ad482977a930528bf11eb26da5ce2810f0 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Sat, 28 Jan 2023 16:04:50 -0800 Subject: [PATCH] Sculpt: Fix T104068, depth calculation error in trim tools Also made the coplanar padding factor relative. --- source/blender/editors/sculpt_paint/paint_mask.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index c0f4ddf4218..177bc33bed5 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -1148,13 +1148,16 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex float depth_front = trim_operation->depth_front; float depth_back = trim_operation->depth_back; + float pad_factor = 0.0f; if (!trim_operation->use_cursor_depth) { + pad_factor = (depth_back - depth_front) * 0.01f + 0.001f; + /* When using cursor depth, don't modify the depth set by the cursor radius. If full depth is * used, adding a little padding to the trimming shape can help avoiding booleans with coplanar * faces. */ - depth_front -= 0.1f; - depth_back += 0.1f; + depth_front -= pad_factor; + depth_back += pad_factor; } float shape_origin[3]; @@ -1198,7 +1201,9 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex } else { copy_v3_v3(new_point, positions[i]); - madd_v3_v3fl(new_point, shape_normal, depth_back); + float dist = dist_signed_to_plane_v3(new_point, shape_plane); + + madd_v3_v3fl(new_point, shape_normal, depth_back - dist); } copy_v3_v3(positions[i + tot_screen_points], new_point);