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 | |
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')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 5 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 42 |
3 files changed, 39 insertions, 10 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 108be50267d..6bb5f432b0d 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -52,6 +52,8 @@ typedef void (*StrokeDone)(struct bContext *C, struct PaintStroke *stroke); struct PaintStroke *paint_stroke_new(struct bContext *C, StrokeGetLocation get_location, StrokeTestStart test_start, StrokeUpdateStep update_step, StrokeDone done); +void paint_stroke_free(struct PaintStroke *stroke); + int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int paint_stroke_exec(struct bContext *C, struct wmOperator *op); struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index e26b1945e7f..89c5443bf99 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -237,6 +237,11 @@ PaintStroke *paint_stroke_new(bContext *C, return stroke; } +void paint_stroke_free(PaintStroke *stroke) +{ + MEM_freeN(stroke); +} + int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) { PaintStroke *stroke = op->customdata; 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) ****/ |