Sculpt: Fix T104068, depth calculation error in trim tools

Also made the coplanar padding factor relative.
This commit is contained in:
Joseph Eagar 2023-01-28 16:04:50 -08:00
parent e497da5fda
commit 042775ad48
Notes: blender-bot 2023-02-14 11:21:43 +01:00
Referenced by issue #104068, Regression: Trim Tools: "Use Cursor for Depth" uses wrong depth when using extrude mode "Fixed" (which is default now)
Referenced by issue #104006, Regression: Sculpt Trim difference does not work with new fixed extrude setting
1 changed files with 8 additions and 3 deletions

View File

@ -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);