[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25852] trunk/blender/source/blender/ editors/sculpt_paint: == Sculpt ==
Nicholas Bishop
nicholasbishop at gmail.com
Sat Jan 9 18:15:02 CET 2010
Revision: 25852
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25852
Author: nicholasbishop
Date: 2010-01-09 18:15:02 +0100 (Sat, 09 Jan 2010)
Log Message:
-----------
== 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.
Modified Paths:
--------------
trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h 2010-01-09 15:49:27 UTC (rev 25851)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h 2010-01-09 17:15:02 UTC (rev 25852)
@@ -52,6 +52,8 @@
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);
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c 2010-01-09 15:49:27 UTC (rev 25851)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c 2010-01-09 17:15:02 UTC (rev 25852)
@@ -237,6 +237,11 @@
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;
Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2010-01-09 15:49:27 UTC (rev 25851)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2010-01-09 17:15:02 UTC (rev 25852)
@@ -2010,15 +2010,20 @@
}
}
-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;
+ float mouse[2] = {x, y}, co[3];
- over_mesh = sculpt_stroke_get_location(C, op->customdata, location, mouse);
-
+ 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 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 @@
/* 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) ****/
More information about the Bf-blender-cvs
mailing list