== 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.
This commit is contained in:
Nicholas Bishop
2010-01-09 17:15:02 +00:00
parent 9ac2d072d1
commit f125060ed5
3 changed files with 39 additions and 10 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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) ****/