Time to start reaping the benefits of code unification. Support for

pressure spacing across all paint systems (was supported only for
texture painting earlier). Also, switch paint code to use the new code
path from now on. No shift-Lclick required anymore.
This commit is contained in:
Antony Riakiotakis 2013-03-10 00:58:09 +00:00
parent 56538ea685
commit 948b92ae8c
3 changed files with 17 additions and 9 deletions

@ -808,9 +808,10 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
if brush.use_space:
col.separator()
row = col.row()
row = col.row(align=True)
row.active = brush.use_space
row.prop(brush, "spacing", text="Spacing")
row.prop(brush, "use_pressure_spacing", toggle=True, text="")
if brush.sculpt_capabilities.has_smooth_stroke:
col = layout.column()
@ -853,9 +854,10 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
col.active = brush.sculpt_capabilities.has_spacing
col.prop(brush, "use_space")
row = col.row()
row = col.row(align=True)
row.active = brush.use_space
row.prop(brush, "spacing", text="Spacing")
row.prop(brush, "use_pressure_spacing", toggle=True, text="")
class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):

@ -760,8 +760,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap = WM_keymap_find(keyconf, "Image Paint", 0, 0);
keymap->poll = image_texture_paint_poll;
WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_image_paint_proj", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
// WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_image_paint_proj", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_clone_cursor_set", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);

@ -247,17 +247,23 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
const Scene *scene = CTX_data_scene(C);
int steps;
int i;
float pressure = 1.0f;
float size_pressure = 1.0f;
float pressure = event_tablet_data(event, NULL);
/* XXX mysterious :) what has 'use size' do with this here... if you don't check for it, pressure fails */
if (BKE_brush_use_size_pressure(scene, stroke->brush))
pressure = event_tablet_data(event, NULL);
size_pressure = pressure;
if (pressure > FLT_EPSILON) {
if (size_pressure > FLT_EPSILON) {
/* 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] */
const float size_clamp = max_ff(1.0f, BKE_brush_size_get(scene, stroke->brush) * pressure);
scale = (size_clamp * stroke->brush->spacing / 50.0f) / length;
const float size_clamp = max_ff(1.0f, BKE_brush_size_get(scene, stroke->brush) * size_pressure);
float spacing = stroke->brush->spacing;
if (stroke->brush->flag & BRUSH_SPACING_PRESSURE)
spacing = max_ff(1.0f, spacing * (1.5f - pressure));
scale = (size_clamp * spacing / 50.0f) / length;
if (scale > FLT_EPSILON) {
mul_v2_fl(vec, scale);