diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-04-25 23:10:23 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-04-25 23:12:04 +0300 |
commit | 2bc0e8d3049ec1b7c775717ec7aff6e9ab1c7726 (patch) | |
tree | b93f99ecf2815baa671e8e18ff150961f85815ec /source/blender/editors/sculpt_paint/paint_mask.c | |
parent | 891268aa824f0fcaf54f56b3a8640a78282552d8 (diff) |
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).
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_mask.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_mask.c | 25 |
1 files changed, 24 insertions, 1 deletions
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; } |