Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 57b1102219e..49ddf2f82d8 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -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) {