From 2bc0e8d3049ec1b7c775717ec7aff6e9ab1c7726 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Mon, 25 Apr 2022 13:10:23 -0700 Subject: Fix T81452: Incorrect trim lasso radius Added a fallback path to compute the cursor radius for when the stroke starts over a blank area of space (in which case SCULPT_cursor_geometry_update fails). --- source/blender/editors/sculpt_paint/paint_mask.c | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 3ca686e9351..fb5e76b578f 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -1057,7 +1057,30 @@ static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext) (trim_operation->depth_back + trim_operation->depth_front) * 0.5f; } - const float depth_radius = ss->cursor_radius; + float depth_radius; + + if (ss->gesture_initial_hit) { + depth_radius = ss->cursor_radius; + } + else { + /* ss->cursor_radius is only valid if the stroke started + * over the sculpt mesh. If it's not we must + * compute the radius ourselves. See T81452. + */ + + Sculpt *sd = CTX_data_tool_settings(vc->C)->sculpt; + Brush *brush = BKE_paint_brush(&sd->paint); + Scene *scene = CTX_data_scene(vc->C); + + if (!BKE_brush_use_locked_size(scene, brush)) { + depth_radius = paint_calc_object_space_radius( + vc, ss->gesture_initial_location, BKE_brush_size_get(scene, brush)); + } + else { + depth_radius = BKE_brush_unprojected_radius_get(scene, brush); + } + } + trim_operation->depth_front = mid_point_depth - depth_radius; trim_operation->depth_back = mid_point_depth + depth_radius; } -- cgit v1.2.3