Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_stroke.c
| Show First 20 Lines • Show All 533 Lines • ▼ Show 20 Lines | #endif | ||||
| /* copy last position -before- jittering, or space fill code | /* copy last position -before- jittering, or space fill code | ||||
| * will create too many dabs */ | * will create too many dabs */ | ||||
| copy_v2_v2(stroke->last_mouse_position, mouse_in); | copy_v2_v2(stroke->last_mouse_position, mouse_in); | ||||
| stroke->last_pressure = pressure; | stroke->last_pressure = pressure; | ||||
| if (paint_stroke_use_scene_spacing(brush, mode)) { | if (paint_stroke_use_scene_spacing(brush, mode)) { | ||||
| sculpt_stroke_get_location(C, stroke->last_scene_space_position, stroke->last_mouse_position); | sculpt_stroke_get_location(C, stroke->last_scene_space_position, stroke->last_mouse_position); | ||||
| mul_m4_v3(stroke->vc.obact->obmat, stroke->last_scene_space_position); | |||||
brecht: Can we rename `scene_space_position` to `world_space_position` here and in other places?
It's… | |||||
| } | } | ||||
| if (paint_stroke_use_jitter(mode, brush, stroke->stroke_mode == BRUSH_STROKE_INVERT)) { | if (paint_stroke_use_jitter(mode, brush, stroke->stroke_mode == BRUSH_STROKE_INVERT)) { | ||||
| float delta[2]; | float delta[2]; | ||||
| float factor = stroke->zoom_2d; | float factor = stroke->zoom_2d; | ||||
| if (brush->flag & BRUSH_JITTER_PRESSURE) { | if (brush->flag & BRUSH_JITTER_PRESSURE) { | ||||
| factor *= pressure; | factor *= pressure; | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Paint *paint = BKE_paint_get_active_from_context(C); | Paint *paint = BKE_paint_get_active_from_context(C); | ||||
| ePaintMode mode = BKE_paintmode_get_active_from_context(C); | ePaintMode mode = BKE_paintmode_get_active_from_context(C); | ||||
| Brush *brush = BKE_paint_brush(paint); | Brush *brush = BKE_paint_brush(paint); | ||||
| float size_clamp = 0.0f; | float size_clamp = 0.0f; | ||||
| float size = BKE_brush_size_get(scene, stroke->brush) * size_pressure; | float size = BKE_brush_size_get(scene, stroke->brush) * size_pressure; | ||||
| if (paint_stroke_use_scene_spacing(brush, mode)) { | if (paint_stroke_use_scene_spacing(brush, mode)) { | ||||
| if (!BKE_brush_use_locked_size(scene, brush)) { | if (!BKE_brush_use_locked_size(scene, brush)) { | ||||
| size_clamp = paint_calc_object_space_radius( | float ob_last_scene_position[3]; | ||||
brechtUnsubmitted Not Done Inline ActionsRename this one to last_object_space_position. brecht: Rename this one to `last_object_space_position`. | |||||
| &stroke->vc, stroke->last_scene_space_position, size); | mul_v3_m4v3( | ||||
| ob_last_scene_position, stroke->vc.obact->imat, stroke->last_scene_space_position); | |||||
| size_clamp = paint_calc_object_space_radius(&stroke->vc, ob_last_scene_position, size); | |||||
| } | } | ||||
| else { | else { | ||||
| size_clamp = BKE_brush_unprojected_radius_get(scene, brush) * size_pressure; | size_clamp = BKE_brush_unprojected_radius_get(scene, brush) * size_pressure; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel | /* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel | ||||
| * causing very high step sizes, hanging blender [#32381] */ | * causing very high step sizes, hanging blender [#32381] */ | ||||
| size_clamp = max_ff(1.0f, size); | size_clamp = max_ff(1.0f, size); | ||||
| } | } | ||||
| float spacing = stroke->brush->spacing; | float spacing = stroke->brush->spacing; | ||||
| /* apply spacing pressure */ | /* apply spacing pressure */ | ||||
| if (stroke->brush->flag & BRUSH_SPACING_PRESSURE) { | if (stroke->brush->flag & BRUSH_SPACING_PRESSURE) { | ||||
| spacing = spacing * (1.5f - spacing_pressure); | spacing = spacing * (1.5f - spacing_pressure); | ||||
| } | } | ||||
| /* stroke system is used for 2d paint too, so we need to account for | /* stroke system is used for 2d paint too, so we need to account for | ||||
| * the fact that brush can be scaled there. */ | * the fact that brush can be scaled there. */ | ||||
| spacing *= stroke->zoom_2d; | spacing *= stroke->zoom_2d; | ||||
| if (paint_stroke_use_scene_spacing(brush, mode)) { | if (paint_stroke_use_scene_spacing(brush, mode)) { | ||||
| return size_clamp * spacing / 50.0f; | return max_ff(0.001f, size_clamp * spacing / 50.f); | ||||
| } | } | ||||
| else { | else { | ||||
| return max_ff(1.0, size_clamp * spacing / 50.0f); | return max_ff(1.0, size_clamp * spacing / 50.0f); | ||||
| } | } | ||||
| } | } | ||||
| static float paint_stroke_overlapped_curve(Brush *br, float x, float spacing) | static float paint_stroke_overlapped_curve(Brush *br, float x, float spacing) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | static int paint_space_stroke(bContext *C, | ||||
| float no_pressure_spacing = paint_space_stroke_spacing(C, scene, stroke, 1.0f, 1.0f); | float no_pressure_spacing = paint_space_stroke_spacing(C, scene, stroke, 1.0f, 1.0f); | ||||
| pressure = stroke->last_pressure; | pressure = stroke->last_pressure; | ||||
| dpressure = final_pressure - stroke->last_pressure; | dpressure = final_pressure - stroke->last_pressure; | ||||
| sub_v2_v2v2(dmouse, final_mouse, stroke->last_mouse_position); | sub_v2_v2v2(dmouse, final_mouse, stroke->last_mouse_position); | ||||
| length = normalize_v2(dmouse); | length = normalize_v2(dmouse); | ||||
| if (paint_stroke_use_scene_spacing(brush, mode)) { | if (paint_stroke_use_scene_spacing(brush, mode)) { | ||||
| bool hit = sculpt_stroke_get_location(C, scene_space_position, final_mouse); | bool hit = sculpt_stroke_get_location(C, scene_space_position, final_mouse); | ||||
| mul_m4_v3(stroke->vc.obact->obmat, scene_space_position); | |||||
| if (hit && stroke->stroke_over_mesh) { | if (hit && stroke->stroke_over_mesh) { | ||||
| sub_v3_v3v3(d_scene_space_position, scene_space_position, stroke->last_scene_space_position); | sub_v3_v3v3(d_scene_space_position, scene_space_position, stroke->last_scene_space_position); | ||||
| length = len_v3(d_scene_space_position); | length = len_v3(d_scene_space_position); | ||||
| stroke->stroke_over_mesh = true; | stroke->stroke_over_mesh = true; | ||||
| } | } | ||||
| else { | else { | ||||
| length = 0.0f; | length = 0.0f; | ||||
| stroke->stroke_over_mesh = hit; | stroke->stroke_over_mesh = hit; | ||||
| ▲ Show 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | #endif | ||||
| /* one time stroke initialization */ | /* one time stroke initialization */ | ||||
| if (!stroke->stroke_started) { | if (!stroke->stroke_started) { | ||||
| stroke->last_pressure = sample_average.pressure; | stroke->last_pressure = sample_average.pressure; | ||||
| copy_v2_v2(stroke->last_mouse_position, sample_average.mouse); | copy_v2_v2(stroke->last_mouse_position, sample_average.mouse); | ||||
| if (paint_stroke_use_scene_spacing(br, mode)) { | if (paint_stroke_use_scene_spacing(br, mode)) { | ||||
| stroke->stroke_over_mesh = sculpt_stroke_get_location( | stroke->stroke_over_mesh = sculpt_stroke_get_location( | ||||
| C, stroke->last_scene_space_position, sample_average.mouse); | C, stroke->last_scene_space_position, sample_average.mouse); | ||||
| mul_m4_v3(stroke->vc.obact->obmat, stroke->last_scene_space_position); | |||||
| } | } | ||||
| stroke->stroke_started = stroke->test_start(C, op, sample_average.mouse); | stroke->stroke_started = stroke->test_start(C, op, sample_average.mouse); | ||||
| BLI_assert((stroke->stroke_started & ~1) == 0); /* 0/1 */ | BLI_assert((stroke->stroke_started & ~1) == 0); /* 0/1 */ | ||||
| if (stroke->stroke_started) { | if (stroke->stroke_started) { | ||||
| if (br->flag & BRUSH_AIRBRUSH) { | if (br->flag & BRUSH_AIRBRUSH) { | ||||
| stroke->timer = WM_event_add_timer( | stroke->timer = WM_event_add_timer( | ||||
| CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate); | CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate); | ||||
| ▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines | |||||
Can we rename scene_space_position to world_space_position here and in other places?
It's more standard terminology and for me makes it more clear which coordinate space these are in.