diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2010-01-09 20:15:02 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2010-01-09 20:15:02 +0300 |
commit | f125060ed5166ba7986283b690da949d1dca789b (patch) | |
tree | bab173bdcaa6a50147359f094753365102b5baf9 /source/blender/editors/sculpt_paint/sculpt.c | |
parent | 9ac2d072d12ecf22b9aa2d0f3fa06cb235bce512 (diff) |
== Sculpt ==
* Added a new property to sculpting, ignore_background_click. If this is on, clicks that don't hit the mesh are passed through, so you can set up the keymap to do ZBrush-like rotation with the tablet.
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 11ce41c5ff8..6671fec783e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2010,15 +2010,20 @@ static void sculpt_flush_update(bContext *C) } } -static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *event) +/* Returns whether the mouse/stylus is over the mesh (1) + or over the background (0) */ +static int over_mesh(bContext *C, struct wmOperator *op, float x, float y) { - float mouse[2] = {event->x, event->y}, location[3]; - int over_mesh; - - over_mesh = sculpt_stroke_get_location(C, op->customdata, location, mouse); + float mouse[2] = {x, y}, co[3]; + return (int)sculpt_stroke_get_location(C, op->customdata, co, mouse); +} + +static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, + wmEvent *event) +{ /* Don't start the stroke until mouse goes over the mesh */ - if(over_mesh) { + if(over_mesh(C, op, event->x, event->y)) { Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -2076,14 +2081,27 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *stroke) static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event) { + struct PaintStroke *stroke; + int ignore_background_click; + if(!sculpt_brush_stroke_init(C, op->reports)) return OPERATOR_CANCELLED; - op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, - sculpt_stroke_test_start, - sculpt_stroke_update_step, - sculpt_stroke_done); + stroke = paint_stroke_new(C, sculpt_stroke_get_location, + sculpt_stroke_test_start, + sculpt_stroke_update_step, + sculpt_stroke_done); + op->customdata = stroke; + + /* For tablet rotation */ + ignore_background_click = RNA_boolean_get(op->ptr, + "ignore_background_click"); + if(ignore_background_click && !over_mesh(C, op, event->x, event->y)) { + paint_stroke_free(stroke); + return OPERATOR_PASS_THROUGH; + } + /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -2144,6 +2162,10 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) /* The initial 2D location of the mouse */ RNA_def_float_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); + + RNA_def_boolean(ot->srna, "ignore_background_click", 0, + "Ignore Background Click", + "Clicks on the background don't start the stroke"); } /**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/ |