Fix T87815: Sculpt: Curve stroke scene spacing not working
This was just not implemented for curve strokes when world spacing was introduced in rB87cafe92ce2f. Now do the equivalent of what was done in said commit in 'paint_space_stroke', now in 'paint_line_strokes_spacing' as well. Maniphest Tasks: T87815 Differential Revision: https://developer.blender.org/D11098
This commit is contained in:
parent
7eb9b7976f
commit
6150dbb5bb
Notes:
blender-bot
2023-02-14 03:00:45 +01:00
Referenced by issue #87815, Sculpt Brush, Curve mode + scene related spacing do not work properly
|
@ -1184,14 +1184,43 @@ static void paint_line_strokes_spacing(bContext *C,
|
|||
const float new_pos[2])
|
||||
{
|
||||
UnifiedPaintSettings *ups = stroke->ups;
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
const bool use_scene_spacing = paint_stroke_use_scene_spacing(brush, mode);
|
||||
|
||||
float mouse[2], dmouse[2];
|
||||
float length;
|
||||
float d_world_space_position[3] = {0.0f};
|
||||
float world_space_position_old[3], world_space_position_new[3];
|
||||
|
||||
sub_v2_v2v2(dmouse, new_pos, old_pos);
|
||||
copy_v2_v2(stroke->last_mouse_position, old_pos);
|
||||
|
||||
length = normalize_v2(dmouse);
|
||||
if (use_scene_spacing) {
|
||||
bool hit_old = SCULPT_stroke_get_location(C, world_space_position_old, old_pos);
|
||||
bool hit_new = SCULPT_stroke_get_location(C, world_space_position_new, new_pos);
|
||||
mul_m4_v3(stroke->vc.obact->obmat, world_space_position_old);
|
||||
mul_m4_v3(stroke->vc.obact->obmat, world_space_position_new);
|
||||
if (hit_old && hit_new && stroke->stroke_over_mesh) {
|
||||
sub_v3_v3v3(d_world_space_position, world_space_position_new, world_space_position_old);
|
||||
length = len_v3(d_world_space_position);
|
||||
stroke->stroke_over_mesh = true;
|
||||
}
|
||||
else {
|
||||
length = 0.0f;
|
||||
zero_v3(d_world_space_position);
|
||||
stroke->stroke_over_mesh = hit_new;
|
||||
if (stroke->stroke_over_mesh) {
|
||||
copy_v3_v3(stroke->last_world_space_position, world_space_position_old);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
sub_v2_v2v2(dmouse, new_pos, old_pos);
|
||||
length = normalize_v2(dmouse);
|
||||
}
|
||||
|
||||
BLI_assert(length >= 0.0f);
|
||||
|
||||
|
@ -1205,8 +1234,18 @@ static void paint_line_strokes_spacing(bContext *C,
|
|||
*length_residue = 0.0;
|
||||
|
||||
if (length >= spacing) {
|
||||
mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing_final;
|
||||
mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing_final;
|
||||
if (use_scene_spacing) {
|
||||
float final_world_space_position[3];
|
||||
normalize_v3(d_world_space_position);
|
||||
mul_v3_v3fl(final_world_space_position, d_world_space_position, spacing_final);
|
||||
add_v3_v3v3(
|
||||
final_world_space_position, world_space_position_old, final_world_space_position);
|
||||
ED_view3d_project(region, final_world_space_position, mouse);
|
||||
}
|
||||
else {
|
||||
mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing_final;
|
||||
mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing_final;
|
||||
}
|
||||
|
||||
ups->overlap_factor = paint_stroke_integrate_overlap(stroke->brush, 1.0);
|
||||
|
||||
|
@ -1302,6 +1341,13 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str
|
|||
if (!stroke->stroke_started) {
|
||||
stroke->last_pressure = 1.0;
|
||||
copy_v2_v2(stroke->last_mouse_position, data + 2 * j);
|
||||
|
||||
if (paint_stroke_use_scene_spacing(br, BKE_paintmode_get_active_from_context(C))) {
|
||||
stroke->stroke_over_mesh = SCULPT_stroke_get_location(
|
||||
C, stroke->last_world_space_position, data + 2 * j);
|
||||
mul_m4_v3(stroke->vc.obact->obmat, stroke->last_world_space_position);
|
||||
}
|
||||
|
||||
stroke->stroke_started = stroke->test_start(C, op, stroke->last_mouse_position);
|
||||
|
||||
if (stroke->stroke_started) {
|
||||
|
|
Loading…
Reference in New Issue